瀏覽代碼

Avances empleados

JoseBrito 2 年之前
父節點
當前提交
2bda86e699

+ 56 - 0
sistema-mantenimiento-front/src/app/components/personal-management/employee/employee-form/employee-form.component.css

@@ -6,4 +6,60 @@ input::-webkit-outer-spin-button,
 input::-webkit-inner-spin-button {
   -webkit-appearance: none;
   margin: 0;
+}
+
+.form-row{
+  width: 100%;
+  display: flex;
+  flex-direction: row;
+  justify-content: center;
+  align-items: center;
+  flex-wrap: wrap;
+}
+
+.form-column{
+  width: 100%;
+  display: flex;
+  flex-direction: column;
+}
+
+.form-order-container{
+  width: 100%;
+  height: calc(100vh - 306px);
+  overflow-x: hidden;
+  overflow-y: auto;
+}
+
+.form-cell{
+  padding: 3px;
+  box-sizing: border-box;
+  overflow: hidden;
+}
+
+.section-divider{
+  width: 100%;
+  font-size: 10px;
+  color: rgba(0, 0, 0, 0.54);
+  padding: 0 3px;
+  margin-bottom: 4px;
+}
+
+.fw_50{
+  width: 50%;
+}
+
+.fw_33{
+  width: calc(100% / 3);
+}
+
+.fw_8{
+  width: calc(100% / 12);
+}
+
+.fw_25{
+    width: 25%;
+}
+
+.fw_42{
+  width: calc(500% / 12);
 }

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

@@ -6,7 +6,7 @@
     </div>
   </div>
   <mat-card class="override-elevation-z8" style="width: 100%; height: 100%;">
-    <mat-card-title style="text-align: center; margin: 15px 0;">{{ action }} subcontratista</mat-card-title>
+    <mat-card-title style="text-align: center; margin: 15px 0;">{{ action }} empleado</mat-card-title>
     <mat-card-content>
       <div class="form-order-container" *ngIf="isLoading">
         <div class="is-loading animated fadeIn fast">
@@ -21,304 +21,426 @@
           <h3>{{ errorStr }}</h3>
         </div>
       </div>
+
+      <div class="form-order-container" *ngIf="!isLoading && !hasError">
+        <div class="form-column" [formGroup]="formGroup">
+          <div class="form-row">
+            <!-- 100 => 12, 50 => 6, 42 => 5, 33 => 4, 25 => 3, 8 => 1 -->
+            <div class="form-cell pt-8 fw_50">
+              <mat-form-field appearance="outline">
+                <mat-label>Empleado</mat-label>
+                <mat-select formControlName="userId">
+                  <mat-option *ngFor="let user of users" [value]="user.IDUSUARIO">
+                    {{ user.NOMBRE }}
+                  </mat-option>
+                </mat-select>
+                <mat-error>Este campo es obligatorio.</mat-error>
+              </mat-form-field>
+            </div>
+            <div class="form-cell pt-8 fw_50">
+              <mat-form-field appearance="outline">
+                <mat-label>Equipo de Trabajo</mat-label>
+                <mat-select formControlName="workteamId">
+                  <mat-option *ngFor="let workteam of workteams" [value]="workteam.WORKTEAM_ID">{{ workteam.NAME }}</mat-option>
+                </mat-select>
+                <mat-error>Este campo es obligatorio.</mat-error>
+              </mat-form-field>
+            </div>
+            <div class="form-cell pt-8 fw_33">
+              <mat-form-field appearance="outline">
+                <mat-label>Tipo de Contrato</mat-label>
+                <mat-select (ngModelChange)="changeContractType()" formControlName="contractType">
+                  <mat-option value="Subcontratista">Subcontratista</mat-option>
+                  <mat-option value="Interno">Interno</mat-option>
+                </mat-select>
+                <mat-error>Este campo es obligatorio.</mat-error>
+              </mat-form-field>
+            </div>
+            <div class="form-cell pt-8 fw_33">
+              <mat-form-field appearance="outline">
+                <mat-label>Subcontratista</mat-label>
+                <mat-select formControlName="subcontratistId">
+                  <mat-option *ngFor="let subcontratist of subcontratists" [value]="subcontratist.ID_SUBCONTRATIST">{{ subcontratist.NAME }}</mat-option>
+                </mat-select>
+                <mat-error>Este campo es obligatorio.</mat-error>
+              </mat-form-field>
+            </div>
+            <div class="form-cell pt-8 fw_33">
+              <mat-form-field appearance="outline">
+                <mat-label>Especialidad</mat-label>
+                <input matInput formControlName="speciality">
+                <mat-error>Este campo es obligatorio.</mat-error>
+              </mat-form-field>
+            </div>
+            <div class="form-cell pt-8 fw_33">
+              <mat-form-field appearance="outline" class="w-100">
+                <mat-label>Nacionalidad</mat-label>
+                <mat-select (ngModelChange)="changeNationality()" formControlName="foreigner" #nat>
+                  <mat-option value="No">Nacional</mat-option>
+                  <mat-option value="Si">Extranjero</mat-option>
+                </mat-select>
+                <mat-error *ngIf="formGroup.controls['foreigner'].hasError('required')">Este campo es obligatorio.</mat-error>
+              </mat-form-field>
+            </div>
+            <div class="form-cell pt-8 fw_33">
+              <mat-form-field appearance="outline">
+                <mat-label>R.F.C.</mat-label>
+                <input matInput placeholder="Ingrese su R.F.C." oninput="javascript: this.value= this.value.toUpperCase();" formControlName="RFC" 
+                (input)="formGroup.controls['RFC'].markAsTouched()">
+                <mat-error *ngIf="formGroup.controls['RFC'].hasError('required')">Este campo es obligatorio.</mat-error>
+                <mat-error *ngIf="formGroup.controls['RFC'].hasError('minlength')">Este campo debe tener al menos 12 caracteres.</mat-error>
+                <mat-error *ngIf="formGroup.controls['RFC'].hasError('maxlength')">Este campo puede tener máximo 12 caracteres.</mat-error>
+                <mat-error *ngIf="formGroup.controls['RFC'].hasError('pattern')">El formato del RFC ingresado es inválido.</mat-error>
+              </mat-form-field>
+            </div>
+            <div class="form-cell pt-8 fw_33">
+              <mat-form-field appearance="outline" class="w-100">
+                <mat-label>TAX ID</mat-label>
+                <input matInput placeholder="Ingrese su TAX ID" oninput="javascript: this.value= this.value.toUpperCase();" formControlName="tax" 
+                (input)="formGroup.controls['tax'].markAsTouched()">
+                <mat-error *ngIf="formGroup.controls['tax'].hasError('required')">Este campo es obligatorio.</mat-error>
+                <mat-error *ngIf="formGroup.controls['tax'].hasError('minlength')">Este campo debe tener al menos 12 caracteres.</mat-error>
+                <mat-error *ngIf="formGroup.controls['tax'].hasError('maxlength')">Este campo puede tener máximo 12 caracteres.</mat-error>
+                <mat-error *ngIf="formGroup.controls['tax'].hasError('pattern')">El formato del TAX ID ingresado es inválido.</mat-error>
+              </mat-form-field>
+            </div>
+            <div class="form-cell pt-8 fw_25">
+              <mat-form-field appearance="outline" class="w-100">
+                <mat-label>País</mat-label>
+                <input matInput formControlName="country" [matAutocomplete]="autocompleteCountry" id="country" 
+                (input)="checkIfAddress(country.value)" #country>
+                <mat-autocomplete autoActiveFirstOption #autocompleteCountry (optionSelected)="checkIfAddress(country.value)">
+                  <mat-option *ngFor="let countryStr of filteredCountries | async" [value]="countryStr" 
+                  [disabled]="(countryStr == 'México (MEX)' && nat.value == 'Si') || (countryStr != 'México (MEX)' && nat.value == 'No')">
+                    {{ countryStr }}
+                  </mat-option>
+                </mat-autocomplete>
+                <mat-error *ngIf="formGroup.controls['country'].hasError('required')">Este campo es obligatorio.</mat-error>
+              </mat-form-field>
+            </div>
+            <div class="form-cell pt-8 fw_25">
+              <mat-form-field appearance="outline" class="w-100" *ngIf="!searchingStates">
+                <mat-label>Estado</mat-label>
+                <input matInput formControlName="federalEntity" [matAutocomplete]="autocompleteState" id="state">
+                <mat-autocomplete autoActiveFirstOption #autocompleteState>
+                  <mat-option *ngFor="let stateStr of filteredStates | async" [value]="stateStr">
+                    {{ stateStr }}
+                  </mat-option>
+                </mat-autocomplete>
+                <mat-error *ngIf="formGroup.controls['federalEntity'].hasError('required')">Este campo es obligatorio.</mat-error>
+              </mat-form-field>
+              <mat-progress-bar mode="indeterminate" class="w-100" *ngIf="searchingStates"></mat-progress-bar>
+            </div>
+            <div class="form-cell pt-8 fw_25">
+              <mat-form-field appearance="outline" class="w-100" *ngIf="!searchingCities">
+                <mat-label>Municipio</mat-label>
+                <input matInput formControlName="city" [matAutocomplete]="autocompleteCity" id="city">
+                <mat-autocomplete autoActiveFirstOption #autocompleteCity>
+                  <mat-option *ngFor="let cityStr of filteredCities | async" [value]="cityStr">
+                    {{ cityStr }}
+                  </mat-option>
+                </mat-autocomplete>
+                <mat-error *ngIf="formGroup.controls['city'].hasError('required')">Este campo es obligatorio.</mat-error>
+              </mat-form-field>
+              <mat-progress-bar mode="indeterminate" class="w-100" *ngIf="searchingCities"></mat-progress-bar>
+            </div>
+            <div class="form-cell pt-8 fw_25">
+              <mat-form-field appearance="outline" class="w-100" *ngIf="!searchingTowns">
+                <mat-label>Localidad</mat-label>
+                <input matInput formControlName="town" [matAutocomplete]="autocompleteTown" id="town">
+                <mat-autocomplete autoActiveFirstOption #autocompleteTown>
+                  <mat-option *ngFor="let townStr of filteredTowns | async" [value]="townStr">
+                    {{ townStr }}
+                  </mat-option>
+                </mat-autocomplete>
+                <mat-error *ngIf="formGroup.controls['town'].hasError('required')">Este campo es obligatorio.</mat-error>
+              </mat-form-field>
+              <mat-progress-bar mode="indeterminate" class="w-100" *ngIf="searchingTowns"></mat-progress-bar>
+            </div>
+            <div class="form-cell pt-8 fw_25">
+              <mat-form-field appearance="outline" class="w-100" *ngIf="!searchingSettings">
+                <mat-label>Colonia</mat-label>
+                <input matInput formControlName="suburb" [matAutocomplete]="autocompleteSetting" id="setting">
+                <mat-autocomplete autoActiveFirstOption #autocompleteSetting>
+                  <mat-option *ngFor="let settingStr of filteredSettings | async" [value]="settingStr">
+                    {{ settingStr }}
+                  </mat-option>
+                </mat-autocomplete>
+                <mat-error *ngIf="formGroup.controls['suburb'].hasError('required')">Este campo es obligatorio.</mat-error>
+              </mat-form-field>
+              <mat-progress-bar mode="indeterminate" class="w-100" *ngIf="searchingSettings"></mat-progress-bar>
+            </div>
+            <div class="form-cell pt-8 fw_25">
+              <mat-form-field appearance="outline" class="w-100" *ngIf="!searchingAddress">
+                <mat-label>Código Postal</mat-label>
+                <input matInput placeholder="Ingrese su Código Postal" formControlName="postalCode" (input)="searchZipCode(zipCode.value)" #zipCode id="zipCode">
+                <mat-error *ngIf="formGroup.controls['postalCode'].hasError('required')">Este campo es obligatorio.</mat-error>
+              </mat-form-field>
+              <mat-progress-bar mode="indeterminate" class="w-100" *ngIf="searchingAddress"></mat-progress-bar>
+            </div>
+            <div class="form-cell pt-8 fw_50">
+              <mat-form-field appearance="outline" class="w-100">
+                <mat-label>Calle</mat-label>
+                <input matInput placeholder="Ingrese su Calle" formControlName="street" (input)="formGroup.controls['street'].markAsTouched()">
+                <mat-error *ngIf="formGroup.controls['street'].hasError('required')">Este campo es obligatorio.</mat-error>
+                <mat-error *ngIf="formGroup.controls['street'].hasError('maxlength')">Este campo puede tener máximo 150 caracteres.</mat-error>
+              </mat-form-field>
+            </div>
+            <div class="form-cell pt-8 fw_25">
+              <mat-form-field appearance="outline" class="w-100">
+                <mat-label>Número Exterior</mat-label>
+                <input type="text" matInput placeholder="Ingrese su Número Exterior" formControlName="exteriorNumber" 
+                (input)="formGroup.controls['exteriorNumber'].markAsTouched()">
+                <mat-error *ngIf="formGroup.controls['exteriorNumber'].hasError('required')">Este campo es obligatorio.</mat-error>
+                <mat-error *ngIf="formGroup.controls['exteriorNumber'].hasError('maxlength')">Este campo puede tener máximo 10 caracteres.</mat-error>
+              </mat-form-field>
+            </div>
+            <div class="form-cell pt-8 fw_25">
+              <mat-form-field appearance="outline" class="w-100">
+                <mat-label>Número Interior</mat-label>
+                <input type="text" matInput placeholder="Ingrese su Número Interior" formControlName="interiorNumber" 
+                (input)="formGroup.controls['interiorNumber'].markAsTouched()">
+                <mat-error *ngIf="formGroup.controls['interiorNumber'].hasError('maxlength')">Este campo puede tener máximo 10 caracteres.</mat-error>
+              </mat-form-field>
+            </div>
+            <div class="section-divider">Configuración del contacto de emergencia</div>
+            <div class="form-cell pt-8 fw_42">
+              <mat-form-field appearance="outline">
+                <mat-label>Nombre del contacto de emergencia</mat-label>
+                <input  matInput formControlName="contactName">
+                <mat-error>Este campo es obligatorio.</mat-error>
+              </mat-form-field>
+            </div>
+            <div class="form-cell pt-8 fw_8">
+              <mat-form-field appearance="outline">
+                <mat-label>Lada</mat-label>
+                <mat-select formControlName="contactLada">
+                  <mat-option *ngFor="let country of countries" [value]="country.LADA">+{{country.LADA}}</mat-option>
+                </mat-select>
+                <mat-error>Este campo es obligatorio.</mat-error>
+              </mat-form-field>
+            </div>
+            <div class="form-cell pt-8 fw_25">
+              <mat-form-field appearance="outline">
+                <mat-label>Número Telefónico</mat-label>
+                <input matInput formControlName="contactTelephone">
+                <mat-error>Este campo es obligatorio.</mat-error>
+              </mat-form-field>
+            </div>
+            <div class="form-cell pt-8 fw_25">
+              <mat-form-field appearance="outline">
+                <mat-label>Dirección</mat-label>
+                <input matInput formControlName="contactAddress">
+                <mat-error>Este campo es obligatorio.</mat-error>
+              </mat-form-field>
+            </div>
+            <div class="section-divider">Documentación del empleado</div>
+            <div class="form-cell pt-8 fw_50">
+              <mat-form-field appearance="outline">
+                <mat-label>Tipo de Documento</mat-label>
+                <mat-select #documentType>
+                  <mat-option value="AU">Autorización</mat-option>
+                  <mat-option value="OF">Oficio</mat-option>
+                  <mat-option value="CE">Certificación</mat-option>
+                </mat-select>
+              </mat-form-field>
+            </div>
+            <div class="form-cell pt-8 fw_50">
+              <button mat-stroked-button [disabled]="documentType.value == null || documentType.value == undefined || documentType.value == ''" 
+              style="margin-bottom: 20px; width: 100%;">
+                Adjuntar Archivo
+              </button>
+            </div>
+          </div>
+        </div>
+      </div>
     </mat-card-content>
   </mat-card>
 </div>
 <!-- CONTENEDOR PRINCIPAL -->
 <!--<main class="main-container animated fadeIn" (window:resize)="onResize()">
 
-    <- REGRESAR A LA PANTALLA ANTERIOR ->
-    <header id="navigation" class="btn-navigate mb-8" style="width: 80%
-        !important;">
-        <div class="prev-page prevent-select indigo_primary_background
-            mat-elevation-z8" matRipple
-            [routerLink]="['/sam/GPRS/employee']">
-            <mat-icon style="color: white">arrow_back</mat-icon>
-            <div class="page-name ml-4">Lista de Empleados</div>
-        </div>
-    </header>
-    <mat-card class="override-card-form override-elevation-z8" style="max-height: calc(100vh - 188px); overflow: auto;">
-        <section class="override-section">
-            <nav class="override-nav">
-                <mat-card-title class="mat-card-title centre"
-                    *ngIf="idEmployee == '0'">Registro de Empleado</mat-card-title>
-                <mat-card-title class="mat-card-title centre"
-                    *ngIf="idEmployee != '0' && enable == '1'">Modificación de
-                    Empleado</mat-card-title>
-                <mat-card-title class="mat-card-title centre"
-                    *ngIf="idEmployee != '0' && enable == '0'">Detalles de
-                    Empleado</mat-card-title>
-            </nav>
-
-            <div class="ph-32" [formGroup]="formGroup">
-                <mat-grid-list  [cols]="12"
-                    rowHeight="82px">
-
-                    <mat-grid-tile colspan="6" *ngIf="enable === '1' || enable === '2'">
-                        <mat-form-field appearance="outline">
-                            <mat-label>Empleado</mat-label>
-                            <mat-select
-                                formControlName="userId">
-                                <mat-option *ngFor="let user of users" [value]="user.ID_USER">{{ user.NAME }}</mat-option>
-                            </mat-select>
-                            <mat-error>El Campo Empleado es
-                                Obligatorio</mat-error>
-                        </mat-form-field>
-                    </mat-grid-tile>
-
-                    <mat-grid-tile colspan="6" *ngIf="enable === '0'">
-                        <mat-form-field appearance="outline">
-                            <mat-label>Empleado</mat-label>
-                            <input  matInput readonly="true"
-                            [value]="userId.value">
-                            <mat-error>El Campo Empleado es
-                                Obligatorio</mat-error>
-                        </mat-form-field>
-                    </mat-grid-tile>
-
-                    <mat-grid-tile colspan="6" *ngIf="enable === '1' || enable === '2'">
-                        <mat-form-field appearance="outline">
-                            <mat-label>Equipo de Trabajo</mat-label>
-                            <mat-select
-                                formControlName="workteamId">
-                                <mat-option *ngFor="let workteam of workteams" [value]="workteam.WORKTEAM_ID">{{ workteam.NAME }}</mat-option>
-                            </mat-select>
-                            <mat-error>El Campo Equipo de Trabajo es
-                                Obligatorio</mat-error>
-                        </mat-form-field>
-                    </mat-grid-tile>
-
-                    <mat-grid-tile colspan="6" *ngIf="enable == '0'">
-                        <mat-form-field appearance="outline">
-                            <mat-label>Equipo de Trabajo</mat-label>
-                            <input  matInput  readonly="true"
-                            [value]="workteamId.value">
-                            <mat-error>El Campo Equipo de Trabajo es
-                                Obligatorio</mat-error>
-                        </mat-form-field>
-                    </mat-grid-tile>
-
-                    <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 == '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' || enable === '2'">
-                        <mat-form-field appearance="outline">
-                            <mat-label>Lada</mat-label>
-                            <mat-select
-                                formControlName="contactLada">
-                                <mat-option *ngFor="let country of countries" [value]="country.LADA">+{{country.LADA}}</mat-option>
-                            </mat-select>
-                            <mat-error>El Campo Lada es
-                                Obligatorio</mat-error>
-                        </mat-form-field>
-                    </mat-grid-tile>
-
-                    <mat-grid-tile colspan="1" *ngIf="enable == '0'">
-                        <mat-form-field appearance="outline">
-                            <mat-label>Lada</mat-label>
-                            <input  matInput readonly="true"
-                            [value]="contactLada.value">
-                            <mat-error>El Campo Lada es
-                                Obligatorio</mat-error>
-                        </mat-form-field>
-                    </mat-grid-tile>
-
-                    <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 == '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"
-                        formControlName="contactTelephone">
-                            <mat-error>El Campo Número Telefónico es Obligatorio</mat-error>
-                        </mat-form-field>
-                    </mat-grid-tile>
-
-                    <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 == '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' || enable === '2'">
-                        <mat-form-field appearance="outline">
-                            <mat-label>Tipo de Contrato</mat-label>
-                            <mat-select (ngModelChange)="changeContractType()"
-                                formControlName="contractType">
-                                <mat-option value="Subcontratista">Subcontratista</mat-option>
-                                <mat-option value="Interno">Interno</mat-option>
-                            </mat-select>
-                            <mat-error>El Campo Tipo de Contrato es
-                                Obligatorio</mat-error>
-                        </mat-form-field>
-                    </mat-grid-tile>
-
-                    <mat-grid-tile colspan="4" *ngIf="enable == '0'">
-                        <mat-form-field appearance="outline">
-                            <mat-label>Tipo de Contrato</mat-label>
-                            <input  matInput readonly="true"
-                            [value]="contractType.value">
-                            <mat-error>El Campo Tipo de Contrato es
-                                Obligatorio</mat-error>
-                        </mat-form-field>
-                    </mat-grid-tile>
-
-                    <mat-grid-tile colspan="4" *ngIf="enable === '1' || enable === '2'">
-                        <mat-form-field appearance="outline">
-                            <mat-label>Subcontratista</mat-label>
-                            <mat-select
-                                formControlName="subcontratistId">
-                                <mat-option *ngFor="let subcontratist of subcontratists" [value]="subcontratist.ID_SUBCONTRATIST">{{ subcontratist.NAME }}</mat-option>
-                            </mat-select>
-                            <mat-error>El Campo Subcontratista es
-                                Obligatorio</mat-error>
-                        </mat-form-field>
-                    </mat-grid-tile>
-
-                    <mat-grid-tile colspan="4" *ngIf="enable == '0'">
-                        <mat-form-field appearance="outline">
-                            <mat-label>Subcontratista</mat-label>
-                            <input  matInput readonly="true"
-                            [value]="subcontratistId.value">
-                            <mat-error>El Campo Subcontratista es
-                                Obligatorio</mat-error>
-                        </mat-form-field>
-                    </mat-grid-tile>
-
-                    <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 == '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' || 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 || authoButton" >
-                        Adjuntar Autorización
-                    </button>
-                </mat-grid-tile>
-
-                    <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 || authoButton" >
-                        Adjuntar Autorización
-                    </button>
-                </mat-grid-tile>
-
-                <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 || officeButton" >
-                        Adjuntar Oficio
-                    </button>
-                </mat-grid-tile>
-
-                <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 || certButton" >
-                        Adjuntar Certificación
-                    </button>
-                </mat-grid-tile>
-
-                <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 || certButton" >
-                        Adjuntar Certificación
-                    </button>
-                </mat-grid-tile>
-
-                <mat-grid-tile colspan="12" *ngIf="enable === '1' && idEmployee !== '0'">
-                    <mat-form-field appearance="outline" style="width: 50%!important;">
-                        <mat-label>Actualizar documento</mat-label>
-                        <mat-select formControlName="updateDocuments" (valueChange)="saveDocumentToUpdate($event)">
-                            <mat-option *ngFor="let document of documentsEmployee" [value]="document">{{ document }}</mat-option>
-                        </mat-select>
-                    </mat-form-field>
-                </mat-grid-tile>
-
-
-            </mat-grid-list>
-
-                <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>
-                    <td mat-cell *matCellDef="let element"> {{element.file.name}} </td>
-                </ng-container>
-
-                <ng-container matColumnDef="size">
-                    <th mat-header-cell *matHeaderCellDef > Tamaño </th>
-                    <td mat-cell *matCellDef="let element"> {{element.file.size}} </td>
-                </ng-container>
-
-                <ng-container matColumnDef="type">
-                    <th mat-header-cell *matHeaderCellDef > Tipo Documento </th>
-                    <td mat-cell *matCellDef="let element"> {{element.type}} </td>
-                </ng-container>
-
-                <ng-container matColumnDef="update" style="width:25%!important;">
-                    <th mat-header-cell *matHeaderCellDef > Actualizar documento </th>
-                    <td mat-cell *matCellDef="let element"> {{element.update === '' ? 'No Aplica' : element.update}} </td>
-                </ng-container>
-
-                <ng-container matColumnDef="action">
-                    <th mat-header-cell *matHeaderCellDef > Acciones </th>
-                    <td mat-cell *matCellDef="let element"> <button
-                        mat-mini-fab
-                        color="warn"
-                        class="override_no_shadow mr-4"
-                        matTooltip="Eliminar Archivo"
-                        (click)="deleteFiles(element)">
-                        <mat-icon>delete</mat-icon>
-                    </button></td>
-                </ng-container>
-
-                <tr mat-header-row *matHeaderRowDef="displayedColumns"></tr>
-                <tr mat-row *matRowDef="let row; columns: displayedColumns;"></tr>
-            </table>
-            </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' || enable == '2'" [disabled]="formGroup.invalid" ><mat-icon>save</mat-icon>{{ idEmployee == "0" ? "Registrar" : "Guardar" }}</button>
-                <button
-                *ngIf="enable === '0'"
-                mat-mini-fab
-                color="warn"
-                class="override_no_shadow mr-4"
-                [disabled]="isLoadingForm"
-                matTooltip="Ficha en Pdf"
-                (click)="openDialog('PDF')">
-                <mat-icon>picture_as_pdf</mat-icon>
-            </button>
-            <button
-            *ngIf="enable === '0'"
-                mat-mini-fab
-                color="primary"
-                class="override_no_shadow mr-4"
-                [disabled]="isLoadingForm"
-                matTooltip="Ficha en Excel"
-                (click)="openDialog('EXC')"
-                downoload="asd.csv">
-                <mat-icon>text_snippet</mat-icon>
-            </button>
-            </div>
-        </section>
-
-    </mat-card>-->
+<- REGRESAR A LA PANTALLA ANTERIOR ->
+<mat-card class="override-card-form override-elevation-z8" style="max-height: calc(100vh - 188px); overflow: auto;">
+  <section class="override-section">
+    <div class="ph-32" [formGroup]="formGroup">
+      <mat-grid-list  [cols]="12" rowHeight="82px">
+        <mat-grid-tile colspan="6" *ngIf="enable === '1' || enable === '2'">
+          <mat-form-field appearance="outline">
+            <mat-label>Empleado</mat-label>
+            <mat-select formControlName="userId">
+              <mat-option *ngFor="let user of users" [value]="user.ID_USER">{{ user.NAME }}</mat-option>
+            </mat-select>
+            <mat-error>El Campo Empleado es Obligatorio</mat-error>
+          </mat-form-field>
+        </mat-grid-tile>
+        <mat-grid-tile colspan="6" *ngIf="enable === '1' || enable === '2'">
+          <mat-form-field appearance="outline">
+            <mat-label>Equipo de Trabajo</mat-label>
+            <mat-select formControlName="workteamId">
+              <mat-option *ngFor="let workteam of workteams" [value]="workteam.WORKTEAM_ID">{{ workteam.NAME }}</mat-option>
+            </mat-select>
+            <mat-error>El Campo Equipo de Trabajo es Obligatorio</mat-error>
+          </mat-form-field>
+        </mat-grid-tile>
+        <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 == '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' || enable === '2'">
+          <mat-form-field appearance="outline">
+            <mat-label>Lada</mat-label>
+            <mat-select formControlName="contactLada">
+              <mat-option *ngFor="let country of countries" [value]="country.LADA">+{{country.LADA}}</mat-option>
+            </mat-select>
+            <mat-error>El Campo Lada es Obligatorio</mat-error>
+          </mat-form-field>
+        </mat-grid-tile>
+        <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 == '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"
+            formControlName="contactTelephone">
+            <mat-error>El Campo Número Telefónico es Obligatorio</mat-error>
+          </mat-form-field>
+        </mat-grid-tile>
+        <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 == '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' || enable === '2'">
+          <mat-form-field appearance="outline">
+            <mat-label>Tipo de Contrato</mat-label>
+            <mat-select (ngModelChange)="changeContractType()" formControlName="contractType">
+              <mat-option value="Subcontratista">Subcontratista</mat-option>
+              <mat-option value="Interno">Interno</mat-option>
+            </mat-select>
+            <mat-error>El Campo Tipo de Contrato es Obligatorio</mat-error>
+          </mat-form-field>
+        </mat-grid-tile>
+        <mat-grid-tile colspan="4" *ngIf="enable === '1' || enable === '2'">
+          <mat-form-field appearance="outline">
+            <mat-label>Subcontratista</mat-label>
+            <mat-select formControlName="subcontratistId">
+              <mat-option *ngFor="let subcontratist of subcontratists" [value]="subcontratist.ID_SUBCONTRATIST">{{ subcontratist.NAME }}</mat-option>
+            </mat-select>
+            <mat-error>El Campo Subcontratista es Obligatorio</mat-error>
+          </mat-form-field>
+        </mat-grid-tile>
+        <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 == '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' || 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 || authoButton" >
+              Adjuntar Autorización
+          </button>
+        </mat-grid-tile>
+        <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 || authoButton" >
+            Adjuntar Autorización
+          </button>
+        </mat-grid-tile>
+        <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 || officeButton" >
+            Adjuntar Oficio
+          </button>
+        </mat-grid-tile>
+        <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 || certButton" >
+            Adjuntar Certificación
+          </button>
+        </mat-grid-tile>
+        <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 || certButton" >
+            Adjuntar Certificación
+          </button>
+        </mat-grid-tile>
+        <mat-grid-tile colspan="12" *ngIf="enable === '1' && idEmployee !== '0'">
+          <mat-form-field appearance="outline" style="width: 50%!important;">
+            <mat-label>Actualizar documento</mat-label>
+            <mat-select formControlName="updateDocuments" (valueChange)="saveDocumentToUpdate($event)">
+              <mat-option *ngFor="let document of documentsEmployee" [value]="document">{{ document }}</mat-option>
+            </mat-select>
+          </mat-form-field>
+        </mat-grid-tile>
+      </mat-grid-list>
+      <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>
+          <td mat-cell *matCellDef="let element"> {{element.file.name}} </td>
+        </ng-container>
+        <ng-container matColumnDef="size">
+          <th mat-header-cell *matHeaderCellDef > Tamaño </th>
+          <td mat-cell *matCellDef="let element"> {{element.file.size}} </td>
+        </ng-container>
+        <ng-container matColumnDef="type">
+          <th mat-header-cell *matHeaderCellDef > Tipo Documento </th>
+          <td mat-cell *matCellDef="let element"> {{element.type}} </td>
+        </ng-container>
+        <ng-container matColumnDef="update" style="width:25%!important;">
+          <th mat-header-cell *matHeaderCellDef > Actualizar documento </th>
+          <td mat-cell *matCellDef="let element"> {{element.update === '' ? 'No Aplica' : element.update}} </td>
+        </ng-container>
+        <ng-container matColumnDef="action">
+          <th mat-header-cell *matHeaderCellDef > Acciones </th>
+          <td mat-cell *matCellDef="let element"> <button
+            mat-mini-fab
+            color="warn"
+            class="override_no_shadow mr-4"
+            matTooltip="Eliminar Archivo"
+            (click)="deleteFiles(element)">
+            <mat-icon>delete</mat-icon>
+          </button></td>
+        </ng-container>
+        <tr mat-header-row *matHeaderRowDef="displayedColumns"></tr>
+        <tr mat-row *matRowDef="let row; columns: displayedColumns;"></tr>
+      </table>
+    </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' || enable == '2'" [disabled]="formGroup.invalid" ><mat-icon>save</mat-icon>{{ idEmployee == "0" ? "Registrar" : "Guardar" }}</button>
+      <button
+        *ngIf="enable === '0'"
+        mat-mini-fab
+        color="warn"
+        class="override_no_shadow mr-4"
+        [disabled]="isLoadingForm"
+        matTooltip="Ficha en Pdf"
+        (click)="openDialog('PDF')">
+        <mat-icon>picture_as_pdf</mat-icon>
+      </button>
+      <button *ngIf="enable === '0'"
+        mat-mini-fab
+        color="primary"
+        class="override_no_shadow mr-4"
+        [disabled]="isLoadingForm"
+        matTooltip="Ficha en Excel"
+        (click)="openDialog('EXC')"
+        downoload="asd.csv">
+        <mat-icon>text_snippet</mat-icon>
+      </button>
+    </div>
+  </section>
+</mat-card>-->

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

@@ -1,17 +1,23 @@
 import { HttpErrorResponse } from '@angular/common/http';
-import { Component, OnInit } from '@angular/core';
+import { Component, Inject, OnInit } from '@angular/core';
 import { FormControl, FormGroup, Validators } from '@angular/forms';
 import { MatDialog } from '@angular/material/dialog';
 import { MatTableDataSource } from '@angular/material/table';
 import { ActivatedRoute, Router } from '@angular/router';
-import { lastValueFrom } from 'rxjs';
+import countryCodeEmoji from 'country-code-emoji';
+import { Observable, lastValueFrom, map, startWith } from 'rxjs';
 import { AlertComponent } from 'src/app/components/resources/dialogs/alert/alert.component';
-import { CountriesList, CountriesListResponse } from 'src/app/interfaces/countries-list.interface';
+import { CitySettings, CitySettingsResponse } from 'src/app/interfaces/city-settings.interface';
+import { CityTown, CityTownsResponse } from 'src/app/interfaces/city-towns.interface';
+import { CountriesList, CountriesListResponse, LadaSelection } from 'src/app/interfaces/countries-list.interface';
+import { CountryState, CountryStatesResponse } from 'src/app/interfaces/country-states.interface';
 import { DownoloadEmployeeInfo, Employee, FilesDocuments } from 'src/app/interfaces/personal-managment/employee.interface';
 import { SubcontratistItem, SubcontratistsResponse } from 'src/app/interfaces/personal-managment/subcontratists.interface';
 import { ResponseData } from 'src/app/interfaces/response-data';
+import { StateCitiesResponse, StateCity } from 'src/app/interfaces/state-cities.interface';
 import { UsersResponse, UserResponse } from 'src/app/interfaces/users.interface';
 import { EncService } from 'src/app/services/enc/enc.service';
+import { FunctionsService } from 'src/app/services/functions.service';
 import { LocateService } from 'src/app/services/locate/locate.service';
 import { EmployeeService } from 'src/app/services/personal-management/employee.service';
 import { SubcontratistService } from 'src/app/services/personal-management/subcontratist.service';
@@ -20,6 +26,9 @@ import { ResourcesService } from 'src/app/services/resources/resources.service';
 import { SystemAdminService } from 'src/app/services/system-admin.service';
 import { UsersProfilesService } from 'src/app/services/users-profiles.service';
 import { hostJean } from 'src/environments/environment';
+import flag from 'country-code-emoji';
+import { DOCUMENT } from '@angular/common';
+import { AddressByZipCodeResponse } from 'src/app/interfaces/address-by-zip-code.interface';
 
 @Component({
   selector: 'app-employee-form',
@@ -62,8 +71,35 @@ export class EmployeeFormComponent implements OnInit {
   public hasError: boolean;
   public errorStr: string;
   public users: UserResponse[];
+  public enableSearchByZipCode: boolean;
+  public countryStates: CountryState[];
+  public stateCities: StateCity[];
+  public cityTowns: CityTown[];
+  public citySettings: CitySettings[];
+  public ladas: LadaSelection[];
+
+  public countriesStr: string[];
+  public countryStatesStr: string[];
+  public stateCitiesStr: string[];
+  public cityTownsStr: string[];
+  public citySettingsStr: string[];
+  public ladasStr: string[];
+
+  filteredCountries?: Observable<string[]>;
+  filteredStates?: Observable<string[]>;
+  filteredCities?: Observable<string[]>;
+  filteredTowns?: Observable<string[]>;
+  filteredSettings?: Observable<string[]>;
+
+  public searchingStates: boolean;
+  public citiesInput: boolean;
+  public searchingCities: boolean;
+  public searchingTowns: boolean;
+  public searchingSettings: boolean;
+  public searchingAddress: boolean;
 
   constructor(
+    @Inject(DOCUMENT) private _document: Document,
     private _activatedRoute: ActivatedRoute,
     private _employeeService: EmployeeService,
     private _resourcesService: ResourcesService,
@@ -74,6 +110,7 @@ export class EmployeeFormComponent implements OnInit {
     private _router: Router,
     private _dialog: MatDialog,
     private _usersProfilesService: UsersProfilesService,
+    private _functionsService: FunctionsService,
   ) {
     this.action = "";
     this.idEmployee = this._activatedRoute.snapshot.paramMap.get('id')!;
@@ -96,13 +133,33 @@ export class EmployeeFormComponent implements OnInit {
     this.documentTipe = 0;
     this.dataSource = new MatTableDataSource<any>();
 
+    this.workteams = [];
+    this.subcontratists = [];
+    this.countries = [];
     this.isLoading = true;
     this.hasError = false;
     this.errorStr = "";
     this.users = [];
-    this.workteams = [];
-    this.subcontratists = [];
-    this.countries = [];
+    this.enableSearchByZipCode = true;
+    this.countryStates = [];
+    this.stateCities = [];
+    this.cityTowns = [];
+    this.citySettings = [];
+    this.ladas = [];
+
+    this.countriesStr = [];
+    this.countryStatesStr = [];
+    this.stateCitiesStr = [];
+    this.cityTownsStr = [];
+    this.citySettingsStr = [];
+    this.ladasStr = [];
+    
+    this.searchingStates = false;
+    this.citiesInput = false;
+    this.searchingCities = false;
+    this.searchingTowns = false;
+    this.searchingSettings = false;
+    this.searchingAddress = false;
   }
 
   ngOnInit(): void {
@@ -111,6 +168,525 @@ export class EmployeeFormComponent implements OnInit {
     this.getWorkteams();
     this.getSubcontratists();
     this.getCountries();*/
+
+    this.formGroup.controls['federalEntity'].valueChanges.subscribe(value => {
+      let countryVal = this.formGroup.controls['country'].value;
+      let countryArr = countryVal.split('(').reverse();
+      let countryCode = countryArr[0].replace(')', '');
+
+      if(countryCode == 'MEX' || countryCode == 'USA' || countryCode == 'CAN'){
+        let validValue = this.countryStatesStr.filter(item => item == value);
+        if(validValue.length > 0){
+          let valueArr = value.split('(').reverse();
+          let stateCode = valueArr[0].replace(')', '');
+  
+          this.verifyState(stateCode);
+        }else{
+          this.formGroup.controls['city'].setValue('');
+          this.formGroup.controls['city'].disable();
+          this.formGroup.controls['town'].setValue('');
+          this.formGroup.controls['town'].disable();
+          this.formGroup.controls['suburb'].setValue('');
+          this.formGroup.controls['suburb'].disable();
+        }
+      }else{
+        this.formGroup.controls['city'].enable();
+      }
+    });
+
+    this.formGroup.controls['city'].valueChanges.subscribe(value => {
+      let countryVal = this.formGroup.controls['country'].value;
+      let countryArr = countryVal.split('(').reverse();
+      let countryCode = countryArr[0].replace(')', '');
+
+      if(countryCode == 'MEX'){
+        let validValue = this.stateCitiesStr.filter(item => item == value);
+        if(validValue.length > 0){
+          let valueArr = value.split('(').reverse();
+          let cityCode = valueArr[0].replace(')', '');
+  
+          this.verifyCity(cityCode);
+        }else{
+          this.formGroup.controls['town'].setValue('');
+          this.formGroup.controls['town'].disable();
+          this.formGroup.controls['suburb'].setValue('');
+          this.formGroup.controls['suburb'].disable();
+        }
+      }else{
+        this.formGroup.controls['town'].enable();
+      }
+    });
+
+    this.formGroup.controls['town'].valueChanges.subscribe(value => {
+      let countryVal = this.formGroup.controls['country'].value;
+      let countryArr = countryVal.split('(').reverse();
+      let countryCode = countryArr[0].replace(')', '');
+
+      if(countryCode == 'MEX'){
+        let validValue = this.cityTownsStr.filter(item => item == value);
+        if(validValue.length > 0){
+          let valueArr = value.split('(').reverse();
+          let townCode = valueArr[0].replace(')', '');
+  
+          this.verifyTown(townCode);
+        }else{
+          this.formGroup.controls['suburb'].setValue('');
+          this.formGroup.controls['suburb'].disable();
+        }
+      }else{
+        this.formGroup.controls['suburb'].enable();
+      }
+    });
+    
+    this.formGroup.controls['suburb'].valueChanges.subscribe(value => {
+      let validValue = this.citySettingsStr.filter(item => item == value);
+      if(validValue.length > 0){
+        let valueArr = value.split('(').reverse();
+        let settingCode = valueArr[0].replace(')', '');
+
+        this.verifySetting(settingCode);
+      }
+    });
+
+    this.filteredCountries = this.formGroup.controls['country'].valueChanges.pipe(
+      startWith(''),
+      map(value => this._filterCountries(value || ''))
+    );
+
+    this.filteredStates = this.formGroup.controls['federalEntity'].valueChanges.pipe(
+      startWith(''),
+      map(value => this._filterStates(value || ''))
+    );
+
+    this.filteredCities = this.formGroup.controls['city'].valueChanges.pipe(
+      startWith(''),
+      map(value => this._filterCities(value || ''))
+    );
+
+    this.filteredTowns = this.formGroup.controls['town'].valueChanges.pipe(
+      startWith(''),
+      map(value => this._filterTowns(value || ''))
+    );
+
+    this.filteredSettings = this.formGroup.controls['suburb'].valueChanges.pipe(
+      startWith(''),
+      map(value => this._filterSettings(value || ''))
+    );
+  }
+
+  private _filterCountries(value: string): string[]{
+    const filterValue = value.toLowerCase();
+    return this.countriesStr.filter(item => item.toLowerCase().includes(filterValue));
+  }
+
+  private _filterStates(value: string): string[]{
+    const filterValue = value.toLowerCase();
+    return this.countryStatesStr.filter(item => item.toLowerCase().includes(filterValue));
+  }
+
+  private _filterCities(value: string): string[]{
+    const filterValue = value.toLowerCase();
+    return this.stateCitiesStr.filter(item => item.toLowerCase().includes(filterValue));
+  }
+
+  private _filterTowns(value: string): string[]{
+    const filterValue = value.toLowerCase();
+    return this.cityTownsStr.filter(item => item.toLowerCase().includes(filterValue));
+  }
+
+  private _filterSettings(value: string): string[]{
+    const filterValue = value.toLowerCase();
+    return this.citySettingsStr.filter(item => item.toLowerCase().includes(filterValue));
+  }
+
+  checkIfAddress(value: string){
+    if(this.formGroup.controls['foreigner'].value == 'Si' && value == 'México (MEX)') return;
+    if(this.formGroup.controls['foreigner'].value == 'No' && value != 'México (MEX)') return;
+
+    let validValue = this.countriesStr.filter(item => item == value);
+    this.formGroup.controls['postalCode'].setValue('', {
+      emitEvent: false,
+    });
+
+    if(validValue.length > 0){
+      let valueArr = value.split('(').reverse();
+      let countryCode = valueArr[0].replace(')', '');
+
+      this.formGroup.controls['postalCode'].disable();
+      this.enableSearchByZipCode = false;
+      this.verifyCountry(countryCode);
+    }else{
+      this.formGroup.controls['federalEntity'].setValue('');
+      this.formGroup.controls['federalEntity'].disable();
+      this.formGroup.controls['city'].setValue('');
+      this.formGroup.controls['city'].disable();
+      this.formGroup.controls['town'].setValue('');
+      this.formGroup.controls['town'].disable();
+      this.formGroup.controls['suburb'].setValue('');
+      this.formGroup.controls['suburb'].disable();
+
+      this.formGroup.controls['postalCode'].enable();
+      this.enableSearchByZipCode = true;
+    }
+  }
+
+  verifyCountry(countryCode: string){
+    this.formGroup.controls['federalEntity'].disable();
+    this.countryStates = [];
+    this.countryStatesStr = [];
+    this.stateCities = [];
+    this.stateCitiesStr = [];
+    this.cityTowns = [];
+    this.cityTownsStr = [];
+    this.citySettings = [];
+    this.citySettingsStr = [];
+
+    if(countryCode != 'MEX'){
+      this.formGroup.controls['postalCode'].enable();
+    }
+
+    if(countryCode == 'CAN' || countryCode == 'MEX' || countryCode == 'USA'){
+      this.searchCountryStates(countryCode);
+    }else{
+      this.formGroup.controls['federalEntity'].enable();
+    }
+  }
+
+  verifyState(value: string){
+    let countryVal = this.formGroup.controls['country'].value;
+    let countryArr = countryVal.split('(').reverse();
+    let countryCode = countryArr[0].replace(')', '');
+    this.stateCities = [];
+    this.stateCitiesStr = [];
+    this.cityTowns = [];
+    this.cityTownsStr = [];
+    this.citySettings = [];
+    this.citySettingsStr = [];
+
+    if(countryCode == 'MEX'){
+      this.citiesInput = false;
+      this.searchStateCities(value);
+    }else{
+      this.citiesInput = true;
+      this.formGroup.controls['city'].enable();
+    }
+  }
+
+  verifyCity(value: string){
+    let stateVal = this.formGroup.controls['federalEntity'].value;
+    let stateArr = stateVal.split('(').reverse();
+    let stateCode = stateArr[0].replace(')', '');
+    
+    this.cityTowns = [];
+    this.cityTownsStr = [];
+    this.citySettings = [];
+    this.citySettingsStr = [];
+    
+    this.searchStateTowns(stateCode, value);
+  }
+
+  verifyTown(value: string){
+    let stateVal = this.formGroup.controls['federalEntity'].value;
+    let stateArr = stateVal.split('(').reverse();
+    let stateCode = stateArr[0].replace(')', '');
+
+    let cityVal = this.formGroup.controls['city'].value;
+    let cityArr = cityVal.split('(').reverse();
+    let cityCode = cityArr[0].replace(')', '');
+    
+    this.citySettings = [];
+    this.citySettingsStr = [];
+    
+    let townCode = value == 'Sin localidad' ? '-' : value;
+    this.searchCitySettings(stateCode, cityCode, townCode);
+  }
+
+  verifySetting(value: string){
+    let settingValid = this.citySettings.filter(item => item.CODIGOCOLONIA == value);
+    if(settingValid.length > 0){
+      this.formGroup.controls['postalCode'].setValue(settingValid[0].CODIGOPOSTAL);
+    }
+  }
+
+  searchZipCode(value: string){
+    let valArr = value.split('');
+    let validChars = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9'];
+    let validVal = "";
+
+    valArr.forEach(char => {
+      if(validChars.includes(char)){
+        validVal += char;
+      }
+    });
+
+    let zipCodeInput = this._document.getElementById('zipCode') as HTMLInputElement;
+    if(validVal.length < 5 && this.enableSearchByZipCode){
+      zipCodeInput.value = validVal;
+      
+      let countryInput = this._document.getElementById('country') as HTMLInputElement;
+      countryInput.value = '';
+      
+      let stateInput = this._document.getElementById('state') as HTMLInputElement;
+      stateInput.value = '';
+      
+      let cityInput = this._document.getElementById('city') as HTMLInputElement;
+      cityInput.value = '';
+      
+      let townInput = this._document.getElementById('town') as HTMLInputElement;
+      townInput.value = '';
+
+      let settingInput = this._document.getElementById('setting') as HTMLInputElement;
+      settingInput.value = '';
+
+      this.citySettings = [];
+      this.citySettingsStr = [];
+    }else{
+      let finalVal = validVal.substring(0, 5);
+      zipCodeInput.value = finalVal;
+
+      this.searchAddressByZipCode(finalVal);
+    }
+  }
+
+  async searchCountryStates(contryCode: string){
+    try{
+      this.searchingStates = true;
+
+      let idUser = localStorage.getItem('idusuario')!;
+      let countryCodeEnc = await this._encService.encrypt(contryCode);
+      let states: CountryStatesResponse = await lastValueFrom(this._sysAdminService.getStatesByCountryCode(
+        countryCodeEnc,
+        idUser,
+        1
+      ));
+    
+      if(!states.error){
+        this.countryStatesStr = [];
+        this.countryStates = states.response;
+
+        this.countryStates.forEach(item => {
+          this.countryStatesStr.push(`${item.NOMBREESTADO} (${item.CODIGOESTADO})`);
+        });
+
+        this.formGroup.controls['federalEntity'].enable();
+      }
+
+      this.searchingStates = false;
+    }catch(error: any){
+      if(error.error == undefined){
+        this._resourcesService.openSnackBar("Ocurrió un error inesperado.");
+      }else if(error.error.msg == undefined){
+        this._resourcesService.openSnackBar("Ocurrió un error inesperado.");
+      }else{
+        this._resourcesService.openSnackBar(error.error.msg);
+      }
+
+      this.searchingStates = false;
+    }
+  }
+
+  async searchStateCities(stateCode: string){
+    try{
+      this.searchingCities = true;
+      
+      let idUser = localStorage.getItem('idusuario')!;
+      let stateCodeEnc = await this._encService.encrypt(stateCode);
+      let cities: StateCitiesResponse = await lastValueFrom(this._sysAdminService.getCitiesByStateCode(
+        stateCodeEnc,
+        idUser,
+        1
+      ));
+
+      if(!cities.error){
+        this.stateCities = cities.response;
+        this.stateCitiesStr = [];
+
+        this.stateCities.forEach(item => {
+          this.stateCitiesStr.push(`${item.NOMBREMUNICIPIO} (${item.CODIGOMUNICIPIO})`);
+        });
+
+        this.formGroup.controls['city'].enable();
+      }
+      
+      this.searchingCities = false;
+    }catch(error: any){
+      if(error.error == undefined){
+        this._resourcesService.openSnackBar("Ocurrió un error inesperado.");
+      }else if(error.error.msg == undefined){
+        this._resourcesService.openSnackBar("Ocurrió un error inesperado.");
+      }else{
+        this._resourcesService.openSnackBar(error.error.msg);
+      }
+
+      this.searchingCities = false;
+    }
+  }
+
+  async searchStateTowns(stateCode: string, cityCode: string){
+    try{
+      this.searchingTowns = true;
+      
+      let idUser = localStorage.getItem('idusuario')!;
+      let stateCodeEnc = await this._encService.encrypt(stateCode);
+      let cityCodeEnc = await this._encService.encrypt(cityCode);
+      let towns: CityTownsResponse = await lastValueFrom(this._sysAdminService.getTowns(
+        stateCodeEnc,
+        cityCodeEnc,
+        idUser,
+        1
+      ));
+
+      if(!towns.error){
+        this.cityTownsStr = [];
+        this.cityTowns = towns.response;
+
+        this.cityTowns.forEach(town => {
+          if(town.CODIGOLOCALIDAD == null){
+            this.cityTownsStr.push('Sin localidad');
+          }else{
+            this.cityTownsStr.push(`${town.NOMBRELOCALIDAD} (${town.CODIGOLOCALIDAD})`);
+          }
+        });
+
+        if(towns.response.length > 1){
+          this.formGroup.controls['town'].enable();
+        }else if(towns.response.length == 1 && towns.response[0].CODIGOLOCALIDAD != null){
+          this.formGroup.controls['town'].enable();
+        }else{
+          this.formGroup.controls['town'].disable();
+          this.formGroup.controls['town'].setValue('Sin localidad');
+        }
+      }
+      
+      this.searchingTowns = false;
+    }catch(error: any){
+      if(error.error == undefined){
+        this._resourcesService.openSnackBar("Ocurrió un error inesperado.");
+      }else if(error.error.msg == undefined){
+        this._resourcesService.openSnackBar("Ocurrió un error inesperado.");
+      }else{
+        this._resourcesService.openSnackBar(error.error.msg);
+      }
+
+      this.searchingTowns = false;
+    }
+  }
+
+  async searchCitySettings(stateCode: string, cityCode: string, townCode: string){
+    try{
+      this.searchingSettings = true;
+
+      let idUser = localStorage.getItem('idusuario')!;
+      let stateCodeEnc = await this._encService.encrypt(stateCode);
+      let cityCodeEnc = await this._encService.encrypt(cityCode);
+      let townCodeEnc = await this._encService.encrypt(townCode);
+      let settings: CitySettingsResponse = await lastValueFrom(this._sysAdminService.getCitySettings(
+        stateCodeEnc,
+        cityCodeEnc,
+        townCodeEnc,
+        idUser,
+        1
+      ));
+      
+      if(!settings.error){
+        this.citySettings = settings.response;
+        this.citySettingsStr = [];
+
+        this.citySettings.forEach(setting => {
+          this.citySettingsStr.push(`${setting.NOMBRECOLONIA} (${setting.CODIGOCOLONIA})`);
+        });
+
+        this.formGroup.controls['suburb'].enable();
+      }
+
+      this.searchingSettings = false;
+    }catch(error: any){
+      if(error.error == undefined){
+        this._resourcesService.openSnackBar("Ocurrió un error inesperado.");
+      }else if(error.error.msg == undefined){
+        this._resourcesService.openSnackBar("Ocurrió un error inesperado.");
+      }else{
+        this._resourcesService.openSnackBar(error.error.msg);
+      }
+
+      this.searchingSettings = false;
+    }
+  }
+
+  async searchAddressByZipCode(zipCode: string){
+    try{
+      if(!this.enableSearchByZipCode) return;
+
+      this.searchingAddress = true;
+
+      let idUser = localStorage.getItem('idusuario')!;
+      let zipCodeEnc = await this._encService.encrypt(zipCode);
+      let address: AddressByZipCodeResponse = await lastValueFrom(this._sysAdminService.getAddressByZipCode(
+        zipCodeEnc,
+        idUser,
+        1
+      ))
+
+      if(address.error){
+        this._resourcesService.openSnackBar(address.msg);
+      }else{
+        let countryInput = this._document.getElementById('country') as HTMLInputElement;
+        let countryVal = countryInput.value;
+        if(countryVal == '' || countryVal == null || countryVal == undefined){
+          countryInput.value = 'México (MEX)';
+          this.formGroup.controls['country'].setValue('México (MEX)', {
+            emitValue: false,
+          });
+
+          let stateInput = this._document.getElementById('state') as HTMLInputElement;
+          stateInput.value = `${address.response.NOMBRE_ESTADO} (${address.response.CODIGO_ESTADO})`;
+
+          let cityInput = this._document.getElementById('city') as HTMLInputElement;
+          if(address.response.CODIGO_MUNICIPIO == null){
+            cityInput.value = 'Sin municipio';
+          }else{
+            cityInput.value = `${address.response.NOMBRE_MUNICIPIO} (${address.response.CODIGO_MUNICIPIO})`;
+          }
+      
+          let townInput = this._document.getElementById('town') as HTMLInputElement;
+          if(address.response.CODIGO_LOCALIDAD == null){
+            townInput.value = 'Sin localidad';
+          }else{
+            townInput.value = `${address.response.NOMBRE_LOCALIDAD} (${address.response.CODIGO_LOCALIDAD})`;
+          }
+
+          if(address.response.COLONIAS.length > 0){
+            address.response.COLONIAS.forEach(item => {
+              let setting: CitySettings = {
+                CODIGOCOLONIA: item.CODIGO_COLONIA,
+                CODIGOPOSTAL: zipCode,
+                NOMBRECOLONIA: item.NOMBRE_COLONIA,
+              };
+
+              this.citySettings.push(setting);
+              this.citySettingsStr.push(`${item.NOMBRE_COLONIA} (${item.CODIGO_COLONIA})`);
+
+              this.formGroup.controls['suburb'].enable();
+            });
+          }else{
+            let settingInput = this._document.getElementById('setting') as HTMLInputElement;
+            settingInput.value = 'Sin colonia';
+          }
+        }
+      }
+
+      this.searchingAddress = false;
+    }catch(error: any){
+      if(error.error == undefined){
+        this._resourcesService.openSnackBar("Ocurrió un error inesperado.");
+      }else if(error.error.msg == undefined){
+        this._resourcesService.openSnackBar("Ocurrió un error inesperado.");
+      }else{
+        this._resourcesService.openSnackBar(error.error.msg);
+      }
+
+      this.searchingAddress = false;
+    }
   }
 
   async init(){
@@ -150,22 +726,32 @@ export class EmployeeFormComponent implements OnInit {
         this.errorStr = users.msg;
         this.isLoading = false;
       }else{
-        users.response.forEach(user => {
+        for(const user of users.response){
           if(user.ESTATUS == 'Activo'){
+            let completeName = this._functionsService.buildName(user.NOMBRE, user.APEPAT, user.APEMAT);
+            completeName = `${completeName} (${user.IDUSUARIO})`;
+
+            let idEnc = await this._encService.encrypt(user.IDUSUARIO);
+            user.NOMBRE = completeName;
+            user.IDUSUARIO = idEnc;
+            
             this.users.push(user);
           }
-        });
+        }
         
         this.getWorkteams();
       }
     }catch(error: any){
       if(error.error == undefined){
-        this._resourcesService.openSnackBar("Ocurrió un error inesperado.");
+        this.errorStr = "Ocurrió un error inesperado.";
       }else if(error.error.msg == undefined){
-        this._resourcesService.openSnackBar("Ocurrió un error inesperado.");
+        this.errorStr = "Ocurrió un error inesperado.";
       }else{
-        this._resourcesService.openSnackBar(error.error.msg);
+        this.errorStr = error.error.msg;
       }
+
+      this.hasError = true;
+      this.isLoading = false;
     }
   }
 
@@ -175,18 +761,30 @@ export class EmployeeFormComponent implements OnInit {
 
   private createFormGroup() {
     return new FormGroup({
+      userId: new FormControl({ value: '', disabled: false }, Validators.required),
+      workteamId: new FormControl('', Validators.required),
+      contractType: new FormControl('', Validators.required),
+      subcontratistId: new FormControl('', Validators.required),
+      speciality: new FormControl('', Validators.required),
+      foreigner: new FormControl('', Validators.required),
+      RFC: new FormControl({value: '', disabled: true}, [Validators.required, Validators.minLength(12), Validators.maxLength(12), Validators.pattern(new RegExp(/^([A-ZÑ&]{3,4}) ?(?:- ?)?(\d{2}(?:0[1-9]|1[0-2])(?:0[1-9]|[12]\d|3[01])) ?(?:- ?)?([A-Z\d]{2})([A\d])$/))]),
+      tax: new FormControl({value: '', disabled: true}, [Validators.required, Validators.minLength(12), Validators.maxLength(12), Validators.pattern(new RegExp(/^([A-ZÑ&]{3,4}) ?(?:- ?)?(\d{2}(?:0[1-9]|1[0-2])(?:0[1-9]|[12]\d|3[01])) ?(?:- ?)?([A-Z\d]{2})([A\d])$/))]),
+      country: new FormControl({value: '', disabled: true}, Validators.required),
+      federalEntity: new FormControl({value: '', disabled: true}, Validators.required),
+      city: new FormControl({value: '', disabled: true}, Validators.required),
+      town: new FormControl({value: '', disabled: true}),
+      suburb: new FormControl({value: '', disabled: true}, Validators.required),
+      street: new FormControl('', [Validators.required, Validators.maxLength(150)]),
+      exteriorNumber: new FormControl('', [Validators.required, Validators.maxLength(10)]),
+      interiorNumber: new FormControl('', Validators.maxLength(10)),
+      postalCode: new FormControl('', Validators.required),
       documentsAutho: new FormControl(''),
       documentOffice: new FormControl(''),
       documentsCert: new FormControl(''),
-      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),
       contactAddress: new FormControl('', Validators.required),
-      contractType: new FormControl('', Validators.required),
-      speciality: new FormControl('', Validators.required),
-      subcontratistId: new FormControl('', Validators.required),
-      workteamId: new FormControl('', Validators.required),
       updateDocuments: new FormControl(''),
     })
   }
@@ -273,23 +871,28 @@ export class EmployeeFormComponent implements OnInit {
         this.errorStr = workTeams.msg;
         this.isLoading = false;
       }else{
-        workTeams.response.forEach((workteam: any) => {
+        for(const workteam of workTeams.response){
           if(workteam.STATUS == 'Activo'){
+            let idEnc = await this._encService.encrypt(`${workteam.WORKTEAM_ID}`);
+            workteam.WORKTEAM_ID = idEnc;
+            
             this.workteams.push(workteam);
           }
-        });
+        }
 
         this.getSubcontratists();
       }
     }catch(error: any){
-      console.log(error);
       if(error.error == undefined){
-        this._resourcesService.openSnackBar("Ocurrió un error inesperado.");
+        this.errorStr = "Ocurrió un error inesperado.";
       }else if(error.error.msg == undefined){
-        this._resourcesService.openSnackBar("Ocurrió un error inesperado.");
+        this.errorStr = "Ocurrió un error inesperado.";
       }else{
-        this._resourcesService.openSnackBar(error.error.msg);
+        this.errorStr = error.error.msg;
       }
+
+      this.hasError = true;
+      this.isLoading = false;
     }
   }
 
@@ -312,7 +915,6 @@ export class EmployeeFormComponent implements OnInit {
         this.getCountries();
       }
     }catch(error: any){
-      console.log(error);
       if(error.error == undefined){
         this._resourcesService.openSnackBar("Ocurrió un error inesperado.");
       }else if(error.error.msg == undefined){
@@ -332,14 +934,69 @@ export class EmployeeFormComponent implements OnInit {
       this.errorStr = countries.msg;
 
       if(!this.hasError){
+        let mex = countries.response.filter(item => item.COUNTRY_ID == 'MEX');
+        this.countries.push(mex[0]);
+        this.countriesStr.push(`${mex[0].NAME} (${mex[0].COUNTRY_ID})`);
+
+        let mexLada: LadaSelection = {
+          FLAG: [mex[0].NOMECLARUTA_ISO2!].map(countryCodeEmoji)[0],
+          LADA: mex[0].LADA!
+        };
+        
+        this.ladas.push(mexLada);
+        this.ladasStr.push(`${mexLada.FLAG} ${mexLada.LADA}`);
+
+        let usa = countries.response.filter(item => item.COUNTRY_ID == 'USA');
+        this.countries.push(usa[0]);
+        this.countriesStr.push(`${usa[0].NAME} (${usa[0].COUNTRY_ID})`);
+
+        let usaLada: LadaSelection = {
+          FLAG: [usa[0].NOMECLARUTA_ISO2!].map(countryCodeEmoji)[0],
+          LADA: usa[0].LADA!
+        };
+        
+        this.ladas.push(usaLada);
+        this.ladasStr.push(`${usaLada.FLAG} ${usaLada.LADA}`);
+
+        let can = countries.response.filter(item => item.COUNTRY_ID == 'CAN');
+        this.countries.push(can[0]);
+        this.countriesStr.push(`${can[0].NAME} (${can[0].COUNTRY_ID})`);
+
+        let canLada: LadaSelection = {
+          FLAG: [can[0].NOMECLARUTA_ISO2!].map(countryCodeEmoji)[0],
+          LADA: can[0].LADA!
+        };
+        
+        this.ladas.push(canLada);
+        this.ladasStr.push(`${canLada.FLAG} ${canLada.LADA}`);
+        
         countries.response.forEach(country => {
-          console.log(country);
+          if(country.COUNTRY_ID != null && country.COUNTRY_ID != 'MEX' && country.COUNTRY_ID != 'USA' && country.COUNTRY_ID != 'CAN'){
+            this.countries.push(country);
+            this.countriesStr.push(`${country.NAME} (${country.COUNTRY_ID})`);
+
+            try{
+              flag(country.NOMECLARUTA_ISO2!);
+              let hasLada = country.LADA != '';
+
+              if(hasLada){
+                let lada: LadaSelection = {
+                  FLAG: [country.NOMECLARUTA_ISO2!].map(countryCodeEmoji)[0],
+                  LADA: country.LADA!
+                };
+
+                this.ladas.push(lada);
+                this.ladasStr.push(`${lada.FLAG} ${lada.LADA}`);
+              }
+            }catch(error: any){
+              //Saltar país
+            }
+          }
         });
       }
 
       this.isLoading = false;
     }catch(error: any){
-      console.log(error);
       if(error.error == undefined){
         this._resourcesService.openSnackBar("Ocurrió un error inesperado.");
       }else if(error.error.msg == undefined){
@@ -348,11 +1005,6 @@ export class EmployeeFormComponent implements OnInit {
         this._resourcesService.openSnackBar(error.error.msg);
       }
     }
-    /*await lastValueFrom(this._locateService.getCountries()).then(
-      (responseData: any) => {
-        this.countries = responseData.response;
-      }, (error: HttpErrorResponse) => this._resourcesService.checkErrors(error)
-    );*/
   }
 
 
@@ -473,11 +1125,11 @@ export class EmployeeFormComponent implements OnInit {
     }
   }
 
-private enableDocumentButtons(){
-  this.authoButton = false;
-  this.officeButton = false;
-  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];
@@ -630,6 +1282,20 @@ private enableDocumentButtons(){
     this.btnSmall = window.innerWidth <= 1405;
   }
 
+  public changeNationality() {
+    let foreigner = this.formGroup.controls['foreigner'].value;
+    this.formGroup.controls['country'].enable();
+    if(foreigner == 'Si'){
+      this.formGroup.controls['RFC'].disable();
+      this.formGroup.controls['RFC'].setValue(null);
+      this.formGroup.controls['tax'].enable();
+    }else{
+      this.formGroup.controls['tax'].disable();
+      this.formGroup.controls['tax'].setValue(null);
+      this.formGroup.controls['RFC'].enable();
+    }
+  }
+
   get contactName() {
     return this.formGroup.get('contactName')!;
   }