Ejemplo n.º 1
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;
 }
Ejemplo n.º 2
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;
 }
Ejemplo n.º 3
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;
 }
Ejemplo n.º 4
0
 /**
   React to missing item
   @param $upc [string] UPC value
   @param $json [keyed array] formatted return value
   @return [keyed array] formatted return value
   
   The $json parameter and return value have the
   same format as Parser since this module interacts
   with input parsing. 
 */
 public function handle($upc, $json)
 {
     $opts = array('upc' => $upc, 'description' => 'BADSCAN');
     TransRecord::add_log_record($opts);
     $json['output'] = DisplayLib::boxMsg(_('not a valid item'), _('UPC: ') . $upc, false, DisplayLib::standardClearButton());
     return $json;
 }
Ejemplo n.º 5
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;
 }
Ejemplo n.º 6
0
 public function parse($str)
 {
     $ret = $this->default_json();
     if (CoreLocal::get('memberID') == '0') {
         $ret['output'] = DisplayLib::boxMsg(_("Apply member number first"), _('No member selected'), false, array_merge(array('Member Search [ID]' => 'parseWrapper(\'ID\');'), DisplayLib::standardClearButton()));
         return $ret;
     }
     if ($str == 'ACCESS') {
         if (CoreLocal::get('AccessQuickMenu') != '' && class_exists('QuickMenuLauncher')) {
             $qm = new QuickMenuLauncher();
             return $qm->parse('QM' . CoreLocal::get('AccessQuickMenu'));
         } else {
             $str = 'ACCESS0';
         }
     }
     if ($str !== 'ACCESS6' && CoreLocal::get('AccessSelection') === '') {
         CoreLocal::set('AccessSelection', $str);
         $ret['main_frame'] = MiscLib::baseURL() . 'gui-modules/adminlogin.php?class=AccessProgramParser';
         return $ret;
     } else {
         CoreLocal::set('AccessSelection', '');
     }
     $selection = substr($str, 6);
     TransRecord::addRecord(array('upc' => 'ACCESS', 'description' => 'ACCESS SIGNUP', 'quantity' => 1, 'ItemQtty' => 1, 'numflag' => $selection));
     $ret['output'] = DisplayLib::lastpage();
     $ret['receipt'] = 'accessSignupSlip';
     return $ret;
 }
Ejemplo n.º 7
0
 /**
   Input processing function
 */
 function preprocess()
 {
     // a selection was made
     if (FormLib::get('comment') !== '') {
         if (FormLib::get('cleared') === '1') {
             $this->change_page($this->page_url . "gui-modules/pos2.php");
             return False;
         }
         $comment = str_replace("\r", '', FormLib::get('comment'));
         // remove trailing newline from double enter
         $comment = substr($comment, 0, strlen($comment) - 1);
         $lines = explode("\n", $comment);
         foreach ($lines as $line) {
             $line = trim($line);
             if (strlen($line) == 0) {
                 continue;
             } elseif (strlen($line) <= 30) {
                 TransRecord::addcomment($line);
             } else {
                 $wrap = wordwrap($line, 30, "\n", True);
                 $shorter_lines = explode("\n", $wrap);
                 foreach ($shorter_lines as $short_line) {
                     TransRecord::addcomment($short_line);
                 }
             }
         }
         $this->change_page($this->page_url . "gui-modules/pos2.php");
         return False;
     }
     return True;
 }
Ejemplo n.º 8
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;
 }
Ejemplo n.º 9
0
 function addItem($row, $quantity, $priceObj)
 {
     if ($quantity == 0) {
         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['discounttype'] > 0 ? 0 : $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;
 }
Ejemplo n.º 10
0
 public function addDiscountLine()
 {
     if (CoreLocal::get("isMember") == 1 || CoreLocal::get("memberID") == CoreLocal::get("visitingMem")) {
         TransRecord::adddiscount($this->savedInfo['memDiscount'], $this->savedRow['department']);
     }
     if ($this->savedInfo['discount'] != 0) {
         TransRecord::adddiscount($this->savedInfo['discount'], $this->savedRow['department']);
     }
 }
Ejemplo n.º 11
0
 public function apply()
 {
     if ($this->card_no === false) {
         return true;
     }
     if (!empty($this->message)) {
         TransRecord::addcomment('Tax Ex ID# ' . $this->message);
     }
     TransRecord::addTaxExempt();
     return true;
 }
Ejemplo n.º 12
0
 /**
   Apply action
   @return [boolean] true if the action
     completes successfully (or is not
     necessary at all) or [string] url
     to redirect to another page for
     further decisions/input.
 */
 public function apply()
 {
     $db = Database::pDataConnect();
     $repeat = CoreLocal::get('msgrepeat');
     $coupons = array();
     $hc_table = $db->table_definition('houseCoupons');
     if ($db->table_exists('autoCoupons')) {
         $autoR = $db->query('SELECT coupID, description FROM autoCoupons');
         while ($autoW = $db->fetch_row($autoR)) {
             $coupons[$autoW['coupID']] = $autoW['description'];
         }
     }
     if (isset($hc_table['description']) && isset($hc_table['auto'])) {
         $autoR = $db->query('SELECT coupID, description FROM houseCoupons WHERE auto=1');
         while ($autoW = $db->fetch_row($autoR)) {
             $coupons[$autoW['coupID']] = $autoW['description'];
         }
     }
     $hc = new HouseCoupon();
     $prefix = CoreLocal::get('houseCouponPrefix');
     if ($prefix == '') {
         $prefix = '00499999';
     }
     foreach ($coupons as $id => $description) {
         if ($hc->checkQualifications($id, true) !== true) {
             // member or transaction does not meet requirements
             // for auto-coupon purposes, this isn't really an
             // error. no feedback necessary
             continue;
         }
         // get value of coupon AND value
         // of any previous applications of this coupon
         $add = $hc->getValue($id);
         $upc = $prefix . str_pad($id, 5, '0', STR_PAD_LEFT);
         $upc = str_pad($upc, 13, '0', STR_PAD_LEFT);
         $current = $db->query('SELECT SUM(-total) AS ttl FROM ' . CoreLocal::get('tDatabase') . $db->sep() . 'localtemptrans
                        WHERE upc=\'' . $upc . '\'');
         $val = 0;
         if ($db->num_rows($current) > 0) {
             $currentW = $db->fetch_row($current);
             $val = $currentW['ttl'];
         }
         $next_val = $add['value'] - $val;
         if ($next_val == 0) {
             // no need to add another line item
             // previous one(s) sum to correct total
             continue;
         }
         TransRecord::addhousecoupon($upc, $add['department'], -1 * $next_val, $description);
     }
     CoreLocal::set('msgrepeat', $repeat);
     return true;
 }
Ejemplo n.º 13
0
 function parse($str)
 {
     $ret = $this->default_json();
     if (strlen($str) > 2) {
         $comment = substr($str, 2);
         TransRecord::addcomment($comment);
         $ret['output'] = DisplayLib::lastpage();
     } else {
         $ret['main_frame'] = MiscLib::base_url() . 'gui-modules/bigComment.php';
     }
     return $ret;
 }
Ejemplo n.º 14
0
 function parse($str)
 {
     $ret = $this->default_json();
     switch (strtoupper($str)) {
         case 'PLU':
             TransRecord::add_log_record(array('upc' => 'PLU', 'description' => 'MISKEY'));
             CoreLocal::set('plainmsg', 'PLU logged');
             $ret['main_frame'] = MiscLib::base_url() . 'gui-modules/pos2.php';
             $ret['udpmsg'] = 'goodBeep';
             break;
     }
     return $ret;
 }
Ejemplo n.º 15
0
 function parse($str)
 {
     $ret = $this->default_json();
     $query = "select upc,description,VolSpecial,quantity,\n            total,discount,memDiscount,discountable,\n            unitPrice,scale,foodstamp,voided,discounttype,\n            trans_type,trans_status,department,regPrice,\n            tax,volume,volDiscType\n            from localtemptrans where \n            trans_id = " . CoreLocal::get("currentid");
     $connection = Database::tDataConnect();
     $result = $connection->query($query);
     $num_rows = $connection->num_rows($result);
     if ($num_rows > 0) {
         $row = $connection->fetch_array($result);
         $strUPC = $row["upc"];
         $strDescription = $row["description"];
         $dblVolSpecial = $row["VolSpecial"];
         $dblquantity = -0.5 * $row["quantity"];
         $dblTotal = MiscLib::truncate2(-1 * 0.5 * $row["total"]);
         // invoked truncate2 rounding function to fix half-penny errors apbw 3/7/05
         $strCardNo = CoreLocal::get("memberID");
         $dblDiscount = $row["discount"];
         $dblmemDiscount = $row["memDiscount"];
         $intDiscountable = $row["discountable"];
         $dblUnitPrice = $row["unitPrice"];
         $intScale = MiscLib::nullwrap($row["scale"]);
         if ($row["foodstamp"] != 0) {
             $intFoodStamp = 1;
         } else {
             $intFoodStamp = 0;
         }
         $intdiscounttype = MiscLib::nullwrap($row["discounttype"]);
         if ($row["voided"] == 20) {
             $ret['output'] = DisplayLib::boxMsg(_("Discount already taken"), '', false, DisplayLib::standardClearButton());
         } elseif ($row["trans_type"] == "T" or $row["trans_status"] == "D" or $row["trans_status"] == "V" or $row["trans_status"] == "C") {
             $ret['output'] = DisplayLib::boxMsg(_("Item cannot be discounted"), '', false, DisplayLib::standardClearButton());
         } elseif (strncasecmp($strDescription, "Club Card", 9) == 0) {
             //----- edited by abpw 2/15/05 -----
             $ret['output'] = DisplayLib::boxMsg(_("Item cannot be discounted"), '', false, DisplayLib::standardClearButton());
         } elseif (CoreLocal::get("tenderTotal") < 0 and $intFoodStamp == 1 and -1 * $dblTotal > CoreLocal::get("fsEligible")) {
             $ret['output'] = DisplayLib::boxMsg(_("Item already paid for"), '', false, DisplayLib::standardClearButton());
         } elseif (CoreLocal::get("tenderTotal") < 0 and -1 * $dblTotal > CoreLocal::get("runningTotal") - CoreLocal::get("taxTotal")) {
             $ret['output'] = DisplayLib::boxMsg(_("Item already paid for"), '', false, DisplayLib::standardClearButton());
         } else {
             // --- added partial item desc to club card description - apbw 2/15/05 ---
             TransRecord::addRecord(array('upc' => $strUPC, 'description' => "Club Card: " . substr($strDescription, 0, 19), 'trans_type' => "I", 'trans_status' => "J", 'department' => $row["department"], 'quantity' => $dblquantity, 'unitPrice' => $dblUnitPrice, 'total' => $dblTotal, 'regPrice' => 0.5 * $row["regPrice"], 'scale' => $intScale, 'tax' => $row["tax"], 'foodstamp' => $intFoodStamp, 'discount' => $dblDiscount, 'memDiscount' => $dblmemDiscount, 'discountable' => $intDiscountable, 'discounttype' => $intdiscounttype, 'ItemQtty' => $dblquantity, 'volDiscType' => $row["volDiscType"], 'volume' => $row["volume"], 'VolSpecial' => $dblVolSpecial));
             $update = "update localtemptrans set voided = 20 where trans_id = " . CoreLocal::get("currentid");
             $connection = Database::tDataConnect();
             $connection->query($update);
             CoreLocal::set("TTLflag", 0);
             CoreLocal::set("TTLRequested", 0);
             $ret['output'] = DisplayLib::lastpage();
         }
     }
     return $ret;
 }
Ejemplo n.º 16
0
 function parse($str)
 {
     Database::getsubtotals();
     $amt = CoreLocal::get('runningTotal') - CoreLocal::get('transDiscount');
     $madCoup = number_format($amt * 0.05, 2);
     if ($madCoup > 2.5) {
         $madCoup = 2.5;
     }
     TransRecord::addRecord(array('upc' => "MAD Coupon", 'description' => "Member Appreciation Coupon", 'trans_type' => "I", 'trans_subtype' => "CP", 'trans_status' => "C", 'quantity' => 1, 'ItemQtty' => 1, 'unitPrice' => -1 * $madCoup, 'total' => -1 * $madCoup, 'regPrice' => -1 * $madCoup, 'voided' => 17));
     $ret = $this->default_json();
     $ret['output'] = DisplayLib::lastpage();
     $ret['redraw_footer'] = true;
     return $ret;
 }
Ejemplo n.º 17
0
 function parse($str)
 {
     $json = $this->default_json();
     CoreLocal::set("memberID", CoreLocal::get('defaultNonMem'));
     CoreLocal::set("memMsg", "End of Shift");
     TransRecord::addRecord(array('upc' => 'ENDOFSHIFT', 'description' => 'End of Shift', 'trans_type' => 'S'));
     Database::getsubtotals();
     $chk = self::ttl();
     if ($chk !== true) {
         $json['main_frame'] = $chk;
         return $json;
     }
     CoreLocal::set("runningtotal", CoreLocal::get("amtdue"));
     return PrehLib::tender("CA", CoreLocal::get("runningtotal") * 100);
 }
Ejemplo n.º 18
0
 function parse($str)
 {
     CoreLocal::set("msgrepeat", 0);
     CoreLocal::set("strendered", "");
     CoreLocal::set("strRemembered", "");
     CoreLocal::set("SNR", 0);
     // added by apbw 6/04/05 to correct voiding of refunded items
     CoreLocal::set("refund", 0);
     //CoreLocal::set("autoReprint",0);
     if (CoreLocal::get("tare") > 0) {
         TransRecord::addTare(0);
     }
     $ret = $this->default_json();
     $ret['main_frame'] = MiscLib::base_url() . "gui-modules/pos2.php";
     return $ret;
 }
Ejemplo n.º 19
0
 function parse($str)
 {
     $ret = $this->default_json();
     $left = substr($str, 0, strlen($str) - 2);
     if ($left == "") {
         $left = 1;
     }
     if (strlen($left) > 4) {
         $ret['output'] = DisplayLib::boxMsg(MiscLib::truncate2($left / 100) . _(" tare not supported"), _('Invalid Tare'), false, DisplayLib::standardClearButton());
     } elseif ($left / 100 > CoreLocal::get("weight") && CoreLocal::get("weight") > 0) {
         $ret['output'] = DisplayLib::boxMsg(_("Tare cannot be") . "<br />" . _("greater than item weight"), _('Excess Tare'), false, DisplayLib::standardClearButton());
     } else {
         TransRecord::addTare($left);
         $ret['output'] = DisplayLib::lastpage();
     }
     return $ret;
 }
Ejemplo n.º 20
0
 /**
   Apply action
   @return [boolean] true if the action
     completes successfully (or is not
     necessary at all) or [string] url
     to redirect to another page for
     further decisions/input.
 */
 public function apply()
 {
     // Is the before-tax total within range?
     if (CoreLocal::get("runningTotal") <= 4.0) {
         $totalBefore = CoreLocal::get("amtdue");
         $ret = Database::changeLttTaxCode("HST", "GST");
         if ($ret !== true) {
             TransRecord::addcomment("{$ret}");
         } else {
             Database::getsubtotals();
             $saved = $totalBefore - CoreLocal::get("amtdue");
             $comment = sprintf("OMTR OK. You saved: \$%.2f", $saved);
             TransRecord::addcomment("{$comment}");
         }
     } else {
         TransRecord::addcomment("Does NOT qualify for OMTR");
     }
     return true;
 }
Ejemplo n.º 21
0
 function parse($str)
 {
     $ret = $this->default_json();
     // this is the currently selected item
     $transID = CoreLocal::get("currentid");
     $row = PrehLib::peekItem(true, $transID);
     if ($row === false) {
         // this shouldn't happen unless there's some weird session problem
         $ret['output'] = DisplayLib::boxMsg(_("Item not found"), '', false, DisplayLib::standardClearButton());
     } else {
         if ($row['trans_type'] != 'I' && $row['trans_type'] != 'D') {
             // only items & open rings are discountable
             $ret['output'] = DisplayLib::boxMsg(_("Line is not discountable"), '', false, DisplayLib::standardClearButton());
         } elseif ($row['discounttype'] != 0) {
             // for simplicity, sale items cannot be discounted
             // this also prevents using this function more than
             // once on a single item
             $ret['output'] = DisplayLib::boxMsg(_("Item already discounted"), '', false, DisplayLib::standardClearButton());
         } else {
             // discount is simply the total times the
             //   non-member discount percentage
             // total is discounted immediately using
             //   the non-member percentage
             // memDiscount is the difference between total
             //   member discount and the non-member discount
             //   since the non-member discount is applied
             //   immediately
             // setting discounttype=2 makes the member discount
             //   apply when a [valid] member number is entered
             $discQ = sprintf("UPDATE localtemptrans SET\n                    discount=(regPrice * quantity * %f), \n                    total=(total-(regPrice*quantity*%f)),\n                    memDiscount=((regPrice*quantity*%f) - (regPrice*quantity*%f)),\n                    discounttype=2\n                    WHERE trans_id=%d", CoreLocal::get("LineItemDiscountNonMem"), CoreLocal::get("LineItemDiscountNonMem"), CoreLocal::get("LineItemDiscountMem"), CoreLocal::get("LineItemDiscountNonMem"), $transID);
             $dbc = Database::tDataConnect();
             $discR = $dbc->query($discQ);
             // add notification line for nonMem discount
             TransRecord::adddiscount($row['regPrice'] * $row['quantity'] * CoreLocal::get("LineItemDiscountNonMem"), $row['department']);
             // footer should be redrawn since savings and totals
             // have changed. Output is the list of items
             $ret['redraw_footer'] = true;
             $ret['output'] = DisplayLib::lastpage();
         }
     }
     return $ret;
 }
Ejemplo n.º 22
0
 public function handle($upc, $json)
 {
     $coupID = ltrim(substr($upc, -5), "0");
     $leadDigits = substr($upc, 3, 5);
     $qualified = $this->checkQualifications($coupID);
     if ($qualified !== true) {
         $json['output'] = $qualified;
         return $json;
     }
     $available = $this->checkLimits($coupID);
     if ($available !== true) {
         $json['output'] = $available;
         return $json;
     }
     $add = $this->getValue($coupID);
     TransRecord::addhousecoupon($upc, $add['department'], -1 * $add['value'], $add['description']);
     $json['output'] = DisplayLib::lastpage();
     $json['udpmsg'] = 'goodBeep';
     $json['redraw_footer'] = true;
     return $json;
 }
Ejemplo n.º 23
0
 function parse($str)
 {
     $ret = $this->default_json();
     if (substr($str, 0, 8) == 'DROPDROP') {
         // repeat cashier's input, if any
         if (strlen($str) > 8) {
             $json['retry'] = substr($str, 8);
         }
         // redraw right side of the screen
         $json['scale'] = true;
         return $ret;
     } else {
         // add drop record to transaction
         $amt = 0;
         if (substr($str, 0, 4) == 'DROP') {
             $amt = substr($str, 4);
         } else {
             $amt = substr($str, 0, strlen($str) - 4);
         }
         TransRecord::addRecord(array('upc' => 'CASHDROP', 'description' => 'CASHDROP', 'trans_type' => "L", 'trans_subtype' => 'CA', 'total' => $amt / 100.0));
         $ret['main_frame'] = MiscLib::base_url() . "gui-modules/pos2.php";
         return $ret;
     }
 }
Ejemplo n.º 24
0
 function addItem($row, $quantity, $priceObj)
 {
     if ($quantity == 0) {
         return false;
     }
     $pricing = $priceObj->priceInfo($row, $quantity);
     // enforce limit on discounting sale items
     $dsi = CoreLocal::get('DiscountableSaleItems');
     if ($dsi == 0 && $dsi !== '' && $priceObj->isSale()) {
         $row['discount'] = 0;
     }
     if ($priceObj->isSale()) {
         $disc = $pricing['unitPrice'] - $row['specialgroupprice'] / $row['specialquantity'];
         if ($priceObj->isMemberSale() || $priceObj->isStaffSale()) {
             $pricing['memDiscount'] = MiscLib::truncate2($disc * $quantity);
         } else {
             $pricing['discount'] = MiscLib::truncate2($disc * $quantity);
         }
     } else {
         $pricing['unitPrice'] = $row['groupprice'] / $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' => $priceObj->isSale() ? $row['specialpricemethod'] : $row['pricemethod'], 'volume' => $priceObj->isSale() ? $row['specialquantity'] : $row['quantity'], 'VolSpecial' => $priceObj->isSale() ? $row['specialgroupprice'] : $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;
 }
Ejemplo n.º 25
0
 function parse($str)
 {
     $ret = $this->default_json();
     if (strlen($str) == 4) {
         CoreLocal::set('qmInput', $str);
         $desc = $this->descriptions[$str];
         $opts = array($desc . ' (Steak)' => 'M', $desc . ' (Risotto)' => 'V', $desc . ' (Squash V)' => 'S');
         if ($str == 1041) {
             $opts[$desc . ' (Kids)'] = 'K';
         }
         CoreLocal::set('qmNumber', $opts);
         $plugin_info = new QuickMenus();
         $ret['main_frame'] = $plugin_info->pluginUrl() . '/QMDisplay.php';
         return $ret;
     } else {
         $flag = strtoupper($str[4]);
         $plu = substr($str, 0, 4);
         $price = $flag == 'K' ? 5.0 : 20.0;
         TransRecord::addRecord(array('upc' => str_pad($plu, 13, '0', STR_PAD_LEFT), 'description' => $this->descriptions[$plu] . ' (' . $flag . ')', 'trans_type' => 'I', 'department' => 235, 'quantity' => 1.0, 'ItemQtty' => 1.0, 'unitPrice' => $price, 'total' => $price, 'regPrice' => $price, 'charflag' => $flag));
         $ret['output'] = DisplayLib::lastpage();
         $ret['redraw_footer'] = True;
         return $ret;
     }
 }
Ejemplo n.º 26
0
 public function handle($upc, $json)
 {
     /**
       Adjust string index of pieces
       based on whether check digits
       have been included
     */
     $man_id_start = 3;
     $fam_start = 8;
     $val_start = 11;
     if ($this->ean && CoreLocal::get('EanIncludeCheckDigits') == 1 || !$this->ean && CoreLocal::get('UpcIncludeCheckDigits') == 1) {
         $man_id_start = 2;
         $fam_start = 9;
         $val_start = 10;
     }
     $man_id = substr($upc, $man_id_start, 5);
     $fam = substr($upc, $fam_start, 3);
     $val = substr($upc, $val_start, 2);
     $db = Database::pDataConnect();
     $query = "select Value,Qty from couponcodes where Code = '" . $val . "'";
     $result = $db->query($query);
     $num_rows = $db->num_rows($result);
     if ($num_rows == 0) {
         $json['output'] = DisplayLib::boxMsg(_("coupon type unknown") . "<br />" . _("enter coupon manually"), '', false, DisplayLib::standardClearButton());
         return $json;
     }
     $query2 = "SELECT reason, threshold FROM disableCoupon WHERE upc='{$upc}'";
     $result2 = $db->query($query2);
     if ($result2 && $db->num_rows($result2) > 0) {
         $row = $db->fetch_row($result2);
         if ($row['threshold'] <= 0) {
             $json['output'] = DisplayLib::boxMsg($row['reason'], _("coupon disabled"), false, DisplayLib::standardClearButton());
             return $json;
         } else {
             $transDB = Database::tDataConnect();
             $q = "SELECT SUM(quantity) FROM localtemptrans WHERE upc='{$upc}'";
             $r = $transDB->query($q);
             if ($transDB->num_rows($r) > 0) {
                 $w = $transDB->fetch_row($r);
                 $qty = $w[0];
                 if ($qty >= $row['threshold']) {
                     $json['output'] = DisplayLib::boxMsg(_('coupon already applied'), '', false, DisplayLib::standardClearButton());
                     return $json;
                 }
             }
         }
     }
     $row = $db->fetch_array($result);
     $value = $row["Value"];
     $qty = $row["Qty"];
     if ($fam == "992") {
         // 992 basically means blanket accept
         // Old method of asking cashier to assign a department
         // just creates confusion
         // Instead I just try to guess, otherwise use zero
         // (since that's what would happen anyway when the
         // confused cashier does a generic coupon tender)
         $value = MiscLib::truncate2($value);
         CoreLocal::set("couponupc", $upc);
         CoreLocal::set("couponamt", $value);
         $dept = 0;
         $db = Database::tDataConnect();
         // SQL strings are indexed starting w/ one instead of zero
         // hence $man_id_start+1
         $query = "select department from localtemptrans \n                WHERE substring(upc," . ($man_id_start + 1) . ",5)='{$man_id}' \n                GROUP BY department\n                ORDER BY count(*) desc";
         $result = $db->query($query);
         if ($db->num_rows($result) > 0) {
             $row = $db->fetch_row($result);
             $dept = $row['department'];
         }
         TransRecord::addCoupon($upc, $dept, $value);
         $json['output'] = DisplayLib::lastpage();
         return $json;
     }
     // validate coupon
     $db = Database::tDataConnect();
     $fam = substr($fam, 0, 2);
     /* the idea here is to track exactly which
                items in the transaction a coupon was 
                previously applied to
     
                SQL strings are indexed starting w/ one instead of zero
                hence $man_id_start+1
             */
     $query = "select max(t.unitPrice) as unitPrice,\n            max(t.department) as department,\n            max(t.ItemQtty) as itemQtty,\n            sum(case when c.quantity is null then 0 else c.quantity end) as couponQtty,\n            max(case when c.quantity is not null then 0 else t.foodstamp end) as foodstamp,\n            max(case when c.quantity is not null then 0 else t.tax end) as tax,\n            max(t.emp_no) as emp_no,\n            max(t.trans_no) as trans_no,\n            t.trans_id from\n            localtemptrans as t left join couponApplied as c\n            on t.emp_no=c.emp_no and t.trans_no=c.trans_no\n            and t.trans_id=c.trans_id\n            where (substring(t.upc," . ($man_id_start + 1) . ",5)='{$man_id}'";
     /* not right per the standard, but organic valley doesn't
      * provide consistent manufacturer ids in the same goddamn
      * coupon book */
     if ($this->ean) {
         $query .= " or substring(t.upc," . $man_id_start . ",5)='{$man_id}'";
     }
     $query .= ") and t.trans_status <> 'C'\n            group by t.trans_id\n            order by t.unitPrice desc";
     $result = $db->query($query);
     $num_rows = $db->num_rows($result);
     /* no item w/ matching manufacturer */
     if ($num_rows == 0) {
         $json['output'] = DisplayLib::boxMsg(_("product not found") . "<br />" . _("in transaction"), '', false, DisplayLib::standardClearButton());
         return $json;
     }
     /* count up per-item quantites that have not
        yet had a coupon applied to them */
     $available = array();
     $emp_no = $transno = $dept = $foodstamp = $tax = -1;
     $act_qty = 0;
     while ($row = $db->fetch_array($result)) {
         if ($row["itemQtty"] - $row["couponQtty"] > 0) {
             $id = $row["trans_id"];
             $available["{$id}"] = array(0, 0);
             $available["{$id}"][0] = $row["unitPrice"];
             $available["{$id}"][1] += $row["itemQtty"];
             $available["{$id}"][1] -= $row["couponQtty"];
             $act_qty += $available["{$id}"][1];
         }
         if ($emp_no == -1) {
             $emp_no = $row["emp_no"];
             $transno = $row["trans_no"];
             $dept = $row["department"];
             $foodstamp = $row["foodstamp"];
             $tax = $row['tax'];
         }
     }
     /* every line has maximum coupons applied */
     if (count($available) == 0) {
         $json['output'] = DisplayLib::boxMsg(_("Coupon already applied") . "<br />" . _("for this item"), '', false, DisplayLib::standardClearButton());
         return $json;
     }
     /* insufficient number of matching items */
     if ($qty > $act_qty) {
         $msg = sprintf(_("coupon requires %d items"), $qty) . "<br />" . sprintf(_("there are only %d item(s)"), $act_qty) . "<br />" . _("in this transaction");
         $json['output'] = DisplayLib::boxMsg($msg, '', false, DisplayLib::standardClearButton());
         return $json;
     }
     /* free item, multiple choices
        needs work, obviously */
     if ($value == 0 && count($available) > 1) {
         // decide which item(s)
         // manually by cashier maybe?
     }
     /* log the item(s) this coupon is
        being applied to */
     $applied = 0;
     foreach (array_keys($available) as $id) {
         if ($value == 0) {
             $value = -1 * $available["{$id}"][0];
         }
         if ($qty <= $available["{$id}"][1]) {
             $q = "INSERT INTO couponApplied \n                    (emp_no,trans_no,quantity,trans_id)\n                    VALUES (\n                    {$emp_no},{$transno},{$qty},{$id})";
             $r = $db->query($q);
             $applied += $qty;
         } else {
             $q = "INSERT INTO couponApplied \n                    (emp_no,trans_no,quantity,trans_id)\n                    VALUES (\n                    {$emp_no},{$transno}," . $available["{$id}"][1] . ",{$id})";
             $r = $db->query($q);
             $applied += $available["{$id}"][1];
         }
         if ($applied >= $qty) {
             break;
         }
     }
     $value = MiscLib::truncate2($value);
     $json['udpmsg'] = 'goodBeep';
     TransRecord::addCoupon($upc, $dept, $value, $foodstamp, $tax);
     $json['output'] = DisplayLib::lastpage();
     $json['redraw_footer'] = True;
     return $json;
 }
Ejemplo n.º 27
0
 public function cleanup($json)
 {
     switch (CoreLocal::get("paycard_mode")) {
         case PaycardLib::PAYCARD_MODE_BALANCE:
             $resp = CoreLocal::get("paycard_response");
             CoreLocal::set("boxMsg", "<b>Success</b><font size=-1>\n                                           <p>Gift card balance: \$" . $resp["Balance"] . "\n                                           <p>\"rp\" to print\n                                           <br>[enter] to continue</font>");
             break;
         case PaycardLib::PAYCARD_MODE_ADDVALUE:
         case PaycardLib::PAYCARD_MODE_ACTIVATE:
             CoreLocal::set("autoReprint", 1);
             $ttl = CoreLocal::get("paycard_amount");
             PrehLib::deptkey($ttl * 100, 9020);
             $resp = CoreLocal::get("paycard_response");
             CoreLocal::set("boxMsg", "<b>Success</b><font size=-1>\n                                           <p>New card balance: \$" . $resp["Balance"] . "\n                                           <p>[enter] to continue\n                                           <br>\"rp\" to reprint slip</font>");
             break;
         case PaycardLib::PAYCARD_MODE_AUTH:
             CoreLocal::set("autoReprint", 1);
             $record_id = $this->last_paycard_transaction_id;
             $charflag = $record_id != 0 ? 'PT' : '';
             TransRecord::addFlaggedTender("Gift Card", "GD", $amt, $record_id, $charflag);
             $resp = CoreLocal::get("paycard_response");
             CoreLocal::set("boxMsg", "<b>Approved</b><font size=-1>\n                                           <p>Used: \$" . CoreLocal::get("paycard_amount") . "\n                                           <br />New balance: \$" . $resp["Balance"] . "\n                                           <p>[enter] to continue\n                                           <br>\"rp\" to reprint slip\n                                           <br>[void] to cancel and void</font>");
             break;
         case PaycardLib::PAYCARD_MODE_VOID:
         case PaycardLib::PAYCARD_MODE_VOIDITEM:
             CoreLocal::set("autoReprint", 1);
             $v = new Void();
             $v->voidid(CoreLocal::get("paycard_id"), array());
             $resp = CoreLocal::get("paycard_response");
             CoreLocal::set("boxMsg", "<b>Voided</b><font size=-1>\n                                           <p>New balance: \$" . $resp["Balance"] . "\n                                           <p>[enter] to continue\n                                           <br>\"rp\" to reprint slip</font>");
             break;
     }
     return $json;
 }
Ejemplo n.º 28
0
 public function addDiscountLine()
 {
     if (isset($this->savedInfo) && $this->savedInfo['discount'] != 0) {
         TransRecord::adddiscount($this->savedInfo['discount'], $this->savedRow['department']);
     }
 }
Ejemplo n.º 29
0
 /**
   Add a percent discount notification
   @param $strl discount percentage
   @param $json keyed array
   @return An array see Parser::default_json()
   @deprecated
   Use discountnotify() instead. This just adds
   hard-coded percentages and PLUs that likely
   aren't applicable anywhere but the Wedge.
 */
 public static function percentDiscount($strl, $json = array())
 {
     if ($strl == 10.01) {
         $strl = 10;
     }
     if (!is_numeric($strl) || $strl > 100 || $strl < 0) {
         $json['output'] = DisplayLib::boxMsg(_("discount invalid"), '', false, DisplayLib::standardClearButton());
     } else {
         if ($strl != 0) {
             TransRecord::discountnotify($strl);
         }
         $dbc = Database::tDataConnect();
         $dbc->query("update localtemptrans set percentDiscount = " . $strl);
         $chk = self::ttl();
         if ($chk !== true) {
             $json['main_frame'] = $chk;
         }
         $json['output'] = DisplayLib::lastpage();
     }
     return $json;
 }
Ejemplo n.º 30
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");
}