public function message($val, $ref, $reprint = false) { $date = ReceiptLib::build_time(time()); list($emp, $reg, $trans) = explode('-', $ref); $slip = ''; // query database for receipt info $db = Database::tDataConnect(); if ($reprint) { $db = Database::mDataConnect(); } $query = "SELECT q.amount, q.name, q.PAN, q.refNum,\n CASE \n WHEN q.mode = 'EBTFOOD_Sale' THEN 'Ebt FS Sale'\n WHEN q.mode = 'EBTFOOD_Return' THEN 'Ebt FS Refund'\n WHEN q.mode = 'EBTCASH_Sale' THEN 'Ebt Cash Sale'\n WHEN q.mode = 'EBTCASH_Return' THEN 'Ebt Cash Refund'\n ELSE q.mode\n END as ebtMode,\n r.xResultMessage, r.xTransactionID\n FROM efsnetRequest AS q\n LEFT JOIN efsnetResponse AS r ON\n q.date = r.date AND\n q.laneNo = r.laneNo AND\n q.transNo = r.transNo AND\n q.transID = r.transID AND\n q.cashierNo = r.cashierNo\n WHERE r.xResultMessage LIKE '%Approve%'\n AND q.mode LIKE 'EBT%'\n AND r.validResponse=1\n AND q.date=" . date('Ymd') . "\n AND q.transNo=" . (int) $trans . "\n ORDER BY q.refNum, q.datetime"; if ($db->table_exists('PaycardTransactions')) { $trans_type = $db->concat('p.cardType', "' '", 'p.transType', ''); $query = "SELECT p.amount,\n p.name,\n p.PAN,\n p.refNum,\n {$trans_type} AS ebtMode,\n p.xResultMessage,\n p.xTransactionID,\n p.xBalance,\n p.requestDatetime AS datetime\n FROM PaycardTransactions AS p\n WHERE dateID=" . date('Ymd') . "\n AND empNo=" . $emp . "\n AND registerNo=" . $reg . "\n AND transNo=" . $trans . "\n AND p.validResponse=1\n AND p.xResultMessage LIKE '%APPROVE%'\n AND p.cardType LIKE 'EBT%'\n ORDER BY p.requestDatetime"; } $result = $db->query($query); $prevRefNum = false; while ($row = $db->fetch_row($result)) { // failover to mercury's backup server can // result in duplicate refnums. this is // by design (theirs, not CORE's) if ($row['refNum'] == $prevRefNum) { continue; } $slip .= ReceiptLib::centerString("................................................") . "\n"; // store header for ($i = 1; $i <= CoreLocal::get('chargeSlipCount'); $i++) { $slip .= ReceiptLib::centerString(CoreLocal::get("chargeSlip" . $i)) . "\n"; } $slip .= "\n"; $col1 = array(); $col2 = array(); $col1[] = $row['ebtMode']; $col2[] = "Entry Method: swiped\n"; $col1[] = "Sequence: " . $row['xTransactionID']; $col2[] = "Card: " . $row['PAN']; $col1[] = "Authorization: " . $row['xResultMessage']; $col2[] = ReceiptLib::boldFont() . "Amount: " . $row['amount'] . ReceiptLib::normalFont(); $balance = 'unknown'; $ebt_type = substr(strtoupper($row['ebtMode']), 0, 5); if ($ebt_type == 'EBT F' || $ebt_type == 'EBTFO') { if (is_numeric(CoreLocal::get('EbtFsBalance'))) { $balance = sprintf('%.2f', CoreLocal::get('EbtFsBalance')); } } else { if ($ebt_type == 'EBT C' || $ebt_type == 'EBTCA') { if (is_numeric(CoreLocal::get('EbtCaBalance'))) { $balance = sprintf('%.2f', CoreLocal::get('EbtCaBalance')); } } } $col1[] = "New Balance: " . $balance; $col2[] = ''; $slip .= ReceiptLib::twoColumns($col1, $col2); $slip .= ReceiptLib::centerString("................................................") . "\n"; $prevRefNum = $row['refNum']; } return $slip; }
/** Print a tender report This tender report is based on a single tender tape view rather than multiple views (e.g. ckTenders, ckTenderTotal, etc). Which tenders to include is defined via checkboxes by the tenders on the install page's "extras" tab. */ public static function get() { $DESIRED_TENDERS = CoreLocal::get("TRDesiredTenders"); $db_a = Database::mDataConnect(); $blank = " "; $fieldNames = " " . substr("Time" . $blank, 0, 13) . substr("Lane" . $blank, 0, 9) . substr("Trans #" . $blank, 0, 12) . substr("Change" . $blank, 0, 14) . substr("Amount" . $blank, 0, 14) . "\n"; $ref = ReceiptLib::centerString(trim(CoreLocal::get("CashierNo")) . " " . trim(CoreLocal::get("cashier")) . " " . ReceiptLib::build_time(time())) . "\n\n"; $receipt = ""; foreach (array_keys($DESIRED_TENDERS) as $tender_code) { $query = "select tdate from TenderTapeGeneric where emp_no=" . CoreLocal::get("CashierNo") . " and tender_code = '" . $tender_code . "' order by tdate"; $result = $db_a->query($query); $num_rows = $db_a->num_rows($result); if ($num_rows <= 0) { continue; } //$receipt .= chr(27).chr(33).chr(5); $titleStr = ""; $itemize = 1; for ($i = 0; $i < strlen($DESIRED_TENDERS[$tender_code]); $i++) { $titleStr .= $DESIRED_TENDERS[$tender_code][$i] . " "; } $titleStr = substr($titleStr, 0, strlen($titleStr) - 1); $receipt .= ReceiptLib::centerString($titleStr) . "\n"; $receipt .= $ref; if ($itemize == 1) { $receipt .= ReceiptLib::centerString("------------------------------------------------------"); } $query = "select tdate,register_no,trans_no,tender\n from TenderTapeGeneric where emp_no=" . CoreLocal::get("CashierNo") . " and tender_code = '" . $tender_code . "' order by tdate"; $result = $db_a->query($query); $num_rows = $db_a->num_rows($result); if ($itemize == 1) { $receipt .= $fieldNames; } $sum = 0; for ($i = 0; $i < $num_rows; $i++) { if ((CoreLocal::get("store") == "harvest-cb" || CoreLocal::get("store") == "harvest-jp") && ($tender_code == "PE" || $tender_code == "BU" || $tender_code == "EL" || $tender_code == "PY" || $tender_code == "TV")) { $itemize = 1; } else { $itemize = 0; } $row = $db_a->fetch_array($result); $timeStamp = self::timeStamp($row["tdate"]); if ($itemize == 1) { $receipt .= " " . substr($timeStamp . $blank, 0, 13) . substr($row["register_no"] . $blank, 0, 9) . substr($row["trans_no"] . $blank, 0, 8) . substr($blank . number_format("0", 2), -10) . substr($blank . number_format($row["tender"], 2), -14) . "\n"; } $sum += $row["tender"]; } $receipt .= ReceiptLib::centerString("------------------------------------------------------"); $receipt .= substr($blank . $blank . $blank . "Count: " . $num_rows . " Total: " . number_format($sum, 2), -56) . "\n"; $receipt .= str_repeat("\n", 4); // $receipt .= chr(27).chr(105); } return $receipt . chr(27) . chr(105); }
protected function varied_message($ref, $reprint = false, $sigSlip = false) { if (CoreLocal::get('autoReprint') == 1) { $sigSlip = true; } $date = ReceiptLib::build_time(time()); list($emp, $reg, $trans) = explode('-', $ref); $slip = ''; // query database for gc receipt info $db = Database::tDataConnect(); if ($reprint) { $db = Database::mDataConnect(); } $order = $sigSlip ? 'DESC' : 'ASC'; $trans_type = $db->concat('p.cardType', "' '", 'p.transType', ''); $sql = "SELECT {$trans_type} AS tranType,\n CASE WHEN p.transType = 'Return' THEN -1*p.amount ELSE p.amount END as amount,\n p.registerNo as terminalID,\n p.PAN,\n CASE WHEN p.manual=1 THEN 'Manual' ELSE 'Swiped' END as entryMethod,\n CASE WHEN transType='VOID' THEN '' ELSE p.xApprovalNumber END AS xAuthorizationCode,\n p.xBalance,\n CASE WHEN transType='VOID' THEN p.xApprovalNumber ELSE '' END AS xVoidCode,\n p.transID,\n p.requestDatetime AS datetime\n FROM PaycardTransactions AS p\n WHERE dateID=" . date('Ymd') . "\n AND empNo=" . $emp . "\n AND registerNo=" . $reg . "\n AND transNo=" . $trans . "\n AND p.validResponse=1\n AND p.xResultMessage LIKE '%Appro%'\n AND p.cardType = 'Gift'\n ORDER BY p.requestDatetime " . $order; $result = $db->query($sql); $num = $db->num_rows($result); while ($row = $db->fetch_row($result)) { $slip .= ReceiptLib::centerString("................................................") . "\n"; // store header for ($i = 1; $i <= CoreLocal::get('chargeSlipCount'); $i++) { $slip .= ReceiptLib::centerString(CoreLocal::get("chargeSlip" . $i)) . "\n"; } $slip .= "\n"; $col1 = array(); $col2 = array(); $col1[] = $row['tranType']; $col2[] = "Date: " . date('m/d/y h:i a', strtotime($row['datetime'])); $col1[] = "Terminal ID: " . $row['terminalID']; $col2[] = "Reference: " . $ref . "-" . $row['transID']; $col1[] = "Card: " . $row['PAN']; $col2[] = "Entry Method: " . $row['entryMethod']; if ((int) $row['xVoidCode'] > 0) { $col1[] = "Void Auth: " . $row['xVoidCode']; $col2[] = "Orig Auth: " . $row['xAuthorizationCode']; } else { $col1[] = "Authorization: " . $row['xAuthorizationCode']; $col2[] = ""; } $col1[] = ReceiptLib::boldFont() . "Amount: " . PaycardLib::paycard_moneyFormat($row['amount']) . ReceiptLib::normalFont(); // bold ttls apbw 11/3/07 $col2[] = "New Balance: " . PaycardLib::paycard_moneyFormat($row['xBalance']); $slip .= ReceiptLib::twoColumns($col1, $col2); // name/phone on activation only if (($row['tranType'] == 'Gift Card Activation' || $row['tranType'] == 'Gift Card Issue') && $sigSlip) { $slip .= "\n" . ReceiptLib::centerString("Name: ___________________________________") . "\n" . "\n" . ReceiptLib::centerString("Phone: ___________________________________") . "\n"; } $slip .= ReceiptLib::centerString("................................................") . "\n"; } return $slip; }
/** Print message as its own receipt @param $ref a transaction reference (emp-lane-trans) @param $reprint boolean @return [string] message to print */ public function standalone_receipt($ref, $reprint = false) { $date = ReceiptLib::build_time(time()); list($emp, $reg, $trans) = explode('-', $ref); $sort = 'asc'; $db = Database::tDataConnect(); $emvP = $db->prepare(' SELECT content FROM EmvReceipt WHERE dateID=? AND empNo=? AND registerNo=? AND transNo=? AND transID=? ORDER BY tdate DESC '); $emvR = $db->execute($emvP, array(date('Ymd'), $emp, $reg, $trans, CoreLocal::get('paycard_id'))); $slip = ''; while ($emvW = $db->fetchRow($emvR)) { $slip .= ReceiptLib::centerString("................................................") . "\n"; $lines = explode("\n", $emvW['content']); for ($i = 0; $i < count($lines); $i++) { if (isset($lines[$i + 1]) && strlen($lines[$i]) + strlen($lines[$i + 1]) < 56) { // don't columnize the amount lines if (strstr($lines[$i], 'AMOUNT') || strstr($lines[$i + 1], 'AMOUNT')) { $slip .= ReceiptLib::centerString($lines[$i]) . "\n"; } elseif (strstr($lines[$i], 'TOTAL') || strstr($lines[$i + 1], 'TOTAL')) { $slip .= ReceiptLib::centerString($lines[$i]) . "\n"; } else { $spacer = 56 - strlen($lines[$i]) - strlen($lines[$i + 1]); $slip .= $lines[$i] . str_repeat(' ', $spacer) . $lines[$i + 1] . "\n"; $i++; } } else { if (strstr($lines[$i], 'x___')) { if ($sigSlip) { $slip .= "\n\n\n"; } else { $i++; continue; } } $slip .= ReceiptLib::centerString($lines[$i]) . "\n"; } } $slip .= "\n" . ReceiptLib::centerString(_('(Customer Copy)')) . "\n"; break; } return $slip; }
/** Print a tender report This tender report is based on a single tender tape view rather than multiple views (e.g. ckTenders, ckTenderTotal, etc) adding a new tender is mostly just a matter of adding it to the $DESIRED_TENDERS array (exception being if you want special handling in the tender tape view (e.g., three tender types are actually compined under EBT) */ public static function get() { $DESIRED_TENDERS = CoreLocal::get("TRDesiredTenders"); // $DESIRED_TENDERS = array( // "CK"=>"CHECK TENDERS", // "GD"=>"GIFT CARD TENDERS", // "TC"=>"GIFT CERT TENDERS", // "MI"=>"STORE CHARGE TENDERS", // "EF"=>"EBT CARD TENDERS", // "CP"=>"COUPONS TENDERED", // "IC"=>"INSTORE COUPONS TENDERED", // "AR"=>"AR PAYMENTS", // "EQ"=>"EQUITY SALES" // ); $DESIRED_TENDERS += array("CP" => "COUPONS TENDERED", "FS" => "EBT CARD TENDERS", "CK" => "CHECK TENDERS", "AR" => "ACCOUNTANT ONLY", "EQ" => "EQUITY"); $db_a = Database::mDataConnect(); $blank = " "; $fieldNames = " " . substr("Time" . $blank, 0, 13) . substr("Lane" . $blank, 0, 9) . substr("Trans #" . $blank, 0, 12) . substr("Change" . $blank, 0, 14) . substr("Amount" . $blank, 0, 14) . "\n"; $ref = ReceiptLib::centerString(trim(CoreLocal::get("CashierNo")) . " " . trim(CoreLocal::get("cashier")) . " " . ReceiptLib::build_time(time())) . "\n\n"; $receipt = ""; $itemize = 0; foreach ($DESIRED_TENDERS as $tender_code => $header) { $query = "select tdate,register_no,trans_no,-total AS tender\n from dlog where emp_no=" . CoreLocal::get("CashierNo") . " and trans_type='T' AND trans_subtype='" . $tender_code . "'\n AND total <> 0 ORDER BY tdate"; switch ($tender_code) { case 'FS': $query = "select tdate,register_no,trans_no,-total AS tender\n from dlog where emp_no=" . CoreLocal::get("CashierNo") . " and trans_type='T' AND trans_subtype IN ('EF','EC','EB','EK')\n AND total <> 0 ORDER BY tdate"; break; case 'CK': $query = "select tdate,register_no,trans_no,-total AS tender\n from dlog where emp_no=" . CoreLocal::get("CashierNo") . " and trans_type='T' AND trans_subtype IN ('PE','BU','EL','PY','TV')\n AND total <> 0 ORDER BY tdate"; break; case 'MC': $query = "select tdate,register_no,trans_no,-total AS tender\n from dlog where emp_no=" . CoreLocal::get("CashierNo") . " and trans_type='T' AND trans_subtype IN ('CP','MC') AND\n upc NOT LIKE '%MAD%' AND total <> 0 ORDER BY tdate"; break; case 'AR': $query = "select tdate,register_no,trans_no,total AS tender\n from dlog where emp_no=" . CoreLocal::get("CashierNo") . " and trans_type='D' AND total <> 0 AND department = 98\n ORDER BY tdate"; break; case 'EQ': $query = "select tdate,register_no,trans_no,total AS tender\n from dlog where emp_no=" . CoreLocal::get("CashierNo") . " and trans_type='D' AND department IN (70,71)\n AND total <> 0 ORDER BY tdate"; break; } $result = $db_a->query($query); $num_rows = $db_a->num_rows($result); if ($num_rows <= 0) { continue; } //$receipt .= chr(27).chr(33).chr(5); $titleStr = ""; for ($i = 0; $i < strlen($header); $i++) { $titleStr .= $header[$i] . " "; } $titleStr = substr($titleStr, 0, strlen($titleStr) - 1); $receipt .= ReceiptLib::centerString($titleStr) . "\n"; $receipt .= $ref; if ($itemize == 1) { $receipt .= ReceiptLib::centerString("------------------------------------------------------"); } // $itemize = 1; if ($itemize == 1) { $receipt .= $fieldNames; } $sum = 0; for ($i = 0; $i < $num_rows; $i++) { $row = $db_a->fetch_array($result); $timeStamp = self::timeStamp($row["tdate"]); if ($itemize == 1) { $receipt .= " " . substr($timeStamp . $blank, 0, 13) . substr($row["register_no"] . $blank, 0, 9) . substr($row["trans_no"] . $blank, 0, 8) . substr($blank . number_format("0", 2), -10) . substr($blank . number_format($row["tender"], 2), -14) . "\n"; } $sum += $row["tender"]; } $receipt .= ReceiptLib::centerString("------------------------------------------------------"); $receipt .= substr($blank . $blank . $blank . "Count: " . $num_rows . " Total: " . number_format($sum, 2), -56) . "\n"; $receipt .= str_repeat("\n", 4); // $receipt .= chr(27).chr(105); } return $receipt . chr(27) . chr(105); }
/** The same data can be rendered two different ways. One's a signature slip, the other is just a list of date, amount, approval code, etc */ protected function variable_slip($ref, $reprint = False, $sigSlip = False) { $date = ReceiptLib::build_time(time()); list($emp, $reg, $trans) = explode('-', $ref); $sort = 'asc'; $slip = ''; $idclause = ''; $db = Database::tDataConnect(); if ($reprint) { $db = Database::mDataConnect(); } if ($sigSlip && is_numeric(CoreLocal::get('paycard_id'))) { $idclause = ' AND transID=' . CoreLocal::get('paycard_id'); } // query database for cc receipt info $query = "select tranType, amount, PAN, entryMethod, issuer, xResultMessage, xApprovalNumber, xTransactionID, name, " . " datetime, transID from ccReceiptView where date=" . date('Ymd', time()) . " and cashierNo = " . $emp . " and laneNo = " . $reg . " and transNo = " . $trans . " " . $idclause . " order by datetime {$sort}, transID DESC"; if ($db->table_exists('PaycardTransactions')) { $trans_type = $db->concat('p.cardType', "' '", 'p.transType', ''); $query = "SELECT {$trans_type} AS tranType,\n CASE WHEN p.transType = 'Return' THEN -1*p.amount ELSE p.amount END as amount,\n p.PAN,\n CASE WHEN p.manual=1 THEN 'Manual' ELSE 'Swiped' END as entryMethod,\n p.issuer,\n p.xResultMessage,\n p.xApprovalNumber,\n p.xTransactionID,\n p.name,\n p.requestDatetime AS datetime,\n p.transID\n FROM PaycardTransactions AS p\n WHERE dateID=" . date('Ymd') . "\n AND empNo=" . $emp . "\n AND registerNo=" . $reg . "\n AND transNo=" . $trans . $idclause . "\n AND p.validResponse=1\n AND (p.xResultMessage LIKE '%APPROVE%' OR p.xResultMessage LIKE '%PENDING%')\n AND p.cardType IN ('Credit', 'Debit')\n ORDER BY p.requestDatetime"; } $result = $db->query($query); $emvP = $db->prepare(' SELECT content FROM EmvReceipt WHERE dateID=? AND empNo=? AND registerNo=? AND transNo=? AND transID=? '); while ($row = $db->fetch_array($result)) { $slip .= ReceiptLib::centerString("................................................") . "\n"; // do not look for EmvReceipt server side; use classic receipt $emvR = $reprint ? false : $db->execute($emvP, array(date('Ymd'), $emp, $reg, $trans, $row['transID'])); if ($emvR && $db->numRows($emvR)) { $emvW = $db->fetchRow($emvR); $lines = explode("\n", $emvW['content']); for ($i = 0; $i < count($lines); $i++) { if (isset($lines[$i + 1]) && strlen($lines[$i]) + strlen($lines[$i + 1]) < 56) { // don't columnize the amount lines if (strstr($lines[$i], 'AMOUNT') || strstr($lines[$i + 1], 'AMOUNT')) { $slip .= ReceiptLib::centerString($lines[$i]) . "\n"; } elseif (strstr($lines[$i], 'TOTAL') || strstr($lines[$i + 1], 'TOTAL')) { $slip .= ReceiptLib::centerString($lines[$i]) . "\n"; } else { $spacer = 56 - strlen($lines[$i]) - strlen($lines[$i + 1]); $slip .= $lines[$i] . str_repeat(' ', $spacer) . $lines[$i + 1] . "\n"; $i++; } } else { if (strstr($lines[$i], 'x___')) { if ($sigSlip) { $slip .= "\n\n\n"; } else { $i++; continue; } } $slip .= ReceiptLib::centerString($lines[$i]) . "\n"; } } if ($sigSlip) { $slip .= "\n" . ReceiptLib::centerString($emp . '-' . $reg . '-' . $trans) . "\n"; $slip .= ReceiptLib::centerString(_('(Merchant Copy)')) . "\n"; } else { $slip .= "\n" . ReceiptLib::centerString(_('(Customer Copy)')) . "\n"; } } else { $trantype = $row['tranType']; if ($row['amount'] < 0) { $amt = "-\$" . number_format(-1 * $row['amount'], 2); } else { $amt = "\$" . number_format($row['amount'], 2); } $pan = $row['PAN']; // already masked in the database $entryMethod = $row['entryMethod']; $cardBrand = $row['issuer']; $approvalPhrase = $row['xResultMessage']; $authCode = "#" . $row['xApprovalNumber']; $sequenceNum = $row['xTransactionID']; $name = $row["name"]; if ($sigSlip) { for ($i = 1; $i <= CoreLocal::get('chargeSlipCount'); $i++) { $slip .= ReceiptLib::centerString(CoreLocal::get("chargeSlip" . $i)) . "\n"; } $slip .= $trantype . "\n" . "Card: " . $cardBrand . " " . $pan . "\n" . "Reference: " . $ref . "\n" . "Date & Time: " . $date . "\n" . "Entry Method: " . $entryMethod . "\n" . "Sequence Number: " . $sequenceNum . "\n" . "Authorization: " . $approvalPhrase . "\n" . ReceiptLib::boldFont() . "Amount: " . $amt . "\n" . ReceiptLib::normalFont(); $slip .= ReceiptLib::centerString("I agree to pay above total amount") . "\n" . ReceiptLib::centerString("according to card issuer agreement.") . "\n\n" . ReceiptLib::centerString("X____________________________________________") . "\n" . ReceiptLib::centerString($name) . "\n"; } else { // use columns instead $c1 = array(); $c2 = array(); $c1[] = $trantype; $c1[] = "Entry Method: " . $entryMethod; $c1[] = "Sequence Number: " . $sequenceNum; $c2[] = $cardBrand . " " . $pan; $c2[] = "Authorization: " . $approvalPhrase; $c2[] = ReceiptLib::boldFont() . "Amount: " . $amt . ReceiptLib::normalFont(); $slip .= ReceiptLib::twoColumns($c1, $c2); } } $slip .= ReceiptLib::centerString(".................................................") . "\n"; if ($sigSlip) { // Cut is added automatically by printing process //$slip .= "\n\n\n\n".chr(27).chr(105); break; } } return $slip; }
/** The same data can be rendered two different ways. One's a signature slip, the other is just a list of date, amount, approval code, etc N.B. This isn't finished for CoopCred, just a placeholder. */ protected function variable_slip($ref, $reprint = False, $sigSlip = False) { global $CORE_LOCAL; $date = ReceiptLib::build_time(time()); list($emp, $reg, $trans) = explode('-', $ref); $sort = 'asc'; $slip = ''; $idclause = ''; $db = Database::tDataConnect(); if ($reprint) { $db = Database::mDataConnect(); } if ($sigSlip && is_numeric($CORE_LOCAL->get('paycard_id'))) { $idclause = ' AND transID=' . $CORE_LOCAL->get('paycard_id'); } // query database for cc receipt info $query = "SELECT tranType, amount, PAN, entryMethod, issuer, " . " xResultMessage, xApprovalNumber, xTransactionID, name, datetime " . " FROM ccReceiptView where date=" . date('Ymd', time()) . " and cashierNo = " . $emp . " and laneNo = " . $reg . " and transNo = " . $trans . " " . $idclause . " ORDER BY datetime {$sort}, transID DESC"; if ($db->table_exists('PaycardTransactions')) { $trans_type = $db->concat('p.cardType', "' '", 'p.transType', ''); $query = "SELECT {$trans_type} AS tranType,\n CASE WHEN p.transType = 'Return' THEN -1*p.amount\n ELSE p.amount END as amount,\n p.PAN,\n CASE WHEN p.manual=1 THEN 'Manual'\n ELSE 'Swiped' END as entryMethod,\n p.issuer,\n p.xResultMessage,\n p.xApprovalNumber,\n p.xTransactionID,\n p.name,\n p.requestDatetime AS datetime\n FROM PaycardTransactions AS p\n WHERE dateID=" . date('Ymd') . "\n AND empNo=" . $emp . "\n AND registerNo=" . $reg . "\n AND transNo=" . $trans . $idclause . "\n AND p.validResponse=1\n AND (p.xResultMessage LIKE '%APPROVE%' OR\n p.xResultMessage LIKE '%PENDING%')\n AND p.cardType IN ('Credit', 'Debit')\n ORDER BY p.requestDatetime"; } $result = $db->query($query); while ($row = $db->fetch_array($result)) { $trantype = $row['tranType']; if ($row['amount'] < 0) { $amt = "-\$" . number_format(-1 * $row['amount'], 2); } else { $amt = "\$" . number_format($row['amount'], 2); } $pan = $row['PAN']; // already masked in the database $entryMethod = $row['entryMethod']; $cardBrand = $row['issuer']; $approvalPhrase = $row['xResultMessage']; $authCode = "#" . $row['xApprovalNumber']; $sequenceNum = $row['xTransactionID']; $name = $row["name"]; $slip .= ReceiptLib::centerString("................................................") . "\n"; if ($sigSlip) { $slip .= ReceiptLib::centerString($CORE_LOCAL->get("chargeSlip1")) . "\n" . ReceiptLib::centerString($CORE_LOCAL->get("chargeSlip3") . ", " . $CORE_LOCAL->get("chargeSlip4")) . "\n" . ReceiptLib::centerString($CORE_LOCAL->get("chargeSlip5")) . "\n" . ReceiptLib::centerString($CORE_LOCAL->get("receiptHeader2")) . "\n\n"; // phone // trans type: purchase, canceled purchase, refund or canceled refund $slip .= $trantype . "\n" . "Card: " . $cardBrand . " " . $pan . "\n" . "Reference: " . $ref . "\n" . "Date & Time: " . $date . "\n" . "Entry Method: " . $entryMethod . "\n" . "Sequence Number: " . $sequenceNum . "\n" . "Authorization: " . $approvalPhrase . "\n" . ReceiptLib::boldFont() . "Amount: " . $amt . "\n" . ReceiptLib::normalFont(); $slip .= ReceiptLib::centerString("I agree to pay above total amount") . "\n" . ReceiptLib::centerString("according to the card issuer agreement.") . "\n\n" . ReceiptLib::centerString("X____________________________________________") . "\n" . ReceiptLib::centerString($name) . "\n"; } else { // use columns instead $c1 = array(); $c2 = array(); $c1[] = $trantype; $c1[] = "Entry Method: " . $entryMethod; $c1[] = "Sequence Number: " . $sequenceNum; $c2[] = $cardBrand . " " . $pan; $c2[] = "Authorization: " . $approvalPhrase; $c2[] = ReceiptLib::boldFont() . "Amount: " . $amt . ReceiptLib::normalFont(); $slip .= ReceiptLib::twoColumns($c1, $c2); } $slip .= ReceiptLib::centerString(".................................................") . "\n"; if ($sigSlip) { // Cut is added automatically by the printing process break; } } return $slip; }
/** Prepare the tender report. @return string The report, ready to send to printer. */ public static function get() { global $CORE_LOCAL; /* First, check for anything still in * . localtemptrans * . dtransactions * and for a proper End of Shift. */ $localCheck = ""; $db_a = Database::tDataConnect(); $localQ = "SELECT *\n FROM localtemptrans\n ORDER BY datetime"; $localR = $db_a->query($localQ); $rowCount1 = 0; $transCount1 = 0; $endOfShiftCount1 = 0; $lastUPC1 = ""; while ($localRow = $db_a->fetch_row($localR)) { $rowCount1++; $lastUPC1 = $localRow['upc']; if ($lastUPC1 == 'ENDOFSHIFT') { $endOfShiftCount1++; } if ($localRow['trans_type'] == 'A') { $transCount1++; } } $localQ = "SELECT *\n FROM dtransactions\n ORDER BY datetime"; $localR = $db_a->query($localQ); $rowCount2 = 0; $transCount2 = 0; $endOfShiftCount2 = 0; $lastUPC2 = ""; while ($localRow = $db_a->fetch_row($localR)) { $rowCount2++; $lastUPC2 = $localRow['upc']; if ($lastUPC2 == 'ENDOFSHIFT') { $endOfShiftCount2++; } if ($localRow['trans_type'] == 'A') { $transCount2++; } } /* Ideally, either * . both tables are empty * . there is one record, an upc=ENDOFSHIFT, * in either localtemptrans or dtransactions * and the other table is empty. */ if ($rowCount1 == 0 && $rowCount2 == 0) { $localCheck .= "\n\nThe shift was ended properly, buffers empty. " . "Good!"; } elseif ($lastUPC1 == 'ENDOFSHIFT' && $rowCount1 == 1 && $rowCount2 == 0 || $lastUPC2 == 'ENDOFSHIFT' && $rowCount2 == 1 && $rowCount1 == 0) { $localCheck .= "\n\nThe shift was ended properly, EndOfShift only. " . "Good!"; } elseif ($lastUPC1 == 'ENDOFSHIFT' && ($rowCount1 > 0 || $endOfShiftCount1 > 0)) { $localCheck .= "\n\nThe local transaction-in-progress buffer suggests " . "the shift was ended but perhaps not properly. " . "\n Please SignOff once again and then re-run this report." . "\n If the same problem or another one is reported just use the " . "\n last or best report you have."; } elseif ($rowCount1 > 0) { $localCheck .= "\nThe local transaction-in-progress still contains " . "{$rowCount1} items." . "\nPlease complete or cancel the current transaction " . "and run this " . "\n report again." . "\n If the same problem or another one is reported just use the " . "\n last or best report you have."; } elseif ($lastUPC2 == 'ENDOFSHIFT' && ($rowCount2 > 0 || $endOfShiftCount2 > 0)) { $localCheck .= "\n\nThe local completed-transaction buffer suggests " . "the shift " . "\n was ended but perhaps not properly. " . "\n Please SignOff once again and then re-run this report." . "\n If the same problem or another one is reported just use the " . "\n last or best report you have."; } else { $localCheck .= "\n\nThe local completed-transaction buffer suggests " . "the shift was not " . "\n ended properly. " . "\nPlease SignOff, again if you already have, and then re-run " . "this report." . "\n If the same problem or another one is reported just use the " . "\n last or best report you have."; } if ($transCount2 > 0) { $localCheck .= "\n\nThe local completed-transaction buffer contains " . "{$transCount2} transactions " . "\n that probably will not appear in this report. " . "\n Please alert the shift co-ordinator."; } if (MiscLib::pingport($CORE_LOCAL->get("mServer"), $CORE_LOCAL->get("mDBMS"))) { $db_a = Database::mDataConnect(); $tTable = "dlog"; $tDate = "tdate"; $tSource = "Fannie"; $excl = ""; } else { $db_a = Database::tDataConnect(); $tTable = "localtranstoday"; $tDate = "datetime"; $tSource = "Lane" . $CORE_LOCAL->get('laneno'); $excl = " AND d.trans_status not in ('D','X','Z') AND d.emp_no <> 9999 " . "AND d.register_no <> 99"; } self::$db_a = $db_a; self::$tTable = $tTable; self::$tDate = $tDate; self::$excl = $excl; $shiftCutoff = date('Y-m-d 00:00:00'); self::$shiftCutoff = $shiftCutoff; $DESIRED_TENDERS = $CORE_LOCAL->get("TRDesiredTenders"); self::$dashLine = str_repeat('-', 54); $receipt = ""; $blank = str_repeat(' ', 13); /* Literal spacing from left margin. C a s h ------------------------------------------------------ Time Lane Trans # Emp # Mem # Amount 03:27 PM 1 1 62 484 -6.00 04:14 PM 1 1 63 484 -7.00 ------------------------------------------------------ Count: 2 Total: -13.00 */ $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"; $ref = ReceiptLib::centerString(trim($CORE_LOCAL->get("CashierNo")) . " " . trim($CORE_LOCAL->get("cashier")) . " " . ReceiptLib::build_time(time())) . "\n"; $cashier_names = ""; $cashierQ = "SELECT CONCAT(SUBSTR(e.FirstName,1,1),SUBSTR(e.Lastname,1,1)) as cashier\n FROM {$tTable} d, " . $CORE_LOCAL->get('pDatabase') . ".employees e\n WHERE d.emp_no = e.emp_no AND d.register_no = " . $CORE_LOCAL->get('laneno') . " AND d.trans_type <> 'L' \n AND d.{$tDate} >= '" . $shiftCutoff . "'{$excl}\n GROUP BY d.emp_no\n ORDER BY d.{$tDate}"; $cashierR = $db_a->query($cashierQ); for ($i = 0; $i < ($row = $db_a->fetch_array($cashierR)); $i++) { $cashier_names .= $row['cashier'] . ", "; } $receipt .= ReceiptLib::centerString("T E N D E R R E P O R T") . "\n"; $receipt .= ReceiptLib::centerString("Data from {$tSource}") . "\n"; $receipt .= $ref; $receipt .= ReceiptLib::centerString("Lane " . $CORE_LOCAL->get('laneno') . " -- Cashiers: " . $cashier_names) . "\n\n"; if ($localCheck) { $receipt .= "{$localCheck}\n\n\n"; } /* NET TOTAL * Does not include tenders such as StoreCharge and Coupons. */ if ($CORE_LOCAL->get('store') == 'WEFC_Toronto') { $netTenderList = "'CA','CK','DC','CC'"; $netTenderMessage = "(Only: Cash, Cheque, Debit, Credit)"; } else { $netTenderList = "'CA','CK','DC','CC','FS','EC'"; $netTenderMessage = "(Only: Cash, Check, Debit, Credit, SNAPs)"; } $netQ = "SELECT -SUM(total) AS net, COUNT(total)\n FROM {$tTable} d\n WHERE register_no=" . $CORE_LOCAL->get('laneno') . " AND trans_subtype IN({$netTenderList})" . " AND {$tDate} >= '{$shiftCutoff}'{$excl}"; $netR = $db_a->query($netQ); $net = $db_a->fetch_row($netR); $receipt .= " " . substr("NET Total: " . $blank . $blank, 0, 20); $receipt .= substr($blank . number_format($net[0], 2), -8) . "\n {$netTenderMessage}\n"; $receipt .= "\n"; /* Total for each of a Tender Type or combination. * Each is listed even if no items. * The PFC version was driven by Desired Tenders. */ $receipt .= self::trTotal('CA', 'CASH'); if ($CORE_LOCAL->get('store') == 'WEFC_Toronto') { $receipt .= self::trTotal('CK', 'CHEQUE'); } else { $receipt .= self::trTotal('CK', 'CHECK'); } $receipt .= self::trTotal(array('CP', 'MC'), 'VENDOR COUPON'); $receipt .= self::trTotal('CC', 'CREDIT CARD'); $receipt .= self::trTotal('DC', 'DEBIT CARD'); if (!$CORE_LOCAL->get('store') == 'WEFC_Toronto') { $receipt .= self::trTotal('FS', 'SNAP - FOOD'); $receipt .= self::trTotal('EC', 'SNAP - CASH'); } $receipt .= self::trTotal('GC', 'GIFT CARD'); $receipt .= self::trTotal('MI', 'INSTORE CHARGE'); $receipt .= self::trTotal('IC', 'INSTORE COUPON'); $receipt .= "\n"; if ($CORE_LOCAL->get('store') == 'WEFC_Toronto') { $receipt .= self::trTotal(array('CA', 'CK'), 'CASH + CHEQUE'); $receipt .= self::trTotal(array('DC', 'CC'), 'DEBIT + CREDIT'); } else { $receipt .= self::trTotal('PT', 'PATRONAGE'); $receipt .= self::trTotal(array('CA', 'CK'), 'CASH + CHECK'); $receipt .= self::trTotal(array('DC', 'CC', 'FS', 'EC'), 'DEB/CRED/SNAP'); } if (!$CORE_LOCAL->get('store') == 'WEFC_Toronto') { $receipt .= self::trTotal(45, 'RCVD. on ACCT.'); $receipt .= self::trTotal(37, 'FRMRS MARKET SNAP'); } $receipt .= ReceiptLib::centerString(self::$dashLine); $receipt .= str_repeat("\n", 5); /* Detail for each Desired Tender Type or combination. * Types with no items are skipped. * The output seems very similar to trTotal(). */ /* If you share a credit/debit-card terminal between cash registers * you might want to list those tenders for all lanes * to help with day-end reconciliation. * Add an item to this array for each tender you want treated that way. */ $allLaneTenders = array(); $allLaneTenders[] = 'CC'; $allLaneTenders[] = 'DC'; foreach (array_keys($DESIRED_TENDERS) as $tender_code) { /* Skip Tender Type if no items of that type. * The first search seems the same as the lower search except for total tests. */ if (in_array($tender_code, $allLaneTenders)) { $registerArg = ''; } else { $registerArg = " AND register_no=" . $CORE_LOCAL->get('laneno'); } $query = "SELECT {$tDate}" . " FROM {$tTable} d" . " WHERE trans_subtype = '" . $tender_code . "'" . $registerArg . " AND {$tDate} >= '{$shiftCutoff}'{$excl}" . " ORDER BY {$tDate}"; $result = $db_a->query($query); $numRows = $db_a->num_rows($result); if ($numRows <= 0) { continue; } $titleStr = ""; $itemize = 1; for ($i = 0; $i < strlen($DESIRED_TENDERS[$tender_code]); $i++) { $titleStr .= $DESIRED_TENDERS[$tender_code][$i] . " "; } $titleStr = substr($titleStr, 0, strlen($titleStr) - 1); $receipt .= ReceiptLib::centerString($titleStr) . "\n"; if ($registerArg == '') { $receipt .= _("The list includes items for all lanes."); } if ($itemize == 1) { $receipt .= ReceiptLib::centerString(self::$dashLine) . "\n"; } $query = "SELECT {$tDate},register_no,emp_no,trans_no,card_no,total" . " FROM {$tTable} d" . " WHERE trans_subtype = '" . $tender_code . "'" . $registerArg . " AND (total <> 0 OR total <> -0) " . " AND {$tDate} >= '{$shiftCutoff}'{$excl}" . " ORDER BY {$tDate}"; $result = $db_a->query($query); $numRows = $db_a->num_rows($result); if ($itemize == 1) { $receipt .= $fieldNames; } $sum = 0; for ($i = 0; $i < $numRows; $i++) { $row = $db_a->fetch_array($result); $timeStamp = self::timeStamp($row["{$tDate}"]); if ($itemize == 1 && $row["total"]) { $receipt .= " " . substr($timeStamp . $blank, 0, 10) . substr($row["register_no"] . $blank, 0, 9) . substr($row["trans_no"] . $blank, 0, 8) . substr($blank . $row['emp_no'], -6) . substr($blank . $row["card_no"], -6) . substr($blank . number_format($row["total"], 2), -14) . "\n"; } $sum += $row["total"]; } $receipt .= ReceiptLib::centerString(self::$dashLine) . "\n"; $receipt .= substr($blank . $blank . $blank . "Count: " . $numRows . " Total: " . number_format($sum, 2), -55) . "\n"; $receipt .= str_repeat("\n", 3); // each desired tender. } /* Each item of purchase of these kinds. * first-param depts are PioneerFoodCoop, not WEFC_Toronto */ $receipt .= self::trTotal(36, 'MEMBER EQUITY', True, False); $receipt .= self::trTotal(45, 'RCVD / ACCOUNT', True, False); $receipt .= self::trTotal(41, 'GIFT CARDS SOLD', True, False); $receipt .= str_repeat("\n", 5); // cut paper? return $receipt . chr(27) . chr(105); // get() }
public static function get() { $db_a = Database::mDataConnect(); $shiftCutoff = date('Y-m-d 00:00:00'); $excl = " AND emp_no <> 9999 "; // $lookup = $db_a->query("SELECT MAX(datetime) FROM dtransactions // WHERE DATE(datetime) = CURDATE() AND upc='ENDOFSHIFT' AND // register_no=".CoreLocal::get('laneno')); // if ($db_a->num_rows($lookup) > 0){ // $row = $db_a->fetch_row($lookup); // if ($row[0] != '') $shiftCutoff = $row[0]; // } // TransRecord::add_log_record(array('upc'=>'ENDOFSHIFT')); $DESIRED_TENDERS = CoreLocal::get("TRDesiredTenders"); $db_a = Database::mDataConnect(); $blank = " "; $fieldNames = " " . substr("Time" . $blank, 0, 13) . substr("Lane" . $blank, 0, 9) . substr("Trans #" . $blank, 0, 12) . substr("Change" . $blank, 0, 14) . substr("Amount" . $blank, 0, 14) . "\n"; $ref = ReceiptLib::centerString(trim(CoreLocal::get("CashierNo")) . " " . trim(CoreLocal::get("cashier")) . " " . ReceiptLib::build_time(time())) . "\n\n"; $receipt = ""; $cashier_names = ""; $cashierQ = "SELECT CONCAT(SUBSTR(e.FirstName,1,1),e.Lastname) as cashier\n FROM dlog d, is4c_op.employees e\n WHERE d.emp_no = e.emp_no AND d.register_no = " . CoreLocal::get('laneno') . " AND d.emp_no <> 9999 AND d.trans_type <> 'L' \n AND d.tdate >= '" . $shiftCutoff . "'\n GROUP BY d.emp_no ORDER BY d.tdate"; $cashierR = $db_a->query($cashierQ); for ($i = 0; $i < ($row = $db_a->fetch_array($cashierR)); $i++) { $cashier_names .= $row['cashier'] . ", "; } $receipt .= ReceiptLib::centerString("T E N D E R R E P O R T") . "\n"; $receipt .= $ref; $receipt .= ReceiptLib::centerString("Cashiers: " . $cashier_names) . "\n\n"; // NET TOTAL $netQ = "SELECT -SUM(total) AS net, COUNT(total) FROM dlog \n WHERE register_no=" . CoreLocal::get('laneno') . " AND (trans_subtype IN('CA','CK','DC','CC','EF','FS','EC','GD','TC','WT') OR (trans_subtype = 'MI' AND staff <> 1))\n AND tdate >= '{$shiftCutoff}'{$excl}"; $netR = $db_a->query($netQ); $net = $db_a->fetch_row($netR); $receipt .= " " . substr("GROSS Total: " . $blank . $blank, 0, 20); $receipt .= substr($blank . number_format($net[0], 2), -8) . "\n"; $receipt .= "\n"; $receipt .= trTotal('CA', 'CASH'); $receipt .= trTotal('CK', 'CHECK'); $receipt .= trTotal('CC', 'CREDIT CARD'); $receipt .= trTotal('DC', 'DEBIT CARD'); $receipt .= trTotal('EF', 'EBT - FOOD'); $receipt .= trTotal('EC', 'EBT - CASH'); $receipt .= trTotal('GD', 'GIFT CARD'); $receipt .= trTotal('TC', 'GIFT CERT.'); $receipt .= trTotal('WT', 'WIC'); $receipt .= "\n"; $receipt .= trTotal(array('CP', 'MC'), 'VENDOR COUPON'); $receipt .= trTotal('MI', 'STORE CHARGE'); $receipt .= trTotal('IC', 'INSTORE COUPON'); $receipt .= "\n\n"; foreach (array_keys($DESIRED_TENDERS) as $tender_code) { $query = "select tdate from TenderTapeGeneric where emp_no=" . CoreLocal::get("CashierNo") . " and tender_code = '" . $tender_code . "' order by tdate"; $result = $db_a->query($query); $num_rows = $db_a->num_rows($result); if ($num_rows <= 0) { continue; } //$receipt .= chr(27).chr(33).chr(5); $titleStr = ""; $itemize = 1; for ($i = 0; $i < strlen($DESIRED_TENDERS[$tender_code]); $i++) { $titleStr .= $DESIRED_TENDERS[$tender_code][$i] . " "; } $titleStr = substr($titleStr, 0, strlen($titleStr) - 1); $receipt .= ReceiptLib::centerString($titleStr) . "\n"; $receipt .= $ref; if ($itemize == 1) { $receipt .= ReceiptLib::centerString("------------------------------------------------------"); } $query = "select tdate,register_no,trans_no,tender_code,tender\n from TenderTapeGeneric where register_no=" . CoreLocal::get("laneno") . " and tender_code = '" . $tender_code . "' order by tdate"; $result = $db_a->query($query); $num_rows = $db_a->num_rows($result); if ($itemize == 1) { $receipt .= $fieldNames; } $sum = 0; for ($i = 0; $i < $num_rows; $i++) { // if (((CoreLocal::get("store") == "harvest-cb") || (CoreLocal::get("store") == "harvest-jp")) && ($tender_code == "PE" || $tender_code == "BU" || $tender_code == "EL" || $tender_code == "PY" || $tender_code == "TV")) $itemize = 1; // else $itemize = 0; $row = $db_a->fetch_array($result); $timeStamp = self::timeStamp($row["tdate"]); if ($itemize == 1) { $receipt .= " " . substr($timeStamp . $blank, 0, 13) . substr($row["register_no"] . $blank, 0, 9) . substr($row["trans_no"] . $blank, 0, 8) . substr($blank . number_format("0", 2), -10) . substr($blank . number_format($row["tender"], 2), -14) . "\n"; } $sum += $row["tender"]; } $receipt .= ReceiptLib::centerString("------------------------------------------------------"); $receipt .= substr($blank . $blank . $blank . "Count: " . $num_rows . " Total: " . number_format($sum, 2), -56) . "\n"; $receipt .= str_repeat("\n", 4); // $receipt .= chr(27).chr(105); } return $receipt . chr(27) . chr(105); }
/** Print a tender report This tender report is based on a single tender tape view rather than multiple views (e.g. ckTenders, ckTenderTotal, etc) adding a new tender is mostly just a matter of adding it to the $DESIRED_TENDERS array (exception being if you want special handling in the tender tape view (e.g., three tender types are actually compined under EBT) */ public static function get() { $DESIRED_TENDERS = CoreLocal::get("TRDesiredTenders"); $DESIRED_TENDERS = array("CK" => "CHECK TENDERS", "CC" => "CREDIT CARD TENDERS", "GD" => "GIFT CARD TENDERS", "TC" => "GIFT CERT TENDERS", "MI" => "STORE CHARGE TENDERS", "EF" => "EBT CARD TENDERS", "CP" => "COUPONS TENDERED", "IC" => "INSTORE COUPONS TENDERED", "ST" => "STAMP BOOKS SOLD", "BP" => "BUS PASSES SOLD", "AR" => "AR PAYMENTS", "EQ" => "EQUITY SALES", "SN" => "SANDWICH CARD", "CF" => "COFFEE CARD", "SC" => "STORE CREDIT"); $db_a = Database::mDataConnect(); $blank = " "; $fieldNames = " " . substr("Time" . $blank, 0, 13) . substr("Lane" . $blank, 0, 9) . substr("Trans #" . $blank, 0, 12) . substr("Change" . $blank, 0, 14) . substr("Amount" . $blank, 0, 14) . "\n"; $ref = ReceiptLib::centerString(trim(CoreLocal::get("CashierNo")) . " " . trim(CoreLocal::get("cashier")) . " " . ReceiptLib::build_time(time())) . "\n\n"; $receipt = ""; $itemize = 0; foreach ($DESIRED_TENDERS as $tender_code => $header) { $query = "select tdate,register_no,trans_no,-total AS tender\n from dlog where emp_no=" . CoreLocal::get("CashierNo") . " and trans_type='T' AND trans_subtype='" . $tender_code . "'\n ORDER BY tdate"; switch ($tender_code) { case 'CC': $query = "select tdate,register_no,trans_no,-total AS tender\n from dlog where emp_no=" . CoreLocal::get("CashierNo") . " and trans_type='T' AND trans_subtype IN ('CC','AX')\n ORDER BY tdate"; break; case 'EF': $query = "select tdate,register_no,trans_no,-total AS tender\n from dlog where emp_no=" . CoreLocal::get("CashierNo") . " and trans_type='T' AND trans_subtype IN ('EF','EC')\n ORDER BY tdate"; break; case 'CP': $query = "select tdate,register_no,trans_no,-total AS tender\n from dlog where emp_no=" . CoreLocal::get("CashierNo") . " and trans_type='T' AND trans_subtype ='CP' AND\n upc NOT LIKE '%MAD%' ORDER BY tdate"; break; case 'SC': $query = "select tdate,register_no,trans_no,-total AS tender\n from dlog where emp_no=" . CoreLocal::get("CashierNo") . " and trans_type='T' AND trans_subtype ='SC' AND\n total<0 ORDER BY tdate"; break; case 'AR': $query = "select tdate,register_no,trans_no,total AS tender\n from dlog where emp_no=" . CoreLocal::get("CashierNo") . " and trans_type='D' AND department = 990\n ORDER BY tdate"; break; case 'EQ': $query = "select tdate,register_no,trans_no,total AS tender\n from dlog where emp_no=" . CoreLocal::get("CashierNo") . " and trans_type='D' AND department IN (991,992)\n ORDER BY tdate"; break; case 'ST': $query = "select tdate,register_no,trans_no,total AS tender\n from dlog where emp_no=" . CoreLocal::get("CashierNo") . " and trans_type='I' AND upc = '0000000001065'\n ORDER BY tdate"; break; case 'BP': $query = "select tdate,register_no,trans_no,total AS tender\n from dlog where emp_no=" . CoreLocal::get("CashierNo") . " and trans_type='I' AND upc IN('0000000007573','0000000007574')\n ORDER BY tdate"; break; case 'SN': $query = "select tdate,register_no,trans_no,total AS tender\n from dlog where emp_no=" . CoreLocal::get("CashierNo") . " and trans_type='I' AND upc LIKE '002001000%'\n ORDER BY tdate"; break; case 'CF': $query = "select tdate,register_no,trans_no,total AS tender\n from dlog where emp_no=" . CoreLocal::get("CashierNo") . " and trans_type='I' AND upc LIKE '002000600%'\n ORDER BY tdate"; break; } $result = $db_a->query($query); $num_rows = $db_a->num_rows($result); if ($num_rows <= 0) { continue; } //$receipt .= chr(27).chr(33).chr(5); $titleStr = ""; for ($i = 0; $i < strlen($header); $i++) { $titleStr .= $header[$i] . " "; } $titleStr = substr($titleStr, 0, strlen($titleStr) - 1); $receipt .= ReceiptLib::centerString($titleStr) . "\n"; $receipt .= $ref; if ($itemize == 1) { $receipt .= ReceiptLib::centerString("------------------------------------------------------"); } $itemize = 1; if ($itemize == 1) { $receipt .= $fieldNames; } $sum = 0; for ($i = 0; $i < $num_rows; $i++) { $row = $db_a->fetch_array($result); $timeStamp = self::timeStamp($row["tdate"]); if ($itemize == 1) { $receipt .= " " . substr($timeStamp . $blank, 0, 13) . substr($row["register_no"] . $blank, 0, 9) . substr($row["trans_no"] . $blank, 0, 8) . substr($blank . number_format("0", 2), -10) . substr($blank . number_format($row["tender"], 2), -14) . "\n"; } $sum += $row["tender"]; } $receipt .= ReceiptLib::centerString("------------------------------------------------------"); $receipt .= substr($blank . $blank . $blank . "Count: " . $num_rows . " Total: " . number_format($sum, 2), -56) . "\n"; $receipt .= str_repeat("\n", 4); $receipt .= chr(27) . chr(105); } return $receipt . chr(27) . chr(105); }