function updateTemplate(){const e=adminPanel.abelKit._admin.get("contracts"),t=e.getActive();1==(1&t.rights)&&$("#navbar_menu_map").removeClass("hidden"),4!=(4&t.rights)&&8192!=(8192&t.rights)||$("#navbar_menu_lookup").removeClass("hidden"),16!=(16&t.rights)&&32!=(32&t.rights)&&64!=(64&t.rights)&&128!=(128&t.rights)&&512!=(512&t.rights)||$("#navbar_menu_reporting").removeClass("hidden"),1048576==(1048576&t.rights)&&$("#navbar_menu_scheduler").removeClass("hidden"),$("#user_name").html(adminPanel.abelKit._admin.get().name),$("#navbar_menu_contract").html(Templates.contracts_selector({contracts:e.data,selectedContract:t})),$("#header_logo").html(Templates.header_logo({settings:t.settings}))}function setSubContainer(e){menu_item=e[0].split("_"),"function"==typeof map_action&&map_action("stop"),"lookup_customer"==e[0]?(lookup_customer_load({}),2==e.length?"add"==e[1]?lookup_customer_load({customer:{new:!0,enabled:!0}}):lookup_customer_lookup(e[1]):3===e.length?lookup_customer_search(decodeURIComponent(e[2])):5===e.length&&"attributes"===e[2]&&"remove"===e[4]?lookup_customer_remove_attribute(e[1],e[3]):lookup_customer_search("")):"lookup_trip"==e[0]?(lookup_trip_load({}),e.length>1?"add"==e[1]?3==e.length?lookup_trip_load_new(e[2]):lookup_trip_load_new(""):e.length>=3?lookup_trip_search(decodeURIComponent(e[2])):lookup_trip_lookup(e[1]):lookup_trip_search("")):"lookup_activity"==e[0]?(lookup_load(menu_item[0],"activity",{}),e.length>1?e.length>=3?lookup_search(menu_item[0],"activity",decodeURIComponent(e[2])):lookup_item(menu_item[0],"activity",e[1]):lookup_search(menu_item[0],"activity")):"lookup_debuglog"==e[0]?(lookup_load(menu_item[0],"debuglog",{}),e.length>1?e.length>=3?lookup_search(menu_item[0],"debuglog",decodeURIComponent(e[2])):lookup_item(menu_item[0],"debuglog",e[1]):lookup_search(menu_item[0],"debuglog")):"settings_user"==e[0]?(lookup_load(menu_item[0],"user",{}),2==e.length?"add"==e[1]?lookup_item_add(menu_item[0],"user"):lookup_item(menu_item[0],"user",e[1]):3==e.length?lookup_search(menu_item[0],"user",decodeURIComponent(e[2])):lookup_search(menu_item[0],"user")):"lookup_tripstate"==e[0]?(lookup_load(menu_item[0],"tripstate",{}),e.length>2?lookup_search(menu_item[0],"tripstate",decodeURIComponent(e[2])):lookup_search(menu_item[0],"tripstate")):"lookup_paymentmethod"==e[0]?(lookup_load(menu_item[0],"paymentmethod",{}),e.length>2?lookup_search(menu_item[0],"paymentmethod",decodeURIComponent(e[2])):lookup_search(menu_item[0],"paymentmethod")):"lookup_reconciliation_invoice"==e[0]?(lookup_load(menu_item[0],"reconciliation_invoice",{}),"search"==e[1]?lookup_search(menu_item[0],"reconciliation_invoice",decodeURIComponent(e[2]),!1):2==e.length?lookup_item(menu_item[0],"reconciliation_invoice",decodeURIComponent(e[1])):(startOfYesterday=moment().tz(adminPanel.abelKit._admin.get("timezone")).startOf("day").subtract(15,"day").format("Y-M-D HH:mm:ss"),lookup_search(menu_item[0],"reconciliation_invoice",'status:open before:"'+startOfYesterday+'"',!1))):"lookup_reconciliation_batch"==e[0]?(lookup_load(menu_item[0],"reconciliation_batch",{}),"search"==e[1]?lookup_search(menu_item[0],"reconciliation_batch",decodeURIComponent(e[2]),!1):lookup_search(menu_item[0],"reconciliation_batch","",!1)):"lookup_reconciliation_payment"==e[0]?(lookup_load(menu_item[0],"reconciliation_payment",{}),"search"==e[1]?lookup_search(menu_item[0],"reconciliation_payment",decodeURIComponent(e[2]),!1):e.length>2?lookup_item(menu_item[0],"reconciliation_payment",decodeURIComponent(e[1])+"/"+decodeURIComponent(e[2])):(startOfYesterday=moment().tz(adminPanel.abelKit._admin.get("timezone")).startOf("day").subtract(15,"day").format("Y-M-D HH:mm:ss"),lookup_search(menu_item[0],"reconciliation_payment","status:open",!1))):"lookup_reconciliation_upload"==e[0]?lookup_load(menu_item[0],"reconciliation_upload",{item:"generic"}):"lookup_servicenotification"==e[0]?(lookup_load(menu_item[0],"servicenotification",{}),"search"==e[1]?lookup_search(menu_item[0],"servicenotification",decodeURIComponent(e[2]),!1):"add"==e[1]?lookup_item_add(menu_item[0],"servicenotification"):2==e.length?lookup_item(menu_item[0],"servicenotification",e[1]):lookup_search(menu_item[0],"servicenotification","status:open",!1)):"lookup_driver"==e[0]?(lookup_driver_load({}),2==e.length?"add"==e[1]?lookup_driver_new():lookup_driver_lookup(e[1]):3==e.length?lookup_driver_search(decodeURIComponent(e[2])):lookup_driver_search("")):"lookup_vehicle"==e[0]?(lookup_vehicle_load({}),2==e.length?"add"==e[1]?lookup_vehicle_new():lookup_vehicle_lookup(e[1]):3==e.length?lookup_vehicle_search(decodeURIComponent(e[2])):lookup_vehicle_search("")):"lookup_discount"==e[0]?(lookup_discount_load({}),2==e.length?"add"==e[1]?lookup_discount_new():lookup_discount_lookup(e[1]):3==e.length?lookup_discount_search(decodeURIComponent(e[2])):lookup_discount_search("")):"lookup_company"==e[0]?(lookup_company_load({}),2==e.length?"add"==e[1]?lookup_company_new():lookup_company_lookup(e[1]):3==e.length?lookup_company_search(decodeURIComponent(e[2])):lookup_company_search("")):"lookup_promocode"==e[0]?(lookup_promocode_load({}),2==e.length?"add"==e[1]?lookup_promocode_new():lookup_promocode_lookup(e[1]):3==e.length?lookup_promocode_search(decodeURIComponent(e[2])):lookup_promocode_search("")):"reporting_clients"==e[0]?reporting_graphs_load("clients"):"reporting_ops_graph"==e[0]?reporting_graphs_load("ops_graph"):"reporting_ops_table"==e[0]?reporting_graphs_load("ops_table"):"reporting_finance"==e[0]?reporting_graphs_load("finance"):"reporting_query"==e[0]?reporting_query_load():"map"==e[0]?map_load():"scheduler"==e[0]?adminPanel.scheduler():"settings_profile"==e[0]?lookup_item(menu_item[0],"profile",!1):"settings_subscriptions"==e[0]?lookup_item(menu_item[0],"subscriptions",!1):"settings_apps"==e[0]?lookup_item(menu_item[0],"apps",!1):"settings_bi"==e[0]?lookup_item(menu_item[0],"bi",!1):"settings_meetingpoints"==e[0]?($("#content").html(Templates.settings_meetingpoints({})),resetLinkListener(),adminPanel.meetingPoints()):"settings_mail"==e[0]?lookup_item(menu_item[0],"mail",!1):"settings_payments"==e[0]?lookup_item(menu_item[0],"payments",!1):"settings_templates"==e[0]?2==e.length?lookup_item(menu_item[0],"templates",e[1]):document.location.hash="settings_templates/changeEmailEn":"reporting"==e[0]?128==(128&adminPanel.abelKit._admin.get("contracts").getActive().rights)||512==(512&adminPanel.abelKit._admin.get("contracts").getActive().rights)?document.location.hash="reporting_query":16==(16&adminPanel.abelKit._admin.get("contracts").getActive().rights)?document.location.hash="reporting_clients":32==(32&adminPanel.abelKit._admin.get("contracts").getActive().rights)?document.location.hash="reporting_ops_graph":64==(64&adminPanel.abelKit._admin.get("contracts").getActive().rights)?document.location.hash="reporting_finance":$.bootstrapGrowl("Cannot find stuff you have access to",{delay:2e3,type:"danger"}):"lookup"==e[0]?4==(4&adminPanel.abelKit._admin.get("contracts").getActive().rights)?document.location.hash="lookup_customer":8192==(8192&adminPanel.abelKit._admin.get("contracts").getActive().rights)?document.location.hash="lookup_reconciliation_invoice":$.bootstrapGrowl("Cannot find stuff you have access to",{delay:2e3,type:"danger"}):"settings"==e[0]&&(document.location.hash="settings_profile"),$(document).trigger("hashchanged")}function resetLinkListener(){$("a").unbind(".dashboardLinkListener"),$("a").on("click.dashboardLinkListener",function(e){var t=location.hash.slice(1),o=$(this),n=o.attr("href");if(void 0!=n){t==n.substring(n.indexOf("#")+1)&&$(window).hashchange()}$(this).unbind(e)})}function number_format(e,t,o){o?e*=1:e=Math.abs(e),e=e.toFixed(t)+"";for(var n=e.split("."),a=n[0],i=n.length>1?"."+n[1]:"",r=/(\d+)(\d{3})/;r.test(a);)a=a.replace(r,"$1,$2");return a+i}function escapeRegExp(e){return e.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&")}function isValidEmailAddress(e){return new RegExp(/^((([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+(\.([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+)*)|((\x22)((((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(([\x01-\x08\x0b\x0c\x0e-\x1f\x7f]|\x21|[\x23-\x5b]|[\x5d-\x7e]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(\\([\x01-\x09\x0b\x0c\x0d-\x7f]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]))))*(((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(\x22)))@((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.?$/i).test(e)}function getUrlParameter(e){var t,o,n=decodeURIComponent(window.location.search.substring(1)),a=n.split("&");for(o=0;omoment().startOf("day")&&emoment().startOf("year")&&emoment().startOf("day")&&emoment().startOf("year")&&e0&&$("#submenu_"+menu_item[1]).addClass("active"),menu_item.length>1&&$("#subsubmenu_"+menu_item[1]+"_"+menu_item[2]).addClass("active"),setSubContainer(t),resetLinkListener()):4==(4&adminPanel.abelKit._admin.get("contracts").getActive().rights)?document.location.hash="lookup_customer":1==(1&adminPanel.abelKit._admin.get("contracts").getActive().rights)?document.location.hash="map":16==(16&adminPanel.abelKit._admin.get("contracts").getActive().rights)?document.location.hash="reporting_clients":32==(32&adminPanel.abelKit._admin.get("contracts").getActive().rights)?document.location.hash="reporting_ops_graph":64==(64&adminPanel.abelKit._admin.get("contracts").getActive().rights)?document.location.hash="reporting_finance":128==(128&adminPanel.abelKit._admin.get("contracts").getActive().rights)||512==(512&adminPanel.abelKit._admin.get("contracts").getActive().rights)?document.location.hash="reporting_query":!0&adminPanel.abelKit._admin.get("contracts").getActive().rights?document.location.hash="settings_user":document.location.hash="settings_profile"}),String.prototype.underscoreToPathCase=function(){return string=this,string=string.replace(/[\-_\s]+(.)?/g,function(e,t){return t?"/"+t.toUpperCase():""}),string.substr(0,1).toUpperCase()+string.substr(1)},$.fn.serializeObject=function(){var e={},t=this.serializeArray();return $.each(t,function(){e[this.name]?(e[this.name].push||(e[this.name]=[e[this.name]]),e[this.name].push(this.value||"")):e[this.name]=this.value||""}),e}; function graph_clear(e){void 0!=graph_components[e]&&(graph_components[e].destroy(),delete graph_components[e])}function graph_plot_graph(e,t,a,n,r,o){if("line"==r){var l=[];for(i=1;iwaiting_on_driver_max&&(o.waiting_too_long=!0);const i=m.getPosition().lng(),g=m.getPosition().lat();(Math.abs(n.lat-g)>1e-5||Math.abs(n.lng-i)>1e-5)&&(fps=36,duration=2,stepLat=(n.lat-g)/fps/duration,stepLng=(n.lng-i)/fps/duration,moveMarker(m,fps,0,fps*duration,stepLat,stepLng,n)),m.setIcon(getMarkerIcon(t,e.getZoom())),m.markup=t,m.touched=!0}else{"driver"==t.type?(o.new_driver=!0,zIndex=1):(o.new_client=!0,0==t.on_time&&(o.changed_to_late=!0),t.time_waiting>waiting_on_driver_max&&(o.waiting_too_long=!0),zIndex=2);const m=new google.maps.Marker({position:n,icon:getMarkerIcon(t,e.getZoom()),title:r,touched:!0,zIndexOffset:zIndex,location:new google.maps.LatLng(n.lat,n.lng),map:e});m.markup=t,mapMarkers.push({id:a,marker:m})}return o}function untouchMarkers(){for(var e=0;e=0;e--)0==mapMarkers[e].marker.touched&&null!=mapMarkers[e].marker&&(mapMarkers[e].marker.setMap(null),mapMarkers.splice(e,1))}function getMarker(e){for(var a=0;amaxLat&&(maxLat=a.lat),a.lngmaxLng&&(maxLng=a.lng)});const n=new google.maps.LatLng(minLat,minLng),r=new google.maps.LatLng(maxLat,maxLng);return a.extend(n),a.extend(r),a}function getMarkerIcon(e,a){var n="https://developers.google.com/maps/documentation/javascript/examples/full/images/beachflag.png",r=[20,32],t=[0,0];switch(e.type){case"driver":n="img/mapKiaSoul.png",r=[46,28];break;case"client":const o="origin"===e.state?1-.7*(10-a)/10:.375;var s="";t="origin"===e.state?[(16*e.passengers+2*(e.passengers-1))*o/2,40*o]:[0*o-18*e.passenger_offset*o,-15*o],r=[(16*e.passengers+2*(e.passengers-1))*o,40*o],e.time_waiting>waiting_on_driver_max?s="_long":e.on_time||(s="_late"),n="img/mapClient_"+e.passengers+s+".png"}return{url:n,scaledSize:new google.maps.Size(r[0],r[1]),origin:new google.maps.Point(0,0),anchor:new google.maps.Point(t[0],t[1])}}var mapMarkers=[],waiting_on_driver_max=120; Handlebars.registerHelper({eq:function(t,n){return t===n},ne:function(t,n){return t!==n},lt:function(t,n){return tn},lte:function(t,n){return t<=n},gte:function(t,n){return t>=n},and:function(t,n){return t&&n},length:function(t){return t.length},contains:function(t,n){return t instanceof Array&&-1!=t.indexOf(n)},has:function(t,n){return(t&n)==n},or:function(t,n){return t||n},index_of:function(t,n){return t[n]},short_datetime:function(t){return void 0!=t&&0!=t?(parsed_moment=moment.utc(t).tz(adminPanel.abelKit._admin.get("timezone")),0==parsed_moment?"":shorter_time_format(parsed_moment,!0)):""},short_date:function(t){return void 0!=t&&0!=t?(parsed_moment=moment.utc(t).tz(adminPanel.abelKit._admin.get("timezone")),0==parsed_moment?"":shorter_time_format(parsed_moment,!1)):""},long_time:function(t){return void 0!=t&&0!=t?(parsed_moment=moment.utc(t).tz(adminPanel.abelKit._admin.get("timezone")),0==parsed_moment?"":parsed_moment.format("HH:mm:ss")):""},long_datetime:function(t){return void 0!=t&&0!=t?(parsed_moment=moment.utc(t).tz(adminPanel.abelKit._admin.get("timezone")),0==parsed_moment?"":parsed_moment.format("HH:mm:ss on D MMM YYYY")):""},date_format:function(t,n){return void 0!=t&&0!=t?(parsed_moment=moment.utc(t).tz(adminPanel.abelKit._admin.get("timezone")),0==parsed_moment?"":parsed_moment.format(n)):""},date:function(t){return void 0!=t&&0!=t?(parsed_moment=moment.utc(t).tz(adminPanel.abelKit._admin.get("timezone")),0==parsed_moment?"":parsed_moment.format("YYYY-MM-DD")):""},full_datetime:function(t){return void 0!=t&&0!=t?(parsed_moment=moment.utc(t).tz(adminPanel.abelKit._admin.get("timezone")),0==parsed_moment?"":short_time_format(parsed_moment,!0)):""},obj_to_string:function(t){try{return JSON.stringify(t,null,2)}catch(t){return""}},number_format:function(t,n){return number_format(t,n,!0)},setting:function(t){return adminPanel.abelKit._admin.get("contracts").getSettingForSelectedContract(t)}}); function lookup_load(e,o,t){return t.user=adminPanel.abelKit._admin.get(),t.contracts=adminPanel.abelKit._admin.get("contracts").data,t.selectedContract=adminPanel.abelKit._admin.get("contracts").getActive(),$("#content").html(Templates[e+"_"+o](t)),resetLinkListener(),$('[data-toggle="tooltip"]').tooltip(),"undefined"!=typeof lookup_load_item_actions&&lookup_load_item_actions(e,o,t),void 0!==t.item?$("#"+e+"_"+o+"_item_form").submit(function(a){return void 0!==t.item.id?lookup_post_item(e,o,t.item.id):void 0!==t.item_id?lookup_post_item(e,o,t.item_id):lookup_post_item(e,o,!1),!1}):$("#"+e+"_"+o+"_form").submit(function(t){return document.location.hash=e+"_"+o+"/search/"+encodeURIComponent($("#"+o+"_search").val()),!1}),!0}function lookup_search_load_more(){$("#searchResultsLoadMoreButton").addClass("hidden"),!1!==lookupSearch&&lookup_search(lookupSearch.menu,lookupSearch.view,lookupSearch.query,!0)}function lookup_search(e,o,t,a){void 0!==t&&$("#"+o+"_search").val(t);var n=o.underscoreToPathCase()+"/Search/"+encodeURI($("#"+o+"_search").val());void 0!==a&&a?n=n+"/next/"+lookupSearch.nextTime+"/"+lookupSearch.nextKey:lookupSearch=!1,$.ajaxWrapper(n,"GET",{},!1,{success:function(n){a||$("#searchtable").html(Templates[e+"_"+o+"_searchtable"]({selectedContract:adminPanel.abelKit._admin.get("contracts").getActive(),results:n.return,pagination:n.pagination})),void 0!==a&&(lookupSearch={nextTime:n.pagination.nextTime,nextKey:n.pagination.nextKey,menu:e,view:o,query:t},$("#searchResultsTable").append(Templates[e+"_"+o+"_searchresults"]({selectedContract:adminPanel.abelKit._admin.get("contracts").getActive(),results:n.return}).trim()),n.pagination.endReached?$("#searchResultsLoadMoreButton").addClass("hidden"):$("#searchResultsLoadMoreButton").removeClass("hidden")),resetLinkListener()},error:function(e,o,t){$("#searchtable").innerHTML=""}})}function lookup_item(e,o,t){if(t)var a=o.underscoreToPathCase()+"/"+t;else var a=o.underscoreToPathCase();$.ajaxWrapper(a,"GET",{},!0,{success:function(a){lookup_load(e,o,{item:a.return,item_id:t})},error:function(t,a,n){lookup_load(e,o,{})}})}function lookup_post_item(e,o,t){if(t)var a=o.underscoreToPathCase()+"/"+t;else var a=o.underscoreToPathCase();var n=!1;"undefined"!=typeof lookup_post_item_prep_data&&(retval=lookup_post_item_prep_data(e,o,t),retval&&(n=retval.requestData,requestType=retval.requestType)),n||(n=$("#"+e+"_"+o+"_item_form").serializeObject(),requestType="POST"),$.ajaxWrapper(a,requestType,n,!0,{success:function(a){"undefined"!=typeof lookup_post_item_actions&&lookup_post_item_actions(e,o,$("#"+e+"_"+o+"_item_form").serializeObject(),a),t||void 0===a.Id?t?lookup_item(e,o,t):lookup_item(e,o,!1):document.location.hash=e+"_"+o+"/"+a.Id,$.bootstrapGrowl("Done.",{delay:2e3,type:"success"})}})}function lookup_item_action(e,o,t,a,n,i){lookup_subitem_action(e,o,t,a,!1,a,n,i)}function lookup_subitem_action(e,o,t,a,n,i,r,s){var u=!1;if("undefined"!=typeof lookup_item_action_prep_data&&(u=lookup_item_action_prep_data(e,o,t,a)),u||(u={}),r&&1!=confirm("Are you sure?"))$.bootstrapGrowl("No changes made.",{delay:2e3,type:"info"});else{if(0==n)var c="";else var c=n.underscoreToPathCase()+"/";$.ajaxWrapper(o.underscoreToPathCase()+"/"+c+i+"/"+t,"POST",u,!1,{success:function(t){1==s?document.location.hash=e+"_"+o:0==s&&lookup_item(e,o,a),$.bootstrapGrowl("Done.",{delay:2e3,type:"success"})}})}}function lookup_item_add(e,o){lookup_load(e,o,{item:{new:!0}})}var lookupSearch=!1; function lookup_company_load(o){return $("#content").html(Templates.lookup_company(o)),resetLinkListener(),$("#lookup_company_form").submit(function(o){return document.location.hash="lookup_company/search/"+encodeURIComponent($("#company_search").val()),!1}),$("#company_form").submit(function(o){return void 0===$("#company_id").val()?$.ajaxWrapper("Company/","POST",{Company:{StatutoryName:$("#company_name").val().trim(),StatutoryAddress:{LocationType:"address",Street:$("#company_street").val().trim(),HouseNumber:$("#company_housenumber").val().trim(),Zip:$("#company_zip").val().trim(),Place:$("#company_place").val().trim(),CountryCode:$("#company_country").val().trim()},Email:$("#company_email").val().trim(),VatNumber:$("#company_vat").val().trim(),KvKNumber:$("#company_kvk").val().trim(),IBAN:$("#company_iban").val().trim()}},!1,{success:function(o){document.location.hash="lookup_company/"+o.result.CompanyExtended.CompanyId,$.bootstrapGrowl("Added.",{delay:2e3,type:"success"})}}):$.ajaxWrapper("Company/"+$("#company_id").val().trim(),"POST",{Company:{StatutoryName:$("#company_name").val().trim(),StatutoryAddress:{LocationType:"address",Street:$("#company_street").val().trim(),HouseNumber:$("#company_housenumber").val().trim(),Zip:$("#company_zip").val().trim(),Place:$("#company_place").val().trim(),CountryCode:$("#company_country").val().trim()},Email:$("#company_email").val().trim(),VatNumber:$("#company_vat").val().trim(),KvKNumber:$("#company_kvk").val().trim(),IBAN:$("#company_iban").val()}},!1,{success:function(o){$.bootstrapGrowl("Saved.",{delay:2e3,type:"success"})}}),!1}),!0}function lookup_company_remove(o){1==confirm("Are you sure?")?$.ajaxWrapper("Company/"+$("#company_id").val()+"/Remove","POST",{},!1,{success:function(o){document.location.hash="lookup_company",$.bootstrapGrowl("Removed.",{delay:2e3,type:"success"})}}):$.bootstrapGrowl("No changes made.",{delay:2e3,type:"info"})}function lookup_company_new(){lookup_company_load({company:{new:!0}})}function lookup_company_search(o){void 0!==o&&$("#company_search").val(o),$.ajaxWrapper("Company/Search/"+encodeURI($("#company_search").val()),"GET",{},!1,{success:function(o){$("#searchtable").html(Templates.lookup_company_searchtable({companies:o.return})),resetLinkListener()},error:function(o,a,e){$("#searchtable").innerHTML=""}})}function lookup_company_lookup(o){$.ajaxWrapper("Company/"+o,"GET",{},!0,{success:function(o){lookup_company_load({company:o.return.company,drivers:o.return.drivers})},error:function(o,a,e){lookup_company_load({})}})} function lookup_customer_load(e){return e.selectedContract=adminPanel.abelKit._admin.get("contracts").getActive(),$("#content").html(Templates.lookup_customer(e)),resetLinkListener(),$('[data-toggle="tooltip"]').tooltip(),$("#lookup_customer_form").submit(function(e){return document.location.hash="lookup_customer/search/"+encodeURIComponent($("#customer_search").val()),!1}),$("#customer_form").submit(function(e){var o=!1;$("#customer_enabled").prop("checked")&&(o=!0);var t=!1;$("#customer_mailchimp").prop("checked")&&(t=!0);var r=moment.tz($("#customer_hold_export_to_collection_agency_until").val(),"YYYY-MM-DD",adminPanel.abelKit._admin.get("timezone")),u="";r.isValid()&&(u=r.toISOString());var s={Customer:{FirstName:$("#customer_first_name").val().trim(),LastName:$("#customer_last_name").val().trim(),Tel:$("#customer_phone").val().trim(),Email:$("#customer_email").val().trim()},HoldExportToCollectionAgencyUntil:u};return void 0===$("#customer_id").val()?(s.Language=$("#customer_language").val(),s.Mailchimp=t):(s.Password=$("#customer_password").val(),s.Enabled=o),lookup_customer_replace(s),!1}),$("#customer_attributes_form").submit(function(e){return lookup_customer_add_attribute($("#customer_id").val(),$("#new_attribute").val()),!1}),!0}function lookup_customer_replace(e){void 0===$("#customer_id").val()?$.ajaxWrapper("Customer/","POST",e,!1,{success:function(e){document.location.hash="lookup_customer/"+e.result.Customer.CustomerId,$.bootstrapGrowl("Saved.",{delay:2e3,type:"success"})}}):$.ajaxWrapper("Customer/"+$("#customer_id").val(),"POST",e,!1,{success:function(e){$.bootstrapGrowl("Saved.",{delay:2e3,type:"success"}),lookup_customer_lookup($("#customer_id").val())}})}function lookup_customer_search(e){void 0!==e&&$("#customer_search").val(e),$.ajaxWrapper("Customer/Search/"+encodeURI($("#customer_search").val()),"GET",{},!1,{success:function(e){$("#searchtable").html(Templates.lookup_customer_searchtable({customers:e.return})),resetLinkListener()},error:function(e,o,t){$("#searchtable").innerHTML=""}})}function lookup_customer_add_attribute(e,o){$.ajaxWrapper("AddUserAttribute","POST",{CustomerId:e,Attribute:o},!0,{success:function(t){document.location.hash="lookup_customer/"+e,$.bootstrapGrowl('Attribute "'+o+'" added.',{delay:2e3,type:"success"})},error:function(o,t,r){document.location.hash="lookup_customer/"+e,$.bootstrapGrowl("Failed to add attribute.",{delay:2e3,type:"error"})}})}function lookup_customer_remove_attribute(e,o){$.ajaxWrapper("RemoveUserAttribute","POST",{CustomerId:e,Attribute:o},!0,{success:function(t){document.location.hash="lookup_customer/"+e,$.bootstrapGrowl('Attribute "'+o+'" removed.',{delay:2e3,type:"success"})},error:function(o,t,r){document.location.hash="lookup_customer/"+e,$.bootstrapGrowl("Failed to remove attribute.",{delay:2e3,type:"error"})}})}function lookup_customer_lookup(e){$.ajaxWrapper("Customer/"+e,"GET",{},!0,{success:function(e){const o=e.return.customer;o.attributes={},o.hasOwnProperty("senior")&&"SENIOR"===o.senior&&(delete o.senior,o.attributes.Senior=!0),lookup_customer_load({customer:o,middleware_server:adminPanel.abelKit.getServer()})},error:function(e,o,t){lookup_customer_load({})}})}function lookup_customer_action(e,o){1==confirm("Are you sure?")?$.ajaxWrapper("Customer/"+e+"/"+o,"POST",{},!0,{success:function(o){$.bootstrapGrowl("Done.",{delay:2e3,type:"success"}),lookup_customer_lookup(e)}}):$.bootstrapGrowl("No changes made.",{delay:2e3,type:"info"})} function lookup_discount_load(o){return $("#content").html(Templates.lookup_discount(o)),resetLinkListener(),$("#lookup_discount_form").submit(function(o){return document.location.hash="lookup_discount/search/"+encodeURIComponent($("#discount_search").val()),!1}),!0}function lookup_discount_remove(o,n,s){1==confirm("Are you sure?")?$.ajaxWrapper("Discount/Remove","POST",{CustomerId:o,DiscountId:n,DiscountType:s},!1,{success:function(o){$(window).trigger("hashchange"),$.bootstrapGrowl("Removed.",{delay:2e3,type:"success"})}}):$.bootstrapGrowl("No changes made.",{delay:2e3,type:"info"})}function lookup_discount_search(o){void 0!==o&&$("#discount_search").val(o),$.ajaxWrapper("Discount/Search/"+encodeURI($("#discount_search").val()),"GET",{},!1,{success:function(o){$("#searchtable").html(Templates.lookup_discount_searchtable({discounts:o.return})),resetLinkListener()},error:function(o,n,s){$("#searchtable").innerHTML=""}})}function lookup_discount_lookup(o){$.ajaxWrapper("Discount/"+o,"GET",{},!0,{success:function(o){lookup_discount_load({discount:o.return.discount})},error:function(o,n,s){lookup_discount_load({})}})}function lookup_discount_add_all(){var o=$("#discount_promocodes").val().split("\n");discounts=[],$.each(o,function(){var o=this.split(",",2);o[0]=o[0].toLowerCase(),o[1]=parseInt(o[1]),discounts.push({Promocode:o[0],CustomerId:o[1]})}),$.ajaxWrapper("Discount/","POST",{Discounts:discounts},!0,{success:function(o){$(window).trigger("hashchange")}}),$("#addDiscountsModal").modal("hide")} function lookup_driver_load(r){return r.random=Math.random(),$("#content").html(Templates.lookup_driver(r)),resetLinkListener(),$("#lookup_driver_form").submit(function(r){return document.location.hash="lookup_driver/search/"+encodeURIComponent($("#driver_search").val()),!1}),$("#driver_photo").change(function(){var r=$("#driver_photo")[0].files[0];if(void 0!==r){$("#driver_avatar").remove(),$("#driver_croppie").croppie("destroy");var e=new FileReader;e.onload=function(r){$("#driver_croppie").croppie({viewport:{width:640,height:640,type:"square"},boundary:{width:700,height:700}}),$("#driver_croppie").croppie("bind",{url:r.target.result}),driver_croppie_set=!0},e.readAsDataURL(r)}}),$("#driver_form").submit(function(r){var e=!1;$("#driver_enabled").prop("checked")&&(e=!0);var o={Driver:{FirstName:$("#driver_first_name").val().trim(),LastName:$("#driver_last_name").val().trim(),Tel:$("#driver_phone").val().trim(),Tel2:$("#driver_phone2").val().trim(),Email:$("#driver_email").val().trim(),DriverCardId:$("#driver_card_id").val().trim(),CompanyId:$("#driver_company").val().trim()}};return void 0===$("#driver_id").val()?o.Password=$("#driver_password").val():(""!=$("#driver_password").val()&&(o.Password=$("#driver_password").val()),o.Enabled=e),driver_croppie_set?$("#driver_croppie").croppie("result",{type:"canvas",size:"viewport",format:"jpg",quality:.8}).then(function(r){o.Avatar=r.substr(r.indexOf(",")+1),lookup_driver_replace(o)}):lookup_driver_replace(o),!1}),!0}function lookup_driver_replace(r){void 0===$("#driver_id").val()?$.ajaxWrapper("Driver/","POST",r,!1,{success:function(r){document.location.hash="lookup_driver/"+r.result.Driver.DriverId,driver_croppie_set=!1,$.bootstrapGrowl("Saved.",{delay:2e3,type:"success"})}}):$.ajaxWrapper("Driver/"+$("#driver_id").val(),"POST",r,!1,{success:function(r){$.bootstrapGrowl("Saved.",{delay:2e3,type:"success"}),driver_croppie_set=!1,lookup_driver_lookup($("#driver_id").val())}})}function lookup_driver_remove(r){1==confirm("Are you sure?")?$.ajaxWrapper("Driver/"+r+"/Remove","POST",{},!1,{success:function(r){document.location.hash="lookup_driver",$.bootstrapGrowl("Removed.",{delay:2e3,type:"success"})}}):$.bootstrapGrowl("No changes made.",{delay:2e3,type:"info"})}function lookup_driver_new(){$.ajaxWrapper("Company/Search/","GET",{},!0,{success:function(r){lookup_driver_load({driver:{new:!0},companies:r.return})}})}function lookup_driver_search(r){void 0!==r&&$("#driver_search").val(r),$.ajaxWrapper("Driver/Search/"+encodeURI($("#driver_search").val()),"GET",{},!1,{success:function(r){$("#searchtable").html(Templates.lookup_driver_searchtable({drivers:r.return})),resetLinkListener()},error:function(r,e,o){$("#searchtable").innerHTML=""}})}function lookup_driver_lookup(r){$.ajaxWrapper("Driver/"+r,"GET",{},!0,{success:function(r){for(i=0;i-1&&e.splice(r,1),lookup_promocode_set_linked_promocodes(e)}function lookup_promocode_show_linked_promocodes(){var o=lookup_promocode_get_linked_promocodes(),e="";if(0!=o.length)for(var e="
Links:
",r=0;r'+o[r]+'
';$("#promocode_linked_codes_view").html(e)} lookup_post_item_actions=function(e,t,a,n){"settings"==e&&"profile"==t&&(adminPanel.abelKit._admin.data.timezone=a.Timezone)},lookup_post_item_prep_data=function(e,t,a){if("settings"==e&&("apps"==t||"mail"==t))return window.FormData?{requestData:new FormData($("#"+e+"_"+t+"_item_form")[0]),requestType:"formData"}:($.bootstrapGrowl("Your browser is outdated. Use chrome.",{delay:2e3,type:"danger"}),!1);if("settings"==e&&"templates"==t){var n=ace.edit("template_editor");if("invoice"==a.substring(0,a.length-2)){var r={Content:n.getValue()};return $("[id^=template_subject_]").each(function(){var e=$(this).attr("id").substring(17);r["Subject"+e.charAt(0).toUpperCase()+e.slice(1)]=$(this).val()}),{requestData:r,requestType:"POST"}}return{requestData:{Content:n.getValue(),Subject:$("#template_subject").val()},requestType:"POST"}}if("settings"==e&&"payments"==t){var r=r=$("#"+e+"_"+t+"_item_form").serializeObject();return $("#defaultPOSPaymentmethod").prop("checked")?r.defaultPOSPaymentmethod=!0:r.defaultPOSPaymentmethod=!1,$("#defaultCashPaymentmethod").prop("checked")?r.defaultCashPaymentmethod=!0:r.defaultCashPaymentmethod=!1,$("#blockAndUnblockCustomersBasedOnInvoiceStatus").prop("checked")?r.blockAndUnblockCustomersBasedOnInvoiceStatus=!0:r.blockAndUnblockCustomersBasedOnInvoiceStatus=!1,isNaN(parseInt($("#invoiceFirstReminderInterval").val()))?r.invoiceFirstReminderInterval=!1:r.invoiceFirstReminderInterval=parseInt($("#invoiceFirstReminderInterval").val()),isNaN(parseInt($("#invoiceSecondReminderInterval").val()))?r.invoiceSecondReminderInterval=!1:r.invoiceSecondReminderInterval=parseInt($("#invoiceSecondReminderInterval").val()),r.availablePaymentMethods=[],$("#paymentMethodsAdyenCreditcard").prop("checked")&&r.availablePaymentMethods.push("adyen_creditcard"),$("#paymentMethodsAdyenSepaDdIdeal").prop("checked")&&r.availablePaymentMethods.push("adyen_sepa_dd_ideal"),$("#paymentMethodsBraintreePaypal").prop("checked")&&r.availablePaymentMethods.push("braintree_paypal"),$("#paymentMethodsBraintreeCreditcard").prop("checked")&&r.availablePaymentMethods.push("braintree_creditcard"),{requestData:r,requestType:"POST"}}return"lookup"==e&&"reconciliation_upload"==t&&(window.FormData?{requestData:new FormData($("#"+e+"_"+t+"_item_form")[0]),requestType:"formData"}:($.bootstrapGrowl("Your browser is outdated. Use chrome.",{delay:2e3,type:"danger"}),!1))},lookup_item_action_prep_data=function(e,t,a,n){if("settings"==e&&"templates"==t&&"SendTest"==a){return{Content:ace.edit("template_editor").getValue(),Subject:$("#template_subject").val()}}return!1},lookup_load_item_actions=function(e,t,a){if("settings"==e&&"templates"==t){ace.config.set("basePath","/js/3rdp/ace-src-min");var n=ace.edit("template_editor");n.setBehavioursEnabled(!1),n.getSession().setMode("ace/mode/twig"),n.getSession().setUseWorker(!1),$("#settings_template_id").change(function(){document.location.hash="settings_templates/"+$("#settings_template_id").val()})}}; function lookup_trip_load(t){return t.selectedContract=adminPanel.abelKit._admin.get("contracts").getActive(),$("#content").html(Templates.lookup_trip(t)),resetLinkListener(),$('[data-toggle="tooltip"]').tooltip(),$("#lookup_trip_form").submit(function(t){return document.location.hash="lookup_trip/search/"+encodeURIComponent($("#trip_search").val()),!1}),!0}function lookup_trip_load_new(t){$("#content").html(Templates.lookup_trip_add({customer_id:t,pickup_timewindow_from:moment().tz(adminPanel.abelKit._admin.get("timezone")).format("YYYY-MM-DDTHH:mm"),pickup_timewindow_to:moment().add(20,"minutes").tz(adminPanel.abelKit._admin.get("timezone")).format("YYYY-MM-DDTHH:mm")})),resetLinkListener(),adminPanel.trip(),adminPanel.view.new(),$("#lookup_trip_form_new").submit(function(t){var i={TimeWindows:{},MaximumDetourIntervalMinutes:$("#trip_maximum_detour_interval").val(),NotificationIntervalMinutes:$("#trip_notification_interval").val()},e=moment.tz($("#trip_pickup_timewindow_from").val(),adminPanel.abelKit._admin.get("timezone")),r=moment.tz($("#trip_pickup_timewindow_to").val(),adminPanel.abelKit._admin.get("timezone")),o=moment.tz($("#trip_delivery_timewindow_from").val(),adminPanel.abelKit._admin.get("timezone")),n=moment.tz($("#trip_delivery_timewindow_to").val(),adminPanel.abelKit._admin.get("timezone"));return e.isValid()&&r.isValid()&&(i.TimeWindows.PickupTimeWindow={EarliestTime:e.toISOString(),LatestTime:r.toISOString()}),o.isValid()&&n.isValid()&&(i.TimeWindows.DeliveryTimeWindow={EarliestTime:o.toISOString(),LatestTime:n.toISOString()}),$.ajaxWrapper("Trip/Book","POST",{Trip:{CustomerId:$("#trip_customer_id").val().trim(),LocationFrom:{GeoType:"wgs84",LocationType:"gpscoord",Coord:{Y:$("#trip_from_lat").val(),X:$("#trip_from_lng").val()},Street:$("#trip_from_route").val(),HouseNumber:$("#trip_from_street_number").val(),POIName:$("#trip_from_poi_name").val(),Place:$("#trip_from_locality").val(),Zip:$("#trip_from_postal_code").val(),CountryCode:$("#trip_from_country").val()},LocationTo:{GeoType:"wgs84",LocationType:"gpscoord",Coord:{Y:$("#trip_to_lat").val(),X:$("#trip_to_lng").val()},Street:$("#trip_to_route").val(),HouseNumber:$("#trip_to_street_number").val(),POIName:$("#trip_to_poi_name").val(),Place:$("#trip_to_locality").val(),Zip:$("#trip_to_postal_code").val(),CountryCode:$("#trip_to_country").val()},Attributes:{Passengers:$("#trip_passengers").val(),Wheelchairs:$("#trip_wheelchairs").val()}},Flexibility:i,PaymentMethodId:$("#trip_payment_method_id").val()},!1,{success:function(t){document.location.hash="lookup_trip/"+t.TripId,$.bootstrapGrowl("Added.",{delay:2e3,type:"success"})}}),!1})}function lookup_trip_search(t){void 0!==t&&$("#trip_search").val(t),$.ajaxWrapper("Trip/Search/"+encodeURI($("#trip_search").val()),"GET",{},!1,{success:function(t){$("#searchtable").html(Templates.lookup_trip_searchtable({trips:lookup_trip_parse_trips(t.return)})),resetLinkListener()},error:function(t,i,e){$("#searchtable").innerHTML=""}})}function lookup_trip_lookup(t){$.ajaxWrapper("Trip/"+t,"GET",{},!0,{success:function(t){lookup_trip_load({trip:lookup_trip_parse_trip(t.return.trip),middleware_server:adminPanel.abelKit.getServer()})},error:function(t,i,e){lookup_trip_load({})}})}function lookup_trip_parse_trips(t){for(i=0;i0?t.p_on_time=!0:t.p_on_time=!1,drpt.isValid()&&(t.pickup_diff=lookup_trip_number_incl_sign(drpt.diff(dlpt,"minutes"))),drdt.isValid()&&(t.delivery_diff=lookup_trip_number_incl_sign(drdt.diff(dldt,"minutes"))),drdt.isValid()&&drdt.diff(dldt)<0||!drdt.isValid()&&dldt.diff(now)>0?t.d_on_time=!0:t.d_on_time=!1,t.action_confirm=!1,t.action_cki=!1,t.action_cko=!1,t.action_cancel=!1,t.action_driver_cancel=!1,t.p_realized=!1,t.d_realized=!1,"creditCardFailed"==t.tripstatus||"tripDeclined"==t.tripstatus||("tripReceived"==t.tripstatus?t.action_cancel=!0:"tripAccepted"==t.tripstatus?t.action_cancel=!0:"paymentAuthorized"==t.tripstatus?t.action_cancel=!0:"awaitingDriverConsent"==t.tripstatus?(t.action_confirm=!0,t.action_cancel=!0):"driverAccepted"==t.tripstatus?(t.action_cki=!0,t.action_cancel=!0,t.action_driver_cancel=!0):"customerPickedUp"==t.tripstatus?(t.action_cko=!0,t.action_driver_cancel=!0,t.p_realized=!0):"customerArrived"==t.tripstatus?(t.p_realized=!0,t.d_realized=!0):"customerCancelled"==t.tripstatus||"driverCancelledBecauseOfClient"==t.tripstatus||(t.tripstatus,t.p_realized=!0)),!t.discount.nonzero&&!t.charged.nonzero||void 0!==t.pending&&0!=t.pending.refund||"customerArrived"!=t.tripstatus&&"customerCancelled"!=t.tripstatus&&"driverCancelledBecauseOfClient"!=t.tripstatus?t.action_withdraw_invoice=!1:t.action_withdraw_invoice=!0,t.olat_dec=t.OLAT/1e7,t.olon_dec=t.OLON/1e7,t.dlat_dec=t.DLAT/1e7,t.dlon_dec=t.DLON/1e7,t}function lookup_trip_change_state(t,i,e,r){1==confirm("Are you sure?")?$.ajaxWrapper("Trip/"+t+"/"+r,"POST",{DriverId:i,CustomerId:e},!0,{success:function(i){$.bootstrapGrowl("Done.",{delay:2e3,type:"success"}),lookup_trip_lookup(t)}}):$.bootstrapGrowl("No changes made.",{delay:2e3,type:"info"})}function lookup_trip_number_incl_sign(t){return t>0?"+"+t:t.toString()} function lookup_vehicle_load(e){var c=adminPanel.abelKit._admin.get("contracts").getSettingForSelectedContract("vehicleTypes");if(void 0!==e.vehicle){for(i=0;i=a[n-1]&&t=0;i--)mp_markers[i].marker.setMap(null),mp_markers.pop()}function meetingpoints_revert_polygon_with_markers(e){if(null==mp_selected_polygon)return void $.bootstrapGrowl("Create/ edit a polygon first",{delay:2e3,type:"danger"});e&&1!=confirm("Are you sure you want to revert?")?$.bootstrapGrowl("No changes made",{delay:2e3,type:"info"}):(meetingpoints_clear_markers(),null==mp_polygons[mp_selected_polygon].id?(mp_polygons[mp_selected_polygon].polygon.setMap(null),mp_polygons.splice(mp_selected_polygon,1)):meetingpoints_load_markers(mp_polygons[mp_selected_polygon].id,mp_selected_polygon,e))}function meetingpoints_remove_polygon_with_markers(){if(null==mp_selected_polygon)return void $.bootstrapGrowl("Select a polygon first",{delay:2e3,type:"danger"});1==confirm("Are you sure you want to remove it?")?(null!=mp_polygons[mp_selected_polygon].id&&$.ajaxWrapper("Meetingpoints/"+mp_polygons[mp_selected_polygon].id+"/Remove","POST",{},!1,{success:function(e){}}),null!=mp_selected_polygon&&(mp_polygons[mp_selected_polygon].polygon.setMap(null),mp_polygons.splice(mp_selected_polygon,1)),mp_selected_polygon=null,mp_selected_polygon_changed=!1,meetingpoints_clear_polygon_selection()):$.bootstrapGrowl("No changes made",{delay:2e3,type:"info"})}function meetingpoints_popover_remove(e){1==confirm("Are you sure you want to remove this meeting point?")?(mp_markers[e].marker.setMap(null),mp_markers.splice(e,1),mp_selected_polygon_changed=!0):$.bootstrapGrowl("No changes made",{delay:2e3,type:"info"})}function meetingpoints_popover_save(e,n,o){selected_language=meetingpoints_get_language(mp_markers[e].languages,n),0==selected_language?mp_markers[e].languages.push({language:n,name:$("#meetingpoints_popover_name").val(),description:$("#meetingpoints_popover_description").val()}):(selected_language.name=$("#meetingpoints_popover_name").val(),selected_language.description=$("#meetingpoints_popover_description").val()),o&&null!=mp_infowindow&&mp_infowindow.close()}function meetingpoints_download_csv(){adminPanel.abelKit._auth.getValidToken(function(e){var n={Auth:e,ContractId:adminPanel.abelKit._admin.get("contracts").getActive().id};window.open(adminPanel.abelKit.getServer()+"AbelAdminService/Meetingpoints/Download/?"+$.param(n),"Download meetingpoints")},function(e){$.bootstrapGrowl("Auth error: "+e.message,{delay:2e3,type:"danger"}),console.log("Auth error: "+e.message)})}var mp_polygons=[],mp_selected_polygon=null,mp_selected_polygon_changed=!1,mp_markers=[],mp_map=null,mp_drawingmanager=null,mp_polygon_options={fillColor:"#194C47",fillOpacity:.4,strokeWeight:3,clickable:!0,draggable:!0,editable:!1,zIndex:1},mp_infowindow=null,mp_marker_options={icon:{path:"M0-48c-9.8 0-17.7 7.8-17.7 17.4 0 15.5 17.7 30.6 17.7 30.6s17.7-15.4 17.7-30.6c0-9.6-7.9-17.4-17.7-17.4z",fillColor:"#B2E5E0",fillOpacity:.9,scale:.8,strokeWeight:3},clickable:!0,draggable:!0,zIndex:2}; function reporting_graphs_load(t){"clients"==t||"ops_graph"==t?($("#filter_granularity").val("days"),"ops_graph"==t?filter_change_granularity(!0,!0):filter_change_granularity(!0,!1),$("#content").html(Templates["reporting_"+t]({user:adminPanel.abelKit._admin.get(),contracts:adminPanel.abelKit._admin.get("contracts").data,selectedContract:adminPanel.abelKit._admin.get("contracts").getActive()})),resetLinkListener(),$('[data-toggle="tooltip"]').tooltip()):"ops_table"==t?($("#content").html("Loading..."),filter_change_granularity(!1,!1)):"finance"==t&&(filter_change_granularity(!1,!1,"Download"),$("#content").html("Note that download will trigger three files. Make sure that your popup-blocker allows this")),$("#filter_div").removeClass("hidden"),reporting_get(t,!1),$("#filter_granularity").change(function(r){"ops_graph"==t?filter_change_granularity(!0,!0):filter_change_granularity(!0,!1),reporting_get(t,!1)}),$("#reporting_filter").submit(function(r){return reporting_get(t,!0),!1})}function reporting_get(t,r){var e=filter_get();"clients"==t?$.ajaxWrapper("Customer/Performance","GET",{grouping:e.grouping,start:e.first_period_start.toISOString(),end:e.last_period_start.toISOString()},!1,{success:function(t){for(var r=["clients","clients_mutations","completed_trips"],a=0;a0,t.return.data[i].rejected_raw=(t.return.data[i].reject_count/(t.return.data[i].accept_count+t.return.data[i].reject_count)*100).toFixed(0),t.return.data[i].rejected=t.return.data[i].rejected_raw+"%",t.return.data[i].trips_bool=t.return.data[i].successful_trip_count+t.return.data[i].trips_canceled_by_driver_count>0,t.return.data[i].canceled_raw=(t.return.data[i].trips_canceled_by_driver_because_of_driver_count/(t.return.data[i].successful_trip_count+t.return.data[i].trips_canceled_by_driver_count)*100).toFixed(0),t.return.data[i].canceled=t.return.data[i].canceled_raw+"%",t.return.data[i].noshow_raw=(t.return.data[i].trips_canceled_by_driver_because_of_customer_count/(t.return.data[i].successful_trip_count+t.return.data[i].trips_canceled_by_driver_count)*100).toFixed(0),t.return.data[i].noshow=t.return.data[i].noshow_raw+"%",t.return.data[i].response_time=t.return.data[i].accept_react_avg.toFixed(0),t.return.data[i].punctuality_raw=((t.return.data[i].successful_trip_on_time_count+t.return.data[i].successful_trip_delivery_on_time_count)/(t.return.data[i].successful_trip_on_time_count+t.return.data[i].successful_trip_pickup_on_time_count+t.return.data[i].successful_trip_delivery_on_time_count+t.return.data[i].successful_trip_nothing_on_time_count)*100).toFixed(0),t.return.data[i].punctuality=t.return.data[i].punctuality_raw+"%",t.return.data[i].relative_utilization_raw=relative_utilization.toFixed(0),t.return.data[i].relative_utilization=relative_utilization.toFixed(0)+"%",0==t.return.data[i].successful_trip_rated_trip_count?t.return.data[i].rating=NaN:t.return.data[i].rating=t.return.data[i].successful_trip_rated_trip_avg_rating.toFixed(2),t.return.data[i].rating_share=(t.return.data[i].successful_trip_rated_trip_count/t.return.data[i].successful_trip_count*100).toFixed(0)+"%";$("#content").html(Templates.reporting_ops_table({drivers:t.return.data}));var r=create_csv_link("#reporting_ops_table_table");r.innerHTML="Download as CSV",r.setAttribute("class","btn btn-default"),r.setAttribute("role","button"),$("#query_csv_export").html(r),$.bootstrapSortable({sign:"arrow reversed"}),resetLinkListener()}}):"finance"==t&&r&&adminPanel.abelKit._auth.getValidToken(function(t){var r={start:e.first_period_start.toISOString(),end:e.last_period_start.add(1,"days").toISOString(),Auth:t,ContractId:adminPanel.abelKit._admin.get("contracts").getActive().id};window.open(adminPanel.abelKit.getServer()+"AbelAdminService/Finance/Backend?"+$.param(r),"Download trips"),window.open(adminPanel.abelKit.getServer()+"AbelAdminService/Finance/BackendRefunds?"+$.param(r),"Download trip refunds"),window.open(adminPanel.abelKit.getServer()+"AbelAdminService/Finance/Payments?"+$.param(r),"Download payments"),window.open(adminPanel.abelKit.getServer()+"AbelAdminService/Finance/Reconciliation?"+$.param(r),"Download reconciliation")},function(t){$.bootstrapGrowl("Auth error: "+t.message,{delay:2e3,type:"danger"}),console.log("Auth error: "+t.message)})}function reporting_graphs_to_sql(t){t in graph_sql?($(document).on("hashchanged",function(r){reporting_query_load(graph_sql[t]),$(this).unbind(r)}),document.location.hash="reporting_query"):$.bootstrapGrowl("SQL not found",{delay:2e3,type:"danger"})}var graph_sql={}; function filter_load(){filter_change_granularity()}function filter_change_granularity(t,e,r){if($("div[id^='filter_group_']").addClass("hidden"),void 0===r&&(r="Filter"),$("#filter_button").html(r),t){$("#filter_granularity_div").removeClass("hidden");var a=$("#filter_granularity").val();"hours"==a?(selection_granularity="day",selection_default_from=moment().format("YYYY-MM-DD"),selection_default_to=moment().format("YYYY-MM-DD")):"days"==a?(selection_granularity="day",selection_default_from=moment().subtract(1,"months").format("YYYY-MM-DD"),selection_default_to=moment().format("YYYY-MM-DD")):"weeks"==a?(selection_granularity="week",selection_default_from=moment().subtract(10,"weeks").format("GGGG-[W]WW"),selection_default_to=moment().format("GGGG-[W]WW")):"months"==a?(selection_granularity="month",selection_default_from=moment().subtract(12,"months").format("YYYY-MM"),selection_default_to=moment().format("YYYY-MM")):(selection_granularity="year",selection_default_from=moment().subtract(1,"years").format("YYYY"),selection_default_to=moment().format("YYYY"))}else $("#filter_granularity_div").addClass("hidden"),selection_granularity="day",selection_default_from=moment().subtract(1,"months").format("YYYY-MM-DD"),selection_default_to=moment().subtract(1,"days").format("YYYY-MM-DD");$("#filter_from_"+selection_granularity).val(selection_default_from),$("#filter_to_"+selection_granularity).val(selection_default_to),$("div[id^='filter_group_"+selection_granularity+"']").removeClass("hidden"),e&&$("div[id^='filter_group_driver_id']").removeClass("hidden")}function filter_get(){var t=$("#filter_granularity").val(),e=$("#filter_driver_id").val();""==e&&(e=!1);return"hours"==t?(first_period_start=moment($("#filter_from_day").val(),"YYYY-MM-DD").startOf("day"),last_period_start=moment($("#filter_to_day").val(),"YYYY-MM-DD").startOf("day").add(23,"hours")):"days"==t?(first_period_start=moment($("#filter_from_day").val(),"YYYY-MM-DD").startOf("day"),last_period_start=moment($("#filter_to_day").val(),"YYYY-MM-DD").startOf("day")):"weeks"==t?(first_period_start=moment($("#filter_from_week").val(),"GGGG-[W]WW").startOf("isoWeek"),last_period_start=moment($("#filter_to_week").val(),"GGGG-[W]WW").startOf("isoWeek")):"months"==t?(first_period_start=moment($("#filter_from_month").val(),"YYYY-MM").startOf("month"),last_period_start=moment($("#filter_to_month").val(),"YYYY-MM").startOf("month")):"years"==t&&(first_period_start=moment($("#filter_from_year").val(),"YYYY").startOf("year"),last_period_start=moment($("#filter_to_year").val(),"YYYY").startOf("year")),{first_period_start:first_period_start,last_period_start:last_period_start,grouping:t,driver_id:e}} var reporting_graphs=[];reporting_graphs.clients={series:[],grouping:"days",load:function(e,r,t,i){this.series=graph_make_time_grid_and_fill_with_data(e,r,t,i,this.seriesRowFormatter,this.seriesNames.length),this.grouping=r},seriesNames:["Registered clients","Active clients"],seriesRowFormatter:function(e){return[moment(e.period_start).unix(),e.registrationsCumulative,e.activationsCumulative]},xAxisFormatter:function(){return graph_time_xaxis_for_grouping(this.grouping)},yAxisFormatter:function(e){return e.toFixed(0)},graphType:function(){return this.series[0].length<=15?"clusteredBar":"line"}},reporting_graphs.clients_mutations={series:[],grouping:"days",load:function(e,r,t,i){this.series=graph_make_time_grid_and_fill_with_data(e,r,t,i,this.seriesRowFormatter,this.seriesNames.length),this.grouping=r},seriesNames:["Registrations","Activated clients","Deativated clients"],seriesRowFormatter:function(e){return[moment(e.period_start).unix(),e.registrations,e.activations,e.deactivations]},xAxisFormatter:function(){return graph_time_xaxis_for_grouping(this.grouping)},yAxisFormatter:function(e){return e.toFixed(0)},graphType:function(){return this.series[0].length<=15?"clusteredBar":"line"}},reporting_graphs.completed_trips={series:[],grouping:"days",load:function(e,r,t,i){this.series=graph_make_time_grid_and_fill_with_data(e,r,t,i,this.seriesRowFormatter,this.seriesNames.length),this.grouping=r},seriesNames:["Completed trips"],seriesRowFormatter:function(e){return[moment(e.period_start).unix(),e.completedTrips]},xAxisFormatter:function(){return graph_time_xaxis_for_grouping(this.grouping)},yAxisFormatter:function(e){return e.toFixed(0)},graphType:function(){return this.series[0].length<=15?"clusteredBar":"line"}},reporting_graphs.drivers_active={series:[],grouping:"days",load:function(e,r,t,i){this.series=graph_make_time_grid_and_fill_with_data(e,r,t,i,this.seriesRowFormatter,this.seriesNames.length),this.grouping=r},seriesNames:["Drivers active [#]"],seriesRowFormatter:function(e){return[moment(e.period_start).unix(),e.minutes_active/60/(moment(e.period_end).unix()-moment(e.period_start).unix())*3600]},xAxisFormatter:function(){return graph_time_xaxis_for_grouping(this.grouping)},yAxisFormatter:function(e){return e.toFixed(2)},graphType:function(){return this.series[0].length<=15?"clusteredBar":"line"}},reporting_graphs.trips_and_shiftminutes={series:[],grouping:"days",load:function(e,r,t,i){this.series=graph_make_time_grid_and_fill_with_data(e,r,t,i,this.seriesRowFormatter,this.seriesNames.length),this.grouping=r},seriesNames:["Trips/Driver hour [#]"],seriesRowFormatter:function(e){return 0==e.minutes_active?val=NaN:val=e.completed_trips/e.minutes_active*60,[moment(e.period_start).unix(),val]},xAxisFormatter:function(){return graph_time_xaxis_for_grouping(this.grouping)},yAxisFormatter:function(e){return e.toFixed(1)},graphType:function(){return this.series[0].length<=15?"clusteredBar":"line"}},reporting_graphs.tripfare_and_shiftminutes={series:[],grouping:"days",load:function(e,r,t,i){this.series=graph_make_time_grid_and_fill_with_data(e,r,t,i,this.seriesRowFormatter,this.seriesNames.length),this.grouping=r},seriesNames:["Gross fare/Driver hour"],seriesRowFormatter:function(e){return 0==e.minutes_active?val=NaN:val=e.gross_fare_completed_trips/e.minutes_active*60,[moment(e.period_start).unix(),val]},xAxisFormatter:function(){return graph_time_xaxis_for_grouping(this.grouping)},yAxisFormatter:function(e){return e.toFixed(2)},graphType:function(){return this.series[0].length<=15?"clusteredBar":"line"}},reporting_graphs.utilization={series:[],grouping:"days",load:function(e,r,t,i){this.series=graph_make_time_grid_and_fill_with_data(e,r,t,i,this.seriesRowFormatter,this.seriesNames.length),this.grouping=r},seriesNames:["Utilization (seats filled/hour) [#]"],seriesRowFormatter:function(e){return 0==e.successful_trip_count?val=NaN:val=e.successful_trip_passenger_load/e.minutes_active,[moment(e.period_start).unix(),val]},xAxisFormatter:function(){return graph_time_xaxis_for_grouping(this.grouping)},yAxisFormatter:function(e){return e.toFixed(1)},graphType:function(){return this.series[0].length<=15?"clusteredBar":"line"}},reporting_graphs.driver_rejects={series:[],grouping:"days",load:function(e,r,t,i){this.series=graph_make_time_grid_and_fill_with_data(e,r,t,i,this.seriesRowFormatter,this.seriesNames.length),this.grouping=r},seriesNames:["Rejections by drivers [% of offered rides]"],seriesRowFormatter:function(e){return e.accept_count+e.reject_count==0?val=NaN:val=e.reject_count/(e.accept_count+e.reject_count),[moment(e.period_start).unix(),val]},xAxisFormatter:function(){return graph_time_xaxis_for_grouping(this.grouping)},yAxisFormatter:function(e){return(100*e).toFixed(0)+"%"},graphType:function(){return this.series[0].length<=15?"clusteredBar":"line"}},reporting_graphs.tripstatus_split={series:[],grouping:"days",load:function(e,r,t,i){this.series=graph_make_time_grid_and_fill_with_data(e,r,t,i,this.seriesRowFormatter,this.seriesNames.length),this.grouping=r},seriesNames:["creditCardFailed","driverCancelledBecauseOfDriver","customerArrived","tripDeclined","customerCancelled","driverCancelledBecauseOfClient"],seriesRowFormatter:function(e){var r=e.creditCardFailed+e.driverCancelledBecauseOfDriver+e.customerArrived+e.tripDeclined+e.customerCancelled+e.driverCancelledBecauseOfClient;return r>0?[moment(e.period_start).unix(),e.creditCardFailed/r,e.driverCancelledBecauseOfDriver/r,e.customerArrived/r,e.tripDeclined/r,e.customerCancelled/r,e.driverCancelledBecauseOfClient/r]:[moment(e.period_start).unix(),NaN,NaN,NaN,NaN,NaN,NaN]},xAxisFormatter:function(){return graph_time_xaxis_for_grouping(this.grouping)},yAxisFormatter:function(e){return(100*e).toFixed(0)+"%"},graphType:function(){return this.series[0].length<=15?"clusteredBar":"line"}},reporting_graphs.acceptance_time={series:[],grouping:"days",load:function(e,r,t,i){this.series=graph_make_time_grid_and_fill_with_data(e,r,t,i,this.seriesRowFormatter,this.seriesNames.length),this.grouping=r},seriesNames:["Average","P10","P90"],seriesRowFormatter:function(e){if(0==e.population)var r=NaN;else var r=e.react_avg;if(e.population<10)var t=NaN,i=NaN;else var t=e.react_p1,i=e.react_p9;return[moment(e.period_start).unix(),r,t,i]},xAxisFormatter:function(){return graph_time_xaxis_for_grouping(this.grouping)},yAxisFormatter:function(e){return e.toFixed(0)},graphType:function(){return this.series[0].length<=15?"clusteredBar":"line"}},reporting_graphs.punctuality_pickup={series:[],grouping:"days",load:function(e,r,t,i){this.series=graph_make_time_grid_and_fill_with_data(e,r,t,i,this.seriesRowFormatter,this.seriesNames.length),this.grouping=r},seriesNames:["On time"],seriesRowFormatter:function(e){var r=e.on_time_pickup+e.late_pickup;return r>0?[moment(e.period_start).unix(),e.on_time_pickup/r]:[moment(e.period_start).unix(),NaN]},xAxisFormatter:function(){return graph_time_xaxis_for_grouping(this.grouping)},yAxisFormatter:function(e){return(100*e).toFixed(0)+"%"},graphType:function(){return this.series[0].length<=15?"clusteredBar":"line"}},reporting_graphs.punctuality_delivery={series:[],grouping:"days",load:function(e,r,t,i){this.series=graph_make_time_grid_and_fill_with_data(e,r,t,i,this.seriesRowFormatter,this.seriesNames.length),this.grouping=r},seriesNames:["On time"],seriesRowFormatter:function(e){var r=e.on_time_delivery+e.late_delivery;return r>0?[moment(e.period_start).unix(),e.on_time_delivery/r]:[moment(e.period_start).unix(),NaN]},xAxisFormatter:function(){return graph_time_xaxis_for_grouping(this.grouping)},yAxisFormatter:function(e){return(100*e).toFixed(0)+"%"},graphType:function(){return this.series[0].length<=15?"clusteredBar":"line"}},reporting_graphs.trip_rating={series:[],grouping:"days",load:function(e,r,t,i){this.series=graph_make_time_grid_and_fill_with_data(e,r,t,i,this.seriesRowFormatter,this.seriesNames.length),this.grouping=r},seriesNames:["Average"],seriesRowFormatter:function(e){return e.rated_trip_count>0?[moment(e.period_start).unix(),e.rated_trip_avg_rating]:[moment(e.period_start).unix(),NaN]},xAxisFormatter:function(){return graph_time_xaxis_for_grouping(this.grouping)},yAxisFormatter:function(e){return e.toFixed(2)},graphType:function(){return this.series[0].length<=15?"clusteredBar":"line"}}; function reporting_query_load(e,r){if($("#filter_div").addClass("hidden"),void 0===e)var t="SELECT TABLE_NAME FROM INFORMATION_SCHEMA.Tables";else var t=e;return void 0===r||"bi"!=r?$("#query_radio_backend").prop("checked",!0):$("#query_radio_bi").prop("checked",!0),$("#content").html(Templates.reporting_query({query:t,user:adminPanel.abelKit._admin.get(),contracts:adminPanel.abelKit._admin.get("contracts").data,selectedContract:adminPanel.abelKit._admin.get("contracts").getActive()})),resetLinkListener(),!0}function reporting_query_submit(){query=$("#queryTextArea").val(),$("#query_radio_backend").prop("checked")?server="Backend":server="Bi",$.ajaxWrapper("Query/"+server,"POST",{Query:query},!0,{success:function(e){returnhtml=reporting_query_generate_table(e.return),$("#queryReturnTable").html(returnhtml);var r=create_csv_link("#queryReturnTable");r.innerHTML="(CSV)",$("#query_csv_export").html(r),$("#queryReturnDiv").removeClass("hidden"),$.bootstrapSortable({sign:"arrow reversed"})},error:function(e,r,t){$("#queryReturnDiv").addClass("hidden")}})}function reporting_query_generate_table(e){if($.isArray(e)&&e.length>0){returnhtml="",$.each(e[0],function(e,r){returnhtml+=""+e+""}),returnhtml+="";for(var r=0;r",$.each(e[r],function(e,r){returnhtml+=""+r+""}),returnhtml+="";return returnhtml+="",returnhtml}return""}var reporting_query_csv=[]; //# sourceMappingURL=maps/app_old.js.map