コード例 #1
0
 public function taxes($numDays)
 {
     //Get our current group characters
     $members = $this->getMembersAsCharIDArray(Yii::app()->user->trackingGroupID);
     $sqlarray = '(' . implode(',', $members) . ')';
     $currentDate = $this->getEveTimeSql();
     //Establish the search criteria
     $criteria = new CDbCriteria();
     $criteria->select = 'amount';
     //select only the amount
     $criteria->condition = 'refTypeID = 54 AND DATE(date) >= (DATE_SUB(DATE( :currentDate ), INTERVAL :numDays DAY)) AND ownerID1 IN ' . $sqlarray . '';
     //where only for the selected number of days and only Blakes and Mathias selling
     $criteria->params = array(':numDays' => $numDays, ':currentDate' => $currentDate);
     //sets the correct number of days for the previous condition above
     //Run the sales query using those criteria
     $taxArray = Journal::model()->findAll($criteria);
     //Add all the numbers in the sales array
     if (!empty($taxArray)) {
         foreach ($taxArray as $arrayRow) {
             $taxValues[] = $arrayRow->amount;
         }
         $totalTaxes = array_sum($taxValues);
         return number_format($totalTaxes, 2);
     } else {
         return "0.00";
     }
 }
コード例 #2
0
 /**
  * Returns the data model based on the primary key given in the GET variable.
  * If the data model is not found, an HTTP exception will be raised.
  * @param integer the ID of the model to be loaded
  */
 public function loadModel($id)
 {
     $model = Journal::model()->findByPk($id);
     if ($model === null) {
         throw new CHttpException(404, 'The requested page does not exist.');
     }
     return $model;
 }