Browse Source

Arreglo de buscadores

Jogibeda 5 months ago
parent
commit
ac45b309d5

+ 1 - 1
modules/v1/controllers/ColorController.php

@@ -52,7 +52,7 @@ class ColorController extends AuthController
     $modelo->load($this->req->getBodyParams(), '');
 
     $clave = $modelo->clave;  
-    $existeClave = $this->modelClass::find()->andWhere(['clave' => $clave])->andWhere(['eliminado'=>null])->exists();
+    $existeClave = $this->modelClass::find()->andWhere(['clave' => $clave])->andWhere(['<>', 'id', $id])->andWhere(['eliminado'=>null])->exists();
 
     if ($existeClave) {
       return (new Respuesta())

+ 14 - 2
modules/v1/controllers/HerramientaInventarioController.php

@@ -13,14 +13,23 @@ class HerramientaInventarioController extends AuthController {
   public function actionIndex() {
     $id = trim($this->req->get("id", ""));
     $buscar = trim($this->req->get("q", ""));
-
+    $herramienta = trim($this ->req->get("herramienta",""));
+    $cantidad = trim($this ->req->get("cantidad",""));
+    $inicio = trim($this->req->get("inicio", ""));
+    $fin = trim($this->req->get("fin", ""));
     $query = $this->queryInicial;
 
     if($id > 0) {
       $query->andWhere(["id" => $id]);
     }
 
+    if($herramienta){
+      $query->andWhere( ['idHerramienta'=>$herramienta]);
+    }
 
+    if($cantidad){
+      $query->andWhere( ['like', 'CAST(cantidad AS TEXT)', (string)$cantidad]);
+    }
     if($buscar) {
       
       $query->andWhere([
@@ -29,7 +38,10 @@ class HerramientaInventarioController extends AuthController {
       ]);
 
     }
-
+    if ($inicio !== "" && $fin !== "") {
+      $query->andWhere(['>=', '[[fechaIngreso]]', $inicio])
+      ->andWhere(['<=', '[[fechaIngreso]]', $fin]);
+    }
     return new Respuesta($query, $this->limite, $this->pagina, $this->ordenar);
   }
 

+ 5 - 4
modules/v1/controllers/ServicioController.php

@@ -21,9 +21,9 @@ class ServicioController extends AuthController {
     $inicio = trim($this->req->get("inicio", ""));
     $fin = trim($this->req->get("fin", ""));
     $query = $this->queryInicial
-      ->leftJoin("Vehiculo", "{{Vehiculo}}.[[id]] = {{Servicio}}.[[idVehiculo]]")
-      ->leftJoin("Marca", "{{Marca}}.[[id]] = {{Vehiculo}}.[[idMarca]]")
-      ->leftJoin("Taller", "{{Taller}}.[[id]] = {{Servicio}}.[[idTaller]]");
+      ->innerJoin("Vehiculo", "{{Vehiculo}}.[[id]] = {{Servicio}}.[[idVehiculo]]")
+      ->innerJoin("Marca", "{{Marca}}.[[id]] = {{Vehiculo}}.[[idMarca]]")
+      ->innerJoin("Taller", "{{Taller}}.[[id]] = {{Servicio}}.[[idTaller]]");
 
 
     if ($id !== "") {
@@ -45,7 +45,8 @@ class ServicioController extends AuthController {
       $query->andWhere(["{{Marca}}.id" => $marca]);
   }*/
     if ($inicio !== "" && $fin !== "") {
-      $query->andWhere(["between", "[[fechaServicio]]", $inicio, $fin]);
+      $query->andWhere(['>=', '[[fechaServicio]]', $inicio])
+      ->andWhere(['<=', '[[fechaServicio]]', $fin]);
     }
     if ($buscar) {