Files
Rasadyar_FrontEnd/build/assets/ProvinceRequests-uW1-xNKR.js
2026-01-19 16:15:09 +03:30

2 lines
158 KiB
JavaScript
Raw Blame History

This file contains invisible Unicode characters
This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import{j as u,aL as we,aM as Pe,T as H,aN as Oe,aO as I6,aP as z6,aQ as R6,aR as B6,aS as U6,aT as W6,ak as U,B as W,p as u0,I as xu,aJ as F0,d as Lu,i as e0,am as Me,ag as k0,av as T0,aw as N0,ax as Tu,aU as $e,aV as Y6,aW as Eu,aX as X0,aY as Ie,a9 as V6,aZ as ze,a_ as Re,a$ as Be,b0 as y0,b1 as Ue,b as K6,al as Hu,an as Q6,ao as We,ap as s0,aq as o0,b2 as g0,b3 as Nu,b4 as d0,ar as Ye}from"./mui-vendor-CkIVaoQP.js";import{G as o,S as w,R as w0,w as P0,x as O0,y as b6,z as Ju,B as M0,D as H6,E as $0,F as I0,k as Ve,H as z0,I as R0,O as wu,P as G6,J as S6,K as A0,j as J,A as su,u as ku,c as Iu,M as gu,m as X6,L as q,N as bu,h as V,C as Yu,Q as qu,T as J0,U as Ke,p as pu,v as ou,V as i0,W as yu,X as tu,Y as Qu,Z as _6,_ as Zu,r as n0,$ as v0,a0 as J6,b as $u,a1 as Qe,a2 as p0,a3 as He,a4 as C0,a5 as Z6,a6 as Ge,a7 as q6,a8 as Xe,a9 as c0,aa as Je,ab as Ze,ac as a0,ad as qe,ae as h0,af as me,n as Z0,o as q0,t as m0,ag as B0,ah as U0,ai as W0,aj as D6,ak as D0,al as Y0,am as V0,an as K0,ao as Q0,ap as H0,aq as L6,ar as m6,as as ue,at as ee,au as un,av as ne,aw as re,ax as te,ay as le,az as ae,aA as se,aB as oe,aC as en,aD as j0,aE as k6,aF as nn,aG as rn,aH as tn,aI as ln,aJ as an,aK as sn,aL as on,aM as T6,aN as cn,aO as Cn,aP as dn,aQ as hn,aR as An,aS as xn,aT as pn,aU as jn,aV as fn,aW as Fn,aX as yn,aY as gn}from"./index-BHF9XhlR.js";import{N as lu}from"./NavLink-D2GD_ItM.js";import{L as au}from"./LinkItem-B0NRrkKX.js";import{V as ce,a as Wu}from"./index.esm-CjWvmHks.js";import{F as ie,a as Ce,b as de,c as he,d as Ae}from"./index.esm-BY9chGNa.js";import{M as xe,a as G0,b as pe}from"./index.esm-BcDC8KuM.js";import{L as Vu}from"./LineWithText-BpnpjRWf.js";import{u as m,f as Fu,a as Au}from"./redux-vendor-B7uoacJt.js";import{f as u6,r as c,u as e6,j as vn,b as x0}from"./react-vendor-CmFgShSM.js";import{A as E0}from"./AdvancedTable-Bc9rwJrH.js";import{d as b0}from"./Plagiarism-DQa3b2yK.js";import{u as je,g as S0}from"./useRequestFile-DJLl5omk.js";import{A as En}from"./index-rXDbFGCK.js";import{d as fe,C as bn,p as Sn,P as _n}from"./ProvinceFreeSales-CAKgsPJn.js";import{A as Dn}from"./AvicultureArchivedRequests-CT0ATC0C.js";import{R as zu}from"./ResponsiveTable-cmj--TTX.js";import{R as Ku,a as mu}from"./index.esm-Bu7XMDZU.js";import{R as Ln,a as kn}from"./RequestsAwaitingInspections-CckGVV5a.js";import{B as Tn}from"./BackButton-C3p7AEJl.js";import{h as Nn}from"./hour-limit-get-kill-request--Wr6A48x.js";import{d as wn,P as Pn,a as On}from"./delete-debtor-killhouses-8AYhfuQB.js";import{u as Mn}from"./useGetAllocationInformation-C1dGiG_T.js";import{d as n6}from"./Delete-BMbGwban.js";import{d as Fe}from"./Add-B14uoYzg.js";import{S as _0}from"./SimpleTable-OFQqh0WK.js";import{d as ye}from"./Tune-rHyTJYQA.js";import{d as ge}from"./Edit-DE-0ja3Q.js";import{d as $n,a as f0}from"./index-CV2Xug6a.js";import{N as ve}from"./NumberFormatCustom-DwWPj40N.js";import{P as In}from"./ProvinceSelectSlaughterForSlaughter-D-wlANu7.js";import{E as zn,S as Rn,P as Bn,a as Un}from"./EnterAuthCodeDirectBuy-BqAphWuG.js";import{l as r6}from"./ChickenLogo-BK6_Z2uq.js";import{s as Wn,a as Yn}from"./slaughter-get-provinces-C6Pl8X0E.js";import{C as Vn,a as Kn}from"./CityHatchingsArchiveOperations-CzPtqR7n.js";import{C as Qn,a as Hn}from"./ChainBarManagement-DQdaupqF.js";import{d as Gn}from"./AddCircleOutline-CRCPZlAA.js";import"./iconBase-BEJYyZsk.js";import"./LabelField-CY9emCr4.js";import"./aviculture-get-hatching-data-BR9pqiDJ.js";import"./DialogAlert-DKhMdDI2.js";import"./Done-CXPGvgsL.js";import"./aviculture-get-unions-DFRgtngr.js";import"./CarPelak-qce8cQdA.js";import"./isValidIndexWeight-C_ik-uYa.js";import"./Close-Daz6UZes.js";import"./VetFarmSubmitClearanceCode-BMbmSr2O.js";import"./Pageview-DPJOtuEI.js";import"./ToggleOn-9h7KsYVp.js";import"./ToggleOff-BEqTZ7eR.js";import"./Check-CnsFWTEq.js";import"./Sms-B-2HP--h.js";import"./FilterAlt-C5yvLNoT.js";import"./styled-components.browser.esm-gS9mh05b.js";import"./VpnKey-g9Vkw0dW.js";import"./Search-D4DyWpQE.js";import"./DoneOutline-CT7FzDqR.js";import"./ThumbUpAlt-D5KcH6HI.js";import"./province-get-sell-for-freezing-status-3W-n3Zfh.js";import"./ProvinceSettlementPdfKillRequest-CWbm18ML.js";import"./PictureAsPdf-Cvt23rlE.js";import"./FileUploader-D2gYZs7M.js";import"./CloudUpload-BmRtl-rF.js";import"./CheckCircle-DVOR8q2_.js";import"./Settings-BRyHIxId.js";const Xn=()=>{const{pathname:e}=u6(),t=m();return u.jsxs(o,{container:!0,gap:w.SMALL,p:w.SMALL,direction:{xs:"column",md:"row"},justifyContent:"center",style:{placeContent:"baseline"},children:[u.jsxs(o,{container:!0,direction:"column",style:{width:"100%"},children:[u.jsx(o,{children:u.jsx(Vu,{text:"مدیریت درخواست ها"})}),u.jsxs(o,{container:!0,justifyContent:"center",gap:w.SMALL,children:[u.jsx(lu,{to:w0,active:e===w0?"true":null,children:u.jsx(au,{icon:u.jsx(ce,{size:30,color:"#244CCC"}),title:"درخواست های کشتار",description:"درخواست های کشتار مرغدار در انتظار بررسی"})}),u.jsx(lu,{to:P0,active:e===P0?"true":null,children:u.jsx(au,{icon:u.jsx(xe,{size:30,color:"#244CCC"}),title:"اعلام نیاز خریداران",description:"درخواست های کشتار در انتظار بررسی"})}),u.jsx(lu,{to:O0,active:e===O0?"true":null,children:u.jsx(au,{icon:u.jsx(Wu,{size:30,color:"#244CCC"}),title:"تخصیصات",description:"مشاهده و تخصیص درخواست ها"})}),u.jsx(lu,{to:b6,active:e===b6?"true":null,children:u.jsx(au,{icon:u.jsx(ie,{size:30,color:"#244CCC"}),title:"تعرفه ها"})})]})]}),u.jsxs(o,{container:!0,direction:"column",style:{width:"100%"},children:[u.jsx(o,{children:u.jsx(Vu,{text:"ویژه"})}),u.jsxs(o,{container:!0,justifyContent:"center",gap:w.SMALL,children:[u.jsx(lu,{to:Ju,active:e===Ju?"true":null,children:u.jsx(au,{icon:u.jsx(G0,{size:30,color:"#244CCC"}),title:"خرید مستقیم"})}),u.jsx(lu,{to:M0,active:e===M0?"true":null,children:u.jsx(au,{icon:u.jsx(pe,{size:30,color:"#244CCC"}),title:"صادرات"})}),u.jsx(lu,{to:H6,children:u.jsx(au,{icon:u.jsx(Wu,{size:30,color:"#244CCC"}),title:"فروش به خارج استان"})}),u.jsx(lu,{to:$0,active:e===$0?"true":null,children:u.jsx(au,{icon:u.jsx(Ce,{size:30,color:"#244CCC"}),title:"زنجیره ها"})}),u.jsx(lu,{to:I0,active:e===I0?"true":null,children:u.jsx(au,{icon:u.jsx(Wu,{size:30,color:"#244CCC"}),title:"مدیریت تخصیصات"})})]})]}),u.jsx(o,{container:!0,gap:w.SMALL,p:w.SMALL,direction:"column",justifyContent:"center",style:{width:"100%"},children:u.jsxs(we,{style:{width:"100%"},children:[u.jsx(Pe,{expandIcon:u.jsx(Ve,{}),children:u.jsx(H,{variant:"body1",color:"error",children:"نظارت درخواست ها"})}),u.jsx(Oe,{children:u.jsxs(o,{container:!0,justifyContent:"center",gap:w.SMALL,mb:2,children:[u.jsx(lu,{to:z0,active:e===z0?"true":null,children:u.jsx(au,{icon:u.jsx(Wu,{size:30,color:"#244CCC"}),title:"تخصیصات خودکار"})}),u.jsx(lu,{to:R0,active:e===R0?"true":null,children:u.jsx(au,{icon:u.jsx(de,{color:"#244CCC",size:30}),title:"صدور نامه",description:"ارسال نامه سیستمی"})}),u.jsx(lu,{onClick:()=>t(wu({title:"اطلاعات گزارش",content:u.jsx(G6,{})})),children:u.jsx(au,{icon:u.jsx(he,{color:"#244CCC",size:30}),title:"گزارش روزانه",description:"گزارش روزانه"})}),u.jsx(lu,{to:S6,active:e===S6?"true":null,children:u.jsx(au,{icon:u.jsx(Ae,{size:30,color:"#244CCC"}),title:"تراکنش ها"})})]})})]})})]})},Jn=()=>{const[e,t]=c.useState(null),r=m(),x=Fu(f=>f.provinceSlice.provinceNewRequests);return c.useEffect(()=>{r(A0())},[]),c.useEffect(()=>{t(x)},[x]),e||[]},Zn=Au("PROVINCE_ACCEPT_REQUEST",async e=>{const{data:t,status:r}=await J.post("province_check_operator_request/",e);return{data:t,status:r}}),qn=Au("PROVINCE_REJECT_REQUEST",async e=>{const{data:t,status:r}=await J.post("province_check_operator_request/",e);return{data:t,status:r}}),t6=({id:e,file:t,item:r,updateTable:x})=>{var j;const f=je(e);t=t||((j=f==null?void 0:f.file)==null?void 0:j.process);const[p,,n,,l,,]=c.useContext(su),[g,F]=c.useState(!1);c.useEffect(()=>{(t==null?void 0:t.province)!==null&&F(!0)},[t]);const A=ku({initialValues:{rejectText:""},validationSchema:Iu({rejectText:gu().required("این فیلد اجباری است!").typeError("لطفا دلیل خود را بیان کنید.")})}),[S,d]=c.useState(!1),h=m();return u.jsx(u.Fragment,{children:!g&&u.jsxs(I6,{sx:{alignSelf:"flex-start",width:"100%"},children:[u.jsxs(z6,{children:[u.jsx(R6,{color:"secondary"}),u.jsx(B6,{})]}),u.jsxs(o,{container:!0,direction:"column",flexWrap:"nowrap",flex:"1",children:[u.jsxs(o,{container:!0,children:[u.jsx(o,{children:u.jsx(U6,{variant:"body1",fontWeight:"bold",color:"secondary",children:"انجام عملیات"})}),u.jsx(o,{children:u.jsx(W6,{color:"textSecondary",children:u.jsx(H,{variant:"body2",children:"در این مرحله درخواست را تایید یا رد کنید."})})})]}),u.jsx(o,{children:u.jsx(o,{xs:12,children:u.jsx(o,{container:!0,gap:w.SMALL,padding:w.SMALL,children:u.jsx(En,{children:S?u.jsx(X6.div,{animate:{x:-10,opacity:1},transition:{duration:.3},initial:{opacity:0},exit:{opacity:0},children:u.jsxs(o,{flexDirection:"column",container:!0,gap:w.SMALL,children:[u.jsx(o,{children:u.jsx(U,{multiline:!0,rows:4,fullWidth:!0,id:"rejectText",label:"پیام خود را وارد کنید",variant:"outlined",value:A.values.rejectText,error:A.touched.rejectText?!!A.errors.rejectText:null,onChange:A.handleChange,onBlur:A.handleBlur,helperText:A.touched.rejectText&&A.errors.rejectText?A.errors.rejectText:null})}),u.jsxs(o,{container:!0,gap:w.SMALL,children:[u.jsx(o,{children:u.jsx(W,{variant:"outlined",color:"secondary",onClick:()=>{d(!1)},children:"لغو"})}),u.jsx(o,{children:u.jsx(W,{disabled:!A.values.rejectText,variant:"outlined",onClick:()=>{h(q()),h(qn({message:A.values.rejectText,key:r==null?void 0:r.cityCheckRequest,state:"reject"})).then(b=>{b.error?p({vertical:"top",horizontal:"center",msg:"مشکلی پیش آمده است!",severity:"error"}):(x(),h(bu({right:!1,bottom:!1,content:null})),h(A0({selectedDate1:n,selectedDate2:l})),h(V()),p({vertical:"top",horizontal:"center",msg:"عملیات با موفقیت انجام شد.",severity:"success"}))})},children:"رد اطلاعات و پیام به مرغدار"})})]})]})}):u.jsxs(o,{container:!0,gap:w.SMALL,xs:12,children:[u.jsx(W,{fullWidth:!0,variant:"outlined",color:"secondary",onClick:()=>{d(!0)},children:"رد اطلاعات و پیام به مرغدار"}),u.jsx(W,{fullWidth:!0,variant:"outlined",onClick:()=>{h(q()),h(Zn({key:r==null?void 0:r.cityCheckRequest,state:"accept"})).then(b=>{b.error?p({vertical:"top",horizontal:"center",msg:"مشکلی پیش آمده است!",severity:"error"}):(x(),h(A0({selectedDate1:n,selectedDate2:l})),h(bu({right:!1,bottom:!1,content:null})),h(wu({title:"عملیات با موفقیت انجام شد.",content:u.jsxs(o,{container:!0,direction:"column",gap:w.MEDIUM,alignItems:"center",justifyContent:"center",children:[u.jsx(o,{children:u.jsx(H,{color:"green",children:"پرونده به کارتابل (در انتظار تخصیص) انتقال پیدا کرد."})}),u.jsx(o,{children:u.jsx(W,{variant:"contained",color:"success",onClick:()=>{h(Yu())},children:"تایید"})})]})})),h(A0({selectedDate1:n,selectedDate2:l})),p({vertical:"top",horizontal:"center",msg:"عملیات با موفقیت انجام شد.",severity:"success"}),h(V()),x())})},children:"تایید و اختصاص به کشتارگاه"})]})})})})})]})]})})};t6.propTypes={file:u0.PropTypes.object};const mn=()=>{const e=e6(),t=m(),r=Jn(),[x,f]=c.useState([]);c.useEffect(()=>{const n=r==null?void 0:r.map((l,g)=>{var F,A,S,d,h,j,b,v,E,L,$,z,P,s,D,a,M,N,R,Y,K;return[g+1,(F=l==null?void 0:l.poultryRequest)==null?void 0:F.orderCode,qu(new Date((A=l==null?void 0:l.poultryRequest)==null?void 0:A.createDate),"yyyy/MM/dd"),qu(new Date((S=l==null?void 0:l.poultryRequest)==null?void 0:S.sendDate),"yyyy/MM/dd"),(j=(h=(d=l==null?void 0:l.poultryRequest)==null?void 0:d.process)==null?void 0:h.poultry)==null?void 0:j.poultryName,(E=(v=(b=l==null?void 0:l.poultryRequest)==null?void 0:b.process)==null?void 0:v.poultry)==null?void 0:E.poultryMobile,(z=($=(L=l==null?void 0:l.poultryRequest)==null?void 0:L.process)==null?void 0:$.poultry)==null?void 0:z.poultryCity,(D=(s=(P=l==null?void 0:l.poultryRequest)==null?void 0:P.process)==null?void 0:s.poultry)==null?void 0:D.poultryProvince,(N=(M=(a=l==null?void 0:l.poultryRequest)==null?void 0:a.process)==null?void 0:M.poultry)==null?void 0:N.age,(K=(Y=(R=l==null?void 0:l.poultryRequest)==null?void 0:R.process)==null?void 0:Y.poultry)==null?void 0:K.poultryQuantity,u.jsx(xu,{color:"primary",onClick:()=>{var y,C,i,k;return t(bu({right:!(window.innerWidth<=600),bottom:window.innerWidth<=600,content:u.jsx(t6,{file:(y=l==null?void 0:l.poultryRequest)==null?void 0:y.process,id:(k=(i=(C=l.poultryRequest)==null?void 0:C.process)==null?void 0:i.poultry)==null?void 0:k.poultryRequestId}),title:"انجام عملیات استان"}))},children:u.jsx(fe,{})},g),u.jsx(xu,{"aria-label":"delete",color:"primary",onClick:()=>{var y,C,i;e(J0+((i=(C=(y=l==null?void 0:l.poultryRequest)==null?void 0:y.process)==null?void 0:C.poultry)==null?void 0:i.poultryRequestId))},children:u.jsx(b0,{})},g)]});f(n)},[r]);const[p]=c.useState(["ردیف","کد سفارش","تاریخ ثبت درخواست","تاریخ درخواست","مرغدار","تلفن مرغدار","شهر","استان","سن مرغ","تعداد","عملیات","مشاهده"]);return u.jsx(F0,{children:u.jsx(E0,{name:"درخواست های جدید در انتظار بررسی",columns:p,data:x})})},ur=()=>{const e=e6(),t=m(),{provinceRejectedRequests:r}=Fu(n=>n.provinceSlice),[x,f]=c.useState([]);c.useEffect(()=>{t(Ke())},[]),c.useEffect(()=>{const n=r==null?void 0:r.map((l,g)=>[g+1,l.orderCode,pu(l==null?void 0:l.createDate),pu(l==null?void 0:l.sendDate),l.fullname,l.mobile,l.city,l.province,l.poultryQuantity,u.jsx(xu,{"aria-label":"delete",color:"primary",onClick:()=>{e(J0+l.id)},children:u.jsx(b0,{})},g)]);f(n)},[r]);const[p]=c.useState(["ردیف","کد سفارش","تاریخ ثبت درخواست","تاریخ درخواست","مرغدار","تلفن مرغدار","شهر","استان","تعداد","مشاهده"]);return u.jsx(F0,{children:u.jsx(E0,{name:"درخواست های رد شده",columns:p,data:x})})},er=()=>{const[,,e,t,r,x]=c.useContext(su),f=m();c.useEffect(()=>{const D=ou(new Date).format("YYYY-MM-DD");t(D),x(D)},[]);const p=D=>{h(D.target.value)},[n,l]=c.useState([]),[g,F]=c.useState(0),[A,S]=c.useState(10),[d,h]=c.useState(""),[j,b]=c.useState(1),[v,E]=c.useState([]),L=async D=>{let a;f(q()),a=await J.get(`management_request/?search=filter&value=${d}&role=${tu()}&date1=${e}&date2=${r}&page=${D}&page_size=${A}`),f(V()),l(a.data.results),F(a.data.count)},$=D=>{L(D),b(D)},z=D=>{S(D),b(1)},P=()=>{L(j!==0?j:1)};c.useEffect(()=>{const D=n==null?void 0:n.map((a,M)=>{var N,R,Y,K,y,C,i,k,B,T,Q,nu,Z,eu,ju;return[j===1?M+1:M+A*(j-1)+1,a.stateProcess==="pending"?"در انتظار تایید شهرستان":"در انتظار تایید استان",a.orderCode,(R=(N=a==null?void 0:a.poultry)==null?void 0:N.user)==null?void 0:R.baseOrder,pu(a==null?void 0:a.createDate)+` (${(Y=a==null?void 0:a.registrar)==null?void 0:Y.fullname} - ${i0((K=a==null?void 0:a.registrar)==null?void 0:K.role)})`,pu(a==null?void 0:a.sendDate),a!=null&&a.freezing?"انجماد":a!=null&&a.export?"صادرات":"عادی",`${(C=(y=a==null?void 0:a.poultry)==null?void 0:y.user)==null?void 0:C.fullname} (${(k=(i=a==null?void 0:a.poultry)==null?void 0:i.user)==null?void 0:k.mobile})`,`${(B=a==null?void 0:a.poultry)==null?void 0:B.unitName}`,(T=a==null?void 0:a.poultry)==null?void 0:T.cityOperator,(Z=(nu=(Q=a==null?void 0:a.poultry)==null?void 0:Q.address)==null?void 0:nu.city)==null?void 0:Z.name,pu((eu=a==null?void 0:a.hatching)==null?void 0:eu.hatchingDate),(ju=a==null?void 0:a.hatching)==null?void 0:ju.age,a==null?void 0:a.IndexWeight,a==null?void 0:a.quantity.toLocaleString(),((a==null?void 0:a.quantity)*(a==null?void 0:a.IndexWeight)).toLocaleString(),u.jsx(xu,{color:"primary",onClick:()=>{var cu;return f(bu({right:!(window.innerWidth<=600),bottom:window.innerWidth<=600,content:a.stateProcess==="pending"?u.jsx(bn,{file:a,id:a.id,updateTable:P}):u.jsx(t6,{item:a,file:(cu=a==null?void 0:a.poultryRequest)==null?void 0:cu.process,id:a.id,updateTable:P}),title:"انجام عملیات تایید/رد"}))},children:u.jsx(fe,{})},M)]});E(D)},[n]),c.useEffect(()=>{L(1)},[f,e,r,A]);const s=async D=>{D.preventDefault(),f(q());try{const a=await J.get(`management_request/?role=${tu()}&search=filter&value=${d}&date1=${e}&date2=${r}&page=1&page_size=${A}`);l(a.data.results),F(a.data.count),f(V())}catch(a){console.error("Error fetching data:",a)}};return u.jsxs(o,{container:!0,xs:12,justifyContent:"center",alignItems:"center",gap:2,children:[u.jsxs(o,{container:!0,xs:12,justifyContent:"start",alignItems:"center",gap:2,children:[u.jsx(o,{children:u.jsx(yu,{label:"از تاریخ",id:"date",renderInput:D=>u.jsx(U,{style:{width:"160px"},...D,size:"small"}),value:e,onChange:D=>{t(ou(D).format("YYYY-MM-DD"))}})}),u.jsx(o,{children:u.jsx(yu,{label:"تا تاریخ",id:"date",renderInput:D=>u.jsx(U,{style:{width:"160px"},...D,size:"small"}),value:r,onChange:D=>{x(ou(D).format("YYYY-MM-DD"))}})}),u.jsx(o,{children:u.jsxs("form",{onSubmit:s,children:[u.jsx(U,{id:"outlined-basic",size:"small",label:"جستجو",variant:"outlined",style:{width:250},onChange:p}),u.jsx(W,{type:"submit",onClick:s,endIcon:u.jsx(Ku,{}),children:"جستجو"})]})})]}),u.jsx(zu,{data:v,columns:["ردیف","وضعیت","کد سفارش","کدکاربری","تاریخ ثبت درخواست","نوع کشتار","تاریخ کشتار","مرغدار (تلفن)","فارم","تعاونی","شهر","تاریخ جوجه ریزی","سن مرغ","میانگین وزن (کیلوگرم)","تعداد","وزن بار (کیلوگرم)","عملیات"],handlePageChange:$,totalRows:g,page:j,perPage:A,handlePerRowsChange:z,title:"مدیریت درخواست ها"})]})},nr=()=>{var nu,Z,eu,ju,cu,iu;const e=Fu(O=>O.userSlice.authToken),{poultryRequestsTotalQuantity:t}=Fu(O=>O.citySlice),r=m(),[x,f]=c.useState(!1),[p,n]=c.useState(""),[l]=c.useContext(su),[g,F]=c.useState([]),[A,S]=c.useState(0),[d,h]=c.useState(10),[j,b]=c.useState(""),[v,E]=c.useState(1),[L,$]=c.useState([]),z=O=>{b(O.target.value)},P=async O=>{r(q());const _=await J.get(`Poultry_Request/?role=${tu()}&today&date1=${N}&date2=${Y}&search=filter&value=${j||""}&page=${O}&page_size=${d}`);r(V()),F(_.data.results),S(_.data.count)},s=O=>{P(O),E(O)},D=async O=>{O.preventDefault(),r(q());try{const _=await J.get(`Poultry_Request/?role=${tu()}&today&date1=${N}&date2=${Y}&search=filter&value=${j||""}`);F(_.data.results),S(_.data.count),r(V())}catch(_){console.error("Error fetching data:",_)}},[a,M]=c.useState(ou(new Date).format("YYYY-MM-DD")),[,,N,R,Y,K]=c.useContext(su);c.useEffect(()=>{const O=ou(new Date).format("YYYY-MM-DD");R(O),K(O)},[]);const y=O=>{h(O),E(1)};c.useEffect(()=>{r(Qu(a))},[a]),c.useEffect(()=>{r(Nn()).then(O=>{var _,Cu,vu,Su;f((Cu=(_=O.payload.data)==null?void 0:_[0])==null?void 0:Cu.active),n((Su=(vu=O.payload.data)==null?void 0:vu[0])==null?void 0:Su.hour)}),r(wn())},[]),c.useEffect(()=>{x&&p&&r(_6({hour:p,active:x})),!x&&p&&(n(null),r(_6({hour:0,active:x})))},[p,x]);const i="/"+window.location.pathname.split("/")[1]+"/file/",k=O=>{let _="";return O!=null&&O.market?_="پنل معاملات":O!=null&&O.directBuying?_="خرید مستقیم":O!=null&&O.union?_="خرید خارج از استان":_="اتحادیه",_};c.useEffect(()=>{const O=g==null?void 0:g.map((_,Cu)=>{var vu,Su,Pu,Ou,I,ru,du,hu,fu,_u,Du,Mu,Ru,Bu,Uu,r0,t0,l0;return[v===1?Cu+1:Cu+d*(v-1)+1,u.jsx(Pn,{fileUrl:i,item:_,updateTable:B},Cu),_.orderCode,Q(_),_!=null&&_.freezing?"انجماد":_!=null&&_.export?"صادرات":"عادی",k(_),Zu(_==null?void 0:_.createDate)+` (${(vu=_==null?void 0:_.registrar)==null?void 0:vu.fullname} - ${i0((Su=_==null?void 0:_.registrar)==null?void 0:Su.role)})`,pu(_==null?void 0:_.sendDate),`${(Pu=_==null?void 0:_.poultry)==null?void 0:Pu.unitName} (${(I=(Ou=_==null?void 0:_.poultry)==null?void 0:Ou.user)==null?void 0:I.mobile})`,(ru=_==null?void 0:_.killHouseList)!=null&&ru.length?_==null?void 0:_.killHouseList.join(" - "):"ندارد",`${(fu=(hu=(du=_==null?void 0:_.poultry)==null?void 0:du.address)==null?void 0:hu.city)==null?void 0:fu.name}/${(_u=_==null?void 0:_.poultry)!=null&&_u.cityOperator?(Du=_==null?void 0:_.poultry)==null?void 0:Du.cityOperator:"بدون تعاونی"}`,(Mu=_==null?void 0:_.hatching)==null?void 0:Mu.age,_==null?void 0:_.IndexWeight,(Bu=(Ru=_==null?void 0:_.hatching)==null?void 0:Ru.totalWeight)==null?void 0:Bu.toLocaleString(),_==null?void 0:_.firstQuantity.toLocaleString(),(_==null?void 0:_.amount.toLocaleString())+" ﷼",(r0=(Uu=_==null?void 0:_.hatching)==null?void 0:Uu.leftOver)==null?void 0:r0.toLocaleString(),(t0=_.quantity)==null?void 0:t0.toLocaleString(),(_.quantity-(_==null?void 0:_.remainQuantity)).toLocaleString(),(l0=_==null?void 0:_.remainQuantity)==null?void 0:l0.toLocaleString(),u.jsx(H,{variant:"body2",sx:{color:_.hatching.fileState==="confirmation_code_pending"?"red":"black"},children:_.hatching.fileState==="province_state_pending"?"در انتظار تایید":_.hatching.fileState==="allocated_pending"?"آماده تخصیص":_.hatching.fileState==="confirmation_code_pending"?"در انتظار ورود کد احراز":"تخصیص داده شده"},Cu)]});$(O)},[g]),c.useEffect(()=>{P(1)},[N,Y,d]);const B=()=>{P(1)},T=u.jsx(o,{container:!0,alignItems:"center",mb:w.SMALL,gap:w.SMALL,justifyContent:"center",children:u.jsx("form",{onSubmit:D,children:u.jsxs(o,{container:!0,alignItems:"center",gap:w.SMALL,children:[u.jsx(U,{size:"small",autoComplete:"off",label:"جستجو",variant:"outlined",style:{width:250},onChange:z}),u.jsx(W,{type:"submit",onClick:D,endIcon:u.jsx(Ku,{}),children:"جستجو"}),u.jsx(o,{children:u.jsx(yu,{label:"از تاریخ",id:"date",renderInput:O=>u.jsx(U,{style:{width:"160px"},...O}),value:N,onChange:O=>{R(ou(O).format("YYYY-MM-DD"))}})}),u.jsx(o,{children:u.jsx(yu,{label:"تا تاریخ",id:"date",renderInput:O=>u.jsx(U,{style:{width:"160px"},...O}),value:Y,onChange:O=>{K(ou(O).format("YYYY-MM-DD"))}})}),u.jsx(Lu,{title:"خروجی اکسل",children:u.jsx(W,{color:"success",onClick:()=>{l({vertical:"top",horizontal:"center",msg:"فایل اکسل در حال دانلود می باشد، این علمیات ممکن است زمان بر باشد لطفا صبر کنید.",severity:"success"});const O=`${J.defaults.baseURL}poultry_kill_request_excel/?start=${N}&end=${Y}&role=${tu()}&token=${e}`;window.location.href=O},children:u.jsx(mu,{size:32})})})]})})}),Q=O=>{let _="";return O!=null&&O.freeSaleInProvince?_="آزاد":_="دولتی",_};return u.jsx(o,{container:!0,children:u.jsx(o,{container:!0,alignItems:"center",justifyContent:"space-between",gap:4,xs:12,children:u.jsxs(o,{container:!0,children:[u.jsx(o,{my:w.SMALL,children:u.jsxs(o,{mb:2,container:!0,alignItems:"center",gap:w.SMALL,children:[u.jsx(o,{children:u.jsx(H,{children:"اطلاعات کشتار"})}),u.jsx(o,{children:u.jsx(yu,{label:"تاریخ",id:"date",renderInput:O=>u.jsx(U,{style:{width:"160px"},...O}),value:a,onChange:O=>{M(ou(O).format("YYYY-MM-DD"))}})})]})}),u.jsx(o,{xs:12,mb:2,isDashboard:!0,children:u.jsx(zu,{isDashboard:!0,noPagination:!0,title:"خلاصه اطلاعات",columns:["درخواست های کشتار صادر شده","درخواست های کشتار تایید شده","درخواست های رد شده","درخواست خریداران","درخواست های خرید مستقیم","مانده در سالن (جوجه ریزی 45 تا 65 روز)"],data:[[t!=null&&t.firstQuantity?((nu=t==null?void 0:t.firstQuantity)==null?void 0:nu.toLocaleString())+" قطعه":0,t!=null&&t.acceptedQuantity?((Z=t==null?void 0:t.acceptedQuantity)==null?void 0:Z.toLocaleString())+" قطعه":0,t!=null&&t.rejectedQuantity?((eu=t==null?void 0:t.rejectedQuantity)==null?void 0:eu.toLocaleString())+" قطعه":0,t!=null&&t.killRequestsQuantity?((ju=t==null?void 0:t.killRequestsQuantity)==null?void 0:ju.toLocaleString())+" قطعه":0,t!=null&&t.directBuyingQuantity?((cu=t==null?void 0:t.directBuyingQuantity)==null?void 0:cu.toLocaleString())+" قطعه":0,t!=null&&t.ageUp45?((iu=t==null?void 0:t.ageUp45)==null?void 0:iu.toLocaleString())+" قطعه":0]]})}),u.jsxs(o,{mt:2,children:[T,u.jsx(zu,{data:L,columns:["ردیف","عملیات","کدسفارش","فروش","کشتار","درخواست","تاریخ ثبت درخواست","تاریخ کشتار","مرغدار","کشتارگاه های پیشنهادی","شهر/تعاونی","سن مرغ","میانگین وزنی","وزن تقریبی","حجم درخواست کشتار","قیمت مرغدار","مانده در سالن","تایید شده","تخصیص داده شده","مانده قابل تخصیص","وضعیت"],handlePageChange:s,totalRows:A,page:v,perPage:d,handlePerRowsChange:y,title:"اطلاعات کشتار"})]})]})})})},rr=Au("PROVINCE_CLOSE_ALLOCATION_SERVICE",async(e,{dispatch:t})=>{try{t(q());const{data:r,status:x}=await J.put("Poultry_Request/0/",e);return t(V()),{data:r,status:x}}catch(r){return t(V()),{error:r.response.data.result}}});var l6={},tr=e0;Object.defineProperty(l6,"__esModule",{value:!0});var Ee=l6.default=void 0,lr=tr(n0()),ar=u;Ee=l6.default=(0,lr.default)((0,ar.jsx)("path",{d:"m13.7826 15.1719 2.1213-2.1213 5.9963 5.9962-2.1213 2.1213zM17.5 10c1.93 0 3.5-1.57 3.5-3.5 0-.58-.16-1.12-.41-1.6l-2.7 2.7-1.49-1.49 2.7-2.7c-.48-.25-1.02-.41-1.6-.41C15.57 3 14 4.57 14 6.5c0 .41.08.8.21 1.16l-1.85 1.85-1.78-1.78.71-.71-1.41-1.41L12 3.49c-1.17-1.17-3.07-1.17-4.24 0L4.22 7.03l1.41 1.41H2.81l-.71.71 3.54 3.54.71-.71V9.15l1.41 1.41.71-.71 1.78 1.78-7.41 7.41 2.12 2.12L16.34 9.79c.36.13.75.21 1.16.21"}),"Construction");var a6={},sr=e0;Object.defineProperty(a6,"__esModule",{value:!0});var be=a6.default=void 0,or=sr(n0()),N6=u;be=a6.default=(0,or.default)([(0,N6.jsx)("path",{d:"M11.99 2C6.47 2 2 6.48 2 12s4.47 10 9.99 10C17.52 22 22 17.52 22 12S17.52 2 11.99 2M12 20c-4.42 0-8-3.58-8-8s3.58-8 8-8 8 3.58 8 8-3.58 8-8 8"},"0"),(0,N6.jsx)("path",{d:"M12.5 7H11v6l5.25 3.15.75-1.23-4.5-2.67z"},"1")],"AccessTime");const cr=Au("PROVINCE_REQUEST_AUCTION",async e=>{const{data:t,status:r}=await J.post("province_request_auction/",e);return{data:t,status:r}}),Se=({poultryRequestKey:e})=>{const[t,r]=c.useState(),{id:x}=vn(),[f]=v0(),{avicultureChickenPrice:p}=Fu(j=>j.avicultureSlice),[n]=c.useContext(su),l=m();c.useEffect(()=>{l(J6())},[]);const[g,F]=c.useState([{id:0,value:"",hour:2}]),A=()=>{F(j=>[...j,{id:j.length,value:"",hour:1}])},S=j=>{let b=g.length-1;if(b!==0){let v=g.filter((E,L)=>L<b);F(v)}},d=j=>{const[b,v]=j.target.name.split("-");b==="price"?F(E=>{const L=E;return L[v].value=j.target.value,L}):b==="hour"&&F(E=>{const L=E;return L[v].hour=Number(j.target.value),L})};c.useEffect(()=>{p&&r(p.key)},[p]);const h=ku({initialValues:{noChicken:"",price1:"",price2:"",price3:"",slaughterDate:ou(Date()).format("YYYY-MM-DD hh:mm:ss"),period1:"4",period2:"4",period3:"4",weight:""},validationSchema:Iu({price1:$u().typeError("لطفا عدد وارد کنید!").min(p==null?void 0:p.floorPrice,"قیمت وارد شده از کف قیمت امروز کمتر است").max(p==null?void 0:p.ceilingPrice,"قیمت وارد شده از سقف قیمت امروز بیشتر است"),price2:$u().typeError("لطفا عدد وارد کنید!").min(p==null?void 0:p.floorPrice,"قیمت وارد شده از کف قیمت امروز کمتر است").max(p==null?void 0:p.ceilingPrice,"قیمت وارد شده از سقف قیمت امروز بیشتر است"),price3:$u().typeError("لطفا عدد وارد کنید!").min(p==null?void 0:p.floorPrice,"قیمت وارد شده از کف قیمت امروز کمتر است").max(p==null?void 0:p.ceilingPrice,"قیمت وارد شده از سقف قیمت امروز بیشتر است"),weight:$u().required("این فیلد اجباری است!").typeError("لطفا وزن را وارد کنید!")})});return u.jsxs(o,{container:!0,gap:w.SMALL,children:[u.jsxs(o,{container:!0,gap:w.SMALL,alignItems:"center",children:[u.jsx(H,{color:j=>j.palette.grey.A700,variant:"caption",children:"کف قیمت امروز:"}),u.jsxs(H,{color:"secondary",variant:"button",children:[p!=null&&p.floorPrice?p==null?void 0:p.floorPrice.toLocaleString():"نامشخص"," "," ","ریال"]})]}),u.jsxs(o,{container:!0,gap:w.SMALL,alignItems:"center",children:[u.jsx(H,{color:j=>j.palette.grey.A700,variant:"caption",children:"سقف قیمت امروز:"}),u.jsxs(H,{color:"secondary",variant:"button",children:[p!=null&&p.ceilingPrice?p==null?void 0:p.ceilingPrice.toLocaleString():"نامشخص"," "," ","ریال"]})]}),u.jsx(Me,{style:{width:"100%"}}),u.jsx(o,{container:!0,direction:"column",children:u.jsx(o,{container:!0,direction:"column",gap:w.SMALL,alignItems:"start",children:u.jsxs(o,{container:!0,gap:w.MEDIUM,alignItems:"center",children:[g.map((j,b)=>u.jsxs(o,{gap:w.SMALL,container:!0,children:[u.jsxs(H,{variant:"body2",fontWeight:"bold",children:["پیشنهاد ",b+1]}),u.jsx(U,{error:!1,fullWidth:!0,label:"قیمت پیشنهادی",variant:"outlined",onChange:d,name:"price-"+b}),u.jsxs(k0,{fullWidth:!0,children:[u.jsx(T0,{id:"demo-simple-select-label",children:"بازه زمانی (ساعت)"}),u.jsxs(N0,{labelId:"demo-simple-select-label",label:"بازه زمانی (ساعت)",name:"hour-"+b,onChange:d,children:[u.jsx(Tu,{value:"1",children:"1"}),u.jsx(Tu,{value:"2",children:"2"}),u.jsx(Tu,{value:"3",children:"3"}),u.jsx(Tu,{value:"4",children:"4"}),u.jsx(Tu,{value:"5",children:"5"}),u.jsx(Tu,{value:"6",children:"6"}),u.jsx(Tu,{value:"7",children:"7"}),u.jsx(Tu,{value:"8",children:"8"}),u.jsx(Tu,{value:"9",children:"9"}),u.jsx(Tu,{value:"10",children:"10"})]}),u.jsx($e,{children:h.touched.period1&&h.errors.period1?h.errors.period1:null})]})]},b)),u.jsxs(o,{container:!0,direction:"column",children:[u.jsx(xu,{"aria-label":"delete",color:"secondary",children:u.jsx(n6,{onClick:S})}),u.jsx(xu,{"aria-label":"delete",color:"success",children:u.jsx(Fe,{onClick:A})})]})]})})}),u.jsx(W,{fullWidth:!0,disabled:!h.isValid,onClick:()=>{l(q()),l(cr({poultry_request_key:e,auction_list:g.map((j,b)=>({pricing_key:t,fee:j.value,hour:j.hour}))})).then(j=>{l(V()),j.error?n({vertical:"top",horizontal:"center",severity:"error",msg:"مشکلی پیش آمده است!"}):(l(Qe()),S0(f,x,l),n({vertical:"top",horizontal:"center",severity:"success",msg:"با موفقیت انجام شد!"}),l(bu({right:!1,bottom:!1,content:null})))})},size:"large",variant:"contained",children:"ثبت درخواست"})]})};Se.propTypes={poultryRequestKey:u0.PropTypes.any};var s6={},ir=e0;Object.defineProperty(s6,"__esModule",{value:!0});var _e=s6.default=void 0,Cr=ir(n0()),dr=u;_e=s6.default=(0,Cr.default)((0,dr.jsx)("path",{d:"M22 4h-2c-.55 0-1 .45-1 1v9c0 .55.45 1 1 1h2zM2.17 11.12c-.11.25-.17.52-.17.8V13c0 1.1.9 2 2 2h5.5l-.92 4.65c-.05.22-.02.46.08.66.23.45.52.86.88 1.22L10 22l6.41-6.41c.38-.38.59-.89.59-1.42V6.34C17 5.05 15.95 4 14.66 4h-8.1c-.71 0-1.36.37-1.72.97z"}),"ThumbDownAlt");const hr=Au("PROVINCE_REMOVE_ALLOCATION",async(e,{dispatch:t})=>{t(q());const{data:r,status:x}=await J.delete("province_kill_request/0/",{params:e});return t(V()),{data:r,status:x}}),Ar=Au("PROVINCE_EDIT_KILL_CAPACITY_SERVICE",async(e,{dispatch:t})=>{try{t(q());const{data:r,status:x}=await J.put("kill_request/0/",e);return t(V()),{data:r,status:x}}catch(r){return t(V()),{error:r.response.data.result}}}),xr=({killRequestKey:e,poultryRequestKey:t,killCapacity:r,updateTable:x})=>{const f=m(),[p]=c.useContext(su),n=ku({initialValues:{number:r},onSubmit:l=>{f(Ar({kill_request_key:e,quantity:l.number})).then(g=>{g.payload.error?p({vertical:"top",horizontal:"center",msg:g.payload.error,severity:"error"}):(f(p0(t)),f(Yu()),p({vertical:"top",horizontal:"center",msg:"عملیات با موفقیت انجام شد.",severity:"success"}),x())})},validate:l=>{const g={};return l.number?isNaN(parseInt(l.number))&&(g.number="باید عدد وارد شود."):g.number="این فیلد اجباری است",g}});return u.jsx("form",{onSubmit:n.handleSubmit,children:u.jsxs(o,{container:!0,gap:w.SMALL,children:[u.jsx(U,{fullWidth:!0,variant:"outlined",label:"ظرفیت کل",name:"number",onChange:n.handleChange,onBlur:n.handleBlur,value:n.values.number,error:n.touched.number&&!!n.errors.number,helperText:n.touched.number&&n.errors.number}),u.jsx(W,{fullWidth:!0,variant:"contained",type:"submit",children:"ثبت"})]})})};var o6={},pr=e0;Object.defineProperty(o6,"__esModule",{value:!0});var De=o6.default=void 0,jr=pr(n0()),fr=u;De=o6.default=(0,jr.default)((0,fr.jsx)("path",{d:"m23 12-2.44-2.79.34-3.69-3.61-.82-1.89-3.2L12 2.96 8.6 1.5 6.71 4.69 3.1 5.5l.34 3.7L1 12l2.44 2.79-.34 3.7 3.61.82L8.6 22.5l3.4-1.47 3.4 1.46 1.89-3.19 3.61-.82-.34-3.69zm-12.91 4.72-3.8-3.81 1.48-1.48 2.32 2.33 5.85-5.87 1.48 1.48z"}),"Verified");const Fr=Iu().shape({quantity:$u().required("تعداد اجباری است.").positive("تعداد باید بالاتر از 0 باشد.").integer("تعداد باید عدد باشد.")});function yr({slaughterHouseReq:e,provinceCheckRequestKey:t,poultryRequestId:r,poultryRequestKey:x,handleAllEntredQauntity:f,allEntredQauntity:p,name:n,file:l,avgLast4KillhousesWeight:g,defaultValueForAllocate:F,updateTable:A}){var a,M,N,R,Y,K,y,C,i,k,B,T,Q,nu;const[S,,d]=c.useContext(su),[h]=v0(),j=m(),[b,v]=c.useState(!1),E=Z=>{v(Z.target.checked)},L=ku({initialValues:{quantity:e.remainQuantity},validationSchema:Fr,onSubmit:Z=>{j(q()),j(He({kill_request_key:e.key,province_check_request_key:t,quantity:Z.quantity,payment_type:"نقدی"})).then(eu=>{j(V()),eu.payload.error?S({vertical:"top",horizontal:"center",msg:eu.payload.error,severity:"error"}):(v(!1),S0(h,r,j),j(C0(d)),j(p0({key:x})),j(Z6({key:x})),S({vertical:"top",horizontal:"center",msg:"عملیات با موفقیت انجام شد.",severity:"success"}),A())})}});c.useEffect(()=>{L.validateForm()},[]),c.useEffect(()=>{const Z=Number(F)<0?0:Number(F);L.setFieldValue("quantity",Z)},[F]),c.useEffect(()=>{if(b){const Z=Number(L.values.quantity)<0?0:Number(L.values.quantity);f({...p,[n]:Z})}else f({...p,[n]:0})},[L.values.quantity,b]);const{poultryRequestIndexWeight:$}=Fu(Z=>Z.fileSlice),z=$==null?void 0:$.ave,P=(a=l==null?void 0:l.poultry)==null?void 0:a.IndexWeight;P>z&&e.firstAverageWeight<g||P<z&&e.firstAverageWeight>g;const s=b&&L.isValid&&F>0,D=(M=e==null?void 0:e.killHouse)!=null&&M.killer?"کشتارکن":"کشتارگاه";return u.jsxs(Y6,{children:[u.jsx(Eu,{style:{alignItems:"center",textAlign:"center"},children:u.jsxs(o,{container:!0,direction:"row",flexWrap:"nowrap",alignItems:"center",children:[u.jsx(X0,{checked:b,onChange:E},(N=e==null?void 0:e.killHouse)==null?void 0:N.name),D+" "+((R=e==null?void 0:e.killHouse)==null?void 0:R.name),(e==null?void 0:e.priority)&&u.jsx(Lu,{title:"پیشنهادی مرغدار",placement:"left-start",children:u.jsx(De,{color:"success"})})]})}),u.jsxs(Eu,{style:{alignItems:"center",textAlign:"center"},children:[(y=(K=(Y=e==null?void 0:e.killHouse)==null?void 0:Y.killHouseOperator)==null?void 0:K.user)==null?void 0:y.fullname," (",(k=(i=(C=e==null?void 0:e.killHouse)==null?void 0:C.killHouseOperator)==null?void 0:i.user)==null?void 0:k.mobile,")"]}),u.jsx(Eu,{style:{alignItems:"center",textAlign:"center"},children:u.jsxs(Gu,{checked:b,children:[e.firstAverageWeight," کیلوگرم"]},"vv")}),u.jsx(Eu,{style:{alignItems:"center",textAlign:"center"},children:u.jsxs(Gu,{checked:b,children:[e==null?void 0:e.killCapacity,u.jsx(W,{"aria-label":"delete",color:"primary",onClick:()=>{j(wu({title:"اضافه کردن به درخواست کشتارگاه",content:u.jsx(xr,{poultryRequestKey:x,killRequestKey:e==null?void 0:e.key,killCapacity:e.killCapacity,updateTable:A})}))},children:"ویرایش"})]},"vv")}),u.jsx(Eu,{style:{alignItems:"center",textAlign:"center"},children:u.jsx(Gu,{checked:b,children:(B=e==null?void 0:e.remainQuantity)==null?void 0:B.toLocaleString()},"vv")}),u.jsx(Eu,{style:{alignItems:"center",textAlign:"center"},children:u.jsx(Gu,{checked:b,children:(T=e==null?void 0:e.numberOfAllocated)==null?void 0:T.toLocaleString()},"vv")}),u.jsx(Eu,{style:{alignItems:"center",textAlign:"center"},children:u.jsx(Gu,{checked:b,children:u.jsx(o,{children:u.jsx(U,{disabled:!b,label:"حجم",type:"number",style:{width:"80%"},inputProps:{min:0,step:1},fullWidth:!0,id:"quantity",value:L.values.quantity,onChange:L.handleChange,error:L.touched.quantity&&!!L.errors.quantity,helperText:L.touched.quantity&&L.errors.quantity})},(Q=e==null?void 0:e.killHouse)==null?void 0:Q.name)},"vv")}),u.jsx(Eu,{style:{alignItems:"center",textAlign:"center"},children:u.jsx(Gu,{checked:b,children:u.jsx(W,{variant:"contained",type:"submit",color:"primary",disabled:!s,onClick:L.handleSubmit,children:"تخصیص"},(nu=e==null?void 0:e.killHouse)==null?void 0:nu.name)},"vv")})]})}const Gu=({children:e,checked:t})=>u.jsx(o,{style:{opacity:t?1:.5},children:e}),gr=({children:e})=>u.jsx(Ie,{component:V6,sx:{maxHeight:"70vh",overflow:"auto"},children:u.jsxs(ze,{stickyHeader:!0,children:[u.jsx(Re,{children:u.jsxs(Y6,{children:[u.jsx(Eu,{children:"خریدار"}),u.jsx(Eu,{children:"اطلاعات خریدار"}),u.jsx(Eu,{children:"میانگین وزن 4 کشتار قبلی"}),u.jsx(Eu,{children:"کل سهمیه خریدار"}),u.jsx(Eu,{children:"مانده از سهمیه"}),u.jsx(Eu,{children:"تعداد تخصیص به کل سفارشات"}),u.jsx(Eu,{children:"قابل تخصیص"}),u.jsx(Eu,{children:"اقدام"})]})}),u.jsx(Be,{children:e})]})}),vr=Au("PROVINCE_EDIT_POULTRY_REQUEST_SERVICE",async(e,{dispatch:t})=>{try{t(q());const{data:r,status:x}=await J.put("Poultry_Request/0/",e);return t(V()),{data:r,status:x}}catch(r){return t(V()),{error:r.response.data.result}}}),Er=({quantity:e,poultryRequestKey:t})=>{const[r]=c.useContext(su),[x]=v0(),f=m(),p=ku({initialValues:{numberField:e},onSubmit:n=>{f(vr({quantity:n.numberField,key:t})).then(l=>{l.payload.error?r({vertical:"top",horizontal:"center",msg:l.payload.error,severity:"error"}):(S0(x,t,f),f(C0()),f(Yu()),r({vertical:"top",horizontal:"center",msg:"عملیات با موفقیت انجام شد.",severity:"success"}))})},validate:n=>{const l={};return n.numberField?/^\d+$/.test(n.numberField)||(l.numberField="Only numbers are allowed"):l.numberField="Field cannot be empty",l}});return u.jsx("form",{onSubmit:p.handleSubmit,children:u.jsxs(o,{container:!0,gap:w.TINY,children:[u.jsx(U,{fullWidth:!0,id:"numberField",label:"حداقل تعداد",variant:"outlined",name:"numberField",value:p.values.numberField,onChange:p.handleChange,error:p.touched.numberField&&!!p.errors.numberField,helperText:p.touched.numberField&&p.errors.numberField}),u.jsx(W,{type:"submit",fullWidth:!0,variant:"contained",children:"ثبت"})]})})},br=({allocated:e})=>{const[t,r]=c.useState([]);return c.useEffect(()=>{const x=e==null?void 0:e.map((f,p)=>{var l;let n;return f.provinceKillRequestState==="accepted"?n="تایید شده":f.provinceKillRequestState==="pending"?n="در انتظار تایید و تخصیص خودرو توسط کشتارگاه می باشد.":f.provinceKillRequestState==="rejected"&&(n="درخواست توسط کشتارگاه رد شده است!"),[`${f.killHouseName} (${f.killHouseUserName})`,qu(new Date(f.date),"yyyy/MM/dd"),(l=f.mainQuantity)==null?void 0:l.toLocaleString(),f.automaticState?"تخصیص خودکار":"تخصیص دستی",n]});r(x)},[]),u.jsx(_0,{columns:["خریدار","تاریخ کشتار","تعداد","نوع تخصیص","وضعیت"],data:t})},Le=({id:e,orginalQuantity:t,item:r,getItemFreeSaleInProvince:x,updateTable:f})=>{var T,Q,nu,Z,eu,ju,cu,iu,O,_,Cu,vu,Su,Pu,Ou;const p=je(e),n=(T=p==null?void 0:p.file)==null?void 0:T.process,[l,,g]=c.useContext(su),F=(Q=n==null?void 0:n.poultry)==null?void 0:Q.poultryRemainQuantity;let{slaughterHousesRequest:A}=Fu(I=>I.fileSlice);const[,S]=c.useState(),[,d]=c.useState(),[h,j]=c.useState(F);c.useEffect(()=>{j(F)},[F,n]);const[b,v]=c.useState(null),E=I=>{v(I)};c.useEffect(()=>{if(b!==null){const I=(du,hu)=>du+hu,ru=Object.values(b).reduce(I,0);j(F-ru)}},[b]),c.useEffect(()=>{var I;D(Ge()),D(p0((I=n==null?void 0:n.poultry)==null?void 0:I.poultryRequestKey))},[n]);const[L]=c.useState("allocate"),[$]=c.useState(),z=(I,ru)=>I+ru,P=Array.isArray(A)?((nu=A==null?void 0:A.map(I=>I.firstAverageWeight))==null?void 0:nu.reduce(z,0))/(A==null?void 0:A.length):"",s=Mn((Z=n==null?void 0:n.poultry)==null?void 0:Z.poultryRequestKey),D=m(),[a]=v0();c.useEffect(()=>{D(J6())},[]);const M=ku({initialValues:{quantity:"",slaughterHouse:"",paymentType:"cash"},validationSchema:Iu({quantity:$u().test("testlimit","تعداد باید کمتر یا مساوی ظرفیت کشتارگاه و مانده درخواست باشد",(I,ru)=>ru.originalValue&&ru.originalValue<=s.quantity&&ru.originalValue<=$&&ru.originalValue>0).required("این فیلد اجباری است!").typeError("لطفا عدد وارد کنید!"),slaughterHouse:gu().required("این فیلد اجباری است!"),paymentType:gu().required("این فیلد اجباری است!")})});c.useEffect(()=>{M.validateForm()},[]),c.useEffect(()=>{M.values.slaughterHouse||(d(null),S(null))},[M.values.slaughterHouse]);const N=(eu=n==null?void 0:n.poultry)==null?void 0:eu.IndexWeight;let R;const{poultryRequestIndexWeight:Y}=Fu(I=>I.fileSlice),K=Y==null?void 0:Y.ave;N>K?R="high":N<K&&(R="low"),A=Array.isArray(A)?A:[];const y=[...A].sort(function(I,ru){var du,hu,fu,_u,Du,Mu;return R==="high"&&I.firstAverageWeight<ru.firstAverageWeight&&((hu=(du=I.killHouse.systemAddress)==null?void 0:du.city)==null?void 0:hu.name)===((fu=n==null?void 0:n.poultry)==null?void 0:fu.poultryCity)||R==="low"&&I.firstAverageWeight>ru.firstAverageWeight&&((Du=(_u=I.killHouse.systemAddress)==null?void 0:_u.city)==null?void 0:Du.name)===((Mu=n==null?void 0:n.poultry)==null?void 0:Mu.poultryCity)?-1:0}),C=(ju=s==null?void 0:s.provinceAssignments)!=null&&ju.length?(cu=s==null?void 0:s.provinceAssignments)==null?void 0:cu.reduce((I,ru)=>ru.provinceKillRequestState!=="rejected"?I+ru.mainQuantity:I,0):0,i=t-C,[k,B]=c.useState("");return u.jsxs(I6,{sx:{alignSelf:"flex-start",width:"100%"},children:[u.jsxs(z6,{children:[u.jsx(R6,{color:"secondary"}),u.jsx(B6,{})]}),u.jsxs(o,{container:!0,direction:"column",flexWrap:"nowrap",flex:"1",children:[u.jsxs(o,{container:!0,children:[u.jsx(o,{children:u.jsx(U6,{variant:"body1",fontWeight:"bold",color:"secondary",children:"انجام عملیات"})}),u.jsx(o,{children:u.jsx(W6,{color:"textSecondary",children:u.jsxs(o,{container:!0,gap:w.LARGE,alignItems:"center",children:[u.jsxs(H,{variant:"body1",color:h<0?"red":"black",children:["تعداد اولیه درخواست کشتار: ",t==null?void 0:t.toLocaleString()," ","قطعه",u.jsx(W,{"aria-label":"delete",color:"primary",onClick:()=>{D(wu({title:"ویرایش تعداد اولیه درخواست کشتار",content:u.jsx(Er,{quantity:C,poultryRequestKey:r.poultryRequest.key})}))},children:"ویرایش"})]}),u.jsxs(H,{variant:"body1",color:h<0?"red":"black",children:["تخصیص داده شده: ",C==null?void 0:C.toLocaleString()," قطعه",u.jsx(W,{onClick:()=>{D(wu({title:"تخصیصات انجام شده",content:u.jsx(br,{allocated:s==null?void 0:s.provinceAssignments})}))},children:"مشاهده"})]}),u.jsxs(H,{variant:"body1",color:"green",children:["تعداد قابل تخصیص: ",h==null?void 0:h.toLocaleString()," قطعه"]}),u.jsxs(H,{variant:"body1",color:"primary",children:["مرغدار:"," ",`${(O=(iu=r==null?void 0:r.poultryRequest)==null?void 0:iu.poultry)==null?void 0:O.unitName} (${(vu=(Cu=(_=r==null?void 0:r.poultryRequest)==null?void 0:_.poultry)==null?void 0:Cu.userprofile)==null?void 0:vu.mobile})`]}),u.jsxs(H,{variant:"body1",color:"primary",children:["نوع فروش: ",x(r)]})]})})})]}),L==="allocate"&&u.jsxs(o,{container:!0,direction:"column",width:"100%",alignItems:"start",children:[u.jsx(o,{container:!0,direction:"column",gap:w.TINY,mt:w.SMALL,children:u.jsxs(o,{container:!0,xs:12,gap:2,children:[u.jsx(U,{label:"جستجو بر اساس خریدار",value:k,onChange:I=>B(I.target.value)}),u.jsx(gr,{children:y==null?void 0:y.filter(I=>{var hu,fu;return(((hu=I==null?void 0:I.killHouse)!=null&&hu.killer?"کشتارکن":"کشتارگاه")+" "+((fu=I==null?void 0:I.killHouse)==null?void 0:fu.name)).includes(k)}).map((I,ru)=>{var du,hu,fu;return u.jsx(yr,{name:ru,slaughterHouseReq:I,avgLast4KillhousesWeight:P,provinceCheckRequestKey:(du=n==null?void 0:n.province)==null?void 0:du.provinceCheckRequestKey,poultryRequestKey:(hu=n==null?void 0:n.poultry)==null?void 0:hu.poultryRequestKey,poultryRequestId:(fu=n==null?void 0:n.poultry)==null?void 0:fu.poultryRequestId,file:n,handleAllEntredQauntity:E,allEntredQauntity:b,defaultValueForAllocate:i,updateTable:f},I==null?void 0:I.name)})})]})}),u.jsx(o,{textAlign:"start",my:w.SMALL,children:u.jsx(H,{fontWeight:"bold",variant:"body1",children:"تخصیص های انجام شده"})}),!((Su=s==null?void 0:s.provinceAssignments)!=null&&Su.length)&&u.jsx(H,{textAlign:"start",variant:"body2",children:"تخصیصی انجام نشده است."}),(Pu=s==null?void 0:s.provinceAssignments)==null?void 0:Pu.map((I,ru)=>{var hu;let du;return I.provinceKillRequestState==="accept"?du="تایید شده است.":I.provinceKillRequestState==="pending"?du="در انتظار تایید و تخصیص خودرو توسط کشتارگاه می باشد.":I.provinceKillRequestState==="rejected"&&(du="درخواست توسط کشتارگاه رد شده است!"),u.jsxs(o,{container:!0,gap:w.MEDIUM,alignItems:"center",mb:w.SMALL,children:[u.jsxs(o,{gap:w.TINY,container:!0,direction:"column",children:[u.jsxs(o,{container:!0,gap:w.SMALL,alignItems:"center",children:[u.jsx(o,{children:u.jsxs(H,{variant:"caption",children:[I.killHouseName," / ",I.killHouseUserName," /",I.killHouseMobile]})}),u.jsx(o,{children:u.jsxs(H,{variant:"caption",children:["تاریخ کشتار"," ",qu(new Date(I.date),"yyyy/MM/dd")]})}),u.jsx(o,{children:u.jsxs(H,{variant:"caption",children:[(hu=I.mainQuantity)==null?void 0:hu.toLocaleString()," قطعه"]})}),u.jsx(o,{children:u.jsx(H,{variant:"caption",fontWeight:"bold",color:"error",children:I!=null&&I.market?"پنل معاملات":I.automaticState?"تخصیص خودکار":"تخصیص دستی"})})]}),u.jsxs(o,{textAlign:"start",container:!0,gap:w.TINY,alignItems:"center",children:[I.provinceKillRequestState!=="rejected"?u.jsx(be,{color:"primary"}):u.jsx(_e,{color:"error"}),u.jsx(H,{variant:"caption",children:du})]})]}),I.provinceKillRequestState!=="rejected"&&(I==null?void 0:I.returnToProvince)===!1&&u.jsx(o,{children:u.jsx(o,{children:u.jsx(W,{size:"small",variant:"outlined",color:"error",onClick:()=>{D(hr({key:I.provinceKillRequestKey})).then(fu=>{var _u,Du;fu.error?(D(V()),fu.error.message.includes("403")?l({vertical:"top",horizontal:"center",msg:"به علت تایید کشتارگاه امکان حذف تخصیص وجود ندارد!",severity:"error"}):l({vertical:"top",horizontal:"center",msg:"مشکلی پیش آمده است!",severity:"error"})):(S0(a,e,D),D(p0((_u=n==null?void 0:n.poultry)==null?void 0:_u.poultryRequestKey)),D(C0(g)),D(Z6({key:(Du=n==null?void 0:n.poultry)==null?void 0:Du.poultryRequestKey})),l({vertical:"top",horizontal:"center",msg:"عملیات با موفقیت انجام شد!",severity:"success"}),f())})},children:"حذف"})})})]},ru)})]}),L==="auction"&&u.jsx(o,{children:u.jsx(Se,{poultryRequestKey:(Ou=n==null?void 0:n.poultry)==null?void 0:Ou.poultryRequestKey})})]})]})};Le.propTypes={file:u0.PropTypes.object};const Sr=({item:e,remainQuantity:t,getItemFreeSaleInProvince:r,updateTable:x})=>{const f=m(),[p,,n]=c.useContext(su),[l,g]=c.useState(null),F=!!l,A=F?"ProvinceAllocateRequests":void 0,S=h=>{g(h.currentTarget)},d=()=>{g(null)};return u.jsxs(o,{children:[u.jsx(xu,{"aria-describedby":A,variant:"contained",color:"primary",onClick:S,children:u.jsx(ye,{})}),u.jsx(y0,{anchorOrigin:{vertical:"bottom",horizontal:"right"},transformOrigin:{vertical:"top",horizontal:"left"},id:A,open:F,anchorEl:l,onClose:d,children:u.jsxs("div",{style:{padding:"20px",display:"flex",flexDirection:"column"},children:[u.jsx(Lu,{title:"تخصیص",placement:"right",children:u.jsx(xu,{color:"primary",onClick:()=>{var h,j,b,v,E,L,$,z,P;d(),((h=e==null?void 0:e.poultryRequest)==null?void 0:h.priceConfirmation)===!0&&!((j=e==null?void 0:e.poultryRequest)!=null&&j.inputPriceConfirmationCode)?f(wu({title:"ورود کد احراز",content:u.jsx(On,{updateTable:x,item:e==null?void 0:e.poultryRequest})})):(e==null?void 0:e.provinceState)==="pending"?f(wu({title:"اطلاعیه سیستم",content:u.jsxs(o,{children:[u.jsx(H,{variant:"body1",color:"secondary",children:"درخواست ابتدا باید توسط استان تایید شود!"}),u.jsx(o,{container:!0,justifyContent:"center",children:u.jsx(o,{item:!0,container:!0,xs:12,justifyContent:"center",mt:2,children:u.jsx(W,{size:"small",color:"success",variant:"contained",onClick:()=>f(Yu()),children:"متوجه شدم"})})})]})})):f(bu({title:"انجام عملیات تخصیص",top:!(window.innerWidth<=600),bottom:window.innerWidth<=600,size:1e3,content:u.jsx(Le,{remainQuantity:t,item:e,id:(E=(v=(b=e==null?void 0:e.poultryRequest)==null?void 0:b.process)==null?void 0:v.poultry)==null?void 0:E.poultryRequestId,orginalQuantity:(z=($=(L=e==null?void 0:e.poultryRequest)==null?void 0:L.process)==null?void 0:$.poultry)==null?void 0:z.poultryQuantity,file:(P=e==null?void 0:e.poultryRequest)==null?void 0:P.process,getItemFreeSaleInProvince:r,updateTable:x})}))},children:u.jsx(Ee,{})})}),u.jsx(Lu,{title:"اتمام",placement:"right",children:u.jsx(xu,{"aria-label":"delete",color:"primary",onClick:()=>{d(),f(wu({title:"آیا مطمئن هستید؟",content:u.jsxs(o,{container:!0,children:[u.jsx(W,{variant:"contained",onClick:()=>{var h,j;f(rr({allocated_number:(h=e==null?void 0:e.quantity)==null?void 0:h.allocatedNumber,final_state:"archive",key:(j=e==null?void 0:e.poultryRequest)==null?void 0:j.key})).then(b=>{f(C0(n)),b.payload.error?p({vertical:"top",horizontal:"center",msg:b.payload.error,severity:"error"}):(f(Yu()),p({vertical:"top",horizontal:"center",msg:"عملیات با موفقیت انجام شد.",severity:"success"}))})},children:"تایید"}),u.jsx(W,{onClick:()=>{f(Yu())},children:"لغو"})]})}))},children:u.jsx(q6,{})})})]})})]})},_r=Au("PROVINCE_EDIT_SEND_DATE",async(e,{dispatch:t})=>{try{t(q());const{data:r,status:x}=await J.put("Poultry_Request/0/",e);return t(V()),{data:r,status:x}}catch(r){return t(V()),{error:r.response.data.result}}}),Dr=({poultryRequestKey:e})=>{const[t]=c.useContext(su),r=m(),x=ku({initialValues:{date:ou(Date()).format("YYYY-MM-DD hh:mm:ss")}});return u.jsxs(o,{container:!0,direction:"column",gap:w.SMALL,children:[u.jsx(yu,{fullWidth:!0,label:"تاریخ",id:"date",renderInput:f=>u.jsx(U,{...f}),value:x.values.date,error:x.touched.date?!!x.errors.date:null,onChange:f=>{x.setFieldValue("date",ou(f).format("YYYY-MM-DD hh:mm:ss"))},onBlur:x.handleBlur,helperText:x.touched.date&&x.errors.date?x.errors.date:null}),u.jsx(W,{variant:"contained",fullWidth:!0,onClick:()=>{r(_r({key:e,send_date:x.values.date})).then(f=>{r(C0()),r(Yu()),f.payload.error?t({vertical:"top",horizontal:"center",msg:f.payload.error,severity:"error"}):t({vertical:"top",horizontal:"center",msg:"عملیات با موفقیت انجام شد.",severity:"success"})})},children:"ثبت"})]})},Lr={hidden:{opacity:0,y:20},visible:{opacity:1,y:0}},kr=()=>{const[,,e,t]=c.useContext(su),r=m();c.useEffect(()=>{const D=ou(new Date).format("YYYY-MM-DD");t(D)},[]);const x=D=>{S(D.target.value)},[f,p]=c.useState([]),[n,l]=c.useState(0),[g,F]=c.useState(10),[A,S]=c.useState(""),[d,h]=c.useState(1),[j,b]=c.useState([]),v=async D=>{r(Qu(e)).then(async()=>{let a;r(q()),a=await J.get(`city_operator_check_request_new/?state=waiting&date=${e}&page=${D}&page_size=${g}&search=filter&value=${A||""}`),r(V()),p(a.data.results),l(a.data.count)})},E=D=>{v(D),h(D)},L=D=>{F(D),h(1)},$=D=>{var M;let a="";return(M=D==null?void 0:D.poultryRequest)!=null&&M.freeSaleInProvince?a="آزاد":a="دولتی",a},z=()=>{v(d!==0?d:1)};c.useEffect(()=>{const D=f==null?void 0:f.map((a,M)=>{var N,R,Y,K,y,C,i,k,B,T,Q,nu,Z,eu,ju,cu,iu,O,_,Cu,vu,Su,Pu,Ou,I,ru,du,hu,fu,_u,Du,Mu,Ru,Bu,Uu,r0,t0,l0,A6,x6,p6,j6,f6,F6,y6,g6,v6;return[d===1?M+1:M+g*(d-1)+1,(N=a==null?void 0:a.poultryRequest)==null?void 0:N.orderCode,$(a),Zu((R=a==null?void 0:a.poultryRequest)==null?void 0:R.createDate),u.jsxs(o,{container:!0,alignItems:"center",justifyContent:"center",width:"100px",children:[u.jsx(H,{variant:"caption",children:pu((Y=a==null?void 0:a.poultryRequest)==null?void 0:Y.sendDate)}),u.jsx(xu,{size:"small",color:"primary",disabled:Number((K=a==null?void 0:a.quantity)==null?void 0:K.allocatedNumber)>0,onClick:()=>{var E6;r(wu({title:"ویرایش تاریخ درخواست کشتار",content:u.jsx(Dr,{poultryRequestKey:(E6=a==null?void 0:a.poultryRequest)==null?void 0:E6.key})}))},children:u.jsx(ge,{fontSize:"small"})})]},(y=a==null?void 0:a.poultryRequest)==null?void 0:y.orderCode),(C=a==null?void 0:a.poultryRequest)!=null&&C.freezing?"انجماد":(i=a==null?void 0:a.poultryRequest)!=null&&i.export?"صادرات":"عادی",`${(T=(B=(k=a==null?void 0:a.poultryRequest)==null?void 0:k.process)==null?void 0:B.poultry)==null?void 0:T.poultryName}/${(Z=(nu=(Q=a==null?void 0:a.poultryRequest)==null?void 0:Q.process)==null?void 0:nu.poultry)==null?void 0:Z.poultryMobile}`,(eu=a==null?void 0:a.poultryRequest)!=null&&eu.killHouseList.length?(cu=(ju=a==null?void 0:a.poultryRequest)==null?void 0:ju.killHouseList)==null?void 0:cu.join(" - "):"-",`${(_=(O=(iu=a==null?void 0:a.poultryRequest)==null?void 0:iu.process)==null?void 0:O.poultry)==null?void 0:_.poultryProvince}/${(Su=(vu=(Cu=a==null?void 0:a.poultryRequest)==null?void 0:Cu.process)==null?void 0:vu.poultry)==null?void 0:Su.poultryCity}`,(Ou=(Pu=a==null?void 0:a.poultryRequest)==null?void 0:Pu.poultry)==null?void 0:Ou.cityOperator,(I=a==null?void 0:a.poultryRequest)==null?void 0:I.killingAge,(hu=(du=(ru=a==null?void 0:a.poultryRequest)==null?void 0:ru.process)==null?void 0:du.poultry)==null?void 0:hu.IndexWeight,(Mu=(Du=(_u=(fu=a==null?void 0:a.poultryRequest)==null?void 0:fu.process)==null?void 0:_u.poultry)==null?void 0:Du.totalWeight)==null?void 0:Mu.toLocaleString(),(r0=(Uu=(Bu=(Ru=a==null?void 0:a.poultryRequest)==null?void 0:Ru.process)==null?void 0:Bu.poultry)==null?void 0:Uu.poultryQuantity)==null?void 0:r0.toLocaleString(),((l0=(t0=a==null?void 0:a.poultryRequest)==null?void 0:t0.amount)==null?void 0:l0.toLocaleString())+" ﷼",u.jsx(H,{color:"green",variant:"caption",fontWeight:"bold",children:(x6=(A6=a==null?void 0:a.quantity)==null?void 0:A6.allocatedNumber)==null?void 0:x6.toLocaleString()},"sss"),(j6=(p6=a==null?void 0:a.quantity)==null?void 0:p6.returnedNumber)==null?void 0:j6.toLocaleString(),(F6=(f6=a==null?void 0:a.quantity)==null?void 0:f6.assignableNumber)==null?void 0:F6.toLocaleString(),u.jsx(Sr,{remainQuantity:(v6=(g6=(y6=a==null?void 0:a.poultryRequest)==null?void 0:y6.process)==null?void 0:g6.poultry)==null?void 0:v6.poultryRemainQuantity,item:a,getItemFreeSaleInProvince:$,updateTable:z},M)]});b(D)},[f]),c.useEffect(()=>{v(1)},[r,e,g]);const P=async D=>{D.preventDefault(),r(q());try{const a=await J.get(`city_operator_check_request_new/?state=waiting&date=${e}&page=1&page_size=${g}&search=filter&value=${A||""}`);p(a.data.results),l(a.data.count),r(V())}catch(a){console.error("Error fetching data:",a)}},{poultryRequestsTotalQuantity:s}=Fu(D=>D.citySlice);return u.jsxs(o,{container:!0,xs:12,justifyContent:"center",alignItems:"center",gap:2,children:[u.jsxs(o,{container:!0,xs:12,justifyContent:"start",alignItems:"center",gap:2,px:{xs:2,sm:0},children:[u.jsx(o,{children:u.jsx(yu,{label:"تاریخ",id:"date",renderInput:D=>u.jsx(U,{style:{width:"160px"},...D,size:"small"}),value:e,onChange:D=>{t(ou(D).format("YYYY-MM-DD"))}})}),u.jsx(o,{children:u.jsxs("form",{onSubmit:P,children:[u.jsx(U,{id:"outlined-basic",size:"small",label:"جستجو",variant:"outlined",style:{width:250},onChange:x}),u.jsx(W,{type:"submit",onClick:P,endIcon:u.jsx(Ku,{}),children:"جستجو"})]})})]}),u.jsx(o,{container:!0,sx:{gap:{xs:"8px 0px",sm:"8px"}},mt:2,justifyContent:"center",alignItems:"center",children:[{label:"تعداد درخواست کشتار",value:(s==null?void 0:s.acceptedQuantity)||0},{label:"اعلام نیاز کشتارگاه ها",value:(s==null?void 0:s.killRequestsQuantity)||0},{label:"تخصیص داده شده",value:(s==null?void 0:s.allocatedQuantity)||0},{label:"قابل تخصیص",value:(s==null?void 0:s.assignableQuantity)||0},{label:"برگشت داده شده",value:(s==null?void 0:s.returnedQuantity)||0}].map((D,a)=>{var M;return u.jsx(o,{item:!0,sx:{width:"250px"},children:u.jsx(X6.div,{variants:Lr,initial:"hidden",animate:"visible",transition:{duration:.5,delay:a*.2},children:u.jsx(F0,{elevation:3,sx:{borderRadius:2},children:u.jsxs(Ue,{children:[u.jsx(H,{color:"red",variant:"subtitle2",gutterBottom:!0,children:D.label}),u.jsxs(H,{variant:"h6",sx:{fontSize:18},children:[(M=D.value)==null?void 0:M.toLocaleString()," قطعه"]})]})})})},a)})}),u.jsx(K6,{px:{xs:1,sm:0},children:u.jsx(zu,{data:j,columns:["ردیف","کد سفارش","نوع فروش","تاریخ ثبت درخواست","تاریخ کشتار","نوع کشتار","مرغدار/تلفن","کشتارگاه انتخابی","استان/شهر","تعاونی","سن مرغ","میانگین وزنی","وزن تقریبی","تعداد","قیمت مرغدار","تخصیص داده شده","برگشت داده شده","قابل تخصیص","عملیات"],handlePageChange:E,totalRows:n,page:d,perPage:g,handlePerRowsChange:L,title:"مدیریت تخصیصات"})})]})},Tr=()=>{const e=m(),t=e6(),{provinceGetActiveRequests:r}=Fu(p=>p.provinceSlice),[x,f]=c.useState([]);return c.useEffect(()=>{e(Xe())},[]),c.useEffect(()=>{const p=r==null?void 0:r.map((n,l)=>{var g,F,A,S,d,h,j,b,v,E,L,$,z,P,s,D,a,M,N,R,Y;return[l+1,(g=n==null?void 0:n.poultryRequest)==null?void 0:g.orderCode,qu(new Date((F=n==null?void 0:n.poultryRequest)==null?void 0:F.createDate),"yyyy/MM/dd"),qu(new Date((A=n==null?void 0:n.poultryRequest)==null?void 0:A.sendDate),"yyyy/MM/dd"),(h=(d=(S=n==null?void 0:n.poultryRequest)==null?void 0:S.process)==null?void 0:d.poultry)==null?void 0:h.poultryName,(v=(b=(j=n==null?void 0:n.poultryRequest)==null?void 0:j.process)==null?void 0:b.poultry)==null?void 0:v.poultryMobile,($=(L=(E=n==null?void 0:n.poultryRequest)==null?void 0:E.process)==null?void 0:L.poultry)==null?void 0:$.poultryCity,(s=(P=(z=n==null?void 0:n.poultryRequest)==null?void 0:z.process)==null?void 0:P.poultry)==null?void 0:s.poultryProvince,(M=(a=(D=n==null?void 0:n.poultryRequest)==null?void 0:D.process)==null?void 0:a.poultry)==null?void 0:M.age,(Y=(R=(N=n==null?void 0:n.poultryRequest)==null?void 0:N.process)==null?void 0:R.poultry)==null?void 0:Y.poultryQuantity,u.jsx(xu,{"aria-label":"delete",color:"primary",onClick:()=>{var K,y,C;t(J0+((C=(y=(K=n==null?void 0:n.poultryRequest)==null?void 0:K.process)==null?void 0:y.poultry)==null?void 0:C.poultryRequestId))},children:u.jsx(b0,{})},l)]});f(p)},[r]),u.jsx(F0,{children:u.jsx(E0,{name:"درخواست های فعال",columns:["ردیف","کد سفارش","تاریخ ثبت درخواست","تاریخ کشتار","مرغدار","تلفن مرغدار","شهر","استان","سن مرغ","تعداد","مشاهده"],data:x})})},Nr=({dataTable:e,item:t,setIsSingleView:r})=>{const x=Array.isArray(e)&&(e==null?void 0:e.reduce((n,l)=>{var g;return n+((g=l.allocations)==null?void 0:g.reduce((F,A)=>F+A.allocationQuantity,0))},0)),f=Array.isArray(e)&&(e==null?void 0:e.reduce((n,l)=>n+l.allocationsSum,0)),p=Array.isArray(e)&&(e==null?void 0:e.reduce((n,l)=>n+l.poultryQuantity,0));return u.jsxs(o,{container:!0,alignItems:"start",my:w.SMALL,children:[u.jsx("table",{className:"auto-allocation-table",children:u.jsxs("tr",{children:[u.jsx("th",{children:u.jsx(o,{children:u.jsxs(W,{color:"error",onClick:()=>{r(null)},children:[u.jsx($n,{}),"بازگشت به بایگانی"]})})}),u.jsxs("th",{children:["کد تخصیص خودکار ",t.allocationOrderCode]}),u.jsxs("th",{children:["تاریخ تخصیص ",pu(t.allocationDate)]})]})}),u.jsxs("table",{className:"auto-allocation-table",children:[u.jsxs("tr",{children:[u.jsx("th",{children:"ردیف"}),u.jsx("th",{children:"نام واحد (مرغدار)"}),u.jsx("th",{children:"تلفن مرغدار"}),u.jsx("th",{children:"آدرس"}),u.jsx("th",{children:"تعداد درخواست کشتار"}),u.jsx("th",{children:"مانده قابل تخصیص"}),u.jsx("th",{children:"ماهیت خریدار"}),u.jsx("th",{children:"نام خریدار"}),u.jsx("th",{children:"تلفن خریدار"}),u.jsx("th",{children:"آدرس"}),u.jsx("th",{children:"محل کشتار"}),u.jsx("th",{children:"تعداد تخصیص"}),u.jsx("th",{children:"جمع مرغ تخصیصی"}),u.jsx("th",{children:"سهم درصد"}),u.jsx("th",{children:"حواله مرغدار"}),u.jsx("th",{children:"حواله خریدار"})]}),e==null?void 0:e.map((n,l)=>{var g;return(g=n==null?void 0:n.allocations)==null?void 0:g.map((F,A)=>{var d,h;const S=(n==null?void 0:n.poultryQuantity)-(n==null?void 0:n.allocationsSum);return u.jsxs("tr",{children:[!A&&u.jsx("td",{rowSpan:n==null?void 0:n.allocations.length,children:l+1}),!A&&u.jsx("td",{rowSpan:n==null?void 0:n.allocations.length,children:n==null?void 0:n.poultryName}),!A&&u.jsx("td",{rowSpan:n==null?void 0:n.allocations.length,children:n==null?void 0:n.poultryMobile}),!A&&u.jsx("td",{rowSpan:n==null?void 0:n.allocations.length,children:n==null?void 0:n.poultryAddress}),!A&&u.jsx("td",{rowSpan:n==null?void 0:n.allocations.length,children:(d=n==null?void 0:n.poultryQuantity)==null?void 0:d.toLocaleString()}),!A&&u.jsx("td",{rowSpan:n==null?void 0:n.allocations.length,children:S.toLocaleString()}),u.jsx("td",{children:F!=null&&F.type?"کشتارکن":"کشتارگاه"}),u.jsx("td",{children:F==null?void 0:F.buyerName}),u.jsx("td",{children:F==null?void 0:F.buyerMobile}),u.jsx("td",{children:F==null?void 0:F.buyerAddress}),u.jsx("td",{children:F==null?void 0:F.KillingPlace}),u.jsx("td",{children:F==null?void 0:F.allocationQuantity}),!A&&u.jsx("td",{rowSpan:n==null?void 0:n.allocations.length,children:(h=n==null?void 0:n.allocationsSum)==null?void 0:h.toLocaleString()}),u.jsxs("td",{children:["%",((F==null?void 0:F.allocationQuantity)/x*100).toFixed(2)]}),!A&&u.jsx("td",{rowSpan:n==null?void 0:n.allocations.length,children:u.jsx(xu,{disabled:!0,color:"primary",children:u.jsx(f0,{})})}),u.jsx("td",{children:u.jsx(xu,{disabled:!0,color:"primary",children:u.jsx(f0,{})})})]},A)})}),u.jsxs("tr",{children:[u.jsx("td",{colSpan:"11",children:"جمع کل"}),u.jsx("td",{children:x.toLocaleString()}),u.jsx("td",{children:f.toLocaleString()}),u.jsx("td",{children:(x/p*100).toFixed(2)})]})]})]})},wr=()=>{const e=m(),[t,r]=c.useState([]),[x,f]=c.useState(),[,,p,n,l,g]=c.useContext(su);c.useEffect(()=>{const A=c0(new Date).format("YYYY-MM-DD");n(A),g(A)},[]);const{provinceGetArchiveAutoAllocations:F}=Fu(A=>A.provinceSlice);return c.useEffect(()=>{e(Je({selectedDate1:p,selectedDate2:l}))},[p,l]),c.useEffect(()=>{const A=F==null?void 0:F.map((S,d)=>[d+1,S.allocationOrderCode,pu(S.allocationDate),S.totalQuantity.toLocaleString(),S.allocatedQuantity.toLocaleString(),S.numberOfPoultry.toLocaleString(),S.numberOfKillHouse.toLocaleString(),u.jsx(xu,{color:"primary",onClick:()=>{f(S)},children:u.jsx(b0,{})},d)]);r(A)},[F]),u.jsxs(o,{mt:w.SMALL,xs:12,px:2,children:[!x&&u.jsx(E0,{name:u.jsxs(o,{container:!0,alignItems:"center",gap:w.SMALL,mb:2,children:[u.jsx(o,{children:u.jsx(H,{children:"بایگانی تخصیصات خودکار"})}),u.jsx(o,{children:u.jsx(yu,{label:"از تاریخ",id:"date",renderInput:A=>u.jsx(U,{style:{width:"160px"},...A}),value:p,onChange:A=>{n(c0(A).format("YYYY-MM-DD"))}})}),u.jsx(o,{children:u.jsx(yu,{label:"تا تاریخ",id:"date",renderInput:A=>u.jsx(U,{style:{width:"160px"},...A}),value:l,onChange:A=>{g(c0(A).format("YYYY-MM-DD"))}})})]}),columns:["ردیف","کد تخصیص خودکار","تاریخ تخصیص","تعداد درخواست کشتار","تعداد تخصیصی","تعداد مرغدار","تعداد کشتارگاه","مشاهده"],data:t}),x&&u.jsx(o,{container:!0,direction:"column",alignItems:"start",gap:w.SMALL,children:u.jsx(Nr,{dataTable:x.allocationsList,item:x,setIsSingleView:f})})]})},Pr=Au("PROVINCE_CREATE_AUTO_ALLOCATION_SERVICE",async(e,{dispatch:t})=>{try{t(q());const{data:r,status:x}=await J.post("automatic_allocation/",e);return t(V()),{data:r,status:x}}catch(r){return t(V()),{error:r.response.data.result}}}),w6=Au("PROVINCE_EDIT_AUTO_ALLOCATION_SERVICE",async(e,{dispatch:t})=>{try{t(q());const{data:r,status:x}=await J.put("automatic_allocation/0/",e);return t(V()),{data:r,status:x}}catch(r){return t(V()),{error:r.response.data.result}}}),Or=({dataTable:e,setDataTable:t,setAddedRows:r,poultryIndex:x})=>{const f=m(),[p,n]=c.useState(null),{provinceGetBuyers:l}=Fu(F=>F.provinceSlice),g=ku({initialValues:{num:""},onSubmit:F=>{}});return c.useEffect(()=>{f(Ze())},[]),u.jsxs(o,{contianer:!0,width:"70%",children:[u.jsx(Hu,{id:"country-select",options:l==null?void 0:l.map(F=>({name:F.debt?`${F.name} (بدهکار)`:F.name,obj:F})),getOptionLabel:F=>F.name,getOptionDisabled:F=>F.disabled,value:p,onChange:(F,A)=>{n(A)},renderInput:F=>u.jsx(U,{...F,label:"انتخاب خریدار",variant:"outlined"})}),u.jsx("div",{style:{marginTop:"10px"}}),u.jsx(ve,{allowLeadingZeros:!0,thousandSeparator:",",fullWidth:!0,id:"num",label:"تعداد مرغ",variant:"outlined",value:g.values.num,error:g.touched.num?!!g.errors.num:null,onChange:g.handleChange,onBlur:g.handleBlur,helperText:g.touched.num&&g.errors.num?g.errors.num:null}),u.jsx("div",{style:{marginTop:"10px"}}),u.jsx(W,{variant:"contained",fullWidth:!0,onClick:()=>{r(F=>{var A;return[...F,{kill_house_key:(A=p==null?void 0:p.obj)==null?void 0:A.key,poultry_request_key:e[x].poultryRequestKey,quantity:Number(g.values.num)}]}),t(F=>{var S,d,h,j,b,v,E;let A=ke(F);return A[x].allocations.push({allocationKey:null,type:(S=p==null?void 0:p.obj)==null?void 0:S.killer,buyerName:p==null?void 0:p.name,buyerMobile:(d=p==null?void 0:p.obj)==null?void 0:d.phone,buyerAddress:(b=(j=(h=p==null?void 0:p.obj)==null?void 0:h.systemAddress)==null?void 0:j.city)==null?void 0:b.name,allocationQuantity:Number(g.values.num),allocationPercent:0,KillingPlace:(v=p==null?void 0:p.obj)==null?void 0:v.killPlace}),A[x].allocationsSum=(E=A[x].allocations)==null?void 0:E.reduce((L,$)=>L+$.allocationQuantity,0),A}),f(Yu())},children:"ثبت"})]})};function ke(e){let t=Array.isArray(e)?[]:{};for(let r in e)typeof e[r]=="object"&&e[r]!==null?t[r]=ke(e[r]):t[r]=e[r];return t}const P6=Au("PROVINCE_DELETE_AUTO_ALLOCATION_SERVICE",async(e,{dispatch:t})=>{try{t(q());const{data:r,status:x}=await J.put("automatic_allocation/0/",e);return t(V()),{data:r,status:x}}catch(r){return t(V()),{error:r.response.data.result}}}),O6=Au("PROVINCE_ADD_AUTO_ALLOCATION_SERVICE",async(e,{dispatch:t})=>{try{t(q());const{data:r,status:x}=await J.put("automatic_allocation/0/",e);return t(V()),{data:r,status:x}}catch(r){return t(V()),{error:r.response.data.result}}}),M6=Au("PROVINCE_SUBMIT_FINAL_AUTO_ALLOCATIONS_SERVICE",async(e,{dispatch:t})=>{try{t(q());const{data:r,status:x}=await J.put("automatic_allocation/0/",e);return t(V()),{data:r,status:x}}catch(r){return t(V()),{error:r.response.data.result}}}),Mr=({handleList:e})=>{function t(L,$){return L.filter(z=>$.indexOf(z)===-1)}function r(L,$){return L.filter(z=>$.indexOf(z)!==-1)}const[x,f]=x0.useState([]),[p,n]=x0.useState([{label:"شهر",key:"city",value:!0},{label:"عدم بدهی",key:"no_debt",value:!0},{label:"حداقل تعداد تخصیص",key:"minimum_allocation",value:!0}]),[l,g]=x0.useState([{label:"شهر محل کشتار",key:"kill_place",value:!0}]),F=r(x,p),A=r(x,l),S=L=>()=>{const $=x.indexOf(L),z=[...x];$===-1?z.push(L):z.splice($,1),f(z)},d=()=>{g(l.concat(p)),n([])},h=()=>{g(l.concat(F)),n(t(p,F)),f(t(x,F))},j=()=>{n(p.concat(A)),g(t(l,A)),f(t(x,A))},b=()=>{n(p.concat(l)),g([])},v=L=>{const $=p.find(P=>P.key==="minimum_allocation"),z=l.find(P=>P.key==="minimum_allocation");$?n(P=>[...P.filter(s=>s.key!=="minimum_allocation"),{...$,value:L.target.value}]):z&&g(P=>[...P.filter(s=>s.key!=="minimum_allocation"),{...z,value:L.target.value}])};c.useEffect(()=>{e(l)},[l]);const E=L=>u.jsx(V6,{sx:{width:"100%",height:150,overflow:"auto"},children:u.jsx(Q6,{dense:!0,component:"div",role:"list",children:L.map(($,z)=>{const P=`transfer-list-item-${$}-label`;return u.jsx(We,{role:"listitem",onClick:S($),children:u.jsxs(o,{container:!0,alignItems:"center",children:[u.jsx(s0,{children:u.jsx(X0,{checked:x.indexOf($)!==-1,tabIndex:-1,disableRipple:!0,inputProps:{"aria-labelledby":P}})}),u.jsx(o0,{id:P,primary:`${z+1}. ${$.label}`}),$.label==="حداقل تعداد تخصیص"&&u.jsx(o,{children:u.jsx(U,{label:"تعداد",type:"number",style:{width:"100px"},value:$.value,onChange:v,size:"small"})})]})},$)})})});return u.jsxs(o,{container:!0,spacing:2,justifyContent:"center",alignItems:"center",mt:w.TINY,width:"100%",children:[u.jsxs(o,{item:!0,flex:1,children:[u.jsx(H,{children:"انتخاب اولویت های تخصیص خودکار"}),E(p)]}),u.jsx(o,{item:!0,flex:1,children:u.jsxs(o,{container:!0,direction:"column",alignItems:"center",children:[u.jsx(W,{sx:{my:.5},variant:"outlined",size:"large",onClick:d,disabled:!0,"aria-label":"move all right",children:"≫"}),u.jsx(W,{sx:{my:.5},variant:"outlined",size:"large",onClick:h,disabled:!0,"aria-label":"move selected right",children:">"}),u.jsx(W,{sx:{my:.5},variant:"outlined",size:"large",onClick:j,disabled:!0,"aria-label":"move selected left",children:"<"}),u.jsx(W,{sx:{my:.5},variant:"outlined",size:"large",onClick:b,disabled:!0,"aria-label":"move all left",children:"≪"})]})}),u.jsxs(o,{item:!0,flex:1,children:[u.jsx(H,{children:"اولویت های انتخاب شده تخصیص خودکار"}),E(l)]})]})},$r=()=>{var R,Y,K,y,C;const e=m(),[t]=c.useContext(su),[r,x]=c.useState([]),[f,p]=c.useState([]),[n,l]=c.useState([]),[g,F]=c.useState({}),[A,S]=c.useState(null),d=!!A,h=d?"popoverr":void 0,j=i=>{S(i.currentTarget)},b=()=>{S(null)};c.useEffect(()=>{b()},[]);const{poultryRequestsTotalQuantity:v}=Fu(i=>i.citySlice),{provinceGetAutoAllocations:E}=Fu(i=>i.provinceSlice);c.useEffect(()=>{e(a0())},[]),c.useEffect(()=>{x(Xu(E))},[E]);const L=()=>{const i=r==null?void 0:r.reduce((k,B)=>{let T=Xu(B.allocations);return T=T.filter(Q=>Q.allocationKey),[...k,...T]},[]);e(P6({allocation_delete_list:f==null?void 0:f.filter(k=>k.allocationKey)})).then(()=>{p([]),e(O6({allocation_add_list:n})).then(()=>{e(w6({allocation_list:i})).then(k=>{l([]),k.payload.error?t({vertical:"top",horizontal:"center",msg:k.payload.error,severity:"error"}):(e(Qu()),e(a0()),t({vertical:"top",horizontal:"center",msg:"عملیات با موفقیت انجام شد.",severity:"success"}))})})})},$=()=>r.map(B=>B.allocations.some(Q=>Q.debt)).some(B=>B),z=()=>{const i=r==null?void 0:r.reduce((k,B)=>{let T=Xu(B.allocations);return T=T.filter(Q=>Q.allocationKey),[...k,...T]},[]);e(P6({allocation_delete_list:f==null?void 0:f.filter(k=>k.allocationKey)})).then(()=>{p([]),e(O6({allocation_add_list:n})).then(()=>{e(w6({allocation_list:i})).then(()=>{l([]);const B=(E==null?void 0:E.reduce((T,Q)=>[...T,...Q.allocations],[])).map(T=>({allocationKey:T.allocationKey}));e(M6({final_registration_list:B})).then(T=>{T.payload.error?t({vertical:"top",horizontal:"center",msg:T.payload.error,severity:"error"}):(e(Qu()),e(a0()),t({vertical:"top",horizontal:"center",msg:"عملیات با موفقیت انجام شد.",severity:"success"}))})})})})},P=Array.isArray(r)&&(r==null?void 0:r.reduce((i,k)=>{var B;return i+((B=k.allocations)==null?void 0:B.reduce((T,Q)=>T+Q.allocationQuantity,0))},0)),s=Array.isArray(r)&&(r==null?void 0:r.reduce((i,k)=>i+k.allocationsSum,0)),D=Array.isArray(r)&&(r==null?void 0:r.reduce((i,k)=>i+k.poultryQuantity,0)),[a,M]=c.useState(c0(new Date).format("YYYY-MM-DD"));c.useEffect(()=>{e(Qu(a))},[a]);const N=i=>{const k=i.map(B=>({[B.key]:B.value}));F(k)};return u.jsxs(o,{container:!0,my:w.SMALL,direction:"column",alignItems:"start",xs:12,pt:2,px:2,children:[u.jsx(_0,{name:u.jsx(o,{xs:12,mb:2,children:u.jsx(yu,{label:"تاریخ تخصیص",id:"date",renderInput:i=>u.jsx(U,{style:{width:"180px"},...i}),value:a,onChange:i=>{M(c0(i).format("YYYY-MM-DD"))}})}),columns:["تعداد کل درخواست کشتار","تخصیص داده شده","قابل تخصیص","تعداد خریداران آماده به تخصیص","تعداد مرغدار"],data:[[`${(R=v==null?void 0:v.acceptedQuantity)==null?void 0:R.toLocaleString()} قطعه`,`${(Y=v==null?void 0:v.allocatedQuantity)==null?void 0:Y.toLocaleString()} قطعه`,`${(K=v==null?void 0:v.assignableQuantity)==null?void 0:K.toLocaleString()} قطعه`,`${(y=v==null?void 0:v.numberOfKillHouse)==null?void 0:y.toLocaleString()} واحد`,`${(C=v==null?void 0:v.numberOfPoultry)==null?void 0:C.toLocaleString()} واحد`]]}),u.jsx(o,{container:!0,gap:w.SMALL,my:w.SMALL,justifyContent:"center",alignItems:"center",width:"100%",children:u.jsxs(o,{container:!0,alignItems:"center",justifyContent:"center",direction:"column",gap:w.SMALL,width:"100%",children:[u.jsx(H,{fontWeight:"bold",children:"اولویت بندی کشتارگاه"}),u.jsx(Mr,{handleList:N}),u.jsx(o,{children:u.jsx(W,{variant:"contained",color:"primary",disabled:r.length,onClick:()=>{e(Pr({date:a,filter_list:g})).then(i=>{i.payload.error?t({vertical:"top",horizontal:"center",msg:i.payload.error,severity:"error"}):(e(Qu()),e(a0()),t({vertical:"top",horizontal:"center",msg:"عملیات با موفقیت انجام شد.",severity:"success"}))})},children:"ایجاد تخصیص خودکار"})})]})}),!!(r!=null&&r.length)&&u.jsxs(u.Fragment,{children:[u.jsx(o,{mb:w.SMALL,children:u.jsx(H,{fontWeight:"bold",color:"error",children:"* توجه: رنگ قرمز خریدار نشان دهنده بدهی قبلی است."})}),u.jsxs("table",{className:"auto-allocation-table",children:[u.jsxs("tr",{children:[u.jsx("th",{children:"ردیف"}),u.jsx("th",{children:"واحد (مرغدار)"}),u.jsx("th",{children:"تعداد درخواست کشتار"}),u.jsx("th",{children:"وزن تقریبی درخواست کشتار"}),u.jsx("th",{children:"مانده قابل تخصیص"}),u.jsx("th",{children:"اضافه"}),u.jsx("th",{children:"ماهیت خریدار"}),u.jsx("th",{children:"خریدار"}),u.jsx("th",{children:"محل کشتار"}),u.jsx("th",{children:"تعداد تخصیص"}),u.jsx("th",{children:"جمع مرغ تخصیصی"}),u.jsx("th",{children:"سهم درصد"}),u.jsx("th",{children:"حواله مرغدار"}),u.jsx("th",{children:"حواله خریدار"}),u.jsx("th",{children:"حذف"})]}),r==null?void 0:r.map((i,k)=>{var B;return(B=i==null?void 0:i.allocations)==null?void 0:B.map((T,Q)=>{var Z,eu,ju;let nu=(i==null?void 0:i.poultryQuantity)-(i==null?void 0:i.allocationsSum);return u.jsxs("tr",{children:[!Q&&u.jsx("td",{rowSpan:i==null?void 0:i.allocations.length,style:{backgroundColor:k%2===0?"#fff":"#f2f2f2"},children:k+1}),!Q&&u.jsxs("td",{rowSpan:i==null?void 0:i.allocations.length,style:{backgroundColor:k%2===0?"#fff":"#f2f2f2"},children:[i==null?void 0:i.poultryName," (",i==null?void 0:i.poultryAddress,") (",i==null?void 0:i.poultryMobile,")"]}),!Q&&u.jsx("td",{rowSpan:i==null?void 0:i.allocations.length,style:{backgroundColor:k%2===0?"#fff":"#f2f2f2"},children:(Z=i==null?void 0:i.poultryQuantity)==null?void 0:Z.toLocaleString()}),!Q&&u.jsxs("td",{rowSpan:i==null?void 0:i.allocations.length,style:{backgroundColor:k%2===0?"#fff":"#f2f2f2"},children:["وزن تقریبی:"," ",(eu=i==null?void 0:i.poultryRequestWeight)==null?void 0:eu.toLocaleString(),u.jsx("hr",{}),"میانگین وزن:"," ",i==null?void 0:i.poultryRequestIndexWeight]}),!Q&&u.jsx("td",{rowSpan:i==null?void 0:i.allocations.length,style:{backgroundColor:k%2===0?"#fff":"#f2f2f2"},children:nu.toLocaleString()}),!Q&&u.jsx("td",{rowSpan:i==null?void 0:i.allocations.length,style:{backgroundColor:k%2===0?"#fff":"#f2f2f2"},children:u.jsx(xu,{color:"primary",onClick:()=>{e(wu({title:"اضافه کردن خریدار",content:u.jsx(Or,{dataTable:r,poultryIndex:k,setDataTable:x,setAddedRows:l})}))},children:u.jsx(Fe,{})})}),u.jsxs("td",{style:{backgroundColor:k%2===0?"#fff":"#f2f2f2",color:T.debt?"red":""},children:[T!=null&&T.type?"کشتارکن":"کشتارگاه"," ",T.debt?"(بدهکار)":""]}),u.jsxs("td",{style:{backgroundColor:k%2===0?"#fff":"#f2f2f2",color:T.debt?"red":""},children:[T==null?void 0:T.buyerName," (",T==null?void 0:T.buyerAddress,") (",T==null?void 0:T.buyerMobile,")"]}),u.jsx("td",{style:{backgroundColor:k%2===0?"#fff":"#f2f2f2",color:T.debt?"red":""},children:T==null?void 0:T.KillingPlace}),u.jsx("td",{style:{backgroundColor:k%2===0?"#fff":"#f2f2f2"},children:u.jsx(U,{style:{width:"100px"},type:"number",color:T.debt?"error":"",inputProps:{style:{color:T.debt?"red":""}},value:T==null?void 0:T.allocationQuantity,onChange:cu=>{if(Number(cu.target.value)<1){t({vertical:"top",horizontal:"center",msg:"در صورت نیاز به کاهش کمتر از 1 از گزینه حذف استفاده نمایید.",severity:"error"});return}x(iu=>{var _;let O=Xu(iu);return O[k].allocations[Q].allocationQuantity=Number(cu.target.value),O[k].allocationsSum=(_=O[k].allocations)==null?void 0:_.reduce((Cu,vu)=>Cu+vu.allocationQuantity,0),O})}})}),!Q&&u.jsx("td",{rowSpan:i==null?void 0:i.allocations.length,style:{backgroundColor:k%2===0?"#fff":"#f2f2f2",color:T.debt?"red":""},children:(ju=i==null?void 0:i.allocationsSum)==null?void 0:ju.toLocaleString()}),u.jsxs("td",{style:{backgroundColor:k%2===0?"#fff":"#f2f2f2",color:T.debt?"red":""},children:["%",((T==null?void 0:T.allocationQuantity)/P*100).toFixed(2)]}),!Q&&u.jsx("td",{rowSpan:i==null?void 0:i.allocations.length,style:{backgroundColor:k%2===0?"#fff":"#f2f2f2"},children:u.jsx(xu,{disabled:!0,color:"primary",children:u.jsx("a",{href:`https://core-inventory.iran.liara.run/pdf/aviculture-remittance?poultryRequestKey=${i.poultryRequestKey}&which=${window.location.origin}`,children:u.jsx(f0,{})})})}),u.jsx("td",{style:{backgroundColor:k%2===0?"#fff":"#f2f2f2"},children:u.jsx(xu,{disabled:!0,color:"primary",children:u.jsx("a",{href:`https://core-inventory.iran.liara.run/pdf/buyer-remittance?allocationKey=${T.allocationKey}&which=${window.location.origin}`,children:u.jsx(f0,{})})})}),u.jsx("td",{style:{backgroundColor:k%2===0?"#fff":"#f2f2f2"},children:u.jsx(xu,{color:"error",onClick:()=>{x(cu=>{var O;let iu=Xu(cu);return p([...f,iu[k].allocations[Q]]),iu[k].allocations.splice(Q,1),iu[k].allocationsSum=(O=iu[k].allocations)==null?void 0:O.reduce((_,Cu)=>_+Cu.allocationQuantity,0),iu})},children:u.jsx(n6,{})})})]},Q)})}),u.jsxs("tr",{children:[u.jsx("td",{colSpan:"10",children:"جمع کل"}),u.jsx("td",{children:P.toLocaleString()}),u.jsx("td",{children:s.toLocaleString()}),u.jsxs("td",{children:["%",(P/D*100).toFixed(2)]}),u.jsxs("td",{colSpan:3,children:[u.jsx(W,{"aria-describedby":h,variant:"contained",color:"primary",onClick:j,fullWidth:!0,children:"عملیات"}),u.jsx(y0,{anchorOrigin:{vertical:"bottom",horizontal:"right"},transformOrigin:{vertical:"top",horizontal:"left"},id:h,open:d,anchorEl:A,onClose:b,children:u.jsx("div",{style:{padding:"20px"},children:u.jsxs(o,{container:!0,direction:"column",gap:w.TINY,children:[u.jsx(W,{variant:"contained",color:"success",onClick:()=>{L()},children:"ثبت موقت"}),u.jsx(W,{variant:"contained",color:"error",onClick:()=>{const k=(E==null?void 0:E.reduce((B,T)=>[...B,...T.allocations],[])).map(B=>({allocationKey:B.allocationKey}));e(M6({cancellation:k})).then(B=>{B.payload.error?t({vertical:"top",horizontal:"center",msg:B.payload.error,severity:"error"}):(e(Qu()),e(a0()),t({vertical:"top",horizontal:"center",msg:"عملیات با موفقیت انجام شد.",severity:"success"}))})},children:"لغو تخصیص خودکار"}),u.jsx(W,{variant:"contained",onClick:()=>{$()?(t({vertical:"top",horizontal:"center",msg:"عدم بدهی در اولویت تخصیص خودکار شما می باشد. لطفا تخصیص را مدیریت نمایید.",severity:"error"}),b()):(z(),b())},children:"ثبت نهایی"})]})})})]})]})]})]}),!r.length&&u.jsx(o,{container:!0,children:u.jsx(H,{children:"تخصیص خودکار ایجاد نشده است!"})})]})};function Xu(e){let t=Array.isArray(e)?[]:{};for(let r in e)typeof e[r]=="object"&&e[r]!==null?t[r]=Xu(e[r]):t[r]=e[r];return t}const L0=Au("PROVINCE_SET_SLAUGHTERHOUSES_QUOTA_SERVICE",async(e,{dispatch:t})=>{try{t(q());const{data:r,status:x}=await J.put("kill_house_percent/0/",e);return t(V()),{data:r,status:x}}catch(r){return t(V()),{error:r.response.data.result}}}),Ir=({item:e})=>{const t=m(),[r,x]=c.useState(null),[f,p]=c.useState([]),[n,l]=c.useState([]);c.useEffect(()=>{const d=n==null?void 0:n.map(h=>{var j,b,v,E,L;return[h==null?void 0:h.guildsName,(j=h==null?void 0:h.user)==null?void 0:j.fullname,(b=h==null?void 0:h.user)==null?void 0:b.mobile,(v=h==null?void 0:h.allocationLimit)==null?void 0:v.toLocaleString(),(L=(E=h==null?void 0:h.address)==null?void 0:E.city)==null?void 0:L.name]});p(d)},[n]);const g=d=>{x(d.currentTarget)},F=()=>{x(null)},A=!!r,S=A?e.key:void 0;return c.useEffect(()=>{t(qe({key:e.key})).then(d=>l(d.payload.data))},[]),u.jsxs(o,{container:!0,alignItems:"center",justifyContent:"center",children:[u.jsx(H,{onClick:g,variant:"caption",color:"success",style:{cursor:"pointer"},children:e.guildsQuantity}),u.jsx(y0,{id:S,open:A,anchorEl:r,onClose:F,anchorOrigin:{vertical:"bottom",horizontal:"right"},transformOrigin:{vertical:"top",horizontal:"left"},children:u.jsx(o,{width:"500px",children:u.jsx(_0,{columns:["نام صنف","نام","تلفن","وزن (کیلوگرم)","شهر"],data:f})})})]})},zr=Iu({percent:$u().typeError("لطفا عدد وارد کنید").min(0,"باید برابر یا بزرگتر از 0 باشد").max(100,"باید کوچکتر یا برابر با 100 باشد").required("درصد الزامی است")}),Rr=({percent:e,slaughterKey:t,onPercentChange:r})=>{const x=ku({initialValues:{percent:e},validationSchema:zr,onSubmit:f=>{}});return c.useEffect(()=>{x.setFieldValue("percent",e)},[e]),u.jsx(o,{container:!0,justifyContent:"center",children:u.jsx(U,{size:"small",name:"percent",type:"number",className:"percent-input-quota",value:x.values.percent,onChange:f=>{r(t,Number(f.target.value)),x.setFieldValue("percent",f.target.value)},onBlur:x.handleBlur,error:x.touched.percent&&!!x.errors.percent,helperText:x.touched.percent&&x.errors.percent,InputProps:{startAdornment:u.jsx("span",{children:"%"})},inputProps:{step:.1},style:{width:100,textAlign:"center"}})})},Br=()=>{var A;const e=m(),[t,r]=c.useState(),[x,f]=c.useState([]),[p]=c.useContext(su),{provinceGetSlaughterhousesQuota:n}=Fu(S=>S.provinceSlice),l=(S,d)=>{f(h=>{const j=h.filter(E=>E.key!==S),b=h.filter(E=>E.key===S)[0],v={key:S,percent:d,killer_kill_house_key:b==null?void 0:b.killer_kill_house_key};return j.push(v),j})},g=(S,d)=>{f(h=>{const j=h.findIndex(L=>L.key===S),b=h[j],v=h.filter(L=>L.key!==S),E={...b,killer_kill_house_key:d};return v.push(E),v})};c.useEffect(()=>{e(h0()),e(me())},[]),c.useEffect(()=>{const S=[],d=n==null?void 0:n.map((h,j)=>{var v,E,L,$,z,P,s,D,a,M,N,R,Y,K,y,C,i;const b=(v=h==null?void 0:h.killHouse)!=null&&v.killer?"کشتارکن":"کشتارگاه";return S.push({key:h.key,percent:h.percent,killer_kill_house_key:(E=h==null?void 0:h.killHouseForKiller)==null?void 0:E.key}),[u.jsx(X0,{defaultChecked:!0},j),j+1,b,(L=h.killHouse)==null?void 0:L.name,(P=(z=($=h.killHouse)==null?void 0:$.killHouseOperator)==null?void 0:z.user)==null?void 0:P.fullname,`${(a=(D=(s=h.killHouse)==null?void 0:s.systemAddress)==null?void 0:D.province)==null?void 0:a.name} - ${(R=(N=(M=h.killHouse)==null?void 0:M.systemAddress)==null?void 0:N.city)==null?void 0:R.name} - ${(K=(Y=h.killHouse)==null?void 0:Y.systemAddress)==null?void 0:K.address}`,(y=h==null?void 0:h.killHouse)!=null&&y.killer?u.jsx(In,{onSlaughterChange:g,slaughterKey:h.key,killHouseForKiller:h.killHouseForKiller,disabled:!0},((C=h.killHouse)==null?void 0:C.name)+j):(i=h.killHouse)==null?void 0:i.name,u.jsx(Rr,{slaughterKey:h.key,onPercentChange:l,percent:h.percent},j),u.jsx(Ir,{item:h},h.key),h.guildsWeight]});f(S),r(d)},[n]);const F=x==null?void 0:x.reduce((S,d)=>S+d.percent,0);return u.jsxs(o,{display:"flex",width:"100%",direction:"column",alignItems:"end",style:{flexDirection:"column"},mt:w.SMALL,pb:w.LARGE,px:2,children:[u.jsxs(o,{container:!0,alignItems:"center",justifyContent:"space-between",mb:w.TINY,width:"100%",children:[u.jsx(o,{children:u.jsxs(H,{style:{color:"green"},children:["تاریخ آخرین بروزرسانی:"," ",(n==null?void 0:n.length)&&pu((A=n[0])==null?void 0:A.lastGuildsUpdateDate)]})}),u.jsxs(o,{container:!0,gap:w.TINY,children:[u.jsx(W,{variant:"contained",onClick:()=>{e(L0({percentage_list:x,type:"guild"})).then(S=>{S.payload.error?p({vertical:"top",horizontal:"center",msg:S.payload.error,severity:"error"}):(e(h0()),p({vertical:"top",horizontal:"center",msg:"عملیات با موفقیت انجام شد.",severity:"success"}))})},children:"بروزرسانی بر اساس واحد"}),u.jsx(W,{variant:"contained",onClick:()=>{e(L0({percentage_list:x,type:"guilds_weight"})).then(S=>{S.payload.error?p({vertical:"top",horizontal:"center",msg:S.payload.error,severity:"error"}):(e(h0()),p({vertical:"top",horizontal:"center",msg:"عملیات با موفقیت انجام شد.",severity:"success"}))})},children:"بروزرسانی بر اساس وزن"})]})]}),u.jsx(_0,{columns:["وضعیت","ردیف","ماهیت","نام واحد","نام و نام خانوادگی","آدرس","محل کشتار","سهم روزانه (درصد)","تعداد زیرمجموعه ها (واحد)","زیرمجموعه (وزن)"],data:t}),u.jsxs(o,{container:!0,gap:w.SMALL,mx:w.SMALL,mt:w.TINY,style:{position:"fixed",bottom:"4px",padding:"10px",borderRadius:"10px",background:"#3c3c3c",color:"white",justifyContent:"center",alignItems:"center",zIndex:99999999999},children:[u.jsx(H,{children:"جمع کل درصد ها"}),u.jsxs(H,{children:[F.toFixed(2),"%"]}),u.jsx(W,{variant:"contained",disabled:F.toFixed(2)!==100 .toFixed(2),onClick:()=>{e(L0({percentage_list:x,type:"manual"})).then(S=>{S.payload.error?p({vertical:"top",horizontal:"center",msg:S.payload.error,severity:"error"}):(e(h0()),p({vertical:"top",horizontal:"center",msg:"عملیات با موفقیت انجام شد.",severity:"success"}))})},children:"ثبت"})]})]})},Ur=()=>{const[e,t]=c.useState(0),r=(x,f)=>{t(f)};return u.jsxs(o,{container:!0,justifyContent:"center",xs:12,children:[u.jsx(o,{container:!0,xs:12,justifyContent:"center",children:u.jsxs(g0,{value:e,onChange:r,"aria-label":"simple tabs example",children:[u.jsx(Nu,{label:"تخصیص خودکار"}),u.jsx(Nu,{label:"سهم بندی کشتارگاه"}),u.jsx(Nu,{label:"بایگانی"})]})}),e===0&&u.jsx($r,{}),e===1&&u.jsx(Br,{}),e===2&&u.jsx(wr,{})]})},G={page:{width:"210mm",margin:"0 auto",display:"flex",flexDirection:"column",position:"relative",direction:"rtl",fontFamily:"nazanin",fontWeight:"bold"},container:{width:"95%",alignSelf:"center",pageBreakInside:"avoid"},invoiceTable:{width:"100%",borderCollapse:"collapse",alignSelf:"center"},tableCell:{border:"1px solid #000",pAlign:"left",textAlign:"center",fontSize:11},tableCellMobile:{border:"1px solid #000",pAlign:"left",textAlign:"center",fontSize:10},tableInnerCell:{border:"1px solid #000",pAlign:"left",textAlign:"center",fontSize:8,whiteSpace:"nowrap"},tableHeader:{pageBreakAfter:"auto"},headerRow:{color:"black",pageBreakInside:"avoid",pageBreakAfter:"auto"},tableRowEven:{backgroundColor:"rgba(170, 183, 255, 0.3)"},logo:{width:"60px",height:"auto",marginBottom:"10px"},contentContainer:{display:"flex",justifyContent:"space-between",marginTop:"20px",marginLeft:"100px",marginRight:"30px"},contentInLine:{display:"flex",flexDirection:"column",alignItems:"center"},mainTitle:{fontFamily:"nazanin",fontSize:11,pAlign:"center",fontWeight:"bolder"},signature:{display:"flex",flexDirection:"column",alignItems:"flex-end",marginLeft:"20px"},watermarkContainer:{position:"fixed",top:450,left:0,right:30,bottom:0,justifyContent:"center",alignItems:"center",opacity:.2,zIndex:-1},watermarkp:{fontSize:100,fontWeight:"bolder",color:"grey",transform:"rotate(-45deg)",left:"50%"},title:{fontSize:12,fontWeight:"bolder",pAlign:"center"},titleTopic:{marginTop:"10px",fontSize:12,fontWeight:"bolder",pAlign:"center"},firsttitle:{fontSize:14,fontWeight:"bolder",marginLeft:"40px",pAlign:"center"},options:{padding:"10px",marginTop:"15px",display:"flex",flexDirection:"column",alignItems:"flex-start"},divider:{width:"100%",height:"2px",backgroundColor:"red",marginBottom:15},pTitleContainer:{pAlign:"right",margin:"15px",textAlign:"justify",textJustify:"inter-word"},tableHeaderCell:{backgroundColor:"rgba(255, 229, 153, 0.5)",fontSize:10,border:"1px solid #000",padding:"4px",textAlign:"center",fontWeight:"bold"}},c6=c.forwardRef((e,t)=>{const{sDate:r}=e,{date:x}=e,{fnumber:f}=e,{receiver:p}=e,{item:n}=e,l=Z0(),g=q0(),F=n==null?void 0:n.reduce((d,h)=>d+((h==null?void 0:h.quantity)||0),0);function A(d){let h=0;return d==null||d.forEach(j=>{j!=null&&j.provinceKillRequests&&j.provinceKillRequests.forEach(b=>{var v;((v=b.info)==null?void 0:v.quantity)!==void 0&&(h+=b.info.quantity)})}),h}function S(d){let h=0;return d==null||d.forEach(j=>{j!=null&&j.provinceKillRequests&&j.provinceKillRequests.forEach(b=>{var v;((v=b.info)==null?void 0:v.weight)!==void 0&&(h+=b.info.weight)})}),h}return u.jsxs("div",{style:G.page,ref:t,children:[u.jsxs("div",{style:G.contentContainer,children:[u.jsxs("div",{style:G.contentInLine,children:[u.jsx("img",{alt:"logo",src:r6,style:G.logo}),u.jsx("span",{style:G.mainTitle,children:"اتحادیه سراسری تعاونی‌های کشاورزی پرورش دهندگان مرغ گوشتی ایران"}),u.jsxs("span",{style:G.title,children:["اتحادیه شرکت های تعاونی کشاورزی مرغداران "," "," ",l]})]}),u.jsx("div",{children:u.jsx("span",{style:G.firsttitle,children:"بسمه تعالی"})}),u.jsxs("div",{style:G.options,children:[u.jsxs("span",{style:G.title,children:["شماره: ",f]}),u.jsxs("span",{style:G.titleTopic,children:["تاریخ: ",pu(x)]}),u.jsx("span",{style:G.titleTopic,children:"پیوست:"})]})]}),u.jsx("hr",{style:G.divider}),u.jsxs("p",{style:G.pTitleContainer,children:[u.jsxs("strong",{style:{fontSize:"20px"},children:[p,u.jsx("br",{}),"با سلام",u.jsx("br",{})]}),u.jsx("br",{}),"احتراماً گزارش تخصیص و کشتار مورخ ",pu(r),"، مرغ گوشتی استان جهت استحضار بحضورتان ارسال میگردد."]}),u.jsxs("div",{style:G.container,children:[u.jsxs("p",{style:{marginTop:"40px"},children:["اطلاعات تخصیص:"," ",u.jsxs("span",{style:{color:"green",fontWeight:"boler"},children:[" ","تعداد درخواست کشتار (",F!==void 0&&F.toLocaleString()," ","قطعه)، تخصیص داده شده (",A(n).toLocaleString()," ","قطعه)، وزن کل تخصیص ("," ",Math.round(S(n)).toLocaleString()," کیلوگرم)."]})]}),u.jsxs("table",{style:G.invoiceTable,children:[u.jsx("thead",{style:G.tableHeader,children:u.jsxs("tr",{style:G.headerRow,children:[u.jsx("th",{style:G.tableHeaderCell,children:"ردیف"}),u.jsx("th",{style:G.tableHeaderCell,children:"مرغدار"}),u.jsx("th",{style:G.tableHeaderCell,children:"تلفن"}),u.jsx("th",{style:G.tableHeaderCell,children:"شهر"}),u.jsx("th",{style:G.tableHeaderCell,children:"تعداد"}),u.jsx("th",{style:G.tableHeaderCell,children:"میانگین وزنی"}),u.jsx("th",{style:G.tableHeaderCell,children:"سن"}),u.jsx("th",{style:G.tableHeaderCell,children:"خریدار"}),u.jsx("th",{style:G.tableHeaderCell,children:"تعداد"}),u.jsx("th",{style:G.tableHeaderCell,children:"وزن تقریبی بار"}),u.jsx("th",{style:G.tableHeaderCell,children:"محل کشتار"})]})}),u.jsx("tbody",{children:n==null?void 0:n.map((d,h)=>{var j,b,v,E,L,$,z,P,s,D,a,M;return u.jsxs("tr",{style:h%2===0?G.tableRowEven:{},children:[u.jsx("td",{style:G.tableCell,children:h+1}),u.jsx("td",{style:G.tableCell,children:(b=(j=d==null?void 0:d.poultry)==null?void 0:j.user)==null?void 0:b.fullname}),u.jsx("td",{style:G.tableCellMobile,children:(E=(v=d==null?void 0:d.poultry)==null?void 0:v.user)==null?void 0:E.mobile}),u.jsx("td",{style:G.tableCell,children:(z=($=(L=d==null?void 0:d.poultry)==null?void 0:L.address)==null?void 0:$.city)==null?void 0:z.name}),u.jsx("td",{style:G.tableCell,children:d==null?void 0:d.quantity.toLocaleString()}),u.jsx("td",{style:G.tableCell,children:d==null?void 0:d.IndexWeight.toLocaleString()}),u.jsx("td",{style:G.tableCell,children:(P=d==null?void 0:d.hatching)==null?void 0:P.age}),u.jsx("td",{style:G.tableInnerCell,children:(s=d==null?void 0:d.provinceKillRequests)==null?void 0:s.map((N,R,Y)=>{var K,y,C,i,k,B;return u.jsxs(u.Fragment,{children:[(C=(y=(K=N==null?void 0:N.killhouseUser)==null?void 0:K.killHouseOperator)==null?void 0:y.user)!=null&&C.fullname?(B=(k=(i=N==null?void 0:N.killhouseUser)==null?void 0:i.killHouseOperator)==null?void 0:k.user)==null?void 0:B.fullname:"............",u.jsx("br",{}),R<Y.length-1&&u.jsx("div",{style:{borderBottom:"1px solid #000"}})]})})}),u.jsx("td",{style:G.tableInnerCell,children:(D=d==null?void 0:d.provinceKillRequests)==null?void 0:D.map((N,R,Y)=>{var K,y;return u.jsxs(u.Fragment,{children:[(K=N==null?void 0:N.info)!=null&&K.quantity?(y=N==null?void 0:N.info)==null?void 0:y.quantity.toLocaleString():"............",u.jsx("br",{}),R<Y.length-1&&u.jsx("div",{style:{borderBottom:"1px solid #000"}})]})})}),u.jsx("td",{style:G.tableInnerCell,children:(a=d==null?void 0:d.provinceKillRequests)==null?void 0:a.map((N,R,Y)=>{var K,y;return u.jsxs(u.Fragment,{children:[Math.round((K=N==null?void 0:N.info)==null?void 0:K.weight)?Math.round((y=N==null?void 0:N.info)==null?void 0:y.weight).toLocaleString():"............",u.jsx("br",{}),R<Y.length-1&&u.jsx("div",{style:{borderBottom:"1px solid #000"}})]})})}),u.jsx("td",{style:G.tableInnerCell,children:(M=d==null?void 0:d.provinceKillRequests)==null?void 0:M.map((N,R,Y)=>{var K,y;return u.jsxs(u.Fragment,{children:[(K=N==null?void 0:N.info)!=null&&K.killPlace?(y=N==null?void 0:N.info)==null?void 0:y.killPlace:"............",u.jsx("br",{}),R<Y.length-1&&u.jsx("div",{style:{borderBottom:"1px solid #000"}})]})})})]},h)})})]})]}),u.jsxs("div",{style:{flexDirection:"row",marginTop:"20px"},children:[u.jsx("div",{style:G.signature,children:u.jsxs("div",{style:G.contentInLine,children:[u.jsx("span",{style:G.title,children:g}),u.jsxs("span",{style:G.title,children:["مدیرعامل اتحادیه مرغداران"," ",l]})]})}),u.jsx("div",{style:G.watermarkContainer,children:u.jsx("p",{style:G.watermarkp,children:"سامانه رصدیار "})})]})]})});c6.displayName="ProvinceSendLetterFactor";c6.propTypes={item:u0.PropTypes.any};const Wr=Au("PROVINCE_GET_ALLOCATION_LETTER",async(e,{dispatch:t})=>{t(q());const{data:r,status:x}=await J.get("poultry_request_letter/?date="+e);return t(V()),{data:r,status:x}}),Yr=()=>{var S;const[,,e,t,r,x]=c.useContext(su);c.useEffect(()=>{const d=ou(new Date).format("YYYY-MM-DD");t(d),x(d)},[]);const f=c.useRef(),[p,n]=c.useState(null),l=m(),g=()=>{try{const d=l(Wr(e));n(d)}catch(d){console.error(d)}},F=m0.useReactToPrint({content:()=>f.current,documentTitle:"گزارش روزانه",onAfterPrint:()=>{n(null)}});c.useEffect(()=>{p&&F()},[p,F]);const A=ku({initialValues:{receiver:"",formNumber:""},validationSchema:Iu({receiver:gu().required("این فیلد اجباری است!").typeError("لطفا مشخصات دریافت کننده را وارد کنید!"),formNumber:gu().required("این فیلد اجباری است!").typeError("لطفا عدد وارد کنید!")})});return c.useEffect(()=>{A.validateForm()},[]),u.jsxs(o,{container:!0,mb:2,mt:2,alignItems:"center",justifyContents:"center",gap:2,xs:12,px:2,children:[u.jsx(o,{item:!0,xs:12,children:u.jsx(Vu,{sx:{alignSlef:"center",textAlign:"center"},text:"صدور نامه گزارش کشتار روزانه"})}),u.jsx(o,{item:!0,xs:12,sm:6,md:6,lg:6,children:u.jsx(U,{id:"receiver",label:"مثال: معاونت محترم توسعه بازرگانی و صنایع کشاورزی",value:A.values.receiver,error:A.touched.receiver?!!A.errors.receiver:null,onChange:A.handleChange,onBlur:A.handleBlur,helperText:A.touched.receiver&&A.errors.receiver?A.errors.receiver:null,autoComplete:"current-password",variant:"outlined",fullWidth:!0})}),u.jsx(o,{item:!0,xs:12,sm:6,md:4,lg:3,children:u.jsx(U,{id:"formNumber",label:"شماره نامه را وارد کنید",value:A.values.formNumber,error:A.touched.formNumber?!!A.errors.formNumber:null,onChange:A.handleChange,onBlur:A.handleBlur,helperText:A.touched.formNumber&&A.errors.formNumber?A.errors.formNumber:null,autoComplete:"current-password",variant:"outlined"})}),u.jsx(o,{item:!0,xs:12,sm:6,md:4,lg:3,children:u.jsx(yu,{label:"تاریخ کشتار",id:"date",renderInput:d=>u.jsx(U,{...d,fullWidth:!0}),value:e,onChange:d=>{t(ou(d).format("YYYY-MM-DD"))}})}),u.jsx(o,{item:!0,xs:12,sm:6,md:4,lg:3,children:u.jsx(yu,{label:"تاریخ نامه",id:"date",renderInput:d=>u.jsx(U,{...d,fullWidth:!0}),value:r,onChange:d=>{x(ou(d).format("YYYY-MM-DD"))}})}),u.jsx(o,{item:!0,xs:12,sm:6,md:4,lg:3,children:u.jsx(Lu,{title:"تولید خروجی PDF",children:u.jsx(W,{fullWidth:!0,disabled:!A.isValid,onClick:()=>{g()},variant:"contained",children:"صدور نامه"})})}),u.jsx("div",{style:{display:"none",position:"absolute"},children:u.jsx(c6,{ref:f,sDate:e,date:r,fnumber:A.values.formNumber,receiver:A.values.receiver,item:(S=p==null?void 0:p.payload)==null?void 0:S.data})})]})},Vr=Au("PROVINCE_GET_SLAUGHTER_LETTER",async(e,{dispatch:t})=>{t(q());const{data:r,status:x}=await J.get("poultry_request_letter_order_code/?date="+e);return t(V()),{data:r,status:x}}),Kr=Au("PROVINCE_GET_VETERINARY_LETTER",async(e,{dispatch:t})=>{t(q());const{data:r,status:x}=await J.get("poultry_request_letter/?order_code="+e);return t(V()),{data:r,status:x}}),uu={page:{width:"210mm",margin:"0 auto",display:"flex",flexDirection:"column",position:"relative",direction:"rtl",fontFamily:"nazanin",fontWeight:"bold"},container:{width:"95%",alignSelf:"center",pageBreakInside:"avoid"},invoiceTable:{width:"100%",borderCollapse:"collapse",alignSelf:"center"},tableCell:{border:"1px solid #000",pAlign:"left",textAlign:"center",fontSize:11},tableHeader:{pageBreakAfter:"auto"},headerRow:{color:"black",pageBreakInside:"avoid",pageBreakAfter:"auto"},logo:{width:"60px",height:"auto",marginBottom:"10px"},contentContainer:{display:"flex",justifyContent:"space-between",marginTop:"20px",marginLeft:"100px",marginRight:"30px"},contentInLine:{display:"flex",flexDirection:"column",alignItems:"center"},mainTitle:{fontFamily:"nazanin",fontSize:11,pAlign:"center",fontWeight:"bolder"},signature:{display:"flex",flexDirection:"column",alignItems:"flex-end",marginLeft:"20px"},watermarkContainer:{position:"fixed",top:450,left:0,right:30,bottom:0,justifyContent:"center",alignItems:"center",opacity:.2,zIndex:-1},watermarkp:{fontSize:100,fontWeight:"bolder",color:"grey",transform:"rotate(-45deg)",left:"50%"},title:{fontSize:12,fontWeight:"bolder",pAlign:"center"},titleTopic:{marginTop:"10px",fontSize:12,fontWeight:"bolder",pAlign:"center"},firsttitle:{fontSize:14,fontWeight:"bolder",marginLeft:"40px",pAlign:"center"},options:{padding:"10px",marginTop:"15px",display:"flex",flexDirection:"column",alignItems:"flex-start"},divider:{width:"100%",height:"2px",backgroundColor:"red",marginBottom:15},pTitleContainer:{pAlign:"right",margin:"15px",textAlign:"justify",textJustify:"inter-word"},tableHeaderCell:{backgroundColor:"rgba(255, 229, 153, 0.5)",fontSize:10,border:"1px solid #000",padding:"4px",textAlign:"center",fontWeight:"bold"}},i6=c.forwardRef((e,t)=>{var A,S,d,h,j,b,v,E,L,$,z,P,s,D,a,M,N,R,Y,K;const{sDate:r}=e,{date:x}=e,{fnumber:f}=e,{receiver:p}=e,{item:n}=e,{price:l}=e,g=Z0(),F=q0();return u.jsxs("div",{style:uu.page,ref:t,children:[u.jsxs("div",{style:uu.contentContainer,children:[u.jsxs("div",{style:uu.contentInLine,children:[u.jsx("img",{alt:"logo",src:r6,style:uu.logo}),u.jsx("span",{style:uu.mainTitle,children:"اتحادیه سراسری تعاونی‌های کشاورزی پرورش دهندگان مرغ گوشتی ایران"}),u.jsxs("span",{style:uu.title,children:["اتحادیه شرکت های تعاونی کشاورزی مرغداران "," "," ",g]})]}),u.jsx("div",{children:u.jsx("span",{style:uu.firsttitle,children:"بسمه تعالی"})}),u.jsxs("div",{style:uu.options,children:[u.jsxs("span",{style:uu.title,children:["شماره: ",f]}),u.jsxs("span",{style:uu.titleTopic,children:["تاریخ: ",pu(x)]}),u.jsx("span",{style:uu.titleTopic,children:"پیوست:"})]})]}),u.jsx("div",{style:uu.watermarkContainer,children:u.jsx("p",{style:uu.watermarkp,children:"سامانه رصدیار "})}),u.jsx("hr",{style:uu.divider}),u.jsxs("p",{style:uu.pTitleContainer,children:[u.jsxs("strong",{style:{fontSize:"20px"},children:[p,u.jsx("br",{}),"با سلام",u.jsx("br",{})]}),u.jsx("br",{}),"احتراماً بدینوسیله واحد"," ",(A=n==null?void 0:n.poultry)!=null&&A.unitName?(S=n==null?void 0:n.poultry)==null?void 0:S.unitName:"..................."," "," ","به مالکیت/ مستاجر"," ",(h=(d=n==null?void 0:n.poultry)==null?void 0:d.user)!=null&&h.fullname?(b=(j=n==null?void 0:n.poultry)==null?void 0:j.user)==null?void 0:b.fullname:"..................."," ","به کد سیستمی"," ",(v=n==null?void 0:n.poultry)!=null&&v.systemCode?(E=n==null?void 0:n.poultry)==null?void 0:E.systemCode:"..................."," ","به ظرفیت پروانه"," ",(L=n==null?void 0:n.poultry)!=null&&L.totalCapacity?($=n==null?void 0:n.poultry)==null?void 0:$.totalCapacity.toLocaleString():"..................."," ","قطعه و تعداد جوجه ریزي"," ",(z=n==null?void 0:n.hatching)==null?void 0:z.hatchingQuantity.toLocaleString()," قطعه در سالن با کد یکتا"," "," ",(P=n==null?void 0:n.poultry)!=null&&P.breedingUniqueId?(s=n==null?void 0:n.poultry)==null?void 0:s.breedingUniqueId:"..................."," ","و مسئول فنی فارم آقاي/خانم"," ",(D=n==null?void 0:n.hatching)!=null&&D.vetFarmName?(a=n==null?void 0:n.hatching)==null?void 0:a.vetFarmName:"..................."," ","تلفن تماس:"," ",(M=n==null?void 0:n.hatching)!=null&&M.vetFarmMobile?(N=n==null?void 0:n.hatching)==null?void 0:N.vetFarmMobile:"..................."," ","در راستاي اجراي شیوه نامه ابلاغی مقام عالی وزارت جهاد کشاورزي براي کشتار"," ",n==null?void 0:n.quantity.toLocaleString()," "," قطعه مرغ با میانگین وزنی",n!=null&&n.IndexWeight?n==null?void 0:n.IndexWeight:"..................."," ","کیلوگرم و سن "," ",(R=n==null?void 0:n.hatching)!=null&&R.age?(Y=n==null?void 0:n.hatching)==null?void 0:Y.age:"..................."," "," ","روز به تاریخ کشتار ",pu(r)," طبق جدول ذیل جهت اخذ مجوز کشتار به حضورتان معرفی می گردد. لازم به توضیح است قیمت مصوب دولتی"," ",l.toLocaleString()," ","ریال براي مرغ زنده ملاك فروش خواهد بود.",u.jsx("br",{}),u.jsx("br",{}),"اعتبار این معرفینامه از تاریخ صدور 24 ساعت می باشد."]}),u.jsxs("div",{style:uu.container,children:[u.jsx("p",{children:"اطلاعات تخصیص:"}),u.jsxs("table",{style:uu.invoiceTable,children:[u.jsx("thead",{style:uu.tableHeader,children:u.jsxs("tr",{style:uu.headerRow,children:[u.jsx("th",{style:uu.tableHeaderCell,children:"ردیف"}),u.jsx("th",{style:uu.tableHeaderCell,children:"خریدار"}),u.jsx("th",{style:uu.tableHeaderCell,children:"تعداد"}),u.jsx("th",{style:uu.tableHeaderCell,children:"وزن تقریبی بار"})]})}),u.jsx("tbody",{children:(K=n==null?void 0:n.provinceKillRequests)==null?void 0:K.map((y,C)=>{var i,k,B,T,Q;return u.jsxs("tr",{children:[u.jsx("td",{style:uu.tableCell,children:C+1}),u.jsx("td",{style:uu.tableCell,children:(B=(k=(i=y==null?void 0:y.killhouseUser)==null?void 0:i.killHouseOperator)==null?void 0:k.user)==null?void 0:B.fullname}),u.jsx("td",{style:uu.tableCell,children:(T=y==null?void 0:y.info)==null?void 0:T.quantity}),u.jsxs("td",{style:uu.tableCell,children:[" ",Math.round((Q=y==null?void 0:y.info)==null?void 0:Q.weight)]})]},C)})})]}),u.jsx("div",{style:{flexDirection:"row",marginTop:"20px"},children:u.jsx("div",{style:uu.signature,children:u.jsxs("div",{style:uu.contentInLine,children:[u.jsx("span",{style:uu.title,children:F}),u.jsxs("span",{style:uu.title,children:["مدیرعامل اتحادیه مرغداران"," ",g]})]})})})]})]})});i6.displayName="ProvinceQuarantineInvoice";i6.propTypes={item:u0.PropTypes.any};const Qr=()=>{var v;const[,,e,t,r,x]=c.useContext(su),f=c.useRef(),[p,n]=c.useState(""),[l,g]=c.useState(null),[F,A]=c.useState(null),S=m(),d=()=>{const E=S(Kr(b.values.userInfoCheck));A(E)},h=m0.useReactToPrint({content:()=>f.current,documentTitle:"فاکتور قرنطینه",onAfterPrint:()=>{A(null)}});c.useEffect(()=>{F&&h()},[F,h]);const j=ku({initialValues:{receiver:"",formNumber:"",price:""},validationSchema:Iu({receiver:gu().required("این فیلد اجباری است!").typeError("لطفا مشخصات دریافت کننده را وارد کنید!"),formNumber:gu().required("این فیلد اجباری است!").typeError("لطفا عدد وارد کنید!"),price:gu().required("این فیلد اجباری است!").typeError("لطفا عدد وارد کنید!")})}),b=ku({initialValues:{userInfoCheck:""},validationSchema:Iu({userInfoCheck:gu().required("این فیلد اجباری است!").typeError("لطفا فیلد را به درستی وارد کنید!")})});return c.useEffect(()=>{j.validateForm(),b.validateForm()},[]),c.useEffect(()=>{S(Vr(e)).then(E=>{n(E.payload.data),g(null)})},[e]),u.jsxs(o,{container:!0,mb:2,mt:2,alignItems:"center",justifyContents:"center",gap:2,px:2,children:[u.jsx(o,{item:!0,xs:12,children:u.jsx(Vu,{sx:{alignSlef:"center",textAlign:"center"},text:"صدور حواله کشتار"})}),u.jsx(o,{item:!0,xs:12,sm:6,md:4,lg:3,children:u.jsx(yu,{label:"تاریخ کشتار",id:"date",renderInput:E=>u.jsx(U,{...E,fullWidth:!0}),value:e,onChange:E=>{t(ou(E).format("YYYY-MM-DD"))}})}),u.jsx(o,{item:!0,xs:12,sm:6,md:4,lg:3,children:u.jsx(Hu,{sx:{width:"100%"},id:"userInfoCheck",getOptionDisabled:E=>E.disabled<=0,options:p?p==null?void 0:p.map(E=>{var L,$,z;return{id:E.orderCode,label:((L=E==null?void 0:E.poultry)==null?void 0:L.unitName)+` (${(z=($=E.poultry)==null?void 0:$.user)==null?void 0:z.mobile})`}}):[],getOptionLabel:E=>E.label,value:l,onChange:(E,L)=>{g(L),b.setFieldValue("userInfoCheck",L?L.id:"")},onBlur:b.handleBlur,renderInput:E=>u.jsx(U,{...E,label:"مرغدار",variant:"outlined",fullWidth:!0})})}),u.jsx(o,{item:!0,xs:12,sm:6,md:6,lg:6,children:u.jsx(U,{id:"receiver",label:"مثال: معاونت محترم توسعه بازرگانی و صنایع کشاورزی",value:j.values.receiver,error:j.touched.receiver?!!j.errors.receiver:null,onChange:j.handleChange,onBlur:j.handleBlur,helperText:j.touched.receiver&&j.errors.receiver?j.errors.receiver:null,autoComplete:"current-password",variant:"outlined",fullWidth:!0})}),u.jsx(o,{item:!0,xs:12,sm:6,md:4,lg:3,children:u.jsx(yu,{label:"تاریخ نامه",id:"date",renderInput:E=>u.jsx(U,{...E,fullWidth:!0}),value:r,onChange:E=>{x(ou(E).format("YYYY-MM-DD"))}})}),u.jsx(o,{item:!0,xs:12,sm:6,md:4,lg:3,children:u.jsx(U,{id:"formNumber",label:"شماره نامه",value:j.values.formNumber,error:j.touched.formNumber?!!j.errors.formNumber:null,onChange:j.handleChange,onBlur:j.handleBlur,helperText:j.touched.formNumber&&j.errors.formNumber?j.errors.formNumber:null,autoComplete:"current-password",variant:"outlined",fullWidth:!0})}),u.jsx(o,{item:!0,xs:12,sm:6,md:4,lg:3,children:u.jsx(ve,{allowLeadingZeros:!0,thousandSeparator:",",fullWidth:!0,id:"price",label:"قیمت روز مرغ (ریال)",variant:"outlined",value:j.values.price,error:j.touched.price?!!j.errors.price:null,onChange:j.handleChange,onBlur:j.handleBlur,helperText:j.touched.price&&j.errors.price?j.errors.price:null})}),u.jsx(o,{item:!0,xs:12,sm:6,md:4,lg:3,children:u.jsx(Lu,{title:"تولید خروجی PDF",children:u.jsx(W,{disabled:!(j.isValid&&b.values.userInfoCheck),onClick:d,variant:"contained",fullWidth:!0,children:"صدور نامه"})})}),u.jsx("div",{style:{display:"none",position:"absolute"},children:u.jsx(i6,{ref:f,sDate:e,date:r,fnumber:j.values.formNumber,receiver:j.values.receiver,item:(v=F==null?void 0:F.payload)==null?void 0:v.data,price:j.values.price})})]})},X={page:{width:"210mm",margin:"0 auto",display:"flex",flexDirection:"column",position:"relative",direction:"rtl",fontFamily:"nazanin",fontWeight:"bold"},container:{width:"95%",alignSelf:"center",pageBreakInside:"avoid"},invoiceTable:{width:"100%",borderCollapse:"collapse",alignSelf:"center"},tableCell:{border:"1px solid #000",pAlign:"left",textAlign:"center",fontSize:11},tableHeader:{pageBreakAfter:"auto"},headerRow:{color:"black",pageBreakInside:"avoid",pageBreakAfter:"auto"},tableRowEven:{backgroundColor:"rgba(170, 183, 255, 0.3)"},logo:{width:"60px",height:"auto",marginBottom:"10px"},contentContainer:{display:"flex",justifyContent:"space-between",marginTop:"20px",marginLeft:"100px",marginRight:"30px"},contentInLine:{display:"flex",flexDirection:"column",alignItems:"center"},mainTitle:{fontFamily:"nazanin",fontSize:11,pAlign:"center",fontWeight:"bolder"},signature:{display:"flex",flexDirection:"column",alignItems:"flex-end",marginLeft:"20px"},watermarkContainer:{position:"fixed",top:450,left:0,right:30,bottom:0,justifyContent:"center",alignItems:"center",opacity:.2,zIndex:-1},watermarkp:{fontSize:100,fontWeight:"bolder",color:"grey",transform:"rotate(-45deg)",left:"50%"},title:{fontSize:12,fontWeight:"bolder",pAlign:"center"},titleTopic:{marginTop:"10px",fontSize:12,fontWeight:"bolder",pAlign:"center"},firsttitle:{fontSize:14,fontWeight:"bolder",marginLeft:"40px",pAlign:"center"},options:{padding:"10px",marginTop:"15px",display:"flex",flexDirection:"column",alignItems:"flex-start"},divider:{width:"100%",height:"2px",backgroundColor:"red",marginBottom:15},pTitleContainer:{pAlign:"right",margin:"15px",textAlign:"justify",textJustify:"inter-word"},tableHeaderCell:{backgroundColor:"rgba(255, 229, 153, 0.5)",fontSize:10,border:"1px solid #000",padding:"4px",textAlign:"center",fontWeight:"bold"}},C6=c.forwardRef((e,t)=>{const{sDate:r}=e,{date:x}=e,{fnumber:f}=e,{receiver:p}=e,{item:n}=e,l=Z0(),g=q0(),F=n==null?void 0:n.reduce((d,h)=>d+((h==null?void 0:h.quantity)||0),0);function A(d){let h=0;return d==null||d.forEach(j=>{var b,v,E;(b=j==null?void 0:j.hatching)!=null&&b.totalWeight&&((v=j==null?void 0:j.hatching)==null?void 0:v.totalWeight)!==void 0&&(h+=(E=j==null?void 0:j.hatching)==null?void 0:E.totalWeight)}),h}const S=d=>{let h="";return d!=null&&d.directBuying?h="خرید مستقیم":d!=null&&d.union?h="خرید خارج از استان":h="اتحادیه",h};return u.jsxs("div",{style:X.page,ref:t,children:[u.jsxs("div",{style:X.contentContainer,children:[u.jsxs("div",{style:X.contentInLine,children:[u.jsx("img",{alt:"logo",src:r6,style:X.logo}),u.jsx("span",{style:X.mainTitle,children:"اتحادیه سراسری تعاونی‌های کشاورزی پرورش دهندگان مرغ گوشتی ایران"}),u.jsxs("span",{style:X.title,children:["اتحادیه شرکت های تعاونی کشاورزی مرغداران "," "," ",l]})]}),u.jsx("div",{children:u.jsx("span",{style:X.firsttitle,children:"بسمه تعالی"})}),u.jsxs("div",{style:X.options,children:[u.jsxs("span",{style:X.title,children:["شماره: ",f]}),u.jsxs("span",{style:X.titleTopic,children:["تاریخ: ",pu(x)]}),u.jsx("span",{style:X.titleTopic,children:"پیوست:"})]})]}),u.jsx("hr",{style:X.divider}),u.jsxs("p",{style:X.pTitleContainer,children:[u.jsxs("strong",{style:{fontSize:"20px"},children:[p,u.jsx("br",{}),"با سلام",u.jsx("br",{})]}),u.jsx("br",{}),"احتراما گزارش درخواست کشتار مرغداران مرغ گوشتی استان مورخ"," ",pu(r),"، به حضورتان ارسال میگردد."]}),u.jsxs("div",{style:X.container,children:[u.jsxs("p",{style:{marginTop:"40px"},children:["اطلاعات درخواست:"," ",u.jsxs("span",{style:{color:"green",fontWeight:"boler"},children:[" ","تعداد درخواست کشتار (",F!==void 0&&F.toLocaleString()," ","قطعه)، وزن کل تقریبی (",A(n).toLocaleString()," ","کیلوگرم)."]})]}),u.jsxs("table",{style:X.invoiceTable,children:[u.jsx("thead",{style:X.tableHeader,children:u.jsxs("tr",{style:X.headerRow,children:[u.jsx("th",{style:X.tableHeaderCell,children:"ردیف"}),u.jsx("th",{style:X.tableHeaderCell,children:"کد سفارش"}),u.jsx("th",{style:X.tableHeaderCell,children:"نوع فروش"}),u.jsx("th",{style:X.tableHeaderCell,children:"تاریخ کشتار"}),u.jsx("th",{style:X.tableHeaderCell,children:"مرغدار"}),u.jsx("th",{style:X.tableHeaderCell,children:"شهر/تعاونی"}),u.jsx("th",{style:X.tableHeaderCell,children:"سن مرغ"}),u.jsx("th",{style:X.tableHeaderCell,children:"میانگین وزن"}),u.jsx("th",{style:X.tableHeaderCell,children:"وزن تقریبی"}),u.jsx("th",{style:X.tableHeaderCell,children:"مانده در سالن"}),u.jsx("th",{style:X.tableHeaderCell,children:"تعداد درخواست کشتار"})]})}),u.jsx("tbody",{children:n==null?void 0:n.map((d,h)=>{var j,b,v,E,L,$,z,P,s,D,a,M,N,R;return u.jsxs("tr",{style:h%2===0?X.tableRowEven:{},children:[u.jsx("td",{style:X.tableCell,children:h+1}),u.jsx("td",{style:X.tableCell,children:d.orderCode}),u.jsx("td",{style:X.tableCell,children:S(d)}),u.jsx("td",{style:X.tableCell,children:pu(d==null?void 0:d.sendDate)}),u.jsx("td",{style:X.tableCell,children:`${(j=d==null?void 0:d.poultry)==null?void 0:j.unitName} (${(v=(b=d==null?void 0:d.poultry)==null?void 0:b.user)==null?void 0:v.mobile})`}),u.jsx("td",{style:X.tableCell,children:`${($=(L=(E=d==null?void 0:d.poultry)==null?void 0:E.address)==null?void 0:L.city)==null?void 0:$.name}/${(z=d==null?void 0:d.poultry)!=null&&z.cityOperator?(P=d==null?void 0:d.poultry)==null?void 0:P.cityOperator:"بدون تعاونی"}`}),u.jsx("td",{style:X.tableCell,children:(s=d==null?void 0:d.hatching)==null?void 0:s.age}),u.jsx("td",{style:X.tableCell,children:d==null?void 0:d.IndexWeight}),u.jsx("td",{style:X.tableCell,children:(a=(D=d==null?void 0:d.hatching)==null?void 0:D.totalWeight)==null?void 0:a.toLocaleString()}),u.jsx("td",{style:X.tableCell,children:(N=(M=d==null?void 0:d.hatching)==null?void 0:M.leftOver)==null?void 0:N.toLocaleString()}),u.jsx("td",{style:X.tableCell,children:(R=d==null?void 0:d.firstQuantity)==null?void 0:R.toLocaleString()})]},h)})})]})]}),u.jsxs("div",{style:{flexDirection:"row",marginTop:"20px"},children:[u.jsx("div",{style:X.signature,children:u.jsxs("div",{style:X.contentInLine,children:[u.jsx("span",{style:X.title,children:g}),u.jsxs("span",{style:X.title,children:["مدیرعامل اتحادیه مرغداران"," ",l]})]})}),u.jsx("div",{style:X.watermarkContainer,children:u.jsx("p",{style:X.watermarkp,children:"سامانه رصدیار "})})]})]})});C6.displayName="ProvinceSendLetterDeclarationNeedFactor";C6.propTypes={item:u0.PropTypes.any};const Hr=()=>{const[,,e,t,r,x]=c.useContext(su),f=c.useRef(),[p,n]=c.useState(null),l=m(),g=async()=>{try{l(q());let S=await J.get(`Poultry_Request/?role=${tu()}&today&date1=${e}&date2=${e}&search=filter&value=&page=1&page_size=1000`);l(V()),n(S.data.results)}catch(S){console.error(S)}},F=m0.useReactToPrint({content:()=>f.current,documentTitle:"گزارش اعلام کشتار مرغ",onAfterPrint:()=>{n(null)}});c.useEffect(()=>{p&&F()},[p,F]);const A=ku({initialValues:{receiver:"",formNumber:""},validationSchema:Iu({receiver:gu().required("این فیلد اجباری است!").typeError("لطفا مشخصات دریافت کننده را وارد کنید!"),formNumber:gu().required("این فیلد اجباری است!").typeError("لطفا عدد وارد کنید!")})});return c.useEffect(()=>{A.validateForm()},[]),u.jsxs(o,{container:!0,mb:2,mt:2,alignItems:"center",justifyContents:"center",gap:2,px:2,children:[u.jsx(o,{item:!0,xs:12,children:u.jsx(Vu,{sx:{alignSlef:"center",textAlign:"center"},text:"صدور نامه اعلام نیاز کشتار مرغدار"})}),u.jsx(o,{item:!0,xs:12,sm:6,md:6,lg:6,children:u.jsx(U,{id:"receiver",label:"مثال: معاونت محترم توسعه بازرگانی و صنایع کشاورزی",value:A.values.receiver,error:A.touched.receiver?!!A.errors.receiver:null,onChange:A.handleChange,onBlur:A.handleBlur,helperText:A.touched.receiver&&A.errors.receiver?A.errors.receiver:null,autoComplete:"current-password",variant:"outlined",fullWidth:!0})}),u.jsx(o,{item:!0,xs:12,sm:6,md:4,lg:3,children:u.jsx(U,{id:"formNumber",label:"شماره نامه را وارد کنید",value:A.values.formNumber,error:A.touched.formNumber?!!A.errors.formNumber:null,onChange:A.handleChange,onBlur:A.handleBlur,helperText:A.touched.formNumber&&A.errors.formNumber?A.errors.formNumber:null,autoComplete:"current-password",variant:"outlined"})}),u.jsx(o,{item:!0,xs:12,sm:6,md:4,lg:3,children:u.jsx(yu,{label:"تاریخ کشتار",id:"date",renderInput:S=>u.jsx(U,{...S,fullWidth:!0}),value:e,onChange:S=>{t(ou(S).format("YYYY-MM-DD"))}})}),u.jsx(o,{item:!0,xs:12,sm:6,md:4,lg:3,children:u.jsx(yu,{label:"تاریخ نامه",id:"date",renderInput:S=>u.jsx(U,{...S,fullWidth:!0}),value:r,onChange:S=>{x(ou(S).format("YYYY-MM-DD"))}})}),u.jsx(o,{item:!0,xs:12,sm:6,md:4,lg:3,children:u.jsx(Lu,{title:"تولید خروجی PDF",children:u.jsx(W,{fullWidth:!0,disabled:!A.isValid,onClick:()=>{g()},variant:"contained",children:"صدور نامه"})})}),u.jsx("div",{style:{display:"none",position:"absolute"},children:u.jsx(C6,{ref:f,sDate:e,date:r,fnumber:A.values.formNumber,receiver:A.values.receiver,item:p})})]})},Gr=()=>{const[e,t]=c.useState("1"),r=(x,f)=>{t(f)};return u.jsxs(o,{xs:12,children:[u.jsx(o,{container:!0,alignItems:"center",justifyContent:"center",xs:12,children:u.jsxs(g0,{scrollButtons:"auto",variant:"scrollable",allowScrollButtonsMobile:!0,value:e,onChange:r,children:[u.jsx(Nu,{label:"گزارش کشتار روزانه",value:"1"}),u.jsx(Nu,{label:"صدور حواله کشتار",value:"2"}),u.jsx(Nu,{label:"گزارش اعلام کشتار مرغدار",value:"3"})]})}),u.jsxs(o,{xs:12,children:[e==="1"&&u.jsx(Yr,{}),e==="2"&&u.jsx(Qr,{}),e==="3"&&u.jsx(Hr,{})]})]})},Xr=()=>{const{pathname:e}=u6(),t=m(),r=(x,f)=>tu()==="SuperAdmin"?x:f;return u.jsxs(o,{container:!0,gap:w.SMALL,p:w.SMALL,direction:{xs:"column",md:"row"},justifyContent:"center",style:{placeContent:"baseline"},children:[u.jsxs(o,{container:!0,direction:"column",style:{width:"100%"},children:[u.jsx(o,{children:u.jsx(Vu,{text:"مدیریت درخواست ها"})}),u.jsxs(o,{container:!0,justifyContent:"center",gap:w.SMALL,children:[u.jsx(lu,{to:r(B0,m6),active:e===B0?"true":null,children:u.jsx(au,{icon:u.jsx(ce,{size:30,color:"#244CCC"}),title:"درخواست های کشتار",description:"درخواست های کشتار مرغدار در انتظار بررسی"})}),u.jsx(lu,{to:r(U0,ue),active:e===U0?"true":null,children:u.jsx(au,{icon:u.jsx(xe,{size:30,color:"#244CCC"}),title:"اعلام نیاز خریداران",description:"درخواست های کشتار در انتظار بررسی"})}),u.jsx(lu,{to:r(W0,ee),active:e===W0?"true":null,children:u.jsx(au,{icon:u.jsx(Wu,{size:30,color:"#244CCC"}),title:"تخصیصات",description:"مشاهده و تخصیص درخواست ها"})}),u.jsx(lu,{to:r(D6,un),active:e===D6?"true":null,children:u.jsx(au,{icon:u.jsx(ie,{size:30,color:"#244CCC"}),title:"تعرفه ها"})})]})]}),u.jsxs(o,{container:!0,direction:"column",style:{width:"100%"},children:[u.jsx(o,{children:u.jsx(Vu,{text:"ویژه"})}),u.jsxs(o,{container:!0,justifyContent:"center",gap:w.SMALL,children:[u.jsx(lu,{to:r(Ju,Ju),active:e===Ju?"true":null,children:u.jsx(au,{icon:u.jsx(G0,{size:30,color:"#244CCC"}),title:"خرید مستقیم"})}),u.jsx(lu,{to:r(D0,D0),active:e===D0?"true":null,children:u.jsx(au,{icon:u.jsx(G0,{size:30,color:"#244CCC"}),title:"پنل معاملات"})}),u.jsx(lu,{to:r(Y0,ne),active:e===Y0?"true":null,children:u.jsx(au,{icon:u.jsx(pe,{size:30,color:"#244CCC"}),title:"صادرات"})}),u.jsx(lu,{to:r(te,re),children:u.jsx(au,{icon:u.jsx(Wu,{size:30,color:"#244CCC"}),title:"فروش خارج از استان"})}),u.jsx(lu,{to:r(V0,le),active:e===V0?"true":null,children:u.jsx(au,{icon:u.jsx(Wu,{size:30,color:"#244CCC"}),title:"تخصیصات خودکار"})}),u.jsx(lu,{to:r(K0,ae),active:e===K0?"true":null,children:u.jsx(au,{icon:u.jsx(Ce,{size:30,color:"#244CCC"}),title:"زنجیره ها"})})]})]}),u.jsxs(o,{container:!0,direction:"column",style:{width:"100%"},children:[u.jsx(o,{children:u.jsx(Vu,{text:"نظارت درخواست ها"})}),u.jsxs(o,{container:!0,justifyContent:"center",placeContent:"baseline",gap:w.SMALL,children:[u.jsx(lu,{to:r(Q0,se),active:e===Q0?"true":null,children:u.jsx(au,{icon:u.jsx(Wu,{size:30,color:"#244CCC"}),title:"مدیریت تخصیصات"})}),u.jsx(lu,{to:r(H0,oe),active:e===H0?"true":null,children:u.jsx(au,{icon:u.jsx(de,{className:"svg-icon-color",color:"#244CCC",size:30}),title:"صدور نامه",description:"ارسال نامه سیستمی"})}),u.jsx(lu,{onClick:()=>t(wu({title:"اطلاعات گزارش",content:u.jsx(G6,{})})),children:u.jsx(au,{icon:u.jsx(he,{className:"svg-icon-color",color:"#244CCC",size:30}),title:"گزارش روزانه",description:"گزارش روزانه"})}),u.jsx(lu,{to:r(L6,en),active:e===L6?"true":null,children:u.jsx(au,{icon:u.jsx(Ae,{size:30,style:{color:"#4285F4"},color:"#244CCC"}),title:"تراکنش ها"})})]})]})]})},Jr=Au("PROVINCE_CHAINS_SUBMIT_COMPANY",async(e,{dispatch:t})=>{try{t(q());const{data:r,status:x}=await J.post("chain-company/",e);return t(V()),{data:r,status:x}}catch(r){return t(V()),{error:r.response.data.result}}}),Zr=Au("PROVINCE_CHAINS_EDIT_COMPANY",async(e,{dispatch:t})=>{try{t(q());const{data:r,status:x}=await J.put("chain-company/0/",e);return t(V()),{data:r,status:x}}catch(r){return t(V()),{error:r.response.data.result}}}),$6=({item:e})=>{var g,F,A,S,d,h,j,b;const t=m(),[r]=c.useContext(su),[x,f]=c.useState([]),[p,n]=c.useState([]),l=ku({initialValues:{mobile:(g=e==null?void 0:e.user)!=null&&g.mobile?(F=e==null?void 0:e.user)==null?void 0:F.mobile:"",name:e!=null&&e.name?e==null?void 0:e.name:"",firstname:(A=e==null?void 0:e.user)!=null&&A.firstName?(S=e==null?void 0:e.user)==null?void 0:S.firstName:"",lastname:(d=e==null?void 0:e.user)!=null&&d.lastName?(h=e==null?void 0:e.user)==null?void 0:h.lastName:"",natioanlId:(j=e==null?void 0:e.user)!=null&&j.nationalId?(b=e==null?void 0:e.user)==null?void 0:b.nationalId:"",postal:e!=null&&e.postalCode?e==null?void 0:e.postalCode:"",province:e!=null&&e.province?e==null?void 0:e.province:"",city:e!=null&&e.city?e==null?void 0:e.city:"",address:e!=null&&e.address?e==null?void 0:e.address:""},validationSchema:Iu({mobile:$u().required("این فیلد اجباری است!").typeError("لطفا فیلد را به صورت عددی وارد کنید!").test("len","شماره تلفن باید با 0 شروع شود",(v,E)=>E.originalValue&&E.originalValue.startsWith("0")).test("len","شماره تماس 11 رقم باید باشد",(v,E)=>{if(E.originalValue)return E.originalValue.length===11}),name:gu().required("این فیلد اجباری است!").typeError("لطفا فیلد را پر کنید!"),firstname:gu().required("این فیلد اجباری است!").typeError("لطفا فیلد را پر کنید!"),lastname:gu().required("این فیلد اجباری است!").typeError("لطفا فیلد را پر کنید!"),province:gu().required("این فیلد اجباری است!").typeError("لطفا فیلد را به درستی وارد کنید!"),city:gu().required("این فیلد اجباری است!").typeError("لطفا فیلد را به درستی وارد کنید!"),address:gu().required("این فیلد اجباری است!").typeError("لطفا فیلد را پر کنید!"),natioanlId:$u().required("این فیلد اجباری است!").typeError("لطفا فیلد را پر کنید!"),postal:$u().required("این فیلد اجباری است!").typeError("لطفا فیلد را پر کنید!")})});return c.useEffect(()=>{l.validateForm()},[]),c.useEffect(()=>{t(Wn()).then(v=>{f(v.payload.data)})},[]),c.useEffect(()=>{l.values.province&&n([],t(Yn(l.values.province)).then(v=>{n(v.payload.data)}))},[l.values.province]),u.jsxs(o,{container:!0,gap:w.SMALL,direction:"column",justifyContent:"space-between",children:[u.jsxs(o,{container:!0,direction:"column",gap:w.SMALL,children:[u.jsx(o,{children:u.jsx(U,{fullWidth:!0,id:"name",label:"نام شرکت",variant:"outlined",value:l.values.name,error:l.touched.name?!!l.errors.name:null,onChange:l.handleChange,onBlur:l.handleBlur,helperText:l.touched.name&&l.errors.name?l.errors.name:null})}),u.jsx(o,{children:u.jsx(U,{fullWidth:!0,id:"firstname",label:"نام مدیرعامل",variant:"outlined",value:l.values.firstname,error:l.touched.firstname?!!l.errors.firstname:null,onChange:l.handleChange,onBlur:l.handleBlur,helperText:l.touched.firstname&&l.errors.firstname?l.errors.firstname:null})}),u.jsx(o,{children:u.jsx(U,{fullWidth:!0,id:"lastname",label:"نام خانوادگی مدیرعامل",variant:"outlined",value:l.values.lastname,error:l.touched.lastname?!!l.errors.lastname:null,onChange:l.handleChange,onBlur:l.handleBlur,helperText:l.touched.lastname&&l.errors.lastname?l.errors.lastname:null})}),u.jsx(o,{children:u.jsx(U,{fullWidth:!0,id:"mobile",label:"موبایل",variant:"outlined",value:l.values.mobile,error:l.touched.mobile?!!l.errors.mobile:null,onChange:l.handleChange,onBlur:l.handleBlur,helperText:l.touched.mobile&&l.errors.mobile?l.errors.mobile:null})}),u.jsxs(o,{children:[u.jsx(Hu,{style:{width:"100%"},disablePortal:!0,id:"province",options:x?x.map(v=>({id:v.name,label:v.name})):[],onChange:(v,E)=>{l.setFieldValue("province",E?E.id:""),l.setFieldValue("city","")},renderInput:v=>u.jsx(U,{...v,label:"استان را انتخاب کنید"})}),e&&u.jsxs(H,{variant:"caption",color:"error",children:["استان: ",l.values.province]})]}),u.jsxs(o,{children:[u.jsx(Hu,{minWidth:210,style:{width:"100%"},disabled:!l.values.province,disablePortal:!0,id:"city",options:p?p.map(v=>({id:v.name,label:v.name})):[],onChange:(v,E)=>{l.setFieldValue("city",E?E.id:"")},renderInput:v=>u.jsx(U,{...v,label:"شهر را انتخاب کنید"})}),e&&u.jsxs(H,{variant:"caption",color:"error",children:["شهر: ",l.values.city]})]}),u.jsx(o,{children:u.jsx(U,{fullWidth:!0,id:"natioanlId",label:"کد ملی",variant:"outlined",value:l.values.natioanlId,onChange:l.handleChange,onBlur:l.handleBlur,error:l.touched.natioanlId?!!l.errors.natioanlId:null,helperText:l.touched.natioanlId&&l.errors.natioanlId?l.errors.natioanlId:null})}),u.jsx(o,{children:u.jsx(U,{fullWidth:!0,id:"address",label:"آدرس",variant:"outlined",sx:{width:"100%"},value:l.values.address,error:l.touched.address?!!l.errors.address:null,onChange:l.handleChange,onBlur:l.handleBlur,helperText:l.touched.address&&l.errors.address?l.errors.address:null})}),u.jsx(o,{children:u.jsx(U,{fullWidth:!0,id:"postal",label:"کد پستی",variant:"outlined",value:l.values.postal,onChange:l.handleChange,onBlur:l.handleBlur,error:l.touched.postal?!!l.errors.postal:null,helperText:l.touched.postal&&l.errors.postal?l.errors.postal:null})})]}),u.jsx(o,{children:u.jsx(W,{variant:"contained",fullWidth:!0,onClick:()=>{e?t(Zr({city:l.values.city,province:l.values.province,mobile:l.values.mobile,first_name:l.values.firstname,last_name:l.values.lastname,national_id:l.values.natioanlId,address:l.values.address,postal_code:l.values.postal,name:l.values.name,company_key:e==null?void 0:e.key})).then(v=>{v.payload.error?r({vertical:"top",horizontal:"center",msg:v.payload.error,severity:"error"}):(t(bu({right:!1,bottom:!1,content:null})),t(j0()),r({vertical:"top",horizontal:"center",msg:"عملیات با موفقیت انجام شد.",severity:"success"}))}):t(Jr({city:l.values.city,province:l.values.province,mobile:l.values.mobile,first_name:l.values.firstname,last_name:l.values.lastname,national_id:l.values.natioanlId,address:l.values.address,postal_code:l.values.postal,name:l.values.name})).then(v=>{v.payload.error?r({vertical:"top",horizontal:"center",msg:v.payload.error,severity:"error"}):(t(j0()),t(bu({right:!1,bottom:!1,content:null})),r({vertical:"top",horizontal:"center",msg:"عملیات با موفقیت انجام شد.",severity:"success"}))})},children:"ثبت"})})]})},qr=()=>{const[,,e,t,r,x]=c.useContext(su),f=Fu(a=>a.userSlice.userProfile.key),p=m();c.useEffect(()=>{const a=ou(new Date).format("YYYY-MM-DD");t(a),x(a)},[t,x]);const[n,l]=c.useState([]),[g,F]=c.useState(0),[A,S]=c.useState(10),[d,h]=c.useState(""),[j,b]=c.useState(1),[v,E]=c.useState([]),L=a=>{h(a.target.value)},$=()=>!(tu()==="AdminX"||tu()==="SuperAdmin"||tu()==="ProvinceOperator"),z=async(a=1)=>{try{p(q());const M=await J.get(`chain-company/?search=filter&value=${d}&page=${a}&page_size=${A}&role=${tu()}&state=total_companies`);p(V()),l(M.data.results),F(M.data.count)}catch(M){p(V()),console.error("Error fetching data:",M)}},P=a=>{b(a),z(a)},s=a=>{S(a),b(1)};c.useEffect(()=>{z()},[e,r,A]),c.useEffect(()=>{const a=n==null?void 0:n.map((M,N)=>{var R,Y,K,y,C,i;return[j===1?N+1:N+A*(j-1)+1,M.name,M.user.firstName,M.user.lastName,M.user.mobile,M.province,M.city,M.address,M.postalCode,(Y=(R=M.requestsInfo)==null?void 0:R.numberOfRequests)==null?void 0:Y.toLocaleString(),(y=(K=M.requestsInfo)==null?void 0:K.totalQuantity)==null?void 0:y.toLocaleString(),(i=(C=M.requestsInfo)==null?void 0:C.totalWeight)==null?void 0:i.toLocaleString(),u.jsx(Lu,{title:"ویرایش اطلاعات",placement:"left",children:u.jsx(xu,{disabled:$(),color:"primary",onClick:()=>p(bu({title:"ویرایش شرکت زنجیره",right:!(window.innerWidth<=600),bottom:window.innerWidth<=600,content:u.jsx($6,{item:M})})),children:u.jsx(ge,{})})},N)]});E(a)},[n,j,A]);const D=async a=>{a.preventDefault(),z(1)};return u.jsxs(o,{container:!0,xs:12,justifyContent:"center",alignItems:"center",gap:2,children:[u.jsx(o,{container:!0,xs:12,children:(tu()==="ProvinceOperator"||tu()==="SuperAdmin")&&u.jsx(W,{onClick:()=>p(bu({title:"ثبت شرکت زنجیره",right:!(window.innerWidth<=600),bottom:window.innerWidth<=600,content:u.jsx($6,{})})),variant:"contained",children:"ثبت شرکت زنجیره"})}),u.jsx(o,{container:!0,xs:12,justifyContent:"center",alignItems:"center",gap:2,children:u.jsxs(o,{container:!0,alignItems:"center",justifyContent:"center",gap:2,paddingTop:2,mb:1,width:"100%",children:[u.jsx(H,{children:"خریداران"}),u.jsxs(o,{container:!0,alignItems:"center",gap:2,children:[u.jsxs("form",{onSubmit:D,children:[u.jsx(U,{id:"outlined-basic",size:"small",autoComplete:"off",label:"جستجو",variant:"outlined",style:{width:250},onChange:L}),u.jsx(W,{type:"submit",endIcon:u.jsx(Ku,{}),children:"جستجو"})]}),u.jsx(o,{children:u.jsx(Lu,{title:"خروجی اکسل شرکت های زنجیره",children:u.jsx("a",{href:`${J.defaults.baseURL}chain_company_buyers_excel/?role=${tu()}&key=${f}&search=filter&value=${d}`,rel:"noreferrer",children:u.jsx(W,{color:"success",children:u.jsx(mu,{size:32})})})})})]})]})}),u.jsx(zu,{data:v,columns:["ردیف","نام شرکت","نام مدیرعامل","نام خانوادگی مدیرعامل","موبایل","استان","شهر","آدرس","کد پستی","تعداد سفارشات","حجم سفارشات (قطعه)","وزن سفارشات (کیلوگرم)","عملیات"],handlePageChange:P,totalRows:g,page:j,perPage:A,handlePerRowsChange:s,title:"مدیریت بارها"})]})};var d6={},mr=e0;Object.defineProperty(d6,"__esModule",{value:!0});var Te=d6.default=void 0,ut=mr(n0()),et=u;Te=d6.default=(0,ut.default)((0,et.jsx)("path",{d:"M11 6c1.38 0 2.63.56 3.54 1.46L12 10h6V4l-2.05 2.05C14.68 4.78 12.93 4 11 4c-3.53 0-6.43 2.61-6.92 6H6.1c.46-2.28 2.48-4 4.9-4m5.64 9.14c.66-.9 1.12-1.97 1.28-3.14H15.9c-.46 2.28-2.48 4-4.9 4-1.38 0-2.63-.56-3.54-1.46L10 12H4v6l2.05-2.05C7.32 17.22 9.07 18 11 18c1.55 0 2.98-.51 4.14-1.36L20 21.49 21.49 20z"}),"FindReplace");const nt=Au("PROVINCE_CHAINS_DELETE_CHAIN",async(e,{dispatch:t})=>{try{t(q());const{data:r,status:x}=await J.put("poultry-choose-chain-company/0/",e);return t(V()),{data:r,status:x}}catch(r){return t(V()),{error:r.response.data.result}}}),rt=Au("PROVINCE_CHAINS_REPLACE_ACTIVE_CHAIN",async(e,{dispatch:t})=>{try{t(q());const{data:r,status:x}=await J.put("poultry-choose-chain-company/0/",e);return t(V()),{data:r,status:x}}catch(r){return t(V()),{error:r.response.data.result}}}),tt=({item:e,updateTable:t})=>{const r=m(),[x,f]=c.useState([]),[p,n]=c.useState(""),[l]=c.useContext(su);return c.useEffect(()=>{r(j0()).then(g=>{f(g.payload.data)})},[]),u.jsxs(o,{container:!0,gap:w.SMALL,direction:"column",justifyContent:"space-between",children:[u.jsx(o,{container:!0,direction:"column",gap:w.SMALL,children:u.jsx(o,{children:u.jsx(Hu,{disablePortal:!0,id:"province",options:x?x==null?void 0:x.map(g=>({id:g.key,label:`${g.name} (${g.user.mobile})`})):[],onChange:(g,F)=>{n(F.id)},renderInput:g=>u.jsx(U,{...g,label:"شرکت زنجیره"})})})}),u.jsx(o,{children:u.jsx(W,{disabled:!p,variant:"contained",fullWidth:!0,onClick:()=>{r(rt({type:"replace",hatching_key:e==null?void 0:e.key,company_key:p})).then(g=>{g.payload.error?l({vertical:"top",horizontal:"center",msg:g.payload.error,severity:"error"}):(t(),l({vertical:"top",horizontal:"center",msg:"عملیات با موفقیت انجام شد.",severity:"success"}))})},children:"ثبت"})})]})};var h6={},lt=e0;Object.defineProperty(h6,"__esModule",{value:!0});var Ne=h6.default=void 0,at=lt(n0()),st=u;Ne=h6.default=(0,at.default)((0,st.jsx)("path",{d:"M22 5.18 10.59 16.6l-4.24-4.24 1.41-1.41 2.83 2.83 10-10zM12 20c-4.41 0-8-3.59-8-8s3.59-8 8-8c1.57 0 3.04.46 4.28 1.25l1.45-1.45C16.1 2.67 14.13 2 12 2 6.48 2 2 6.48 2 12s4.48 10 10 10c1.73 0 3.36-.44 4.78-1.22l-1.5-1.5c-1 .46-2.11.72-3.28.72m7-5h-3v2h3v3h2v-3h3v-2h-3v-3h-2z"}),"AddTask");const ot=({item:e,updateTable:t})=>{const[r,x]=c.useState(null),f=m(),[p]=c.useContext(su),n=A=>{x(A.currentTarget)},l=()=>{x(null)},g=!!r,F=g?"popover":void 0;return u.jsxs("div",{children:[u.jsx(xu,{"aria-describedby":F,variant:"contained",color:"primary",onClick:n,children:u.jsx(ye,{})}),u.jsx(y0,{anchorOrigin:{vertical:"bottom",horizontal:"right"},transformOrigin:{vertical:"top",horizontal:"left"},slotProps:{paper:{sx:{mt:1}}},id:F,open:g,anchorEl:r,onClose:l,children:u.jsxs(Q6,{sx:{p:1},children:[u.jsxs(d0,{onClick:()=>{l(),f(bu({title:"تخصیص به زنجیره",right:!(window.innerWidth<=600),bottom:window.innerWidth<=600,content:u.jsx(Qn,{item:e,updateTable:t})}))},sx:{borderRadius:1,mb:.5,color:"primary.main","&:last-of-type":{mb:0}},children:[u.jsx(s0,{sx:{color:"primary.main",minWidth:36},children:u.jsx(Ne,{sx:{fontSize:{xs:20,md:18}}})}),u.jsx(o0,{primary:u.jsx(H,{sx:{color:"primary.main",fontWeight:600,fontSize:{xs:"13px",md:"14px"}},children:"تخصیص به زنجیره"})})]}),u.jsxs(d0,{onClick:()=>{l(),f(bu({right:!(window.innerWidth<=600),bottom:window.innerWidth<=600,title:"جایگزین کردن مرغداری ",content:u.jsx(tt,{item:e,updateTable:t})}))},sx:{borderRadius:1,mb:.5,color:"info.main","&:last-of-type":{mb:0}},children:[u.jsx(s0,{sx:{color:"info.main",minWidth:36},children:u.jsx(Te,{sx:{fontSize:{xs:20,md:18}}})}),u.jsx(o0,{primary:u.jsx(H,{sx:{color:"info.main",fontWeight:600,fontSize:{xs:"13px",md:"14px"}},children:"جایگزین کردن"})})]}),u.jsxs(d0,{onClick:()=>{l(),f(bu({title:"انتقال به آرشیو",right:!(window.innerWidth<=600),bottom:window.innerWidth<=600,content:u.jsx(Vn,{item:e,updateTable:t})}))},sx:{borderRadius:1,mb:.5,color:"secondary.main","&:last-of-type":{mb:0}},children:[u.jsx(s0,{sx:{color:"secondary.main",minWidth:36},children:u.jsx(q6,{sx:{fontSize:{xs:20,md:18}}})}),u.jsx(o0,{primary:u.jsx(H,{sx:{color:"secondary.main",fontWeight:600,fontSize:{xs:"13px",md:"14px"}},children:"انتقال به بایگانی"})})]}),u.jsxs(d0,{onClick:()=>{l(),f(nt({type:"delete",hatching_key:e==null?void 0:e.key})).then(A=>{A.payload.error?p({vertical:"top",horizontal:"center",msg:A.payload.error,severity:"error"}):(t(),p({vertical:"top",horizontal:"center",msg:"عملیات با موفقیت انجام شد.",severity:"success"}))})},sx:{borderRadius:1,mb:.5,color:"error.main","&:last-of-type":{mb:0}},children:[u.jsx(s0,{sx:{color:"error.main",minWidth:36},children:u.jsx(n6,{sx:{fontSize:{xs:20,md:18}}})}),u.jsx(o0,{primary:u.jsx(H,{sx:{color:"error.main",fontWeight:600,fontSize:{xs:"13px",md:"14px"}},children:"خروج از زنجیره"})})]})]})})]})},ct=Au("PROVINCE_CHAINS_SUBMIT_ACTIVE_CHAIN",async(e,{dispatch:t})=>{try{t(q());const{data:r,status:x}=await J.post("poultry-choose-chain-company/",e);return t(V()),{data:r,status:x}}catch(r){return t(V()),{error:r.response.data.result}}}),it=({updateTable:e})=>{const t=m(),[r,x]=c.useState([]),[f,p]=c.useState([]),[n,l]=c.useState([]),[g,F]=c.useState([]),[A,S]=c.useState(""),[d]=c.useContext(su);return c.useEffect(()=>{t(Sn({chain:!0})).then(h=>{p(h.payload.data)}),t(j0()).then(h=>{l(h.payload.data)})},[]),c.useEffect(()=>{x(f==null?void 0:f.map(h=>{var j;return{label:`${h.unitName} (${h==null?void 0:h.user.mobile})`,value:`${(j=h.chainCompany)==null?void 0:j.hatchingKey}`}}))},[f]),u.jsxs(o,{container:!0,gap:w.SMALL,direction:"column",justifyContent:"space-between",children:[u.jsxs(o,{container:!0,direction:"column",gap:w.SMALL,children:[u.jsx(o,{children:u.jsx(Hu,{disablePortal:!0,id:"province",multiple:!0,options:r,getOptionLabel:h=>h.label,onChange:(h,j)=>{F(j)},renderInput:h=>u.jsx(U,{...h,label:"انتخاب مرغداران"})})}),u.jsx(o,{children:u.jsx(Hu,{disablePortal:!0,id:"province",options:n?n==null?void 0:n.map(h=>({id:h.key,label:`${h.name} (${h.user.mobile})`})):[],onChange:(h,j)=>{S(j.id)},renderInput:h=>u.jsx(U,{...h,label:"شرکت زنجیره"})})})]}),u.jsx(o,{children:u.jsx(W,{disabled:!g.length||!A,variant:"contained",fullWidth:!0,onClick:()=>{t(ct({poultry_hitchings:g==null?void 0:g.map(h=>h==null?void 0:h.value),chain_company:A})).then(h=>{h.payload.error?d({vertical:"top",horizontal:"center",msg:"مشکلی پیش آمده است!",severity:"error"}):(e(),d({vertical:"top",horizontal:"center",msg:"عملیات با موفقیت انجام شد!",severity:"success"}),t(bu({right:!1,bottom:!1,content:null})))})},children:"ثبت"})})]})},Ct=()=>{const e=m(),[t,r]=c.useState(0),[x,f]=c.useState(0),p=Fu(y=>y.userSlice.userProfile.key),n=y=>{b(y.target.value)},[l]=c.useContext(su),[g,F]=c.useState([]),[A,S]=c.useState(0),[d,h]=c.useState(10),[j,b]=c.useState(""),[v,E]=c.useState(1),[L,$]=c.useState([]),z=async y=>{let C;e(q()),C=await J.get(`poultry_hatching?search=filter&value=${j}&role=${tu()}&page=${y}&page_size=${d}&chain=true`),e(V()),F(C.data.results),S(C.data.count)},P=y=>{z(y),E(y)},s=y=>{h(y),E(1)},D=()=>{z(v!==0?v:1)},a=y=>{let C="";return C=y.quantity-y.losses-y.leftOver,C};c.useEffect(()=>{const y=g==null?void 0:g.map((C,i)=>{var B,T,Q,nu,Z,eu,ju,cu,iu,O,_,Cu,vu,Su,Pu,Ou,I,ru,du,hu,fu,_u,Du,Mu,Ru,Bu,Uu;let k;return[u.jsx(ot,{item:C,updateTable:D},i),v===1?i+1:i+d*(v-1)+1,`${(B=C==null?void 0:C.chainCompany)==null?void 0:B.name} (${(T=C==null?void 0:C.chainCompany)==null?void 0:T.user.mobile})`,C.violation?"متخلف":"عادی",C.poultry.unitName,`${C.poultry.userprofile.fullName} (${C.poultry.userprofile.mobile})`,`${(Q=C==null?void 0:C.poultry)==null?void 0:Q.address.city.name}/${(nu=C==null?void 0:C.poultry)!=null&&nu.cityOperator?(Z=C==null?void 0:C.poultry)==null?void 0:Z.cityOperator:"بدون تعاونی"}`,(eu=C==null?void 0:C.vetFarm)!=null&&eu.vetFarmMobile?`${(ju=C==null?void 0:C.vetFarm)==null?void 0:ju.vetFarmFullName} (${(cu=C==null?void 0:C.vetFarm)==null?void 0:cu.vetFarmMobile})`:"-",C.hall,C.period,k6(C==null?void 0:C.createDate),k6(C==null?void 0:C.date),C.chickenBreed,C.age,(iu=C==null?void 0:C.quantity)==null?void 0:iu.toLocaleString(),`${C.losses} (%${(C.losses*100/C.quantity).toFixed(0)})`,`${(O=C==null?void 0:C.totalCommitmentQuantity)==null?void 0:O.toLocaleString()}`,`${(_=C==null?void 0:C.governmentalQuantity)==null?void 0:_.toLocaleString()}`,`${(Cu=C==null?void 0:C.governmentalKilledQuantity)==null?void 0:Cu.toLocaleString()}`,`${(vu=C==null?void 0:C.freeQuantity)==null?void 0:vu.toLocaleString()}`,`${(Su=C==null?void 0:C.freeKilledQuantity)==null?void 0:Su.toLocaleString()}`,`${(Pu=C==null?void 0:C.outProvinceKilledQuantity)==null?void 0:Pu.toLocaleString()}`,`${(Ou=C==null?void 0:C.outProvinceKilledWeight)==null?void 0:Ou.toLocaleString()}`,(I=C==null?void 0:C.chainKilledQuantity)==null?void 0:I.toLocaleString(),(ru=C==null?void 0:C.chainKilledWeight)==null?void 0:ru.toLocaleString(),((du=a(C))==null?void 0:du.toLocaleString())+` (%${(a(C)*100/C.quantity).toFixed(0)})`,`${(hu=C==null?void 0:C.leftOver)==null?void 0:hu.toLocaleString()} (%${(C.leftOver*100/C.quantity).toFixed(0)})`,((fu=C==null?void 0:C.totalCommitment)==null?void 0:fu.toLocaleString())+" کیلوگرم ",((_u=C==null?void 0:C.governmentalKilledQuantity)==null?void 0:_u.toLocaleString())+" کیلوگرم ",((Du=C==null?void 0:C.freeKilledQuantity)==null?void 0:Du.toLocaleString())+" کیلوگرم ",((Mu=C==null?void 0:C.totalAverageKilledWeight)==null?void 0:Mu.toLocaleString())+" کیلوگرم ",((Ru=C==null?void 0:C.totalKilledWeight)==null?void 0:Ru.toLocaleString())+" کیلوگرم ",(Bu=C==null?void 0:C.activeKill)!=null&&Bu.activeKill?"دارد":"ندارد",(Uu=C==null?void 0:C.activeKill)!=null&&Uu.countOfRequest?C.activeKill.countOfRequest:"-",k=C.lastChange?`${C.lastChange.fullName} (${i0(C.lastChange.role)}) در تاریخ ${C.lastChange.date}`:"-",k=C.latestHatchingChange&&C.latestHatchingChange.date&&`${C.latestHatchingChange.fullName} (${i0(C.latestHatchingChange.role)}) در تاریخ ${C.latestHatchingChange.date}`,C.latestHatchingChange?k:"-"]});$(y)},[g]),c.useEffect(()=>{z(1)},[e,d]);const M=async y=>{y.preventDefault(),e(q());try{const C=await J.get(`poultry_hatching/?role=${tu()}&search=filter&value=${j}&chain=true`);F(C.data.results),S(C.data.count),e(V())}catch(C){console.error("Error fetching data:",C)}},N=async y=>{y.preventDefault(),r(null),f(null);try{const C=await J.get(`poultry_hatching/?role=${tu()}&chain=true&search=filter&value=`);F(C.data.results),S(C.data.count)}catch(C){console.error("Error fetching data:",C)}},R=async y=>{y.preventDefault(),e(q());try{const C=await J.get(`poultry_hatching?role=${tu()}&age1=${t}&age2=${x}&chain=true`);F(C.data.results),S(C.data.count),e(V())}catch(C){console.error("Error fetching data:",C)}},Y=Array.from({length:75},(y,C)=>C+1),K=u.jsxs(o,{container:!0,alignItems:"center",justifyContent:"space-between",gap:2,paddingTop:2,mb:1,children:[u.jsxs(o,{container:!0,alignItems:"center",gap:w.SMALL,style:{padding:"10px",border:"1px solid #bbb",borderRadius:"10px"},children:[u.jsx(H,{children:"زنجیره های فعال"}),u.jsxs("form",{onSubmit:M,children:[u.jsx(U,{id:"outlined-basic",size:"small",label:"جستجو",variant:"outlined",style:{width:250},onChange:n}),u.jsx(W,{type:"submit",onClick:M,endIcon:u.jsx(Ku,{}),children:"جستجو"}),u.jsx(Lu,{title:"خروجی اکسل",children:u.jsx(W,{color:"success",onClick:()=>{l({vertical:"top",horizontal:"center",msg:"فایل اکسل در حال دانلود می باشد، این علمیات ممکن است زمان بر باشد لطفا صبر کنید.",severity:"success"});const y=`${J.defaults.baseURL}0/hatching_excel/?role=${tu()}&key=${p}&chain=true`;window.location.href=y},children:u.jsx(mu,{size:32})})})]})]}),u.jsxs(o,{container:!0,alignItems:"center",gap:w.SMALL,style:{padding:"10px",border:"1px solid #bbb",borderRadius:"10px"},children:[u.jsx(o,{children:u.jsx(H,{variant:"caption",children:"جستجو براساس سن:"})}),u.jsx(o,{style:{width:"80px"},children:u.jsxs(k0,{fullWidth:!0,children:[u.jsx(T0,{id:"demo-simple-select-label",children:"از سن"}),u.jsx(N0,{MenuProps:{PaperProps:{style:{maxHeight:200,width:80}}},labelId:"demo-simple-select-label",id:"demo-simple-select",value:t,label:"از سن",size:"small",onChange:y=>r(y.target.value),children:Y.map(y=>u.jsx(Tu,{value:y,children:y},y))})]})}),u.jsx(o,{style:{width:"80px"},children:u.jsxs(k0,{fullWidth:!0,children:[u.jsx(T0,{id:"demo-simple-select-label",children:"تا سن"}),u.jsx(N0,{MenuProps:{PaperProps:{style:{maxHeight:200,width:80}}},labelId:"demo-simple-select-label",id:"demo-simple-select",value:x,label:"تا سن",size:"small",onChange:y=>f(y.target.value),children:Y.map(y=>u.jsx(Tu,{value:y,children:y},y))})]})}),u.jsx(W,{onClick:R,endIcon:u.jsx(Ku,{}),children:"جستجو"}),u.jsx(Lu,{title:"خروجی اکسل",children:u.jsx(W,{color:"success",onClick:()=>{l({vertical:"top",horizontal:"center",msg:"فایل اکسل در حال دانلود می باشد، این علمیات ممکن است زمان بر باشد لطفا صبر کنید.",severity:"success"});const y=`${J.defaults.baseURL}hatching_report_from_age_excel/?age1=${t}&age2=${x}&chain=true`;window.location.href=y},children:u.jsx(mu,{size:32})})})]}),u.jsx(W,{onClick:N,color:"error",children:"حذف فیلتر"})]});return u.jsxs(o,{container:!0,xs:12,justifyContent:"center",alignItems:"center",gap:2,children:[u.jsx(o,{container:!0,xs:12,children:u.jsx(W,{onClick:()=>{e(bu({title:"ثبت زنجیره فعال",right:!(window.innerWidth<=600),bottom:window.innerWidth<=600,content:u.jsx(it,{updateTable:D})}))},variant:"contained",children:"ثبت زنجیره فعال"})}),K,u.jsx(zu,{data:L,columns:["عملیات","ردیف","شرکت زنجیره","وضعیت","نام فارم","مرغدار","شهر/تعاونی","دامپزشک فارم","سالن","دوره جوجه ریزی","تاریخ ثبت جوجه ریزی","تاریخ جوجه ریزی","نژاد","سن","تعداد جوجه ریزی","تلفات دوره (قطعه)","تعداد کل تعهد دولتی (قطعه)","تعداد کشتار شده دولتی (قطعه)","وزن کشتار شده دولتی","تعداد کشتار شده آزاد (قطعه)","وزن کشتار شده آزاد ","حجم خارج از استان","وزن خارج از استان","حخم کشتار زنجیره (قطعه)","وزن کشتار زنجیره (کیلوگرم)","کشتار شده (قطعه)","مانده در سالن (قطعه)","وزن تعهد دولتی","وزن کشتار دولتی","وزن کشتار آزاد","میانگین وزن کشتار","وزن کل کشتار شده","کشتار فعال","تعداد درخواست کشتار","آخرین تغییر","سازنده جوجه ریزی"],handlePageChange:P,totalRows:A,page:v,perPage:d,handlePerRowsChange:s,title:"زنجیره"})]})},dt=({item:e,updateArchive:t,readOnly:r})=>u.jsx(Kn,{item:e,updateArchive:t,readOnly:r}),ht=({readOnly:e})=>{e=e||!1;const[t,r]=c.useState([]),[x,f]=c.useState([]),[p,n]=c.useState(0),[l,g]=c.useState(10),[F,A]=c.useState(1),[S,d]=c.useState(""),h=Fu(P=>P.userSlice.userProfile.key),j=P=>{d(P.target.value)},b=async(P,s)=>{let D;s?D=await J.get(`poultry_hatching/?archive=true&search=filter&value=${s}&role=${tu()}&page=${P}&page_size=&chain=true`):D=await J.get(`poultry_hatching/?archive=true&role=${tu()}&page=${P}&page_size=${l}&chain=true`),r(D.data.results),n(D.data.count)},v=P=>{A(P),b(P,S)},E=P=>{g(Number(P)),A(1)};c.useEffect(()=>{l&&b(1,S)},[l]),c.useEffect(()=>{b(1,"")},[]);const L=["عملیات","ردیف","شرکت زنجیره","وضعیت","نام فارم","مرغدار","شهر/تعاونی","دامپزشک فارم","سالن","دوره جوجه ریزی","تاریخ ثبت جوجه ریزی","تاریخ جوجه ریزی","نژاد","سن","تعداد جوجه ریزی","تلفات دوره","حجم خارج از استان","وزن کشتار شده دولتی","وزن کشتار شده آزاد ","وزن خارج از استان","حخم کشتار زنجیره (قطعه)","وزن کشتار زنجیره (کیلوگرم)","کشتار شده","مانده در سالن","کشتار فعال","تعداد درخواست کشتار","آخرین تغییر"];c.useEffect(()=>{if(!t||!Array.isArray(t)){f([]);return}const P=t.map((s,D)=>{var N,R,Y,K,y,C,i,k,B,T,Q,nu,Z,eu,ju,cu,iu,O,_;const a=(s==null?void 0:s.quantity)-(s==null?void 0:s.losses)-(s==null?void 0:s.leftOver),M=(s==null?void 0:s.lastChange)&&((N=s==null?void 0:s.lastChange)==null?void 0:N.date)&&`${(R=s==null?void 0:s.lastChange)==null?void 0:R.fullName} (${i0((Y=s==null?void 0:s.lastChange)==null?void 0:Y.role)}) در تاریخ ${Zu((K=s==null?void 0:s.lastChange)==null?void 0:K.date)}`;return[u.jsx(dt,{item:s,updateArchive:Cu=>b(Cu||F,S),readOnly:e},`operations-${(s==null?void 0:s.key)||D}`),F===1?D+1:D+l*(F-1)+1,(y=s==null?void 0:s.chainCompany)!=null&&y.name&&((i=(C=s==null?void 0:s.chainCompany)==null?void 0:C.user)!=null&&i.mobile)?`${s.chainCompany.name} (${s.chainCompany.user.mobile})`:"-",u.jsx(H,{variant:"body2",color:s!=null&&s.violation?"error":"black",children:s!=null&&s.violation?"متخلف":"عادی"},`status-${(s==null?void 0:s.key)||D}`),((k=s==null?void 0:s.poultry)==null?void 0:k.unitName)||"-",(T=(B=s==null?void 0:s.poultry)==null?void 0:B.userprofile)!=null&&T.fullName&&((nu=(Q=s==null?void 0:s.poultry)==null?void 0:Q.userprofile)!=null&&nu.mobile)?`${s.poultry.userprofile.fullName} (${s.poultry.userprofile.mobile})`:"-",(ju=(eu=(Z=s==null?void 0:s.poultry)==null?void 0:Z.address)==null?void 0:eu.city)!=null&&ju.name?`${s.poultry.address.city.name}/${(cu=s==null?void 0:s.poultry)!=null&&cu.cityOperator?s.poultry.cityOperator:"بدون تعاونی"}`:"-",(iu=s==null?void 0:s.vetFarm)!=null&&iu.vetFarmMobile?`${s.vetFarm.vetFarmFullName} (${s.vetFarm.vetFarmMobile})`:"-",(s==null?void 0:s.hall)||"-",(s==null?void 0:s.period)||"-",Zu(s==null?void 0:s.createDate)||"-",Zu(s==null?void 0:s.date)||"-",(s==null?void 0:s.chickenBreed)||"-",(s==null?void 0:s.age)||"-",s!=null&&s.quantity?s.quantity.toLocaleString():"-",s!=null&&s.losses&&(s!=null&&s.quantity)?`${s.losses} (%${(s.losses*100/s.quantity).toFixed(0)})`:"-",s!=null&&s.outProvinceKilledQuantity?s.outProvinceKilledQuantity.toLocaleString():"-",s!=null&&s.governmentalKilledQuantity?s.governmentalKilledQuantity.toLocaleString():"-",s!=null&&s.freeKilledQuantity?s.freeKilledQuantity.toLocaleString():"-",s!=null&&s.outProvinceKilledWeight?s.outProvinceKilledWeight.toLocaleString():"-",s!=null&&s.chainKilledQuantity?s.chainKilledQuantity.toLocaleString():"-",s!=null&&s.chainKilledWeight?s.chainKilledWeight.toLocaleString():"-",s!=null&&s.quantity&&a!==void 0?`${a.toLocaleString()} (%${(a*100/s.quantity).toFixed(0)})`:"-",s!=null&&s.leftOver&&(s!=null&&s.quantity)?`${s.leftOver.toLocaleString()} (%${(s.leftOver*100/s.quantity).toFixed(0)})`:"-",(O=s==null?void 0:s.activeKill)!=null&&O.activeKill?"دارد":"ندارد",((_=s==null?void 0:s.activeKill)==null?void 0:_.countOfRequest)||"-",M||"-"]});f(P)},[t,F,l,S,e]);const $=async P=>{P.preventDefault(),A(1),b(1,S)},z=u.jsx(o,{container:!0,alignItems:"center",justifyContent:"space-between",gap:2,paddingTop:2,mb:1,children:u.jsxs(o,{container:!0,alignItems:"center",gap:w.SMALL,children:[u.jsx(H,{children:"آرشیو جوجه ریزی "}),u.jsxs("form",{onSubmit:$,children:[u.jsx(U,{id:"outlined-basic",size:"small",label:"جستجو",variant:"outlined",style:{width:250},onChange:j}),u.jsx(W,{type:"submit",onClick:$,endIcon:u.jsx(Ku,{}),children:"جستجو"}),u.jsx(Lu,{title:"خروجی اکسل",children:u.jsx("a",{href:`${J.defaults.baseURL}archive_hatching_excel/?chain=true&key=${h}&role=${tu()}`,rel:"noreferrer",children:u.jsx(W,{color:"success",children:u.jsx(mu,{size:32})})})})]})]})});return u.jsx(o,{alignItems:"center",justifyContent:"center",xs:12,children:u.jsx(zu,{title:z,columns:L,data:x,totalRows:p,page:F,perPage:l,handlePageChange:v,handlePerRowsChange:E})})},At=()=>{const[e,t]=x0.useState("0"),r=(x,f)=>{t(f)};return u.jsxs(o,{container:!0,justifyContent:"center",xs:12,children:[u.jsxs(g0,{value:e,onChange:r,textColor:"secondary",indicatorColor:"secondary","aria-label":"secondary tabs example",scrollButtons:"auto",variant:"scrollable",allowScrollButtonsMobile:!0,children:[u.jsx(Nu,{value:"0",label:"زنجیره های فعال"}),u.jsx(Nu,{value:"1",label:"مدیریت بارها"}),u.jsx(Nu,{value:"2",label:"شرکت ها"}),u.jsx(Nu,{value:"3",label:"بایگانی"})]}),u.jsxs(o,{container:!0,justifyContent:"center",alignItems:"center",px:2,xs:12,children:[u.jsx(o,{container:!0,justifyContent:"center",mt:2,xs:12,children:e==="0"&&u.jsx(Ct,{})}),u.jsx(o,{container:!0,justifyContent:"center",mt:2,xs:12,children:e==="1"&&u.jsx(Hn,{})}),u.jsx(o,{container:!0,justifyContent:"center",mt:2,xs:12,children:e==="2"&&u.jsx(qr,{})}),u.jsx(o,{container:!0,justifyContent:"center",xs:12,children:e==="3"&&u.jsx(ht,{})})]})]})},xt=()=>{const e=m(),[t,r]=c.useState(0),x=(y,C)=>{r(C)},[,,f,p,n,l]=c.useContext(su);c.useEffect(()=>{const y=ou(new Date).format("YYYY-MM-DD");p(y),l(y)},[]);const g=y=>{v(y.target.value)},[F,A]=c.useState([]),[S,d]=c.useState(0),[h,j]=c.useState(10),[b,v]=c.useState(""),[E,L]=c.useState(1),[$,z]=c.useState([]),[P,s]=c.useState([]),D=async y=>{e(q());const C=await J.get(`kill_request/?export=true&type=${t===0?"pending":"archive"}&search=filter&value=${b}&role=${tu()}&date1=${f}&date2=${n}&page=${y}&page_size=${h}`);e(V()),A(C.data.results),d(C.data.count)},a=y=>{D(y),L(y)},M=y=>{j(y),L(1)},N=()=>{D(E!==0?E:1)};c.useEffect(()=>{D(1)},[]);const R=y=>{let C="";return y.exportState==="pending"?C="در انتظار تایید":y.exportState==="rejected"?C="رد شده":y.exportState==="accepted"?C="تایید شده":y.exportState==="deleted"&&(C="حذف شده"),C};c.useEffect(()=>{const y=F==null?void 0:F.map((i,k)=>{var B,T,Q,nu,Z,eu;return[E===1?k+1:k+h*(E-1)+1,pu(i==null?void 0:i.createDate),pu(i.reciveDate),`${i.killHouse.name} (${i.killHouse.killHouseOperator.user.mobile})`,i!=null&&i.slaughterHouse?(B=i==null?void 0:i.slaughterHouse)==null?void 0:B.name:(T=i==null?void 0:i.killHouse)==null?void 0:T.name,i==null?void 0:i.exportCountry,`${(nu=(Q=i==null?void 0:i.poultry)==null?void 0:Q.userprofile)==null?void 0:nu.fullName} (${(eu=(Z=i==null?void 0:i.poultry)==null?void 0:Z.userprofile)==null?void 0:eu.mobile})`,i.killCapacity,i.IndexWeight,(i.IndexWeight*i.killCapacity).toLocaleString(),u.jsx(u.Fragment,{children:i!=null&&i.inputDirectBuyingCode?i==null?void 0:i.inputDirectBuyingCode:u.jsx(Lu,{title:"ثبت کد احراز",placement:"top",children:u.jsx(xu,{color:"primary",size:"small",onClick:()=>{e(wu({title:"ثبت کد احراز",size:"auto",content:u.jsx(zn,{item:i,updateTable:N})}))},children:u.jsx(Gn,{fontSize:"small"})})})}),u.jsx(Ye,{label:R(i),color:R(i)==="تایید شده"?"success":R(i)==="رد شده"?"error":R(i)==="حذف شده"?"default":"warning",size:"small",variant:"outlined"},`${i.key}-state`),u.jsx(Rn,{item:i,updateTable:N},i)]});z(y);const C=F==null?void 0:F.map((i,k)=>{var B,T,Q,nu,Z,eu;return[E===1?k+1:k+h*(E-1)+1,pu(i==null?void 0:i.createDate),pu(i.reciveDate),`${i.killHouse.name} (${i.killHouse.killHouseOperator.user.mobile})`,i!=null&&i.slaughterHouse?(B=i==null?void 0:i.slaughterHouse)==null?void 0:B.name:(T=i==null?void 0:i.killHouse)==null?void 0:T.name,i==null?void 0:i.exportCountry,`${(nu=(Q=i==null?void 0:i.poultry)==null?void 0:Q.userprofile)==null?void 0:nu.fullName} (${(eu=(Z=i==null?void 0:i.poultry)==null?void 0:Z.userprofile)==null?void 0:eu.mobile})`,i.killCapacity,i.IndexWeight,(i.IndexWeight*i.killCapacity).toLocaleString(),R(i),i!=null&&i.acceptRejectDate?Zu(i==null?void 0:i.acceptRejectDate):"-",i==null?void 0:i.directBuyingMessage]});s(C)},[F]),c.useEffect(()=>{D(1)},[f,n,h,t]);const Y=async y=>{y.preventDefault(),e(q());try{const C=await J.get(`kill_request/?export=true&type=${t===0?"pending":"archive"}&role=${tu()}&search=filter&value=${b}&date1=${f}&date2=${n}&page=1&page_size=${h}`);A(C.data.results),d(C.data.count),e(V())}catch(C){console.error("Error fetching data:",C)}},K=Fu(y=>y.userSlice.userProfile.key);return u.jsxs(o,{container:!0,direction:"column",flexWrap:"nowrap",mt:w.SMALL,children:[u.jsx(o,{container:!0,justifyContent:"center",alignItems:"center",my:w.SMALL,children:u.jsxs(g0,{scrollButtons:"auto",variant:"scrollable",allowScrollButtonsMobile:!0,value:t,onChange:x,children:[u.jsx(Nu,{label:"درخواست های جدید"}),u.jsx(Nu,{label:"بایگانی"})]})}),u.jsxs(o,{container:!0,mt:w.MEDIUM,alignItems:"center",justifyContent:"center",gap:2,children:[u.jsx("form",{onSubmit:Y,children:u.jsxs(o,{container:!0,alignItems:"center",gap:w.SMALL,children:[u.jsx(U,{size:"small",autoComplete:"off",label:"جستجو",variant:"outlined",style:{width:250},onChange:g}),u.jsx(W,{type:"submit",onClick:Y,endIcon:u.jsx(Ku,{}),children:"جستجو"}),u.jsx(o,{children:u.jsx(yu,{label:"از تاریخ",id:"date",renderInput:y=>u.jsx(U,{style:{width:"160px"},...y}),value:f,onChange:y=>{p(ou(y).format("YYYY-MM-DD"))}})}),u.jsx(o,{children:u.jsx(yu,{label:"تا تاریخ",id:"date",renderInput:y=>u.jsx(U,{style:{width:"160px"},...y}),value:n,onChange:y=>{l(ou(y).format("YYYY-MM-DD"))}})}),t===1&&u.jsx(o,{children:u.jsx(Lu,{title:"خروجی اکسل",children:u.jsx("a",{href:`${J.defaults.baseURL}export_kill_house_excel/?date1=${f}&date2=${n}&role=${tu()}&key=${K}`,rel:"noreferrer",children:u.jsx(W,{color:"success",children:u.jsx(mu,{size:32})})})})})]})}),t===0?u.jsx(zu,{data:$,columns:["ردیف","تاریخ ثبت درخواست","تاریخ کشتار","خریدار","محل کشتار","کشور مقصد","مرغدار (تلفن)","تعداد درخواست (قطعه)","میانگین وزنی (کیلوگرم)","وزن کل (کیلوگرم)","کد احراز","وضعیت","عملیات"],handlePageChange:a,totalRows:S,page:E,perPage:h,handlePerRowsChange:M,title:"صادرات"}):u.jsx(zu,{data:P,columns:["ردیف","تاریخ ثبت درخواست","تاریخ کشتار","خریدار","محل کشتار","کشور مقصد","مرغدار (تلفن)","تعداد درخواست (قطعه)","میانگین وزنی (کیلوگرم)","وزن کل (کیلوگرم)","وضعیت","تاریخ تایید/رد","دلیل رد"],handlePageChange:a,totalRows:S,page:E,perPage:h,handlePerRowsChange:M,title:"بایگانی صادرات"})]})]})},Dl=()=>{const{pathname:e}=u6();return u.jsx(K6,{display:"flex",justifyContent:"center",children:u.jsxs(o,{container:!0,direction:"column",justifyContent:"center",xs:12,sm:12,md:10,lg:10,children:[e===nn||e===rn||e===tn?u.jsx(o,{justifyContent:"start",alignItems:"start",my:w.MEDIUM,children:tu()==="SuperAdmin"||tu()==="AdminX"?u.jsxs(u.Fragment,{children:[u.jsx(o,{children:tu()==="SuperAdmin"?u.jsx(H,{textAlign:"center",variant:"h6",children:"داشبورد ادمین کل"}):u.jsx(H,{textAlign:"center",variant:"h6",children:"داشبورد ادمین ایکس"})}),u.jsx(Xr,{})]}):u.jsxs(u.Fragment,{children:[u.jsx(o,{children:u.jsx(H,{textAlign:"center",variant:"h6",children:"داشبورد تخصیص استان"})}),u.jsx(Xn,{})]})}):u.jsx(Tn,{}),u.jsxs(o,{xs:12,container:!0,children:[(e===w0||e===B0||e===m6)&&u.jsx(er,{}),(e===P0||e===U0||e===ue)&&u.jsx(nr,{}),e===ln&&u.jsx(mn,{}),(e===O0||e===W0||e===ee)&&u.jsx(kr,{}),(e===an||e===sn||e===on)&&u.jsx(Tr,{}),(e===H6||e===te||e===re)&&u.jsx(_n,{}),(e===T6||e===cn||e===T6)&&u.jsx(ur,{}),(e===Cn||e===dn||e===hn)&&u.jsx(Dn,{}),(e===An||e===xn||e===pn)&&u.jsx(Ln,{}),(e===jn||e===fn||e===Fn)&&u.jsx(kn,{}),(e===z0||e===V0||e===le)&&u.jsx(Ur,{}),(e===$0||e===K0||e===ae)&&u.jsx(At,{}),(e===I0||e===Q0||e===se)&&u.jsx(Bn,{}),(e===Ju||e===yn||e===gn)&&u.jsx(Un,{}),(e===R0||e===H0||e===oe)&&u.jsx(Gr,{}),(e===Y0||e===M0||e===ne)&&u.jsx(xt,{})]})]})})};export{Dl as default};