コード例 #1
0
ファイル: VendorItemsModel.php プロジェクト: phpsmith/IS4C
 /**
   Helper: create a vendorItems record for an existing
   product if one does not exist
 */
 public function createIfMissing($upc, $vendorID)
 {
     // look for entry directly by UPC or via SKU mapping
     $findP = $this->connection->prepare('
         SELECT v.upc
         FROM vendorItems AS v
             LEFT JOIN vendorSKUtoPLU AS m ON v.vendorID=m.vendorID AND v.sku=m.sku
         WHERE v.vendorID=?
             AND (v.upc=? OR m.upc=?)');
     $findR = $this->connection->execute($findP, array($vendorID, $upc, $upc));
     if ($this->connection->num_rows($findR) == 0) {
         // create item from product
         $prod = new ProductsModel($this->connection);
         $prod->upc($upc);
         $prod->load();
         $vend = new VendorItemsModel($this->connection);
         $vend->vendorID($vendorID);
         $vend->upc($upc);
         $vend->sku($upc);
         $vend->brand($prod->brand());
         $vend->description($prod->description());
         $vend->cost($prod->cost());
         $vend->saleCost(0);
         $vend->vendorDept(0);
         $vend->units(1);
         $vend->size($prod->size() . $prod->unitofmeasure());
         $vend->save();
     }
 }
コード例 #2
0
ファイル: IncompleteItemsPage.php プロジェクト: phpsmith/IS4C
 /**
   For each store, examine all items.
   For all items in a given store, check
   whether it exists in all other stores.
   Copy the item to store(s) where it
   does not exist if needed.
 
   This may be better suited to a cron/CLI
   approach. Time required to check every
   item scales rapidly with both number of
   items and number of stores.
 */
 public function post_view()
 {
     $dbc = $this->connection;
     $dbc->selectDB($this->config->get('OP_DB'));
     $model = new StoresModel();
     $stores = array();
     foreach ($model->find() as $s) {
         $stores[] = $s->storeID();
     }
     $product = new ProductsModel();
     $chkP = $dbc->prepare('
         SELECT upc
         FROM products
         WHERE upc=?
             AND store_id=?');
     for ($i = 0; $i < count($stores); $i++) {
         $store_id = $stores[$i];
         $product->store_id($store_id);
         foreach ($product->find() as $p) {
             for ($j = 0; $j < count($stores); $j++) {
                 if ($i == $j) {
                     continue;
                 }
                 $chkR = $dbc->execute($chkP, array($p->upc(), $stores[$j]));
                 if ($dbc->numRows($chkR) == 0) {
                     $p->store_id($stores[$j]);
                     $p->save();
                 }
             }
         }
     }
     header('Location: ' . $_SERVER['PHP_SELF']);
     return false;
 }
コード例 #3
0
ファイル: CreateTagsByManu.php プロジェクト: phpsmith/IS4C
 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;
 }
コード例 #4
0
ファイル: CloneItemPage.php プロジェクト: phpsmith/IS4C
 public function get_id_view()
 {
     $dbc = FannieDB::get($this->config->get('OP_DB'));
     $model = new ProductsModel($dbc);
     $model->upc(BarcodeLib::padUPC($this->id));
     if (!$model->load()) {
         return '<div class="alert alert-danger">Item ' . $this->id . ' does not exist</dv>';
     }
     $ret = '<form action="' . $_SERVER['PHP_SELF'] . '" method="post">
         <input type="hidden" name="id" value="' . $model->upc() . '" />
         <p>
             Create a copy of ' . $model->upc() . ' (' . $model->description() . ')
         </p>
         <div class="form-group">
             <label>New Item UPC</label>
             <input type="text" name="new-upc" class="form-control" id="new-upc" required />
         </div>
         <p>
             <button type="submit" class="btn btn-default">Clone Item</button>
         </p>
         </form>';
     $this->addOnloadCommand("enableLinea('#new-upc');\n");
     $this->addOnloadCommand("\$('#new-upc').focus();\n");
     return $ret;
 }
コード例 #5
0
function unsale($batchID)
{
    global $sql, $FANNIE_SERVER_DBMS;
    if ($FANNIE_SERVER_DBMS == "MSSQL") {
        $unsale1Q = $sql->prepare("update products set special_price=0,\n        discounttype=0,start_date='',end_date='',\n        specialpricemethod=0,specialquantity=0,\n        specialgroupprice=0\n        from\n        products as p left join\n        batchlist as b on p.upc=b.upc\n        where b.batchID=?");
        $unsale2Q = $sql->prepare("update products set special_price=0,\n                discounttype=0,start_date='',end_date='',\n                specialpricemethod=0,specialquantity=0,\n                specialgroupprice=0\n                from products as p left join\n                upcLike as v on v.upc=p.upc left join\n                batchlist as l on l.upc='LC'+convert(varchar,v.likecode)\n                left join batches as b on b.batchID = l.batchID\n                where b.batchID=?");
        $sql->execute($unsale1Q, array($batchID));
        $sql->execute($unsale2Q, array($batchID));
    } else {
        $unsale1Q = $sql->prepare("update products as p\n        left join batchList as b ON p.upc=b.upc\n        set special_price=0,\n        p.discounttype=0,start_date='',end_date='',\n        specialpricemethod=0,specialquantity=0,\n        specialgroupprice=0\n        where b.batchID=?");
        $unsale2Q = $sql->prepare("update products as p left join\n                upcLike as v on v.upc=p.upc left join\n                batchList as l on l.upc=concat('LC',convert(v.likeCode,char))\n                left join batches as b on b.batchID = l.batchID\n                set special_price=0,\n                p.discounttype=0,start_date='',end_date='',\n                specialpricemethod=0,specialquantity=0,\n                specialgroupprice=0\n                where b.batchID=?");
        $sql->execute($unsale1Q, array($batchID));
        $sql->execute($unsale2Q, array($batchID));
    }
    $q = $sql->prepare("SELECT upc FROM batchList WHERE batchID=?");
    $r = $sql->execute($q, array($batchID));
    $q2 = $sql->prepare("SELECT upc FROM upcLike WHERE likeCode=?");
    while ($w = $sql->fetch_row($r)) {
        $upcs = array($w['upc']);
        if (substr($w['upc'], 0, 2) == 'LC') {
            $upcs = array();
            $lc = substr($w['upc'], 2);
            $r2 = $sql->execute($q2, array($lc));
            while ($w2 = $sql->fetch_row($r2)) {
                $upcs[] = $w2['upc'];
            }
        }
        foreach ($upcs as $u) {
            $model = new ProductsModel();
            $model->upc($u);
            $model->pushToLanes();
        }
    }
}
コード例 #6
0
ファイル: ProductsController.php プロジェクト: glianyi/MyPHP
 public function DisplayAction()
 {
     //require_once './model/ProductsModel.php';//有问题
     $products = new ProductsModel();
     $rows = $products->ProdList();
     require_once './view/products.html';
 }
コード例 #7
0
ファイル: NonMovementReport.php プロジェクト: phpsmith/IS4C
 function preprocess()
 {
     global $FANNIE_OP_DB;
     // custom: can delete items from report results
     if (isset($_REQUEST['deleteItem'])) {
         $upc = FormLib::get_form_value('deleteItem', '');
         if (is_numeric($upc)) {
             $upc = BarcodeLib::padUPC($upc);
         }
         $dbc = FannieDB::get($FANNIE_OP_DB);
         $model = new ProductsModel($dbc);
         $model->upc($upc);
         $model->store_id(1);
         $model->delete();
         echo 'Deleted';
         return false;
     } elseif (FormLib::get('deactivate') !== '') {
         $upc = BarcodeLib::padUPC(FormLib::get('deactivate'));
         $dbc = FannieDB::get($FANNIE_OP_DB);
         $model = new ProductsModel($dbc);
         $model->upc($upc);
         $model->store_id(1);
         $model->inUse(0);
         $model->save();
         echo 'Deactivated';
     }
     $ret = parent::preprocess();
     // custom: needs extra JS for delete option
     if ($this->content_function == 'report_content' && $this->report_format == 'html') {
         $this->add_script("../../src/javascript/jquery.js");
         $this->add_script('delete.js');
     }
     return $ret;
 }
コード例 #8
0
ファイル: DeleteItemPage.php プロジェクト: phpsmith/IS4C
 public function get_id_confirm_view()
 {
     $dbc = $this->connection;
     $dbc->selectDB($this->config->get('OP_DB'));
     $upc = BarcodeLib::padUPC($this->id);
     $model = new ProductsModel($dbc);
     $model->upc($upc);
     foreach ($model->find('store_id') as $obj) {
         $obj->delete();
     }
     if (substr($upc, 0, 3) == '002') {
         $scaleQ = $dbc->prepare_statement("DELETE FROM scaleItems WHERE plu=?");
         $dbc->exec_statement($scaleQ, array($upc));
         $plu = substr($upc, 3, 4);
         \COREPOS\Fannie\API\item\HobartDgwLib::deleteItemsFromScales($plu);
         \COREPOS\Fannie\API\item\EpScaleLib::deleteItemsFromScales($plu);
     }
     $userP = $dbc->prepare("DELETE FROM productUser WHERE upc=?");
     $dbc->execute($userP, array($upc));
     if ($dbc->tableExists('prodExtra')) {
         $extraP = $dbc->prepare("DELETE FROM prodExtra WHERE upc=?");
         $dbc->execute($extraP, array($upc));
     }
     return '<div class="alert alert-success">Item deleted</div>';
 }
コード例 #9
0
ファイル: CreateTagsByDept.php プロジェクト: phpsmith/IS4C
 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;
 }
コード例 #10
0
ファイル: CoolItemUploadPage.php プロジェクト: phpsmith/IS4C
 function process_file($linedata)
 {
     $dbc = $this->connection;
     $dbc->selectDB($this->config->get('OP_DB'));
     $upc_index = $this->get_column_index('upc');
     $price_index = $this->get_column_index('price');
     $cool_index = $this->get_column_index('cool');
     $itemP = $dbc->prepare('
         SELECT itemdesc,
             description,
             weight
         FROM scaleItems AS s
             LEFT JOIN products AS p ON s.plu=p.upc
         WHERE plu=?');
     $saveP = $dbc->prepare('
         UPDATE scaleItems
         SET price=?,
             itemdesc=?,
             modified=' . $dbc->now() . '
         WHERE plu=?');
     $product = new ProductsModel($dbc);
     $prodPricing = FormLib::get('prodPricing') === '' ? false : true;
     $scale_items = array();
     foreach ($linedata as $line) {
         $upc = trim($line[$upc_index]);
         $upc = BarcodeLib::padUPC($upc);
         $price = str_replace('$', '', $line[$price_index]);
         $price = trim($price);
         $cool = $line[$cool_index];
         if (!is_numeric($upc) || !is_numeric($price)) {
             continue;
         }
         $item = $dbc->getRow($itemP, array($upc));
         if ($item === false) {
             continue;
         }
         $itemdesc = !empty($item['itemdesc']) ? $item['itemdesc'] : $item['description'];
         if (strstr($itemdesc, "\n")) {
             list($line1, $line2) = explode("\n", $itemdesc);
             $itemdesc = $line1 . "\n" . $cool;
         } else {
             $itemdesc .= "\n" . $cool;
         }
         $dbc->execute($itemP, array($price, $itemdesc, $upc));
         if ($prodPricing) {
             $product->upc($upc);
             foreach ($product->find() as $obj) {
                 $obj->normal_price($price);
                 $obj->save();
             }
         }
         $scale_info = array('RecordType' => 'ChangeOneItem', 'PLU' => substr($upc, 3, 4), 'Description' => $itemdesc, 'Price' => $price, 'Type' => $item['weight'] == 0 ? 'Random Weight' : 'Fixed Weight', 'ReportingClass' => 1);
         $scale_items[] = $scale_info;
     }
     $scales = $this->getScales(FormLib::get('scales'));
     HobartDgwLib::writeItemsToScales($scale_items, $scales);
     EpScaleLib::writeItemsToScales($scale_items, $scales);
     return true;
 }
コード例 #11
0
 public function report_description_content()
 {
     $dbc = $this->connection;
     $dbc->selectDB($this->config->get('OP_DB'));
     $prod = new ProductsModel($dbc);
     $prod->upc(BarcodeLib::padUPC($this->form->upc));
     $prod->load();
     return array('Weekly Sales For ' . $prod->upc() . ' ' . $prod->description());
 }
コード例 #12
0
ファイル: UnitBreakdownPage.php プロジェクト: phpsmith/IS4C
 public function get_id_break_handler()
 {
     $dbc = FannieDB::get($this->config->get('OP_DB'));
     $model = new VendorBreakdownsModel($dbc);
     $model->vendorID($this->id);
     $original = new VendorItemsModel($dbc);
     $product = new ProductsModel($dbc);
     foreach ($model->find() as $obj) {
         $original->vendorID($this->id);
         $original->sku($obj->sku());
         if (!$original->load()) {
             $this->addOnloadCommand("showBootstrapAlert('#alert-area', 'danger', 'Vendor SKU #" . $obj->sku() . " not found');\n");
             continue;
         }
         $split_factor = false;
         $unit_size = '';
         if (preg_match('/^\\d+$/', $original->size())) {
             $split_factor = $original->size();
         } elseif (preg_match('/(\\d+)\\s*\\/\\s*(.+)/', $original->size(), $matches)) {
             $split_factor = $matches[1];
             $unit_size = $matches[2];
         } elseif (preg_match('/(\\d+)\\s*CT/', $original->size(), $matches)) {
             $split_factor = $matches[1];
         } elseif (preg_match('/(\\d+)\\s*PKT/', $original->size(), $matches)) {
             $split_factor = $matches[1];
         }
         if (!$split_factor) {
             $this->addOnloadCommand("showBootstrapAlert('#alert-area', 'danger', 'Vendor SKU #" . $original->size() . " cannot be broken down');\n");
             continue;
         }
         // add an entry using the store UPC/PLU in place of the vendor SKU
         // since two records from the same vendor with same SKU are not
         // permitted in the table
         $original->sku($obj->upc());
         $original->upc($obj->upc());
         $original->units(1);
         $original->size($unit_size);
         $original->cost($original->cost() / $split_factor);
         $original->saleCost($original->saleCost() / $split_factor);
         if ($original->save()) {
             // update cost in products table, too
             $product->reset();
             $product->upc($obj->upc());
             foreach ($product->find('store_id') as $p) {
                 if ($p->load() && $p->default_vendor_id() == $this->id) {
                     $p->cost($original->cost());
                     $p->save();
                     $original->description($p->description());
                     $original->save();
                 }
             }
         } else {
             $this->addOnloadCommand("showBootstrapAlert('#alert-area', 'success', 'Error saving vendor SKU #" . $obj->sku() . "');\n");
         }
     }
     return true;
 }
コード例 #13
0
 function actionIndex()
 {
     $managers = $this->model->getManagers();
     /*  Google capcha settings */
     $config = parse_ini_file(ROOT . "/app/config/config.ini");
     $secret = $config['Secret_key'];
     $publicKey = $config['Site_key'];
     if ($_SERVER["REQUEST_METHOD"] == "POST") {
         $recaptcha = $_POST['g-recaptcha-response'];
         if (!empty($recaptcha)) {
             $google_url = "https://www.google.com/recaptcha/api/siteverify";
             $ip = $_SERVER['REMOTE_ADDR'];
             $url = $google_url . "?secret=" . $secret . "&response=" . $recaptcha . "&remoteip=" . $ip;
             $res = $this->getCurlData($url);
             $res = json_decode($res, true);
             //reCaptcha введена
             if ($res['success']) {
                 $fio = ClearInput::clearInput($_POST['fio'], 's');
                 if (mb_strlen($fio) < 6) {
                     $errors[] = 'Поле ФИО должно иметь больше 6 символов';
                 }
                 if (!($phone = ClearInput::cheackPhone($_POST['tel']))) {
                     $errors[] = 'Телефон должен быть из 10 цифр например:  044 537 02 22';
                 }
                 if (!($email = ClearInput::validate_email($_POST['email']))) {
                     $errors[] = 'Email не валидный';
                 }
                 $message = ClearInput::clearInput($_POST['message'], 's');
                 if (mb_strlen($message) < 6) {
                     $errors[] = 'Сообщение должно иметь больше 6 символов';
                 }
             } else {
                 $errors[] = "Please re-enter your reCAPTCHA.";
             }
         } else {
             $errors[] = "Please re-enter your reCAPTCHA.";
         }
         if (!isset($errors)) {
             $body = "ФИО: {$fio} <br/>\n                      Телефон: {$phone} <br/>\n                      Email: {$email} <br/>\n                      {$message}";
             $subject = 'Форма связаться с нами';
             $emails = $config['admin_email'];
             try {
                 $mail = new SendEmail($body, $emails, $subject);
                 $result = 'Письмо успешно отправлено';
             } catch (Exception $e) {
                 $errors[] = $e->getMessage();
             }
         }
     }
     $products = new ProductsModel();
     $data = array('title' => 'Контакты', 'is_left_slider' => true, 'is_right_slider' => true, 'is_logged' => Session::is_logged(), 'categories' => $products->get_categories(), 'products' => $products->get_data(), 'managers' => $managers, 'errors' => isset($errors) ? $errors : null, 'result' => isset($result) ? $result : null, 'capchaPublicKey' => $publicKey);
     $this->view->render('contact_view.twig', $data);
 }
コード例 #14
0
ファイル: ScaleItemsModel.php プロジェクト: phpsmith/IS4C
 public function mergeDescription()
 {
     if ($this->itemdesc() != '') {
         return $this->itemdesc();
     } else {
         $p = new ProductsModel($this->connection);
         $p->upc($this->plu());
         if ($p->load()) {
             return $p->description();
         }
     }
     return $this->itemdesc();
 }
コード例 #15
0
ファイル: products.php プロジェクト: chamalC/simple-mvc
 public function addReview()
 {
     $review = new ProductsDAO();
     $review->setName($_POST['name']);
     $review->setEmail($_POST['email']);
     $review->setAddress($_POST['address']);
     $review->setTel($_POST['tel']);
     $review->setReview($_POST['review']);
     $model = new ProductsModel();
     $result = $model->createReview($review);
     if ($result == 1) {
         header("Location: " . SITE_URL . "/products/?e=1");
     }
 }
コード例 #16
0
ファイル: ajax.php プロジェクト: phpsmith/IS4C
function MarginFS($upc, $cost, $deptID)
{
    global $FANNIE_OP_DB;
    $dbc = FannieDB::get($FANNIE_OP_DB);
    $price = 'None';
    $prod = new ProductsModel($dbc);
    $prod->upc($upc);
    if ($prod->load()) {
        $price = $prod->normal_price();
    }
    $dm = 'Unknown';
    $dept = new DepartmentsModel($dbc);
    $dept->dept_no($deptID);
    if ($dept->load()) {
        $dm = $dept->margin();
    }
    if ((empty($dm) || $dm == 'Unknown') && $dbc->tableExists('deptMargin')) {
        $prep = $dbc->prepare_statement("SELECT margin FROM deptMargin WHERE dept_ID=?");
        $dm = $dbc->exec_statement($prep, array($deptID));
        if ($dbc->num_rows($dm) > 0) {
            $row = $dbc->fetch_row($dm);
            $dm = $dm['margin'];
        }
    }
    $ret = "Desired margin on this department is ";
    if ($dm == "Unknown") {
        $ret .= $dm;
    } else {
        $ret .= sprintf("%.2f%%", $dm * 100);
    }
    $ret .= "<br />";
    $actual = 0;
    if ($price != 0) {
        $actual = ($price - $cost) / $price;
    }
    if ($actual > $dm && is_numeric($dm) || !is_numeric($dm)) {
        $ret .= sprintf("<span style=\"color:green;\">Current margin on this item is %.2f%%<br />", $actual * 100);
    } else {
        if (!is_numeric($price)) {
            $ret .= "<span style=\"color:green;\">No price has been saved for this item<br />";
        } else {
            $ret .= sprintf("<span style=\"color:red;\">Current margin on this item is %.2f%%</span><br />", $actual * 100);
            $srp = getSRP($cost, $dm);
            $ret .= sprintf("Suggested price: \$%.2f ", $srp);
            $ret .= sprintf("(<a href=\"\" onclick=\"setPrice(%.2f); return false;\">Use this price</a>)", $srp);
        }
    }
    echo $ret;
}
コード例 #17
0
ファイル: EndItemSale.php プロジェクト: phpsmith/IS4C
 function post_id_handler()
 {
     global $FANNIE_OP_DB;
     $dbc = FannieDB::get($FANNIE_OP_DB);
     $upc = BarcodeLib::padUPC($this->id);
     $model = new ProductsModel($dbc);
     $model->upc($upc);
     $model->store_id(1);
     $model->discounttype(0);
     $model->special_price(0);
     $model->modified(date('Y-m-d H:i:s'));
     $model->save();
     $batchID = FormLib::get_form_value('batchID');
     $batchUPC = FormLib::get_form_value('batchUPC');
     if ($batchID !== '' && $batchUPC !== '') {
         if (substr($batchUPC, 0, 2) != 'LC') {
             $batchUPC = BarcodeLib::padUPC($batchUPC);
         }
         $batchP = $dbc->prepare_statement('DELETE FROM batchList
                 WHERE upc=? AND batchID=?');
         $batchR = $dbc->exec_statement($batchP, array($batchUPC, $batchID));
     }
     require 'laneUpdates.php';
     updateProductAllLanes($upc);
     header('Location: ItemEditorPage.php?searchupc=' . $upc);
     return False;
 }
コード例 #18
0
ファイル: ShrinkTool.php プロジェクト: phpsmith/IS4C
 public function get_id_handler()
 {
     global $FANNIE_OP_DB;
     $dbc = FannieDB::get($FANNIE_OP_DB);
     $upc = BarcodeLib::padUPC($this->id);
     $product = new ProductsModel($dbc);
     $product->upc($upc);
     if (!$product->load()) {
         $this->add_onload_command("showBootstrapAlert('#alert-area', 'danger', 'Item not found');\n");
         $this->__route_stem = 'get';
     } else {
         $this->description = $product->description();
         $this->cost = $product->cost();
         $this->price = $product->normal_price();
         $this->department = $product->department();
         $this->upc = $upc;
     }
     return true;
 }
コード例 #19
0
ファイル: WfcWebModule.php プロジェクト: phpsmith/IS4C
 public function SaveFormData($upc)
 {
     $local = $this->db();
     $upc = BarcodeLib::padUPC($upc);
     $pu = new ProductUserModel($local);
     $pu->upc($upc);
     $pu->enableOnline(FormLib::get('u_online') == 1 ? 1 : 0);
     $pu->soldOut(FormLib::get('u_soldout') == 1 ? 1 : 0);
     $pu->save();
     include dirname(__FILE__) . '/../../src/Credentials/OutsideDB.tunneled.php';
     $remote = $dbc;
     $pu->load();
     if ($pu->enableOnline() && $remote->isConnected()) {
         $pu->setConnection($remote);
         $pu->save();
         $prod = new ProductsModel($local);
         $prod->upc($upc);
         $prod->load();
         $prod->setConnection($remote);
         $prod->save();
     } elseif (FormLib::get('u_already_online') && $remote->isConnected()) {
         $prod = new ProductsModel($remote);
         $prod->upc($upc);
         $prod->delete();
     }
     if ($local->tableExists('productExpires')) {
         $e = new ProductExpiresModel($local);
         $e->upc($upc);
         $e->expires(FormLib::getDate('u_expires', date('Y-m-d')));
         $e->save();
         if ($e->expires() && $remote->isConnected()) {
             $e->setConnection($remote);
             $e->save();
         }
     }
 }
コード例 #20
0
ファイル: RecentSalesReport.php プロジェクト: phpsmith/IS4C
 public function report_description_content()
 {
     $dbc = $this->connection;
     $dbc->selectDB($this->config->get('OP_DB'));
     $prod = new ProductsModel($dbc);
     $prod->upc(BarcodeLib::padUPC(FormLib::get('upc')));
     $prod->load();
     $ret = array('Recent Sales For ' . $prod->upc() . ' ' . $prod->description() . '<br />');
     if ($this->report_format == 'html') {
         $ret[] = sprintf('<a href="../ItemLastQuarter/ItemLastQuarterReport.php?upc=%s">Weekly Sales Details</a> | ', $prod->upc());
         $ret[] = sprintf('<a href="../ItemOrderHistory/ItemOrderHistoryReport.php?upc=%s">Recent Order History</a>', $prod->upc());
     }
     return $ret;
 }
コード例 #21
0
ファイル: ProdUpdateModel.php プロジェクト: phpsmith/IS4C
 public function logUpdate($type = 'UNKNOWN', $user = false)
 {
     if (!$user) {
         $user = FannieAuth::getUID(FannieAuth::checkLogin());
     }
     $product = new ProductsModel($this->connection);
     $product->upc($this->upc());
     $exists = $product->load();
     if (!$exists) {
         return false;
     }
     $this->storeID($product->store_id());
     $this->updateType($type);
     $this->description($product->description());
     $this->price($product->normal_price());
     $this->salePrice($product->special_price());
     $this->cost($product->cost());
     $this->dept($product->department());
     $this->tax($product->tax());
     $this->fs($product->foodstamp());
     $this->scale($product->scale());
     $this->modified($product->modified());
     $this->forceQty($product->qttyEnforced());
     $this->noDisc($product->discount());
     $this->inUse($product->inUse());
     $this->user($user);
     $likecode = 0;
     if ($this->connection->table_exists('upcLike')) {
         $upcQ = $this->connection->prepare('SELECT likeCode FROM upcLike WHERE upc=?');
         $upcR = $this->connection->execute($upcQ, array($this->upc()));
         if ($this->connection->num_rows($upcR) > 0) {
             $upcW = $this->connection->fetch_row($upcR);
             $this->likeCode($upcW['likeCode']);
         }
     }
     $this->save();
     return true;
 }
コード例 #22
0
ファイル: WfcFreshDeals.php プロジェクト: phpsmith/IS4C
 public function showEditForm($upc, $display_mode = 1, $expand_mode = 1)
 {
     $upc = BarcodeLib::padUPC($upc);
     $dbc = $this->db();
     $prod = new ProductsModel($dbc);
     $prod->upc($upc);
     if (FannieConfig::config('STORE_MODE') == 'HQ') {
         $prod->store_id(FannieConfig::config('STORE_ID'));
     }
     $prod->load();
     $ret = '<div id="FreshDealsFieldset" class="panel panel-default">';
     $ret .= "<div class=\"panel-heading\">\n                <a href=\"\" onclick=\"\$('#FreshDealsDiv').toggle();return false;\">\n                Fresh Deals</a>\n                </div>";
     $ret .= '<div id="FreshDealsDiv" class="panel-body">';
     $ret .= sprintf('<table class="table table-bordered"><tr>
         <td>%s</td>
         <td>%s</td>
         <td>%s</td>
         <td>$%.2f</td>
         <td>$%.2f</td>
         </tr></table>', $prod->brand(), $prod->description(), $prod->upc(), $prod->cost(), $prod->normal_price());
     $ret .= '</div></div>';
     return $ret;
 }
コード例 #23
0
ファイル: VolumePricingModule.php プロジェクト: phpsmith/IS4C
 public function SaveFormData($upc)
 {
     $upc = BarcodeLib::padUPC($upc);
     $dbc = $this->db();
     $model = new ProductsModel($dbc);
     $model->upc($upc);
     $model->store_id(1);
     $method = FormLib::get_form_value('vp_method', 0);
     $qty = FormLib::get_form_value('vp_qty', 0);
     $price = FormLib::get_form_value('vp_price', 0);
     $mixmatch = FormLib::get_form_value('vp_mm', 0);
     $model->pricemethod($method);
     $model->quantity($qty);
     $model->groupprice($price);
     $model->mixmatchcode($mixmatch);
     $r1 = $model->save();
     if ($r1 === false) {
         return false;
     } else {
         return true;
     }
 }
コード例 #24
0
 public function report_description_content()
 {
     $dbc = $this->connection;
     $dbc->selectDB($this->config->get('OP_DB'));
     $prod = new ProductsModel($dbc);
     $prod->upc(BarcodeLib::padUPC($this->form->upc));
     $prod->load();
     $ret = array('Order History For ' . $prod->upc() . ' ' . $prod->description());
     if (FormLib::get('all')) {
         $ret[] = 'All [known] orders';
         if ($this->report_format = 'html') {
             $ret[] = sprintf('<a href="ItemOrderHistoryReport.php?upc=%s">Show Recent</a>', $prod->upc());
         }
     } else {
         $ret[] = 'Since ' . date('F d, Y', strtotime('92 days ago'));
         if ($this->report_format = 'html') {
             $ret[] = sprintf('<a href="ItemOrderHistoryReport.php?upc=%s&all=1">Show All</a>', $prod->upc());
         }
     }
     return $ret;
 }
コード例 #25
0
 /**
  * test if productsModelID returns empty when you don't use setID
  */
 public function testIfIDIsEmpty()
 {
     $productsModel = new ProductsModel();
     $this->assertEquals("", $productsModel->getID());
 }
コード例 #26
0
ファイル: DefaultUploadPage.php プロジェクト: phpsmith/IS4C
 function process_file($linedata)
 {
     global $FANNIE_OP_DB;
     $dbc = FannieDB::get($FANNIE_OP_DB);
     if (!isset($_SESSION['vid'])) {
         $this->error_details = 'Missing vendor setting';
         return False;
     }
     $VENDOR_ID = $_SESSION['vid'];
     $p = $dbc->prepare_statement("SELECT vendorID,vendorName FROM vendors WHERE vendorID=?");
     $idR = $dbc->exec_statement($p, array($VENDOR_ID));
     if ($dbc->num_rows($idR) == 0) {
         $this->error_details = 'Cannot find vendor';
         return False;
     }
     $idW = $dbc->fetch_row($idR);
     $vendorName = $idW['vendorName'];
     $SKU = $this->get_column_index('sku');
     $BRAND = $this->get_column_index('brand');
     $DESCRIPTION = $this->get_column_index('desc');
     $QTY = $this->get_column_index('qty');
     $SIZE1 = $this->get_column_index('size');
     $UPC = $this->get_column_index('upc');
     $CATEGORY = $this->get_column_index('vDept');
     $REG_COST = $this->get_column_index('cost');
     $NET_COST = $this->get_column_index('saleCost');
     $REG_UNIT = $this->get_column_index('unitCost');
     $NET_UNIT = $this->get_column_index('unitSaleCost');
     $SRP = $this->get_column_index('srp');
     // PLU items have different internal UPCs
     // map vendor SKUs to the internal PLUs
     $SKU_TO_PLU_MAP = array();
     $skusP = $dbc->prepare('SELECT sku, upc FROM vendorSKUtoPLU WHERE vendorID=?');
     $skusR = $dbc->execute($skusP, array($VENDOR_ID));
     while ($skusW = $dbc->fetch_row($skusR)) {
         $SKU_TO_PLU_MAP[$skusW['sku']] = $skusW['upc'];
     }
     $itemP = $dbc->prepare("\n            INSERT INTO vendorItems (\n                brand, \n                sku,\n                size,\n                upc,\n                units,\n                cost,\n                description,\n                vendorDept,\n                vendorID,\n                saleCost,\n                modified,\n                srp\n            ) VALUES (\n                ?,\n                ?,\n                ?,\n                ?,\n                ?,\n                ?,\n                ?,\n                ?,\n                ?,\n                ?,\n                ?,\n                ?\n            )");
     $srpP = false;
     if ($dbc->tableExists('vendorSRPs')) {
         $srpP = $dbc->prepare_statement("INSERT INTO vendorSRPs (vendorID, upc, srp) VALUES (?,?,?)");
     }
     $pm = new ProductsModel($dbc);
     foreach ($linedata as $data) {
         if (!is_array($data)) {
             continue;
         }
         if (!isset($data[$UPC])) {
             continue;
         }
         // grab data from appropriate columns
         $sku = $data[$SKU];
         $brand = $BRAND === false ? $vendorName : substr($data[$BRAND], 0, 50);
         $description = substr($data[$DESCRIPTION], 0, 50);
         if ($QTY === false) {
             $qty = 1.0;
         } else {
             $qty = $data[$QTY];
             if (!is_numeric($qty)) {
                 $qty = 1.0;
             }
         }
         $size = $SIZE1 === false ? '' : substr($data[$SIZE1], 0, 25);
         $upc = $data[$UPC];
         $upc = str_replace(' ', '', $upc);
         $upc = str_replace('-', '', $upc);
         if (strlen($upc) > 13) {
             $upc = substr($upc, -13);
         } else {
             $upc = str_pad($upc, 13, '0', STR_PAD_LEFT);
         }
         // zeroes isn't a real item, skip it
         if ($upc == "0000000000000") {
             continue;
         }
         if ($_SESSION['vUploadCheckDigits']) {
             $upc = '0' . substr($upc, 0, 12);
         }
         if (isset($SKU_TO_PLU_MAP[$sku])) {
             $upc = $SKU_TO_PLU_MAP[$sku];
         }
         $category = $CATEGORY === false ? 0 : $data[$CATEGORY];
         $reg_unit = '';
         if ($REG_UNIT !== false) {
             $reg_unit = trim($data[$REG_UNIT]);
             $reg_unit = $this->priceFix($reg_unit);
         }
         if (!is_numeric($reg_unit) && $REG_COST !== false) {
             $reg = trim($data[$REG_COST]);
             $reg = $this->priceFix($reg);
             if (is_numeric($reg)) {
                 $reg_unit = $reg / $qty;
             }
         }
         // skip the item if prices aren't numeric
         // this will catch the 'label' line in the first CSV split
         // since the splits get returned in file system order,
         // we can't be certain *when* that chunk will come up
         // can't process items w/o price (usually promos/samples anyway)
         if (empty($reg_unit) || !is_numeric($reg_unit)) {
             continue;
         }
         $net_unit = '';
         if ($NET_UNIT !== false) {
             $net_unit = trim($data[$NET_UNIT]);
             $net_unit = $this->priceFix($net_unit);
         }
         if (!is_numeric($net_unit) && $NET_COST !== false) {
             $net = trim($data[$NET_COST]);
             $net = $this->priceFix($net);
             if (is_numeric($net)) {
                 $net_unit = $net / $qty;
             }
         }
         // blank spreadsheet cell
         if (empty($net_unit)) {
             $net_unit = 0.0;
         }
         $srp = $SRP === false ? 0.0 : trim($data[$SRP]);
         if ($net_unit == $reg_unit) {
             $net_unit = 0.0;
             // not really a sale
         }
         // syntax fixes. kill apostrophes in text fields,
         // trim $ off amounts as well as commas for the
         // occasional > $1,000 item
         $srp = $this->priceFix($srp);
         if (!is_numeric($srp)) {
             $srp = 0;
         }
         $brand = str_replace("'", "", $brand);
         $description = str_replace("'", "", $description);
         $args = array($brand, $sku, $size, $upc, $qty, $reg_unit, $description, $category, $VENDOR_ID, $net_unit, date('Y-m-d H:i:s'), $srp);
         $dbc->execute($itemP, $args);
         if ($srpP) {
             $dbc->exec_statement($srpP, array($VENDOR_ID, $upc, $srp));
         }
         if ($_SESSION['vUploadChangeCosts']) {
             $pm->reset();
             $pm->upc($upc);
             $pm->default_vendor_id($VENDOR_ID);
             foreach ($pm->find('store_id') as $obj) {
                 $obj->cost($reg_unit);
                 $obj->save();
             }
         }
     }
     return true;
 }
コード例 #27
0
ファイル: EditItemsFromSearch.php プロジェクト: phpsmith/IS4C
 function post_save_handler()
 {
     global $FANNIE_OP_DB;
     $upcs = FormLib::get('upc', array());
     if (!is_array($upcs) || empty($upcs)) {
         echo 'Error: invalid data';
         return false;
     }
     $dept = FormLib::get('dept');
     $tax = FormLib::get('tax');
     $local = FormLib::get('local');
     $brand = FormLib::get('brand');
     $vendor = FormLib::get('vendor');
     $dbc = FannieDB::get($FANNIE_OP_DB);
     $vlookup = new VendorsModel($dbc);
     for ($i = 0; $i < count($upcs); $i++) {
         $model = new ProductsModel($dbc);
         $upc = BarcodeLib::padUPC($upcs[$i]);
         $model->upc($upc);
         $model->store_id(1);
         if (isset($dept[$i])) {
             $model->department($dept[$i]);
         }
         if (isset($tax[$i])) {
             $model->tax($tax[$i]);
         }
         if (isset($local[$i])) {
             $model->local($local[$i]);
         }
         if (isset($brand[$i])) {
             $model->brand($brand[$i]);
         }
         if (isset($vendor[$i])) {
             $vlookup->reset();
             $vlookup->vendorName($vendor[$i]);
             foreach ($vlookup->find('vendorID') as $obj) {
                 $model->default_vendor_id($obj->vendorID());
                 break;
             }
         }
         if (in_array($upc, FormLib::get('fs', array()))) {
             $model->foodstamp(1);
         } else {
             $model->foodstamp(0);
         }
         if (in_array($upc, FormLib::get('disc', array()))) {
             $model->discount(1);
         } else {
             $model->discount(0);
         }
         if (in_array($upc, FormLib::get('scale', array()))) {
             $model->scale(1);
         } else {
             $model->scale(0);
         }
         $model->modified(date('Y-m-d H:i:s'));
         $try = $model->save();
         if ($try) {
             $model->pushToLanes();
         } else {
             $this->save_results[] = 'Error saving item ' . $upc;
         }
         if (isset($vendor[$i]) && $vendor[$i] != '' || isset($brand[$i]) && $brand[$i] != '') {
             $extra = new ProdExtraModel($dbc);
             $extra->upc($upc);
             if (isset($vendor[$i]) && $vendor[$i] != '') {
                 $extra->distributor($vendor[$i]);
             }
             if (isset($brand[$i]) && $brand[$i] != '') {
                 $extra->manufacturer($brand[$i]);
             }
             $extra->save();
         }
         $this->upcs[] = $upc;
     }
     return true;
 }
コード例 #28
0
ファイル: EditVendorItems.php プロジェクト: phpsmith/IS4C
 public function post_id_sku_field_value_handler()
 {
     global $FANNIE_OP_DB;
     $dbc = FannieDB::get($FANNIE_OP_DB);
     $item = new VendorItemsModel($dbc);
     $item->vendorID($this->id);
     $item->sku($this->sku);
     $ret = array('error' => 0);
     if ($this->field === 'brand') {
         $item->brand($this->value);
     } elseif ($this->field === 'description') {
         $item->description($this->value);
     } elseif ($this->field === 'unitSize') {
         $item->size($this->value);
     } elseif ($this->field === 'caseQty') {
         $item->units($this->value);
     } elseif ($this->field === 'cost') {
         $item->cost($this->value);
     } else {
         $ret['error'] = 1;
         $ret['error_msg'] = 'Unknown field';
     }
     if ($ret['error'] == 0) {
         $saved = $item->save();
         if (!$saved) {
             $ret['error'] = 1;
             $ret['error_msg'] = 'Save failed';
         } else {
             /**
               If cost was updated, update the corresponding
               product cost
             */
             $prodP = $dbc->prepare('
                 SELECT p.upc
                 FROM products AS p
                     INNER JOIN vendorItems AS v ON p.upc=v.upc AND p.default_vendor_id=v.vendorID
                 WHERE v.vendorID=?
                     AND v.sku=?');
             $prodR = $dbc->execute($prodP, array($this->id, $this->sku));
             $model = new ProductsModel($dbc);
             while ($prodW = $dbc->fetch_row($prodR)) {
                 $model->reset();
                 $model->upc($prodW['upc']);
                 foreach ($model->find('store_id') as $obj) {
                     $obj->cost($this->value);
                     $obj->save();
                 }
             }
         }
     }
     echo json_encode($ret);
     return false;
 }
コード例 #29
0
     $model->upc($upc);
     $model->pushToLanes();
     $update = new ProdUpdateModel($sql);
     $update->upc($upc);
     $update->logUpdate(ProdUpdateModel::UPDATE_BATCH);
 } else {
     $lc = substr($upc, 2);
     $unsaleQ = $sql->prepare("UPDATE products AS p LEFT JOIN upcLike as u on p.upc=u.upc\n                    LEFT JOIN batchList as b ON b.upc=concat('LC',convert(u.likeCode,char))\n                    set p.discounttype=0,special_price=0,start_date=0,end_date=0 \n                    WHERE u.likeCode=? and b.batchID=?");
     if ($FANNIE_SERVER_DBMS == "MSSQL") {
         $unsaleQ = $sql->prepare("update products set discounttype=0,special_price=0,start_date=0,end_date=0\n                    from products as p, batches as b, upcLike as u\n                    where u.likeCode=? and u.upc=p.upc and b.startdate=p.start_date and b.enddate=p.end_date\n                    and b.batchID=?");
     }
     $unsaleR = $sql->execute($unsaleQ, array($lc, $id));
     $prep = $sql->prepare('SELECT upc FROM upcLike WHERE likeCode=?');
     $all = $sql->execute($prep, array($lc));
     while ($row = $sql->fetch_row($all)) {
         $model = new ProductsModel($sql);
         $model->upc($row['upc']);
         $model->pushToLanes();
         $update = new ProdUpdateModel($sql);
         $update->upc($upc);
         $update->logUpdate(ProdUpdateModel::UPDATE_BATCH);
     }
 }
 $delQ = $sql->prepare("delete from batchList where batchID=? and upc=?");
 $delR = $sql->execute($delQ, array($id, $upc));
 $delQ = $sql->prepare("delete from batchBarcodes where upc=? and batchID=?");
 $delR = $sql->execute($delQ, array($upc, $id));
 $audited = $_GET['audited'];
 if ($audited == "1") {
     \COREPOS\Fannie\API\lib\AuditLib::batchNotification($id, $upc, \COREPOS\Fannie\API\lib\AuditLib::BATCH_DELETE, substr($upc, 0, 2) == 'LC' ? true : false);
 }
コード例 #30
0
 private function doSearch()
 {
     $m = new ProductsModel();
     return $m->run($this->parameters);
 }