Advertisement
fernandezekiel

Untitled

Jun 4th, 2013
292
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.72 KB | None | 0 0
  1. public function defaultScope() {
  2.         $criteria = new CDbCriteria;
  3.         $criteria->alias = $this->alias;
  4.  
  5.         $criteria->together = true;
  6.  
  7.         $criteria->with = array(
  8.             'quotationDetails'=>array('alias'=>'qd'),
  9.             'opportunity'=>array('alias'=>'opp'),
  10.             'sales'=>array('alias'=>'sls'),
  11.         );
  12.  
  13.         $criteria->select = array("*",
  14.             "ROUND(SUM(qd.selling_price * qd.quantity),2) as totalAmount",
  15.             "ROUND(SUM(qd.selling_price * qd.quantity)*(1-($this->alias.discount/100)),2) as totalDiscountedAmount",
  16.             "ROUND(SUM(sls.amount)) as totalSalesCredited",
  17.         );
  18.         $criteria->group = "$this->alias.id";
  19.         return $criteria;
  20.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement