![]() Server : Apache/2 System : Linux server-15-235-50-60 5.15.0-164-generic #174-Ubuntu SMP Fri Nov 14 20:25:16 UTC 2025 x86_64 User : gositeme ( 1004) PHP Version : 8.2.29 Disable Function : exec,system,passthru,shell_exec,proc_close,proc_open,dl,popen,show_source,posix_kill,posix_mkfifo,posix_getpwuid,posix_setpgid,posix_setsid,posix_setuid,posix_setgid,posix_seteuid,posix_setegid,posix_uname Directory : /home/gositeme/domains/lavocat.ca/private_html/.next/server/pages/api/admin/ |
"use strict";(()=>{var e={};e.id=434,e.ids=[434],e.modules={8667:(e,t)=>{Object.defineProperty(t,"A",{enumerable:!0,get:function(){return o}});var o=function(e){return e.PAGES="PAGES",e.PAGES_API="PAGES_API",e.APP_PAGE="APP_PAGE",e.APP_ROUTE="APP_ROUTE",e.IMAGE="IMAGE",e}({})},29021:e=>{e.exports=require("fs")},33480:(e,t,o)=>{e.exports=o(75600)},33873:e=>{e.exports=require("path")},35134:(e,t,o)=>{o.a(e,async(e,a)=>{try{o.r(t),o.d(t,{config:()=>f,default:()=>d,routeModule:()=>p});var l=o(33480),n=o(8667),r=o(86435),i=o(93151),s=e([i]);i=(s.then?(await s)():s)[0];let d=(0,r.M)(i,"default"),f=(0,r.M)(i,"config"),p=new l.PagesAPIRouteModule({definition:{kind:n.A.PAGES_API,page:"/api/admin/export-v2",pathname:"/api/admin/export-v2",bundlePath:"",filename:""},userland:i});a()}catch(e){a(e)}})},65515:e=>{e.exports=require("jspdf")},75600:e=>{e.exports=require("next/dist/compiled/next-server/pages-api.runtime.prod.js")},83501:e=>{e.exports=import("jspdf-autotable")},86435:(e,t)=>{Object.defineProperty(t,"M",{enumerable:!0,get:function(){return function e(t,o){return o in t?t[o]:"then"in t&&"function"==typeof t.then?t.then(t=>e(t,o)):"function"==typeof t&&"default"===o?t:void 0}}})},93151:(e,t,o)=>{o.a(e,async(e,a)=>{try{o.r(t),o.d(t,{default:()=>g});var l=o(29021),n=o.n(l),r=o(33873),i=o.n(r),s=o(65515),d=o.n(s),f=o(83501),p=e([f]);async function g(e,t){if("POST"!==e.method)return t.status(405).json({error:"Method not allowed"});try{let{format:o,startDate:a,endDate:l}=e.body,r=i().join(process.cwd(),"registrations.json"),s=n().readFileSync(r,"utf-8"),p=JSON.parse(s);if(a&&l&&(p=p.filter(e=>{let t=new Date(e.date);return t>=new Date(a)&&t<=new Date(l)})),p.sort((e,t)=>new Date(t.date).getTime()-new Date(e.date).getTime()),"pdf"===o){let e=new(d())({orientation:"portrait",unit:"mm",format:"a4"}),o=e=>{let t=i().join(process.cwd(),"public/images","Logo_w.png");if(n().existsSync(t)){let o=n().readFileSync(t).toString("base64"),a=(e.internal.pageSize.width-80)/2,l=(e.internal.pageSize.height-80)/2;e.addImage(o,"PNG",a,l,80,80,void 0,"FAST")}else console.error(`Logo_w.png not found at ${t}`)},r=10;e.setFillColor(41,128,185),e.rect(0,0,e.internal.pageSize.width,30,"F"),e.setFontSize(18),e.setTextColor(255,255,255),e.text("Registration Profiles",e.internal.pageSize.width/2,18,{align:"center"}),e.setFontSize(10),e.setTextColor(255,255,255);let s=[a&&l?`Date Range: ${a} to ${l}`:null,`Total Profiles: ${p.length}`].filter(Boolean).join(" | ");e.text(s,e.internal.pageSize.width/2,25,{align:"center"}),o(e),r=40,p.forEach((t,a)=>{e.setFontSize(14),e.setTextColor(41,128,185),e.text(`Profile ${a+1}: ${t.name||"Unnamed"}`,14,r),r+=8;let l=[["Name:",t.name||"N/A"],["Email:",t.email||"N/A"],["Phone:",t.phone||"N/A"],["Birth Date:",t.birthDate||"N/A"],["Relationship:",t.relationship||"N/A"],["Registration Date:",new Date(t.date).toLocaleString()],["Status:",t.status||"N/A"]];if((0,f.default)(e,{startY:r,body:l,theme:"striped",headStyles:{fillColor:[220,220,220],textColor:[0,0,0],fontSize:10,fontStyle:"bold"},bodyStyles:{fontSize:9,textColor:[0,0,0]},margin:{left:14,right:14},columnStyles:{0:{fontStyle:"bold",cellWidth:40}},didDrawPage:t=>{t.pageNumber>1&&o(e)}}),r=e.lastAutoTable.finalY+8,t.address){let a=[["Street:",t.address.street||"N/A"],["City:",t.address.city||"N/A"],["State:",t.address.state||"N/A"],["Postal Code:",t.address.postalCode||"N/A"],["Country:",t.address.country||"N/A"]];(0,f.default)(e,{startY:r,body:a,theme:"striped",headStyles:{fillColor:[220,220,220],textColor:[0,0,0],fontSize:10,fontStyle:"bold"},bodyStyles:{fontSize:9,textColor:[0,0,0]},margin:{left:14,right:14},columnStyles:{0:{fontStyle:"bold",cellWidth:40}},didDrawPage:t=>{t.pageNumber>1&&o(e)}}),r=e.lastAutoTable.finalY+8}if(t.detaineeInfo){let a=[["Name:",t.detaineeInfo.name||"N/A"],["Facility:",t.detaineeInfo.facility||"N/A"],["Inmate ID:",t.detaineeInfo.inmateId||"N/A"],["Incarceration Date:",t.detaineeInfo.incarcerationDate||"N/A"],["Expected Release Date:",t.detaineeInfo.expectedReleaseDate||"N/A"]];(0,f.default)(e,{startY:r,body:a,theme:"striped",headStyles:{fillColor:[220,220,220],textColor:[0,0,0],fontSize:10,fontStyle:"bold"},bodyStyles:{fontSize:9,textColor:[0,0,0]},margin:{left:14,right:14},columnStyles:{0:{fontStyle:"bold",cellWidth:40}},didDrawPage:t=>{t.pageNumber>1&&o(e)}}),r=e.lastAutoTable.finalY+8}let n=[["Preferred Language:",t.preferredLanguage||"N/A"],["Preferred Contact Method:",t.preferredContactMethod||"N/A"]];if((0,f.default)(e,{startY:r,body:n,theme:"striped",headStyles:{fillColor:[220,220,220],textColor:[0,0,0],fontSize:10,fontStyle:"bold"},bodyStyles:{fontSize:9,textColor:[0,0,0]},margin:{left:14,right:14},columnStyles:{0:{fontStyle:"bold",cellWidth:40}},didDrawPage:t=>{t.pageNumber>1&&o(e)}}),r=e.lastAutoTable.finalY+8,t.legalRepresentation){let a=[["Has Lawyer:",t.legalRepresentation.hasLawyer?"Yes":"No"],["Lawyer Name:",t.legalRepresentation.lawyerName||"N/A"],["Lawyer Contact:",t.legalRepresentation.lawyerContact||"N/A"]];(0,f.default)(e,{startY:r,body:a,theme:"striped",headStyles:{fillColor:[220,220,220],textColor:[0,0,0],fontSize:10,fontStyle:"bold"},bodyStyles:{fontSize:9,textColor:[0,0,0]},margin:{left:14,right:14},columnStyles:{0:{fontStyle:"bold",cellWidth:40}},didDrawPage:t=>{t.pageNumber>1&&o(e)}}),r=e.lastAutoTable.finalY+8}if(t.additionalContacts&&t.additionalContacts.length>0){let a=t.additionalContacts.map((e,t)=>[`Contact ${t+1}:`,`Name: ${e.name||"N/A"}
Relationship: ${e.relationship||"N/A"}
Phone: ${e.phone||"N/A"}
Email: ${e.email||"N/A"}`]);(0,f.default)(e,{startY:r,head:[["Additional Contacts",""]],body:a,theme:"striped",headStyles:{fillColor:[220,220,220],textColor:[0,0,0],fontSize:10,fontStyle:"bold"},bodyStyles:{fontSize:9,textColor:[0,0,0]},margin:{left:14,right:14},columnStyles:{0:{fontStyle:"bold",cellWidth:40}},didDrawPage:t=>{t.pageNumber>1&&o(e)}}),r=e.lastAutoTable.finalY+8}if(t.message){e.setFontSize(12),e.setTextColor(0),e.text("Message:",14,r),r+=6,e.setFontSize(10),e.setTextColor(0);let o=e.splitTextToSize(t.message,e.internal.pageSize.width-28);e.text(o,14,r),r+=5*o.length+8}if(t.documents&&t.documents.length>0){let a=t.documents.map((e,t)=>[`Document ${t+1}:
Type: ${e.type||"N/A"}
Date: ${e.date||"N/A"}`,e.description||"N/A"]);(0,f.default)(e,{startY:r,head:[["Documents","Description"]],body:a,theme:"striped",headStyles:{fillColor:[220,220,220],textColor:[0,0,0],fontSize:10,fontStyle:"bold"},bodyStyles:{fontSize:9,textColor:[0,0,0]},margin:{left:14,right:14},columnStyles:{0:{fontStyle:"bold",cellWidth:60}},didDrawPage:t=>{t.pageNumber>1&&o(e)}}),r=e.lastAutoTable.finalY+8}a<p.length-1&&(e.addPage(),r=40)});let g=e.internal.pages.length;for(let t=1;t<=g;t++)e.setPage(t),e.setFontSize(10),e.setTextColor(100),e.text(`Page ${t} of ${g}`,e.internal.pageSize.width-14,e.internal.pageSize.height-10,{align:"right"});let u=e.output("arraybuffer");t.setHeader("Content-Type","application/pdf"),t.setHeader("Content-Disposition","attachment; filename=registration-profiles.pdf"),t.send(Buffer.from(u))}else"csv"===o?t.status(501).json({error:"CSV export not implemented yet"}):t.status(400).json({error:"Invalid format"})}catch(e){console.error("Error exporting registrations:",e),t.status(500).json({error:"Failed to export registrations"})}}f=(p.then?(await p)():p)[0],a()}catch(e){a(e)}})}};var t=require("../../../webpack-api-runtime.js");t.C(e);var o=t(t.s=35134);module.exports=o})();