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 ""; }
/** 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; }
/** Check for errors @return True or an error message string */ public function errorCheck() { //force negative entered value when the total is negative. if (CoreLocal::get("amtdue") < 0 && $this->amount >= 0) { $this->amount = -1 * $this->amount; } $clearButton = array('OK [clear]' => 'parseWrapper(\'CL\');'); if (CoreLocal::get("LastID") == 0) { return DisplayLib::boxMsg(_("no transaction in progress"), '', false, $clearButton); } elseif (CoreLocal::get('refund') == 1) { CoreLocal::set('refund', 0); return DisplayLib::boxMsg(_("refund cannot apply to tender"), '', false, $clearButton); } else { if ($this->amount > 99999.99000000001) { return DisplayLib::boxMsg(_("tender amount of") . " " . $this->amount . "<br />" . _("exceeds allowable limit"), '', false, $clearButton); } else { if (CoreLocal::get("ttlflag") == 0) { return DisplayLib::boxMsg(_("transaction must be totaled before tender can be accepted"), '', false, array('Total [subtotal]' => 'parseWrapper(\'TL\');$(\'#reginput\').focus();', 'Dimiss [clear]' => 'parseWrapper(\'CL\');')); } else { if ($this->name_string === "") { return DisplayLib::inputUnknown(); } elseif (CoreLocal::get('fntlflag') && CoreLocal::get('fsEligible') < 0 && abs($this->amount - CoreLocal::get('fsEligible')) < 0.005) { // not actually an error // if return tender exactly matches FS elgible return amount // pass through so the subsequent exact amount error // does not occur. } elseif (abs($this->amount - CoreLocal::get('amtdue')) > 0.005 && CoreLocal::get("amtdue") < 0 && $this->amount != 0) { // the return tender needs to be exact because the transaction state can get weird. return DisplayLib::xboxMsg(_("return tender must be exact"), $clearButton); } elseif (CoreLocal::get("amtdue") > 0 && $this->amount < 0) { return DisplayLib::xboxMsg(_("Why are you using a negative number for a positive sale?"), $clearButton); } elseif (CoreLocal::get('TenderHardMinMax') && $this->amount > $this->max_limit) { return DisplayLib::boxMsg("\$" . $this->amount . " " . _("is greater than tender limit for") . " " . $this->name_string, '', false, $clearButton); } } } } return true; }
function preprocess() { $this->display = ""; $sd = MiscLib::scaleObject(); $entered = ""; if (isset($_REQUEST["reginput"])) { $entered = strtoupper(trim($_REQUEST["reginput"])); } if (substr($entered, -2) == "CL") { $entered = "CL"; } if ($entered == "RI") { $entered = CoreLocal::get("strEntered"); } if (CoreLocal::get("msgrepeat") == 1 && $entered != "CL") { $entered = CoreLocal::get("strRemembered"); CoreLocal::set('strRemembered', ''); } CoreLocal::set("strEntered", $entered); $json = array(); if ($entered != "") { if (in_array("Paycards", CoreLocal::get("PluginList"))) { /* this breaks the model a bit, but I'm putting * putting the CC parser first manually to minimize * code that potentially handles the PAN */ if (CoreLocal::get("PaycardsCashierFacing") == "1" && substr($entered, 0, 9) == "PANCACHE:") { /* cashier-facing device behavior; run card immediately */ $entered = substr($entered, 9); CoreLocal::set("CachePanEncBlock", $entered); } $pe = new paycardEntered(); if ($pe->check($entered)) { $valid = $pe->parse($entered); $entered = "PAYCARD"; CoreLocal::set("strEntered", ""); $json = $valid; } CoreLocal::set("quantity", 0); CoreLocal::set("multiple", 0); } /* FIRST PARSE CHAIN: * Objects belong in the first parse chain if they * modify the entered string, but do not process it * This chain should be used for checking prefixes/suffixes * to set up appropriate session variables. */ $parser_lib_path = $this->page_url . "parser-class-lib/"; if (!is_array(CoreLocal::get("preparse_chain"))) { CoreLocal::set("preparse_chain", PreParser::get_preparse_chain()); } foreach (CoreLocal::get("preparse_chain") as $cn) { if (!class_exists($cn)) { continue; } $p = new $cn(); if ($p->check($entered)) { $entered = $p->parse($entered); } if (!$entered || $entered == "") { break; } } if ($entered != "" && $entered != "PAYCARD") { /* * SECOND PARSE CHAIN * these parser objects should process any input * completely. The return value of parse() determines * whether to call lastpage() [list the items on screen] */ if (!is_array(CoreLocal::get("parse_chain"))) { CoreLocal::set("parse_chain", Parser::get_parse_chain()); } $result = False; foreach (CoreLocal::get("parse_chain") as $cn) { if (!class_exists($cn)) { continue; } $p = new $cn(); if ($p->check($entered)) { $result = $p->parse($entered); break; } } if ($result && is_array($result)) { // postparse chain: modify result if (!is_array(CoreLocal::get("postparse_chain"))) { CoreLocal::set("postparse_chain", PostParser::getPostParseChain()); } foreach (CoreLocal::get('postparse_chain') as $class) { if (!class_exists($class)) { continue; } $obj = new $class(); $result = $obj->parse($result); } $json = $result; if (isset($result['udpmsg']) && $result['udpmsg'] !== False) { if (is_object($sd)) { $sd->WriteToScale($result['udpmsg']); } } } else { $arr = array('main_frame' => false, 'target' => '.baseHeight', 'output' => DisplayLib::inputUnknown()); $json = $arr; if (is_object($sd)) { $sd->WriteToScale('errorBeep'); } } } } CoreLocal::set("msgrepeat", 0); if (isset($json['main_frame']) && $json['main_frame'] != False) { $this->change_page($json['main_frame']); return False; } if (isset($json['output']) && !empty($json['output'])) { $this->display = $json['output']; } if (isset($json['retry']) && $json['retry'] != False) { $this->add_onload_command("setTimeout(\"inputRetry('" . $json['retry'] . "');\", 150);\n"); } if (isset($json['receipt']) && $json['receipt'] != False) { $ref = isset($json['trans_num']) ? $json['trans_num'] : ReceiptLib::mostRecentReceipt(); $this->add_onload_command("receiptFetch('" . $json['receipt'] . "', '" . $ref . "');\n"); } if (CoreLocal::get('CustomerDisplay') === true) { $child_url = MiscLib::baseURL() . 'gui-modules/posCustDisplay.php'; $this->add_onload_command("setCustomerURL('{$child_url}');\n"); $this->add_onload_command("reloadCustomerDisplay();\n"); } return true; }
/** 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; }
} foreach (CoreLocal::get('postparse_chain') as $class) { if (!class_exists($class)) { continue; } $obj = new $class(); $result = $obj->parse($result); } $json = $result; if (isset($result['udpmsg']) && $result['udpmsg'] !== False) { if (is_object($sd)) { $sd->WriteToScale($result['udpmsg']); } } } else { $arr = array('main_frame' => false, 'target' => '.baseHeight', 'output' => DisplayLib::inputUnknown()); $json = $arr; if (is_object($sd)) { $sd->WriteToScale('errorBeep'); } } } } CoreLocal::set("msgrepeat", 0); if (empty($json)) { echo "{}"; } else { if (isset($json['redraw_footer']) && $json['redraw_footer'] !== False) { $json['redraw_footer'] = DisplayLib::printfooter(); } if (isset($json['scale']) && $json['scale'] !== False) {
public function testDisplayLib() { $footer = DisplayLib::printfooter(); $this->assertInternalType('string', $footer); $this->assertNotEmpty($footer); $pmsg = DisplayLib::plainmsg('test message'); $this->assertInternalType('string', $pmsg); $this->assertNotEmpty($pmsg); $this->assertContains('test message', $pmsg); $mbox = DisplayLib::msgbox('test msgbox', '', True); $this->assertInternalType('string', $mbox); $this->assertNotEmpty($mbox); $this->assertContains('test msgbox', $mbox); $xbox = DisplayLib::xboxMsg('test xboxMsg'); $this->assertInternalType('string', $xbox); $this->assertNotEmpty($xbox); $this->assertContains('test xboxMsg', $xbox); $bmsg = DisplayLib::boxMsg('test boxMsg', '', True); $this->assertInternalType('string', $bmsg); $this->assertNotEmpty($bmsg); $this->assertContains('test boxMsg', $bmsg); $unk = DisplayLib::inputUnknown(); $this->assertInternalType('string', $unk); $this->assertNotEmpty($unk); $headerb = DisplayLib::printheaderb(); $this->assertInternalType('string', $headerb); $this->assertNotEmpty($headerb); $item = DisplayLib::printItem('name', 'weight', '1.99', 'T', 1); $this->assertInternalType('string', $item); $this->assertNotEmpty($item); $itemC = DisplayLib::printItemColor('004080', 'name', 'weight', '1.99', 'T', 2); $this->assertInternalType('string', $itemC); $this->assertNotEmpty($itemC); $itemH = DisplayLib::printItemColorHilite('004080', 'name', 'weight', '1.99', 'T'); $this->assertInternalType('string', $itemH); $this->assertNotEmpty($itemH); CoreLocal::set('weight', 0); CoreLocal::set('scale', 0); CoreLocal::set('SNR', 0); $basic = DisplayLib::scaledisplaymsg(); $this->assertInternalType('string', $basic); $this->assertEquals('0.00 lb', $basic); $scale_in_out = array('S11000' => '0.00 lb', 'S11001' => '0.01 lb', 'S11' => '_ _ _ _', 'S141' => '_ _ _ _', 'S143' => '0.00 lb', 'S145' => 'err -0', 'S142' => 'error', 'ASDF' => '? ? ? ?', 'S144000' => '0.00 lb', 'S144002' => '0.02 lb'); foreach ($scale_in_out as $input => $output) { $test = DisplayLib::scaledisplaymsg($input); $this->assertInternalType('array', $test); $this->assertArrayHasKey('display', $test); $this->assertEquals($output, $test['display']); } $this->assertEquals(1, CoreLocal::get('scale')); $this->assertEquals(0.02, CoreLocal::get('weight')); CoreLocal::set('SNR', '4011'); $both = DisplayLib::scaledisplaymsg('S11050'); $this->assertInternalType('array', $both); $this->assertArrayHasKey('display', $both); $this->assertArrayHasKey('upc', $both); $this->assertEquals('0.50 lb', $both['display']); $this->assertEquals('4011', $both['upc']); $list = DisplayLib::listItems(0, 0); $this->assertInternalType('string', $list); $rf = DisplayLib::printReceiptFooter(); $this->assertInternalType('string', $rf); $draw = DisplayLib::drawItems(0, 11, 0); $this->assertInternalType('string', $draw); $lp = DisplayLib::lastpage(); $this->assertInternalType('string', $lp); $this->assertEquals($lp, $list); }