Exemple #1
0
 function check($str)
 {
     // only check & warn once per transaction
     if (CoreLocal::get('cashDropWarned') == True) {
         return False;
     }
     // checking one time
     CoreLocal::set('cashDropWarned', True);
     // cannot check in standalone
     if (CoreLocal::get('standalone') == 1) {
         return False;
     }
     // lookup cashier total
     $db = Database::mDataConnect();
     $q = sprintf("SELECT sum(-total) FROM dtransactions WHERE\n            trans_subtype='CA' AND trans_status <> 'X' AND emp_no=%d", CoreLocal::get('CashierNo'));
     $r = $db->query($q);
     $ttl = 0;
     if ($db->num_rows($r) > 0) {
         $row = $db->fetch_row($r);
         $ttl = $row[0];
     }
     if ($ttl > CoreLocal::get('cashDropThreshold')) {
         return True;
     } else {
         return False;
     }
 }
 /**
   Implementation function
   @return SQL result object
 */
 public function fetch($empNo = false, $laneNo = false, $transNo = false)
 {
     $op_db = CoreLocal::get('pDatabase');
     $sql = Database::tDataConnect();
     $join_table = $op_db . $sql->sep() . 'MasterSuperDepts';
     $column = 's.super_name';
     if (!$sql->table_exists($join_table)) {
         $join_table = $op_db . $sql->sep() . 'subdepts';
         $column = 's.subdept_name';
     }
     $query = 'SELECT l.upc,l.trans_type,l.description,
         l.total,l.percentDiscount,l.trans_status,
         l.charflag,l.scale,l.quantity,l.unitPrice,
         l.ItemQtty,l.matched,l.numflag,l.tax,
         l.foodstamp,l.trans_id,l.department,
         l.trans_subtype,l.regPrice,
         ' . $column . ' AS category 
         FROM localtemptrans AS l 
             LEFT JOIN ' . $join_table . ' AS s ON l.department=s.dept_ID
         WHERE trans_type <> \'L\'
         ORDER BY trans_id DESC';
     if ($empNo && $laneNo && $transNo) {
         $query = sprintf("SELECT l.upc,l.trans_type,l.description,\n                l.total,l.percentDiscount,l.trans_status,\n                l.charflag,l.scale,l.quantity,l.unitPrice,\n                l.ItemQtty,l.matched,l.numflag,l.tax,\n                l.foodstamp,l.trans_id,l.department,\n                l.trans_subtype,l.regPrice,\n                " . $column . " AS category \n                FROM localtranstoday as l \n                    LEFT JOIN " . $join_table . " AS s ON l.department=s.dept_ID\n                WHERE trans_type <> 'L' AND\n                emp_no=%d AND register_no=%d AND trans_no=%d\n                AND datetime >= " . $sql->curdate() . "\n                ORDER BY trans_id DESC", $empNo, $laneNo, $transNo);
     }
     $result = $sql->query($query);
     return $result;
 }
Exemple #3
0
 function tender_out($asTender)
 {
     $ret = $this->default_json();
     Database::getsubtotals();
     if (CoreLocal::get("amtdue") <= 0.005) {
         CoreLocal::set("change", -1 * CoreLocal::get("amtdue"));
         $cash_return = CoreLocal::get("change");
         if ($asTender != "FS") {
             TransRecord::addchange($cash_return, 'CA');
         }
         CoreLocal::set("End", 1);
         $ret['output'] = DisplayLib::printReceiptFooter();
         $ret['redraw_footer'] = true;
         $ret['receipt'] = 'full';
         TransRecord::finalizeTransaction();
     } else {
         CoreLocal::set("change", 0);
         CoreLocal::set("fntlflag", 0);
         $ttl_result = PrehLib::ttl();
         TransRecord::debugLog('Tender Out (PrehLib): ' . print_r($ttl_result, true));
         TransRecord::debugLog('Tender Out (amtdue): ' . print_r(CoreLocal::get('amtdue'), true));
         $ret['output'] = DisplayLib::lastpage();
     }
     return $ret;
 }
 function preprocess()
 {
     if (isset($_REQUEST['doLookup'])) {
         $ref = $_REQUEST['id'];
         $local = $_REQUEST['local'];
         $mode = $_REQUEST['mode'];
         $obj = null;
         $resp = array();
         foreach (CoreLocal::get('RegisteredPaycardClasses') as $rpc) {
             $obj = new $rpc();
             if ($obj->myRefNum($ref)) {
                 break;
             } else {
                 $obj = null;
             }
         }
         if ($obj === null) {
             $resp['output'] = DisplayLib::boxMsg('Invalid Transaction ID' . '<br />Local System Error', '', true);
             $resp['confirm_dest'] = MiscLib::base_url() . 'gui-modules/pos2.php';
             $resp['cancel_dest'] = MiscLib::base_url() . 'gui-modules/pos2.php';
         } else {
             if ($local == 0 && $mode == 'verify') {
                 $resp['output'] = DisplayLib::boxMsg('Cannot Verify - Already Complete' . '<br />Local System Error', '', true);
                 $resp['confirm_dest'] = MiscLib::base_url() . 'gui-modules/pos2.php';
                 $resp['cancel_dest'] = MiscLib::base_url() . 'gui-modules/pos2.php';
             } else {
                 $resp = $obj->lookupTransaction($ref, $local, $mode);
             }
         }
         echo JsonLib::array_to_json($resp);
         return false;
     }
     return true;
 }
Exemple #5
0
 private static function basicAdminXml()
 {
     $e2e = new MercuryE2E();
     $termID = $e2e->getTermID();
     $operatorID = CoreLocal::get("CashierNo");
     $mcTerminalID = CoreLocal::get('PaycardsTerminalID');
     $refNum = $e2e->refnum(CoreLocal::get('LastID'));
     $dc_host = CoreLocal::get('PaycardsDatacapLanHost');
     if (empty($dc_host)) {
         $dc_host = '127.0.0.1';
     }
     $msgXml = '<?xml version="1.0"?' . '>
         <TStream>
         <Transaction>
         <HostOrIP>' . $dc_host . '</HostOrIP>
         <MerchantID>' . $termID . '</MerchantID>
         <TerminalID>' . $mcTerminalID . '</TerminalID>
         <OperatorID>' . $operatorID . '</OperatorID>
         <MerchantLanguage>' . self::caLanguage() . '</MerchantLanguage>
         <TranCode>{{TranCode}}</TranCode>
         <SecureDevice>{{SecureDevice}}</SecureDevice>
         <ComPort>{{ComPort}}</ComPort>
         <SequenceNo>{{SequenceNo}}</SequenceNo>
         <InvoiceNo>' . $refNum . '</InvoiceNo>
         <RefNo>' . $refNum . '</RefNo>
         </Transaction>
         </TStream>';
     return $msgXml;
 }
Exemple #6
0
 function kickOnSignOut()
 {
     if (CoreLocal::get('training') == 1) {
         return False;
     }
     return True;
 }
Exemple #7
0
 public function handle($upc, $json)
 {
     $my_url = MiscLib::base_url();
     switch (ltrim($upc, '0')) {
         case '8006':
             if (CoreLocal::get("memberID") == 0) {
                 $json['main_frame'] = $my_url . 'gui-modules/memlist.php';
             } else {
                 if (CoreLocal::get("msgrepeat") == 0) {
                     CoreLocal::set("boxMsg", "<B>" . $total . " stock payment</B><BR>insert form<BR>press [enter] to endorse<P><FONT size='-1'>[clear] to cancel</FONT>");
                     $ret["main_frame"] = $my_url . "gui-modules/boxMsg2.php?endorse=stock&endorseAmt=" . $total;
                 }
             }
             break;
         case '8005':
             if (CoreLocal::get("memberID") == 0) {
                 $json['main_frame'] = $my_url . 'gui-modules/memlist.php';
             } elseif (CoreLocal::get("isMember") == 0) {
                 $json['output'] = DisplayLib::boxMsg(_("member discount not applicable"), '', false, DisplayLib::standardClearButton());
             } elseif (CoreLocal::get("percentDiscount") > 0) {
                 $json['output'] = DisplayLib::boxMsg(CoreLocal::get("percentDiscount") . "% discount already applied", '', false, DisplayLib::standardClearButton());
             }
             break;
     }
     // magic plu, but other conditions not matched
     if ($json['main_frame'] === false && empty($json['output'])) {
         $json['output'] = DisplayLib::boxMsg($upc . "<br />is not a valid item", '', false, DisplayLib::standardClearButton());
     }
     return $json;
 }
Exemple #8
0
 /**
   Display the notification
   @return [string] html
 */
 public function draw()
 {
     if (CoreLocal::get('PaycardsCashierFacing') == '1') {
         return '';
     }
     // style box to look like a little screen
     $ret = '<div style="background:#ccc;border:solid 1px black;padding:7px;text-align:center;font-size:120%;">';
     $rdy = '<div style="background:#0c0;border:solid 1px black;padding:7px;text-align:center;font-size:120%;">';
     switch (CoreLocal::get('ccTermState')) {
         case 'swipe':
             return $ret . 'Slide<br />Card</div>';
             break;
         case 'ready':
             return $rdy . 'Ready</div>';
             break;
         case 'pin':
             return $ret . 'Enter<br />PIN</div>';
             break;
         case 'type':
             return $ret . 'Card<br />Type</div>';
             break;
         case 'cashback':
             return $ret . 'Cash<br />Back</div>';
             break;
     }
     return '';
 }
Exemple #9
0
 public function errorCheck()
 {
     if ($this->amount - CoreLocal::get('amtdue') > 0 && CoreLocal::get('amtdue') > 0) {
         return DisplayLib::boxMsg(_('max tender is ') . CoreLocal::get('amtdue'), _('no change allowed'), false, DisplayLib::standardClearButton());
     }
     return true;
 }
Exemple #10
0
 public function body_content()
 {
     echo $this->noinput_header();
     ?>
     <div class="baseHeight">
     <?php 
     if (CoreLocal::get("plainmsg") && strlen(CoreLocal::get("plainmsg")) > 0) {
         echo DisplayLib::printheaderb();
         echo "<div class=\"centerOffset\">";
         echo DisplayLib::plainmsg(CoreLocal::get("plainmsg"));
         echo "</div>";
     } else {
         // No input and no messages, so
         // list the items
         if (CoreLocal::get("End") == 1) {
             echo DisplayLib::printReceiptfooter(true);
         } else {
             echo DisplayLib::lastpage(true);
         }
     }
     echo "</div>";
     // end base height
     echo "<div id=\"footer\">";
     echo DisplayLib::printfooter(true);
     echo '</div>';
 }
Exemple #11
0
 function check($str)
 {
     $as_upc = str_pad($str, 13, '0', STR_PAD_LEFT);
     if (substr($str, -3) == "QK9") {
         $this->remainder = str_replace("QK9", "QM9", $str);
         return True;
     } else {
         if (substr($str, -4) == "QK10") {
             $this->remainder = str_replace("QK10", "QM10", $str);
             return True;
         } else {
             if (($as_upc == '0000000001112' || $as_upc == '0000000001113') && CoreLocal::get('msgrepeat') == 0) {
                 $this->remainder = 'QM708';
                 return true;
             } elseif (preg_match('/(\\d+)\\*0*1112/', $str, $matches) && CoreLocal::get('msgrepeat') == 0) {
                 $this->remainder = $matches[1] . '*QM708';
                 return true;
             } elseif (preg_match('/(\\d+)\\*0*1113/', $str, $matches) && CoreLocal::get('msgrepeat') == 0) {
                 $this->remainder = $matches[1] . '*QM708';
                 return true;
             } elseif ($as_upc == '0049999900047') {
                 $this->remainder = '0049999900048';
                 return true;
             }
         }
     }
     return False;
 }
Exemple #12
0
 protected function ajax()
 {
     CoreLocal::set("cabReference", $_REQUEST['input']);
     $receipt = ReceiptLib::printReceipt('cab', CoreLocal::get('cabReference'));
     ReceiptLib::writeLine($receipt);
     return 'Done';
 }
Exemple #13
0
 public function preprocess()
 {
     $this->upc = FormLib::get('upc');
     if (FormLib::get('reginput', false) !== false) {
         $inp = FormLib::get('reginput');
         if (strtoupper($inp) == 'CL') {
             $this->change_page(MiscLib::baseURL() . 'gui-modules/pos2.php');
             return false;
         }
         $dbc = Database::pDataConnect();
         $empP = $dbc->prepare('
             SELECT emp_no
             FROM employees
             WHERE EmpActive=1
                 AND frontendsecurity >= ?
                 AND (CashierPassword=? OR AdminPassword=?)');
         if ($dbc->getValue($empP, array(30, $inp, $inp)) !== false) {
             CoreLocal::set('strRemembered', $this->upc);
             CoreLocal::set('msgrepeat', 1);
             $arr = CoreLocal::get('WicOverride');
             if (!is_array($arr)) {
                 $arr = array();
             }
             $arr[] = ltrim($this->upc, '0');
             CoreLocal::set('WicOverride', $arr);
             $this->change_page(MiscLib::baseURL() . 'gui-modules/pos2.php');
             return false;
         } else {
             $this->box_color = 'errorColoredArea';
         }
     }
     return true;
 }
Exemple #14
0
 function parse($str)
 {
     $curID = CoreLocal::get("currentid");
     $dbc = Database::tDataConnect();
     $query = "SELECT trans_type,tax,foodstamp FROM localtemptrans WHERE trans_id={$curID}";
     $res = $dbc->query($query);
     if ($dbc->num_rows($res) == 0) {
         return True;
     }
     // shouldn't ever happen
     $item = $dbc->fetch_row($res);
     $query = "SELECT MAX(id) FROM taxrates";
     $res = $dbc->query($query);
     $tax_cap = 0;
     if ($dbc->num_rows($res) > 0) {
         $taxID = $dbc->fetch_row($res);
         $max = $taxID[0];
         if (!empty($max)) {
             $tax_cap = $max;
         }
     }
     $dbc->query($query);
     $next_tax = $item['tax'] + 1;
     $next_fs = 0;
     if ($next_tax > $max) {
         $next_tax = 0;
         $next_fs = 1;
     }
     $query = "UPDATE localtemptrans \n            set tax={$next_tax},foodstamp={$next_fs} \n            WHERE trans_id={$curID}";
     $dbc->query($query);
     $ret = $this->default_json();
     $ret['output'] = DisplayLib::listItems(CoreLocal::get("currenttopid"), $curID);
     return $ret;
     // maintain item cursor position
 }
Exemple #15
0
 function addItem($row, $quantity, $priceObj)
 {
     if ($quantity == 0) {
         return False;
     }
     // enforce limit on discounting sale items
     $dsi = CoreLocal::get('DiscountableSaleItems');
     if ($dsi == 0 && $dsi !== '' && $priceObj->isSale()) {
         $row['discount'] = 0;
     }
     /*
       Use "quantity" field in products record as a per-transaction
       limit. This is analogous to a similar feature with sale items.
     */
     if (!$priceObj->isSale() && $row['quantity'] > 0) {
         $db = Database::tDataConnect();
         $query = "SELECT SUM(quantity) as qty FROM localtemptrans\n                WHERE upc='{$row['upc']}'";
         $result = $db->query($query);
         if ($db->num_rows($result) > 0) {
             $chkRow = $db->fetch_row($result);
             if ($chkRow['qty'] + $quantity > $row['quantity']) {
                 $this->error_msg = _("item only allows ") . $row['quantity'] . _(" per transaction");
                 return False;
             }
         }
     }
     $pricing = $priceObj->priceInfo($row, $quantity);
     TransRecord::addRecord(array('upc' => $row['upc'], 'description' => $row['description'], 'trans_type' => 'I', 'trans_subtype' => isset($row['trans_subtype']) ? $row['trans_subtype'] : '', 'department' => $row['department'], 'quantity' => $quantity, 'unitPrice' => $pricing['unitPrice'], 'total' => MiscLib::truncate2($pricing['unitPrice'] * $quantity), 'regPrice' => $pricing['regPrice'], 'scale' => $row['scale'], 'tax' => $row['tax'], 'foodstamp' => $row['foodstamp'], 'discount' => $pricing['discount'], 'memDiscount' => $pricing['memDiscount'], 'discountable' => $row['discount'], 'discounttype' => $row['discounttype'], 'ItemQtty' => $quantity, 'volDiscType' => $row['pricemethod'], 'volume' => $row['quantity'], 'VolSpecial' => $row['groupprice'], 'mixMatch' => $row['mixmatchcode'], 'cost' => isset($row['cost']) ? $row['cost'] * $quantity : 0.0, 'numflag' => isset($row['numflag']) ? $row['numflag'] : 0, 'charflag' => isset($row['charflag']) ? $row['charflag'] : ''));
     return true;
 }
Exemple #16
0
 function parse($str)
 {
     $ret = $this->default_json();
     if ($str == "FNTL") {
         $ret['main_frame'] = MiscLib::base_url() . 'gui-modules/fsTotalConfirm.php';
     } elseif ($str == "TETL") {
         $ret['main_frame'] = MiscLib::base_url() . 'gui-modules/requestInfo.php?class=Totals';
     } elseif ($str == "FTTL") {
         PrehLib::finalttl();
     } elseif ($str == "TL") {
         CoreLocal::set('End', 0);
         $chk = PrehLib::ttl();
         if ($chk !== True) {
             $ret['main_frame'] = $chk;
         }
     } elseif ($str == "MTL") {
         $chk = PrehLib::omtr_ttl();
         if ($chk !== True) {
             $ret['main_frame'] = $chk;
         }
     } elseif ($str == "WICTL") {
         $ttl = PrehLib::wicableTotal();
         $ret['output'] = DisplayLib::boxMsg(_('WIC Total') . sprintf(': $%.2f', $ttl), '', true, DisplayLib::standardClearButton());
         // return early since output has been set
         return $ret;
     }
     if (!$ret['main_frame']) {
         $ret['output'] = DisplayLib::lastpage();
         $ret['redraw_footer'] = True;
     }
     return $ret;
 }
Exemple #17
0
 function parse($str)
 {
     $lines = CoreLocal::get('screenLines');
     if (!$lines === '' || !is_numeric($lines)) {
         $lines = 11;
     }
     $ret = $this->default_json();
     if ($str == "U") {
         $ret["output"] = DisplayLib::listItems(CoreLocal::get("currenttopid"), $this->next_valid(CoreLocal::get("currentid"), True));
     } elseif ($str == "D") {
         $ret["output"] = DisplayLib::listItems(CoreLocal::get("currenttopid"), $this->next_valid(CoreLocal::get("currentid"), False));
     } else {
         $change = (int) substr($str, 1);
         $curID = CoreLocal::get("currenttopid");
         $newID = CoreLocal::get("currentid");
         if ($str[0] == "U") {
             $newID -= $change;
         } else {
             $newID += $change;
         }
         if ($newID == $curID || $newID == $curID + $lines) {
             $curID = $newID - 5;
         }
         if ($curID < 1) {
             $curID = 1;
         }
         $ret["output"] = DisplayLib::listItems($curID, $newID);
     }
     return $ret;
 }
Exemple #18
0
 /**
   Input processing function
 */
 function preprocess()
 {
     // a selection was made
     if (isset($_REQUEST['search'])) {
         $entered = strtoupper($_REQUEST['search']);
         if ($entered == "" || $entered == "CL") {
             // should be empty string
             // javascript causes this input if the
             // user presses CL{enter}
             // Redirect to main screen
             CoreLocal::set("tenderTotal", "0");
             $this->change_page($this->page_url . "gui-modules/pos2.php");
             return False;
         }
         if (!empty($entered)) {
             // built department input string and set it
             // to be the next POS entry
             // Redirect to main screen
             $input = CoreLocal::get("tenderTotal") . "CQ" . $entered;
             CoreLocal::set("msgrepeat", 1);
             CoreLocal::set("strRemembered", $input);
             $this->change_page($this->page_url . "gui-modules/pos2.php");
             return False;
         }
     }
     return True;
 }
 /**
   localtranstoday used to be a view; recreate
   it as a table if needed.
 */
 public function normalize($db_name, $mode = BasicModel::NORMALIZE_MODE_CHECK, $doCreate = False)
 {
     if ($db_name == CoreLocal::get('pDatabase')) {
         $this->connection = Database::pDataConnect();
     } else {
         if ($db_name == CoreLocal::get('tDatabase')) {
             $this->connection = Database::tDataConnect();
         } else {
             echo "Error: Unknown database ({$db_name})";
             return false;
         }
     }
     if ($this->connection->isView($this->name)) {
         if ($mode == BasicModel::NORMALIZE_MODE_CHECK) {
             echo "View {$this->name} should be a table!\n";
             echo "==========================================\n";
             printf("%s table %s\n", "Check complete. Need to drop view & create replacement table.", $this->name);
             echo "==========================================\n\n";
             return 999;
         } else {
             $drop = $this->connection->query('DROP VIEW ' . $this->name);
             echo "==========================================\n";
             printf("Dropping view %s %s\n", $this->name, $drop ? "OK" : "failed");
             if ($drop) {
                 $cResult = $this->create();
                 printf("Update complete. Creation of table %s %s\n", $this->name, $cResult ? "OK" : "failed");
             }
             echo "==========================================\n";
             return true;
         }
     } else {
         return parent::normalize($db_name, $mode, $doCreate);
     }
 }
Exemple #20
0
 public function __construct($refNum)
 {
     $this->refNum = $refNum;
     $this->today = date('Ymd');
     // numeric date only, it goes in an 'int' field as part of the primary key
     $this->now = date('Y-m-d H:i:s');
     // full timestamp
     $this->cashierNo = CoreLocal::get("CashierNo");
     $this->laneNo = CoreLocal::get("laneno");
     $this->transNo = CoreLocal::get("transno");
     $this->transID = CoreLocal::get("paycard_id");
     $this->setType(CoreLocal::get('CacheCardType'));
     $this->amount = CoreLocal::get("paycard_amount");
     if (($this->type == "Debit" || $this->type == "EBTCASH") && $this->amount > CoreLocal::get("amtdue")) {
         $this->cashback = $this->amount - CoreLocal::get("amtdue");
         $this->amount = CoreLocal::get("amtdue");
     } else {
         $this->cashback = 0;
     }
     $this->mode = $this->amount < 0 ? 'Return' : 'Sale';
     $this->manual = CoreLocal::get("paycard_keyed") === True ? 1 : 0;
     $this->live = 1;
     if (CoreLocal::get("training") != 0 || CoreLocal::get("CashierNo") == 9999) {
         $this->live = 0;
     }
     $this->cardholder = 'Cardholder';
 }
Exemple #21
0
 function check($str)
 {
     $this->ret = $this->default_json();
     if (substr($str, -2) == "DA") {
         $strl = substr($str, 0, strlen($str) - 2);
         if (substr($str, 0, 2) == "VD") {
             $this->ret = PrehLib::percentDiscount(0, $this->ret);
         } elseif (!is_numeric($strl)) {
             return false;
         } elseif (CoreLocal::get("tenderTotal") != 0) {
             $this->ret['output'] = DisplayLib::boxMsg(_("discount not applicable after tender"), '', false, DisplayLib::standardClearButton());
         } elseif ($strl > 50) {
             $this->ret['output'] = DisplayLib::boxMsg(_("discount exceeds maximum"), '', false, DisplayLib::standardClearButton());
         } elseif ($strl <= 0) {
             $this->ret['output'] = DisplayLib::boxMsg(_("discount must be greater than zero"), '', false, DisplayLib::standardClearButton());
         } elseif ($strl <= 50 and $strl > 0) {
             $this->ret = PrehLib::percentDiscount($strl, $this->ret);
             $this->ret['redraw_footer'] = true;
         } else {
             return false;
         }
         return true;
     }
     return false;
 }
Exemple #22
0
 public function normalize($db_name, $mode = BasicModel::NORMALIZE_MODE_CHECK, $doCreate = False)
 {
     if ($db_name == CoreLocal::get('pDatabase')) {
         $this->connection = Database::pDataConnect();
     } else {
         if ($db_name == CoreLocal::get('tDatabase')) {
             $this->connection = Database::tDataConnect();
         } else {
             echo "Error: Unknown database ({$db_name})";
             return false;
         }
     }
     $viewSQL = $this->connection->getViewDefinition($this->name);
     echo "==========================================\n";
     printf("%s view %s\n", $mode == BasicModel::NORMALIZE_MODE_CHECK ? "Checking" : "Updating", "{$db_name}.{$this->name}");
     echo "==========================================\n";
     if (strstr($viewSQL, '0 AS memType') || strstr($viewSQL, '0 AS ' . $this->connection->identifier_escape('memType'))) {
         /**
           Structure-check 27Dec2013
           Make sure memType is calcluated instead of hardcoded to zero
         */
         echo "==========================================\n";
         if ($mode == BasicModel::NORMALIZE_MODE_CHECK) {
             echo "View needs to be rebuild to calculate memType correctly\n";
         } else {
             echo "Rebuilding view to calculate memType correctly... ";
             $this->connection->query('DROP VIEW ' . $this->connection->identifier_escape($this->name));
             $success = $this->create();
             echo ($success ? 'succeeded' : 'failed') . "\n";
         }
     }
     return 0;
 }
Exemple #23
0
 function preprocess()
 {
     if (isset($_REQUEST["selectlist"])) {
         $input = $_REQUEST["selectlist"];
         if ($input == "CL") {
             CoreLocal::set("msgrepeat", 0);
             CoreLocal::set("strRemembered", "");
             CoreLocal::set("refundComment", "");
         } else {
             if ($input == "Other") {
                 return True;
             } else {
                 $input = str_replace("'", "", $input);
                 CoreLocal::set("strRemembered", CoreLocal::get("refundComment"));
                 // add comment calls additem(), which wipes
                 // out refundComment; save it
                 TransRecord::addcomment("PO: " . $input);
                 CoreLocal::set("refundComment", CoreLocal::get("strRemembered"));
                 CoreLocal::set("msgrepeat", 1);
                 //CoreLocal::set("refund",1);
             }
         }
         $this->change_page($this->page_url . "gui-modules/pos2.php");
         return False;
     }
     return True;
 }
Exemple #24
0
 /**
   Determine whether to open the drawer when
   a cashier signs out
   @return boolean
 */
 public function kickOnSignOut()
 {
     if (CoreLocal::get('training') == 1) {
         return false;
     }
     return true;
 }
Exemple #25
0
 function check($str)
 {
     $this->ret = $this->default_json();
     if (substr($str, -2) == "SD") {
         $strl = substr($str, 0, strlen($str) - 2);
         if (!is_numeric($strl)) {
             return False;
         } elseif (CoreLocal::get("tenderTotal") != 0) {
             $this->ret['output'] = DisplayLib::boxMsg(_("discount not applicable after tender"), '', false, DisplayLib::standardClearButton());
         } elseif ($strl > 50) {
             $this->ret['output'] = DisplayLib::boxMsg(_("discount exceeds maximum"), '', false, DisplayLib::standardClearButton());
         } elseif ($strl <= 0) {
             $this->ret['output'] = DisplayLib::boxMsg(_("discount must be greater than zero"), '', false, DisplayLib::standardClearButton());
         } elseif ($strl <= 50 and $strl > 0) {
             $existingPD = CoreLocal::get("percentDiscount");
             $stackablePD = $strl;
             $equivalentPD = $existingPD + $stackablePD;
             //    sum discounts
             $this->ret = PrehLib::percentDiscount($equivalentPD, $this->ret);
         } else {
             return false;
         }
         return true;
     }
     return false;
 }
Exemple #26
0
 protected function ajax()
 {
     $decision = strtoupper(FormLib::get('input', 'CL'));
     $ret = array('dest_page' => MiscLib::base_url() . 'gui-modules/pos2.php', 'endorse' => false, 'cleared' => false);
     $repeat_cmd = CoreLocal::get('strEntered');
     $requested_cmd = FormLib::get('cmd');
     if (!empty($requested_cmd)) {
         $repeat_cmd = $requested_cmd;
     }
     if ($decision == "CL") {
         CoreLocal::set("msgrepeat", 0);
         CoreLocal::set("lastRepeat", '');
         CoreLocal::set("toggletax", 0);
         CoreLocal::set("togglefoodstamp", 0);
         CoreLocal::set("RepeatAgain", false);
         $ret['cleared'] = true;
     } elseif (strlen($decision) > 0) {
         CoreLocal::set("msgrepeat", 1);
         CoreLocal::set("strRemembered", $repeat_cmd);
     } else {
         CoreLocal::set("msgrepeat", 1);
         CoreLocal::set("strRemembered", $repeat_cmd);
     }
     return $ret;
 }
Exemple #27
0
 function parse($str)
 {
     if ($str == "0ID") {
         // Member zero clears member info from the transaction
         PrehLib::clearMember();
         $ret = array("main_frame" => false, "output" => DisplayLib::lastpage(), "target" => ".baseHeight", "redraw_footer" => true);
         return $ret;
     } else {
         if (CoreLocal::get('RestrictDefaultNonMem') == 1 && $str == CoreLocal::get('defaultNonMem') . 'ID') {
             // PrehLib::ttl will automatically prompt for member if it
             // has not been entered; otherwise just total
             $ret = $this->default_json();
             $try = PrehLib::ttl();
             if ($try !== true) {
                 $ret['main_frame'] = $try . '?idSearch=' . CoreLocal::get('defaultNonMem');
             } else {
                 $ret['output'] = DisplayLib::lastpage();
             }
             return $ret;
         } else {
             // always re-apply other member numbers
             $ret = PrehLib::memberID(substr($str, 0, strlen($str) - 2));
             return $ret;
         }
     }
 }
Exemple #28
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;
 }
Exemple #29
0
 public function priceInfo($row, $quantity = 1)
 {
     if (is_array($this->savedInfo)) {
         return $this->savedInfo;
     }
     $ret = array();
     $ret["regPrice"] = $row['normal_price'];
     $ret["unitPrice"] = $row['special_price'];
     /* if not by weight, just use the sticker price 
           (for scaled items, the UPC parse module
           calculates a weight estimate and sets a quantity
           so normal_price can be used. This could be done
           for all items, but typically the deli doesn't
           keep good track of whether their items are
           marked scale correctly since it only matters when an
           item goes on sale
        */
     if (isset($row['stickerprice']) && $row['scale'] == 0) {
         $ret['regPrice'] = $row['stickerprice'];
     }
     $ret['discount'] = ($ret['regPrice'] - $row['special_price']) * $quantity;
     $ret['memDiscount'] = 0;
     if ($row['line_item_discountable'] == 1 && CoreLocal::get("itemPD") > 0) {
         $discount = $row['special_price'] * (CoreLocal::get("itemPD") / 100);
         $ret["unitPrice"] = $row['special_price'] - $discount;
         $ret["discount"] += $discount * $quantity;
     }
     // enforce per-transaction limit
     if ($row['specialpricemethod'] == 0 && $row['specialquantity'] > 0) {
         $tdb = Database::tDataConnect();
         $chkQ = "SELECT sum(ItemQtty) FROM\n                localtemptrans WHERE upc='{$row['upc']}'";
         if (strlen($row['mixmatchcode']) > 0 && $row['mixmatchcode'][0] == 'b') {
             $chkQ .= " OR mixMatch='{$row['mixmatchcode']}'";
         }
         $chkR = $tdb->query($chkQ);
         $prevSales = 0;
         if ($tdb->num_rows($chkR) > 0) {
             $prevSales = array_pop($tdb->fetch_row($chkR));
         }
         if ($prevSales >= $row['specialquantity']) {
             // already sold the limit; use non-sale price
             $ret['unitPrice'] = $row['normal_price'];
             $ret['discount'] = 0;
         } else {
             if ($prevSales + $quantity > $row['specialquantity']) {
                 // this multiple qty ring will pass the limit
                 // set discount based on appropriate quantity
                 // and adjust unitPrice so total comes out correctly
                 $discountQty = $row['specialquantity'] - $prevSales;
                 $ret['discount'] = ($ret['regPrice'] - $row['special_price']) * $discountQty;
                 $total = $ret['regPrice'] * $quantity - $ret['discount'];
                 $ret['unitPrice'] = MiscLib::truncate2($total / $quantity);
             }
         }
     }
     $this->savedRow = $row;
     $this->savedInfo = $ret;
     return $ret;
 }
Exemple #30
0
 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;
 }