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; }
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; }
/** 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; }