예제 #1
0
파일: ClubCard.php 프로젝트: phpsmith/IS4C
 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;
 }
예제 #2
0
 public function testMiscLib()
 {
     chdir(dirname(__FILE__) . '/../../pos/is4c-nf/gui-modules/');
     $rel = MiscLib::baseURL();
     $this->assertEquals('../', $rel);
     $this->assertEquals(1, MiscLib::nullwrap(1));
     $this->assertEquals(1.5, MiscLib::nullwrap(1.5));
     $this->assertEquals('test', MiscLib::nullwrap('test'));
     $this->assertEquals(0, MiscLib::nullwrap(False));
     $this->assertEquals(1, MiscLib::truncate2(1));
     $this->assertEquals(1.99, MiscLib::truncate2(1.99));
     $this->assertEquals(1.99, MiscLib::truncate2("1.99"));
     $this->assertEquals(1.35, MiscLib::truncate2("1.345"));
     $hostCheck = MiscLib::pingport(CoreLocal::get('localhost'), CoreLocal::get('DBMS'));
     $this->assertInternalType('integer', $hostCheck);
     $hostCheck = MiscLib::win32();
     $this->assertInternalType('integer', $hostCheck);
     $scale = MiscLib::scaleObject();
     if ($scale !== 0) {
         $this->assertInstanceOf('ScaleDriverWrapper', $scale);
     }
 }
예제 #3
0
파일: ItemPD.php 프로젝트: phpsmith/IS4C
 function discountupc($upc, $item_num = -1, $pd = 0)
 {
     $lastpageflag = 1;
     $deliflag = 0;
     $quantity = 0;
     if (strpos($upc, "*") && (strpos($upc, "**") || strpos($upc, "*") == 0 || strpos($upc, "*") == strlen($upc) - 1)) {
         $upc = "stop";
     } elseif (strpos($upc, "*")) {
         $voidupc = explode("*", $upc);
         if (!is_numeric($voidupc[0])) {
             $upc = "stop";
         } else {
             $quantity = $voidupc[0];
             $upc = $voidupc[1];
             $weight = 0;
         }
     } elseif (!is_numeric($upc) && !strpos($upc, "DP")) {
         $upc = "stop";
     } else {
         $quantity = 1;
         $weight = CoreLocal::get("weight");
     }
     $scaleprice = 0;
     if (is_numeric($upc)) {
         $upc = substr("0000000000000" . $upc, -13);
         if (substr($upc, 0, 3) == "002" && substr($upc, -5) != "00000") {
             $scaleprice = substr($upc, 10, 4) / 100;
             $upc = substr($upc, 0, 8) . "0000";
             $deliflag = 1;
         } elseif (substr($upc, 0, 3) == "002" && substr($upc, -5) == "00000") {
             $deliflag = 1;
         }
     }
     if ($upc == "stop") {
         return DisplayLib::inputUnknown();
     }
     $db = Database::tDataConnect();
     $query = "select sum(ItemQtty) as voidable, sum(quantity) as vquantity, max(scale) as scale, " . "max(volDiscType) as volDiscType from localtemptrans where upc = '" . $upc . "' and unitPrice = " . $scaleprice . " and discounttype <> 3 group by upc";
     $result = $db->query($query);
     $num_rows = $db->num_rows($result);
     if ($num_rows == 0) {
         return DisplayLib::boxMsg(_("Item not found: ") . $upc, '', false, DisplayLib::standardClearButton());
     }
     $row = $db->fetch_array($result);
     if ($row["scale"] == 1 && $weight > 0) {
         $quantity = $weight - CoreLocal::get("tare");
         CoreLocal::set("tare", 0);
     }
     $volDiscType = $row["volDiscType"];
     $voidable = MiscLib::nullwrap($row["voidable"]);
     $VolSpecial = 0;
     $volume = 0;
     $scale = MiscLib::nullwrap($row["scale"]);
     //----------------------Void Item------------------
     $query_upc = "select ItemQtty,foodstamp,discounttype,mixMatch,cost,\n            numflag,charflag,unitPrice,discounttype,regPrice,discount,\n            memDiscount,discountable,description,trans_type,trans_subtype,\n            department,tax,VolSpecial\n            from localtemptrans where upc = '" . $upc . "' and unitPrice = " . $scaleprice . " and trans_id={$item_num}";
     $result = $db->query($query_upc);
     $row = $db->fetch_array($result);
     $ItemQtty = $row["ItemQtty"];
     $foodstamp = MiscLib::nullwrap($row["foodstamp"]);
     $discounttype = MiscLib::nullwrap($row["discounttype"]);
     $mixMatch = MiscLib::nullwrap($row["mixMatch"]);
     $cost = isset($row["cost"]) ? -1 * $row["cost"] : 0;
     $numflag = isset($row["numflag"]) ? $row["numflag"] : 0;
     $charflag = isset($row["charflag"]) ? $row["charflag"] : 0;
     $unitPrice = $row["unitPrice"];
     if (CoreLocal::get("isMember") != 1 && $row["discounttype"] == 2 || CoreLocal::get("isStaff") == 0 && $row["discounttype"] == 4) {
         $unitPrice = $row["regPrice"];
     } elseif ((CoreLocal::get("isMember") == 1 && $row["discounttype"] == 2 || CoreLocal::get("isStaff") != 0 && $row["discounttype"] == 4) && $row["unitPrice"] == $row["regPrice"]) {
         $db_p = Database::pDataConnect();
         $query_p = "select special_price from products where upc = '" . $upc . "'";
         $result_p = $db_p->query($query_p);
         $row_p = $db_p->fetch_array($result_p);
         $unitPrice = $row_p["special_price"];
     }
     $discount = -1 * $row["discount"];
     $memDiscount = -1 * $row["memDiscount"];
     $discountable = $row["discountable"];
     $CardNo = CoreLocal::get("memberID");
     $discounttype = MiscLib::nullwrap($row["discounttype"]);
     if ($discounttype == 3) {
         $quantity = -1 * $ItemQtty;
     } elseif ($quantity != 0) {
         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, 'quantity' => $quantity, 'volDiscType' => $volDiscType, 'volume' => $volume, 'VolSpecial' => $VolSpecial, 'mixMatch' => $mixMatch, 'voided' => 1, 'cost' => $cost, 'numflag' => $numflag, 'charflag' => $charflag));
         if ($row["trans_type"] != "T") {
             CoreLocal::set("ttlflag", 0);
         }
         $db = Database::pDataConnect();
         $chk = $db->query("SELECT deposit FROM products WHERE upc='{$upc}'");
         if ($db->num_rows($chk) > 0) {
             $dpt = array_pop($db->fetch_row($chk));
             if ($dpt > 0) {
                 $dupc = (int) $dpt;
                 return $this->voidupc(-1 * $quantity . "*" . $dupc, True);
             }
         }
     }
     return "";
 }
예제 #4
0
파일: UPC.php 프로젝트: phpsmith/IS4C
 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);
 }
예제 #5
0
 function preprocess()
 {
     $this->upc = "";
     $this->found = false;
     $this->pricing = array('sale' => false, 'actual_price' => '', 'memPrice' => '', 'description', 'department', 'regular_price');
     if (isset($_REQUEST['reginput']) && strtoupper($_REQUEST['reginput']) == "CL") {
         // cancel
         $this->change_page($this->page_url . "gui-modules/pos2.php");
         return false;
     } else {
         if (isset($_REQUEST['reginput']) || isset($_REQUEST['upc'])) {
             // use reginput as UPC unless it's empty
             $this->upc = isset($_REQUEST['reginput']) ? $_REQUEST['reginput'] : '';
             if ($this->upc == '' && isset($_REQUEST['upc'])) {
                 $this->upc = $_REQUEST['upc'];
             }
             $this->upc = str_pad($this->upc, 13, '0', STR_PAD_LEFT);
             $db = Database::pDataConnect();
             $query = "select inUse,upc,description,normal_price,scale,deposit,\n                qttyEnforced,department,local,cost,tax,foodstamp,discount,\n                discounttype,specialpricemethod,special_price,groupprice,\n                pricemethod,quantity,specialgroupprice,specialquantity,\n                mixmatchcode,idEnforced,tareweight,d.dept_name\n                from products, departments d where department = d.dept_no\n                AND upc = ?";
             $prep = $db->prepare($query);
             $result = $db->execute($prep, array($this->upc));
             $num_rows = $db->num_rows($result);
             // lookup item info
             if ($num_rows > 0) {
                 $this->found = true;
                 $row = $db->fetch_row($result);
                 $discounttype = MiscLib::nullwrap($row["discounttype"]);
                 $DiscountObject = null;
                 // see UPC parser for explanation
                 $DTClasses = CoreLocal::get("DiscountTypeClasses");
                 if ($row['discounttype'] < 64 && isset(DiscountType::$MAP[$row['discounttype']])) {
                     $class = DiscountType::$MAP[$row['discounttype']];
                     $DiscountObject = new $class();
                 } else {
                     if ($row['discounttype'] > 64 && isset($DTClasses[$row['discounttype'] - 64])) {
                         $class = $DTClasses[$row['discounttype'] - 64];
                         $DiscountObject = new $class();
                     } else {
                         // If the requested discounttype isn't available,
                         // fallback to normal pricing. Debatable whether
                         // this should be a hard error.
                         $DiscountObject = new NormalPricing();
                     }
                 }
                 if ($DiscountObject->isSale()) {
                     $this->pricing['sale'] = true;
                 }
                 $info = $DiscountObject->priceInfo($row, 1);
                 $this->pricing['actual_price'] = sprintf('$%.2f%s', $info['unitPrice'], $row['scale'] > 0 ? ' /lb' : '');
                 $this->pricing['regular_price'] = sprintf('$%.2f%s', $info['regPrice'], $row['scale'] > 0 ? ' /lb' : '');
                 if ($info['memDiscount'] > 0) {
                     $this->pricing['memPrice'] = sprintf('$%.2f%s', $info['unitPrice'] - $info['memDiscount'], $row['scale'] > 0 ? ' /lb' : '');
                 }
                 $this->pricing['description'] = $row['description'];
                 $this->pricing['department'] = $row['dept_name'];
                 MiscLib::goodBeep();
             }
             // user hit enter and there is a valid UPC present
             if (isset($_REQUEST['reginput']) && $_REQUEST['reginput'] == '' && $this->found) {
                 CoreLocal::set("msgrepeat", 1);
                 CoreLocal::set("strRemembered", $this->upc);
                 $this->change_page($this->page_url . "gui-modules/pos2.php");
                 return false;
             }
         }
     }
     return true;
 }
예제 #6
0
파일: Void.php 프로젝트: phpsmith/IS4C
 /**
   Void the given UPC
   @param $upc [string] upc to void. Optionally including quantity and asterisk
   @param $item_num [int] trans_id of record to void. Optional.
   @param $json parser return value structure
 */
 public function voidupc($upc, $json, $item_num = -1)
 {
     $lastpageflag = 1;
     $deliflag = false;
     $quantity = 0;
     /**
       If UPC contains an asterisk, extract quantity
       and validate input. Otherwise use quantity 1.
     */
     if (strstr($upc, '*')) {
         list($quantity, $upc) = explode('*', $upc, 2);
         if ($quantity === '' || $upc === '' || !is_numeric($quantity) || !is_numeric($upc)) {
             $json['output'] = DisplayLib::inputUnknown();
             return $json;
         } else {
             $weight = 0;
         }
     } else {
         $quantity = 1;
         $weight = CoreLocal::get("weight");
     }
     $scaleprice = 0;
     if (is_numeric($upc)) {
         $upc = substr("0000000000000" . $upc, -13);
         if (substr($upc, 0, 3) == "002" && substr($upc, -5) != "00000") {
             $scaleprice = substr($upc, 10, 4) / 100;
             $upc = substr($upc, 0, 8) . "0000";
             $deliflag = true;
         } else {
             if (substr($upc, 0, 3) == "002" && substr($upc, -5) == "00000") {
                 $scaleprice = $this->scaleprice;
                 $deliflag = true;
             }
         }
     }
     $db = Database::tDataConnect();
     $query = "SELECT SUM(ItemQtty) AS voidable, \n                    SUM(quantity) AS vquantity,\n                    MAX(scale) AS scale,\n                    MAX(volDiscType) AS volDiscType \n                  FROM localtemptrans \n                  WHERE upc = '" . $upc . "'";
     if ($deliflag) {
         $query .= ' AND unitPrice = ' . $scaleprice;
     }
     $query .= ' GROUP BY upc';
     $result = $db->query($query);
     $num_rows = $db->num_rows($result);
     if ($num_rows == 0) {
         $json['output'] = DisplayLib::boxMsg(_("Item not found: ") . $upc, '', false, DisplayLib::standardClearButton());
         return $json;
     }
     $row = $db->fetch_array($result);
     if ($row["scale"] == 1 && $weight > 0) {
         $quantity = $weight - CoreLocal::get("tare");
         CoreLocal::set("tare", 0);
     }
     $volDiscType = $row["volDiscType"];
     $voidable = MiscLib::nullwrap($row["voidable"]);
     $VolSpecial = 0;
     $volume = 0;
     $scale = MiscLib::nullwrap($row["scale"]);
     if ($voidable == 0 && $quantity == 1) {
         $json['output'] = DisplayLib::boxMsg(_("Item already voided"), '', false, DisplayLib::standardClearButton());
         return $json;
     } elseif ($voidable == 0 && $quantity > 1) {
         $json['output'] = DisplayLib::boxMsg(_("Items already voided"), '', false, DisplayLib::standardClearButton());
         return $json;
     } elseif ($scale == 1 && $quantity < 0) {
         $json['output'] = DisplayLib::boxMsg(_("tare weight cannot be greater than item weight"), '', false, DisplayLib::standardClearButton());
         return $json;
     } elseif ($voidable < $quantity && $row["scale"] == 1) {
         $message = _("Void request exceeds") . "<br />" . _("weight of item rung in") . "<p><b>" . sprintf(_("You can void up to %.2f lb"), $row['voidable']) . "</b>";
         $json['output'] = DisplayLib::boxMsg($message, '', false, DisplayLib::standardClearButton());
         return $json;
     } elseif ($voidable < $quantity) {
         $message = _("Void request exceeds") . "<br />" . _("number of items rung in") . "<p><b>" . sprintf(_("You can void up to %d"), $row['voidable']) . "</b>";
         $json['output'] = DisplayLib::boxMsg($message, '', false, DisplayLib::standardClearButton());
         return $json;
     }
     //----------------------Void Item------------------
     $query_upc = "SELECT \n                        ItemQtty,\n                        foodstamp,\n                        discounttype,\n                        mixMatch,\n                        cost,\n                        numflag,\n                        charflag,\n                        unitPrice,\n                        total,\n                        discounttype,\n                        regPrice,\n                        discount,\n                        memDiscount,\n                        discountable,\n                        description,\n                        trans_type,\n                        trans_subtype,\n                        department,\n                        tax,\n                        VolSpecial,\n                        matched,\n                        scale,\n                        trans_id\n                      FROM localtemptrans \n                      WHERE upc = '" . $upc . "'";
     if ($deliflag) {
         $query_upc .= ' AND unitPrice = ' . $scaleprice;
     }
     if ($item_num != -1) {
         $query_upc .= ' AND trans_id = ' . $item_num;
     } else {
         $query_upc .= ' AND voided=0 ORDER BY total';
     }
     $result = $db->query($query_upc);
     $row = $db->fetch_array($result);
     $foodstamp = MiscLib::nullwrap($row["foodstamp"]);
     $discounttype = MiscLib::nullwrap($row["discounttype"]);
     $mixMatch = MiscLib::nullwrap($row["mixMatch"]);
     $matched = -1 * $row['matched'];
     $item_num = $row['trans_id'];
     $cost = $row['cost'];
     $numflag = $row['numflag'];
     $charflag = $row['charflag'];
     $unitPrice = $row["unitPrice"];
     /**
       11Jun14 Andy
       Convert unitPrice to/from sale price based on
       member status. I'm not sure this is actually
       necessary.
     */
     if (CoreLocal::get("isMember") != 1 && $row["discounttype"] == 2 || CoreLocal::get("isStaff") == 0 && $row["discounttype"] == 4) {
         $unitPrice = $row["regPrice"];
     } elseif ((CoreLocal::get("isMember") == 1 && $row["discounttype"] == 2 || CoreLocal::get("isStaff") != 0 && $row["discounttype"] == 4) && $row["unitPrice"] == $row["regPrice"]) {
         $db_p = Database::pDataConnect();
         $query_p = "select special_price from products where upc = '" . $upc . "'";
         $result_p = $db_p->query($query_p);
         $row_p = $db_p->fetch_array($result_p);
         $unitPrice = $row_p["special_price"];
     }
     $discount = -1 * $row["discount"];
     $memDiscount = -1 * $row["memDiscount"];
     $discountable = $row["discountable"];
     $quantity = -1 * $quantity;
     $total = $quantity * $unitPrice;
     if ($row['unitPrice'] == 0) {
         $total = $quantity * $row['total'];
     } elseif ($row['total'] != $total && $row['scale'] == 1) {
         /**
           If the total does not match quantity times unit price,
           the cashier probably manually specified a quantity
           i.e., VD{qty}*{upc}. This is probably OK for non-weight
           items. Each record should be the same and voiding multiple
           in one line will usually be fine.
         */
         $total = -1 * $row['total'];
     }
     /**
       Check if the voiding item will exceed the limit. If so,
       prompt for admin password. 
     */
     if (is_numeric(CoreLocal::get('VoidLimit')) && CoreLocal::get('VoidLimit') > 0) {
         $currentTotal = CoreLocal::get('voidTotal');
         if ($currentTotal + -1 * $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;
         }
     }
     $db = Database::tDataConnect();
     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;
         }
     }
     if ($quantity != 0) {
         $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' => $volDiscType, 'volume' => $volume, 'VolSpecial' => $VolSpecial, 'mixMatch' => $mixMatch, 'matched' => $matched, 'voided' => 1, 'cost' => $cost, 'numflag' => $numflag, 'charflag' => $charflag));
         if ($row["trans_type"] != "T") {
             CoreLocal::set("ttlflag", 0);
         }
         $db = Database::pDataConnect();
         $chk = $db->query("SELECT deposit FROM products WHERE upc='{$upc}'");
         if ($db->num_rows($chk) > 0) {
             $w = $db->fetch_row($chk);
             $dpt = $w['deposit'];
             if ($dpt <= 0) {
                 return $json;
                 // no deposit found
             }
             $db = Database::tDataConnect();
             $dupc = str_pad((int) $dpt, 13, '0', STR_PAD_LEFT);
             $id = $db->query(sprintf("SELECT trans_id FROM localtemptrans\n                    WHERE upc='%s' AND voided=0 AND quantity=%d", $dupc, -1 * $quantity));
             if ($db->num_rows($id) > 0) {
                 $w = $db->fetch_row($id);
                 $trans_id = $w['trans_id'];
                 // pass an empty array instead of $json so
                 // voiding the deposit doesn't result in an error
                 // message.
                 $this->voidupc(-1 * $quantity . "*" . $dupc, array(), $trans_id);
             }
         }
     }
     return $json;
 }
예제 #7
0
 /**
   Add an item to localtemptrans.
   Parameters correspond to columns in localtemptrans. See that table
   for valid types.
   @param $strupc localtemptrans.upc
   @param $strdescription localtemptrans.description
   @param $strtransType localtemptrans.trans_type
   @param $strtranssubType localtemptrans.trans_subtype
   @param $strtransstatuts localtemptrans.trans_status
   @param $dblquantity localtemptrans.quantity
   @param $dblunitPrice localtemptrans.unitPrice
   @param $dbltotal localtemptrans.total
   @param $dblregPrice localtemptrans.regPrice
   @param $intscale localtemptrans.scale
   @param $inttax localtemptrans.tax
   @param $intfoodstamp localtemptrans.foodstamp
   @param $dbldiscount localtemptrans.discount
   @param $dblmemDiscount localtemptrans.memDiscount
   @param $intdiscountable localtemptrans.discounttable
   @param $intdiscounttype localtemptrans.discounttype
   @param $dblItemQtty localtemptrans.ItemQtty
   @param $intvolDiscType localtemptrans.volDiscType
   @param $intvolume localtemptrans.volume
   @param $dblVolSpecial localtemptrans.VolSpecial
   @param $intmixMatch localtemptrans.mixMatch
   @param $intmatched localtemptrans.matched
   @param $intvoided localtemptrans.voided
   @param $cost localtemptrans.cost
   @param $numflag localtemptrans.numflag
   @param $charflag localtemptrans.charflag
 
   In many cases there is a simpler function that takes far
   fewer arguments and adds a specific type of record.
   All such functions should be in this file.
 */
 public static function addItem($strupc, $strdescription, $strtransType, $strtranssubType, $strtransstatus, $intdepartment, $dblquantity, $dblunitPrice, $dbltotal, $dblregPrice, $intscale, $inttax, $intfoodstamp, $dbldiscount, $dblmemDiscount, $intdiscountable, $intdiscounttype, $dblItemQtty, $intvolDiscType, $intvolume, $dblVolSpecial, $intmixMatch, $intmatched, $intvoided, $cost = 0, $numflag = 0, $charflag = '')
 {
     //$dbltotal = MiscLib::truncate2(str_replace(",", "", $dbltotal)); replaced by apbw 7/27/05 with the next 4 lines -- to fix thousands place errors
     $dbltotal = str_replace(",", "", $dbltotal);
     $dbltotal = number_format($dbltotal, 2, '.', '');
     $dblunitPrice = str_replace(",", "", $dblunitPrice);
     $dblunitPrice = number_format($dblunitPrice, 2, '.', '');
     // do not clear refund flag when adding an informational log record
     if ($strtransType != 'L' && CoreLocal::get("refund") == 1) {
         $dblquantity = -1 * $dblquantity;
         $dbltotal = -1 * $dbltotal;
         $dbldiscount = -1 * $dbldiscount;
         $dblmemDiscount = -1 * $dblmemDiscount;
         if ($strtransstatus != "V" && $strtransstatus != "D") {
             $strtransstatus = "R";
             // edited by apbw 6/04/05 to correct voiding of refunded items
         }
         CoreLocal::set("refund", 0);
         CoreLocal::set("refundComment", "");
         CoreLocal::set("autoReprint", 1);
         if (CoreLocal::get("refundDiscountable") == 0) {
             $intdiscountable = 0;
         }
     }
     $intregisterno = CoreLocal::get("laneno");
     $intempno = CoreLocal::get("CashierNo");
     $inttransno = CoreLocal::get("transno");
     $strCardNo = CoreLocal::get("memberID");
     $memType = CoreLocal::get("memType");
     $staff = CoreLocal::get("isStaff");
     $percentDiscount = CoreLocal::get("percentDiscount");
     $db = Database::tDataConnect();
     $datetimestamp = "";
     if (CoreLocal::get("DBMS") == "mssql") {
         $datetimestamp = strftime("%m/%d/%y %H:%M:%S %p", time());
     } else {
         $datetimestamp = strftime("%Y-%m-%d %H:%M:%S", time());
     }
     CoreLocal::set("LastID", CoreLocal::get("LastID") + 1);
     $trans_id = CoreLocal::get("LastID");
     if (strlen($strdescription) > 30) {
         $strdescription = substr($strdescription, 0, 30);
     }
     $values = array('datetime' => $datetimestamp, 'register_no' => $intregisterno, 'emp_no' => $intempno, 'trans_no' => MiscLib::nullwrap($inttransno), 'upc' => MiscLib::nullwrap($strupc), 'description' => $strdescription, 'trans_type' => MiscLib::nullwrap($strtransType), 'trans_subtype' => MiscLib::nullwrap($strtranssubType, true), 'trans_status' => MiscLib::nullwrap($strtransstatus, true), 'department' => MiscLib::nullwrap($intdepartment), 'quantity' => MiscLib::nullwrap($dblquantity), 'cost' => MiscLib::nullwrap($cost), 'unitPrice' => MiscLib::nullwrap($dblunitPrice), 'total' => MiscLib::nullwrap($dbltotal), 'regPrice' => MiscLib::nullwrap($dblregPrice), 'scale' => MiscLib::nullwrap($intscale), 'tax' => MiscLib::nullwrap($inttax), 'foodstamp' => MiscLib::nullwrap($intfoodstamp), 'discount' => MiscLib::nullwrap($dbldiscount), 'memDiscount' => MiscLib::nullwrap($dblmemDiscount), 'discountable' => MiscLib::nullwrap($intdiscountable), 'discounttype' => MiscLib::nullwrap($intdiscounttype), 'ItemQtty' => MiscLib::nullwrap($dblItemQtty), 'volDiscType' => MiscLib::nullwrap($intvolDiscType), 'volume' => MiscLib::nullwrap($intvolume), 'VolSpecial' => MiscLib::nullwrap($dblVolSpecial), 'mixMatch' => MiscLib::nullwrap($intmixMatch), 'matched' => MiscLib::nullwrap($intmatched), 'voided' => MiscLib::nullwrap($intvoided), 'memType' => MiscLib::nullwrap($memType), 'staff' => MiscLib::nullwrap($staff), 'percentDiscount' => MiscLib::nullwrap($percentDiscount), 'numflag' => MiscLib::nullwrap($numflag), 'charflag' => $charflag, 'card_no' => (string) $strCardNo);
     if (CoreLocal::get("DBMS") == "mssql" && CoreLocal::get("store") == "wfc") {
         unset($values["staff"]);
         $values["isStaff"] = MiscLib::nullwrap($staff);
     }
     $db->smart_insert("localtemptrans", $values);
     if ($strtransType == "I" || $strtransType == "D") {
         CoreLocal::set("repeatable", 1);
     }
     CoreLocal::set("toggletax", 0);
     CoreLocal::set("togglefoodstamp", 0);
     CoreLocal::set("SNR", 0);
     if ($intscale == 1) {
         CoreLocal::set("lastWeight", $dblquantity);
     }
 }