protected function post_id_handler() { $batchList = new BatchListModel($this->connection); $batchList->batchID($this->id); try { $upc = $this->form->upc; $style = $this->form->style; for ($i = 0; $i < count($upc); $i++) { $batchList->upc($upc[$i]); $batchList->signMultiplier($style[$i]); $batchList->save(); } } catch (Exception $ex) { } return filter_input(INPUT_SERVER, 'PHP_SELF') . '?id=' . $this->id; }
public function post_upc_price_batchID_mult_handler() { $dbc = $this->connection; $dbc->selectDB($this->config->get('OP_DB')); $added = 0; $batchList = new BatchListModel($dbc); for ($i = 0; $i < count($this->batchID); $i++) { if ($this->batchID[$i] == '') { continue; } if (!isset($this->upc[$i]) || !isset($this->price[$i])) { continue; } $batchList->salePrice($this->price[$i]); $batchList->batchID($this->batchID[$i]); $batchList->upc(BarcodeLib::padUPC($this->upc[$i])); $batchList->signMultiplier($this->mult[$i]); if ($batchList->save()) { $added++; } } header('Location: ?added=' . $added); return false; }
public function results_content() { global $FANNIE_OP_DB; $dbc = FannieDB::get($FANNIE_OP_DB); $start = date('Y-m-d', strtotime(FormLib::get_form_value('start', date('Y-m-d')))); $end = date('Y-m-d', strtotime(FormLib::get_form_value('end', date('Y-m-d')))); $b_start = date('Y-m-d', strtotime(FormLib::get_form_value('bstart', date('Y-m-d')))); $b_end = date('Y-m-d', strtotime(FormLib::get_form_value('bend', date('Y-m-d')))); $naming = FormLib::get_form_value('naming', ''); $upcs = FormLib::get_form_value('upc', array()); $prices = FormLib::get_form_value('price', array()); $names = FormLib::get_form_value('batch', array()); $set = FormLib::get('deal-set'); $batchIDs = array(); if (FormLib::get_form_value('group_by_superdepts', '') == 'on') { $superdept_grouping = "CASE WHEN s.super_name IS NULL THEN 'sale' ELSE s.super_name END"; } else { $superdept_grouping = ""; } $saleItemsP = $dbc->prepare_statement("\n SELECT t.upc,\n t.price,\n t.multiplier," . $dbc->concat($superdept_grouping ? $superdept_grouping : "''", $superdept_grouping ? "' '" : "''", "'Co-op Deals '", "t.abtpr", '') . " AS batch\n FROM CoopDealsItems as t\n " . DTrans::joinProducts('t', 'p', 'INNER') . "\n LEFT JOIN MasterSuperDepts AS s ON p.department=s.dept_ID\n WHERE p.inUse=1\n AND t.dealSet=?\n ORDER BY s.super_name, t.upc\n "); $saleItemsR = $dbc->exec_statement($saleItemsP, array($set)); $batchP = $dbc->prepare_statement(' INSERT INTO batches ( batchName, batchType, discountType, priority, startDate, endDate ) VALUES (?, ?, ?, 0, ?, ?) '); $list = new BatchListModel($dbc); $list->active(0); $list->pricemethod(0); $list->quantity(0); while ($row = $dbc->fetch_row($saleItemsR)) { if (!isset($batchIDs[$row['batch']])) { $args = array($row['batch'] . ' ' . $naming, 1, 1); if (substr($row['batch'], -2) == " A") { $args[] = $start; $args[] = $end; } else { if (substr($row['batch'], -2) == " B") { $args[] = $b_start; $args[] = $b_end; } else { $args[] = $start; $args[] = $b_end; } } $dbc->exec_statement($batchP, $args); $bID = $dbc->insert_id(); $batchIDs[$row['batch']] = $bID; if ($this->config->get('STORE_MODE') === 'HQ') { StoreBatchMapModel::initBatch($bID); } } $id = $batchIDs[$row['batch']]; $list->upc($row['upc']); $list->batchID($id); $list->salePrice(sprintf("%.2f", $row['price'])); $list->signMultiplier($row['multiplier']); $list->save(); } $ret = "<p>New sales batches have been created!</p>"; $ret .= "<p><a href=\"../newbatch/\">View batches</a></p>"; return $ret; }