(window["webpackJsonp"]=window["webpackJsonp"]||[]).push([["chunk-4e6e9a16"],{7793: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:"report-records-page"},[a("div",{staticClass:"row"},[a("div",{staticClass:"col-12"},[a("div",{staticClass:"card"},[a("div",{staticClass:"card-body"},[a("div",{staticClass:"row mb-md-4"},[a("div",{staticClass:"col-md-6"},[a("label",{staticClass:"field-label"},[t._v("Date Range")]),a("date-range-picker",{ref:"picker",attrs:{opens:t.filter.opens,"locale-data":{firstDay:1,format:"mmm dd, yyyy"},"min-date":t.filter.minDate,"max-date":t.filter.maxDate,"single-date-picker":t.filter.singleDatePicker,"time-picker":t.filter.timePicker,"time-picker24-hour":t.filter.timePicker24Hour,"show-week-numbers":t.filter.showWeekNumbers,"show-dropdowns":t.filter.showDropdowns,"auto-apply":t.filter.autoApply,"always-show-calendars":t.filter.alwaysShowCalendars,"linked-calendars":t.filter.linkedCalendars,ranges:t.filter.ranges},on:{update:t.filterDateUpdateValues},model:{value:t.filter.dateRange,callback:function(e){t.$set(t.filter,"dateRange",e)},expression:"filter.dateRange"}})],1)]),a("div",{staticClass:"row mb-md-2"},[a("div",{staticClass:"col-sm-12 col-md-6"},[a("div",{staticClass:"dataTables_length"},[a("label",{staticClass:"d-inline-flex align-items-center"},[t._v(" Show "),a("b-form-select",{staticClass:"ml-1 mr-1",attrs:{size:"sm",options:[10,15,25,50,100]},on:{change:t.getRecords},model:{value:t.datatable.queries.per_page,callback:function(e){t.$set(t.datatable.queries,"per_page",e)},expression:"datatable.queries.per_page"}}),t._v(" entries ")],1)])])]),t.loading?a("div",{staticClass:"text-center"},[a("b-spinner")],1):[a("div",{staticClass:"table-responsive mb-0"},[a("b-table",{attrs:{items:t.records,fields:t.datatable.columns,"sort-by":t.datatable.queries.sort_by,"sort-desc":t.datatable.queries.sort_desc,"per-page":t.datatable.queries.per_page,"no-local-sorting":!0},on:{"update:sortBy":function(e){return t.$set(t.datatable.queries,"sort_by",e)},"update:sort-by":function(e){return t.$set(t.datatable.queries,"sort_by",e)},"update:sortDesc":function(e){return t.$set(t.datatable.queries,"sort_desc",e)},"update:sort-desc":function(e){return t.$set(t.datatable.queries,"sort_desc",e)},"sort-changed":t.sortChanged},scopedSlots:t._u([{key:"cell(total)",fn:function(e){return[t._v(" $ "+t._s(e.item.total)+" ")]}},{key:"cell(created_at)",fn:function(e){return[t._v(" "+t._s(t._f("moment")(e.item.created_at,"MM-DD-YYYY hh:mm:ss A"))+" ")]}},{key:"cell(paid)",fn:function(e){return[e.item.paid?a("feather",{staticClass:"icon-dual-success",attrs:{type:"check"}}):t._e()]}},{key:"cell(actions)",fn:function(e){return[a("b-button",{attrs:{variant:"primary",size:"sm",title:"Download Invoice",disabled:t.processing},on:{click:function(a){return t.download(e.item)}}},[t.processing?a("b-spinner",{attrs:{small:""}}):a("i",{staticClass:"uil uil-download-alt"})],1)]}}],null,!1,3818405067)},[a("div",{staticClass:"text-center text-danger my-2"},[a("b-spinner",{staticClass:"align-middle"})],1)])],1),a("div",{staticClass:"row mt-4"},[a("div",{staticClass:"col"},[a("div",{staticClass:"float-left mt-2"},[t._v(" Page "),a("b",[t._v("#"+t._s(t.datatable.queries.pageIndex))])]),a("div",{staticClass:"dataTables_paginate paging_simple_numbers float-right"},[a("button",{staticClass:"ml-1 btn btn-primary btn-sm",attrs:{disabled:t.datatable.queries.pageIndex<=1||t.loading},on:{click:t.onPagePrev}},[a("i",{staticClass:"uil uil-angle-double-left"}),t._v(" Prev ")]),a("button",{staticClass:"ml-1 btn btn-primary btn-sm",attrs:{disabled:t.noData||t.loading},on:{click:t.onPageNext}},[t._v(" Next "),a("i",{staticClass:"uil uil-angle-double-right"})])])])])]],2)])])])])},i=[],r=a("bbf5"),l=a.n(r),n=(a("53b4"),a("7f45")),o=a.n(n),d=a("bc3a"),c=a.n(d),u={components:{DateRangePicker:l.a},data(){return{datatable:{columns:[{key:"id",label:"Invoice Id",sortable:!1},{key:"total",label:"Amount",sortable:!1},{key:"paid",label:"Paid",sortable:!1},{key:"created_at",label:"Created At",sortable:!1},{key:"actions"}],queries:{per_page:10,page:1,pageIndex:1,business_id:null,start_at:null,end_at:null}},records:[],firstId:null,lastId:null,noData:!1,loading:!1,processing:!1,businesses:[],filter:{opens:"right",minDate:null,maxDate:null,singleDatePicker:!1,timePicker:!1,timePicker24Hour:!1,showWeekNumbers:!1,showDropdowns:!1,autoApply:!1,dateRange:{startDate:o()().subtract(30,"days").toDate(),endDate:o()().toDate()},linkedCalendars:!0,ranges:{Today:[o()().toDate(),o()().toDate()],"Last 7 Days":[o()().subtract(7,"days").toDate(),o()().toDate()],"Last 30 Days":[o()().subtract(30,"days").toDate(),o()().toDate()],"This Month":[o()().startOf("month").toDate(),o()().endOf("month").toDate()],"Last Month":[o()().subtract(1,"month").startOf("month").toDate(),o()().subtract(1,"month").endOf("month").toDate()]},alwaysShowCalendars:!0}}},computed:{totalRecords(){return this.records&&this.records.meta?this.records.meta.total:0}},mounted(){this.filterDateUpdateValues(),this.getBusinessOptions()},methods:{download(t){this.processing=!0,c.a.get("/reports/download-invoice/"+t.id).then(t=>{let e=t.data;e.success&&window.open(e.data.url,"_blank"),this.processing=!1}).catch(t=>{this.processing=!1})},onPagePrev(){this.getRecords("prev")},onPageNext(){this.getRecords("next")},filterDateUpdateValues(t){this.datatable.queries.start_at=o()(this.filter.dateRange.startDate).startOf("day").utc().format("YYYY-MM-DD HH:mm:ss"),this.datatable.queries.end_at=o()(this.filter.dateRange.endDate).endOf("day").utc().format("YYYY-MM-DD HH:mm:ss"),this.getRecords()},sortChanged(t){this.datatable.queries.sort_by=t.sortBy,this.datatable.queries.sort_desc=t.sortDesc,this.datatable.queries.page=1,this.getRecords()},onPageChanged(t){this.datatable.queries.page=t,this.getRecords()},onQueryChange(t){this.$nextTick(()=>{"search"===t&&(this.datatable.queries.page=1),this.getRecords()})},getBusinessOptions(){this.$store.dispatch("business/getBusinessOptions").then(t=>{this.businesses=[{name:"All businesses",id:null},...t.map(t=>({name:t.name,id:t.id}))]}).catch(()=>{})},getRecords(t){this.loading=!0;let e=null;"next"===t?e=this.lastId:"prev"===t?e=this.firstId:this.datatable.queries.pageIndex=1;let a={direction:t,obj_id:e,...this.datatable.queries};this.records=[],this.$store.dispatch("report/getBillingHistory",a).then(e=>{this.records=e.data,"next"===t?this.datatable.queries.pageIndex++:"prev"===t&&this.datatable.queries.pageIndex--,0===this.records.length?(this.firstId=this.lastId,this.noData=!0):(this.records.length<this.datatable.queries.per_page?this.noData=!0:this.noData=!1,this.firstId=this.records[0]["id"],this.lastId=this.records[this.records.length-1]["id"]),this.loading=!1}).catch(t=>{this.loading=!1})},refresh(){this.datatable.queries.business_id=null,this.getRecords()}}},h=u,b=(a("e34b"),a("2877")),p=Object(b["a"])(h,s,i,!1,null,"169e0f9e",null);e["default"]=p.exports},c3d6:function(t,e,a){},e34b:function(t,e,a){"use strict";a("c3d6")}}]);
//# sourceMappingURL=chunk-4e6e9a16.dc0bc801.js.map