/** * Updates a particular model. * If update is successful, the browser will be redirected to the 'view' page. * @param integer $id the ID of the model to be updated */ public function actionUpdate($id) { try { $model = $this->loadModel($id); $model->scenario = 'update'; $model->aModelDetail = $model->rDetail; if (!FiInvoice::CanUpdate($model)) { $this->redirect(array('index')); } if (isset($_POST['FiInvoice'])) { $model->attributes = $_POST['FiInvoice']; if ($model->save()) { FiInvoiceDetail::deleteDetail($model); FiInvoiceDetail::fnUpdateInvoiceId($_POST['FiInvoiceDetail']['id'], $model->id); FiInvoiceDetail::fnUpdateAmount($model); FiInvoice::fnUpdateTotalAmount($model); $this->redirect(array('view', 'id' => $model->id)); // $this->redirect(array('update','id'=>$model->id)); } } $this->render('update', array('model' => $model, 'actions' => $this->listActionsCanAccess)); } catch (Exception $e) { Yii::log("Exception " . print_r($e, true), 'error'); throw new CHttpException("Exception " . print_r($e, true)); } }