4
0

2 Ревизии c0f1a6854d ... 45c32aeef6

Автор SHA1 Съобщение Дата
  MathewCordourier 45c32aeef6 Merge branch 'master' of http://209.50.56.224/git/ITTEC/SAMPracticantes преди 2 години
  MathewCordourier 497a87a404 Actualización en vistas преди 2 години

+ 16 - 10
sistema-mantenimiento-front/src/app/components/personal-management/employee/employee.component.html

@@ -125,13 +125,15 @@
                             <ng-container matColumnDef="ACCIONES">
                                 <th mat-header-cell *matHeaderCellDef>Acciones</th>
                                 <td mat-cell *matCellDef="let element">
-                                    <button mat-mini-fab color="accent" *ngIf="btnSmall"
-                                        [disabled]="element.STATUS == 'Eliminado'
-                                        ||
-                                        isLoading" [matMenuTriggerFor]="menu"
+                                    <button mat-mini-fab color="accent" *ngIf="btnSmall && element.STATUS !== 'Eliminado'"
+                                        [disabled]="isLoading" [matMenuTriggerFor]="menu"
                                         #menuTrigger class="override-no-shadow">
                                         <mat-icon>settings</mat-icon>
                                     </button>
+                                    <button mat-mini-fab color="success" class="override-no-shadow" [disabled]="isLoading"
+                                    (click)="openDialog('ACT', element)" *ngIf="btnSmall && element.STATUS == 'Eliminado'">
+                                    <mat-icon>restore_from_trash</mat-icon>
+                                  </button>
                                     <mat-menu #menu="matMenu">
                                         <button mat-menu-item
                                             (click)="openDialog('DET',
@@ -170,29 +172,33 @@
                                     </mat-menu>
                                     <div *ngIf="!btnSmall">
                                         <button mat-mini-fab color="primary" class="override-no-shadow ml-4" matTooltip="Ver Detalles"
-                                          (click)="openDialog('DET', element)" [disabled]="element.ESTADO == 'Eliminado' || isLoadingForm">
+                                          (click)="openDialog('DET', element)" [disabled]="element.STATUS == 'Eliminado' || isLoadingForm">
                                           <mat-icon>visibility</mat-icon>
                                         </button>
                                         <button mat-mini-fab color="accent" class="override-no-shadow ml-4" matTooltip="Ver Tasa Horaria"
-                                          (click)="openDialog('TAH', element)" [disabled]="element.ESTADO == 'Eliminado' || isLoadingForm">
+                                          (click)="openDialog('TAH', element)" [disabled]="element.STATUS == 'Eliminado' || isLoadingForm">
                                           <mat-icon>timer</mat-icon>
                                         </button>
                                         <button mat-mini-fab color="info" class="override-no-shadow ml-4" matTooltip="Ver Documentos"
-                                          (click)="openDialog('DOC', element)" [disabled]="element.ESTADO == 'Eliminado' || isLoadingForm">
+                                          (click)="openDialog('DOC', element)" [disabled]="element.STATUS == 'Eliminado' || isLoadingForm">
                                           <mat-icon>folder_open</mat-icon>
                                         </button>
                                         <button mat-mini-fab color="success" class="override-no-shadow ml-4" matTooltip="Ver Órdenes"
-                                          (click)="openDialog('ORD', element)" [disabled]="element.ESTADO == 'Eliminado' || isLoadingForm">
+                                          (click)="openDialog('ORD', element)" [disabled]="element.STATUS == 'Eliminado' || isLoadingForm">
                                           <mat-icon>description</mat-icon>
                                         </button>
                                         <button mat-mini-fab color="accent" class="override-no-shadow ml-4" matTooltip="Editar Empleado"
-                                          (click)="openDialog('UPD', element)" [disabled]="element.ESTADO == 'Eliminado' || isLoadingForm">
+                                          (click)="openDialog('UPD', element)" [disabled]="element.STATUS == 'Eliminado' || isLoadingForm">
                                           <mat-icon>edit</mat-icon>
                                         </button>
                                         <button mat-mini-fab color="warn" class="override-no-shadow ml-4" matTooltip="Eliminar Empleado"
-                                          (click)="openDialog('DEL', element)" [disabled]="element.ESTADO == 'Eliminado' || isLoadingForm">
+                                          (click)="openDialog('DEL', element)" [disabled]="isLoadingForm" *ngIf="element.STATUS == 'Activo'">
                                           <mat-icon>delete</mat-icon>
                                         </button>
+                                        <button mat-mini-fab color="success" class="override-no-shadow ml-4" matTooltip="Activar Empleado"
+                                          (click)="openDialog('ACT', element)" [disabled]="isLoadingForm" *ngIf="element.STATUS == 'Eliminado'">
+                                          <mat-icon>restore_from_trash</mat-icon>
+                                        </button>
                                       </div>
                                 </td>
                             </ng-container>

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

@@ -129,6 +129,19 @@ export class EmployeeComponent implements OnInit {
           this.deleteEmployee(element!.ID_EMPLOYEE);
         }
       });
+    } else if (typeForm === 'ACT') {
+      this._dialog.open(AlertComponent, {
+        data: {
+          title: 'Activación de Empleado',
+          description: '¿Está seguro que desea activar al empleado?',
+          icon: 'warning',
+        },
+        disableClose: true,
+      }).afterClosed().subscribe((result) => {
+        if (result) {
+          this.activateEmployee(element!.ID_EMPLOYEE);
+        }
+      });
     }
   }
 
@@ -155,6 +168,19 @@ export class EmployeeComponent implements OnInit {
     );
   }
 
+  private async activateEmployee(employeeId: string) {
+    await lastValueFrom(this._employeeService.updateToActiveStatus({
+      EMPLOYEE_ID: employeeId,
+      LINE_NUMBER: '01',
+      SAVED_BY_USER: this.resourcesService.getUser()
+    })).then(
+      (responseData: any) => {
+        this.getEmployees();
+        this.resourcesService.openSnackBar('¡Activación Exitosa!');
+      }, (error: HttpErrorResponse) => this.resourcesService.checkErrors(error)
+    );
+  }
+
   public async getContractsByEmployees() {
     this.isLoading = true;
     await lastValueFrom(this._employeeService.getContractsOfEveryEmployee()).then(

+ 11 - 22
sistema-mantenimiento-front/src/app/components/personal-management/intervention/contract-form/contract-form.component.ts

@@ -60,17 +60,18 @@ export class ContractFormComponent implements OnInit {
     this.getEmployees();
     this.setHours();
     this.decript();
-    this.readOnlyForm();
   }
 
   private async getEmployees() {
     await lastValueFrom(this._employeeService.getConsultOfEmployees()).then(
       (responseData: any) => {
         responseData.response.forEach((element: any) => {
-          if (element.CONTRACT_TYPE == "Interno") {
-            this.interns.push(element);
-          } else {
-            this.subcontratists.push(element);
+          if (element.STATUS === "Activo") {
+            if (element.CONTRACT_TYPE == "Interno") {
+              this.interns.push(element);
+            } else {
+              this.subcontratists.push(element);
+            }
           }
         });
       }, (error: HttpErrorResponse) => this._resourcesService.checkErrors(error)
@@ -78,18 +79,6 @@ export class ContractFormComponent implements OnInit {
   }
 
 
-  private readOnlyForm() {
-    // this.enable == '1' ? this.contractType?.enable() : this.contractType?.disable()
-    // this.enable == '1' ? this.denominationSubcontratist?.enable() : this.denominationSubcontratist?.disable()
-    // this.enable == '1' ? this.denominationIntern?.enable() : this.denominationIntern?.disable()
-    // this.enable == '1' ? this.startDate?.enable() : this.startDate?.disable()
-    // this.enable == '1' ? this.endDate?.enable() : this.endDate?.disable()
-    // this.enable == '1' ? this.startHour?.enable() : this.startHour?.disable()
-    // this.enable == '1' ? this.endHour?.enable() : this.endHour?.disable()
-    // this.enable == '1' ? this.cost?.enable() : this.cost?.disable()
-    // this.enable == '1' ? this.documentsInput?.enable() : this.documentsInput?.disable()
-  }
-
   private createFormGroup() {
     return new FormGroup({
       contractType: new FormControl('', Validators.required),
@@ -176,16 +165,16 @@ export class ContractFormComponent implements OnInit {
   private async getData() {
     await lastValueFrom(this._interventionService.getContractById(this.idContract)).then(
       (responseData: ResponseDataContract) => {
-        if(this.enable != "1"){
+        if (this.enable != "1") {
 
           this.subcontratists.forEach(element => {
-            if(element.ID_EMPLOYEE == responseData.response.DENOMINATION){
+            if (element.ID_EMPLOYEE == responseData.response.DENOMINATION) {
               responseData.response.DENOMINATION = element.NAME;
             }
           });
 
           this.interns.forEach(element => {
-            if(element.ID_EMPLOYEE == responseData.response.DENOMINATION){
+            if (element.ID_EMPLOYEE == responseData.response.DENOMINATION) {
               responseData.response.DENOMINATION = element.NAME;
             }
           });
@@ -216,11 +205,11 @@ export class ContractFormComponent implements OnInit {
     this.endDate.setValue(endDate);
 
     this.hours.forEach(hour => {
-      if(hour.value == startHour){
+      if (hour.value == startHour) {
         this.startHour.setValue(hour.label);
       }
 
-      if(hour.value == endHour){
+      if (hour.value == endHour) {
         this.endHour.setValue(hour.label);
       }
     });

+ 17 - 7
sistema-mantenimiento-front/src/app/components/personal-management/subcontratist/subcontratist.component.html

@@ -125,13 +125,15 @@
                             <th mat-header-cell *matHeaderCellDef>Acciones</th>
                             <td mat-cell *matCellDef="let element">
                                 <button mat-mini-fab color="accent"
-                                    *ngIf="btnSmall"
-                                    [disabled]="element.STATUS == 'Eliminado'
-                                    ||
-                                    isLoading" [matMenuTriggerFor]="menu"
+                                    *ngIf="btnSmall && element.STATUS !== 'Eliminado'"
+                                    [disabled]="isLoading" [matMenuTriggerFor]="menu"
                                     #menuTrigger class="override-no-shadow">
                                     <mat-icon>settings</mat-icon>
                                 </button>
+                                <button mat-mini-fab color="success" class="override-no-shadow" [disabled]="isLoading"
+                                (click)="openDialog('ACT', element)" *ngIf="btnSmall && element.STATUS == 'Eliminado'">
+                                <mat-icon>restore_from_trash</mat-icon>
+                              </button>
                                 <mat-menu #menu="matMenu">
                                     <button mat-menu-item
                                         (click)="openDialog('DET',
@@ -179,14 +181,22 @@
                                         mat-mini-fab
                                         color="warn"
                                         class="override-no-shadow mr-4"
-                                        [disabled]="element.STATUS ==
-                                        'Eliminado'
-                                        || isLoadingForm"
+                                        [disabled]="isLoadingForm" *ngIf="element.STATUS == 'Activo'"
                                         matTooltip="Eliminar Subcontratista"
                                         (click)="openDialog('DEL',
                                         element)">
                                         <mat-icon>delete</mat-icon>
                                     </button>
+                                    <button
+                                        mat-mini-fab
+                                        color="success"
+                                        class="override-no-shadow mr-4"
+                                        [disabled]="isLoadingForm" *ngIf="element.STATUS == 'Eliminado'"
+                                        matTooltip="Activar Subcontratista"
+                                        (click)="openDialog('ACT',
+                                        element)">
+                                        <mat-icon>restore_from_trash</mat-icon>
+                                    </button>
                                 </div>
                             </td>
                         </ng-container>

+ 26 - 0
sistema-mantenimiento-front/src/app/components/personal-management/subcontratist/subcontratist.component.ts

@@ -125,6 +125,19 @@ public tabChange(tab : any){
           this.deleteSubcontratist(element!.ID_SUBCONTRATIST);
         }
       });
+    } else if (typeForm === 'ACT') {
+      this._dialog.open(AlertComponent, {
+        data: {
+          title: 'Activación de Subcontratista',
+          description: '¿Está seguro que desea activar al subcontratista?',
+          icon: 'warning',
+        },
+        disableClose: true,
+      }).afterClosed().subscribe((result) => {
+        if (result) {
+          this.activateSubcontratist(element!.ID_SUBCONTRATIST);
+        }
+      });
     }
   }
   
@@ -151,6 +164,19 @@ public tabChange(tab : any){
     );
   }
 
+  private async activateSubcontratist(subcontratistId: string) {
+    await lastValueFrom(this._subcontratistService.updateToActiveStatus({
+      ID_SUBCONTRATIST: subcontratistId,
+      LINE_NUMBER: '01',
+      SAVED_BY_USER: this.resourcesService.getUser()
+    })).then(
+      (responseData: any) => {
+        this.getSubcontratists();
+        this.resourcesService.openSnackBar('¡Activación Exitosa!');
+      }, (error: HttpErrorResponse) => this.resourcesService.checkErrors(error)
+    );
+  }
+
   public async getContractsBySubcontratists() {
     this.isLoading = true;
     await lastValueFrom(this._subcontratistService.getContractsOfEverySubcontratist()).then(

+ 16 - 5
sistema-mantenimiento-front/src/app/components/personal-management/work-team/work-team.component.html

@@ -77,12 +77,15 @@
                     <ng-container matColumnDef="ACCIONES">
                         <th mat-header-cell *matHeaderCellDef>Acciones</th>
                         <td mat-cell *matCellDef="let element">
-                            <button mat-mini-fab color="accent" *ngIf="btnSmall"
-                                [disabled]="element.STATUS == 'Eliminado' ||
-                                isLoadingForm" [matMenuTriggerFor]="menu"
+                            <button mat-mini-fab color="accent" *ngIf="btnSmall && element.STATUS !== 'Eliminado'"
+                                [disabled]="isLoadingForm" [matMenuTriggerFor]="menu"
                                 #menuTrigger class="override-no-shadow">
                                 <mat-icon>settings</mat-icon>
                             </button>
+                            <button mat-mini-fab color="success" class="override-no-shadow" [disabled]="isLoading"
+                            (click)="openDialog('ACT', element)" *ngIf="btnSmall && element.STATUS == 'Eliminado'">
+                            <mat-icon>restore_from_trash</mat-icon>
+                          </button>
                             <mat-menu #menu="matMenu">
                                 <button mat-menu-item (click)="openDialog('DET',
                                     element)">
@@ -123,12 +126,20 @@
                                     mat-mini-fab
                                     color="warn"
                                     class="override-no-shadow mr-4"
-                                    [disabled]="element.STATUS == 'Eliminado'
-                                    || isLoadingForm"
+                                    [disabled]="isLoadingForm" *ngIf="element.STATUS == 'Activo'"
                                     matTooltip="Eliminar Equipo"
                                     (click)="openDialog('DEL', element)">
                                     <mat-icon>delete</mat-icon>
                                 </button>
+                                <button
+                                    mat-mini-fab
+                                    color="success"
+                                    class="override-no-shadow mr-4"
+                                    [disabled]="isLoadingForm" *ngIf="element.STATUS == 'Eliminado'"
+                                    matTooltip="Activar Equipo"
+                                    (click)="openDialog('ACT', element)">
+                                    <mat-icon>restore_from_trash</mat-icon>
+                                </button>
                             </div>
                         </td>
                     </ng-container>

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

@@ -84,6 +84,19 @@ export class WorkTeamComponent implements OnInit {
           this.deleteWorkteam(element!.WORKTEAM_ID);
         }
       });
+    } else if (typeForm === 'ACT') {
+      this._dialog.open(AlertComponent, {
+        data: {
+          title: 'Activación de Equipo de Trabajo',
+          description: '¿Está seguro que desea activar al equipo de trabajo?',
+          icon: 'warning',
+        },
+        disableClose: true,
+      }).afterClosed().subscribe((result) => {
+        if (result) {
+          this.activateWorkteam(element!.WORKTEAM_ID);
+        }
+      });
     }
   }
 
@@ -100,6 +113,19 @@ export class WorkTeamComponent implements OnInit {
     );
   }
 
+  private async activateWorkteam(workteamId: string) {
+    await lastValueFrom(this._workteamService.updateToActiveStatus({
+      WORKTEAM_ID: workteamId,
+      LINE_NUMBER: '01',
+      SAVED_BY_USER: this.resourcesService.getUser()
+    })).then(
+      (responseData: any) => {
+        this.getWorkteams();
+        this.resourcesService.openSnackBar('¡Activación Exitosa!');
+      }, (error: HttpErrorResponse) => this.resourcesService.checkErrors(error)
+    );
+  }
+
   public async getWorkteams() {
     this.isLoading = true;
     await lastValueFrom(this._workteamService.getConsultOfWorkteams()).then(

+ 5 - 0
sistema-mantenimiento-front/src/app/services/personal-management/employee.service.ts

@@ -42,6 +42,11 @@ export class EmployeeService {
       .pipe(map((data: any) => data));
   }
 
+  public updateToActiveStatus(response: UpdatedStatusEmployee) {
+    return this._httpRequestService.putQuery(`${this._url}/active-employee/${response.EMPLOYEE_ID}`, response)
+      .pipe(map((data: any) => data));
+  }
+
   public storeEmployee(response: any) {
     return this._httpRequestService.postQuery(`${this._url}`, response)
       .pipe(map((data: any) => data));

+ 5 - 0
sistema-mantenimiento-front/src/app/services/personal-management/subcontratist.service.ts

@@ -23,6 +23,11 @@ export class SubcontratistService {
       .pipe(map((data: any) => data));
   }
 
+  public updateToActiveStatus(response: UpdatedStatusSubcontratist) {
+    return this._httpRequestService.putQuery(`${this._url}/active-subcontratist/${response.ID_SUBCONTRATIST}`, response)
+      .pipe(map((data: any) => data));
+  }
+
   public storeSubcontratist(response: Subcontratist) {
     return this._httpRequestService.postQuery(`${this._url}`, response)
       .pipe(map((data: any) => data));

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

@@ -38,6 +38,11 @@ export class WorkTeamService {
       .pipe(map((data: any) => data));
   }
 
+  public updateToActiveStatus(response: UpdatedStatusWorkteam) {
+    return this._httpRequestService.putQuery(`${this._url}/active-workteam/${response.WORKTEAM_ID}`, response)
+      .pipe(map((data: any) => data));
+  }
+
   public storeWorkteam(response: Workteam) {
     return this._httpRequestService.postQuery(`${this._url}`, response)
       .pipe(map((data: any) => data));