import { Component, EventEmitter, Injector, ViewChild, Output, Input, HostListener, ElementRef, Renderer2 } from '@angular/core'; import { AppComponentBase } from '@shared/common/app-component-base'; import { WillCallServiceServiceProxy, Route4MeServiceProxy, GetClinicResultDto, GetRouteByClinicResultDto, CreateCallinInput,SaveNotesInput, GetClinicSchedResultDto, CreateOptimizeInputDto, OrderServiceProxy ,CancelOrderInputDto,GetEmailConfirmationDto, GetClinicInputForWillCall, NameValueDto, GetAutomaticSchedulesResultDto, EmailConfirmationInput, GetCustomerProfileDto} from '@shared/service-proxies/service-proxies'; import { ModalDirective, parseDate } from 'ngx-bootstrap'; import { PrimengTableHelper } from 'shared/helpers/PrimengTableHelper'; import { finalize, catchError } from 'rxjs/operators'; import * as jquery from 'jquery'; import * as moment from 'moment-timezone'; import { AutoComplete } from 'primeng/autocomplete'; import { TabsetComponent } from 'ngx-bootstrap'; import { LazyLoadEvent } from 'primeng/components/common/lazyloadevent'; import { Paginator } from 'primeng/components/paginator/paginator'; import { Table } from 'primeng/components/table/table'; import { throwError } from 'rxjs'; import { AppConsts } from '@shared/AppConsts'; import { load } from '@progress/kendo-angular-intl'; import { CommonLookupModalComponent } from '@app/shared/common/lookup/common-lookup-modal.component'; import { Router } from '@angular/router'; import { AppLocalizationService } from '@app/shared/common/localization/app-localization.service'; export enum KEY_CODE { UP_ARROW = 38, DOWN_ARROW = 40, TAB_KEY = 9, ENTER = 13 } @Component({ templateUrl: './customer-callin.component.html', selector: 'customerCallInModal', styleUrls: ['./customer-callin.component.less'], providers : [WillCallServiceServiceProxy, OrderServiceProxy, Route4MeServiceProxy] }) export class CustomerCallInModalComponent extends AppComponentBase { @ViewChild('clinicsList', {static: true}) clinicsList: CommonLookupModalComponent; @ViewChild('callInModal', {static: false}) modal: ModalDirective; @Output() modalSave: EventEmitter = new EventEmitter(); @ViewChild('autoCompleteObject', {static: false}) private autoCompleteObject: AutoComplete; @ViewChild('callInTab', { static: false }) staticTabs: TabsetComponent; @ViewChild('searchTab', { static: false }) searchTabs: TabsetComponent; @ViewChild('dataTable', { static: true }) dataTable: Table; @ViewChild('paginator', { static: true }) paginator: Paginator; @ViewChild('testyo', { static: true }) element: ElementRef; @ViewChild('dataList', { static: true }) dataList: ElementRef; clinicNameFilter = ''; clinicAccountFilter = ''; clinicAddressFilter = ''; isShown = false; isShow = false; txtfilterAcctNumber:string = ""; txtfilterClinicName:string = ""; txtfilterAddress:string = ""; txtfilterOrderId:string = ""; messageResult = ""; test = 1; active = false; @Input() isActive: number; hide: boolean = false; txtFilter: any; clinics: GetClinicResultDto[]; routes: GetClinicSchedResultDto[]; routesAuto: GetClinicSchedResultDto[]; _isAuto: boolean = false; _isAutoSelected: boolean = false; autoStop: GetClinicSchedResultDto[]; CreateCallinInput = new CreateCallinInput(); SaveNotesInput = new SaveNotesInput(); updateOrderInput = new CancelOrderInputDto(); OptimizeInput = new CreateOptimizeInputDto(); emailInput = new GetEmailConfirmationDto() clinicId:number =0; routeSchedDetailId:number; routeTypeCode: string; routeCode:string; routeId:number; hide_callin: boolean = true; currently_selected: string; eta_selected: string; load_date: Date; cut_off: string; day: string; required: any; date: any; clinicName: string; accountNumber: string; address: string; phoneNumber:string; requestType: string; requestor: string; specialInstructions:string; email:string; orderRouteCode:string; routeEta:string; tabSearch: number; orderId : string; isCancel:boolean = false; confirmationNumber : string; checkedList = []; multipleCheck: Array = []; confirmation: any; clinicBackground: string; clinicInfo:string; nextNum: number = 0; canGoBack: boolean = false; eta_GoBack: any; txtfilter: string; eta: Date; loadDate: string; etaAuto: Date; getAccountNumber: string; location: string; request =[ this._appLocalizationService.l('SchedulePickUp'), this._appLocalizationService.l('CancelPickup') ]; pastMidnight = false; showroutType :boolean = true; dropDownOne : string; @Input('inputs') inputs: { locationId: number; loadDate: any; } = {}; searchByAccountNumber : boolean = false; searchByOrderId : boolean = false; showDropDown = false; showDropDownClinicName = false; showDropDownAddress = false; counter:number = 0; counterClinicName:number = 0; counterAddress:number = 0; spInstructions : boolean = true; txtRequestorName: string = null; constructor( injector: Injector, private renderer: Renderer2, private _callIn : WillCallServiceServiceProxy, private _order : OrderServiceProxy, private _route4me : Route4MeServiceProxy, private router: Router, private _appLocalizationService: AppLocalizationService, ) { super(injector); this.renderer.listen('window', 'click',(e:Event)=>{ /** * Only run when toggleButton is not clicked * If we don't check this, all clicks (even on the toggle button) gets into this * section which in the result we might never see the menu open! * And the menu itself is checked here, and it's where we check just outside of * the menu and button the condition abbove must close the menu */ // if(e.target !== this.dataList){ this.showDropDown=false; this.showDropDownClinicName = false; this.showDropDownAddress = false; // } }); } show(profile:GetCustomerProfileDto) { // console.log(this._appLocalizationService.l('SchedulePickUp')); // console.log(this.request); this.active = true; this.clinicId = profile.clinicId; this.clinicName = profile.clinicName; this.accountNumber = profile.accountNo; this.address = profile.addressLine1 +"," +profile.addressLine2 +"," +profile.city +"," +profile.state +"," +profile.postalCode; this.phoneNumber = profile.phone; this.email = profile.email; this.getRoutesSched(this.clinicId,undefined, this.isCancel); this.requestor = profile.name +" " +profile.surname; this.modal.show(); } ngOnInit(){ this.currently_selected = 'NONE'; //this.hide_callin = false; moment.tz.setDefault(localStorage.getItem('timeZoneId')); moment().tz(localStorage.getItem('timeZoneId')).format(); this.clinicBackground = AppConsts.appBaseUrl + '/assets/common/images/clinic_bg.jpg'; this.clinicInfo = "Collect the information to search for the account before scheduling or cancelling a pickup"; this.dropDownOne = this._appLocalizationService.l('SchedulePickUp') //Select Clinic this.initClinicList(); } onKeydown(event, txtRequestorName:string) { if (event.key === "Enter" && txtRequestorName != null && this.clinicId != 0) { this.loadNext(1); } } onKeyDownAction(event: KeyboardEvent):void { if(this.showDropDown == true){ if (event.keyCode === KEY_CODE.DOWN_ARROW) { this.counter = (this.counter === this.clinics.length-1)?this.counter:++this.counter; this.checkHighlight(this.counter); } if (event.keyCode === KEY_CODE.UP_ARROW) { this.counter = (this.counter === 0)?this.counter:--this.counter; this.checkHighlight(this.counter); } if (event.keyCode === KEY_CODE.ENTER) { this.searchClinic(this.clinics[this.counter].id); } } } checkHighlight(currentItem):boolean{ if(this.counter === currentItem) return true; else return false; } onKeyDownActionClinicName(event: KeyboardEvent):void { if(this.showDropDownClinicName == true){ if (event.keyCode === KEY_CODE.DOWN_ARROW) { this.counterClinicName = (this.counterClinicName === this.clinics.length-1)?this.counterClinicName:++this.counterClinicName; this.checkHighlightCllinicName(this.counterClinicName); } if (event.keyCode === KEY_CODE.UP_ARROW) { this.counterClinicName = (this.counterClinicName === 0)?this.counterClinicName:--this.counterClinicName; this.checkHighlightCllinicName(this.counterClinicName); } if (event.keyCode === KEY_CODE.ENTER) { this.searchClinic(this.clinics[this.counterClinicName].id); } } } checkHighlightCllinicName(currentItem):boolean{ if(this.counterClinicName === currentItem) return true; else return false; } onKeyDownActionAddress(event: KeyboardEvent):void { if(this.showDropDownClinicName == true){ if (event.keyCode === KEY_CODE.DOWN_ARROW) { this.counterAddress = (this.counterAddress === this.clinics.length-1)?this.counterAddress:++this.counterAddress; this.checkHighlightCllinicName(this.counterClinicName); } if (event.keyCode === KEY_CODE.UP_ARROW) { this.counterAddress = (this.counterAddress === 0)?this.counterAddress:--this.counterAddress; this.checkHighlightCllinicName(this.counterAddress); } if (event.keyCode === KEY_CODE.ENTER) { this.searchClinic(this.clinics[this.counterAddress].id); } } } checkHighlightAddress(currentItem):boolean{ if(this.counterAddress === currentItem) return true; else return false; } searchForClinic(): void { this._callIn.getClinicForCallback(this.txtFilter,undefined) .subscribe(result => { this.clinics = result; }); } getSelected(event):void{ this.clinicId = event.id; } getClinicWithRoute(OrderId:string){ this.viewClinicByOrderId(OrderId); } searchClinic(clinicId:number): void { this.spinnerService.show(); this._callIn.getClinicDetails(undefined,clinicId) .pipe( catchError((err) => { this.spinnerService.hide(); this.clinicName = ""; this.accountNumber = ""; this.address = ""; this.phoneNumber = ""; this.email = ""; return throwError(err); }) ) .subscribe(result => { if(result[0].message != null){ this.message.error(result[0].message); this.spinnerService.hide(); } else{ this.spinnerService.hide(); this.clinicId = result[0].id; this.clinicName = result[0].name; this.accountNumber = result[0].accountNumber; this.address = result[0].address; this.phoneNumber = result[0].phone; this.email = result[0].email; this.showDropDown = false; this.showDropDownClinicName =false; this.showDropDownAddress = false; this.clinics = null; this.txtFilter = result[0].name; this.orderRouteCode = null; this.routeEta = null; this.getAutoStop(); this.getRoutesSched(this.clinicId,undefined, this.isCancel); } }); $('#txtRequestorName').focus(); } selectClinic(item:NameValueDto):void{ if(this.searchByOrderId){ var orderId = item.value; this.getClinicWithRoute(orderId); } else{ let clinicId = parseInt(item.value); this.searchClinic(clinicId); } this.clinicsList.clinic = ""; } initClinicList(){ this.clinicsList.configure({ title: this.l('Select Clinic'), dataSource: (skipCount: number, maxResultCount: number, filter: string, tenantId?: number, locationId?:number) => { let input = new GetClinicInputForWillCall(); input.filter = filter; input.maxResultCount = maxResultCount; input.skipCount = skipCount; input.tenantId = tenantId; if(this.searchByAccountNumber){ return this._callIn.showClinicsListByAccountNumber(input); } else if (this.searchByOrderId){ return this._callIn.showClinicsListByOrderId(input); } else{ input.tabSearch = this.tabSearch; return this._callIn.showClinicsList(input); } } }); } tabChanged(tabChangeEvent: any): void { alert(tabChangeEvent); } viewClinicByAcctNumber(txtfilter:string, clinicId:number){ this.spinnerService.show(); this.searchByAccountNumber = true; this.searchByOrderId = false; this.initClinicList(); this._callIn.getClinicByAccountNumber(txtfilter,undefined) .pipe( catchError((err) => { this.spinnerService.hide(); this.clinicName = ""; this.accountNumber = ""; this.address = ""; this.phoneNumber = ""; this.email = ""; return throwError(err); }) ) .subscribe(result => { var fresult = JSON.parse(JSON.stringify(result)); if(fresult[0].message != null){ this.message.error(fresult[0].message); this.spinnerService.hide(); } else{ if(Object.keys(fresult).length > 1) { this.clinics = result; // this.showDropDown = true; // this.checkHighlight(0); this.clinicsList.tenantId = null; this.clinicsList.clinic = "Clinic"; this.clinicsList.show(); this.clinicsList.filterText = txtfilter; } else{ this.clinicId = result[0].id; if(clinicId == 0){ this.getRoutesSched(this.clinicId,undefined, this.isCancel); } this.clinicName = result[0].name; this.accountNumber = result[0].accountNumber; this.address = result[0].address; this.phoneNumber = result[0].phone; this.showDropDown = false; this.clinics = null; this.txtFilter = result[0].name; if(result[0].email != null){ this.email = result[0].email; } else{ this.email = ''; } $('#txtRequestorName').focus(); this.getAutoStop(); } //console.log(this.clinics.length); this.orderRouteCode = null; this.routeEta = null; if(clinicId != 0){ this.spinnerService.hide(); } } }); // setTimeout(function (){ // $('#clinicAccountNumberInfo').focus(); // }, 1000); } viewClinicByClinicName(txtfilter:string, clinicId:number){ this.spinnerService.show(); this.searchTabs this.searchByAccountNumber = false; this.searchByOrderId = false; this.initClinicList(); this._callIn.getClinicByClinicName(txtfilter,undefined) .pipe( catchError((err) => { this.spinnerService.hide(); return throwError(err); }) ) .subscribe(result => { var fresult = JSON.parse(JSON.stringify(result)); if(fresult[0].message != null){ this.message.error(fresult[0].message); this.spinnerService.hide(); } else{ if(Object.keys(fresult).length > 1) { this.clinics = result; this.clinicsList.tenantId = null; this.clinicsList.clinic = "Clinic"; this.clinicsList.show(); this.clinicsList.filterText = txtfilter; this.tabSearch = 1; } else{ this.clinicId = result[0].id; if(clinicId == 0){ this.getRoutesSched(this.clinicId,undefined, this.isCancel); } this.clinicName = result[0].name; this.accountNumber = result[0].accountNumber; this.address = result[0].address; this.phoneNumber = result[0].phone; this.showDropDown = false; this.clinics = null; this.txtFilter = result[0].name; if(result[0].email != null){ this.email = result[0].email; } else{ this.email = ''; } $('#txtRequestorName').focus(); this.getAutoStop(); } //console.log(this.clinics.length); this.orderRouteCode = null; this.routeEta = null; if(clinicId != 0){ this.spinnerService.hide(); } } }); // setTimeout(function (){ // $('#clinicNameInfo').focus(); // }, 1000); } viewClinic(txtfilter:string, clinicId:number){ this.spinnerService.show(); this.searchByAccountNumber = false; this.searchByOrderId = false; this.initClinicList(); this._callIn.getClinicForCallIn(txtfilter,undefined) .pipe( catchError((err) => { this.spinnerService.hide(); return throwError(err); }) ) .subscribe(result => { var fresult = JSON.parse(JSON.stringify(result)); if(fresult[0].message != null){ this.message.error(fresult[0].message); this.spinnerService.hide(); } else{ if(Object.keys(fresult).length > 1) { this.clinics = result; this.clinicsList.tenantId = null; this.clinicsList.clinic = "Clinic"; this.clinicsList.show(); this.clinicsList.filterText = txtfilter; this.tabSearch = 2; } else{ this.clinicId = result[0].id; if(clinicId == 0){ this.getRoutesSched(this.clinicId,undefined, this.isCancel); } this.clinicName = result[0].name; this.accountNumber = result[0].accountNumber; this.address = result[0].address; this.phoneNumber = result[0].phone; this.showDropDown = false; this.clinics = null; this.txtFilter = result[0].name; if(result[0].email != null){ this.email = result[0].email; } else{ this.email = ''; } $('#txtRequestorName').focus(); this.getAutoStop(); } //console.log(this.clinics.length); this.orderRouteCode = null; this.routeEta = null; if(clinicId != 0){ this.spinnerService.hide(); } } }); // setTimeout(function (){ // $('#clinicAddressInfo').focus(); // }, 1000); } viewClinicByOrderId(txtfilter: string){ this.spinnerService.show(); this.searchByAccountNumber = false; this.searchByOrderId = true; this.initClinicList(); this._callIn.getClinicByOrderId(txtfilter,undefined) .pipe( catchError((err) => { this.spinnerService.hide(); return throwError(err); }) ) .subscribe(result => { var fresult = JSON.parse(JSON.stringify(result)); if(Object.keys(fresult).length > 1) { //this.clinics = result; this.clinicsList.tenantId = null; this.clinicsList.clinic = "Clinic"; this.clinicsList.show(); this.clinicsList.filterText = txtfilter; } else{ this.clinicId = result[0].clinicId; this.clinicName = result[0].name; this.accountNumber = result[0].accountNumber; this.address = result[0].address; this.phoneNumber = result[0].phone; this.showDropDown = false; this.clinics = null; this.txtFilter = result[0].name; this.orderRouteCode = result[0].routeCode; this.routeEta = result[0].eta.toString(); if(result[0].email != null){ this.email = result[0].email; } else{ this.email = ''; } $('#txtRequestorName').focus(); window.open('/app/sprintship/controller-order-details/' + result[0].orderId, '_blank'); } //console.log(this.clinics.length); this.spinnerService.hide(); this.getAutoStop(); // this.showDropDownAddress = true; // this.checkHighlight(0); }); // setTimeout(function (){ // $('#clinicAddressInfo').focus(); // }, 1000); } onClickedOutside(e: Event) { this.showDropDown = false; this.showDropDownClinicName =false; this.showDropDownAddress = false; } getRoutesSched(clinicId : number, timeId: string, isCancel : boolean) { this.spinnerService.show(); //let loadDate = moment.tz(localStorage.getItem('loadDate')); this._callIn.getRoutesSchedule(clinicId, undefined, undefined, undefined, undefined, isCancel, undefined) .pipe( catchError((err) => { this.spinnerService.hide(); this.staticTabs.tabs[0].active = false; return throwError(err); }) ) .subscribe(result => { var fresult = JSON.parse(JSON.stringify(result)); this.routes = fresult; if(Object.keys(fresult).length > 0) { this._isAuto = false; if(fresult[0].message != null && fresult[0].routeScheduleCount != 0){ this.message.error(fresult[0].message); this.spinnerService.hide(); this.staticTabs.tabs[0].active = false; } else{ var that = this; that.currently_selected = fresult[0].routeCode; that.cut_off = fresult[0].date; that.routeSchedDetailId = fresult[0].id; that.routeTypeCode = fresult[0].routeTypeCode; that.confirmationNumber = fresult[0].confirmationNumber; //that.eta_selected = moment(fresult[0].eta).tz(localStorage.getItem('timeZoneId')).format('hh:mm A'); that.eta_selected = fresult[0].etaConvert; that.eta = fresult[0].etaUtc; that.day = fresult[0].day; that.location = fresult[0].location; that.pastMidnight = fresult[0].pastMidnight; that.loadDate = fresult[0].loadDate; this.staticTabs.tabs[0].active = true; this.nextNum = 1; this.messageResult = fresult[0].message; } this.spinnerService.hide(); this.routesAuto = null; } this.spinnerService.hide(); } ); $('#txtRequestorName').focus(); // var that = this; // that.clinicName = this.txtFilter.name; // that.accountNumber = this.txtFilter.accountNumber; // that.address = this.txtFilter.address; // that.phoneNumber = ""; // that.email = this.txtFilter.email; } clinicChange(routeCode: string,routeSchedDetailId: number, routeKey : string, etaUtc: Date, etaConvertedSelected : string, cutOff: string , confirmationNumber: string, day:string , location: string, pastMidnight: boolean, isAuto : boolean, loadDate: string, eta: Date) { this._isAutoSelected = isAuto; this.currently_selected = routeCode; this.routeSchedDetailId = routeSchedDetailId; this.etaAuto = eta; this.eta = etaUtc; this.eta_selected = etaConvertedSelected; this.cut_off = cutOff; this.confirmationNumber = confirmationNumber; this.day = day; this.location = location; this.pastMidnight = pastMidnight; this.loadDate = loadDate; $("input[name='options']").click(function() { $(".itemCode").removeClass("kt-radio kt-radio--bold kt-radio--success").addClass("kt-radio kt-radio--bold"); if ($(this).is(":checked")) { $(this).parent().addClass("kt-radio kt-radio--bold kt-radio--success"); } }); } changeTab(type: string){ $(".lblPickup input[name='pickups']").click(function() { $(".lblPickup").removeClass("activePickup"); if ($(this).is(":checked")) { $(this).parent().addClass("activePickup"); } }); } onItemChange(event , type){ let timeId = localStorage.getItem('timeZoneId'); let clinicID = this.clinicId; this.dropDownOne = type; if(event.target.checked) { if(this.dropDownOne == this._appLocalizationService.l('CancelPickup')) { this.isCancel = true; this.getRoutesSched(clinicID, timeId, this.isCancel); } else{ this.isCancel = false; this.getRoutesSched(clinicID, timeId, this.isCancel); } // alert(" Value is : " + type ); } } showHide(){ $("#txtInstructions").toggle(100); this.isShow = !this.isShow; if(this.isShow == false){ $('.txtInstructions').removeClass("active"); } else{ $('.txtInstructions').addClass("active"); } setTimeout(function (){ $('#notes').focus(); }, 1000); } showHideAutosPickup(){ $("#automaticSched").toggle(200); } saveNote(): void{ let specialInstructions = (document.getElementById('notes')).value; if(specialInstructions == null || specialInstructions == ''){ this.message.info("Please input special instruction to proceed.","Automatic Schedules"); } else{ this.SaveNotesInput.clinicId = this.clinicId; this.SaveNotesInput.orderId = this.routeSchedDetailId; this.SaveNotesInput.routeScheduleDetailId = this.routeSchedDetailId; this.SaveNotesInput.date = moment(this.etaAuto); this.SaveNotesInput.specialInstructions = specialInstructions; //this.SaveNotesInput.location = this.location; this._callIn.saveNote(this.SaveNotesInput) .pipe( catchError((err) => { this.spinnerService.hide(); return throwError(err); }) ) .subscribe((result) => { this.staticTabs.tabs[1].active = true; if(result.orderId == 0){ this.confirmation = null; } else{ this.confirmation = result.orderId; } // this.requestor = (document.getElementById('txtRequestorName')).value; this.specialInstructions = specialInstructions; this.dropDownOne = this._appLocalizationService.l('SchedulePickUp') this.spinnerService.hide(); this.notify.info(this.l('SavedSuccessfully')); }); } } save(): void { this.spinnerService.show(); if(this.isCancel == true ) { let specialInstructions = (document.getElementById('notes')).value; this.updateOrderInput.confirmationNumber = this.checkedList; this.updateOrderInput.specialInstructions = specialInstructions; this._order.cancelOrder(this.updateOrderInput) .pipe( catchError((err) => { this.spinnerService.hide(); return throwError(err); }) ) .subscribe((result) => { //this.confirmation = result.confirmationNumber; // if(result[0].message != null){ // this.message.error(result[0].message); // this.spinnerService.hide(); // } this.staticTabs.tabs[1].active = true; // this.requestor = (document.getElementById('txtRequestorName')).value; this.specialInstructions = specialInstructions; this.dropDownOne = this._appLocalizationService.l('SchedulePickUp'); this.checkedList = []; this.spinnerService.hide(); this.modalSave.emit(null); this.notify.info(this.l('SavedSuccessfully')); }); } else{ //alert(this.cut_off); this.CreateCallinInput.clinicId = this.clinicId; this.CreateCallinInput.routeScheduleDetailId = this.routeSchedDetailId; //this.CreateCallinInput.goBack = this.canGoBack; this.CreateCallinInput.etaUtc = moment(this.eta); this.CreateCallinInput.requestorName = this.txtRequestorName; this.CreateCallinInput.specialInstructions = (document.getElementById('notes')).value; this.CreateCallinInput.specialInstructionsVisibleToDriver = this.spInstructions; this.CreateCallinInput.pastMidnight = this.pastMidnight; this._callIn.createOrder(this.CreateCallinInput) .pipe( catchError((err) => { this.spinnerService.hide(); return throwError(err); }) ) .subscribe((result) => { this.confirmation = result.confirmationCode; this.staticTabs.tabs[1].active = true; // this.requestor = (document.getElementById('txtRequestorName')).value; this.specialInstructions = (document.getElementById('notes')).value; this.dropDownOne = this._appLocalizationService.l('SchedulePickUp'); this.modalSave.emit(null); this.spinnerService.hide(); this.notify.info(this.l('SavedSuccessfully')); }); } } onShown(): void { $('.kt-select2').select2(); } close(): void { this.active = false; this.clinicId = 0; this.modal.hide(); this.txtFilter = ""; this.clinicName = ""; this.accountNumber = ""; this.address = ""; this.phoneNumber = ""; this.email = ""; this.currently_selected = "NONE"; this.isCancel = false; this.nextNum = 0; this.day = ""; this.loadDate = ""; $('#txtRequestorName').val(''); $('#txtfilter').val(''); $("#test").trigger("reset"); this.txtfilterAcctNumber = ''; this.txtfilterClinicName = ''; this.txtfilterAddress = ''; this.txtfilterOrderId = ''; this.orderRouteCode = ""; this.routeEta = ""; this._isAutoSelected = false; this.dropDownOne = this._appLocalizationService.l('SchedulePickUp'); this.multipleCheck = []; this.multipleCheck.length = 0; this.confirmation = ""; } clear(): void{ this.clinicId = 0; this.txtFilter = ""; this.clinicName = ""; this.accountNumber = ""; this.address = ""; this.phoneNumber = ""; this.email = ""; this.currently_selected = "NONE"; this.isCancel = false; this.nextNum = 0; this.day = ""; this.orderRouteCode = ""; this.routeEta = ""; this._isAutoSelected = false; this.loadDate = ""; this.txtfilterAcctNumber = ''; this.txtfilterClinicName = ''; this.txtfilterAddress = ''; this.txtfilterOrderId = ''; this.multipleCheck = []; this.multipleCheck.length = 0; $('#txtRequestorName').val(''); $('#txtfilterAcctNumber').val(''); $('#txtfilterClinicName').val(''); $('#txtfilterAddress').val(''); $('#txtfilter').val(''); this.confirmation = ""; } onAfterShow(event) { this.autoCompleteObject.focusInput(); this.autoCompleteObject.onKeyUp = null; } loadNext(next : number){ this.requestor = (document.getElementById('txtRequestorName')).value; this.specialInstructions = (document.getElementById('notes')).value; if(this.clinicId == 0 && (this.txtfilterAcctNumber == ''|| this.txtfilterAcctNumber != '') && this.searchTabs.tabs[0].active == true){ this.viewClinicByAcctNumber(this.txtfilterAcctNumber, this.clinicId); } else if(this.clinicId == 0 && (this.txtfilterClinicName == '' || this.txtfilterClinicName != '') && this.searchTabs.tabs[1].active == true){ this.viewClinicByClinicName(this.txtfilterClinicName, this.clinicId); } else if(this.clinicId == 0 && (this.txtfilterAddress == '' || this.txtfilterAddress !== '') && this.searchTabs.tabs[2].active == true){ this.viewClinic(this.txtfilterAddress, this.clinicId); } else{ this.getRoutesSched(this.clinicId,undefined, this.isCancel); } $(".itemCode").focus(); //this.nextNum = next; } loadPrev(next : number){ this.staticTabs.tabs[next].active = true; this.nextNum = next; } loadNew(next : number){ this.currently_selected = "NONE"; this.staticTabs.tabs[next].active = true; this.isCancel = false; this.dropDownOne = this._appLocalizationService.l('SchedulePickUp'); this.checkedList = []; this.multipleCheck = []; this.multipleCheck.length = 0; this.confirmation = ""; this._isAutoSelected = false; this.loadDate = ""; this.nextNum = 0; this.day = ""; this.requestor = ""; this.txtfilterAcctNumber = ''; this.txtfilterClinicName = ''; this.txtfilterAddress = ''; if(this.isShow == true){ $("#txtInstructions").toggle(100); $('.txtInstructions').removeClass("active"); this.isShow = false; } this.getRoutesSched(this.clinicId,undefined, this.isCancel); } // selectOption(type: string): void{ // let timeId = localStorage.getItem('timeZoneId'); // let clinicID = this.clinicId; // this.dropDownOne = type; // if(this.dropDownOne == "Cancel Pickup") // { // this.isCancel = true; // this.getRoutesSched(clinicID, timeId, this.isCancel); // } // else{ // this.isCancel = false; // this.getRoutesSched(clinicID, timeId, this.isCancel); // } // } onCheckboxChange(option, event) { let obj = new EmailConfirmationInput(); if(event.target.checked) { this.checkedList.push(option.confirmationNumber); obj.confirmationCode = option.confirmationNumber; obj.routeCode = option.routeCode; obj.location = option.location; obj.day = option.day; obj.eta = option.etaConvert; obj.cutOff = option.date; obj.clinicId = this.clinicId; obj.isCancel = this.isCancel; obj.email = this.email; obj.requestor = this.requestor; obj.loadDate = option.loadDate; this.multipleCheck.push(obj); //$(".chkCancel").addClass("kt-checkbox kt-checkbox--bold kt-checkbox--success"); } else { for( var i=0 ; i < this.routes.length; i++) { if(this.checkedList[i] == option.confirmationNumber) { this.checkedList.splice(i,1); } if(this.multipleCheck[i].confirmationCode == option.confirmationNumber) { this.multipleCheck.splice(i,1); } } //$(".chkCancel").removeClass("kt-checkbox kt-checkbox--bold kt-checkbox--success").addClass("kt-checkbox kt-checkbox--bold"); } } // onChangeDriverNotes(event){ // if(event.target.checked) { // this.spInstructions = true; // $(".spInstructions").addClass("kt-checkbox kt-checkbox--bold kt-checkbox--success"); // } // else{ // $(".spInstructions").removeClass("kt-checkbox kt-checkbox--bold kt-checkbox--success").addClass("kt-checkbox kt-checkbox--bold"); // } // } sendEmailConfirmation(email: string): void{ this.spinnerService.show(); if(this.isCancel == true){ this.emailInput.emailConfirmationInput = this.multipleCheck; } else{ let obj = new EmailConfirmationInput(); obj.confirmationCode = this.confirmation; obj.routeCode = this.currently_selected; obj.location = this.location; obj.day = this.day; obj.eta = this.eta_selected; obj.cutOff = this.cut_off; obj.clinicId = this.clinicId; obj.isCancel = this.isCancel; obj.email = this.email; obj.requestor = this.requestor; obj.loadDate = this.loadDate; this.multipleCheck.push(obj); this.emailInput.emailConfirmationInput = this.multipleCheck; } this._callIn.createEmailConfirmation(this.emailInput) .subscribe((result) => { this.spinnerService.hide(); this.notify.info(this.l('EmailSent')); this.multipleCheck = []; }); } @HostListener('document:keydown', ['$event']) onKeydownSelect(event: KeyboardEvent): void { let clinicID = this.clinicId; if (event.altKey && event.key.toLowerCase() ==="s" && this.nextNum == 1) { this.isCancel = false; this.getRoutesSched(clinicID, undefined, this.isCancel); this.getAutoStop(); this.dropDownOne = this._appLocalizationService.l('SchedulePickUp'); } else if (event.altKey && event.key.toLowerCase() ==="c" && this.nextNum == 1) { this.isCancel = true; this.getRoutesSched(clinicID, undefined, this.isCancel); this.dropDownOne = this._appLocalizationService.l('CancelPickup'); } else if((event.keyCode == 38 || event.keyCode == 40) && this.nextNum ==1){ $(".itemCode").focus(); } } getAutoStop() { let isCancel = false; //let loadDate = moment.tz(localStorage.getItem('loadDate')); this._callIn.getRoutesAutoSchedule(this.clinicId, undefined, undefined, undefined, undefined, isCancel, undefined) .pipe( catchError((err) => { this.spinnerService.hide(); return throwError(err); }) ) .subscribe((result) => { var fresult = JSON.parse(JSON.stringify(result)); this.autoStop = fresult; }); } PickUpActivity(){ if(this.clinicId == 0){ this.notify.error(this.l('No Clinic found.')); }else{ window.open('/app/main/laboratory/clinic-history/' + this.clinicId, '_blank'); //window.location.href = "/app/main/laboratory/clinic-history/" + this.clinicId; } } PickUpSchedule(){ if(this.clinicId == 0){ this.notify.error(this.l('No Clinic found.')); }else{ window.open('/app/main/laboratory/clinics-schedule/' + this.clinicId, '_blank'); //window.location.href = "/app/main/laboratory/clinics-schedule/" + this.clinicId; } } }