当前位置: 首页>>代码示例>>PHP>>正文


PHP MiscLib::truncate2方法代码示例

本文整理汇总了PHP中MiscLib::truncate2方法的典型用法代码示例。如果您正苦于以下问题:PHP MiscLib::truncate2方法的具体用法?PHP MiscLib::truncate2怎么用?PHP MiscLib::truncate2使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在MiscLib的用法示例。


在下文中一共展示了MiscLib::truncate2方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: addItem

 function addItem($row, $quantity, $priceObj)
 {
     if ($quantity == 0) {
         return False;
     }
     // enforce limit on discounting sale items
     $dsi = CoreLocal::get('DiscountableSaleItems');
     if ($dsi == 0 && $dsi !== '' && $priceObj->isSale()) {
         $row['discount'] = 0;
     }
     /*
       Use "quantity" field in products record as a per-transaction
       limit. This is analogous to a similar feature with sale items.
     */
     if (!$priceObj->isSale() && $row['quantity'] > 0) {
         $db = Database::tDataConnect();
         $query = "SELECT SUM(quantity) as qty FROM localtemptrans\n                WHERE upc='{$row['upc']}'";
         $result = $db->query($query);
         if ($db->num_rows($result) > 0) {
             $chkRow = $db->fetch_row($result);
             if ($chkRow['qty'] + $quantity > $row['quantity']) {
                 $this->error_msg = _("item only allows ") . $row['quantity'] . _(" per transaction");
                 return False;
             }
         }
     }
     $pricing = $priceObj->priceInfo($row, $quantity);
     TransRecord::addRecord(array('upc' => $row['upc'], 'description' => $row['description'], 'trans_type' => 'I', 'trans_subtype' => isset($row['trans_subtype']) ? $row['trans_subtype'] : '', 'department' => $row['department'], 'quantity' => $quantity, 'unitPrice' => $pricing['unitPrice'], 'total' => MiscLib::truncate2($pricing['unitPrice'] * $quantity), 'regPrice' => $pricing['regPrice'], 'scale' => $row['scale'], 'tax' => $row['tax'], 'foodstamp' => $row['foodstamp'], 'discount' => $pricing['discount'], 'memDiscount' => $pricing['memDiscount'], 'discountable' => $row['discount'], 'discounttype' => $row['discounttype'], 'ItemQtty' => $quantity, 'volDiscType' => $row['pricemethod'], 'volume' => $row['quantity'], 'VolSpecial' => $row['groupprice'], 'mixMatch' => $row['mixmatchcode'], 'cost' => isset($row['cost']) ? $row['cost'] * $quantity : 0.0, 'numflag' => isset($row['numflag']) ? $row['numflag'] : 0, 'charflag' => isset($row['charflag']) ? $row['charflag'] : ''));
     return true;
 }
开发者ID:phpsmith,项目名称:IS4C,代码行数:30,代码来源:BasicPM.php

示例2: preprocess

 function preprocess()
 {
     // check for posts before drawing anything, so we can redirect
     if (isset($_REQUEST['reginput'])) {
         $input = strtoupper(trim($_REQUEST['reginput']));
         // CL always exits
         if ($input == "CL") {
             CoreLocal::set("msgrepeat", 0);
             CoreLocal::set("toggletax", 0);
             CoreLocal::set("togglefoodstamp", 0);
             $this->change_page(MiscLib::baseURL() . "gui-modules/pos2.php");
             return false;
         } elseif ($input == "") {
             $this->change_page('BitCoinPaymentPage.php?amount=' . CoreLocal::get('amtdue'));
             return false;
         } elseif ($input != "" && substr($input, -2) != "CL") {
             // any other input is an alternate amount
             // convert cents to dollars and make sure it's valid
             $this->amt = $input;
             if (is_numeric($input)) {
                 $this->amt = MiscLib::truncate2($this->amt / 100.0);
             }
             if ($this->validateAmount($this->amt)) {
                 $this->change_page('BitCoinPaymentPage.php?amount=' . $this->amt);
                 return false;
             }
         }
     }
     // post?
     return true;
 }
开发者ID:phpsmith,项目名称:IS4C,代码行数:31,代码来源:BitCoinAmountPage.php

示例3: errorCheck

 /**
   Check for errors
   @return True or an error message string
 */
 public function errorCheck()
 {
     if (MiscLib::truncate2(CoreLocal::get("amtdue")) < MiscLib::truncate2($this->amount)) {
         return DisplayLib::xboxMsg(_("tender cannot exceed purchase amount"), DisplayLib::standardClearButton());
     }
     return true;
 }
开发者ID:phpsmith,项目名称:IS4C,代码行数:11,代码来源:ManagerApproveTender.php

示例4: priceInfo

 public function priceInfo($row, $quantity = 1)
 {
     if (is_array($this->savedInfo)) {
         return $this->savedInfo;
     }
     $ret = array();
     $ret["regPrice"] = $row['normal_price'];
     $ret["unitPrice"] = $row['special_price'];
     /* if not by weight, just use the sticker price 
           (for scaled items, the UPC parse module
           calculates a weight estimate and sets a quantity
           so normal_price can be used. This could be done
           for all items, but typically the deli doesn't
           keep good track of whether their items are
           marked scale correctly since it only matters when an
           item goes on sale
        */
     if (isset($row['stickerprice']) && $row['scale'] == 0) {
         $ret['regPrice'] = $row['stickerprice'];
     }
     $ret['discount'] = ($ret['regPrice'] - $row['special_price']) * $quantity;
     $ret['memDiscount'] = 0;
     if ($row['line_item_discountable'] == 1 && CoreLocal::get("itemPD") > 0) {
         $discount = $row['special_price'] * (CoreLocal::get("itemPD") / 100);
         $ret["unitPrice"] = $row['special_price'] - $discount;
         $ret["discount"] += $discount * $quantity;
     }
     // enforce per-transaction limit
     if ($row['specialpricemethod'] == 0 && $row['specialquantity'] > 0) {
         $tdb = Database::tDataConnect();
         $chkQ = "SELECT sum(ItemQtty) FROM\n                localtemptrans WHERE upc='{$row['upc']}'";
         if (strlen($row['mixmatchcode']) > 0 && $row['mixmatchcode'][0] == 'b') {
             $chkQ .= " OR mixMatch='{$row['mixmatchcode']}'";
         }
         $chkR = $tdb->query($chkQ);
         $prevSales = 0;
         if ($tdb->num_rows($chkR) > 0) {
             $prevSales = array_pop($tdb->fetch_row($chkR));
         }
         if ($prevSales >= $row['specialquantity']) {
             // already sold the limit; use non-sale price
             $ret['unitPrice'] = $row['normal_price'];
             $ret['discount'] = 0;
         } else {
             if ($prevSales + $quantity > $row['specialquantity']) {
                 // this multiple qty ring will pass the limit
                 // set discount based on appropriate quantity
                 // and adjust unitPrice so total comes out correctly
                 $discountQty = $row['specialquantity'] - $prevSales;
                 $ret['discount'] = ($ret['regPrice'] - $row['special_price']) * $discountQty;
                 $total = $ret['regPrice'] * $quantity - $ret['discount'];
                 $ret['unitPrice'] = MiscLib::truncate2($total / $quantity);
             }
         }
     }
     $this->savedRow = $row;
     $this->savedInfo = $ret;
     return $ret;
 }
开发者ID:phpsmith,项目名称:IS4C,代码行数:59,代码来源:EveryoneSale.php

示例5: calculate

 public function calculate($discountable_total = 0)
 {
     $discount = parent::calculate();
     if (CoreLocal::get('NeedDiscountFlag') === 1) {
         $extra = 0.05 * CoreLocal::get('discountableTotal');
         $discount = MiscLib::truncate2($discount + $extra);
     }
     return $discount;
 }
开发者ID:phpsmith,项目名称:IS4C,代码行数:9,代码来源:NeedDiscountModule.php

示例6: addItem

 function addItem($row, $quantity, $priceObj)
 {
     if ($quantity == 0) {
         return false;
     }
     $pricing = $priceObj->priceInfo($row, $quantity);
     TransRecord::addRecord(array('upc' => $row['upc'], 'description' => $row['description'], 'trans_type' => 'I', 'trans_subtype' => isset($row['trans_subtype']) ? $row['trans_subtype'] : '', 'department' => $row['department'], 'quantity' => $quantity, 'unitPrice' => $pricing['unitPrice'], 'total' => MiscLib::truncate2($pricing['unitPrice'] * $quantity), 'regPrice' => $pricing['regPrice'], 'scale' => $row['scale'], 'tax' => $row['tax'], 'foodstamp' => $row['foodstamp'], 'discount' => $pricing['discount'], 'memDiscount' => $pricing['memDiscount'], 'discountable' => $row['discounttype'] > 0 ? 0 : $row['discount'], 'discounttype' => $row['discounttype'], 'ItemQtty' => $quantity, 'volDiscType' => $row['pricemethod'], 'volume' => $row['quantity'], 'VolSpecial' => $row['groupprice'], 'mixMatch' => $row['mixmatchcode'], 'cost' => isset($row['cost']) ? $row['cost'] * $quantity : 0.0, 'numflag' => isset($row['numflag']) ? $row['numflag'] : 0, 'charflag' => isset($row['charflag']) ? $row['charflag'] : ''));
     return True;
 }
开发者ID:phpsmith,项目名称:IS4C,代码行数:9,代码来源:NoDiscOnSalesPM.php

示例7: errorCheck

 /**
   Check for errors
   @return True or an error message string
 */
 public function errorCheck()
 {
     global $CORE_LOCAL;
     $this->conn = CoopCredLib::ccDataConnect();
     if ($this->conn === False) {
         return "Error: ccDataConnect() failed.";
     }
     $programOK = CoopCredLib::programOK($this->tender_code, $this->conn);
     if ($programOK !== True) {
         return DisplayLib::boxMsg("{$programOK}");
     }
     $subtotals = CoopCredLib::getCCredSubtotals($this->tender_code, $this->conn);
     if ($subtotals !== True) {
         return DisplayLib::boxMsg("{$subtotals}");
     }
     $pc = $CORE_LOCAL->get("CCredProgramCode");
     //$pc = $CORE_LOCAL->get("programCode");
     /* For Refunding the total without entering the exact amount
      *  i.e. with QA alone.
      */
     if ($this->amount == '' && $this->DefaultTotal() < 0) {
         $this->amount = $this->DefaultTotal();
     }
     /* No Available Balance.
      */
     if ($CORE_LOCAL->get("{$pc}availBal") < 0) {
         return DisplayLib::boxMsg(_("Member") . " #" . $CORE_LOCAL->get("memberID") . ' ' . _("does not have enough Coop Cred in ") . '<b>' . $CORE_LOCAL->get("{$pc}programName") . '</b>' . _(" to cover this purchase."));
     }
     /* Tender more than Available Balance
      * the amount remaining less the amount of this type already tendered
      * in the current transaction.
      * I think availBal already includes memChargeTotal.
      */
     if (abs($CORE_LOCAL->get("{$pc}memChargeTotal")) + $this->amount >= $CORE_LOCAL->get("{$pc}availBal") + 0.005) {
         $memChargeCommitted = $CORE_LOCAL->get("{$pc}availBal") + $CORE_LOCAL->get("{$pc}memChargeTotal");
         return DisplayLib::xboxMsg(_("The amount of Coop Cred you have in ") . '<b>' . $CORE_LOCAL->get("{$pc}programName") . '</b>' . _(" is only \$") . number_format($memChargeCommitted, 2) . '.');
     }
     /* Tender more than Amount Due.
      */
     if (MiscLib::truncate2($CORE_LOCAL->get("amtdue")) < MiscLib::truncate2($this->amount)) {
         return DisplayLib::xboxMsg(_("The amount of Coop Cred tendered may not exceed the Amount Due."));
     }
     /* Add the tender to those used in this transaction.
      */
     if ($CORE_LOCAL->get('CCredTendersUsed') == '') {
         $CORE_LOCAL->set('CCredTendersUsed', array("{$this->tender_code}" => $CORE_LOCAL->get("CCredProgramID")));
     } else {
         $tu = $CORE_LOCAL->get('CCredTendersUsed');
         if (!array_key_exists("{$this->tender_code}", $tu)) {
             $tu["{$this->tender_code}"] = $CORE_LOCAL->get("CCredProgramID");
             $CORE_LOCAL->set('CCredTendersUsed', $tu);
         }
     }
     return true;
     // errorCheck()
 }
开发者ID:phpsmith,项目名称:IS4C,代码行数:60,代码来源:CoopCredTender.php

示例8: errorCheck

 /**
   Check for errors
   @return True or an error message string
 */
 public function errorCheck()
 {
     if (MiscLib::truncate2(CoreLocal::get("amtdue")) < MiscLib::truncate2($this->amount)) {
         return DisplayLib::xboxMsg(_("store transfer exceeds purchase amount"), DisplayLib::standardClearButton());
     }
     $db = Database::pDataConnect();
     $query = 'SELECT chargeOk FROM custdata WHERE chargeOk=1 AND CardNo=' . CoreLocal::get('memberID');
     $result = $db->query($query);
     if ($db->num_rows($result) == 0) {
         return DisplayLib::xboxMsg(_("member cannot make transfers"), DisplayLib::standardClearButton());
     }
     return true;
 }
开发者ID:phpsmith,项目名称:IS4C,代码行数:17,代码来源:StoreTransferTender.php

示例9: parse

 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;
 }
开发者ID:phpsmith,项目名称:IS4C,代码行数:51,代码来源:ClubCard.php

示例10: priceInfo

 public function priceInfo($row, $quantity = 1)
 {
     if (is_array($this->savedInfo)) {
         return $this->savedInfo;
     }
     $ret = array();
     $ret["regPrice"] = $row['normal_price'];
     $ret["unitPrice"] = $row['normal_price'];
     $ret['discount'] = 0;
     $ret['memDiscount'] = MiscLib::truncate2($row['special_price'] * $quantity);
     if (CoreLocal::get("isMember")) {
         $ret['unitPrice'] -= $row['special_price'];
     }
     $this->savedRow = $row;
     $this->savedInfo = $ret;
     return $ret;
 }
开发者ID:phpsmith,项目名称:IS4C,代码行数:17,代码来源:SlidingMemSale.php

示例11: parse

 function parse($str)
 {
     $ret = $this->default_json();
     $left = substr($str, 0, strlen($str) - 2);
     if ($left == "") {
         $left = 1;
     }
     if (strlen($left) > 4) {
         $ret['output'] = DisplayLib::boxMsg(MiscLib::truncate2($left / 100) . _(" tare not supported"), _('Invalid Tare'), false, DisplayLib::standardClearButton());
     } elseif ($left / 100 > CoreLocal::get("weight") && CoreLocal::get("weight") > 0) {
         $ret['output'] = DisplayLib::boxMsg(_("Tare cannot be") . "<br />" . _("greater than item weight"), _('Excess Tare'), false, DisplayLib::standardClearButton());
     } else {
         TransRecord::addTare($left);
         $ret['output'] = DisplayLib::lastpage();
     }
     return $ret;
 }
开发者ID:phpsmith,项目名称:IS4C,代码行数:17,代码来源:AutoTare.php

示例12: errorCheck

 /**
   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;
 }
开发者ID:phpsmith,项目名称:IS4C,代码行数:23,代码来源:StoreChargeTender.php

示例13: priceInfo

 public function priceInfo($row, $quantity = 1)
 {
     if (is_array($this->savedInfo)) {
         return $this->savedInfo;
     }
     $ret = array();
     $ret["regPrice"] = $row['normal_price'];
     $ret["unitPrice"] = $row['normal_price'];
     $ret['discount'] = 0;
     $ret['memDiscount'] = 0;
     if (CoreLocal::get("casediscount") > 0 && CoreLocal::get("casediscount") <= 100) {
         $casediscount = (100 - CoreLocal::get("casediscount")) / 100;
         $ret['unitPrice'] = MiscLib::truncate2($casediscount * $ret['unitPrice']);
         $ret['regPrice'] = $ret['unitPrice'];
         CoreLocal::set("casediscount", 0);
     }
     $this->savedRow = $row;
     $this->savedInfo = $ret;
     return $ret;
 }
开发者ID:phpsmith,项目名称:IS4C,代码行数:20,代码来源:CasePriceDiscount.php

示例14: testMiscLib

 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);
     }
 }
开发者ID:phpsmith,项目名称:IS4C,代码行数:22,代码来源:BaseLibsTest.php

示例15: priceInfo

 public function priceInfo($row, $quantity = 1)
 {
     if (is_array($this->savedInfo)) {
         return $this->savedInfo;
     }
     $ret = array();
     $ret["regPrice"] = $row['normal_price'];
     $ret["unitPrice"] = $row['normal_price'];
     $ret['discount'] = 0;
     $ret['memDiscount'] = MiscLib::truncate2(($ret['regPrice'] - $row['special_price']) * $quantity);
     if (CoreLocal::get("isMember") == 1 || CoreLocal::get("memberID") == CoreLocal::get("visitingMem") && CoreLocal::get('visitingMem') !== '') {
         $ret["unitPrice"] = $row['special_price'];
     }
     if ($row['line_item_discountable'] == 1 && CoreLocal::get("itemPD") > 0) {
         $discount = $ret['unitPrice'] * (CoreLocal::get("itemPD") / 100);
         $ret["unitPrice"] -= $discount;
         $ret["discount"] += $discount * $quantity;
     }
     $this->savedRow = $row;
     $this->savedInfo = $ret;
     return $ret;
 }
开发者ID:phpsmith,项目名称:IS4C,代码行数:22,代码来源:MemberSale.php


注:本文中的MiscLib::truncate2方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。