Forráskód Böngészése

Modificación de Frontend

JeanBenitez 2 éve
szülő
commit
612210402b

+ 49 - 0
sistema-mantenimiento-back/app/Http/Controllers/CountriesController.php

@@ -0,0 +1,49 @@
+<?php
+
+namespace App\Http\Controllers;
+
+use Illuminate\Http\Request;
+use Illuminate\Support\Facades\DB;
+use Throwable;
+
+class CountriesController extends Controller
+{
+    private $response_controller;
+    private $encrypt_controller;
+    public function __construct()
+    {
+        $this->response_controller = new ResponseController();
+        $this->encrypt_controller = new EncryptionController();
+    }
+
+    public function getCountries($line_number)
+    {
+        try {
+
+            // Busca si el subcontratista existe
+            $countries = DB::table("S002V01TPAIS")
+                ->select(
+                    "PAIS_IDPA as COUNTRY_ID",
+                    "PAIS_NOMB as NAME",
+                    "PAIS_LADA as LADA",
+                    "PAIS_NOME AS NOMECLARUTA_ISO2",
+                    "PAIS_NOM2 AS NOMECLARUTA_ISO3"
+                )
+                ->where('PAIS_NULI', '=', $line_number)
+                ->get();
+
+            // Verifica si el objeto esta vacio
+            if (!isset($countries[0]) && empty($countries[0])) {
+                return $this->response_controller
+                    ->makeResponse(TRUE, "ERR_SUBCONTRATISTA_REG001: No se encontró al subcontratista", $countries, 500);
+            }
+
+            return $this->response_controller->makeResponse(FALSE, 'Consulta exitosa', $countries);
+
+        } catch (Throwable $th) {
+            return $this->response_controller
+                ->makeResponse(TRUE, 'ERR_SUBCONTRATISTA_REG005: Error inesperado', strtoupper($th->getMessage()), 500);
+        }
+    }
+
+}

+ 99 - 88
sistema-mantenimiento-back/app/Http/Controllers/EmployeeController.php

@@ -399,94 +399,105 @@ class EmployeeController extends Controller
         }
     }
 
-    // Metodo para la activación logica de un empleado
-    public function updateToActiveStatus(Request $request, $id_employee)
-    {
-        try {
-            $request['SAVED_BY_USER'] = $this->encrypt_controller->decrypt($request->SAVED_BY_USER);
-            $validator = Validator::make($request->all(), [
-                "SAVED_BY_USER" => ['required', 'digits:10']
-            ]);
-
-            if ($validator->fails()) {
-                return $this->response_controller->makeResponse(
-                    TRUE,
-                    'ERR_PERSONAL_REG001: Uno o más errores encontrados',
-                    $this->response_controller->makeErrors($validator->errors()->messages()),
-                    400
-                );
-            }
-
-            // Busca si el empleado existe
-            $search_employee = DB::table("S002V01TPERS")
-                ->select("PERS_IDPE")
-                ->where("PERS_IDPE", "=", $id_employee)
-                ->where('PERS_NULI', '=', $request->LINE_NUMBER)
-                ->first();
-
-            // Verifica si el objeto esta vacio
-            if (!isset($search_employee) && empty($search_employee)) {
-                return $this->response_controller
-                    ->makeResponse(TRUE, "ERR_PERSONAL_REG002: No se encontró al empleado", $search_employee, 500);
-            }
-
-            $user_register = DB::table('S002V01TUSUA')
-                ->select('USUA_IDUS as ID_USER')
-                ->where('USUA_IDUS', '=', $request->SAVED_BY_USER)
-                ->where('USUA_NULI', '=', $request->LINE_NUMBER)
-                ->first();
-
-            // Verifica si el objeto esta vacio
-            if (!isset($user_register) && empty($user_register)) {
-                return $this->response_controller
-                    ->makeResponse(TRUE, "ERR_USUARIO_REG003: Tu usuario no es válido para activar empleados", [], 500);
-            }
-
-            DB::beginTransaction(); # Para impedir que las actualizaciones queden incompletas
-
-            $UPDATE_DATE = Carbon::now()->timezone('America/Mexico_City')->toDateTimeString();
-
-            $activate_employee = DB::table('S002V01TPERS')
-                ->where('PERS_IDPE', $id_employee)
-                ->where('PERS_NULI', '=', $request->LINE_NUMBER)
-                ->update([
-                    "PERS_ESTA" => "Activo",
-                    "PERS_USMO" => trim($request->SAVED_BY_USER),
-                    "PERS_FEMO" => $UPDATE_DATE,
-                    "PERS_FEAR" => DB::raw('CURRENT_TIMESTAMP')
-                ]);
-
-            // Verifica que la actualización fuera exitosa
-            if ($activate_employee < 1) {
-                return $this->response_controller
-                    ->makeResponse(TRUE, 'ERR_PERSONAL_REG004: Algo salió mal, error activando al empleado', [], 500);
-            }
-
-            $activate_employee = DB::table('S002V01TPEEM')
-                ->where('PEEM_IDPE', $id_employee)
-                ->where('PEEM_NULI', '=', $request->LINE_NUMBER)
-                ->update([
-                    "PEEM_ESTA" => "Activo",
-                    "PEEM_USMO" => trim($request->SAVED_BY_USER),
-                    "PEEM_FEMO" => $UPDATE_DATE,
-                    "PEEM_FEAR" => DB::raw('CURRENT_TIMESTAMP')
-                ]);
-
-            // Verifica que la actualización fuera exitosa
-            if ($activate_employee < 1) {
-                DB::rollBack(); # Si no se logra eliminar al empleado en el equipo, se revierten los cambios previos
-                return $this->response_controller
-                    ->makeResponse(TRUE, 'ERR_PERSONAL_REG005: Algo salió mal, error activando al empleado del equipo', [], 500);
-            }
-
-            DB::commit(); # Para guardar los cambios en la base de datos
-            return $this->response_controller->makeResponse(FALSE, "Activación exitosa");
-
-        } catch (Throwable $th) {
-            return $this->response_controller->
-                makeResponse(TRUE, 'ERR_PERSONAL_REG006: Error inesperado', strtoupper($th->getMessage()), 500);
-        }
-    }
+     // Metodo para la activación logica de un empleado
+     public function updateToActiveStatus(Request $request, $id_employee)
+     {
+         try {
+             $request['SAVED_BY_USER'] = $this->encrypt_controller->decrypt($request->SAVED_BY_USER);
+             $validator = Validator::make($request->all(), [
+                 "SAVED_BY_USER" => ['required', 'digits:10']
+             ]);
+ 
+             if ($validator->fails()) {
+                 return $this->response_controller->makeResponse(
+                     TRUE,
+                     'ERR_PERSONAL_REG001: Uno o más errores encontrados',
+                     $this->response_controller->makeErrors($validator->errors()->messages()),
+                     400
+                 );
+             }
+ 
+             // Busca si el empleado existe
+             $search_employee = DB::table("S002V01TPERS")
+                 ->select("PERS_IDPE")
+                 ->where("PERS_IDPE", "=", $id_employee)
+                 ->where('PERS_NULI', '=', $request->LINE_NUMBER)
+                 ->first();
+ 
+             // Verifica si el objeto esta vacio
+             if (!isset($search_employee) && empty($search_employee)) {
+                 return $this->response_controller
+                     ->makeResponse(TRUE, "ERR_PERSONAL_REG002: No se encontró al empleado", $search_employee, 500);
+             }
+ 
+             $user_register = DB::table('S002V01TUSUA')
+                 ->select('USUA_IDUS as ID_USER')
+                 ->where('USUA_IDUS', '=', $request->SAVED_BY_USER)
+                 ->where('USUA_NULI', '=', $request->LINE_NUMBER)
+                 ->first();
+ 
+             // Verifica si el objeto esta vacio
+             if (!isset($user_register) && empty($user_register)) {
+                 return $this->response_controller
+                     ->makeResponse(TRUE, "ERR_USUARIO_REG003: Tu usuario no es válido para activar empleados", [], 500);
+             }
+ 
+             $check_workteam = DB::table("S002V01TEQMA")
+             ->select("S002V01TEQMA.EQMA_ESTA as STATUS")
+             ->where("S002V01TPEEM.PEEM_IDPE", '=', $id_employee)
+             ->join('S002V01TPEEM', 'S002V01TEQMA.EQMA_IDEQ', '=', 'S002V01TPEEM.PEEM_IDEM')
+             ->first();
+             
+             if($check_workteam->STATUS == "Eliminado"){
+                 return $this->response_controller
+                 ->makeResponse(TRUE, "ERR_EQUIPO_TRABAJO_REG004: El equipo de trabajo no esta activo", [], 500);
+             }
+ 
+             DB::beginTransaction(); # Para impedir que las actualizaciones queden incompletas
+ 
+             $UPDATE_DATE = Carbon::now()->timezone('America/Mexico_City')->toDateTimeString();
+ 
+             $activate_employee = DB::table('S002V01TPERS')
+                 ->where('PERS_IDPE', $id_employee)
+                 ->where('PERS_NULI', '=', $request->LINE_NUMBER)
+                 ->update([
+                     "PERS_ESTA" => "Activo",
+                     "PERS_USMO" => trim($request->SAVED_BY_USER),
+                     "PERS_FEMO" => $UPDATE_DATE,
+                     "PERS_FEAR" => DB::raw('CURRENT_TIMESTAMP')
+                 ]);
+ 
+             // Verifica que la actualización fuera exitosa
+             if ($activate_employee < 1) {
+                 return $this->response_controller
+                     ->makeResponse(TRUE, 'ERR_PERSONAL_REG005: Algo salió mal, error activando al empleado', [], 500);
+             }
+ 
+             $activate_employee = DB::table('S002V01TPEEM')
+                 ->where('PEEM_IDPE', $id_employee)
+                 ->where('PEEM_NULI', '=', $request->LINE_NUMBER)
+                 ->update([
+                     "PEEM_ESTA" => "Activo",
+                     "PEEM_USMO" => trim($request->SAVED_BY_USER),
+                     "PEEM_FEMO" => $UPDATE_DATE,
+                     "PEEM_FEAR" => DB::raw('CURRENT_TIMESTAMP')
+                 ]);
+ 
+             // Verifica que la actualización fuera exitosa
+             if ($activate_employee < 1) {
+                 DB::rollBack(); # Si no se logra eliminar al empleado en el equipo, se revierten los cambios previos
+                 return $this->response_controller
+                     ->makeResponse(TRUE, 'ERR_PERSONAL_REG006: Algo salió mal, error activando al empleado del equipo', [], 500);
+             }
+ 
+             DB::commit(); # Para guardar los cambios en la base de datos
+             return $this->response_controller->makeResponse(FALSE, "Activación exitosa");
+ 
+         } catch (Throwable $th) {
+             return $this->response_controller->
+                 makeResponse(TRUE, 'ERR_PERSONAL_REG007: Error inesperado', strtoupper($th->getMessage()), 500);
+         }
+     }
 
     // Metodo para obtener a los usuarios que no son empleados y el enviado por path
     public function getAvaibleUsers($id_employee, $line_number)

+ 19 - 2
sistema-mantenimiento-back/app/Http/Controllers/InterventionController.php

@@ -452,8 +452,25 @@ class InterventionController extends Controller
                 $final_part_name_document = substr($final_part_name_document, 28);
             }
 
+            $contracts = DB::table("S002V01TCONT")
+                ->select("CONT_LIDO as SEQUENCE")
+                ->get();
+
+                $sequence_number = "000001";
+
+                // Itera cada archivo guardado en el la base
+            foreach ($contracts as $contract) {
+
+                    // Encuentra el siguiente numero de secuencia
+                    if (substr($contract->SEQUENCE, 18, 6) >= $sequence_number) {
+                        $sequence_number = substr($contract->SEQUENCE, 18, 6);
+                        $sequence_number++;
+                    }
+
+            }
+
             // Se crea el nombre del documento
-            $name_document = '01-GPRS-CO-' . $DATE_TO_DOCUMENT . '-000001' . '=01=' . $final_part_name_document;
+            $name_document = '01-GPRS-CO-' . $DATE_TO_DOCUMENT . '-' . $this->resources_controller->formatSecuence($sequence_number, 6) . '=01=' . $final_part_name_document;
 
             // Verifica si el nombre de documento no existe aún
             $repeated_names = $this->documents_controller->getDocumentsWithSameCodificationStructureName($name_document, 'pdf');
@@ -466,7 +483,7 @@ class InterventionController extends Controller
                 foreach ($repeated_names as $name) {
                     if ($name == $name_document) {
                         return $this->response_controller
-                            ->makeResponse(TRUE, 'ERR_CONTRATO_REG005: Este nombre ya ha sido ocupado el dia de hoy', [], 500);
+                            ->makeResponse(TRUE, 'ERR_CONTRATO_REG005: El nombre de contrato ya ha sido ocupado el dia de hoy', [], 500);
                     }
                 }
             }

+ 15 - 5
sistema-mantenimiento-back/app/Http/Controllers/ResourcesController.php

@@ -21,7 +21,17 @@ class ResourcesController extends Controller
     // Establece la duracion entre dos fechas
     public function durationDate($date)
     {
-        if ($date->y > 0 && $date->m > 0 && $date->d > 0) {
+        if ($date->d > 29) {
+            if ($date->m > 11) {
+                $date->y++;
+            } else {
+                $date->m++;
+            }
+        }else{
+            $date->d++;
+        }
+
+        if ($date->y > 0) {
 
             if ($date->y > 1) {
                 $duration = $date->y . " años, ";
@@ -31,17 +41,17 @@ class ResourcesController extends Controller
 
             if ($date->m > 1) {
                 $duration .= $date->m . " meses, ";
-            } else {
+            } else if ($date->m == 1) {
                 $duration .= $date->m . " mes, ";
             }
 
             if ($date->d > 1) {
                 $duration .= $date->d . " dias";
-            } else {
+            } else if ($date->d == 1) {
                 $duration .= $date->d . " dia";
             }
 
-        } else if ($date->m > 0 && $date->d > 0) {
+        } else if ($date->m > 0) {
 
             if ($date->m > 1) {
                 $duration = $date->m . " meses, ";
@@ -51,7 +61,7 @@ class ResourcesController extends Controller
 
             if ($date->d > 1) {
                 $duration .= $date->d . " dias";
-            } else {
+            } else if ($date->d == 1) {
                 $duration .= $date->d . " dia";
             }
 

+ 8 - 1
sistema-mantenimiento-back/app/Http/Controllers/SubcontractController.php

@@ -915,13 +915,20 @@ class SubcontractController extends Controller
         }
     }
 
+    // Metodo para obtener los paises
     public function getCountries($line_number)
     {
         try {
 
             // Busca si el subcontratista existe
             $countries = DB::table("S002V01TPAIS")
-                ->select("PAIS_IDPA as COUNTRY_ID" ,"PAIS_NOMB as NAME", "PAIS_LADA as LADA")
+                ->select(
+                    "PAIS_IDPA as COUNTRY_ID",
+                    "PAIS_NOMB as NAME",
+                    "PAIS_LADA as LADA",
+                    "PAIS_NOME AS NOMECLARUTA_ISO2",
+                    "PAIS_NOM2 AS NOMECLARUTA_ISO3"
+                    )
                 ->where('PAIS_NULI', '=', $line_number)
                 ->get();
 

+ 24 - 0
sistema-mantenimiento-back/app/Http/Controllers/WorkTeamController.php

@@ -106,6 +106,30 @@ class WorkTeamController extends Controller
         }
     }
 
+    // Metodo para obtener los integrantes de un equipo
+    public function getMembersOfWorkteamById($id_workteam, $line_number)
+    {
+        try {
+            // Obtiene las intervenciones del empleado
+            $workteam_members = DB::table('S002V01TPERS')
+                ->select(
+                    DB::raw('TRIM(CONCAT(S002V01TUSUA.USUA_NOMB, " " , S002V01TUSUA.USUA_APPA, " ", COALESCE(S002V01TUSUA.USUA_APMA,""))) as NAME')
+                )
+                ->where('S002V01TPEEM.PEEM_IDEM', '=', $id_workteam)
+                ->where('S002V01TPERS.PERS_NULI', '=', $line_number)
+                ->where('S002V01TPEEM.PEEM_NULI', '=', $line_number)
+                ->join('S002V01TPEEM', 'S002V01TPERS.PERS_IDPE', '=', 'S002V01TPEEM.PEEM_IDPE')
+                ->join('S002V01TUSUA', 'S002V01TPERS.PERS_IDUS', '=', 'S002V01TUSUA.USUA_IDUS')
+                ->get();
+
+            return $this->response_controller->makeResponse(FALSE, 'Consulta exitosa', $workteam_members, 200);
+
+        } catch (Throwable $th) {
+            return $this->response_controller
+                ->makeResponse(TRUE, 'ERR_EQUIPO_TRABAJO_REG002: Error inesperado', strtoupper($th->getMessage()), 500);
+        }
+    }
+
     // Metodo para obtener los detalles de un equipo de trabajo por el id
     public function getDetailsOfWorkteamById($id_workteam, $line_number)
     {

+ 6 - 0
sistema-mantenimiento-back/routes/api.php

@@ -1,5 +1,6 @@
 <?php
 
+use App\Http\Controllers\CountriesController;
 use App\Http\Controllers\EmployeeController;
 use App\Http\Controllers\InterventionController;
 use App\Http\Controllers\SubcontractController;
@@ -171,8 +172,13 @@ Route::controller(WorkTeamController::class)->prefix('/workteam')->group(functio
     Route::get('/active-teams/{line_number}',                             'getActiveWorkteams');
     Route::get('/{id_workteam}/{line_number}',                            'getWorkteamById');
     Route::get('/details/{id_workteam}/{line_number}',                    'getDetailsOfWorkteamById');
+    Route::get('/workteam-members/{id_workteam}/{line_number}',           'getMembersOfWorkteamById');
     Route::put('/inactive-workteam/{id_workteam}',                        'updateToInactiveStatus');
     Route::put('/active-workteam/{id_workteam}',                          'updateToActiveStatus');
     Route::post('/',                                                      'storeWorkteam');
     Route::put('/{id_workteam}',                                          'updateWorkteam');
+});
+
+Route::controller(CountriesController::class)->prefix('/country')->group(function () {
+    Route::get('/{line_number}',                                         'getCountries');
 });

+ 27 - 27
sistema-mantenimiento-front/src/app/components/personal-management/employee/employee-form/employee-form.component.html

@@ -40,7 +40,7 @@
                         </mat-form-field>
                     </mat-grid-tile>
 
-                    <mat-grid-tile colspan="6" *ngIf="enable !== '1'">
+                    <mat-grid-tile colspan="6" *ngIf="enable === '0'">
                         <mat-form-field appearance="outline">
                             <mat-label>Empleado</mat-label>
                             <input  matInput readonly="true"
@@ -50,7 +50,7 @@
                         </mat-form-field>
                     </mat-grid-tile>
 
-                    <mat-grid-tile colspan="6" *ngIf="enable === '1'">
+                    <mat-grid-tile colspan="6" *ngIf="enable === '1' || enable === '2'">
                         <mat-form-field appearance="outline">
                             <mat-label>Equipo de Trabajo</mat-label>
                             <mat-select
@@ -62,7 +62,7 @@
                         </mat-form-field>
                     </mat-grid-tile>
 
-                    <mat-grid-tile colspan="6" *ngIf="enable !== '1'">
+                    <mat-grid-tile colspan="6" *ngIf="enable == '0'">
                         <mat-form-field appearance="outline">
                             <mat-label>Equipo de Trabajo</mat-label>
                             <input  matInput  readonly="true"
@@ -75,13 +75,13 @@
                     <mat-grid-tile colspan="4">
                         <mat-form-field appearance="outline">
                             <mat-label>Nombre</mat-label>
-                            <input  matInput placeholder="Ingrese el Nombre de su Contacto de Emergencia" maxlength="150" [readonly]="enable == '1' ? false : true"
+                            <input  matInput placeholder="Ingrese el Nombre de su Contacto de Emergencia" maxlength="150" [readonly]="enable == '0' ? true : false"
                                 formControlName="contactName">
                             <mat-error>El Campo Nombre es Obligatorio</mat-error>
                         </mat-form-field>
                     </mat-grid-tile>
 
-                    <mat-grid-tile colspan="1" *ngIf="enable === '1'">
+                    <mat-grid-tile colspan="1" *ngIf="enable === '1' || enable === '2'">
                         <mat-form-field appearance="outline">
                             <mat-label>Lada</mat-label>
                             <mat-select
@@ -93,7 +93,7 @@
                         </mat-form-field>
                     </mat-grid-tile>
 
-                    <mat-grid-tile colspan="1" *ngIf="enable !== '1'">
+                    <mat-grid-tile colspan="1" *ngIf="enable == '0'">
                         <mat-form-field appearance="outline">
                             <mat-label>Lada</mat-label>
                             <input  matInput readonly="true"
@@ -106,7 +106,7 @@
                     <mat-grid-tile colspan="3">
                         <mat-form-field appearance="outline">
                             <mat-label>Número Telefónico</mat-label>
-                            <input matInput placeholder="Ingrese el Número Telefónico de su Contacto de Emergencia" [readonly]="enable == '1' ? false : true"
+                            <input matInput placeholder="Ingrese el Número Telefónico de su Contacto de Emergencia" [readonly]="enable == '0' ? true : false"
                             type="number" oninput="javascript: if
                             (this.value.length> this.maxLength) this.value =
                         this.value.slice(0, this.maxLength);" minlength="7" maxlength="10"
@@ -118,13 +118,13 @@
                     <mat-grid-tile colspan="4">
                         <mat-form-field appearance="outline">
                             <mat-label>Dirección</mat-label>
-                            <input matInput placeholder="Ingrese la Dirección de su Contacto de Emergencia" maxlength="150" [readonly]="enable == '1' ? false : true"
+                            <input matInput placeholder="Ingrese la Dirección de su Contacto de Emergencia" maxlength="150" [readonly]="enable == '0' ? true : false"
                                 formControlName="contactAddress">
                             <mat-error>El Campo Dirección es Obligatorio</mat-error>
                         </mat-form-field>
                     </mat-grid-tile>
 
-                    <mat-grid-tile colspan="4" *ngIf="enable === '1'">
+                    <mat-grid-tile colspan="4" *ngIf="enable === '1' || enable === '2'">
                         <mat-form-field appearance="outline">
                             <mat-label>Tipo de Contrato</mat-label>
                             <mat-select (ngModelChange)="changeContractType()"
@@ -137,7 +137,7 @@
                         </mat-form-field>
                     </mat-grid-tile>
 
-                    <mat-grid-tile colspan="4" *ngIf="enable !== '1'">
+                    <mat-grid-tile colspan="4" *ngIf="enable == '0'">
                         <mat-form-field appearance="outline">
                             <mat-label>Tipo de Contrato</mat-label>
                             <input  matInput readonly="true"
@@ -147,7 +147,7 @@
                         </mat-form-field>
                     </mat-grid-tile>
 
-                    <mat-grid-tile colspan="4" *ngIf="enable === '1'">
+                    <mat-grid-tile colspan="4" *ngIf="enable === '1' || enable === '2'">
                         <mat-form-field appearance="outline">
                             <mat-label>Subcontratista</mat-label>
                             <mat-select
@@ -159,7 +159,7 @@
                         </mat-form-field>
                     </mat-grid-tile>
 
-                    <mat-grid-tile colspan="4" *ngIf="enable !== '1'">
+                    <mat-grid-tile colspan="4" *ngIf="enable == '0'">
                         <mat-form-field appearance="outline">
                             <mat-label>Subcontratista</mat-label>
                             <input  matInput readonly="true"
@@ -172,48 +172,48 @@
                     <mat-grid-tile colspan="4">
                         <mat-form-field appearance="outline" >
                             <mat-label>Especialidad</mat-label>
-                            <input  matInput placeholder="Ingrese su Especialidad" maxlength="150" [readonly]="enable == '1' ? false : true"
+                            <input  matInput placeholder="Ingrese su Especialidad" maxlength="150" [readonly]="enable == '0' ? true : false"
                                 formControlName="speciality">
                             <mat-error>El Campo Especialidad es Obligatorio</mat-error>
                         </mat-form-field>
                     </mat-grid-tile>
 
-                    <mat-grid-tile colspan="4" *ngIf="enable == '1'">
+                    <mat-grid-tile colspan="4" *ngIf="enable == '1' || enable == '2'">
                     <input appearance="outline" hidden type="file" name="fileAutho" id="fileAutho" #fileAutho (change)="checkFile($event,'Autho')" accept="application/pdf">
                     <button  type="button" mat-stroked-button matTooltip="Seleccione 1 Archivo PDF"
-                    (click)="fileAutho.click()" [disabled]="authoDoc.length >= 1 " >
+                    (click)="fileAutho.click()" [disabled]="authoDoc.length >= 1 || authoButton" >
                         Adjuntar Autorización
                     </button>
                 </mat-grid-tile>
 
-                    <mat-grid-tile colspan="4" *ngIf="enable == '1'">
+                    <mat-grid-tile colspan="4" *ngIf="enable == '1' || enable == '2'">
                     <input appearance="outline" hidden type="file" name="fileAutho2" id="fileAutho2" #fileAutho2 (change)="checkFile($event,'Autho2')" accept="application/pdf">
                     <button type="button" mat-stroked-button matTooltip="Seleccione 1 Archivo PDF"
-                    (click)="fileAutho2.click()" [disabled]="authoDoc2.length >= 1" >
+                    (click)="fileAutho2.click()" [disabled]="authoDoc2.length >= 1 || authoButton" >
                         Adjuntar Autorización
                     </button>
                 </mat-grid-tile>
 
-                <mat-grid-tile colspan="4" *ngIf="enable == '1'">
+                <mat-grid-tile colspan="4" *ngIf="enable == '1' || enable == '2'">
                     <input hidden type="file" name="fileOffi" id="fileOffi" #fileOffi (change)="checkFile($event,'Office')" accept="application/pdf">
                     <button type="button" mat-stroked-button matTooltip="Seleccione 1 Archivo PDF"
-                    (click)="fileOffi.click()" [disabled]="officeDoc.length >= 1" >
+                    (click)="fileOffi.click()" [disabled]="officeDoc.length >= 1 || officeButton" >
                         Adjuntar Oficio
                     </button>
                 </mat-grid-tile>
 
-                <mat-grid-tile colspan="6" *ngIf="enable == '1'">
+                <mat-grid-tile colspan="6" *ngIf="enable == '1' || enable == '2'">
                     <input hidden type="file" name="fileCert" id="fileCert" #fileCert (change)="checkFile($event,'Cert')" accept="application/pdf">
                     <button  type="button" mat-stroked-button matTooltip="Seleccione 1 Archivo PDF"
-                    (click)="fileCert.click()" [disabled]="certDoc.length >= 1" >
+                    (click)="fileCert.click()" [disabled]="certDoc.length >= 1 || certButton" >
                         Adjuntar Certificación
                     </button>
                 </mat-grid-tile>
 
-                <mat-grid-tile colspan="6" *ngIf="enable == '1'">
+                <mat-grid-tile colspan="6" *ngIf="enable == '1' || enable == '2'">
                     <input hidden type="file" name="fileCert2" id="fileCert2" #fileCert2 (change)="checkFile($event,'Cert2')" accept="application/pdf">
                     <button  type="button" mat-stroked-button matTooltip="Seleccione 1 Archivo PDF"
-                    (click)="fileCert2.click()" [disabled]="certDoc2.length >= 1" >
+                    (click)="fileCert2.click()" [disabled]="certDoc2.length >= 1 || certButton" >
                         Adjuntar Certificación
                     </button>
                 </mat-grid-tile>
@@ -230,7 +230,7 @@
 
             </mat-grid-list>
 
-                <table *ngIf="enable == '1'"  mat-table [dataSource]="dataSource!" style="padding:
+                <table *ngIf="enable == '1' || enable == '2'"  mat-table [dataSource]="dataSource!" style="padding:
                 0x 20px 10px 20px!important;">
                 <ng-container matColumnDef="name">
                     <th mat-header-cell *matHeaderCellDef > Nombre </th>
@@ -270,9 +270,9 @@
             </div>
 
             <div style="padding: 10px 32px 22px 32px;" align="end">
-                <button mat-raised-button color="primary" class="override-no-shadow" (click)="this.alert()" *ngIf="enable == '1'" [disabled]="formGroup.invalid" ><mat-icon>save</mat-icon>{{ idEmployee == "0" ? "Registrar" : "Guardar" }}</button>
+                <button mat-raised-button color="primary" class="override-no-shadow" (click)="this.alert()" *ngIf="enable == '1' || enable == '2'" [disabled]="formGroup.invalid" ><mat-icon>save</mat-icon>{{ idEmployee == "0" ? "Registrar" : "Guardar" }}</button>
                 <button
-                *ngIf="enable != '1'"
+                *ngIf="enable === '0'"
                 mat-mini-fab
                 color="warn"
                 class="override-no-shadow mr-4"
@@ -282,7 +282,7 @@
                 <mat-icon>picture_as_pdf</mat-icon>
             </button>
             <button
-            *ngIf="enable != '1'"
+            *ngIf="enable === '0'"
                 mat-mini-fab
                 color="primary"
                 class="override-no-shadow mr-4"

+ 46 - 14
sistema-mantenimiento-front/src/app/components/personal-management/employee/employee-form/employee-form.component.ts

@@ -38,7 +38,12 @@ export class EmployeeFormComponent implements OnInit {
   public officeDoc2!: Array<any>;
   public certDoc2!: Array<any>;
   public authoDoc2!: Array<any>;
+  public authoButton!: boolean;
+  public officeButton!: boolean;
+  public certButton!: boolean;
+
   public nameUpdateDocument!: string;
+  public documentTipe!: number;
 
   public formData: FormData = new FormData();
   public documentsEmployee!: Array<any>;
@@ -58,8 +63,8 @@ export class EmployeeFormComponent implements OnInit {
     private _router: Router,
     private _dialog: MatDialog,
   ) {
-    this.idEmployee = "";
-    this.enable = "";
+    this.idEmployee = this._activatedRoute.snapshot.paramMap.get('id')!;
+    this.enable = this._activatedRoute.snapshot.paramMap.get('enable')!;
     this.btnSmall = false;
     this.formGroup = this.createFormGroup();
     this.isLoadingForm = false;
@@ -69,15 +74,17 @@ export class EmployeeFormComponent implements OnInit {
     this.officeDoc2 = [];
     this.certDoc2 = [];
     this.authoDoc2 = [];
+    this.authoButton = false;
+    this.officeButton = false;
+    this.certButton = false;
     this.nameUpdateDocument = "";
     this.documents = [];
     this.documentsEmployee = [];
+    this.documentTipe = 0;
     this.dataSource = new MatTableDataSource<any>();
   }
 
   ngOnInit(): void {
-    this.idEmployee = this._activatedRoute.snapshot.paramMap.get('id')!;
-    this.enable = this._activatedRoute.snapshot.paramMap.get('enable')!;
     this.decript();
     this.getWorkteams();
     this.getSubcontratists();
@@ -89,7 +96,7 @@ export class EmployeeFormComponent implements OnInit {
       documentsAutho: new FormControl(''),
       documentOffice: new FormControl(''),
       documentsCert: new FormControl(''),
-      userId: new FormControl({ value: '', disabled: this.enable !== '1'}, Validators.required),
+      userId: new FormControl({ value: '', disabled: this.enable != "2" }, Validators.required),
       contactName: new FormControl('', Validators.required),
       contactLada: new FormControl('', Validators.required),
       contactTelephone: new FormControl('', Validators.required),
@@ -111,7 +118,7 @@ export class EmployeeFormComponent implements OnInit {
   }
 
   public changeContractType() {
-    if (this.enable == "1") {
+    if (this.enable == "1" || this.enable == "2") {
       if (this.contractType?.value == "Subcontratista") {
         this.subcontratistId?.enable();
       } else {
@@ -175,12 +182,11 @@ export class EmployeeFormComponent implements OnInit {
   }
 
   private async getUsers() {
-    console.log(this.idEmployee);
-      await lastValueFrom(this._employeeService.getAvaibleUsers(this.idEmployee)).then(
-        (responseData: any) => {
-          this.users = responseData.response;
-        }, (error: HttpErrorResponse) => this._resourcesService.checkErrors(error)
-      );
+    await lastValueFrom(this._employeeService.getAvaibleUsers(this.idEmployee)).then(
+      (responseData: any) => {
+        this.users = responseData.response;
+      }, (error: HttpErrorResponse) => this._resourcesService.checkErrors(error)
+    );
   }
 
   private async getWorkteams() {
@@ -211,7 +217,7 @@ export class EmployeeFormComponent implements OnInit {
   private async getData() {
     await lastValueFrom(this._employeeService.getEmployeeById(this.idEmployee)).then(
       (responseData: ResponseDataEmployee) => {
-        if (this.enable != "1") {
+        if (this.enable === "0") {
           this.users.forEach(user => {
             if (user.ID_USER == responseData.response.USER_ID) {
               responseData.response.USER_ID = user.NAME
@@ -244,7 +250,9 @@ export class EmployeeFormComponent implements OnInit {
       (responseData: any) => {
         if (responseData.response.length > 0) {
           responseData.response.forEach((document: any) => {
-            this.documentsEmployee.push(document);
+            if (!document.includes("=Details_Of_Employee_")) {
+              this.documentsEmployee.push(document);
+            }
           });
         }
       }, (error: HttpErrorResponse) => this._resourcesService.checkErrors(error)
@@ -298,8 +306,31 @@ export class EmployeeFormComponent implements OnInit {
 
   public saveDocumentToUpdate(event: string) {
     this.nameUpdateDocument = event;
+    this.disableDocumentButtons();
   }
 
+  private disableDocumentButtons() {
+    if (this.nameUpdateDocument.includes("-IN-")) {
+      this.authoButton = false;
+      this.officeButton = true;
+      this.certButton = true;
+    } else if (this.nameUpdateDocument.includes("-CO-")) {
+      this.authoButton = true;
+      this.officeButton = false;
+      this.certButton = true;
+    } else if (this.nameUpdateDocument.includes("-CE-")) {
+      this.authoButton = true;
+      this.officeButton = true;
+      this.certButton = false;
+    }
+  }
+
+private enableDocumentButtons(){
+  this.authoButton = false;
+  this.officeButton = false;
+  this.certButton = false;
+}
+
   public checkFile(event: any, type: string) {
     let file: any = event.target.files[0];
 
@@ -376,6 +407,7 @@ export class EmployeeFormComponent implements OnInit {
     event.target.value = '';
     // Limpia el select de los documentos
     this.nameUpdateDocument = "";
+    this.enableDocumentButtons()
     this.updateDocuments.setValue("");
   }
 

+ 1 - 1
sistema-mantenimiento-front/src/app/components/personal-management/employee/employee.component.ts

@@ -96,7 +96,7 @@ export class EmployeeComponent implements OnInit {
   public async openDialog(typeForm: string, element?: any) {
     if (typeForm === 'REG') {
       const id = await this._encService.encriptar("0");
-      this._router.navigate(['sam/GPRS/employee/form/' + id + '/1']);
+      this._router.navigate(['sam/GPRS/employee/form/' + id + '/2']);
     } else if (typeForm === 'UPD') {
       const id = await this._encService.encriptar(element.ID_EMPLOYEE);
       this._router.navigate(['sam/GPRS/employee/form/' + id + '/1']);

+ 20 - 6
sistema-mantenimiento-front/src/app/components/personal-management/work-team/work-team-form/work-team-form.component.html

@@ -1,6 +1,9 @@
-<h2 mat-dialog-title *ngIf="dialogData.action == 'REG'" style="text-align: center;">Registrar Equipo de Trabajo</h2>
-<h2 mat-dialog-title *ngIf="dialogData.action == 'UPD'" style="text-align: center;">Modificación Equipo de Trabajo</h2>
-<h2 mat-dialog-title *ngIf="dialogData.action == 'DET'" style="text-align: center;">Detalles Equipo de Trabajo</h2>
+<h2 mat-dialog-title *ngIf="dialogData.action == 'REG'" style="text-align:
+  center;">Registrar Equipo de Trabajo</h2>
+<h2 mat-dialog-title *ngIf="dialogData.action == 'UPD'" style="text-align:
+  center;">Modificación Equipo de Trabajo</h2>
+<h2 mat-dialog-title *ngIf="dialogData.action == 'DET'" style="text-align:
+  center;">Detalles Equipo de Trabajo</h2>
 <mat-dialog-content style="padding: 0 24px 0 24px !important;">
   <div class="is-loading" *ngIf="isLoading">
     <mat-spinner></mat-spinner>
@@ -11,7 +14,8 @@
       <mat-form-field appearance="outline" style="width: 100%; padding-top:
         10px;">
         <mat-label>Nombre del Equipo</mat-label>
-        <input formControlName="name" matInput placeholder="Equipo de reparación" style="width: 100%!important;" maxlength="100" [readonly]="enable == '1' ? false : true">
+        <input formControlName="name" matInput placeholder="Equipo de reparación" style="width: 100%!important;" maxlength="100"
+          [readonly]="enable == '1' ? false : true">
         <mat-error>El Campo Nombre del Equipo es Obligatorio</mat-error>
       </mat-form-field>
     </p>
@@ -22,10 +26,20 @@
         <mat-error>El Campo Especialidad es Obligatorio</mat-error>
       </mat-form-field>
     </p>
+    <div *ngIf="enable == '0'">
+      <h3 style="font-weight:bold; margin-bottom: 0px;">Miembros del equipo</h3>
+      <mat-list>
+        <mat-list-item *ngFor="let member of members" style="margin: 0px">
+          <span matListItemTitle>{{ member.NAME }}</span>
+        </mat-list-item>
+      </mat-list>
+    </div>
   </div>
 </mat-dialog-content>
 <mat-dialog-actions align="end">
   <button mat-button mat-dialog-close color="warn" style="margin-right: 10px;">Cerrar</button>
-  <button *ngIf="dialogData.action != 'DET'" mat-button color="primary" class="override-no-shadow"
-    (click)="this.alert(dialogData.action)" [disabled]="formGroup.invalid">{{dialogData.action == "REG" ? "Registrar" : "Guardar"}}</button>
+  <button *ngIf="dialogData.action != 'DET'" mat-button color="primary"
+    class="override-no-shadow"
+    (click)="this.alert(dialogData.action)" [disabled]="formGroup.invalid">{{dialogData.action
+    == "REG" ? "Registrar" : "Guardar"}}</button>
 </mat-dialog-actions>

+ 13 - 0
sistema-mantenimiento-front/src/app/components/personal-management/work-team/work-team-form/work-team-form.component.ts

@@ -21,6 +21,7 @@ export class WorkTeamFormComponent implements OnInit {
   public formGroup: FormGroup;
   public idWorkteam: string;
   public enable: string;
+  public members: any[];
 
   constructor(
     private _resourcesService: ResourcesService,
@@ -32,6 +33,7 @@ export class WorkTeamFormComponent implements OnInit {
     this.isLoading = false;
     this.idWorkteam = "";
     this.enable = "";
+    this.members = [];
     this.formGroup = this.createFormGroup();
   }
 
@@ -39,6 +41,7 @@ export class WorkTeamFormComponent implements OnInit {
     if (this.dialogData.action != "REG") {
       this.idWorkteam = this.dialogData.dataElement.WORKTEAM_ID;
       this.getData();
+      this.getMembers();
     }
     this.enable = this.dialogData.action == "DET" ? "0" : "1";
   }
@@ -123,6 +126,16 @@ export class WorkTeamFormComponent implements OnInit {
     );
   }
 
+  private async getMembers(){
+    this.isLoading = true;
+    await lastValueFrom(this._workteamService.getMembersOfWorkteamById(this.idWorkteam)).then(
+      (responseData: any) => {
+        this.members = responseData.response;
+        this.isLoading = false;
+      }, (error: HttpErrorResponse) => this._resourcesService.checkErrors(error)
+    );
+  }
+
   get name() {
     return this.formGroup.get('name')!;
   }

+ 6 - 1
sistema-mantenimiento-front/src/app/services/personal-management/work-team.service.ts

@@ -28,11 +28,16 @@ export class WorkTeamService {
       map((data: any) => data));
   }
 
-  public getDetailsOfWorkteamById(workteamId: number) {
+  public getDetailsOfWorkteamById(workteamId: string) {
     return this._httpRequestService.getQuery(`${this._url}/details/${workteamId}`).pipe(
       map((data: any) => data));
   }
 
+  public getMembersOfWorkteamById(workteamId: string) {
+    return this._httpRequestService.getQuery(`${this._url}/workteam-members/${workteamId}`).pipe(
+      map((data: any) => data));
+  }
+
   public updateToInactiveStatus(response: UpdatedStatusWorkteam) {
     return this._httpRequestService.putQuery(`${this._url}/inactive-workteam/${response.WORKTEAM_ID}`, response)
       .pipe(map((data: any) => data));