Ejemplo n.º 1
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Objeto::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $this->load($params);
     if (!$this->validate()) {
         // uncomment the following line if you do not want to return any records when validation fails
         // $query->where('0=1');
         return $dataProvider;
     }
     $query->andFilterWhere(['id' => $this->id, 'estado' => $this->estado, 'fecha_alta' => $this->fecha_alta, 'fecha_baja' => $this->fecha_baja]);
     $query->andFilterWhere(['like', 'ubicacion', $this->ubicacion])->andFilterWhere(['like', 'categoria', $this->categoria])->andFilterWhere(['like', 'tipo', $this->tipo])->andFilterWhere(['like', 'Descripcion', $this->Descripcion]);
     return $dataProvider;
 }
Ejemplo n.º 2
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";
                 }
             }
         }
     }
 }
Ejemplo n.º 3
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getObjetos()
 {
     return $this->hasMany(Objeto::className(), ['ubicacion' => 'id']);
 }
Ejemplo n.º 4
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getObjetos()
 {
     return $this->hasMany(Objeto::className(), ['tipo' => 'tipo']);
 }
Ejemplo n.º 5
0
 /**
  * Finds the Objeto model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return Objeto the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = Objeto::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
Ejemplo n.º 6
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getObjetos()
 {
     return $this->hasMany(Objeto::className(), ['categoria' => 'id']);
 }