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; }