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; }
public static function requestInfoCallback($info) { if ($info === '' || strtoupper($info) == 'CL') { // clear/blank => go back to adminlist return MiscLib::base_url . 'gui-modules/adminlist.php'; } else { if (!is_numeric($info)) { // other non-number is invalid input return false; } else { // change employee setting to desired, // print report, change back $my_emp_no = CoreLocal::get('CashierNo'); CoreLocal::set('CashierNo', $info); TenderReport::printReport(); CoreLocal::set('CashierNo', $my_emp_no); return true; } } }
/** @param $codes tender code(s) or department(s) @param $label label(s) for codes @param $listEach Boolean - True List each transaction - False List the sum of the transactions @return string A section of the report for the tender or department. */ private static function trTotal($codes, $label, $listEach = False, $reportIfNone = True) { global $CORE_LOCAL; $db_a = self::$db_a; $blank = str_repeat(' ', 13); // Names padded on right with blanks. %10s? $fieldNames = " " . substr("Time" . $blank, 0, 10) . substr("Lane" . $blank, 0, 8) . substr("Trans #" . $blank, 0, 10) . substr("Emp #" . $blank, 0, 8) . substr("Mem #" . $blank, 0, 11) . substr("Amount" . $blank, 0, 14) . "\n"; if (is_array($codes)) { $codes = "'" . implode("','", $codes) . "'"; } elseif (!is_numeric($codes)) { $codes = "'" . $codes . "'"; } $codeField = !is_numeric($codes) ? 'trans_subtype' : 'department'; if ($listEach === False) { $tenderQ = "SELECT -SUM(total) AS net, COUNT(total)" . " FROM " . self::$tTable . " d" . " WHERE register_no=" . $CORE_LOCAL->get('laneno') . " AND {$codeField} IN({$codes}) AND " . self::$tDate . " >= '" . self::$shiftCutoff . "'" . self::$excl; } else { $tenderQ = "SELECT " . self::$tDate . ",register_no,emp_no,trans_no,card_no,total" . " FROM " . self::$tTable . " d" . " WHERE register_no=" . $CORE_LOCAL->get('laneno') . " AND {$codeField} IN({$codes}) AND " . self::$tDate . " >= '" . self::$shiftCutoff . "'" . self::$excl; " ORDER BY " . self::$tDate; } $tenderR = $db_a->query($tenderQ); $tender = $db_a->fetch_array($tenderR); $numRows = $db_a->num_rows($tenderR); $ret = ''; // Reports even if 0. reportIfNone if (!$reportIfNone && $numRows == 0) { return ''; } if ($listEach === False) { $ret = " " . substr($label . $blank . $blank, 0, 20) . substr($blank . number_format($tender[0], 2), -8) . substr($blank . $tender[1], -8) . "\n"; } else { $sum = 0; $ret = ReceiptLib::centerString($label) . "\n"; $ret .= ReceiptLib::centerString(self::$dashLine) . "1\n"; $ret .= $fieldNames; for ($i = 0; $i < $numRows; $i++) { $row = $db_a->fetch_array($tenderR); $timeStamp = TenderReport::timeStamp($row["self::{$tDate}"]); $ret .= " " . substr($timeStamp . $blank, 0, 10) . substr($row["register_no"] . $blank, 0, 9) . substr($row["trans_no"] . $blank, 0, 8) . substr($blank . $row['emp_no'], -8) . substr($blank . $row["card_no"], -6) . substr($blank . number_format($row["total"], 2), -14) . "\n"; $sum += $row["total"]; } $ret .= ReceiptLib::centerString(self::$dashLine) . "2\n"; $ret .= substr($blank . $blank . $blank . "Count: " . $numRows . " Total: " . number_format($sum, 2), -55) . "\n"; $ret .= str_repeat("\n", 3); } return $ret; // trTotal() }
function trTotal($k, $label, $i = False) { $db_a = Database::mDataConnect(); $blank = " "; $fieldNames = " " . substr("Time" . $blank, 0, 10) . substr("Lane" . $blank, 0, 8) . substr("Trans #" . $blank, 0, 8) . substr("Emp #" . $blank, 0, 10) . substr("Mem #" . $blank, 0, 10) . substr("Amount" . $blank, 0, 12) . "\n"; $shiftCutoff = date('Y-m-d 00:00:00'); $lookup = $db_a->query("SELECT MAX(datetime) FROM dtransactions \n WHERE DATE(datetime) = CURDATE() AND upc='ENDOFSHIFT' AND \n register_no=" . CoreLocal::get('laneno')); if ($db_a->num_rows($lookup) > 0) { $row = $db_a->fetch_row($lookup); if ($row[0] != '') { $shiftCutoff = $row[0]; } } if (is_array($k)) { $k = "'" . implode("','", $k) . "'"; } elseif (!is_numeric($k)) { if ($k[0] == '#') { $k = substr($k, 1); $q = 'card_no'; } else { $k = "'" . $k . "'"; $q = 'trans_subtype'; } } else { $q = 'department'; } // $q = (!is_numeric($k)) ? 'trans_subtype' : 'department'; if ($i === False) { $tenderQ = "SELECT -SUM(total) AS net, COUNT(total) FROM dlog \n WHERE register_no=" . CoreLocal::get('laneno') . " AND {$q} IN({$k}) AND tdate >= '{$shiftCutoff}' AND emp_no <> 9999"; } else { $tenderQ = "SELECT tdate,register_no,emp_no,trans_no,card_no,total FROM dlog \n WHERE register_no=" . CoreLocal::get('laneno') . " and {$q} IN({$k}) AND tdate >= '{$shiftCutoff}' AND emp_no <> 9999 order by tdate"; } $tenderR = $db_a->query($tenderQ); $tender = $db_a->fetch_array($tenderR); $num_rows = $db_a->num_rows($tenderR); if ($i === False) { $ret = " " . substr($label . $blank . $blank, 0, 20) . substr($blank . number_format($tender[0], 2), -8) . substr($blank . $tender[1], -8) . "\n"; } else { $sum = 0; $ret = ReceiptLib::centerString($label) . "\n"; $ret .= ReceiptLib::centerString("------------------------------------------------------"); $ret .= $fieldNames; // for ($i = 0; $i < $num_rows; $i++) { while ($row = $db_a->fetch_array($tenderR)) { // $row = $db_a->fetch_array($tenderR); $timeStamp = TenderReport::timeStamp($row["tdate"]); $ret .= " " . substr($timeStamp . $blank, 0, 10) . substr($row["register_no"] . $blank, 0, 9) . substr($row["trans_no"] . $blank, 0, 8) . substr($blank . $row['emp_no'], -5) . substr($blank . $row["card_no"], -6) . substr($blank . number_format($row["total"], 2), -12) . "\n"; $sum += $row["total"]; } $ret .= ReceiptLib::centerString("------------------------------------------------------"); $ret .= substr($blank . $blank . $blank . "Count: " . $num_rows . " Total: " . number_format($sum, 2), -56) . "\n"; $ret .= str_repeat("\n", 3); } return $ret; }