Guest User

Untitled

a guest
Jun 11th, 2026
1,365
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.72 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="UTF-8" />
  5. <meta name="viewport" content="width=device-width, initial-scale=1.0"/>
  6. <title>Chex Report Analyzer</title>
  7. <!-- PDF.js library -->
  8. <script src="https://cdnjs.cloudflare.com/ajax/libs/pdf.js/3.3.122/pdf.min.js"></script>
  9. <style>
  10. body {
  11. font-family: sans-serif;
  12. max-width: 800px;
  13. margin: 2rem auto;
  14. padding: 0 1rem;
  15. }
  16. h1 {
  17. text-align: center;
  18. }
  19. input[type="file"] {
  20. display: block;
  21. margin: 1rem 0;
  22. }
  23. #downloadLink {
  24. display: none;
  25. margin: 1rem 0;
  26. }
  27. #summary {
  28. margin-top: 1.5rem;
  29. }
  30. .copy-button {
  31. margin-top: 0.5rem;
  32. padding: 0.5rem 1rem;
  33. font-size: 1rem;
  34. }
  35. </style>
  36. </head>
  37. <body>
  38. <h1>Chex Report Analyzer</h1>
  39. <input type="file" id="pdfInput" accept="application/pdf" />
  40.  
  41. <h2>Choose Date to Base Summary On</h2>
  42.  
  43. <input type="date" id="summaryDate">
  44.  
  45. <a id="downloadLink"></a>
  46.  
  47. <div id="summary"></div>
  48.  
  49. <script>
  50. // Automatically trigger the extraction when a new file is uploaded
  51. document.getElementById('pdfInput').addEventListener('change', processPDF);
  52. document.getElementById('summaryDate').addEventListener('change', processPDF);
  53.  
  54. async function processPDF() {
  55. const fileInput = document.getElementById('pdfInput');
  56. if (!fileInput.files.length) {
  57. alert('Please select a PDF file.');
  58. return;
  59. }
  60.  
  61. const summaryDateInput = document.getElementById('summaryDate');
  62.  
  63. if (!summaryDateInput.value) {
  64.  
  65. alert('Please select a date for the summary.');
  66.  
  67. return;
  68.  
  69. }
  70.  
  71. const file = fileInput.files[0];
  72. const arrayBuffer = await file.arrayBuffer();
  73.  
  74. // Configure the workerSrc property
  75. pdfjsLib.GlobalWorkerOptions.workerSrc =
  76. 'https://cdnjs.cloudflare.com/ajax/libs/pdf.js/3.3.122/pdf.worker.min.js';
  77.  
  78. const pdf = await pdfjsLib.getDocument({ data: arrayBuffer }).promise;
  79. const summaryDate = await summaryDateInput.value;
  80. let fullText = '';
  81.  
  82. // Extract text from each page
  83. for (let i = 0; i < pdf.numPages; i++) {
  84. const page = await pdf.getPage(i + 1);
  85. const textContent = await page.getTextContent();
  86. const pageText = textContent.items.map(item => item.str).join(' ');
  87. fullText += pageText + '\n';
  88. }
  89.  
  90. // Extract the "Inquiries Viewed By Others" section
  91. const sectionPattern = /Inquiries Viewed By Others([\s\S]*?)Inquiries Viewed Only By You/;
  92. const sectionMatch = fullText.match(sectionPattern);
  93.  
  94. if (!sectionMatch) {
  95. alert("Could not find the 'Inquiries Viewed By Others' section.");
  96. return;
  97. }
  98.  
  99. const inquiriesSection = sectionMatch[1];
  100. const inquiryPattern = /Inquirer:\s*(.*?);\s*(.*?)Phone Number:\s*(.*?)(?:Inquiry Date:\s*(\d{2}\/\d{2}\/\d{4}))/g;
  101. const inquiries = [];
  102. let match;
  103.  
  104. while ((match = inquiryPattern.exec(inquiriesSection)) !== null) {
  105. inquiries.push({
  106. bank_name: match[1].trim(),
  107. bank_address: match[2].trim(),
  108. bank_phone: match[3].trim(),
  109. inquiry_date: match[4].trim()
  110. });
  111. }
  112.  
  113. if (inquiries.length === 0) {
  114. alert('No inquiries found.');
  115. return;
  116. }
  117.  
  118. // Generate CSV content
  119. const csvContent = 'bank_name,bank_address,bank_phone,inquiry_date\n' +
  120. inquiries.map(inquiry =>
  121. `"${inquiry.bank_name}","${inquiry.bank_address}","${inquiry.bank_phone}","${inquiry.inquiry_date}"`)
  122. .join('\n');
  123.  
  124. // Create a download link for the CSV
  125. const blob = new Blob([csvContent], { type: 'text/csv' });
  126. const downloadLink = document.getElementById('downloadLink');
  127. downloadLink.href = URL.createObjectURL(blob);
  128. downloadLink.download = 'inquiries_viewed_by_others.csv';
  129. downloadLink.style.display = 'inline-block';
  130. downloadLink.textContent = '⬇️ Download CSV';
  131.  
  132. // Generate the summary
  133. generateSummary(inquiries,summaryDate);
  134. }
  135.  
  136. function generateSummary(inquiries,summaryDate) {
  137. const now = new Date(summaryDate);
  138. //const now = new Date();
  139. const oneMonthAgo = new Date(now);
  140. oneMonthAgo.setMonth(now.getMonth() - 1);
  141. //const twoMonthsAgo = new Date(now);
  142. //twoMonthsAgo.setMonth(now.getMonth() - 2);
  143. const threeMonthsAgo = new Date(now);
  144. threeMonthsAgo.setMonth(now.getMonth() - 3);
  145. const sixMonthsAgo = new Date(now);
  146. sixMonthsAgo.setMonth(now.getMonth() - 6);
  147. const twelveMonthsAgo = new Date(now);
  148. twelveMonthsAgo.setMonth(now.getMonth() - 12);
  149. const twentyFourMonthsAgo = new Date(now);
  150. twentyFourMonthsAgo.setMonth(now.getMonth() - 24);
  151.  
  152. let last1Month = 0;
  153. //let last2Months = 0;
  154. let last3Months = 0;
  155. let last6Months = 0;
  156. let last12Months = 0;
  157. let last24Months = 0;
  158.  
  159. inquiries.forEach(inquiry => {
  160. const parts = inquiry.inquiry_date.split('/');
  161. const inquiryDate = new Date(`${parts[2]}-${parts[0]}-${parts[1]}`);
  162. if (inquiryDate > oneMonthAgo && inquiryDate <= now) last1Month++;
  163. //if (inquiryDate >= twoMonthsAgo) last2Months++;
  164. if (inquiryDate > threeMonthsAgo && inquiryDate <= now) last3Months++;
  165. if (inquiryDate > sixMonthsAgo && inquiryDate <= now) last6Months++;
  166. if (inquiryDate > twelveMonthsAgo && inquiryDate <= now) last12Months++;
  167. if (inquiryDate > twentyFourMonthsAgo && inquiryDate <= now) last24Months++;
  168. });
  169.  
  170. // Display the summary
  171. //<li>Last 2 months: ${last2Months}</li>
  172. //${last2Months},
  173. const summaryDiv = document.getElementById('summary');
  174. summaryDiv.innerHTML = `
  175. <h2>Inquiry Summary</h2>
  176. <ul>
  177. <li>Last 1 month: ${last1Month}</li>
  178. <li>Last 3 months: ${last3Months}</li>
  179. <li>Last 6 months: ${last6Months}</li>
  180. <li>Last 12 months: ${last12Months}</li>
  181. <li>Last 24 months: ${last24Months}</li>
  182. </ul>
  183. <button class="copy-button" onclick="copySummary(${last1Month}, ${last3Months}, ${last6Months}, ${last12Months}, ${last24Months})">
  184. 📋 Copy Summary
  185. </button>
  186. `;
  187. }
  188. //m2,
  189. //${m2}/2,
  190. function copySummary(m1, m3, m6, m12, m24) {
  191. const summaryText = `${m1}/1, ${m3}/3, ${m6}/6, ${m12}/12, ${m24}/24`;
  192. navigator.clipboard.writeText(summaryText)
  193. .then(() => alert("Summary copied to clipboard:\n" + summaryText))
  194. .catch(() => alert("Failed to copy summary."));
  195. }
  196. </script>
  197. </body>
  198. </html>
  199.  
Advertisement
Add Comment
Please, Sign In to add comment