import { Component, ViewChild, Injector, Output, EventEmitter} from '@angular/core'; import { ModalDirective } from 'ngx-bootstrap'; import { AppComponentBase } from '@shared/common/app-component-base'; import { WillCallServiceServiceProxy, CreateOrderIncidentDto } from '@shared/service-proxies/service-proxies'; import * as moment from 'moment'; @Component({ selector: 'missedPickuUpModal', templateUrl: './missed-pickup.component.html' }) export class MissedPickUpModalComponent extends AppComponentBase { @ViewChild('missedPickuUpModal', { static: true }) modal: ModalDirective; @Output() modalSave: EventEmitter = new EventEmitter(); active = false; data: any; userData: any; managers: any; email: any; managerId: any; order: any; id = 0; mId = 0; content: string; incidentDate: any = new Date(); time: any = new Date(); routeDate: string; routeCode: string; constructor( injector: Injector, private _willcallService: WillCallServiceServiceProxy, ) { super(injector); } show(record?, id?): void { this.active = true; this.data = record; this.id = id; this._willcallService.getModalMissedPickUp(id, record.contactId).subscribe(result => { this.userData = result; this.email = result.email; this.mId = result.managerId; this.routeDate = result.routeDate; this.routeCode = result.routeCode; this._willcallService.getManagers() .subscribe(result=>{ this.managers = result; }) }); this.modal.show(); }; onShown(): void { $('.kt-select2').select2(); document.getElementById('contentInput').focus(); } close(): void { this.active = false; this.modal.hide(); } save(){ let createOrderIncidents = new CreateOrderIncidentDto({ orderId: this.id, incidentTypeId: undefined, geocodeId: 0, content: this.content, incidentDate: moment.utc(moment(this.incidentDate).format('YYYY-MM-DD') + ' ' + moment(this.time).format('HH:mm:ss')), managerId : Number((document.getElementById('Manager')).value), email : this.email, id: undefined }); this._willcallService.createMissedPickup(createOrderIncidents).subscribe(result=>{ this.notify.info(this.l('EmailSent')); this.active = false; this.content = ""; this.modalSave.emit(null); this.close(); }); } }