Bladeren bron

Agregado las fechas en nomina, un buscador en obra para gasto, pago y nomina

Jogibeda 6 maanden geleden
bovenliggende
commit
3041e93046

+ 42 - 0
migrations/m241017_192914_Agregar_Fechas_en_Nomina.php

@@ -0,0 +1,42 @@
+<?php
+
+use yii\db\Migration;
+
+/**
+ * Class m241017_192914_Agregar_Fechas_en_Nomina
+ */
+class m241017_192914_Agregar_Fechas_en_Nomina extends Migration
+{
+    /**
+     * {@inheritdoc}
+     */
+    public function safeUp()
+    { 
+        $this->addColumn('Nomina', 'fechaInicio', $this->timestamp()->append(" with time zone"),);
+        $this->addColumn('Nomina', 'fechaFin', $this->timestamp()->append(" with time zone"),);
+    }
+
+    /**
+     * {@inheritdoc}
+     */
+    public function safeDown()
+    {
+        $this->dropColumn('Nomina', 'fechaInicio');
+        $this->dropColumn('Nomina', 'fechaFin');
+    }
+
+    /*
+    // Use up()/down() to run migration code without a transaction.
+    public function up()
+    {
+
+    }
+
+    public function down()
+    {
+        echo "m241017_192914_Agregar_Fechas_en_Nomina cannot be reverted.\n";
+
+        return false;
+    }
+    */
+}

+ 3 - 1
models/Nomina.php

@@ -40,7 +40,7 @@ class Nomina extends ModeloBase
         return [
             [['id'], 'required'],
             [['montoPagado', 'descuento'], 'number'],
-            [['creado', 'fechaPago', 'modificado', 'eliminado'], 'safe'],
+            [['creado', 'fechaInicio','fechaFin', 'modificado', 'eliminado'], 'safe'],
             [['id', 'idEmpleado', 'idObra', 'idUsuario'], 'string', 'max' => 36],
             [['id'], 'unique'],
             [['idEmpleado'], 'exist', 'skipOnError' => true, 'targetClass' => Empleado::class, 'targetAttribute' => ['idEmpleado' => 'id']],
@@ -61,6 +61,8 @@ class Nomina extends ModeloBase
             'idUsuario' => 'Id Usuario',
             'montoPagado' => 'Monto Pagado',
             'descuento' => 'Descuento',
+            'fechaInicio'=>'fecha Inicio',
+            'fechaFin'=>'fecha Fin',
             'creado' => 'Creado',
             'fechaPago' => 'Fecha Pago',
             'modificado' => 'Modificado',

+ 1 - 1
models/Servicio.php

@@ -43,7 +43,7 @@ class Servicio extends ModeloBase
             [['id', 'factura'], 'required'],
             [['descripcion'], 'string'],
             [['fechaServicio', 'creado', 'modificado', 'eliminado'], 'safe'],
-            [['id', 'idTaller', 'idVehiculo', 'idTipo' ], 'string', 'max' => 36],
+            [['id', 'idTaller', 'idVehiculo',  ], 'string', 'max' => 36],
             [['factura'], 'string', 'max' => 100],
             [['id'], 'unique'],
             [['idTaller'], 'exist', 'skipOnError' => true, 'targetClass' => Taller::class, 'targetAttribute' => ['idTaller' => 'id']],

+ 4 - 2
modules/v1/controllers/GastoController.php

@@ -15,14 +15,16 @@ class GastoController extends AuthController
   {
     $id = trim($this->req->get("id", ""));
     $buscar = trim($this->req->get("q", ""));
-
+    $idObra=trim($this->req->get("idObra",""));
     $query = $this->queryInicial;
 
 
     if ($id !== "") {
       $query->andWhere(["id" => $id]);
     }
-
+    if ($idObra !== "") {
+      $query->andWhere(["idObra" => $idObra]);
+    }
     if ($buscar) {
 
       $query->andWhere([

+ 4 - 6
modules/v1/controllers/NominaController.php

@@ -14,8 +14,8 @@ class NominaController extends AuthController
   public function actionIndex()
   {
     $id = trim($this->req->get("id", ""));
-    $idEmpleado = trim($this->req->get("idEmpleado", ""));
-    $idObra = trim($this->req->get("idObra", ""));
+    $idEmpleado = trim($this->req->get("empleado", ""));
+    $idObra = trim($this->req->get("obra", ""));
     $buscar = trim($this->req->get("q", ""));
 
     $query = $this->queryInicial;
@@ -24,7 +24,7 @@ class NominaController extends AuthController
     if ($id !== "") {
       $query->andWhere(["id" => $id]);
     }
-    
+   
     if ($idEmpleado !== "") {
         $query->andWhere(["idEmpleado" => $idEmpleado]);
     }
@@ -33,9 +33,7 @@ class NominaController extends AuthController
         $query->andWhere(["idObra" => $idObra]);
     }
 
-    if($buscar !==""){
-      $query->andWhere(["nombre"=>$buscar]);
-    }
+   
 
     return new Respuesta($query, $this->limite, $this->pagina, $this->ordenar);
   }

+ 4 - 1
modules/v1/controllers/PagoController.php

@@ -15,6 +15,7 @@ class PagoController extends AuthController
   {
     $id = trim($this->req->get("id", ""));
     $buscar = trim($this->req->get("q", ""));
+    $idObra=trim($this->req->get("idObra",""));
 
     $query = $this->queryInicial;
 
@@ -22,7 +23,9 @@ class PagoController extends AuthController
     if ($id !== "") {
       $query->andWhere(["id" => $id]);
     }
-
+    if ($idObra !== "") {
+      $query->andWhere(["idObra" => $idObra]);
+    }
     if ($buscar) {
 
       $query->andWhere([

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

@@ -60,7 +60,7 @@ class ServicioController extends AuthController {
 
   public function actionGuardar() {
     $id = trim($this->req->getBodyParam("id", ""));
-    $tipoServicio = $this->req->getBodyParam("tipoServicio", []);
+    $tipoServicio = $this->req->getBodyParam("ListaTipoServicios", []);
     $modelo = null;
 
     $transaccion = \Yii::$app->db->beginTransaction();

+ 2 - 1
modules/v1/models/Nomina.php

@@ -16,7 +16,8 @@ class Nomina extends ModeloNomina
             'idUsuario',
             'montoPagado',
             'descuento',
-            'fechaPago',
+            'fechaInicio',
+            'fechaFin',
             'creado',
             'modificado',
 

+ 1 - 1
modules/v1/models/Servicio.php

@@ -41,7 +41,7 @@ class Servicio extends ModeloServicio {
         return $this->hasOne(Vehiculo::class, ['id' => 'idVehiculo']);
     }
     public function getTipoServicio() {
-        return $this->hasMany(TipoServicio::class, ['id' => 'idTipo']);
+        return $this->hasMany(TipoServicio::class, ['idTipo' => 'id']);
     }
     public function getServicioElemento()
     {