1import{A as v}from"./AccountMenu-BzJaR-29.js";import{a1 as _,_ as k,o as n,c as l,a as r,F as y,h as p,t as u,u as I,K as P,f as g,A as M,d as f,b as C,a3 as E,a6 as T,r as w}from"./index-6Q7eoBbo.js";import{S as N}from"./Spinner-DScztdnG.js";import{p as D}from"./parseISO-Bx8E0ZNk.js";const A={getCustomers(){return _.get("/admin/commercial-customers")},getSegmentInfos(s){return _.get(`/admin/commercial-customers/segments/?segmentId=${s}`)}},O={props:["customer"]},j={style:{padding:"1em"}},B={style:{display:"flex","justify-content":"space-between"}},L=["href"],R=["href"];function F(s,t,d,b,o,a){return n(),l("div",j,[t[3]||(t[3]=r("h1",null,"Members",-1)),r("div",B,[r("div",null,[t[0]||(t[0]=r("h2",null,"Usernames",-1)),r("ul",null,[(n(!0),l(y,null,p(d.customer.members,(i,c)=>(n(),l("li",{key:c},u(i.username),1))),128))])]),r("div",null,[t[2]||(t[2]=r("h2",null,"Email Addresses",-1)),r("ul",null,[(n(!0),l(y,null,p(d.customer.members,(i,c)=>(n(),l("li",{key:c},[r("a",{href:`mailto:${i.email}`},u(i.email),9,L)]))),128))]),r("a",{href:`mailto:${d.customer.members.map(i=>i.email).filter(i=>i&&i!=="").join(",")}`},[...t[1]||(t[1]=[r("i",{class:"material-icons info-outline-material"},"mail",-1),I(" all ",-1)])],8,R)])])])}const U=k(O,[["render",F]]),$={name:"Customers",components:{Spinner:N,AccountMenu:v},data(){return{mounted:!1,processing:!1,customers:[],editedcustomer:void 0,businessId:void 0,tables:{customers:{columns:[{label:"Customer Group",field:"customerGroupName",filterOptions:{enabled:!0},sortable:!0},{label:"Username",field:"username",filterOptions:{enabled:!0},sortable:!0},{label:"Email",field:"email",filterOptions:{enabled:!0},sortable:!0},{label:"ProAbono Client",field:"proAbonoClient",tdClass:"nowrap",sortable:!0},{label:"ProAbono Email",field:"proAbonoEmail",sortable:!0},{label:"Num. total",field:"numAnalysesTotal",type:"number",sortable:!0},{label:"Num. 30 days",field:"numAnalysesLast30Days",type:"number",sortable:!0},{label:"Num. this month",field:"numAnalysesThisMonth",type:"number",sortable:!0},{label:"Last Accessed",field:"lastAccessed",tdClass:"nowrap",sortable:!0},{label:"Total Csv Consumed",field:"totalCsvConsumed",type:"number",sortable:!0},{label:"Members usernames",field:"membersUsernames",sortable:!1},{label:"Members emails",field:"membersEmails",sortable:!1},{label:"Active",field:"active",filterOptions:{enabled:!0,filterValue:"true",filterDropdownItems:["true","false"]},sortable:!0},{label:"Logo",field:"logo"},{label:"Segment",field:"segment",filterOptions:{enabled:!0},sortable:!0},{label:"Subs. type",field:"subscriptionType",filterOptions:{enabled:!0},sortable:!1},{label:"Subs. date",field:"subscriptionDate",sortable:!1},{label:"Subs. price",field:"subscriptionPrice",sortable:!1},{label:"Subs. status",field:"subscriptionStatus",filterOptions:{enabled:!0},sortable:!1},{label:"Balance",field:"paymentBalance",thClass:"sortable",sortable:!1},{label:"Payment menthod",field:"paymentMethod",sortable:!0},{label:"Payment status",field:"paymentStatus",sortable:!0}],csvColumns:[{label:"Customer Group",field:"customerGroupName"},{label:"Username",field:"username"},{label:"Email",field:"email"},{label:"ProAbono Reference",field:"referenceCustomer"},{label:"ProAbono Client",field:"proAbono",transform:s=>s?s.Name:void 0},{label:"ProAbono Email",field:"proAbono",transform:s=>s?s.Email:void 0},{label:"Num. total",field:"numAnalysesTotal"},{label:"Num. 30 days",field:"numAnalysesLast30Days"},{label:"Num. this month",field:"numAnalysesThisMonth"},{label:"Last Accessed",field:"lastAccessed",type:"date",dateOutputFormat:"YYYY-MM-DD HH:mm:ss"},{label:"Total Csv Consumed",field:"totalCsvConsumed"},{label:"Members usernames",field:"membersUsernames",transform:s=>s&&s.join(",")},{label:"Members emails",field:"membersEmails",transform:s=>s&&s.join(",")},{label:"Active",field:"active"},{label:"Logo",field:"logo"},{label:"Segment",field:"segment"},{label:"Subs. type",field:"subscriptions",transform:s=>s?s.map(t=>t.TitleLocalized).join(","):void 0},{label:"Subs. date",field:"subscriptions",transform:s=>s?s.map(t=>t.DateStart).join(","):void 0},{label:"Subs. price",field:"subscriptions",transform:s=>s?'"'+s.map(t=>t.AmountRecurrence).join(",")+'"':void 0},{label:"Subs. status",field:"subscriptions",transform:s=>s?s.map(t=>t.StateSubscription).join(","):void 0},{label:"Balance",field:"paymentBalance"},{label:"Payment menthod",field:"paymentMethod"},{label:"Payment status",field:"paymentStatus"}]}}}},computed:{},mounted(){this.mounted=!0,this.reloadCustomers()},methods:{dateString(s){return s?T(D(s),"yyyy-MM-dd HH:mm:ss"):""},numberFormat:P,reloadCustomers(){this.processing=!0,A.getCustomers().then(s=>{this.processing=!1,s.data.forEach(t=>{t.proAbono=void 0,t.subscriptions=void 0,t.balance=void 0,t.lastPayment=void 0}),this.customers=s.data,this.loadProAbonoInfos()}).catch(s=>{console.log(s),this.processing=!1})},loadProAbonoInfos(){let s=[...new Set(this.customers.map(t=>t.segmentId))];
1this.processing=!0,s.forEach(t=>A.getSegmentInfos(t).then(d=>{this.processing=!1;let b=d.data;this.businessId=d.data.businessId,this.customers.filter(o=>o.referenceCustomer).forEach(o=>{let a=b.customers.Items.find(i=>i.ReferenceCustomer===o.referenceCustomer);if(a){o.proAbono=a;let i=b.subscriptions.Items.filter(c=>o.proAbono.Id===c.IdCustomer);o.subscriptions=i,o.balance=b.balances&&b.balances[o.proAbono.Id],o.lastPayment=b.lastPayments&&b.lastPayments.find(c=>o.proAbono.Id===c.IdCustomer)}})}).catch(d=>{console.log(d),this.processing=!1}))},downloadCsv(){function s(){function o(i){return(i<10?"0":"")+i}var a=new Date;return""+a.getFullYear()+o(a.getMonth()+1)+o(a.getDate())+"-"+o(a.getHours())+o(a.getMinutes())}let t=this.tables.customers.csvColumns.map(o=>o.label).join(";")+` 2`;t+=this.$refs.commercialTable.filteredRows[0].children.map(o=>this.tables.customers.csvColumns.map(a=>a.transform===void 0?o[a.field]:a.transform(o[a.field])).join(";")).join(` 3`),console.log("data",this.$refs.commercialTable.filteredRows[0].children),console.log("csv",t);let d=new Blob([t]),b="commercial-"+s()+".csv";if(window.navigator.msSaveOrOpenBlob)window.navigator.msSaveOrOpenBlob(d,b);else{const o=(window.URL||window.webkitURL).createObjectURL(d),a=document.createElement("a");a.href=o,a.setAttribute("download",b),document.body.appendChild(a),a.click()}},showMembers(s){this.$modal.show(U,{customer:s},{height:"auto",scrollable:!0})}}},x={class:"page-content--inner customers--main"},G={key:0,class:"multivalue-column"},V=["href"],H={class:"secondary-column-value"},Y=["href"],z={key:1},q={key:2,class:"multivalue-column"},K=["href"],X={key:3,class:"multivalue-column"},J={key:4,class:"multivalue-column"},Q={key:5,class:"multivalue-column"},W={key:6},Z=["onClick"],ee={key:7},te=["onClick"],se={style:{display:"none"}},oe={key:8},ne=["href"],le={key:9},ae=["href"],re={key:10},ie=["href"],me={key:11},ue={key:12},de={key:13};function be(s,t,d,b,o,a){const i=w("vue-good-table"),c=w("spinner"),S=w("account-menu");return n(),l("div",x,[t[6]||(t[6]=r("h1",null,"Gestion des utilisateurs commercial",-1)),r("button",{title:"Refresh data",onClick:t[0]||(t[0]=e=>a.loadProAbonoInfos())},[...t[2]||(t[2]=[r("i",{class:"material-icons info-outline-material"},"refresh",-1)])]),r("button",{title:"Download current selection as CSV",onClick:t[1]||(t[1]=e=>a.downloadCsv())},[...t[3]||(t[3]=[r("i",{class:"material-icons info-outline-material"},"cloud_download",-1)])]),g(i,{id:"customers",ref:"commercialTable",columns:o.tables.customers.columns,rows:o.customers,"style-class":"vgt-table striped","sort-options":{enabled:!1,initialSortBy:{field:"customerGroupName",type:"asc"}}},{"table-row":M(e=>[e.column.field=="proAbonoClient"&&e.row.proAbono?(n(),l("span",G,[r("span",null,[o.businessId?(n(),l("a",{key:0,href:`https://via.proabono.com/App/${o.businessId}/Sub/Customer/${e.row.proAbono.Id}`,target:"_blank"},u(e.row.proAbono.Name),9,V)):f("",!0)]),r("span",H,[o.businessId?(n(),l("a",{key:0,href:`https://via.proabono.com/App/${o.businessId}/Sub/Customer/${e.row.proAbono.Id}`,target:"_blank"},u(e.row.referenceCustomer),9,Y)):f("",!0)])])):e.column.field=="proAbonoEmail"&&e.row.proAbono?(n(),l("span",z,u(e.row.proAbono.Email),1)):e.column.field=="subscriptionType"&&e.row.subscriptions?(n(),l("span",q,[(n(!0),l(y,null,p(e.row.subscriptions,(m,h)=>(n(),l("span",{key:h,class:"nowrap"},[o.businessId?(n(),l("a",{key:0,href:`https://via.proabono.com/App/${o.businessId}/Sub/Subscription/${m.Id}`,target:"_blank"},u(m.TitleLocalized),9,K)):f("",!0)]))),128))])):e.column.field=="subscriptionDate"&&e.row.subscriptions?(n(),l("span",X,[(n(!0),l(y,null,p(e.row.subscriptions.map(m=>a.dateString(m.DateStart)),(m,h)=>(n(),l("span",{key:h,class:"nowrap"},u(m),1))),128))])):e.column.field=="subscriptionPrice"&&e.row.subscriptions?(n(),l("span",J,[(n(!0),l(y,null,p(e.row.subscriptions.map(m=>m.AmountRecurrence),(m,h)=>(n(),l("span",{key:h,class:"nowrap"},u(a.numberFormat(m/100)),1))),128))])):e.column.field=="subscriptionStatus"&&e.row.subscriptions?(n(),l("span",Q,[(n(!0),l(y,null,p(e.row.subscriptions.map(m=>m.StateSubscription),(m,h)=>(n(),l("span",{key:h,class:"nowrap"}
3,u(m),1))),128))])):e.column.field=="membersEmails"?(n(),l("span",W,[r("button",{title:"Show emails of members",onClick:m=>a.showMembers(e.row)},[...t[4]||(t[4]=[r("i",{class:"material-icons info-outline-material"},"how_to_vote",-1)])],8,Z)])):e.column.field=="membersUsernames"?(n(),l("span",ee,[r("button",{title:"Show usernames of members",onClick:m=>a.showMembers(e.row)},[...t[5]||(t[5]=[r("i",{class:"material-icons info-outline-material"},"group",-1)])],8,te),r("span",se,u(e.row.members.map(m=>m.username).join(",")),1)])):e.column.field=="paymentBalance"&&e.row.proAbono&&e.row.balance?(n(),l("span",oe,[o.businessId?(n(),l("a",{key:0,href:`https://via.proabono.com/App/${o.businessId}/Finance/Customer/${e.row.proAbono.Id}/Invoicing`,target:"_blank"},u(a.numberFormat(e.row.balance.amountTotalDue/100)),9,ne)):f("",!0)])):e.column.field=="paymentMethod"&&e.row.lastPayment?(n(),l("span",le,[o.businessId?(n(),l("a",{key:0,href:`https://via.proabono.com/App/${o.businessId}/Finance/Customer/${e.row.proAbono.Id}/Payment`,target:"_blank"},u(e.row.lastPayment.TypePayment),9,ae)):f("",!0)])):e.column.field=="paymentStatus"&&e.row.lastPayment?(n(),l("span",re,[o.businessId?(n(),l("a",{key:0,href:`https://via.proabono.com/App/${o.businessId}/Finance/Customer/${e.row.proAbono.Id}/Payment`,target:"_blank"},u(e.row.lastPayment.StatePayment),9,ie)):f("",!0)])):e.column.field=="totalCsvConsumed"&&e.row.totalCsvConsumed?(n(),l("span",me,u(e.row.totalCsvConsumed),1)):e.column.field==="lastAccessed"?(n(),l("span",ue,u(a.dateString(e.formattedRow[e.column.field])),1)):(n(),l("span",de,u(e.formattedRow[e.column.field]),1))]),_:1},8,["columns","rows"]),o.processing?(n(),C(c,{key:0})):f("",!0),o.mounted?(n(),C(E,{key:1,to:"#header-bar"},[g(S)])):f("",!0)])}const pe=k($,[["render",be]]);export{pe as default};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.