Esempio n. 1
0
 /**
  *	Retrievs a list of all possible branches of RM_Barcode_Entity.
  *
  *	@param 		RM_Barcode_Entity		obEntity
  *	@return		array
  **/
 public function getBranches(RM_Barcode_Entity $obEntity)
 {
     $map = qw2('generaltype>g owner>o brand>b subbrand>s variant>v garbage>gb');
     $query = M('Db')->createQuery($this->_tables['barcode'] . ' AS ba');
     foreach ($map as $name => $key) {
         $query->what(sprintf("%s.id as %s_id, %s.name as %s_name", $key, $name, $key, $name));
         $query->join('ba', sprintf("LEFT JOIN %s %s ON %s.id = ba.%s", $this->_tables[$name], $key, $key, $this->_fields['barcode'][$name . '_id']));
         $query->group('ba.' . $this->_fields['barcode'][$name . '_id']);
         $query->order($key . '.name ASC');
         if ($name == $obEntity->type()) {
             break;
         }
     }
     $query->what('COUNT(*) as barcodes_qty');
     $query->where($this->_fields['barcode'][$obEntity->type() . '_id'] . ' = ?', $obEntity->id());
     $query->limit(300);
     return iteratorToArray($query->execute());
 }
Esempio n. 2
0
 /**
  * Moves barcodes
  *
  * @param 	RM_Barcode_Entity	$obDestination
  * @param 	array				$restriction
  * @return	bool
  **/
 public function move(RM_Barcode_Entity $obDestination, $restriction = array())
 {
     if ($obDestination->id() == $this->id()) {
         return FALSE;
     }
     if ($this->stoplist) {
         if ($this->type() == 'generaltype') {
             throw new RM_Base_Exception_BadUsage(__METHOD__ . "(): Cannot move generaltype generaltype allocated in the stoplist!");
         }
     }
     return $this->_mapper->moveBarcodes($this, $obDestination, $restriction);
 }