Esempio n. 1
0
 /**
   Suspends the current transaction
   If the remote server is available, it will be suspended
   there. Otherwise it is suspended locally.
   @return [string] transaction identifier
 */
 public static function suspendorder()
 {
     $query_a = "select emp_no, trans_no from localtemptrans";
     $db_a = Database::tDataConnect();
     $result_a = $db_a->query($query_a);
     $row_a = $db_a->fetch_array($result_a);
     $cashier_no = substr("000" . $row_a["emp_no"], -2);
     $trans_no = substr("0000" . $row_a["trans_no"], -4);
     $trans_num = ReceiptLib::receiptNumber();
     if (CoreLocal::get("standalone") == 0) {
         $db_a->add_connection(CoreLocal::get("mServer"), CoreLocal::get("mDBMS"), CoreLocal::get("mDatabase"), CoreLocal::get("mUser"), CoreLocal::get("mPass"), false, true);
         $cols = Database::getMatchingColumns($db_a, "localtemptrans", "suspended");
         $db_a->transfer(CoreLocal::get("tDatabase"), "select {$cols} from localtemptrans", CoreLocal::get("mDatabase"), "insert into suspended ({$cols})");
         $db_a->close(CoreLocal::get("mDatabase"), True);
     } else {
         $query = "insert into suspended select * from localtemptrans";
         $result = $db_a->query($query);
     }
     /* ensure the cancel happens */
     $cancelR = $db_a->query("UPDATE localtemptrans SET trans_status='X',charflag='S'");
     TransRecord::finalizeTransaction(true);
     CoreLocal::set("plainmsg", _("transaction suspended"));
     $recall_line = CoreLocal::get("standalone") . " " . CoreLocal::get("laneno") . " " . $cashier_no . " " . $trans_no;
     /**
       If the transaction is marked as complete but somehow did not
       actually finish, this will prevent the suspended receipt from
       adding tax/discount lines to the transaction
     */
     CoreLocal::set('End', 0);
     return $trans_num;
 }
Esempio n. 2
0
 function preprocess()
 {
     if (isset($_REQUEST['selectlist'])) {
         if (!empty($_REQUEST['selectlist'])) {
             $print_class = CoreLocal::get('ReceiptDriver');
             if ($print_class === '' || !class_exists($print_class)) {
                 $print_class = 'ESCPOSPrintHandler';
             }
             $PRINT_OBJ = new $print_class();
             $receipt = ReceiptLib::printReceipt('reprint', $_REQUEST['selectlist']);
             if (session_id() != '') {
                 session_write_close();
             }
             if (is_array($receipt)) {
                 if (!empty($receipt['any'])) {
                     $PRINT_OBJ->writeLine($receipt['any']);
                 }
                 if (!empty($receipt['print'])) {
                     $PRINT_OBJ->writeLine($receipt['print']);
                 }
             } elseif (!empty($receipt)) {
                 $PRINT_OBJ->writeLine($receipt);
             }
         }
         $this->change_page($this->page_url . "gui-modules/pos2.php");
         return false;
     }
     return true;
 }
Esempio n. 3
0
 protected function ajax()
 {
     CoreLocal::set("cabReference", $_REQUEST['input']);
     $receipt = ReceiptLib::printReceipt('cab', CoreLocal::get('cabReference'));
     ReceiptLib::writeLine($receipt);
     return 'Done';
 }
Esempio n. 4
0
 public function standalone_receipt($ref, $reprint = false)
 {
     list($emp, $reg, $trans) = explode('-', $ref, 3);
     $ret = 'Date of Application: ' . date('M d, Y') . "\n";
     $ret .= 'Owner Name: ' . CoreLocal::get('fname') . ' ' . CoreLocal::get('lname') . ', Owner No.: ' . CoreLocal::get('memberID') . "\n";
     $ret .= "\n";
     $ret .= ReceiptLib::centerString(str_repeat('_', 30)) . "\n";
     $ret .= ReceiptLib::centerString('Owner Signature') . "\n";
     if (CoreLocal::get('standalone') == 0) {
         $ret .= $this->memAddress();
     }
     $ret .= "\n";
     $ret .= ReceiptLib::centerString(str_repeat('_', 30)) . "\n";
     $ret .= ReceiptLib::centerString('Employee Signature') . "\n";
     $ret .= "\n";
     $ret .= ReceiptLib::centerString(str_repeat('_', 30)) . "\n";
     $ret .= ReceiptLib::centerString('Manager Signature') . "\n";
     $dbc = Database::tDataConnect();
     $query = sprintf('SELECT MAX(numflag) FROM localtemptrans
                     WHERE upc=\'ACCESS\'
                         AND emp_no=%d
                         AND register_no=%d
                         AND trans_no=%d', $emp, $reg, $trans);
     if ($reprint) {
         $query = str_replace('localtemptrans', 'localtranstoday', $query);
     }
     $result = $dbc->query($query);
     if ($dbc->num_rows($result) > 0) {
         $row = $dbc->fetch_row($result);
         if ($row[0] != 0) {
             $ret .= 'Program No: ' . $row[0] . "\n";
         }
     }
     return $ret;
 }
Esempio n. 5
0
 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;
 }
Esempio n. 6
0
 public function preprocess()
 {
     $this->box_css_class = 'coloredArea';
     $this->msg = _('please enter your password');
     $this->body_class = '';
     if (isset($_REQUEST['reginput']) || isset($_REQUEST['userPassword'])) {
         $passwd = '';
         if (isset($_REQUEST['reginput']) && !empty($_REQUEST['reginput'])) {
             $passwd = $_REQUEST['reginput'];
             UdpComm::udpSend('goodBeep');
         } elseif (isset($_REQUEST['userPassword']) && !empty($_REQUEST['userPassword'])) {
             $passwd = $_REQUEST['userPassword'];
         }
         if (Authenticate::checkPassword($passwd)) {
             Database::testremote();
             $sd = MiscLib::scaleObject();
             if (is_object($sd)) {
                 $sd->ReadReset();
             }
             /**
               Find a drawer for the cashier
             */
             $my_drawer = ReceiptLib::currentDrawer();
             if ($my_drawer == 0) {
                 $available = ReceiptLib::availableDrawers();
                 if (count($available) > 0) {
                     ReceiptLib::assignDrawer(CoreLocal::get('CashierNo'), $available[0]);
                     $my_drawer = $available[0];
                 }
             } else {
                 ReceiptLib::assignDrawer(CoreLocal::get('CashierNo'), $my_drawer);
             }
             TransRecord::addLogRecord(array('upc' => 'SIGNIN', 'description' => 'Sign In Emp#' . CoreLocal::get('CashierNo')));
             /**
               Use Kicker object to determine whether the drawer should open
               The first line is just a failsafe in case the setting has not
               been configured.
             */
             if (session_id() != '') {
                 session_write_close();
             }
             $kicker_class = CoreLocal::get("kickerModule") == "" ? 'Kicker' : CoreLocal::get('kickerModule');
             $kicker_object = new $kicker_class();
             if ($kicker_object->kickOnSignIn()) {
                 ReceiptLib::drawerKick();
             }
             if ($my_drawer == 0) {
                 $this->change_page($this->page_url . "gui-modules/drawerPage.php");
             } else {
                 $this->change_page($this->page_url . "gui-modules/pos2.php");
             }
             return false;
         } else {
             $this->box_css_class = 'errorColoredArea';
             $this->msg = _('password invalid, please re-enter');
         }
     }
     return true;
 }
 /**
   Generate the message
   @param $val the value returned by the object's select_condition()
   @param $ref a transaction reference (emp-lane-trans)
   @param $reprint boolean
   @return [string] message to print on receipt
 */
 public function message($val, $ref, $reprint = false)
 {
     list($emp, $reg, $trans) = explode('-', $ref, 3);
     // full identier:
     // YYYY-MM-DD emp_no-register_no-trans_no
     $identifier = date('Y-m-d') . ' ' . $emp . '-' . $reg . '-' . $trans;
     return "\n" . ReceiptLib::code39($identifier) . "\n";
 }
Esempio n. 8
0
 /** 
 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);
 }
Esempio n. 9
0
 public function message($str)
 {
     $ret = "\n";
     $ret .= ReceiptLib::biggerFont(ReceiptLib::centerBig('Save $5 on a ')) . "\n";
     $ret .= ReceiptLib::biggerFont(ReceiptLib::centerBig('purchase of $25 or more')) . "\n\n";
     $expires = strtotime('+30 days');
     $ret .= ReceiptLib::centerString('Expires: ' . date('m/d/Y', $expires)) . "\n";
     $barcode = 'RC' . date('ym', $expires) . '009';
     $ret .= ReceiptLib::code39($barcode);
     return array('print' => $ret, 'any' => '');
 }
Esempio n. 10
0
 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;
 }
Esempio n. 11
0
 public function message($val, $ref, $reprint = False)
 {
     if ($val <= 0) {
         return '';
     }
     $slip = ReceiptLib::centerString("................................................") . "\n\n";
     $slip .= ReceiptLib::biggerFont("Class B Equity Purchase") . "\n\n";
     $slip .= ReceiptLib::biggerFont(sprintf('Amount: $%.2f', $val)) . "\n";
     $slip .= "\n";
     $slip .= "Proof of purchase for owner equity\n";
     $slip .= "Please retain receipt for your records\n\n";
     $slip .= ReceiptLib::centerString("................................................") . "\n\n";
     CoreLocal::set("equityNoticeAmt", $val);
     return $slip;
 }
Esempio n. 12
0
 /**
   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)
 {
     // balance inquiries are not logged and have no meaning in a reprint,
     // so we can assume that it just happened now and all data is still in session vars
     $tempArr = CoreLocal::get("paycard_response");
     if (!is_array($tempArr) || !isset($tempArr['Balance'])) {
         return '';
     }
     $bal = "\$" . number_format($tempArr["Balance"], 2);
     $pan = CoreLocal::get("paycard_PAN");
     // no need to mask gift card numbers
     $slip = ReceiptLib::normalFont() . ReceiptLib::centerString(".................................................") . "\n";
     for ($i = 1; $i <= CoreLocal::get('chargeSlipCount'); $i++) {
         $slip .= ReceiptLib::centerString(CoreLocal::get("chargeSlip" . $i)) . "\n";
     }
     $slip .= "\n" . "Gift Card Balance\n" . "Card: " . $pan . "\n" . "Date: " . date('m/d/y h:i a') . "\n" . ReceiptLib::boldFont() . "Balance: " . $bal . "\n" . ReceiptLib::normalFont() . ReceiptLib::centerString(".................................................") . "\n" . "\n";
     return $slip;
 }
Esempio n. 13
0
 function message($str)
 {
     $ret = "";
     if (strstr($str, " == ")) {
         $lines = explode(" == ", $str);
         if (CoreLocal::get("equityNoticeAmt") > 0) {
             if (isset($lines[0]) && is_numeric(substr($lines[0], 13))) {
                 $newamt = substr($lines[0], 13) - CoreLocal::get("equityNoticeAmt");
                 $lines[0] = sprintf('EQUITY BALANCE DUE $%.2f', $newamt);
                 if ($newamt <= 0 && isset($lines[1])) {
                     $lines[1] = "PAID IN FULL";
                 }
             }
         }
         foreach ($lines as $line) {
             $ret .= ReceiptLib::centerString($line) . "\n";
         }
     } else {
         $ret .= $str;
     }
     return $ret;
 }
Esempio n. 14
0
 function preprocess()
 {
     $this->color = "coloredArea";
     $this->heading = _("enter password");
     $this->msg = _("confirm no sales");
     if (isset($_REQUEST['reginput']) || isset($_REQUEST['userPassword'])) {
         $passwd = '';
         if (isset($_REQUEST['reginput']) && !empty($_REQUEST['reginput'])) {
             $passwd = $_REQUEST['reginput'];
         } elseif (isset($_REQUEST['userPassword']) && !empty($_REQUEST['userPassword'])) {
             $passwd = $_REQUEST['userPassword'];
         }
         if (strtoupper($passwd) == "CL") {
             $this->change_page($this->page_url . "gui-modules/pos2.php");
             return False;
         } elseif (Authenticate::checkPassword($passwd)) {
             ReceiptLib::drawerKick();
             if (CoreLocal::get('LoudLogins') == 1) {
                 UdpComm::udpSend('twoPairs');
             }
             $this->change_page($this->page_url . "gui-modules/pos2.php");
             return false;
         } else {
             $this->color = "errorColoredArea";
             $this->heading = _("re-enter password");
             $this->msg = _("invalid password");
             if (CoreLocal::get('LoudLogins') == 1) {
                 UdpComm::udpSend('errorBeep');
             }
         }
     } else {
         // beep on initial page load
         if (CoreLocal::get('LoudLogins') == 1) {
             UdpComm::udpSend('twoPairs');
         }
     }
     return true;
 }
Esempio n. 15
0
 public function message($val, $ref, $reprint = false)
 {
     if ($val == 0) {
         return '';
     }
     $slip = '';
     // reprints always include. if the original transaction
     // has an automatic reprtint, only include one slip
     if ($reprint || CoreLocal::get('autoReprint') == 0) {
         $slip .= ReceiptLib::centerString("................................................") . "\n\n";
         $slip .= ReceiptLib::centerString("( S T O R E   C O P Y )") . "\n";
         $slip .= ReceiptLib::biggerFont(sprintf("Amount \$%.2f", $val)) . "\n\n";
         if (CoreLocal::get("fname") != "" && CoreLocal::get("lname") != "") {
             $slip .= "Name: " . CoreLocal::get("fname") . " " . CoreLocal::get("lname") . "\n\n";
         } else {
             $slip .= "Name: ____________________________________________\n\n";
         }
         $slip .= "X: ____________________________________________\n";
         $slip .= ReceiptLib::centerString('(please sign)') . "\n\n";
         $slip .= ReceiptLib::centerString("................................................") . "\n";
     }
     return $slip;
 }
 public function message($val, $ref, $reprint = False)
 {
     if ($val <= 0) {
         return '';
     }
     $slip = '';
     if ($reprint || CoreLocal::get('autoReprint') == 0) {
         $slip .= ReceiptLib::centerString("................................................") . "\n\n";
         $slip .= ReceiptLib::centerString("( C U S T O M E R   C O P Y )") . "\n";
         $slip .= ReceiptLib::biggerFont("Store credit issued") . "\n\n";
         $slip .= ReceiptLib::biggerFont(sprintf("Amount \$%.2f", $val)) . "\n\n";
         if (CoreLocal::get("fname") != "" && CoreLocal::get("lname") != "") {
             $slip .= "Name: " . CoreLocal::get("fname") . " " . CoreLocal::get("lname") . "\n\n";
         } else {
             $slip .= "Name: ____________________________________________\n\n";
         }
         $slip .= "Ph #: ____________________________________________\n\n";
         $slip .= " * no cash back on store credit refunds\n";
         $slip .= " * change amount is not transferable to\n   another store credit\n";
         $slip .= ReceiptLib::centerString("................................................") . "\n";
     }
     return $slip;
 }
Esempio n. 17
0
     $output = $yesSync;
     UdpComm::udpSend("termReset");
     $sd = MiscLib::scaleObject();
     if (is_object($sd)) {
         $sd->ReadReset();
     }
     CoreLocal::set('ccTermState', 'swipe');
     uploadAndReset($receiptType);
 }
 // close session so if printer hangs
 // this script won't lock the session file
 if (session_id() != '') {
     session_write_close();
 }
 if ($receiptType == "full" && $dokick) {
     ReceiptLib::drawerKick();
 }
 /**
   Disable receipt for cancelled and/or suspended
   transactions if configured to do so
 */
 if ($receiptType == 'cancelled' && CoreLocal::get('CancelReceipt') == 0 && CoreLocal::get('CancelReceipt') !== '') {
     $receiptContent = array();
 } elseif ($receiptType == 'suspended' && CoreLocal::get('SuspendReceipt') == 0 && CoreLocal::get('SuspendReceipt') !== '') {
     $receiptContent = array();
 } elseif ($receiptType == 'ddd' && CoreLocal::get('ShrinkReceipt') == 0 && CoreLocal::get('ShrinkReceipt') !== '') {
     $receiptContent = array();
 }
 $EMAIL_OBJ = new $email_class();
 foreach ($receiptContent as $receipt) {
     if (is_array($receipt)) {
Esempio n. 18
0
*********************************************************************************/
ini_set('display_errors', 'Off');
include_once dirname(__FILE__) . '/../lib/AutoLoader.php';
/*
 * Mark items as shrink/unsellable.
 *
 * DDD is WFC lingo for unsaleable goods (dropped, dented, damaged,
 * etc) Functionally this works like canceling a transaction, but
 * marks items with a different trans_status (Z) so these items can be
 * pulled out in later reports.  A mappable reason code is stored in
 * localtemptrans.numflag.
 */
$shrinkReason = 0;
if (CoreLocal::get('shrinkReason') > 0) {
    $shrinkReason = CoreLocal::get('shrinkReason');
}
$db = Database::tDataConnect();
$query = "UPDATE localtemptrans SET trans_status='Z', numflag=" . (int) $shrinkReason;
$db->query($query);
CoreLocal::set("plainmsg", "items marked as shrink/unsellable");
CoreLocal::set("End", 2);
CoreLocal::set('shrinkReason', 0);
$_REQUEST['receiptType'] = 'ddd';
$_REQUEST['ref'] = ReceiptLib::receiptNumber();
TransRecord::finalizeTransaction(true);
ob_start();
include realpath(dirname(__FILE__) . '/ajax-end.php');
ob_end_clean();
if (!headers_send()) {
    header("Location: " . MiscLib::base_url() . "gui-modules/pos2.php");
}
Esempio n. 19
0
 /**
   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;
 }
Esempio n. 20
0
 /**
   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;
 }
Esempio n. 21
0
 /**
 @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()
 }
Esempio n. 22
0
 /**
   A return array for parse() with proper keys
   @return array
 
   See parse() method
 */
 function default_json()
 {
     return array('main_frame' => false, 'target' => '.baseHeight', 'output' => false, 'redraw_footer' => false, 'receipt' => false, 'trans_num' => ReceiptLib::receiptNumber(), 'scale' => false, 'udpmsg' => false, 'retry' => false);
 }
Esempio n. 23
0
 function writeLine($text)
 {
     ReceiptLib::writeLine($text);
 }
Esempio n. 24
0
 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);
 }
Esempio n. 25
0
 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;
 }
Esempio n. 26
0
    echo $m;
    ?>
</option>
<?php 
}
?>
</select> <br />

Send to printer <select name="print">
<option value="0">No</option>
<option value="1">Yes</option>
</select> <br />


Emp# <input type="text" size="3" name="emp_no" />

<input type="submit" value="Get Output" />
</form>
<hr />
<?php 
if (isset($_REQUEST['t_mod']) && isset($_REQUEST['emp_no'])) {
    CoreLocal::set('CashierNo', $_REQUEST['emp_no']);
    $tmod = $_REQUEST['t_mod'];
    echo "Output for {$tmod}:<br />";
    echo '<pre>';
    $report = $tmod::get();
    echo '</pre>';
    if (isset($_REQUEST['print']) && $_REQUEST['print'] == 1) {
        ReceiptLib::writeLine($report);
    }
}
Esempio n. 27
0
 /** 
 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);
 }
Esempio n. 28
0
 /**
   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;
 }
Esempio n. 29
0
    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA

*********************************************************************************/
ini_set('display_errors', 'Off');
include_once dirname(__FILE__) . '/../lib/AutoLoader.php';
$endorseType = isset($_REQUEST['type']) ? $_REQUEST['type'] : '';
$amount = isset($_REQUEST['amount']) ? $_REQUEST['amount'] : '';
if (strlen($endorseType) > 0) {
    // close session so if printer hangs
    // this script won't lock the session file
    if (session_id() != '') {
        session_write_close();
    }
    switch ($endorseType) {
        case "check":
            ReceiptLib::frank($amount);
            break;
        case "giftcert":
            ReceiptLib::frankgiftcert($amount);
            break;
        case "stock":
            ReceiptLib::frankstock($amount);
            break;
        case "classreg":
            ReceiptLib::frankclassreg();
            break;
        default:
            break;
    }
}
echo "Done";
Esempio n. 30
0
<form action="receiptTest.php" method="get">
<b>Receipt Type</b>:
<select name="rtype">
    <option value="full">Normal Transaction</option>
    <option value="cab">Cab Coupon</option>
    <option value="partial">Partial Transaction</option>
    <option value="cancelled">Cancelled Transaction</option>
    <option value="resume">Resumed Transaction</option>
    <option value="suspended">Suspended Transaction</option>
    <option value="ccSlip">Credit Card Slip</option>
    <option value="gcSlip">Gift Card Slip</option>
    <option value="gcBalSlip">Gift Card Balance</option>
</select>
<input type="submit" value="Get Receipt">
</form>
<hr />
<?php 
if (isset($_REQUEST['rtype'])) {
    echo '<b>Results</b><br /><pre>';
    $receipt = ReceiptLib::printReceipt($_REQUEST['rtype'], False, False);
    if (is_array($receipt)) {
        echo $receipt['print'];
    } else {
        echo $receipt;
    }
    echo '</pre>';
}
?>
</body>
</html>