public function report($params)
 {
     $query = Prestamos::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $this->load($params);
     if (!$this->validate()) {
         return $dataProvider;
     }
     $query->andFilterWhere(['id' => $this->id, 'codigo' => $this->codigo, 'id_status' => 3]);
     $query->andWhere('fecha_devolucion <  CURDATE() ');
     $query->andFilterWhere(['like', 'cedula', $this->cedula]);
     return $dataProvider;
 }
Beispiel #2
0
 public function esta_disponible($atributo, $params)
 {
     $disponible = 0;
     $recurso = Recursos::findOne($this->codigo);
     if ($recurso == null) {
         $this->addError($atributo, 'Recurso no existe');
         return false;
     }
     $prestamos = Prestamos::findBySql("SELECT id FROM prestamos WHERE codigo = " . $this->codigo . " and id_status = 3 ")->all();
     if ($prestamos == null) {
         $numPrestamos = 0;
     } else {
         $numPrestamos = count($prestamos);
     }
     $disponible = $recurso->total_existente - $numPrestamos;
     if ($disponible > 0) {
         return true;
     } else {
         $this->addError($atributo, 'Recurso no disponible');
         return false;
     }
 }
 /**
  * Finds the Prestamos model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return Prestamos the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = Prestamos::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }