import{B as q,p as O,ae as y,ag as x,ah as k,ai as $,r as N,c as o,b as s,t as e,a as S,g as m,i as p,F as f,h as w,s as P,y as C,o as l,d as I}from"./app-CYVHboi-.js";import"./browser-BwNzv7vE.js";const D={class:"border-b border-gray-200 p-4 sm:px-6 dark:border-gray-700 print:hidden"},T={class:"absolute end-8 top-0 flex items-center gap-3 pe-4 pt-4"},B={class:"sr-only"},V={class:"text-base leading-6 font-semibold text-gray-900 dark:text-gray-100"},H={key:0,class:"m-6 flex flex-col gap-4"},F=["src"],L={key:1,class:"text-center text-lg font-bold"},Q={class:"text-center text-lg font-bold"},R={key:0},j={key:1},z={class:"-mx-2"},E={class:"w-full divide-y divide-gray-200 dark:divide-gray-700 print:divide-gray-400 dark:print:divide-gray-400"},M={class:"px-2 py-0.5 text-start"},A={class:"w-10 px-2 py-0.5 text-center"},G={class:"px-2 py-0.5 text-start"},J={key:0,class:"pb-1 text-xs"},K={class:"px-2 py-0.5 text-start"},U={class:"w-10 px-2 py-0.5 text-center"},W={class:"px-2 py-0.5 text-start"},X={key:0,class:"pb-1 text-xs"},Y={class:"w-10 px-2 py-0.5 text-center"},Z={key:1,class:"m-6 flex flex-col gap-4 text-yellow-600"},st={__name:"PrintOrder",props:["form","show","sendPrint","halls"],setup(r){const d=P(),{t:c}=q({}),u=r,_=C(()=>u.halls.find(t=>t.id===u.form.selectedHallId)?.tables||[]);O(()=>{d.props.settings?.print_dialog==1&&setTimeout(v,250)});function v(){if(d.props.settings?.pos_server==1){const t={type:"print-json-order",data:{}};t.data.logo=d.props.opened_register.store.logo||d.props.settings?.logo||"",t.data.heading=d.props.settings?.name,t.data.store_heading=d.props.opened_register.store?.name||"",t.data.store_details={},t.data.store_details.state=d.props.opened_register.store?.state?.name||"",t.data.store_details.country=d.props.opened_register.store?.country?.name||"",t.data.type=c("Order"),t.data.headers=null,t.data.info=[[c("Ref"),u.form.reference],[c("Order No."),u.form.number],[c("Created by"),u.form.user?.name||d.props.auth?.user?.name||""],[c("Printed at"),y(new Date().toISOString(),null,null,!0)]],t.data.table_headers=[{label:c("Description")},{label:c("Qty")}];let i=u.form.items.map(n=>{if(n.variations&&n.variations.length){const h=n.variations.map(b=>({type:"item",name:k(b.meta),qty:x(b.quantity)}));return{variations:[{type:"text",text:n.name+(n.comment?`
`+n.comment:"")},...h]}}else return{type:"item",name:n.name+(n.comment?`
`+n.comment:""),qty:$(n.quantity)}});const g=i.filter(n=>n.variations).map(n=>n.variations),a=i.filter(n=>!n.variations);i=[...g.flat(),...a],t.data.items=[i],t.data.totals=[{label:c("Total Items"),value:Number(u.form.items.length)+" ("+u.form.items.reduce((n,h)=>n+Number(h.quantity),0)+")"}],t.data.footers=null,t.data.notice=null,console.log(t),u.sendPrint(t)}else window.print()}return(t,i)=>{const g=N("Icon");return l(),o("div",null,[s("div",D,[s("div",T,[s("button",{type:"button",onClick:i[0]||(i[0]=a=>v()),class:"focus relative rounded-md text-gray-500 hover:text-gray-700 dark:text-gray-400 dark:hover:text-gray-200"},[i[1]||(i[1]=s("span",{class:"absolute -inset-2.5"},null,-1)),s("span",B,e(t.$t("Print")),1),S(g,{name:"print-o",className:"size-6"})])]),s("div",null,[s("h3",V,e(t.$t("Print Order")),1)])]),r.form.items&&r.form.items.filter(a=>a.quantity).length?(l(),o("div",H,[m(d).props.opened_register.store.logo?(l(),o("img",{key:0,class:"h-8 max-w-[200pc]",src:m(d).props.opened_register.store.logo,alt:"Logo"},null,8,F)):(l(),o("h2",L,e(m(d).props.opened_register.store.name||t.settings.name),1)),s("h2",Q,e(t.$t("Order")),1),s("div",null,[r.form.id?(l(),o("div",R,e(t.$t("Id"))+": "+e(r.form.id),1)):p("",!0),r.form.customer?(l(),o("div",j,e(t.$t("Customer"))+": "+e(r.form.customer?.company||r.form.customer?.name||""),1)):p("",!0),s("div",null,e(t.$t("Order Ref"))+": "+e(r.form.reference),1),s("div",null,e(t.$t("Order Number"))+": "+e(r.form.number),1),s("div",null,e(t.$t("Hall"))+": "+e(r.form.table?.hall?.name||r.halls.find(a=>a.id===r.form.selectedHallId)?.name||""),1),s("div",null,e(t.$t("Table"))+": "+e(r.form.table?.name||_.value.find(a=>a.id===r.form.selectedTableId)?.name||""),1),s("div",null,e(t.$t("Created at"))+": "+e(r.form.created_at?m(y)(r.form.created_at):m(y)(new Date().toISOString(),null,null,!0)),1),s("div",null,e(t.$t("Created  by"))+": "+e(r.form.user?.name||m(d).props.auth?.user?.name||""),1)]),s("div",z,[s("table",E,[s("thead",null,[s("tr",null,[s("th",M,e(t.$t("Description")),1),s("th",A,e(t.$t("Qty")),1)])]),(l(!0),o(f,null,w(r.form.items,a=>(l(),o(f,null,[a.variations&&a.variations.length?(l(),o("tbody",{key:a.id},[s("tr",null,[s("td",G,[I(e(a.name)+" ",1),a.comment?(l(),o("div",J,e(a.comment),1)):p("",!0)]),i[2]||(i[2]=s("td",{class:"w-10 px-2 py-0.5 text-center"},null,-1))]),(l(!0),o(f,null,w(a.variations,n=>(l(),o("tr",{key:n.id},[s("td",K,e(m(k)(n.meta)),1),s("td",U,e(m(x)(n.quantity)),1)]))),128))])):(l(),o(f,{key:1},[a.quantity>0?(l(),o("tbody",{key:a.id+"_"},[s("tr",null,[s("td",W,[I(e(a.name)+" ",1),a.comment?(l(),o("div",X,e(a.comment),1)):p("",!0)]),s("td",Y,e(m($)(a.quantity)),1)])])):p("",!0)],64))],64))),256))])]),s("div",null,[s("div",null,e(t.$t("Sent at"))+": "+e(m(y)(new Date().toISOString(),null,null,!0)),1),s("div",null,e(t.$t("Sent by"))+": "+e(m(d).props.auth?.user?.name||""),1)])])):(l(),o("div",Z,e(t.$t("Please add at least one item to form.")),1))])}}};export{st as default};
