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(); } } } }
public function actionAjaxCreate($field, $value) { $model = new EcprContainerProcesing(); $model->{$field} = $value; try { if ($model->save()) { return TRUE; } else { return var_export($model->getErrors()); } } catch (Exception $e) { throw new CHttpException(500, $e->getMessage()); } }