public function run() { $dbc = FannieDB::get($this->config->get('OP_DB')); $yesterday = date('Y-m-d', strtotime('yesterday')); $url = $this->config->get('URL'); $host = php_uname('n'); $dtrans = DTransactionsModel::selectDTrans($yesterday); $findP = $dbc->prepare(' SELECT d.upc, d.description, d.department, p.inUse, count(*) AS occurences FROM ' . $dtrans . ' AS d ' . DTrans::joinProducts('d') . ' WHERE d.trans_type=\'L\' AND d.trans_subtype=\'OG\' AND d.charflag=\'IU\' AND d.emp_no <> 9999 AND d.register_no <> 99 AND d.datetime BETWEEN ? AND ? GROUP BY d.upc, d.description, d.department, p.inUse HAVING SUM(d.quantity) <> 0 '); $findR = $dbc->execute($findP, array($yesterday . ' 00:00:00', $yesterday . ' 23:59:59')); while ($w = $dbc->fetchRow($findR)) { $msg = sprintf('%s (%s) was sold %d times while not inUse', $w['description'], $w['upc'], $w['occurences']); $email = \COREPOS\Fannie\API\lib\AuditLib::getAddresses($w['department']); if ($email) { $subject = 'Not In Use Report'; $from = "From: automail\r\n"; $msg .= "\n"; $msg .= "http://{$host}/{$url}item/ItemEditorPage.php?searchupc={$w['upc']}\n"; mail($email, $subject, $msg, $from); } else { $this->cronMsg($msg); } } }
$upc = $_GET['upc']; $saleprice = $_GET['saleprice']; $method = 0; $qty = $_GET['saleqty']; if (is_numeric($qty)) { $method = 2; } else { $qty = 0; } $upQ = $sql->prepare("update batchList set saleprice=?,pricemethod=?,quantity=? where batchID=? and upc=?"); $upR = $sql->execute($upQ, array($saleprice, $method, $qty, $id, $upc)); $upQ = $sql->prepare("update batchBarcodes set normal_price=? where upc=? and batchID=?"); $upR = $sql->execute($upQ, array($saleprice, $upc, $id)); $audited = $_GET["audited"]; if ($audited == "1") { \COREPOS\Fannie\API\lib\AuditLib::batchNotification($this->id, $this->upc, \COREPOS\Fannie\API\lib\AuditLib::BATCH_EDIT, substr($this->upc, 0, 2) == 'LC' ? true : false); } break; case 'newTag': $id = $_GET['id']; $upc = $_GET['upc']; $price = $_GET['price']; $out .= newTagInput($upc, $price, $id); break; case 'addTag': $id = $_GET['id']; $upc = $_GET['upc']; $price = $_GET['price']; $desc = $_GET['desc']; $brand = $_GET['brand']; $units = $_GET['units'];
$sID = array_pop($dbc->fetch_row($sR)); } /* 1. Validate credentials of the operator. */ $uid = 0; if (!$validatedUser && !$auditedUser && $logged_in) { $validatedUser = validateUserQuiet('pricechange', $subdepartment); } if ($validatedUser) { $validatedUID = getUID($validatedUser); $uid = $validatedUID; } elseif ($auditedUser) { /* 2el. Notify dept manager of the new values. */ if (!empty($likeCode)) { \COREPOS\Fannie\API\lib\AuditLib::itemUpdate($upc, $likeCode); } else { \COREPOS\Fannie\API\lib\AuditLib::itemUpdate($upc); } } /* 2. Insert or update per-coop products data */ /* For WEFC_Toronto only * Store the raw versions of products.description and productUser.description in products_WEFC_Toronto. */ if (isset($FANNIE_COOP_ID) && $FANNIE_COOP_ID == "WEFC_Toronto") { $table_name = "products_{$FANNIE_COOP_ID}"; if ($dbc->table_exists("{$table_name}")) { $coop_array = array("description" => $dbc->escape(substr($_REQUEST['descript'], 0, 255)), "search_description" => isset($_REQUEST['puser_description']) ? $dbc->escape(substr($_REQUEST['puser_description'], 0, 255)) : ''); $checkR = $dbc->query("SELECT upc FROM {$table_name} WHERE upc='{$upc}'"); if ($dbc->num_rows($checkR) == 0) { $coop_array['upc'] = $dbc->escape($upc); $dbc->smart_insert("{$table_name}", $coop_array); } else {
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; }
protected function delete_id_upc_handler() { global $FANNIE_OP_DB; $dbc = FannieDB::get($FANNIE_OP_DB); $id = $this->id; $upc = $this->upc; $json = array('error' => 0, 'msg' => 'Item ' . $upc . ' removed from batch'); if (substr($upc, 0, 2) != 'LC') { // take the item off sale if this batch is currently on sale if ($this->unsaleUPC($this->upc) === false) { $json['error'] = 1; $json['msg'] = 'Error taking item ' . $upc . ' off sale'; } updateProductAllLanes($upc); } else { $likecode = substr($upc, 2); if ($this->unsaleLikeCode($likecode) === false) { $json['error'] = 1; $json['msg'] = 'Error taking like code ' . $likecode . ' off sale'; } } $delQ = $dbc->prepare_statement("delete from batchList where batchID=? and upc=?"); $delR = $dbc->exec_statement($delQ, array($id, $upc)); if ($delR === false) { if ($json['error']) { $json['msg'] .= '<br />Error deleting item ' . $upc . ' from batch'; } else { $json['error'] = 1; $json['msg'] = 'Error deleting item ' . $upc . ' from batch'; } } $delQ = $dbc->prepare_statement("delete from batchBarcodes where upc=? and batchID=?"); $delR = $dbc->exec_statement($delQ, array($upc, $id)); if (FormLib::get_form_value('audited') == '1') { \COREPOS\Fannie\API\lib\AuditLib::batchNotification($id, $upc, \COREPOS\Fannie\API\lib\AuditLib::BATCH_DELETE, substr($upc, 0, 2) == 'LC' ? true : false); } echo json_encode($json); return false; }