Esempio n. 1
0
 /**
  * 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);
     $exists = Bienmueble::model()->exists('factura_id=' . $model->id);
     if (!$exists) {
         $model->delete();
     } else {
         Yii::app()->user->setFlash('error', 'Existen bienes que utilizan esta factura.');
         $this->redirect(array('view', 'id' => $model->id));
     }
     if (!isset($_GET['ajax'])) {
         $this->redirect(isset($_POST['returnUrl']) ? $_POST['returnUrl'] : array('index'));
     }
 }
Esempio n. 2
0
 public function actionUpdateAjax()
 {
     $data = array();
     $error = '';
     $user_id = Yii::app()->user->getId();
     $user = Usuario::model()->findbyPk($user_id);
     $dp_id = $user->dependencia_id;
     if (isset($_POST['codigo'])) {
         $bm = Bienmueble::model()->findByDp($dp_id, $_POST['codigo']);
         if ($bm == NULL) {
             $error = 'No se encuentra la placa indicada en el departamento.';
         } else {
             Yii::app()->session['bmid'] = $bm;
             $data['bm'] = $bm;
         }
     } else {
         $error = 'Por favor, indique correctamente la placa.';
     }
     $data['error'] = $error;
     $this->renderPartial('_content', $data, false, true);
 }
Esempio n. 3
0
 /**
  * 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 the ID of the model to be loaded
  */
 public function loadModel($id)
 {
     $model = Bienmueble::model()->findByPk($id);
     if ($model === null) {
         throw new CHttpException(404, 'The requested page does not exist.');
     }
     return $model;
 }