angular.module("directive.agsHeader",[]).directive("agsHeader",[function(){return{restrict:"E",scope:{},templateUrl:"../Angular/Directives/ags_header/ags-header.html"}}]).controller("agsHeaderCtrl",["$http","$scope","$rootScope","$location","$timeout","$window","userFactory","userService",function(n,t,i,r,u,f,e,o){o.rootUser();e.checkAuth().then(function(n){n.data.isAuthenticated==!0&&e.getUser().then(function(n){t.user=n.data}).catch(function(n){console.log(n)})}).catch(function(){console.log(error)})}]);angular.module("directive.adminHeader",[]).directive("adminHeader",[function(){return{restrict:"E",scope:{},templateUrl:"../../Angular/Directives/admin_header/admin-header.html"}}]).controller("adminHeaderCtrl",["$http","$scope","$rootScope","$location","$timeout","$window","companyFactory","userFactory",function(n,t,i,r,u,f,e,o){var s=function(){e.getCompanyInfo(t.user.custNo).then(function(n){t.user.company=n.data[0]?n.data[0]:null}).catch(function(n){t.user.company=null;t.companyInfo=[];console.log(n)})},h=function(){t.user.fcategory==1?t.user.agsAdmin=!0:t.user.fcategory==2?t.user.agsCorporate=!0:t.user.fcategory==3?t.user.customerAdmin=!0:t.user.agsCustomer=!0},c=function(){o.getUserById(t.user.auton).then(function(n){t.user.features={};t.user.features.pickupEntry=n.data.features[0].OnOff;t.user.features.pickupFolder=n.data.features[1].OnOff;t.user.features.tracking=n.data.features[2].OnOff;t.user.features.intImport=n.data.features[3].OnOff;t.user.features.intExport=n.data.features[4].OnOff;t.user.features.intFolder=n.data.features[5].OnOff;t.user.features.documents=n.data.features[6].OnOff;t.user.features.poManager=n.data.features[7].OnOff;t.user.features.quotes=n.data.features[8].OnOff;t.user.features.quotesFolder=n.data.features[9].OnOff;t.user.features.settings=n.data.features[10].OnOff;t.user.features.reports=n.data.features[11].OnOff;t.user.features.finacialReports=n.data.features[12].OnOff;t.user.features.userCreation=n.data.features[13].OnOff;t.user.features.groupCode=n.data.features[14].OnOff}).catch(function(){})};t.agsFeature={shipment:!1,tracking:!1,quotes:!1,international:!1,reports:!1,account:!1},function(){var n=r.absUrl();/Shipment\/MyShipment/.test(n)?t.agsFeature.shipment=!0:/Tracking\/MyTracking/.test(n)?t.agsFeature.tracking=!0:/Quotes\/MyQuotes/.test(n)?t.agsFeature.quotes=!0:/International\/MyInternational/.test(n)?t.agsFeature.international=!0:/Reports\/MyReports/.test(n)?t.agsFeature.reports=!0:/Account\/MyAccount/.test(n)&&(t.agsFeature.account=!0)}()}]);angular.module("myAGS.admin",["ui.bootstrap","directive.createUsers","directive.updateUsers","directive.corporatePswd","directive.spreadSheets","factories.userFactory","factories.companyFactory","factories.shipmentFactory","factories.trackingFactory","factories.quoteFactory","factories.internationalFactory","factories.reportFactory"]).controller("adminCtrl",["$http","$scope","$location","$timeout","$window","userService",function(n,t,i,r,u,f){f.rootUser();t.dashAdmin={create:!0,update:!1,sheets:!1};t.setDashAdmin=function(n){t.dashAdmin=_.map(t.dashAdmin,function(){return!1});t.dashAdmin[n]=!0}}]);angular.module("myAGS.aGSSMSModal",[]).controller("aGSSMSModalCtrl",["$http","$scope","$rootScope","$location","$timeout","$window","$uibModalInstance","helpTitle","userFactory","shipmentFactory","shipmentForm","shipmentId","shipmentService","shipmentData","smsAlert","emailAlert",function(n,t,i,r,u,f,e,o,s,h,c,l,a,v,y,p){t.helpTitle=o;t.newShipment=c;t.billToNumber=v.HouseAirWaybillNumber;t.shipmentId=l;t.smsAlert=y;t.emailAlert=p;s.getMileStones().then(function(n){v.FileStatus==="LIVE"&&(t.mileStones=n.data.filter(function(n){return n.mileStoneCode!=="NEWORD"&&n.mileStoneCode!=="APTCONF"&&n.mileStoneCode!=="APTREMIND"}));console.log(t.mileStones)}).catch(function(n){console.log(n)});t.ok=function(){e.close(t.selected.item)};t.close=function(){e.dismiss("cancel")};t.agsSMSForm={SMSUserID:t.userId||null,agsUserId:i.user.auton,MileStoneStatus:t.mileStones,AspinBillto:i.user.custNo,Application:"MYAGS",SHIPMENTID:t.shipmentId};t.agsSMSForm.agsUserId!=null&&s.getSMSUserbymyAGSUserID(t.agsSMSForm.agsUserId,t.agsSMSForm.SHIPMENTID).then(function(n){var i=n.data;t.helpTitle.indexOf("SMS")!==-1?t.agsSMSForm=i.filter(function(n){return n.ALERTPHONE==!0})[0]:t.helpTitle.indexOf("EMAIL")!==-1&&(t.agsSMSForm=i.filter(function(n){return n.ALERTEMAIL==!0})[0]);window.console.log(t.shipmentId);angular.forEach(i,function(n){n.MileStoneStatus&&n.MileStoneStatus.length>0&&angular.forEach(n.MileStoneStatus,function(n){if(t.mileStones&&t.mileStones.length>0){let i=t.mileStones.filter(function(i){return i.mileStoneCode===n.MILESTONE&&n.ShipmentID===t.shipmentId})[0];i&&(i.selected=!0)}})})}).catch(function(n){console.log(n)});t.createSMSOREmailUser=function(n){t.smsSubmitted=!0;t.smsErrorMessage=null;n&&(t.disableSaveAGSSMS=!0,t.agsSMSSpinner=!0,t.agsSMSForm.MileStoneStatus=t.mileStones.filter(function(n){return n.selected===!0}),t.agsSMSForm.SHIPMENTID=t.shipmentId,t.smsAlert==!0&&(t.agsSMSForm.ALERTPHONE=!0),t.emailAlert==!0&&(t.agsSMSForm.ALERTEMAIL=!0),s.saveMileStonesWithShipmentID(t.agsSMSForm).then(function(){t.agsSMSForm.MileStoneStatus=t.mileStones;t.smsSubmitted=!1;t.agsSMSSpinner=!1;t.disableSaveAGSSMS=!1;t.smsSaved=!0;w()}).catch(function(n){t.agsSMSSpinner=!1;t.disableSaveAGSSMS=!1;t.smsErrorMessage="Status Subscribtion failed.Submit again.";console.log(n)}))};var w=function(){u(function(){t.smsSubmitted=!1;t.smsSaved=!1;t.disableSaveAGSSMS=!1},2e3)}}]);angular.module("myAGS.helpModal",[]).controller("helpModalCtrl",["$http","$scope","$location","$timeout","$window","$uibModalInstance","helpTitle",function(n,t,i,r,u,f,e){t.helpTitle=e;t.ok=function(){f.close(t.selected.item)};t.close=function(){f.dismiss("cancel")}}]);angular.module("myAGS.home",[]).controller("homeCtrl",["$http","$scope","$location","$timeout","$window","userService",function(){}]);angular.module("myAGS.international",["directive.importEntry","directive.importFolder","directive.importShow","directive.importPreview","directive.exportEntry","directive.exportFolder","directive.exportShow","directive.exportPreview","directive.serviceForms","directive.poSheets","directive.poManager","directive.poFiles","directive.poLoad","directive.poManifest","directive.poMaster","services.shipmentService","services.quoteService","services.internationalService","services.poLoadService","factories.shipmentFactory","factories.quoteFactory","factories.internationalFactory","factories.userFactory","factories.companyFactory"]).controller("internationalCtrl",["$http","$scope","$rootScope","$location","$timeout","$window","internationalService","userService",function(n,t,i,r,u,f,e,o){o.rootUser();t.dashMyInternational={importEntry:!1,importFolder:!1,importShow:!1,exportEntry:!1,exportFolder:!0,exportShow:!1,serviceForms:!1,poSheets:!1,poLoad:!1,poManifest:!1,poMaster:!1};t.toggleNavMenu=function(){t.navMenuOpen=t.navMenuOpen?!1:!0};t.setDashInternational=function(n){t.dashMyInternational=_.mapObject(t.dashMyInternational,function(){return!1});t.navMenuOpen=!1;e.resetsAllEntries();t.dashMyInternational[n]=!0};t.$watch(function(){return e._folderView},function(n){n&&(t.setDashInternational(n),e.resetFolder())});t.$watch(function(){return e._newExportEntryID},function(n){n&&(t.dashMyInternational=_.mapObject(t.dashMyInternational,function(){return!1}),t.dashMyInternational.exportFolder=!0)});t.$watch(function(){return e._newImportEntryID},function(n){n&&(t.dashMyInternational=_.mapObject(t.dashMyInternational,function(){return!1}),t.dashMyInternational.importFolder=!0)});t.$watch(function(){return e._copiedImportEntry},function(n){n&&(t.dashMyInternational=_.mapObject(t.dashMyInternational,function(){return!1}),t.dashMyInternational.importEntry=!0)});t.$watch(function(){return e._returnedImportEntry},function(n){n&&(t.dashMyInternational=_.mapObject(t.dashMyInternational,function(){return!1}),t.dashMyInternational.exportEntry=!0)});t.$watch(function(){return e._importEntry},function(n){n?(t.selectedImportEntry=n,t.dashMyInternational=_.mapObject(t.dashMyInternational,function(){return!1}),t.dashMyInternational.importShow=!0):t.selectedImportEntry=n});t.$watch(function(){return e._copiedExportEntry},function(n){n&&(t.dashMyInternational=_.mapObject(t.dashMyInternational,function(){return!1}),t.dashMyInternational.exportEntry=!0)});t.$watch(function(){return e._returnedExportEntry},function(n){n&&(t.dashMyInternational=_.mapObject(t.dashMyInternational,function(){return!1}),t.dashMyInternational.importEntry=!0)});t.$watch(function(){return e._exportEntry},function(n){n?(t.selectedExportEntry=n,t.dashMyInternational=_.mapObject(t.dashMyInternational,function(){return!1}),t.dashMyInternational.exportShow=!0):t.selectedExportEntry=n})}]);angular.module("myAGS.internationalShipmentConfirmModel",["ngclipboard"]).controller("internationalShipmentConfirmModel",["$http","$scope","$rootScope","$timeout","$window","$uibModalInstance","route","billToNumber","shipmentForm","shipmentId","shipmentFactory","shipmentService","internationalFactory",function(n,t,i,r,u,f,e,o,s,h,c,l,a){t.onSuccess=function(n){console.info("Action:",n.action);console.info("Text:",n.text);console.info("Trigger:",n.trigger);n.clearSelection()};t.onError=function(n){console.error("Action:",n.action);console.error("Trigger:",n.trigger)};t.billToNumber=o;t.shipmentId=h;t.newShipment=s;t.confirmationForm={LoggedInUserEmail:i.user.email,SHIPPEREMAIL:s.ShipperInfo.EMAIL,CONSIGNEEMAIL:s.ConsigneeInfo.EMAIL,EMAIL3:null,EMAIL4:null,EMAIL5:null,EMAIL6:null};t.ok=function(){f.close(t.selected.item)};t.close=function(){f.dismiss("cancel");t.newShipment.ShipmentData.FILESTATUS=="LIVE"&&l.setReloadRoute(e)};t.sendEmails=function(){f.dismiss("cancel");t.confirmationForm.houseNo=t.billToNumber;t.confirmationForm.ShipmentId=t.shipmentId;a.sendMail(t.confirmationForm).then(function(){l.setReloadRoute(e)}).catch(function(n){console.log(n)})}}]);angular.module("myAGS.myAccount",["ui.bootstrap","directive.myInfo","directive.mySettings","directive.addressBook","directive.links","directive.createMyUsers","directive.sms","services.userService"]).controller("myAccountCtrl",["$http","$scope","$location","$timeout","$window","$rootScope","userService",function(n,t,i,r,u,f,e){e.rootUser();t.myAccountRoute=!0;t.dashMyAccount={info:!0,address:!1,settings:!1,links:!1,createMyUsers:!1,sms:!1};t.toggleNavMenu=function(){t.navMenuOpen=t.navMenuOpen?!1:!0};t.setDashAccount=function(n){t.dashMyAccount=_.map(t.dashMyAccount,function(){return!1});t.navMenuOpen=!1;t.dashMyAccount[n]=!0}}]);angular.module("myAGS.poLoadModal",[]).controller("poLoadModalCtrl",["$http","$scope","$location","$timeout","$window","$uibModalInstance","internationalFactory","poLoadService","title","object",function(n,t,i,r,u,f,e,o,s,h){t.title=s;t.loadList=h;t.container={};t.confirm=function(){t.poLoading=!0;e.updateOrderILoadNumber(t.loadList.list).then(function(){e.getAllPOLoads().then(function(n){t.poLoadActivated=!0;t.poLoading=!1;o.resetLoadList();t.loadList=o.setShipments(n.data);t.close()}).catch(function(n){t.poLoading=!1;console.log(n)})}).catch(function(n){console.log(n)})};var c=function(){var n=1;_.each(t.loadList.list,function(i){t.container["Shipment_"+n]=i.ID;o.mockShipmentEntryUpdate(i.ID);n++})};t.close=function(){f.dismiss("cancel")}}]);angular.module("myAGS.poManifestConfirmModal",[]).controller("poManifestConfirmModal",["$http","$scope","$timeout","$window","$uibModalInstance","title","consolNumber",function(n,t,i,r,u,f,e){t.consolNumber=e;t.close=function(){u.dismiss("cancel");r.location.reload()}}]);angular.module("myAGS.poMasterConfirmModal",[]).controller("poMasterConfirmModal",["$http","$scope","$timeout","$window","$uibModalInstance","title","consolNumber",function(n,t,i,r,u,f,e){t.consolNumber=e;t.close=function(){u.dismiss("cancel")}}]);angular.module("myAGS.quoteConfirmModal",["ngclipboard"]).controller("quoteConfirmModalCtrl",["$http","$scope","$rootScope","$timeout","$window","$uibModalInstance","route","billToNumber","quoteForm","shipmentId","shipmentFactory","shipmentService","quoteFactory","quoteService",function(n,t,i,r,u,f,e,o,s,h,c,l,a,v){t.onSuccess=function(n){console.info("Action:",n.action);console.info("Text:",n.text);console.info("Trigger:",n.trigger);n.clearSelection()};t.onError=function(n){console.error("Action:",n.action);console.error("Trigger:",n.trigger)};t.billToNumber=o;t.shipmentId=s.ID;t.newQuote=s;t.confirmationForm={LoggedInUserEmail:i.user.email,SHIPPEREMAIL:t.newQuote.Parties[1].Email,CONSIGNEEMAIL:t.newQuote.Parties[2].Email,EMAIL3:null,EMAIL4:null,EMAIL5:null,EMAIL6:null};t.ok=function(){f.close(t.selected.item)};t.close=function(){f.dismiss("cancel");v.setReloadQuote(e);u.location.reload()};t.sendEmails=function(){t.errorMessage=null;t.disableCreateUser=!0;t.createSpinner=!0;t.confirmationForm.houseNo=t.billToNumber;t.confirmationForm.ShipmentId=t.shipmentId;a.sendMail(t.confirmationForm).then(function(){t.createSpinner=!1;t.activating=!1;t.infoSaved=!0;f.dismiss("cancel");l.setReloadRoute(e);u.location.reload()}).catch(function(n){t.createSpinner=!1;t.disableCreateUser=!1;t.errorMessage="Unable to send email. Submit again.";console.log(n)})}}]);angular.module("myAGS.quoteModal",[]).controller("quoteModalCtrl",["$http","$scope","$location","$timeout","$window","$uibModalInstance","route","title","object","quoteService","quoteFactory",function(n,t,i,r,u,f,e,o,s,h,c){t.totalEstimate=0;t.title=o;t.object=s;t.route=e;c.getQuoteByIdFromStaging(t.object.ID).then(function(n){t.modalObject=n.data[0];_.mapObject(t.modalObject.Receivable.Receivables,function(n){t.totalEstimate+=n.EstimatedReceivable;t.modalObject.TotalEstimateCost=t.totalEstimate})}).catch(function(n){console.log(n);t.errorQuoteMessage="Quote did not generate. Please validate all required fields or contact your AGS representative."});t.ok=function(){t.route?f.dismiss("cancel"):f.dismiss("cancel")};t.close=function(){t.route&&t.route=="/myQuotes"?(u.location.reload(),h.setReloadQuote(e)):f.dismiss("cancel")};t.activateQuote=function(n){h.activate(n);f.dismiss("cancel")}}]);angular.module("myAGS.quotes",["ui.bootstrap","directive.quoteRequest","directive.quickQuotes","directive.myQuotes","directive.quoteShow","services.shipmentService","services.quoteService","services.internationalService","factories.shipmentFactory","factories.quoteFactory","factories.internationalFactory"]).controller("quotesCtrl",["$http","$scope","$location","$timeout","$window","quoteService","userService",function(n,t,i,r,u,f,e){e.rootUser();t.selectedQuote=f._quote;t.dashMyQuotes={request:!1,quickQuotes:!1,myQuotes:!0,quote:!1};t.toggleNavMenu=function(){t.navMenuOpen=t.navMenuOpen?!1:!0};t.setDashQuotes=function(n){t.dashMyQuotes=_.mapObject(t.dashMyQuotes,function(){return!1});f.clear();t.navMenuOpen=!1;t.dashMyQuotes[n]=!0};t.$watch(function(){return f._quote},function(n){n&&(t.dashMyQuotes=_.mapObject(t.dashMyQuotes,function(){return!1}),t.selectedQuote=n,t.navMenuOpen=!1,t.dashMyQuotes.quote=!0)});t.$watch(function(){return f._copiedQuote},function(n){n&&(t.dashMyQuotes=_.mapObject(t.dashMyQuotes,function(){return!1}),t.navMenuOpen=!1,t.dashMyQuotes.request=!0)});t.$watch(function(){return f._activateQuote},function(n){n&&(t.dashMyQuotes=_.mapObject(t.dashMyQuotes,function(){return!1}),t.navMenuOpen=!1,t.dashMyQuotes.request=!0)})}]);angular.module("myAGS.reports",["directive.myReports"]).controller("reportsCtrl",["$http","$scope","$location","$timeout","$window","userService",function(n,t,i,r,u,f){f.rootUser()}]);angular.module("myAGS.shipmentConfirmModal",["ngclipboard"]).controller("shipmentConfirmModalCtrl",["$http","$scope","$rootScope","$timeout","$window","$uibModalInstance","route","billToNumber","shipmentForm","shipmentId","shipmentFactory","shipmentService",function(n,t,i,r,u,f,e,o,s,h,c,l){t.onSuccess=function(n){console.info("Action:",n.action);console.info("Text:",n.text);console.info("Trigger:",n.trigger);n.clearSelection()};t.onError=function(n){console.error("Action:",n.action);console.error("Trigger:",n.trigger)};t.billToNumber=o;t.shipmentId=h;t.newShipment=s;t.confirmationForm={LoggedInUserEmail:i.user.email,SHIPPEREMAIL:s.ShipperInfo.EMAIL,CONSIGNEEMAIL:s.ConsigneeInfo.EMAIL,EMAIL3:null,EMAIL4:null,EMAIL5:null,EMAIL6:null};t.ok=function(){f.close(t.selected.item)};t.close=function(){f.dismiss("cancel");t.newShipment.ShipmentData.FILESTATUS=="LIVE"&&l.setReloadRoute(e)};t.sendEmails=function(){t.errorMessage=null;t.disableCreateUser=!0;t.createSpinner=!0;t.confirmationForm.houseNo=t.billToNumber;t.confirmationForm.ShipmentId=t.shipmentId;c.sendMail(t.confirmationForm).then(function(){t.createSpinner=!1;t.activating=!1;t.infoSaved=!0;f.dismiss("cancel");l.setReloadRoute(e)}).catch(function(n){t.createSpinner=!1;t.disableCreateUser=!1;t.errorMessage="Unable to send email. Submit again.";console.log(n)})}}]);angular.module("myAGS.shipments",["ui.bootstrap","directive.shipmentsDashboard","directive.pickupRequest","directive.myShipments","directive.shipmentShow","directive.shipmentPreview","directive.shipmentSheet","services.shipmentService","services.quoteService","services.internationalService","factories.shipmentFactory","factories.quoteFactory","factories.internationalFactory"]).controller("shipmentsCtrl",["$http","$scope","$rootScope","$location","$timeout","$window","shipmentService","userService",function(n,t,i,r,u,f,e,o){o.rootUser()}]);angular.module("myAGS.tracking",["directive.billNumber","directive.references","directive.shipmentDates","directive.zipcode","directive.consignee","directive.partsContainers","directive.trackedShipments","services.trackingService"]).controller("trackingCtrl",["$http","$scope","$compile","$location","$timeout","$window","$uibModal","$sce","shipmentFactory","trackingService","trackingFactory","$filter","userService","internationalFactory",function(n,t,i,r,u,f,e,o,s,h,c,l,a){var v,y,p,b,w;a.rootUser();t.trackedShipments=null;t.trackDash={tracking:!1,planner:!0};t.setTrackDashNav=function(n){t.trackDash=_.mapObject(t.trackDash,function(){return!1});t.trackDash[n]=!0};t.trackingShipNav={billTo:!0,references:!1,shipmentDates:!1,zipcode:!1,consignee:!1,partContainer:!1};t.trackingViews={search:!0,show:!1};t.setTrackNavigation=function(n){t.trackingShipNav=_.mapObject(t.trackingShipNav,function(){return!1});t.trackingShipNav[n]=!0};t.shipmentDocuments=[];t.shipmentImages=[];t.documentTypes=[];t.selectedDocumentType=null;t.shipmentForm={Files:{Documents:[],Images:[]}};t.showTracking=function(n){t.trackLoaded=!1;t.trackLoading=!0;n.InternationalOrDomestic=="I"&&n.ExportOrImport=="I"?s.getInternationalShipmentById(n.ID).then(function(n){t.trackLoaded=!0;t.showShipment=n.data[0];t.showShipment.MemoNotes=[];v(n.data[0]);t.showShipment.mileStonesHash={};_.each(t.showShipment.MileStone,function(n){t.showShipment.mileStonesHash[n.KEY.replace(/\s/g,"")]=n});h._setTrackedShow(t.showShipment);y();t.showShipment.PODInfo=p()}).catch(function(n){console.log(n)}):n.InternationalOrDomestic=="I"&&n.ExportOrImport=="E"?s.getInternationalExportShipmentByID(n.ID).then(function(n){t.trackLoaded=!0;t.showShipment=n.data[0];t.showShipment.MemoNotes=[];v(n.data[0]);t.showShipment.mileStonesHash={};_.each(t.showShipment.MileStone,function(n){t.showShipment.mileStonesHash[n.KEY.replace(/\s/g,"")]=n});h._setTrackedShow(t.showShipment);y();t.showShipment.PODInfo=p()}).catch(function(n){console.log(n)}):s.getShipmentById(n.ID).then(function(n){t.trackLoaded=!0;t.showShipment=n.data[0];t.showShipment.MemoNotes=[];v(n.data[0]);t.showShipment.mileStonesHash={};_.each(t.showShipment.MileStone,function(n){t.showShipment.mileStonesHash[n.KEY.replace(/\s/g,"")]=n});h._setTrackedShow(t.showShipment);y();t.showShipment.PODInfo=p()}).catch(function(n){console.log(n)})};v=function(n){_.each(n.TraceNotes,function(n){n.ExternallyAvailable&&(n.Memo.indexOf("POD")!=0&&n.Memo.indexOf("DELIVERED")==-1?n.LastUpdateDate=parseInt(n.LastUpdateDate.match(/(\d+)|(-\d+)/)[0]):(n.LastUpdateDate=null,n.LastUpdateTime=null),t.showShipment.MemoNotes.push(n))})};t.resetShow=function(){t.showShipment=null;t.trackLoading=!1};y=function(){t.showShipment.DeliveryDate={};t.showShipment.ShipDate={};t.showShipment.StaticDeliveryDate={};t.showShipment.StaticShipDate={};_.each(t.showShipment.Tracking,function(n){var i,r;n.Key=="READY"?(t.showShipment.ShipDate=parseInt(n.TrackDate.match(/(\d+)|(-\d+)/)[0]),t.showShipment.StaticShipDate=n.StaticTrackDate.toString()):n.Key=="POD"?(i=parseInt(n.TrackDate.match(/(\d+)|(-\d+)/)[0]),t.showShipment.DeliveryDate=i>0?i:null):n.Key=="SCHEDULEDDELIVERY"&&(r=parseInt(n.TrackDate.match(/(\d+)|(-\d+)/)[0]),r>0?(t.showShipment.ScheduledDelivery=r,t.showShipment.StaticDeliveryDate=n.StaticTrackDate.toString(),t.showShipment.ScheduledTime=n.TrackTime):(t.showShipment.ScheduledDelivery=null,t.showShipment.StaticDeliveryDate=null,t.showShipment.ScheduledTime=null))})};p=function(){var n={};return _.each(t.showShipment.Tracking,function(i){if(i.Key=="POD"){var r=i.TrackTime,u=parseInt(i.TrackDate.match(/(\d+)|(-\d+)/)[0]);n.DocType=i.Key;n.TrackingName=i.TrackingName;n.TrackTime=r>0?r:null;n.TrackDate=u>0?u:null;_.each(t.showShipment.DocuHeader,function(t){if(t.DOCTYPEDESCRIPTION=="POD")return n.DOCTYPEDESCRIPTION=t.DOCTYPEDESCRIPTION,n.DOCURL=t.DOCURL,n})}}),n};t.$watch(function(){return h._trackedShipments},function(n){n&&(t.trackingSubmitted=!0,t.trackedShipments=h._trackedShipments)});t.sortToggle={bill:!1,shipName:!1,shipCity:!1,consigneeName:!1,consigneCity:!1,deliveryDate:!1,shipDate:!0};t.orderHeader="ShipDate";t.reverse=!0;t.order=function(n,i){t.reverse=t.orderHeader===n?!t.reverse:!1;t.orderHeader=n;t.sortToggle=_.mapObject(t.sortToggle,function(){return!1});t.sortToggle[i]=!0};t.status={plannerMonth:!1};t.openMonth=function(){t.status.plannerMonth=!0};b=function(n){return n.DeliveryDate?new Date(n.DeliveryDate).toLocaleDateString():""};t.renderEvent=function(n,r){var u="<div class='tooltip-wrapper'><div class='tooltip-info-field'><p>AGS BOL:<\/p><p>"+n.HouseAirWaybillNumber+"<\/p><\/div>";u=u+"<div class='tooltip-info-field'><p>Ship Ref:<\/p><p>"+n.ShipperReferenceNumber+"<\/p><\/div>";u=u+"<div class='tooltip-info-field'><p>Consig Ref:<\/p><p>"+n.ConsigneeReferenceNumber+"<\/p><\/div>";u=u+"<div class='tooltip-info-field'><p>Shipped:<\/p><p>"+n.StaticTrackDate.split(" ")[0]+"<\/p><\/div>";u=u+"<div class='tooltip-info-field'><p>Delivered:<\/p><p>"+b(n)+"<\/p><\/div>";u=u+"<div class='tooltip-info-field'><p>Pieces:<\/p><p>"+n.TotalPieces+"<\/p><\/div>";u=u+"<div class='tooltip-info-field'><p>Chg.Weight:<\/p><p>"+n.ChargeableWeight+"<\/p><\/div><\/div>";r.tooltip({container:".planner-wrapper",title:u,html:!0});i(r)(t)};t.dataShipments=[];t.searchShipment=function(n){t.showTracking(n)};t.forwardMonth=function(n){n&&(t.trackedShipmentList=null,$(".calendar").fullCalendar("gotoDate",$.fullCalendar.moment(n)))};t.eventsF=function(n,i,r,u){t.trackedShipmentList=null;c.trackShipmentByBilltoByReadyDate(n._d,i._d).then(function(n){t.unFilteredList=n.data;t.trackedShipmentList=l("filter")(n.data,{OrderQuoteCallBack:"O"});t.schedulePlannerSetDates();u(t.trackedShipmentList)}).catch(function(n){t.trackedShipmentList=[];console.log(n)})};t.schedulePlannerSetDates=function(){_.each(t.trackedShipmentList,function(n){n.DeliveryDate={};n.ShipDate={};n.title=n.HouseAirWaybillNumber;n.ShipDate=parseInt(n.ReadyDate.match(/(\d+)|(-\d+)/)[0]);n.start=n.ShipDate;var t=parseInt(n.PODDate.match(/(\d+)|(-\d+)/)[0]);n.DeliveryDate=t>0?t:null})};t.shipmentEvents={color:"#3062A9",textColor:"white"};t.eventsSource=[t.shipmentEvents,t.eventsF];t.uiConfig={calendar:{eventRender:t.renderEvent,eventClick:t.searchShipment}};t.toggleTrackType=!0;t.toggleTrackShow=function(){t.toggleTrackType=!t.toggleTrackType};t.modalPathUrls={trackShipments:"../../Angular/Directives/modals/my_tracking_modals/track-shipments-help.html",shipmentPlanner:"../../Angular/Directives/modals/my_tracking_modals/shipment-planner-help.html"};t.animationsEnabled=!0;t.openHelp=function(n,i,r){var u=e.open({animation:!0,templateUrl:t.modalPathUrls[r],controller:"helpModalCtrl",size:n,resolve:{helpTitle:function(){return i}}})};w=function(n){_.find(t.shipmentDocuments,function(t){return t.file==n?!0:!1})};s.getDocumentTypes().then(function(n){t.documentTypes=_.reject(n.data,function(n){return n.DOCTYPE==="IMAGE"})}).catch(function(n){console.log(n)});t.addDocument=function(n){n&&!w(n)&&(t.shipmentDocuments.push({type:t.selectedDocumentType,file:n}),t.selectedDocumentType=null,console.log(n),t.shipmentForm.Files.Documents=t.shipmentDocuments,t.$apply)};t.onDocTypeChange=function(n){t.selectedDocumentType=n};t.addImage=function(n){!n||$.inArray(n,t.shipmentImages)>-1||(console.log(n),t.shipmentImages.push(n),t.currentImagePreview=t.shipmentImages[t.shipmentImages.length-1],t.shipmentForm.Files.Images=t.shipmentImages,t.$apply)};t.removeDocumentFile=function(n){var i=t.shipmentDocuments.indexOf(n);t.shipmentDocuments.splice(i,1);t.shipmentForm.Files.Documents=angular.copy(t.shipmentDocuments);t.$apply};t.removeImageFile=function(n){var i=t.shipmentImages.indexOf(n);t.shipmentImages.splice(i,1);t.currentImagePreview=t.shipmentImages[t.shipmentImages.length-1];t.shipmentForm.Files.Images=angular.copy(t.shipmentImages);t.$apply};w=function(n){_.find(t.shipmentDocuments,function(t){return t.file==n?!0:!1})};t.getModelAsFormData=function(){var n=new FormData;return t.shipmentDocuments.length>0&&angular.forEach(t.shipmentDocuments,function(t){n.append("files",t.file);n.append("types",t.type)}),n};t.getImageAsFormData=function(){var n=new FormData;return t.shipmentImages.length>0&&angular.forEach(t.shipmentImages,function(t){n.append("images",t)}),n};t.uploadDocuments=function(){t.updating=!0;(t.shipmentDocuments.length>0||t.shipmentImages.length>0)&&n({url:"/tracking/UploadShipmentDocs",method:"POST",headers:{"Content-Type":undefined},transformRequest:angular.identity,data:t.getModelAsFormData()}).success(function(i){t.shipmentCreated=!0;t.updating=!1;i=="True"&&n({url:"/tracking/UploadImages",method:"POST",headers:{"Content-Type":undefined},transformRequest:angular.identity,data:t.getImageAsFormData()}).success(function(n){t.shipmentCreated=!0;t.updating=!1;n=="True"&&c.uploadDocuments(t.showShipment.ID,t.showShipment.HouseAirWaybillNumber).then(function(){}).catch(function(n){console.log(n);t.updating=!1})})})}}]);angular.module("factories.companyFactory",[]).factory("companyFactory",["$http","$location","$rootScope",function(n){return{getCompanyInfo:function(t){return n.get("/account/GetCompanyInfo",{params:{date:(new Date).getTime(),customerNum:t}})},getTeamDetails:function(t){return n.get("/account/GetTeamDetails",{params:{date:(new Date).getTime(),customerNum:t}})},getCustomerServices:function(t){return n.get("/account/GetCustomerServices",{params:{date:(new Date).getTime(),customerNum:t}})}}}]);angular.module("factories.internationalFactory",[]).factory("internationalFactory",["$http","$location","$rootScope",function(n){return{getCountries:function(){return n.get("/international/GetCountries",{params:{date:(new Date).getTime()}})},getIncoTerms:function(){return n.get("/international/GetIncoTerms",{params:{date:(new Date).getTime()}})},getAirports:function(){return n.get("/international/GetAirports",{params:{date:(new Date).getTime()}})},getInternationImportShipmentsByShipmentID:function(t){return n.get("/international/GetInternationImportShipmentsByShipmentID",{params:{shipmentId:t,date:(new Date).getTime()}})},getInternationalExportShipmentByID:function(t){return n.get("/international/GetInternationalExportShipmentByID",{params:{shipmentId:t,date:(new Date).getTime()}})},getAllInternationalShipmentByBilltoByReadyDate:function(t,i){return n.get("/international/GetAllInternationalShipmentByBilltoByReadyDate",{params:{fromDate:t,toDate:i,date:(new Date).getTime()}})},getAllInternationalImportShipmentByBilltoByReadyDate:function(t,i){return n.get("/international/GetAllInternationalImportShipmentByBilltoByReadyDate",{params:{fromDate:t,toDate:i,date:(new Date).getTime()}})},createOrUpdateImportOrExportEntry:function(t){var i=/\((.*)\)/.exec((new Date).toString())[1];return n.post("/international/CreateOrUpdateImportOrExportEntry?tzm="+i,t)},getAllPOLoads:function(){return n.get("/international/GetAllPOLoads",{params:{date:(new Date).getTime()}})},getNextPONumber:function(){return n.get("/international/GetNextPONumber",{params:{date:(new Date).getTime()}})},updateOrderILoadNumber:function(t){return n.post("/international/UpdateOrderILoadNumber",t)},manifestSelectedLoads:function(t){return n.post("/international/ManifestSelectedLoads",t)},pOMasterSave:function(t){return n.post("/international/POMasterSave",t)},getPOManifestByAgent:function(){return n.get("/international/GetPOManifestByAgent",{params:{date:(new Date).getTime()}})},getGoogleDocs:function(){return n.get("/international/GetGoogleDocs",{params:{date:(new Date).getTime()}})},googleDocSpreadSheetSave:function(t){return n.post("/international/GoogleDocSpreadSheetSave",t)},sendMail:function(t){return n.post("/international/SendMail",t)}}}]);angular.module("factories.quoteFactory",[]).factory("quoteFactory",["$http","$location","$rootScope",function(n){return{createOrUpdateQuote:function(t){return n.post("/quotes/CreateOrUpdateQuote",t)},getQuoteById:function(t){return n.get("/quotes/GetQuoteById",{params:{quoteId:t,date:(new Date).getTime()}})},getQuoteByIdFromStaging:function(t){return n.get("/quotes/GetQuoteByIdFromStaging",{params:{quoteId:t,date:(new Date).getTime()}})},getAllQuotes:function(t,i){return n.get("/quotes/GetAllQuotesByBilltoByReadyDate",{params:{fromDate:t,toDate:i,date:(new Date).getTime()}})},getAdditionalCharges:function(){return n.get("/quotes/GetAdditionalCharges",{params:{date:(new Date).getTime()}})},getServiceRequest:function(){return n.get("/quotes/GetServiceRequest",{params:{date:(new Date).getTime()}})},activateQuote:function(t,i){return n.post("/quotes/ActivateQuote",{quoteId:t,fileStatus:i})},generateQuote:function(t,i){return n.post("/quotes/GenerateQuote",{quoteId:t,fileStatus:i})},sendMail:function(t){return n.post("/quotes/SendMail",t)},getQuickQuote:function(t,i,r,u,f,e,o,s,h,c,l,a,v,y,p,w,b,k,d,g,nt,tt,it,rt,ut,ft,et,ot){return n.post("/quotes/GetQuickQuote",{originState:t,originZip:i,destState:r,destZip:u,totalPieces:f,weight:e,charge1:o,sequence1:s,charge2:h,sequence2:c,charge3:l,sequence3:a,charge4:v,sequence4:y,charge5:p,sequence5:w,charge6:b,sequence6:k,charge7:d,sequence7:g,charge8:nt,sequence8:tt,charge9:it,sequence9:rt,charge10:ut,sequence10:ft,services:et,pieces:ot})}}}]);angular.module("factories.reportFactory",[]).factory("reportFactory",["$http","$location","$rootScope",function(n){return{signupReport:function(t){return n.post("/clientportal/reports/ReportsSignup",t)},getAllDynamicReportsByUserId:function(){return n.get("/reports/GetAllDynamicReportsByUserId",{params:{date:(new Date).getTime()}})}}}]);angular.module("factories.shipmentFactory",[]).factory("shipmentFactory",["$http","$location","$rootScope",function(n){return{createOrUpdateShipment:function(t){return n.post("/shipment/CreateOrUpdateShipment",t)},getShipmentById:function(t){return n.get("/shipment/GetShipmentById",{params:{shipmentId:t,date:(new Date).getTime()}})},getInternationalShipmentById:function(t){return n.get("/shipment/GetInternationalShipmentById",{params:{shipmentId:t,date:(new Date).getTime()}})},getInternationalExportShipmentByID:function(t){return n.get("/shipment/GetInternationalExportShipmentByID",{params:{shipmentId:t,date:(new Date).getTime()}})},getShipmentFromStaging:function(t){return n.get("/shipment/getShipmentFromStaging",{params:{shipmentId:t,date:(new Date).getTime()}})},getAllShipmentsbyUserId:function(t,i){return n.get("/shipment/GetAllShipmentsByBilltoByUserIDByReadyDate",{params:{fromDate:t,toDate:i,date:(new Date).getTime()}})},getDocumentTypes:function(){return n.get("/shipment/GetDocumentTypes",{params:{date:(new Date).getTime()}})},getAdditionalCharges:function(t){return n.get("/shipment/GetAdditionalCharges",{params:{billTo:t,date:(new Date).getTime()}})},getServiceRequest:function(t){return n.get("/shipment/GetServiceRequest",{params:{billTo:t,date:(new Date).getTime()}})},sendMail:function(t){return n.post("/shipment/SendMail",t)},getAGSShipmentFields:function(){return n.get("/shipment/GetAGSShipmentFields",{params:{date:(new Date).getTime()}})},setAGSShipmentFields:function(t){return n.post("/shipment/SetAGSShipmentFields",t)},deleteShipment:function(t){return n.post("/shipment/DeleteShipment",{shipmentId:t})},requestEmailForDeleteShipment:function(t,i){return n.post("/shipment/RequestEmailForDeleteShipment",{shipmentId:t,houseNo:i})},getGoogleDocs:function(){return n.get("/shipment/GetGoogleDocs",{params:{date:(new Date).getTime()}})},getGroupCode:function(t){return n.get("/shipment/GetGroupCode",{params:{custNo:t,date:(new Date).getTime()}})}}}]);angular.module("factories.trackingFactory",[]).factory("trackingFactory",["$http","$location","$rootScope",function(n){return{trackShipmentByBillNumber:function(t){return n.get("/tracking/TrackShipmentByBillNumber",{params:{house:t,date:(new Date).getTime()}})},trackShipmentByBillNumberFromStaging:function(t){return n.get("/tracking/TrackShipmentByBillNumberFromStaging",{params:{house:t,date:(new Date).getTime()}})},trackShipmentByDateByReferenceOne:function(t,i,r){return n.get("/tracking/TrackShipmentByDateByReferenceOne",{params:{fromDateRefOne:t,toDateRefOne:i,reference:r,date:(new Date).getTime()}})},trackShipmentByDateByReferenceTwo:function(t,i,r){return n.get("/tracking/TrackShipmentByDateByReferenceTwo",{params:{fromDateRefTwo:t,toDateRefTwo:i,reference:r,date:(new Date).getTime()}})},trackShipmentByBilltoByDeliveryDate:function(t,i){return n.get("/tracking/TrackShipmentByBilltoByDeliveryDate",{params:{shipDate:t,deliveryDate:i,date:(new Date).getTime()}})},trackShipmentByBilltoByReadyDate:function(t,i){return n.get("/tracking/TrackShipmentByBilltoByReadyDate",{params:{fromDate:t,toDate:i,date:(new Date).getTime()}})},trackShipmentByDatePickUpZipCode:function(t,i,r,u){return n.get("/tracking/TrackShipmentByDatePickUpZipCode",{params:{pickupFromDate:t,pickupToDate:i,zipType:u,pickupZipcode:r,date:(new Date).getTime()}})},trackShipmentByDateByDeliveryZipCode:function(t,i,r,u){return n.get("/tracking/TrackShipmentByDateByDeliveryZipCode",{params:{deliveryFromDate:t,deliveryToDate:i,zipType:u,deliveryZipcode:r,date:(new Date).getTime()}})},trackShipmentByDatePart:function(t,i,r){return n.get("/tracking/TrackShipmentByDatePart",{params:{partNumber:t,partFromDate:i,partToDate:r,date:(new Date).getTime()}})},trackShipmentByContainer:function(t,i,r){return n.get("/tracking/TrackShipmentByContainer",{params:{containerNumber:t,containerFromDate:i,containerToDate:r,date:(new Date).getTime()}})},trackShipmentByConsinee:function(t,i,r){return n.get("/tracking/TrackShipmentByConsinee",{params:{consigneeName:t,consigneeFromDate:i,consigneeToDate:r,date:(new Date).getTime()}})},uploadDocuments:function(t,i){return n.post("/tracking/UploadDocuments",{shipmentId:t,houseAWB:i})}}}]);angular.module("factories.userFactory",[]).factory("userFactory",["$http","$location","$rootScope",function(n){return{checkAuth:function(){return n.get("/logon/IsAuthenticated",{params:{date:(new Date).getTime()}})},getUser:function(){return n.get("/logon/GetUserDetails",{params:{date:(new Date).getTime()}})},getLoggedInUser:function(){return n.get("/clientportal/account/GetLoggedInUser",{params:{date:(new Date).getTime()}})},getUserById:function(t){return n.get("/User/GetUserById",{params:{date:(new Date).getTime(),userId:t}})},getUserCategories:function(){return n.get("/user/GetUserCategories",{params:{date:(new Date).getTime()}})},createUser:function(t){return n.post("/adminportal/user/createUser",t)},updateUser:function(t){return n.post("/adminportal/user/updateUser",t)},updateUserStatus:function(t,i){return n.post("/adminportal/user/UpdateUserStatus",{userId:t,status:i})},getUserFeatures:function(){return n.get("/user/GetUserFeatures",{params:{date:(new Date).getTime()}})},getUsersByUserType:function(t){return n.get("/user/GetUsersByUserType",{params:{date:(new Date).getTime(),userTypeid:t}})},getCompanyTypes:function(){return n.get("/user/GetCompanyTypes",{params:{date:(new Date).getTime()}})},getMileStones:function(){return n.get("/user/GetMileStones",{params:{date:(new Date).getTime()}})},getStateProv:function(){return n.get("/user/GetStateProv",{params:{date:(new Date).getTime()}})},getClientRoles:function(){return n.get("/masterdata/GetClientRoles",{params:{date:(new Date).getTime()}})},createClientUser:function(t){return n.post("/account/createClientUser",t)},saveUserInfo:function(t){return n.post("/account/SaveUserInfo",t)},changePassword:function(t){return n.post("/account/changePassword",t)},getAddressBook:function(){return n.get("/account/GetAddressBook",{params:{date:(new Date).getTime()}})},createShipper:function(t){return n.post("/account/CreateShipper",t)},updateShipper:function(t){return n.post("/account/UpdateShipper",t)},getCustomPieceData:function(){return n.get("/account/GetCustomPieceData",{params:{date:(new Date).getTime()}})},insertCustomPieceData:function(t){return n.post("/account/InsertCustomPieceData",t)},updateCustomPieceData:function(){return n.post("/account/UpdateCustomPieceData",userPieces)},getUserSettings:function(){return n.get("/account/getUserSettings",{params:{date:(new Date).getTime()}})},getUserFeaturesByUserId:function(t){return n.get("/user/GetUserFeaturesByUserId",{userId:t})},getCompanyInfoByBillTo:function(t){return n.get("/account/GetCompanyInfoByBillTo",{params:{userId:t}})},getPiecesDefaults:function(){return n.get("/account/GetPiecesDefaults",{params:{date:(new Date).getTime()}})},createSMSOREmailUser:function(t){return n.post("/account/CreateSMSOREmailUser",t)},unSubscribeSMSOREmailUser:function(t){return n.post("/account/UnSubscribeSMSOREmailUser",t)},getSMSUserbymyAGSUserID:function(t,i){return n.get("/account/GetSMSUserbymyAGSUserID",{params:{userId:t,shipmentId:i}})},saveMileStonesWithShipmentID:function(t){return n.post("/account/SaveMileStonesWithShipmentID",t)},insertUpdateUserSettings:function(t){return n.post("/account/InsertUpdateUserSettings",{SVCTYPE:t.SVCTYPE,PICKUPTIME:t.PICKUPTIME==null?0:t.PICKUPTIME,CLOSETIME:t.CLOSETIME==null?0:t.CLOSETIME,REFLABEL1:t.REFLABEL1,REFLABEL2:t.REFLABEL2,SPEC1:t.SPEC1,SPEC2:t.SPEC2,SPEC3:t.SPEC3,SPEC4:t.SPEC4,SPEC5:t.SPEC5})},deleteCustomPieceData:function(t){return n.post("/account/DeleteCustomPieceData",{pieceId:t})},deleteAddressBook:function(t){return n.post("/account/DeleteAddressBook",{addressId:t})},getUserWithCopy:function(){return n.get("/account/GetUserWithCopy",{params:{date:(new Date).getTime()}})},createUserWithCopy:function(t){return n.post("/account/createUserWithCopy",t)},getUserPiecesWithCopy:function(){return n.get("/account/getUserPiecesWithCopy",{params:{date:(new Date).getTime()}})},getAddressBookWithCopy:function(){return n.get("/account/getAddressBookWithCopy",{params:{date:(new Date).getTime()}})}}}]);angular.module("services.internationalService",[]).service("internationalService",[function(){this._newExportEntryID=null;this._newImportEntryID=null;this._importEntry=null;this._copiedImportEntry=null;this._returnedImportEntry=null;this._exportEntry=null;this._copiedExportEntry=null;this._returnedExportEntry=null;this._folderView=null;this.setNewExportEntry=function(n){return this._newExportEntryID=n,this._newExportEntryID};this.setNewImportEntry=function(n){return this._newImportEntryID=n,this._newImportEntryID};this.resetsAllEntries=function(){this._newEntryID=null;this._copiedImportEntry=null;this._returnedImportEntry=null;this._importEntry=null;this._exportEntry=null;this._copiedExportEntry=null;this._returnedExportEntry=null};this.setToFolder=function(n){return this._folderView=n,this._folderView};this.resetFolder=function(){return this._folderView=null,this._folderView};this.setImportEntry=function(n){return this._importEntry=n,this._importEntry};this.setExportEntry=function(n){return this._exportEntry=n,this._exportEntry};this.copyImportEntry=function(n){return this._copiedImportEntry=null,this._returnedImportEntry=null,n&&(this._copiedImportEntry=n),this._copiedImportEntry};this.copyExportEntry=function(n){return this._copiedExportEntry=null,this._returnedExportEntry=null,n&&(this._copiedExportEntry=n),this._copiedExportEntry};this.returnImportEntry=function(n){return this._copiedImportEntry=null,this._returnedImportEntry=null,this._returnedImportEntry=n,this._returnedImportEntry};this.returnExportEntry=function(n){return this._copiedExportEntry=null,this._returnedExportEntry=null,this._returnedExportEntry=n,this._returnedExportEntry}}]);angular.module("services.poLoadService",[]).service("poLoadService",["shipmentFactory",function(){this._loadList=[];this._shipments=null;this.mockShipmentEntryUpdate=function(t){n(t,this._shipments)};this.resetLoadList=function(){this._loadList=[]};this.setShipments=function(n){return this._shipments=n,this._shipments};var n=function(n,t){for(var i=0;i<t.length;i++)t[i].ID===n&&t.splice(i,1)}}]);angular.module("services.quoteService",[]).service("quoteService",[function(){this._quote=null;this._copiedQuote=null;this._activateQuote=null;this._reloadQuote=null;this.setReloadQuote=function(n){return this._reloadQuote=n,this._reloadQuote};this.setQuote=function(n){return this._quote=n,this._quote};this.copyQuote=function(n){return this._copiedQuote=n,this._copiedQuote};this.clear=function(){return this._activateQuote=null,this._copiedQuote=null,this._quote};this.activate=function(n){return this._activateQuote=null,n&&(this._activateQuote=n),this._activateQuote}}]);angular.module("services.shipmentService",[]).service("shipmentService",[function(){this._shipment=null;this._updateShipment=null;this._copiedShipment=null;this._returnedShipment=null;this._newShipmentID=null;this._reloadRoute=null;var n={},t=[{field:"ShipperName"},{field:"ShipperCity"},{field:"ShipperStateProvince"},{field:"ShipperReferenceNumber"},{field:"ConsigneeName"},{field:"ConsigneeCity"},{field:"ConsigneeStateProvince"},{field:"ConsigneeReferenceNumber"},{field:"TotalPieces"},{field:"ChargeableWeight"},{field:"Service"},{field:"ShipDate"},{field:"DeliveryDate"},];this.setSelectedFields=function(t){n=t};this.getSelectedFields=function(){return n};this.getFields=function(){return t};this.setReloadRoute=function(n){return this._reloadRoute=n,this._reloadRoute};this.setShipment=function(n){return this._shipment=n,this._shipment};this.editShipment=function(n){return this._updateShipment=n,this._updateShipment};this.setNewShipment=function(n){return this._newShipmentID=n,this._newShipmentID};this.resetShipments=function(){this._updateShipment=null;this._copiedShipment=null;this._returnedShipment=null};this.copyShip=function(n){return this._copiedShipment=null,this._returnedShipment=null,n&&(this._copiedShipment=n),this._copiedShipment};this.returnShip=function(n){return this._copiedShipment=null,this._returnedShipment=null,n&&(this._returnedShipment=n),this._returnedShipment}}]);angular.module("services.trackingService",[]).service("trackingService",[function(){this._trackedShipments=null;this._showTrackedShipment=null;this.setTrackedShipments=function(n){return this._trackedShipments=n,this._trackedShipments};this._setTrackedShow=function(n){return this._showTrackedShipment=n,this._showTrackedShipment}}]);angular.module("services.userService",[]).service("userService",["userFactory","companyFactory","$rootScope",function(n,t,i){this._user=null;this.rootUser=function(){n.checkAuth().then(function(t){t.data.isAuthenticated==!0?n.getUser().then(function(n){return i.user=n.data,r(),u(),f(),i.user}).catch(function(n){console.log(n)}):console.log(t.data.isAuthenticated)}).catch(function(){console.log(error)})};var r=function(){i.user.fcategory==1?i.user.agsAdmin=!0:i.user.fcategory==2?i.user.agsCorporate=!0:i.user.fcategory==3?i.user.customerAdmin=!0:i.user.agsCustomer=!0},u=function(){n.getUserById(i.user.auton).then(function(n){i.user.features={};_.each(n.data.features,function(n){var t=n.FeatureName.replace(/\s+/g,"");t=="InternationalImport Entry"?i.user.features.InternationalImportEntry=n.OnOff:t=="InternationalExport Entry"?i.user.features.InternationalExportEntry=n.OnOff:t=="PickupFolder List"?i.user.features.PickupFolderList=n.OnOff:i.user.features[t]=n.OnOff})}).catch(function(){})},f=function(){t.getCompanyInfo(i.user.custNo).then(function(n){i.user.company=n.data[0]?n.data[0].company:null}).catch(function(n){i.user.company=null;console.log(n)})}}]);angular.module("directive.createUsers",[]).directive("createUsers",[function(){return{restrict:"E",scope:{},templateUrl:"../../Angular/Directives/admin/create_users/create-users.html"}}]).controller("createUsersCtrl",["$http","$scope","$location","$timeout","$window","userFactory","companyFactory",function(n,t,i,r,u,f){var h,o,c,s,e;t.formSubmitted=!1;t.infoSaved=!1;t.formIncomplete=!1;t.newUserInfo={MULTI:[]};t.priorUserForm={EMAIL:""};t.userType=null;t.userCategories=null;t.getStateProv=null;t.getCompanyTypes=null;f.getUserCategories().then(function(n){t.userCategories=n.data}).catch(function(n){console.log(n)});f.getStateProv().then(function(n){t.stateProvinces=n.data}).catch(function(n){console.log(n)});f.getCompanyTypes().then(function(n){t.companyCategories=n.data}).catch(function(n){console.log(n)});f.getUserFeatures().then(function(n){t.newUserInfo.userFeatures=n.data}).catch(function(n){console.log(n)});t.priorUserEmail=null;h=function(){if(t.newUserInfo.MULTI=[],t.newUserInfo.MULTIBILLTO){var n=[];n=t.newUserInfo.MULTIBILLTO.split(",");_.each(n,function(n){t.newUserInfo.MULTI.push(parseInt(n))});console.log(t.newUserInfo.MULTI)}else console.log("I can't make an array. Enter some numbers.")};t.saveUser=function(n){t.errorMessage=null;t.formSubmitted=!0;n&&t.passwordCheck?(s(),t.disableCreateUser=!0,t.createSpinner=!0,f.createUser(t.newUserInfo).then(function(n){t.createSpinner=!1;n.data>0?t.infoSaved=!0:t.errorMessage=n.data==-1?"Email already exists!..":n.data==-2?"Invalid BillTo!..":n.data==-3?"Invalid Customer Number!..":"Form did not save. Submit again.";r(function(){o()},2e3)}).catch(function(n){t.createSpinner=!1;t.disableCreateUser=!1;t.errorMessage="Form did not save. Submit again.";console.log(n)})):n?t.passwordCheck?(t.createSpinner=!1,t.disableCreateUser=!1,t.errorMessage="Form did not save. Submit again."):(t.createSpinner=!1,t.disableCreateUser=!1,t.errorMessage="Invalid Password."):(t.createSpinner=!1,t.disableCreateUser=!1,t.errorMessage="Form must be complete before submitting.")};o=function(){t.formSubmitted=!1;t.infoSaved=!1;t.formIncomplete=!1;t.disableCreateUser=!1};t.clearForm=function(){t.newUserInfo={};t.userCategories=null;t.getStateProv=null;t.getCompanyTypes=null;t.errorMessage=null;f.getUserCategories().then(function(n){t.userCategories=n.data}).catch(function(n){console.log(n)});f.getStateProv().then(function(n){t.stateProvinces=n.data}).catch(function(n){console.log(n)});f.getCompanyTypes().then(function(n){t.companyCategories=n.data}).catch(function(n){console.log(n)});f.getUserFeatures().then(function(n){t.newUserInfo.userFeatures=n.data}).catch(function(n){console.log(n)})};c=function(){return t.newUserInfo.EMAIL==t.priorUserEmail?!0:!1};s=function(){var n=t.newUserInfo.EMAIL;t.priorUserEmail=n};t.generateTempPassword=function(){for(var i="",r="ABCDEFGHIJKLMNOPQRSTUVWXYZ",u="1234567890",f="@#%&*$#",n=5;n>0;n--)i+=r[Math.floor(Math.random()*r.length)];for(n=2;n>0;n--)i+=u[Math.floor(Math.random()*u.length)];i+=f[Math.floor(Math.random()*f.length)];t.newUserInfo.PASSWORD=i;t.newUserInfo.CONFRIMPASSWORD=i};t.$watch("newUserInfo.PASSWORD",function(n){n&&t.checkPassword()});t.$watch("newUserInfo.CONFRIMPASSWORD",function(n){n&&t.checkPassword()});t.setUserSettings=function(){t.newUserInfo.FKCATEGORY==1?(e(),_.each(t.newUserInfo.userFeatures,function(n){n.OnOff=!0})):t.newUserInfo.FKCATEGORY==2?e():t.newUserInfo.FKCATEGORY==3?(e(),_.each(t.newUserInfo.userFeatures,function(n){n.OnOff=!0})):t.newUserInfo.FKCATEGORY==4?(e(),_.each(t.newUserInfo.userFeatures,function(n){n.FeatureName==="Pickup Entry"?n.OnOff=!0:n.FeatureName==="Tracking"?n.OnOff=!0:n.FeatureName==="Pickup Folder List"?n.OnOff=!0:n.FeatureName==="International Import Entry"?n.OnOff=!0:n.FeatureName==="International Export Entry"?n.OnOff=!0:n.FeatureName==="International Folder"?n.OnOff=!0:n.FeatureName==="Documents"?n.OnOff=!0:n.FeatureName==="PO Manager"?n.OnOff=!0:n.FeatureName==="Quotes"?n.OnOff=!0:n.FeatureName==="Quotes Folder"?n.OnOff=!0:n.FeatureName==="PO Load"?n.OnOff=!0:n.FeatureName==="PO MANIFEST"?n.OnOff=!0:n.FeatureName==="PO MASTER"&&(n.OnOff=!0)})):t.newUserInfo.FKCATEGORY==5?(e(),_.each(t.newUserInfo.userFeatures,function(n){n.FeatureName==="Tracking"?n.OnOff=!0:n.FeatureName==="Reports"&&(n.OnOff=!0)})):t.newUserInfo.FKCATEGORY==6?(e(),_.each(t.newUserInfo.userFeatures,function(n){n.FeatureName==="Tracking"?n.OnOff=!0:n.FeatureName==="Reports"&&(n.OnOff=!0)})):t.newUserInfo.FKCATEGORY==7?(e(),_.each(t.newUserInfo.userFeatures,function(n){n.FeatureName==="Tracking"?n.OnOff=!0:n.FeatureName==="Pickup Folder List"?n.OnOff=!0:n.FeatureName==="Quotes"?n.OnOff=!0:n.FeatureName==="Quotes Folder"?n.OnOff=!0:n.FeatureName==="Reports"?n.OnOff=!0:n.FeatureName==="Financial Reports"&&(n.OnOff=!0)})):t.newUserInfo.FKCATEGORY==8&&(e(),_.each(t.newUserInfo.userFeatures,function(n){n.FeatureName==="Tracking"?n.OnOff=!0:n.FeatureName==="Pickup Folder List"?n.OnOff=!0:n.FeatureName==="Reports"?n.OnOff=!0:n.FeatureName==="Financial Reports"&&(n.OnOff=!0)}))};e=function(){_.each(t.newUserInfo.userFeatures,function(n){n.OnOff=!1})};t.checkPassword=function(){var n=/^(?=.*[A-Z])(?=.*\d)(?=.*[$@$!%*#?&])[A-Za-z\d$@$!%*#?&]{8,}/.test(t.newUserInfo.PASSWORD);t.newUserInfo.PASSWORD!=t.newUserInfo.CONFRIMPASSWORD&&t.newUserInfo.PASSWORD?(t.passwordCheck=!1,t.passwordErrorMessage="Passwords do not match."):n?t.passwordCheck=!0:(t.passwordCheck=!1,t.passwordErrorMessage="Minimum 8 characters, at least 1 Uppercase letter, 1 number, and 1 special character")}}]);angular.module("directive.updateUsers",[]).directive("updateUsers",[function(){return{restrict:"E",scope:{},templateUrl:"../../Angular/Directives/admin/update_users/update-users.html"}}]).controller("updateUsersCtrl",["$http","$scope","$location","$timeout","$window","userFactory",function(n,t,i,r,u,f){t.imageUrl="/Content/images/ags-icon.png";t.getStateProv=[];t.getCompanyTypes=[];f.getUserCategories().then(function(n){t.userTypes=n.data}).catch(function(n){console.log(n)});f.getStateProv().then(function(n){t.stateProvinces=n.data}).catch(function(n){console.log(n)});f.getCompanyTypes().then(function(n){t.companyCategories=n.data}).catch(function(n){console.log(n)});t.getUsers=function(n){t.spinner=!0;t.foundUsers=null;t.selectedUser=null;t.searchText=null;f.getUsersByUserType(n>0?n:t.userType.id).then(function(n){t.spinner=!1;t.foundUsers=n.data}).catch(function(n){console.log(n)})};t.getUser=function(n){t.selectedUser=null;t.spinner=!0;f.getUserById(n.userId).then(function(n){t.spinner=!1;t.selectedUser=n.data.user;t.selectedUser.UserFeatures=n.data.features}).catch(function(n){console.log(n)})};t.userUpdate=function(n){t.formSubmitted=!0;t.disableUpdateUser=!0;t.updateSpinner=!0;n?(t.formIncomplete=!1,f.updateUser(t.selectedUser).then(function(){t.infoSaved=!0;t.disableUpdateUser=!1;t.updateSpinner=!1;r(function(){e()},3e3)}).catch(function(n){console.log(n)})):(t.disableUpdateUser=!1,t.updateSpinner=!1,t.formIncomplete=!0,e())};t.setStatus=function(n,i){f.updateUserStatus(n.userId,i).then(function(){t.getUsers(t.userType)}).catch(function(n){console.log(n)})};var e=function(){t.infoSaved=null}}]);angular.module("directive.corporatePswd",[]).directive("corporatePswd",[function(){return{restrict:"E",scope:{},templateUrl:"../../Angular/Directives/admin/corporate_pswd/corporate-pswd.html"}}]).controller("corporatePswdCtrl",["$http","$scope","$location","$timeout","$window",function(n,t){t.ctrlMessage="Hey! This is a message from corporatePswdCtrl"}]);angular.module("directive.spreadSheets",[]).directive("spreadSheets",[function(){return{restrict:"E",scopre:{},templateUrl:"../../Angular/Directives/admin/spread_sheets/spread-sheets.html"}}]).controller("spreadSheetsCtrl",["$http","$scope","$location","$timeout","$window","internationalFactory",function(n,t,i,r,u,f){t.newSheets={};t.createSpreadSheet=function(n){t.formSubmitted=!0;t.disableCreateSheet=!0;t.errorMessage=null;n?(f.googleDocSpreadSheetSave(t.newSheets).then(function(n){t.newSheets=n.data}).catch(function(n){console.log(n)}),r(function(){t.disableCreateSheet=!1;t.sheetCreated=!0;t.newSheets={};e()},1e3)):(t.disableCreateSheet=!1,t.errorMessage="Complete the form before submitting.")};var e=function(){t.formSubmitted=!1;r(function(){t.disableCreateSheet=!1;t.sheetCreated=!1;t.errorMessage=null},3e3)}}]);angular.module("directive.addressBook",[]).directive("addressBook",[function(){return{restrict:"E",scope:{},templateUrl:"../../Angular/Directives/my_account/address_book/address-book.html"}}]).controller("addressBookCtrl",["$http","$scope","$location","$timeout","$window","$filter","$uibModal","userFactory",function(n,t,i,r,u,f,e,o){var s,h;o.getStateProv().then(function(n){t.stateProvinces=n.data}).catch(function(n){console.log(n)});s=function(n){n==="shipper"?o.getAddressBook().then(function(n){if(t.shipperAddresses=f("filter")(n.data,{CUSTTYPE:"S"}),t.shipperAddresses.length>0){var i=f("filter")(t.shipperAddresses,{NAME:t.currentShipper.NAME})[0];t.currentShipper=i}}).catch(function(n){console.log(n)}):n==="consignee"?o.getAddressBook().then(function(n){if(t.consigneeAddresses=f("filter")(n.data,{CUSTTYPE:"C"}),t.consigneeAddresses.length>0){var i=f("filter")(t.consigneeAddresses,{NAME:t.currentConsignee.NAME})[0];t.currentConsignee=i}}).catch(function(n){console.log(n)}):o.getAddressBook().then(function(n){t.shipperAddresses=f("filter")(n.data,{CUSTTYPE:"S"});t.consigneeAddresses=f("filter")(n.data,{CUSTTYPE:"C"});t.shipperAddresses.length>0&&(t.currentShipper=f("filter")(t.shipperAddresses,{DEFAULTADDRESS:!0})[0]);t.consigneeAddresses.length>0&&(t.currentConsignee=f("filter")(t.consigneeAddresses,{DEFAULTADDRESS:!0})[0])}).catch(function(n){console.log(n)})};s();t.saveShipper=function(n){t.shipperSubmitted=!0;t.shipperErrorMessage=null;t.currentShipper.CUSTTYPE="S";n?(t.disableSaveShipper=!0,t.shipperSpinner=!0,t.currentShipper.AUTON>0?(t.currentShipper.CONTACT=t.currentShipper.CONTACT?t.currentShipper.CONTACT:" ",t.currentShipper.COUNTRY=t.currentShipper.COUNTRY?t.currentShipper.COUNTRY:" ",o.updateShipper(t.currentShipper).then(function(){t.shipperSubmitted=!1;t.shipperSpinner=!1;t.disableSaveShipper=!1;t.shipperSaved=!0;s("shipper");h()}).catch(function(n){t.shipperSpinner=!1;t.disableSaveShipper=!1;t.shipperErrorMessage="Form did not save. Submit again.";console.log(n)})):(t.currentShipper.CONTACT=t.currentShipper.CONTACT?t.currentShipper.CONTACT:" ",t.currentShipper.COUNTRY=t.currentShipper.COUNTRY?t.currentShipper.COUNTRY:" ",o.createShipper(t.currentShipper).then(function(){t.shipperSpinner=!1;t.disableSaveShipper=!1;t.shipperSaved=!0;s("shipper");h()}).catch(function(n){t.shipperSpinner=!1;t.disableSaveShipper=!1;t.shipperErrorMessage="Form did not save. Submit again.";console.log(n)}))):n||(t.shipperSpinner=!1,t.disableSaveShipper=!1,t.shipperErrorMessage="Form must be complete before submitting.")};t.saveConsignee=function(n){t.consigneeSubmitted=!0;t.consigneeErrorMessage=null;t.currentConsignee.CUSTTYPE="C";n?(t.disableSaveConsignee=!0,t.consigneeSpinner=!0,t.currentConsignee.AUTON>0?(t.currentConsignee.CONTACT=t.currentConsignee.CONTACT?t.currentConsignee.CONTACT:" ",t.currentConsignee.COUNTRY=t.currentConsignee.COUNTRY?t.currentConsignee.COUNTRY:" ",o.updateShipper(t.currentConsignee).then(function(){t.consigneeSubmitted=!1;t.consigneeSpinner=!1;t.disableSaveConsignee=!1;t.consigneeSaved=!0;s("consignee");h()}).catch(function(n){t.consigneeSpinner=!1;t.disableSaveConsignee=!1;t.consigneeErrorMessage="Form did not save. Submit again.";console.log(n)})):(t.currentConsignee.CONTACT=t.currentConsignee.CONTACT?t.currentConsignee.CONTACT:" ",t.currentConsignee.COUNTRY=t.currentConsignee.COUNTRY?t.currentConsignee.COUNTRY:" ",o.createShipper(t.currentConsignee).then(function(){t.consigneeSpinner=!1;t.disableSaveConsignee=!1;t.infoSaved=!0;s("consignee");h()}).catch(function(n){t.consigneeSpinner=!1;t.disableSaveConsignee=!1;t.consigneeErrorMessage="Form did not save. Submit again.";console.log(n)}))):n||(t.consigneeSpinner=!1,t.disableSaveConsignee=!1,t.consigneeErrorMessage="Form must be complete before submitting.")};t.deleteAddressBook=function(n){o.deleteAddressBook(n).then(function(){o.getAddressBook().then(function(n){t.currentShipper={};t.shipperAddresses=f("filter")(n.data,{CUSTTYPE:"S"});t.currentConsignee={};t.consigneeAddresses=f("filter")(n.data,{CUSTTYPE:"C"})})}).catch(function(n){console.log(n)})};h=function(){r(function(){t.shipperSubmitted=!1;t.consigneeSubmitted=!1;t.shipperSaved=!1;t.consigneeSaved=!1;t.disableSaveShipper=!1;t.disableSaveConsignee=!1},2e3)};t.modalPathUrls={shipper:"../../Angular/Directives/modals/my_account_modals/address_book/address-shipper-help.html",consignee:"../../Angular/Directives/modals/my_account_modals/address_book/address-consignee-help.html"};t.animationsEnabled=!0;t.openHelp=function(n,i,r){var u=e.open({animation:!0,templateUrl:t.modalPathUrls[r],controller:"helpModalCtrl",size:n,resolve:{helpTitle:function(){return i}}})}}]);angular.module("directive.myInfo",[]).directive("myInfo",[function(){return{restrict:"E",scope:{},templateUrl:"../../Angular/Directives/my_account/my_info/my-info.html"}}]).directive("passwordVerify",function(){return{require:"ngModel",scope:{passwordVerify:"="},link:function(n,t,i,r){n.$watch(function(){var t;return(n.passwordVerify||r.$viewValue)&&(t=n.passwordVerify+"_"+r.$viewValue),t},function(t){t&&r.$parsers.unshift(function(t){var i=n.passwordVerify;return i!==t?(r.$setValidity("passwordVerify",!1),undefined):(r.$setValidity("passwordVerify",!0),t)})})}}}).controller("myInfoCtrl",["$http","$scope","$location","$timeout","$window","$uibModal","userFactory","companyFactory",function(n,t,i,r,u,f,e,o){t.formSubmitted=!1;t.infoSaved=!1;t.formIncomplete=!1;e.getLoggedInUser().then(function(n){e.getUserById(n.data).then(function(n){t.currentUser=n.data.user;o.getCompanyInfo(t.currentUser.CUSTOMERNUM).then(function(n){t.companyInfo=n.data[0]}).catch(function(n){t.companyInfo=[];console.log(n)});o.getTeamDetails(t.currentUser.CUSTOMERNUM).then(function(n){t.myAccountTeam=n.data}).catch(function(n){t.myAccountTeam=[];console.log(n)})}).catch(function(n){console.log(n)})}).catch(function(n){console.log(n)});t.infoNav={myInfo:!0,myPswd:!1};t.setInfoNav=function(n){t.infoNav=_.object(_.map(t.infoNav,function(n,t){return[t,!1]}));t.infoNav[n]=!0};t.changePassword=function(n){t.errorMessage=null;t.passwordSubmitted=!0;n&&h()?e.changePassword(t.currentUser).then(function(n){n.data.message!=""&&(t.errorMessage=n.data.message);t.passwordSubmitted=!1;t.infoSaved=n.data.message==""?!0:!1;t.createSpinner=!1;t.disableCreateUser=!1;r(function(){s()},2e3)}).catch(function(n){t.createSpinner=!1;t.disableCreateUser=!1;t.errorMessage="Form did not save. Submit again.";console.log(n)}):n||(t.createSpinner=!1,t.disableChangePassword=!1,t.errorMessage="Form must be complete before submitting.")};t.saveUserInfo=function(n){t.errorMessage=null;t.formSubmitted=!0;n?(t.disableCreateUser=!0,t.createSpinner=!0,e.saveUserInfo(t.currentUser).then(function(){t.createSpinner=!1;t.disableCreateUser=!1;t.infoSaved=!0;r(function(){s()},2e3)}).catch(function(n){t.createSpinner=!1;t.disableCreateUser=!1;t.errorMessage="Form did not save. Submit again.";console.log(n)})):n?checkDuplicateForm()?(t.createSpinner=!1,t.disableCreateUser=!1,t.errorMessage="Duplicate Form. Change email to submit."):t.checkPasswordMatch()?(t.createSpinner=!1,t.disableCreateUser=!1,t.errorMessage="Form did not save. Submit again."):(t.createSpinner=!1,t.disableCreateUser=!1,t.errorMessage="Enter matching Passwords."):(t.createSpinner=!1,t.disableCreateUser=!1,t.errorMessage="Form must be complete before submitting.")};var s=function(){t.formSubmitted=!1;t.infoSaved=!1;t.formIncomplete=!1;t.disableCreateUser=!1},h=function(){var n=/^(?=.*[A-Z])(?=.*\d)(?=.*[$@#$!%*?&])[A-Za-z\d$@#$!%*?&]{8,}/.test(t.currentUser.newPassword);return t.currentUser.oldPassword==t.currentUser.newPassword?(t.createSpinner=!1,t.disableChangePassword=!1,t.errorMessage="Old and new passwords should not be the same.",!1):t.currentUser.newPassword!=t.currentUser.confirmNewPassword&&t.newUserInfo.PASSWORD?(t.createSpinner=!1,t.disableChangePassword=!1,t.errorMessage="Passwords do not match.",!1):n?!0:(t.createSpinner=!1,t.disableChangePassword=!1,t.errorMessage="Minimum 8 characters, at least 1 Uppercase letter, 1 number, and 1 special character",!1)};t.modalPathUrls={myInfo:"../../Angular/Directives/modals/my_account_modals/my_info/my-info-help.html",password:"../../Angular/Directives/modals/my_account_modals/my_info/password-help.html",company:"../../Angular/Directives/modals/my_account_modals/my_info/company-info-help.html",team:"../../Angular/Directives/modals/my_account_modals//my_info/account-team-help.html"};t.animationsEnabled=!0;t.openHelp=function(n,i,r){var u=f.open({animation:!0,templateUrl:t.modalPathUrls[r],controller:"helpModalCtrl",size:n,resolve:{helpTitle:function(){return i}}})}}]);angular.module("directive.mySettings",[]).directive("mySettings",[function(){return{restrict:"E",scope:{},templateUrl:"../../Angular/Directives/my_account/my_settings/my-settings.html"}}]).controller("mySettingsCtrl",["$http","$scope","$location","$timeout","$window","$filter","$uibModal","userFactory","companyFactory",function(n,t,i,r,u,f,e,o,s){t.newCustomPieceData={};t.customSetting={};o.getLoggedInUser().then(function(n){o.getUserById(n.data).then(function(n){t.currentUser=n.data.user;s.getCustomerServices(t.currentUser.CUSTOMERNUM).then(function(n){t.pickupServices=n.data}).catch(function(n){console.log(n)})}).catch(function(n){console.log(n)})}).catch(function(n){console.log(n)});o.getUserSettings().then(function(n){t.customSetting=n.data[0]||n.data}).catch(function(n){console.log(n)});o.getCustomPieceData().then(function(n){t.customPieceData=n.data}).catch(function(n){console.log(n)});o.getPiecesDefaults().then(function(n){t.defaultPieceData=n.data}).catch(function(n){console.log(n)});t.insertCustomPieceData=function(n){t.pieceSubmitted=!0;t.pieceErrorMessage=null;n?o.insertCustomPieceData(t.newCustomPieceData).then(function(){c();t.pieceSubmitted=!1;o.getCustomPieceData().then(function(n){t.customPieceData=n.data})}).catch(function(){t.pieceErrorMessage="Did not save. Please submit again."}):t.pieceErrorMessage="Complete form before submitting piece data."};t.deleteCustomPieceData=function(n){o.deleteCustomPieceData(n).then(function(){o.getCustomPieceData().then(function(n){t.customPieceData=n.data})}).catch(function(n){console.log(n)})};t.updateServiceSettings=function(n){t.serviceSpinner=!0;t.serviceErrorMessage=null;t.serviceSubmitted=!0;n?o.insertUpdateUserSettings(t.customSetting).then(function(){t.serviceSpinner=!1;t.serviceSaved=!0;t.serviceSubmitted=!1;r(function(){h()},2e3)}).catch(function(){t.serviceErrorMessage="Did not save. Please submit again."}):t.customSetting.PICKUPTIME&&t.customSetting.CLOSETIME?(t.serviceSpinner=!1,t.serviceErrorMessage="Complete form before submitting your default service."):(t.serviceSpinner=!1,t.serviceErrorMessage="Enter a time within the correct range.")};t.updateUserRefernces=function(n){t.referenceSpinner=!0;t.referenceErrorMessage=null;n?o.insertUpdateUserSettings(t.customSetting).then(function(){t.referenceSpinner=!1;t.referenceSaved=!0;r(function(){h()},2e3)}).catch(function(){referenceErrorMessage="Did not save. Please submit again."}):referenceErrorMessage="Complete form before submitting piece data."};t.updateUserSpecInstructions=function(n){t.instructionsSpinner=!0;t.instructionsErrorMessage=null;n&&o.insertUpdateUserSettings(t.customSetting).then(function(){t.instructionsSpinner=!1;t.instructionsSaved=!0}).catch(function(){t.instructionsErrorMessage="Did not save. Please submit again."})};var c=function(){t.newCustomPieceData={}},h=function(){t.pieceSubmitted=!1;t.serviceSubmitted=!1;t.serviceSaved=!1;t.referenceSaved=!1;t.istructionsSaved=!1};t.modalPathUrls={customPiece:"../../Angular/Directives/modals/my_account_modals/my_settings/custom-piece-help.html",settings:"../../Angular/Directives/modals/my_account_modals/my_settings/default-settings-help.html",reference:"../../Angular/Directives/modals/my_account_modals/my_settings/reference-help.html",instructions:"../../Angular/Directives/modals/my_account_modals/my_settings/default-instructions-help.html"};t.animationsEnabled=!0;t.openHelp=function(n,i,r){var u=e.open({animation:!0,templateUrl:t.modalPathUrls[r],controller:"helpModalCtrl",size:n,resolve:{helpTitle:function(){return i}}})}}]);angular.module("directive.links",[]).directive("links",[function(){return{restrict:"E",scope:{},templateUrl:"../../Angular/Directives/my_account/links/links.html"}}]).controller("linksCtrl",["$http","$scope","$location","$timeout","$window","$filter","$uibModal",function(n,t,i,r,u,f,e){t.dashNav={usGov:!0,international:!1,cargoTransit:!1,news:!1,trade:!1};t.setDashNav=function(n){t.dashNav=_.object(_.map(t.dashNav,function(n,t){return[t,!1]}));t.dashNav[n]=!0};t.modalPathUrls={usGov:"../../Angular/Directives/modals/my_account_modals/helpful_links/us-gov-help.html",international:"../../Angular/Directives/modals/my_account_modals/helpful_links/international-help.html",cargoTransit:"../../Angular/Directives/modals/my_account_modals/helpful_links/cargo-transit-help.html",news:"../../Angular/Directives/modals/my_account_modals/helpful_links/news-help.html",trade:"../../Angular/Directives/modals/my_account_modals/helpful_links/trade-help.html"};t.animationsEnabled=!0;t.openHelp=function(n,i,r){var u=e.open({animation:!0,templateUrl:t.modalPathUrls[r],controller:"helpModalCtrl",size:n,resolve:{helpTitle:function(){return i}}})}}]);angular.module("directive.createMyUsers",[]).directive("createMyUsers",[function(){return{restrict:"E",scope:{},templateUrl:"../../Angular/Directives/my_account/create_my_users/create-my-users.html"}}]).controller("createMyUsersCtrl",["$http","$scope","$location","$timeout","$window","$uibModal","userFactory",function(n,t,i,r,u,f,e){var s,l,h,o,c;t.formSubmitted=!1;t.infoSaved=!1;t.formIncomplete=!1;t.newUserInfo={};t.priorUserForm={EMAIL:""};t.userType=null;t.userCategories=null;t.getStateProv=null;t.selectedProfile=null;t.userFeatures={};e.getUserFeatures().then(function(n){t.userFeatures=n.data}).catch(function(n){console.log(n)});e.getClientRoles().then(function(n){t.userCategories=n.data}).catch(function(n){console.log(n)});e.getStateProv().then(function(n){t.stateProvinces=n.data}).catch(function(n){console.log(n)});e.getUserWithCopy().then(function(n){t.customerAdminProfiles=n.data}).catch(function(n){console.log(n)});t.createType={newUser:!1,copyProfile:!1};t.priorUserEmail=null;t.createTypeToggle=function(n){t.newUserInfo={};t.selectedProfile=null;t.createType=_.mapObject(t.createType,function(){return!1});t.createType[n]=!0;t.newUserInfo.userFeatures=t.userFeatures};t.copyProfile=function(){t.newUserInfo={FIRSTNAME:t.selectedProfile.FIRSTNAME+" (Copied User)",LASTNAME:t.selectedProfile.LASTNAME+" (Copied User)",ADDRESS1:t.selectedProfile.ADDRESS1,ADDRESS2:t.selectedProfile.ADDRESS2,CITY:t.selectedProfile.CITY,STATE:t.selectedProfile.STATE,ZIPCODE:t.selectedProfile.ZIPCODE,PHONE:t.selectedProfile.PHONE,AUTON:t.selectedProfile.AUTON,BILLTO:t.selectedProfile.BILLTO,FKCOMPANYTYPE:t.selectedProfile.FKCOMPANYTYPE,TITLE:t.selectedProfile.TITLE,ADDRESS3:t.selectedProfile.ADDRESS3,ADDRESS4:t.selectedProfile.ADDRESS4,CUSTOMERNUM:t.selectedProfile.CUSTOMERNUM,ACTIVE:t.selectedProfile.ACTIVE,COPIEDAUTON:t.selectedProfile.COPYAUTON,FKCATEGORY:t.selectedProfile.FKCATEGORY};t.newUserInfo.userFeatures=t.userFeatures;t.setUserSettings()};t.generateTempPassword=function(){for(var i="",r="ABCDEFGHIJKLMNOPQRSTUVWXYZ",u="1234567890",f="@#%&*$",n=5;n>0;n--)i+=r[Math.floor(Math.random()*r.length)];for(n=2;n>0;n--)i+=u[Math.floor(Math.random()*u.length)];i+=f[Math.floor(Math.random()*f.length)];t.newUserInfo.PASSWORD=i;t.newUserInfo.CONFRIMPASSWORD=i};t.$watch(t.newUserInfo,function(n){n&&t.checkPasswordMatch()});t.checkPasswordMatch=function(){return t.newUserInfo.PASSWORD==t.newUserInfo.CONFRIMPASSWORD&&t.newUserInfo.PASSWORD?!0:!1};s=function(){t.formSubmitted=!1;t.infoSaved=!1;t.formIncomplete=!1;t.disableCreateUser=!1};t.clearForm=function(){t.createType={newUser:!1,copyProfile:!1};t.newUserInfo=null;t.selectedProfile=null};t.saveUser=function(n){t.formSubmitted=!0;t.errorMessage=null;n&&t.checkPasswordMatch()?(h(),t.disableCreateUser=!0,t.createSpinner=!0,t.createType.copyProfile==!0?(t.newUserInfo.isCopyProfile=!0,e.createUserWithCopy(t.newUserInfo).then(function(n){t.createSpinner=!1;n.data>0?t.infoSaved=!0:n.data==-1&&(t.errorMessage="Email already exists!..");c();r(function(){s()},2e3)}).catch(function(n){t.createSpinner=!1;t.disableCreateUser=!1;t.errorMessage="Form did not save. Submit again.";console.log(n)})):e.createUser(t.newUserInfo).then(function(n){t.createSpinner=!1;n.data>0?t.infoSaved=!0:n.data==-1&&(t.errorMessage="Email already exists!..");r(function(){s()},2e3)}).catch(function(n){t.createSpinner=!1;t.disableCreateUser=!1;t.errorMessage="Form did not save. Submit again.";console.log(n)})):n?t.checkPasswordMatch()?(t.createSpinner=!1,t.disableCreateUser=!1,t.errorMessage="Form did not save. Submit again."):(t.createSpinner=!1,t.disableCreateUser=!1,t.errorMessage="Enter matching Passwords."):(t.createSpinner=!1,t.disableCreateUser=!1,t.errorMessage="Form must be complete before submitting.")};l=function(){return t.newUserInfo.EMAIL==t.priorUserEmail?!0:!1};h=function(){var n=t.newUserInfo.EMAIL;t.priorUserEmail=n};t.setUserSettings=function(){t.newUserInfo.FKCATEGORY==1?(o(),_.each(t.newUserInfo.userFeatures,function(n){n.OnOff=!0})):t.newUserInfo.FKCATEGORY==2?o():t.newUserInfo.FKCATEGORY==3?(o(),_.each(t.newUserInfo.userFeatures,function(n){n.OnOff=!0})):t.newUserInfo.FKCATEGORY==4?(o(),_.each(t.newUserInfo.userFeatures,function(n){n.FeatureName==="Pickup Entry"?n.OnOff=!0:n.FeatureName==="Tracking"?n.OnOff=!0:n.FeatureName==="Pickup Folder List"?n.OnOff=!0:n.FeatureName==="International Import Entry"?n.OnOff=!0:n.FeatureName==="International Export Entry"?n.OnOff=!0:n.FeatureName==="International Folder"?n.OnOff=!0:n.FeatureName==="Documents"?n.OnOff=!0:n.FeatureName==="PO Manager"?n.OnOff=!0:n.FeatureName==="Quotes"?n.OnOff=!0:n.FeatureName==="Quotes Folder"?n.OnOff=!0:n.FeatureName==="PO Load"?n.OnOff=!0:n.FeatureName==="PO MANIFEST"?n.OnOff=!0:n.FeatureName==="PO MASTER"&&(n.OnOff=!0)})):t.newUserInfo.FKCATEGORY==5?(o(),_.each(t.newUserInfo.userFeatures,function(n){n.FeatureName==="Tracking"?n.OnOff=!0:n.FeatureName==="Reports"&&(n.OnOff=!0)})):t.newUserInfo.FKCATEGORY==6?(o(),_.each(t.newUserInfo.userFeatures,function(n){n.FeatureName==="Tracking"?n.OnOff=!0:n.FeatureName==="Reports"&&(n.OnOff=!0)})):t.newUserInfo.FKCATEGORY==7?(o(),_.each(t.newUserInfo.userFeatures,function(n){n.FeatureName==="Tracking"?n.OnOff=!0:n.FeatureName==="Pickup Folder List"?n.OnOff=!0:n.FeatureName==="Quotes"?n.OnOff=!0:n.FeatureName==="Quotes Folder"?n.OnOff=!0:n.FeatureName==="Reports"?n.OnOff=!0:n.FeatureName==="Financial Reports"&&(n.OnOff=!0)})):t.newUserInfo.FKCATEGORY==8&&(o(),_.each(t.newUserInfo.userFeatures,function(n){n.FeatureName==="Tracking"?n.OnOff=!0:n.FeatureName==="Pickup Folder List"?n.OnOff=!0:n.FeatureName==="Reports"?n.OnOff=!0:n.FeatureName==="Financial Reports"&&(n.OnOff=!0)}))};o=function(){_.each(t.newUserInfo.userFeatures,function(n){n.OnOff=!1})};t.modalPathUrls={newUser:"../../Angular/Directives/modals/my_account_modals/create_myusers/create-new-users-help.html",copyUser:"../../Angular/Directives/modals/my_account_modals/create_myusers/create-copy-users-help.html"};t.animationsEnabled=!0;t.openHelp=function(n,i,r){var u=f.open({animation:!0,templateUrl:t.modalPathUrls[r],controller:"helpModalCtrl",size:n,resolve:{helpTitle:function(){return i}}})};c=function(){e.getUserWithCopy().then(function(n){t.customerAdminProfiles=n.data}).catch(function(n){console.log(n)})}}]);angular.module("directive.sms",[]).directive("sms",[function(){return{restrict:"E",scope:{},templateUrl:"../../Angular/Directives/my_account/sms/my-sms.html"}}]).controller("mySMSCtrl",["$http","$scope","$location","$rootScope","$timeout","$window","$filter","$uibModal","userFactory","companyFactory",function(n,t,i,r,u,f,e,o,s){t.mileStones={};t.mileStoneSelected={};s.getMileStones().then(function(n){t.mileStones=n.data.filter(function(n){return n.mileStone!=="Appointment Confirmation"&&n.mileStone!=="Appointment Reminder"})}).catch(function(n){console.log(n)});t.agsSMSForm={SMSUserID:t.userId||null,shipmentId:0,agsUserId:r.user.auton,MileStoneStatus:t.mileStones,ASPINBILLTO:r.user.custNo,APPLICATION:"MYAGS"};t.agsSMSForm.agsUserId!=null&&s.getSMSUserbymyAGSUserID(t.agsSMSForm.agsUserId,t.agsSMSForm.shipmentId).then(function(n){var i=n.data;t.agsSMSForm=i[0];angular.forEach(i,function(n){n.MileStoneStatus&&n.MileStoneStatus.length>0&&angular.forEach(n.MileStoneStatus,function(n){if(t.mileStones&&t.mileStones.length>0){let i=t.mileStones.filter(function(t){return t.mileStoneCode===n.MILESTONE})[0];i&&(i.selected=!0)}});n.ALERTEMAIL==!0&&(t.agsSMSForm.ALERTEMAIL=!0,t.agsSMSForm.EMAIL=n.EMAIL);n.ALERTEWHATSAPP==!0&&(t.agsSMSForm.ALERTEWHATSAPP=!0,t.agsSMSForm.PHONE=n.PHONE);n.ALERTPHONE==!0&&(t.agsSMSForm.ALERTPHONE=!0,t.agsSMSForm.PHONE=n.PHONE)})}).catch(function(n){console.log(n)});t.createAGSSMSAlerts=function(n){t.smsSubmitted=!0;t.smsErrorMessage=null;n&&(t.disableSaveAGSSMS=!0,t.agsSMSSpinner=!0,t.agsSMSForm.MileStoneStatus=t.mileStones.filter(function(n){return n.selected===!0}),s.createSMSOREmailUser(t.agsSMSForm).then(function(){t.agsSMSForm.MileStoneStatus=t.mileStones;t.smsSubmitted=!1;t.agsSMSSpinner=!1;t.disableSaveAGSSMS=!1;t.smsSaved=!0;h()}).catch(function(n){t.agsSMSSpinner=!1;t.disableSaveAGSSMS=!1;t.smsErrorMessage="Status Subscribtion failed.Submit again.";console.log(n)}))};var h=function(){u(function(){t.smsSubmitted=!1;t.smsSaved=!1;t.disableSaveAGSSMS=!1},2e3)}}]);angular.module("directive.shipmentsDashboard",[]).directive("shipmentsDashboard",[function(){return{restrict:"E",scope:{},templateUrl:"../../Angular/Directives/shipments/shipments_dashboard/shipments-dashboard.html"}}]).controller("shipmentsDashboardCtrl",["$http","$scope","$location","$timeout","$window","shipmentService",function(n,t,i,r,u,f){t.selectedShipment=f._shipment;t.dashMyShipments={pickup:!1,myShipments:!0,shipment:!1,shipmentSheet:!1};t.toggleNavMenu=function(){t.navMenuOpen=t.navMenuOpen?!1:!0};t.setDashShipments=function(n){t.dashMyShipments=_.mapObject(t.dashMyShipments,function(){return!1});f.resetShipments();t.navMenuOpen=!1;t.dashMyShipments[n]=!0};t.$watch(function(){return f._shipment},function(n){n&&(t.selectedShipment=n,t.dashMyShipments=_.mapObject(t.dashMyShipments,function(){return!1}),t.dashMyShipments.shipment=!0)});t.$watch(function(){return f._updateShipment},function(n){n&&(t.dashMyShipments=_.mapObject(t.dashMyShipments,function(){return!1}),t.dashMyShipments.pickup=!0)});t.$watch(function(){return f._copiedShipment},function(n){n&&(t.dashMyShipments=_.mapObject(t.dashMyShipments,function(){return!1}),t.dashMyShipments.pickup=!0)});t.$watch(function(){return f._returnedShipment},function(n){n&&(t.dashMyShipments=_.mapObject(t.dashMyShipments,function(){return!1}),t.dashMyShipments.pickup=!0)})}]);angular.module("directive.pickupRequest",[]).directive("pickupRequest",[function(){return{restrict:"E",scope:{},templateUrl:"../../Angular/Directives/shipments/pickup_requests/pickup-request.html"}}]).controller("pickupRequestCtrl",["$http","$scope","$rootScope","$location","$timeout","$window","$filter","$uibModal","shipmentService","shipmentFactory","userFactory","companyFactory",function(n,t,i,r,u,f,e,o,s,h,c,l){var et,vt,it,ot,rt,ft,st,ht,ct,a,lt,at,gt;t.shipmentForm={ShipmentData:{FILESTATUS:"NEW",CUSTNO:i.user.custNo},ShipperInfo:{},ConsigneeInfo:{},ServiceInfo:{},UserSettings:{},PieceInfo:{},Pieces:[],Parts:[],PickupInstructions:{},DeliveryInstructions:{},ShipperReference:{},ConsigneeReference:{},Accessorials:{},Files:{Documents:[],Images:[]},Receivable:{},MemoInfo:{},TradeShow:{}};t.previewShipmentForm={ShipmentData:{},ShipperInfo:{},ConsigneeInfo:{},ServiceInfo:{},UserSettings:{},PieceInfo:{},Pieces:[],Parts:[],PickupInstructions:{},DeliveryInstructions:{},Receivable:{},ShipperReference:{},ConsigneeReference:{},Accessorials:{},Files:{},TradeShow:{}};t.newAccessorial={};et=function(){s.setReloadRoute(null);t.shipmentForm={ShipmentData:{FILESTATUS:"NEW",CUSTNO:i.user.custNo},ShipperInfo:{},ConsigneeInfo:{},ServiceInfo:{},UserSettings:{},PieceInfo:{},Pieces:[],Parts:[],PickupInstructions:{},DeliveryInstructions:{},ShipperReference:{},ConsigneeReference:{},Accessorials:{},Files:{Documents:[],Images:[]},MemoInfo:{},TradeShow:{}};t.previewShipmentForm={ShipmentData:{},ShipperInfo:{},ConsigneeInfo:{},ServiceInfo:{},UserSettings:{},PieceInfo:{},Pieces:[],Parts:[],PickupInstructions:{},DeliveryInstructions:{},ShipperReference:{},ConsigneeReference:{},Accessorials:{},Files:{}};t.newAccessorial={};t.formActive=!0;t.newCustomPieceData={TOTALPIECES:null,LONGDESCRIPTION:null,WEIGHT:0,LENGTH:0,WIDTH:0,HEIGHT:0,DIMENSIONALWEIGHT:0};t.shipmentForm.PieceInfo.TotalPieceWeight=0;t.shipmentForm.PieceInfo.TotalPieceDimWeight=0;t.shipmentForm.PieceInfo.TotalPieces=0;t.stateProvinces=[];t.piecePallets=[];c.getStateProv().then(function(n){t.stateProvinces=n.data}).catch(function(n){console.log(n)});c.getAddressBook().then(function(n){t.shipperAddresses=e("filter")(n.data,{CUSTTYPE:"S"});t.consigneeAddresses=e("filter")(n.data,{CUSTTYPE:"C"});s._copiedShipment||s._returnedShipment||s._updateShipment||(t.shipmentForm.ConsigneeInfo=e("filter")(t.consigneeAddresses,{DEFAULTADDRESS:!0})[0],t.shipmentForm.ShipperInfo=e("filter")(t.shipperAddresses,{DEFAULTADDRESS:!0})[0])}).catch(function(n){console.log(n)});c.getLoggedInUser().then(function(n){c.getUserById(n.data).then(function(n){t.currentUser=n.data.user;t.shipmentForm.MemoInfo={MEMO1:"myAGS Shipment Entry",MEMO2:"myAGS Entry By: "+t.currentUser.FIRSTNAME+" "+t.currentUser.LASTNAME,MEMO3:"myAGS Contact Email: "+t.currentUser.EMAIL,MEMO4:"myAGS Contact Phone "+t.currentUser.PHONE};c.getCompanyInfoByBillTo(t.currentUser.AUTON).then(function(n){t.multiBillTo=n.data;t.currentUser.CUSTOMERNUM=="1031930"?(t.billToInfo=t.multiBillTo[2],t.shipmentForm.ShipmentData.BILLTO=t.billToInfo.customerNum):t.currentUser.CUSTOMERNUM=="5470258"?(t.billToInfo=t.multiBillTo[1],t.shipmentForm.ShipmentData.BILLTO=t.billToInfo.customerNum):t.currentUser.CUSTOMERNUM=="5292535"?(t.billToInfo=t.multiBillTo[1],t.shipmentForm.ShipmentData.BILLTO=t.billToInfo.customerNum):t.currentUser.CUSTOMERNUM=="5473288"?(t.billToInfo=t.multiBillTo[2],t.shipmentForm.ShipmentData.BILLTO=t.billToInfo.customerNum):t.currentUser.CUSTOMERNUM=="5382463"?(t.billToInfo=t.multiBillTo[2],t.shipmentForm.ShipmentData.BILLTO=t.billToInfo.customerNum):t.currentUser.CUSTOMERNUM=="5209669"?(t.billToInfo=t.multiBillTo[7],t.shipmentForm.ShipmentData.BILLTO=t.billToInfo.customerNum):(t.billToInfo=t.multiBillTo[0],t.shipmentForm.ShipmentData.BILLTO=t.billToInfo.customerNum)}).catch(function(n){t.multiBillTo=[];console.log(n)})}).catch(function(n){console.log(n)})}).catch(function(n){console.log(n)});h.getServiceRequest(t.billToInfo==null?null:t.billToInfo.customerNum).then(function(n){s._copiedShipment||s._returnedShipment||s._updateShipment||!n.data[0]||(t.pickupServices=n.data);c.getUserSettings().then(function(n){t.shipmentForm.PickupInstructions.REFLABEL1!=undefined&&t.shipmentForm.DeliveryInstructions.REFLABEL2!=undefined&&(t.shipmentForm.PickupInstructions.REFLABEL1=n.data[0].REFLABEL1,t.shipmentForm.DeliveryInstructions.REFLABEL2=n.data[0].REFLABEL2);t.shipmentForm.ServiceInfo.READYDATETYPE==null&&(t.shipmentForm.ServiceInfo.READYDATETYPE=v());t.shipmentForm.ServiceInfo.DATESCHEDULEDDELIVERYDATE==null&&(s._copiedShipment||s._returnedShipment||s._updateShipment||!n.data[0]||(t.shipmentForm.PickupInstructions.PICKUPINSTRUCTIONS1=n.data[0].SPEC1,t.shipmentForm.PickupInstructions.PICKUPINSTRUCTIONS2=n.data[0].SPEC2,t.shipmentForm.PickupInstructions.PICKUPINSTRUCTIONS3=n.data[0].SPEC3,t.shipmentForm.PickupInstructions.PICKUPINSTRUCTIONS4=n.data[0].SPEC4,t.shipmentForm.PickupInstructions.PICKUPINSTRUCTIONS5=n.data[0].SPEC5,t.setServiceType(n.data[0]),t.shipmentForm.ServiceInfo.PICKUPTIME=n.data[0].PICKUPTIME,t.shipmentForm.ServiceInfo.CLOSETIME=n.data[0].CLOSETIME))}).catch(function(n){console.log(n)})}).catch(function(n){t.pickupServices=[];console.log(n)});t.accessorialServices=[];h.getAdditionalCharges(t.billToInfo==null?null:t.billToInfo.customerNum).then(function(n){s._copiedShipment||s._returnedShipment||s._updateShipment||(t.accessorialServices=n.data)}).catch(function(n){t.accessorialServices=[];console.log(n)});t.enabled={Accessorial1:!1,Accessorial2:!1,Accessorial3:!1,Accessorial4:!1,Accessorial5:!1,Accessorial6:!1,Accessorial7:!1,Accessorial8:!1,Accessorial9:!1,Accessorial10:!1};c.getPiecesDefaults().then(function(n){t.defaultPieceData=n.data;it()}).catch(function(n){console.log(n)})};vt=function(){_.each(t.piecePallets,function(n){n.WEIGHT==0&&(n.WEIGHT=1);n.LENGTH==0&&(n.LENGTH=1);n.WIDTH==0&&(n.WIDTH=1);n.HEIGHT==0&&(n.HEIGHT=1)})};c.getAddressBook().then(function(n){t.shipperAddresses=e("filter")(n.data,{CUSTTYPE:"S"});t.consigneeAddresses=e("filter")(n.data,{CUSTTYPE:"C"});t.shipmentForm.ConsigneeInfo=e("filter")(t.consigneeAddresses,{DEFAULTADDRESS:!0})[0];t.shipmentForm.ShipperInfo=e("filter")(t.shipperAddresses,{DEFAULTADDRESS:!0})[0]}).catch(function(n){console.log(n)});it=function(){c.getCustomPieceData().then(function(n){n.data&&(t.customPieceData=n.data,t.piecePallets=t.defaultPieceData.concat(t.customPieceData))}).catch(function(n){console.log(n)})};et();t.getUpdatedServices=function(){t.shipmentForm.ShipmentData.BILLTO=t.billToInfo.customerNum;h.getAdditionalCharges(t.billToInfo==null?null:t.billToInfo.customerNum).then(function(n){t.accessorialServices=n.data}).catch(function(n){t.accessorialServices=[];console.log(n)});h.getServiceRequest(t.billToInfo==null?null:t.billToInfo.customerNum).then(function(n){t.pickupServices=n.data;c.getUserSettings().then(function(n){t.shipmentForm.PickupInstructions.REFLABEL1=n.data[0].REFLABEL1;t.shipmentForm.DeliveryInstructions.REFLABEL2=n.data[0].REFLABEL2;t.shipmentForm.ServiceInfo.READYDATETYPE=v();s._copiedShipment||s._returnedShipment||s._updateShipment||!n.data[0]||(t.shipmentForm.PickupInstructions.PICKUPINSTRUCTIONS1=n.data[0].SPEC1,t.shipmentForm.PickupInstructions.PICKUPINSTRUCTIONS2=n.data[0].SPEC2,t.shipmentForm.PickupInstructions.PICKUPINSTRUCTIONS3=n.data[0].SPEC3,t.shipmentForm.PickupInstructions.PICKUPINSTRUCTIONS4=n.data[0].SPEC4,t.shipmentForm.PickupInstructions.PICKUPINSTRUCTIONS5=n.data[0].SPEC5,t.shipmentForm.ServiceInfo.PICKUPTIME=n.data[0].PICKUPTIME,t.shipmentForm.ServiceInfo.CLOSETIME=n.data[0].CLOSETIME,t.setServiceType(n.data[0]))}).catch(function(n){console.log(n)})}).catch(function(n){t.pickupServices=[];console.log(n)});h.getAdditionalCharges(t.billToInfo==null?null:t.billToInfo.customerNum).then(function(n){t.accessorialServices=n.data}).catch(function(n){t.accessorialServices=[];console.log(n)});t.enabled={Accessorial1:!1,Accessorial2:!1,Accessorial3:!1,Accessorial4:!1,Accessorial5:!1,Accessorial6:!1,Accessorial7:!1,Accessorial8:!1,Accessorial9:!1,Accessorial10:!1}};t.$watch(function(){return s._reloadRoute},function(n){n==="/pickupRequest"&&(t.shipmentForm={ShipmentData:{},ShipperInfo:{},ConsigneeInfo:{},ServiceInfo:{},UserSettings:{},PieceInfo:{},Pieces:[],Parts:[],PickupInstructions:{},DeliveryInstructions:{},ShipperReference:{},ConsigneeReference:{},Accessorials:{},Files:{Documents:[],Images:[]}},t.previewShipmentForm={ShipmentData:{},ShipperInfo:{},ConsigneeInfo:{},ServiceInfo:{},UserSettings:{},PieceInfo:{},Pieces:[],Parts:[],PickupInstructions:{},DeliveryInstructions:{},ShipperReference:{},ConsigneeReference:{},Accessorials:{},Files:{}},t.shipperAddresses=null,t.consigneeAddresses=null,t.pickupServices=null,s.setReloadRoute(null),f.location.reload())});t.$watch(function(){return s._updateShipment},function(n){n&&(t.shipmentForm={ShipmentData:{},ShipperInfo:{},ConsigneeInfo:{},ServiceInfo:{},UserSettings:{},PieceInfo:{},Pieces:[],Parts:[],PickupInstructions:{},DeliveryInstructions:{},ShipperReference:{},ConsigneeReference:{},Accessorials:{},Files:{Documents:[],Images:[]},MemoInfo:{},TradeShow:{}},t.shipmentForm.PieceInfo.TotalPieceWeight=0,t.shipmentForm.PieceInfo.TotalPieceDimWeight=0,t.shipmentForm.PieceInfo.TotalPieces=0,t.shipmentForm.PieceInfo.TotalChargeableWeightLBS=0,h.getShipmentFromStaging(s._updateShipment.ID).then(function(n){var t=n.data[0];yt(t);y(t);p(t);w(t);b(t);k(t);g(t);nt(t);tt(t);d(t);ut(t);pt(t)}).catch(function(n){console.log(n)}))});t.$watch(function(){return s._copiedShipment},function(n){n&&(n.FileStatus==="LIVE"&&h.getShipmentById(s._copiedShipment.ID).then(function(n){var t=n.data[0];y(t);p(t);w(t);b(t);k(t);g(t);nt(t);tt(t);d(t);ut(t)}).catch(function(n){console.log(n)}),n.FileStatus==="NEW"&&h.getShipmentFromStaging(s._copiedShipment.ID).then(function(n){var t=n.data[0];y(t);p(t);w(t);b(t);k(t);g(t);nt(t);tt(t);d(t);ut(t)}).catch(function(n){console.log(n)}))});t.$watch(function(){return s._returnedShipment},function(n){n&&(n.FileStatus==="LIVE"&&h.getShipmentById(s._returnedShipment.ID).then(function(n){var t=n.data[0],i,r;t&&(i=t.Parties[2],r=t.Parties[1],t.Parties[1]=i,t.Parties[2]=r,t.Tracking[0].StaticTrackDate=new v,t.Tracking[4].StaticTrackDate="",t.Tracking[4].TrackTime="");y(t);p(t);b(t);w(t);k(t);g(t);nt(t);tt(t);d(t)}).catch(function(n){console.log(n)}),n.FileStatus==="NEW"&&h.getShipmentFromStaging(s._returnedShipment.ID).then(function(n){var t=n.data[0],i,r;t&&(i=t.Parties[2],r=t.Parties[1],t.Parties[1]=i,t.Parties[2]=r,t.Tracking[0].StaticTrackDate=new v,t.Tracking[4].StaticTrackDate=t.Tracking[4].StaticTrackDate,t.Tracking[4].TrackTime=t.Tracking[4].TrackTime);y(t);p(t);b(t);w(t);k(t);g(t);nt(t);tt(t);d(t)}).catch(function(n){console.log(n)}))});var yt=function(n){n&&(t.shipmentForm.ShipmentData.SHIPMENTID=n.ID,t.shipmentForm.ShipmentData.HOUSE=n.HouseAirWaybillNumber)},y=function(n){n&&(t.shipmentForm.ShipperInfo.NAME=n.Parties[1].PartyName,t.shipmentForm.ShipperInfo.NAME9A=n.Parties[1].PartyAlphaCode,t.shipmentForm.ShipperInfo.ADDRESS1=n.Parties[1].Address1,t.shipmentForm.ShipperInfo.ADDRESS2=n.Parties[1].Address2,t.shipmentForm.ShipperInfo.CITY=n.Parties[1].City,t.shipmentForm.ShipperInfo.STATE=n.Parties[1].StateProvince,t.shipmentForm.ShipperInfo.ZIPCODE=n.Parties[1].ZipCode,t.shipmentForm.ShipperInfo.CONTACT=n.Parties[1].Contact,t.shipmentForm.ShipperInfo.PHONE=n.Parties[1].PhoneNumber,t.shipmentForm.ShipperInfo.EMAIL=n.Parties[1].Email)},p=function(n){n&&(t.shipmentForm.ConsigneeInfo.NAME=n.Parties[2].PartyName,t.shipmentForm.ConsigneeInfo.NAME9A=n.Parties[2].PartyAlphaCode,t.shipmentForm.ConsigneeInfo.ADDRESS1=n.Parties[2].Address1,t.shipmentForm.ConsigneeInfo.ADDRESS2=n.Parties[2].Address2,t.shipmentForm.ConsigneeInfo.CITY=n.Parties[2].City,t.shipmentForm.ConsigneeInfo.STATE=n.Parties[2].StateProvince,t.shipmentForm.ConsigneeInfo.ZIPCODE=n.Parties[2].ZipCode,t.shipmentForm.ConsigneeInfo.CONTACT=n.Parties[2].Contact,t.shipmentForm.ConsigneeInfo.PHONE=n.Parties[2].PhoneNumber,t.shipmentForm.ConsigneeInfo.EMAIL=n.Parties[2].Email)},w=function(n){var i;if(n&&!s._returnedShipment){for(i=0;i<n.PickupInstructions.length;i++)number=i+1,t.shipmentForm.PickupInstructions["PICKUPINSTRUCTIONS"+number]=n.PickupInstructions[i].Note;for(i=0;i<n.DeliveryInstructions.length;i++)number=i+1,t.shipmentForm.DeliveryInstructions["DELIVERYINSTRUCTIONS"+number]=n.DeliveryInstructions[i].Note}if(n&&s._returnedShipment){if(n.DeliveryInstructions.length>0)for(i=0;i<n.DeliveryInstructions.length;i++)number=i+1,t.shipmentForm.PickupInstructions["PICKUPINSTRUCTIONS"+number]=n.DeliveryInstructions[i].Note;if(n.PickupInstructions.length>0)for(i=0;i<n.PickupInstructions.length;i++)number=i+1,t.shipmentForm.DeliveryInstructions["DELIVERYINSTRUCTIONS"+number]=n.PickupInstructions[i].Note}},b=function(n){var i=n.HouseServices.Service;t.shipmentForm.ServiceInfo.PICKUPTIME=n.HouseServices.ReadyTime;t.shipmentForm.ServiceInfo.CLOSETIME=n.HouseServices.CloseTime;t.shipmentForm.ServiceInfo.CODAMOUNT=n.CODAmount;t.shipmentForm.ServiceInfo.DECLAREDVALUE=n.DeclaredValue;_.each(n.Tracking,function(i){i.Key=="READY"&&(t.shipmentForm.ServiceInfo.READYDATETYPE=new Date(n.Tracking[0].StaticTrackDate))});h.getServiceRequest(t.billToInfo==null?null:t.billToInfo.customerNum).then(function(n){t.pickupServices=n.data;_.each(t.pickupServices,function(n){n.ServiceLevelDescription===i&&(t.shipmentForm.ServiceInfo.ServiceRequest=n,t.shipmentForm.ServiceInfo.DIMENSIONALFACTOR=n.DimRate,t.shipmentForm.ServiceInfo.SVCTYPE=n.ServiceLevel,t.shipmentForm.ServiceInfo.TariffCode=n.TariffCode)})}).catch(function(n){t.pickupServices=[];console.log(n)})},k=function(n){n&&angular.forEach(n.Piece.Pieces,function(n){var i={TOTALPIECES:n.Pieces,PIECETYPE:n.PieceType,LONGDESCRIPTION:n.Description,WEIGHT:n.RptWeightLbs,LENGTH:n.RptLength,WIDTH:n.RptWidth,HEIGHT:n.RptHeight,DIMENSIONALWEIGHT:n.DimWeight};t.shipmentForm.Pieces.push(i);rt(i)})},d=function(n){n&&!s._returnedShipment?(t.shipmentForm.TradeShow.ORGBOOTHNUMBERS=n.TradeShow.ORGBOOTHNUMBERS,t.shipmentForm.TradeShow.ORGCONTACTSITENAME=n.TradeShow.ORGCONTACTSITENAME,t.shipmentForm.TradeShow.ORGCONTACTSITEPHONE=n.TradeShow.ORGCONTACTSITEPHONE,t.shipmentForm.TradeShow.ORGDECORATOR=n.TradeShow.ORGDECORATOR,t.shipmentForm.TradeShow.ORGEXHIBITOR=n.TradeShow.ORGEXHIBITOR,t.shipmentForm.TradeShow.ORGSHOWNAME=n.TradeShow.ORGSHOWNAME,t.shipmentForm.TradeShow.DESTBOOTHNUMBERS=n.TradeShow.DESTBOOTHNUMBERS,t.shipmentForm.TradeShow.DESTCONTACTSITENAME=n.TradeShow.DESTCONTACTSITENAME,t.shipmentForm.TradeShow.DESTCONTACTSITEPHONE=n.TradeShow.DESTCONTACTSITEPHONE,t.shipmentForm.TradeShow.DESTDECORATOR=n.TradeShow.DESTDECORATOR,t.shipmentForm.TradeShow.DESTEXHIBITOR=n.TradeShow.DESTEXHIBITOR,t.shipmentForm.TradeShow.DESTSHOWNAME=n.TradeShow.DESTSHOWNAME,_.each(n.Tracking,function(i){i.Key=="SCHEDULEDDELIVERY"&&(t.shipmentForm.ServiceInfo.DATESCHEDULEDDELIVERYDATE=n.Tracking[4].StaticTrackDate=="1/1/0001"?n.Tracking[4].StaticTrackDate:new Date(n.Tracking[4].StaticTrackDate))}),t.shipmentForm.ServiceInfo.SCHEDULEDDELIVERYTIME=n.Tracking[4].TrackTime):(t.shipmentForm.TradeShow.ORGBOOTHNUMBERS=n.TradeShow.DESTBOOTHNUMBERS,t.shipmentForm.TradeShow.ORGCONTACTSITENAME=n.TradeShow.DESTCONTACTSITENAME,t.shipmentForm.TradeShow.ORGCONTACTSITEPHONE=n.TradeShow.DESTCONTACTSITEPHONE,t.shipmentForm.TradeShow.ORGDECORATOR=n.TradeShow.DESTDECORATOR,t.shipmentForm.TradeShow.ORGEXHIBITOR=n.TradeShow.DESTEXHIBITOR,t.shipmentForm.TradeShow.ORGSHOWNAME=n.TradeShow.DESTSHOWNAME,t.shipmentForm.TradeShow.DESTBOOTHNUMBERS=n.TradeShow.ORGBOOTHNUMBERS,t.shipmentForm.TradeShow.DESTCONTACTSITENAME=n.TradeShow.ORGCONTACTSITENAME,t.shipmentForm.TradeShow.DESTCONTACTSITEPHONE=n.TradeShow.ORGCONTACTSITEPHONE,t.shipmentForm.TradeShow.DESTDECORATOR=n.TradeShow.ORGDECORATOR,t.shipmentForm.TradeShow.DESTEXHIBITOR=n.TradeShow.ORGEXHIBITOR,t.shipmentForm.TradeShow.DESTSHOWNAME=n.TradeShow.ORGSHOWNAME,_.each(n.Tracking,function(i){i.Key=="SCHEDULEDDELIVERY"&&(t.shipmentForm.ServiceInfo.DATESCHEDULEDDELIVERYDATE=n.Tracking[4].StaticTrackDate=="1/1/0001"?n.Tracking[4].StaticTrackDate:new Date(n.Tracking[4].StaticTrackDate))}),t.shipmentForm.ServiceInfo.SCHEDULEDDELIVERYTIME=n.Tracking[4].TrackTime)},g=function(n){n&&angular.forEach(n.Parts,function(n){var i={QUANTITY:n.Quan36,PARTNUMBER:n.Part36,PARTDESCRIPTION:n.ParD36,SERIALNUMBER:n.Ser36,CUSTOMERREFERENCE:n.Cstr36};t.shipmentForm.Parts.push(i)})},pt=function(n){n&&(t.shipmentDocuments=[],t.deletedDocuments=[],angular.forEach(n.DocuHeader,function(n){t.shipmentDocuments.push(n);t.shipmentForm.Files.Documents.push(n);t.shipmentForm.Files.Images.push(n);t.selectedDocumentType=null;t.$apply}))},nt=function(n){var i;if(n){for(i=0;i<n.Parties[1].References.length;i++)number=i+1,t.shipmentForm.ShipperReference["AddlRef"+number]=n.Parties[1].References[i].ReferenceNumber;for(i=0;i<n.Parties[2].References.length;i++)number=i+1,t.shipmentForm.ConsigneeReference["AddlRef"+number]=n.Parties[2].References[i].ReferenceNumber}},ut=function(n){t.shipmentForm.Receivable=angular.copy(n.Receivable)},tt=function(n){n&&h.getAdditionalCharges(t.billToInfo==null?null:t.billToInfo.customerNum).then(function(i){t.accessorialServices=i.data;wt(n)})},wt=function(n){var i,r,u;for(console.log(t.accessorialServices),i=1,r=0;r<n.Receivable.Receivables.length;r++)u=n.Receivable.Receivables[r].ServiceCode,_.each(t.accessorialServices,function(n){n.ChargeCode==u&&(t.newAccessorial["service"+i]=n,t.checkAccessorial(n,i),i++)})},v=function(){return new Date};t.minDate=v();t.status={shipDateOpened:!1,specifiedDateOpened:!1};t.open=function(){t.status.shipDateOpened=!0};t.openSpecified=function(){t.status.specifiedDateOpened=!0};t.setServiceType=function(n){n?_.each(t.pickupServices,function(i){n.SVCTYPE==i.ServiceLevel&&(t.shipmentForm.ServiceInfo.ServiceRequest=i,t.shipmentForm.ServiceInfo.DIMENSIONALFACTOR=i.DimRate,t.shipmentForm.ServiceInfo.SVCTYPE=i.ServiceLevel,t.shipmentForm.ServiceInfo.TariffCode=i.TariffCode)}):(t.shipmentForm.ServiceInfo.DIMENSIONALFACTOR=t.shipmentForm.ServiceInfo.ServiceRequest.DimRate,t.shipmentForm.ServiceInfo.SVCTYPE=t.shipmentForm.ServiceInfo.ServiceRequest.ServiceLevel,t.shipmentForm.ServiceInfo.TariffCode=t.shipmentForm.ServiceInfo.ServiceRequest.TariffCode,ot())};ot=function(){t.shipmentForm.PieceInfo.TotalPieceWeight=0;t.shipmentForm.PieceInfo.TotalPieceDimWeight=0;t.shipmentForm.PieceInfo.TotalPieces=0;t.shipmentForm.PieceInfo.TotalChargeableWeightLBS=0;t.calcDimWeight();_.each(t.shipmentForm.Pieces,function(n){var i=n.LENGTH*n.WIDTH*n.HEIGHT*n.TOTALPIECES/t.shipmentForm.ServiceInfo.DIMENSIONALFACTOR;n.DIMENSIONALWEIGHT=Math.floor(i/1);rt(n)})};t.formNav={accessorials:!1,shipInformation:!0,SpecialInstructions:!1,shipReferences:!1,shipDocuments:!1};t.setFormNav=function(n){t.formNav=_.mapObject(t.formNav,function(){return!1});t.formNav[n]=!0};t.dashShipmentInfo={piece:!0,part:!1};t.setTableNav=function(n){t.dashShipmentInfo=_.object(_.map(t.dashShipmentInfo,function(n,t){return[t,!1]}));t.dashShipmentInfo[n]=!0};t.addShipmentPiece=function(n){t.pieceSubmitted=!0;bt(n)&&(t.newCustomPieceData.PCSDESCLONGTmp!=null&&(n.PCSDESCLONG=t.newCustomPieceData.PCSDESCLONGTmp),n.ChargeableWeightLBS=dt(n),t.shipmentForm.Pieces.push(angular.copy({TOTALPIECES:n.TOTALPIECES,PIECETYPE:n.PCSCODE,PCSDESCSHORT:n.PCSDESCSHORT,LONGDESCRIPTION:n.PCSDESCLONG,WEIGHT:n.WEIGHT,LENGTH:n.LENGTH,WIDTH:n.WIDTH,HEIGHT:n.HEIGHT,DIMENSIONALWEIGHT:n.DIMENSIONALWEIGHT,ChargeableWeightLBS:n.ChargeableWeightLBS})),t.newQuantity=null,rt(n),kt(),t.pieceSubmitted=!1,c.getPiecesDefaults().then(function(n){t.defaultPieceData=n.data;it()}).catch(function(n){console.log(n)}))};var bt=function(n){return n.TOTALPIECES&&n.PCSCODE&&n.PCSDESCLONG&&n.WEIGHT&&n.LENGTH&&n.WIDTH&&n.HEIGHT?!0:!1},kt=function(){t.newCustomPieceData={TOTALPIECES:null,LONGDESCRIPTION:null,WEIGHT:0,LENGTH:0,WIDTH:0,HEIGHT:0,DIMENSIONALWEIGHT:0};t.newCustomPieceData.DIMENSIONALWEIGHT=Math.floor(t.dimWeight/1)},dt=function(n){return n.WEIGHT>n.DIMENSIONALWEIGHT?n.WEIGHT:n.DIMENSIONALWEIGHT};t.validateMaxDeclaredValue=function(){parseInt(t.shipmentForm.ServiceInfo.DECLAREDVALUE)>25e3&&(t.shipmentForm.ServiceInfo.DECLAREDVALUE=25e3)};t.calcDimWeight=function(){var n=t.newCustomPieceData.LENGTH*t.newCustomPieceData.WIDTH*t.newCustomPieceData.HEIGHT*t.newCustomPieceData.TOTALPIECES/t.shipmentForm.ServiceInfo.DIMENSIONALFACTOR,i=Math.floor(n/1);t.newCustomPieceData.DIMENSIONALWEIGHT=i};t.addToPiece=function(n){t.newCustomPieceData=t.pieceCode.indexOf("@")!=0?e("filter")(t.piecePallets,{PCSDESCLONG:t.pieceCode.split("@")[1]})[0]:e("filter")(t.piecePallets,{PCSDESCLONG:t.pieceCode})[0];t.pieceDesc=t.newCustomPieceData.PCSDESCLONG;t.newCustomPieceData.TOTALPIECES=n;t.newCustomPieceData.PCSDESCLONGTmp=null;t.calcDimWeight()};t.updateDesc=function(){t.newCustomPieceData.PCSDESCLONGTmp=t.pieceDesc};rt=function(n){t.shipmentForm.PieceInfo.TotalPieceWeight+=n.WEIGHT;t.shipmentForm.PieceInfo.TotalPieceDimWeight+=Math.floor(n.DIMENSIONALWEIGHT/1);t.shipmentForm.PieceInfo.TotalPieces+=n.TOTALPIECES;t.shipmentForm.PieceInfo.TotalChargeableWeightLBS=ft()};t.deleteShipmentPiece=function(n){var i=t.shipmentForm.Pieces.indexOf(n);t.shipmentForm.PieceInfo.TotalPieceWeight-=n.WEIGHT;t.shipmentForm.PieceInfo.TotalPieceDimWeight-=Math.floor(n.DIMENSIONALWEIGHT/1);t.shipmentForm.PieceInfo.TotalPieces-=n.TOTALPIECES;t.shipmentForm.PieceInfo.TotalChargeableWeightLBS=ft();t.shipmentForm.Pieces.splice(i,1)};ft=function(){return t.shipmentForm.PieceInfo.TotalPieceWeight>=t.shipmentForm.PieceInfo.TotalPieceDimWeight?t.shipmentForm.PieceInfo.TotalPieceWeight:t.shipmentForm.PieceInfo.TotalPieceWeight<=t.shipmentForm.PieceInfo.TotalPieceDimWeight?t.shipmentForm.PieceInfo.TotalPieceDimWeight:void 0};t.shipmentPart={};t.addShipmentPart=function(n){t.partSubmitted=!0;st(n)&&(t.shipmentForm.Parts.push(angular.copy(n)),t.shipmentPart=null,t.partSubmitted=!1)};st=function(n){return n.QUANTITY&&n.PARTNUMBER&&n.PARTDESCRIPTION&&n.SERIALNUMBER&&n.CUSTOMERREFERENCE?!0:!1};t.deleteShipmentPart=function(n){var i=t.shipmentForm.Parts.indexOf(n);t.shipmentForm.Parts.splice(i,1)};t.shipmentDocuments=[];t.deletedDocuments=[];t.shipmentImages=[];t.documentTypes=[];t.selectedDocumentType=null;h.getDocumentTypes().then(function(n){t.documentTypes=_.reject(n.data,function(n){return n.DOCTYPE==="IMAGE"})}).catch(function(n){console.log(n)});t.addDocument=function(n){n&&!ht(n)&&(t.shipmentDocuments.push({type:t.selectedDocumentType,file:n}),t.selectedDocumentType=null,console.log(n),t.shipmentForm.Files.Documents=t.shipmentDocuments,t.$apply)};t.addImage=function(n){!n||$.inArray(n,t.shipmentImages)>-1||(console.log(n),t.shipmentImages.push(n),t.currentImagePreview=t.shipmentImages[t.shipmentImages.length-1],t.shipmentForm.Files.Images=t.shipmentImages,t.$apply)};t.removeDocumentFile=function(n){var i=t.shipmentDocuments.indexOf(n);t.shipmentDocuments.splice(i,1);t.deletedDocuments.push(n);t.shipmentForm.Files.Documents=angular.copy(t.shipmentDocuments);t.$apply};t.deleteDocumentHeader=function(n){c.deleteAddressBook(n).then(function(n){t.deleteDocument=n.data}).catch(function(n){console.log(n)})};t.removeImageFile=function(n){var i=t.shipmentImages.indexOf(n);t.shipmentImages.splice(i,1);t.currentImagePreview=t.shipmentImages[t.shipmentImages.length-1];t.shipmentForm.Files.Images=angular.copy(t.shipmentImages);t.$apply};ht=function(n){_.find(t.shipmentDocuments,function(t){return t.file==n?!0:!1})};t.previewShipment=function(n){var u,i,r;n===!1&&(t.formActive=t.formActive?!1:!0);u=(new Date).setHours(0,0,0,0);n&&new Date(t.shipmentForm.ServiceInfo.READYDATETYPE).setHours(0,0,0,0)<u?(n=!1,t.formCreateShipment.ship_date.$setValidity("expired",!1)):new Date(t.shipmentForm.ServiceInfo.READYDATETYPE).setHours(0,0,0,0)>=u&&(t.formCreateShipment.ship_date.$setValidity("expired",!0),n=!0);i=t.shipmentForm.ServiceInfo.READYDATETYPE.getFullYear().toString()+"-";i=t.shipmentForm.ServiceInfo.READYDATETYPE.getMonth()>=9?i+(t.shipmentForm.ServiceInfo.READYDATETYPE.getMonth()+1).toString()+"-":i+"0"+(t.shipmentForm.ServiceInfo.READYDATETYPE.getMonth()+1).toString()+"-";i=t.shipmentForm.ServiceInfo.READYDATETYPE.getDate()>9?i+t.shipmentForm.ServiceInfo.READYDATETYPE.getDate().toString():i+"0"+t.shipmentForm.ServiceInfo.READYDATETYPE.getDate().toString();t.previewShipmentForm.ServiceInfo.ReadyDateString=i;t.shipmentForm.ServiceInfo.ReadyDateString=i;t.shipmentForm.ServiceInfo.DATESCHEDULEDDELIVERYDATE!=undefined&&t.shipmentForm.ServiceInfo.DATESCHEDULEDDELIVERYDATE!="1/1/0001"?(r=t.shipmentForm.ServiceInfo.DATESCHEDULEDDELIVERYDATE.getFullYear().toString()+"-",r=t.shipmentForm.ServiceInfo.DATESCHEDULEDDELIVERYDATE.getMonth()>=9?r+(t.shipmentForm.ServiceInfo.DATESCHEDULEDDELIVERYDATE.getMonth()+1).toString()+"-":r+"0"+(t.shipmentForm.ServiceInfo.DATESCHEDULEDDELIVERYDATE.getMonth()+1).toString()+"-",r=t.shipmentForm.ServiceInfo.DATESCHEDULEDDELIVERYDATE.getDate()>9?r+t.shipmentForm.ServiceInfo.DATESCHEDULEDDELIVERYDATE.getDate().toString():r+"0"+t.shipmentForm.ServiceInfo.DATESCHEDULEDDELIVERYDATE.getDate().toString(),t.previewShipmentForm.ServiceInfo.SchedDelDateString=r,t.shipmentForm.ServiceInfo.SchedDelDateString=r):t.shipmentForm.ServiceInfo.SchedDelDateString="";t.invalidShipDate=!1;t.formSubmitted=!0;t.shipmentCreated=!1;n&&t.shipmentForm.Pieces.length?(t.errorMessage=null,t.formActive=t.formActive?!1:!0,f.scrollTo(0,0),ct()):!n&&new Date(t.shipmentForm.ServiceInfo.READYDATETYPE).setHours(0,0,0,0)<u?(console.log("INVALID  form!!!"),t.errorMessage="Invalid Ship Date",a()):t.shipmentForm.Pieces.length?n||(console.log("INVALID form!!!"),t.errorMessage="Form must be complete before submitting.",a()):(console.log("ADD SOME PIECES!!!"),t.errorMessage="Add Pieces to your shipment to complete the form",t.setFormNav("shipInformation"),t.addPieces=!0,a())};t.pickupRequestNav=function(){f.scrollTo(0,0);t.formActive=t.formActive?!1:!0};ct=function(){t.previewShipmentForm.ShipperInfo=angular.copy(t.shipmentForm.ShipperInfo);t.previewShipmentForm.ConsigneeInfo=angular.copy(t.shipmentForm.ConsigneeInfo);t.previewShipmentForm.ServiceInfo=angular.copy(t.shipmentForm.ServiceInfo);t.previewShipmentForm.UserSettings=angular.copy(t.shipmentForm.UserSettings);t.previewShipmentForm.PieceInfo=angular.copy(t.shipmentForm.PieceInfo);t.previewShipmentForm.Pieces=angular.copy(t.shipmentForm.Pieces);t.previewShipmentForm.Parts=angular.copy(t.shipmentForm.Parts);t.previewShipmentForm.PickupInstructions=angular.copy(t.shipmentForm.PickupInstructions);t.previewShipmentForm.DeliveryInstructions=angular.copy(t.shipmentForm.DeliveryInstructions);t.previewShipmentForm.ShipperReference=angular.copy(t.shipmentForm.ShipperReference);t.previewShipmentForm.ConsigneeReference=angular.copy(t.shipmentForm.ConsigneeReference);t.previewShipmentForm.Files=angular.copy(t.shipmentForm.Files);t.previewShipmentForm.Receivable=angular.copy(t.shipmentForm.Receivable);c.getUserSettings().then(function(n){t.userSettings=n.data[0]||n.data;t.totalEstimate=0;t.previewShipmentForm.Receivable!=null&&_.mapObject(t.previewShipmentForm.Receivable.Receivables,function(n){t.totalEstimate+=n.EstimatedReceivable;t.previewShipmentForm.TotalEstimateCost=t.totalEstimate})}).catch(function(n){console.log(n)});t.previewShipmentForm.saveShipperAddress=angular.copy(t.shipmentForm.saveShipperAddress);t.previewShipmentForm.saveConsigneeAddress=angular.copy(t.shipmentForm.saveConsigneeAddress);t.previewShipmentForm.TradeShow=t.shipmentForm.TradeShow?angular.copy(t.shipmentForm.TradeShow):null;t.$apply};t.checkAccessorial=function(n,i){n?(t.shipmentForm.Accessorials["Accessorial"+i]=n.ChargeCode,t.shipmentForm.Accessorials["Sequence"+i]=n.ChargeCodeSequence,t.previewShipmentForm.Accessorials["Accessorial"+i]=n.ChargeCodeShortDescription):(delete t.shipmentForm.Accessorials["Accessorial"+i],delete t.shipmentForm.Accessorials["Sequence"+i],delete t.previewShipmentForm.Accessorials["Accessorial"+i])};t.createShipment=function(i,r){t.shipmentForm.ShipmentData.BILLTONUMBER=t.billToInfo!=null?t.billToInfo.customerNum:t.shipmentForm.ShipmentData.CUSTNO;t.formSubmitted=!0;t.disableCreateShipment=!0;t.errorMessage=null;t.addPieces=null;t.updating=r?!1:!0;t.activating=r?!0:!1;t.setShipmentLive(r);i&&t.shipmentForm.Pieces.length?(lt(),at(),(t.shipmentDocuments.length>0||t.shipmentImages.length>0)&&t.shipmentForm.ShipmentData.FILESTATUS!="LIVE"?n({url:"/shipment/UploadShipmentDocs",method:"POST",headers:{"Content-Type":undefined},transformRequest:angular.identity,data:t.getModelAsFormData()}).success(function(i){i=="True"&&n({url:"/shipment/DeleteDocumentHeader",method:"POST",headers:{"Content-Type":"application/json"},transformRequest:angular.identity,data:t.getIdForDeletedDocument()}).success(function(i){i=="True"&&n({url:"/shipment/UploadImages",method:"POST",headers:{"Content-Type":undefined},transformRequest:angular.identity,data:t.getImageAsFormData()}).success(function(n){n=="True"&&h.createOrUpdateShipment(t.shipmentForm).then(function(n){t.formSubmitted=!1;t.shipmentCreated=!0;t.shipmentForm.ID=n.data.Entity.ShipmentData.SHIPMENTID;t.openConfirmation("lg",n.data.Entity.ShipmentData.HOUSE,n.data.Entity.ShipmentData.SHIPMENTID);s.resetShipments();t.pickupRequestNav();a();s.editShipment({ID:n.data.Entity.ShipmentData.SHIPMENTID})}).catch(function(n){console.log(n);t.errorMessage="Shipment did not generate. Please validate all required fields or contact your AGS representative.";t.devError=n;a()})})})}):n({url:"/shipment/DeleteDocumentHeader",method:"POST",headers:{"Content-Type":"application/json"},transformRequest:angular.identity,data:t.getIdForDeletedDocument()}).success(function(){h.createOrUpdateShipment(t.shipmentForm).then(function(n){t.formSubmitted=!1;t.shipmentCreated=!0;t.shipmentForm.ID=n.data.Entity.ShipmentData.SHIPMENTID;t.openConfirmation("lg",n.data.Entity.ShipmentData.HOUSE,n.data.Entity.ShipmentData.SHIPMENTID);s.resetShipments();t.pickupRequestNav();a();s.editShipment({ID:n.data.Entity.ShipmentData.SHIPMENTID})}).catch(function(n){console.log(n);t.errorMessage="Shipment did not generate. Please validate all required fields or contact your AGS representative.";t.devError=n;a()})})):i?t.shipmentForm.Pieces.length||(t.errorMessage="Add Pieces to your shipment to complete the form",t.setFormNav("shipInformation"),t.addPieces=!0,a()):(t.errorMessage="Form must be complete before submitting.",a())};t.setShipmentLive=function(n){t.shipmentForm.ShipmentData.FILESTATUS=n?"LIVE":"NEW"};a=function(){t.disableCreateShipment=!1;t.updating=!1;t.activating=!1};t.getModelAsFormData=function(){var n=new FormData;return t.shipmentDocuments.length>0&&angular.forEach(t.shipmentDocuments,function(t){n.append("files",t.file);n.append("types",t.type)}),n};t.getIdForDeletedDocument=function(){var n=[];t.deletedDocuments.length>0&&angular.forEach(t.deletedDocuments,function(t){t.AUTON&&n.push(t.AUTON)});let i={filesIds:n};return JSON.stringify(i)};t.getImageAsFormData=function(){var n=new FormData;return t.shipmentImages.length>0&&angular.forEach(t.shipmentImages,function(t){n.append("images",t)}),n};t.setSaveShipperAddress=function(){t.shipmentForm.ShipperInfo.DEFAULTADDRESS&&(t.shipmentForm.saveShipperAddress=!0)};t.setSaveConsigneeAddress=function(){t.shipmentForm.ConsigneeInfo.DEFAULTADDRESS&&(t.shipmentForm.saveConsigneeAddress=!0)};lt=function(){t.shipmentForm.ShipperInfo.CUSTTYPE="S";t.shipmentForm.ShipperInfo.CONTACT=t.shipmentForm.ShipperInfo.CONTACT?t.shipmentForm.ShipperInfo.CONTACT:" ";t.shipmentForm.ShipperInfo.AUTON>0&&t.shipmentForm.saveShipperAddress?c.updateShipper(t.shipmentForm.ShipperInfo).then(function(){console.log("SHIPPER ADDRESS IS SAVED!")}).catch(function(n){console.log("SHIPPER ADDRESS DID NOT SAVE!");console.log(n)}):t.shipmentForm.saveShipperAddress&&c.createShipper(t.shipmentForm.ShipperInfo).then(function(){console.log("SHIPPER ADDRESS HAS BEEN CREATED!")}).catch(function(n){console.log("SHIPPER ADDRESS DID NOT CREATE!");console.log(n)})};at=function(){t.shipmentForm.ConsigneeInfo.CUSTTYPE="C";t.shipmentForm.ConsigneeInfo.CONTACT=t.shipmentForm.ConsigneeInfo.CONTACT?t.shipmentForm.ConsigneeInfo.CONTACT:" ";t.shipmentForm.ConsigneeInfo.AUTON>0&&t.shipmentForm.saveConsigneeAddress?c.updateShipper(t.shipmentForm.ConsigneeInfo).then(function(){console.log("CONSIGNEE ADDRESS IS SAVED!")}).catch(function(n){console.log("CONSIGNEE ADDRESS DID NOT SAVE!");console.log(n)}):t.shipmentForm.saveConsigneeAddress&&c.createShipper(t.shipmentForm.ConsigneeInfo).then(function(){console.log("CONSIGNEE ADDRESS HAS BEEN CREATED!")}).catch(function(n){console.log("CONSIGNEE ADDRESS DID NOT CREATE!");console.log(n)})};t.activateShipment=function(){t.shipmentForm.ShipmentData.FILESTATUS="LIVE";h.createOrUpdateShipment(t.shipmentForm)};t.updateShipment=function(){h.createOrUpdateShipment(t.shipmentForm)};t.modalPathUrls={shipperInfo:"../../Angular/Directives/modals/my_shipments_modals/shipper-info-help.html",consigneeInfo:"../../Angular/Directives/modals/my_shipments_modals/consignee-info-help.html",serviceInfo:"../../Angular/Directives/modals/my_shipments_modals/service-info-help.html",additionalServices:"../../Angular/Directives/modals/my_shipments_modals/additional-services-help.html",partsPieces:"../../Angular/Directives/modals/my_shipments_modals/parts-pieces-help.html",specialInstructions:"../../Angular/Directives/modals/my_shipments_modals/special-instructions-help.html",references:"../../Angular/Directives/modals/my_shipments_modals/references-help.html",documents:"../../Angular/Directives/modals/my_shipments_modals/documents-help.html"};t.animationsEnabled=!0;t.openHelp=function(n,i,r){var u=o.open({animation:!0,templateUrl:t.modalPathUrls[r],controller:"helpModalCtrl",size:n,resolve:{helpTitle:function(){return"Pickup Request - "+i}}})};t.openConfirmation=function(n,i,r){var u=o.open({animation:!0,templateUrl:"../../Angular/Directives/modals/my_shipments_modals/shipment-create-confirm.html",controller:"shipmentConfirmModalCtrl",size:n,resolve:{billToNumber:function(){return i},shipmentForm:function(){return t.shipmentForm},shipmentId:function(){return r},route:function(){return"/pickupRequest"}}})};t.test=function(){console.log("TEST SUCCESS!")};gt=function(){s.setReloadRoute(null);t.shipmentForm={ShipmentData:{FILESTATUS:"NEW",CUSTNO:i.user.custNo},ShipperInfo:{},ConsigneeInfo:{},ServiceInfo:{},UserSettings:{},PieceInfo:{},Pieces:[],Parts:[],PickupInstructions:{},DeliveryInstructions:{},ShipperReference:{},ConsigneeReference:{},Accessorials:{},Files:{Documents:[],Images:[]},MemoInfo:{},TradeShow:{}};t.previewShipmentForm={ShipperInfo:{},ConsigneeInfo:{},ServiceInfo:{},UserSettings:{},PieceInfo:{},Pieces:[],Parts:[],PickupInstructions:{},DeliveryInstructions:{},ShipperReference:{},ConsigneeReference:{},Accessorials:{},Files:{},TradeShow:{}};t.newAccessorial={};t.formActive=!0;t.newCustomPieceData={TOTALPIECES:null,LONGDESCRIPTION:null,WEIGHT:0,LENGTH:0,WIDTH:0,HEIGHT:0,DIMENSIONALWEIGHT:0};t.shipmentForm.PieceInfo.TotalPieceWeight=0;t.shipmentForm.PieceInfo.TotalPieceDimWeight=0;t.shipmentForm.PieceInfo.TotalPieces=0;t.stateProvinces=[];t.piecePallets=[];c.getStateProv().then(function(n){t.stateProvinces=n.data}).catch(function(n){console.log(n)});c.getAddressBook().then(function(n){t.shipperAddresses=e("filter")(n.data,{CUSTTYPE:"S"});t.consigneeAddresses=e("filter")(n.data,{CUSTTYPE:"C"});t.shipmentForm.ConsigneeInfo=e("filter")(t.consigneeAddresses,{DEFAULTADDRESS:!0})[0];t.shipmentForm.ShipperInfo=e("filter")(t.shipperAddresses,{DEFAULTADDRESS:!0})[0]}).catch(function(n){console.log(n)});c.getLoggedInUser().then(function(n){c.getUserById(n.data).then(function(n){t.currentUser=n.data.user;t.shipmentForm.MemoInfo={MEMO1:"myAGS Shipment Entry",MEMO2:"myAGS Entry By: "+t.currentUser.FIRSTNAME+" "+t.currentUser.LASTNAME,MEMO3:"myAGS Contact Email: "+t.currentUser.EMAIL,MEMO4:"myAGS Contact Phone "+t.currentUser.PHONE};l.getCompanyInfo(t.currentUser.CUSTOMERNUM).then(function(n){t.multiBillTo=n.data;t.billToInfo=t.multiBillTo[0];t.shipmentForm.ShipmentData.BILLTO=t.billToInfo.customerNum}).catch(function(n){t.multiBillTo=[];console.log(n)})}).catch(function(n){console.log(n)})}).catch(function(n){console.log(n)});h.getServiceRequest(t.billToInfo==null?null:t.billToInfo.customerNum).then(function(n){t.pickupServices=n.data;c.getUserSettings().then(function(n){t.shipmentForm.PickupInstructions.PICKUPINSTRUCTIONS1=n.data[0].SPEC1;t.shipmentForm.PickupInstructions.PICKUPINSTRUCTIONS2=n.data[0].SPEC2;t.shipmentForm.PickupInstructions.PICKUPINSTRUCTIONS3=n.data[0].SPEC3;t.shipmentForm.PickupInstructions.PICKUPINSTRUCTIONS4=n.data[0].SPEC4;t.shipmentForm.PickupInstructions.PICKUPINSTRUCTIONS5=n.data[0].SPEC5;t.setServiceType(n.data[0]);t.shipmentForm.SpecialInstructions.REFLABEL1=n.data[0].REFLABEL1;t.shipmentForm.SpecialInstructions.REFLABEL2=n.data[0].REFLABEL2;t.shipmentForm.ServiceInfo.READYDATETYPE=v();t.shipmentForm.ServiceInfo.SCHEDULEDDELIVERYTIME=n.data[0].SCHEDULEDDELIVERYTIME;t.shipmentForm.ServiceInfo.PICKUPTIME=n.data[0].PICKUPTIME;t.shipmentForm.ServiceInfo.CLOSETIME=n.data[0].CLOSETIME}).catch(function(n){console.log(n)})}).catch(function(n){t.pickupServices=[];console.log(n)});t.accessorialServices=[];h.getAdditionalCharges(t.billToInfo==null?null:t.billToInfo.customerNum).then(function(n){t.accessorialServices=n.data}).catch(function(n){t.accessorialServices=[];console.log(n)});t.enabled={Accessorial1:!1,Accessorial2:!1,Accessorial3:!1,Accessorial4:!1,Accessorial5:!1,Accessorial6:!1,Accessorial7:!1,Accessorial8:!1,Accessorial9:!1,Accessorial10:!1};c.getPiecesDefaults().then(function(n){t.defaultPieceData=n.data;it()}).catch(function(n){console.log(n)})}}]);angular.module("directive.shipmentPreview",[]).directive("shipmentPreview",[function(){return{restrict:"E",scope:!1,templateUrl:"../../Angular/Directives/shipments/shipment_preview/shipment-preview.html"}}]);angular.module("directive.myShipments",[]).directive("myShipments",[function(){return{restrict:"E",scope:{},templateUrl:"../../Angular/Directives/shipments/my_shipments/my-shipments.html"}}]).controller("myShipmentsCtrl",["$http","$scope","$rootScope","$location","$timeout","$window","$uibModal","shipmentService","shipmentFactory","userFactory","trackingFactory","$filter",function(n,t,i,r,u,f,e,o,s,h,c,l){t.curPage=0;t.pageSize=10;t.searchText="";Array.prototype.contains=function(n){for(var t=this.length;t--;)if(this[t].Field===n)return!0;return!1};t.getSelectedFields=function(){s.getAGSShipmentFields().then(function(n){t.selectedfields=n.data.userFields;t.refreshfields()}).catch(function(n){console.log(n)})};t.getSelectedFields();t.refreshfields=function(){t.showShipperName=t.selectedfields.contains("Shipper Name");t.showShipperCity=t.selectedfields.contains("Shipper City");t.showShipperStateProvince=t.selectedfields.contains("Shipper StateProvince");t.showShipperReferenceNumber=t.selectedfields.contains("Shipper ReferenceNumber");t.showConsigneeName=t.selectedfields.contains("Consignee Name");t.showConsigneeCity=t.selectedfields.contains("Consignee City");t.showConsigneeStateProvince=t.selectedfields.contains("Consignee StateProvince");t.showConsigneeReferenceNumber=t.selectedfields.contains("Consignee ReferenceNumber");t.showTotalPieces=t.selectedfields.contains("Total Pieces");t.showChargeableWeight=t.selectedfields.contains("Chargeable Weight");t.showService=t.selectedfields.contains("Service");t.showShipDate=t.selectedfields.contains("Ship Date");t.showDeliveryDate=t.selectedfields.contains("Delivery Date")};t.reorder=function(){i.showMessage=!0;var n=e.open({templateUrl:"../../angular/directives/modals/reorder.html",controller:"ModalReorderController",windowClass:"app-modal-window"});n.result.then(function(){t.getSelectedFields()},function(){})};var a=function(){i.user.features.LimitDefaultShipmentRange==!0?function(){var n=new Date,i=new Date,r=n.setDate(n.getDate()),u=i.setDate(i.getDate()+14);t.startDate=new Date(r);t.endDate=new Date(u);t.loadingShipments=!0;s.getAllShipmentsbyUserId(t.startDate,t.endDate).then(function(n){t.loadingShipments=!1;t.myShipments=n.data;t.setDates()}).catch(function(n){t.loadingShipments=!1;t.myShipments=[];console.log(n)})}():function(){var n=new Date,i=new Date,r=n.setDate(n.getDate()-30),u=i.setDate(i.getDate());t.startDate=new Date(r);t.endDate=new Date(u);t.loadingShipments=!0;s.getAllShipmentsbyUserId(t.startDate,t.endDate).then(function(n){t.loadingShipments=!1;t.myShipments=n.data;t.setDates()}).catch(function(n){t.loadingShipments=!1;t.myShipments=[];console.log(n)})}()};a();t.setDates=function(){_.each(t.myShipments,function(n){n.DeliveryDate={};n.ShipDate={};n.StaticDeliveryDate={};n.StaticShipDate={};n.ShipDate=parseInt(n.ReadyDate.match(/(\d+)|(-\d+)/)[0]);n.StaticShipDate=n.StaticTrackDate.toString();n.StaticDeliveryDate=n.ScheduleDeliveryDate=="1/1/0001"?null:n.ScheduleDeliveryDate})};t.numberOfPages=function(){return t.myShipments!=undefined?Math.ceil(t.myShipments.length/t.pageSize):0};t.checkFileStatus=function(n){return n.FileStatus==="LIVE"?!0:!1};t.checkNewFileStatus=function(n){return n.FileStatus==="NEW"?!0:!1};t.calendar={startOpen:!1,endOpen:!1};t.open=function(n){t.calendar[n]=!0};t.createDateIncrements=function(n,i){t.loadingShipments=!0;t.searchText="";s.getAllShipmentsbyUserId(n,i).then(function(n){t.loadingShipments=!1;t.myShipments=n.data;t.setDates()}).catch(function(n){t.loadingShipments=!1;t.myShipments=[];console.log(n)})};t.searchByAGSBILL=function(){t.myShipments.FileStatus==="LIVE"?(t.loadingShipments=!0,c.trackShipmentByBillNumber(t.searchText).then(function(n){t.loadingShipments=!1;t.myShipments=n.data;t.setDates()}).catch(function(n){t.loadingShipments=!1;t.myShipments=[];console.log(n)})):(t.loadingShipments=!0,c.trackShipmentByBillNumberFromStaging(t.searchText).then(function(n){t.loadingShipments=!1;t.myShipments=n.data;t.setDates()}).catch(function(n){t.loadingShipments=!1;t.myShipments=[];console.log(n)}))};t.originalShipments=[];t.filterChange=function(){t.originalShipments.length==0&&(t.originalShipments=angular.copy(t.myShipments));t.searchText==""?t.myShipments=t.originalShipments:t.originalShipments=angular.copy(t.myShipments);t.myShipments=l("filter")(t.originalShipments,t.searchText)};t.deleteShipment=function(n){deleteShipmentMsg=f.confirm("Are you sure you want to delete HAWB No ="+n.HouseAirWaybillNumber);deleteShipmentMsg&&s.deleteShipment(n.ID).then(function(){a()}).catch(function(n){console.log(n)})};t.confirmationForm={LoggedInUserEmail:i.user.email};t.ok=function(){$uibModalInstance.close(t.selected.item)};t.deleteRequested=!1;t.requestEmailForDeleteShipment=function(n){confirm("Are you sure you want to request for Deletion of Shipment : "+n.HouseAirWaybillNumber)&&(t.errorMessage=null,t.disableCreateUser=!0,t.createSpinner=!0,s.requestEmailForDeleteShipment(n.ID,n.HouseAirWaybillNumber).then(function(){t.deleteRequested=!0;t.createSpinner=!1;t.activating=!1;t.infoSaved=!0}).catch(function(n){t.createSpinner=!1;t.disableCreateUser=!1;t.errorMessage="Unable to send email. Submit again.";console.log(n)}))};t.editShipment=function(n){o.editShipment(n)};t.copyShipment=function(n){o.copyShip(n)};t.returnShipment=function(n){o.returnShip(n)};t.showShipment=function(n){o.setShipment(n)};t.sortToggle={bill:!1,shipName:!1,shipCity:!1,consigneeName:!1,consigneCity:!1,shipDate:!0,deliveryDate:!1};t.orderHeader="ShipDate";t.reverse=!0;t.prevPage=function(){t.curPage=t.curPage-1};t.nextPage=function(){t.curPage=t.curPage+1};t.order=function(n,i){t.reverse=t.orderHeader===n?!t.reverse:!1;t.orderHeader=n;t.myShipments=l("orderBy")(t.myShipments,n,t.reverse);t.sortToggle=_.mapObject(t.sortToggle,function(){return!1});t.sortToggle[i]=!0};t.modalPathUrls={myShipments:"../../Angular/Directives/modals/my_shipments_modals/my-shipments-help.html"};t.smsmodalPathUrls={mySMSAlerts:"../../Angular/Directives/modals/my_shipments_modals/ags-smsalerts.html"};t.animationsEnabled=!0;t.openSMSAlerts=function(n,i,r,u,f,o){var s=e.open({animation:!0,templateUrl:"../../Angular/Directives/modals/my_shipments_modals/ags-smsalerts.html",controller:"aGSSMSModalCtrl",size:n,resolve:{shipmentForm:function(){return t.myShipments},shipmentId:function(){return o.ID},shipmentData:function(){return o},helpTitle:function(){return u},smsAlert:function(){return i},emailAlert:function(){return r},route:function(){return"myShipments"}}})};t.animationsEnabled=!0;t.openHelp=function(n,i,r){var u=e.open({animation:!0,templateUrl:t.modalPathUrls[r],controller:"helpModalCtrl",size:n,resolve:{helpTitle:function(){return"My Shipments"}}})}}]).filter("pagination",function(){return function(n,t){if(n&&n.length)return t=+t,n.slice(t)}}).controller("ModalReorderController",["$scope","$http","shipmentService","shipmentFactory","$uibModalInstance","$rootScope",function(n,t,i,r,u,f){n.availablefields=[];n.selectedfields=[];r.getAGSShipmentFields().then(function(t){n.availablefields=t.data.fields;n.selectedfields=t.data.userFields}).catch(function(n){console.log(n)});n.cancel=function(){u.dismiss();f.showMessage=!0;f.myRootMessage="Information cancelled!"};n.ok=function(){n.selectedfields.length>0&&r.setAGSShipmentFields(n.selectedfields).then(function(){u.close()}).catch(function(n){console.log(n)})};n.moveItem=function(n,t,i){var r=t.indexOf(n);r!=-1&&(t.splice(r,1),i.push(n))};Array.prototype.move=function(n,t){this.splice(t,0,this.splice(n,1)[0])};n.orderItemUp=function(n,t){var i=t.indexOf(n);i!=-1&&i!=0&&t.move(i,i-1)};n.orderItemDown=function(n,t){var i=t.indexOf(n);i!=-1&&t.length!=i+1&&t.move(i,i+1)}}]);angular.module("directive.shipmentSheet",[]).directive("shipmentSheet",[function(){return{restrict:"E",scope:{},templateUrl:"../../Angular/Directives/shipments/po_googlesheets/po-googlesheet.html"}}]).controller("poGoogleSheetCtrl",["$http","$scope","$location","$timeout","$window","$uibModal","shipmentService","shipmentFactory","userFactory",function(n,t,i,r,u,f,e,o){o.getGoogleDocs().then(function(n){t.mySheets=n.data}).catch(function(n){console.log(n)})}]);angular.module("directive.shipmentShow",[]).directive("shipmentShow",[function(){return{restrict:"E",scope:{},templateUrl:"../../Angular/Directives/shipments/shipment_show/shipment-show.html"}}]).controller("shipmentShowCtrl",["$http","$scope","$rootScope","$location","$timeout","$window","shipmentService","userFactory","companyFactory","shipmentFactory","shipmentService",function(n,t,i,r,u,f,e,o,s,h,e){var c,l,a;t.billToInfo={};t.userSettings={};i.groupcode={};t.totalEstimate=0,function(){e._shipment.FileStatus==="LIVE"?h.getShipmentById(e._shipment.ID).then(function(n){t.showShipment=n.data[0];t.showShipment.MemoNotes=[];l(n.data[0]);c();a();o.getUserSettings().then(function(n){t.userSettings=n.data[0]||n.data;_.mapObject(t.showShipment.Receivable.Receivables,function(n){t.totalEstimate+=n.EstimatedReceivable;t.showShipment.TotalEstimateCost=t.totalEstimate})}).catch(function(n){console.log(n)})}).catch(function(n){console.log(n)}):h.getShipmentFromStaging(e._shipment.ID).then(function(n){t.showShipment=n.data[0];t.showShipment.MemoNotes=[];l(n.data[0]);c();o.getUserSettings().then(function(n){t.userSettings=n.data[0]||n.data;_.mapObject(t.showShipment.Receivable.Receivables,function(n){t.totalEstimate+=n.EstimatedReceivable;t.showShipment.TotalEstimateCost=t.totalEstimate})}).catch(function(n){console.log(n)})}).catch(function(n){console.log(n)})}();c=function(){t.showShipment.DeliveryDate={};t.showShipment.StaticDeliveryDate={};t.showShipment.ShipDate={};t.showShipment.StaticShipDate={};_.each(t.showShipment.Tracking,function(n){if(n.Key=="READY"&&(t.showShipment.ShipDate=parseInt(n.TrackDate.match(/(\d+)|(-\d+)/)[0]),t.showShipment.StaticShipDate=n.StaticTrackDate.toString()),n.Key=="SCHEDULEDDELIVERY"){var i=parseInt(n.TrackDate.match(/(\d+)|(-\d+)/)[0]);i>0?(t.showShipment.DeliveryDate=i,t.showShipment.StaticDeliveryDate=n.StaticTrackDate.toString()):(t.showShipment.DeliveryDate=null,t.showShipment.StaticDeliveryDate="")}})};l=function(n){_.each(n.TraceNotes,function(n){n.ExternallyAvailable&&(n.Memo.indexOf("POD")!=0&&n.Memo.indexOf("DELIVERED")==-1?n.LastUpdateDate=parseInt(n.LastUpdateDate.match(/(\d+)|(-\d+)/)[0]):(n.LastUpdateDate=null,n.LastUpdateTime=null),t.showShipment.MemoNotes.push(n))})};t.copyShipment=function(n){e.copyShip(n)};t.returnShipment=function(n){e.returnShip(n)};a=function(){h.getGroupCode(i.user.custNo).then(function(n){i.groupcode=n.data[0]?n.data[0]:null}).catch(function(n){t.user.groupcode=null;t.companyInfo=[];console.log(n)})}}]);angular.module("directive.billNumber",[]).directive("billNumber",[function(){return{restrict:"E",scope:{},templateUrl:"../../Angular/Directives/tracking/bill_number/bill-number.html"}}]).controller("billNumberCtrl",["$http","$scope","$location","$timeout","$window","trackingService","trackingFactory",function(n,t,i,r,u,f,e){t.billToNumber=null;t.trackedShipmentList=[];t.trackShipmentByBillNumber=function(n){t.trackingSubmitted=!0;n&&(t.trackLoading=!0,e.trackShipmentByBillNumber(t.billToNumber).then(function(n){t.trackedShipmentList=n.data;o();t.setDates();f.setTrackedShipments(t.trackedShipmentList);t.trackLoading=!1;t.trackingSubmitted=!1}).catch(function(n){console.log(n);t.trackLoading=!1}))};t.setDates=function(){_.each(t.trackedShipmentList,function(n){n.DeliveryDate={};n.ShipDate={};n.StaticDeliveryDate={};n.StaticShipDate={};n.ShipDate=parseInt(n.ReadyDate.match(/(\d+)|(-\d+)/)[0]);n.StaticShipDate=n.StaticTrackDate.toString();n.StaticDeliveryDate=n.ScheduleDeliveryDate=="1/1/0001"?null:n.ScheduleDeliveryDate.toString()})};var o=function(){_.each(t.trackedShipmentList,function(n){n.mileStonesHash={};_.each(n.MileStone,function(t){n.mileStonesHash[t.KEY.replace(/\s/g,"")]=t})})}}]);angular.module("directive.references",[]).directive("references",[function(){return{restrict:"E",scope:{},templateUrl:"../../Angular/Directives/tracking/references/references.html"}}]).controller("referencesCtrl",["$http","$scope","$location","$timeout","$window","trackingService","trackingFactory",function(n,t,i,r,u,f,e){var o,s,h;t.status={fromDateRefOne:!1,toDateRefOne:!1,fromDateRefTwo:!1,toDateRefTwo:!1};t.openCalendar=function(n){t.status[n]=!0};o=function(){return new Date};s=function(){var n=new Date;return n.setMonth(n.getMonth()-12),n};t.fromDateReference1=s();t.toDateReference1=o();t.fromDateReference2=s();t.toDateReference2=o();t.trackShipmentByDateByReferenceOne=function(n){t.ref1Submitted=!0;n&&(t.ref1Loading=!0,e.trackShipmentByDateByReferenceOne(t.fromDateReference1,t.toDateReference1,t.reference1).then(function(n){t.trackedShipmentList=n.data;t.setDates();h();f.setTrackedShipments(t.trackedShipmentList);t.ref1Loading=!1;t.ref1Submitted=!1}).catch(function(n){console.log(n);t.ref1Loading=!1;t.ref1Submitted=!1}))};t.trackShipmentByDateByReferenceTwo=function(n){t.ref2Submitted=!0;n&&(t.ref2Loading=!0,e.trackShipmentByDateByReferenceTwo(t.fromDateReference2,t.toDateReference2,t.reference2).then(function(n){t.trackedShipmentList=n.data;t.setDates();h();f.setTrackedShipments(t.trackedShipmentList);t.ref2Loading=!1;t.ref2Submitted=!1}).catch(function(n){console.log(n);t.ref2Loading=!1;t.ref2Submitted=!1}))};t.setDates=function(){_.each(t.trackedShipmentList,function(n){n.DeliveryDate={};n.ShipDate={};n.StaticDeliveryDate={};n.StaticShipDate={};n.ShipDate=parseInt(n.ReadyDate.match(/(\d+)|(-\d+)/)[0]);n.StaticShipDate=n.StaticTrackDate.toString();n.StaticDeliveryDate=n.ScheduleDeliveryDate=="1/1/0001"?null:n.ScheduleDeliveryDate.toString()})};h=function(){_.each(t.trackedShipmentList,function(n){n.mileStonesHash={};_.each(n.MileStone,function(t){n.mileStonesHash[t.KEY.replace(/\s/g,"")]=t})})}}]);angular.module("directive.shipmentDates",[]).directive("shipmentDates",[function(){return{restrict:"E",scope:{},templateUrl:"../../Angular/Directives/tracking/shipment_dates/shipment-dates.html"}}]).controller("shipmentDatesCtrl",["$http","$scope","$location","$timeout","$window","trackingService","trackingFactory",function(n,t,i,r,u,f,e){var s=function(){return new Date},o;t.status={shipDate:!1,deliveryDate:!1,fromDate:!1,toDate:!1};t.openCalendar=function(n){t.status[n]=!0};t.trackedShipmentList=[];t.trackReadyRange=function(n){t.readySubmitted=!0;n&&(t.readyLoading=!0,e.trackShipmentByBilltoByReadyDate(t.fromReadyDate,t.toReadyDate).then(function(n){t.trackedShipmentList=n.data;t.setDates();o();f.setTrackedShipments(t.trackedShipmentList);t.readySubmitted=!1;t.readyLoading=!1}).catch(function(n){console.log(n);t.trackedShipmentList=[];t.readySubmitted=!1;t.readyLoading=!1}))};t.trackDelieveryRange=function(n){t.deliverySubmitted=!0;n&&(t.deliveryLoading=!0,e.trackShipmentByBilltoByDeliveryDate(t.fromDeliveryDate,t.toDeliveryDate).then(function(n){t.trackedShipmentList=n.data;t.setDates();o();f.setTrackedShipments(t.trackedShipmentList);t.deliveryLoading=!1;t.deliverySubmitted=!1}).catch(function(n){console.log(n);t.trackedShipmentList=[];t.deliveryLoading=!1;t.deliverySubmitted=!1}))};t.setDates=function(){_.each(t.trackedShipmentList,function(n){n.DeliveryDate={};n.ShipDate={};n.StaticDeliveryDate={};n.StaticShipDate={};n.ShipDate=parseInt(n.ReadyDate.match(/(\d+)|(-\d+)/)[0]);n.StaticShipDate=n.StaticTrackDate.toString();n.StaticDeliveryDate=n.ScheduleDeliveryDate=="1/1/0001"?null:n.ScheduleDeliveryDate.toString()})};o=function(){_.each(t.trackedShipmentList,function(n){n.mileStonesHash={};_.each(n.MileStone,function(t){n.mileStonesHash[t.KEY.replace(/\s/g,"")]=t})})}}]);angular.module("directive.zipcode",[]).directive("zipcode",[function(){return{restrict:"E",scope:{},templateUrl:"../../Angular/Directives/tracking/zipcode/zipcode.html"}}]).controller("zipcodeCtrl",["$http","$scope","$location","$timeout","$window","trackingService","trackingFactory",function(n,t,i,r,u,f,e){var o,s,h;t.dataShipments=[];t.pickupZipcode=null;t.deliveryZipcode=null;o=function(){return new Date};t.status={pickupFromDate:!1,pickupToDate:!1,deliveryFromDate:!1,deliveryToDate:!1};t.openCalendar=function(n){t.status[n]=!0};o=function(){return new Date};s=function(){var n=new Date;return n.setMonth(n.getMonth()-12),n};t.pickupZipcodeFromDate=s();t.pickupZipcodeToDate=o();t.deliveryZipcodeFromDate=s();t.deliveryZipcodeToDate=o();t.trackByPickUpZipcodeDate=function(n){t.pickupSubmitted=!0;n&&(t.pickupLoading=!0,e.trackShipmentByDatePickUpZipCode(t.pickupZipcodeFromDate,t.pickupZipcodeToDate,t.pickupZipcode,"SHIPPER").then(function(n){t.trackedShipmentList=n.data;t.setDates();h();f.setTrackedShipments(t.trackedShipmentList);t.pickupLoading=!1;t.pickupSubmitted=!1}).catch(function(n){console.log(n);t.pickupLoading=!1;t.pickupSubmitted=!1}))};t.trackByDeliveryZipcodeDate=function(n){t.deliverySubmitted=!0;n&&(t.deliveryLoading=!0,e.trackShipmentByDateByDeliveryZipCode(t.deliveryZipcodeFromDate,t.deliveryZipcodeToDate,t.deliveryZipcode,"CONSIGNEE").then(function(n){t.trackedShipmentList=n.data;t.setDates();h();f.setTrackedShipments(t.trackedShipmentList);t.deliverySubmitted=!1;t.deliveryLoading=!1}).catch(function(n){console.log(n);t.deliverySubmitted=!1;t.deliveryLoading=!1}));f.setTrackedShipments(t.trackedShipmentList)};t.setDates=function(){_.each(t.trackedShipmentList,function(n){n.DeliveryDate={};n.ShipDate={};n.StaticDeliveryDate={};n.StaticShipDate={};n.ShipDate=parseInt(n.ReadyDate.match(/(\d+)|(-\d+)/)[0]);n.StaticShipDate=n.StaticTrackDate.toString();n.StaticDeliveryDate=n.ScheduleDeliveryDate=="1/1/0001"?null:n.ScheduleDeliveryDate.toString()})};h=function(){_.each(t.trackedShipmentList,function(n){n.mileStonesHash={};_.each(n.MileStone,function(t){n.mileStonesHash[t.KEY.replace(/\s/g,"")]=t})})};t.$watch(t.pickupZipcode,function(n){n==""&&(t.pickupZipcode=null)});t.$watch(t.deliveryZipcode,function(n){n==""&&(t.deliveryZipcode=null)})}]);angular.module("directive.consignee",[]).directive("consignee",[function(){return{restrict:"E",scope:{},templateUrl:"../../Angular/Directives/tracking/consignee/consignee.html"}}]).controller("consigneeCtrl",["$http","$scope","$location","$timeout","$window","trackingService","trackingFactory",function(n,t,i,r,u,f,e){var o=function(){return new Date},s,h;t.minDate=o();t.status={consigneeFromDate:!1,consigneeToDate:!1};t.openCalendar=function(n){t.status[n]=!0};o=function(){return new Date};s=function(){var n=new Date;return n.setMonth(n.getMonth()-12),n};t.consigneeFromDate=s();t.consigneeToDate=o();t.consigneeName=null;t.trackShipmentByConsinee=function(n){t.consigneeSubmitted=!0;n&&(t.consigneeLoading=!0,e.trackShipmentByConsinee(t.consigneeName,t.consigneeFromDate,t.consigneeToDate).then(function(n){t.trackedShipmentList=n.data;t.setDates();h();f.setTrackedShipments(t.trackedShipmentList);t.consigneeSubmitted=!1;t.consigneeLoading=!1}).catch(function(n){console.log(n);t.consigneeSubmitted=!1;t.consigneeLoading=!1}))};t.setDates=function(){_.each(t.trackedShipmentList,function(n){n.DeliveryDate={};n.ShipDate={};n.StaticDeliveryDate={};n.StaticShipDate={};n.ShipDate=parseInt(n.ReadyDate.match(/(\d+)|(-\d+)/)[0]);n.StaticShipDate=n.StaticTrackDate.toString();n.StaticDeliveryDate=n.ScheduleDeliveryDate=="1/1/0001"?null:n.ScheduleDeliveryDate.toString()})};h=function(){_.each(t.trackedShipmentList,function(n){n.mileStonesHash={};_.each(n.MileStone,function(t){n.mileStonesHash[t.KEY.replace(/\s/g,"")]=t})})}}]);angular.module("directive.partsContainers",[]).directive("partsContainers",[function(){return{restrict:"E",scope:{},templateUrl:"../../Angular/Directives/tracking/parts_containers/parts-containers.html"}}]).controller("partsContainersCtrl",["$http","$scope","$location","$timeout","$window","trackingService","trackingFactory",function(n,t,i,r,u,f,e){var o=function(){return new Date},s,h;t.status={partFromDate:!1,partToDate:!1,containerFromDate:!1,containerToDate:!1};t.openCalendar=function(n){t.status[n]=!0};o=function(){return new Date};s=function(){var n=new Date;return n.setMonth(n.getMonth()-12),n};t.partFromDate=s();t.partToDate=o();t.containerFromDate=s();t.containerToDate=o();t.trackShipmentByDatePart=function(n){t.partSubmitted=!0;n&&(t.partLoading=!0,e.trackShipmentByDatePart(t.partNumber,t.partFromDate,t.partToDate).then(function(n){t.trackedShipmentList=n.data;t.setDates();h();f.setTrackedShipments(t.trackedShipmentList);t.partSubmitted=!1;t.partLoading=!1}).catch(function(n){console.log(n);t.partSubmitted=!1;t.partLoading=!1}))};t.trackShipmentByContainer=function(n){t.containerSubmitted=!0;n&&(t.containerLoading=!0,e.trackShipmentByContainer(t.containerNumber,t.containerFromDate,t.containerToDate).then(function(n){t.trackedShipmentList=n.data;t.setDates();h();f.setTrackedShipments(t.trackedShipmentList);t.containerSubmitted=!1;t.containerLoading=!1}).catch(function(n){console.log(n);t.containerSubmitted=!1;t.containerLoading=!1}))};t.setDates=function(){_.each(t.trackedShipmentList,function(n){n.DeliveryDate={};n.ShipDate={};n.StaticDeliveryDate={};n.StaticShipDate={};n.ShipDate=parseInt(n.ReadyDate.match(/(\d+)|(-\d+)/)[0]);n.StaticShipDate=n.StaticTrackDate.toString();n.StaticDeliveryDate=n.ScheduleDeliveryDate=="1/1/0001"?null:n.ScheduleDeliveryDate.toString()})};h=function(){_.each(t.trackedShipmentList,function(n){n.mileStonesHash={};_.each(n.MileStone,function(t){n.mileStonesHash[t.KEY.replace(/\s/g,"")]=t})})}}]);angular.module("directive.trackedShipments",[]).directive("trackedShipments",[function(){return{restrict:"E",scope:{},templateUrl:"../../Angular/Directives/tracking/tracked_shipments/tracked-shipments.html"}}]).controller("trackedShipmentsCtrl",["$http","$scope","$location","$timeout","$window",function(){}]);angular.module("directive.quoteRequest",[]).directive("quoteRequest",[function(){return{restrict:"E",scope:{},templateUrl:"../../Angular/Directives/quotes/quote_request/quote-request.html"}}]).controller("quoteRequestCtrl",["$http","$scope","$rootScope","$location","$timeout","$window","$filter","$uibModal","shipmentFactory","userFactory","companyFactory","shipmentService","quoteService","quoteFactory",function(n,t,i,r,u,f,e,o,s,h,c,l,a,v){var ut,ot,et,ft,rt,st,ht,bt;t.quoteForm={ShipmentData:{FILESTATUS:"NEW",CUSTNO:i.user.custNo},ShipperInfo:{},ConsigneeInfo:{},UserSettings:{},ServiceInfo:{},PieceInfo:{},Pieces:[],Parts:[],PickupInstructions:{},DeliveryInstructions:{},ShipperReference:{},ConsigneeReference:{},Accessorials:{},MemoInfo:{},TradeShow:{}};t.newAccessorial={};t.stateProvinces=[];t.piecePallets=[];h.getStateProv().then(function(n){t.stateProvinces=n.data}).catch(function(n){console.log(n)});h.getAddressBook().then(function(n){t.shipperAddresses=e("filter")(n.data,{CUSTTYPE:"S"});t.consigneeAddresses=e("filter")(n.data,{CUSTTYPE:"C"});a._activateQuote||a._copiedQuote||(t.quoteForm.ConsigneeInfo=e("filter")(t.consigneeAddresses,{DEFAULTADDRESS:!0})[0],t.quoteForm.ShipperInfo=e("filter")(t.shipperAddresses,{DEFAULTADDRESS:!0})[0])}).catch(function(n){console.log(n)});h.getLoggedInUser().then(function(n){h.getUserById(n.data).then(function(n){t.currentUser=n.data.user;t.quoteForm.MemoInfo={MEMO1:"myAGS Shipment Entry",MEMO2:"myAGS Entry By: "+t.currentUser.FIRSTNAME+" "+t.currentUser.LASTNAME,MEMO3:"myAGS Contact Email: "+t.currentUser.EMAIL,MEMO4:"myAGS Contact Phone "+t.currentUser.PHONE};c.getCompanyInfo(t.currentUser.CUSTOMERNUM).then(function(n){t.billToInfo=n.data[0]?n.data[0]:{}}).catch(function(n){t.billToInfo={};console.log(n)})}).catch(function(n){console.log(n)})}).catch(function(n){console.log(n)});v.getServiceRequest().then(function(n){a._activateQuote||a._copiedQuote||!n.data||(t.pickupServices=n.data);h.getUserSettings().then(function(n){t.quoteForm.PickupInstructions.PICKUPINSTRUCTIONS1=n.data[0].SPEC1;t.quoteForm.PickupInstructions.PICKUPINSTRUCTIONS2=n.data[0].SPEC2;t.quoteForm.PickupInstructions.PICKUPINSTRUCTIONS3=n.data[0].SPEC3;t.quoteForm.PickupInstructions.PICKUPINSTRUCTIONS4=n.data[0].SPEC4;t.quoteForm.PickupInstructions.PICKUPINSTRUCTIONS5=n.data[0].SPEC5;t.quoteForm.PickupInstructions.REFLABEL1=n.data[0].REFLABEL1;t.quoteForm.DeliveryInstructions.REFLABEL2=n.data[0].REFLABEL2;t.quoteForm.ServiceInfo.READYDATETYPE==null&&(t.quoteForm.ServiceInfo.READYDATETYPE=ut());t.quoteForm.ServiceInfo.DATESCHEDULEDDELIVERYDATE==null;a._activateQuote||a._copiedQuote||!n.data[0]||(t.quoteForm.SpecialInstructions=n.data[0],t.setServiceType(n.data[0]),t.quoteForm.ServiceInfo.PICKUPTIME=t.quoteForm.SpecialInstructions.PICKUPTIME,t.quoteForm.ServiceInfo.CLOSETIME=t.quoteForm.SpecialInstructions.CLOSETIME)}).catch(function(n){console.log(n)})}).catch(function(n){console.log(n)});t.accessorialServices=[];v.getAdditionalCharges().then(function(n){a._activateQuote||a._copiedQuote||!n.data[0]||(t.accessorialServices=n.data)}).catch(function(n){console.log(n)});t.$watch(function(){return l._reloadRoute},function(n){n==="/myQuotes"&&(t.shipperAddresses=null,t.consigneeAddresses=null,l.setReloadRoute(null),f.location.reload())});t.$watch(function(){return a._copiedQuote},function(n){n&&(n.FileStatus==="LIVE"&&v.getQuoteById(a._copiedQuote.ID).then(function(n){var r=n.data[0];t.quoteForm={ShipmentData:{FILESTATUS:"NEW",CUSTNO:i.user.custNo},ShipperInfo:{},ConsigneeInfo:{},UserSettings:{},ServiceInfo:{},PieceInfo:{},Pieces:[],Parts:[],PickupInstructions:{},DeliveryInstructions:{},ShipperReference:{},ConsigneeReference:{},Accessorials:{},MemoInfo:{},TradeShow:{}};t.quoteForm.PieceInfo.TotalPieceWeight=0;t.quoteForm.PieceInfo.TotalPieceDimWeight=0;t.quoteForm.PieceInfo.TotalPieces=0;t.quoteForm.PieceInfo.TotalChargeableWeightLBS=0;p(r);w(r);k(r);b(r);g(r);nt(r);tt(r);it(r);d(r)}).catch(function(n){console.log(n)}),n.FileStatus==="NEW"&&v.getQuoteByIdFromStaging(a._copiedQuote.ID).then(function(n){var r=n.data[0];t.quoteForm={ShipmentData:{FILESTATUS:"NEW",CUSTNO:i.user.custNo},ShipperInfo:{},ConsigneeInfo:{},UserSettings:{},ServiceInfo:{},PieceInfo:{},Pieces:[],Parts:[],PickupInstructions:{},DeliveryInstructions:{},ShipperReference:{},ConsigneeReference:{},Accessorials:{},MemoInfo:{},TradeShow:{}};t.quoteForm.PieceInfo.TotalPieceWeight=0;t.quoteForm.PieceInfo.TotalPieceDimWeight=0;t.quoteForm.PieceInfo.TotalPieces=0;t.quoteForm.PieceInfo.TotalChargeableWeightLBS=0;p(r);w(r);k(r);b(r);g(r);nt(r);tt(r);it(r);d(r)}).catch(function(n){console.log(n)}))});t.$watch(function(){return a._copiedQuote},function(n){n&&(n.FileStatus==="LIVERO"&&v.getQuoteById(a._copiedQuote.ID).then(function(n){var r=n.data[0];t.quoteForm={ShipmentData:{FILESTATUS:"NEW",CUSTNO:i.user.custNo},ShipperInfo:{},ConsigneeInfo:{},UserSettings:{},ServiceInfo:{},PieceInfo:{},Pieces:[],Parts:[],PickupInstructions:{},DeliveryInstructions:{},ShipperReference:{},ConsigneeReference:{},Accessorials:{},MemoInfo:{},TradeShow:{}};t.quoteForm.PieceInfo.TotalPieceWeight=0;t.quoteForm.PieceInfo.TotalPieceDimWeight=0;t.quoteForm.PieceInfo.TotalPieces=0;t.quoteForm.PieceInfo.TotalChargeableWeightLBS=0;p(r);w(r);k(r);b(r);g(r);nt(r);tt(r);it(r);d(r)}).catch(function(n){console.log(n)}),n.FileStatus==="NEW"&&v.getQuoteByIdFromStaging(a._copiedQuote.ID).then(function(n){var r=n.data[0];t.quoteForm={ShipmentData:{FILESTATUS:"NEW",CUSTNO:i.user.custNo},ShipperInfo:{},ConsigneeInfo:{},UserSettings:{},ServiceInfo:{},PieceInfo:{},Pieces:[],Parts:[],PickupInstructions:{},DeliveryInstructions:{},ShipperReference:{},ConsigneeReference:{},Accessorials:{},MemoInfo:{},TradeShow:{}};t.quoteForm.PieceInfo.TotalPieceWeight=0;t.quoteForm.PieceInfo.TotalPieceDimWeight=0;t.quoteForm.PieceInfo.TotalPieces=0;t.quoteForm.PieceInfo.TotalChargeableWeightLBS=0;p(r);w(r);k(r);b(r);g(r);nt(r);tt(r);it(r);d(r)}).catch(function(n){console.log(n)}))});t.$watch(function(){return a._activateQuote},function(n){n&&v.getQuoteByIdFromStaging(a._activateQuote.ID).then(function(n){var r=n.data[0];t.quoteForm={ShipmentData:{FILESTATUS:"NEW",CUSTNO:i.user.custNo},ShipperInfo:{},ConsigneeInfo:{},UserSettings:{},ServiceInfo:{},PieceInfo:{},Pieces:[],Parts:[],PickupInstructions:{},DeliveryInstructions:{},ShipperReference:{},ConsigneeReference:{},Accessorials:{},MemoInfo:{},TradeShow:{}};t.quoteForm.PieceInfo.TotalPieceWeight=0;t.quoteForm.PieceInfo.TotalPieceDimWeight=0;t.quoteForm.PieceInfo.TotalPieces=0;t.quoteForm.PieceInfo.TotalChargeableWeightLBS=0;lt(r);p(r);w(r);k(r);b(r);g(r);nt(r);tt(r);it(r);d(r)}).catch(function(n){console.log(n)})});var lt=function(n){n&&(t.quoteForm.ShipmentData.SHIPMENTID=n.ID,t.quoteForm.ShipmentData.HOUSE=n.HouseAirWaybillNumber,t.quoteForm.ShipmentData.ID=n.ID)},p=function(n){n&&(t.quoteForm.ShipperInfo.NAME=n.Parties[1].PartyName,t.quoteForm.ShipperInfo.NAME9A=n.Parties[1].PartyAlphaCode,t.quoteForm.ShipperInfo.ADDRESS1=n.Parties[1].Address1,t.quoteForm.ShipperInfo.ADDRESS2=n.Parties[1].Address2,t.quoteForm.ShipperInfo.CITY=n.Parties[1].City,t.quoteForm.ShipperInfo.STATE=n.Parties[1].StateProvince,t.quoteForm.ShipperInfo.ZIPCODE=n.Parties[1].ZipCode,t.quoteForm.ShipperInfo.CONTACT=n.Parties[1].Contact,t.quoteForm.ShipperInfo.PHONE=n.Parties[1].PhoneNumber,t.quoteForm.ShipperInfo.EMAIL=n.Parties[1].Email)},w=function(n){n&&(t.quoteForm.ConsigneeInfo.NAME=n.Parties[2].PartyName,t.quoteForm.ConsigneeInfo.NAME9A=n.Parties[2].PartyAlphaCode,t.quoteForm.ConsigneeInfo.ADDRESS1=n.Parties[2].Address1,t.quoteForm.ConsigneeInfo.ADDRESS2=n.Parties[2].Address2,t.quoteForm.ConsigneeInfo.CITY=n.Parties[2].City,t.quoteForm.ConsigneeInfo.STATE=n.Parties[2].StateProvince,t.quoteForm.ConsigneeInfo.ZIPCODE=n.Parties[2].ZipCode,t.quoteForm.ConsigneeInfo.CONTACT=n.Parties[2].Contact,t.quoteForm.ConsigneeInfo.PHONE=n.Parties[2].PhoneNumber,t.quoteForm.ConsigneeInfo.EMAIL=n.Parties[2].Email)},b=function(n){var i=n.HouseServices.Service;t.quoteForm.ServiceInfo.PICKUPTIME=n.HouseServices.ReadyTime;t.quoteForm.ServiceInfo.CLOSETIME=n.HouseServices.CloseTime;t.quoteForm.ServiceInfo.CODAMOUNT=n.CODAmount;t.quoteForm.ServiceInfo.DECLAREDVALUE=n.DeclaredValue;_.each(n.Tracking,function(i){i.Key=="READY"&&(t.quoteForm.ServiceInfo.READYDATETYPE=new Date(n.Tracking[0].StaticTrackDate))});v.getServiceRequest().then(function(n){t.pickupServices=n.data;t.quoteForm.ServiceInfo.READYDATETYPE==null&&(t.quoteForm.ServiceInfo.READYDATETYPE=ut());t.quoteForm.ServiceInfo.DATESCHEDULEDDELIVERYDATE==null;_.each(t.pickupServices,function(n){n.ServiceLevelDescription===i&&(t.quoteForm.ServiceInfo.ServiceRequest=n,t.quoteForm.ServiceInfo.DIMENSIONALFACTOR=n.DimRate,t.quoteForm.ServiceInfo.SVCTYPE=n.ServiceLevel,t.quoteForm.ServiceInfo.TariffCode=n.TariffCode)})}).catch(function(n){console.log(n)})},k=function(n){var i;if(n){for(i=0;i<n.PickupInstructions.length;i++)number=i+1,t.quoteForm.PickupInstructions["PICKUPINSTRUCTIONS"+number]=n.PickupInstructions[i].Note;for(i=0;i<n.DeliveryInstructions.length;i++)number=i+1,t.quoteForm.DeliveryInstructions["DELIVERYINSTRUCTIONS"+number]=n.DeliveryInstructions[i].Note}},d=function(n){n&&(t.quoteForm.TradeShow.ORGBOOTHNUMBERS=n.TradeShow.ORGBOOTHNUMBERS,t.quoteForm.TradeShow.ORGCONTACTSITENAME=n.TradeShow.ORGCONTACTSITENAME,t.quoteForm.TradeShow.ORGCONTACTSITEPHONE=n.TradeShow.ORGCONTACTSITEPHONE,t.quoteForm.TradeShow.ORGDECORATOR=n.TradeShow.ORGDECORATOR,t.quoteForm.TradeShow.ORGEXHIBITOR=n.TradeShow.ORGEXHIBITOR,t.quoteForm.TradeShow.ORGSHOWNAME=n.TradeShow.ORGSHOWNAME,t.quoteForm.TradeShow.DESTBOOTHNUMBERS=n.TradeShow.DESTBOOTHNUMBERS,t.quoteForm.TradeShow.DESTCONTACTSITENAME=n.TradeShow.DESTCONTACTSITENAME,t.quoteForm.TradeShow.DESTCONTACTSITEPHONE=n.TradeShow.DESTCONTACTSITEPHONE,t.quoteForm.TradeShow.DESTDECORATOR=n.TradeShow.DESTDECORATOR,t.quoteForm.TradeShow.DESTEXHIBITOR=n.TradeShow.DESTEXHIBITOR,t.quoteForm.TradeShow.DESTSHOWNAME=n.TradeShow.DESTSHOWNAME,_.each(n.Tracking,function(i){i.Key=="SCHEDULEDDELIVERY"&&(t.quoteForm.ServiceInfo.DATESCHEDULEDDELIVERYDATE=n.Tracking[4].StaticTrackDate=="1/1/0001"?n.Tracking[4].StaticTrackDate:new Date(n.Tracking[4].StaticTrackDate))}),t.quoteForm.ServiceInfo.SCHEDULEDDELIVERYTIME=n.Tracking[4].TrackTime)},g=function(n){n&&angular.forEach(n.Piece.Pieces,function(n){var i={TOTALPIECES:n.Pieces,PIECETYPE:n.PieceType,LONGDESCRIPTION:n.Description,WEIGHT:n.RptWeightLbs,LENGTH:n.RptLength,WIDTH:n.RptWidth,HEIGHT:n.RptHeight,DIMENSIONALWEIGHT:n.DimWeight};t.quoteForm.Pieces.push(i);ft(i)})},nt=function(n){n&&angular.forEach(n.Parts,function(n){var i={QUANTITY:n.Quan36,PARTNUMBER:n.Part36,PARTDESCRIPTION:n.ParD36,SERIALNUMBER:n.Ser36,CUSTOMERREFERENCE:n.Cstr36};t.quoteForm.Parts.push(i)})},tt=function(n){var i;if(n){for(i=0;i<n.Parties[1].References.length;i++)number=i+1,t.quoteForm.ShipperReference["AddlRef"+number]=n.Parties[1].References[i].ReferenceNumber;for(i=0;i<n.Parties[2].References.length;i++)number=i+1,t.quoteForm.ConsigneeReference["AddlRef"+number]=n.Parties[2].References[i].ReferenceNumber}},it=function(n){n&&v.getAdditionalCharges().then(function(i){t.accessorialServices=i.data;at(n)})},at=function(n){for(var r=1,u,i=0;i<n.Receivable.Receivables.length;i++)u=n.Receivable.Receivables[i].ServiceCode,_.each(t.accessorialServices,function(n){n.ChargeCode==u&&(t.newAccessorial["service"+r]=n,t.checkAccessorial(n,r),r++)})};t.cancelSpecificDelivery=function(){t.quoteForm.ServiceInfo.DATESCHEDULEDDELIVERYDATE=null;t.quoteForm.ServiceInfo.SCHEDULEDDELIVERYTIME=null};ut=function(){return new Date};t.minDate=ut();t.status={shipDateOpened:!1,specifiedDateOpened:!1};t.open=function(){t.status.shipDateOpened=!0};t.openSpecified=function(){t.status.specifiedDateOpened=!0};t.setServiceType=function(n){n?_.each(t.pickupServices,function(i){n.SVCTYPE==i.ServiceLevel&&(t.quoteForm.ServiceInfo.ServiceRequest=i,t.quoteForm.ServiceInfo.DIMENSIONALFACTOR=i.DimRate,t.quoteForm.ServiceInfo.SVCTYPE=i.ServiceLevel,t.quoteForm.ServiceInfo.TariffCode=i.TariffCode)}):(t.quoteForm.ServiceInfo.DIMENSIONALFACTOR=t.quoteForm.ServiceInfo.ServiceRequest.DimRate,t.quoteForm.ServiceInfo.SVCTYPE=t.quoteForm.ServiceInfo.ServiceRequest.ServiceLevel,t.quoteForm.ServiceInfo.TariffCode=t.quoteForm.ServiceInfo.ServiceRequest.TariffCode,ot())};ot=function(){t.quoteForm.PieceInfo.TotalPieceWeight=0;t.quoteForm.PieceInfo.TotalPieceDimWeight=0;t.quoteForm.PieceInfo.TotalPieces=0;t.calcDimWeight();_.each(t.quoteForm.Pieces,function(n){var i=n.LENGTH*n.WIDTH*n.HEIGHT*n.TOTALPIECES/t.quoteForm.ServiceInfo.DIMENSIONALFACTOR;ft(n)})};et=function(){h.getCustomPieceData().then(function(n){t.customPieceData=n.data;t.piecePallets=t.defaultPieceData.concat(t.customPieceData)}).catch(function(n){console.log(n)})};t.quotePieceData={TOTALPIECES:null,PCSCODE:null,PCSDESCLONG:null,WEIGHT:0,LENGTH:0,WIDTH:0,HEIGHT:0,DIMENSIONALWEIGHT:0};t.quoteForm.PieceInfo.TotalPieceWeight=0;t.quoteForm.PieceInfo.TotalPieceDimWeight=0;t.quoteForm.PieceInfo.TotalPieces=0;t.quoteForm.PieceInfo.TotalChargeableWeightLBS=0;t.quoteFormNav={quoteAccessorials:!1,quoteInformation:!0,quoteInstructions:!1,quoteReferences:!1,tradeShowInstructions:!1,quoteDocuments:!1};t.setTableNav=function(n){t.dashQuoteInfo=_.mapObject(t.dashQuoteInfo,function(){return!1});t.dashQuoteInfo[n]=!0};t.setFormNav=function(n){t.quoteFormNav=_.mapObject(t.quoteFormNav,function(){return!1});t.quoteFormNav[n]=!0};t.dashQuoteInfo={piece:!0,part:!1};t.addQuotePiece=function(n){t.pieceSubmitted=!0;vt(n)&&(t.quotePieceData.PCSDESCLONGTmp!=null&&(n.PCSDESCLONG=t.quotePieceData.PCSDESCLONGTmp),n.ChargeableWeightLBS=rt(n),t.quoteForm.Pieces.push({TOTALPIECES:n.TOTALPIECES,PIECETYPE:n.PCSCODE,PCSDESCSHORT:n.PCSDESCSHORT,LONGDESCRIPTION:n.PCSDESCLONG,WEIGHT:n.WEIGHT,LENGTH:n.LENGTH,WIDTH:n.WIDTH,HEIGHT:n.HEIGHT,DIMENSIONALWEIGHT:n.DIMENSIONALWEIGHT,ChargeableWeightLBS:n.ChargeableWeightLBS}),t.newQuantity=null,ft(n),yt(),t.pieceSubmitted=!1,h.getPiecesDefaults().then(function(n){t.defaultPieceData=n.data;et()}).catch(function(n){console.log(n)}))};var vt=function(n){return n.TOTALPIECES&&n.PCSCODE&&n.PCSDESCLONG&&n.WEIGHT&&n.LENGTH&&n.WIDTH&&n.HEIGHT?!0:!1},yt=function(){t.quotePieceData={TOTALPIECES:null,LONGDESCRIPTION:null,PCSDESCLONG:null,WEIGHT:0,LENGTH:0,WIDTH:0,HEIGHT:0,DIMENSIONALWEIGHT:0};t.quotePieceData.DIMENSIONALWEIGHT=Math.floor(t.dimWeight*10)/10},rt=function(){return t.quoteForm.PieceInfo.TotalPieceWeight>=t.quoteForm.PieceInfo.TotalPieceDimWeight?t.quoteForm.PieceInfo.TotalPieceWeight:t.quoteForm.PieceInfo.TotalPieceWeight<=t.quoteForm.PieceInfo.TotalPieceDimWeight?t.quoteForm.PieceInfo.TotalPieceDimWeight:void 0};t.validateMaxDeclaredValue=function(){parseInt(t.quoteForm.ServiceInfo.DECLAREDVALUE)>25e3&&(t.quoteForm.ServiceInfo.DECLAREDVALUE=25e3)};h.getPiecesDefaults().then(function(n){t.defaultPieceData=n.data;et()}).catch(function(n){console.log(n)});t.addToPiece=function(n){t.quotePieceData=t.pieceCode.indexOf("@")!=0?e("filter")(t.piecePallets,{PCSDESCLONG:t.pieceCode.split("@")[1]})[0]:e("filter")(t.piecePallets,{PCSDESCLONG:t.pieceCode})[0];t.pieceDesc=t.quotePieceData.PCSDESCLONG;t.quotePieceData.TOTALPIECES=n;t.quotePieceData.PCSDESCLONGTmp=null;t.calcDimWeight()};t.updateDesc=function(){t.quotePieceData.PCSDESCLONGTmp=t.pieceDesc};ft=function(n){t.quoteForm.PieceInfo.TotalPieceWeight+=n.WEIGHT;let i=Math.round(n.DIMENSIONALWEIGHT);i==0&&(dimWeigth=1);t.quoteForm.PieceInfo.TotalPieceDimWeight+=i;t.quoteForm.PieceInfo.TotalPieces+=n.TOTALPIECES;t.quoteForm.PieceInfo.TotalChargeableWeightLBS=rt()};t.deleteQuotePiece=function(n){var i=t.quoteForm.Pieces.indexOf(n);t.quoteForm.PieceInfo.TotalPieceWeight-=n.WEIGHT;t.quoteForm.PieceInfo.TotalPieceDimWeight-=Math.floor(n.DIMENSIONALWEIGHT/1);t.quoteForm.PieceInfo.TotalPieces-=n.TOTALPIECES;t.quoteForm.PieceInfo.TotalChargeableWeightLBS=rt();t.quoteForm.Pieces.splice(i,1)};rt=function(){return t.quoteForm.PieceInfo.TotalPieceWeight>=t.quoteForm.PieceInfo.TotalPieceDimWeight?t.quoteForm.PieceInfo.TotalPieceWeight:t.quoteForm.PieceInfo.TotalPieceWeight<=t.quoteForm.PieceInfo.TotalPieceDimWeight?t.quoteForm.PieceInfo.TotalPieceDimWeight:void 0};t.calcDimWeight=function(){var i=t.quotePieceData.LENGTH*t.quotePieceData.WIDTH*t.quotePieceData.HEIGHT*t.quotePieceData.TOTALPIECES/t.quoteForm.ServiceInfo.DIMENSIONALFACTOR,n=Math.round(i);n===0&&(n=1);t.quotePieceData.DIMENSIONALWEIGHT=n};t.addQuotePart=function(n){t.partSubmitted=!0;st(n)&&(t.quoteForm.Parts.push(angular.copy(n)),t.quotePart=null,t.partSubmitted=!1)};st=function(n){return n.QUANTITY&&n.PARTNUMBER&&n.PARTDESCRIPTION&&n.SERIALNUMBER&&n.CUSTOMERREFERENCE?!0:!1};t.deleteQuotePart=function(n){var i=t.quoteForm.Parts.indexOf(n);t.quoteForm.Parts.splice(i,1)};t.quoteDocuments=[];t.quoteImages=[];t.documentTypes=[];t.selectedDocumentType=null;s.getDocumentTypes().then(function(n){t.documentTypes=n.data}).catch(function(n){console.log(n)});t.addDocument=function(n){n&&!ht(n)&&(t.quoteDocuments.push({type:t.selectedDocumentType,file:n}),t.selectedDocumentType=null,console.log(n))};ht=function(n){_.find(t.quoteDocuments,function(t){return t.file==n?!0:!1})};t.addImage=function(n){!n||$.inArray(n,t.quoteImages)>-1||(console.log(n),t.quoteImages.push(n),t.currentImagePreview=t.quoteImages[t.quoteImages.length-1])};t.removeDocumentFile=function(n){var i=t.quoteDocuments.indexOf(n);t.quoteDocuments.splice(i,1)};t.removeImageFile=function(n){var i=t.quoteImages.indexOf(n);t.quoteImages.splice(i,1);t.currentImagePreview=t.quoteImages[t.quoteImages.length-1]};t.createQuote=function(i,r,u){var o=(new Date).setHours(0,0,0,0),e,f;i&&new Date(t.quoteForm.ServiceInfo.READYDATETYPE).setHours(0,0,0,0)<o?(i=!1,t.formCreateQuote.ship_date.$setValidity("expired",!1)):i&&new Date(t.quoteForm.ServiceInfo.READYDATETYPE).setHours(0,0,0,0)>=o&&(t.formCreateQuote.ship_date.$setValidity("expired",!0),i=!0);t.invalidShipDate=!1;t.formSubmitted=!0;t.quoteErrorMessage=null;t.addPieces=null;t.updating=!0;t.quoteCreated=!1;i&&t.quoteForm.Pieces.length?(pt(),wt(),t.disableCreateQuote=!0,e=t.quoteForm.ServiceInfo.READYDATETYPE.getFullYear().toString()+"-",e=t.quoteForm.ServiceInfo.READYDATETYPE.getMonth()>=9?e+(t.quoteForm.ServiceInfo.READYDATETYPE.getMonth()+1).toString()+"-":e+"0"+(t.quoteForm.ServiceInfo.READYDATETYPE.getMonth()+1).toString()+"-",e=t.quoteForm.ServiceInfo.READYDATETYPE.getDate()>9?e+t.quoteForm.ServiceInfo.READYDATETYPE.getDate().toString():e+"0"+t.quoteForm.ServiceInfo.READYDATETYPE.getDate().toString(),t.quoteForm.ServiceInfo.ReadyDateString=e,t.quoteForm.ServiceInfo.DATESCHEDULEDDELIVERYDATE!=undefined&&t.quoteForm.ServiceInfo.DATESCHEDULEDDELIVERYDATE!="1/1/0001"?(f=t.quoteForm.ServiceInfo.DATESCHEDULEDDELIVERYDATE.getFullYear().toString()+"-",f=t.quoteForm.ServiceInfo.DATESCHEDULEDDELIVERYDATE.getMonth()>=9?f+(t.quoteForm.ServiceInfo.DATESCHEDULEDDELIVERYDATE.getMonth()+1).toString()+"-":f+"0"+(t.quoteForm.ServiceInfo.DATESCHEDULEDDELIVERYDATE.getMonth()+1).toString()+"-",f=t.quoteForm.ServiceInfo.DATESCHEDULEDDELIVERYDATE.getDate()>9?f+t.quoteForm.ServiceInfo.DATESCHEDULEDDELIVERYDATE.getDate().toString():f+"0"+t.quoteForm.ServiceInfo.DATESCHEDULEDDELIVERYDATE.getDate().toString(),t.quoteForm.ServiceInfo.DATESCHEDULEDDELIVERYDATE=f,t.quoteForm.ServiceInfo.SchedDelDateString=f):t.quoteForm.ServiceInfo.SchedDelDateString="",t.quoteDocuments.length>0||t.quoteImages.length>0?n({url:"/quotes/UploadQuoteDocs",method:"POST",headers:{"Content-Type":undefined},transformRequest:angular.identity,data:t.getModelAsFormData()}).success(function(i){i=="True"&&n({url:"/quotes/UploadImages",method:"POST",headers:{"Content-Type":undefined},transformRequest:angular.identity,data:t.getImageAsFormData()}).success(function(n){n=="True"&&v.createOrUpdateQuote(t.quoteForm).then(function(n){t.formSubmitted=!1;t.quoteCreated=!0;t.quoteForm.ID=n.data.Entity.ShipmentData.SHIPMENTID;ct(t.quoteForm);y();u!=null?u():a.activate({ID:n.data.Entity.ShipmentData.SHIPMENTID})}).catch(function(n){console.log(n);t.quoteErrorMessage="Quote did not create. Please validate all required fields or contact your AGS representative.";t.devError=n;y()})})}):v.createOrUpdateQuote(t.quoteForm).then(function(n){t.quoteCreated=!0;t.formSubmitted=!1;t.quoteForm.ID=n.data.Entity.ShipmentData.SHIPMENTID;ct(t.quoteForm);t.$apply;y();u!=null?u():a.activate({ID:n.data.Entity.ShipmentData.SHIPMENTID})}).catch(function(n){console.log(n);t.quoteErrorMessage="Quote did not generate. Please validate all required fields or contact your AGS representative.";t.devError=n;y()})):!i&&new Date(t.quoteForm.ServiceInfo.READYDATETYPE).setHours(0,0,0,0)<o?(console.log("INVALID form!!!"),t.quoteErrorMessage="Invalid Ship Date.",y()):i?t.quoteForm.Pieces.length||(console.log("ADD SOME PIECES!!!"),t.quoteErrorMessage="Add Pieces to your shipment to complete the form",t.setFormNav("quoteInformation"),t.addPieces=!0,y()):(console.log("INVALID form!!!"),t.quoteErrorMessage="Form must be complete before submitting.",y())};t.generateQuote=function(n){t.createQuote(n,!0,function(){t.formSubmitted=!0;t.quoteErrorMessage=null;t.addPieces=null;t.disableCreateQuote=!0;t.activating=!0;t.quoteCreated=!1;t.quoteForm.ShipmentData.FILESTATUS="LIVE";n&&t.quoteForm.Pieces.length?(console.log(t.quoteForm.ShipmentData.SHIPMENTID),v.generateQuote(t.quoteForm.ShipmentData.SHIPMENTID,t.quoteForm.ShipmentData.FILESTATUS).then(function(){t.quoteCreated=!0;y();a.setQuote({ID:t.quoteForm.ShipmentData.SHIPMENTID,FileStatus:"LIVE"})}).catch(function(n){console.log(n);t.quoteErrorMessage="Quote did not generate. Please submit again or contact your AGS representative.";y()})):t.quoteCreated?(console.log("INVALID form!!!"),t.quoteErrorMessage="Form must be complete before submitting",y()):(console.log("Quote not updated!!!"),t.quoteErrorMessage="Please update quote request before activating",y())})};t.checkAccessorial=function(n,i){n?(t.quoteForm.Accessorials["Accessorial"+i]=n.ChargeCode,t.quoteForm.Accessorials["Sequence"+i]=n.ChargeCodeSequence):(delete t.quoteForm.Accessorials["Accessorial"+i],delete t.quoteForm.Accessorials["Sequence"+i])};t.getModelAsFormData=function(){var n=new FormData;return t.quoteDocuments.length>0&&(angular.forEach(t.quoteDocuments,function(t){n.append("files",t.file)}),angular.forEach(t.quoteDocuments,function(t){n.append("types",t.type)})),n};t.getImageAsFormData=function(){var n=new FormData;return t.quoteImages.length>0&&angular.forEach(t.quoteImages,function(t){n.append("images",t)}),n};t.setSaveShipperAddress=function(){t.quoteForm.ShipperInfo.DEFAULTADDRESS&&(t.quoteForm.saveShipperAddress=!0)};t.setSaveConsigneeAddress=function(){t.quoteForm.ConsigneeInfo.DEFAULTADDRESS&&(t.quoteForm.saveConsigneeAddress=!0)};var pt=function(){t.quoteForm.ShipperInfo.CUSTTYPE="S";t.quoteForm.ShipperInfo.CONTACT=t.quoteForm.ShipperInfo.CONTACT?t.quoteForm.ShipperInfo.CONTACT:" ";t.quoteForm.ShipperInfo.AUTON>0&&t.quoteForm.saveShipperAddress?h.updateShipper(t.quoteForm.ShipperInfo).then(function(){console.log("SHIPPER ADDRESS IS SAVED!")}).catch(function(n){console.log("SHIPPER ADDRESS DID NOT SAVE!");console.log(n)}):t.quoteForm.saveShipperAddress&&h.createShipper(t.quoteForm.ShipperInfo).then(function(){console.log("SHIPPER ADDRESS HAS BEEN CREATED!")}).catch(function(n){console.log("SHIPPER ADDRESS DID NOT CREATE!");console.log(n)})},wt=function(){t.quoteForm.ConsigneeInfo.CUSTTYPE="C";t.quoteForm.ConsigneeInfo.CONTACT=t.quoteForm.ConsigneeInfo.CONTACT?t.quoteForm.ConsigneeInfo.CONTACT:" ";t.quoteForm.ConsigneeInfo.AUTON>0&&t.quoteForm.saveConsigneeAddress?h.updateShipper(t.quoteForm.ConsigneeInfo).then(function(){console.log("CONSIGNEE ADDRESS IS SAVED!")}).catch(function(n){console.log("CONSIGNEE ADDRESS DID NOT SAVE!");console.log(n)}):t.quoteForm.saveConsigneeAddress&&h.createShipper(t.quoteForm.ConsigneeInfo).then(function(){console.log("CONSIGNEE ADDRESS HAS BEEN CREATED!")}).catch(function(n){console.log("CONSIGNEE ADDRESS DID NOT CREATE!");console.log(n)})},y=function(){t.disableCreateQuote=!1;t.updating=!1;t.activating=!1},ct=function(n){var t=o.open({animation:!0,templateUrl:"../../Angular/Directives/modals/quote-modal.html",controller:"quoteModalCtrl",size:"lg",resolve:{title:function(){return"Quote"},object:function(){return n},route:function(){return"/quoteRequest"}}})};t.modalPathUrls={shipperInfo:"../../Angular/Directives/modals/my_quotes_modals/quote-shipper-info-help.html",consigneeInfo:"../../Angular/Directives/modals/my_quotes_modals/quote-consignee-info-help.html",serviceInfo:"../../Angular/Directives/modals/my_quotes_modals/quote-service-info-help.html",additionalServices:"../../Angular/Directives/modals/my_quotes_modals/quote-additional-services-help.html",partsPieces:"../../Angular/Directives/modals/my_quotes_modals/quote-parts-pieces-help.html",specialInstructions:"../../Angular/Directives/modals/my_quotes_modals/quote-special-instructions-help.html",references:"../../Angular/Directives/modals/my_quotes_modals/quote-references-help.html",documents:"../../Angular/Directives/modals/my_quotes_modals/quote-documents-help.html"};t.animationsEnabled=!0;t.openHelp=function(n,i,r){var u=o.open({animation:!0,templateUrl:t.modalPathUrls[r],controller:"helpModalCtrl",size:n,resolve:{helpTitle:function(){return"Quote Request - "+i}}})};bt=function(){a.setReloadQoute(null);t.quoteForm={ShipmentData:{FILESTATUS:"NEW",CUSTNO:i.user.custNo},ShipperInfo:{},ConsigneeInfo:{},UserSettings:{},ServiceInfo:{},PieceInfo:{},Pieces:[],Parts:[],PickupInstructions:{},DeliveryInstructions:{},ShipperReference:{},ConsigneeReference:{},Accessorials:{},TradeShow:{}};h.getStateProv().then(function(n){t.stateProvinces=n.data}).catch(function(n){console.log(n)});h.getAddressBook().then(function(n){t.shipperAddresses=e("filter")(n.data,{CUSTTYPE:"S"});t.consigneeAddresses=e("filter")(n.data,{CUSTTYPE:"C"});t.quoteForm.ConsigneeInfo=e("filter")(t.consigneeAddresses,{DEFAULTADDRESS:!0})[0];t.quoteForm.ShipperInfo=e("filter")(t.shipperAddresses,{DEFAULTADDRESS:!0})[0]}).catch(function(n){console.log(n)});h.getLoggedInUser().then(function(n){h.getUserById(n.data).then(function(n){t.currentUser=n.data.user;c.getCompanyInfo(t.currentUser.CUSTOMERNUM).then(function(n){n.data[0]&&(t.billToInfo=n.data[0])}).catch(function(n){t.billToInfo=[];console.log(n)})}).catch(function(n){console.log(n)})}).catch(function(n){console.log(n)});v.getServiceRequest().then(function(n){t.pickupServices=n.data}).catch(function(n){console.log(n)});h.getUserSettings().then(function(n){t.quoteForm.SpecialInstructions=n.data[0];t.quoteForm.ServiceInfo.READYDATETYPE=new Date;t.quoteFrom.ServiceInfo.DATESCHEDULEDDELIVERYDATE==null&&(t.quoteForm.ServiceInfo.PICKUPTIME=t.quoteForm.SpecialInstructions.PICKUPTIME);t.quoteForm.ServiceInfo.CLOSETIME=t.quoteForm.SpecialInstructions.CLOSETIME}).catch(function(n){console.log(n)});t.service1=null;t.service2=null;t.service3=null;t.service4=null;t.service5=null;t.service6=null;t.service7=null;t.service8=null;t.service9=null;t.service10=null}}]);angular.module("directive.quickQuotes",[]).directive("quickQuotes",[function(){return{restrict:"E",scope:{},templateUrl:"../../Angular/Directives/quotes/quick_quotes/quick-quotes.html"}}]).controller("quickQuotesCtrl",["$http","$scope","$location","$timeout","$window","$filter","$uibModal","userFactory","companyFactory","quoteFactory","quoteService",function(n,t,i,r,u,f,e,o,s,h){var c,l,a;t.quickQuotesForm={OriginInfo:{},DestInfo:{},Services:[],Accessorials:[],Pieces:[],DIMENSIONALFACTOR:0};t.resultsTable=[{ChargeCode:"AIR",ChargeDescription:"TRANSPORTATION CHARGE",Services:[]},{ChargeCode:"PKUP",ChargeDescription:"PICKUP",Services:[]},{ChargeCode:"DLVY",ChargeDescription:"DELIVERY",Services:[]},{ChargeCode:"FUSC",ChargeDescription:"FUEL SURCHARGE",Services:[]}];t.quickQuotesForm.TotalPieces=0;t.quickQuotesForm.TotalWeight=0;t.quickQuotesForm.TotalDisplayWeight=0;t.quickQuotesForm.TotalDimWeight=0;t.quickQuoteNav={pieces:!1,accessorials:!0};t.setFormNav=function(n){t.quickQuoteNav=_.mapObject(t.quickQuoteNav,function(){return!1});t.quickQuoteNav[n]=!0};o.getStateProv().then(function(n){t.stateProvinces=n.data}).catch(function(n){console.log(n)});h.getServiceRequest().then(function(n){t.pickupServices=n.data;_.each(t.pickupServices,function(n,t){n[t]=!0});t.selectServices();o.getUserSettings().then(function(n){t.userSettings=n.data[0];_.each(t.pickupServices,function(n){n.ServiceLevelDescription===n.ServiceLevel&&(t.quickQuotesForm.DIMENSIONALFACTOR=n.DimRate)})}).catch(function(n){console.log(n)})}).catch(function(n){t.pickupServices=[];console.log(n)});h.getAdditionalCharges().then(function(n){t.accessorialServices=n.data}).catch(function(n){console.log(n)});t.selectServices=function(){t.quickQuotesForm.Services=[];t.quickQuotesForm.DIMENSIONALFACTOR=0;_.each(t.pickupServices,function(n,i){n[i]&&(t.quickQuotesForm.Services.push({ServiceLevel:n.ServiceLevel,TariffCode:n.TariffCode,Description:n.ServiceLevelDescription}),t.quickQuotesForm.DIMENSIONALFACTOR+=n.DimRate)})};t.selectAccessorial=function(n,i){var f,e,r,u;n?(f={accessorialIndex:i,ChargeCode:n.ChargeCode,ChargeCodeDescription:n.ChargeCodeDescription,ChargeCodeSequence:n.ChargeCodeSequence,ChargeCodeShortDescription:n.ChargeCodeShortDescription},e={accessorialIndex:i,ChargeCode:n.ChargeCode,ChargeDescription:n.ChargeCodeShortDescription,Services:[]},t.quickQuotesForm.Accessorials.push(f),t.resultsTable.push(e),t.$apply):(r=null,u=null,_.findIndex(t.quickQuotesForm.Accessorials,function(n,t){n.accessorialIndex==i&&(r=t)}),_.findIndex(t.resultsTable,function(n,t){n.accessorialIndex==i&&(u=t)}),t.quickQuotesForm.Accessorials.splice(r,1),t.resultsTable.splice(u,1))};t.checkedItem=function(n){return _.findIndex(t.loadList.list,function(t){return t.ID==n})};t.generateQuickQuote=function(n){if(t.hasCharges=!0,t.formSubmitted=!0,t.disableQuickQuote=!0,t.quoteErrorMessage=null,n&&t.quickQuotesForm.Services.length&&t.quickQuotesForm.OriginInfo.OriginZipCode&&t.quickQuotesForm.DestInfo.DestZipCode){var i=[];angular.forEach(t.quickQuotesForm.Services,function(n){i.push(n.ServiceLevel)});h.getQuickQuote(t.quickQuotesForm.OriginInfo.OriginState==null?"":t.quickQuotesForm.OriginInfo.OriginState,t.quickQuotesForm.OriginInfo.OriginZipCode,t.quickQuotesForm.DestInfo.DestState==null?"":t.quickQuotesForm.DestInfo.DestState,t.quickQuotesForm.DestInfo.DestZipCode,t.quickQuotesForm.TotalPieces,t.quickQuotesForm.TotalDisplayWeight,t.accessorial1==null?"":t.accessorial1.ChargeCode,t.accessorial1==null?0:t.accessorial1.ChargeCodeSequence,t.accessorial2==null?"":t.accessorial2.ChargeCode,t.accessorial2==null?0:t.accessorial2.ChargeCodeSequence,t.accessorial3==null?"":t.accessorial3.ChargeCode,t.accessorial3==null?0:t.accessorial3.ChargeCodeSequence,t.accessorial4==null?"":t.accessorial4.ChargeCode,t.accessorial4==null?0:t.accessorial4.ChargeCodeSequence,t.accessorial5==null?"":t.accessorial5.ChargeCode,t.accessorial5==null?0:t.accessorial5.ChargeCodeSequence,t.accessorial6==null?"":t.accessorial6.ChargeCode,t.accessorial6==null?0:t.accessorial6.ChargeCodeSequence,t.accessorial7==null?"":t.accessorial7.ChargeCode,t.accessorial7==null?0:t.accessorial7.ChargeCodeSequence,t.accessorial8==null?"":t.accessorial8.ChargeCode,t.accessorial8==null?0:t.accessorial8.ChargeCodeSequence,t.accessorial9==null?"":t.accessorial9.ChargeCode,t.accessorial9==null?0:t.accessorial9.ChargeCodeSequence,t.accessorial10==null?"":t.accessorial10.ChargeCode,t.accessorial10==null?0:t.accessorial10.ChargeCodeSequence,i,t.quickQuotesForm.Pieces).then(function(n){t.quoteResults=n.data.quoteCharges;t.sessionId=n.data.sessionId;t.tServices=i.join();var r=!1;_.each(n.data,function(i){i.ChargeAmount>0&&(r=!0);i.Disclaimer!=null&&i.Disclaimer!=""&&(t.disclaimer=n.data[0].Disclaimer)});!r&&n.data.length>0&&(t.hasCharges=!1);y();c()}).catch(function(n){t.formSubmitted=!1;t.disableQuickQuote=!1;t.quoteResults=[];console.log(n)})}else n?t.quickQuotesForm.Services.length||(t.disableQuickQuote=!1,t.quoteErrorMessage="Choose a selected services before submitting."):(t.disableQuickQuote=!1,t.quoteErrorMessage="Complete all required fields before submitting.")};o.getPiecesDefaults().then(function(n){t.defaultPieceData=n.data;c()}).catch(function(n){console.log(n)});c=function(){o.getCustomPieceData().then(function(n){n.data&&(t.customPieceData=n.data,t.piecePallets=t.defaultPieceData.concat(t.customPieceData))}).catch(function(n){console.log(n)})};t.quotePieceData={TOTALPIECES:null,PCSDESCSHORT:null,PCSDESCLONG:null,WEIGHT:0,LENGTH:0,WIDTH:0,HEIGHT:0,DIMENSIONALWEIGHT:0};t.calcDimWeight=function(){var n=t.quotePieceData.LENGTH*t.quotePieceData.WIDTH*t.quotePieceData.HEIGHT*t.quotePieceData.TOTALPIECES/t.quickQuotesForm.DIMENSIONALFACTOR;t.quotePieceData.DIMENSIONALWEIGHT=Math.floor(n/1)};t.addToPiece=function(n){t.quotePieceData=t.pieceCode.indexOf("@")!=0?f("filter")(t.piecePallets,{PCSDESCLONG:t.pieceCode.split("@")[1]})[0]:f("filter")(t.piecePallets,{PCSDESCLONG:t.pieceCode})[0];t.quotePieceData.TOTALPIECES=n};t.addQuotePiece=function(n){t.pieceSubmitted=!0;t.calcDimWeight();l(n)&&(t.quickQuotesForm.Pieces.push(angular.copy({TOTALPIECES:n.TOTALPIECES,PIECETYPE:n.PCSCODE,PCSDESCSHORT:n.PCSDESCSHORT,LONGDESCRIPTION:n.PCSDESCLONG,WEIGHT:n.WEIGHT,LENGTH:n.LENGTH,WIDTH:n.WIDTH,HEIGHT:n.HEIGHT,DIMENSIONALWEIGHT:n.DIMENSIONALWEIGHT})),t.newQuantity=null,a(n),v(),t.pieceSubmitted=!1,o.getPiecesDefaults().then(function(n){t.defaultPieceData=n.data;c()}).catch(function(n){console.log(n)}))};l=function(n){return n.TOTALPIECES&&n.PCSCODE&&n.PCSDESCLONG&&n.WEIGHT&&n.LENGTH&&n.WIDTH&&n.HEIGHT?!0:!1};a=function(n){t.quickQuotesForm.TotalPieces||(t.quickQuotesForm.TotalPieces=0);t.quickQuotesForm.TotalWeight||(t.quickQuotesForm.TotalWeight=0);t.quickQuotesForm.TotalDimWeight||(t.quickQuotesForm.TotalDimWeight=0);t.quickQuotesForm.TotalDisplayWeight||(t.quickQuotesForm.TotalDisplayWeight=0);t.quickQuotesForm.TotalPieces=0;_.each(t.quickQuotesForm.Pieces,function(n){t.quickQuotesForm.TotalPieces+=n.TOTALPIECES});t.quickQuotesForm.TotalWeight+=n.WEIGHT;t.quickQuotesForm.TotalDimWeight+=n.DIMENSIONALWEIGHT;t.quickQuotesForm.TotalDisplayWeight=t.quickQuotesForm.TotalWeight>t.quickQuotesForm.TotalDimWeight?t.quickQuotesForm.TotalWeight:t.quickQuotesForm.TotalDimWeight};t.deleteQuotePiece=function(n){var i=t.quickQuotesForm.Pieces.indexOf(n);t.quickQuotesForm.TotalPieces-=n.TOTALPIECES;t.quickQuotesForm.TotalWeight-=n.WEIGHT;t.quickQuotesForm.TotalDimWeight-=n.DIMENSIONALWEIGHT;t.quickQuotesForm.TotalDisplayWeight=t.quickQuotesForm.TotalWeight>t.quickQuotesForm.TotalDimWeight?t.quickQuotesForm.TotalWeight:t.quickQuotesForm.TotalDimWeight;t.quickQuotesForm.Pieces.splice(i,1)};var v=function(){t.quotePieceData={TOTALPIECES:null,PCSDESCLONG:null,WEIGHT:0,LENGTH:0,WIDTH:0,HEIGHT:0,DIMENSIONALWEIGHT:0}},y=function(){t.totalCharges={};t.quoteResultsTable=angular.copy(t.resultsTable);p();_.each(t.quoteResults,function(n){if(!w(n.Charge,t.quoteResultsTable)){var i={ChargeCode:n.Charge,ChargeDescription:n.ChargeDescription,Services:[]};t.quoteResultsTable.push(i)}_.each(t.quoteResultsTable,function(i){if(i.ChargeCode==n.Charge&&!b(n.Service,i.Services)){var r={ServiceLevel:n.Service,ChargeAmount:k(n.Charge,n.Service)};t.totalCharges[n.Service+"_TOTAL"]=0;i.Services.push(r)}})});_.each(t.quoteResultsTable[0].Services,function(n){_.each(t.pickupServices,function(t){n.ServiceLevel==t.ServiceLevel&&(n.ServiceLevelDescription=t.ServiceLevelDescription)})});_.each(t.quoteResultsTable,function(n){_.each(n.Services,function(n){t.totalCharges[n.ServiceLevel+"_TOTAL"]+=n.ChargeAmount})});t.disableQuickQuote=!1},p=function(){_.each(t.quoteResultsTable,function(n){n.Services=[]})},w=function(n,t){for(var i=0;i<t.length;i++)if(n==t[i].ChargeCode)return!0;return!1},d=function(){var n=[];_.each(t.quoteResults,function(t){var i={Charge:t.Charge,ChargeDescription:t.ChargeDescription,ChargeAmount:t.ChargeAmount,Service:t.Service};n.push(i)})},b=function(n,t){for(var i=0;i<t.length;i++)if(n==t[i].ServiceLevel)return!0;return!1},g=function(n,t){for(var i=0;i<t.length;i++)if(n.ChargeCode==t[i].ChargeCode)return t[i]},k=function(n,i){var r=0;return _.each(t.quoteResults,function(t){n==t.Charge&&i==t.Service&&(r=t.ChargeAmount)}),r}}]);angular.module("directive.myQuotes",[]).directive("myQuotes",[function(){return{restrict:"E",scope:{},templateUrl:"../../Angular/Directives/quotes/my_quotes/my-quotes.html"}}]).controller("myQuotesCtrl",["$http","$scope","$rootScope","$location","$timeout","$window","$filter","$uibModal","userFactory","companyFactory","quoteFactory","quoteService","shipmentService","shipmentFactory","trackingFactory",function(n,t,i,r,u,f,e,o,s,h,c,l,a,v,y){t.curPage=0;t.pageSize=10;t.searchText="";i.user.features.LimitDefaultShipmentRange==!0?function(){var n=new Date,i=new Date,r=n.setDate(n.getDate()),u=i.setDate(i.getDate()+14);t.startDate=new Date(r);t.endDate=new Date(u);t.loadingQuotes=!0;c.getAllQuotes(t.startDate,t.endDate).then(function(n){t.loadingQuotes=!1;t.myQuotes=n.data;t.setDates()}).catch(function(n){t.loadingQuotes=!1;t.myQuotes=[];console.log(n)})}():function(){var n=new Date,i=new Date,r=n.setDate(n.getDate()-30),u=i.setDate(i.getDate());t.startDate=new Date(r);t.endDate=new Date(u);t.loadingQuotes=!0;c.getAllQuotes(t.startDate,t.endDate).then(function(n){t.loadingQuotes=!1;t.myQuotes=n.data;t.setDates()}).catch(function(n){t.loadingQuotes=!1;t.myQuotes=[];console.log(n)})}();t.setDates=function(){_.each(t.myQuotes,function(n){n.DeliveryDate={};n.ShipDate={};n.StaticDeliveryDate={};n.StaticShipDate={};n.ShipDate=parseInt(n.ReadyDate.match(/(\d+)|(-\d+)/)[0]);n.StaticShipDate=n.StaticTrackDate.toString();n.StaticDeliveryDate=n.ScheduleDeliveryDate=="1/1/0001"||n.ScheduleDeliveryDate=="1/1/1901"||n.ScheduleDeliveryDate=="1/1/2001"?null:n.ScheduleDeliveryDate})};t.numberOfPages=function(){return Math.ceil(t.myQuotes.length/t.pageSize)};t.checkFileStatus=function(n){return n.FileStatus==="LIVE"||n.FileStatus==="LIVERO"?!0:!1};t.calendar={startOpen:!1,endOpen:!1};t.open=function(n){t.calendar[n]=!0};t.createDateIncrements=function(n,i){t.loadingQuotes=!0;c.getAllQuotes(n,i).then(function(n){t.loadingQuotes=!1;t.myQuotes=n.data;t.setDates()}).catch(function(n){t.loadingQuotes=!1;t.myQuotes=[];console.log(n)})};var p=function(n,i){var r=new Date(n),u=new Date(i);t.loadingQuotes=!0;c.getAllQuotes(r,u).then(function(n){t.loadingQuotes=!1;t.myQuotes=n.data;t.setDates()}).catch(function(n){t.loadingQuotes=!1;t.myQuotes=[];console.log(n)})};t.searchByAGSBILL=function(){t.loadingQuotes=!0;y.trackShipmentByBillNumber(t.searchText).then(function(n){t.loadingQuotes=!1;t.myQuotes=n.data;t.setDates()}).catch(function(n){t.loadingQuotes=!1;t.myQuotes=[];console.log(n)})};t.originalQuotes=[];t.filterChange=function(){t.originalQuotes.length==0&&(t.originalQuotes=angular.copy(t.myQuotes));t.searchText==""&&(t.myQuotes=t.originalQuotes);t.myQuotes=e("filter")(t.originalQuotes,t.searchText)};t.activateQuote=function(n){l.activate(n)};t.copyQuote=function(n){l.copyQuote(n)};t.sortToggle={bill:!1,shipName:!1,shipCity:!1,consigneeName:!1,consigneCity:!1,shipDate:!0,deliveryDate:!1};t.orderHeader="ShipDate";t.reverse=!0;t.prevPage=function(){t.curPage=t.curPage-1};t.nextPage=function(){t.curPage=t.curPage+1};t.order=function(n,i){t.reverse=t.orderHeader===n?!t.reverse:!1;t.orderHeader=n;t.myQuotes=e("orderBy")(t.myQuotes,n,t.reverse);t.sortToggle=_.mapObject(t.sortToggle,function(){return!1});t.sortToggle[i]=!0};t.animationsEnabled=!0;t.showQuote=function(n){var t=o.open({animation:!0,templateUrl:"../../Angular/Directives/modals/quote-modal.html",controller:"quoteModalCtrl",size:"lg",resolve:{title:function(){return"Quote"},object:function(){return n},route:function(){return null}}})};t.viewQuoteDetails=function(n){console.log("Getting the quote!!!");console.log(n);l.setQuote(n)};t.modalPathUrls={myQuotes:"../../Angular/Directives/modals/my_quotes_modals/quote-shipper-info-help.html"};t.openHelp=function(n,i,r){var u=o.open({animation:!0,templateUrl:t.modalPathUrls[r],controller:"helpModalCtrl",size:n,resolve:{helpTitle:function(){return i}}})}}]).filter("pagination",function(){return function(n,t){return t=+t,n.slice(t)}});angular.module("directive.quoteShow",[]).directive("quoteShow",[function(){return{restrict:"E",scope:{},templateUrl:"../../Angular/Directives/quotes/quote_show/quote-show.html"}}]).controller("quoteShowCtrl",["$http","$scope","$rootScope","$location","$timeout","$window","$uibModal","shipmentService","userFactory","companyFactory","shipmentFactory","quoteFactory","quoteService",function(n,t,i,r,u,f,e,o,s,h,c,l,a){var y,p,w;t.billToInfo={};t.quoteForm={ShipmentData:{FILESTATUS:"NEW",CUSTNO:i.user.custNo},ShipperInfo:{},ConsigneeInfo:{},UserSettings:{},ServiceInfo:{},PieceInfo:{},Pieces:[],Parts:[],PickupInstructions:{},DeliveryInstructions:{},ShipperReference:{},ConsigneeReference:{},Accessorials:{},MemoInfo:{},TradeShow:{}};t.userSettings={};t.disableActivateQuote=!1,function(){t.fileStatus=a._quote.FileStatus;t.fileStatus==="LIVE"||t.fileStatus==="LIVERO"?l.getQuoteById(a._quote.ID).then(function(n){t.processQuote(n)}).catch(function(n){console.log(n)}):l.getQuoteByIdFromStaging(a._quote.ID).then(function(n){t.processQuote(n)}).catch(function(n){console.log(n)})}();t.processQuote=function(n){l.getServiceRequest().then(function(i){t.pickupServices=i.data;t.showQuote=n.data[0];p(t.showQuote);d(n.data[0]);b();k();t.quoteForm.ServiceInfo.READYDATETYPE==null&&(t.quoteForm.ServiceInfo.READYDATETYPE=y());_.each(t.pickupServices,function(n){n.ServiceLevelDescription===t.activeServiceLevel&&(t.quoteForm.ServiceInfo.ServiceRequest=n,t.quoteForm.ServiceInfo.DIMENSIONALFACTOR=n.DimRate,t.quoteForm.ServiceInfo.SVCTYPE=n.ServiceLevel,t.quoteForm.ServiceInfo.TariffCode=n.TariffCode)})}).catch(function(n){console.log(n)})};t.totalEstimate=0;t.setServiceType=function(n){n?_.each(t.pickupServices,function(i){n.SVCTYPE==i.ServiceLevel&&(t.quoteForm.ServiceInfo.ServiceRequest=i,t.quoteForm.ServiceInfo.DIMENSIONALFACTOR=i.DimRate,t.quoteForm.ServiceInfo.SVCTYPE=i.ServiceLevel,t.quoteForm.ServiceInfo.TariffCode=i.TariffCode)}):(t.quoteForm.ServiceInfo.DIMENSIONALFACTOR=t.quoteForm.ServiceInfo.ServiceRequest.DimRate,t.quoteForm.ServiceInfo.SVCTYPE=t.quoteForm.ServiceInfo.ServiceRequest.ServiceLevel,t.quoteForm.ServiceInfo.TariffCode=t.quoteForm.ServiceInfo.ServiceRequest.TariffCode)};y=function(){return new Date};t.minDate=y();var b=function(){a._quote.FileStatus==="LIVE"||a._quote.FileStatus==="LIVERO"?l.getQuoteById(t.showQuote.ID).then(function(n){t.showQuote.QuoteCharges=n.data[0];_.mapObject(t.showQuote.QuoteCharges.Receivable.Receivables,function(n){t.totalEstimate+=n.EstimatedReceivable;t.showQuote.QuoteCharges.TotalEstimateCost=t.totalEstimate})}).catch(function(n){console.log(n)}):l.getQuoteByIdFromStaging(t.showQuote.ID).then(function(n){t.showQuote.QuoteCharges=n.data[0];_.mapObject(t.showQuote.QuoteCharges.Receivable.Receivables,function(n){t.totalEstimate+=n.EstimatedReceivable;t.showQuote.QuoteCharges.TotalEstimateCost=t.totalEstimate})}).catch(function(n){console.log(n)})},k=function(){t.showQuote.DeliveryDate={};t.showQuote.ShipDate={};t.showQuote.ShipDate={};t.showQuote.StaticShipDate={};_.each(t.showQuote.Tracking,function(n){if(n.Key=="READY"&&(t.showQuote.ShipDate=parseInt(n.TrackDate.match(/(\d+)|(-\d+)/)[0]),t.showQuote.StaticShipDate=n.StaticTrackDate.toString()),n.Key=="SCHEDULEDDELIVERY"){var i=parseInt(n.TrackDate.match(/(\d+)|(-\d+)/)[0]);i>0?(t.showQuote.DeliveryDate=i,t.showQuote.StaticDeliveryDate=n.StaticTrackDate.toString()):(t.showQuote.DeliveryDate=null,t.showQuote.StaticDeliveryDate="")}})},d=function(n){t.showQuote.MemoNotes=[];_.each(n.TraceNotes,function(n){n.ExternallyAvailable&&(n.LastUpdateDate=parseInt(n.LastUpdateDate.match(/(\d+)|(-\d+)/)[0]),t.showQuote.MemoNotes.push(n))})};t.activateQuote=function(){t.quoteErrorMessage=null;t.quoteActivated=!1;t.disableActivateQuote=!0;l.activateQuote(t.showQuote.ID,"LIVERO").then(function(n){t.quoteActivated=!0;t.openConfirmation("lg",n.data,n.data);t.disableActivateQuote=!1}).catch(function(n){console.log(n);t.quoteErrorMessage="Quote did not activate. Please submit again or contact your AGS representative.";t.disableActivateQuote=!1})};var g=function(n){n&&(t.quoteForm.ShipmentData.SHIPMENTID=n.ID,t.quoteForm.ShipmentData.HOUSE=n.HouseAirWaybillNumber,t.quoteForm.ShipmentData.ID=n.ID)},nt=function(n){n&&(t.quoteForm.ShipperInfo.NAME=n.Parties[1].PartyName,t.quoteForm.ShipperInfo.NAME9A=n.Parties[1].PartyAlphaCode,t.quoteForm.ShipperInfo.ADDRESS1=n.Parties[1].Address1,t.quoteForm.ShipperInfo.ADDRESS2=n.Parties[1].Address2,t.quoteForm.ShipperInfo.CITY=n.Parties[1].City,t.quoteForm.ShipperInfo.STATE=n.Parties[1].StateProvince,t.quoteForm.ShipperInfo.ZIPCODE=n.Parties[1].ZipCode,t.quoteForm.ShipperInfo.CONTACT=n.Parties[1].Contact,t.quoteForm.ShipperInfo.PHONE=n.Parties[1].PhoneNumber,t.quoteForm.ShipperInfo.EMAIL=n.Parties[1].Email)},tt=function(n){n&&(t.quoteForm.ConsigneeInfo.NAME=n.Parties[2].PartyName,t.quoteForm.ConsigneeInfo.NAME9A=n.Parties[2].PartyAlphaCode,t.quoteForm.ConsigneeInfo.ADDRESS1=n.Parties[2].Address1,t.quoteForm.ConsigneeInfo.ADDRESS2=n.Parties[2].Address2,t.quoteForm.ConsigneeInfo.CITY=n.Parties[2].City,t.quoteForm.ConsigneeInfo.STATE=n.Parties[2].StateProvince,t.quoteForm.ConsigneeInfo.ZIPCODE=n.Parties[2].ZipCode,t.quoteForm.ConsigneeInfo.CONTACT=n.Parties[2].Contact,t.quoteForm.ConsigneeInfo.PHONE=n.Parties[2].PhoneNumber,t.quoteForm.ConsigneeInfo.EMAIL=n.Parties[2].Email)},it=function(n){t.activeServiceLevel=n.HouseServices.Service;t.quoteForm.ServiceInfo.PICKUPTIME=n.HouseServices.ReadyTime;t.quoteForm.ServiceInfo.CLOSETIME=n.HouseServices.CloseTime;t.quoteForm.ServiceInfo.CODAMOUNT=n.CODAmount;t.quoteForm.ServiceInfo.DECLAREDVALUE=n.DeclaredValue;_.each(n.Tracking,function(n){if(n.Key=="READY"){var i=parseInt(n.TrackDate.match(/(\d+)|(-\d+)/)[0]);t.quoteForm.ServiceInfo.READYDATETYPE=new Date(i)}})},rt=function(n){t.quoteForm.PieceInfo.TotalPieceWeight+=n.WEIGHT;let i=Math.round(n.DIMENSIONALWEIGHT);i===0&&(i=1);t.quoteForm.PieceInfo.TotalPieceDimWeight+=i;t.quoteForm.PieceInfo.TotalPieces+=n.TOTALPIECES;t.quoteForm.PieceInfo.TotalChargeableWeightLBS=ut()},ut=function(){return t.quoteForm.PieceInfo.TotalPieceWeight>=t.quoteForm.PieceInfo.TotalPieceDimWeight?t.quoteForm.PieceInfo.TotalPieceWeight:t.quoteForm.PieceInfo.TotalPieceWeight<=t.quoteForm.PieceInfo.TotalPieceDimWeight?t.quoteForm.PieceInfo.TotalPieceDimWeight:void 0},ft=function(n){var i;if(n){for(i=0;i<n.PickupInstructions.length;i++)number=i+1,t.quoteForm.PickupInstructions["PICKUPINSTRUCTIONS"+number]=n.PickupInstructions[i].Note;for(i=0;i<n.DeliveryInstructions.length;i++)number=i+1,t.quoteForm.DeliveryInstructions["DELIVERYINSTRUCTIONS"+number]=n.DeliveryInstructions[i].Note}},et=function(n){n&&(t.quoteForm.TradeShow.ORGBOOTHNUMBERS=n.TradeShow.ORGBOOTHNUMBERS,t.quoteForm.TradeShow.ORGCONTACTSITENAME=n.TradeShow.ORGCONTACTSITENAME,t.quoteForm.TradeShow.ORGCONTACTSITEPHONE=n.TradeShow.ORGCONTACTSITEPHONE,t.quoteForm.TradeShow.ORGDECORATOR=n.TradeShow.ORGDECORATOR,t.quoteForm.TradeShow.ORGEXHIBITOR=n.TradeShow.ORGEXHIBITOR,t.quoteForm.TradeShow.ORGSHOWNAME=n.TradeShow.ORGSHOWNAME,t.quoteForm.TradeShow.DESTBOOTHNUMBERS=n.TradeShow.DESTBOOTHNUMBERS,t.quoteForm.TradeShow.DESTCONTACTSITENAME=n.TradeShow.DESTCONTACTSITENAME,t.quoteForm.TradeShow.DESTCONTACTSITEPHONE=n.TradeShow.DESTCONTACTSITEPHONE,t.quoteForm.TradeShow.DESTDECORATOR=n.TradeShow.DESTDECORATOR,t.quoteForm.TradeShow.DESTEXHIBITOR=n.TradeShow.DESTEXHIBITOR,t.quoteForm.TradeShow.DESTSHOWNAME=n.TradeShow.DESTSHOWNAME,_.each(n.Tracking,function(n){if(n.Key=="SCHEDULEDDELIVERY"){var i=parseInt(n.TrackDate.match(/(\d+)|(-\d+)/)[0]);t.quoteForm.ServiceInfo.DATESCHEDULEDDELIVERYDATE=new Date(i)}}),t.quoteForm.ServiceInfo.SCHEDULEDDELIVERYTIME=n.Tracking[4].TrackTime)},ot=function(n){n&&angular.forEach(n.Piece.Pieces,function(n){var i={TOTALPIECES:n.Pieces,PIECETYPE:n.PieceType,LONGDESCRIPTION:n.Description,WEIGHT:n.RptWeightLbs,LENGTH:n.RptLength,WIDTH:n.RptWidth,HEIGHT:n.RptHeight,DIMENSIONALWEIGHT:n.DimWeight};t.quoteForm.Pieces.push(i);rt(i)})},st=function(n){n&&angular.forEach(n.Parts,function(n){var i={QUANTITY:n.Quan36,PARTNUMBER:n.Part36,PARTDESCRIPTION:n.ParD36,SERIALNUMBER:n.Ser36,CUSTOMERREFERENCE:n.Cstr36};t.quoteForm.Parts.push(i)})},ht=function(n){var i;if(n){for(i=0;i<n.Parties[1].References.length;i++)number=i+1,t.quoteForm.ShipperReference["AddlRef"+number]=n.Parties[1].References[i].ReferenceNumber;for(i=0;i<n.Parties[2].References.length;i++)number=i+1,t.quoteForm.ConsigneeReference["AddlRef"+number]=n.Parties[2].References[i].ReferenceNumber}},ct=function(n){n&&l.getAdditionalCharges().then(function(i){t.accessorialServices=i.data;lt(n)})},lt=function(n){for(var r=1,u,i=0;i<n.Receivable.Receivables.length;i++)u=n.Receivable.Receivables[i].ServiceCode,_.each(t.accessorialServices,function(n){n.ChargeCode==u&&(t.newAccessorial["service"+r]=n,t.checkAccessorial(n,r),r++)})},at=function(){t.quoteForm.ShipperInfo.CUSTTYPE="S";t.quoteForm.ShipperInfo.CONTACT=t.quoteForm.ShipperInfo.CONTACT?t.quoteForm.ShipperInfo.CONTACT:" ";t.quoteForm.ShipperInfo.AUTON>0&&t.quoteForm.saveShipperAddress?s.updateShipper(t.quoteForm.ShipperInfo).then(function(){console.log("SHIPPER ADDRESS IS SAVED!")}).catch(function(n){console.log("SHIPPER ADDRESS DID NOT SAVE!");console.log(n)}):t.quoteForm.saveShipperAddress&&s.createShipper(t.quoteForm.ShipperInfo).then(function(){console.log("SHIPPER ADDRESS HAS BEEN CREATED!")}).catch(function(n){console.log("SHIPPER ADDRESS DID NOT CREATE!");console.log(n)})},vt=function(){t.quoteForm.ConsigneeInfo.CUSTTYPE="C";t.quoteForm.ConsigneeInfo.CONTACT=t.quoteForm.ConsigneeInfo.CONTACT?t.quoteForm.ConsigneeInfo.CONTACT:" ";t.quoteForm.ConsigneeInfo.AUTON>0&&t.quoteForm.saveConsigneeAddress?s.updateShipper(t.quoteForm.ConsigneeInfo).then(function(){console.log("CONSIGNEE ADDRESS IS SAVED!")}).catch(function(n){console.log("CONSIGNEE ADDRESS DID NOT SAVE!");console.log(n)}):t.quoteForm.saveConsigneeAddress&&s.createShipper(t.quoteForm.ConsigneeInfo).then(function(){console.log("CONSIGNEE ADDRESS HAS BEEN CREATED!")}).catch(function(n){console.log("CONSIGNEE ADDRESS DID NOT CREATE!");console.log(n)})},v=function(){t.disableCreateQuote=!1;t.updating=!1;t.activating=!1};t.createQuote=function(n,i,r){t.formSubmitted=!0;t.quoteErrorMessage=null;t.addPieces=null;t.updating=!0;t.quoteCreated=!1;var u=t.quoteForm.ServiceInfo.READYDATETYPE.getFullYear().toString()+"-";u=t.quoteForm.ServiceInfo.READYDATETYPE.getMonth()>=9?u+(t.quoteForm.ServiceInfo.READYDATETYPE.getMonth()+1).toString()+"-":u+"0"+(t.quoteForm.ServiceInfo.READYDATETYPE.getMonth()+1).toString()+"-";u=t.quoteForm.ServiceInfo.READYDATETYPE.getDate()>9?u+t.quoteForm.ServiceInfo.READYDATETYPE.getDate().toString():u+"0"+t.quoteForm.ServiceInfo.READYDATETYPE.getDate().toString();t.quoteForm.ServiceInfo.ReadyDateString=u;n&&t.quoteForm.Pieces.length?(at(),vt(),t.disableCreateQuote=!0,l.createOrUpdateQuote(t.quoteForm).then(function(n){t.quoteCreated=!0;t.formSubmitted=!1;t.quoteForm.ID=n.data.Entity.ShipmentData.SHIPMENTID;w(t.quoteForm);t.$apply;v();r!=null&&r()}).catch(function(n){console.log(n);t.quoteErrorMessage="Quote did not create. Please validate all required fields or contact your AGS representative.";t.devError=n;v()})):n?t.quoteForm.Pieces.length||(console.log("ADD SOME PIECES!!!"),t.quoteErrorMessage="Add Pieces to your shipment to complete the form",t.setFormNav("quoteInformation"),t.addPieces=!0,v()):(console.log("INVALID form!!!"),t.quoteErrorMessage="Form must be complete before submitting.",v())};t.generateQuote=function(n){t.createQuote(n,!0,function(){t.formSubmitted=!0;t.quoteErrorMessage=null;t.addPieces=null;t.disableCreateQuote=!0;t.activating=!0;t.quoteCreated=!1;t.quoteForm.ShipmentData.FILESTATUS="LIVE";n&&t.quoteForm.Pieces.length?(console.log(t.quoteForm.ID),l.generateQuote(t.quoteForm.ID,t.quoteForm.ShipmentData.FILESTATUS).then(function(){t.quoteCreated=!0;v()}).catch(function(n){console.log(n);t.quoteErrorMessage="Quote did not generate. Please submit again or contact your AGS representative.";v()})):t.quoteCreated?(console.log("INVALID form!!!"),t.quoteErrorMessage="Form must be complete before submitting",v()):(console.log("Quote not updated!!!"),t.quoteErrorMessage="Please update quote request before generating",v())})};p=function(n){t.quoteForm={ShipmentData:{FILESTATUS:"LIVE",CUSTNO:i.user.custNo},ShipperInfo:{},ConsigneeInfo:{},UserSettings:{},ServiceInfo:{},PieceInfo:{},Pieces:[],Parts:[],PickupInstructions:{},DeliveryInstructions:{},ShipperReference:{},ConsigneeReference:{},Accessorials:{},MemoInfo:{},TradeShow:{}};t.quoteForm.PieceInfo.TotalPieceWeight=0;t.quoteForm.PieceInfo.TotalPieceDimWeight=0;t.quoteForm.PieceInfo.TotalPieces=0;t.quoteForm.PieceInfo.TotalChargeableWeightLBS=0;g(n);nt(n);tt(n);ft(n);it(n);ot(n);st(n);ht(n);ct(n);et(n)};t.openConfirmation=function(n,i,r){var u=e.open({animation:!0,templateUrl:"../../Angular/Directives/modals/my_quotes_modals/quote-create-confirm.html",controller:"quoteConfirmModalCtrl",size:n,resolve:{billToNumber:function(){return i},quoteForm:function(){return t.showQuote},shipmentId:function(){return r},route:function(){return"/myQuotes"}}})};w=function(n){var t=e.open({animation:!0,templateUrl:"../../Angular/Directives/modals/quote-modal.html",controller:"quoteModalCtrl",size:"lg",resolve:{title:function(){return"Quote"},object:function(){return n},route:function(){return"/myQuotes"}}})}}]);angular.module("directive.importEntry",[]).directive("importEntry",[function(){return{restrict:"E",scope:{},templateUrl:"../../Angular/Directives/international/import_entry/import-entry.html"}}]).controller("importEntryCtrl",["$http","$scope","$rootScope","$location","$timeout","$window","$filter","$uibModal","shipmentFactory","internationalFactory","shipmentService","internationalService","userFactory",function(n,t,i,r,u,f,e,o,s,h,c,l,a){var b,y,p,st,ht,w,ct,v,kt;t.importEntryForm={ShipmentData:{ExportOrImport:"I",FILESTATUS:"LIVE",CUSTNO:i.user.custNo},ShipperInfo:{},ConsigneeInfo:{},ServiceInfo:{},PieceInfo:{},Payment:{},Pieces:[],Parts:[],SpecialInstructions:{},Accessorials:{},Files:{Documents:[],Images:[]},MemoInfo:{}};t.previewImportEntryForm={ShipmentData:{ExportOrImport:"I",FILESTATUS:"LIVE"},ShipperInfo:{},ConsigneeInfo:{},ServiceInfo:{},PieceInfo:{},Payment:{},Pieces:[],Parts:[],SpecialInstructions:{},Accessorials:{},Files:{Documents:[],Images:[]}};t.importEntryForm.ServiceInfo.SVCTYPE="SD";t.importEntryForm.ServiceInfo.DIMENSIONALFACTOR=166;t.importEntryForm.PieceInfo.TotalPieceWeight=0;t.importEntryForm.PieceInfo.TotalPieceDimWeight=0;t.importEntryForm.PieceInfo.TotalPieces=0;t.importFormNav={importInformation:!0,importDocuments:!1};t.formActive=!0;t.setFormNav=function(n){t.importFormNav=_.mapObject(t.importFormNav,function(){return!1});t.importFormNav[n]=!0};a.getLoggedInUser().then(function(n){a.getUserById(n.data).then(function(n){t.currentUser=n.data.user;t.importEntryForm.MemoInfo={MEMO1:"myAGS Shipment Entry",MEMO2:"myAGS Entry By: "+t.currentUser.FIRSTNAME+" "+t.currentUser.LASTNAME,MEMO3:"myAGS Contact Email: "+t.currentUser.EMAIL,MEMO4:"myAGS Contact Phone "+t.currentUser.PHONE}}).catch(function(n){console.log(n)})}).catch(function(n){console.log(n)});a.getStateProv().then(function(n){t.stateProvinces=n.data}).catch(function(n){console.log(n)});a.getAddressBook().then(function(n){t.shipperAddresses=e("filter")(n.data,{CUSTTYPE:"S"});t.consigneeAddresses=e("filter")(n.data,{CUSTTYPE:"C"});l._copiedImportEntry||l.returnImportEntry||(t.importEntryForm.ConsigneeInfo=e("filter")(t.consigneeAddresses,{DEFAULTADDRESS:!0})[0],t.importEntryForm.ShipperInfo=e("filter")(t.shipperAddresses,{DEFAULTADDRESS:!0})[0]);h.getCountries().then(function(n){t.countries=n.data;t.defaultCountry=e("filter")(t.countries,{CountryCode:"US"})[0];t.importEntryForm.ConsigneeInfo.COUNTRY=t.defaultCountry.CountryCode}).catch(function(n){console.log(n)})}).catch(function(n){console.log(n)});a.getUserSettings().then(function(n){l._copiedImportEntry||l._returnedExportEntry||(n.data[0]&&(t.importEntryForm.ServiceInfo=n.data[0]),t.importEntryForm.ServiceInfo.READYDATETYPE=new Date)}).catch(function(n){console.log(n)});b=function(){return new Date};t.minDate=b();t.status={importDate:!1};t.openCalendar=function(){t.status.importDate=!0};t.$watch(function(){return c._reloadRoute},function(n){n==="/importFolder"&&(t.shipperAddresses=null,t.consigneeAddresses=null,l.setToFolder("importFolder"),c.setReloadRoute(null))});t.$watch(function(){return l._copiedImportEntry},function(n){n&&h.getInternationImportShipmentsByShipmentID(n.ID).then(function(n){var t=n.data[0];k(t);d(t);g(t);nt(t);tt(t);it(t);rt(t);ut(t);ft(t);et(t)}).catch(function(n){console.log(n)})});t.$watch(function(){return l._returnedExportEntry},function(n){n&&h.getInternationImportShipmentsByShipmentID(n.ID).then(function(n){var t=n.data[0],i,r;t&&(i=t.Parties[2],r=t.Parties[1],t.Parties[1]=i,t.Parties[2]=r);k(t);d(t);g(t);nt(t);tt(t);it(t);rt(t);ut(t);ft(t);et(t)}).catch(function(){})});var k=function(n){n&&(t.importEntryForm.ShipperInfo.NAME=n.Parties[1].PartyName,t.importEntryForm.ShipperInfo.NAME9A=n.Parties[1].PartyAlphaCode,t.importEntryForm.ShipperInfo.ADDRESS1=n.Parties[1].Address1,t.importEntryForm.ShipperInfo.ADDRESS2=n.Parties[1].Address2,t.importEntryForm.ShipperInfo.CITY=n.Parties[1].City,t.importEntryForm.ShipperInfo.STATE=n.Parties[1].StateProvince,t.importEntryForm.ShipperInfo.ZIPCODE=n.Parties[1].ZipCode,t.importEntryForm.ShipperInfo.CONTACT=n.Parties[1].Contact,t.importEntryForm.ShipperInfo.PHONE=n.Parties[1].PhoneNumber,t.importEntryForm.ShipperInfo.EMAIL=n.Parties[1].Email)},d=function(n){n&&(t.importEntryForm.ConsigneeInfo.NAME=n.Parties[2].PartyName,t.importEntryForm.ConsigneeInfo.NAME9A=n.Parties[2].PartyAlphaCode,t.importEntryForm.ConsigneeInfo.ADDRESS1=n.Parties[2].Address1,t.importEntryForm.ConsigneeInfo.ADDRESS2=n.Parties[2].Address2,t.importEntryForm.ConsigneeInfo.CITY=n.Parties[2].City,t.importEntryForm.ConsigneeInfo.STATE=n.Parties[2].StateProvince,t.importEntryForm.ConsigneeInfo.ZIPCODE=n.Parties[2].ZipCode,t.importEntryForm.ConsigneeInfo.CONTACT=n.Parties[2].Contact,t.importEntryForm.ConsigneeInfo.PHONE=n.Parties[2].PhoneNumber,t.importEntryForm.ConsigneeInfo.EMAIL=n.Parties[2].Email)},g=function(n){n&&(t.importEntryForm.ServiceInfo.READYDATETYPE=new Date(n.Tracking[0].StaticTrackDate),t.importEntryForm.ServiceInfo.PICKUPTIME=n.HouseServices.ReadyTime,t.importEntryForm.ServiceInfo.CLOSETIME=n.HouseServices.CloseTime,a.getUserSettings().then(function(i){t.importEntryForm.ServiceInfo.REFLABEL1=i.data[0].REFLABEL1;t.importEntryForm.ServiceInfo.REFLABEL2=i.data[0].REFLABEL2;t.importEntryForm.ServiceInfo.READYDATETYPE=new Date(n.Tracking[0].StaticTrackDate);_.each(t.internationalServices.services,function(i){i.serviceShort==n.service1&&(t.selectedInternationalService=i,t.setInternationalServices(i))});_.each(t.internationalServices.customClearancePaid,function(i){n.CustomsClearancePaidBy==i.clearanceShort&&(t.clearancePaid=i,t.setClearancePaid(i))})}).catch(function(n){console.log(n)}))},nt=function(n){if(n)for(var i=0;i<n.SpecialInstructions.length;i++)number=i+1,t.importEntryForm.ServiceInfo["SPEC"+number]=n.SpecialInstructions[i].Note},tt=function(n){n&&angular.forEach(n.Piece.Pieces,function(n){var i={TOTALPIECES:n.Pieces,PIECETYPE:n.PieceType,LONGDESCRIPTION:n.Description,WEIGHT:n.RptWeightLbs,LENGTH:n.RptLength,WIDTH:n.RptWidth,HEIGHT:n.RptHeight,DIMENSIONALWEIGHT:n.DimWeight};t.importEntryForm.Pieces.push(i);y(i)})},it=function(n){n&&angular.forEach(n.Parts,function(n){var i={QUANTITY:n.Quan36,PARTNUMBER:n.Part36,PARTDESCRIPTION:n.ParD36,SERIALNUMBER:n.Ser36,CUSTOMERREFERENCE:n.Cstr36};t.importEntryForm.Parts.push(i)})},rt=function(n){n&&(t.importEntryForm.ShipperInfo.SHIPPERREFERENCE=n.Parties[1].ReferenceNumber)},ut=function(n){var i,r;if(n)for(number=1,i=0;i<n.Receivable.Receivables.length;i++)r=n.Receivable.Receivables[i].ServiceCode,_.each(t.accessorialServices,function(n){n.ServiceCode==r&&(t.importEntryForm.Accessorials["Accessorial"+number]=r,number++)})},ft=function(n){t.importEntryForm.ShipmentData.NOTIFYPARTY=n.NotifyParty;t.importEntryForm.ShipmentData.ORIGINATINGAIRPORT=n.OriginAirport;t.importEntryForm.ShipmentData.DESTINATIONAIRPORT=n.DestinationAirport},et=function(n){n&&(lt(n.DutiesAndTaxesPaidBy),at(n.PrepaidCollectOther))},lt=function(n){n==="P"?(t.dutyTaxesValue="S",t.setDutyAndTaxes("Sender")):n==="C"?(t.dutyTaxesValue="R",t.setDutyAndTaxes("Recipient")):n==="3"?(t.dutyTaxesValue="T",t.setDutyAndTaxes("Third Party")):n==="I"?(t.dutyTaxesValue="I",t.setDutyAndTaxes("Incoterm")):(t.dutyTaxesValue="T",t.setDutyAndTaxes("Third Party"))},at=function(n){n=="P"?(t.importEntryForm.Payment.PaymentType="S",t.checkPaymentType("S")):n=="C"?(t.importEntryForm.Payment.PaymentType="R",t.checkPaymentType("R")):n=="3"&&(t.importEntryForm.Payment.PaymentType="T",t.checkPaymentType("T"))},ot=function(){a.getCustomPieceData().then(function(n){t.customPieceData=n.data;t.piecePallets=t.defaultPieceData.concat(t.customPieceData)}).catch(function(n){console.log(n)})};a.getPiecesDefaults().then(function(n){t.defaultPieceData=n.data;ot()}).catch(function(n){console.log(n)});h.getIncoTerms().then(function(n){t.incoterms=n.data}).catch(function(n){console.log(n)});h.getAirports().then(function(n){t.airports=n.data}).catch(function(n){console.log(n)});t.dashShipmentInfo={piece:!0,part:!1};t.setTableNav=function(n){t.dashShipmentInfo=_.object(_.map(t.dashShipmentInfo,function(n,t){return[t,!1]}));t.dashShipmentInfo[n]=!0};t.importPieceData={TOTALPIECES:null,LONGDESCRIPTION:null,WEIGHT:0,LENGTH:0,WIDTH:0,HEIGHT:0,DIMENSIONALWEIGHT:0};t.temporaryDimFactor=166;t.addImportPiece=function(n){t.pieceSubmitted=!0;vt(n)&&(n.ChargeableWeightLBS=pt(n),t.importEntryForm.Pieces.push(angular.copy({TOTALPIECES:n.TOTALPIECES,PIECETYPE:n.PCSCODE,PCSDESCSHORT:n.PCSDESCSHORT,LONGDESCRIPTION:n.PCSDESCLONG,WEIGHT:n.WEIGHT,LENGTH:n.LENGTH,WIDTH:n.WIDTH,HEIGHT:n.HEIGHT,DIMENSIONALWEIGHT:n.DIMENSIONALWEIGHT,ChargeableWeightLBS:n.ChargeableWeightLBS})),t.newQuantity=null,y(n),yt(),t.pieceSubmitted=!1,a.getPiecesDefaults().then(function(n){t.defaultPieceData=n.data;ot()}))};var vt=function(n){return n.TOTALPIECES&&n.PCSCODE&&n.PCSDESCLONG&&n.WEIGHT&&n.LENGTH&&n.WIDTH&&n.HEIGHT?!0:!1},yt=function(){t.importPieceData=_.object(_.map(t.importPieceData,function(n,t){return[t,null]}))},pt=function(n){return n.WEIGHT>n.DIMENSIONALWEIGHT?n.WEIGHT:n.DIMENSIONALWEIGHT};t.calcDimWeight=function(){var n=t.importPieceData.LENGTH*t.importPieceData.WIDTH*t.importPieceData.HEIGHT*t.importPieceData.TOTALPIECES/t.temporaryDimFactor,i=Math.round(n*10)/10;t.importPieceData.DIMENSIONALWEIGHT=i};t.addToPiece=function(n){t.importPieceData=t.pieceCode.indexOf("@")!=0?e("filter")(t.piecePallets,{PCSDESCLONG:t.pieceCode.split("@")[1]})[0]:e("filter")(t.piecePallets,{PCSDESCLONG:t.pieceCode})[0];t.importPieceData.TOTALPIECES=n;t.calcDimWeight()};y=function(n){t.importEntryForm.PieceInfo.TotalPieceWeight+=n.WEIGHT;t.importEntryForm.PieceInfo.TotalPieceDimWeight+=n.DIMENSIONALWEIGHT;t.importEntryForm.PieceInfo.TotalPieces+=n.TOTALPIECES;t.importEntryForm.PieceInfo.TotalChargeableWeightLBS=p()};t.deleteImportPiece=function(n){var i=t.importEntryForm.Pieces.indexOf(n);t.importEntryForm.PieceInfo.TotalPieceWeight-=n.WEIGHT;t.importEntryForm.PieceInfo.TotalPieceDimWeight-=n.DIMENSIONALWEIGHT;t.importEntryForm.PieceInfo.TotalPieces-=n.TOTALPIECES;t.importEntryForm.PieceInfo.TotalChargeableWeightLBS=p();t.importEntryForm.Pieces.splice(i,1)};p=function(){return t.importEntryForm.PieceInfo.TotalPieceWeight>=t.importEntryForm.PieceInfo.TotalPieceDimWeight?t.importEntryForm.PieceInfo.TotalPieceWeight:t.importEntryForm.PieceInfo.TotalPieceWeight<=t.importEntryForm.PieceInfo.TotalPieceDimWeight?t.importEntryForm.PieceInfo.TotalPieceDimWeight:void 0};t.addImportPart=function(n){t.partSubmitted=!0;st(n)&&(t.importEntryForm.Parts.push(angular.copy(n)),t.ImportPart=null,t.partSubmitted=!1)};st=function(n){return n.QUANTITY&&n.PARTNUMBER&&n.PARTDESCRIPTION&&n.SERIALNUMBER&&n.CUSTOMERREFERENCE?!0:!1};t.deleteImportPart=function(n){var i=t.importEntryForm.Parts.indexOf(n);t.importEntryForm.Parts.splice(i,1)};t.clearAmount=function(){t.importEntryForm.insuranceAmount=null;t.importEntryForm.carriageValue=null};t.importDocuments=[];t.importImages=[];t.documentTypes=[];t.selectedDocumentType=null;s.getDocumentTypes().then(function(n){t.documentTypes=_.reject(n.data,function(n){return n.DOCTYPE==="IMAGE"})}).catch(function(n){console.log(n)});t.addDocument=function(n){n&&!ht(n)&&(t.importDocuments.push({type:t.selectedDocumentType,file:n}),t.selectedDocumentType=null,console.log(n))};ht=function(n){_.find(t.importDocuments,function(t){return t.file==n?!0:!1})};t.addImage=function(n){!n||$.inArray(n,t.importImages)>-1||(console.log(n),t.importImages.push(n),t.currentImagePreview=t.importImages[t.importImages.length-1])};t.removeDocumentFile=function(n){var i=t.importDocuments.indexOf(n);t.importDocuments.splice(i,1)};t.removeImageFile=function(n){var i=t.importImages.indexOf(n);t.importImages.splice(i,1);t.currentImagePreview=t.importImages[t.importImages.length-1]};t.checkPaymentType=function(){t.importEntryForm.ConsigneeInfo.COUNTRY=t.defaultCountry.CountryCode;t.importEntryForm.Payment.PaymentType==="T"?(t.thirdPartyOption=!0,t.importEntryForm.Payment.Company=null,t.importEntryForm.Payment.Address=null,t.importEntryForm.Payment.Phone=null):t.importEntryForm.Payment.PaymentType==="S"?(t.thirdPartyOption=!1,t.importEntryForm.Payment.Company=t.importEntryForm.ShipperInfo.NAME,t.importEntryForm.Payment.Address=w("ShipperInfo"),t.importEntryForm.Payment.Phone=t.importEntryForm.ShipperInfo.PHONE):t.importEntryForm.Payment.PaymentType==="R"&&(t.thirdPartyOption=!1,t.importEntryForm.Payment.Company=t.importEntryForm.ConsigneeInfo.NAME,t.importEntryForm.Payment.Address=w("ConsigneeInfo"),t.importEntryForm.Payment.Phone=t.importEntryForm.ConsigneeInfo.PHONE)};w=function(n){return t.importEntryForm[n].ADDRESS1+" "+t.importEntryForm[n].CITY+" "+t.importEntryForm[n].STATE+" "+t.importEntryForm[n].COUNTRY+" "+t.importEntryForm[n].ZIPCODE};t.internationalServices={services:[{serviceName:"Air",serviceShort:"A"},{serviceName:"Ocean",serviceShort:"O"}],customClearancePaid:[{clearanceName:"Sender",clearanceShort:"S"},{clearanceName:"Recipient",clearanceShort:"R"}]};t.setInternationalServices=function(){t.importEntryForm.ShipmentData.SERVICE1=t.selectedInternationalService.serviceShort;t.importEntryForm.ShipmentData.SERVICE2=null;t.previewImportEntryForm.ShipmentData.SERVICE1=angular.copy(t.selectedInternationalService.serviceName);t.$apply};t.setClearancePaid=function(){t.importEntryForm.ShipmentData.CUSTOMSCLEARANCEPAIDBY=t.clearancePaid.clearanceShort;t.previewImportEntryForm.ShipmentData.CUSTOMSCLEARANCEPAIDBY=angular.copy(t.clearancePaid.clearanceName);t.$apply};t.setDutyAndTaxes=function(n){n=="S"?(t.importEntryForm.ShipmentData.DUTIESANDTAXESPAIDBY="S",t.previewImportEntryForm.ShipmentData.DUTIESANDTAXESPAIDBY="Sender",t.previewImportEntryForm.ShipmentData.INCOTERM=null,t.selectedIncotermCode=null,t.$apply,t.paidByIncoterm=!1):n=="R"?(t.importEntryForm.ShipmentData.DUTIESANDTAXESPAIDBY="R",t.previewImportEntryForm.ShipmentData.DUTIESANDTAXESPAIDBY="Recipient",t.previewImportEntryForm.ShipmentData.INCOTERM=null,t.selectedIncotermCode=null,t.$apply,t.paidByIncoterm=!1):n=="T"?(t.importEntryForm.ShipmentData.DUTIESANDTAXESPAIDBY="T",t.previewImportEntryForm.ShipmentData.DUTIESANDTAXESPAIDBY="Third Party",t.previewImportEntryForm.ShipmentData.INCOTERM=null,t.selectedIncotermCode=null,t.$apply,t.paidByIncoterm=!1):n=="Incoterm"&&(t.importEntryForm.ShipmentData.DUTIESANDTAXESPAIDBY=null,t.previewImportEntryForm.ShipmentData.DUTIESANDTAXESPAIDBY=null,t.selectedIncotermCode=null,t.$apply,t.paidByIncoterm=!0)};t.setIncoterm=function(){t.selectedIncotermCode&&(t.importEntryForm.ShipmentData.DUTIESANDTAXESPAIDBY=t.selectedIncotermCode.IncoTermCode,t.previewImportEntryForm.ShipmentData.INCOTERM=t.selectedIncotermCode.IncoTermCode)};t.previewImport=function(n){t.formSubmitted=!0;n&&t.importEntryForm.Pieces.length?(t.errorMessage=null,t.formActive=t.formActive?!1:!0,f.scrollTo(0,0),ct()):n?t.importEntryForm.Pieces.length||(console.log("ADD SOME PIECES!!!"),t.errorMessage="Add Pieces to your shipment to complete the form",t.setFormNav("importInformation"),t.addPieces=!0,v()):(console.log("INVALID form!!!"),t.errorMessage="Form must be complete before submitting.",v())};t.importEntryNav=function(){t.formActive=t.formActive?!1:!0};ct=function(){t.previewImportEntryForm.ShipmentData.NOTIFYPARTY=angular.copy(t.importEntryForm.ShipmentData.NOTIFYPARTY);t.previewImportEntryForm.ShipmentData.ORIGINATINGAIRPORT=angular.copy(t.importEntryForm.ShipmentData.ORIGINATINGAIRPORT);t.previewImportEntryForm.ShipmentData.DESTINATIONAIRPORT=angular.copy(t.importEntryForm.ShipmentData.DESTINATIONAIRPORT);t.previewImportEntryForm.ServiceInfo.READYDATETYPE=angular.copy(t.importEntryForm.ServiceInfo.READYDATETYPE);t.previewImportEntryForm.ServiceInfo.PICKUPTIME=angular.copy(t.importEntryForm.ServiceInfo.PICKUPTIME);t.previewImportEntryForm.ServiceInfo.CLOSETIME=angular.copy(t.importEntryForm.ServiceInfo.CLOSETIME);t.previewImportEntryForm.ShipperInfo=angular.copy(t.importEntryForm.ShipperInfo);t.previewImportEntryForm.ConsigneeInfo=angular.copy(t.importEntryForm.ConsigneeInfo);t.previewImportEntryForm.ServiceInfo=angular.copy(t.importEntryForm.ServiceInfo);t.previewImportEntryForm.ShipperReference=angular.copy(t.importEntryForm.ShipperReference);t.previewImportEntryForm.PieceInfo=angular.copy(t.importEntryForm.PieceInfo);t.previewImportEntryForm.Pieces=angular.copy(t.importEntryForm.Pieces);t.previewImportEntryForm.Parts=angular.copy(t.importEntryForm.Parts);t.previewImportEntryForm.Payment=angular.copy(t.importEntryForm.Payment);t.previewImportEntryForm.insuranceRequest=angular.copy(t.importEntryForm.insuranceRequest);t.previewImportEntryForm.saveShipperAddress=angular.copy(t.importEntryForm.saveShipperAddress);t.previewImportEntryForm.saveConsigneeAddress=angular.copy(t.importEntryForm.saveConsigneeAddress);t.$apply};t.createImportEntry=function(i){t.formSubmitted=!0;i&&t.importEntryForm.Pieces.length?(t.disableCreateImport=!0,t.importErrorMessage=null,t.addPieces=null,wt(),bt(),t.importDocuments.length>0||t.importImages.length>0?n({url:"/international/UploadShipmentDocs",method:"POST",headers:{"Content-Type":undefined},transformRequest:angular.identity,data:t.getModelAsFormData()}).success(function(i){i=="True"&&n({url:"/international/UploadImages",method:"POST",headers:{"Content-Type":undefined},transformRequest:angular.identity,data:t.getImageAsFormData()}).success(function(n){n=="True"&&h.createOrUpdateImportOrExportEntry(t.importEntryForm).then(function(n){t.importCreated=!0;t.formSubmitted=!1;t.formActive=!0;t.openConfirmation("lg",n.data.Entity.ShipmentData.HOUSE,n.data.Entity.ShipmentData.SHIPMENTID);v()}).catch(function(n){t.formSubmitted=!1;t.disableCreateImport=!1;v();t.errorMessage="Import Entry did not create. Please try again.";console.log(n)})})}):h.createOrUpdateImportOrExportEntry(t.importEntryForm).then(function(n){t.importCreated=!0;t.formSubmitted=!1;t.formActive=!0;t.openConfirmation("lg",n.data.Entity.ShipmentData.HOUSE,n.data.Entity.ShipmentData.SHIPMENTID);v()}).catch(function(n){t.formSubmitted=!1;t.disableCreateImport=!1;v();t.errorMessage="Import Entry did not create. Please try again.";console.log(n)})):i?t.importEntryForm.Pieces.length||(console.log("ADD SOME PIECES!!!"),t.errorMessage="Add Pieces to your shipment to complete the form",t.disableCreateImport=!1,t.addPieces=!0):(console.log("INVALID form!!!"),t.errorMessage="Form must be complete before submitting.",t.disableCreateImport=!1)};v=function(){t.importCreated=!1;t.disableCreateImport=!1};t.getModelAsFormData=function(){var n=new FormData;return t.importDocuments.length>0&&angular.forEach(t.importDocuments,function(t){n.append("files",t.file);n.append("types",t.type)}),n};t.getImageAsFormData=function(){var n=new FormData;return t.importImages.length>0&&angular.forEach(t.importImages,function(t){n.append("images",t)}),n};t.setSaveShipperAddress=function(){t.importEntryForm.ShipperInfo.DEFAULTADDRESS&&(t.importEntryForm.saveShipperAddress=!0)};t.setSaveConsigneeAddress=function(){t.importEntryForm.ConsigneeInfo.DEFAULTADDRESS&&(t.importEntryForm.saveConsigneeAddress=!0)};var wt=function(){t.importEntryForm.ShipperInfo.CUSTTYPE="S";t.importEntryForm.ShipperInfo.CONTACT=t.importEntryForm.ShipperInfo.CONTACT?t.importEntryForm.ShipperInfo.CONTACT:" ";t.importEntryForm.ShipperInfo.AUTON>0&&t.importEntryForm.saveShipperAddress?a.updateShipper(t.importEntryForm.ShipperInfo).then(function(){console.log("SHIPPER ADDRESS IS SAVED!")}).catch(function(n){t.errorMessage="Shipper address did not save. Please try again or contact your AGS representative.";console.log("SHIPPER ADDRESS DID NOT SAVE!");console.log(n)}):t.importEntryForm.saveShipperAddress&&a.createShipper(t.importEntryForm.ShipperInfo).then(function(){console.log("SHIPPER ADDRESS HAS BEEN CREATED!")}).catch(function(n){t.errorMessage="Consignee address did not save. Please try again or contact your AGS representative.";console.log("SHIPPER ADDRESS DID NOT CREATE!");console.log(n)})},bt=function(){t.importEntryForm.ConsigneeInfo.CUSTTYPE="C";t.importEntryForm.ConsigneeInfo.CONTACT=t.importEntryForm.ConsigneeInfo.CONTACT?t.importEntryForm.ConsigneeInfo.CONTACT:" ";t.importEntryForm.ConsigneeInfo.AUTON>0&&t.importEntryForm.saveConsigneeAddress?a.updateShipper(t.importEntryForm.ConsigneeInfo).then(function(){console.log("CONSIGNEE ADDRESS IS SAVED!")}).catch(function(n){t.errorMessage="Shipper address did not save. Please try again or contact your AGS representative.";console.log("CONSIGNEE ADDRESS DID NOT SAVE!");console.log(n)}):t.importEntryForm.saveConsigneeAddress&&a.createShipper(t.importEntryForm.ConsigneeInfo).then(function(){console.log("CONSIGNEE ADDRESS HAS BEEN CREATED!")}).catch(function(n){t.errorMessage="Consignee address did not save. Please try again or contact your AGS representative.";console.log("CONSIGNEE ADDRESS DID NOT CREATE!");console.log(n)})},dt=function(n){n&&(t.importEntryForm.ShipmentData.SHIPMENTID=n.ID,t.importEntryForm.ShipmentData.HOUSE=n.HouseAirWaybillNumber)};t.modalPathUrls={from:"../../Angular/Directives/modals/my_international_modals/import_entry_modals/import-from-help.html",ultimateConsignee:"../../Angular/Directives/modals/my_international_modals/import_entry_modals/import-consignee-help.html",notifyParty:"../../Angular/Directives/modals/my_international_modals/import_entry_modals/import-party-help.html",partsPieces:"../../Angular/Directives/modals/my_international_modals/import_entry_modals/import-parts-pieces-help.html",documents:"../../Angular/Directives/modals/my_international_modals/import_entry_modals/import-documents-help.html",intServiceOptions:"../../Angular/Directives/modals/my_international_modals/import_entry_modals/import-service-options-help.html",requestsInsurance:"../../Angular/Directives/modals/my_international_modals/import_entry_modals/import-request-ins-help.html",payment:"../../Angular/Directives/modals/my_international_modals/import_entry_modals/import-payment-help.html",dutyTaxes:"../../Angular/Directives/modals/my_international_modals/import_entry_modals/import-duty-taxes-help.html"};t.animationsEnabled=!0;t.openHelp=function(n,i,r){var u=o.open({animation:!0,templateUrl:t.modalPathUrls[r],controller:"helpModalCtrl",size:n,resolve:{helpTitle:function(){return i}}})};t.openConfirmation=function(n,i,r){var u=o.open({animation:!0,templateUrl:"../../Angular/Directives/modals/my_shipments_modals/shipment-create-confirm.html",controller:"shipmentConfirmModalCtrl",size:n,resolve:{billToNumber:function(){return i},shipmentId:function(){return r},shipmentForm:function(){return t.previewImportEntryForm},route:function(){return"/importFolder"}}})};kt=function(){t.importEntryForm={ShipmentData:{ExportOrImport:"I",CUSTNO:i.user.custNo},ShipperInfo:{},ConsigneeInfo:{},ServiceInfo:{},PieceInfo:{},Payment:{},Pieces:[],Parts:[],SpecialInstructions:{},Accessorials:{},Files:{Documents:[],Images:[]}};t.previewImportEntryForm={ShipmentData:{ExportOrImport:"I"},ShipperInfo:{},ConsigneeInfo:{},ServiceInfo:{},PieceInfo:{},Payment:{},Pieces:[],Parts:[],SpecialInstructions:{},Accessorials:{},Files:{Documents:[],Images:[]}};t.importEntryForm.PieceInfo.TotalPieceWeight=0;t.importEntryForm.PieceInfo.TotalPieceDimWeight=0;t.importEntryForm.PieceInfo.TotalPieces=0;a.getStateProv().then(function(n){t.stateProvinces=n.data}).catch(function(n){console.log(n)});a.getAddressBook().then(function(n){t.shipperAddresses=e("filter")(n.data,{CUSTTYPE:"S"});t.consigneeAddresses=e("filter")(n.data,{CUSTTYPE:"C"});l._copiedImportEntry||l._returnedImportEntry||(t.importEntryForm.ConsigneeInfo=e("filter")(t.consigneeAddresses,{DEFAULTADDRESS:!0})[0],t.importEntryForm.ShipperInfo=e("filter")(t.shipperAddresses,{DEFAULTADDRESS:!0})[0]);h.getCountries().then(function(n){t.countries=n.data;t.defaultCountry=e("filter")(t.countries,{CountryCode:"US"})[0];t.importEntryForm.ConsigneeInfo.COUNTRY=t.defaultCountry.CountryCode}).catch(function(n){console.log(n)})}).catch(function(n){console.log(n)});a.getUserSettings().then(function(n){l._copiedImportEntry||l._returnedImportEntry||(t.importEntryForm.ServiceInfo=n.data[0],t.importEntryForm.ServiceInfo.READYDATETYPE=new Date)}).catch(function(n){console.log(n)});var n=function(){a.getCustomPieceData().then(function(n){t.customPieceData=n.data;t.piecePallets=t.defaultPieceData.concat(t.customPieceData)}).catch(function(n){console.log(n)})};a.getPiecesDefaults().then(function(i){t.defaultPieceData=i.data;n()}).catch(function(n){console.log(n)});h.getCountries().then(function(n){t.countries=n.data}).catch(function(n){console.log(n)});h.getIncoTerms().then(function(n){t.incoterms=n.data}).catch(function(n){console.log(n)});h.getAirports().then(function(n){t.airports=n.data}).catch(function(n){console.log(n)});s.getDocumentTypes().then(function(n){t.documentTypes=_.reject(n.data,function(n){return n.DOCTYPE==="IMAGE"})}).catch(function(n){console.log(n)})}}]);angular.module("directive.importFolder",[]).directive("importFolder",[function(){return{restrict:"E",scope:{},templateUrl:"../../Angular/Directives/international/import_folder/import-folder.html"}}]).controller("importFolderCtrl",["$http","$scope","$location","$timeout","$window","$filter","$uibModal","internationalService","shipmentFactory","internationalFactory",function(n,t,i,r,u,f,e,o,s,h){var c,l;(function(){var n=new Date,i=new Date,r=n.setDate(n.getDate()-30),u=i.setDate(i.getDate());t.startDate=new Date(r);t.endDate=new Date(u);t.loadingImports=!0;h.getAllInternationalImportShipmentByBilltoByReadyDate(t.startDate,t.endDate).then(function(n){t.myImportEntries=n.data;t.loadingImports=!1;c()}).catch(function(n){t.myImportEntries=[];t.loadingImports=!1;console.log(n)})})();c=function(){_.each(t.myImportEntries,function(n){n.DeliveryDate={};n.ShipDate={};n.StaticDeliveryDate={};n.StaticShipDate={};n.ShipDate=parseInt(n.ReadyDate.match(/(\d+)|(-\d+)/)[0]);n.StaticShipDate=n.StaticTrackDate.toString();var t=parseInt(n.PODDate.match(/(\d+)|(-\d+)/)[0]);n.DeliveryDate=t>0?t:null})};t.calendar={startOpen:!1,endOpen:!1};t.open=function(n){t.calendar[n]=!0};t.createDateIncrements=function(n,i){t.loadingImports=!0;h.getAllInternationalImportShipmentByBilltoByReadyDate(n,i).then(function(n){t.myImportEntries=n.data;t.loadingImports=!1;c()}).catch(function(n){t.myImportEntries=[];t.loadingImports=!1;console.log(n)})};l=function(n,i){var r=new Date(n),u=new Date(i);t.loadingImports=!0;h.getAllInternationalImportShipmentByBilltoByReadyDate(r,u).then(function(n){t.loadingImports=!1;t.myImportEntries=n.data;c()}).catch(function(n){t.loadingImports=!1;t.myImportEntries=[];console.log(n)})};t.sortToggle={bill:!1,shipName:!1,shipCity:!1,consigneeName:!1,consigneCity:!1,deliveryDate:!1,shipDate:!0,weight:!1};t.orderHeader="ShipDate";t.reverse=!0;t.order=function(n,i){t.reverse=t.orderHeader===n?!t.reverse:!1;t.orderHeader=n;t.sortToggle=_.mapObject(t.sortToggle,function(){return!1});t.sortToggle[i]=!0};t.showImportEntry=function(n){o.setImportEntry(n)};t.copyImportEntry=function(n){o.copyImportEntry(n)};t.returnImportEntry=function(n){o.returnImportEntry(n)};t.modalPathUrls={importFolder:"../../Angular/Directives/modals/my_international_modals/import-folder-help.html"};t.animationsEnabled=!0;t.openHelp=function(n,i,r){var u=e.open({animation:!0,templateUrl:t.modalPathUrls[r],controller:"helpModalCtrl",size:n,resolve:{helpTitle:function(){return i}}})}}]);angular.module("directive.importShow",[]).directive("importShow",[function(){return{restrict:"E",scope:{},templateUrl:"../../Angular/Directives/international/import_show/import-show.html"}}]).controller("importShowCtrl",["$http","$scope","$location","$timeout","$window","$filter","internationalService","shipmentFactory","internationalFactory",function(n,t,i,r,u,f,e,o,s){t.importMessage="Hello from importShowCtrl.";t.selectedEntry=e._importEntry;t.internationalServices={services:[{serviceName:"AGS Global Same Day",serviceShort:"SD",options:[{optionName:"Global Same Day",optionShort:"SD"}]},{serviceName:"AGS Global Door-to-Door Express",serviceShort:"D2D",options:[{optionName:"Global Package Express",optionShort:"PEXP"}]},{serviceName:"AGS Global Economy Airfreight",serviceShort:"EAIR",options:[{optionName:"Global Economy",optionShort:"GE"}]},{serviceName:"AGS Global Seafreight",serviceShort:"SEA",options:[{optionName:"LCL Ocean Export",optionShort:"LCLOCN"},{optionName:"20ft Std Container",optionShort:"20FT"},{optionName:"40ft High Cube Container",optionShort:"40FTTHCC"},{optionName:"40ft Std Container",optionShort:"40FTSTD"},{optionName:"45ft Std Container",optionShort:"45FTSTD"},{optionName:"Other",optionShort:"OTHR"}]},{serviceName:"NAFTA-Transborder Service",serviceShort:"TRANSB",options:[{optionName:"Mexico Prime Air",optionShort:"MEXPA"},{optionName:"Canada Economy",optionShort:"CAECON"},{optionName:"Mexico Economy",optionShort:"MEXECON"}]}],pickupOptions:[{pickupName:"Air(port) to Air(port)",pickupShort:"A2A"},{pickupName:"Door to Air(port)",pickupShort:"D2A"},{pickupName:"Air(port) to Door",pickupShort:"A2D"},{pickupName:"Door to Door",pickupShort:"D2D"}],customClearancePaid:[{clearanceName:"Sender",clearanceShort:"S"},{clearanceName:"Recipient",clearanceShort:"R"}],indications:["No EEI required per Exemption","No EEI required value $2500 or less per Schedule B number","EEI FILED AES ITN"]};s.getInternationImportShipmentsByShipmentID(t.selectedEntry.ID).then(function(n){t.importEntryShow=n.data[0];t.importEntryShow.ID=t.selectedEntry.ID;y(n.data[0]);h();c(n.data[0])}).catch(function(n){console.log(n)});t.setImportFolder=function(){console.log("Go back to Import Folder");e.setToFolder("importFolder")};var h=function(){t.importEntryShow.DeliveryDate={};t.importEntryShow.StaticDeliveryDate={};t.importEntryShow.ShipDate={};t.importEntryShow.StaticShipDate={};_.each(t.importEntryShow.Tracking,function(n){if(n.Key=="READY")t.importEntryShow.ShipDate=parseInt(n.TrackDate.match(/(\d+)|(-\d+)/)[0]),t.importEntryShow.StaticShipDate=n.StaticTrackDate.toString();else if(n.Key=="POD"){var i=parseInt(n.TrackDate.match(/(\d+)|(-\d+)/)[0]);t.importEntryShow.DeliveryDate=i>0?i:null}})},c=function(n){n&&(t.importEntryShow.AESPARTIESTOTRANSACTION=n.SEDHeader.AESPartiesToTransaction==1?"Related":"Non-Related",t.importEntryShow.DIRECTORCONSOLIDATION=n.DirectOrConsolidation=="C"?"Consolidate":"Direct",t.importEntryShow.AESROUTEDEXPORT=n.AESRoutedExport?"Yes":"No",t.importEntryShow.FTZ=n.SEDHeader.FTZ,t.importEntryShow.COURTRYOFULTIMATEDESTINATION=n.SEDHeader.CountryOfUltimateDestination,t.importEntryShow.ENTRYNUMBER=n.SEDHeader.EntryNumber,l(n),a(n.DutiesAndTaxesPaidBy),v(n.PrepaidCollectOther))},l=function(n){_.each(t.internationalServices.services,function(i){i.serviceShort==n.Service1&&(t.selectedInternationalService=i)});_.each(t.internationalServices.customClearancePaid,function(i){n.CustomsClearancePaidBy==i.clearanceShort&&(t.clearancePaid=i)})},a=function(n){t.importEntryShow.DutiesAndTaxes=n==="S"?"Sender":n==="R"?"Recipient":n==="T"?"Third Party":n},v=function(n){n=="P"?t.importEntryShow.PaymentType="Sender":n=="C"?t.importEntryShow.PaymentType="Recipient":n=="3"&&(t.importEntryShow.PaymentType="Third Party")},y=function(n){t.importEntryShow.MemoNotes=[];_.each(n.TraceNotes,function(n){n.ExternallyAvailable&&(n.LastUpdateDate=parseInt(n.LastUpdateDate.match(/(\d+)|(-\d+)/)[0]),t.importEntryShow.MemoNotes.push(n))})}}]);angular.module("directive.importPreview",[]).directive("importPreview",[function(){return{restrict:"E",scope:!1,templateUrl:"../../Angular/Directives/international/import_preview/import-preview.html"}}]);angular.module("directive.exportEntry",[]).directive("exportEntry",[function(){return{restrict:"E",scope:{},templateUrl:"../../Angular/Directives/international/export_entry/export-entry.html"}}]).controller("exportEntryCtrl",["$http","$scope","$rootScope","$location","$timeout","$window","$filter","$uibModal","shipmentFactory","internationalFactory","shipmentService","internationalService","userFactory",function(n,t,i,r,u,f,e,o,s,h,c,l,a){var w,y,p,ut,ot,st,v,ht,ct,wt;t.exportEntryForm={ShipmentData:{ExportOrImport:"E",FILESTATUS:"LIVE",CUSTNO:i.user.custNo},ShipperInfo:{},ConsigneeInfo:{},ServiceInfo:{},PieceInfo:{},Pieces:[],Parts:[],Payment:{},SpecialInstructions:{},Accessorials:{},Files:{Documents:[],Images:[]},MemoInfo:{}};t.previewExportEntryForm={ShipmentData:{ExportOrImport:"E",FILESTATUS:"LIVE"},ShipperInfo:{},ConsigneeInfo:{},ServiceInfo:{},PieceInfo:{},Pieces:[],Parts:[],Payment:{},SpecialInstructions:{},Accessorials:{},Files:{}};t.exportEntryForm.ServiceInfo.SVCTYPE="SD";t.exportEntryForm.ServiceInfo.DIMENSIONALFACTOR=166;t.exportEntryForm.PieceInfo.TotalPieceWeight=0;t.exportEntryForm.PieceInfo.TotalPieceDimWeight=0;t.exportEntryForm.PieceInfo.TotalPieces=0;t.formActive=!0;a.getLoggedInUser().then(function(n){a.getUserById(n.data).then(function(n){t.currentUser=n.data.user;t.exportEntryForm.MemoInfo={MEMO1:"myAGS Shipment Entry",MEMO2:"myAGS Entry By: "+t.currentUser.FIRSTNAME+" "+t.currentUser.LASTNAME,MEMO3:"myAGS Contact Email: "+t.currentUser.EMAIL,MEMO4:"myAGS Contact Phone "+t.currentUser.PHONE}}).catch(function(n){console.log(n)})}).catch(function(n){console.log(n)});a.getStateProv().then(function(n){t.stateProvinces=n.data}).catch(function(n){console.log(n)});a.getAddressBook().then(function(n){t.shipperAddresses=e("filter")(n.data,{CUSTTYPE:"S"});t.consigneeAddresses=e("filter")(n.data,{CUSTTYPE:"C"});l._copiedExportEntry||l._returnedExportEntry||(t.exportEntryForm.ConsigneeInfo=e("filter")(t.consigneeAddresses,{DEFAULTADDRESS:!0})[0],t.exportEntryForm.ShipperInfo=e("filter")(t.shipperAddresses,{DEFAULTADDRESS:!0})[0]);h.getCountries().then(function(n){t.countries=n.data;t.defaultCountry=e("filter")(t.countries,{CountryCode:"US"})[0];t.exportEntryForm.ShipperInfo.COUNTRY=t.defaultCountry.CountryCode}).catch(function(n){console.log(n)})}).catch(function(n){console.log(n)});w=function(){return new Date};a.getUserSettings().then(function(n){l._copiedExportEntry||l._returnedExportEntry||(n.data[0]&&(t.exportEntryForm.ServiceInfo=n.data[0]),t.exportEntryForm.ServiceInfo.READYDATETYPE=new Date)}).catch(function(n){console.log(n)});t.minDate=w();t.status={exportDate:!1};t.openCalendar=function(){t.status.exportDate=!0};t.$watch(function(){return c._reloadRoute},function(n){n==="/exportEntry"&&(t.shipperAddresses=null,t.consigneeAddresses=null,c.setReloadRoute(null),f.location.reload())});t.$watch(function(){return l._copiedExportEntry},function(n){n&&h.getInternationalExportShipmentByID(n.ID).then(function(n){var t=n.data[0];b(t);k(t);d(t);g(t);nt(t);tt(t);it(t);rt(t)}).catch(function(n){console.log(n)})});t.$watch(function(){return l._returnedImportEntry},function(n){n&&h.getInternationImportShipmentsByShipmentID(n.ID).then(function(n){var t=n.data[0],i,r;t&&(i=t.Parties[2],r=t.Parties[1],t.Parties[1]=i,t.Parties[2]=r);b(t);k(t);d(t);g(t);nt(t);tt(t);it(t);rt(t)}).catch(function(){})});t.validateDecimalValue=function(){t.exportPieceData.HARMONIZEDCODE!=null&&(t.exportPieceData.HARMONIZEDCODE=parseInt(t.exportPieceData.HARMONIZEDCODE))};var b=function(n){n&&(t.exportEntryForm.ShipperInfo.NAME=n.Parties[1].PartyName,t.exportEntryForm.ShipperInfo.NAME9A=n.Parties[1].PartyAlphaCode,t.exportEntryForm.ShipperInfo.ADDRESS1=n.Parties[1].Address1,t.exportEntryForm.ShipperInfo.ADDRESS2=n.Parties[1].Address2,t.exportEntryForm.ShipperInfo.CITY=n.Parties[1].City,t.exportEntryForm.ShipperInfo.STATE=n.Parties[1].StateProvince,t.exportEntryForm.ShipperInfo.ZIPCODE=n.Parties[1].ZipCode,t.exportEntryForm.ShipperInfo.CONTACT=n.Parties[1].Contact,t.exportEntryForm.ShipperInfo.PHONE=n.Parties[1].PhoneNumber,t.exportEntryForm.ShipperInfo.EMAIL=n.Parties[1].Email)},k=function(n){n&&(t.exportEntryForm.ConsigneeInfo.NAME=n.Parties[2].PartyName,t.exportEntryForm.ConsigneeInfo.NAME9A=n.Parties[2].PartyAlphaCode,t.exportEntryForm.ConsigneeInfo.ADDRESS1=n.Parties[2].Address1,t.exportEntryForm.ConsigneeInfo.ADDRESS2=n.Parties[2].Address2,t.exportEntryForm.ConsigneeInfo.CITY=n.Parties[2].City,t.exportEntryForm.ConsigneeInfo.STATE=n.Parties[2].StateProvince,t.exportEntryForm.ConsigneeInfo.ZIPCODE=n.Parties[2].ZipCode,t.exportEntryForm.ConsigneeInfo.CONTACT=n.Parties[2].Contact,t.exportEntryForm.ConsigneeInfo.PHONE=n.Parties[2].PhoneNumber,t.exportEntryForm.ConsigneeInfo.EMAIL=n.Parties[2].Email)},d=function(n){n&&(t.exportEntryForm.ServiceInfo.READYDATETYPE=new Date(n.Tracking[0].StaticTrackDate),t.exportEntryForm.ServiceInfo.PICKUPTIME=n.HouseServices.ReadyTime,t.exportEntryForm.ServiceInfo.CLOSETIME=n.HouseServices.CloseTime,a.getUserSettings().then(function(i){t.exportEntryForm.ServiceInfo.REFLABEL1=i.data[0].REFLABEL1;t.exportEntryForm.ServiceInfo.REFLABEL2=i.data[0].REFLABEL2;_.each(t.internationalServices.services,function(i){i.serviceShort==n.service1&&(t.selectedInternationalService=i,t.setInternationalServices(i),_.each(i.options,function(i){i.optionShort==n.service2&&(t.selectedOption=i,t.setServiceOptions(i))}))});_.each(t.internationalServices.pickupOptions,function(i){i.pickupShort==n.service3&&(t.selectedPickup=i,t.setServicePickup(i))});_.each(t.internationalServices.customClearancePaid,function(i){n.CustomsClearancePaidBy==i.clearanceShort&&(t.clearancePaid=i,t.setClearancePaid(i))})}).catch(function(n){console.log(n)}))},g=function(n){if(n)for(var i=0;i<n.SpecialInstructions.length;i++)number=i+1,t.exportEntryForm.ServiceInfo["SPEC"+number]=n.SpecialInstructions[i].Note},nt=function(n){n&&angular.forEach(n.Piece.Pieces,function(n){var i={TOTALPIECES:n.Pieces,PIECETYPE:n.PieceType,LONGDESCRIPTION:n.Description,WEIGHT:n.RptWeightLbs,LENGTH:n.RptLength,WIDTH:n.RptWidth,HEIGHT:n.RptHeight,DIMENSIONALWEIGHT:n.DimWeight};t.exportEntryForm.Pieces.push(i);et(i)})},tt=function(n){n&&angular.forEach(n.Parts,function(n){var i={QUANTITY:n.Quan36,PARTNUMBER:n.Part36,PARTDESCRIPTION:n.ParD36,SERIALNUMBER:n.Ser36,CUSTOMERREFERENCE:n.Cstr36};t.exportEntryForm.Parts.push(i)})},it=function(n){n&&(t.exportEntryForm.ShipmentData.SHIPPERREFERENCE=n.Parties[1].ReferenceNumber)},bt=function(n){var i,r;if(n)for(number=1,i=0;i<n.Receivable.Receivables.length;i++)r=n.Receivable.Receivables[i].ServiceCode,_.each(t.accessorialServices,function(n){n.ServiceCode==r&&(t.exportEntryForm.Accessorials["Accessorial"+number]=r,number++)})},rt=function(n){n&&(t.exportEntryForm.ShipmentData.AESPARTIESTOTRANSACTION=n.SEDDetails.AESPartiesToTransaction==1?"Related":"Non-Related",t.exportEntryForm.ShipmentData.PARTYIDTYPE=n.SEDHeader.PARTYIDTYPE==1?"Direct Consumer":"Government Entity",t.exportEntryForm.ShipmentData.AESROUTEDEXPORT=n.AESRoutedExport?"Yes":"No",t.exportEntryForm.ShipmentData.FTZ=n.SEDHeader.FTZ,t.exportEntryForm.ShipmentData.COURTRYOFULTIMATEDESTINATION=n.SEDHeader.CountryOfUltimateDestination,t.exportEntryForm.ShipmentData.ENTRYNUMBER=n.SEDHeader.EntryNumber,t.exportEntryForm.ShipmentData.NOTIFYPARTY=n.NOTIFYPARTY,lt(n.DutiesAndTaxesPaidBy),at(n.PrepaidCollectOther))},lt=function(n){n==="P"?(t.dutyTaxesValue="S",t.setDutyAndTaxes("Sender")):n==="C"?(t.dutyTaxesValue="R",t.setDutyAndTaxes("Recipient")):n==="3"?(t.dutyTaxesValue="T",t.setDutyAndTaxes("Third Party")):n==="I"?(t.dutyTaxesValue="I",t.setDutyAndTaxes("Incoterm")):t.setDutyAndTaxes("Third Party")},at=function(){t.checkPaymentType(t.exportEntryForm.Payment.PaymentType)},kt=function(n){n&&(t.exportEntryForm.ShipmentData.SHIPMENTID=n.ID,t.exportEntryForm.ShipmentData.HOUSE=n.HouseAirWaybillNumber)};t.internationalServices={services:[{serviceName:"AGS Global Same Day",serviceShort:"SD",options:[{optionName:"Global Same Day",optionShort:"SD"}]},{serviceName:"AGS Global Door-to-Door Express",serviceShort:"D2D",options:[{optionName:"Global Package Express",optionShort:"PEXP"}]},{serviceName:"AGS Global Economy Airfreight",serviceShort:"EAIR",options:[{optionName:"Global Economy",optionShort:"GE"}]},{serviceName:"AGS Global Seafreight",serviceShort:"SEA",options:[{optionName:"LCL Ocean Export",optionShort:"LCLOCN"},{optionName:"20ft Std Container",optionShort:"20FT"},{optionName:"40ft High Cube Container",optionShort:"40FTTHCC"},{optionName:"40ft Std Container",optionShort:"40FTSTD"},{optionName:"45ft Std Container",optionShort:"45FTSTD"},{optionName:"Other",optionShort:"OTHR"}]},{serviceName:"NAFTA-Transborder Service",serviceShort:"TRANSB",options:[{optionName:"Mexico Prime Air",optionShort:"MEXPA"},{optionName:"Canada Economy",optionShort:"CAECON"},{optionName:"Mexico Economy",optionShort:"MEXECON"}]}],pickupOptions:[{pickupName:"Air(port) to Air(port)",pickupShort:"A2A"},{pickupName:"Door to Air(port)",pickupShort:"D2A"},{pickupName:"Air(port) to Door",pickupShort:"A2D"},{pickupName:"Door to Door",pickupShort:"D2D"}],customClearancePaid:[{clearanceName:"Sender",clearanceShort:"S"},{clearanceName:"Recipient",clearanceShort:"R"}],indications:[{id:1,value:"No EEI required per Exemption"},{id:2,value:"No EEI required value $2500 or less per Schedule B number"},{id:3,value:"EEI FILED AES ITN"},{id:4,value:"Request AGS to file EEI"}]};t.CustomIndication=!1;t.setIndication=function(){t.exportEntryForm.ShipmentData.CUSTOMSSTATEMENT==3?t.CustomIndication=!0:(t.CustomIndication=!1,t.exportEntryForm.ShipmentData.ITNNUMBER="")};t.setInternationalServices=function(n){t.exportEntryForm.ShipmentData.SERVICE1=n.serviceShort;t.exportEntryForm.ShipmentData.SERVICE2=null;t.previewExportEntryForm.ShipmentData.SERVICE1=angular.copy(n.serviceName);t.$apply};t.setServiceOptions=function(n){t.exportEntryForm.ShipmentData.SERVICE2=n.optionShort;t.previewExportEntryForm.ShipmentData.SERVICE2=angular.copy(n.optionName);t.$apply};t.setServicePickup=function(n){t.exportEntryForm.ShipmentData.SERVICE3=n.pickupShort;t.previewExportEntryForm.ShipmentData.SERVICE3=angular.copy(n.pickupName);t.$apply};t.setClearancePaid=function(n){t.exportEntryForm.ShipmentData.CUSTOMSCLEARANCEPAIDBY=n.clearanceShort;t.previewExportEntryForm.ShipmentData.CUSTOMSCLEARANCEPAIDBY=angular.copy(n.clearanceName);t.$apply};t.setDutyAndTaxes=function(n){n=="Sender"?(t.exportEntryForm.ShipmentData.DUTIESANDTAXESPAIDBY="S",t.previewExportEntryForm.ShipmentData.DUTIESANDTAXESPAIDBY="Sender",t.previewExportEntryForm.ShipmentData.INCOTERM=null,t.selectedIncotermCode=null,t.$apply,t.paidByIncoterm=!1):n=="Recipient"?(t.exportEntryForm.ShipmentData.DUTIESANDTAXESPAIDBY="R",t.previewExportEntryForm.ShipmentData.DUTIESANDTAXESPAIDBY="Recipient",t.previewExportEntryForm.ShipmentData.INCOTERM=null,t.selectedIncotermCode=null,t.$apply,t.paidByIncoterm=!1):n=="Third Party"?(t.exportEntryForm.ShipmentData.DUTIESANDTAXESPAIDBY="T",t.previewExportEntryForm.ShipmentData.DUTIESANDTAXESPAIDBY="Third Party",t.previewExportEntryForm.ShipmentData.INCOTERM=null,t.selectedIncotermCode=null,t.$apply,t.paidByIncoterm=!1):n=="Incoterm"&&(t.exportEntryForm.ShipmentData.DUTIESANDTAXESPAIDBY=null,t.previewExportEntryForm.ShipmentData.DUTIESANDTAXESPAIDBY=null,t.selectedIncotermCode=null,t.$apply,t.paidByIncoterm=!0)};t.setIncoterm=function(n){n&&(t.exportEntryForm.ShipmentData.DUTIESANDTAXESPAIDBY=n.IncoTermCode,t.previewExportEntryForm.ShipmentData.INCOTERM=n.IncoTermCode)};t.checkPaymentType=function(n){t.exportEntryForm.ShipperInfo.COUNTRY=t.defaultCountry.CountryCode;n==="3"?(t.thirdPartyOption=!0,t.exportEntryForm.Payment.Company=null,t.exportEntryForm.Payment.Address=null,t.exportEntryForm.Payment.Phone=null):n==="P"?(t.thirdPartyOption=!1,t.exportEntryForm.Payment.Company=t.exportEntryForm.ShipperInfo.NAME,t.exportEntryForm.Payment.Address=y("ShipperInfo"),t.exportEntryForm.Payment.Phone=t.exportEntryForm.ShipperInfo.PHONE):n==="C"&&(t.thirdPartyOption=!1,t.exportEntryForm.Payment.Company=t.exportEntryForm.ConsigneeInfo.NAME,t.exportEntryForm.Payment.Address=y("ConsigneeInfo"),t.exportEntryForm.Payment.Phone=t.exportEntryForm.ConsigneeInfo.PHONE)};y=function(n){return t.exportEntryForm[n].ADDRESS1+" "+t.exportEntryForm[n].CITY+" "+t.exportEntryForm[n].STATE+" "+t.exportEntryForm[n].COUNTRY+" "+t.exportEntryForm[n].ZIPCODE};p=function(){a.getCustomPieceData().then(function(n){t.customPieceData=n.data;t.piecePallets=t.defaultPieceData.concat(t.customPieceData)}).catch(function(n){console.log(n)})};a.getPiecesDefaults().then(function(n){t.defaultPieceData=n.data;p()}).catch(function(n){console.log(n)});h.getIncoTerms().then(function(n){t.incoterms=n.data}).catch(function(n){console.log(n)});h.getAirports().then(function(n){t.airports=n.data}).catch(function(n){console.log(n)});t.exportFormNav={exportInstructions:!1,exportDocuments:!1,exportInformation:!0};t.setFormNav=function(n){t.exportFormNav=_.mapObject(t.exportFormNav,function(){return!1});t.exportFormNav[n]=!0};t.dashShipmentInfo={piece:!0,part:!1};t.setTableNav=function(n){t.dashShipmentInfo=_.object(_.map(t.dashShipmentInfo,function(n,t){return[t,!1]}));t.dashShipmentInfo[n]=!0};t.exportDocuments=[];t.exportImages=[];t.documentTypes=[];t.selectedDocumentType=null;s.getDocumentTypes().then(function(n){t.documentTypes=_.reject(n.data,function(n){return n.DOCTYPE==="IMAGE"})}).catch(function(n){console.log(n)});t.addDocument=function(n){n&&!ut(n)&&(t.exportDocuments.push({type:t.selectedDocumentType,file:n}),t.selectedDocumentType=null,console.log(n),t.exportEntryForm.Files.Documents=angular.copy(t.exportDocuments),t.$apply)};ut=function(n){_.find(t.exportDocuments,function(t){return t.file==n?!0:!1})};t.addImage=function(n){!n||$.inArray(n,t.exportImages)>-1||(console.log(n),t.exportImages.push(n),t.currentImagePreview=t.exportImages[t.exportImages.length-1],t.exportEntryForm.Files.Images=angular.copy(t.exportImages),t.$apply)};t.removeDocumentFile=function(n){var i=t.exportDocuments.indexOf(n);t.exportDocuments.splice(i,1);t.exportEntryForm.Files.Documents=angular.copy(t.exportDocuments);t.$apply};t.removeImageFile=function(n){var i=t.exportImages.indexOf(n);t.exportImages.splice(i,1);t.currentImagePreview=t.exportImages[t.exportImages.length-1];t.exportEntryForm.Files.Images=angular.copy(t.exportImages);t.$apply};t.exportPieceData={TOTALPIECES:null,LONGDESCRIPTION:null,WEIGHT:0,LENGTH:0,WIDTH:0,HEIGHT:0,DIMENSIONALWEIGHT:0};t.temporaryDimFactor=166;t.addExportPiece=function(n){t.pieceSubmitted=!0;vt(n)&&(n.ChargeableWeightLBS=pt(n),t.exportEntryForm.Pieces.push(angular.copy({TOTALPIECES:n.TOTALPIECES,PIECETYPE:n.PCSCODE,PCSDESCSHORT:n.PCSDESCSHORT,LONGDESCRIPTION:n.PCSDESCLONG,WEIGHT:n.WEIGHT,LENGTH:n.LENGTH,WIDTH:n.WIDTH,HEIGHT:n.HEIGHT,ChargeableWeightLBS:n.ChargeableWeightLBS,DIMENSIONALWEIGHT:n.DIMENSIONALWEIGHT,HARMONIZEDCODE:n.HARMONIZEDCODE,PRIMARYQUANTITY:n.PRIMARYQUANTITY,DOMESTICORFOREIGN:n.DOMESTICORFOREIGN,CUSTOMSVALUE:n.CUSTOMSVALUE})),t.newQuantity=null,et(n),yt(),t.pieceSubmitted=!1,a.getPiecesDefaults().then(function(n){t.defaultPieceData=n.data;p()}))};t.addToPiece=function(n){t.exportPieceData=t.pieceCode.indexOf("@")!=0?e("filter")(t.piecePallets,{PCSDESCLONG:t.pieceCode.split("@")[1]})[0]:e("filter")(t.piecePallets,{PCSDESCLONG:t.pieceCode})[0];t.exportPieceData.TOTALPIECES=n;t.calcDimWeight()};t.deleteExportPiece=function(n){var i=t.exportEntryForm.Pieces.indexOf(n);t.exportEntryForm.PieceInfo.TotalPieceWeight-=n.WEIGHT;t.exportEntryForm.PieceInfo.TotalPieceDimWeight-=n.DIMENSIONALWEIGHT;t.exportEntryForm.PieceInfo.TotalPieces-=n.TOTALPIECES;t.exportEntryForm.PieceInfo.TotalChargeableWeightLBS=ft();t.exportEntryForm.Pieces.splice(i,1)};var ft=function(){return t.exportEntryForm.PieceInfo.TotalPieceWeight>=t.exportEntryForm.PieceInfo.TotalPieceDimWeight?t.exportEntryForm.PieceInfo.TotalPieceWeight:t.exportEntryForm.PieceInfo.TotalPieceWeight<=t.exportEntryForm.PieceInfo.TotalPieceDimWeight?t.exportEntryForm.PieceInfo.TotalPieceDimWeight:void 0},et=function(n){t.exportEntryForm.PieceInfo.TotalPieceWeight+=n.WEIGHT;t.exportEntryForm.PieceInfo.TotalPieceDimWeight+=n.DIMENSIONALWEIGHT;t.exportEntryForm.PieceInfo.TotalPieces+=n.TOTALPIECES;t.exportEntryForm.PieceInfo.TotalChargeableWeightLBS=ft()},vt=function(n){return n.TOTALPIECES&&n.PCSCODE&&n.PCSDESCLONG&&n.WEIGHT&&n.LENGTH&&n.WIDTH&&n.HEIGHT?!0:!1},yt=function(){t.exportPieceData=_.object(_.map(t.exportPieceData,function(n,t){return[t,null]}))},pt=function(n){return n.WEIGHT>n.DIMENSIONALWEIGHT?n.WEIGHT:n.DIMENSIONALWEIGHT};t.calcDimWeight=function(){var n=t.exportPieceData.LENGTH*t.exportPieceData.WIDTH*t.exportPieceData.HEIGHT*t.exportPieceData.TOTALPIECES/366;t.exportPieceData.DIMENSIONALWEIGHT=Math.round(n*10)/10};t.addExportPart=function(n){t.partSubmitted=!0;ot(n)&&(t.exportEntryForm.Parts.push(angular.copy(n)),t.ExportPart=null,t.partSubmitted=!1)};ot=function(n){return n.QUANTITY&&n.PARTNUMBER&&n.PARTDESCRIPTION&&n.SERIALNUMBER&&n.CUSTOMERREFERENCE?!0:!1};t.deleteExportPart=function(n){var i=t.exportEntryForm.Parts.indexOf(n);t.exportEntryForm.Parts.splice(i,1)};t.clearAmount=function(){t.exportEntryForm.insuranceAmount=null;t.exportEntryForm.carriageValue=null};t.previewExport=function(n){t.formSubmitted=!0;n&&t.exportEntryForm.Pieces.length?(t.exportErrorMessage=null,t.formActive=t.formActive?!1:!0,f.scrollTo(0,0),st()):n?t.exportEntryForm.Pieces.length||(console.log("ADD SOME PIECES!!!"),t.exportErrorMessage="Add Pieces to your shipment to complete the form",t.setFormNav("exportInformation"),t.addPieces=!0,v()):(console.log("INVALID form!!!"),t.exportErrorMessage="Form must be complete before submitting.",v())};st=function(){t.previewExportEntryForm.ShipmentData.SHIPPERREFERENCE=angular.copy(t.exportEntryForm.ShipmentData.SHIPPERREFERENCE);t.previewExportEntryForm.ShipmentData.EXPORTERSEIN=angular.copy(t.exportEntryForm.ShipmentData.EXPORTERSEIN);t.previewExportEntryForm.ConsigneeInfo.INTERMIDATECONSIGNEE=angular.copy(t.exportEntryForm.ConsigneeInfo.INTERMIDATECONSIGNEE);t.previewExportEntryForm.ShipmentData.AESPARTIESTOTRANSACTION=angular.copy(t.exportEntryForm.ShipmentData.AESPARTIESTOTRANSACTION);t.exportEntryForm.ShipmentData.ITNNUMBER!=""&&(t.previewExportEntryForm.ShipmentData.ITNNUMBER=angular.copy(t.exportEntryForm.ShipmentData.ITNNUMBER));t.previewExportEntryForm.ShipmentData.PARTYIDTYPE=angular.copy(t.exportEntryForm.ShipmentData.PARTYIDTYPE);t.previewExportEntryForm.ShipmentData.DIRECTORCONSOLIDATION=angular.copy(t.exportEntryForm.ShipmentData.DIRECTORCONSOLIDATION);t.previewExportEntryForm.ShipmentData.AESROUTEDEXPORT=angular.copy(t.exportEntryForm.ShipmentData.AESROUTEDEXPORT);t.previewExportEntryForm.ShipmentData.IRSEINSUFFIX=angular.copy(t.exportEntryForm.ShipmentData.IRSEINSUFFIX);t.previewExportEntryForm.ShipmentData.FTZ=angular.copy(t.exportEntryForm.ShipmentData.FTZ);t.previewExportEntryForm.ShipmentData.COURTRYOFULTIMATEDESTINATION=angular.copy(t.exportEntryForm.ShipmentData.COURTRYOFULTIMATEDESTINATION);t.previewExportEntryForm.ShipmentData.ENTRYNUMBER=angular.copy(t.exportEntryForm.ShipmentData.ENTRYNUMBER);t.previewExportEntryForm.ShipmentData.NOTIFYPARTY=angular.copy(t.exportEntryForm.ShipmentData.NOTIFYPARTY);t.previewExportEntryForm.intermediateConsignee=angular.copy(t.exportEntryForm.intermediateConsignee);t.previewExportEntryForm.ShipperInfo=angular.copy(t.exportEntryForm.ShipperInfo);t.previewExportEntryForm.ConsigneeInfo=angular.copy(t.exportEntryForm.ConsigneeInfo);t.previewExportEntryForm.ShipperReference=angular.copy(t.exportEntryForm.ShipperReference);t.previewExportEntryForm.ConsigneeReference=angular.copy(t.exportEntryForm.ConsigneeReference);t.previewExportEntryForm.ServiceInfo=angular.copy(t.exportEntryForm.ServiceInfo);t.previewExportEntryForm.PieceInfo=angular.copy(t.exportEntryForm.PieceInfo);t.previewExportEntryForm.Pieces=angular.copy(t.exportEntryForm.Pieces);t.previewExportEntryForm.Parts=angular.copy(t.exportEntryForm.Parts);t.previewExportEntryForm.Payment=angular.copy(t.exportEntryForm.Payment);t.previewExportEntryForm.SpecialInstructions=angular.copy(t.exportEntryForm.SpecialInstructions);t.previewExportEntryForm.Accessorials=angular.copy(t.exportEntryForm.Accessorials);t.previewExportEntryForm.insuranceRequest=angular.copy(t.exportEntryForm.insuranceRequest);t.exportEntryForm.ShipmentData.CUSTOMSSTATEMENT=="1"&&(t.previewExportEntryForm.ShipmentData.CUSTOMSSTATEMENT="No EEI required per Exemption");t.exportEntryForm.ShipmentData.CUSTOMSSTATEMENT=="2"&&(t.previewExportEntryForm.ShipmentData.CUSTOMSSTATEMENT="No EEI required value $2500 or less per Schedule B number");t.exportEntryForm.ShipmentData.CUSTOMSSTATEMENT=="3"&&(t.previewExportEntryForm.ShipmentData.CUSTOMSSTATEMENT="EEI FILED AES ITN");t.exportEntryForm.ShipmentData.CUSTOMSSTATEMENT=="4"&&(t.previewExportEntryForm.ShipmentData.CUSTOMSSTATEMENT="Request AGS to file EEI");t.previewExportEntryForm.saveShipperAddress=angular.copy(t.exportEntryForm.saveShipperAddress);t.previewExportEntryForm.saveConsigneeAddress=angular.copy(t.exportEntryForm.saveConsigneeAddress);t.$apply};t.exportEntryNav=function(){t.formActive=t.formActive?!1:!0};t.createExportEntry=function(i){t.formSubmitted=!0;t.exportEntryForm.ShipmentData.PREPAIDCOLLECTORTHIRDPARTY=t.exportEntryForm.Payment.PaymentType;t.exportEntryForm.ShipmentData.AESPARTIESTOTRANSACTION=t.exportEntryForm.ShipmentData.AESPARTIESTOTRANSACTION=="Related"?"R":"N";t.exportEntryForm.ShipmentData.AESROUTEDEXPORT=t.exportEntryForm.ShipmentData.AESROUTEDEXPORT=="Yes"?"True":"False";i&&t.exportEntryForm.Pieces.length?(t.disableCreateExport=!0,t.errorMessage=null,t.addPieces=null,ht(),ct(),t.exportDocuments.length>0||t.exportImages.length>0?n({url:"/international/UploadShipmentDocs",method:"POST",headers:{"Content-Type":undefined},transformRequest:angular.identity,data:t.getModelAsFormData()}).success(function(i){i=="True"&&n({url:"/international/UploadImages",method:"POST",headers:{"Content-Type":undefined},transformRequest:angular.identity,data:t.getImageAsFormData()}).success(function(n){n=="True"&&h.createOrUpdateImportOrExportEntry(t.exportEntryForm).then(function(n){t.exportCreated=!0;t.formSubmitted=!1;t.formActive=!0;t.openConfirmation("lg",n.data.Entity.ShipmentData.HOUSE,n.data.Entity.ShipmentData.SHIPMENTID);v()}).catch(function(n){t.errorMessage="Export Entry did not create. Please try again.";t.formSubmitted=!1;t.formActive=!0;console.log(n);v()})})}):h.createOrUpdateImportOrExportEntry(t.exportEntryForm).then(function(n){t.exportCreated=!0;t.formSubmitted=!1;t.formActive=!0;t.openConfirmation("lg",n.data.Entity.ShipmentData.HOUSE,n.data.Entity.ShipmentData.SHIPMENTID);v()}).catch(function(n){t.errorMessage="Export Entry did not create. Please try again.";t.formSubmitted=!1;t.formActive=!0;console.log(n);v()})):i?t.exportEntryForm.Pieces.length||(console.log("ADD SOME PIECES!!!"),t.errorMessage="Add Pieces to your shipment to complete the form",t.disableCreateExport=!1,t.addPieces=!0):(console.log("INVALID form!!!"),t.errorMessage="Form must be complete before submitting.",t.disableCreateExport=!1)};v=function(){t.exportCreated=!1;t.disableCreateExport=!1};t.getModelAsFormData=function(){var n=new FormData;return t.exportDocuments.length>0&&angular.forEach(t.exportDocuments,function(t){n.append("files",t.file);n.append("types",t.type)}),n};t.getImageAsFormData=function(){var n=new FormData;return t.exportImages.length>0&&angular.forEach(t.exportImages,function(t){n.append("images",t)}),n};t.setSaveShipperAddress=function(){t.exportEntryForm.ShipperInfo.DEFAULTADDRESS&&(t.exportEntryForm.saveShipperAddress=!0)};t.setSaveConsigneeAddress=function(){t.exportEntryForm.ConsigneeInfo.DEFAULTADDRESS&&(t.exportEntryForm.saveConsigneeAddress=!0)};ht=function(){t.exportEntryForm.ShipperInfo.CUSTTYPE="S";t.exportEntryForm.ShipperInfo.CONTACT=t.exportEntryForm.ShipperInfo.CONTACT?t.exportEntryForm.ShipperInfo.CONTACT:" ";t.exportEntryForm.ShipperInfo.COUNTRY=t.exportEntryForm.ShipperInfo.COUNTRY?t.exportEntryForm.ShipperInfo.COUNTRY:" ";t.exportEntryForm.ShipperInfo.AUTON>0&&t.exportEntryForm.saveShipperAddress?a.updateShipper(t.exportEntryForm.ShipperInfo).then(function(){console.log("SHIPPER ADDRESS IS SAVED!")}).catch(function(n){t.errorMessage="Shipper address did not save. Please try again or contact your AGS representative.";console.log("SHIPPER ADDRESS DID NOT SAVE!");console.log(n)}):t.exportEntryForm.saveShipperAddress&&a.createShipper(t.exportEntryForm.ShipperInfo).then(function(){console.log("SHIPPER ADDRESS HAS BEEN CREATED!")}).catch(function(n){t.errorMessage="Consignee address did not save. Please try again or contact your AGS representative.";console.log("SHIPPER ADDRESS DID NOT CREATE!");console.log(n)})};ct=function(){t.exportEntryForm.ConsigneeInfo.CUSTTYPE="C";t.exportEntryForm.ConsigneeInfo.CONTACT=t.exportEntryForm.ConsigneeInfo.CONTACT?t.exportEntryForm.ConsigneeInfo.CONTACT:" ";t.exportEntryForm.ShipperInfo.COUNTRY=t.exportEntryForm.ShipperInfo.COUNTRY?t.exportEntryForm.ShipperInfo.COUNTRY:" ";t.exportEntryForm.ConsigneeInfo.AUTON>0&&t.exportEntryForm.saveConsigneeAddress?a.updateShipper(t.exportEntryForm.ConsigneeInfo).then(function(){console.log("CONSIGNEE ADDRESS IS SAVED!")}).catch(function(n){t.errorMessage="Shipper address did not save. Please try again or contact your AGS representative.";console.log("CONSIGNEE ADDRESS DID NOT SAVE!");console.log(n)}):t.exportEntryForm.saveConsigneeAddress&&a.createShipper(t.exportEntryForm.ConsigneeInfo).then(function(){console.log("CONSIGNEE ADDRESS HAS BEEN CREATED!")}).catch(function(n){t.errorMessage="Consignee address did not save. Please try again or contact your AGS representative.";console.log("CONSIGNEE ADDRESS DID NOT CREATE!");console.log(n)})};t.modalPathUrls={from:"../../Angular/Directives/modals/my_international_modals/export_entry_modals/export-from-help.html",ultimateConsignee:"../../Angular/Directives/modals/my_international_modals/export_entry_modals/export-consignee-help.html",intermediateConsignee:"../../Angular/Directives/modals/my_international_modals/export_entry_modals/export-inter-consignee-help.html",partiesTransaction:"../../Angular/Directives/modals/my_international_modals/export_entry_modals/export-transaction-help.html",consigneeType:"../../Angular/Directives/modals/my_international_modals/export_entry_modals/export-consignee-type-help.html",consolidation:"../../Angular/Directives/modals/my_international_modals/export_entry_modals/export-consolidation-help.html",routedExport:"../../Angular/Directives/modals/my_international_modals/export_entry_modals/export-routed-help.html",pointOrigin:"../../Angular/Directives/modals/my_international_modals/export_entry_modals/export-origin-help.html",countryDestination:"../../Angular/Directives/modals/my_international_modals/export_entry_modals/export-destination-help.html",entryNumber:"../../Angular/Directives/modals/my_international_modals/export_entry_modals/export-entry-number-help.html",invoiceNumber:"../../Angular/Directives/modals/my_international_modals/export_entry_modals/export-invoice-number-help.html",intServiceOptions:"../../Angular/Directives/modals/my_international_modals/export_entry_modals/export-int-service-options-help.html",dutyTaxes:"../../Angular/Directives/modals/my_international_modals/export_entry_modals/export-duty-taxes-help.html",payment:"../../Angular/Directives/modals/my_international_modals/export_entry_modals/export-payment-help.html",specialInstructions:"../../Angular/Directives/modals/my_international_modals/export_entry_modals/export-special-instructions-help.html",documents:"../../Angular/Directives/modals/my_international_modals/export_entry_modals/export-documents-help.html",partsPieces:"../../Angular/Directives/modals/my_international_modals/export_entry_modals/export-parts-pieces-help.html",requestsInsurance:"../../Angular/Directives/modals/my_international_modals/export_entry_modals/export-requests-ins-help.html",pleaseIndicate:"../../Angular/Directives/modals/my_international_modals/export_entry_modals/export-please-indicate-help.html"};t.animationsEnabled=!0;t.openHelp=function(n,i,r){var u=o.open({animation:!0,templateUrl:t.modalPathUrls[r],controller:"helpModalCtrl",size:n,resolve:{helpTitle:function(){return i}}})};t.openConfirmation=function(n,i,r){var u=o.open({animation:!0,templateUrl:"../../Angular/Directives/modals/my_international_modals/international-create-confirm.html",controller:"internationalShipmentConfirmModel",size:n,resolve:{billToNumber:function(){return i},shipmentId:function(){return r},shipmentForm:function(){return t.exportEntryForm},route:function(){return"/exportEntry"}}})};wt=function(){t.exportEntryForm={ShipmentData:{ExportOrImport:"E",CUSTNO:i.user.custNo},ShipperInfo:{},ConsigneeInfo:{},ServiceInfo:{},PieceInfo:{},Pieces:[],Parts:[],Payment:{},SpecialInstructions:{},Accessorials:{},Files:{Documents:[],Images:[]}};t.previewExportEntryForm={ShipmentData:{ExportOrImport:"E"},ShipperInfo:{},ConsigneeInfo:{},ServiceInfo:{},PieceInfo:{},Pieces:[],Parts:[],Payment:{},SpecialInstructions:{},Accessorials:{},Files:{}};t.exportEntryForm.PieceInfo.TotalPieceWeight=0;t.exportEntryForm.PieceInfo.TotalPieceDimWeight=0;t.exportEntryForm.PieceInfo.TotalPieces=0;a.getStateProv().then(function(n){t.stateProvinces=n.data}).catch(function(n){console.log(n)});a.getAddressBook().then(function(n){t.shipperAddresses=e("filter")(n.data,{CUSTTYPE:"S"});t.consigneeAddresses=e("filter")(n.data,{CUSTTYPE:"C"});t.exportEntryForm.ConsigneeInfo=e("filter")(t.consigneeAddresses,{DEFAULTADDRESS:!0})[0];t.exportEntryForm.ShipperInfo=e("filter")(t.shipperAddresses,{DEFAULTADDRESS:!0})[0]}).catch(function(n){console.log(n)});a.getUserSettings().then(function(n){n.data[0]&&(t.exportEntryForm.ServiceInfo=n.data[0]);t.exportEntryForm.ServiceInfo.READYDATETYPE=new Date}).catch(function(n){console.log(n)});var n=function(){a.getCustomPieceData().then(function(n){t.customPieceData=n.data;t.piecePallets=t.defaultPieceData.concat(t.customPieceData)}).catch(function(n){console.log(n)})};a.getPiecesDefaults().then(function(i){t.defaultPieceData=i.data;n()}).catch(function(n){console.log(n)});h.getCountries().then(function(n){t.countries=n.data;t.defaultCountry=e("filter")(t.countries,{CountryCode:"US"})[0];t.exportEntryForm.ShipperInfo.COUNTRY=t.defaultCountry.CountryCode}).catch(function(n){console.log(n)});h.getIncoTerms().then(function(n){t.incoterms=n.data}).catch(function(n){console.log(n)});h.getAirports().then(function(n){t.airports=n.data}).catch(function(n){console.log(n)});s.getDocumentTypes().then(function(n){t.documentTypes=_.reject(n.data,function(n){return n.DOCTYPE==="IMAGE"})}).catch(function(n){console.log(n)})}}]);angular.module("directive.exportFolder",[]).directive("exportFolder",[function(){return{restrict:"E",scope:{},templateUrl:"../../Angular/Directives/international/export_folder/export-folder.html"}}]).controller("exportFolderCtrl",["$http","$scope","$location","$timeout","$window","$filter","$uibModal","internationalService","shipmentFactory","internationalFactory",function(n,t,i,r,u,f,e,o,s,h){var c,l;(function(){var n=new Date,i=new Date,r=n.setDate(n.getDate()-30),u=i.setDate(i.getDate());t.startDate=new Date(r);t.endDate=new Date(u);t.loadingExports=!0;h.getAllInternationalShipmentByBilltoByReadyDate(t.startDate,t.endDate).then(function(n){t.loadingExports=!1;t.myExportEntries=n.data;c()}).catch(function(n){t.loadingExports=!1;t.myExportEntries=[];console.log(n)})})();c=function(){_.each(t.myExportEntries,function(n){n.DeliveryDate={};n.ShipDate={};n.StaticDeliveryDate={};n.StaticShipDate={};n.ShipDate=parseInt(n.ReadyDate.match(/(\d+)|(-\d+)/)[0]);n.StaticShipDate=n.StaticTrackDate.toString();var t=parseInt(n.PODDate.match(/(\d+)|(-\d+)/)[0]);n.DeliveryDate=t>0?t:null})};t.calendar={startOpen:!1,endOpen:!1};t.open=function(n){t.calendar[n]=!0};t.createDateIncrements=function(n,i){t.loadingExports=!0;h.getAllInternationalShipmentByBilltoByReadyDate(n,i).then(function(n){t.loadingExports=!1;t.myExportEntries=n.data;c()}).catch(function(n){t.loadingExports=!1;t.myExportEntries=[];console.log(n)})};l=function(n,i){var r=new Date(n),u=new Date(i);t.loadingShipments=!0;h.getAllInternationalShipmentByBilltoByReadyDate(r,u).then(function(n){t.myExportEntries=n.data;c()}).catch(function(n){t.myExportEntries=[];console.log(n)})};t.sortToggle={bill:!1,shipName:!1,shipCity:!1,consigneeName:!1,consigneCity:!1,deliveryDate:!1,shipDate:!0,weight:!1};t.orderHeader="ShipDate";t.reverse=!0;t.order=function(n,i){t.reverse=t.orderHeader===n?!t.reverse:!1;t.orderHeader=n;t.sortToggle=_.mapObject(t.sortToggle,function(){return!1});t.sortToggle[i]=!0};t.showExportEntry=function(n){o.setExportEntry(n)};t.copyExportEntry=function(n){o.copyExportEntry(n)};t.returnExportEntry=function(n){o.returnExportEntry(n)};t.modalPathUrls={exportFolder:"../../Angular/Directives/modals/my_international_modals/export-folder-help.html"};t.animationsEnabled=!0;t.openHelp=function(n,i,r){var u=e.open({animation:!0,templateUrl:t.modalPathUrls[r],controller:"helpModalCtrl",size:n,resolve:{helpTitle:function(){return i}}})}}]);angular.module("directive.exportShow",[]).directive("exportShow",[function(){return{restrict:"E",scope:{},templateUrl:"../../Angular/Directives/international/export_show/export-show.html"}}]).controller("exportShowCtrl",["$http","$scope","$location","$timeout","$window","$filter","internationalService","shipmentFactory","internationalFactory",function(n,t,i,r,u,f,e,o,s){t.exportMessage="Hello from exportShowCtrl.";t.selectedEntry=e._exportEntry;t.internationalServices={services:[{serviceName:"AGS Global Same Day",serviceShort:"SD",options:[{optionName:"Global Same Day",optionShort:"SD"}]},{serviceName:"AGS Global Door-to-Door Express",serviceShort:"D2D",options:[{optionName:"Global Package Express",optionShort:"PEXP"}]},{serviceName:"AGS Global Economy Airfreight",serviceShort:"EAIR",options:[{optionName:"Global Economy",optionShort:"GE"}]},{serviceName:"AGS Global Seafreight",serviceShort:"SEA",options:[{optionName:"LCL Ocean Export",optionShort:"LCLOCN"},{optionName:"20ft Std Container",optionShort:"20FT"},{optionName:"40ft High Cube Container",optionShort:"40FTTHCC"},{optionName:"40ft Std Container",optionShort:"40FTSTD"},{optionName:"45ft Std Container",optionShort:"45FTSTD"},{optionName:"Other",optionShort:"OTHR"}]},{serviceName:"NAFTA-Transborder Service",serviceShort:"TRANSB",options:[{optionName:"Mexico Prime Air",optionShort:"MEXPA"},{optionName:"Canada Economy",optionShort:"CAECON"},{optionName:"Mexico Economy",optionShort:"MEXECON"}]}],pickupOptions:[{pickupName:"Air(port) to Air(port)",pickupShort:"A2A"},{pickupName:"Door to Air(port)",pickupShort:"D2A"},{pickupName:"Air(port) to Door",pickupShort:"A2D"},{pickupName:"Door to Door",pickupShort:"D2D"}],customClearancePaid:[{clearanceName:"Sender",clearanceShort:"S"},{clearanceName:"Recipient",clearanceShort:"R"}],indications:["No EEI required per Exemption","No EEI required value $2500 or less per Schedule B number","EEI FILED AES ITN"]};s.getInternationalExportShipmentByID(t.selectedEntry.ID).then(function(n){t.exportEntryShow=n.data[0];t.exportEntryShow.ID=t.selectedEntry.ID;y(n.data[0]);h();c(n.data[0])}).catch(function(n){console.log(n)});t.setExportFolder=function(){console.log("Go back to Export Folder");e.setToFolder("exportFolder")};var h=function(){t.exportEntryShow.DeliveryDate={};t.exportEntryShow.ShipDate={};t.exportEntryShow.ShipDate={};t.exportEntryShow.StaticShipDate={};_.each(t.exportEntryShow.Tracking,function(n){if(n.Key=="READY"&&(t.exportEntryShow.ShipDate=parseInt(n.TrackDate.match(/(\d+)|(-\d+)/)[0]),t.exportEntryShow.StaticShipDate=n.StaticTrackDate.toString()),n.Key=="SCHEDULEDDELIVERY"){var i=parseInt(n.TrackDate.match(/(\d+)|(-\d+)/)[0]);i>0?(t.exportEntryShow.DeliveryDate=i,t.exportEntryShow.StaticDeliveryDate=n.StaticTrackDate.toString()):(t.exportEntryShow.DeliveryDate=null,t.exportEntryShow.StaticDeliveryDate="")}})},c=function(n){n&&(t.exportEntryShow.AESPARTIESTOTRANSACTION=n.SEDDetail[0].PartiesToTransaction=="R"?"Related":"Non-Related",t.exportEntryShow.DIRECTORCONSOLIDATION=n.DirectOrConsolidation=="C"?"Consolidate":"Direct",t.exportEntryShow.AESROUTEDEXPORT=n.SEDHeader.AESRoutedExport?"Yes":"No",t.exportEntryShow.FTZ=n.SEDHeader.FTZ,t.exportEntryShow.COURTRYOFULTIMATEDESTINATION=n.SEDHeader.CourtryOfUltimateDestination,t.exportEntryShow.ENTRYNUMBER=n.SEDHeader.EntryNumber,l(n),a(n.DutiesAndTaxesPaidBy),v(n.PrepaidCollectOther))},l=function(n){_.each(t.internationalServices.services,function(i){i.serviceShort==n.Service1&&(t.selectedInternationalService=i,_.each(i.options,function(i){i.optionShort==n.Service2&&(t.selectedOption=i)}))});_.each(t.internationalServices.pickupOptions,function(i){i.pickupShort==n.Service3&&(t.selectedPickup=i)});_.each(t.internationalServices.customClearancePaid,function(i){n.CustomsClearancePaidBy==i.clearanceShort&&(t.clearancePaid=i)})},a=function(n){t.exportEntryShow.DutiesAndTaxes=n==="S"?"Sender":n==="R"?"Recipient":n==="T"?"Third Party":n},v=function(n){n=="P"?t.exportEntryShow.PaymentType="Sender":n=="C"?t.exportEntryShow.PaymentType="Recipient":n=="3"&&(t.exportEntryShow.PaymentType="Third Party")},y=function(n){t.exportEntryShow.MemoNotes=[];_.each(n.TraceNotes,function(n){n.ExternallyAvailable&&(n.LastUpdateDate=parseInt(n.LastUpdateDate.match(/(\d+)|(-\d+)/)[0]),t.exportEntryShow.MemoNotes.push(n))})}}]);angular.module("directive.exportPreview",[]).directive("exportPreview",[function(){return{restrict:"E",scope:!1,templateUrl:"../../Angular/Directives/international/export_preview/export-preview.html"}}]);angular.module("directive.serviceForms",[]).directive("serviceForms",[function(){return{restrict:"E",scope:{},templateUrl:"../../Angular/Directives/international/service_forms/service-forms.html"}}]).controller("serviceFormsCtrl",["$http","$scope","$location","$timeout","$window","$filter","$uibModal",function(n,t,i,r,u,f,e){t.dashNav={services:!0,forms:!1};t.setDashNav=function(n){t.dashNav=_.object(_.map(t.dashNav,function(n,t){return[t,!1]}));t.dashNav[n]=!0};t.serviceShow={sameDay:!1,expFreight:!1,seaFreight:!1,nafta:!1,express:!1,economy:!1,impFreight:!1,logistics:!1};t.setServiceShow=function(n){t.serviceShow=_.object(_.map(t.serviceShow,function(n,t){return[t,!1]}));t.serviceShow[n]=!0};t.modalPathUrls={services:"../../Angular/Directives/modals/my_international_modals/services-help.html",forms:"../../Angular/Directives/modals/my_international_modals/forms-help.html"};t.animationsEnabled=!0;t.openHelp=function(n,i,r){var u=e.open({animation:!0,templateUrl:t.modalPathUrls[r],controller:"helpModalCtrl",size:n,resolve:{helpTitle:function(){return i}}})}}]);angular.module("directive.poFiles",[]).directive("poFiles",[function(){return{restrict:"E",scope:{},templateUrl:"../../Angular/Directives/international/po_manager/po-files.html"}}]).controller("poFilesCtrl",["$http","$scope","$location","$timeout","$window","$filter",function(n,t){t.filesMessage="poFilesCtrl Message"}]);angular.module("directive.poLoad",[]).directive("poLoad",[function(){return{restrict:"E",scope:{},templateUrl:"../../Angular/Directives/international/po_manager/po-load.html"}}]).controller("poLoadCtrl",["$http","$scope","$location","$timeout","$window","$filter","$uibModal","shipmentFactory","internationalFactory","poLoadService",function(n,t,i,r,u,f,e,o,s,h){var c,l,a,v;s.getAllPOLoads().then(function(n){t.myShipments=h.setShipments(n.data);t.shipmentsUpdated=!0}).catch(function(n){console.log(n)});t.setDates=function(){_.each(t.myShipments,function(n){n.DeliveryDate={};n.ShipDate={};_.each(n.Tracking,function(t){if(t.Key=="READY")n.ShipDate=parseInt(t.TrackDate.match(/(\d+)|(-\d+)/)[0]);else if(t.Key=="POD"){var i=parseInt(t.TrackDate.match(/(\d+)|(-\d+)/)[0]);n.DeliveryDate=i>0?i:null}})})};t.$watch(function(){return h._shipments},function(n){n&&(t.myShipments=n)});t.sortToggle={HAWBNO:!0,poNumber:!1,origin:!1,destination:!1,pieces:!1,weight:!1,CUBEM:!1};t.orderHeader="HAWBNO";t.reverse=!0;t.order=function(n,i){t.loadList=[];t.reverse=t.orderHeader===n?!t.reverse:!1;t.orderHeader=n;t.sortToggle=_.mapObject(t.sortToggle,function(){return!1});t.sortToggle[i]=!0};t.loadList={TotalPieces:0,TotalWeight:0,TotalCUBEM:0,list:[]};t.container={};t.selectedShipment={};t.$watch(function(){return h._loadList},function(){t.loadList={TotalPieces:0,TotalWeight:0,TotalCUBEM:0,list:[]}});c=function(n,t){var r=-1,i;if(n.length==0)r=-1;else for(i=0;i<n.length;i++)n[i].ID==t.ID&&(r=i);return r};t.addShipmentLoad=function(n){var i=c(t.loadList.list,n);i>-1?(t.loadList.list.splice(i,1),a(n),t.selectedShipment[n.ID]=!1,console.log("Shipment "+n.ID+" was removed.")):(t.loadList.list.push(n),l(n),t.selectedShipment[n.ID]=!0,console.log("Shipment "+n.ID+" was added."),console.log(t.selectedShipment))};l=function(n){t.loadList.TotalPieces+=n.TOTALPIECES;t.loadList.TotalWeight+=n.TOTALWEIGHT;t.loadList.TotalCUBEM+=n.TOTALCUBICMETERS;t.loadList.TotalPieces=Math.round(t.loadList.TotalPieces*100)/100;t.loadList.TotalWeight=Math.round(t.loadList.TotalWeight*100)/100;t.loadList.TotalCUBEM=Math.round(t.loadList.TotalCUBEM*100)/100};a=function(n){t.loadList.TotalPieces-=n.TOTALPIECES;t.loadList.TotalWeight-=n.TOTALWEIGHT;t.loadList.TotalCUBEM-=n.TOTALCUBICMETERS;t.loadList.TotalPieces=Math.round(t.loadList.TotalPieces*100)/100;t.loadList.TotalWeight=Math.round(t.loadList.TotalWeight*100)/100;t.loadList.TotalCUBEM=Math.round(t.loadList.TotalCUBEM*100)/100};t.loadShipments=function(){var n=1;_.each(t.loadList.list,function(i){t.container["Shipment_"+n]=i;v(i);n++});t.loadList.list=[];console.log(t.container)};t.getSelectedShipmentsIds=function(){return Object.keys(t.selectedShipment)};v=function(n){for(var i=0;i<t.myShipments.length;i++)t.myShipments[i].ID===n&&t.myShipments.splice(i,1)};t.checkedItem=function(n){return _.findIndex(t.loadList.list,function(t){return t.ID==n})};t.confirmLoad=function(){var n=e.open({animation:!0,templateUrl:"../../Angular/Directives/modals/my_international_modals/po_manager_modals/po-load-modal.html",controller:"poLoadModalCtrl",size:"lg",resolve:{title:function(){return"Confirm Shipment Load"},object:function(){return t.loadList}}});console.log("YOU DID IT!!!")};t.modalPathUrls={load:"../../Angular/Directives/modals/my_international_modals/po_manager_modals/po-load-help.html"};t.animationsEnabled=!0;t.openHelp=function(n,i,r){var u=e.open({animation:!0,templateUrl:t.modalPathUrls[r],controller:"helpModalCtrl",size:n,resolve:{helpTitle:function(){return i}}})}}]);angular.module("directive.poManager",[]).directive("poManager",[function(){return{restrict:"E",scope:{},templateUrl:"../../Angular/Directives/international/po_manager/po-manager.html"}}]).controller("poManagerCtrl",["$http","$scope","$location","$timeout","$window","$filter",function(n,t){t.poNav={sheets:!1,load:!0,manifest:!1,master:!1};t.setManagerNavigation=function(n){t.poNav=_.mapObject(t.poNav,function(){return!1});t.poNav[n]=!0}}]);angular.module("directive.poManifest",[]).directive("poManifest",[function(){return{restrict:"E",scope:{},templateUrl:"../../Angular/Directives/international/po_manager/po-manifest.html"}}]).controller("poManifestCtrl",["$http","$scope","$location","$timeout","$window","$filter","$uibModal","shipmentFactory","internationalFactory",function(n,t,i,r,u,f,e,o,s){var h,c;s.getPOManifestByAgent().then(function(n){t.myLoads=n.data;t.myLoadsUpdated=!0;t.setDates()}).catch(function(n){t.myLoadsUpdated=!0;console.log(n)});t.setDates=function(){_.each(t.myShipments,function(n){n.DeliveryDate={};n.ShipDate={};_.each(n.Tracking,function(t){if(t.Key=="READY")n.ShipDate=parseInt(t.TrackDate.match(/(\d+)|(-\d+)/)[0]);else if(t.Key=="POD"){var i=parseInt(t.TrackDate.match(/(\d+)|(-\d+)/)[0]);n.DeliveryDate=i>0?i:null}})})};t.consolidateList={consolNumber:null,list:[]};t.selectedLoad={};t.loadSubmitted={};h=function(n,t){var r=-1,i;if(n.length==0)r=-1;else for(i=0;i<n.length;i++)n[i].POLOADNUMBER==t.POLOADNUMBER&&(r=i);return r};t.updateManifestID=function(n){t.consolidateList.list.length&&_.each(t.consolidateList.list,function(t){t.MANIFESTID=n})};t.addToContainer=function(n){var i=h(t.consolidateList.list,n);i>-1?(t.consolidateList.list.splice(i,1),t.loadSubmitted[n.POLOADNUMBER]=!1,t.selectedLoad[n.POLOADNUMBER]=!1,console.log("Load "+n.POLOADNUMBER+" was removed.")):(n.MANIFESTID=t.consolidateList.MANIFESTID,t.consolidateList.list.push(n),t.loadSubmitted[n.POLOADNUMBER]=!0,t.selectedLoad[n.POLOADNUMBER]=!0,console.log("Load "+n.POLOADNUMBER+" was added."))};t.consolidateLoads=function(n){t.manifestFormSubmitted=!0;n?(t.manifestLoading=!0,s.manifestSelectedLoads(t.consolidateList.list).then(function(n){t.manifestFormSubmitted=!1;t.manifestLoading=!1;n.data.Success&&c()}).catch(function(n){t.manifestFormSubmitted=!1;t.manifestLoading=!1;console.log(n)})):console.log("INVALID FORM")};t.checkedItem=function(n){return _.findIndex(t.consolidateList.list,function(t){return t.POLOADNUMBER==n})};c=function(){var n=e.open({animation:!0,templateUrl:"../../Angular/Directives/modals/my_international_modals/po_manager_modals/po-manifest-confirm.html",controller:"poManifestConfirmModal",size:"lg",resolve:{title:function(){return"Confirm PO Load"},consolNumber:function(){return t.consolidateList.MANIFESTID}}});console.log("YOU DID IT!!!")};t.modalPathUrls={manifest:"../../Angular/Directives/modals/my_international_modals/po_manager_modals/po-manifest-help.html"};t.animationsEnabled=!0;t.openHelp=function(n,i,r){var u=e.open({animation:!0,templateUrl:t.modalPathUrls[r],controller:"helpModalCtrl",size:n,resolve:{helpTitle:function(){return i}}})}}]);angular.module("directive.poMaster",[]).directive("poMaster",[function(){return{restrict:"E",scope:{},templateUrl:"../../Angular/Directives/international/po_manager/po-master.html"}}]).controller("poMasterCtrl",["$http","$scope","$location","$timeout","$window","$filter","$uibModal","internationalFactory",function(n,t,i,r,u,f,e,o){t.distributionTypes=["By House","By Actual Weight","By Chargeable Weight","By Cubic Meters","By Cubic Feet"];t.masterForm={};t.createMaster=function(n){t.formSubmitted=!0;n?(t.masterLoading=!0,o.pOMasterSave(t.masterForm).then(function(n){t.formSubmitted=!1;t.masterLoading=!1;n.data.Success&&(s(),t.masterForm={})}).catch(function(n){t.formSubmitted=!1;t.masterLoading=!1;console.log(n)})):console.log("INVALID FORM")};var s=function(){var n=e.open({animation:!0,templateUrl:"../../Angular/Directives/modals/my_international_modals/po_manager_modals/po-master-confirm.html",controller:"poMasterConfirmModal",size:"lg",resolve:{title:function(){return"Confirm PO Master"},consolNumber:function(){return t.masterForm.CONSOLNUMBER}}});console.log("YOU DID IT!!!")};t.modalPathUrls={master:"../../Angular/Directives/modals/my_international_modals/po_manager_modals/po-sheets-help.html"};t.animationsEnabled=!0;t.openHelp=function(n,i,r){var u=e.open({animation:!0,templateUrl:t.modalPathUrls[r],controller:"helpModalCtrl",size:n,resolve:{helpTitle:function(){return i}}})}}]);angular.module("directive.poSheets",[]).directive("poSheets",[function(){return{restrict:"E",scope:{},templateUrl:"../../Angular/Directives/international/po_manager/po-sheets.html"}}]).controller("poSheetsCtrl",["$http","$scope","$location","$timeout","$window","$filter","$uibModal","internationalFactory",function(n,t,i,r,u,f,e,o){o.getGoogleDocs().then(function(n){t.mySpreadSheets=n.data}).catch(function(n){console.log(n)});t.modalPathUrls={sheets:"../../Angular/Directives/modals/my_international_modals/po_manager_modals/po-sheets-help.html"};t.animationsEnabled=!0;t.openHelp=function(n,i,r){var u=e.open({animation:!0,templateUrl:t.modalPathUrls[r],controller:"helpModalCtrl",size:n,resolve:{helpTitle:function(){return i}}})}}]);angular.module("directive.myReports",[]).directive("myReports",[function(){return{restrict:"E",scope:{},templateUrl:"../../Angular/Directives/my_reports/my-reports.html"}}]).controller("myReportsCtrl",["$http","$rootScope","$scope","$location","$timeout","$window","$uibModal","userFactory","$filter","reportFactory",function(n,t,i,r,u,f,e,o,s,h){i.currentReport={};i.reportsDash={defaultReports:!0,customReports:!1,dynamicReports:!1};i.setReportsDashNav=function(n){i.reportsDash=_.mapObject(i.reportsDash,function(){return!1});i.reportsDash[n]=!0};i.reportNav={dailyShipments:!1,scheduledDelivery:!1,dailyDelivery:!1,laneSegment:!1,monthlyShipments:!1,emailSignup:!1};i.setReportNav=function(n){i.reportNav=_.mapObject(i.reportNav,function(){return!1});i.reportNav[n]=!0;i.currentReport={};i.message="";i.showMsg=null;i.currentReport.startDate=new Date};i.closeAll=function(){i.reportNav=_.mapObject(i.reportNav,function(){return!1});i.currentReport={};i.message="";i.showMsg=null;i.currentReport.startDate=new Date};h.getAllDynamicReportsByUserId().then(function(n){i.dynamicReports=n.data}).catch(function(){});i.openStatus={dailyShipments:{start:!1,end:!1},scheduledDelivery:{start:!1,end:!1},dailyDelivery:{start:!1,end:!1},laneSegment:{start:!1,end:!1},monthlyShipments:{start:!1,end:!1},emailSignup:{start:!1,end:!1}};i.minDate=new Date;i.currentReport.startDate=new Date;i.toggleOpenStatus=function(n,t){i.openStatus[n][t]=!0};i.showMsg=!1;i.message="";i.generateReport=function(n){var t=s("date")(i.currentReport.startDate,"MM/dd/yyyy"),r=s("date")(i.currentReport.endDate,"MM/dd/yyyy"),u="/clientportal/reports/generatereport?reportNo="+n+"&startDate="+t+"&endDate="+r;f.open(u)};i.signupReport=function(){i.showMsg=!1;i.message="";h.signupReport(i.currentReport).then(function(){strMsg=null;i.currentReport.podReport!=null&&(i.currentReport.frequencyDaily!=null&&i.currentReport.frequencyDaily==!0&&(strMsg="You chose a POD report to be sent daily. <br />"),i.currentReport.frequencyWeekly!=null&&i.currentReport.frequencyWeekly==!0&&(strMsg="You chose a POD report to be sent weekly. <br />"),i.currentReport.frequencyMonthly!=null&&i.currentReport.frequencyMonthly==!0&&(strMsg="You chose a POD report to be sent monthly. <br />"));i.currentReport.shipmentReport!=null&&(i.currentReport.frequencyDaily!=null&&i.currentReport.frequencyDaily==!0&&(strMsg=strMsg+"You chose a Shipment report to be sent daily. <br />"),i.currentReport.frequencyWeekly!=null&&i.currentReport.frequencyWeekly==!0&&(strMsg=strMsg+"You chose a Shipment report to be sent weekly. <br />"),i.currentReport.frequencyMonthly!=null&&i.currentReport.frequencyMonthly==!0&&(strMsg=strMsg+"You chose a Shipment report to be sent monthly. <br />"));(i.currentReport.reportformat=="EXCE"||i.currentReport.reportformat=="PDF")&&(strMsg=i.currentReport.reportformat=="EXCE"?strMsg+"<br/>The report will be sent to "+i.currentReport.emailAddress+" in EXCEL format. <br/> Please contact <a href= 'mailto:reports@agsystems.com'>reports@agsystems.com<\/a> for modifications.":strMsg+"<br/>The report will be sent to "+i.currentReport.emailAddress+" in PDF format. <br/> Please contact <a href= 'mailto:reports@agsystems.com'>reports@agsystems.com<\/a> for modifications.");i.message=strMsg;i.showMsg=!0}).catch(function(n){console.log(n)})};i.modalPathUrls={reports:"../../Angular/Directives/modals/my_reports_modals/reports-help.html"};i.animationsEnabled=!0;i.openHelp=function(n,t,r){var u=e.open({animation:!0,templateUrl:i.modalPathUrls[r],controller:"helpModalCtrl",size:n,resolve:{helpTitle:function(){return t}}})}}]);var myAGS=angular.module("myAGS",["ngSanitize","ngFileUpload","ngAnimate","ui.calendar","ui.bootstrap","angular-ladda","directive.adminHeader","directive.agsHeader","myAGS.home","myAGS.international","myAGS.myAccount","myAGS.quotes","myAGS.reports","myAGS.shipments","myAGS.tracking","myAGS.admin","myAGS.aGSSMSModal","myAGS.helpModal","myAGS.quoteModal","myAGS.poLoadModal","myAGS.poManifestConfirmModal","myAGS.poMasterConfirmModal","myAGS.shipmentConfirmModal","myAGS.quoteConfirmModal","myAGS.internationalShipmentConfirmModel",])