/** * 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) { $model = $this->loadModel($id); $oClientes = Cliente::model()->ordemNome()->findAll(); $oLogItemNaoCadastrador = new LogItemNaoCadastrado(); $oOrdemServicoItem = new OrdemServicoItem(); $oServicos = Servico::model()->ordenarTitulo()->naoExcluido()->findAll(); $oProdutos = Produto::model()->ordenarTitulo()->naoExcluido()->findAll(); if (isset($_POST['OrdemServico'])) { $model->attributes = $_POST['OrdemServico']; if ($model->save()) { $oOrdemServicoItem->ordem_servico_id = $model->id; if (!empty($_POST['OrdemServicoItem'])) { $oOrdemServicoItem->salvarItens($_POST['OrdemServicoItem']); } if (!empty($_POST['LogItemNaoCadastrado'])) { $oOrdemServicoItem->salvarItensNaoCadastrados($_POST['LogItemNaoCadastrado']); } $this->redirect(array('view', 'id' => $model->id)); } } $this->render('update', array('model' => $model, 'oClientes' => $oClientes, 'oOrdemServicoItem' => $oOrdemServicoItem, 'valor_total' => $model->getValorTotal(), 'oLogItemNaoCadastrador' => $oLogItemNaoCadastrador, 'oServicos' => $oServicos, 'oProdutos' => $oProdutos)); }
/** * 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 $id the ID of the model to be loaded * @return Servico the loaded model * @throws CHttpException */ public function loadModel($id) { $model = Servico::model()->findByPk($id); if ($model === null) { throw new CHttpException(404, 'The requested page does not exist.'); } return $model; }