Пример #1
0
 /**
  * Retorna todos los atributos con sus tipos correspondientes
  * @return array() de tipos
  */
 public function getTipos()
 {
     $ubicaciones = new Ubicaciones();
     $categorias = new CategoriasObjetos();
     $subcategorias = new TipoCategorias();
     return ['ID' => 'number', 'Estado' => Objeto::$estados, 'Fecha de Alta' => 'date', 'Fecha de Baja' => 'date', 'Categoría' => $categorias->getCategorias(), 'Ubicación' => $ubicaciones->getUbicaciones(), 'Tipo' => $subcategorias->getAllTipoCategorias(), 'Descripción (N/S)' => 'text'];
 }
 /**
  * Updates an existing TipoCategorias model.
  * If update is successful, the browser will be redirected to the 'view' page.
  * @param integer $id
  * @return mixed
  */
 public function actionUpdate($id)
 {
     //$this->comprobarPermiso();
     $model = $this->findModel($id);
     $objetos = new CategoriasObjetos();
     $categorias = $objetos->getCategorias();
     if ($model->load(Yii::$app->request->post()) && $model->save()) {
         return $this->redirect(['view', 'id' => $model->id]);
     } else {
         return $this->render('update', ['model' => $model, 'categorias' => $categorias]);
     }
 }
Пример #3
0
 public function actionAjax()
 {
     if (isset($_POST['categoria'])) {
         $categoria = $_POST['categoria'];
         $tc = new TipoCategorias();
         echo json_encode($tc->getTipoCategoriasByCategoria($categoria));
     }
     if (isset($_POST['dameusu'])) {
         $damecat = $_POST['dameusu'];
         if ($damecat) {
             $tc = new Usuario();
             echo json_encode($tc->getUsuarios());
         }
     }
     if (isset($_POST['damecat'])) {
         $damecat = $_POST['damecat'];
         if ($damecat) {
             $tc = new CategoriasObjetos();
             echo json_encode($tc->getCategorias());
         }
     }
     if (isset($_POST['dameubi'])) {
         $damecat = $_POST['dameubi'];
         if ($damecat) {
             $tc = new Ubicaciones();
             echo json_encode($tc->getUbicaciones());
         }
     }
     if (isset($_POST['damesubc'])) {
         $damecat = $_POST['damesubc'];
         if ($damecat) {
             $tc = new TipoCategorias();
             echo json_encode($tc->getAllTipoCategorias());
         }
     }
     if (isset($_POST['damecg'])) {
         $damecat = $_POST['damecg'];
         if ($damecat) {
             $tc = new Cuenta();
             echo json_encode($tc->getConceptosGastos());
         }
     }
     if (isset($_POST['dameci'])) {
         $damecat = $_POST['dameci'];
         if ($damecat) {
             $tc = new Cuenta();
             echo json_encode($tc->getConceptoIngresos());
         }
     }
     if (isset($_POST['duplicar'])) {
         //Llama al procedimiento
         $dup = $_POST['duplicar'];
         if ($dup) {
             if (isset($_POST['id']) && isset($_POST['cantidad'])) {
                 $id = $_POST['id'];
                 $cantidad = $_POST['cantidad'];
                 $model = new Objeto();
                 try {
                     $numRowsAffected = $model::getDb()->createCommand("call duplicarObjeto(" . $id . "," . $cantidad . ");")->execute();
                     $objeto = Objeto::findOne($id);
                     echo "Se han añadido " . $cantidad . " registros más del objeto " . $objeto->tipo . " de " . $objeto->ubicacion;
                 } catch (yii\db\Exception $e) {
                     echo "No se ha podido duplicar según su solicitud";
                 }
             }
         }
     }
 }
Пример #4
0
 /**
  * Updates an existing Objeto model.
  * If update is successful, the browser will be redirected to the 'view' page.
  * @param integer $id
  * @return mixed
  */
 public function actionUpdate($id)
 {
     $this->comprobarPermiso();
     $model = $this->findModel($id);
     echo $id;
     if ($model->load(Yii::$app->request->post()) && $model->save()) {
         return $this->redirect(['view', 'id' => $model->id]);
     } else {
         $objetos = new CategoriasObjetos();
         $categorias = $objetos->getCategorias();
         $ubicacion = new Ubicaciones();
         $ubicaciones = $ubicacion->getUbicaciones();
         $tc = new TipoCategorias();
         $tiposCategorias = $tc->getTipoCategorias();
         return $this->render('update', ['model' => $model, 'categorias' => $categorias, 'ubicaciones' => $ubicaciones, 'estados' => Objeto::$estados]);
     }
 }