Beispiel #1
0
     $del = $dbc->prepare("DELETE FROM productUser WHERE upc=?");
     $dbc->execute($del, array($upc));
     $del = $dbc->prepare("DELETE FROM productExpires WHERE upc=?");
     $dbc->execute($del, array($upc));
 } else {
     $dbs[] = $dbc;
     $del = $dbc->prepare("DELETE FROM products WHERE upc=?");
     $dbc->execute($del, array($upc));
     $query99 = $dbc->prepare("INSERT INTO products (upc,description,normal_price,pricemethod,groupprice,quantity,special_price,specialpricemethod,\n                specialgroupprice,specialquantity,start_date,end_date,department,size,tax,foodstamp,scale,scaleprice,mixmatchcode,\n                modified,tareweight,discount,discounttype,unitofmeasure,wicable,qttyEnforced,idEnforced,cost,inUse,numflag,\n                subdept,deposit,local)\n                VALUES(?,?,?,0,0.00,0,?,0,0.00,0,'','',?,0,?,?,?,0,0,now(),0,?,\n                ?,0,0,0,0,0.00,1,\n                0,0,0.00,?)");
     $dbc->execute($query99, array($upc, $descript, $price, $w['special_price'], $dept, $tax, $FS, $Scale, $NoDisc, $w['discounttype'], $local));
 }
 foreach ($dbs as $con) {
     $char = strstr($utext, "start");
     $pu_model = new ProductUserModel($con);
     $pu_model->upc($upc);
     $pu_model->brand($ubrand);
     $pu_model->description($udesc);
     $pu_model->sizing($usize);
     $pu_model->long_text($utext);
     $pu_model->enableOnline($uonline);
     $pu_model->save();
     $prep = $con->prepare("SELECT * FROM productExpires WHERE upc=?");
     $chk = $con->execute($prep, array($upc));
     if ($con->num_rows($chk) == 0) {
         $ins = $con->prepare("INSERT INTO productExpires (upc,expires) VALUES (?, ?)");
         $con->execute($ins, array($upc, $uexpires));
     } else {
         $up = $con->prepare("UPDATE productExpires SET expires=? WHERE upc=?");
         $con->execute($up, array($uexpires, $upc));
     }
 }
Beispiel #2
0
 protected function updateRealItem($upc, $brand, $description)
 {
     $dbc = $this->getDB();
     $model = new \ProductUserModel($dbc);
     $model->upc(\BarcodeLib::padUPC($upc));
     $model->brand($brand);
     $model->description($description);
     $model->save();
     $model = new \ProductsModel($dbc);
     $model->upc(\BarcodeLib::padUPC($upc));
     foreach ($model->find('store_id') as $obj) {
         $obj->brand($brand);
         $obj->save();
     }
 }
Beispiel #3
0
 public function process_file($linedata)
 {
     global $FANNIE_OP_DB;
     $dbc = FannieDB::get($FANNIE_OP_DB);
     $upc_index = $this->get_column_index('upc');
     $desc_index = $this->get_column_index('desc');
     $size_index = $this->get_column_index('size');
     $brand_index = $this->get_column_index('brand');
     $sku_index = $this->get_column_index('sku');
     if ($desc_index === false && $brand_index === false) {
         $this->error_details = 'Neither brand nor description provided; nothing to import!';
         return false;
     }
     $ret = true;
     $checks = FormLib::get_form_value('checks') == 'yes' ? true : false;
     $normalize = FormLib::get_form_value('norm') == 'yes' ? true : false;
     $model = new ProductUserModel($dbc);
     $verifyP = $dbc->prepare('
         SELECT p.upc
         FROM products AS p
         WHERE p.upc = ?
     ');
     $skuP = $dbc->prepare('
         SELECT p.upc
         FROM vendorItems AS v
             INNER JOIN products AS p ON v.upc=p.upc AND p.default_vendor_id=v.vendorID
         WHERE v.sku = ?
     ');
     foreach ($linedata as $line) {
         $upc = $line[$upc_index];
         // upc cleanup
         $upc = str_replace(" ", "", $upc);
         $upc = str_replace("-", "", $upc);
         if (!is_numeric($upc)) {
             continue;
         }
         // skip header(s) or blank rows
         $this->stats['total']++;
         if ($checks) {
             $upc = substr($upc, 0, strlen($upc) - 1);
         }
         $upc = BarcodeLib::padUPC($upc);
         $verifyR = $dbc->execute($verifyP, array($upc));
         if ($dbc->num_rows($verifyR) == 0) {
             if ($sku_index !== false) {
                 $skuR = $dbc->execute($skuP, array($line[$sku_index]));
                 if ($dbc->num_rows($skuR) == 0) {
                     // no UPC match, no vendor sku match
                     continue;
                 } else {
                     $skuW = $dbc->fetch_row($skuR);
                     $upc = $skuW['upc'];
                 }
             } else {
                 // item does not exist, no vendor sku provided
                 continue;
             }
         }
         $model->reset();
         $model->upc($upc);
         $model->load();
         $changed = false;
         if ($model->brand() == '' && $brand_index !== false && !empty($line[$brand_index])) {
             $brand = $line[$brand_index];
             if ($normalize) {
                 $brand = ucwords(strtolower($brand));
             }
             $model->brand($brand);
             $changed = true;
         }
         if ($model->description() == '' && $desc_index !== false && !empty($line[$desc_index])) {
             $desc = $line[$desc_index];
             if ($normalize) {
                 $desc = ucwords(strtolower($desc));
             }
             $model->description($desc);
             if ($upc == '0002529300278') {
                 var_dump($model->description());
             }
             $changed = true;
         }
         if ($model->sizing() == '' && $size_index !== false && !empty($line[$size_index])) {
             $size = $line[$size_index];
             $model->sizing($size);
             $changed = true;
         }
         // possible that columns exist for brand and/or description
         // but are blank for the given row. No need to update.
         if ($changed) {
             $model->save();
             $this->stats['here']++;
         }
     }
     return $ret;
 }
Beispiel #4
0
 function SaveFormData($upc)
 {
     $upc = BarcodeLib::padUPC($upc);
     $brand = FormLib::get('lf_brand');
     $desc = FormLib::get('lf_desc');
     $origin = FormLib::get('origin', 0);
     $floorID = FormLib::get('floor-id', 0);
     $text = FormLib::get('lf_text');
     $text = str_replace("\r", '', $text);
     $text = str_replace("\n", '<br />', $text);
     // strip non-ASCII (word copy/paste artifacts)
     $text = preg_replace("/[^-]/", "", $text);
     $signs = FormLib::get('sign-count', 1);
     if ($signs < 1) {
         $signs = 1;
     }
     $dbc = $this->db();
     $loc = new ProdPhysicalLocationModel($dbc);
     $loc->upc($upc);
     $loc->floorSectionID($floorID);
     $loc->save();
     $model = new ProductUserModel($dbc);
     $model->upc($upc);
     $model->brand($brand);
     $model->description($desc);
     $model->long_text($text);
     $model->signCount($signs);
     $multiOrigin = FormLib::get('otherOrigin', array());
     $originMap = array();
     if ($origin != 0) {
         $originMap[] = $origin;
     }
     foreach ($multiOrigin as $originID) {
         if ($originID != 0) {
             $originMap[] = $originID;
         }
     }
     $mapP = $dbc->prepare('DELETE FROM ProductOriginsMap WHERE upc=?');
     $addP = $dbc->prepare('INSERT INTO ProductOriginsMap
                             (originID, upc, active)
                             VALUES (?, ?, 1)');
     $lcP = $dbc->prepare('SELECT u.upc
                         FROM upcLike AS u
                             ' . DTrans::joinProducts('u', 'p', 'INNER') . '
                         WHERE u.likeCode IN (
                             SELECT l.likeCode
                             FROM upcLike AS l
                             WHERE l.upc = ?
                         )');
     $lcR = $dbc->execute($lcP, array($upc));
     $items = array($upc);
     while ($w = $dbc->fetch_row($lcR)) {
         if ($w['upc'] == $upc) {
             continue;
         }
         $items[] = $w['upc'];
     }
     $prod = new ProductsModel($dbc);
     $stores = new StoresModel($dbc);
     foreach ($items as $item) {
         $prod->upc($item);
         $prod->store_id(1);
         $prod->current_origin_id($origin);
         $prod->save();
         $dbc->execute($mapP, array($item));
         foreach ($originMap as $originID) {
             $dbc->execute($addP, array($originID, $item));
         }
     }
     return $model->save();
 }