Browse Source

Modificacion de buscadores de Marca,Obra y TipoAuto, tambien se añadio la migracion donde la clave en todos los modulos es unica

Jogibeda 8 months ago
parent
commit
52666e7a86

+ 88 - 0
migrations/m240816_194601_agregacion_unique_en_claves.php

@@ -0,0 +1,88 @@
+<?php
+
+use yii\db\Migration;
+
+/**
+ * Class m240816_194601_agregacion_unique_en_claves
+ */
+class m240816_194601_agregacion_unique_en_claves extends Migration
+{
+    /**
+     * {@inheritdoc}
+     */
+    public function safeUp()
+    {
+        $this->createIndex(
+            'id-claveColor-unique',
+            'Color',
+            'clave',
+            true 
+        );
+        $this->createIndex(
+            'id-claveMarca-unique',
+            'Marca',
+            'clave',
+            true 
+        );
+        $this->createIndex(
+            'id-claveTipoAuto-unique',
+            'TipoAuto',
+            'clave',
+            true 
+        );
+        $this->createIndex(
+            'id-claveTipoHerramienta-unique',
+            'TipoHerramienta',
+            'clave',
+            true 
+        );
+        $this->createIndex(
+            'id-claveTipoServicio-unique',
+            'TipoServicio',
+            'clave',
+            true 
+        );
+    }
+
+    /**
+     * {@inheritdoc}
+     */
+    public function safeDown()
+    {
+        $this->dropIndex(
+            'id-claveColor-unique',
+            'Color'
+        );
+        $this->dropIndex(
+            'id-claveMarca-unique',
+            'Marca'
+        );
+        $this->dropIndex(
+            'id-claveTipoAuto-unique',
+            'TipoAuto'
+        );
+        $this->dropIndex(
+            'id-claveTipoHerramienta-unique',
+            'TipoHerramienta'
+        );
+        $this->dropIndex(
+            'id-claveTipoServicio-unique',
+            'TipoServicio'
+        );
+    }
+
+    /*
+    // Use up()/down() to run migration code without a transaction.
+    public function up()
+    {
+
+    }
+
+    public function down()
+    {
+        echo "m240816_194601_agregacion_unique_en_claves cannot be reverted.\n";
+
+        return false;
+    }
+    */
+}

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

@@ -25,7 +25,7 @@ class MarcaController extends AuthController {
       
       $query->andWhere([
         "OR",
-        ["ilike", "marca", $buscar]
+        ["like", "marca", $buscar]
       ]);
 
     }

+ 10 - 4
modules/v1/controllers/ObraController.php

@@ -13,16 +13,22 @@ class ObraController extends AuthController {
   public function actionIndex() {
     $id = trim($this->req->get("id", ""));
     $buscar = trim($this->req->get("q", ""));
-   
-
+   $rangoInicio= trim($this->req->get("inicio",""));
+   $rangoFin= trim($this->req->get("fin",""));
+  $rangoI=trim($this->req->get("rinicio",""));
+  $rangoF=trim($this->req->get("rfin",""));
     $query = $this->queryInicial;
 
     if($id > 0) {
       $query->andWhere(["id" => $id]);
     }
 
-    
-
+    if($rangoInicio !=="" && $rangoFin !==""){
+      $query->andWhere(["between", "[[fechaInicio]]", $rangoInicio,$rangoFin]);
+    }
+    if($rangoI !=="" && $rangoF !==""){
+      $query->andWhere(["between", "[[fechaFinal]]", $rangoI,$rangoF]);
+    }
     if($buscar) {
       
       $query->andWhere([

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

@@ -25,7 +25,7 @@ class TipoAutoController extends AuthController {
       
       $query->andWhere([
         "OR",
-        ["ilike", "tipo", $buscar]
+        ["like", "tipo", $buscar]
       ]);
 
     }