/** * 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 ClienteFiador the loaded model * @throws CHttpException */ public function loadModel($id) { $model = ClienteFiador::model()->findByPk($id); if ($model === null) { throw new CHttpException(404, 'The requested page does not exist.'); } return $model; }
?> </div> <div class="clearfix"></div> <?php } ?> <?php $fiador_rut = ""; $fiador_nombre = ""; $fiador_apellido = ""; $fiador_email = ""; $fiador_telefono = ""; $fiador_direccion = ""; $cliente_fiador = ClienteFiador::model()->findByAttributes(array('cliente_id' => $model->id)); if ($cliente_fiador != null) { $fiador = Fiador::model()->findByAttributes(array('id' => $cliente_fiador->fiador_id)); if ($fiador != null) { $fiador_rut = $fiador->rut; $fiador_nombre = $fiador->nombre; $fiador_apellido = $fiador->apellido; $fiador_email = $fiador->email; $fiador_telefono = $fiador->telefono; $fiador_direccion = $fiador->direccion; } } ?> <br/> <fieldset> <legend>Opcionalmente puede agregar un Fiador a este cliente</legend>
/** * Deletes a particular model. * If deletion is successful, the browser will be redirected to the 'admin' page. * @param integer $id the ID of the model to be deleted */ public function actionDelete($id) { $model = $this->loadModel($id); $usuario = Usuario::model()->findByPk($model->usuario_id); $cliente_fiador = ClienteFiador::model()->findByAttributes(array('cliente_id' => $id)); if ($cliente_fiador != null) { $fiador = $cliente_fiador->fiador; $cliente_fiador->delete(); if ($fiador != null) { $fiador->delete(); } } $model->delete(); Authassignment::model()->deleteAllByAttributes(array('userid' => $usuario->id)); $usuario->delete(); // if AJAX request (triggered by deletion via admin grid view), we should not redirect the browser if (!isset($_GET['ajax'])) { $this->redirect(isset($_POST['returnUrl']) ? $_POST['returnUrl'] : array('admin')); } }