public function loadModel($id) { $m = EtprTerminalPrices::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('EdifactDataModule.crud', 'The requested page does not exist.')); } return $model; }
public function recalc() { //parent::afterSave(); $must_save = false; //konteiner init record if (empty($this->ecnt_ecpr_id) && empty($this->ecprContainerProcesings) && ($this->ecnt_operation == EcntContainer::ECNT_OPERATION_TRUCK_IN || $this->ecnt_operation == EcntContainer::ECNT_OPERATION_VESSEL_DISCHARGE)) { $ecpr = new EcprContainerProcesing(); $ecpr->ecpr_start_ecnt_id = $this->ecnt_id; $ecpr->save(); $this->ecnt_ecpr_id = $ecpr->ecpr_id; $must_save = true; } $action_amt = EtprTerminalPrices::calcActionAmt($this->ecnt_id); if ($action_amt['amt'] != $this->ecnt_action_amt) { $this->ecnt_action_amt = $action_amt['amt']; $this->ecnt_action_calc_notes = $action_amt['amt_formul']; $must_save = true; } $time_amt = EtprTerminalPrices::calcTimeAmt($this); if ($time_amt['amt'] != $this->ecnt_time_amt) { $this->ecnt_time_amt = $time_amt['amt']; $this->ecnt_time_calc_notes = $time_amt['amt_formul']; $must_save = true; } if ($must_save) { $this->save(); } //konteinera final record if ($this->ecnt_operation == EcntContainer::ECNT_OPERATION_TRUCK_OUT || $this->ecnt_operation == EcntContainer::ECNT_OPERATION_VESSEL_LOAD) { if (!empty($this->ecnt_ecpr_id)) { $ecpr = $this->ecntEcpr; if (!empty($ecpr) && $ecpr->ecprStartEcnt->ecnt_datetime < $this->ecnt_datetime) { $ecpr->ecpr_end_ecnt_id = $this->ecnt_id; $ecpr->save(); } } } }