Kaynağa Gözat

Arreglo de buscador de HerramientaObra

Jogibeda 8 ay önce
ebeveyn
işleme
3210003bab

+ 26 - 11
modules/v1/controllers/HerramientaObraController.php

@@ -13,24 +13,39 @@ class HerramientaObraController extends AuthController {
   public function actionIndex() {
     $id = trim($this->req->get("id", ""));
     $buscar = trim($this->req->get("q", ""));
-   
-
-    $query = $this->queryInicial;
+   $empleado= trim($this->req->get("empleado",""));
+   $herramienta= trim($this->req->get("herramienta",""));
+   $obra= trim($this->req->get("obra",""));
+   $inicio= trim($this-> req->get("inicio", ""));
+    $fin= trim($this-> req->get("fin", ""));
+    $query = $this->queryInicial
+    -> innerJoin("Empleado","{{Empleado}}.[[id]] = {{HerramientaObra}}.[[idEmpleado]]")
+    -> innerJoin("Herramienta","{{Herramienta}}.[[id]] = {{HerramientaObra}}.[[idHerramienta]]")
+    -> innerJoin("Obra","{{Obra}}.[[id]] = {{HerramientaObra}}.[[idObra]]");
 
     if($id > 0) {
-      $query->andWhere(["id" => $id]);
+      $query->andWhere(["{{HerramientaObra}}.id" => $id]);
     }
 
-    
+    if($id !== "") {
+      $query->andWhere(["{{HerramientaObra}}.id" => $id]);
+    }
+    if ($empleado !== "") {
+      $query->andWhere(["like", "{{Empleado}}.[[nombre]]", $empleado]);
+  }
+    if($herramienta !== "") {
+      $query->andWhere(["{{Herramienta}}.id" => $herramienta]);
 
-    if($buscar) {
-      
-      $query->andWhere([
-        "OR",
-        ["ilike", "idEmpleado", $buscar]
-      ]);
+    }
+
+    if($obra !== "") {
+      $query->andWhere(["{{Obra}}.id" => $obra]);
 
     }
+    if($inicio !=="" && $fin !==""){
+      $query->andWhere(["between", "[[fechaServicio]]", $inicio,$fin]);
+    }
+    
 
     return new Respuesta($query, $this->limite, $this->pagina, $this->ordenar);
   }

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

@@ -31,6 +31,10 @@ class ServicioController extends AuthController {
     if($taller !== "") {
         $query->andWhere(["{{Taller}}.id" => $taller]);
     }
+    
+    if($marca !==""){
+      $query ->andWhere(["{{Marca}}.id" => $marca]);
+    }
 
     if($vehiculo !== "") {
         $query->andWhere(["{{Vehiculo}}.id" => $vehiculo]);

+ 3 - 1
modules/v1/models/HerramientaObra.php

@@ -3,7 +3,9 @@
 namespace v1\models;
 
 use app\models\HerramientaObra as ModeloHerramientaObra;
-
+use app\models\Empleado;
+use app\models\Herramienta;
+use app\models\Obra;
 class HerramientaObra extends ModeloHerramientaObra
 {