function preprocess() { global $FANNIE_OP_DB; $this->title = _("Fannie") . ' : ' . _("Manufacturer Shelf Tags"); $this->header = _("Manufacturer Shelf Tags"); if (FormLib::get_form_value('manufacturer', False) !== false) { $manu = FormLib::get_form_value('manufacturer'); $pageID = FormLib::get_form_value('sID', 0); $cond = ""; if (is_numeric($_REQUEST['manufacturer'])) { $cond = " p.upc LIKE ? "; } else { $cond = " p.brand LIKE ? "; } $dbc = FannieDB::get($FANNIE_OP_DB); $prodP = $dbc->prepare_statement("\n SELECT\n p.upc\n FROM\n products AS p\n WHERE {$cond}\n "); $prodR = $dbc->exec_statement($prodP, array('%' . $manu . '%')); $tag = new ShelftagsModel($dbc); $product = new ProductsModel($dbc); while ($prodW = $dbc->fetch_row($prodR)) { $product->upc($prodW['upc']); $info = $product->getTagData(); $tag->id($pageID); $tag->upc($prodW['upc']); $tag->setData($info); $tag->save(); } $this->msgs = '<em>Created tags for manufacturer</em> <br /><a href="ShelfTagIndex.php">Home</a>'; } return true; }
function preprocess() { global $FANNIE_OP_DB; if (FormLib::get_form_value('deptStart', False) !== false) { $start = FormLib::get_form_value('deptStart'); $end = FormLib::get_form_value('deptEnd'); $pageID = FormLib::get_form_value('sID', 0); $dbc = FannieDB::get($FANNIE_OP_DB); $prodP = $dbc->prepare_statement("\n SELECT p.upc\n FROM products AS p\n WHERE p.department BETWEEN ? AND ?\n "); $prodR = $dbc->exec_statement($prodP, array($start, $end)); $tag = new ShelftagsModel($dbc); $product = new ProductsModel($dbc); while ($row = $dbc->fetch_row($prodR)) { $product->upc($row['upc']); $info = $product->getTagData(); $tag->id($pageID); $tag->upc($row['upc']); $tag->setData($info); $tag->save(); } $this->msgs = sprintf('<em>Created tags for departments #%d through #%d</em> <br /><a href="ShelfTagIndex.php">Home</a>', $start, $end); } return true; }
function post_createBatch_handler() { global $FANNIE_OP_DB; $dbc = FannieDB::get($FANNIE_OP_DB); $type = $this->form->batchType; $name = $this->form->batchName; $startdate = $this->form->startDate; $enddate = $this->form->endDate; $owner = $this->form->batchOwner; $priority = 0; $upcs = $this->form->upc; $prices = $this->form->price; $btype = new BatchTypeModel($dbc); $btype->batchTypeID($type); if (!$btype->load()) { echo 'Invalid Batch Type ' . $type; return false; } $discounttype = $btype->discType(); // make sure item data is present before creating batch if (!is_array($upcs) || !is_array($prices) || count($upcs) != count($prices) || count($upcs) == 0) { echo 'Invalid item data'; return false; } $batch = new BatchesModel($dbc); $batch->startDate($startdate); $batch->endDate($enddate); $batch->batchName($name); $batch->batchType($type); $batch->discountType($discounttype); $batch->priority($priority); $batch->owner($owner); $batchID = $batch->save(); if ($this->config->get('STORE_MODE') === 'HQ') { StoreBatchMapModel::initBatch($batchID); } if ($dbc->tableExists('batchowner')) { $insQ = $dbc->prepare_statement("insert batchowner values (?,?)"); $insR = $dbc->exec_statement($insQ, array($batchID, $owner)); } // add items to batch for ($i = 0; $i < count($upcs); $i++) { $upc = $upcs[$i]; $price = isset($prices[$i]) ? $prices[$i] : 0.0; $list = new BatchListModel($dbc); $list->upc(BarcodeLib::padUPC($upc)); $list->batchID($batchID); $list->salePrice($price); $list->groupSalePrice($price); $list->active(0); $list->pricemethod(0); $list->quantity(0); $list->save(); } /** If tags were requested and it's price change batch, make them Lookup vendor info for each item then add a shelftag record */ $tagset = $this->form->tagset; if ($discounttype == 0 && $tagset !== '') { $vendorID = $this->form->preferredVendor; $tag = new ShelftagsModel($dbc); $product = new ProductsModel($dbc); for ($i = 0; $i < count($upcs); $i++) { $upc = $upcs[$i]; $price = isset($prices[$i]) ? $prices[$i] : 0.0; $product->upc($upc); $info = $product->getTagData($price); $tag->id($tagset); $tag->upc($upc); $tag->description($info['description']); $tag->normal_price($price); $tag->brand($info['brand']); $tag->sku($info['sku']); $tag->size($info['size']); $tag->units($info['units']); $tag->vendor($info['vendor']); $tag->pricePerUnit($info['pricePerUnit']); $tag->save(); } } return 'Location: newbatch/BatchManagementTool.php?startAt=' . $batchID; }
private function addToPos($upc, $vid, $price, $dept, $tags = -1) { global $FANNIE_OP_DB; $dbc = FannieDB::get($FANNIE_OP_DB); $p = $dbc->prepare_statement("SELECT i.*,v.vendorName FROM vendorItems AS i\n LEFT JOIN vendors AS v ON v.vendorID=i.vendorID\n WHERE i.vendorID=? AND upc=?"); $vinfo = $dbc->exec_statement($p, array($vid, $upc)); $vinfo = $dbc->fetch_row($vinfo); $p = $dbc->prepare_statement("SELECT * FROM departments WHERE dept_no=?"); $dinfo = $dbc->exec_statement($p, array($dept)); $dinfo = $dbc->fetch_row($dinfo); $model = new ProductsModel($dbc); $model->upc(BarcodeLib::padUPC($upc)); $model->description($vinfo['description']); $model->normal_price($price); $model->department($dept); $model->tax($dinfo['dept_tax']); $model->foodstamp($dinfo['dept_fs']); $model->cost($vinfo['cost']); $model->default_vendor_id($vid); $model->brand($vinfo['brand']); $model->store_id(1); $model->save(); $xInsQ = $dbc->prepare_statement("INSERT INTO prodExtra (upc,manufacturer,distributor,cost,margin,variable_pricing,location,\n case_quantity,case_cost,case_info) VALUES\n (?,?,?,?,0.00,0,'','',0.00,'')"); $args = array($upc, $vinfo['brand'], $vinfo['vendorName'], $vinfo['cost']); $dbc->exec_statement($xInsQ, $args); if ($tags !== -1) { $tag = new ShelftagsModel($dbc); $tag->id($tags); $tag->upc($upc); $info = $model->getTagData(); $tag->normal_price($info['normal_price']); $tag->description($info['description']); $tag->brand($info['brand']); $tag->vendor($info['vendor']); $tag->sku($info['sku']); $tag->size($info['size']); $tag->units($info['units']); $tag->pricePerUnit($info['pricePerUnit']); $tag->save(); } echo "Item added"; }
$bid = FormLib::get_form_value('batchID'); $sid = FormLib::get_form_value('queueID', 0); if ($sid == 99) { $sid = 0; } $price = FormLib::get_form_value('price', 0); $model = new BatchListModel($dbc); $model->batchID($bid); $model->upc($upc); $model->salePrice($price); $model->pricemethod(0); $model->quantity(0); $model->save(); $product = new ProductsModel($dbc); $product->upc($upc); $info = $product->getTagData($price); /* create a shelftag */ $tag = new ShelftagsModel($dbc); $tag->id($sid); $tag->upc($upc); $tag->description($info['description']); $tag->normal_price($price); $tag->brand($info['brand']); $tag->sku($info['sku']); $tag->size($info['size']); $tag->units($info['units']); $tag->vendor($info['vendor']); $tag->pricePerUnit($info['pricePerUnit']); $tag->save(); break; case 'batchDel':
* Currently the vendor name input is just text, not controlled. * It would be better if it used size and unitofmeasure from the form. * In update, would need a post-update shelftag create as in insertItem.php */ require dirname(__FILE__) . '/../config.php'; if (!class_exists('FannieAPI')) { include $FANNIE_ROOT . 'classlib2.0/FannieAPI.php'; } if (basename(__FILE__) != basename($_SERVER['PHP_SELF'])) { return; } $dbc = FannieDB::get($FANNIE_OP_DB); $upc = BarcodeLib::padUPC(FormLib::get('upc')); $product = new ProductsModel($dbc); $product->upc($upc); $tagData = $product->getTagData(); $prodQ = $dbc->prepare_statement("SELECT p.*,s.superID FROM products AS p\n LEFT JOIN MasterSuperDepts AS s ON p.department=s.dept_ID\n where upc=?"); $prodR = $dbc->exec_statement($prodQ, array($upc)); $prodW = $dbc->fetchRow($prodR); $superID = $prodW['superID']; $price = $tagData['normal_price']; $desc = $tagData['description']; $brand = $tagData['brand']; $size = $tagData['size']; $units = $tagData['units']; $sku = $tagData['sku']; $vendor = $tagData['vendor']; $ppo = $tagData['pricePerUnit']; ?> <!doctype html> <html>