function preprocess() { $this->display = ""; $sd = MiscLib::scaleObject(); $entered = ""; if (isset($_REQUEST["reginput"])) { $entered = strtoupper(trim($_REQUEST["reginput"])); } if (substr($entered, -2) == "CL") { $entered = "CL"; } if ($entered == "RI") { $entered = CoreLocal::get("strEntered"); } if (CoreLocal::get("msgrepeat") == 1 && $entered != "CL") { $entered = CoreLocal::get("strRemembered"); CoreLocal::set('strRemembered', ''); } CoreLocal::set("strEntered", $entered); $json = array(); if ($entered != "") { if (in_array("Paycards", CoreLocal::get("PluginList"))) { /* this breaks the model a bit, but I'm putting * putting the CC parser first manually to minimize * code that potentially handles the PAN */ if (CoreLocal::get("PaycardsCashierFacing") == "1" && substr($entered, 0, 9) == "PANCACHE:") { /* cashier-facing device behavior; run card immediately */ $entered = substr($entered, 9); CoreLocal::set("CachePanEncBlock", $entered); } $pe = new paycardEntered(); if ($pe->check($entered)) { $valid = $pe->parse($entered); $entered = "PAYCARD"; CoreLocal::set("strEntered", ""); $json = $valid; } CoreLocal::set("quantity", 0); CoreLocal::set("multiple", 0); } /* FIRST PARSE CHAIN: * Objects belong in the first parse chain if they * modify the entered string, but do not process it * This chain should be used for checking prefixes/suffixes * to set up appropriate session variables. */ $parser_lib_path = $this->page_url . "parser-class-lib/"; if (!is_array(CoreLocal::get("preparse_chain"))) { CoreLocal::set("preparse_chain", PreParser::get_preparse_chain()); } foreach (CoreLocal::get("preparse_chain") as $cn) { if (!class_exists($cn)) { continue; } $p = new $cn(); if ($p->check($entered)) { $entered = $p->parse($entered); } if (!$entered || $entered == "") { break; } } if ($entered != "" && $entered != "PAYCARD") { /* * SECOND PARSE CHAIN * these parser objects should process any input * completely. The return value of parse() determines * whether to call lastpage() [list the items on screen] */ if (!is_array(CoreLocal::get("parse_chain"))) { CoreLocal::set("parse_chain", Parser::get_parse_chain()); } $result = False; foreach (CoreLocal::get("parse_chain") as $cn) { if (!class_exists($cn)) { continue; } $p = new $cn(); if ($p->check($entered)) { $result = $p->parse($entered); break; } } if ($result && is_array($result)) { // postparse chain: modify result if (!is_array(CoreLocal::get("postparse_chain"))) { CoreLocal::set("postparse_chain", PostParser::getPostParseChain()); } foreach (CoreLocal::get('postparse_chain') as $class) { if (!class_exists($class)) { continue; } $obj = new $class(); $result = $obj->parse($result); } $json = $result; if (isset($result['udpmsg']) && $result['udpmsg'] !== False) { if (is_object($sd)) { $sd->WriteToScale($result['udpmsg']); } } } else { $arr = array('main_frame' => false, 'target' => '.baseHeight', 'output' => DisplayLib::inputUnknown()); $json = $arr; if (is_object($sd)) { $sd->WriteToScale('errorBeep'); } } } } CoreLocal::set("msgrepeat", 0); if (isset($json['main_frame']) && $json['main_frame'] != False) { $this->change_page($json['main_frame']); return False; } if (isset($json['output']) && !empty($json['output'])) { $this->display = $json['output']; } if (isset($json['retry']) && $json['retry'] != False) { $this->add_onload_command("setTimeout(\"inputRetry('" . $json['retry'] . "');\", 150);\n"); } if (isset($json['receipt']) && $json['receipt'] != False) { $ref = isset($json['trans_num']) ? $json['trans_num'] : ReceiptLib::mostRecentReceipt(); $this->add_onload_command("receiptFetch('" . $json['receipt'] . "', '" . $ref . "');\n"); } if (CoreLocal::get('CustomerDisplay') === true) { $child_url = MiscLib::baseURL() . 'gui-modules/posCustDisplay.php'; $this->add_onload_command("setCustomerURL('{$child_url}');\n"); $this->add_onload_command("reloadCustomerDisplay();\n"); } return true; }
- full => normal transaction receipt - cancelled => transaction cancelled - suspended => transaction suspended - ddd => shrink items - none => don't print a receipt, just flush localtemptrans Note: none is currently only used by the RRR parser which could probably be refactored into a plugin providing its own receipt type implementation via a ReceiptMessage */ $transFinished = false; if ($receiptType == 'full' || $receiptType == 'cancelled' || $receiptType == 'suspended' || $receiptType == 'none' || $receiptType == 'ddd') { $transFinished = true; } if (!preg_match('/^\\d+-\\d+-\\d+$/', $receiptNum)) { $receiptNum = ReceiptLib::mostRecentReceipt(); } $yesSync = JsonLib::array_to_json(array('sync' => true)); $noSync = JsonLib::array_to_json(array('sync' => false)); $output = $noSync; ob_start(); if (strlen($receiptType) > 0) { register_shutdown_function(array('ReceiptLib', 'shutdownFunction')); $receiptContent = array(); if ($transFinished) { $kicker_class = CoreLocal::get("kickerModule") == "" ? 'Kicker' : CoreLocal::get('kickerModule'); $kicker_object = new $kicker_class(); if (!is_object($kicker_object)) { $kicker_object = new Kicker(); } $dokick = $kicker_object->doKick($receiptNum);
/** Calculate Coop Cred-related subtotals for the named tender in the current transaction. @param $tender @param $programCode @param $table, default to localtemptrans for during-transaction, but localtranstoday for end of transaction. @param $ref emp-lane-trans, if needed for end of transaction @return True or error message string. */ public static function getCCredSubtotals($tender = '', $conn, $programCode = '', $table = '', $ref = '') { global $CORE_LOCAL; $pc = $programCode != '' ? $programCode : $CORE_LOCAL->get("CCredProgramCode"); //$pc = ($programCode != '') ? $programCode : $CORE_LOCAL->get("programCode"); if ($table == '') { $table = 'localtemptrans'; $refSQL = ''; } else { if ($ref == '') { $ref = ReceiptLib::mostRecentReceipt(); if ($ref === false) { return "Cannot find most recent receipt"; } } $refs = explode('-', $ref); $refSQL = ' AND emp_no =' . $refs[0] . ' AND register_no =' . $refs[1] . ' AND trans_no =' . $refs[2]; } $subsQ = "SELECT\n SUM(CASE\n WHEN trans_subtype = '{$tender}' \n THEN total\n ELSE 0 END) AS chargeTotal,\n SUM(CASE\n WHEN department=" . $CORE_LOCAL->get("{$pc}paymentDepartment") . " THEN total\n ELSE 0 END) as paymentTotal\n FROM " . $CORE_LOCAL->get("tDatabase") . ".{$table}\n WHERE trans_type <> 'L'{$refSQL}"; $subsR = $conn->query("{$subsQ}"); if ($subsR === False) { return "Error: query() failed for query: {$subsQ}"; } else { $row = $conn->fetch_array($subsR); $CORE_LOCAL->set("{$pc}chargeTotal", !$row || !isset($row['chargeTotal']) ? 0 : (double) $row["chargeTotal"]); $CORE_LOCAL->set("{$pc}paymentTotal", !$row || !isset($row['paymentTotal']) ? 0 : (double) $row["paymentTotal"]); $CORE_LOCAL->set("{$pc}memChargeTotal", $CORE_LOCAL->get("{$pc}chargeTotal") + $CORE_LOCAL->get("{$pc}paymentTotal")); } $availBal = ($CORE_LOCAL->get("{$pc}availCreditBalance") == '' ? 0 : $CORE_LOCAL->get("{$pc}availCreditBalance")) + $CORE_LOCAL->get("{$pc}memChargeTotal"); $CORE_LOCAL->set("{$pc}availBal", number_format($availBal, 2, '.', '')); $CORE_LOCAL->set("{$pc}balance", $CORE_LOCAL->get("{$pc}creditBalance") == '' ? 0 : $CORE_LOCAL->get("{$pc}creditBalance")); return True; // getCCredSubtotals() }