You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

410 lines
14 KiB

​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  1. <!DOCTYPE html>
  2. <html lang="en" xmlns:th="http://www.thymeleaf.org">
  3. <head th:replace="~{fragments/modules/base/head :: head}">
  4. </head>
  5. <style>
  6. </style>
  7. <body>
  8. <div class="wrapper">
  9. <!-- header top menu Start -->
  10. <header th:replace="~{fragments/modules/base/header :: header}"></header>
  11. <!-- header top menu end -->
  12. <div class="page-wrap">
  13. <!--=============== Left Menu side Start ================-->
  14. <div th:replace="~{fragments/modules/base/menu :: menu}"></div>
  15. <!--=============== Left side End ================-->
  16. <div class="main-content">
  17. <div class="container-fluid">
  18. <div class="page-header mb-2">
  19. <div class="row align-items-end">
  20. <div class="col-lg-8">
  21. <div class="page-header-title">
  22. <i class="fa fa-list-alt bg-blue"></i>
  23. <div class="d-inline">
  24. <h5>Reports</h5>
  25. <span>C&D Waste Collections Reports</span>
  26. </div>
  27. </div>
  28. </div>
  29. <div class="col-lg-4">
  30. <nav class="breadcrumb-container" aria-label="breadcrumb">
  31. <ol class="breadcrumb">
  32. <li class="breadcrumb-item"><a href="/gcc/index"><i
  33. class="ik ik-home"></i></a></li>
  34. <li class="breadcrumb-item" aria-current="page">C&D Waste Collections Reports</li>
  35. <li class="breadcrumb-item active" aria-current="page"> Reports</li>
  36. </ol>
  37. </nav>
  38. </div>
  39. </div>
  40. </div>
  41. <div class="row mt-4">
  42. <div class="col-12">
  43. <div class="card">
  44. <div class="card-header">
  45. <span style="font-size: medium;font-weight: bold;">Reports Filters</span>
  46. </div>
  47. <div class="card-body">
  48. <div class="row">
  49. <div class="col-sm-2 mb-2">
  50. <label for="startDate" class="form-label">From Date:<span class="text-danger">*</span></label>
  51. <input type="date" id="startDate" class="form-control">
  52. </div>
  53. <div class="col-sm-2 mb-2">
  54. <label for="endDate" class="form-label" >To Date:<span class="text-danger">*</span></label>
  55. <input type="date" id="endDate" class="form-control">
  56. </div>
  57. <div class="col-sm-2 mb-2 ">
  58. <label for="wastequantity" class="form-label">Select weight quantity<span class="text-danger">*</span>
  59. </label> <select id="wastequantity" class="form-control">
  60. <!-- dynamically get the quantities -->
  61. </select>
  62. </div>
  63. <div class="col-sm-2 mb-2">
  64. <label for="zoneDropdown" class="form-label"> Select
  65. Zone <span class="text-danger">*</span>
  66. </label> <select id="zoneDropdown" class="form-control">
  67. <option value="">Select Zone</option>
  68. <!-- Zones will be loaded dynamically -->
  69. </select>
  70. </div>
  71. <div class="row mt-4">
  72. <div class="col-md-12 mb-2 d-flex justify-content-center">
  73. <button type="submit" id="searchBtn"
  74. class="btn btn-primary mx-2">Search</button>
  75. <button class="btn btn-danger mx-2" id="resetBtn" name="reset" type="button">Reset</button>
  76. </div>
  77. </div>
  78. </div>
  79. </div>
  80. </div>
  81. </div>
  82. <div class="col-md-12">
  83. <div class="card">
  84. <div class="card-header">
  85. <span style="font-size: medium;font-weight: bold;">Reports List</span>
  86. </div>
  87. <div class="card-body">
  88. <div class="table-responsive" >
  89. <table id="ReportDatatable" class="table table-striped table-bordered table-hover dataTable" role="grid">
  90. <thead class="thead-dark">
  91. <tr role="row">
  92. <th class="text-center no-sort">S.No</th>
  93. <th class="text-center">Request ID</th>
  94. <th class="text-center">Request Date</th>
  95. <th class="text-center">Name</th>
  96. <th class="text-center">Mobile Number</th>
  97. <th class="text-center">Area</th>
  98. <th class="text-center">Zone</th>
  99. <th class="text-center">Weight Quantity</th>
  100. <th class="text-center">Waste Type</th>
  101. <th class="text-center">Dumping Location</th>
  102. <th class="text-center">Actual Weight</th>
  103. <th class="text-center">Payment Status</th>
  104. <th class="text-center">Total Amount</th>
  105. </tr>
  106. </thead>
  107. <tbody>
  108. </tbody>
  109. </table>
  110. </div>
  111. </div>
  112. </div>
  113. </div>
  114. </div>
  115. </div>
  116. <div id="pageLoader" style="display: none; position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(255, 255, 255, 0.8); z-index: 9999; text-align: center;">
  117. <div style="position: relative; top: 50%; transform: translateY(-50%);">
  118. <div class="spinner-border text-primary" role="status" style="width: 3rem; height: 3rem;">
  119. <span class="sr-only">Loading...</span>
  120. </div>
  121. <!-- Add the 'Please wait' text below the spinner -->
  122. <p style="margin-top: 1rem; font-size: 1.2rem; color: #007bff;">Please wait...</p>
  123. </div>
  124. </div>
  125. </div>
  126. <footer th:replace="~{fragments/modules/base/footer :: footer}"></footer>
  127. </div>
  128. </div>
  129. <!-- in the code use to show the download different type microsoft -->
  130. <!-- Include jQuery and Bootstrap JavaScript -->
  131. <script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
  132. <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.5.2/js/bootstrap.min.js"></script>
  133. <script th:replace="~{fragments/modules/base/script :: script}"></script>
  134. <!-- sweet alert -->
  135. <script src="https://cdn.jsdelivr.net/npm/sweetalert2@11"></script>
  136. <script type="text/javascript">
  137. $(document).ready(function() {
  138. var table = $('#ReportDatatable').DataTable({
  139. dom: 'Bftip',
  140. columnDefs: [
  141. { targets: 'no-sort', orderable: false }
  142. ],
  143. lengthMenu: [
  144. [50, 100, 200, 500, -1],
  145. ['50 rows', '100 rows', '200 rows', 'Show all']
  146. ],
  147. scrollY: '80vh',
  148. scrollX: true,
  149. buttons: [
  150. {
  151. extend: 'pageLength',
  152. className: 'btn btn-warning'
  153. },
  154. {
  155. title: 'Data export',
  156. extend: 'copyHtml5',
  157. text: 'Copy',
  158. className: 'btn btn-secondary',
  159. id: 'copyBtn'
  160. },
  161. {
  162. extend: 'excelHtml5',
  163. text: 'Excel',
  164. className: 'btn btn-secondary',
  165. id: 'excelBtn'
  166. },
  167. {
  168. extend: 'csvHtml5',
  169. text: 'CSV',
  170. className: 'btn btn-secondary',
  171. id: 'csvBtn'
  172. },
  173. {
  174. extend: 'pdfHtml5',
  175. text: 'PDF',
  176. className: 'btn btn-secondary',
  177. id: 'pdfBtn'
  178. }
  179. ],
  180. fixedHeader: true,
  181. autoWidth: false,
  182. scrollX: true,
  183. responsive: false,
  184. paging:true,
  185. searching: true,
  186. select: false,
  187. processing: false
  188. });
  189. // Event listener for From Date selection
  190. $(document).ready(function () {
  191. const today = new Date();
  192. const formattedToday = today.toISOString().split('T')[0];
  193. // Get date 30 days ago
  194. const pastDate = new Date();
  195. pastDate.setDate(today.getDate() - 30);
  196. const formattedPast = pastDate.toISOString().split('T')[0];
  197. // Set default values and limits
  198. $("#startDate").val(formattedPast);
  199. $("#startDate").attr("max", formattedToday);
  200. $("#endDate").val(formattedToday);
  201. $("#endDate").attr("min", formattedPast);
  202. $("#endDate").attr("max", formattedToday);
  203. // Load quantities
  204. $.ajax({
  205. url: "/gcc/api/dumpregistration/getquantity",
  206. type: "GET",
  207. success: function (data) {
  208. let quantityDropdown = $("#wastequantity");
  209. quantityDropdown.empty().append("<option value=''>Select Quantity</option>");
  210. $.each(data, function (index, item) {
  211. quantityDropdown.append(`<option value="${item.quantity}">${item.quantity}</option>`);
  212. });
  213. },
  214. error: function (xhr, status, error) {
  215. console.error("Error fetching quantities:", error);
  216. }
  217. });
  218. // Function to fetch and load data
  219. function loadReportData() {
  220. let startDate = $('#startDate').val();
  221. let endDate = $('#endDate').val();
  222. let zone = $('#zoneDropdown').val();
  223. let wasteQuantity = $('#wastequantity').val();
  224. const params = new URLSearchParams({
  225. fromDate: startDate,
  226. toDate: endDate
  227. });
  228. if (zone) {
  229. params.append("zone", zone);
  230. }
  231. if (wasteQuantity) {
  232. params.append("wastequantity", wasteQuantity);
  233. }
  234. $('#pageLoader').show();
  235. $.ajax({
  236. type: "GET",
  237. url: `/gcc/api/dumpregistration/getAllDetails?${params.toString()}`,
  238. contentType: "application/json",
  239. success: function (response) {
  240. $('#pageLoader').hide();
  241. if (Array.isArray(response) && response.length > 0) {
  242. $('#ReportDatatable').DataTable({
  243. destroy: true,
  244. searching: true,
  245. paging: true,
  246. info: true,
  247. autoWidth: true, // IMPORTANT: let you control column width
  248. scrollX: true, // Enables horizontal scroll
  249. responsive: true, // Disable built-in responsive which hides columns
  250. data: response,
  251. columns: [
  252. { data: null, render: (data, type, row, meta) => meta.row + 1, className: 'text-center' },
  253. { data: 'refid', defaultContent: '-', className: 'text-center' },
  254. { data: 'request_date', defaultContent: '-', className: 'text-center' },
  255. { data: 'name', defaultContent: '-', className: 'text-center' },
  256. { data: 'mobile_no', defaultContent: '-', className: 'text-center' },
  257. { data: 'area', defaultContent: '-', className: 'text-center' },
  258. { data: 'zone', defaultContent: '-', className: 'text-center' },
  259. { data: 'quantity', defaultContent: '-', className: 'text-center' },
  260. { data: 'waste_type', defaultContent: '-', className: 'text-center' },
  261. { data: 'location', defaultContent: '-', className: 'text-center' },
  262. { data: 'actual_weight', defaultContent: '-', className: 'text-center' },
  263. { data: 'payment_status', defaultContent: '-', className: 'text-center' },
  264. { data: 'total_charge', defaultContent: '-', className: 'text-center' }
  265. ],
  266. dom: 'Bfrtip',
  267. buttons: [
  268. { extend: 'pageLength', className: 'btn btn-warning' },
  269. { extend: 'copyHtml5', text: 'Copy', className: 'btn btn-secondary' },
  270. { extend: 'excelHtml5', text: 'Excel', className: 'btn btn-secondary' },
  271. { extend: 'csvHtml5', text: 'CSV', className: 'btn btn-secondary' },
  272. { extend: 'pdfHtml5', text: 'PDF', className: 'btn btn-secondary' }
  273. ],
  274. columnDefs: [{ targets: 'no-sort', orderable: false }],
  275. lengthMenu: [
  276. [50, 100, 200, 500, -1],
  277. ['50 rows', '100 rows', '200 rows', 'Show all']
  278. ],
  279. scrollY: '80vh',
  280. scrollX: true,
  281. responsive: true
  282. });
  283. } else {
  284. Swal.fire({
  285. icon: 'warning',
  286. title: 'No Data',
  287. text: 'No data available for the selected criteria.'
  288. });
  289. }
  290. },
  291. error: function () {
  292. $('#pageLoader').hide();
  293. Swal.fire({
  294. icon: 'error',
  295. title: 'Error',
  296. text: 'Something went wrong while fetching the data.'
  297. });
  298. }
  299. });
  300. }
  301. // Bind search button to loadReportData
  302. $('#searchBtn').on('click', function (e) {
  303. e.preventDefault();
  304. let startDate = $('#startDate').val();
  305. let endDate = $('#endDate').val();
  306. if (!startDate || !endDate) {
  307. Swal.fire({
  308. icon: 'warning',
  309. title: 'Error',
  310. text: 'Please Select Both From Date and To Date',
  311. showConfirmButton: true,
  312. timer: 3000
  313. });
  314. return;
  315. }
  316. loadReportData();
  317. });
  318. // Load data for the last 30 days on page load
  319. loadReportData();
  320. });
  321. });
  322. $('#resetBtn').click(function () {
  323. location.reload();
  324. });
  325. // Load all zones
  326. $(document).ready(function () {
  327. $.ajax({
  328. url: '/gcc/api/dumpregistration/getzones',
  329. type: 'GET',
  330. success: function (zones) {
  331. $.each(zones, function (index, zone) {
  332. $('#zoneDropdown').append('<option value="' + zone.id + '">' + zone.zone_name + '</option>');
  333. });
  334. },
  335. error: function () {
  336. alert('Failed to load zones.');
  337. }
  338. });
  339. });
  340. </script>
  341. </body>
  342. </html>