Beispiel #1
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = ProyectoPedido::find();
     // Join para la relacion
     $query->joinWith(['idMaterial']);
     $query->joinWith(['asignado0']);
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     //Ordenamiento
     $dataProvider->sort->attributes['nombreMaterial'] = ['asc' => ['materiales_servicios.nombre' => SORT_ASC], 'desc' => ['materiales_servicios.nombre' => SORT_DESC]];
     $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(['proyecto_pedido.id' => $this->id, 'id_material' => $this->id_material, 'enero' => $this->enero, 'febrero' => $this->febrero, 'marzo' => $this->marzo, 'abril' => $this->abril, 'mayo' => $this->mayo, 'junio' => $this->junio, 'julio' => $this->julio, 'agosto' => $this->agosto, 'septiembre' => $this->septiembre, 'octubre' => $this->octubre, 'noviembre' => $this->noviembre, 'diciembre' => $this->diciembre, 'precio' => $this->precio, 'fecha_creacion' => $this->fecha_creacion, 'asignado' => $this->asignado, 'proyecto_pedido.estatus' => $this->estatus]);
     $query->andFilterWhere(['like', 'materiales_servicios.nombre', $this->nombreMaterial]);
     $query->andFilterWhere(['like', 'proyecto_usuario_asignar.proyecto_especifica', $this->proyectoEspecifica]);
     return $dataProvider;
 }
 /**
  * Finds the ProyectoPedido model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return ProyectoPedido the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = ProyectoPedido::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }