import { Component, ViewChild, Injector, Input, Output, EventEmitter, OnInit, AfterViewInit } from '@angular/core'; import { ModalDirective } from 'ngx-bootstrap'; import { finalize } from 'rxjs/operators'; //import { ClinicsServiceProxy, CreateOrEditClinicDto } from '@shared/service-proxies/service-proxies'; import { ClinicsServiceProxy, CreateOrEditClinicDto, RouteDefinitionsServiceProxy, CreateOrEditRouteDefinitionDto, RouteTypesServiceProxy, RouteScheduleDetailsServiceProxy, RouteScheduleDetailDto, CreateOrEditRouteScheduleDetailDto, CreateOrEditClinicScheduleDto, GetAllRouteDefinitionsInput, RouteTemplateServiceProxy } from '@shared/service-proxies/service-proxies'; import { AddressServiceProxy, CreateAddressInput } from '@shared/service-proxies/service-proxies'; import { EmailServiceProxy, CreateEmailInput } from '@shared/service-proxies/service-proxies'; import { RouteSchedulesServiceProxy, CreateOrEditRouteScheduleDto, GetRouteScheduleSettingsItemDto } from '@shared/service-proxies/service-proxies'; import { AppComponentBase } from '@shared/common/app-component-base'; import * as moment from 'moment-timezone'; import { AddressFormComponent } from '@app/shared/layout/form/address-form.component'; import { AddressFormMainComponent } from '../../../shared/layout/formMain/address-form.component'; import { CommonLookupModalComponent } from '@app/shared/common/lookup/common-lookup-modal.component'; declare var KTWizard: any; declare var $: any; declare var KTApp: any; declare let swal: any; @Component({ selector: 'createOrEditClinicModal', templateUrl: './create-or-edit-clinic-modal.component.html', styleUrls: ['./create-or-edit-clinic-modal.component.less'], }) export class CreateOrEditClinicModalComponent extends AppComponentBase implements OnInit{ @ViewChild('createOrEditModal', { static: true }) modal: ModalDirective; @ViewChild('routeCodeList', {static: true}) routeCodeList: CommonLookupModalComponent; @ViewChild(AddressFormMainComponent, { static: false }) addressForm; @Output() modalSave: EventEmitter = new EventEmitter(); @Output() iconChange = new EventEmitter(); active = false; saving = false; edit = false; change = false; activeTabIndex: number = 0; scheduleInput: CreateOrEditRouteScheduleDetailDto = new CreateOrEditRouteScheduleDetailDto; input: CreateOrEditRouteScheduleDto = new CreateOrEditRouteScheduleDto; clinic: CreateOrEditClinicDto = new CreateOrEditClinicDto(); address: CreateAddressInput = new CreateAddressInput(); schedules: any; routeDefinitions: any; routeTypes: any; designationSelect: any; designation: any; etaMonday: any; etaTuesday: any; etaWednesday: any; etaThursday: any; etaFriday: any; etaSaturday: any; etaSunday: any; routeTypeName :any; cutOffMonday: any; cutOffTuesday: any; cutOffWednesday: any; cutOffThursday: any; cutOffFriday: any; cutOffSaturday: any; cutOffSunday: any; effectivityDate: any; sundayIsAuto: any; mondayIsAuto: any; tuesdayIsAuto: any; wednesdayIsAuto: any; thursdayIsAuto: any; fridayIsAuto: any; saturdayIsAuto: any; clinicId: any; scheduleId: any; showSchedule: boolean; isSaturday: boolean = false; isSunday: boolean = false; showSearch : boolean; txtRouteCodeFilter : string; routeTemplateId : number; sundayIsLTA: any; mondayIsLTA: any; tuesdayIsLTA: any; wednesdayIsLTA: any; thursdayIsLTA: any; fridayIsLTA: any; saturdayIsLTA: any; ltaMonday: any; ltaTuesday: any; ltaWednesday: any; ltaThursday: any; ltaFriday: any; ltaSaturday: any; ltaSunday: any; daySelect: any; IsAuto: any; lta: any; IsLTA: any; eta: any; cutOff: any; routeTypeId: number; scheduleSel = 0; today = new Date(); dayList: Array = [ {id: 1, name: 'Sun'}, {id: 2, name: 'Mon'}, {id: 3, name: 'Tues'}, {id: 4, name: 'Wed'}, {id: 5, name: 'Thur'}, {id: 6, name: 'Fri'}, {id: 7, name: 'Sat'} ]; dayListSel: Array = []; performBlindCount: boolean = false; isDropOff: boolean = false; etaLock: boolean = false; schedSetting: any; schedSettingInput: Array = []; performBlindCountInput: GetRouteScheduleSettingsItemDto = new GetRouteScheduleSettingsItemDto(); isDropOffInput: GetRouteScheduleSettingsItemDto = new GetRouteScheduleSettingsItemDto(); etaLockInput: GetRouteScheduleSettingsItemDto = new GetRouteScheduleSettingsItemDto(); constructor( injector: Injector, private _clinicsServiceProxy: ClinicsServiceProxy, private _routeDefinitionsServiceProxy: RouteDefinitionsServiceProxy, private _routeTemplatesServiceProxy: RouteTemplateServiceProxy, private _routeScheduleDetailsServiceProxy: RouteScheduleDetailsServiceProxy, private _routeSchedulesServiceProxy: RouteSchedulesServiceProxy, private _routeTypesServiceProxy: RouteTypesServiceProxy, private _addressService: AddressServiceProxy, private _emailService: EmailServiceProxy, ) { super(injector); } routeCodeModalInit(){ this.routeCodeList.configure({ title: this.l('Select Route Template'), dataSource: (skipCount: number, maxResultCount: number, filter: string, tenantId?: number, locationId?:number) => { let input = new GetAllRouteDefinitionsInput(); input.filter = filter; input.maxResultCount = maxResultCount; input.skipCount = skipCount; return this._routeDefinitionsServiceProxy.showPagedRouteDefinitionForSearch(input); } }); } getRoute(routeFilter){ this.routeCodeList.show(); this.routeCodeList.filterText = routeFilter; } clearRoute(){ this.showSearch = true; this.txtRouteCodeFilter = ''; this.routeTemplateId = null; this.scheduleInput.routeTemplateId = null; } selectRouteCode(item){ var templateId = item.value; this.getRouteCode(templateId); } getRouteCode(templateId){ this._routeTemplatesServiceProxy.getRouteTemplateById(templateId) .subscribe(result => { this.routeTemplateId = result.routeTemplateId; this.txtRouteCodeFilter = result.routeTemplateName + ' - ' + result.location; this.showSearch = false; this.scheduleInput.routeTemplateId = result.routeTemplateId; this.scheduleInput.routeCode = result.routeTemplateName; }); } //show(schedule?: any, routeScheduleId?: any, clinicId?: any): void { show(schedule?: any, clinicId?: any): void { this.dayList= [ {id: 1, name: 'Sun'}, {id: 2, name: 'Mon'}, {id: 3, name: 'Tues'}, {id: 4, name: 'Wed'}, {id: 5, name: 'Thur'}, {id: 6, name: 'Fri'}, {id: 7, name: 'Sat'} ]; this.dayListSel= []; //this.onRouteChange(); this.today = new Date(); this.showSchedule = true; let that = this; //console.log(clinicId) this.clinicId = Number(clinicId); //this.scheduleId = routeScheduleId; this.cutOffMonday = moment(this.today).toDate(); this.etaMonday = moment(this.today).toDate(); this.mondayIsAuto = null; this.mondayIsLTA = false; this.cutOffTuesday = moment(this.today).toDate(); this.etaTuesday = moment(this.today).toDate(); this.tuesdayIsAuto = null; this.tuesdayIsLTA = false; this.cutOffWednesday = moment(this.today).toDate(); this.etaWednesday = moment(this.today).toDate(); this.wednesdayIsAuto = null; this.wednesdayIsLTA = false; this.cutOffThursday = moment(this.today).toDate(); this.etaThursday = moment(this.today).toDate(); this.thursdayIsAuto = null; this.thursdayIsLTA = false; this.cutOffFriday = moment(this.today).toDate(); this.etaFriday = moment(this.today).toDate(); this.fridayIsAuto = null; this.fridayIsLTA = false; this.cutOffSaturday = moment(this.today).toDate(); this.etaSaturday = moment(this.today).toDate(); this.saturdayIsAuto = null; this.saturdayIsLTA = false; this.cutOffSunday = moment(this.today).toDate(); this.etaSunday = moment(this.today).toDate(); this.sundayIsAuto = null; this.sundayIsLTA = false; this.eta = moment(this.today).toDate(); this.cutOff = moment(this.today).toDate(); this.lta = moment(this.today).toDate(); //#region Schedule Data if (schedule == undefined) { this.scheduleInput.isActive = true; this.scheduleInput.routeTemplateId = null; //this.scheduleInput.routeScheduleId = routeScheduleId; this.showSearch = true; this.txtRouteCodeFilter = ''; this.getAllDropDown(); this.active = true; this.modal.show(); } else { this.getRouteCode(schedule.routeTemplateId) this.today = moment(schedule.today).tz(localStorage.getItem('timeZoneId')).toDate(); this.scheduleInput = schedule; this.scheduleInput.clinicId = Number(clinicId); this.routeTypeName = schedule.routeTypeName; this.routeTypeId = schedule.routeTypeId this.edit = true; this.getAllDropDown(); this.active = true; this.modal.show(); this.eta = this.today; this.cutOff = this.today; this.lta = this.today; if (schedule.willCall == true) { this.designation = "willCall"; } else if (schedule.automatic == true) { this.designation = "auto"; } let dateCutOff = this.today.toDateString() + ' ' + schedule.cutOff; let dateEta = this.today.toDateString() + ' ' + schedule.estimatedTimeOfArrival; if((schedule.mondayIsAuto == 1 && schedule.mondayETATime != "") || (schedule.mondayIsAuto == 0 && schedule.mondayCutOffTime != "")) { this.dayListSel.push(2); const index: number = this.dayList.findIndex(x => x.id == 2); if (index !== -1) { this.dayList.splice(index, 1); } let mondayEta = this.today.toDateString() + ' ' + schedule.mondayETATime; let mondayCutOff = this.today.toDateString() + ' ' + schedule.mondayCutOffTime; this.etaMonday = moment(mondayEta).toDate(); this.cutOffMonday = moment(mondayCutOff).toDate(); this.mondayIsAuto = schedule.mondayIsAuto; let mondayLTA = this.today.toDateString() + ' ' + schedule.mondayLTA; this.mondayIsLTA = schedule.mondayLTA == "" ? false : true; this.ltaMonday = moment(mondayLTA).toDate(); } if((schedule.tuesdayIsAuto == 1 && schedule.tuesdayETATime != "") || (schedule.tuesdayIsAuto == 0 && schedule.tuesdayCutOffTime != "")) { this.dayListSel.push(3); const index: number = this.dayList.findIndex(x => x.id == 3); if (index !== -1) { this.dayList.splice(index, 1); } let tuesdayEta = this.today.toDateString() + ' ' + schedule.tuesdayETATime; let tuesdayCutOff = this.today.toDateString() + ' ' + schedule.tuesdayCutOffTime; this.etaTuesday = moment(tuesdayEta).toDate(); this.cutOffTuesday = moment(tuesdayCutOff).toDate(); this.tuesdayIsAuto = schedule.tuesdayIsAuto; let tuesdayLTA = this.today.toDateString() + ' ' + schedule.tuesdayLTA; this.tuesdayIsLTA = schedule.tuesdayLTA == "" ? false : true; this.ltaTuesday = moment(tuesdayLTA).toDate(); } if((schedule.wednesdayIsAuto == 1 && schedule.wednesdayETATime != "") || (schedule.wednesdayIsAuto == 0 && schedule.wednesdayCutOffTime != "")) { this.dayListSel.push(4); const index: number = this.dayList.findIndex(x => x.id == 4); if (index !== -1) { this.dayList.splice(index, 1); } let wednesdayEta = this.today.toDateString() + ' ' + schedule.wednesdayETATime; let wednesdayCutOff = this.today.toDateString() + ' ' + schedule.wednesdayCutOffTime; this.etaWednesday = moment(wednesdayEta).toDate(); this.cutOffWednesday = moment(wednesdayCutOff).toDate(); this.wednesdayIsAuto = schedule.wednesdayIsAuto; let wednesdayLTA = this.today.toDateString() + ' ' + schedule.wednesdayLTA; this.wednesdayIsLTA = schedule.wednesdayLTA == "" ? false : true; this.ltaWednesday = moment(wednesdayLTA).toDate(); } if((schedule.thursdayIsAuto == 1 && schedule.thursdayETATime != "") || (schedule.thursdayIsAuto == 0 && schedule.thursdayCutOffTime != "")) { this.dayListSel.push(5); const index: number = this.dayList.findIndex(x => x.id == 5); if (index !== -1) { this.dayList.splice(index, 1); } let thursdayEta = this.today.toDateString() + ' ' + schedule.thursdayETATime; let thursdayCutOff = this.today.toDateString() + ' ' + schedule.thursdayCutOffTime; this.etaThursday = moment(thursdayEta).toDate(); this.cutOffThursday = moment(thursdayCutOff).toDate(); this.thursdayIsAuto = schedule.thursdayIsAuto; let thursdayLTA = this.today.toDateString() + ' ' + schedule.thursdayLTA; this.thursdayIsLTA = schedule.thursdayLTA == "" ? false : true; this.ltaThursday = moment(thursdayLTA).toDate(); } if((schedule.fridayIsAuto == 1 && schedule.fridayETATime != "") || (schedule.fridayIsAuto == 0 && schedule.fridayCutOffTime != "")) { this.dayListSel.push(6); const index: number = this.dayList.findIndex(x => x.id == 6); if (index !== -1) { this.dayList.splice(index, 1); } let fridayEta = this.today.toDateString() + ' ' + schedule.fridayETATime; let fridayCutOff = this.today.toDateString() + ' ' + schedule.fridayCutOffTime; this.etaFriday = moment(fridayEta).toDate(); this.cutOffFriday = moment(fridayCutOff).toDate(); this.fridayIsAuto = schedule.fridayIsAuto; let fridayLTA = this.today.toDateString() + ' ' + schedule.fridayLTA; this.fridayIsLTA = schedule.fridayLTA == "" ? false : true; this.ltaFriday = moment(fridayLTA).toDate(); } if((schedule.saturdayIsAuto == 1 && schedule.saturdayETATime != "") || (schedule.saturdayIsAuto == 0 && schedule.saturdayCutOffTime != "")) { this.dayListSel.push(7); const index: number = this.dayList.findIndex(x => x.id == 7); if (index !== -1) { this.dayList.splice(index, 1); } let saturdayEta = this.today.toDateString() + ' ' + schedule.saturdayETATime; let saturdayCutOff = this.today.toDateString() + ' ' + schedule.saturdayCutOffTime; this.etaSaturday = moment(saturdayEta).toDate(); this.cutOffSaturday = moment(saturdayCutOff).toDate(); this.saturdayIsAuto = schedule.saturdayIsAuto; let saturdayLTA = this.today.toDateString() + ' ' + schedule.saturdayLTA; this.saturdayIsLTA = schedule.saturdayLTA == "" ? false : true; this.ltaSaturday = moment(saturdayLTA).toDate(); } if((schedule.sundayETATime != "" && schedule.sundayIsAuto == 1) || (schedule.sundayCutOffTime != "" && schedule.sundayIsAuto == 0)) { this.dayListSel.push(1); const index: number = this.dayList.findIndex(x => x.id == 1); if (index !== -1) { this.dayList.splice(index, 1); } let sundayEta = this.today.toDateString() + ' ' + schedule.sundayETATime; let sundayCutOff = this.today.toDateString() + ' ' + schedule.sundayCutOffTime; this.etaSunday = moment(sundayEta).toDate(); this.cutOffSunday = moment(sundayCutOff).toDate(); this.sundayIsAuto = schedule.sundayIsAuto; let sundayLTA = this.today.toDateString() + ' ' + schedule.sundayLTA; this.sundayIsLTA = schedule.sundayLTA == "" ? false : true; this.ltaSunday = moment(sundayLTA).toDate(); } // this.eta = dateEta; // this.cutOff = dateCutOff; this.effectivityDate = moment(schedule.effectivityDate).toDate(); for (var val of schedule.scheduleSetting) { /*if(val.code == 'PerformBlindCount') { if(val.value == 'true') { this.performBlindCount = true; } else { this.performBlindCount = false; } } else if(val.code == 'IsDropOff') { if(val.value == 'true') { this.isDropOff = true; } else { this.isDropOff = false; } } else if(val.code == 'EtaLock') { if(val.value == 'true') { this.etaLock = true; } else { this.etaLock = false; } }*/ if(val.code == 'EtaLock') { if(val.value == 'true') { this.etaLock = true; } else { this.etaLock = false; } } } } //#endregion this.daySelect = this.dayList.length > 0 ? this.dayList[0].id : 0; this.IsAuto = 1; } ngAfterViewInit() { } onRouteChange(){ let that = this; $(document).ready(function () { $('#routeDefinition').on('select2:select', function (e) { var data = e.params.data; let selectedRouteDefintion = that.routeDefinitions.find(i => i.routeTemplateId == data.id); //that.routeDefinitions.map(({ routeTemplateName }) => data.id); that.scheduleInput.routeTemplateId = selectedRouteDefintion.routeTemplateId; that.scheduleInput.routeCode = selectedRouteDefintion.routeTemplateName; //alert(selectedRouteDefintion.routeTemplateId +" - " + selectedRouteDefintion.routeTemplateName); that.scheduleInput.routeTypeId = selectedRouteDefintion.routeDefinition.routeTypeId; that.getAllDropDown(); }); }); } ngOnInit() { let maxcount = 5000; let that = this; this._routeDefinitionsServiceProxy.getAll( undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, maxcount ).subscribe(result => { that.routeDefinitions = result.items; }); this.routeCodeModalInit(); } ngOnChanges() { } save(): void { this.spinnerService.show(); this.scheduleInput.effectivityDate = moment(this.effectivityDate).tz(localStorage.getItem('timeZoneId')); this.scheduleInput.locationId = Number(localStorage.getItem('operatingLocationId')); this.scheduleInput.clinicId = this.clinicId; this.scheduleInput.routeTypeId = this.routeTypeId; // if (this.scheduleId == undefined) { // this.input.clinicId = this.clinicId; // this.scheduleInput.createRouteSchedule = this.input; // } if (this.scheduleInput.dateEtaLocked != null || this.scheduleInput.dateEtaLocked != undefined) { this.scheduleInput.dateEtaLocked = moment.utc(this.scheduleInput.dateEtaLocked); } if (this.scheduleInput.oorRate == null) { this.scheduleInput.oorRate = 0; } if (this.scheduleInput.serviceTime == null) { this.scheduleInput.oorRate = 0; } //#region Schedule var etaMoment = moment(this.eta).tz(localStorage.getItem('timeZoneId')); var mondayEtaMoment = moment(this.etaMonday).tz(localStorage.getItem('timeZoneId')); var tuesdayEtaMoment = moment(this.etaTuesday).tz(localStorage.getItem('timeZoneId')); var wednesdayEtaMoment = moment(this.etaWednesday).tz(localStorage.getItem('timeZoneId')); var thursdayEtaMoment = moment(this.etaThursday).tz(localStorage.getItem('timeZoneId')); var fridayEtaMoment = moment(this.etaFriday).tz(localStorage.getItem('timeZoneId')); var saturdayEtaMoment = moment(this.etaSaturday).tz(localStorage.getItem('timeZoneId')); var sundayEtaMoment = moment(this.etaSunday).tz(localStorage.getItem('timeZoneId')); var cutOffMoment = moment(this.cutOff).tz(localStorage.getItem('timeZoneId')); var mondayCutOffMoment = moment(this.cutOffMonday).tz(localStorage.getItem('timeZoneId')); var tuesdayCutOffMoment = moment(this.cutOffTuesday).tz(localStorage.getItem('timeZoneId')); var wednesdayCutOffMoment = moment(this.cutOffWednesday).tz(localStorage.getItem('timeZoneId')); var thursdayCutOffMoment = moment(this.cutOffThursday).tz(localStorage.getItem('timeZoneId')); var fridayCutOffMoment = moment(this.cutOffFriday).tz(localStorage.getItem('timeZoneId')); var saturdayCutOffMoment = moment(this.cutOffSaturday).tz(localStorage.getItem('timeZoneId')); var sundayCutOffMoment = moment(this.cutOffSunday).tz(localStorage.getItem('timeZoneId')); this.scheduleInput.estimatedTimeOfArrival = etaMoment; // this.scheduleInput.etaTime = new Date(etaMoment.format()).toLocaleTimeString('en-US', { // hour12: true, // hour: "numeric", // minute: "numeric", // second: "numeric" // }) as any; // this.scheduleInput.cutOff = new Date(cutOffMoment.format()).toLocaleTimeString('en-US', { // hour12: true, // hour: "numeric", // minute: "numeric", // second: "numeric" // }) as any; this.scheduleInput.mondayETATime = new Date(mondayEtaMoment.format()).toLocaleTimeString('en-US', { hour12: true, hour: "numeric", minute: "numeric", second: "numeric" }) as any; this.scheduleInput.tuesdayETATime = new Date(tuesdayEtaMoment.format()).toLocaleTimeString('en-US', { hour12: true, hour: "numeric", minute: "numeric", second: "numeric" }) as any; this.scheduleInput.wednesdayETATime = new Date(wednesdayEtaMoment.format()).toLocaleTimeString('en-US', { hour12: true, hour: "numeric", minute: "numeric", second: "numeric" }) as any; this.scheduleInput.thursdayETATime = new Date(thursdayEtaMoment.format()).toLocaleTimeString('en-US', { hour12: true, hour: "numeric", minute: "numeric", second: "numeric" }) as any; this.scheduleInput.fridayETATime = new Date(fridayEtaMoment.format()).toLocaleTimeString('en-US', { hour12: true, hour: "numeric", minute: "numeric", second: "numeric" }) as any; this.scheduleInput.saturdayETATime = new Date(saturdayEtaMoment.format()).toLocaleTimeString('en-US', { hour12: true, hour: "numeric", minute: "numeric", second: "numeric" }) as any; this.scheduleInput.sundayETATime = new Date(sundayEtaMoment.format()).toLocaleTimeString('en-US', { hour12: true, hour: "numeric", minute: "numeric", second: "numeric" }) as any; // this.scheduleInput.cutOffTime = new Date(cutOffMoment.format()).toLocaleTimeString('en-US', { // hour12: true, // hour: "numeric", // minute: "numeric", // second: "numeric" // }) as any; this.scheduleInput.mondayCutOffTime = new Date(mondayCutOffMoment.format()).toLocaleTimeString('en-US', { hour12: true, hour: "numeric", minute: "numeric", second: "numeric" }) as any; this.scheduleInput.tuesdayCutOffTime = new Date(tuesdayCutOffMoment.format()).toLocaleTimeString('en-US', { hour12: true, hour: "numeric", minute: "numeric", second: "numeric" }) as any; this.scheduleInput.wednesdayCutOffTime = new Date(wednesdayCutOffMoment.format()).toLocaleTimeString('en-US', { hour12: true, hour: "numeric", minute: "numeric", second: "numeric" }) as any; this.scheduleInput.thursdayCutOffTime = new Date(thursdayCutOffMoment.format()).toLocaleTimeString('en-US', { hour12: true, hour: "numeric", minute: "numeric", second: "numeric" }) as any; this.scheduleInput.fridayCutOffTime = new Date(fridayCutOffMoment.format()).toLocaleTimeString('en-US', { hour12: true, hour: "numeric", minute: "numeric", second: "numeric" }) as any; this.scheduleInput.saturdayCutOffTime = new Date(saturdayCutOffMoment.format()).toLocaleTimeString('en-US', { hour12: true, hour: "numeric", minute: "numeric", second: "numeric" }) as any; this.scheduleInput.sundayCutOffTime = new Date(sundayCutOffMoment.format()).toLocaleTimeString('en-US', { hour12: true, hour: "numeric", minute: "numeric", second: "numeric" }) as any; this.scheduleInput.sundayIsAuto = this.sundayIsAuto; this.scheduleInput.saturdayIsAuto = this.saturdayIsAuto; this.scheduleInput.fridayIsAuto = this.fridayIsAuto; this.scheduleInput.thursdayIsAuto = this.thursdayIsAuto; this.scheduleInput.wednesdayIsAuto = this.wednesdayIsAuto; this.scheduleInput.tuesdayIsAuto = this.tuesdayIsAuto; this.scheduleInput.mondayIsAuto = this.mondayIsAuto; //#endregion //#region Lta if (!this.sundayIsLTA || this.sundayIsAuto == 1 || this.sundayIsAuto == 'null' || this.sundayIsAuto == undefined) { this.scheduleInput.sundayLTA = null; }else{ var sundayLTAMoment = moment(this.ltaSunday).tz(localStorage.getItem('timeZoneId')); this.scheduleInput.sundayLTA = new Date(sundayLTAMoment.format()).toLocaleTimeString('en-US', { hour12: true, hour: "numeric", minute: "numeric", second: "numeric" }) as any; } if (!this.saturdayIsLTA || this.saturdayIsAuto == 1 || this.saturdayIsAuto == 'null' || this.saturdayIsAuto == undefined) { this.scheduleInput.saturdayLTA = null; }else{ var saturdayLTAMoment = moment(this.ltaSaturday).tz(localStorage.getItem('timeZoneId')); this.scheduleInput.saturdayLTA = new Date(saturdayLTAMoment.format()).toLocaleTimeString('en-US', { hour12: true, hour: "numeric", minute: "numeric", second: "numeric" }) as any; } if (!this.fridayIsLTA || this.fridayIsAuto == 1 || this.fridayIsAuto == 'null' || this.fridayIsAuto == undefined) { this.scheduleInput.fridayLTA = null; }else{ var fridayLTAMoment = moment(this.ltaFriday).tz(localStorage.getItem('timeZoneId')); this.scheduleInput.fridayLTA = new Date(fridayLTAMoment.format()).toLocaleTimeString('en-US', { hour12: true, hour: "numeric", minute: "numeric", second: "numeric" }) as any; } if (!this.thursdayIsLTA || this.thursdayIsAuto == 1 || this.thursdayIsAuto == 'null' || this.thursdayIsAuto == undefined) { this.scheduleInput.thursdayLTA = null; }else{ var thursdayLTAMoment = moment(this.ltaThursday).tz(localStorage.getItem('timeZoneId')); this.scheduleInput.thursdayLTA = new Date(thursdayLTAMoment.format()).toLocaleTimeString('en-US', { hour12: true, hour: "numeric", minute: "numeric", second: "numeric" }) as any; } if (!this.wednesdayIsLTA || this.wednesdayIsAuto == 1 || this.wednesdayIsAuto == 'null' || this.wednesdayIsAuto == undefined) { this.scheduleInput.wednesdayLTA = null; }else{ var wednesdayLTAMoment = moment(this.ltaWednesday).tz(localStorage.getItem('timeZoneId')); this.scheduleInput.wednesdayLTA = new Date(wednesdayLTAMoment.format()).toLocaleTimeString('en-US', { hour12: true, hour: "numeric", minute: "numeric", second: "numeric" }) as any; } if (!this.tuesdayIsLTA || this.tuesdayIsAuto == 1 || this.tuesdayIsAuto == 'null' || this.tuesdayIsAuto == undefined) { this.scheduleInput.tuesdayLTA = null; }else{ var tuesdayLTAMoment = moment(this.ltaTuesday).tz(localStorage.getItem('timeZoneId')); this.scheduleInput.tuesdayLTA = new Date(tuesdayLTAMoment.format()).toLocaleTimeString('en-US', { hour12: true, hour: "numeric", minute: "numeric", second: "numeric" }) as any; } if (!this.mondayIsLTA || this.mondayIsAuto == 1 || this.mondayIsAuto == 'null' || this.mondayIsAuto == undefined) { this.scheduleInput.mondayLTA = null; }else{ var mondayLTAMoment = moment(this.ltaMonday).tz(localStorage.getItem('timeZoneId')); this.scheduleInput.mondayLTA = new Date(mondayLTAMoment.format()).toLocaleTimeString('en-US', { hour12: true, hour: "numeric", minute: "numeric", second: "numeric" }) as any; } //#endregion this.etaLockInput.code = 'EtaLock'; this.etaLockInput.value = this.etaLock.toString(); //this.isDropOffInput.code = 'IsDropOff'; //this.isDropOffInput.value = this.isDropOff.toString(); //this.performBlindCountInput.code = 'PerformBlindCount'; //this.performBlindCountInput.value = this.performBlindCount.toString(); if(this.edit == true) { this.scheduleInput.scheduleSetting.push(this.etaLockInput); //this.scheduleInput.scheduleSetting.push(this.isDropOffInput); //this.scheduleInput.scheduleSetting.push(this.performBlindCountInput); } else { let etaLockInputCreate = {code: 'EtaLock', value: this.etaLock.toString()}; //let isDropOffInputCreate = {code: 'IsDropOff', value: this.etaLock.toString()}; //let performBlindCountInputCreate = {code: 'PerformBlindCount', value: this.etaLock.toString()}; this.schedSettingInput[0] = this.etaLockInput; //this.schedSettingInput[1] = this.isDropOffInput; //this.schedSettingInput[2] = this.performBlindCountInput; this.scheduleInput.scheduleSetting = this.schedSettingInput; } this._routeScheduleDetailsServiceProxy.createOrEdit(this.scheduleInput) .pipe(finalize(() => { this.saving = false; })) .subscribe(() => { this.notify.info(this.l('SavedSuccessfully')); this.modalSave.emit(null); this.close(); this.spinnerService.hide(); }); } close(): void { this.eta = null; this.showSchedule = false; this.effectivityDate = null; this.etaSunday = null; this.cutOffSunday = null; this.etaMonday = null; this.cutOffMonday = null; this.etaTuesday = null; this.cutOffTuesday = null; this.etaWednesday = null; this.cutOffWednesday = null; this.etaThursday = null; this.cutOffThursday = null; this.etaFriday = null; this.cutOffFriday = null; this.etaSaturday = null; this.cutOffSaturday = null; this.cutOff = null; this.scheduleInput = new CreateOrEditRouteScheduleDetailDto; this.edit = false; //this.scheduleInput = null; this.active = false; this.modalSave.emit(null); this.modal.hide(); } getAllDropDown() { let maxcount = 1000; let that = this; jQuery(document).ready(function () { $('.kt-select2').select2(); $('.select2-container').css('width', '100%'); }); this._routeDefinitionsServiceProxy.getAllRouteTypeForLookupTable( undefined, undefined, undefined, undefined, maxcount ).subscribe(result => { that.routeTypes = result.items; }); } clickLTA(field: string, val: boolean){ if(val){ this[field] = false; } if(!val){ this[field] = true; } } addSchedule(scheduleSel){ this.dayList.push(scheduleSel); } checkDay(day: number){ if(this.dayListSel.find(x => x == day) != undefined){ return true; }else{ return false; } } addField(day){ if(day == 1){ let sundayEta = this.eta; let sundayCutOff = this.cutOff; this.etaSunday = sundayEta; this.cutOffSunday = sundayCutOff; this.sundayIsAuto = this.IsAuto; let sundayLTA = this.IsLTA == false ? undefined : this.lta; this.sundayIsLTA = this.IsLTA; this.ltaSunday = this.IsLTA == false ? undefined : moment(sundayLTA).toDate(); } if(day == 2){ let mondayEta = this.eta; let mondayCutOff = this.cutOff; this.etaMonday = mondayEta; this.cutOffMonday = mondayCutOff; this.mondayIsAuto = this.IsAuto; let mondayLTA = this.IsLTA == false ? undefined : this.lta; this.mondayIsLTA = this.IsLTA; this.ltaMonday = this.IsLTA == false ? undefined : moment(mondayLTA).toDate(); } if(day == 3){ let tuesdayEta = this.eta; let tuesdayCutOff = this.cutOff; this.etaTuesday = tuesdayEta; this.cutOffTuesday = tuesdayCutOff; this.tuesdayIsAuto = this.IsAuto; let tuesdayLTA = this.IsLTA == false ? undefined : this.lta; this.tuesdayIsLTA = this.IsLTA; this.ltaTuesday = this.IsLTA == false ? undefined : moment(tuesdayLTA).toDate(); } if(day == 4){ let wednesdayEta = this.eta; let wednesdayCutOff = this.cutOff; this.etaWednesday = wednesdayEta; this.cutOffWednesday = wednesdayCutOff; this.wednesdayIsAuto = this.IsAuto; let wednesdayLTA = this.IsLTA == false ? undefined : this.lta; this.wednesdayIsLTA = this.IsLTA; this.ltaWednesday = this.IsLTA == false ? undefined : moment(wednesdayLTA).toDate(); } if(day == 5){ let thursdayEta = this.eta; let thursdayCutOff = this.cutOff; this.etaThursday = thursdayEta; this.cutOffThursday = thursdayCutOff; this.thursdayIsAuto = this.IsAuto; let thursdayLTA = this.IsLTA == false ? undefined : this.lta; this.thursdayIsLTA = this.IsLTA; this.ltaThursday = this.IsLTA == false ? undefined : moment(thursdayLTA).toDate(); } if(day == 6){ let fridayEta = this.eta; let fridayCutOff = this.cutOff; this.etaFriday = fridayEta; this.cutOffFriday = fridayCutOff; this.fridayIsAuto = this.IsAuto; let fridayLTA = this.IsLTA == false ? undefined : this.lta; this.fridayIsLTA = this.IsLTA; this.ltaFriday = this.IsLTA == false ? undefined : moment(fridayLTA).toDate(); } if(day == 7){ let saturdayEta = this.eta; let saturdayCutOff = this.cutOff; this.etaSaturday = saturdayEta; this.cutOffSaturday = saturdayCutOff; this.saturdayIsAuto = this.IsAuto; let saturdayLTA = this.IsLTA == false ? undefined : this.lta; this.saturdayIsLTA = this.IsLTA; this.ltaSaturday = this.IsLTA == false ? undefined : moment(saturdayLTA).toDate(); } this.dayListSel.push(day); const index: number = this.dayList.findIndex(x => x.id == day); if (index !== -1) { this.dayList.splice(index, 1); } this.daySelect = this.dayList.length > 0 ? this.dayList[0].id : 0; this.IsAuto = 1; } removeField(day){ let name: string = ''; if(day == 1){ this.sundayIsAuto = null; this.sundayIsLTA = ''; this.ltaSunday = ''; name = 'Sun'; } if(day == 2){ this.mondayIsAuto = null; this.mondayIsLTA = '';; this.ltaMonday = '';; name = 'Mon'; } if(day == 3){ this.tuesdayIsAuto = null; this.tuesdayIsLTA = '';; this.ltaTuesday = '';; name = 'Tue'; } if(day == 4){ this.wednesdayIsAuto = null; this.wednesdayIsLTA = '';; this.ltaWednesday = '';; name = 'Wed'; } if(day == 5){ this.thursdayIsAuto = null; this.thursdayIsLTA = '';; this.ltaThursday = '';; name = 'Thur'; } if(day == 6){ this.fridayIsAuto = null; this.fridayIsLTA = '';; this.ltaFriday = '';; name = 'Fri'; } if(day == 7){ this.saturdayIsAuto = null; this.saturdayIsLTA = '';; this.ltaSaturday = '';; name = 'Sat'; } let dd = {id : day, name : name}; this.dayList.push(dd); const index: number = this.dayListSel.findIndex(x => x == day); if (index !== -1) { this.dayListSel.splice(index, 1); } this.daySelect = this.dayList.length > 0 ? this.dayList[0].id : 0; this.IsAuto = 1; } }