(window["webpackJsonp"]=window["webpackJsonp"]||[]).push([["chunk-ffb2206e"],{"08a2":function(t,e,a){"use strict";a("6cdc")},"14f1":function(t,e,a){"use strict";a("ee57")},"2c4a":function(t,e,a){"use strict";a("8cf5")},"54b1":function(t,e,a){"use strict";a.r(e);var s=function(){var t=this,e=t.$createElement,a=t._self._c||e;return a("div",{staticClass:"overview"},[a("overview-exports"),a("overview-stats",{staticClass:"mt-5"})],1)},n=[],r=(a("caad"),a("2532"),function(){var t=this,e=t.$createElement,a=t._self._c||e;return a("section",[a("h1",{staticClass:"section-header"},[t._v("Export")]),a("div",{staticClass:"row mt-3"},[a("div",{staticClass:"col-md-6"},[a("monthly-report",{attrs:{title:"Körjournal",type:"drivelog"}})],1),a("div",{staticClass:"col-md-6"},[a("monthly-report",{attrs:{title:"Fordon",type:"vehicles"}})],1)])])}),i=[],o=function(){var t=this,e=t.$createElement,a=t._self._c||e;return a("article",{staticClass:"export box box--outline"},[a("div",{staticClass:"export__label"},[t._v(" "+t._s(t.title)+" ")]),a("div",{staticClass:"export__actions d-flex mt-3"},[a("date-picker",{staticClass:"mt-2",staticStyle:{width:"100%"},attrs:{"range-separator":" - ",range:"",type:"date",valueType:"format"},model:{value:t.timespan,callback:function(e){t.timespan=e},expression:"timespan"}}),a("app-button",{staticClass:"btn--transparent mt-2",attrs:{icon:"excel-outline"},on:{click:t.getReports}},[t._v("Excel")])],1)])},c=[],l=a("1da1"),u=(a("96cf"),a("a15b"),a("d3b7"),a("3ca3"),a("ddb0"),a("2b3d"),a("19c8")),p=a("5c40"),d=a("ec45"),m=a("c1df"),v=a.n(m),f=(a("99af"),a("bc3a")),h=a.n(f),b={getStats:function(){return h.a.get("/dashboard/stats")},getReports:function(t,e){return h.a.get("/reports/".concat(t,"/excel?dateFrom=").concat(e[0],"&dateTo=").concat(e[1]),{responseType:"blob"})}},g={props:["title","type"],components:{AppButton:p["a"],InputField:u["a"],DatePicker:d["default"]},data:function(){return{timespan:["2021-05-07","2021-05-20"]}},methods:{getReports:function(){var t=this;return Object(l["a"])(regeneratorRuntime.mark((function e(){var a,s;return regeneratorRuntime.wrap((function(e){while(1)switch(e.prev=e.next){case 0:return e.prev=0,e.next=3,b.getReports(t.type,t.timespan);case 3:a=e.sent,s="drivelog"===t.type?"Körjournal "+t.timespan.join("__"):"Fordonsexport "+t.timespan.join("__"),t.downloadExel(a,s),e.next=10;break;case 8:e.prev=8,e.t0=e["catch"](0);case 10:case"end":return e.stop()}}),e,null,[[0,8]])})))()},downloadExel:function(t,e){var a=new Blob([t],{type:"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"}),s=URL.createObjectURL(a),n=document.createElement("a");n.href=s,n.setAttribute("download",e),document.body.appendChild(n),n.click()}},created:function(){var t=new Date,e=v()(t).subtract(7,"d").format("YYYY-MM-DD"),a=v()(t).format("YYYY-MM-DD");this.timespan=[e,a]}},_=g,y=(a("aa71"),a("2877")),w=Object(y["a"])(_,o,c,!1,null,"299e4722",null),x=w.exports,C={components:{MonthlyReport:x}},M=C,j=Object(y["a"])(M,r,i,!1,null,"582b853a",null),k=j.exports,E=function(){var t=this,e=t.$createElement,a=t._self._c||e;return a("section",{staticClass:"overview-stats"},[a("h1",{staticClass:"section-header mb-4"},[t._v("Statistik")]),a("div",{staticClass:"box box--gray items"},[a("stats-card",{attrs:{options:t.stats.brand,type:"Märken"}}),a("stats-card",{attrs:{options:t.stats.fuel,type:"Drivmedel"}}),a("stats-card",{attrs:{options:t.stats.mileage,type:"Körningar"}})],1)])},R=[],T=(a("d81d"),function(){var t=this,e=t.$createElement,a=t._self._c||e;return a("div",{staticClass:"box box--white stat"},[a("h3",{staticClass:"stat-title"},[t._v(t._s(t.type))]),a("div",{staticClass:"mt-4"},t._l(t.options.slice(0,4),(function(e,s){return a("div",{key:s,staticClass:"stat-item"},[a("div",{staticClass:"value"},[t._v(t._s(e.name)+" "),a("b",[t._v(t._s(e.value)+"%")])]),a("div",{staticClass:"progress"},[a("div",{staticClass:"progress--active",style:{width:e.value+"%"}})])])})),0)])}),S=[],A={props:{type:String,options:Array}},B=A,O=(a("08a2"),Object(y["a"])(B,T,S,!1,null,"f1e80b2a",null)),D=O.exports,I={components:{StatsCard:D},data:function(){return{stats:{brand:[],fuel:[],mileage:[]}}},methods:{sortItems:function(t,e){return e.value-t.value},mapStats:function(t){var e=this;return function(a){return{name:e.mapTripTypeName(a[t]),value:Math.round(a.percentage)}}},mapTripTypeName:function(t){return"business"===t?"Tjänst":"private"===t?"Privat":t}},created:function(){var t=this;return Object(l["a"])(regeneratorRuntime.mark((function e(){var a;return regeneratorRuntime.wrap((function(e){while(1)switch(e.prev=e.next){case 0:return e.prev=0,e.next=3,b.getStats();case 3:a=e.sent,t.stats.brand=a.vehicleBrandPercentage.stats.map(t.mapStats("brand")).sort(t.sortItems),t.stats.fuel=a.vehicleFuelTypePercentage.stats.map(t.mapStats("fuelType")).sort(t.sortItems),t.stats.mileage=a.mileageByTripCategoryPercentage.stats.map(t.mapStats("category")).sort(t.sortItems),e.next=12;break;case 9:e.prev=9,e.t0=e["catch"](0),console.log(e.t0);case 12:case"end":return e.stop()}}),e,null,[[0,9]])})))()}},$=I,Y=(a("f67a"),Object(y["a"])($,E,R,!1,null,"1bd531f7",null)),F=Y.exports,P=function(){var t=this,e=t.$createElement,a=t._self._c||e;return a("div",{staticClass:"event-log"},[a("h1",{staticClass:"section-header mb-4"},[t._v("Händelser")]),a("div",{staticClass:"box box--outline",staticStyle:{position:"relative",overflow:"hidden"}},[a("app-table",{attrs:{head:t.head}},t._l(t.logs,(function(e,s){return a("tr",{key:s},[a("td",["alert"===e.type?a("alert-icon"):t._e(),"warning"===e.type?a("warning-icon"):t._e()],1),a("td",[t._v(t._s(e.vehicle))]),a("td",[t._v(t._s(e.message))]),a("td",[t._v(t._s(e.time))])])})),0),a("div",{staticClass:"load-more-overlay"},[a("app-button",{staticClass:"btn--blue"},[t._v("Show all")])],1)],1)])},U=[],L=a("aca0"),W=a("3fde"),N=a.n(W),K=a("f192"),H=a.n(K),J={components:{AppButton:p["a"],AppTable:L["a"],AlertIcon:N.a,WarningIcon:H.a},data:function(){return{head:[{name:"",width:5},{name:"Fordon",width:20},{name:"Händelse",width:55},{name:"Tidpunkt",width:35}],logs:[{type:"alert",vehicle:"BMW M5 (ABC 123)",message:"Tappat anslutning",time:"28 March 14:49"},{type:"warning",vehicle:"BMW M5 (ABC 123)",message:"Utanför säkerhetszon",time:"28 March 14:49"},{type:"alert",vehicle:"BMW M5 (ABC 123)",message:"Tappat anslutning",time:"28 March 14:49"},{type:"warning",vehicle:"BMW M5 (ABC 123)",message:"Tappat anslutning",time:"28 March 14:49"}]}}},z=J,q=(a("14f1"),Object(y["a"])(z,P,U,!1,null,"2c5e825c",null)),G=q.exports,Q=a("1fc2"),V={components:{EventLog:G,OverviewStats:F,OverviewExports:k},mounted:function(){},created:function(){(this.$store.getters.getUserRoles.includes(Q["c"].RESELLER_ADMIN)||this.$store.getters.getUserRoles.includes(Q["c"].SUPER_ADMIN))&&this.$router.push("/companies")}},X=V,Z=(a("2c4a"),Object(y["a"])(X,s,n,!1,null,"2a529f58",null));e["default"]=Z.exports},"6cdc":function(t,e,a){},7020:function(t,e,a){},"8cf5":function(t,e,a){},a15b:function(t,e,a){"use strict";var s=a("23e7"),n=a("44ad"),r=a("fc6a"),i=a("a640"),o=[].join,c=n!=Object,l=i("join",",");s({target:"Array",proto:!0,forced:c||!l},{join:function(t){return o.call(r(this),void 0===t?",":t)}})},aa71:function(t,e,a){"use strict";a("af5c")},af5c:function(t,e,a){},d81d:function(t,e,a){"use strict";var s=a("23e7"),n=a("b727").map,r=a("1dde"),i=r("map");s({target:"Array",proto:!0,forced:!i},{map:function(t){return n(this,t,arguments.length>1?arguments[1]:void 0)}})},ee57:function(t,e,a){},f67a:function(t,e,a){"use strict";a("7020")}}]); //# sourceMappingURL=chunk-ffb2206e.d3b6d57e.js.map