function __construct() { if (CoreLocal::get('fntlflag') == 0 && CoreLocal::get('End') != 1) { CoreLocal::set("fntlflag", 1); Database::setglobalvalue("FntlFlag", 1); } }
function preprocess() { $this->my_drawer = ReceiptLib::currentDrawer(); $this->available = ReceiptLib::availableDrawers(); $this->is_admin = false; $db = Database::pDataConnect(); $sec = Authenticate::getPermission(CoreLocal::get('CashierNo')); if ($sec >= 30) { $this->is_admin = true; } if (isset($_REQUEST['selectlist'])) { if (empty($_REQUEST['selectlist'])) { if (empty($this->available) && !$this->is_admin && $this->my_drawer == 0) { // no drawer available and not admin // sign out and go back to main login screen Database::setglobalvalue("LoggedIn", 0); CoreLocal::set("LoggedIn", 0); CoreLocal::set("training", 0); CoreLocal::set("gui-scale", "no"); $this->change_page($this->page_url . "gui-modules/login2.php"); } else { $this->change_page($this->page_url . "gui-modules/pos2.php"); } return False; } if (substr($_REQUEST['selectlist'], 0, 2) == 'TO' && $this->is_admin) { // take over a drawer $new_drawer = substr($_REQUEST['selectlist'], 2); if ($this->my_drawer != 0) { // free up the current drawer if it exists ReceiptLib::drawerKick(); ReceiptLib::freeDrawer($this->my_drawer); } // switch to the requested drawer ReceiptLib::assignDrawer(CoreLocal::get('CashierNo'), $new_drawer); ReceiptLib::drawerKick(); $this->my_drawer = $new_drawer; } elseif (substr($_REQUEST['selectlist'], 0, 2) == 'SW') { // switch to available drawer $new_drawer = substr($_REQUEST['selectlist'], 2); foreach ($this->available as $id) { // verify the requested drawer is available if ($new_drawer == $id) { if ($this->my_drawer != 0) { // free up the current drawer if it exists ReceiptLib::drawerKick(); ReceiptLib::freeDrawer($this->my_drawer); } // switch to the requested drawer ReceiptLib::assignDrawer(CoreLocal::get('CashierNo'), $new_drawer); ReceiptLib::drawerKick(); $this->my_drawer = $new_drawer; break; } } } } return True; }
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; }
/** 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; } }
/** Finish the current transaction @param $incomplete [boolean] optional, default false This method: 1) Adds tax and discount lines if transaction is complete (i.e., $incomplete == false) 2) Rotates data out of localtemptrans 3) Advances trans_no variable to next available value This method replaces older ajax-end.php / end.php operations where the receipt was printed first and then steps 1-3 above happened. This method should be called BEFORE printing a receipt. Receipts are now always printed via localtranstoday. */ public static function finalizeTransaction($incomplete = false) { if (!$incomplete) { self::addtransDiscount(); self::addTax(); $taxes = Database::LineItemTaxes(); foreach ($taxes as $tax) { if (CoreLocal::get('TaxExempt') == 1) { $tax['amount'] = 0.0; } self::addLogRecord(array('upc' => 'TAXLINEITEM', 'description' => $tax['description'], 'numflag' => $tax['rate_id'], 'amount2' => $tax['amount'])); } DiscountModule::lineItems(); } if (Database::rotateTempData()) { // rotate data Database::clearTempTables(); } // advance trans_no value Database::loadglobalvalues(); $nextTransNo = Database::gettransno(CoreLocal::get('CashierNo')); CoreLocal::set('transno', $nextTransNo); Database::setglobalvalue('TransNo', $nextTransNo); }
public function cleanup($json) { switch (CoreLocal::get("paycard_mode")) { case PaycardLib::PAYCARD_MODE_ADDVALUE: case PaycardLib::PAYCARD_MODE_ACTIVATE: CoreLocal::set("autoReprint", 1); $ttl = CoreLocal::get("paycard_amount"); PrehLib::deptkey($ttl * 100, 9020); $bal = CoreLocal::get('GiftBalance'); CoreLocal::set("boxMsg", "<b>Success</b><font size=-1>\n <p>New card balance: \$" . $bal . "\n <p>[enter] to continue\n <br>\"rp\" to reprint slip</font>"); break; case PaycardLib::PAYCARD_MODE_BALANCE: $bal = CoreLocal::get('DatacapBalanceCheck'); CoreLocal::set("boxMsg", "<b>Success</b><font size=-1>\n <p>Card balance: \$" . $bal . "\n <p>\"rp\" to print\n <br>[enter] to continue</font>"); break; case PaycardLib::PAYCARD_MODE_AUTH: // cast to string. tender function expects string input // numeric input screws up parsing on negative values > $0.99 $amt = "" . -1 * CoreLocal::get("paycard_amount"); $type = CoreLocal::get("CacheCardType"); $t_type = 'CC'; if (CoreLocal::get('paycard_issuer') == 'American Express') { $t_type = 'AX'; } if ($type == 'EBTFOOD') { // extra tax exemption steps TransRecord::addfsTaxExempt(); CoreLocal::set("fntlflag", 0); Database::setglobalvalue("FntlFlag", 0); } list($tender_code, $tender_description) = PaycardLib::getTenderInfo($type, CoreLocal::get('paycard_issuer')); // if the transaction has a non-zero paycardTransactionID, // include it in the tender line $record_id = $this->last_paycard_transaction_id; $charflag = $record_id != 0 ? 'PT' : ''; TransRecord::addFlaggedTender($tender_description, $tender_code, $amt, $record_id, $charflag); $appr_type = 'Approved'; if (CoreLocal::get('paycard_partial')) { $appr_type = 'Partial Approval'; } elseif (CoreLocal::get('paycard_amount') == 0) { $appr_type = 'Declined'; $json['receipt'] = 'ccDecline'; } CoreLocal::set('paycard_partial', false); $isCredit = CoreLocal::get('CacheCardType') == 'CREDIT' || CoreLocal::get('CacheCardType') == '' ? true : false; $needSig = CoreLocal::get('paycard_amount') > CoreLocal::get('CCSigLimit') || CoreLocal::get('paycard_amount') < 0 ? true : false; if (($isCredit || CoreLocal::get('EmvSignature') === true) && $needSig) { CoreLocal::set("boxMsg", "<b>{$appr_type}</b>\n <font size=-1>\n <p>Please verify cardholder signature\n <p>[enter] to continue\n <br>\"rp\" to reprint slip\n <br>[void] " . _('to reverse the charge') . "\n </font>"); if (CoreLocal::get('PaycardsSigCapture') != 1) { $json['receipt'] = 'ccSlip'; } } else { CoreLocal::set("boxMsg", "<b>{$appr_type}</b>\n <font size=-1>\n <p>No signature required\n <p>[enter] to continue\n <br>[void] " . _('to reverse the charge') . "\n </font>"); } break; case PaycardLib::PAYCARD_MODE_VOID: $void = new Void(); $void->voidid(CoreLocal::get("paycard_id"), array()); // advanced ID to the void line CoreLocal::set('paycard_id', CoreLocal::get('paycard_id') + 1); CoreLocal::set("boxMsg", "<b>Voided</b>\n <p><font size=-1>[enter] to continue\n <br>\"rp\" to reprint slip</font>"); break; } return $json; }
public function testAuthenticate() { CoreLocal::set('scaleDriver', ''); // don't interact w/ scale Database::setglobalvalue('LoggedIn', 1); Database::setglobalvalue('CashierNo', 1); $fail = Authenticate::checkPassword('9999'); $this->assertEquals(False, $fail); Database::setglobalvalue('CashierNo', 9999); $pass = Authenticate::checkPassword('9999'); $this->assertEquals(True, $pass); Database::setglobalvalue('LoggedIn', 0); Database::setglobalvalue('CashierNo', 1); $pass = Authenticate::checkPassword('9999'); $this->assertEquals(True, $pass); Database::setglobalvalue('LoggedIn', 0); Database::setglobalvalue('CashierNo', 1); $pass = Authenticate::checkPassword('56'); $this->assertEquals(True, $pass); Database::setglobalvalue('LoggedIn', 0); Database::setglobalvalue('CashierNo', 1); $fail = Authenticate::checkPassword('invalid password'); $this->assertEquals(false, $fail); $this->assertEquals(false, Authenticate::checkPermission('56', 50)); $this->assertEquals(false, Authenticate::checkPermission('56', 21)); $this->assertEquals(true, Authenticate::checkPermission('56', 20)); $this->assertEquals(true, Authenticate::checkPermission('56', 10)); $this->assertEquals(false, Authenticate::getEmployeeByPassword('asdf')); $this->assertInternalType('array', Authenticate::getEmployeeByPassword('56')); $this->assertEquals(false, Authenticate::getEmployeeByNumber(75)); $this->assertInternalType('array', Authenticate::getEmployeeByNumber(56)); $this->assertEquals(0, Authenticate::getPermission(55)); $this->assertEquals(20, Authenticate::getPermission(56)); }
function check($str) { $my_url = MiscLib::base_url(); $this->dest_input_page = ""; $this->dest_main_page = ""; $this->dest_scale = False; $this->ret = $this->default_json(); // Argument to PV, either before or after. if (substr($str, -2, 2) == "PV") { $pvsearch = substr($str, 0, -2); $str = "PV"; } elseif (substr($str, 0, 2) == "PV") { $pvsearch = substr($str, 2); $str = "PV"; } // common error message $repeat = CoreLocal::get('msgrepeat'); $in_progress_msg = DisplayLib::boxMsg(_("transaction in progress"), '', true, DisplayLib::standardClearButton()); CoreLocal::set('msgrepeat', $repeat); switch ($str) { case 'CAB': if (CoreLocal::get("LastID") != "0") { $this->ret['output'] = $in_progress_msg; } else { $this->ret['main_frame'] = $my_url . "gui-modules/cablist.php"; } return true; case "PV": CoreLocal::set("pvsearch", "{$pvsearch}"); $this->ret['main_frame'] = $my_url . "gui-modules/productlist.php"; return true; case "MSTG": if (CoreLocal::get('memType') == 1 || CoreLocal::get('memType') == 2) { // could this be CoreLocal::get('isMember') == 1 // to avoid relying on specific memTypes? $this->ret['output'] = DisplayLib::boxMsg(_("Cannot UNset a member status"), '', true, DisplayLib::standardClearButton()); } elseif (CoreLocal::get("SecuritySR") > 20) { $this->ret['main_frame'] = $my_url . "gui-modules/adminlogin.php?class=MemStatusAdminLogin"; } else { $this->ret['output'] = DisplayLib::boxMsg(_("You must be an admin to do this."), _('Access Denied'), true, DisplayLib::standardClearButton()); } return true; case "UNDO": if (CoreLocal::get("LastID") != "0") { $this->ret['output'] = $in_progress_msg; } else { $this->ret['main_frame'] = $my_url . "gui-modules/adminlogin.php?class=UndoAdminLogin"; } return true; case 'SK': case "DDD": $this->ret['main_frame'] = $my_url . "gui-modules/DDDReason.php"; return true; case 'MG': if (CoreLocal::get("SecuritySR") > 20) { $this->ret['main_frame'] = $my_url . "gui-modules/adminlogin.php?class=SusResAdminLogin"; } else { $this->ret['main_frame'] = $my_url . "gui-modules/adminlist.php"; } return true; case 'RP': if (CoreLocal::get("LastID") != "0") { $tr = CoreLocal::get("receiptToggle"); if ($tr == 1) { CoreLocal::set("receiptToggle", 0); } else { CoreLocal::set("receiptToggle", 1); } $this->ret['main_frame'] = $my_url . "gui-modules/pos2.php"; } else { $db = Database::tDataConnect(); $query = "select register_no, emp_no, trans_no, " . "sum((case when trans_type = 'T' then -1 * total else 0 end)) as total " . "from localtranstoday where register_no = " . CoreLocal::get("laneno") . " and emp_no = " . CoreLocal::get("CashierNo") . " AND datetime >= " . $db->curdate() . " group by register_no, emp_no, trans_no order by 1000 - trans_no"; $result = $db->query($query); $num_rows = $db->num_rows($result); if ($num_rows == 0) { $this->ret['output'] = DisplayLib::boxMsg(_("no receipt found"), '', true, DisplayLib::standardClearButton()); } else { $this->ret['main_frame'] = $my_url . "gui-modules/rplist.php"; } } return true; case 'ID': $this->ret['main_frame'] = $my_url . "gui-modules/memlist.php"; return true; case 'DDM': $this->ret['main_frame'] = $my_url . 'gui-modules/drawerPage.php'; return true; case 'SS': case 'SO': // sign off and suspend shift are identical except for // drawer behavior if (CoreLocal::get("LastID") != 0) { $this->ret['output'] = $in_progress_msg; } else { TransRecord::addLogRecord(array('upc' => 'SIGNOUT', 'description' => 'Sign Out Emp#' . CoreLocal::get('CashierNo'))); Database::setglobalvalue("LoggedIn", 0); CoreLocal::set("LoggedIn", 0); CoreLocal::set("training", 0); CoreLocal::set("gui-scale", "no"); /** An empty transaction may still contain invisible, logging records. Rotate those out of localtemptrans to ensure sequential trans_id values */ if (Database::rotateTempData()) { Database::clearTempTables(); } if ($str == 'SO') { if (session_id() != '') { session_write_close(); } $kicker_class = CoreLocal::get("kickerModule") == "" ? 'Kicker' : CoreLocal::get('kickerModule'); $kicker_object = new $kicker_class(); if ($kicker_object->kickOnSignOut()) { ReceiptLib::drawerKick(); } ReceiptLib::freeDrawer(ReceiptLib::currentDrawer()); } $this->ret['main_frame'] = $my_url . "login.php"; } return true; case 'NS': if (CoreLocal::get("LastID") != 0) { $this->ret['output'] = $in_progress_msg; } else { $this->ret['main_frame'] = $my_url . "gui-modules/nslogin.php"; } return true; case 'GD': CoreLocal::set("msgrepeat", 0); $this->ret['main_frame'] = $my_url . "gui-modules/giftcardlist.php"; return true; case 'IC': CoreLocal::set("msgrepeat", 0); $this->ret['main_frame'] = $my_url . "gui-modules/HouseCouponList.php"; return true; case "CN": $this->ret['main_frame'] = $my_url . "gui-modules/mgrlogin.php"; return true; case "PO": $this->ret['main_frame'] = $my_url . "gui-modules/adminlogin.php?class=PriceOverrideAdminLogin"; return true; } return false; }