1import{u as lt,j as e}from"./query-vendor-hhwDzQ2O.js";import{r as n}from"./react-vendor-CeHpY9tY.js";import{D as Ct}from"./DashboardLayout-DvVs0FN8.js";import{a as xt,i as mt,I as m,B as re,u as ht,L as b}from"./index-DCdJkPd2.js";import{_ as St,ai as Ne,t as kt,X as je,bj as Dt,aO as Ke,a9 as He,C as ue,r as Ae,A as qe,h as nt,e as ot,a3 as Ft,z as At,D as Tt,T as it,bx as ct,bk as Rt,a0 as It,b as Bt}from"./icons-vendor-B7tMGsnB.js";const xe={async get(s){const o=localStorage.getItem("token")||sessionStorage.getItem("token");console.log(" Auth token found:",o?"YES":"NO");const i=await fetch(s,{headers:{Authorization:o?`Bearer ${o}`:"","Content-Type":"application/json"}});if(console.log(" Response status:",i.status),console.log(" Response OK:",i.ok),!i.ok){console.error(" Response not OK:",i.status,i.statusText);let j=`HTTP ${i.status}: ${i.statusText}`;try{const z=await i.json();console.error(" Error details:",z),j=z.message||j}catch(z){console.error(" Could not parse error response as JSON:",z);try{const M=await i.text();console.error(" Error response text:",M),M&&(j=M)}catch(M){console.error(" Could not get error response text:",M)}}throw new Error(j)}let d;try{return d=await i.json(),console.log(" Raw response data:",d),console.log(" Data type:",typeof d),console.log(" Is null?",d===null),console.log(" Is undefined?",d===void 0),console.log(" Is array?",Array.isArray(d)),d}catch(j){throw console.error(" Failed to parse JSON:",j),new Error("Invalid JSON response from server")}},async post(s,o){const i=localStorage.getItem("token")||sessionStorage.getItem("token"),d=await fetch(s,{method:"POST",headers:{Authorization:i?`Bearer ${i}`:"","Content-Type":"application/json"},body:JSON.stringify(o)});if(!d.ok){let j=`HTTP ${d.status}: ${d.statusText}`;try{const z=await d.json();j=z.error||z.message||j}catch{}throw new Error(j)}return await d.json()},async put(s,o){const i=localStorage.getItem("token")||sessionStorage.getItem("token"),d=await fetch(s,{method:"PUT",headers:{Authorization:i?`Bearer ${i}`:"","Content-Type":"application/json"},body:JSON.stringify(o)});if(!d.ok){let j=`HTTP ${d.status}: ${d.statusText}`;try{const z=await d.json();j=z.error||z.message||j}catch{}throw new Error(j)}return await d.json()},async delete(s){const o=localStorage.getItem("token")||sessionStorage.getItem("token"),i=await fetch(s,{method:"DELETE",headers:{Authorization:o?`Bearer ${o}`:""}});if(!i.ok){let d=`HTTP ${i.status}: ${i.statusText}`;try{const j=await i.json();d=j.error||j.message||d}catch{}throw new Error(d)}return await i.json()}};function Yt({initialTab:s}){const{toast:o}=xt(),{user:i,token:d}=mt(),j=i?.role==="branch_admin"||i?.role==="accountant",{data:z=[]}=lt({queryKey:["branches-list"],queryFn:async()=>{const r=await fetch("/api/branches",{headers:d?{Authorization:`Bearer ${d}`}:{}});return r.ok?r.json():[]},staleTime:6e4}),M=z.find(r=>Number(r.id)===Number(i?.branchId))?.name||(i?.branchId?`Branch #${i.branchId}`:"Assigned Branch"),[T,O]=n.useState(s||"admission"),[h,E]=n.useState(""),[R,q]=n.useState(null),F=R?.branchId?z.find(r=>Number(r.id)===Number(R.branchId))?.name:M,[G,V]=n.useState(!1),[_,c]=n.useState("");n.useEffect(()=>{s&&(O(s),q(null),E(""),V(!1))},[s]);const p={admission:{title:"Admission Record",subtitle:"Generate and print official student admission records"},feechart:{title:"Student Fee Chart",subtitle:"Generate and print student fee charts with installment details"},clearance:{title:"Certificate Clearance",subtitle:"Issue and manage certificate clearance entries for students"}}[T];n.useEffect(()=>{const r=setTimeout(()=>{c(h)},100);return()=>clearTimeout(r)},[h]),n.useEffect(()=>{_.trim().length>=2?V(!0):V(!1)},[_]);const{data:a,isLoading:D,error:v}=lt({queryKey:["/api/users/students/search",_],queryFn:async()=>_.trim().length<2?[]:await xe.get(`/api/users/students/search?q=${encodeURIComponent(_)}`),enabled:_.trim().length>=2,staleTime:3e4}),u=n.useMemo(()=>!a||!Array.isArray(a)?[]:j&&i?.branchId?a.filter(r=>!r.branchId||Number(r.branchId)===Number(i.branchId)):a,[a,j,i?.branchId]),y=()=>{if(!h.trim()||h.trim().length<2){o({title:"Please enter at least 2 characters",variant:"destructive"});return}V(!0)},A=async r=>{try{let l=typeof r=="object"&&r!==null?r:(u||[]).find(g=>g.id===r);if(!l||!l.id||!l.enrollments){const g=typeof r=="number"?r:r?.id;l=await xe.get(`/api/users/${g}/details`)}if(!l||typeof l!="object"||!l.id)throw new Error("Invalid student data received");if(j&&i?.branchId&&l.branchId&&Number(l.branchId)!==Number(i.branchId)){o({title:"Access Restricted",description:`This student belongs to another campus. You can only view ${M} students.`,variant:"destructive"});return}q(l),V(!1),E(""),o({title:` Form Auto-Filled for ${l.fullName||l.name}`})}catch(l){o({title:"Error loading student details",description:l.message||"Please try again",variant:"destructive"})}},f=()=>{const r=document.querySelector(".form-printable");if(!r){o({title:"Error: Form not found",variant:"destructive"});return}const l=r.cloneNode(!0),g=r.querySelectorAll("input"),W=l.querySelectorAll("input");g.forEach((Q,X)=>{W[X].setAttribute("value",Q.value)});const ee=r.querySelectorAll("textarea"),I=l.querySelectorAll("textarea");ee.forEach((Q,X)=>{I[X].textContent=Q.value});const L=r.querySelectorAll("select"),K=l.querySelectorAll("select");
1L.forEach((Q,X)=>{const Z=Q,te=K[X];te.value=Z.value;const ne=Z.selectedIndex;te.options[ne]&&te.options[ne].setAttribute("selected","selected")});const P=window.open("","_blank");if(!P){o({title:"Error: Please allow popups",variant:"destructive"});return}const J=T==="admission"?"Student Admission Record":T==="feechart"?"Student Fee Chart":"Certificate Clearance",Y=F||M,le=l.innerHTML;P.document.write(` 2 <!DOCTYPE html> 3 <html> 4 <head> 5 <title>${J}${Y?` - ${Y}`:""} - Global College</title> 6 <style> 7 * { 8 margin: 0; 9 padding: 0; 10 box-sizing: border-box; 11 -webkit-print-color-adjust: exact !important; 12 color-adjust: exact !important; 13 print-color-adjust: exact !important; 14 } 15 body { 16 font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif; 17 padding: 0.3cm; 18 background: #ffffff; 19 color: #0f172a; 20 font-size: 10.5pt; 21 } 22 @page { 23 size: A4 portrait; 24 margin: 0.3cm; 25 } 26 /* Hide print-hidden elements and action buttons */ 27 button, .print\\:hidden, [class*="print:hidden"] { 28 display: none !important; 29 } 30 /* Form inputs and textareas font alignment */ 31 input, textarea { 32 font-family: inherit; 33 color: inherit; 34 } 35 /* Responsive table behavior for print */ 36 table { 37 width: 100% !important; 38 table-layout: auto !important; 39 } 40 /* Avoid page break inside key sections */ 41 table, tr, .signature-section { 42 page-break-inside: avoid; 43 } 44 @media print { 45 .max-w-6xl { 46 max-width: 100% !important; 47 padding: 0 !important; 48 border: none !important; 49 box-shadow: none !important; 50 margin: 0 !important; 51 } 52 table { 53 min-width: 0 !important; 54 } 55 } 56 </style> 57 </head> 58 <body> 59 ${le} 60 </body> 61 </html> 62 `),P.document.close(),P.focus(),P.onafterprint=()=>{P.close()},setTimeout(()=>{P.print()},250)};return e.jsx(Ct,{children:e.jsxs("div",{className:"pb-12 print:hidden",children:[e.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center sm:justify-between gap-3 mb-6",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-bold text-gray-900 mb-1",children:p.title}),e.jsx("p",{className:"text-gray-500 text-sm",children:p.subtitle})]}),j&&e.jsxs("div",{className:"flex items-center gap-2 px-3.5 py-2 rounded-xl border border-indigo-200 bg-indigo-50/90 text-indigo-900 text-xs font-bold self-start sm:self-auto shadow-sm",children:[e.jsx(St,{className:"h-4 w-4 text-indigo-600 shrink-0"}),e.jsxs("span",{children:["Branch Locked: ",e.jsx("strong",{className:"text-indigo-950 font-black",children:M})]})]})]}),e.jsxs("div",{className:"bg-white rounded-2xl border border-slate-200/80 p-5 sm:p-6 mb-6 shadow-md",children:[e.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center justify-between gap-2 mb-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"h-9 w-9 rounded-xl bg-indigo-100 flex items-center justify-center text-indigo-600 shrink-0",children:e.jsx(Ne,{className:"h-5 w-5"})}),e.jsxs("div",{children:[e.jsx("h2",{className:"text-base font-extrabold text-slate-900",children:"Search Student"}),e.jsx("p",{className:"text-xs text-slate-500",children:j?`Auto-fill form for ${M} students only`:"Auto-fill the form with official student enrollment & fee records"})]})]}),e.jsxs("div",{className:"flex items-center gap-2 self-start sm:self-auto",children:[j&&e.jsxs("span",{className:"text-[11px] text-indigo-800 font-extrabold bg-indigo-50 px-2.5 py-1 rounded-lg border border-indigo-200 flex items-center gap-1.5",children:[e.jsx(kt,{className:"h-3.5 w-3.5 text-indigo-600"}),M]}),e.jsx("span",{className:"text-[10px] text-indigo-700 font-extrabold bg-indigo-50 px-2.5 py-1 rounded-lg border border-indigo-200",children:"Instant Form Auto-Fill"})]})]}),e.jsx("div",{className:"relative group",children:e.jsxs("div",{className:"relative flex items-center",children:[e.jsx(Ne,{className:"absolute left-3.5 h-4.5 w-4.5 text-slate-400 group-focus-within:text-indigo-600 transition-colors pointer-events-none z-10"}),e.jsx(m,{type:"text",placeholder:j?`Search ${M} Students by CNIC, Name, Roll No, or Reg No...`:"Search Student by CNIC (e.g. 35202-1234567-1), Name, Roll No, or Reg No...",value:h,onChange:r=>E(r.target.value),onKeyPress:r=>r.key==="Enter"&&y(),className:"pl-10 pr-10 h-12 rounded-xl border-slate-200 bg-slate-50/50 hover:bg-white hover:border-indigo-300 focus:bg-white focus:border-indigo-500 focus:ring-4 focus:ring-indigo-500/10 text-sm font-semibold shadow-sm transition-all duration-200",autoComplete:"off"}),h&&e.jsx("button",{onClick:()=>{E(""),V(!1)},className:"absolute right-3.5 h-6 w-6 rounded-full hover:bg-slate-100 flex items-center justify-center text-slate-400 hover:text-slate-700 transition-colors",type:"button",children:e.jsx(je,{className:"h-4 w-4"})})]})}),G&&h.trim().length>=2&&e.jsx("div",{className:"mt-3 max-h-80 overflow-y-auto border border-slate-200 rounded-2xl shadow-2xl bg-white border-t-4 border-t-indigo-600 divide-y divide-slate-100 animate-in fade-in-50 slide-in-from-top-2 duration-150",children:D?e.jsxs("div",{className:"p-6 text-center text-slate-500 flex items-center justify-center gap-2",children:[e.jsx(Ne,{className:"h-5 w-5 animate-spin text-indigo-600"}),e.jsx("span",{className:"font-bold text-sm",children:"Searching student database..."})]}):!u||u.length===0?e.jsxs("div",{className:"p-6 text-center text-slate-500 font-medium",children:["No active ",j?`${M} `:"",'students found matching "',h,'"']}
62):e.jsxs("div",{className:"divide-y divide-slate-100",children:[e.jsxs("div",{className:"px-4 py-2 bg-slate-50 border-b border-slate-200 flex items-center justify-between sticky top-0 z-10",children:[e.jsxs("span",{className:"text-[11px] font-black text-slate-600 uppercase tracking-wider",children:["Found ",u.length," Student Result",u.length>1?"s":""]}),e.jsx("span",{className:"text-[10px] text-indigo-700 font-bold",children:"Click to select & auto-fill form"})]}),u.map(r=>e.jsxs("div",{onClick:()=>A(r),className:"p-3.5 hover:bg-indigo-50/80 cursor-pointer transition-all flex flex-col sm:flex-row items-start sm:items-center justify-between gap-3 group border-b last:border-0 border-slate-100",children:[e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("div",{className:"h-10 w-10 rounded-xl bg-gradient-to-br from-[#6b1a2e] to-[#8b1538] text-white font-black flex items-center justify-center text-base shadow-sm shrink-0 mt-0.5",children:r.fullName?.charAt(0).toUpperCase()||"S"}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("p",{className:"font-extrabold text-slate-900 group-hover:text-[#6b1a2e] transition-colors text-sm",children:r.fullName}),r.fatherName&&e.jsxs("span",{className:"text-xs text-slate-400 font-medium",children:["(S/O ",r.fatherName,")"]})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-x-2 gap-y-0.5 text-xs text-slate-500 font-medium mt-0.5",children:[r.rollNumber&&e.jsxs("span",{children:["Roll: ",e.jsx("strong",{className:"text-slate-800",children:r.rollNumber})]}),r.registrationNumber&&e.jsxs("span",{children:["Reg: ",e.jsx("strong",{className:"text-slate-800",children:r.registrationNumber})]}),r.cnic&&e.jsxs("span",{children:["CNIC: ",e.jsx("strong",{className:"text-slate-800",children:r.cnic})]})]}),r.enrollments&&r.enrollments.length>0&&e.jsxs("div",{className:"flex flex-wrap items-center gap-1 mt-1.5",children:[e.jsxs("span",{className:"text-[10px] font-bold text-[#6b1a2e] uppercase",children:["Courses (",r.enrollments.length,"):"]}),r.enrollments.slice(0,3).map((l,g)=>e.jsx("span",{className:"text-[10px] font-bold bg-slate-100 text-slate-700 px-2 py-0.5 rounded border border-slate-200",children:l.course?.title||l.courseName||l.courseTitle},g)),r.enrollments.length>3&&e.jsxs("span",{className:"text-[10px] font-bold bg-indigo-50 text-indigo-700 px-1.5 py-0.5 rounded",children:["+",r.enrollments.length-3," more"]})]})]})]}),e.jsx("div",{className:"bg-[#6b1a2e] text-white font-extrabold text-xs px-3.5 py-2 rounded-xl group-hover:bg-[#581525] transition-all shadow-sm shrink-0 flex items-center gap-1 self-end sm:self-center",children:"Instant Auto-Fill"})]},r.id))]})}),R&&e.jsx("div",{className:"mt-4 p-4 bg-green-50 border border-green-200 rounded-lg",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-12 h-12 rounded-full bg-green-600 flex items-center justify-center text-white font-bold text-lg",children:R.fullName.charAt(0)}),e.jsxs("div",{className:"flex-1",children:[e.jsx("p",{className:"font-bold text-green-900",children:R.fullName}),e.jsxs("p",{className:"text-sm text-green-700",children:["Roll: ",R.rollNumber," | Father: ",R.fatherName]})]}),e.jsx(re,{size:"sm",variant:"outline",onClick:()=>{q(null),E("")},children:e.jsx(je,{className:"h-4 w-4"})})]})})]}),e.jsxs("div",{className:"bg-white rounded-lg border-2 border-gray-200 shadow-sm print:border-0 print:shadow-none",children:[T!=="clearance"&&e.jsxs("div",{className:"p-4 border-b border-gray-200 bg-gray-50 flex gap-2 print:hidden",children:[e.jsxs(re,{onClick:f,variant:"default",className:"bg-[#6b1a2e] hover:bg-[#581525]",children:[e.jsx(Dt,{className:"h-4 w-4 mr-2"}),"Print ",T==="admission"?"Admission Record":"Fee Chart"]}),e.jsx(re,{variant:"outline",onClick:()=>q(null),children:"Clear Form"})]}),e.jsxs("div",{className:`${T!=="clearance"?"p-6":""} form-printable print:p-0`,children:[T==="admission"&&e.jsx(Et,{student:R,campusName:F||M}),T==="feechart"&&e.jsx(Pt,{student:R,campusName:F||M}),T==="clearance"&&e.jsx($t,{student:R})]})]})]})})}function Re(s){return s?s.receiptNo||s.receiptNumber||s.receipt_no||(s.id?String(s.id):""):""}function Te(s){const o=["","One","Two","Three","Four","Five","Six","Seven","Eight","Nine","Ten","Eleven","Twelve","Thirteen","Fourteen","Fifteen","Sixteen","Seventeen","Eighteen","Nineteen"],i=["","","Twenty","Thirty","Forty","Fifty","Sixty","Seventy","Eighty","Ninety"];
62if(s===0)return"Zero";if(s<0)return"Negative "+Te(-s);let d="";return s>=1e5&&(d+=Te(Math.floor(s/1e5))+" Lakh ",s%=1e5),s>=1e3&&(d+=Te(Math.floor(s/1e3))+" Thousand ",s%=1e3),s>=100&&(d+=o[Math.floor(s/100)]+" Hundred ",s%=100),s>=20&&(d+=i[Math.floor(s/10)]+" ",s%=10),s>0&&(d+=o[s]+" "),d.trim()}function Et({student:s,campusName:o}){const{user:i}=mt(),{get:d}=ht(),j=d("site_name","Global Group of Colleges"),z=i?.role==="branch_admin"||i?.role==="accountant",[M,T]=n.useState(""),[O,h]=n.useState([]),E=new Date().toLocaleDateString("en-GB"),R=new Date().toLocaleDateString("en-GB",{month:"long",year:"numeric"});n.useEffect(()=>{if(T(R),s&&s.enrollments&&s.enrollments.length>0){const c=[],k=new Set;for(const v of s.enrollments){const u=(v.course?.title||v.courseName||v.courseTitle||"").trim().toLowerCase(),y=v.courseId||v.course?.id||u;y&&!k.has(y)?(k.add(y),c.push(v)):y||c.push(v)}const p=(s.payments||[]).filter(v=>v.status==="approved"||v.status==="verified"||v.status==="paid"),a=new Set,D=c.map((v,u)=>{let y=p.filter(I=>I.courseId&&Number(I.courseId)===Number(v.courseId));if(y.length===0&&c.length===1&&(y=p),y.length===0){const I=p.filter(L=>!a.has(L.id)&&!L.courseId);I.length>0&&(c.length>1&&u<I.length?y=[I[u]]:u===0&&(y=I))}y.forEach(I=>a.add(I.id));const A=y.reduce((I,L)=>I+(Number(L.amount)||0),0),f=y.map(I=>Re(I)).filter(Boolean),r=f.length>0?f[f.length-1]:"",l=v.enrollmentDate?new Date(v.enrollmentDate).toLocaleDateString("en-GB"):E,g=v.course?.title||v.courseName||v.courseTitle||"Enrolled Course",W=v.course?.duration||v.courseDuration||"3 months",ee=v.course?.fee||v.course?.tuitionFee||(A>0?A:0);return{id:u+1,name:s.fullName,histNo:s.rollNumber||s.registrationNumber||"",course:g,admDate:l,duration:W,recNo:r,amount:A,totalFee:ee}});h(D)}else h(s?[{id:1,name:s.fullName,histNo:s.rollNumber||s.registrationNumber||"",course:"General Admission",admDate:E,duration:"3 months",recNo:s.payments&&s.payments[0]?Re(s.payments[0]):"",amount:s.payments&&s.payments[0]?s.payments[0].amount:0,totalFee:s.payments&&s.payments[0]?s.payments[0].amount:0}]:[{id:1,name:"",histNo:"",course:"",admDate:"",duration:"",recNo:"",amount:0,totalFee:0}])},[s,R]);const q=()=>{h([...O,{id:O.length+1,name:s?.fullName||"",histNo:s?.rollNumber||s?.registrationNumber||"",course:"",admDate:E,duration:"",recNo:"",amount:0,totalFee:0}])},F=c=>{h(O.filter(k=>k.id!==c))},G=(c,k,p)=>{h(O.map(a=>a.id===c?{...a,[k]:p}:a))},V=O.reduce((c,k)=>c+(parseFloat(k.amount)||0),0),_=O.reduce((c,k)=>c+(parseFloat(k.totalFee)||0),0);return e.jsxs("div",{className:"max-w-6xl mx-auto font-sans bg-white p-6 sm:p-10 border border-slate-200 shadow-xl rounded-md my-4",children:[e.jsxs("div",{style:{borderBottom:"3px double #0f2c6f",paddingBottom:"16px",marginBottom:"24px"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:"20px",paddingBottom:"16px",borderBottom:"1px solid #e2e8f0"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"16px"},children:[e.jsx("img",{src:"/logo.png",alt:"Global College Logo",style:{width:"70px",height:"70px",objectFit:"contain",flexShrink:0},onError:c=>{c.target.style.display="none"}}),e.jsxs("div",{children:[e.jsx("h1",{style:{margin:0,color:"#0f2c6f",fontSize:"20px",fontWeight:"950",letterSpacing:"0.5px",textTransform:"uppercase",lineHeight:"1.2"},children:j.toUpperCase()}),o&&e.jsx("div",{style:{color:"#0f2c6f",fontSize:"12px",fontWeight:"800",textTransform:"uppercase",letterSpacing:"0.8px",marginTop:"2px"},children:o}),e.jsxs("p",{style:{margin:"4px 0 0 0",color:"#475569",fontSize:"11px",fontWeight:"600"},children:[o?`${o} Branch`:"18 Hazari, Jhang District, Punjab, Pakistan"," Â |Â Phone: +92 348 6507399"]}),e.jsx("p",{style:{margin:"2px 0 0 0",color:"#64748b",fontSize:"10px",fontWeight:"500"},children:"Affiliated & Registered Technical Training Institution"})]})]}),e.jsxs("div",{style:{textAlign:"right",flexShrink:0,background:"#f8fafc",border:"1px solid #cbd5e1",padding:"8px 14px",borderRadius:"6px"},children:[e.jsx("div",{style:{color:"#64748b",fontSize:"9px",fontWeight:"800",textTransform:"uppercase",letterSpacing:"1px"},children:"Doc Ref No."}),e.jsx("div",{style:{color:"#0f2c6f",fontWeight:"900",fontSize:"13px",letterSpacing:"1px",marginTop:"2px"},children:"ADM-REC-2026"})]})]}),e.jsxs("div",{style:{background:"#f1f5f9",border:"1px solid #cbd5e1",borderRadius:"6px",margin:"16px 0",padding:"10px 20px",display:"flex",alignItems:"center",justifyContent:"space-between"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[e.jsx("span",{style:{fontSize:"11px",fontWeight:"800",color:"#334155",textTransform:"uppercase",letterSpacing:"0.5px"},children:"Record Month:"}),e.jsx("input",{type:"text",value:M,onChange:c=>T(c.target.value),placeholder:"e.g. July 2026",style:{border:"none",borderBottom:"2px s
62olid #0f2c6f",background:"transparent",fontSize:"12px",fontWeight:"800",color:"#0f2c6f",outline:"none",width:"120px",padding:"2px 4px"}})]}),e.jsx("h2",{style:{margin:0,fontSize:"16px",fontWeight:"900",color:"#0f2c6f",textTransform:"uppercase",letterSpacing:"2px",textAlign:"center"},children:"STUDENT ADMISSION RECORD"}),e.jsxs("div",{style:{fontSize:"11px",fontWeight:"800",color:"#334155"},children:[e.jsx("span",{style:{color:"#64748b",fontWeight:"600",marginRight:"6px"},children:"Date Prepared:"}),e.jsx("span",{style:{color:"#0f172a"},children:E})]})]}),s&&e.jsx("div",{style:{border:"1px solid #cbd5e1",borderRadius:"6px",padding:"16px",background:"#fafafa",marginTop:"12px"},children:e.jsxs("div",{style:{display:"flex",gap:"20px",alignItems:"flex-start"},children:[e.jsxs("div",{style:{flexShrink:0,textAlign:"center"},children:[e.jsx("div",{style:{width:"90px",height:"110px",border:"1.5px solid #0f2c6f",borderRadius:"4px",overflow:"hidden",background:"#ffffff",boxShadow:"0 1px 3px rgba(0,0,0,0.1)"},children:s.profilePicture?e.jsx("img",{src:s.profilePicture,alt:s.fullName,style:{width:"100%",height:"100%",objectFit:"cover"}}):e.jsxs("div",{style:{width:"100%",height:"100%",background:"linear-gradient(135deg, #0f2c6f, #1e3a8a)",display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center"},children:[e.jsx("span",{style:{color:"#ffffff",fontWeight:"900",fontSize:"28px"},children:s.fullName?.charAt(0).toUpperCase()}),e.jsx("span",{style:{color:"rgba(255,255,255,0.7)",fontSize:"8px",fontWeight:"700",letterSpacing:"1px",marginTop:"2px"},children:"TRAINEE"})]})}),e.jsx("div",{style:{marginTop:"4px",fontSize:"8px",fontWeight:"800",color:"#0f2c6f",textTransform:"uppercase"},children:"PASSPORT PHOTO"})]}),e.jsx("div",{style:{flex:1,display:"grid",gridTemplateColumns:"1fr 1fr",gap:"8px 24px"},children:[{label:"Trainee Name",value:s.fullName+(s.fatherName?` (S/O ${s.fatherName})`:"")},{label:"Roll Number",value:s.rollNumber||"N/A",highlight:!0},{label:"Registration No.",value:s.registrationNumber||"N/A"},{label:"Contact Phone",value:s.phoneNumber||"N/A"},{label:"CNIC / B-Form",value:s.cnic||"N/A"},{label:"Assigned Branch",value:o||s.branchName||"Main Branch"}].map(({label:c,value:k,highlight:p})=>e.jsxs("div",{style:{borderBottom:"1px solid #e2e8f0",paddingBottom:"4px",display:"flex",alignItems:"center",gap:"8px"},children:[e.jsxs("span",{style:{fontSize:"10px",fontWeight:"800",color:"#475569",textTransform:"uppercase",minWidth:"110px"},children:[c,":"]}),e.jsx("span",{style:{fontSize:"12px",fontWeight:"800",color:p?"#0f2c6f":"#0f172a",wordBreak:"break-word"},children:k})]},c))})]})})]}),e.jsxs("div",{className:"mb-4 print:hidden flex items-center gap-3",children:[e.jsxs(re,{onClick:q,size:"sm",className:"bg-[#0f2c6f] hover:bg-[#0b2256] text-white font-bold",children:[e.jsx(Ke,{className:"h-4 w-4 mr-2"}),"Add Admission Record"]}),e.jsx("span",{className:"text-xs text-slate-500 font-medium",children:"Click to add a new course admission row"})]}),e.jsx("div",{className:"overflow-x-auto",style:{border:"1px solid #0f2c6f",borderRadius:"6px",marginBottom:"28px"},children:e.jsxs("table",{style:{width:"100%",borderCollapse:"collapse",fontSize:"12px",minWidth:"900px"},children:[e.jsx("thead",{children:e.jsxs("tr",{style:{background:"#0f2c6f",color:"#ffffff"},children:[e.jsx("th",{style:{border:"1px solid #1e3a8a",padding:"10px 8px",textAlign:"center",fontWeight:"800",fontSize:"10px",textTransform:"uppercase",width:"45px"},children:"Sr."}),e.jsx("th",{style:{border:"1px solid #1e3a8a",padding:"10px 10px",textAlign:"left",fontWeight:"800",fontSize:"10px",textTransform:"uppercase",minWidth:"140px"},children:"Name of Trainee"}),e.jsx("th",{style:{border:"1px solid #1e3a8a",padding:"10px 10px",textAlign:"center",fontWeight:"800",fontSize:"10px",textTransform:"uppercase",minWidth:"135px"},children:"Roll / Hist. No."}),e.jsx("th",{style:{border:"1px solid #1e3a8a",padding:"10px 10px",textAlign:"left",fontWeight:"800",fontSize:"10px",textTransform:"uppercase",minWidth:"180px"},children:"Course Title"}),e.jsx("th",{style:{border:"1px solid #1e3a8a",padding:"10px 10px",textAlign:"center",fontWeight:"800",fontSize:"10px",textTransform:"uppercase",minWidth:"125px"},children:"Adm. Date"}),e.jsx("th",{style:{border:"1px solid #1e3a8a",padding:"10px 8px",textAlign:"center",fontWeight:"800",fontSize:"10px",textTransform:"uppercase",minWidth:"95px"},children:"Duration"}),e.jsx("th",{style:{border:"1px solid #1e3a8a",padding:"10px 8px",textAlign:"center",fontWeight:"800",fontSize:"10px",textTransform:"uppercase",minWidth:"95px"},children:"Fee Rec. No."}),e.jsx("th",{style:{border:"1px solid #1e3a8a",padding:"10px 10px",textAlign:"right",fontWeight:"800",fontSize:"10px",textTransform:"uppercase",minWidth:"105px"},children:"Fees Paid (Rs)"}),e.jsx("th",{style:{border:"1px solid #1e3a8a",padding:"10px 10px",textAlign:"right",fontWeight:"800",fontSize:"10px",textTransform:"uppercase",minWidth:"115px"},children:"Total Fee (Rs)"}),e.jsx("th",{className:"print:hidden",style:{border:"1px solid #1e3a8a",padding:"10px 6px",textAlign:"center",fontWeight:"800",fontSize:"10px",width:"40px"},children:"Action"})]})}),e.jsx("tbody",{children:O.map((c,k)=>
62e.jsxs("tr",{style:{background:k%2===0?"#ffffff":"#f8fafc",borderBottom:"1px solid #cbd5e1"},children:[e.jsx("td",{style:{border:"1px solid #cbd5e1",padding:"8px 4px",textAlign:"center",fontWeight:"900",color:"#0f2c6f",fontSize:"12px"},children:k+1}),e.jsx("td",{style:{border:"1px solid #cbd5e1",padding:"6px 8px"},children:e.jsx("input",{type:"text",value:c.name,onChange:p=>G(c.id,"name",p.target.value),style:{border:"none",background:"transparent",fontSize:"12px",fontWeight:"700",color:"#0f172a",width:"100%",outline:"none"},placeholder:"Student name"})}),e.jsx("td",{style:{border:"1px solid #cbd5e1",padding:"6px 8px",textAlign:"center",minWidth:"135px"},children:e.jsx("input",{type:"text",value:c.histNo,onChange:p=>G(c.id,"histNo",p.target.value),style:{border:"none",background:"transparent",fontSize:"12px",fontWeight:"800",color:"#0f2c6f",width:"100%",outline:"none",textAlign:"center",letterSpacing:"0.3px"},placeholder:"Roll / Hist. No."})}),e.jsx("td",{style:{border:"1px solid #cbd5e1",padding:"6px 8px"},children:e.jsx("textarea",{value:c.course,onChange:p=>G(c.id,"course",p.target.value),rows:c.course&&c.course.length>28?2:1,style:{border:"none",background:"transparent",fontSize:"12px",fontWeight:"800",color:"#0f172a",width:"100%",resize:"none",outline:"none",padding:"0",lineHeight:"1.4",overflow:"hidden"},placeholder:"Course name"})}),e.jsx("td",{style:{border:"1px solid #cbd5e1",padding:"6px 8px",textAlign:"center",minWidth:"125px"},children:e.jsx("input",{type:"text",value:c.admDate,onChange:p=>G(c.id,"admDate",p.target.value),style:{border:"none",background:"transparent",fontSize:"12px",fontWeight:"800",color:"#334155",width:"100%",outline:"none",textAlign:"center"},placeholder:"DD/MM/YYYY"})}),e.jsx("td",{style:{border:"1px solid #cbd5e1",padding:"6px 6px",textAlign:"center"},children:e.jsx("input",{type:"text",value:c.duration,onChange:p=>G(c.id,"duration",p.target.value),style:{border:"none",background:"transparent",fontSize:"11px",fontWeight:"700",color:"#334155",width:"100%",outline:"none",textAlign:"center"},placeholder:"e.g. 3 Months"})}),e.jsx("td",{style:{border:"1px solid #cbd5e1",padding:"6px 6px",textAlign:"center"},children:e.jsx("input",{type:"text",value:c.recNo,onChange:p=>G(c.id,"recNo",p.target.value),style:{border:"none",background:"transparent",fontSize:"11px",fontWeight:"800",color:"#2563eb",width:"100%",outline:"none",textAlign:"center"},placeholder:"Receipt #"})}),e.jsx("td",{style:{border:"1px solid #cbd5e1",padding:"6px 8px",textAlign:"right",background:"#f0fdf4"},children:e.jsx("input",{type:"number",value:c.amount,onChange:p=>G(c.id,"amount",p.target.value),style:{border:"none",background:"transparent",fontSize:"12px",fontWeight:"800",color:"#166534",width:"100%",outline:"none",textAlign:"right"},placeholder:"0"})}),e.jsx("td",{style:{border:"1px solid #cbd5e1",padding:"6px 8px",textAlign:"right",background:"#fdf2f2"},children:e.jsx("input",{type:"number",value:c.totalFee,onChange:p=>G(c.id,"totalFee",p.target.value),style:{border:"none",background:"transparent",fontSize:"12px",fontWeight:"900",color:"#991b1b",width:"100%",outline:"none",textAlign:"right"},placeholder:"0"})}),e.jsx("td",{className:"print:hidden",style:{border:"1px solid #cbd5e1",padding:"4px",textAlign:"center"},children:e.jsx(re,{size:"sm",variant:"ghost",onClick:()=>F(c.id),className:"h-6 w-6 p-0 text-red-500 hover:text-red-700 hover:bg-red-50",title:"Delete row",children:e.jsx(je,{className:"h-3.5 w-3.5"})})})]},c.id))}),e.jsx("tfoot",{children:e.jsxs("tr",{style:{background:"#0f2c6f",color:"#ffffff"},children:[e.jsx("td",{colSpan:7,style:{border:"1px solid #1e3a8a",padding:"10px 16px",textAlign:"center",fontWeight:"900",fontSize:"12px",textTransform:"uppercase",letterSpacing:"2px"},children:"GRAND TOTAL"}),e.jsxs("td",{style:{border:"1px solid #1e3a8a",padding:"10px 10px",textAlign:"right",color:"#86efac",fontWeight:"950",fontSize:"13px"},children:["Rs. ",V.toLocaleString()]}),e.jsxs("td",{style:{border:"1px solid #1e3a8a",padding:"10px 10px",textAlign:"right",color:"#fde68a",fontWeight:"950",fontSize:"13px"}
62,children:["Rs. ",_.toLocaleString()]}),e.jsx("td",{className:"print:hidden",style:{border:"1px solid #1e3a8a"}})]})})]})}),e.jsxs("div",{style:{marginTop:"48px",paddingTop:"10px"},children:[e.jsx("div",{style:{display:"flex",justifyContent:"space-between",gap:"30px"},children:[{role:"Prepared By",title:z?"Accountant / Branch Admin":"Admin Officer"},{role:"Verified By",title:"Academic Supervisor"},{role:"Approved By",title:"Principal / Director"}].map(({role:c,title:k})=>e.jsxs("div",{style:{flex:1,textAlign:"center"},children:[e.jsx("div",{style:{height:"45px"}}),e.jsxs("div",{style:{borderTop:"2px solid #0f2c6f",paddingTop:"8px",margin:"0 auto",maxWidth:"200px"},children:[e.jsx("div",{style:{fontSize:"11px",fontWeight:"900",color:"#0f172a",textTransform:"uppercase",letterSpacing:"0.5px"},children:c}),e.jsx("div",{style:{fontSize:"10px",fontWeight:"600",color:"#475569",marginTop:"2px"},children:k})]})]},c))}),e.jsxs("div",{style:{marginTop:"36px",paddingTop:"12px",borderTop:"1px solid #e2e8f0",textAlign:"center",color:"#64748b",fontSize:"10px",fontWeight:"500"},children:["This is an official computer-generated document of ",j,". For any verification, contact administration."]})]})]})}function dt({student:s,enrollment:o,courseIndex:i,totalCourses:d,campusName:j}){const{get:z}=ht(),M=z("site_name","Global Group of Colleges"),T=o?.course?.title||"Course Fee Chart",O=o?.course?.duration||"3 months",[h,E]=n.useState({rollNo:"",admNo:"",admDate:"",traineeName:"",fatherName:"",dob:"",mobile:"",fromDate:"",toDate:"",admFee:"",admFeeRecNo:"",certFee:"",certFeeRecNo:"",certFeeDate:"",totalWords:"",traineeSign:"",certBoard:"",certNo:"",photo:""}),[R,q]=n.useState(Array.from({length:12},(a,D)=>({month:D+1,recNo:"",date:"",amount:""})));n.useEffect(()=>{if(s){const a=o?.enrollmentDate?new Date(o.enrollmentDate):s.enrollments?.[0]?new Date(s.enrollments[0].enrollmentDate):null,D=a?a.toISOString().split("T")[0]:"";let v="";if(a){const W=O.match(/(\d+)/),ee=W?parseInt(W[1]):3,I=new Date(a);I.setMonth(I.getMonth()+ee),v=I.toISOString().split("T")[0]}const u=(s.payments||[]).filter(g=>g.status==="rejected"||g.status==="cancelled"||g.status==="failed"?!1:o?.courseId?!g.courseId||g.courseId===o.courseId:!0),y=u.reduce((g,W)=>g+(W.amount||0),0),A=u.map(g=>Re(g)).filter(Boolean),f=A.length>0?A[A.length-1]:"",r=o?.course?.fee||o?.courseFee||o?.course?.admissionFee||"",l=o?.course?.certificateFee>0?o?.course?.certificateFee:"";if(E({rollNo:s.rollNumber||"",admNo:s.registrationNumber||"",admDate:D,traineeName:s.fullName||"",fatherName:s.fatherName||"",dob:s.dateOfBirth?new Date(s.dateOfBirth).toISOString().split("T")[0]:"",mobile:s.phoneNumber||"",fromDate:D,toDate:v,admFee:r?r.toString():y>0?y.toString():"",admFeeRecNo:f,certFee:l?l.toString():"",certFeeRecNo:f||"",certFeeDate:"",totalWords:"",traineeSign:"",certBoard:"",certNo:"",photo:s.profilePicture||""}),u.length>0){u.sort((L,K)=>{const P=new Date(L.paymentDate||L.createdAt||0).getTime(),J=new Date(K.paymentDate||K.createdAt||0).getTime();return P-J});const g={};u.forEach(L=>{const K=L.paymentDate||L.createdAt||L.date,P=new Date(K);if(!isNaN(P.getTime())){const J=`${P.getFullYear()}-${String(P.getMonth()+1).padStart(2,"0")}`;g[J]||(g[J]=[]),g[J].push({amount:L.amount||0,recNo:Re(L),date:P.toISOString().split("T")[0]})}});const W=new Date(u[0].paymentDate||u[0].createdAt),ee=!isNaN(W.getTime())&&a&&W<a?W:a||(isNaN(W.getTime())?new Date:W),I=Array.from({length:12},(L,K)=>{const P=new Date(ee);P.setMonth(ee.getMonth()+K);const J=`${P.getFullYear()}-${String(P.getMonth()+1).padStart(2,"0")}`,Y=g[J]||[];if(Y.length>0){const le=Y.reduce((ne,me)=>ne+me.amount,0),Q=Y.map(ne=>ne.recNo).filter(Boolean),X=Q.length>0?Q[Q.length-1]:"",Z=Y[Y.length-1]?.date||Y[0]?.date||"";let te=Z;if(Z&&Z.includes("-")){const[ne,me,Ie]=Z.split("-");te=`${Ie}/${me}/${ne}`}return{month:K+1,recNo:X,date:te,amount:le>0?le.toString():""}}return{month:K+1,recNo:"",date:"",amount:""}});q(I)}}},[s,o]);const F=(a,D)=>{E({...h,[a]:D})},G=(a,D,v)=>{q(R.map(u=>u.month===a?{...u,[D]:v}:u))},V=R.reduce((a,D)=>a+(parseFloat(D.amount)||0),0),_=parseFloat(h.admFee)||0,c=parseFloat(h.certFee)||0,k=(_>0?_:V)+c,p=k>0?Te(Math.floor(k))+" Rupees Only":"";return n.useEffect(()=>{s&&T&&(async()=>{const D=u=>{if(!u)return"";const y=u.trim().split("/");if(y.length===3){const f=y[0].padStart(2,"0"),r=y[1].padStart(2,"0"),l=y[2];if(f&&r&&l&&l.length===4)return`${l}-${r}-${f}`}const A=new Date(u);return isNaN(A.getTime())?u:A.toISOString().split("T")[0]};try{const u=localStorage.getItem("token")||sessionStorage.getItem("token"),y=await fetch(`/api/admin/certificates?userId=${s.id}`,{headers:{Authorization:u?`Bearer ${u}`:""}});if(y.ok){const f=(await y.json()).find(r=>{const l=(r.courseName||"").trim().toLowerCase(),g=T.trim().toLowerCase();return l===g||l.includes(g)||g.includes(l)});if(f){const r=f.certFeeDate||f.issuedAt||"";let l="";r&&(r instanceof Date?l=r.toISOString().split("T")[0]:l=D(String(r))),E(g=>({...g,certNo:f.certificateNumber||g.certNo,certBoard:f.certBoard||f.certType||g.certBoard,certFee:f.certFee||g.certFee||"",certFeeRecNo:f.certFeeRecNo||g.certFeeRecNo||"",certFeeDate:l||g.certFeeDate||""}));return}}}catch(u){console.warn("API certificates load error for fee chart:",u)}const v=localStorage.getItem("gccs_clearance_records");if(v)try{const u=JSON.parse(v),y=T.trim().toLowerCase(),A=u.find(f=>{if(!(f.studentCnic&&s.cnic&&f.studentCnic.trim()===s.cnic.trim()||f.studentRoll&&s.rollNumber&&f.studentRoll.trim().toLowerCase()===s.rollNumber.trim().toLowerCase()||f.studentName&&s.fullName&&f.studentName.trim().toLowerCase()===s.fullName.trim().toLowerCase()))return!1;const l=(f.courseName||"").trim().toLowerCase();return l?l===y||y.includes(l)||l.includes(y):!1});if(A){const f=A.certFeeDate||A.issuedAt||"";let r="";f&&(f instanceof Date?r=f.toISOString().split("T")[0]:r=D(String(f))),E(l=>({...l,certNo:A.certificateNumber||l.certNo,certBoard:A.certBoard||A.certType||l.certBoard,certFee:A.certFee||l.certFee||"",certFeeRecNo:A.certFeeRecNo||l.certFeeRecNo||"",certFeeDate:r||l.certFeeDate||""}))}}catch{}})()},[s,T]),n.useEffect(()=>{p&&p!==h.totalWords&&E(a=>({...a,totalWords:p}))}
62,[p]),e.jsx("div",{className:"max-w-2xl mx-auto mb-10",children:e.jsxs("div",{className:"border-2 border-[#6b1a2e] rounded bg-white shadow-sm",children:[e.jsxs("div",{className:"bg-[#6b1a2e] text-white text-center py-3 px-4",children:[e.jsxs("h2",{className:"font-black text-base sm:text-lg tracking-wide",children:[M.toUpperCase()," â STUDENT FEE CHART"]}),j&&e.jsxs("div",{className:"text-xs font-bold text-amber-200 uppercase tracking-wider mt-0.5",children:["Branch: ",j]}),e.jsxs("div",{className:"mt-1 inline-block bg-white/20 text-white font-extrabold text-xs px-3 py-0.5 rounded-full uppercase tracking-wider",children:["Course ",i+1," of ",d,": ",T," (",O,")"]})]}),e.jsxs("div",{className:"p-6",children:[e.jsxs("div",{className:"flex gap-4 mb-4",children:[e.jsxs("div",{className:"flex-1",children:[e.jsxs("div",{className:"grid grid-cols-3 gap-3 mb-3",children:[e.jsxs("div",{children:[e.jsx(b,{className:"text-xs font-bold",children:"Roll No."}),e.jsx(m,{type:"text",value:h.rollNo,onChange:a=>F("rollNo",a.target.value),className:"h-8 border-b-2 border-t-0 border-x-0 rounded-none px-0"})]}),e.jsxs("div",{children:[e.jsx(b,{className:"text-xs font-bold",children:"Admission No."}),e.jsx(m,{type:"text",value:h.admNo,onChange:a=>F("admNo",a.target.value),className:"h-8 border-b-2 border-t-0 border-x-0 rounded-none px-0"})]}),e.jsxs("div",{children:[e.jsx(b,{className:"text-xs font-bold",children:"Admission Date"}),e.jsx(m,{type:"date",value:h.admDate,onChange:a=>F("admDate",a.target.value),className:"h-8 border-b-2 border-t-0 border-x-0 rounded-none px-0"})]})]}),e.jsxs("div",{className:"mb-3",children:[e.jsx(b,{className:"text-xs font-bold",children:"Trainee Name"}),e.jsx(m,{type:"text",value:h.traineeName,onChange:a=>F("traineeName",a.target.value),className:"h-8 border-b-2 border-t-0 border-x-0 rounded-none px-0"})]}),e.jsxs("div",{children:[e.jsx(b,{className:"text-xs font-bold",children:"Father Name"}),e.jsx(m,{type:"text",value:h.fatherName,onChange:a=>F("fatherName",a.target.value),className:"h-8 border-b-2 border-t-0 border-x-0 rounded-none px-0"})]})]}),e.jsxs("div",{className:"flex flex-col items-center",children:[e.jsx(b,{className:"text-xs font-bold mb-1",children:"PHOTO"}),e.jsx("div",{className:"w-20 h-24 border-2 border-gray-400 flex items-center justify-center text-xs text-gray-400",children:h.photo?e.jsx("img",{src:h.photo,alt:"Student",className:"w-full h-full object-cover"}):"No Photo"})]})]}),e.jsxs("div",{className:"grid grid-cols-3 gap-3 mb-4",children:[e.jsxs("div",{children:[e.jsx(b,{className:"text-xs font-bold",children:"Date of Birth"}),e.jsx(m,{type:"date",value:h.dob,onChange:a=>F("dob",a.target.value),className:"h-8 border-b-2 border-t-0 border-x-0 rounded-none px-0"})]}),e.jsxs("div",{children:[e.jsx(b,{className:"text-xs font-bold",children:"Mobile #"}),e.jsx(m,{type:"tel",value:h.mobile,onChange:a=>F("mobile",a.target.value),className:"h-8 border-b-2 border-t-0 border-x-0 rounded-none px-0"})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[e.jsxs("div",{children:[e.jsx(b,{className:"text-xs font-bold",children:"From"}),e.jsx(m,{type:"date",value:h.fromDate,onChange:a=>F("fromDate",a.target.value),className:"h-8 border-b-2 border-t-0 border-x-0 rounded-none px-0"})]}),e.jsxs("div",{children:[e.jsx(b,{className:"text-xs font-bold",children:"To"}),e.jsx(m,{type:"date",value:h.toDate,onChange:a=>F("toDate",a.target.value),className:"h-8 border-b-2 border-t-0 border-x-0 rounded-none px-0"})]})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3 mb-4",children:[e.jsxs("div",{children:[e.jsx(b,{className:"text-xs font-bold",children:"Admission Fee"}),e.jsx(m,{type:"number",value:h.admFee,onChange:a=>F("admFee",a.target.value),className:"h-8 border-b-2 border-t-0 border-x-0 rounded-none px-0"})]}),e.jsxs("div",{children:[e.jsx(b,{className:"text-xs font-bold",children:"Rec. No."}),e.jsx(m,{type:"text",value:h.admFeeRecNo,onChange:a=>F("admFeeRecNo",a.target.value),className:"h-8 border-b-2 border-t-0 border-x-0 rounded-none px-0 font-mono font-bold text-gray-800"})]})]}),e.jsxs("div",{className:"bg-[#6b1a2e] text-white text-xs font-bold py-1 px-3 -mx-6 mb-3 flex justify-between items-center",children:[e.jsxs("span",{children:["COURSE FEE RECORD ",T.toUpperCase()]}),e.jsxs("span",{className:"text-[10px] font-normal uppercase opacity-90",children:["Duration: ",O]})]}),e.jsxs("table",{className:"w-full border-collapse text-xs mb-4",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"bg-[#6b1a2e] text-white",children:[e.jsx("th",{className:"border border-gray-400 px-2 py-1",children:"Course Fee"}),e.jsx("th",{className:"border border-gray-400 px-2 py-1",children:"Amount"}),e.jsx("th",{className:"border border-gray-400 px-2 py-1",children:"Rec. No"}),e.jsx("th",{className:"border border-gray-400 px-2 py-1",children:"Submission Date"})]})}),e.jsx("tbody",{children:R.map(a=>e.jsxs("tr",{className:"even:bg-gray-50",children:[e.jsxs("td",{className:"border border-gray-300 px-2 py-1 font-bold text-[#6b1a2e]",children:["Month ",a.month," Fee"]}),e.jsx("td",{className:"border border-gray-300 px-2 py-1",children:e.jsx(m,{type:"number",value:a.amount,onChange:D=>G(a.month,"amount",D.target.value),placeholder:"0",className:"border-0 h-6 font-bold"})}),e.jsx("td",{className:"border border-gray-300 px-2 py-1",children:e.jsx(m,{type:"text",value:a.recNo,onChange:D=>G(a.month,"recNo",D.target.value),className:"border-0 h-6 font-mono font-bold text-gray-800"})}),e.jsx("td",{className:"border border-gray-300 px-2 py-1",children:e.jsx(m,{type:"date",value:a.date,onChange:D=>G(a.month,"date",D.target.value),className:"border-0 h-6"})})]},a.month))})]}),e.jsxs("div",{className:"grid grid-cols-3 gap-3 mb-4",children:[e.jsxs("div",{children:[e.jsx(b,{className:"text-xs font-bold",children:"Certificate Fee"}),e.jsx(m,{type:"number",value:h.certFee,onChange:a=>F("certFee",a.target.value),className:"h-8 border-b-2 border-t-0 border-x-0 rounded-none px-0"})]}),e.jsxs("div",{children:[e.jsx(b,{className:"text-xs font-bold",children:"Rec. No."}),e.jsx(m,{type:"text",value:h.certFeeRecNo,onChange:a=>F("certFeeRecNo",a.target.value),className:"h-8 border-b-2 border-t-0 border-x-0 rounded-none px-0"})]}),e.jsxs("div",{children:[e.jsx(b,{className:"text-xs font-bold",children:"Date"}),e.jsx(m,{type:"date",value:h.certFeeDate,onChange:a=>F("certFeeDate",a.target.value),className:"h-8 border-b-2 border-t-0 border-x-0 rounded-none px-0"})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3 mb-4",children:[e.jsxs("div",{children:[e.jsx(b,{className:"text-xs font-bold",children:"Total Fees in Figure"}),e.jsx(m,{type:"text",value:k,readOnly:!0,className:"h-8 border-b-2 border-t-0 border-x-0 rounded-none px-0 bg-gray-100 font-bold text-emerald-700"})]}),e.jsxs("div",{children:[e.jsx(b,{className:"text-xs font-bold",children:"in Words"}),e.jsx(m,{type:"text",value:h.totalWords,onChange:a=>F("totalWords",a.target.value),className:"h-8 border-b-2 border-t-0 border-x-0 rounded-none px-0 font-semibold",placeholder:"e.g. Five Thousand Only"})]})]}),e.jsxs("div",{className:"grid grid-cols-3 gap-3 mb-4",children:[e.jsxs("div",{children:[e.jsx(b,{className:"text-xs font-bold",children:"Trainee Signature"}),e.jsx(m,{type:"text",value:h.traineeSign,onChange:a=>F("traineeSign",a.target.value),className:"h-8 border-b-2 border-t-0 border-x-0 rounded-none px-0"})]}),e.jsxs("div",{children:[e.jsx(b,{className:"text-xs font-bold",children:"Certificate Board"}),e.jsx(m,{type:"text",value:h.certBoard,onChange:a=>F("certBoard",a.target.value),className:"h-8 border-b-2 border-t-0 border-x-0 rounded-none px-0"})]}),e.jsxs("div",{children:[e.jsx(b,{className:"text-xs font-bold",children:"Certificate No."}),e.jsx(m,{type:"text",value:h.certNo,onChange:a=>F("certNo",a.target.value),className:"h-8 border-b-2 border-t-0 border-x-0 rounded-none px-0"})]})]}),e.jsxs("div",{className:"flex justify-between pt-6 border-t-2 border-gray-400 text-xs font-bold text-center",children:[e.jsxs("div",{className:"flex-1",children:[e.jsx("div",{className:"h-8 mb-1"}),e.jsx("div",{children:"Sign. Principal"})]}),e.jsxs("div",{className:"flex-1",children:[e.jsx("div",{className:"h-8 mb-1"}),e.jsx("div",{children:"Sign. Director"})]})]})]})]})})}function Pt({student:s,campusName:o}){return!s||!s.enrollments||s.enrollments.length===0?e.jsx(dt,{student:s,enrollment:null,courseIndex:0,totalCourses:1,campusName:o}):e.jsx("div",{className:"space-y-8",children:s.enrollments.map((i,d)=>
62e.jsx(dt,{student:s,enrollment:i,courseIndex:d,totalCourses:s.enrollments?.length||0,campusName:o},i.id||d))})}function $t({student:s}){const{toast:o}=xt(),i=new Date().toLocaleDateString("en-GB"),[d,j]=n.useState("enter"),[z,M]=n.useState("manual"),[T,O]=n.useState(s?.fullName||""),[h,E]=n.useState(s?.fatherName||""),[R,q]=n.useState(s?.cnic||""),[F,G]=n.useState(s?.rollNumber||""),[V,_]=n.useState(s?.registrationNumber||""),[c,k]=n.useState(s?.phoneNumber||""),[p,a]=n.useState(""),[D,v]=n.useState("6 Months"),[u,y]=n.useState("Diploma"),[A,f]=n.useState(""),[r,l]=n.useState("PBTE"),[g,W]=n.useState(""),[ee,I]=n.useState(i),[L,K]=n.useState(""),[P,J]=n.useState(""),[Y,le]=n.useState(!1),[Q,X]=n.useState(""),[Z,te]=n.useState("0"),[ne,me]=n.useState(i),[Ie,Mt]=n.useState("Fully Cleared (100% Fees Paid)"),[Be,Ue]=n.useState("Approved & Cleared"),[Ee,Pe]=n.useState("All requirements verified."),[Je,Ve]=n.useState(!1),[$e,ve]=n.useState(""),[Me,be]=n.useState(""),[We,fe]=n.useState(i),[he,ze]=n.useState(s||null),[Ge,Le]=n.useState(s?.id||null),[pt,De]=n.useState(null),[ie,ge]=n.useState([]),[ye,Qe]=n.useState(""),[Xe,Oe]=n.useState([]),[Ze,et]=n.useState(!1),[C,ce]=n.useState(null),[N,we]=n.useState(null);n.useEffect(()=>{Ge&&p?(async()=>{try{const x=localStorage.getItem("token")||sessionStorage.getItem("token"),B=await fetch(`/api/admin/certificates?userId=${Ge}`,{headers:{Authorization:x?`Bearer ${x}`:""}});if(B.ok){const w=(await B.json()).find($=>{const U=($.courseName||"").trim().toLowerCase(),se=p.trim().toLowerCase();return U===se||U.includes(se)||se.includes(U)});if(w){De(w),f(w.certificateNumber||"");const $=(w.certBoard||"").trim(),U=$.toUpperCase();["PBTE","TEVTA","NTB","BTPEI"].includes(U)?(l(U),W("")):$&&(l("Other"),W($)),ve(w.certFee||""),be(w.certFeeRecNo||""),fe(w.certFeeDate||""),y(w.certType||"Diploma"),le(!!w.isGiven),I(w.issuedAt||i),me(w.issuedAt||i),K(w.certDateFrom||""),J(w.certDateTo||""),w.duration&&v(w.duration),X(w.marksPercent||""),w.remainingDues!==void 0&&w.remainingDues!==null&&te(String(w.remainingDues)),o({title:"Certificate Record Loaded",description:`Student already has certificate number ${w.certificateNumber} for ${p}. Auto-filled details.`})}else{De(null),f(""),ve(""),X(""),le(!1);const $=he?.enrollments?.find(U=>{const se=U.course?.title||U.courseName||U.courseTitle||"",Ce=p.trim().toLowerCase(),Se=se.trim().toLowerCase();return Se===Ce||Se.includes(Ce)||Ce.includes(Se)});if($){if($.course?.duration&&v($.course.duration),$.enrollmentDate){const H=new Date($.enrollmentDate);if(!isNaN(H.getTime())){const ke=String(H.getDate()).padStart(2,"0"),Fe=String(H.getMonth()+1).padStart(2,"0"),de=H.getFullYear();K(`${ke}/${Fe}/${de}`);let ae=6;const oe=($.course?.duration||D||"").toLowerCase();oe.includes("1 year")||oe.includes("12 month")?ae=12:oe.includes("1 month")?ae=1:oe.includes("2 month")?ae=2:oe.includes("3 month")?ae=3:oe.includes("4 month")?ae=4:oe.includes("6 month")?ae=6:(oe.includes("2 year")||oe.includes("24 month"))&&(ae=24);const pe=new Date(H);pe.setMonth(pe.getMonth()+ae);const vt=String(pe.getDate()).padStart(2,"0"),yt=String(pe.getMonth()+1).padStart(2,"0"),wt=pe.getFullYear();J(`${vt}/${yt}/${wt}`)}}const U=$.courseId,se=(he?.payments||[]).filter(H=>H.courseId===U),Ce=Number($.course?.fee||$.totalFee||0),Se=se.reduce((H,ke)=>H+Number(ke.amount||0),0),jt=Math.max(0,Ce-Se);if(te(String(jt)),se.length>0){se.sort((de,ae)=>new Date(de.paymentDate).getTime()-new Date(ae.paymentDate).getTime());const H=se[se.length-1],ke=H.receiptNo||H.receiptNumber||H.receipt_no||(H.id?String(H.id):"");let Fe=i;if(H.paymentDate){const de=new Date(H.paymentDate);if(!isNaN(de.getTime())){const ae=String(de.getDate()).padStart(2,"0"),oe=String(de.getMonth()+1).padStart(2,"0"),pe=de.getFullYear();Fe=`${ae}/${oe}/${pe}`}}be(ke),fe(Fe)}else be(""),fe(i)}}}}catch{}})():De(null)},[Ge,he,p]),n.useEffect(()=>{if(s&&(ze(s),Le(s.id),O(s.fullName||""),E(s.fatherName||""),q(s.cnic||""),G(s.rollNumber||""),_(s.registrationNumber||""),k(s.phoneNumber||""),s.enrollments&&s.enrollments.length>0)){const t=s.enrollments.map(x=>
62x.course?.title||x.courseName||x.courseTitle).filter(Boolean);Oe(t),t.length>0&&a(t[0])}},[s]),n.useEffect(()=>{tt()},[]);const tt=async()=>{let t=[];const x=localStorage.getItem("gccs_clearance_records");if(x)try{t=JSON.parse(x)}catch{}try{const B=await xe.get("/api/admin/certificates/clearance/search");if(Array.isArray(B)){const S=new Map;[...B,...t].forEach(w=>{w&&(w.id||w.certificateNumber)&&S.set(w.id||w.certificateNumber,w)}),ge(Array.from(S.values()));return}}catch(B){console.warn("Backend clearance fetch fallback to local storage:",B)}ge(t)},st=async t=>{const x=(t||R).trim();if(!x){o({title:"Please enter CNIC or Roll Number to search",variant:"destructive"});return}et(!0);try{const B=await xe.get(`/api/users/students/search?q=${encodeURIComponent(x)}`),S=B.students?.[0]||B?.[0];if(S){if(ze(S),Le(S.id),O(S.fullName||S.name||""),E(S.fatherName||""),q(S.cnic||x),G(S.rollNumber||S.rollNo||""),_(S.registrationNumber||S.regNo||""),k(S.phoneNumber||S.phone||""),S.enrollments&&S.enrollments.length>0){const w=S.enrollments.map($=>$.course?.title||$.courseName||$.courseTitle).filter(Boolean);Oe(w),w.length>0&&a(w[0])}o({title:" Student Record Found & Auto-Fetched!",description:`Auto-filled details for ${S.fullName||S.name}`})}else o({title:"No student found matching this CNIC or Roll Number",variant:"destructive"})}catch(B){o({title:"Failed to search student details",description:B.message,variant:"destructive"})}finally{et(!1)}},at=()=>{ze(null),Le(null),De(null),O(""),E(""),q(""),G(""),_(""),k(""),a(""),v("6 Months"),y("Diploma"),f(""),l("PBTE"),W(""),I(i),me(i),K(""),J(""),le(!1),X(""),te("0"),Ue("Approved & Cleared"),Pe("All requirements verified."),ve(""),be(""),fe(i),Oe([]),o({title:"Form Cleared",description:"All fields have been reset to blank."})},ut=async()=>{if(!T.trim()){o({title:"Please enter Student Name",variant:"destructive"});return}if(pt){o({title:"Duplicate Clearance Entry",description:`A certificate record already exists for course "${p}". You cannot duplicate it.`,variant:"destructive"});return}Ve(!0);const t=r==="Other"?g.trim()||"Other":r,x={id:Date.now(),certificateNumber:A,studentName:T,studentFather:h,studentCnic:R,studentRoll:F,studentReg:V,studentPhone:c,courseName:p||"Computer Application & IT",certType:u||"Diploma",certBoard:t,duration:D,issuedAt:ee||ne,feeStatus:Ie,status:Be,remarks:Ee,certFee:$e,certFeeRecNo:Me,certFeeDate:We,isGiven:Y,certDateFrom:L,certDateTo:P,marksPercent:Q,remainingDues:Z,createdAt:new Date().toISOString()};try{const S=he?.enrollments?.find(U=>(U.course?.title||U.courseName||U.courseTitle||"").toLowerCase()===p.toLowerCase())?.courseId||1,w=await xe.post("/api/admin/certificates/clearance",{userId:he?.id,courseId:S,courseName:p||"Computer Application & IT",cnic:R,certType:u||"Diploma",certificateNumber:A,remarks:Ee,clearanceDate:ee||ne,status:Be==="Approved & Cleared"?"issued":"pending",certBoard:t,certFee:$e,certFeeRecNo:Me,certFeeDate:We,isGiven:Y,certDateFrom:L,certDateTo:P,duration:D,marksPercent:Q,remainingDues:Z});w?.certificate?.id&&(x.id=w.certificate.id);const $=[x,...ie];ge($),localStorage.setItem("gccs_clearance_records",JSON.stringify($)),o({title:" Certificate Clearance Record Saved!",description:`Ref No. ${A||"N/A"} registered for ${T}`}),f(""),y("Diploma"),l("PBTE"),W(""),O(""),E(""),q(""),G(""),_(""),k(""),a(""),Pe("All requirements verified."),ve(""),be(""),fe(i),le(!1),K(""),J(""),X(""),te("0")}catch(B){o({title:"Error Saving Clearance Record",description:B.message||"Failed to save the certificate clearance details to the database.",variant:"destructive"})}finally{Ve(!1)}},rt=async t=>{const x=!t.isGiven,B=ie.map(S=>S.id===t.id?{...S,isGiven:x}:S);ge(B),localStorage.setItem("gccs_clearance_records",JSON.stringify(B));try{t.id&&typeof t.id=="number"&&t.id<2e12&&await xe.put(`/api/admin/certificates/clearance/${t.id}`,{isGiven:x}),o({title:x?" Certificate Marked as Given / Delivered":" Certificate Marked as In Office / Pending",description:`${t.studentName} (${t.certificateNumber||"No Ref"})`})}catch(S){console.warn("Backend sync toggle error:",S)}},bt=async t=>{if(!window.confirm("Are you sure you want to delete this clearance record?"))return;const x=ie.filter(B=>B.id!==t);ge(x),localStorage.setItem("gccs_clearance_records",JSON.stringify(x));try{typeof t=="number"&&t<2e12&&await xe.delete(`/api/admin/certificates/clearance/${t}`)}catch(B){console.warn("Backend delete record error:",B)}o({title:"Clearance record deleted"})},ft=async()=>
62{if(!C)return;const t=ie.map(x=>x.id===C.id?C:x);ge(t),localStorage.setItem("gccs_clearance_records",JSON.stringify(t));try{C.id&&typeof C.id=="number"&&C.id<2e12&&await xe.put(`/api/admin/certificates/clearance/${C.id}`,{certificateNumber:C.certificateNumber,remarks:C.remarks,clearanceDate:C.issuedAt,status:C.status==="Approved & Cleared"?"issued":"pending",certBoard:C.certBoard,certFee:C.certFee,certFeeRecNo:C.certFeeRecNo,certFeeDate:C.certFeeDate,isGiven:C.isGiven,certDateFrom:C.certDateFrom,certDateTo:C.certDateTo,duration:C.duration,marksPercent:C.marksPercent,remainingDues:C.remainingDues})}catch(x){console.warn("Backend edit save error:",x)}o({title:"Record updated successfully!"}),ce(null)},Ye=ie.filter(t=>{if(!ye.trim())return!0;const x=ye.toLowerCase();return t.studentName&&t.studentName.toLowerCase().includes(x)||t.studentFather&&t.studentFather.toLowerCase().includes(x)||t.studentCnic&&t.studentCnic.includes(x)||t.studentRoll&&t.studentRoll.toLowerCase().includes(x)||t.certificateNumber&&t.certificateNumber.toLowerCase().includes(x)||t.courseName&&t.courseName.toLowerCase().includes(x)||t.certBoard&&t.certBoard.toLowerCase().includes(x)}),_e=ie.length,gt=ie.filter(t=>t.isGiven).length,Nt=ie.filter(t=>!t.isGiven).length;return e.jsxs("div",{className:"max-w-7xl mx-auto space-y-5",children:[e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-3 gap-3 sm:gap-4",children:[e.jsxs("div",{className:"bg-white p-4 rounded-xl border border-slate-200 shadow-sm flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-[10px] font-bold text-slate-500 uppercase tracking-wider",children:"Total Clearance Entries"}),e.jsx("h3",{className:"text-2xl font-black text-[#6b1a2e] mt-0.5",children:_e})]}),e.jsx("div",{className:"h-11 w-11 rounded-xl bg-[#6b1a2e]/10 flex items-center justify-center",children:e.jsx(He,{className:"h-5 w-5 text-[#6b1a2e]"})})]}),e.jsxs("div",{className:"bg-white p-4 rounded-xl border border-slate-200 shadow-sm flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-[10px] font-bold text-slate-500 uppercase tracking-wider",children:"Certificates Given (Delivered)"}),e.jsx("h3",{className:"text-2xl font-black text-emerald-600 mt-0.5",children:gt})]}),e.jsx("div",{className:"h-11 w-11 rounded-xl bg-emerald-100 flex items-center justify-center",children:e.jsx(ue,{className:"h-5 w-5 text-emerald-600"})})]}),e.jsxs("div",{className:"bg-white p-4 rounded-xl border border-slate-200 shadow-sm flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-[10px] font-bold text-slate-500 uppercase tracking-wider",children:"Not Given (In Office)"}),e.jsx("h3",{className:"text-2xl font-black text-amber-600 mt-0.5",children:Nt})]}),e.jsx("div",{className:"h-11 w-11 rounded-xl bg-amber-100 flex items-center justify-center",children:e.jsx(Ae,{className:"h-5 w-5 text-amber-600"})})]})]}),e.jsxs("div",{className:"bg-white rounded-xl border border-slate-200 shadow-md overflow-hidden",children:[e.jsxs("div",{className:"flex border-b border-slate-200 bg-slate-50",children:[e.jsxs("button",{onClick:()=>j("enter"),className:`flex-1 flex items-center justify-center gap-1.5 sm:gap-2 py-3 px-2 text-xs sm:text-sm font-bold transition-all duration-200 ${d==="enter"?"bg-[#6b1a2e] text-white shadow-sm":"text-slate-600 hover:bg-slate-100"}`,children:[e.jsx(Ke,{className:"h-4 w-4"}),e.jsx("span",{children:"Enter Certificate Entry"})]}),e.jsxs("button",{onClick:()=>{j("records"),tt()},className:`flex-1 flex items-center justify-center gap-1.5 sm:gap-2 py-3 px-2 text-xs sm:text-sm font-bold transition-all duration-200 ${d==="records"?"bg-[#6b1a2e] text-white shadow-sm":"text-slate-600 hover:bg-slate-100"}`,children:[e.jsx(He,{className:"h-4 w-4"}),e.jsx("span",{children:"Show Entries"}),_e>0&&e.jsx("span",{className:`inline-flex items-center justify-center h-5 min-w-5 px-1.5 rounded-full text-[10px] font-black ${d==="records"?"bg-white/20 text-white":"bg-[#6b1a2e] text-white"}`,children:_e})]})]}),d==="enter"&&e.jsxs("div",{className:"p-4 sm:p-6 space-y-6",children:[e.jsxs("div",{className:"bg-gradient-to-r from-slate-900 via-[#3d0f1a] to-[#6b1a2e] p-4 sm:p-5 rounded-2xl text-white shadow-md space-y-3",children:[e.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center justify-between gap-2",children:[e.jsxs("div",{children:[e.jsxs("h2",{className:"text-sm sm:text-base font-black tracking-wide flex items-center gap-2",children:[e.jsx(qe,{className:"h-5 w-5 text-amber-400 shrink-0"}),"Certificate Clearance & Registry Entry"]}),e.jsx("p",{className:"text-[11px] sm:text-xs text-slate-300 mt-0.5",children:"Search student by CNIC, Roll No or Name to auto-populate, or type directly into any field below."})]}),he?e.jsxs("span",{className:"inline-flex items-center gap-1.5 px-3 py-1 rounded-full text-xs font-black bg-emerald-500/20 text-emerald-300 border border-emerald-500/40 shrink-0",children:[e.jsx(ue,{className:"h-3.5 w-3.5 text-emerald-400"}),"Auto-Fetched: ",T]}):e.jsx("span",{className:"inline-flex items-center gap-1 px-2.5 py-0.5 rounded-full text-[11px] font-bold bg-white/10 text-slate-300 border border-white/15 shrink-0",children:"Direct Key-In Mode"})]}),e.jsxs("div",{className:"flex flex-col sm:flex-row gap-2 pt-1",children:[e.jsxs("div",{className:"relative flex-1",children:[e.jsx(Ne,{className:"absolute left-3 top-2.5 h-4 w-4 text-slate-400"}),e.jsx(m,{type:"text",value:R,onChange:t=>q(t.target.value),onKeyDown:t=>{t.key==="Enter"&&(t.preventDefault(),st(R))},placeholder:"Enter Student CNIC (e.g. 37405-1234567-1), Roll No, or Name...",className:"h-10 pl-9 pr-4 text-xs font-bold bg-white text-slate-900 placeholder:text-slate-400 rounded-xl border-0 shadow-inner"})]}),e.jsxs(re,{type:"button",onClick:()=>st(R),disabled:Ze,className:"bg-amber-500 hover:bg-amber-600 text-slate-950 font-black text-xs px-5 h-10 rounded-xl shrink-0 shadow-sm transition-all",children:[Ze?e.jsx(nt,{className:"h-4 w-4 animate-spin mr-1.5"}):e.jsx(Ne,{className:"h-4 w-4 mr-1.5"}),"Auto-Fetch Details"]}
62),(he||T)&&e.jsxs(re,{type:"button",variant:"outline",onClick:at,className:"bg-white/10 hover:bg-white/20 text-white border-white/25 text-xs h-10 px-3.5 rounded-xl shrink-0 transition-all",children:[e.jsx(ot,{className:"h-3.5 w-3.5 mr-1.5"}),"Reset"]})]})]}),e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-5 sm:gap-6 items-start",children:[e.jsxs("div",{className:"bg-white rounded-2xl border border-slate-200 p-4 sm:p-5 shadow-sm space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-2 pb-2.5 border-b border-slate-100",children:[e.jsx("div",{className:"h-7 w-7 rounded-lg bg-[#6b1a2e]/10 flex items-center justify-center text-[#6b1a2e]",children:e.jsx(Ft,{className:"h-4 w-4"})}),e.jsxs("div",{children:[e.jsx("h3",{className:"text-xs font-black uppercase text-[#6b1a2e] tracking-wider",children:"1. Trainee & Course Information"}),e.jsx("p",{className:"text-[11px] text-slate-400",children:"Personal information and enrolled academic program"})]})]}),e.jsxs("div",{className:"space-y-3.5",children:[e.jsxs("div",{children:[e.jsx(b,{className:"text-xs font-bold text-slate-700 mb-1 block",children:"Trainee Full Name *"}),e.jsx(m,{type:"text",value:T,onChange:t=>O(t.target.value),placeholder:"e.g. Muhammad Ali",className:"h-10 text-xs font-bold bg-slate-50/50 focus:bg-white"})]}),e.jsxs("div",{children:[e.jsx(b,{className:"text-xs font-bold text-slate-700 mb-1 block",children:"Father Name (S/O)"}),e.jsx(m,{type:"text",value:h,onChange:t=>E(t.target.value),placeholder:"e.g. Ghulam Muhammad",className:"h-10 text-xs font-medium bg-slate-50/50 focus:bg-white"})]}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-3",children:[e.jsxs("div",{children:[e.jsx(b,{className:"text-xs font-bold text-slate-700 mb-1 block",children:"CNIC / B-Form No."}),e.jsx(m,{type:"text",value:R,onChange:t=>q(t.target.value),placeholder:"37405-1234567-1",className:"h-10 text-xs font-bold font-mono bg-slate-50/50 focus:bg-white"})]}),e.jsxs("div",{children:[e.jsx(b,{className:"text-xs font-bold text-slate-700 mb-1 block",children:"Contact Phone"}),e.jsx(m,{type:"text",value:c,onChange:t=>k(t.target.value),placeholder:"0301-1234567",className:"h-10 text-xs font-semibold bg-slate-50/50 focus:bg-white"})]})]}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-3",children:[e.jsxs("div",{children:[e.jsx(b,{className:"text-xs font-bold text-slate-700 mb-1 block",children:"Roll Number"}),e.jsx(m,{type:"text",value:F,onChange:t=>G(t.target.value),placeholder:"e.g. 7842",className:"h-10 text-xs font-bold text-[#6b1a2e] bg-slate-50/50 focus:bg-white"})]}),e.jsxs("div",{children:[e.jsx(b,{className:"text-xs font-bold text-slate-700 mb-1 block",children:"Registration No."}),e.jsx(m,{type:"text",value:V,onChange:t=>_(t.target.value),placeholder:"e.g. GCCS/2026/892",className:"h-10 text-xs font-semibold bg-slate-50/50 focus:bg-white"})]})]}),e.jsxs("div",{children:[e.jsx(b,{className:"text-xs font-bold text-slate-700 mb-1 block",children:"Course Enrolled"}),Xe.length>0?e.jsxs("select",{value:p,onChange:t=>a(t.target.value),className:"h-10 w-full rounded-md border border-[#6b1a2e]/40 bg-white px-3 py-2 text-xs font-black text-[#6b1a2e] focus:outline-none focus:ring-2 focus:ring-[#6b1a2e]",children:[e.jsx("option",{value:"",children:"-- Select Enrolled Course --"}),Xe.map((t,x)=>e.jsx("option",{value:t,children:t},x))]}):e.jsx(m,{type:"text",value:p,onChange:t=>a(t.target.value),placeholder:"e.g. Computer Application & IT",className:"h-10 text-xs font-bold bg-slate-50/50 focus:bg-white"})]}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-3",children:[e.jsxs("div",{children:[e.jsx(b,{className:"text-xs font-bold text-slate-700 mb-1 block",children:"Course Duration"}),e.jsx(m,{type:"text",value:D,onChange:t=>v(t.target.value),placeholder:"e.g. 6 Months",className:"h-10 text-xs font-semibold bg-slate-50/50 focus:bg-white"})]}),e.jsxs("div",{children:[e.jsx(b,{className:"text-xs font-bold text-slate-700 mb-1 block",children:"Certificate Type"}),e.jsx(m,{type:"text",value:u,onChange:t=>y(t.target.value),placeholder:"e.g. Diploma",className:"h-10 text-xs font-bold bg-slate-50/50 focus:bg-white"})]})]}),e.jsxs("div",{className:"p-3.5 bg-blue-50/40 rounded-xl border border-blue-100 space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs(b,{className:"text-xs font-black text-blue-900 flex items-center gap-1.5",children:[e.jsx(At,{className:"h-3.5 w-3.5 text-blue-600"}),"Certificate Session Dates (From â To)"]}),e.jsx("span",{className:"text-[10px] text-blue-600 font-bold",children:"Auto-Calculated"})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-2.5",children:[e.jsxs("div",{children:[e.jsx("span",{className:"text-[10px] font-bold text-slate-500 uppercase block mb-0.5",children:"Session From"}),e.jsx(m,{type:"text",value:L,onChange:t=>K(t.target.value),placeholder:"DD/MM/YYYY",className:"h-9 text-xs font-bold bg-white"})]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-[10px] font-bold text-slate-500 uppercase block mb-0.5",children:"Session To"}),e.jsx(m,{type:"text",value:P,onChange:t=>J(t.target.value),placeholder:"DD/MM/YYYY",className:"h-9 text-xs font-bold bg-white"})]})]}),e.jsx("p",{className:"text-[10px] text-slate-400 italic",children:"Computed from enrollment date + course duration. Fully editable."})]})]})]}),e.jsxs("div",{className:"bg-white rounded-2xl border border-slate-200 p-4 sm:p-5 shadow-sm space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-2 pb-2.5 border-b border-slate-100",children:[e.jsx("div",{className:"h-7 w-7 rounded-lg bg-[#6b1a2e]/10 flex items-center justify-center text-[#6b1a2e]",children:e.jsx(qe,{className:"h-4 w-4"})}),e.jsxs("div",{children:[e.jsx("h3",{className:"text-xs font-black uppercase text-[#6b1a2e] tracking-wider",children:"2. Certificate, Board & Clearance Details"}),e.jsx("p",{className:"text-[11px] text-slate-400",children:"Delivery status, affiliation board, marks and remaining fee dues"})]})]}),e.jsxs("div",{className:"space-y-3.5",children:[e.jsxs("div",{children:[e.jsx(b,{className:"text-xs font-black text-slate-800 mb-1.5 block",children:"Certificate Delivery Status (Physical Handover) *"}),e.jsxs("div",{className:"grid grid-cols-2 gap-2.5",children:[e.jsxs("button",{type:"button",onClick:()=>le(!1),className:`p-3 rounded-xl border text-left transition-all ${Y?"bg-slate-50/60 border-slate-200 text-slate-600 hover:bg-slate-100":"bg-amber-50/80 border-2 border-amber-500 text-amber-950 shadow-sm"}`,children:[e.jsxs("div",{className:"flex items-center justify-between mb-1",children:[e.jsxs("span",{className:"text-xs font-black flex items-center gap-1.5",children:[e.jsx(Ae,{className:`h-4 w-4 ${Y?"text-slate-400":"text-amber-600"}`}),"Not Given"]}),!Y&&e.jsx("span",{className:"h-2 w-2 rounded-full bg-amber-500"})]}),e.jsx("p",{className:"text-[10px] text-slate-500 font-medium",children:"In branch / awaiting collection"})]}),e.jsxs("button",{type:"button",onClick:()=>le(!0),className:`p-3 rounded-xl border text-left transition-all ${Y?"bg-emerald-50/80 border-2 border-emerald-600 text-emerald-950 shadow-sm":"bg-slate-50/60 border-slate-200 text-slate-600 hover:bg-slate-100"}`,children:[e.jsxs("div",{className:"flex items-center justify-between mb-1",children:[e.jsxs("span",{className:"text-xs font-black flex items-center gap-1.5 text-emerald-800",children:[e.jsx(ue,{className:`h-4 w-4 ${Y?"text-emerald-600":"text-slate-400"}`}),"Given (Delivered)"]}),Y&&e.jsx("span",{className:"h-2 w-2 rounded-full bg-emerald-600"})]}),e.jsx("p",{className:"text-[10px] text-slate-500 font-medium",children:"Handed over to trainee"})]})]})]}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-3",children:[e.jsxs("div",{children:[e.jsx(b,{className:"text-xs font-bold text-slate-700 mb-1 block",children:"Certificate Ref / Serial No."}),e.jsx(m,{type:"text",value:A,onChange:t=>f(t.target.value),placeholder:"e.g. GCC-CERT-101",className:"h-10 text-xs font-bold text-[#6b1a2e] bg-slate-50/50 focus:bg-white font-mono"})]}),e.jsxs("div",{children:[e.jsx(b,{className:"text-xs font-bold text-slate-700 mb-1 block",children:"Certificate Issue Date"}),e.jsx(m,{type:"text",value:ee,onChange:t=>{I(t.target.value),me(t.target.value)},placeholder:"DD/MM/YYYY",className:"h-10 text-xs font-bold bg-slate-50/50 focus:bg-white"})]})]}),e.jsxs("div",{children:[e.jsx(b,{className:"text-xs font-bold text-slate-700 mb-1.5 block",children:"Board Affiliation"}
62),e.jsx("div",{className:"grid grid-cols-5 gap-1.5 p-1 bg-slate-100 rounded-xl",children:["PBTE","TEVTA","NTB","BTPEI","Other"].map(t=>e.jsx("button",{type:"button",onClick:()=>l(t),className:`py-1.5 px-1 rounded-lg text-xs font-extrabold transition-all text-center ${r===t?"bg-[#6b1a2e] text-white shadow-sm":"text-slate-600 hover:text-slate-900 hover:bg-slate-200/60"}`,children:t},t))}),r==="Other"&&e.jsx("div",{className:"mt-2",children:e.jsx(m,{type:"text",value:g,onChange:t=>W(t.target.value),placeholder:"Enter Custom Board Name (e.g. Trade Testing Board)...",className:"h-9 text-xs font-bold text-[#6b1a2e] bg-slate-50/50 focus:bg-white"})})]}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-3",children:[e.jsxs("div",{children:[e.jsx(b,{className:"text-xs font-bold text-slate-700 mb-1 block",children:"Percentage / Marks Obtained"}),e.jsx(m,{type:"text",value:Q,onChange:t=>X(t.target.value),placeholder:"e.g. 85% or 850/1000",className:"h-10 text-xs font-bold text-blue-700 bg-slate-50/50 focus:bg-white"})]}),e.jsxs("div",{children:[e.jsx(b,{className:"text-xs font-bold text-slate-700 mb-1 block",children:"Clearance Status"}),e.jsxs("select",{value:Be,onChange:t=>Ue(t.target.value),className:"h-10 w-full rounded-md border border-slate-300 bg-white px-3 py-2 text-xs font-extrabold text-[#6b1a2e] focus:outline-none focus:ring-2 focus:ring-[#6b1a2e]",children:[e.jsx("option",{value:"Approved & Cleared",children:"Approved & Cleared"}),e.jsx("option",{value:"Pending Verification",children:"Pending Verification"}),e.jsx("option",{value:"Hold (Lab / Library Clearance)",children:"Hold (Lab / Library Clearance)"})]})]})]}),e.jsxs("div",{className:"p-3.5 bg-slate-50 rounded-xl border border-slate-200 space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs(b,{className:"text-xs font-black text-slate-800 flex items-center gap-1",children:[e.jsx(Tt,{className:"h-3.5 w-3.5 text-[#6b1a2e]"}),"Fees & Remaining Dues Status"]}),Number(Z)>0?e.jsxs("span",{className:"inline-flex items-center gap-1 text-[10px] font-black text-red-600 bg-red-100 px-2 py-0.5 rounded-full",children:[e.jsx(it,{className:"h-3 w-3"})," Outstanding Dues"]}):e.jsxs("span",{className:"inline-flex items-center gap-1 text-[10px] font-black text-emerald-700 bg-emerald-100 px-2 py-0.5 rounded-full",children:[e.jsx(ue,{className:"h-3 w-3"})," Fully Cleared"]})]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-[10px] font-bold text-slate-500 uppercase block mb-1",children:"Remaining Course Dues (PKR)"}),e.jsx(m,{type:"text",value:Z,onChange:t=>te(t.target.value),placeholder:"0",className:`h-10 text-xs font-black bg-white ${Number(Z)>0?"border-red-400 text-red-600 bg-red-50/30 ring-1 ring-red-300":"text-emerald-700 border-slate-200"}`})]}),e.jsxs("div",{className:"grid grid-cols-3 gap-2",children:[e.jsxs("div",{children:[e.jsx("span",{className:"text-[10px] font-bold text-slate-500 uppercase block mb-0.5",children:"Cert Fee (PKR)"}),e.jsx(m,{type:"number",value:$e,onChange:t=>ve(t.target.value),placeholder:"e.g. 6000",className:"h-9 text-xs font-bold bg-white"})]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-[10px] font-bold text-slate-500 uppercase block mb-0.5",children:"Fee Rec. No."}),e.jsx(m,{type:"text",value:Me,onChange:t=>be(t.target.value),placeholder:"REC-150",className:"h-9 text-xs font-bold font-mono bg-white"})]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-[10px] font-bold text-slate-500 uppercase block mb-0.5",children:"Fee Pay Date"}),e.jsx(m,{type:"text",value:We,onChange:t=>fe(t.target.value),placeholder:"DD/MM/YYYY",className:"h-9 text-xs font-bold bg-white"})]})]})]}),e.jsxs("div",{children:[e.jsx(b,{className:"text-xs font-bold text-slate-700 mb-1 block",children:"Remarks / Clearance Notes"}),e.jsx(m,{type:"text",value:Ee,onChange:t=>Pe(t.target.value),placeholder:"e.g. All requirements verified and signed.",className:"h-10 text-xs font-medium bg-slate-50/50 focus:bg-white"})]})]})]})]}),e.jsxs("div",{className:"flex flex-col sm:flex-row items-center justify-between gap-3 pt-2 border-t border-slate-100",children:[e.jsxs(re,{type:"button",variant:"outline",onClick:at,className:"w-full sm:w-auto text-xs text-slate-600 hover:text-slate-900 border-slate-200",children:[e.jsx(ot,{className:"h-3.5 w-3.5 mr-1.5"}),"Reset to Blank"]}),e.jsx(re,{onClick:ut,disabled:Je,className:"bg-[#6b1a2e] hover:bg-[#581525] text-white font-black text-xs h-11 px-8 rounded-xl shadow-md transition-all w-full sm:w-auto",children:Je?e.jsxs(e.Fragment,{children:[e.jsx(nt,{className:"h-4 w-4 animate-spin mr-2"}),"Saving Record..."]}):e.jsxs(e.Fragment,{children:[e.jsx(Ke,{className:"h-4 w-4 mr-2"}),"Save Certificate Clearance Entry"]})})]})]}),d==="records"&&e.jsxs("div",{className:"p-4 sm:p-6 space-y-4",children:[e.jsxs("div",{className:"flex flex-col sm:flex-row items-stretch sm:items-center gap-3",children:[e.jsxs("div",{className:"relative flex-1",children:[e.jsx(Ne,{className:"absolute left-3 top-2.5 h-4 w-4 text-slate-400"}),e.jsx(m,{type:"text",placeholder:"Search by Name, Father, CNIC, Roll No, Ref No, Board, Course...",value:ye,onChange:t=>Qe(t.target.value),className:"pl-9 h-9 text-xs font-semibold"}),ye&&e.jsx("button",{onClick:()=>Qe(""),className:"absolute right-3 top-2.5 text-slate-400 hover:text-slate-600",children:e.jsx(je,{className:"h-4 w-4"})})]}),e.jsxs("span",{className:"text-xs font-medium text-slate-500 shrink-0",children:["Showing ",e.jsx("strong",{children:Ye.length})," of ",ie.length," records"]})]}),N&&e.jsx("div",{className:"fixed inset-0 z-50 bg-black/50 flex items-center justify-center p-4 backdrop-blur-xs",onClick:()=>we(null),children:e.jsxs("div",{className:"bg-white rounded-2xl shadow-2xl max-w-2xl w-full p-4 sm:p-6 space-y-4 max-h-[92vh] overflow-y-auto",onClick:t=>t.stopPropagation(),children:[e.jsxs("div",{className:"flex items-center justify-between border-b pb-3",children:[e.jsxs("div",{className:"flex items-center gap-2.5",children:[e.jsx("div",{className:"h-9 w-9 rounded-xl bg-[#6b1a2e]/10 flex items-center justify-center text-[#6b1a2e]",children:e.jsx(qe,{className:"h-5 w-5"})}),e.jsxs("div",{children:[e.jsx("h3",{className:"text-base font-black text-slate-900 flex items-center gap-2",children:"Certificate Clearance Record"}),e.jsxs("p",{className:"text-xs text-slate-500 font-mono",children:["Ref
62: ",e.jsx("span",{className:"font-bold text-[#6b1a2e]",children:N.certificateNumber||"N/A"})]})]})]}),e.jsx("button",{onClick:()=>we(null),className:"text-slate-400 hover:text-slate-700 p-1 rounded-lg hover:bg-slate-100",children:e.jsx(je,{className:"h-5 w-5"})})]}),e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2 p-3 bg-slate-50 rounded-xl border border-slate-200",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-[11px] font-bold text-slate-500 uppercase tracking-wider",children:"Delivery:"}),e.jsx("span",{className:`inline-flex items-center gap-1 px-2.5 py-0.5 rounded-full text-xs font-black border ${N.isGiven?"bg-emerald-100 text-emerald-800 border-emerald-300":"bg-amber-100 text-amber-800 border-amber-300"}`,children:N.isGiven?e.jsxs(e.Fragment,{children:[e.jsx(ue,{className:"h-3.5 w-3.5 text-emerald-600"}),"Given (Delivered to Student)"]}):e.jsxs(e.Fragment,{children:[e.jsx(Ae,{className:"h-3.5 w-3.5 text-amber-600"}),"Not Given (Retained in Office)"]})})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-[11px] font-bold text-slate-500 uppercase tracking-wider",children:"Status:"}),e.jsx("span",{className:`inline-flex items-center gap-1 px-2.5 py-0.5 rounded-full text-xs font-black border ${N.status==="Approved & Cleared"?"bg-emerald-100 text-emerald-800 border-emerald-300":"bg-amber-100 text-amber-800 border-amber-300"}`,children:N.status||"Approved & Cleared"})]})]}),e.jsxs("div",{className:`p-4 rounded-xl border space-y-3 ${Number(N.remainingDues)>0?"bg-red-50/70 border-red-200":"bg-emerald-50/60 border-emerald-200"}`,children:[e.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center justify-between gap-2 pb-2 border-b border-black/5",children:[e.jsxs("div",{children:[e.jsx("span",{className:"text-[10px] font-black uppercase tracking-wider text-slate-500 block",children:"Remaining Course Fee / Dues"}),e.jsxs("div",{className:"flex items-baseline gap-2 mt-0.5",children:[e.jsxs("h4",{className:`text-2xl sm:text-3xl font-black ${Number(N.remainingDues)>0?"text-red-600":"text-emerald-700"}`,children:["PKR ",N.remainingDues||"0"]}),Number(N.remainingDues)>0?e.jsxs("span",{className:"inline-flex items-center gap-1 text-[11px] font-black text-red-700 bg-red-100 px-2 py-0.5 rounded-full border border-red-200",children:[e.jsx(it,{className:"h-3 w-3"})," Outstanding Fee Dues"]}):e.jsxs("span",{className:"inline-flex items-center gap-1 text-[11px] font-black text-emerald-800 bg-emerald-100 px-2 py-0.5 rounded-full border border-emerald-200",children:[e.jsx(ue,{className:"h-3 w-3"})," Fully Cleared (No Dues)"]})]})]}),Number(N.remainingDues)>0&&e.jsxs("p",{className:"text-[11px] text-red-600 font-semibold bg-white/80 p-2 rounded-lg border border-red-200 max-w-xs",children:["â ï¸ Notice: Collect outstanding course dues of PKR ",N.remainingDues," before handing over the certificate."]})]}),e.jsxs("div",{className:"grid grid-cols-3 gap-2 text-xs",children:[e.jsxs("div",{className:"bg-white/80 rounded-lg p-2 border border-slate-200/60",children:[e.jsx("span",{className:"text-[10px] font-bold text-slate-400 uppercase block",children:"Certificate Fee"}),e.jsxs("span",{className:"font-bold text-slate-800",children:["PKR ",N.certFee||"0"]})]}),e.jsxs("div",{className:"bg-white/80 rounded-lg p-2 border border-slate-200/60",children:[e.jsx("span",{className:"text-[10px] font-bold text-slate-400 uppercase block",children:"Fee Receipt No."}),e.jsx("span",{className:"font-mono font-bold text-[#6b1a2e]",children:N.certFeeRecNo||"N/A"})]}),e.jsxs("div",{className:"bg-white/80 rounded-lg p-2 border border-slate-200/60",children:[e.jsx("span",{className:"text-[10px] font-bold text-slate-400 uppercase block",children:"Payment Date"}),e.jsx("span",{className:"font-semibold text-slate-700",children:N.certFeeDate||"N/A"})]})]})]}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-3 text-xs",children:[e.jsxs("div",{className:"bg-slate-50 rounded-xl p-3 border border-slate-200/70 space-y-2",children:[e.jsx("h5",{className:"text-[11px] font-black uppercase text-[#6b1a2e] border-b pb-1",children:"Trainee Details"}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs("div",{children:[e.jsx("span",{className:"text-[10px] font-bold text-slate-400 uppercase block",children:"Full Name"}),e.jsx("span",{className:"font-bold text-slate-900",children:N.studentName||"N/A"})]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-[10px] font-bold text-slate-400 uppercase block",children:"Father Name"}),e.jsx("span",{className:"font-medium text-slate-700",children:N.studentFather?`S/O ${N.studentFather}`:"N/A"})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-1",children:[e.jsxs("div",{children:[e.jsx("span",{className:"text-[10px] font-bold text-slate-400 uppercase block",children:"CNIC"}),e.jsx("span",{className:"font-mono font-semibold text-slate-700",children:N.studentCnic||"N/A"})]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-[10px] font-bold text-slate-400 uppercase block",children:"Phone"}),e.jsx("span",{className:"font-semibold text-slate-700",children:N.studentPhone||"N/A"})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-1",children:[e.jsxs("div",{children:[e.jsx("span",{className:"text-[10px] font-bold text-slate-400 uppercase block",children:"Roll No."}),e.jsx("span",{className:"font-bold text-[#6b1a2e]",children:N.studentRoll||"N/A"})]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-[10px] font-bold text-slate-400 uppercase block",children:"Reg No."}),e.jsx("span",{className:"font-semibold text-slate-700",children:N.studentReg||"N/A"})]})]})]})]}),e.jsxs("div",{className:"bg-slate-50 rounded-xl p-3 border border-slate-200/70 space-y-2",children:[e.jsx("h5",{className:"text-[11px] font-black uppercase text-[#6b1a2e] border-b pb-1",children:"Course & Certificate"}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs("div",{children:[e.jsx("span",{className:"text-[10px] font-bold text-slate-400 uppercase block",children:"Course Enrolled"}),e.jsx("span",{className:"font-bold text-slate-900",children:N.courseName||"N/A"})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-1",children:[e.jsxs("div",{children:[e.jsx("span",{className:"text-[10px] font-bold text-slate-400 uppercase block",children:"Duration"}),e.jsx("span",{className:"font-semibold text-slate-700",children:N.duration||"6 Months"})]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-[10px] font-bold text-slate-400 uppercase block",children:"Cert Type"}),e.jsx("span",{className:"font-semibold text-slate-700",children:N.certType||"Diploma"})]})]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-[10px] font-bold text-slate-400 uppercase block",children:"Session Range"}),e.jsx("span",{className:"font-bold text-slate-800",children:N.certDateFrom?`${N.certDateFrom} to ${N.certDateTo||"Present"}`:"N/A"})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-1",children:[e.jsxs("div",{children:[e.jsx("span",{className:"text-[10px] font-bold text-slate-400 uppercase block",children:"Board"}),e.jsx("span",{className:"font-extrabold text-[#6b1a2e]",children:N.certBoard||"PBTE"})]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-[10px] font-bold text-slate-400 uppercase block",children:"Marks / %"}),e.jsx("span",{className:"font-bold text-blue-700",children:N.marksPercent||"N/A"})]})]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-[10px] font-bold text-slate-400 uppercase block",children:"Issue Date"}),e.jsx("span",{className:"font-semibold text-slate-700",children:N.issuedAt||N.clearanceDate||"N/A"})]})]})]})]}),N.remarks&&e.jsxs("div",{className:"bg-slate-50 rounded-xl px-3 py-2 border border-slate-200/70 text-xs",children:[e.jsx("span",{className:"text-[10px] font-bold text-slate-400 uppercase block",children:"Clearance Remarks"}
62),e.jsx("p",{className:"text-slate-700 font-medium mt-0.5",children:N.remarks})]}),e.jsxs("div",{className:"flex items-center justify-between pt-2 border-t border-slate-100",children:[e.jsx("button",{type:"button",onClick:async()=>{await rt(N),we({...N,isGiven:!N.isGiven})},className:`px-3 py-1.5 rounded-xl text-xs font-bold border transition-all ${N.isGiven?"bg-amber-50 text-amber-800 border-amber-300 hover:bg-amber-100":"bg-emerald-50 text-emerald-800 border-emerald-300 hover:bg-emerald-100"}`,children:N.isGiven?"Mark as Not Given (In Office)":"Mark as Given (Delivered)"}),e.jsx(re,{onClick:()=>we(null),className:"bg-[#6b1a2e] hover:bg-[#581525] text-white text-xs px-5",children:"Close"})]})]})}),C&&e.jsx("div",{className:"fixed inset-0 z-50 bg-black/50 flex items-center justify-center p-4",onClick:()=>ce(null),children:e.jsxs("div",{className:"bg-white rounded-2xl shadow-2xl max-w-3xl w-full p-4 sm:p-6 space-y-4 max-h-[90vh] overflow-y-auto",onClick:t=>t.stopPropagation(),children:[e.jsxs("div",{className:"flex items-center justify-between border-b pb-3",children:[e.jsxs("h3",{className:"text-base sm:text-lg font-black text-[#6b1a2e] flex items-center gap-2",children:[e.jsx(ct,{className:"h-5 w-5"})," Edit Clearance Record"]}),e.jsx("button",{onClick:()=>ce(null),className:"text-slate-400 hover:text-slate-700",children:e.jsx(je,{className:"h-5 w-5"})})]}),e.jsxs("div",{className:"p-3 bg-slate-50 rounded-xl border flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-xs font-black text-slate-800",children:"Certificate Given / Delivered to Student?"}),e.jsx("p",{className:"text-[11px] text-slate-500",children:"Toggle whether the trainee has collected their physical certificate"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("button",{type:"button",onClick:()=>ce({...C,isGiven:!1}),className:`px-3 py-1.5 rounded-lg text-xs font-bold border transition-all ${C.isGiven?"bg-white text-slate-700 border-slate-200":"bg-amber-500 text-white border-amber-600"}`,children:"Not Given"}),e.jsx("button",{type:"button",onClick:()=>ce({...C,isGiven:!0}),className:`px-3 py-1.5 rounded-lg text-xs font-bold border transition-all ${C.isGiven?"bg-emerald-600 text-white border-emerald-700":"bg-white text-slate-700 border-slate-200"}`,children:"Given"})]})]}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 md:grid-cols-3 gap-3",children:[[{label:"Ref No.",field:"certificateNumber"},{label:"Issue Date",field:"issuedAt"},{label:"Student Name",field:"studentName"},{label:"Father Name",field:"studentFather"},{label:"CNIC",field:"studentCnic"},{label:"Roll No.",field:"studentRoll"},{label:"Reg No.",field:"studentReg"},{label:"Phone",field:"studentPhone"},{label:"Course",field:"courseName"},{label:"Duration",field:"duration"},{label:"Session From",field:"certDateFrom"},{label:"Session To",field:"certDateTo"},{label:"Board",field:"certBoard"},{label:"Marks / %",field:"marksPercent"},{label:"Remaining Dues (PKR)",field:"remainingDues"},{label:"Cert Type",field:"certType"},{label:"Certificate Fee",field:"certFee"},{label:"Fee Rec No.",field:"certFeeRecNo"},{label:"Fee Payment Date",field:"certFeeDate"},{label:"Remarks",field:"remarks"}].map(({label:t,field:x})=>e.jsxs("div",{children:[e.jsx(b,{className:"text-xs font-bold text-slate-600",children:t}),e.jsx(m,{className:"mt-1 h-9 text-xs",value:C[x]||"",onChange:B=>ce({...C,[x]:B.target.value})})]},x)),e.jsxs("div",{children:[e.jsx(b,{className:"text-xs font-bold text-slate-600",children:"Clearance Status"}),e.jsxs("select",{className:"mt-1 h-9 w-full rounded-md border border-slate-300 bg-white px-3 text-xs font-semibold text-[#6b1a2e] focus:outline-none focus:ring-1 focus:ring-[#6b1a2e]",value:C.status||"",onChange:t=>ce({...C,status:t.target.value}),children:[e.jsx("option",{value:"Approved & Cleared",children:"Approved & Cleared"}),e.jsx("option",{value:"Pending Verification",children:"Pending Verification"}),e.jsx("option",{value:"Hold (Lab / Library Clearance)",children:"Hold (Lab / Library Clearance)"})]})]})]}),e.jsxs("div",{className:"flex items-center justify-end gap-3 pt-2",children:[e.jsx(re,{variant:"outline",onClick:()=>ce(null),className:"text-xs",children:"Cancel"}),e.jsxs(re,{onClick:ft,className:"bg-[#6b1a2e] hover:bg-[#581525] text-white text-xs",children:[e.jsx(Rt,{className:"h-3.5 w-3.5 mr-1.5"})," Save Changes"]})]})]})}),Ye.length===0?e.jsxs("div",{className:"p-12 text-center text-slate-400",children:[e.jsx(He,{className:"h-10 w-10 mx-auto mb-2 text-slate-300"}),e.jsx("p",{className:"font-medium",children:ye?"No matching records foun
62d.":"No clearance records yet. Add your first entry!"})]}):e.jsx("div",{className:"border border-slate-200 rounded-xl overflow-hidden shadow-sm w-full overflow-x-auto",children:e.jsxs("table",{className:"w-full border-collapse text-xs min-w-[950px]",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"bg-gradient-to-r from-[#6b1a2e] to-[#8b1538] text-white font-extrabold uppercase",children:[e.jsx("th",{className:"px-3 py-3 text-left w-8",children:"#"}),e.jsx("th",{className:"px-3 py-3 text-left",children:"Given?"}),e.jsx("th",{className:"px-3 py-3 text-left",children:"Issue Date"}),e.jsx("th",{className:"px-3 py-3 text-left",children:"Ref No."}),e.jsx("th",{className:"px-3 py-3 text-left",children:"Trainee & Father"}),e.jsx("th",{className:"px-3 py-3 text-left",children:"CNIC"}),e.jsx("th",{className:"px-3 py-3 text-left",children:"Course & Duration"}),e.jsx("th",{className:"px-3 py-3 text-left",children:"Session (From-To)"}),e.jsx("th",{className:"px-3 py-3 text-left",children:"Board"}),e.jsx("th",{className:"px-3 py-3 text-center",children:"Marks %"}),e.jsx("th",{className:"px-3 py-3 text-right",children:"Dues"}),e.jsx("th",{className:"px-3 py-3 text-center",children:"Status"}),e.jsx("th",{className:"px-3 py-3 text-center",children:"Actions"})]})}),e.jsx("tbody",{className:"divide-y divide-slate-100",children:Ye.map((t,x)=>e.jsxs("tr",{className:`${x%2===0?"bg-white":"bg-slate-50/50"} hover:bg-rose-50/20 transition-colors`,children:[e.jsx("td",{className:"px-3 py-2.5 font-bold text-slate-400",children:x+1}),e.jsx("td",{className:"px-3 py-2.5",children:e.jsx("button",{type:"button",onClick:()=>rt(t),title:"Click to toggle Given / Not Given status",className:`inline-flex items-center gap-1 px-2 py-0.5 rounded-full text-[10px] font-black border transition-all hover:scale-105 cursor-pointer whitespace-nowrap ${t.isGiven?"bg-emerald-100 text-emerald-800 border-emerald-300 hover:bg-emerald-200":"bg-amber-100 text-amber-800 border-amber-300 hover:bg-amber-200"}`,children:t.isGiven?e.jsxs(e.Fragment,{children:[e.jsx(ue,{className:"h-3 w-3 text-emerald-600"}),e.jsx("span",{children:"Given"})]}):e.jsxs(e.Fragment,{children:[e.jsx(Ae,{className:"h-3 w-3 text-amber-600"}),e.jsx("span",{children:"In Office"})]})})}),e.jsx("td",{className:"px-3 py-2.5 font-medium text-slate-600 whitespace-nowrap",children:t.issuedAt||i}),e.jsx("td",{className:"px-3 py-2.5 font-mono font-bold text-[#6b1a2e] whitespace-nowrap",children:t.certificateNumber||"-"}),e.jsxs("td",{className:"px-3 py-2.5",children:[e.jsx("p",{className:"font-extrabold text-slate-900 whitespace-nowrap",children:t.studentName}),t.studentFather&&e.jsxs("p",{className:"text-[10px] text-slate-500 whitespace-nowrap",children:["S/O ",t.studentFather]})]}),e.jsx("td",{className:"px-3 py-2.5 font-semibold text-slate-600 whitespace-nowrap",children:t.studentCnic||"-"}),e.jsxs("td",{className:"px-3 py-2.5",children:[e.jsx("p",{className:"font-semibold text-slate-800 max-w-[140px] truncate",title:t.courseName,children:t.courseName}),e.jsx("p",{className:"text-[10px] text-slate-500",children:t.duration||"6 Months"})]}),e.jsx("td",{className:"px-3 py-2.5 text-slate-600 whitespace-nowrap text-[11px]",children:t.certDateFrom?`${t.certDateFrom} - ${t.certDateTo||"Present"}`:"-"}),e.jsx("td",{className:"px-3 py-2.5 whitespace-nowrap",children:e.jsx("span",{className:"inline-block px-2 py-0.5 rounded bg-slate-100 text-slate-800 font-extrabold text-[10px]",children:t.certBoard||"PBTE"})}),e.jsx("td",{className:"px-3 py-2.5 text-center font-bold text-blue-700 whitespace-nowrap",children:t.marksPercent||"-"}),e.jsx("td",{className:"px-3 py-2.5 text-right whitespace-nowrap font-extrabold",children:Number(t.remainingDues)>0?e.jsxs("span",{className:"text-red-600 bg-red-50 px-1.5 py-0.5 rounded border border-red-200",children:["PKR ",t.remainingDues]}):e.jsx("span",{className:"text-emerald-700 bg-emerald-50 px-1.5 py-0.5 rounded",children:"Nil"})}),e.jsx("td",{className:"px-3 py-2.5 text-center",children:e.jsx("span",{className:`inline-block px-2 py-0.5 rounded-full text-[10px] font-extrabold whitespace-nowrap ${t.status==="Approved &
62Cleared"?"bg-emerald-100 text-emerald-800 border border-emerald-200":"bg-amber-100 text-amber-800 border border-amber-200"}`,children:t.status||"Approved & Cleared"})}),e.jsx("td",{className:"px-3 py-2.5",children:e.jsxs("div",{className:"flex items-center justify-center gap-1.5",children:[e.jsx("button",{onClick:()=>we(t),className:"h-7 w-7 rounded-lg bg-blue-50 hover:bg-blue-100 text-blue-600 flex items-center justify-center transition-colors",title:"View Details",children:e.jsx(It,{className:"h-3.5 w-3.5"})}),e.jsx("button",{onClick:()=>ce({...t}),className:"h-7 w-7 rounded-lg bg-amber-50 hover:bg-amber-100 text-amber-600 flex items-center justify-center transition-colors",title:"Edit Record",children:e.jsx(ct,{className:"h-3.5 w-3.5"})}),e.jsx("button",{onClick:()=>bt(t.id),className:"h-7 w-7 rounded-lg bg-red-50 hover:bg-red-100 text-red-600 flex items-center justify-center transition-colors",title:"Delete Record",children:e.jsx(Bt,{className:"h-3.5 w-3.5"})})]})})]},t.id))})]})})]})]})]})}export{Yt as default};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.