Explorar el Código

Se corrigio actionEliminar en ObraEmpleadoController

Jose Cienfuegos hace 8 meses
padre
commit
6ffd59f36e

+ 4 - 4
modules/v1/controllers/ObraEmpleadoController.php

@@ -36,21 +36,21 @@ class ObraEmpleadoController extends AuthController {
     $id = trim($this->req->getBodyParam("id", ""));
     $modelo = null;
 
-    if($id !== "") {
+    if ($id !== "") {
       $modelo = $this->modelClass::findOne(["id" => $id]);
     }
-    if($modelo === null) {
+    if ($modelo === null) {
       return (new Respuesta())
         ->esError()
         ->mensaje("Empleado no encontrado");
     }
     $modelo->eliminado = new Expression('now()');
-    if(!$modelo->save()) {
+    if (!$modelo->save()) {
       return (new Respuesta($modelo))
         ->mensaje("No se pudo eliminar el Empleado");
     }
 
     return (new Respuesta())
-      ->mensaje("Empleado eliminada");
+      ->mensaje("Empleado eliminado");
   }
 }

+ 39 - 43
modules/v1/controllers/ServicioController.php

@@ -18,44 +18,41 @@ class ServicioController extends AuthController {
     $taller = trim($this->req->get("taller", ""));
     $vehiculo = trim($this->req->get("vehiculo", ""));
     $marca = trim($this->req->get("marca", ""));
-    $inicio= trim($this-> req->get("inicio", ""));
-    $fin= trim($this-> req->get("fin", ""));
-    $query = $this->queryInicial 
-    -> innerJoin("Vehiculo","{{Vehiculo}}.id = {{Servicio}}.[[idVehiculo]]")
-    ->innerJoin("Marca","{{Marca}}.id = {{Vehiculo}}.[[idMarca]]")
-    ->innerJoin("Taller","{{Taller}}.id = {{Servicio}}.[[idTaller]]");
-    
-
-    if($id !== "") {
+    $inicio = trim($this->req->get("inicio", ""));
+    $fin = trim($this->req->get("fin", ""));
+    $query = $this->queryInicial
+      ->innerJoin("Vehiculo", "{{Vehiculo}}.id = {{Servicio}}.[[idVehiculo]]")
+      ->innerJoin("Marca", "{{Marca}}.id = {{Vehiculo}}.[[idMarca]]")
+      ->innerJoin("Taller", "{{Taller}}.id = {{Servicio}}.[[idTaller]]");
+
+
+    if ($id !== "") {
       $query->andWhere(["{{Servicio}}.id" => $id]);
     }
 
-    if($taller !== "") {
-        $query->andWhere(["{{Taller}}.id" => $taller]);
+    if ($taller !== "") {
+      $query->andWhere(["{{Taller}}.id" => $taller]);
     }
-    
-    if($marca !==""){
-      $query ->andWhere(["{{Marca}}.id" => $marca]);
+
+    if ($marca !== "") {
+      $query->andWhere(["{{Marca}}.id" => $marca]);
     }
 
-    if($vehiculo !== "") {
-        $query->andWhere(["{{Vehiculo}}.id" => $vehiculo]);
+    if ($vehiculo !== "") {
+      $query->andWhere(["{{Vehiculo}}.id" => $vehiculo]);
     }
-   /* if($marca !== "") {
+    /* if($marca !== "") {
       $query->andWhere(["{{Marca}}.id" => $marca]);
   }*/
-    if($inicio !=="" && $fin !==""){
-      $query->andWhere(["between", "[[fechaServicio]]", $inicio,$fin]);
+    if ($inicio !== "" && $fin !== "") {
+      $query->andWhere(["between", "[[fechaServicio]]", $inicio, $fin]);
     }
-    if($buscar) {
-      
+    if ($buscar) {
+
       $query->andWhere([
         "OR",
         ["ilike", "{{Vehiculo}}.nombre", $buscar]
       ]);
-      
-    
-
     }
 
     return new Respuesta($query, $this->limite, $this->pagina, $this->ordenar);
@@ -91,29 +88,28 @@ class ServicioController extends AuthController {
       foreach ($tipoServicio as $tipoServicioItem) {
 
         $tipoServicios = ServicioTipoServicio::findOne([
-            'idServicio' => $modelo->id,
-            'idTipoServicio' => $tipoServicioItem['idTipoServicio']
+          'idServicio' => $modelo->id,
+          'idTipoServicio' => $tipoServicioItem['idTipoServicio']
         ]);
-    
+
         if ($tipoServicios === null) {
-            $tipoServicios = new ServicioTipoServicio();
-            $tipoServicios->uuid();
-            $tipoServicios->idServicio = $modelo->id;
-            $tipoServicios->idTipoServicio = $tipoServicioItem['idTipoServicio'];
-            $tipoServicios->creado = new Expression('now()');
+          $tipoServicios = new ServicioTipoServicio();
+          $tipoServicios->uuid();
+          $tipoServicios->idServicio = $modelo->id;
+          $tipoServicios->idTipoServicio = $tipoServicioItem['idTipoServicio'];
+          $tipoServicios->creado = new Expression('now()');
         } else {
-            $tipoServicios->modificado = new Expression('now()');
+          $tipoServicios->modificado = new Expression('now()');
         }
-    
+
         $tipoServicios->nombre = $tipoServicioItem['nombre'];
         $tipoServicios->costo = $tipoServicioItem['costo'];
-    
+
         if (!$tipoServicios->save()) {
-            return (new Respuesta($tipoServicios))
-                ->mensaje("Hubo un problema al guardar el Tipo de Servicio");
+          return (new Respuesta($tipoServicios))
+            ->mensaje("Hubo un problema al guardar el Tipo de Servicio");
         }
-    }
-    
+      }
 
       $transaccion->commit();
       $modelo->refresh();
@@ -131,16 +127,16 @@ class ServicioController extends AuthController {
     $id = trim($this->req->getBodyParam("id", ""));
     $modelo = null;
 
-    if($id !== "") {
+    if ($id !== "") {
       $modelo = $this->modelClass::findOne(["id" => $id]);
     }
-    if($modelo === null) {
+    if ($modelo === null) {
       return (new Respuesta())
         ->esError()
         ->mensaje("Servicio no encontrado");
     }
     $modelo->eliminado = new Expression('now()');
-    if(!$modelo->save()) {
+    if (!$modelo->save()) {
       return (new Respuesta($modelo))
         ->mensaje("No se pudo eliminar Servicio");
     }
@@ -148,4 +144,4 @@ class ServicioController extends AuthController {
     return (new Respuesta())
       ->mensaje("Servicio eliminada");
   }
-}
+}