diff --git a/.env b/.env index 0a592df..7e88e56 100644 --- a/.env +++ b/.env @@ -1,4 +1,9 @@ -DB_URL=jdbc:oracle:thin:@10.1.0.14:1521:chncorp -DB_USERNAME=fileadjust -DB_PASSWORD=fileadjust +# DB_URL=jdbc:oracle:thin:@10.1.0.14:1521:chncorp +# DB_USERNAME=fileadjust +# DB_PASSWORD=fileadjust +# FORCE_HTTPS=false + +DB_URL=jdbc:oracle:thin:@//localhost:1522/XEPDB1 +DB_USERNAME=system +DB_PASSWORD=root FORCE_HTTPS=false \ No newline at end of file diff --git a/src/main/java/com/adjustment_file_management_system/springboot/AdjustmentFileManagementSystemApplication.java b/src/main/java/com/adjustment_file_management_system/springboot/AdjustmentFileManagementSystemApplication.java index 0d941d4..6c56885 100644 --- a/src/main/java/com/adjustment_file_management_system/springboot/AdjustmentFileManagementSystemApplication.java +++ b/src/main/java/com/adjustment_file_management_system/springboot/AdjustmentFileManagementSystemApplication.java @@ -13,10 +13,10 @@ import io.github.cdimascio.dotenv.DotenvEntry; @SpringBootApplication @EnableJpaAuditing(auditorAwareRef = "auditorAware") public class AdjustmentFileManagementSystemApplication { - + static { Dotenv dotEnv = Dotenv.configure().ignoreIfMissing().load(); - for(DotenvEntry entry : dotEnv.entries()) { + for (DotenvEntry entry : dotEnv.entries()) { System.setProperty(entry.getKey(), entry.getValue()); } } diff --git a/src/main/java/com/adjustment_file_management_system/springboot/controller/FileDataController.java b/src/main/java/com/adjustment_file_management_system/springboot/controller/FileDataController.java index 47c000c..e43a20d 100644 --- a/src/main/java/com/adjustment_file_management_system/springboot/controller/FileDataController.java +++ b/src/main/java/com/adjustment_file_management_system/springboot/controller/FileDataController.java @@ -79,4 +79,12 @@ public class FileDataController { return "file/view-file"; } + @GetMapping("/reports") + public String viewReports(Model model) { + List fileDataResDTOs = fileDataSer.getAllFileData(); + model.addAttribute("fileDatum", fileDataResDTOs); + model.addAttribute("curPage", "reports"); + return "file/reports"; + } + } diff --git a/src/main/java/com/adjustment_file_management_system/springboot/controller/HomeController.java b/src/main/java/com/adjustment_file_management_system/springboot/controller/HomeController.java index 69c2346..93c5d0e 100644 --- a/src/main/java/com/adjustment_file_management_system/springboot/controller/HomeController.java +++ b/src/main/java/com/adjustment_file_management_system/springboot/controller/HomeController.java @@ -10,6 +10,7 @@ import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestParam; import com.adjustment_file_management_system.springboot.service.HomeService; +import com.adjustment_file_management_system.springboot.service.FileDataService; @Controller @RequestMapping("/") @@ -18,11 +19,15 @@ public class HomeController { @Autowired private HomeService homeSer; + @Autowired + private FileDataService fileDataSer; + @GetMapping("/home") public String homePage(Model model) { Map stats = homeSer.getFileDataStat(); model.addAttribute("curPage", "home"); model.addAttribute("stats", stats); + model.addAttribute("fileDatum", fileDataSer.getAllFileData()); return "home/home"; } @@ -30,8 +35,8 @@ public class HomeController { public String usrRedirect(@RequestParam("usr-role") String usrRole) { return switch (usrRole) { - case "ROLE_ADMIN" -> "redirect:/home"; - default -> "redirect:/"; // fallback to login page + case "ROLE_ADMIN" -> "redirect:/home"; + default -> "redirect:/"; // fallback to login page }; } diff --git a/src/main/java/com/adjustment_file_management_system/springboot/service/FileDataService.java b/src/main/java/com/adjustment_file_management_system/springboot/service/FileDataService.java index 8aef612..68cf204 100644 --- a/src/main/java/com/adjustment_file_management_system/springboot/service/FileDataService.java +++ b/src/main/java/com/adjustment_file_management_system/springboot/service/FileDataService.java @@ -267,9 +267,23 @@ public class FileDataService { } } + private void normalizeFinYear(FileDataResponseDTO dto) { + if (dto.getFinYear() != null && dto.getFinYear().contains("-")) { + String[] parts = dto.getFinYear().split("-"); + if (parts.length == 2 && parts[1].trim().length() == 2) { + String startYear = parts[0].trim(); + if (startYear.length() == 4) { + String endYear = startYear.substring(0, 2) + parts[1].trim(); + dto.setFinYear(startYear + "-" + endYear); + } + } + } + } + @Transactional(readOnly = true) public FileDataResponseDTO getFileDataByFileNum(String fileNum) { FileDataResponseDTO dto = fileDataMap.toFileDataResDTO(fileDataRepo.findFileDataByFileDataNum(fileNum)); + normalizeFinYear(dto); calculateDaysPass(dto); return dto; } @@ -288,6 +302,7 @@ public class FileDataService { return fileDataRepo.findAll().stream().map(fileData -> { FileDataResponseDTO dto = fileDataMap.toFileDataResDTO(fileData); + normalizeFinYear(dto); calculateDaysPass(dto); return dto; }).sorted(comparator).toList(); diff --git a/src/main/resources/static/js/view-file-detail-script.js b/src/main/resources/static/js/view-file-detail-script.js index 87fba9d..3713925 100644 --- a/src/main/resources/static/js/view-file-detail-script.js +++ b/src/main/resources/static/js/view-file-detail-script.js @@ -13,6 +13,7 @@ function viewFileInModal(fileNum, fileType, filePath) { var modalTitle = document.getElementById('pdf-modal-label'); var pdfContainer = document.getElementById('pdf-container'); pdfContainer.innerHTML = ''; // Clear previous pages + pdfContainer.scrollTop = 0; // Scroll to the first page (top) var decodedFilePath = decodeURIComponent(filePath); var fileName = decodedFilePath.split(/[\\/]/).pop(); @@ -31,11 +32,13 @@ function viewFileInModal(fileNum, fileType, filePath) { headers: { 'Content-Type': 'application/x-www-form-urlencoded' }, body: params.toString() }).then(function (response) { + if (!response.ok) { throw new Error('Failed to fetch PDF: ' + response.statusText); } return response.arrayBuffer(); }).then(function (pdfData) { + console.log(pdfData); var blob = new Blob([pdfData], { type: 'application/pdf' }); var blobUrl = URL.createObjectURL(blob); @@ -69,6 +72,12 @@ function viewFileInModal(fileNum, fileType, filePath) { return sequence; }).then(function () { + var modalElement = document.getElementById('pdf-modal'); + modalElement.addEventListener('shown.bs.modal', function onShown() { + pdfContainer.scrollTop = 0; // Reset scroll position + modalElement.scrollTop = 0; // Reset modal scroll + modalElement.removeEventListener('shown.bs.modal', onShown); // Clean up listener + }); pdfModal.show(); }).catch(function (error) { alert('Error loading PDF: ' + error.message); diff --git a/src/main/resources/static/js/view-file-script.js b/src/main/resources/static/js/view-file-script.js index c4f5d4d..188aff3 100644 --- a/src/main/resources/static/js/view-file-script.js +++ b/src/main/resources/static/js/view-file-script.js @@ -1,4 +1,4 @@ -$(document).ready(function() { +$(document).ready(function () { // Initialize DataTable var table = $('#file-det-tbl').DataTable({ paging: true, @@ -27,7 +27,7 @@ $(document).ready(function() { exportOptions: { columns: ':visible:not(:eq(12))', // exclude 13th column format: { - body: function(data, row, column, node) { + body: function (data, row, column, node) { // If it's the first column (S.No), replace with sequential number if (column === 0) { return row + 1; // row is 0-based index of **visible filtered rows** @@ -42,9 +42,9 @@ $(document).ready(function() { }); // --- SEQUENTIAL S.NO FIX --- - table.on('order.dt search.dt draw.dt', function() { + table.on('order.dt search.dt draw.dt', function () { var pageInfo = table.page.info(); // get current page info - table.column(0, { search: 'applied', order: 'applied' }).nodes().each(function(cell, i) { + table.column(0, { search: 'applied', order: 'applied' }).nodes().each(function (cell, i) { cell.innerHTML = i + 1 + pageInfo.start; // keep numbering continuous across pages }); }).draw(); @@ -56,24 +56,24 @@ $(document).ready(function() { $('.dataTables_filter').hide(); // hide default search // Custom search box - $('#filter-records').on('keyup', function() { + $('#filter-records').on('keyup', function () { table.search($(this).val()).draw(); }); // Custom export buttons - $('#export-excel').on('click', function() { + $('#export-excel').on('click', function () { table.button('.buttons-excel').trigger(); }); - $('#export-pdf').on('click', function() { + $('#export-pdf').on('click', function () { var originalLength = table.page.len(); - table.one('draw', function() { + table.one('draw', function () { var tableClone = $('#file-det-tbl').clone(); tableClone.removeClass('dataTable'); tableClone.find('thead, tbody, tfoot').removeAttr('style'); // Remove "Supporting Documents" column (13th col = index 12) - tableClone.find('tr').each(function() { + tableClone.find('tr').each(function () { $(this).find('th:eq(12), td:eq(12)').remove(); }); @@ -98,7 +98,7 @@ $(document).ready(function() { image: { type: 'jpeg', quality: 0.98 }, html2canvas: { scale: 2, useCORS: true }, jsPDF: { unit: 'in', format: 'a3', orientation: 'landscape' } - }).from(pdfContainer[0]).save().then(function() { + }).from(pdfContainer[0]).save().then(function () { table.page.len(originalLength).draw(); pdfContainer.hide(); }); @@ -109,7 +109,7 @@ $(document).ready(function() { function populateFilters() { var advSet = {}, fundSet = {}, yearSet = {}, statSet = {}, numSet = {}, vendSet = {}; - table.rows().every(function() { + table.rows().every(function () { var data = this.data(); var advType = data[3] ? data[3].trim() : ''; @@ -170,4 +170,28 @@ $(document).ready(function() { $('#filter-file-stat').on('input', applyFilters); $('#filter-file-num').on('input', applyFilters); $('#filter-vend-name').on('input', applyFilters); // input, not datalist + + // --- Check for URL parameters to pre-apply filters --- + const urlParams = new URLSearchParams(window.location.search); + const advTypeParam = urlParams.get('advType'); + const finYearParam = urlParams.get('finYear'); + const fileStatParam = urlParams.get('fileStat'); + + let shouldApplyFilter = false; + if (advTypeParam) { + $('#filter-adv-type').val(advTypeParam); + shouldApplyFilter = true; + } + if (finYearParam) { + $('#filter-fin-year').val(finYearParam); + shouldApplyFilter = true; + } + if (fileStatParam) { + $('#filter-file-stat').val(fileStatParam); + shouldApplyFilter = true; + } + + if (shouldApplyFilter) { + applyFilters(); + } }); diff --git a/src/main/resources/templates/file/reports.html b/src/main/resources/templates/file/reports.html new file mode 100644 index 0000000..119cb99 --- /dev/null +++ b/src/main/resources/templates/file/reports.html @@ -0,0 +1,181 @@ + + + + + + + Adjustment File Management System + + + + + + + + + + + + + + + + + + + + + +
+
+
+ +
+

Reports

+ +
+ +
+ + +
+
+
+ + +
+
+
+
+
+ + + + + +
+
+ + + + + +
+
+ + + + + +
+
+
+
+ + + + + +
+
+ + + + + +
+
+ + + + + +
+
+
+
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
S.NoFile NumberFinancial YearAdvance TypeFund TypeVendor NameFile StatusDays PastFile Remarks
+ + + +
+
+
+
+
+
+
+ +
+
+ + + + + + + + + + + \ No newline at end of file diff --git a/src/main/resources/templates/file/view-file-detail.html b/src/main/resources/templates/file/view-file-detail.html index 6d426f3..0db61c3 100644 --- a/src/main/resources/templates/file/view-file-detail.html +++ b/src/main/resources/templates/file/view-file-detail.html @@ -130,6 +130,12 @@ type="button"> +


+
+
+ + + +
+
+
- Total Files :
- - Files Adjusted :
- Files Not Adjusted :
+ +
+ + +
+ + +
@@ -48,6 +65,100 @@ + \ No newline at end of file