Advertisement
fernandezekiel

Something wrong

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