Ejemplo n.º 1
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;
 }
Ejemplo n.º 2
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;
 }
Ejemplo n.º 3
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;
 }
Ejemplo n.º 4
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.º 5
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;
         }
     }
 }
Ejemplo n.º 6
0
 function preprocess()
 {
     $AR_department = '990';
     if (CoreLocal::get("store") == 'WEFC_Toronto') {
         $AR_department = '1005';
     }
     if (isset($_REQUEST['reginput'])) {
         $dec = $_REQUEST['reginput'];
         $amt = CoreLocal::get("old_ar_balance");
         CoreLocal::set("msgrepeat", 0);
         CoreLocal::set("strRemembered", "");
         if (strtoupper($dec) == "CL") {
             if (CoreLocal::get('memType') == 0) {
                 PrehLib::setMember(CoreLocal::get("defaultNonMem"), 1);
             }
             $this->change_page($this->page_url . "gui-modules/pos2.php");
             return False;
         } elseif ($dec == "" || strtoupper($dec) == "BQ") {
             if (strtoupper($dec) == "BQ") {
                 $amt = CoreLocal::get("balance");
             }
             CoreLocal::set("strRemembered", $amt * 100 . "DP{$AR_department}0");
             CoreLocal::set("msgrepeat", 1);
             $memtype = CoreLocal::get("memType");
             $type = CoreLocal::get("Type");
             if ($memtype == 1 || $memtype == 3 || $type == "INACT") {
                 CoreLocal::set("isMember", 1);
                 PrehLib::ttl();
             }
             $this->change_page($this->page_url . "gui-modules/pos2.php");
             return False;
         }
     }
     return True;
 }
Ejemplo n.º 7
0
 function parse($str)
 {
     $ret = $this->default_json();
     PrehLib::chargeOk();
     $memChargeCommitted = CoreLocal::get("availBal") - CoreLocal::get("memChargeTotal");
     $title = _('Member #') . CoreLocal::get('memberID');
     $msg = _("Current AR balance is ") . CoreLocal::get("balance") . "<br />" . _("Available AR balance is ") . CoreLocal::get("availBal");
     $ret['output'] = DisplayLib::boxMsg($msg, $title, true, array_merge(array('Tender [Store Credit]' => 'parseWrapper(\'MI\');'), DisplayLib::standardClearButton()));
     return $ret;
 }
Ejemplo n.º 8
0
 public function parse($str)
 {
     $my_url = MiscLib::base_url();
     $split = explode("DP", $str);
     $dept = $split[1];
     $amt = $split[0];
     if (strstr($amt, '.')) {
         $amt = round($amt * 100);
     }
     $ret = $this->default_json();
     /**
       This "if" is the new addition to trigger the
       department select screen
     */
     if (empty($split[1])) {
         // no department specified, just amount followed by DP
         // maintain refund if needed
         if (CoreLocal::get("refund")) {
             $amt = "RF" . $amt;
         }
         // save entered amount
         CoreLocal::set("departmentAmount", $amt);
         // go to the department select screen
         $ret['main_frame'] = $my_url . 'gui-modules/deptlist.php';
     } else {
         if (CoreLocal::get("refund") == 1 && CoreLocal::get("refundComment") == "") {
             if (CoreLocal::get("SecurityRefund") > 20) {
                 $ret['main_frame'] = $my_url . "gui-modules/adminlogin.php?class=RefundAdminLogin";
             } else {
                 $ret['main_frame'] = $my_url . 'gui-modules/refundComment.php';
             }
             CoreLocal::set("refundComment", CoreLocal::get("strEntered"));
         }
     }
     /* apply any appropriate special dept modules */
     $deptmods = CoreLocal::get('SpecialDeptMap');
     $db = Database::pDataConnect();
     if (!is_array($deptmods) && $db->table_exists('SpecialDeptMap')) {
         $model = new \COREPOS\pos\lib\models\op\SpecialDeptMapModel($db);
         $deptmods = $model->buildMap();
         CoreLocal::set('SpecialDeptMap', $deptmods);
     }
     $index = (int) ($dept / 10);
     if (is_array($deptmods) && isset($deptmods[$index])) {
         foreach ($deptmods[$index] as $mod) {
             $obj = new $mod();
             $ret = $obj->handle($dept, $amt / 100, $ret);
         }
     }
     if (!$ret['main_frame']) {
         $ret = PrehLib::deptkey($amt, $dept, $ret);
     }
     return $ret;
 }
Ejemplo n.º 9
0
 public static function adminLoginCallback($success)
 {
     if ($success) {
         CoreLocal::set('InactiveMemList', array());
         return true;
     } else {
         CoreLocal::set('InactiveMemList', array());
         PrehLib::clearMember();
         return false;
     }
 }
Ejemplo n.º 10
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()
 {
     $temp = PrehLib::chargeOk();
     if (CoreLocal::get("balance") < CoreLocal::get("memChargeTotal") && CoreLocal::get("memChargeTotal") > 0) {
         if (CoreLocal::get('msgrepeat') == 0) {
             CoreLocal::set("boxMsg", sprintf("<b>A/R Imbalance</b><br />\n                    Total AR payments \$%.2f exceeds AR balance %.2f<br />", CoreLocal::get("memChargeTotal"), CoreLocal::get("balance")));
             CoreLocal::set('boxMsgButtons', array('Confirm [enter]' => '$(\'#reginput\').val(\'\');submitWrapper();', 'Cancel [clear]' => '$(\'#reginput\').val(\'CL\');submitWrapper();'));
             CoreLocal::set("strEntered", "TL");
             return MiscLib::baseURL() . "gui-modules/boxMsg2.php?quiet=1";
         }
     }
     return true;
 }
Ejemplo n.º 11
0
 public function handle($upc, $json)
 {
     $db = Database::pDataConnect();
     $query = "select card_no from memberCards where upc='{$upc}'";
     $result = $db->query($query);
     if ($db->num_rows($result) < 1) {
         $json['output'] = DisplayLib::boxMsg(_("Card not assigned"), '', false, DisplayLib::standardClearButton());
         return $json;
     }
     $row = $db->fetch_array($result);
     CoreLocal::set("memberCardUsed", 1);
     $json = PrehLib::memberID($row[0]);
     return $json;
 }
Ejemplo n.º 12
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.º 13
0
 public function parse($str)
 {
     $multiplier = strlen($str) > 1 ? substr($str, 1) : 1;
     $peek = PrehLib::peekItem(true, CoreLocal::get('currentid'));
     $fp = fopen('/tmp/peek', 'a');
     if ($peek && $peek['trans_type'] == 'I' && $peek['trans_status'] == '') {
         $upcP = new UPC();
         CoreLocal::set('quantity', $multiplier);
         CoreLocal::set('multiple', 1);
         $ret = $upcP->parse($peek['upc']);
         return $ret;
     } else {
         $json = $this->default_json();
         $json['output'] = DisplayLib::boxMsg(_('product cannot be repeated'), _('Ineligible line'), false, DisplayLib::standardClearButton());
         return $json;
     }
 }
Ejemplo n.º 14
0
 function parse($str)
 {
     $ret = $this->default_json();
     // Sets $balance and $availBal.
     $chargeOk = PrehLib::chargeOk();
     // $memChargeCommitted isn't used here.
     $memChargeCommitted = CoreLocal::get("availBal") - CoreLocal::get("memChargeTotal");
     $message = "<p style='font-weight:bold; text-align:center; margin: 0em 0em 0em -1.0em;'>" . _("Member") . " #" . CoreLocal::get("memberID") . "<br />";
     if ($chargeOk) {
         $message .= _("Available Coop Cred") . "<br />" . _("Balance is:") . "<br />" . "<span style='font-size:1.4em;'>" . " " . CoreLocal::get("availBal") . "</span>";
     } else {
         $message .= _("Is not authorized to use") . "<br />" . _("Coop Cred");
     }
     $message .= "</p>";
     $ret['output'] = DisplayLib::boxMsg("{$message}", "", True);
     return $ret;
 }
Ejemplo n.º 15
0
 /**
   Check for errors
   @return True or an error message string
 */
 public function errorCheck()
 {
     $charge_ok = PrehLib::chargeOk();
     $buttons = array('[clear]' => 'parseWrapper(\'CL\');');
     if ($charge_ok == 0) {
         return DisplayLib::boxMsg(_("member") . ' ' . CoreLocal::get("memberID") . '<br />' . _("is not authorized") . '<br />' . _("to make charges"), 'Not Allowed', false, $buttons);
     } else {
         if (CoreLocal::get("availBal") < 0) {
             return DisplayLib::boxMsg(_("member") . ' ' . CoreLocal::get("memberID") . '<br />' . _("is over limit"), 'Over Limit', false, $buttons);
         } elseif (abs(CoreLocal::get("memChargeTotal")) + $this->amount >= CoreLocal::get("availBal") + 0.005) {
             $memChargeRemain = CoreLocal::get("availBal");
             $memChargeCommitted = $memChargeRemain + CoreLocal::get("memChargeTotal");
             return DisplayLib::xboxMsg(_("available balance for charge") . '<br />' . _("is only \$") . $memChargeCommitted, $buttons);
         } elseif (MiscLib::truncate2(CoreLocal::get("amtdue")) < MiscLib::truncate2($this->amount)) {
             return DisplayLib::xboxMsg(_("charge tender exceeds purchase amount"), $buttons);
         }
     }
     return true;
 }
Ejemplo n.º 16
0
 function parse($str)
 {
     $dept = CoreLocal::get('roundUpDept');
     if ($dept === '') {
         $dept = 701;
     }
     $ret = $this->default_json();
     if ($str == "RU") {
         Database::getsubtotals();
         $ttl = CoreLocal::get("amtdue");
         $next = ceil($ttl);
         $amt = sprintf('%.2f', $ttl == $next ? 1.0 : $next - $ttl);
         $ret = PrehLib::deptkey($amt * 100, $dept . '0', $ret);
     } else {
         $amt = substr($str, 0, strlen($str) - 2);
         $ret = PrehLib::deptkey($amt, $dept . '0', $ret);
     }
     return $ret;
 }
Ejemplo n.º 17
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.º 18
0
 function parse($str)
 {
     $my_url = MiscLib::base_url();
     $split = explode("CQ", $str);
     $tender = $split[1];
     $amt = $split[0];
     $ret = $this->default_json();
     /**
       This "if" is the new addition to trigger the
       department select screen
     */
     if (empty($split[1])) {
         // no department specified, just amount followed by DP
         // save entered amount
         CoreLocal::set("tenderTotal", $amt);
         // go to the department select screen
         $ret['main_frame'] = $my_url . 'gui-modules/checklist.php';
     }
     if (!$ret['main_frame']) {
         $ret = PrehLib::tender($split[1], $split[0]);
     }
     return $ret;
 }
Ejemplo n.º 19
0
 private function addDeposit($upc)
 {
     $upc = str_pad($upc, 13, '0', STR_PAD_LEFT);
     $db = Database::pDataConnect();
     $query = "select description,scale,tax,foodstamp,discounttype,\n            discount,department,normal_price\n                   from products where upc='" . $upc . "'";
     $result = $db->query($query);
     if ($db->num_rows($result) <= 0) {
         return;
     }
     $row = $db->fetch_array($result);
     $description = $row["description"];
     $description = str_replace("'", "", $description);
     $description = str_replace(",", "", $description);
     $scale = 0;
     if ($row["scale"] != 0) {
         $scale = 1;
     }
     list($tax, $foodstamp, $discountable) = PrehLib::applyToggles($row['tax'], $row['foodstamp'], $row['discount']);
     $discounttype = MiscLib::nullwrap($row["discounttype"]);
     $quantity = 1;
     if (CoreLocal::get("quantity") != 0) {
         $quantity = CoreLocal::get("quantity");
     }
     $save_refund = CoreLocal::get("refund");
     TransRecord::addRecord(array('upc' => $upc, 'description' => $description, 'trans_type' => 'I', 'trans_subtype' => 'AD', 'department' => $row['department'], 'quantity' => $quantity, 'ItemQtty' => $quantity, 'unitPrice' => $row['normal_price'], 'total' => $quantity * $row['normal_price'], 'regPrice' => $row['normal_price'], 'scale' => $scale, 'tax' => $tax, 'foodstamp' => $foodstamp, 'discountable' => $discountable, 'discounttype' => $discounttype));
     CoreLocal::set("refund", $save_refund);
 }
Ejemplo n.º 20
0
 public function testScreenDisplay()
 {
     lttLib::clear();
     $u = new UPC();
     $u->check('666');
     $u->parse('666');
     $records = DisplayLib::screenDisplay(0, 1);
     $item = array('description' => 'EXTRA BAG', 'comment' => '', 'total' => 0.05, 'status' => 'T', 'lineColor' => '004080', 'discounttype' => 0, 'trans_type' => 'I', 'trans_status' => '', 'voided' => 0, 'trans_id' => 1);
     $spec = array(1 => $item);
     $this->assertEquals(count($records), count($spec));
     $view = $this->getViewVersion(0, 2);
     foreach (array_keys($records) as $i) {
         $this->assertArrayHasKey($i, $records);
         $this->assertArrayHasKey($i, $spec);
         $this->compareArrays($records[$i], $spec[$i]);
         $this->compareArrays($records[$i], $view[$i]);
     }
     $t = new TenderModule('CA', 1.0);
     $t->add();
     $tender = array('description' => '', 'comment' => 'Cash', 'total' => -1.0, 'status' => '', 'lineColor' => '800000', 'discounttype' => 0, 'trans_type' => 'T', 'trans_status' => '', 'voided' => 0, 'trans_id' => 2);
     $spec[2] = $tender;
     $records = DisplayLib::screenDisplay(0, 2);
     $view = $this->getViewVersion(0, 2);
     $this->assertEquals(count($records), count($spec));
     foreach (array_keys($records) as $i) {
         $this->assertArrayHasKey($i, $records);
         $this->assertArrayHasKey($i, $spec);
         $this->compareArrays($records[$i], $spec[$i]);
         $this->compareArrays($records[$i], $view[$i]);
     }
     CoreLocal::set('memberID', 1);
     CoreLocal::set('isMember', 1);
     CoreLocal::set('percentDiscount', 10);
     CoreLocal::set('memType', 1);
     PrehLib::ttl();
     $notify = array('description' => '** 10% Discount Applied **', 'comment' => '', 'total' => '', 'status' => '', 'lineColor' => '408080', 'discounttype' => 0, 'trans_type' => '0', 'trans_status' => 'D', 'voided' => 4, 'trans_id' => 3);
     $discount = array('description' => '', 'comment' => 'Discount', 'total' => 0.0, 'status' => '', 'lineColor' => '408080', 'discounttype' => 0, 'trans_type' => 'C', 'trans_status' => 'D', 'voided' => 5, 'trans_id' => 4);
     $subtotal = array('description' => 'Subtotal -0.95, Tax0.00 #1', 'comment' => 'Total ', 'total' => -0.95, 'status' => '', 'lineColor' => '000000', 'discounttype' => 0, 'trans_type' => 'C', 'trans_status' => 'D', 'voided' => 3, 'trans_id' => 5);
     $spec[3] = $notify;
     $spec[4] = $discount;
     $spec[5] = $subtotal;
     $records = DisplayLib::screenDisplay(0, 5);
     $view = $this->getViewVersion(0, 5);
     $this->assertEquals(count($records), count($spec));
     foreach (array_keys($records) as $i) {
         $this->assertArrayHasKey($i, $records);
         $this->assertArrayHasKey($i, $spec);
         $this->compareArrays($records[$i], $spec[$i]);
         $this->compareArrays($records[$i], $view[$i]);
     }
     CoreLocal::set('quantity', 2);
     CoreLocal::set('multiple', 1);
     $u = new UPC();
     $u->check('4627');
     $u->parse('4627');
     $item = array('description' => 'PKALE', 'comment' => '2 @ 1.99', 'total' => 3.98, 'status' => 'F', 'lineColor' => '408080', 'discounttype' => 1, 'trans_type' => 'I', 'trans_status' => '', 'voided' => 0, 'trans_id' => 6);
     $notice = array('description' => '** YOU SAVED $0.60 **', 'comment' => '', 'total' => '', 'status' => '', 'lineColor' => '408080', 'discounttype' => 0, 'trans_type' => 'I', 'trans_status' => 'D', 'voided' => 2, 'trans_id' => 7);
     $spec[6] = $item;
     $spec[7] = $notice;
     $records = DisplayLib::screenDisplay(0, 7);
     $view = $this->getViewVersion(0, 7);
     $this->assertEquals(count($records), count($spec));
     foreach (array_keys($records) as $i) {
         $this->assertArrayHasKey($i, $records);
         $this->assertArrayHasKey($i, $spec);
         $this->compareArrays($records[$i], $spec[$i]);
         $this->compareArrays($records[$i], $view[$i]);
     }
     CoreLocal::set('quantity', 0);
     CoreLocal::set('multiple', 0);
     CoreLocal::set('currentid', 1);
     $v = new Void();
     $v->check('VD');
     $v->parse('VD');
     $void = array('description' => 'EXTRA BAG', 'comment' => '', 'total' => -0.05, 'status' => 'VD', 'lineColor' => '800000', 'discounttype' => 0, 'trans_type' => 'I', 'trans_status' => 'V', 'voided' => 1, 'trans_id' => 8);
     $spec[8] = $void;
     $spec[1]['voided'] = 1;
     $records = DisplayLib::screenDisplay(0, 8);
     $view = $this->getViewVersion(0, 8);
     $this->assertEquals(count($records), count($spec));
     foreach (array_keys($records) as $i) {
         $this->assertArrayHasKey($i, $records);
         $this->assertArrayHasKey($i, $spec);
         $this->compareArrays($records[$i], $spec[$i]);
         $this->compareArrays($records[$i], $view[$i]);
     }
     TransRecord::addFsTaxExempt();
     $fs = array('description' => '', 'comment' => 'FS Tax Exempt', 'total' => 0.0, 'status' => '', 'lineColor' => '800000', 'discounttype' => 0, 'trans_type' => 'C', 'trans_status' => 'D', 'voided' => 17, 'trans_id' => 9);
     $spec[9] = $fs;
     $records = DisplayLib::screenDisplay(0, 9);
     $view = $this->getViewVersion(0, 9);
     $this->assertEquals(count($records), count($spec));
     foreach (array_keys($records) as $i) {
         $this->assertArrayHasKey($i, $records);
         $this->assertArrayHasKey($i, $spec);
         $this->compareArrays($records[$i], $spec[$i]);
         $this->compareArrays($records[$i], $view[$i]);
         $this->compareArrays($spec[$i], $view[$i]);
     }
     CoreState::memberReset();
     lttLib::clear();
 }
Ejemplo n.º 21
0
 function preprocess()
 {
     $this->box_color = "coloredArea";
     $this->msg = "Undo transaction";
     if (isset($_REQUEST['reginput'])) {
         $trans_num = strtoupper($_REQUEST['reginput']);
         // clear/cancel undo attempt
         if ($trans_num == "" || $trans_num == "CL") {
             $this->change_page($this->page_url . "gui-modules/pos2.php");
             return False;
         }
         // error: malformed transaction number
         if (!strpos($trans_num, "-")) {
             $this->box_color = "errorColoredArea";
             $this->msg = "Transaction not found";
             return True;
         }
         $temp = explode("-", $trans_num);
         // error: malformed transaction number (2)
         if (count($temp) != 3) {
             $this->box_color = "errorColoredArea";
             $this->msg = "Transaction not found";
             return True;
         }
         $emp_no = $temp[0];
         $register_no = $temp[1];
         $old_trans_no = $temp[2];
         // error: malformed transaction number (3)
         if (!is_numeric($emp_no) || !is_numeric($register_no) || !is_numeric($old_trans_no)) {
             $this->box_color = "errorColoredArea";
             $this->msg = "Transaction not found";
             return True;
         }
         $db = 0;
         $query = "";
         if ($register_no == CoreLocal::get("laneno")) {
             // look up transation locally
             $db = Database::tDataConnect();
             $query = "select upc, description, trans_type, trans_subtype,\n                    trans_status, department, quantity, scale, unitPrice,\n                    total, regPrice, tax, foodstamp, discount, memDiscount,\n                    discountable, discounttype, voided, PercentDiscount,\n                    ItemQtty, volDiscType, volume, VolSpecial, mixMatch,\n                    matched, card_no, trans_id\n                    from localtranstoday where register_no = {$register_no}\n                    and emp_no = {$emp_no} and trans_no = {$old_trans_no}\n                    and datetime >= " . $db->curdate() . "\n                    and trans_status <> 'X'\n                    order by trans_id";
         } else {
             if (CoreLocal::get("standalone") == 1) {
                 // error: remote lookups won't work in standalone
                 $this->box_color = "errorColoredArea";
                 $this->msg = "Transaction not found";
                 return True;
             } else {
                 // look up transaction remotely
                 $db = Database::mDataConnect();
                 $query = "select upc, description, trans_type, trans_subtype,\n                    trans_status, department, quantity, scale, unitPrice,\n                    total, regPrice, tax, foodstamp, discount, memDiscount,\n                    discountable, discounttype, voided, PercentDiscount,\n                    ItemQtty, volDiscType, volume, VolSpecial, mixMatch,\n                    matched, card_no, trans_id\n                    from dtransactions where register_no = {$register_no}\n                    and emp_no = {$emp_no} and trans_no = {$old_trans_no}\n                    and datetime >= " . $db->curdate() . "\n                    and trans_status <> 'X'\n                    order by trans_id";
             }
         }
         $result = $db->query($query);
         // transaction not found
         if ($db->num_rows($result) < 1) {
             $this->box_color = "errorColoredArea";
             $this->msg = "Transaction not found";
             return True;
         }
         /* change the cashier to the original transaction's cashier */
         $prevCashier = CoreLocal::get("CashierNo");
         CoreLocal::set("CashierNo", $emp_no);
         CoreLocal::set("transno", Database::gettransno($emp_no));
         /* rebuild the transaction, line by line, in reverse */
         $card_no = 0;
         TransRecord::addcomment("VOIDING TRANSACTION {$trans_num}");
         while ($row = $db->fetch_array($result)) {
             $card_no = $row["card_no"];
             if ($row["upc"] == "TAX") {
                 //TransRecord::addtax();
             } elseif ($row["trans_type"] == "T") {
                 if ($row["description"] == "Change") {
                     TransRecord::addchange(-1 * $row["total"]);
                 } elseif ($row["description"] == "FS Change") {
                     TransRecord::addfsones(-1 * $row["total"]);
                 } else {
                     TransRecord::addtender($row["description"], $row["trans_subtype"], -1 * $row["total"]);
                 }
             } elseif (strstr($row["description"], "** YOU SAVED")) {
                 $temp = explode("\$", $row["description"]);
                 TransRecord::adddiscount(substr($temp[1], 0, -3), $row["department"]);
             } elseif ($row["upc"] == "FS Tax Exempt") {
                 TransRecord::addfsTaxExempt();
             } elseif (strstr($row["description"], "% Discount Applied")) {
                 $temp = explode("%", $row["description"]);
                 TransRecord::discountnotify(substr($temp[0], 3));
             } elseif ($row["description"] == "** Order is Tax Exempt **") {
                 TransRecord::addTaxExempt();
             } elseif ($row["description"] == "** Tax Excemption Reversed **") {
                 TransRecord::reverseTaxExempt();
             } elseif ($row["description"] == " * Manufacturers Coupon") {
                 TransRecord::addCoupon($row["upc"], $row["department"], -1 * $row["total"]);
             } elseif (strstr($row["description"], "** Tare Weight")) {
                 $temp = explode(" ", $row["description"]);
                 TransRecord::addTare($temp[3] * 100);
             } elseif ($row["upc"] == "DISCOUNT") {
                 //TransRecord::addTransDiscount();
             } elseif ($row["trans_status"] != "M" && $row["upc"] != "0" && (is_numeric($row["upc"]) || strstr($row["upc"], "DP"))) {
                 $row["trans_status"] = "V";
                 $row["total"] *= -1;
                 $row["discount"] *= -1;
                 $row["memDiscount"] *= -1;
                 $row["quantity"] *= -1;
                 $row["ItemQtty"] *= -1;
                 TransRecord::addRecord($row);
             }
         }
         PrehLib::setMember($card_no, 1);
         CoreLocal::set("autoReprint", 0);
         /* do NOT restore logged in cashier until this transaction is complete */
         $this->change_page($this->page_url . "gui-modules/undo_confirm.php");
         return False;
     }
     return True;
 }
Ejemplo n.º 22
0
 /**
   Void record by trans_id
   @param $item_num [int] trans_id
   @param $json parser return value structure
 
   This marks the specified record as voided
   and adds an offsetting record also marked voided
   Neither record can be subsequently modified via
   voids.
 */
 public function voidid($item_num, $json)
 {
     $query = "select upc,VolSpecial,quantity,trans_subtype,unitPrice,\n            discount,memDiscount,discountable,scale,numflag,charflag,\n            foodstamp,discounttype,total,cost,description,trans_type,\n            department,regPrice,tax,volDiscType,volume,mixMatch,matched,\n            trans_status\n                   from localtemptrans where trans_id = " . $item_num;
     $db = Database::tDataConnect();
     $result = $db->query($query);
     $row = $db->fetch_array($result);
     $upc = $row["upc"];
     $VolSpecial = $row["VolSpecial"];
     $quantity = -1 * $row["quantity"];
     $total = -1 * $row["total"];
     // 11Jun14 Andy => don't know why FS is different. legacy?
     if ($row["trans_subtype"] == "FS") {
         $total = -1 * $row["unitPrice"];
     } elseif ($row['trans_status'] == 'R' && $row['trans_type'] == 'D') {
         // set refund flag and let that logic reverse
         // the total and quantity
         CoreLocal::set('refund', 1);
         $total = $row['total'];
         $quantity = $row['quantity'];
     }
     $discount = -1 * $row["discount"];
     $memDiscount = -1 * $row["memDiscount"];
     $discountable = $row["discountable"];
     $unitPrice = $row["unitPrice"];
     $scale = MiscLib::nullwrap($row["scale"]);
     $cost = -1 * $row['cost'];
     $numflag = $row["numflag"];
     $charflag = $row["charflag"];
     $mm = $row['mixMatch'];
     $matched = $row['matched'];
     $foodstamp = 0;
     if ($row["foodstamp"] != 0) {
         $foodstamp = 1;
     }
     $discounttype = MiscLib::nullwrap($row["discounttype"]);
     /**
       Check if the voiding item will exceed the limit. If so,
       prompt for admin password. For baffling reasons, the
       void amount $row['total'] is postive on open rings
     */
     if ($row['trans_type'] == 'D' && is_numeric(CoreLocal::get('VoidLimit')) && CoreLocal::get('VoidLimit') > 0) {
         $currentTotal = CoreLocal::get('voidTotal');
         if ($currentTotal + $row['total'] > CoreLocal::get('VoidLimit') && CoreLocal::get('voidOverride') != 1) {
             CoreLocal::set('strRemembered', CoreLocal::get('strEntered'));
             CoreLocal::set('voidOverride', 0);
             $json['main_frame'] = MiscLib::base_url() . 'gui-modules/adminlogin.php?class=Void';
             return $json;
         }
     }
     /**
       tenderTotal => tenders have been applied
       Amount to be voided is greater than remaining balance of
       the transaction. Restrict voids if cash is involved.
     */
     if (CoreLocal::get("tenderTotal") < 0 && -1 * $total > CoreLocal::get("runningTotal") - CoreLocal::get("taxTotal")) {
         $cash = $db->query("SELECT total FROM localtemptrans WHERE trans_subtype='CA' AND total <> 0");
         if ($db->num_rows($cash) > 0) {
             $json['output'] = DisplayLib::boxMsg(_("Item already paid for"), '', false, DisplayLib::standardClearButton());
             return $json;
         }
     }
     $update = "update localtemptrans set voided = 1 where trans_id = " . $item_num;
     $db->query($update);
     TransRecord::addRecord(array('upc' => $upc, 'description' => $row["description"], 'trans_type' => $row["trans_type"], 'trans_subtype' => $row["trans_subtype"], 'trans_status' => "V", 'department' => $row["department"], 'quantity' => $quantity, 'unitPrice' => $unitPrice, 'total' => $total, 'regPrice' => $row["regPrice"], 'scale' => $scale, 'tax' => $row["tax"], 'foodstamp' => $foodstamp, 'discount' => $discount, 'memDiscount' => $memDiscount, 'discountable' => $discountable, 'discounttype' => $discounttype, 'ItemQtty' => $quantity, 'volDiscType' => $row["volDiscType"], 'volume' => $row["volume"], 'VolSpecial' => $VolSpecial, 'mixMatch' => $mm, 'matched' => $matched, 'voided' => 1, 'cost' => $cost, 'numflag' => $numflag, 'charflag' => $charflag));
     if ($row["trans_type"] != "T") {
         CoreLocal::set("ttlflag", 0);
     } else {
         PrehLib::ttl();
     }
     return $json;
 }
Ejemplo n.º 23
0
 function parse($str)
 {
     /**
       If customer card is available, prevent other tenders
       unless specficially allowed (e.g., coupons).
     */
     if (CoreLocal::get('PaycardsBlockTenders') == 1) {
         $tender_code = strtoupper(substr($str, -2));
         $exceptions = strtoupper(CoreLocal::get('PaycardsBlockExceptions'));
         $except_array = preg_split('/[^A-Z]+/', $exceptions, 0, PREG_SPLIT_NO_EMPTY);
         if (CoreLocal::get('ccTermState') == 'ready' && !in_array($tender_code, $except_array)) {
             CoreLocal::set('boxMsg', _('Tender customer card before other tenders'));
             CoreLocal::set('boxMsgButtons', array('Charge Card [enter]' => '$(\'#reginput\').val(\'\');submitWrapper();', 'Cancel [clear]' => '$(\'#reginput\').val(\'CL\');submitWrapper();'));
             CoreLocal::set('strEntered', 'CCFROMCACHE');
             $ret = $this->default_json();
             $ret['main_frame'] = MiscLib::baseURL() . 'gui-modules/boxMsg2.php';
             return $ret;
         }
     }
     if (strlen($str) > 2) {
         $left = substr($str, 0, strlen($str) - 2);
         $right = substr($str, -2);
         $ret = PrehLib::tender($right, $left);
         return $ret;
     } else {
         $ret = $this->default_json();
         $base_object = new TenderModule($str, False);
         $tender_object = 0;
         $map = CoreLocal::get("TenderMap");
         if (is_array($map) && isset($map[$str])) {
             $class = $map[$str];
             $tender_object = new $class($str, False);
         }
         $errors = $base_object->ErrorCheck();
         if ($errors !== True) {
             $ret['output'] = $errors;
             return $ret;
         }
         if (is_object($tender_object)) {
             $errors = $tender_object->ErrorCheck();
             if ($errors !== True) {
                 $ret['output'] = $errors;
                 return $ret;
             }
         }
         if (is_object($tender_object) && !$tender_object->AllowDefault()) {
             $ret['output'] = $tender_object->DisabledPrompt();
             return $ret;
         } elseif (is_object($tender_object) && $tender_object->AllowDefault()) {
             CoreLocal::set('RepeatAgain', true);
             $ret['main_frame'] = $tender_object->DefaultPrompt();
             return $ret;
         } else {
             if ($base_object->AllowDefault()) {
                 CoreLocal::set('RepeatAgain', true);
                 $ret['main_frame'] = $base_object->DefaultPrompt();
                 return $ret;
             } else {
                 $ret['output'] = $base_object->DisabledPrompt();
                 return $ret;
             }
         }
     }
 }
Ejemplo n.º 24
0
 function preprocess()
 {
     // set variable ahead of time
     // so we know if lookup found no one
     // vs. lookup didn't happen
     $this->temp_num_rows = -1;
     $entered = "";
     if (isset($_REQUEST['idSearch']) && strlen($_REQUEST['idSearch']) > 0) {
         $entered = $_REQUEST['idSearch'];
     } elseif (isset($_REQUEST['search'])) {
         $entered = strtoupper(trim($_REQUEST["search"]));
         $entered = str_replace("'", "''", $entered);
     } else {
         return True;
     }
     if (substr($entered, -2) == "ID") {
         $entered = substr($entered, 0, strlen($entered) - 2);
     }
     $personNum = 1;
     $selected_name = False;
     // Values of memlist items are "CardNo::personNum"
     if (strstr($entered, "::") !== False) {
         $tmp = explode("::", $entered);
         $entered = $tmp[0];
         $personNum = $tmp[1];
         $selected_name = True;
     }
     // No input available, stop
     if (!$entered || strlen($entered) < 1 || $entered == "CL") {
         $this->change_page($this->page_url . "gui-modules/memlist_cards.php");
         return False;
     }
     $memberID = $entered;
     $db_a = Database::pDataConnect();
     if (!is_numeric($entered)) {
         $query = "select CardNo,personNum,LastName,FirstName from custdata \n                where LastName like '" . $entered . "%' order by LastName, FirstName";
     } else {
         $query = "select CardNo,personNum,LastName,FirstName,CashBack,Balance,Discount,\n                ChargeOk,WriteChecks,StoreCoupons,Type,memType,staff,\n                SSI,Purchases,NumberOfChecks,memCoupons,blueLine,Shown,id from custdata \n                where CardNo = '" . $entered . "' order by personNum";
     }
     $result = $db_a->query($query);
     $num_rows = $db_a->num_rows($result);
     // if theres only 1 match don't show the memlist
     if ($num_rows == 1) {
         $selected_name = True;
         $personNum = 1;
     }
     // if there's one result and either
     // a. it's the default nonmember account or
     // b. it's been confirmed in the select box
     // then set the member number
     // proceed/return to the appropriate next page
     if ($num_rows == 1 && $entered == CoreLocal::get("defaultNonMem") || is_numeric($entered) && is_numeric($personNum) && $selected_name) {
         $row = $db_a->fetch_array($result);
         // Don't want to affect the current trans.  Will it still work?
         // PrehLib::setMember($row["CardNo"], $personNum);
         // WEFC_Toronto: If a Member Card # was entered when the choice from the list was made,
         // add the memberCards record.
         if (CoreLocal::get('store') == "WEFC_Toronto") {
             $mmsg = "";
             if (isset($_REQUEST['memberCard']) && $_REQUEST['memberCard'] != "") {
                 $memberCard = $_REQUEST['memberCard'];
                 $upc = sprintf("00401229%05d", $memberCard);
                 $card_no = $row['CardNo'];
                 // Get the Member Card # from CiviCRM.
                 //  By looking up card_no in Civi members to get the contact id and use contact_id to get mcard.
                 // Can't do that because MySQL on Civi will only allow access from pos and posdev.
                 // Have to get op to enter mcard# again.
                 if (!is_numeric($memberCard) || strlen($memberCard) > 5 || $memberCard == 0) {
                     $mmsg .= "<br />Bad Member Card# format >{$memberCard}<";
                 } else {
                     /* Check that it isn't already in use, perhaps for someone else.
                      */
                     $masterLane = CoreLocal::get('laneno');
                     $currentLane = $masterLane;
                     $mQ = "SELECT card_no FROM memberCards where card_no = {$card_no}";
                     $mResult = $db_a->query($mQ);
                     $mNumRows = $db_a->num_rows($mResult);
                     if ($mNumRows > 0) {
                         $mmsg .= "<br />On lane {$currentLane} {$row['CardNo']} is already associated with a Member Card";
                     } else {
                         $mQ = "INSERT INTO memberCards (card_no, upc) VALUES ({$row['CardNo']}, '{$upc}')";
                         $mResult = $db_a->query($mQ);
                         if (!$mResult) {
                             $mmsg .= "<br />On lane {$currentLane} linking membership to Member Card failed.";
                         }
                     }
                     // Do other lane.
                     $otherLane = $masterLane == 1 ? 2 : 1;
                     $currentLane = $otherLane;
                     $isLAN = 1;
                     if ($isLAN) {
                         $LANE = "10.0.0.6{$otherLane}";
                         $LANE_PORT = "3306";
                     } else {
                         $LANE = "wefc.dyndns.org";
                         $LANE_PORT = "5066{$otherLane}";
                     }
                     $LANE_USER = "******";
                     $LANE_PW = "wefc1229";
                     $LANE_DB = "opdata";
                     $db_b = new mysqli("{$LANE}", "{$LANE_USER}", "{$LANE_PW}", "{$LANE_DB}", "{$LANE_PORT}");
                     if ($db_b->connect_error != "") {
                         $mmsg .= "<br />Connection to lane {$currentLane} failed >" . $db_b->connect_error . "<";
                     } else {
                         $mQ = "SELECT card_no FROM memberCards where card_no = {$card_no}";
                         $mResult = $db_b->query("{$mQ}");
                         $mNumRows = $mResult->{$num_rows};
                         if ($mNumRows > 0) {
                             $mmsg .= "<br />On lane {$currentLane} member {$card_no} is already associated with a Member Card";
                         } else {
                             $mQ = "INSERT INTO memberCards (card_no, upc) VALUES ({$card_no}, '{$upc}')";
                             $mResult = $db_b->query($mQ);
                             if (!$mResult) {
                                 $mmsg .= "<br />On lane {$currentLane} linking membership to Member Card failed.";
                             }
                         }
                     }
                     $db_b->close();
                 }
             } else {
                 $mmsg .= "<br />Member Card# absent or empty.";
             }
             if ($mmsg != "") {
                 // Prepare to display the error.
                 $this->temp_result = $result;
                 $this->temp_num_rows = $num_rows;
                 $this->entered = $entered;
                 $this->db = $db_a;
                 $this->temp_message = preg_replace("/^<br />/", "", $mmsg);
                 return True;
             }
             // /WEFC_Toronto bit.
         }
         if ($entered != CoreLocal::get("defaultNonMem") && PrehLib::check_unpaid_ar($row["CardNo"])) {
             $this->change_page($this->page_url . "gui-modules/UnpaidAR.php");
         } else {
             $this->change_page($this->page_url . "gui-modules/memlist_cards.php");
         }
         return False;
     }
     // Prepare to display the memlist (list to choose from).
     $this->temp_result = $result;
     $this->temp_num_rows = $num_rows;
     $this->entered = $entered;
     $this->db = $db_a;
     $this->temp_message = "";
     return True;
 }
Ejemplo n.º 25
0
 /**
   Add or update a discount module in the
   current transaction. Automatically 
   subtotals if the discount changes.
 */
 public static function updateDiscount(DiscountModule $mod, $do_subtotal = true)
 {
     $changed = true;
     // serialize/unserialize before saving to avoid
     // auto-session errors w/ undefined classes
     $current_discounts = unserialize(CoreLocal::get('CurrentDiscounts'));
     if (!is_array($current_discounts)) {
         $current_discounts = array();
     }
     /**
       Examine current discounts to see if this
       one has already applied
     */
     foreach ($current_discounts as $class => $obj) {
         if ($mod->name == $obj->name) {
             if ($mod->percentage() == $obj->percentage()) {
                 $changed = false;
             }
             break;
         }
     }
     if ($changed) {
         /**
           Add object to the list of active discounts
           Then loop through to see whether it changes
           the effective discount with stacking settings
           taken into account
         */
         $current_discounts[$mod->name] = $mod;
         $old_effective_discount = CoreLocal::get('percentDiscount');
         $new_effective_discount = 0;
         foreach ($current_discounts as $obj) {
             if (CoreLocal::get('NonStackingDiscounts') && $obj->percentage() > $new_effective_discount) {
                 $new_effective_discount = $obj->percentage();
             } elseif (CoreLocal::get('NonStackingDiscounts') == 0) {
                 $new_effective_discount += $obj->percentage();
             }
         }
         /**
           When discount changes:
           1. Update the session value
           2. Update the localtemptrans.percentDiscount value
           3. Subtotal the transaction
         */
         if ($old_effective_discount != $new_effective_discount) {
             CoreLocal::set('percentDiscount', $new_effective_discount);
             $dbc = Database::tDataConnect();
             $dbc->query('UPDATE localtemptrans SET percentDiscount=' . (int) $new_effective_discount);
             if ($do_subtotal) {
                 PrehLib::ttl();
             }
         }
         // serialize/unserialize before saving to avoid
         // auto-session errors w/ undefined classes
         CoreLocal::set('CurrentDiscounts', serialize($current_discounts));
     }
 }
Ejemplo n.º 26
0
 function preprocess()
 {
     $entered = "";
     if (isset($_REQUEST['idSearch']) && strlen($_REQUEST['idSearch']) > 0) {
         $entered = $_REQUEST['idSearch'];
     } elseif (isset($_REQUEST['search'])) {
         $entered = strtoupper(trim($_REQUEST["search"]));
         $entered = str_replace("'", '', $entered);
     } else {
         return true;
     }
     if (substr($entered, -2) == "ID") {
         $entered = substr($entered, 0, strlen($entered) - 2);
     }
     // No input available, stop
     if (!$entered || strlen($entered) < 1 || $entered == "CL") {
         $this->change_page($this->page_url . "gui-modules/pos2.php");
         return false;
     }
     $personNum = false;
     $memberID = false;
     $this->submitted = true;
     if (strstr($entered, "::") !== false) {
         // User selected a :: delimited item from the list interface
         list($memberID, $personNum) = explode("::", $entered, 2);
     } else {
         // search for the member
         $lookups = AutoLoader::ListModules('MemberLookup', True);
         foreach ($lookups as $class) {
             if (!class_exists($class)) {
                 continue;
             }
             $obj = new $class();
             if (is_numeric($entered) && !$obj->handle_numbers()) {
                 continue;
             } else {
                 if (!is_numeric($entered) && !$obj->handle_text()) {
                     continue;
                 } else {
                     if (is_numeric($entered)) {
                         $chk = $obj->lookup_by_number($entered);
                         if ($chk['url'] !== false) {
                             $this->change_page($chk['url']);
                             return false;
                         }
                         foreach ($chk['results'] as $key => $val) {
                             $this->results[$key] = $val;
                         }
                     } elseif (!is_numeric($entered)) {
                         $chk = $obj->lookup_by_text($entered);
                         if ($chk['url'] !== false) {
                             $this->change_page($chk['url']);
                             return false;
                         }
                         foreach ($chk['results'] as $key => $val) {
                             $this->results[$key] = $val;
                         }
                     }
                 }
             }
         }
         if (count($this->results) == 1 && (CoreLocal::get('verifyName') == 0 || $entered == CoreLocal::get('defaultNonMem'))) {
             $members = array_keys($this->results);
             $match = $members[0];
             list($memberID, $personNum) = explode('::', $match, 2);
         }
     }
     // we have exactly one row and
     // don't need to confirm any further
     if ($memberID !== false && $personNum !== false) {
         $callback = $this->getCallbackAction($memberID);
         if ($callback != false) {
             $callback->apply();
         }
         if ($memberID == CoreLocal::get('defaultNonMem')) {
             $personNum = 1;
         }
         PrehLib::setMember($memberID, $personNum);
         if (CoreLocal::get('store') == "WEFC_Toronto") {
             $error_msg = $this->wefcCardCheck($memberID);
             if ($error_msg !== true) {
                 $this->temp_message = $error_msg;
                 return true;
             }
         }
         // don't bother with unpaid balance check if there is no balance
         if ($memberID != CoreLocal::get("defaultNonMem") && CoreLocal::get('balance') > 0) {
             $unpaid = PrehLib::check_unpaid_ar($memberID);
             if ($unpaid) {
                 $this->change_page($this->page_url . "gui-modules/UnpaidAR.php");
             } else {
                 $this->change_page($this->page_url . "gui-modules/pos2.php");
             }
         } else {
             $this->change_page($this->page_url . "gui-modules/pos2.php");
         }
         return false;
     }
     return true;
 }
Ejemplo n.º 27
0
 /**
   Add an open ring to a department
   @param $price amount in cents (100 = $1)
   @param $dept POS department
   @ret an array of return values
   @returns An array. See Parser::default_json()
    for format explanation.
 */
 public static function deptkey($price, $dept, $ret = array())
 {
     if (CoreLocal::get("quantity") == 0 && CoreLocal::get("multiple") == 0) {
         CoreLocal::set("quantity", 1);
     }
     $ringAsCoupon = false;
     if (substr($price, 0, 2) == 'MC') {
         $ringAsCoupon = true;
         $price = substr($price, 2);
     }
     if (!is_numeric($dept) || !is_numeric($price) || strlen($price) < 1 || strlen($dept) < 2) {
         $ret['output'] = DisplayLib::inputUnknown();
         CoreLocal::set("quantity", 1);
         $ret['udpmsg'] = 'errorBeep';
         return $ret;
     }
     $strprice = $price;
     $strdept = $dept;
     $price = $price / 100;
     $dept = $dept / 10;
     $discount = 0;
     if (CoreLocal::get("casediscount") > 0 && CoreLocal::get("casediscount") <= 100) {
         $case_discount = (100 - CoreLocal::get("casediscount")) / 100;
         $price = $case_discount * $price;
     } elseif (CoreLocal::get('itemPD') > 0 && CoreLocal::get('SecurityLineItemDiscount') == 30 && CoreLocal::get('msgrepeat') == 0) {
         $ret['main_frame'] = MiscLib::baseURL() . "gui-modules/adminlogin.php?class=LineItemDiscountAdminLogin";
         return $ret;
     } elseif (CoreLocal::get('itemPD') > 0) {
         $discount = MiscLib::truncate2($price * (CoreLocal::get('itemPD') / 100.0));
         $price -= $discount;
     }
     $discount = $discount * CoreLocal::get('quantity');
     $query = "SELECT dept_no,\n        dept_name,\n        dept_tax,\n        dept_fs,\n        dept_limit,\n        dept_minimum,\n        dept_discount,";
     $dbc = Database::pDataConnect();
     $table = $dbc->table_definition('departments');
     if (isset($table['dept_see_id'])) {
         $query .= 'dept_see_id,';
     } else {
         $query .= '0 as dept_see_id,';
     }
     if (isset($table['memberOnly'])) {
         $query .= 'memberOnly';
     } else {
         $query .= '0 AS memberOnly';
     }
     $query .= " FROM departments \n                WHERE dept_no = " . (int) $dept;
     $result = $dbc->query($query);
     $num_rows = $dbc->num_rows($result);
     if ($num_rows == 0) {
         $ret['output'] = DisplayLib::boxMsg(_("department unknown"), '', false, DisplayLib::standardClearButton());
         $ret['udpmsg'] = 'errorBeep';
         CoreLocal::set("quantity", 1);
     } elseif ($ringAsCoupon) {
         $row = $dbc->fetch_array($result);
         $ret = self::deptCouponRing($row, $price, $ret);
     } else {
         $row = $dbc->fetch_array($result);
         $my_url = MiscLib::baseURL();
         if ($row['dept_see_id'] > 0) {
             list($bad_age, $ret) = PrehLib::ageCheck($row['dept_see_id'], $ret);
             if ($bad_age === true) {
                 return $ret;
             }
         }
         $ret = self::deptOpenRing($row, $price, $discount, $ret);
     }
     CoreLocal::set("quantity", 0);
     CoreLocal::set("itemPD", 0);
     return $ret;
 }
Ejemplo n.º 28
0
 function paycard_entered($mode, $card, $manual, $type)
 {
     $ret = $this->default_json();
     // initialize
     $validate = true;
     // run Luhn's on PAN, check expiration date
     PaycardLib::paycard_reset();
     CoreLocal::set("paycard_mode", $mode);
     CoreLocal::set("paycard_manual", $manual ? 1 : 0);
     // error checks based on transaction
     if ($mode == PaycardLib::PAYCARD_MODE_AUTH) {
         if (CoreLocal::get("ttlflag") != 1) {
             // must subtotal before running card
             $ret['output'] = PaycardLib::paycard_msgBox($type, "No Total", "Transaction must be totaled before tendering or refunding", "[clear] to cancel");
             return $ret;
         } else {
             if (abs(CoreLocal::get("amtdue")) < 0.005) {
                 // can't tender for more than due
                 $ret['output'] = PaycardLib::paycard_msgBox($type, "No Total", "Nothing to tender or refund", "[clear] to cancel");
                 return $ret;
             }
         }
     }
     // check for pre-validation override
     if (strtoupper(substr($card, 0, 1)) == 'O') {
         $validate = false;
         $card = substr($card, 1);
     }
     // parse card data
     if (CoreLocal::get("paycard_manual")) {
         // make sure it's numeric
         if (!ctype_digit($card) || strlen($card) < 18) {
             // shortest known card # is 14 digits, plus MMYY
             $ret['output'] = PaycardLib::paycard_msgBox($type, "Manual Entry Unknown", "Please enter card data like:<br>CCCCCCCCCCCCCCCCMMYY", "[clear] to cancel");
             return $ret;
         }
         // split up input (and check for the Concord test card)
         if ($type == PaycardLib::PAYCARD_TYPE_UNKNOWN) {
             $type = PaycardLib::paycard_type($card);
         }
         if ($type == PaycardLib::PAYCARD_TYPE_GIFT) {
             CoreLocal::set("paycard_PAN", $card);
             // our gift cards have no expiration date or conf code
         } else {
             CoreLocal::set("paycard_PAN", substr($card, 0, -4));
             CoreLocal::set("paycard_exp", substr($card, -4, 4));
         }
     } else {
         if ($type == PaycardLib::PAYCARD_TYPE_ENCRYPTED) {
             // add leading zero back to fix hex encoding, if needed
             if (substr($card, 0, 7) == "2E60080") {
                 $card = "0" . $card;
             }
             CoreLocal::set("paycard_PAN", $card);
         } else {
             // swiped magstripe (reference to ISO format at end of this file)
             $stripe = PaycardLib::paycard_magstripe($card);
             if (!is_array($stripe)) {
                 $ret['output'] = PaycardLib::paycard_errBox($type, CoreLocal::get("paycard_manual") . "Card Data Invalid", "Please swipe again or type in manually", "[clear] to cancel");
                 return $ret;
             }
             CoreLocal::set("paycard_PAN", $stripe["pan"]);
             CoreLocal::set("paycard_exp", $stripe["exp"]);
             CoreLocal::set("paycard_name", $stripe["name"]);
             CoreLocal::set("paycard_tr1", $stripe["tr1"]);
             CoreLocal::set("paycard_tr2", $stripe["tr2"]);
             CoreLocal::set("paycard_tr3", $stripe["tr3"]);
         }
     }
     // manual/swiped
     // determine card issuer and type
     CoreLocal::set("paycard_type", PaycardLib::paycard_type(CoreLocal::get("paycard_PAN")));
     CoreLocal::set("paycard_issuer", PaycardLib::paycard_issuer(CoreLocal::get("paycard_PAN")));
     /* check card type. Credit is default. */
     $type = CoreLocal::get("CacheCardType");
     if ($type == '') {
         $type = 'CREDIT';
         CoreLocal::set("CacheCardType", "CREDIT");
     }
     /* assign amount due. EBT food should use eligible amount */
     CoreLocal::set("paycard_amount", CoreLocal::get("amtdue"));
     if ($type == 'EBTFOOD') {
         if (CoreLocal::get('fntlflag') == 0) {
             /* try to automatically do fs total */
             $try = PrehLib::fsEligible();
             if ($try !== True) {
                 $ret['output'] = PaycardLib::paycard_msgBox($type, "Type Mismatch", "Foodstamp eligible amount inapplicable", "[clear] to cancel");
                 return $ret;
             }
         }
         /**
           Always validate amount as non-zero
         */
         if (CoreLocal::get('fsEligible') <= 0.005 && CoreLocal::get('fsEligible') >= -0.005) {
             $ret['output'] = PaycardLib::paycard_msgBox($type, _('Zero Total'), "Foodstamp eligible amount is zero", "[clear] to cancel");
             UdpComm::udpSend('termReset');
             return $ret;
         }
         CoreLocal::set("paycard_amount", CoreLocal::get("fsEligible"));
     }
     if (($type == 'EBTCASH' || $type == 'DEBIT') && CoreLocal::get('CacheCardCashBack') > 0) {
         CoreLocal::set('paycard_amount', CoreLocal::get('amtdue') + CoreLocal::get('CacheCardCashBack'));
     }
     // if we knew the type coming in, make sure it agrees
     if ($type != PaycardLib::PAYCARD_TYPE_UNKNOWN && $type != CoreLocal::get("paycard_type")) {
         $ret['output'] = PaycardLib::paycard_msgBox($type, "Type Mismatch", "Card number does not match card type", "[clear] to cancel");
         return $ret;
     }
     foreach (CoreLocal::get("RegisteredPaycardClasses") as $rpc) {
         if (!class_exists($rpc)) {
             continue;
         }
         $myObj = new $rpc();
         if ($myObj->handlesType(CoreLocal::get("paycard_type"))) {
             return $myObj->entered($validate, $ret);
         }
     }
     $ret['output'] = PaycardLib::paycard_errBox(PaycardLib::PAYCARD_TYPE_UNKNOWN, "Unknown Card Type " . CoreLocal::get("paycard_type"), "", "[clear] to cancel");
     return $ret;
 }
Ejemplo n.º 29
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.º 30
0
 public function parse($str)
 {
     $ret = $this->default_json();
     $plugin_info = new Paycards();
     $ret['main_frame'] = $plugin_info->pluginUrl() . '/gui/PaycardEmvPage.php';
     Database::getsubtotals();
     switch ($str) {
         case 'DATACAP':
             $ret['main_frame'] = $plugin_info->pluginUrl() . '/gui/PaycardEmvMenu.php';
             break;
         case 'DATACAPEMV':
             CoreLocal::set('paycard_amount', CoreLocal::get('amtdue'));
             CoreLocal::set('CacheCardType', 'EMV');
             CoreLocal::set('paycard_mode', PaycardLib::PAYCARD_MODE_AUTH);
             CoreLocal::set('paycard_type', PaycardLib::PAYCARD_TYPE_CREDIT);
             break;
         case 'DATACAPCC':
             CoreLocal::set('paycard_amount', CoreLocal::get('amtdue'));
             CoreLocal::set('CacheCardType', 'CREDIT');
             CoreLocal::set('paycard_mode', PaycardLib::PAYCARD_MODE_AUTH);
             CoreLocal::set('paycard_type', PaycardLib::PAYCARD_TYPE_CREDIT);
             break;
         case 'DATACAPDC':
             CoreLocal::set('paycard_amount', CoreLocal::get('amtdue'));
             if (CoreLocal::get('CacheCardCashBack')) {
                 CoreLocal::set('paycard_amount', CoreLocal::get('amtdue') + CoreLocal::get('CacheCardCashBack'));
             }
             CoreLocal::set('CacheCardType', 'DEBIT');
             CoreLocal::set('paycard_mode', PaycardLib::PAYCARD_MODE_AUTH);
             CoreLocal::set('paycard_type', PaycardLib::PAYCARD_TYPE_CREDIT);
             break;
         case 'DATACAPEF':
             if (CoreLocal::get('fntlflag') == 0) {
                 /* try to automatically do fs total */
                 $try = PrehLib::fsEligible();
                 if ($try !== true) {
                     $ret['output'] = PaycardLib::paycard_msgBox($type, "Type Mismatch", "Foodstamp eligible amount inapplicable", "[clear] to cancel");
                     $ret['main_frame'] = false;
                     return $ret;
                 }
             }
             CoreLocal::set('paycard_amount', CoreLocal::get('fsEligible'));
             CoreLocal::set('CacheCardType', 'EBTFOOD');
             CoreLocal::set('paycard_mode', PaycardLib::PAYCARD_MODE_AUTH);
             CoreLocal::set('paycard_type', PaycardLib::PAYCARD_TYPE_CREDIT);
             break;
         case 'DATACAPEC':
             CoreLocal::set('paycard_amount', CoreLocal::get('amtdue'));
             if (CoreLocal::get('CacheCardCashBack')) {
                 CoreLocal::set('paycard_amount', CoreLocal::get('amtdue') + CoreLocal::get('CacheCardCashBack'));
             }
             CoreLocal::set('CacheCardType', 'EBTCASH');
             CoreLocal::set('paycard_mode', PaycardLib::PAYCARD_MODE_AUTH);
             CoreLocal::set('paycard_type', PaycardLib::PAYCARD_TYPE_CREDIT);
             break;
         case 'DATACAPGD':
             CoreLocal::set('paycard_amount', CoreLocal::get('amtdue'));
             CoreLocal::set('CacheCardType', 'GIFT');
             CoreLocal::set('paycard_mode', PaycardLib::PAYCARD_MODE_AUTH);
             CoreLocal::set('paycard_type', PaycardLib::PAYCARD_TYPE_GIFT);
             break;
         case 'PVDATACAPGD':
             CoreLocal::set('CacheCardType', 'GIFT');
             CoreLocal::set('paycard_mode', PaycardLib::PAYCARD_MODE_BALANCE);
             CoreLocal::set('paycard_type', PaycardLib::PAYCARD_TYPE_GIFT);
             $ret['main_frame'] = $plugin_info->pluginUrl() . '/gui/PaycardEmvBalance.php';
             break;
         case 'PVDATACAPEF':
             CoreLocal::set('CacheCardType', 'EBTFOOD');
             CoreLocal::set('paycard_mode', PaycardLib::PAYCARD_MODE_BALANCE);
             CoreLocal::set('paycard_type', PaycardLib::PAYCARD_TYPE_CREDIT);
             $ret['main_frame'] = $plugin_info->pluginUrl() . '/gui/PaycardEmvBalance.php';
             break;
         case 'PVDATACAPEC':
             CoreLocal::set('CacheCardType', 'EBTCASH');
             CoreLocal::set('paycard_mode', PaycardLib::PAYCARD_MODE_BALANCE);
             CoreLocal::set('paycard_type', PaycardLib::PAYCARD_TYPE_CREDIT);
             $ret['main_frame'] = $plugin_info->pluginUrl() . '/gui/PaycardEmvBalance.php';
             break;
         case 'ACDATACAPGD':
             CoreLocal::set('CacheCardType', 'GIFT');
             CoreLocal::set('paycard_mode', PaycardLib::PAYCARD_MODE_ACTIVATE);
             CoreLocal::set('paycard_type', PaycardLib::PAYCARD_TYPE_GIFT);
             $ret['main_frame'] = $plugin_info->pluginUrl() . '/gui/PaycardEmvGift.php?mode=' . CoreLocal::get('paycard_mode');
             break;
         case 'AVDATACAPGD':
             CoreLocal::set('CacheCardType', 'GITFT');
             CoreLocal::set('paycard_mode', PaycardLib::PAYCARD_MODE_ADDVALUE);
             CoreLocal::set('paycard_type', PaycardLib::PAYCARD_TYPE_GIFT);
             $ret['main_frame'] = $plugin_info->pluginUrl() . '/gui/PaycardEmvGift.php?mode=' . CoreLocal::get('paycard_mode');
             break;
     }
     CoreLocal::set('paycard_id', CoreLocal::get('LastID') + 1);
     return $ret;
 }