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, SendEmailToCustomerDto, OrderServiceProxy } from '@shared/service-proxies/service-proxies'; import * as moment from 'moment'; @Component({ selector: 'sendEmail', templateUrl: './sendorderdetail-modal.html' }) export class HistorySendEmailComponent extends AppComponentBase { @ViewChild('sendEmail', { 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; cc: string; constructor( injector: Injector, private _willcallService: WillCallServiceServiceProxy, private _orderService: OrderServiceProxy, ) { super(injector); } show(record?, id?): void { this.active = true; this.data = record; this.id = id; this.modal.show(); this.email = record.email; }; onShown(): void { $('.kt-select2').select2(); document.getElementById('Email').focus(); } close(): void { this.active = false; this.modal.hide(); } save(){ this.spinnerService.show(); let sendInput = new SendEmailToCustomerDto({ orderId: this.id, emailFrom: undefined, emailTo: this.email, emailCc: this.cc }); this._orderService.sendOrderDetailToCustomer(sendInput) .subscribe(result=>{ this.spinnerService.hide(); this.notify.info(this.l('EmailSent')); this.active = false; this.email = ""; this.cc = ""; this.close(); }) } }