import { Component, Injector, ViewChild, ViewEncapsulation } from '@angular/core'; import { ActivatedRoute, Router } from '@angular/router'; import { appModuleAnimation } from '@shared/animations/routerTransition'; import { AppComponentBase } from '@shared/common/app-component-base'; import { OrderServiceProxy, OrderListDto, LocationServiceProxy, LocationListDto, UpdateOrderV2Input, DestinationDetailListDto, ContactListDto, AddressListDto, TagTypeListDto, TagListDto, EmailListDto, PhoneListDto, PostalCodeInAddressListDto, NoteListDto, OrderPackageListDto, ShippingPackageListDto, TagTypeServiceProxy, PostalCodeServiceProxy, ShippingPackageServiceProxy, OrderPackageServiceProxy, CreateOrderV2Input, PickupDetailInput, ContactInput, AddressInput, DestinationDetailInput, PackageInput, PostalCodeListDto, CreateNoteInput, CreateEmailInput, CreatePhoneInput, PackagesServiceProxy, CreateOrderApiInput, TagInput, CreateOrderDefaultInput, AddressTypeServiceProxy, CreatePostalCodeInput, CreateOrEditAddressDto, ContactAddressCheckerInput, CreateOnDemandOrderInput, OrderTypesServiceProxy, GetOrderTypeForViewDto } from '@shared/service-proxies/service-proxies'; import { LazyLoadEvent } from 'primeng/components/common/lazyloadevent'; import { Paginator } from 'primeng/components/paginator/paginator'; import { Table } from 'primeng/components/table/table'; import { finalize } from 'rxjs/operators'; import * as moment from 'moment'; import { CreateOrderModalComponent } from './create-order-modal.component'; import { PrimengTableHelper } from '@shared/helpers/PrimengTableHelper'; import * as _ from 'lodash'; import {Location} from '@angular/common'; import { AddressFormComponent } from '@app/shared/layout/form/address-form.component'; import { GooglePlaceDirective } from 'ngx-google-places-autocomplete'; import { Address } from 'ngx-google-places-autocomplete/objects/address'; import { ILatLng, DirectionsMapDirective } from '@app/sprintship/fleet-management/driver-proximities/driver-proximities.directive'; import { GoogleMapsAPIWrapper, MapsAPILoader } from '@agm/core'; import { result } from 'lodash'; import { XmlHttpRequestHelper } from '@shared/helpers/XmlHttpRequestHelper'; import { AppConsts } from '@shared/AppConsts'; import { isUndefined } from 'util'; declare var KTWizard: any; declare var $: any; declare var KTBootstrapDaterangepicker: any; declare let swal: any; declare var google: any; @Component({ templateUrl: './update-order.component.html', encapsulation: ViewEncapsulation.None, animations: [appModuleAnimation()], styleUrls: ['create-order.component.less'], }) export class UpdateOrderComponent extends AppComponentBase { @ViewChild(AddressFormComponent, {static:false}) addressForm; saving = false; // createInput: CreateOrderV2Input = new CreateOrderV2Input(); createInput: CreateOrderDefaultInput = new CreateOrderDefaultInput(); postalCodeInput: CreatePostalCodeInput = new CreatePostalCodeInput(); destinationPostalCodeInput: CreatePostalCodeInput = new CreatePostalCodeInput(); address: CreateOrEditAddressDto = new CreateOrEditAddressDto(); pickupDetailInput: PickupDetailInput = new PickupDetailInput(); pickupContactInput: ContactInput = new ContactInput(); pickupContactAddress: AddressInput = new AddressInput; destinationDetailInput: DestinationDetailInput = new DestinationDetailInput; destinationContactInput: ContactInput = new ContactInput; destinationContactAddress: AddressInput = new AddressInput; locationFilter: LocationListDto = new LocationListDto(); filteredLocation: any; tagTypeFilter: TagTypeListDto = new TagTypeListDto(); filteredTagType: any; tagType: any; packageFilter: ShippingPackageListDto = new ShippingPackageListDto(); filteredPackage: any; filteredLocationPackages: any; packagePrice: any; filteredCountries: any; filteredCities: any; filteredStates: any; filteredPostal: any; filteredDestinationCountries: any; filteredDestinationStates: any; filteredDestinationCities: any; filteredDestinationPostal: any; filteredPickupPostal: any; filteredPackages: any; noteInput: string; packages: Array = []; packageList: Array = []; tagList: Array = []; pickUpTo: any; pickUpFrom: any; deliveryFrom: any; deliveryTo: any; pickupEta: Date; deliveryEta: Date; orderPackageInput: Object = new Object(); addPackage: any; packageQuantity: number; packageNameMessageError: boolean = false; packageQtyMessageError: boolean = false; packageMessageError: boolean = false; tagNameMessageError: boolean = false; tagValueMessageError: boolean = false; tagMessageError: boolean = false; pickuppostalId: PostalCodeListDto = new PostalCodeListDto(); destinationpostalId: PostalCodeListDto = new PostalCodeListDto(); locationInput: number; pickupPhone: string; pickupEmail: string; destinationPhone: string; destinationEmail: string; toAdd: PackageInput; toAddTag = new TagInput; selectedLocation: any; selectedTagType: any; selectedPickupCountry: any; selectedPickupPostalCode: any; selectedPickupState: any; selectedPickupCity: any; selectedDestinationCountry: any; selectedDestinationPostalCode: any; selectedDestinationState: any; selectedDestinationCity: any; filteredAddressType: any; addressTypeId: number; pickupFilterChange = false; destinationFilterChange = false; tagValue: string; city: string; state: string; value: string; country: string; stateFeature: boolean; format_address_pickup: string; format_address_deliver: string; options = { componentRestriction: { // types: ['geocode'], // country: 'UA' }, // types: ['cities'], } place_id_pickup: string; place_id_deliver: string; postal_code_pickup: string; postal_code_deliver: string; country_deliver: string; country_pickup: string; state_deliver: string; state_pickup: string; city_deliver: string; city_pickup: string; street_number_pickup: string; street_number_deliver: string; route_pickup: string; route_deliver: string; neighborhood_pickup: string; neighborhood_deliver: string; sublocality_pickup: string; sublocality_deliver: string; addressLine1_pickup: string; addressLine1_deliver: string; addressLine2_pickup: string; addressLine2_deliver: string; map_pickup: any; map_deliver: any; map: any; orderTypeList : GetOrderTypeForViewDto[]; origin: ILatLng = { latitude: 38.889931, longitude: -77.009003 }; // New York City, NY, USA destination: ILatLng = { latitude: 40.730610, longitude: -73.935242 }; displayDirections = true; zoom_pickup = 18; zoom_deliver = 18; zoom =18; contactAddressChecker: ContactAddressCheckerInput = new ContactAddressCheckerInput(); createOnDemandOrderInput: CreateOnDemandOrderInput = new CreateOnDemandOrderInput(); @ViewChild('placesRef', {static: true}) placesRef : GooglePlaceDirective; @ViewChild('placesRef1', {static: true}) placesRef1 : GooglePlaceDirective; placeExist: boolean = true; routeId: any; addressType_pickup: string; addressType_deliver: string; orderId: number; compleAddressPickup: string = ""; compleAddressDeliver: string = ""; constructor( injector: Injector, private _orderAppService: OrderServiceProxy, private _locationAppService: LocationServiceProxy, private _tagTypeAppService: TagTypeServiceProxy, private _postalCodeService: PostalCodeServiceProxy, private _packageService: ShippingPackageServiceProxy, private _packagesServiceProxy: PackagesServiceProxy, private _location:Location, private router: Router, private _addressTypeService: AddressTypeServiceProxy, private _postalCodeServiceProxy: PostalCodeServiceProxy, private apiloader: MapsAPILoader, private route: ActivatedRoute, private _orderTypeServiceProxy: OrderTypesServiceProxy ) { super(injector); } saveOrder(): void{ this.createOnDemandOrderInput.packageInput = this.packageList; this.createOnDemandOrderInput.orderId = this.orderId; this.createOnDemandOrderInput.noteInput = this.noteInput; this.createOnDemandOrderInput.orderTypeId = Number((document.getElementById('orderType')).value); // console.log(this.createOnDemandOrderInput); this.spinnerService.show(); this.saving = true; this._orderAppService.updateOnDemandOrder(this.createOnDemandOrderInput).subscribe(result =>{ this.notify.info(this.l('SavedSuccessfully')); this.saving = false; this.router.navigateByUrl("/app/sprintship/order"); this.spinnerService.hide(); }); } getOrderTypes(){ this._orderTypeServiceProxy.getAllOrderTypeForTableDropdown().subscribe(result => { this.orderTypeList = result; }) } mapReady_pickup(event?: any) { this.map_pickup=event; } mapReady_deliver(event?: any) { this.map_deliver = event; } mapReady(event?: any) { this.map = event; } public pickUpAddressChange(address: Address) { this.placeExist = true; $('#nextStep').removeAttr("disabled"); this.format_address_pickup = address.formatted_address; this.addressLine1_pickup = ""; this.street_number_pickup = ""; this.route_pickup = ""; this.neighborhood_pickup = ""; this.sublocality_pickup = ""; this.place_id_pickup = address.place_id; let x: ILatLng = { longitude : address.geometry.location.lng(), latitude : address.geometry.location.lat(), } this.origin = x; for(var data in address.address_components){ for (var data2 in address.address_components[data].types){ if(address.address_components[data].types[data2]=="postal_code"){ this.postal_code_pickup = address.address_components[data].long_name; } if(address.address_components[data].types[data2]=="country"){ this.country_pickup = address.address_components[data].long_name; } if(address.address_components[data].types[data2]=="administrative_area_level_1"){ this.state_pickup = address.address_components[data].long_name; } if(address.address_components[data].types[data2]=="locality" || address.address_components[data].types[data2]=="postal_town" || address.address_components[data].types[data2]=="administrative_area_level_3"){ this.city_pickup = address.address_components[data].short_name; } if(address.address_components[data].types[data2]=="route"){ this.route_pickup = address.address_components[data].long_name; } if(address.address_components[data].types[data2]=="street_number"){ this.street_number_pickup = address.address_components[data].long_name; } if(address.address_components[data].types[data2]=="neighborhood"){ this.neighborhood_pickup = address.address_components[data].long_name; } if(address.address_components[data].types[data2]=="sublocality"){ this.sublocality_pickup = address.address_components[data].long_name; } } } this.street_number_pickup = this.street_number_pickup==undefined || this.route_pickup=="" || this.route_pickup==" "? "" : this.street_number_pickup +" "; this.route_pickup = this.route_pickup==undefined || this.route_pickup=="" || this.route_pickup==" "? "" : "" +this.route_pickup +", "; this.neighborhood_pickup = this.neighborhood_pickup==undefined || this.neighborhood_pickup=="" || this.neighborhood_pickup==" "? "" : "" +this.neighborhood_pickup +", "; this.sublocality_pickup = this.sublocality_pickup==undefined || this.sublocality_pickup=="" || this.sublocality_pickup==" "? "" : "" +this.sublocality_pickup +", "; this.addressLine1_pickup = this.street_number_pickup +this.route_pickup +this.sublocality_pickup +this.neighborhood_pickup; this.createOnDemandOrderInput.formattedAddress_pickup = this.format_address_pickup; this.createOnDemandOrderInput.addressLine1_pickup = this.addressLine1_pickup; this.createOnDemandOrderInput.city_pickup = this.city_pickup; this.createOnDemandOrderInput.country_pickup = this.country_pickup; this.createOnDemandOrderInput.state_pickup= this.state_pickup; this.createOnDemandOrderInput.postalcode_pickup = this.postal_code_pickup; this.createOnDemandOrderInput.latitude_pickup = address.geometry.location.lat(); this.createOnDemandOrderInput.longitude_pickup = address.geometry.location.lng(); this.createOnDemandOrderInput.addressType_pickup = address.types[0]==null ? "" : address.types[0]; // console.log(address); // console.log(this.addressLine1_pickup); // console.log(this.origin); // console.log(this.format_address_pickup); } public deliveryAddressChange(address: Address) { this.placeExist = true; $('#nextStep').removeAttr("disabled"); this.format_address_deliver = address.formatted_address; this.place_id_deliver = address.place_id; this.addressLine1_pickup = ""; this.street_number_deliver = ""; this.route_deliver = ""; this.neighborhood_deliver = ""; this.sublocality_deliver = ""; let y: ILatLng = { longitude : address.geometry.location.lng(), latitude : address.geometry.location.lat(), } this.destination = y; for(var data in address.address_components){ for (var data2 in address.address_components[data].types){ if(address.address_components[data].types[data2]=="postal_code"){ this.postal_code_deliver = address.address_components[data].long_name; } if(address.address_components[data].types[data2]=="country"){ this.country_deliver = address.address_components[data].long_name; } if(address.address_components[data].types[data2]=="administrative_area_level_1"){ this.state_deliver = address.address_components[data].long_name; } if(address.address_components[data].types[data2]=="locality" || address.address_components[data].types[data2]=="postal_town" || address.address_components[data].types[data2]=="administrative_area_level_3"){ this.city_deliver = address.address_components[data].long_name; } if(address.address_components[data].types[data2]=="route"){ this.route_deliver = address.address_components[data].long_name; } if(address.address_components[data].types[data2]=="street_number"){ this.street_number_deliver = address.address_components[data].long_name; } if(address.address_components[data].types[data2]=="neighborhood"){ this.neighborhood_deliver = address.address_components[data].long_name; } if(address.address_components[data].types[data2]=="sublocality"){ this.sublocality_deliver = address.address_components[data].long_name; } } } this.street_number_deliver = this.street_number_deliver==undefined || this.street_number_deliver=="" || this.street_number_deliver==" "? "" : this.street_number_deliver +" "; this.route_deliver = this.route_deliver==undefined || this.route_deliver=="" || this.route_deliver==" "? "" : " " +this.route_deliver +", "; this.neighborhood_deliver = this.neighborhood_deliver==undefined || this.neighborhood_deliver=="" || this.neighborhood_deliver==" "? "" : " " +this.neighborhood_deliver +", "; this.sublocality_deliver = this.sublocality_deliver==undefined || this.sublocality_deliver=="" || this.sublocality_deliver==" "? "" : " " +this.sublocality_deliver +", "; this.addressLine1_deliver = this.street_number_deliver +this.route_deliver +this.sublocality_deliver +this.neighborhood_deliver; this.createOnDemandOrderInput.formattedAddress_deliver = this.format_address_deliver; this.createOnDemandOrderInput.addressLine1_deliver = this.addressLine1_deliver; this.createOnDemandOrderInput.city_deliver = this.city_deliver; this.createOnDemandOrderInput.country_deliver = this.country_deliver; this.createOnDemandOrderInput.state_deliver= this.state_deliver; this.createOnDemandOrderInput.postalcode_deliver = this.postal_code_deliver; this.createOnDemandOrderInput.latitude_deliver = address.geometry.location.lat(); this.createOnDemandOrderInput.longitude_deliver = address.geometry.location.lng(); this.createOnDemandOrderInput.addressType_deliver = address.types[0]==null ? "" : address.types[0]; // console.log(address); // console.log(this.addressLine1_deliver); } ngOnInit() { this.stateFeature = abp.features.isEnabled('App.StateFeature'); // this.ktwizard2(); let maxcount = 1000; // this.filterLocation(); // this.filterTagType(); // this.filterAddressTypes(maxcount); // this.filterPostal(); // this.filterCountries(undefined); this.filterPackage(); $('.kt-select2').select2(); // this.filterLocationPackages(); this.createInput = new CreateOrderDefaultInput(); this.createInput.packageInput = Object(); this.pickuppostalId = new PostalCodeListDto(); this.destinationpostalId = new PostalCodeListDto(); this.locationInput = 0; this.pickupPhone = ""; this.pickupEmail = ""; this.destinationPhone = ""; this.destinationEmail = ""; this.orderPackageInput = new Object(); this.toAdd = new PackageInput(); var that = this; $("#packages").change(function () { // this.selectedLocation = $("#packages option:selected").text(); // $("#selectedLocation").text(this.selectedLocation); // console.log(that.filterLocationPackages($("#packages").val(), $("#location").val())); }); $("#TagType").change(function () { this.selectedTagType = $("#TagType option:selected").text(); $("#selectedTagType").text(this.selectedTagType); }); $("#countryPickupSelectInput").change(function () { this.selectedPickupCountry = $("#countryPickupSelectInput option:selected").text(); $("#selectedPickupCountry").text(this.selectedPickupCountry); }); $("#pickupPostalInput").change(function () { this.selectedPickupPostalCode = $("#pickupPostalInput option:selected").text(); $("#selectedPickupPostalCode").text(this.selectedPickupPostalCode); this.selectedPickupPostalCode = this.selectedPickupPostalCode.trim(); that.pickupFilterChange = true; }); $("#pickupStateInput").change(function () { this.selectedPickupState = $("#pickupStateInput option:selected").text(); $("#selectedPickupState").text(this.selectedPickupState); }); $("#pickupCityInput").change(function () { this.selectedPickupCity = $("#pickupCityInput option:selected").text(); $("#selectedPickupCity").text(this.selectedPickupCity); }); $("#destinationCountryInput").change(function () { this.selectedDestinationCountry = $("#destinationCountryInput option:selected").text(); $("#selectedDestinationCountry").text(this.selectedDestinationCountry); }); $("#destinationPostalInput").change(function () { this.selectedDestinationPostalCode = $("#destinationPostalInput option:selected").text(); $("#selectedDestinationPostalCode").text(this.selectedDestinationPostalCode); this.selectedDestinationPostalCode = this.selectedDestinationPostalCode.trim() that.destinationFilterChange = true; }); $("#destinationStateInput").change(function () { this.selectedDestinationState = $("#destinationStateInput option:selected").text(); $("#selectedDestinationState").text(this.selectedDestinationState); }); $("#destinationCityInput").change(function () { this.selectedDestinationCity = $("#destinationCityInput option:selected").text(); $("#selectedDestinationCity").text(this.selectedDestinationCity); }); this.route.paramMap.subscribe(params => { this.orderId = Number(params.get("id")) }); this.getOrder(this.orderId); this.getOrderTypes(); } ngAfterViewInit() { $("#countryPickupSelectInput").change(function () { this.selectedPickupCountry = $("#countryPickupSelectInput option:selected").text(); $("#selectedPickupCountry").text(this.selectedPickupCountry); }); $('#kt_daterangepicker_5').daterangepicker({ buttonClasses: ' btn', applyClass: 'btn-primary', cancelClass: 'btn-secondary', singleDatePicker: true, showDropdowns: true, locale: { format: 'MM/DD/YYYY' } }, function (start, end, label) { $('#kt_daterangepicker_5 .form-control').val(start.format('MM/DD/YYYY') + ' / ' + end.format('MM/DD/YYYY')); }); var KTWizard2 = function () { var e, r, i; $(".pickUpFrom input").attr("name", "pickUpFrom"); $(".pickUpTo input").attr("name", "pickUpTo"); $(".deliveryFrom input").attr("name", "deliveryFrom"); $(".deliveryTo input").attr("name", "deliveryTo"); return { init: function () { var t; KTUtil.get("kt_wizard_v2"), e = $("#kt_form"), (i = new KTWizard("kt_wizard_v2", { startStep: 1, clickableSteps: !0 })).on("beforeNext", function (e) { !0 !== r.form() && e.stop() }), i.on("beforePrev", function (e) { !0 !== r.form() && e.stop() }), i.on("change", function (e) { KTUtil.scrollTop() }), r = e.validate({ ignore: ":hidden", rules: { address_pickup: {required: !0 }, deliver_pickup: {required: !0 }, destinationPhoneInput: {required: !0 }, pickupFirstNameInput: { required: !0 }, pickupLastNameInput: { required: !0 }, // pickupEmailInput: { required: !0, email: !0 }, pickupPhoneInput: { required: !0,}, PickupEta: { required: !0 }, pickUpFrom: { required: !0 }, pickUpTo: { required: !0 }, deliveryFrom: { required: !0 }, deliveryTo: { required: !0 }, }, invalidHandler: function (e, r) { }, submitHandler: function (e) { } }) } } }(); jQuery(document).ready(function () { KTWizard2.init() }); } getOrder(id:number){ this.spinnerService.show(); this._orderAppService.trackOrder(id, undefined, undefined,undefined,undefined,undefined,undefined,undefined).subscribe(res =>{ this.noteInput = res[0].note; this.createOnDemandOrderInput.orderTypeId = res[0].orderTypeId; this.createOnDemandOrderInput.pickupDetailsId = res[0].pickupDetailsId; this.createOnDemandOrderInput.addressLine1_pickup = res[0].pickupAddressLine1; this.createOnDemandOrderInput.city_pickup = res[0].pickupCity; this.createOnDemandOrderInput.country_pickup = res[0].pickupCountry; this.createOnDemandOrderInput.email_pickup = res[0].pickUpEmail; this.createOnDemandOrderInput.firstName_pickup = res[0].pickupFirstName; this.createOnDemandOrderInput.formattedAddress_pickup = res[0].pickupFormatAddress; this.createOnDemandOrderInput.lastName_pickup = res[0].pickupLastName; this.createOnDemandOrderInput.latitude_pickup = res[0].pickupLat; this.createOnDemandOrderInput.longitude_pickup = res[0].pickupLong; this.createOnDemandOrderInput.phone_pickup = res[0].pickUpPhone; this.createOnDemandOrderInput.postalcode_pickup = res[0].pickupPostal; this.createOnDemandOrderInput.state_pickup = res[0].pickupState; this.createOnDemandOrderInput.addressType_pickup = res[0].pickupAddressType; this.createOnDemandOrderInput.addressLine2_pickup= res[0].pickupAddressLine2 == null ? "" : res[0].pickupAddressLine2; this.createOnDemandOrderInput.deliveryDetailsId = res[0].deliveryDetailsId; this.createOnDemandOrderInput.addressLine1_deliver = res[0].deliveryAddressLine1; this.createOnDemandOrderInput.city_deliver = res[0].deliveryCity; this.createOnDemandOrderInput.country_deliver = res[0].deliveryCountry; this.createOnDemandOrderInput.email_deliver = res[0].deliveryEmail; this.createOnDemandOrderInput.firstName_deliver = res[0].deliveryFirstName; this.createOnDemandOrderInput.formattedAddress_deliver = res[0].deliverFormatAddress; this.createOnDemandOrderInput.lastName_deliver = res[0].deliveryLastName; this.createOnDemandOrderInput.latitude_deliver = res[0].deliveryLat; this.createOnDemandOrderInput.longitude_deliver = res[0].deliveryLong; this.createOnDemandOrderInput.phone_deliver = res[0].deliveryPhone; this.createOnDemandOrderInput.postalcode_deliver = res[0].deliveryPostal; this.createOnDemandOrderInput.state_deliver = res[0].deliveryState; this.createOnDemandOrderInput.addressType_deliver = res[0].deliverAddressType; this.createOnDemandOrderInput.addressLine2_deliver = res[0].deliveryAddressLine2 == null ? "" : res[0].deliveryAddressLine2; this.compleAddressPickup = res[0].pickupFormatAddress==null || res[0].pickupFormatAddress=="" ? res[0].pickupAddressLine1 +", " +res[0].pickupCity +", " +res[0].pickupState==null ? "" : res[0].pickupState +", " +res[0].pickupCountry +", " +res[0].pickupPostal : res[0].pickupFormatAddress; this.compleAddressDeliver = res[0].deliverFormatAddress==null || res[0].deliverFormatAddress=="" ? res[0].deliveryAddressLine1 +", " +res[0].deliveryCity +", " +res[0].deliveryState==null ? "" : res[0].deliveryState +res[0].deliveryCountry +", " +res[0].deliveryPostal : res[0].deliverFormatAddress; this.format_address_pickup = res[0].pickupFormatAddress; this.format_address_deliver = res[0].deliverFormatAddress; let x: ILatLng = { longitude : this.createOnDemandOrderInput.longitude_pickup, latitude : this.createOnDemandOrderInput.latitude_pickup, } this.origin = x; let y: ILatLng = { longitude : this.createOnDemandOrderInput.longitude_deliver, latitude : this.createOnDemandOrderInput.latitude_deliver, } this.destination = y; let that = this; $('#address_pickup').val(that.compleAddressPickup); $('#deliver_pickup').val(that.compleAddressDeliver); for(var data in res[0].orderPackages){ this.toAdd = new PackageInput(); this.toAdd.packageName = res[0].orderPackages[data].package.name; this.toAdd.packageId = res[0].orderPackages[data].package.id this.toAdd.quantity = res[0].orderPackages[data].quantity this.toAdd.price = res[0].orderPackages[data].package.price this.packageList.push(this.toAdd); } this.spinnerService.hide(); }); } filterPackage(): void { this.spinnerService.show(); this._packagesServiceProxy.getAll( undefined, undefined, undefined, undefined, undefined, 1000 ).subscribe(result => { this.filteredPackage = result.items; this.spinnerService.hide(); }); } filterPackages(id): void { this._packagesServiceProxy.getPackageForView(id ).subscribe(result => { this.filteredPackages = result; //console.log(this.filteredPackages['package']['price']); $("#packagePrice").val(this.filteredPackages['package']['price']); }); } addPackageToList() { let key, packageId, packagePrice, tagValue, key2, arrAny = {}; packageId = Number((document.getElementById('packagess')).value); if ((packageId === 0 || packageId == null) && (this.packageQuantity === 0 || this.packageQuantity == null)) { this.packageNameMessageError = true; this.packageQtyMessageError = true; } else if ((packageId === 0 || packageId == null)) { this.packageNameMessageError = true; this.packageQtyMessageError = false; } else if ((this.packageQuantity === 0 || this.packageQuantity == null)) { this.packageNameMessageError = false; this.packageQtyMessageError = true; } else { for (key in this.filteredPackage) { if (packageId === this.filteredPackage[key]['package']['id']) { this.toAdd = new PackageInput(); this.toAdd.packageName = this.filteredPackage[key]['package']['name']; this.toAdd.packageId = this.filteredPackage[key]['package']['id']; this.toAdd.quantity = this.packageQuantity; this.toAdd.price = this.filteredPackage[key]['package']['price']; this.packageList.push(this.toAdd) } this.packageNameMessageError = false; this.packageQtyMessageError = false; } } } removePackageToList(packages) { let key; for (key in this.packageList) { if (packages.packageId == this.packageList[key].packageId) { this.packageList.splice(key, 1) } } } filterAddressTypes(maxcount): void { this._addressTypeService.getAddressType( undefined, undefined, undefined, undefined, maxcount, undefined ).subscribe(result => { this.filteredAddressType = result.items; }); } goBack(){ this._location.back(); } getCurrentLocation() { if (navigator.geolocation) { navigator.geolocation.getCurrentPosition((position) => { if (position) { // console.log(position.coords); // this.lat = position.coords.latitude; // this.lng = position.coords.longitude; // this.getAddress = (this.lat, this.lng) // console.log(position) this.apiloader.load().then(() => { let geocoder = new google.maps.Geocoder; let latlng = { lat: position.coords.latitude, lng: position.coords.longitude }; geocoder.geocode({ 'location': latlng }, function(results) { // console.log(results); if (results[0]) { this.currentLocation = results[0].formatted_address; // console.log(this.assgin); } else { console.log('Not found'); } }); }); } }) } } onSubmitPickup(): void{ try{ if(this.placesRef.place.address_components==undefined || this.placesRef.place.address_components==null){ this.placeExist = false; }else{ this.placeExist = true; } }catch(e){ this.placeExist = false; } if(!this.placeExist) { $('#nextStep').attr("disabled",""); } } onSubmitDeliver(): void { try{ if(this.placesRef1.place.address_components==undefined || this.placesRef1.place.address_components==null){ this.placeExist = false; }else{ this.placeExist = true; } }catch(e){ this.placeExist = false; } if(!this.placeExist) { $('#nextStep').attr("disabled",""); } } }