function tender_out($asTender) { $ret = $this->default_json(); Database::getsubtotals(); if (CoreLocal::get("amtdue") <= 0.005) { CoreLocal::set("change", -1 * CoreLocal::get("amtdue")); $cash_return = CoreLocal::get("change"); if ($asTender != "FS") { TransRecord::addchange($cash_return, 'CA'); } CoreLocal::set("End", 1); $ret['output'] = DisplayLib::printReceiptFooter(); $ret['redraw_footer'] = true; $ret['receipt'] = 'full'; TransRecord::finalizeTransaction(); } else { CoreLocal::set("change", 0); CoreLocal::set("fntlflag", 0); $ttl_result = PrehLib::ttl(); TransRecord::debugLog('Tender Out (PrehLib): ' . print_r($ttl_result, true)); TransRecord::debugLog('Tender Out (amtdue): ' . print_r(CoreLocal::get('amtdue'), true)); $ret['output'] = DisplayLib::lastpage(); } return $ret; }
function preprocess() { $me = CoreLocal::get('CashierNo'); $this->security = Authenticate::getPermission($me); if (isset($_REQUEST['selectlist'])) { if (!FormLib::validateToken()) { return false; } if (empty($_REQUEST['selectlist'])) { $this->change_page($this->page_url . "gui-modules/pos2.php"); return False; } elseif ($_REQUEST['selectlist'] == 'SUSPEND') { Database::getsubtotals(); if (CoreLocal::get("LastID") == 0) { CoreLocal::set("boxMsg", _("no transaction in progress")); CoreLocal::set('boxMsgButtons', array('Dismiss [clear]' => '$(\'#reginput\').val(\'CL\');submitWrapper();')); $this->change_page($this->page_url . "gui-modules/boxMsg2.php"); return False; } else { // ajax call to end transaction // and print receipt $ref = SuspendLib::suspendorder(); $this->add_onload_command("\$.ajax({\n type:'post',\n url:'{$this->page_url}ajax-callbacks/ajax-end.php',\n cache: false,\n data: 'receiptType=suspended&ref={$ref}',\n dataType: 'json',\n success: function(data){\n \$.ajax({\n type:'post',\n url:'{$this->page_url}ajax-callbacks/ajax-transaction-sync.php',\n cache: false,\n success: function(data){\n location='{$this->page_url}gui-modules/pos2.php';\n },\n error: function(e1){\n location='{$this->page_url}gui-modules/pos2.php';\n }\n });\n },\n error: function(e1){\n location='{$this->page_url}gui-modules/pos2.php';\n }\n });"); return True; } } else { if ($_REQUEST['selectlist'] == 'RESUME') { Database::getsubtotals(); if (CoreLocal::get("LastID") != 0) { CoreLocal::set("boxMsg", _("transaction in progress")); CoreLocal::set('boxMsgButtons', array('Dismiss [clear]' => '$(\'#reginput\').val(\'CL\');submitWrapper();')); $this->change_page($this->page_url . "gui-modules/boxMsg2.php"); } elseif (SuspendLib::checksuspended() == 0) { CoreLocal::set("boxMsg", _("no suspended transaction")); CoreLocal::set('boxMsgButtons', array('Dismiss [clear]' => '$(\'#reginput\').val(\'CL\');submitWrapper();')); CoreLocal::set("strRemembered", ""); $this->change_page($this->page_url . "gui-modules/boxMsg2.php"); } else { $this->change_page($this->page_url . "gui-modules/suspendedlist.php"); } return False; } else { if ($_REQUEST['selectlist'] == 'TR') { TenderReport::printReport(); $this->change_page($this->page_url . "gui-modules/pos2.php"); return False; } else { if ($_REQUEST['selectlist'] == 'OTR' && $this->security >= 30) { $this->change_page($this->page_url . 'gui-modules/requestInfo.php?class=AnyTenderReportRequest'); return False; } elseif ($_REQUEST['selectlist'] == 'UNDO' && $this->security >= 30) { $this->change_page($this->page_url . 'gui-modules/undo.php'); return false; } } } } } return True; }
function parse($str) { $json = $this->default_json(); $arg = $this->left; CoreLocal::set("sc", 1); $staffID = substr($arg, 0, 4); $pQuery = "select staffID,chargecode,blueLine from chargecodeview where chargecode = '" . $arg . "'"; $pConn = Database::pDataConnect(); $result = $pConn->query($pQuery); $num_rows = $pConn->num_rows($result); $row = $pConn->fetch_array($result); if ($num_rows == 0) { $json['output'] = DisplayLib::xboxMsg(_("unable to authenticate staff ") . $staffID, DisplayLib::standardClearButton()); CoreLocal::set("isStaff", 0); // apbw 03/05/05 SCR return $json; } else { CoreLocal::set("isStaff", 1); // apbw 03/05/05 SCR CoreLocal::set("memMsg", $row["blueLine"]); $tQuery = "update localtemptrans set card_no = '" . $staffID . "', percentDiscount = 15"; $tConn = Database::tDataConnect(); $this->addscDiscount(); TransRecord::discountnotify(15); $tConn->query($tQuery); Database::getsubtotals(); $chk = self::ttl(); if ($chk !== True) { $json['main_frame'] = $chk; return $json; } CoreLocal::set("runningTotal", CoreLocal::get("amtdue")); return self::tender("MI", CoreLocal::get("runningTotal") * 100); } }
function body_content() { $this->input_header(); echo DisplayLib::printheaderb(); ?> <div class="baseHeight"> <div class="<?php echo $this->color; ?> centeredDisplay"> <img alt="key" src='<?php echo $this->img; ?> ' /> <p> <?php echo $this->msg; ?> </p> </div> </div> <?php Database::getsubtotals(); echo "<div id=\"footer\">"; echo DisplayLib::printfooter(); echo "</div>"; }
/** Populates session with default values. Short-hand for calling every other function in this file. Normally called once on startup. */ public static function initiate_session() { self::systemInit(); self::memberReset(); self::transReset(); self::printReset(); PaycardLib::paycard_reset(); Database::getsubtotals(); Database::loadglobalvalues(); self::loadData(); self::customReceipt(); self::loadParams(); }
function parse($str) { Database::getsubtotals(); $amt = CoreLocal::get('runningTotal') - CoreLocal::get('transDiscount'); $madCoup = number_format($amt * 0.05, 2); if ($madCoup > 2.5) { $madCoup = 2.5; } TransRecord::addRecord(array('upc' => "MAD Coupon", 'description' => "Member Appreciation Coupon", 'trans_type' => "I", 'trans_subtype' => "CP", 'trans_status' => "C", 'quantity' => 1, 'ItemQtty' => 1, 'unitPrice' => -1 * $madCoup, 'total' => -1 * $madCoup, 'regPrice' => -1 * $madCoup, 'voided' => 17)); $ret = $this->default_json(); $ret['output'] = DisplayLib::lastpage(); $ret['redraw_footer'] = true; return $ret; }
function parse($str) { $json = $this->default_json(); CoreLocal::set("memberID", CoreLocal::get('defaultNonMem')); CoreLocal::set("memMsg", "End of Shift"); TransRecord::addRecord(array('upc' => 'ENDOFSHIFT', 'description' => 'End of Shift', 'trans_type' => 'S')); Database::getsubtotals(); $chk = self::ttl(); if ($chk !== true) { $json['main_frame'] = $chk; return $json; } CoreLocal::set("runningtotal", CoreLocal::get("amtdue")); return PrehLib::tender("CA", CoreLocal::get("runningtotal") * 100); }
function parse($str) { $dept = CoreLocal::get('roundUpDept'); if ($dept === '') { $dept = 701; } $ret = $this->default_json(); if ($str == "RU") { Database::getsubtotals(); $ttl = CoreLocal::get("amtdue"); $next = ceil($ttl); $amt = sprintf('%.2f', $ttl == $next ? 1.0 : $next - $ttl); $ret = PrehLib::deptkey($amt * 100, $dept . '0', $ret); } else { $amt = substr($str, 0, strlen($str) - 2); $ret = PrehLib::deptkey($amt, $dept . '0', $ret); } return $ret; }
/** Apply action @return [boolean] true if the action completes successfully (or is not necessary at all) or [string] url to redirect to another page for further decisions/input. */ public function apply() { // Is the before-tax total within range? if (CoreLocal::get("runningTotal") <= 4.0) { $totalBefore = CoreLocal::get("amtdue"); $ret = Database::changeLttTaxCode("HST", "GST"); if ($ret !== true) { TransRecord::addcomment("{$ret}"); } else { Database::getsubtotals(); $saved = $totalBefore - CoreLocal::get("amtdue"); $comment = sprintf("OMTR OK. You saved: \$%.2f", $saved); TransRecord::addcomment("{$comment}"); } } else { TransRecord::addcomment("Does NOT qualify for OMTR"); } return true; }
function parse($str) { $ret = $this->default_json(); $qty = 1; if ($str != "RRR") { $split = explode("*", $str); if (!is_numeric($split[0])) { return true; } $qty = $split[0]; } $no_trans = CoreLocal::get('LastID') == 0 ? true : false; $this->add($qty); $ret['output'] = DisplayLib::lastpage(); $ret['udpmsg'] = 'goodBeep'; Database::getsubtotals(); if ($no_trans && CoreLocal::get("runningTotal") == 0) { TransRecord::finalizeTransaction(true); } return $ret; }
public function body_content() { $this->input_header(); echo DisplayLib::printheaderb(); echo '<div class="baseHeight">'; echo '<div class=" ' . $this->box_color . ' centeredDisplay">'; echo '<span class="larger">'; echo $this->upc . ' - ' . $this->getItem() . '<br />'; echo 'Item is not eligible'; echo '</span><br />'; echo '<p>'; echo 'Type manager password to override.<br />'; echo '[clear] to go back'; echo '</p>'; echo '</div>'; echo '</div>'; Database::getsubtotals(); echo "<div id=\"footer\">"; echo DisplayLib::printfooter(); echo "</div>"; $this->add_onload_command("\$('<input type=\"hidden\" name=\"upc\">').val(" . $this->upc . ").appendTo('#formlocal');\n"); }
/** Add foodstamp elgibile total record */ public static function fsEligible() { Database::getsubtotals(); if (CoreLocal::get("fsEligible") < 0 && False) { CoreLocal::set("boxMsg", "Foodstamp eligible amount inapplicable<P>Please void out earlier tender and apply foodstamp first"); CoreLocal::set('boxMsgButtons', array('Dismiss [clear]' => '$(\'#reginput\').val(\'CL\');submitWrapper();')); return MiscLib::baseURL() . "gui-modules/boxMsg2.php"; } else { CoreLocal::set("fntlflag", 1); Database::setglobalvalue("FntlFlag", 1); if (CoreLocal::get("ttlflag") != 1) { return self::ttl(); } else { TransRecord::addRecord(array('description' => 'Foodstamps Eligible', 'trans_type' => '0', 'trans_status' => 'D', 'unitPrice' => MiscLib::truncate2(CoreLocal::get('fsEligible')), 'voided' => 7)); } return true; } }
public function parse($str) { $ret = $this->default_json(); $plugin_info = new Paycards(); $ret['main_frame'] = $plugin_info->pluginUrl() . '/gui/PaycardEmvPage.php'; Database::getsubtotals(); switch ($str) { case 'DATACAP': $ret['main_frame'] = $plugin_info->pluginUrl() . '/gui/PaycardEmvMenu.php'; break; case 'DATACAPEMV': CoreLocal::set('paycard_amount', CoreLocal::get('amtdue')); CoreLocal::set('CacheCardType', 'EMV'); CoreLocal::set('paycard_mode', PaycardLib::PAYCARD_MODE_AUTH); CoreLocal::set('paycard_type', PaycardLib::PAYCARD_TYPE_CREDIT); break; case 'DATACAPCC': CoreLocal::set('paycard_amount', CoreLocal::get('amtdue')); CoreLocal::set('CacheCardType', 'CREDIT'); CoreLocal::set('paycard_mode', PaycardLib::PAYCARD_MODE_AUTH); CoreLocal::set('paycard_type', PaycardLib::PAYCARD_TYPE_CREDIT); break; case 'DATACAPDC': CoreLocal::set('paycard_amount', CoreLocal::get('amtdue')); if (CoreLocal::get('CacheCardCashBack')) { CoreLocal::set('paycard_amount', CoreLocal::get('amtdue') + CoreLocal::get('CacheCardCashBack')); } CoreLocal::set('CacheCardType', 'DEBIT'); CoreLocal::set('paycard_mode', PaycardLib::PAYCARD_MODE_AUTH); CoreLocal::set('paycard_type', PaycardLib::PAYCARD_TYPE_CREDIT); break; case 'DATACAPEF': if (CoreLocal::get('fntlflag') == 0) { /* try to automatically do fs total */ $try = PrehLib::fsEligible(); if ($try !== true) { $ret['output'] = PaycardLib::paycard_msgBox($type, "Type Mismatch", "Foodstamp eligible amount inapplicable", "[clear] to cancel"); $ret['main_frame'] = false; return $ret; } } CoreLocal::set('paycard_amount', CoreLocal::get('fsEligible')); CoreLocal::set('CacheCardType', 'EBTFOOD'); CoreLocal::set('paycard_mode', PaycardLib::PAYCARD_MODE_AUTH); CoreLocal::set('paycard_type', PaycardLib::PAYCARD_TYPE_CREDIT); break; case 'DATACAPEC': CoreLocal::set('paycard_amount', CoreLocal::get('amtdue')); if (CoreLocal::get('CacheCardCashBack')) { CoreLocal::set('paycard_amount', CoreLocal::get('amtdue') + CoreLocal::get('CacheCardCashBack')); } CoreLocal::set('CacheCardType', 'EBTCASH'); CoreLocal::set('paycard_mode', PaycardLib::PAYCARD_MODE_AUTH); CoreLocal::set('paycard_type', PaycardLib::PAYCARD_TYPE_CREDIT); break; case 'DATACAPGD': CoreLocal::set('paycard_amount', CoreLocal::get('amtdue')); CoreLocal::set('CacheCardType', 'GIFT'); CoreLocal::set('paycard_mode', PaycardLib::PAYCARD_MODE_AUTH); CoreLocal::set('paycard_type', PaycardLib::PAYCARD_TYPE_GIFT); break; case 'PVDATACAPGD': CoreLocal::set('CacheCardType', 'GIFT'); CoreLocal::set('paycard_mode', PaycardLib::PAYCARD_MODE_BALANCE); CoreLocal::set('paycard_type', PaycardLib::PAYCARD_TYPE_GIFT); $ret['main_frame'] = $plugin_info->pluginUrl() . '/gui/PaycardEmvBalance.php'; break; case 'PVDATACAPEF': CoreLocal::set('CacheCardType', 'EBTFOOD'); CoreLocal::set('paycard_mode', PaycardLib::PAYCARD_MODE_BALANCE); CoreLocal::set('paycard_type', PaycardLib::PAYCARD_TYPE_CREDIT); $ret['main_frame'] = $plugin_info->pluginUrl() . '/gui/PaycardEmvBalance.php'; break; case 'PVDATACAPEC': CoreLocal::set('CacheCardType', 'EBTCASH'); CoreLocal::set('paycard_mode', PaycardLib::PAYCARD_MODE_BALANCE); CoreLocal::set('paycard_type', PaycardLib::PAYCARD_TYPE_CREDIT); $ret['main_frame'] = $plugin_info->pluginUrl() . '/gui/PaycardEmvBalance.php'; break; case 'ACDATACAPGD': CoreLocal::set('CacheCardType', 'GIFT'); CoreLocal::set('paycard_mode', PaycardLib::PAYCARD_MODE_ACTIVATE); CoreLocal::set('paycard_type', PaycardLib::PAYCARD_TYPE_GIFT); $ret['main_frame'] = $plugin_info->pluginUrl() . '/gui/PaycardEmvGift.php?mode=' . CoreLocal::get('paycard_mode'); break; case 'AVDATACAPGD': CoreLocal::set('CacheCardType', 'GITFT'); CoreLocal::set('paycard_mode', PaycardLib::PAYCARD_MODE_ADDVALUE); CoreLocal::set('paycard_type', PaycardLib::PAYCARD_TYPE_GIFT); $ret['main_frame'] = $plugin_info->pluginUrl() . '/gui/PaycardEmvGift.php?mode=' . CoreLocal::get('paycard_mode'); break; } CoreLocal::set('paycard_id', CoreLocal::get('LastID') + 1); return $ret; }
function preprocess() { $this->bmp_path = $this->page_url . 'scale-drivers/drivers/NewMagellan/ss-output/tmp/'; $terminal_msg = 'termSig'; if (isset($_REQUEST['amt']) && isset($_REQUEST['type'])) { $terminal_msg .= $_REQUEST['type'] . sprintf(': $%.2f', $_REQUEST['amt']); } else { if (isset($_REQUEST['amt'])) { $terminal_msg .= sprintf('Amount: $.%2f', $_REQUEST['amt']); } } if (isset($_REQUEST['reginput'])) { if (strtoupper($_REQUEST['reginput']) == 'CL') { if (isset($_REQUEST['bmpfile']) && file_exists($_REQUEST['bmpfile'])) { unlink($_REQUEST['bmpfile']); } $this->change_page($this->page_url . 'gui-modules/pos2.php'); UdpComm::udpSend('termReset'); return false; } else { if ($_REQUEST['reginput'] == '') { if (isset($_REQUEST['bmpfile']) && file_exists($_REQUEST['bmpfile'])) { // this should have been set already, but if we have sufficient info // we can make sure it's correct. if (isset($_REQUEST['amt']) && !empty($_REQUEST['amt']) && isset($_REQUEST['code']) && !empty($_REQUEST['code'])) { CoreLocal::set('strRemembered', 100 * $_REQUEST['amt'] . $_REQUEST['code']); } CoreLocal::set('msgrepeat', 1); $bmp = file_get_contents($_REQUEST['bmpfile']); $format = 'BMP'; $img_content = $bmp; /** Idea: convert image to PNG if GD functions are available. It would reduce storage size but also make printing the image more complicated since it would need to be converted *back* to a bitmap. Undecided whether to use this. Maybe reformatting happens server-side for long term storage. Update: does not work with GD. That extension does not understand bitmaps. Same idea may work with a different library like ImageMagick. if (function_exists('imagecreatefromstring')) { $image = imagecreatefromstring($bmp); if ($image !== false) { ob_start(); $success = imagepng($image); $png_content = ob_get_clean(); if ($success) { $format = 'PNG'; $img_content = $png_content; } } } */ $dbc = Database::tDataConnect(); $capQ = 'INSERT INTO CapturedSignature (tdate, emp_no, register_no, trans_no, trans_id, filetype, filecontents) VALUES (?, ?, ?, ?, ?, ?, ?)'; $capP = $dbc->prepare_statement($capQ); Database::getsubtotals(); $args = array(date('Y-m-d H:i:s'), CoreLocal::get('CashierNo'), CoreLocal::get('laneno'), CoreLocal::get('transno'), CoreLocal::get('LastID') + 1, $format, $img_content); $capR = $dbc->exec_statement($capP, $args); unlink($_REQUEST['bmpfile']); $this->change_page($this->page_url . 'gui-modules/pos2.php'); return false; } else { UdpComm::udpSend($terminal_msg); } } } } else { UdpComm::udpSend($terminal_msg); } return true; }
public function body_content() { $this->input_header(); echo DisplayLib::printheaderb(); echo '<div class="baseHeight">'; echo '<div class=" ' . $this->box_color . ' centeredDisplay">'; echo $this->stepContent(); echo '</div>'; echo '</div>'; Database::getsubtotals(); echo "<div id=\"footer\">"; echo DisplayLib::printfooter(); echo "</div>"; $this->add_onload_command("\$('<input type=\"hidden\" name=\"step\">').val(" . $this->step . ").appendTo('#formlocal');\n"); }
private function doResume($reg, $emp, $trans) { $query_del = "DELETE FROM suspended WHERE register_no = " . $reg . " AND emp_no = " . $emp . " AND trans_no = " . $trans; $db_a = Database::tDataConnect(); $success = false; // use SQLManager's transfer method when not in stand alone mode // to eliminate the cross server query - andy 8/31/07 if (CoreLocal::get("standalone") == 0) { $db_a->add_connection(CoreLocal::get("mServer"), CoreLocal::get("mDBMS"), CoreLocal::get("mDatabase"), CoreLocal::get("mUser"), CoreLocal::get("mPass")); $cols = Database::getMatchingColumns($db_a, "localtemptrans", "suspended"); // localtemptrans might not actually be empty; let trans_id // populate via autoincrement rather than copying it from // the suspended table if (substr($cols, -9) == ',trans_id') { $cols = substr($cols, 0, strlen($cols) - 9); } $remoteQ = "SELECT {$cols} \n FROM suspended \n WHERE \n register_no = {$reg} \n AND emp_no = {$emp}\n AND trans_no = {$trans}\n AND datetime >= " . date("'Y-m-d 00:00:00'") . "\n ORDER BY trans_id"; $success = $db_a->transfer(CoreLocal::get("mDatabase"), $remoteQ, CoreLocal::get("tDatabase"), "insert into localtemptrans ({$cols})"); if ($success) { $db_a->query($query_del, CoreLocal::get("mDatabase")); } $db_a->close(CoreLocal::get("mDatabase"), true); } else { // localtemptrans might not actually be empty; let trans_id // populate via autoincrement rather than copying it from // the suspended table $def = $db_a->table_definition('localtemptrans'); $cols = ''; foreach ($def as $name => $info) { if ($name == 'trans_id') { continue; } $cols .= $name . ','; } $cols = substr($cols, 0, strlen($cols) - 1); $localQ = "SELECT {$cols} \n FROM suspended \n WHERE \n register_no = {$reg} \n AND emp_no = {$emp}\n AND trans_no = {$trans}\n AND datetime >= " . date("'Y-m-d 00:00:00'") . "\n ORDER BY trans_id"; $success = $db_a->query("insert into localtemptrans ({$cols}) " . $localQ); if ($success) { $db_a->query($query_del); } } $query_update = "update localtemptrans set register_no = " . CoreLocal::get("laneno") . ", emp_no = " . CoreLocal::get("CashierNo") . ", trans_no = " . CoreLocal::get("transno"); $db_a->query($query_update); /** Add a log record after succesfully resuming a suspended transaction. Log record added after resume so records preceeding the log record were part of the original transaction and records following the log record were part of the resumed transaction */ if ($success) { TransRecord::addLogRecord(array('upc' => 'RESUME', 'description' => $emp . '-' . $reg . '-' . $trans, 'charflag' => 'SR')); } Database::getsubtotals(); }
/** Get the currently displayed items @param $readOnly don't update session @return An HTML string This will always display the most recently scanned items. If you want a specific subset, use listitems(). */ public static function lastpage($readOnly = False) { $lines = CoreLocal::get('screenLines'); if (!$lines === '' || !is_numeric($lines)) { $lines = 11; } if (!$readOnly) { Database::getsubtotals(); } $last_id = CoreLocal::get("LastID"); if ($last_id - $lines < 0) { $top_id = 1; } else { $top_id = $last_id - $lines; } if (!$readOnly) { CoreLocal::set("currentid", $last_id); CoreLocal::set("currenttopid", $top_id); } return self::drawItems($top_id, $lines, $last_id); }
/** Get information about how much the coupon is worth @param $id [int] coupon ID @return array with keys: value => [float] coupon value department => [int] department number for the coupon description => [string] description for coupon */ public function getValue($id) { $infoW = $this->lookupCoupon($id); if ($infoW === false) { return array('value' => 0, 'department' => 0, 'description' => ''); } $transDB = Database::tDataConnect(); /* if we got this far, the coupon * should be valid */ $value = 0; $coupID = $id; $description = isset($infoW['description']) ? $infoW['description'] : ''; switch ($infoW["discountType"]) { case "Q": // quantity discount // discount = coupon's discountValue // times the cheapeast coupon item $valQ = "select unitPrice, department \n " . $this->baseSQL($transDB, $coupID, 'upc') . "\n and h.type in ('BOTH', 'DISCOUNT')\n and l.total > 0\n order by unitPrice asc "; $valR = $transDB->query($valQ); $valW = $transDB->fetch_row($valR); $value = $valW[0] * $infoW["discountValue"]; break; case "P": // discount price // query to get the item's department and current value // current value minus the discount price is how much to // take off $value = $infoW["discountValue"]; $deptQ = "select department, (total/quantity) as value \n " . $this->baseSQL($transDB, $coupID, 'upc') . "\n and h.type in ('BOTH', 'DISCOUNT')\n and l.total > 0\n order by unitPrice asc "; $deptR = $transDB->query($deptQ); $row = $transDB->fetch_row($deptR); $value = $row[1] - $value; break; case "FD": // flat discount for departments // simply take off the requested amount // scales with quantity for by-weight items $value = $infoW["discountValue"]; $valQ = "select department, quantity \n " . $this->baseSQL($transDB, $coupID, 'department') . "\n and h.type in ('BOTH', 'DISCOUNT')\n and l.total > 0\n order by unitPrice asc "; $valR = $transDB->query($valQ); $row = $transDB->fetch_row($valR); $value = $row[1] * $value; break; case "MD": // mix discount for departments // take off item value or discount value // whichever is less $value = $infoW["discountValue"]; $valQ = "select department, l.total \n " . $this->baseSQL($transDB, $coupID, 'department') . "\n and h.type in ('BOTH', 'DISCOUNT')\n and l.total > 0\n order by l.total desc "; $valR = $transDB->query($valQ); $row = $transDB->fetch_row($valR); $value = $row[1] < $value ? $row[1] : $value; break; case "AD": // all department discount // apply discount across all items // scales with quantity for by-weight items $value = $infoW["discountValue"]; $valQ = "select sum(quantity) \n " . $this->baseSQL($transDB, $coupID, 'department') . "\n and h.type in ('BOTH', 'DISCOUNT')\n and l.total > 0\n order by unitPrice asc "; $valR = $transDB->query($valQ); $row = $transDB->fetch_row($valR); $value = $row[1] * $value; break; case "FI": // flat discount for items // simply take off the requested amount // scales with quantity for by-weight items $value = $infoW["discountValue"]; $valQ = "select l.upc, quantity \n " . $this->baseSQL($transDB, $coupID, 'upc') . "\n and h.type in ('BOTH', 'DISCOUNT')\n and l.total > 0\n order by unitPrice asc"; $valR = $transDB->query($valQ); $row = $transDB->fetch_row($valR); $value = $row[1] * $value; break; case 'PI': // per-item discount // take of the request amount times the // number of matching items. $value = $infoW["discountValue"]; $valQ = "\n SELECT \n SUM(CASE WHEN ItemQtty IS NULL THEN 0 ELSE ItemQtty END) AS qty\n " . $this->baseSQL($transDB, $coupID, 'upc'); $valR = $transDB->query($valQ); $row = $transDB->fetch_row($valR); $value = $row['qty'] * $value; break; case "F": // completely flat; no scaling for weight $value = $infoW["discountValue"]; break; case "%": // percent discount on all items Database::getsubtotals(); $value = $infoW["discountValue"] * CoreLocal::get("discountableTotal"); break; case "%B": // better percent discount applies Database::getsubtotals(); $coupon_discount = (int) ($infoW['discountValue'] * 100); if ($coupon_discount <= CoreLocal::get('percentDiscount')) { // customer's discount is better than coupon discount; skip // applying coupon $value = 0; } else { // coupon discount is better than customer's discount // apply coupon & zero out customer's discount $value = $infoW["discountValue"] * CoreLocal::get("discountableTotal"); CoreLocal::set('percentDiscount', 0); $transDB->query('UPDATE localtemptrans SET percentDiscount=0'); } break; case "%D": // percent discount on all items in give department(s) $valQ = "select sum(total) \n " . $this->baseSQL($transDB, $coupID, 'department') . "\n and h.type in ('BOTH', 'DISCOUNT')"; $valR = $transDB->query($valQ); $row = $transDB->fetch_row($valR); $value = $row[0] * $infoW["discountValue"]; break; case "%E": // better percent discount applies to specified department only Database::getsubtotals(); $coupon_discount = (int) ($infoW['discountValue'] * 100); if ($coupon_discount <= CoreLocal::get('percentDiscount')) { // customer's discount is better than coupon discount; skip // applying coupon $value = 0; } else { // coupon discount is better than customer's discount // apply coupon & exclude those items from customer's discount $valQ = "select sum(total) \n " . $this->baseSQL($transDB, $coupID, 'department') . "\n and h.type in ('BOTH', 'DISCOUNT')"; $valR = $transDB->query($valQ); $row = $transDB->fetch_row($valR); $value = $row[0] * $infoW["discountValue"]; $clearQ = "\n UPDATE localtemptrans AS l \n INNER JOIN " . CoreLocal::get('pDatabase') . $transDB->sep() . "houseCouponItems AS h ON l.department = h.upc\n SET l.discountable=0\n WHERE h.coupID = " . $coupID . "\n AND h.type IN ('BOTH', 'DISCOUNT')"; $clearR = $transDB->query($clearR); } break; case 'PD': // modify customer percent discount // rather than add line-item $couponPD = $infoW['discountValue'] * 100; DiscountModule::updateDiscount(new DiscountModule($couponPD, 'HouseCoupon')); // still need to add a line-item with the coupon UPC to the // transaction to track usage $value = 0; $description = $couponPD . ' % Discount Coupon'; break; case 'OD': // override customer percent discount // rather than add line-item $couponPD = $infoW['discountValue'] * 100; DiscountModule::updateDiscount(new DiscountModule(0, 'custdata')); DiscountModule::updateDiscount(new DiscountModule($couponPD, 'HouseCoupon')); // still need to add a line-item with the coupon UPC to the // transaction to track usage $value = 0; $description = $couponPD . ' % Discount Coupon'; break; } return array('value' => $value, 'department' => $infoW['department'], 'description' => $description); }
/** Add tax exemption for foodstamps */ public static function addfsTaxExempt() { Database::getsubtotals(); self::addRecord(array('upc' => 'FS Tax Exempt', 'description' => ' Fs Tax Exempt ', 'trans_type' => 'C', 'trans_status' => 'D', 'unitPrice' => CoreLocal::get('fsTaxExempt'), 'voided' => 17)); }
function body_content() { $this->input_header("onsubmit=\"return submitWrapper();\" action=\"" . $_SERVER['PHP_SELF'] . "\""); ?> <div class="baseHeight"> <?php // Signature Capture support // If: // a) enabled // b) a Credit transaction // c) Over limit threshold OR a return $isCredit = CoreLocal::get('CacheCardType') == 'CREDIT' || CoreLocal::get('CacheCardType') == '' ? true : false; // gift doesn't set CacheCardType so customer swipes and // cashier types don't overwrite each other's type if (CoreLocal::get('paycard_type') == PaycardLib::PAYCARD_TYPE_GIFT) { $isCredit = false; } $needSig = CoreLocal::get('paycard_amount') > CoreLocal::get('CCSigLimit') || CoreLocal::get('paycard_amount') < 0 ? true : false; $isVoid = CoreLocal::get('paycard_mode') == PaycardLib::PAYCARD_MODE_VOID ? true : false; if (CoreLocal::get("PaycardsSigCapture") == 1 && $isCredit && $needSig && !$isVoid) { echo "<div id=\"boxMsg\" class=\"centeredDisplay\">"; echo "<div class=\"boxMsgAlert coloredArea\">"; echo "Waiting for signature"; echo "</div>"; echo "<div class=\"\">"; echo "<div id=\"imgArea\"></div>"; echo '<div class="textArea">'; echo '$' . sprintf('%.2f', CoreLocal::get('paycard_amount')) . ' as CREDIT'; echo '<br />'; echo '<span id="sigInstructions" style="font-size:90%;">'; echo '[enter] to get re-request signature, [void] ' . _('to reverse the charge'); echo '<br />'; if (isset($_REQUEST['reginput']) && ($_REQUEST['reginput'] == '' || $_REQUEST['reginput'] == 'CL')) { echo '<b>'; } echo '[reprint] to quit & use paper slip'; if (isset($_REQUEST['reginput']) && ($_REQUEST['reginput'] == '' || $_REQUEST['reginput'] == 'CL')) { echo '</b>'; } echo '</span>'; echo "</div>"; echo "</div>"; // empty class echo "</div>"; // #boxMsg UdpComm::udpSend('termSig'); $this->add_onload_command("addToForm('doCapture', '1');\n"); } else { echo DisplayLib::boxMsg(CoreLocal::get("boxMsg"), "", true); UdpComm::udpSend('termApproved'); } CoreLocal::set("CachePanEncBlock", ""); CoreLocal::set("CachePinEncBlock", ""); ?> </div> <?php echo "<div id=\"footer\">"; Database::getsubtotals(); // in case of partial approval shows remainder due echo DisplayLib::printfooter(); echo "</div>"; $rp_type = ''; if (isset($_REQUEST['receipt']) && strlen($_REQUEST['receipt']) > 0) { $rp_type = $_REQUEST['receipt']; $this->add_onload_command("\$('#reginput').val('RP');\n"); $this->add_onload_command("submitWrapper();\n"); } elseif (CoreLocal::get("paycard_type") == PaycardLib::PAYCARD_TYPE_GIFT) { if (CoreLocal::get("paycard_mode") == PaycardLib::PAYCARD_MODE_BALANCE) { $rp_type = "gcBalSlip"; } else { $rp_type = "gcSlip"; } } elseif (CoreLocal::get("paycard_type") == PaycardLib::PAYCARD_TYPE_CREDIT) { $rp_type = "ccSlip"; } elseif (CoreLocal::get("paycard_type") == PaycardLib::PAYCARD_TYPE_ENCRYPTED) { $rp_type = "ccSlip"; } printf("<input type=\"hidden\" id=\"rp_type\" value=\"%s\" />", $rp_type); }
function uploadAndReset($type) { if (CoreLocal::get("testremote") == 0) { Database::testremote(); } if (CoreLocal::get("TaxExempt") != 0) { CoreLocal::set("TaxExempt", 0); Database::setglobalvalue("TaxExempt", 0); } CoreState::memberReset(); CoreState::transReset(); CoreState::printReset(); Database::getsubtotals(); return 1; }
public function parse($str) { $ret = $this->default_json(); if (is_numeric(CoreLocal::get('VoidLimit')) && CoreLocal::get('VoidLimit') > 0) { Database::getsubtotals(); if (CoreLocal::get('voidTotal') > CoreLocal::get('VoidLimit') && CoreLocal::get('voidOverride') != 1) { CoreLocal::set('strRemembered', CoreLocal::get('strEntered')); CoreLocal::set('voidOverride', 0); $ret['main_frame'] = MiscLib::base_url() . 'gui-modules/adminlogin.php?class=Void'; return $ret; } } if (strlen($str) > 2) { $ret = $this->voidupc(substr($str, 2), $ret); } elseif (CoreLocal::get("currentid") == 0) { $ret['output'] = DisplayLib::boxMsg(_("No Item on Order"), '', false, DisplayLib::standardClearButton()); } else { $id = CoreLocal::get("currentid"); $status = PrehLib::checkstatus($id); $this->discounttype = $status['discounttype']; $this->discountable = $status['discountable']; $this->caseprice = $status['caseprice']; $this->scaleprice = $status['scaleprice']; /** Voided values: 2 => "you saved" line 3 => subtotal line 4 => discount notice 5 => % Discount line 6 => tare weight, case disc notice, 8 => FS change, regular change 10 => tax exempt */ if ($status['voided'] == 2) { // void preceeding item $ret = $this->voiditem($id - 1, $ret); } else { if ($status['voided'] == 3 || $status['voided'] == 6 || $status['voided'] == 8) { $ret['output'] = DisplayLib::boxMsg(_("Cannot void this entry"), '', false, DisplayLib::standardClearButton()); } else { if ($status['voided'] == 4 || $status['voided'] == 5) { PrehLib::percentDiscount(0); } else { if ($status['voided'] == 10) { TransRecord::reverseTaxExempt(); } else { if ($status['status'] == "V") { $ret['output'] = DisplayLib::boxMsg(_("Item already voided"), '', false, DisplayLib::standardClearButton()); } else { $ret = $this->voiditem($id, $ret); } } } } } } if (empty($ret['output']) && empty($ret['main_frame'])) { $ret['output'] = DisplayLib::lastpage(); $ret['redraw_footer'] = true; $ret['udpmsg'] = 'goodBeep'; } elseif (empty($ret['main_frame'])) { $ret['udpmsg'] = 'errorBeep'; } return $ret; }