Ejemplo n.º 1
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.º 2
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.º 3
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.º 4
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.º 5
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.º 6
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.º 7
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.º 8
0
 function preprocess()
 {
     $this->tendertype = "";
     if (isset($_REQUEST["selectlist"])) {
         $choice = $_REQUEST["selectlist"];
         if ($choice == "EF") {
             $chk = PrehLib::fsEligible();
             if ($chk !== true) {
                 $this->change_page($chk);
                 return false;
             }
             // 13Feb13 Andy
             // Disable option to enter tender here by returning immediately
             // to pos2.php. Should be conigurable or have secondary
             // functionality removed entirely
             $this->tendertype = 'EF';
             $this->change_page($this->page_url . "gui-modules/pos2.php");
             return false;
         } else {
             if ($choice == "EC") {
                 $chk = PrehLib::ttl();
                 if ($chk !== true) {
                     $this->change_page($chk);
                     return false;
                 }
                 // 13Feb13 Andy
                 // Disabled option; see above
                 $this->tendertype = 'EC';
                 $this->change_page($this->page_url . "gui-modules/pos2.php");
                 return false;
             } else {
                 if ($choice == '') {
                     $this->change_page($this->page_url . "gui-modules/pos2.php");
                     return false;
                 }
             }
         }
     } else {
         if (isset($_REQUEST['tendertype'])) {
             $this->tendertype = $_REQUEST['tendertype'];
             $valid_input = false;
             $in = $_REQUEST['tenderamt'];
             if (empty($in)) {
                 if ($this->tendertype == 'EF') {
                     CoreLocal::set("strRemembered", 100 * CoreLocal::get("fsEligible") . "EF");
                 } else {
                     CoreLocal::set("strRemembered", 100 * CoreLocal::get("runningTotal") . "EC");
                 }
                 CoreLocal::set("msgrepeat", 1);
                 $valid_input = true;
             } else {
                 if (is_numeric($in)) {
                     if ($this->tendertype == 'EF' && $in > 100 * CoreLocal::get("fsEligible")) {
                         $valid_input = false;
                     } else {
                         CoreLocal::set("strRemembered", $in . $this->tendertype);
                         CoreLocal::set("msgrepeat", 1);
                         $valid_input = true;
                     }
                 } else {
                     if (strtoupper($in) == "CL") {
                         CoreLocal::set("strRemembered", "");
                         CoreLocal::set("msgrepeat", 0);
                         $valid_input = true;
                     }
                 }
             }
             if ($valid_input) {
                 $this->change_page($this->page_url . "gui-modules/pos2.php");
                 return false;
             }
         }
     }
     return true;
 }