import { Component, ViewChild, Injector, Output, EventEmitter, Input} from '@angular/core'; import { ModalDirective } from 'ngx-bootstrap'; import { finalize } from 'rxjs/operators'; import { PostalCodesServiceProxy, CreateOrEditPostalCodeDto, OrderStatusTypeServiceProxy, OrderStatusServiceProxy, OrderStatusDto, CreateOrderStatusInput, ControllerOrderPackagesListServiceProxy, AddBatchOrderStatusInput } from '@shared/service-proxies/service-proxies'; import { AppComponentBase } from '@shared/common/app-component-base'; import {CalendarModule} from 'primeng/calendar'; import * as moment from 'moment'; import { ControllerOrderPackageDetailComponent } from '../order-packages/order-packages-detail.component'; import { ViewOrderStatusComponent } from './view-order-status.component' declare var $: any; @Component({ selector: 'addBatchOrderStatusModal', templateUrl: './add-order-status-modal.component.html', styleUrls: ['./add-order-status-modal.component.less'] }) export class AddBatchOrderStatusModalComponent extends AppComponentBase { @ViewChild('createOrEditModal', { static: true }) modal: ModalDirective; @Input() orderId:number; @Output() modalSave: EventEmitter = new EventEmitter(); @Output() statusEvent: EventEmitter = new EventEmitter(); @Input() myFunction:Function active = false; saving = false; orderStatusTypes: any value:Date orderStatusNote:string orderStatusLongitude: any orderStatusLatitude : any orderStatusTime:any orderIds:any DateObject = Date currentDate = moment().format("MM/DD/YYYY HH:mm"); orderArray:Array = []; batchOrders:any statusBoolean=false; orderStatus: CreateOrderStatusInput = new CreateOrderStatusInput(); constructor( injector: Injector, private _orderStatusAppService : OrderStatusServiceProxy, private _orderStatusTypeAppService : OrderStatusTypeServiceProxy, private _orderPackageListAppService : ControllerOrderPackagesListServiceProxy, ) { super(injector); } // orderStatusUpdate(get: boolean){ // this.statusEvent.emit(get) // } ngOnInit(){ this.getOrderStatusType(); } passedData($event){ this.orderIds = $event console.log($event) } onShown(): void{ $('.kt-select2').select2(); } show(): void { this.active = true; this.modal.show(); this.orderStatus.note = null // this.orderStatus.orderStatusTypeId = null this.orderStatusLongitude = null this.orderStatusLatitude=null this.orderStatusTime=this.currentDate console.log("array"+this.orderIds) console.log(this.orderIds.length) } getOrderStatusType(): void{ this._orderPackageListAppService.getOrderStatusTypeList() .pipe(finalize(() => this.spinnerService.hide())).subscribe(result => { this.orderStatusTypes=result.items; }); } save(): void { this.saving = true; if(moment.utc(this.orderStatusTime) != moment.utc(this.currentDate)){ this.orderStatus.time = moment.utc(this.orderStatusTime) } else{ this.orderStatus.time = moment.utc(this.currentDate); } console.log(this.orderStatus.time) this.orderStatus.orderStatusTypeId=Number((document.getElementById('OrderStatusType')).value); // this.orderStatus.note=String((document.getElementById('OrderStatusNote')).value); this.orderStatus.latitude=Number((document.getElementById('OrderStatusLatitude')).value); this.orderStatus.longitude=Number((document.getElementById('OrderStatusLongitude')).value); this.orderStatus.orderId = this.orderIds; console.log(this.orderStatus) this.orderArray = []; for(let index = 0; index { this.saving = false;})) .subscribe(() => { this.modalSave.emit(null); this.notify.info(this.l('SavedSuccessfully')); this.close(); }); } close(): void { this.active = false; this.modal.hide(); } }