/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Ubicaciones::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(['like', 'id', $this->id])->andFilterWhere(['like', 'Descripcion', $this->Descripcion]); return $dataProvider; }
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"; } } } } }
/** * @return \yii\db\ActiveQuery */ public function getUbicacion0() { return $this->hasOne(Ubicaciones::className(), ['id' => 'ubicacion']); }
/** * 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]); } }
/** * Finds the Ubicaciones model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * @param string $id * @return Ubicaciones the loaded model * @throws NotFoundHttpException if the model cannot be found */ protected function findModel($id) { if (($model = Ubicaciones::findOne($id)) !== null) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } }