Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public function search() {
- $criteria = new ExtendedDbCriteria;
- $criteria->scopes = array('withTotals');
- $criteria->with = array(
- 'coordinator' => array(
- 'alias' => 'cid',
- 'with' => array('profile' => array(
- 'alias' => 'cidp'
- )
- )
- ),
- 'opportunity' => array(
- 'alias' => 'o',
- 'with' => array('customer' => array('alias' => 'ocu')),
- ),
- );
- if (isset($this->alias))
- $criteria->alias = $this->alias;
- $criteria->compareHaving('totalTaxedAmount', $this->totalTaxedAmount, true);
- $criteria->compareHaving('totalSalesCredited', $this->totalSalesCredited, true);
- $criteria->compare("CONCAT(cidp.first_name, ' ', cidp.last_name)", $this->coordinator_name, true);
- $criteria->compare("$criteria->alias.id", $this->id);
- $criteria->compare("o.name", $this->opportunity_name, true);
- $criteria->compare("$criteria->alias.opportunity_id", $this->opportunity_id);
- $criteria->compare("$criteria->alias.quotation_number", $this->quotation_number, true);
- //$criteria->compare("$criteria->alias.contact_id", $this->contact_id);
- if($this->date != null)
- $criteria->compare("$criteria->alias.date", date('Y-m-d', strtotime($this->date)), true);
- $criteria->compare("$criteria->alias.description", $this->description, true);
- $criteria->compare("$criteria->alias.discount", $this->discount, true);
- $criteria->compare("$criteria->alias.discount_type", $this->discount_type);
- $criteria->compare("$criteria->alias.status", $this->status);
- $criteria->compare("ocu.name", $this->customer_name, true);
- $criteria->compare("$criteria->alias.project_type",$this->project_type);
- $sort = new CSort();
- $sort->defaultOrder = "$this->alias.date DESC";
- $sort->attributes = array('*',
- 'totalAmount' => array(
- 'asc' => 'total',
- 'desc' => 'totalAmount DESC',
- ),
- 'totalTaxedAmount' => array(
- 'asc' => 'totalTaxedAmount',
- 'desc' => 'totalTaxedAmount DESC',
- ),
- 'opportunity_name'=>array(
- 'asc'=>'o.name',
- 'desc'=>'o.name DESC'
- ),
- 'coordinator_name' => array(
- 'asc' => 'cidp.first_name, cidp.last_name',
- 'desc' => 'cidp.first_name DESC, cidp.last_name DESC',
- ),
- 'customer_name' => array(
- 'asc' => 'ocu.name',
- 'desc' => 'ocu.name DESC',
- ),
- );
- //this does not work
- $count = self::model()->count($criteria);
- return new RestrictedDataProvider($this, array(
- 'criteria' => $criteria,
- 'sort' => $sort,
- 'totalItemCount'=>$count,
- //'recomputeTotalItemCount' => true,
- 'pagination' => array(
- 'pageSize' => 10,
- ),
- ));
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement