Skip to content

Commit

Permalink
Renovación de matrícula Foto y Firma
Browse files Browse the repository at this point in the history
  • Loading branch information
Fabio-Ramirez committed Jul 18, 2024
1 parent b1f7bd3 commit 5e37afe
Show file tree
Hide file tree
Showing 3 changed files with 67 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,11 @@ export class FirmasProfesionalComponent implements OnInit {
public firmaAdmin = null;
loading;

constructor(private ng2ImgMax: Ng2ImgMaxService, public sanitizer: DomSanitizer, private plex: Plex, private _profesionalService: ProfesionalService) {
constructor(
private ng2ImgMax: Ng2ImgMaxService,
public sanitizer: DomSanitizer,
private plex: Plex,
private _profesionalService: ProfesionalService) {
}

ngOnInit() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ import {
OnInit,
ViewChild
} from '@angular/core';
import { catchError } from 'rxjs/operators';
import { of } from 'rxjs';
import { DomSanitizer } from '@angular/platform-browser';
// Plex
import {
Plex
Expand Down Expand Up @@ -54,21 +57,46 @@ export class FormacionGradoDetalleComponent implements OnInit {
public campoBaja = false;
public fechaTemporal = null;
public motivoTemporal = null;
public urlFirma = null;
public foto = null;
public tieneFoto = false;
public matriculaEdit = null;
public firmaSave = null;
public fotoSave = null;

constructor(
private _profesionalService: ProfesionalService,
private _numeracionesService: NumeracionMatriculasService,
private _pdfUtils: PDFUtils,
public sanitizer: DomSanitizer,
private plex: Plex,
public auth: Auth) { }




ngOnInit() {
this.hoy = new Date();
this.compruebaBajas();
this.esSupervisor = this.auth.check('matriculaciones:supervisor:aprobar');
this.esSupervisor = this.auth?.check('matriculaciones:supervisor:aprobar');
if (this.formacion.matriculacion && this.formacion.renovacionOnline?.estado !== 'rechazada') {

this._profesionalService.getProfesionalFirma({ id: this.profesional.id, matricula: this.formacion.matriculacion[this.formacion.matriculacion?.length - 1].matriculaNumero }).pipe(catchError(() => of(null))).subscribe(resp => {
const base64Data = 'data:image/jpeg;base64,' + resp;
this.urlFirma = resp.length ? this.sanitizer.bypassSecurityTrustResourceUrl(base64Data) : null;
this.firmaSave = base64Data.replace(/^data:image\/[a-z]+;base64,/, '');
});

this._profesionalService.getProfesionalFoto({
id: this.profesional.id,
matricula: this.formacion.matriculacion[this.formacion.matriculacion?.length - 1].matriculaNumero
})
.pipe(catchError(() => of(null))).subscribe(resp => {
if (resp) {
const base64Data = 'data:image/jpeg;base64,' + resp;
this.foto = this.sanitizer.bypassSecurityTrustResourceUrl('data:image/jpeg;base64,' + resp);
this.fotoSave = base64Data.replace(/^data:image\/[a-z]+;base64,/, '');
this.tieneFoto = true;
}
});
}
}

cerrar() {
Expand Down Expand Up @@ -135,7 +163,9 @@ export class FormacionGradoDetalleComponent implements OnInit {
} else {
this.profesional.formacionGrado[this.index].matriculacion.push(oMatriculacion);
}
this.matriculaEdit = matriculaNumero;
this.actualizar();

this.plex.toast('success', 'Se aprobó con exito la renovacion!', 'informacion', 2000);
}, () => {
this.plex.toast('danger', 'Se rechazó la renovacion de matrícula!', 'informacion', 2000);
Expand Down Expand Up @@ -177,13 +207,14 @@ export class FormacionGradoDetalleComponent implements OnInit {
this.edicionRechazo = true;
}
opcionRechazarRenovacion() {
const op = (this.formacion.matriculacion && this.formacion.matriculado && !this.formacion.papelesVerificados && this.formacion.renovacionOnline
&& this.formacion.renovacionOnline.estado === 'pendiente');
const op = (this.formacion.matriculacion && !this.formacion.papelesVerificados
&& this.formacion.renovacionOnline?.estado === 'pendiente');
return (op);
}

opcionPapelesVerificados() {
const op = (this.formacion.matriculacion && !this.formacion.papelesVerificados && this.formacion.renovacion === true);
const op = (this.formacion.matriculacion && !this.formacion.papelesVerificados
&& this.formacion.renovacion === true && this.formacion.renovacionOnline?.estado !== 'rechazada');
return op;

}
Expand Down Expand Up @@ -277,8 +308,11 @@ export class FormacionGradoDetalleComponent implements OnInit {
};
this.profesional.formacionGrado[this.index] = this.formacion;
this.profesional.formacionGrado[this.index].matriculado = false;

this.firmaSave = null;
this.fotoSave = null;
this.matriculaEdit = this.formacion.matriculacion[this.formacion.matriculacion?.length - 1].matriculaNumero;
}

this.actualizar();
this.plex.toast('success', 'Se rechazo la renovacion de matricula!', 'informacion', 2000);
this.edicionRechazo = false;
Expand Down Expand Up @@ -331,11 +365,16 @@ export class FormacionGradoDetalleComponent implements OnInit {

actualizar() {
const cambio = {
'idProfesional': this.profesional.id,
'op': 'updateEstadoGrado',
'data': this.profesional.formacionGrado,
'agente': this.auth.usuario.nombreCompleto
'agente': this.auth.usuario.nombreCompleto,
'matricula': this.matriculaEdit,
'firmaP': this.firmaSave,
'img': this.fotoSave
};
this._profesionalService.patchProfesional(this.profesional.id, cambio).subscribe((data) => {

this.profesional = data;
});

Expand All @@ -355,6 +394,4 @@ export class FormacionGradoDetalleComponent implements OnInit {
}
}



}
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,20 @@
</plex-label>
<plex-label titulo="Fecha de egreso" subtitulo="{{profesional | edad}}"></plex-label>
</plex-detail>
<div *ngIf="opcionRechazarRenovacion() && esSupervisor">
<plex-title titulo="Documentación a Verificar" size="sm"></plex-title>
<div class="row">
<div class="col-6">
<label for="filePicker">Firma</label>
<img *ngIf='urlFirma' [src]="urlFirma" height="100px" />
</div>
<div class="col-6">
<label for="filePicker">Foto</label>
<img *ngIf='foto' [src]="foto" height="100px" />
</div>
</div>
</div>

<div class="row mt-3">
<div class="col-12">
<plex-accordion>
Expand Down

0 comments on commit 5e37afe

Please sign in to comment.