Exemplo n.º 1
0
 /**
  *	Parse barcode barcode user description
  *
  *	@param		RM_Barcode_Object		obBarcode
  *	@param		string|NULL				name
  *	@return		array|NULL
  **/
 public function parseUserDescription(RM_Barcode_Object $obBarcode, $name = NULL)
 {
     if (!isset($this->_volumeParsed[$obBarcode->id()])) {
         if (preg_match_all("/[0-9]+[0-9., xх]*(г|гр|кг|л|мл|мг|g|шт)+\\.?/", $obBarcode->attribute_1, $c) && strlen($c[0][0]) > 0) {
             $rr = preg_match_all("/[0-9]+[0-9.,]*/", trim($c[0][0]), $cc);
             $qty = trim($cc[0][0]);
             $total = trim($c[0][0]);
             $measure = @$c[1][0];
             switch ($measure) {
                 case "г":
                 case "гр":
                 case "гр.":
                 case "g":
                     $measure = "GRM";
                     break;
                 case "кг":
                     $measure = "KGM";
                     break;
                 case "л":
                     $measure = "LTR";
                     break;
                 case "мл":
                     $measure = "MLT";
                     break;
                 case "мг":
                     $measure = "MGR";
                     break;
                 case "шт":
                 case "шт.":
                 default:
                     $measure = "PCE";
                     break;
             }
             $this->_volumeParsed[$obBarcode->id()] = array('total' => $total, 'qty' => $qty, 'measure' => $measure);
         } else {
             $this->_volumeParsed[$obBarcode->id()] = array();
         }
     }
     return isset($this->_volumeParsed[$obBarcode->id()][$name]) ? $this->_volumeParsed[$obBarcode->id()][$name] : NULL;
 }
Exemplo n.º 2
0
 /**
  *	Creates (dosn't save) catalog price object
  *
  *	@param 		array					data
  *	@param 		RM_Barcode_Object		obBarcode
  *	@return		RM_Store_Object
  **/
 public function createPrice($data, RM_Barcode_Object $obBarcode)
 {
     $data['barcode_id'] = $obBarcode->id();
     $data['catalog_price'] = str_replace(',', '.', $data['catalog_price']);
     return $this->_mapper->storage('catalogprice')->createObject($data);
 }
Exemplo n.º 3
0
 /**
  * Checks and cleans Flavour2Barcode relation using Flavour2Brick
  *
  * @param 		RM_Barcode_Object			obBarcode
  * @return		bool
  **/
 public function cleanBarcodeFlavours(RM_Barcode_Object $obBarcode)
 {
     if (isNull($obBrick = $obBarcode->getBrick())) {
         return 0;
     }
     $query = M('Db')->createQuery($this->_tables['flavour'] . ' AS f')->what('f.*')->what('f2ba.type')->join('f', 'LEFT JOIN ' . $this->_tables['flavour2barcode'] . ' f2ba ON f2ba.' . $this->_fields['flavour2barcode']['flavour_id'] . ' = f.' . $this->_fields['flavour']['id'] . ' AND f2ba.' . $this->_fields['flavour2barcode']['barcode_id'] . ' = ?', $obBarcode->id())->join('f2ba', 'LEFT JOIN ' . $this->_tables['flavour2brick'] . ' f2br ON f2br.' . $this->_fields['flavour2brick']['flavour_id'] . ' = f.' . $this->_fields['flavour']['id'] . ' AND f2br.' . $this->_fields['flavour2brick']['brick_id'] . ' = ?' . ' AND f2br.' . $this->_fields['flavour2brick']['type'] . ' = f2ba.' . $this->_fields['flavour2barcode']['type'], $obBrick->id())->where('f2ba.' . $this->_fields['flavour2brick']['flavour_id'] . ' IS NOT NULL')->where('f2br.' . $this->_fields['flavour2brick']['brick_id'] . ' IS NULL');
     $request = $this->_storages['flavour']->request($query, array('id' => 'f.' . $this->_fields['flavour']['id']), M('Store')->factoryData($this->_storages['flavour']->factory(), array($this->_fields['flavour2barcode']['type'])));
     $result = 0;
     foreach ($request as $obFlavour) {
         $obFlavour->removeBarcode($obBarcode, $obFlavour->type);
         $result = 1;
     }
     return $result;
 }