import{w as j,j as l}from"./index-c5c88b67.js";import{D as M,P as H,a as e,b as _,V as c,T as s,c as v}from"./index-669f61e9.js";const I=n=>{const h=Math.ceil(n.length/2);return[n.slice(0,h),n.slice(h)]};function P({materialRequestData:n,companyData:h,locationData:t,authorizationData:o}){var b,f,C,i;const p=[{label:"Doc No:",value:n==null?void 0:n.code},{label:"Date:",value:j(n==null?void 0:n.date).format("DD-MM-YYYY")},{label:"Location:",value:(b=n==null?void 0:n.location)==null?void 0:b.name},{label:"Remarks:",value:n==null?void 0:n.description}],[Y,w]=I(p);return l.jsx(M,{children:l.jsxs(H,{size:"A4",style:e.body,children:[l.jsx(_,{companyData:h,locationData:t}),l.jsx(c,{style:[e.bid,{marginTop:30}],children:l.jsx(s,{style:e.content,children:"Material Request"})}),l.jsx(c,{style:e.tablefeilds,children:l.jsxs(c,{style:e.tableRow,children:[l.jsx(c,{style:e.column,children:Y.map((d,x)=>l.jsxs(c,{style:e.itemRow,children:[l.jsx(s,{style:e.labelCell,children:d.label}),l.jsx(s,{style:e.valueCell,children:d.value})]},`left-${x}`))}),l.jsx(c,{style:e.column,children:w.map((d,x)=>l.jsxs(c,{style:e.itemRow,children:[l.jsx(s,{style:e.labelCell,children:d.label}),l.jsx(s,{style:e.valueCell,children:d.value})]},`right-${x}`))})]})}),l.jsxs(c,{style:e.table,children:[l.jsxs(c,{style:e.tableRow,children:[l.jsx(s,{style:[e.tableCellHeader,{flex:.5}],children:"SI No"}),l.jsx(s,{style:[e.tableCellHeader,{flex:2}],children:"Item"}),l.jsx(s,{style:[e.tableCellHeader,{flex:2}],children:"Quantity"}),l.jsx(s,{style:[e.tableCellHeader,{flex:1}],children:"Unit"}),l.jsx(s,{style:[e.tableCellHeader,{flex:2}],children:"Required Date"})]}),(f=n==null?void 0:n.mr_items)==null?void 0:f.slice(0,10).map((d,x)=>{var r,y;return l.jsxs(c,{style:e.tableRow,wrap:!1,children:[l.jsx(s,{style:[e.tableCell,{flex:.5}],children:x+1}),l.jsx(s,{style:[e.tableCell,{flex:2}],children:(r=d.item)==null?void 0:r.name}),l.jsx(s,{style:[e.tableCell,{flex:2}],children:parseInt(d.qty)}),l.jsx(s,{style:[e.tableCell,{flex:1}],children:(y=d.unit)==null?void 0:y.name}),l.jsx(s,{style:[e.tableCell,{flex:2}],children:d!=null&&d.required_date?j(d.required_date).format("DD-MM-YYYY"):"N/A"})]},x)})]}),((C=n==null?void 0:n.mr_items)==null?void 0:C.length)>10&&l.jsx(c,{style:e.table,break:!0,children:(i=n==null?void 0:n.mr_items)==null?void 0:i.slice(10).map((d,x)=>{var r,y;return l.jsxs(c,{style:e.tableRow,wrap:!1,children:[l.jsx(s,{style:[e.tableCell,{flex:.5}],children:x+11}),l.jsx(s,{style:[e.tableCell,{flex:2}],children:(r=d.item)==null?void 0:r.name}),l.jsx(s,{style:[e.tableCell,{flex:2}],children:parseInt(d.qty)}),l.jsx(s,{style:[e.tableCell,{flex:1}],children:(y=d.unit)==null?void 0:y.name}),l.jsx(s,{style:[e.tableCell,{flex:2}],children:d!=null&&d.required_date?j(d.required_date).format("DD-MM-YYYY"):"N/A"})]},x+10)})}),l.jsxs(c,{style:e.table,children:[l.jsxs(c,{style:e.tableRow,children:[l.jsx(s,{style:[e.tableCellHeader,{flex:.5}],children:"SI No"}),l.jsx(s,{style:[e.tableCellHeader,{flex:.5}],children:"Level"}),l.jsx(s,{style:[e.tableCellHeader,{flex:2}],children:"Authorization By"}),l.jsx(s,{style:[e.tableCellHeader,{flex:2}],children:"Status"}),l.jsx(s,{style:[e.tableCellHeader,{flex:2}],children:"Authorized On"})]}),o==null?void 0:o.map((d,x)=>{var r;return l.jsxs(c,{style:e.tableRow,wrap:!1,children:[l.jsx(s,{style:[e.tableCell,{flex:.5}],children:x+1},x),l.jsx(s,{style:[e.tableCell,{flex:.5}],children:d.authorized_level},x),l.jsx(s,{style:[e.tableCell,{flex:2}],children:(r=d.authorized_by)==null?void 0:r.username},x),l.jsx(s,{style:[e.tableCell,{flex:2}],children:d.authorized_status_name},x),l.jsxs(s,{style:[e.tableCell,{flex:2}],children:[" ",j(d.authorized_on).format("DD-MM-YYYY - HH:mm:ss")]},x)]})})]}),l.jsx(v,{companyData:h,selectedData:n})]})})}export{P as M};
