Example #1
0
 public function afterSave()
 {
     $items = PfOrderItems::model()->findAllByAttributes(['order_id' => $this->order_id]);
     $m3 = $loadingMeters = 0;
     foreach ($items as $item) {
         $m3 += $item->m3;
         $loadingMeters += $item->load_meters;
     }
     $order = PfOrder::model()->findByPk($this->order_id);
     $order->m3 = $m3;
     $order->loading_meters = $loadingMeters;
     $order->save();
     parent::afterSave();
 }
Example #2
0
 public function loadModel($id)
 {
     $m = PfOrder::model();
     // apply scope, if available
     $scopes = $m->scopes();
     if (isset($scopes[$this->scope])) {
         $m->{$this->scope}();
     }
     $model = $m->findByPk($id);
     if ($model === null) {
         throw new CHttpException(404, Yii::t('LdmModule.crud', 'The requested page does not exist.'));
     }
     return $model;
 }