Exemplo n.º 1
0
 /**
  * Retrieves a list of models based on the current search/filter conditions.
  * @return CActiveDataProvider the data provider that can return the models based on the search/filter conditions.
  */
 public function searchForPricelist($criteria = false)
 {
     $alias = $this->getTableAlias();
     if ($provider = $this->beforeSearch(!request()->getParam('Product'))) {
         return $provider;
     }
     if (is_array($criteria)) {
         $criteria = new SDbCriteria($criteria);
     }
     if (!$criteria) {
         $criteria = new SDbCriteria();
     }
     $criteria->with = ['pricelists', 'bcategory'];
     $criteria->group = 't.id';
     $criteria->together = true;
     $criteria->compare('t.id', $this->id);
     $criteria->compare('t.id_category', $this->id_category);
     $criteria->compare('t.id_brand', $this->id_brand);
     $criteria->compare('t.article', $this->article, true);
     $criteria->compare('t.model', $this->model, true);
     $criteria->compare('t.name', $this->name, true);
     $criteria->compare('t.price', $this->price);
     $criteria->compare('t.archive', $this->archive);
     $criteria->compare('t.active', $this->active);
     $criteria->compare('pricelists.id_product', '>0');
     $criteria->compare('pricelists.name', $this->pricelist_name, true);
     $criteria->compare('pricelists.article', $this->pricelist_article, true);
     $criteriaArray = $criteria->toArray();
     return new SActiveDataProvider($this, array('totalItemCount' => $this->count($criteriaArray['condition'], $criteriaArray['params']), 'criteria' => $criteria, 'pagination' => array('pageSize' => Common::getPagerSize(__CLASS__), 'pageVar' => 'page')));
 }