$action = "ChangeOneItem"; if ($dbc->num_rows($chk) == 0) { $dbc->smart_insert('scaleItems', $scale_array); $action = "WriteOneItem"; } else { unset($scale_array['plu']); $dbc->smart_update('scaleItems', $scale_array, "plu='{$upc}'"); $action = "ChangeOneItem"; } include 'hobartcsv/parse.php'; parseitem($action, $s_plu, trim($scale_array["itemdesc"], "'"), $scale_array['tare'], $scale_array['shelflife'], $scale_array['price'], $scale_array['bycount'], $s_type, 0.0, trim($scale_array['text'], "'"), $scale_array['label'], $scale_array['graphics'] == 1 ? 121 : 0); } /* 10. Delete and re-add to product-related tables on the lanes. */ /* push updates to the lanes */ include 'laneUpdates_WEFC_Toronto.php'; updateAllLanes($upc, array("products", "productUser")); // $dbc is looking at lane db now, so change it back. // What is the DB function to do this? FannieDB::get()? // We're not in the right environment for that. $dbc = new SQLManager($FANNIE_SERVER, $FANNIE_SERVER_DBMS, $FANNIE_OP_DB, $FANNIE_SERVER_USER, $FANNIE_SERVER_PW); /* 'i9el. Update likecodes */ /* update the item's likecode if specified also update other items in the likecode if the appropriate box isn't checked */ if (isset($_REQUEST['likeCode']) && $_REQUEST['likeCode'] != -1) { $dbc->query("DELETE FROM upcLike WHERE upc='{$upc}'"); $lcQ = "INSERT INTO upcLike (upc,likeCode) VALUES ('{$upc}',{$_REQUEST['likeCode']})"; $dbc->query($lcQ); if (!isset($_REQUEST['update'])) { $upcsQ = "SELECT upc FROM upcLike WHERE likeCode={$_REQUEST['likeCode']} AND upc <> '{$upc}'"; $upcsR = $dbc->query($upcsQ);
function save_item($isNew) { $FANNIE_PRODUCT_MODULES = $this->config->get('PRODUCT_MODULES'); $FANNIE_URL = $this->config->get('URL'); $upc = FormLib::get_form_value('upc', ''); if ($upc === '' || !is_numeric($upc)) { return '<span style="color:red;">Error: bad UPC:</span> ' . $upc; } $upc = BarcodeLib::padUPC($upc); $audited = false; if (FannieAuth::validateUserQuiet('pricechange')) { // validated; nothing to do } elseif (FannieAuth::validateUserQuiet('audited_pricechange')) { $audited = true; } elseif (($range = FannieAuth::validateUserLimited('pricechange')) !== false) { // validated for certain departments; nothing to do } else { // not authorized to make edits return '<span style="color:red;">Error: Log in to edit</span>'; } uasort($FANNIE_PRODUCT_MODULES, array('ItemEditorPage', 'sortModules')); $form = new \COREPOS\common\mvc\FormValueContainer(); foreach ($FANNIE_PRODUCT_MODULES as $class => $params) { $mod = new $class(); $mod->setConnection($this->connection); $mod->setConfig($this->config); $mod->setForm($form); $mod->SaveFormData($upc); } /* push updates to the lanes */ $dbc = $this->connection; $dbc->selectDB($this->config->get('OP_DB')); $FANNIE_COOP_ID = $this->config->get('COOP_ID'); if (isset($FANNIE_COOP_ID) && $FANNIE_COOP_ID == 'WEFC_Toronto') { updateAllLanes($upc, array('products', 'productUser')); } else { updateProductAllLanes($upc); } if ($audited) { $lc = FormLib::get('likeCode', -1); $no_update = FormLib::get('LikeCodeNoUpdate', false); if ($lc != -1 && !$no_update) { \COREPOS\Fannie\API\lib\AuditLib::itemUpdate($upc, $lc); } else { \COREPOS\Fannie\API\lib\AuditLib::itemUpdate($upc); } } $ret = "<table class=\"table\">"; foreach ($FANNIE_PRODUCT_MODULES as $class => $params) { $mod = new $class(); $rows = $mod->summaryRows($upc); foreach ($rows as $row) { $ret .= '<tr>' . $row . '</tr>'; } } $ret .= '</table>'; return $ret; }