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.

606 lines
18 KiB

3 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  1. <!DOCTYPE html>
  2. <html lang="en" dir="">
  3. <html xmlns:th="http://www.thymeleaf.org">
  4. <head th:replace="~{fragments/modules/base/head :: head}"></head>
  5. <body>
  6. <!--[if lt IE 8]>
  7. <p class="browserupgrade">You are using an <strong>outdated</strong> browser. Please <a href="http://browsehappy.com/">upgrade your browser</a> to improve your experience.</p>
  8. <![endif]-->
  9. <div class="wrapper">
  10. <!-- header top menu Start -->
  11. <header th:replace="~{fragments/modules/base/header :: header}"></header>
  12. <!-- header top menu end -->
  13. <div class="page-wrap">
  14. <!--=============== Left Menu side Start ================-->
  15. <div th:replace="~{fragments/modules/base/menu :: menu}"></div>
  16. <!--=============== Left side End ================-->
  17. <div class="main-content">
  18. <div class="container-fluid">
  19. <div class="page-header">
  20. <div class="row align-items-end">
  21. <div class="col-lg-8">
  22. <div class="page-header-title">
  23. <i class="ik ik-bar-chart-2 bg-blue"></i>
  24. <div class="d-inline">
  25. <h5>Circular Report</h5>
  26. <span>Circular Report Module</span>
  27. </div>
  28. </div>
  29. </div>
  30. <div class="col-lg-4">
  31. <nav class="breadcrumb-container" aria-label="breadcrumb">
  32. <ol class="breadcrumb">
  33. <li class="breadcrumb-item"><a href="/index"><i
  34. class="ik ik-home"></i></a></li>
  35. <li class="breadcrumb-item">Circular</li>
  36. <li class="breadcrumb-item">Report</li>
  37. <li class="breadcrumb-item active" aria-current="page">Circular
  38. Report</li>
  39. </ol>
  40. </nav>
  41. </div>
  42. </div>
  43. </div>
  44. <hr>
  45. <div class="row">
  46. <div class="col-md-12">
  47. <div class="card">
  48. <div class="card-block">
  49. <div class="row">
  50. <!-- <div class="col-md-2">
  51. <div class="form-group">
  52. <label for="usertype">From Department :</label> <select
  53. class="form-control" name="usertype" id="usertype" required>
  54. <option>1</option>
  55. <option>2</option>
  56. </select>
  57. </div>
  58. </div> -->
  59. <!-- <div class="col-md-2">
  60. <div class="form-group">
  61. <label for="usertype">Type :</label> <select
  62. class="form-control" name="usertype" id="usertype" required>
  63. <option>Circular</option>
  64. <option>Minutes</option>
  65. </select>
  66. </div>
  67. </div> -->
  68. <div class="col-md-3">
  69. <label class="" for="lastName">From Date :</label> <input
  70. type="date" class="form-control" id="date" name="date"
  71. required>
  72. </div>
  73. <div class="col-md-3">
  74. <label class="" for="lastName">To Date :</label> <input
  75. type="date" class="form-control" id="toDate" name="toDate"
  76. required>
  77. </div>
  78. <br>
  79. <!-- <div class="col-md-2"></div> -->
  80. <div class="col-md-3">
  81. <label class="invisible" for="search"> </label>
  82. <button type="button" class="btn btn-primary btn-block">Search</button>
  83. </div>
  84. </div>
  85. </div>
  86. <div>
  87. <table id="assetDatatable"
  88. class="table table-striped table-bordered table-hover dataTable"
  89. role="grid" width="99.5%">
  90. <thead class="thead-dark">
  91. <tr role="row">
  92. <th>S.No</th>
  93. <th>Department</th>
  94. <th>No. of Circulars</th>
  95. <th>No. of Minutes</th>
  96. <th>Total Count</th>
  97. </tr>
  98. </theadclass="thead-dark">
  99. <tbody>
  100. <tr th:each="category, i : ${assetcategorylist}"
  101. class="assetcategorylist">
  102. <td th:text="${i.count}">0</td>
  103. <td th:text="${category.cId}"></td>
  104. <td th:text="${category.catName}"></td>
  105. <td th:if="${category.isActive}" class="text-center"><label
  106. class="badge badge-success mb-0">Active</label></td>
  107. <td th:unless="${category.isActive}" class="text-center"><label
  108. class="badge badge-danger mb-0">InActive</label></td>
  109. <td class="text-center"><a th:href="@{#}"
  110. th:onclick="return callEdit([[${category.cId}]])"
  111. data-animation="true" data-toggle="tooltip"
  112. data-placement="top" title="Edit"
  113. data-original-title="Edit"><i
  114. class="ik ik-edit f-16 mr-15 text-green"></i></a> <a
  115. th:href="@{#}"
  116. th:onclick="return callDelete([[${category.catName}]], [[${category.cId}]] );"
  117. data-animation="true" data-toggle="tooltip"
  118. data-placement="top" title="Delete"
  119. data-original-title="Delete"><i
  120. class="ik ik-trash-2 f-16 text-red"></i></a></td>
  121. </tr>
  122. </tbody>
  123. <tfoot class="thead-dark">
  124. <tr>
  125. <th>S.No</th>
  126. <th>Department</th>
  127. <th>No. of Circulars</th>
  128. <th>No. of Minutes</th>
  129. <th>Total Count</th>
  130. </tr>
  131. </tfoot>
  132. </table>
  133. </div>
  134. </div>
  135. </div>
  136. </div>
  137. </div>
  138. </div>
  139. </div>
  140. <footer th:replace="~{fragments/modules/base/footer :: footer}"></footer>
  141. </div>
  142. </div>
  143. <div class="modal fade" id="addForm" tabindex="-1" role="dialog"
  144. aria-hidden="true">
  145. <div class="modal-dialog modal-dialog-centered" role="document">
  146. <div class="modal-content">
  147. <form name="addCategoryForm" id="addCategoryForm"
  148. onsubmit="return saveCategory();">
  149. <div class="modal-header">
  150. <h5 class="modal-title" id="exampleModalCenterLabel">Master
  151. Category Form</h5>
  152. <button type="button" class="close" data-dismiss="modal"
  153. aria-label="Close">
  154. <span aria-hidden="true">&times;</span>
  155. </button>
  156. </div>
  157. <div class="modal-body">
  158. <div id="addFormError" class="text-danger text-center"></div>
  159. <div class="form-group row">
  160. <label for="catName" class="col-sm-12 col-form-label">Asset
  161. Category Name</label>
  162. <div class="col-sm-12">
  163. <input type="text" class="form-control" name="catName"
  164. id="catName" placeholder="Category Name" required>
  165. </div>
  166. </div>
  167. <div class="form-group row">
  168. <label for="isActive" class="col-sm-12 col-form-label">IsActive</label>
  169. <div class="col-sm-12">
  170. <select class="form-control" id="isActive" name="isActive">
  171. <option value=1>Yes</option>
  172. <option value=0>No</option>
  173. </select>
  174. </div>
  175. </div>
  176. </div>
  177. <div class="modal-footer">
  178. <button type="reset" class="btn btn-secondary btn-sm"
  179. data-dismiss="modal" onclick="return closeModel();">
  180. <i class="ik ik-x-square"></i>Close
  181. </button>
  182. <button type="submit" class="btn btn-success btn-sm" id="savebtn">
  183. <i class="ik ik-save"></i>Save
  184. </button>
  185. </div>
  186. </form>
  187. </div>
  188. </div>
  189. </div>
  190. <div class="modal fade" id="editForm" data-backdrop="static"
  191. tabindex="-1" role="dialog" aria-labelledby="staticBackdropLabel"
  192. aria-hidden="true">
  193. <div class="modal-dialog modal-dialog-centered" role="document">
  194. <div class="modal-content">
  195. <form name="editCategoryForm" id="editCategoryForm"
  196. onsubmit="return updateCategory();">
  197. <div class="modal-header">
  198. <h5 class="modal-title" id="exampleModalCenterLabel">Master
  199. Category Form</h5>
  200. <button type="button" class="close" data-dismiss="modal"
  201. aria-label="Close">
  202. <span aria-hidden="true">&times;</span>
  203. </button>
  204. </div>
  205. <div class="modal-body">
  206. <div id="editFormError" class="text-danger text-center"></div>
  207. <div class="form-group row">
  208. <label for="catName" class="col-sm-12 col-form-label">Asset
  209. Category Name</label>
  210. <div class="col-sm-12">
  211. <input type="text" class="form-control" name="catName"
  212. id="editCatName" placeholder="Category Name" required>
  213. </div>
  214. </div>
  215. <div class="form-group row">
  216. <label for="isActive" class="col-sm-12 col-form-label">IsActive</label>
  217. <div class="col-sm-12">
  218. <select class="form-control" id="editIsActive" name="isActive">
  219. <option value=1>Yes</option>
  220. <option value=0>No</option>
  221. </select>
  222. </div>
  223. </div>
  224. </div>
  225. <div class="modal-footer">
  226. <input type="hidden" name="cId" id="cId" value="0">
  227. <button type="reset" class="btn btn-secondary btn-sm"
  228. data-dismiss="modal" onclick="return closeModel();">
  229. <i class="ik ik-x-square"></i>Close
  230. </button>
  231. <button type="submit" class="btn btn-success btn-sm" id="editbtn">
  232. <i class="ik ik-save"></i>Update
  233. </button>
  234. </div>
  235. </form>
  236. </div>
  237. </div>
  238. </div>
  239. <!--end modal-->
  240. <div th:replace="~{fragments/modules/base/app_module_menu_box :: div}"></div>
  241. <script th:replace="~{fragments/modules/base/script :: script}"></script>
  242. <script type="text/javascript">
  243. var qrAssetFeedbackApiUrl = "[[${qrAssetFeedbackApiUrl}]]";
  244. $(document).ready(function() {
  245. // DataTables buttons configuration
  246. var buttons = [
  247. {
  248. extend: 'pageLength',
  249. className: 'btn btn-warning'
  250. },
  251. {
  252. title: 'Data export',
  253. extend: 'copyHtml5',
  254. text: 'Copy',
  255. className: 'btn btn-secondary',
  256. id: 'copyBtn'
  257. },
  258. {
  259. extend: 'excelHtml5',
  260. text: 'Excel',
  261. className: 'btn btn-secondary',
  262. id: 'excelBtn'
  263. },
  264. {
  265. extend: 'csvHtml5',
  266. text: 'CSV',
  267. className: 'btn btn-secondary',
  268. id: 'csvBtn'
  269. },
  270. {
  271. extend: 'pdfHtml5',
  272. text: 'PDF',
  273. className: 'btn btn-secondary',
  274. id: 'pdfBtn'
  275. },
  276. // Additional button
  277. /* {
  278. text: '<i class="far fa-plus-square"></i> Add New Asset Category',
  279. className: 'btn btn-warning',
  280. action: function () {
  281. callAdd();
  282. }
  283. } */
  284. ];
  285. $('#assetDatatable').DataTable( {
  286. dom: 'Bftip',
  287. columnDefs: [
  288. { targets: 'no-sort', orderable: false }
  289. ],
  290. lengthMenu: [
  291. [ 50, 100, 200, 500, -1 ],
  292. [ '50 rows', '100 rows', '200 rows','500 rows', 'Show all' ]
  293. ],
  294. scrollY: '50vh',
  295. fixedColumns: {
  296. left: 1,
  297. right: 1
  298. },
  299. buttons: [buttons],
  300. responsive: true,
  301. searching: false,
  302. select: false,
  303. processing: false,
  304. } );
  305. } );
  306. function callAdd(){
  307. formReset();
  308. $('#addForm').modal({
  309. backdrop: 'static',
  310. keyboard: false
  311. })
  312. $('#addForm').modal('show');
  313. }
  314. function callEdit(id){
  315. // Form reste
  316. formReset();
  317. //Fetch data by id
  318. getEditdata(id);
  319. $('#editForm').modal({
  320. backdrop: 'static',
  321. keyboard: false
  322. })
  323. $('#editForm').modal('show');
  324. return false;
  325. }
  326. function callDelete(name,id){
  327. Swal.fire({
  328. title: 'Are you sure you want to delete the category?`<br>'+name+'`',
  329. text: "You won't be able to revert this!",
  330. icon: 'warning',
  331. showCancelButton: true,
  332. confirmButtonColor: '#3085d6',
  333. cancelButtonColor: '#d33',
  334. confirmButtonText: 'Yes, delete it!',
  335. }).then(function(result) {
  336. if (result.isConfirmed) {
  337. $.ajax({
  338. type: "GET",
  339. dataType: 'json',
  340. url: "/api/qrfeedback/category/"+id+"/delete",
  341. //data: "id=" + id + "&name=" + name,
  342. success: function(data){
  343. Swal.fire(
  344. 'Deleted!',
  345. 'Category `'+name+'` has been deleted.',
  346. 'success'
  347. ).then(() => {
  348. location.reload();
  349. });
  350. }
  351. })
  352. }
  353. })
  354. return false;
  355. }
  356. function saveCategory(){
  357. // Disable the button to prevent multiple clicks
  358. $("#savebtn").prop("disabled", true);
  359. // Show the loading icon on the button
  360. $("#savebtn").html('<i class="fas fa-spinner fa-spin"></i>Save');
  361. // Get form data
  362. var formData = {
  363. catName: $('#catName').val(),
  364. isActive: $('#isActive').val()
  365. };
  366. if(formData.catName!=''){
  367. //alert(qrAssetFeedbackApiUrl);
  368. $.ajax({
  369. type: "POST",
  370. dataType: 'json',
  371. url: "/api/qrfeedback/category/checkbyname",
  372. //contentType: 'application/json',
  373. data: formData,
  374. success: function(data){
  375. if(data==0){
  376. $('#addFormError').html("");
  377. callSaveCategoryAPI();
  378. }
  379. else{
  380. $('#addFormError').html("<i class='ik ik-alert-triangle'></i> Asset Category Name `"+formData.catName+"` already exists!.");
  381. $("#savebtn").prop("disabled", false);
  382. $("#savebtn").html('<i class="ik ik-save"></i>Save');
  383. }
  384. },
  385. error: function(xhr, status, error) {
  386. console.error('Form submission error:', error);
  387. $("#savebtn").prop("disabled", false);
  388. $("#savebtn").html('<i class="ik ik-save"></i>Save');
  389. // Handle errors here
  390. }
  391. })
  392. }
  393. return false;
  394. }
  395. function callSaveCategoryAPI(){
  396. // Get form data
  397. var formData = {
  398. catName: $('#catName').val(),
  399. isActive: $('#isActive').val()
  400. };
  401. if (formData.catName.trim() !== '') {
  402. //alert(qrAssetFeedbackApiUrl);
  403. $.ajax({
  404. type: "POST",
  405. dataType: 'json',
  406. url: "/api/qrfeedback/saveCategory",
  407. //contentType: 'application/json',
  408. data: formData,
  409. success: function(data){
  410. $('#addFormError').html("");
  411. Swal.fire(
  412. 'Add Category!',
  413. 'Category `'+formData.catName+'` added successfully.',
  414. 'success'
  415. ).then(() => {
  416. formReset();
  417. $('#addForm').modal('hide');
  418. $("#savebtn").prop("disabled", false);
  419. $("#savebtn").html('<i class="ik ik-save"></i>Save');
  420. location.reload();
  421. });
  422. },
  423. error: function(xhr, status, error) {
  424. console.error('Form submission error:', error);
  425. $("#savebtn").prop("disabled", false);
  426. $("#savebtn").html('<i class="ik ik-save"></i>Save');
  427. // Handle errors here
  428. }
  429. })
  430. }
  431. return false;
  432. }
  433. function getEditdata(id){
  434. $.ajax({
  435. type: "POST",
  436. dataType: 'json',
  437. url: "/api/qrfeedback/category/"+id,
  438. //data: formData,
  439. success: function(data){
  440. //console.log(data);
  441. $("#cId").val(data[0]["cId"]);
  442. $("#editCatName").val(data[0]["catName"]);
  443. if(data[0]["isActive"]==true){
  444. $("#editIsActive").val(1); // True (Yes)
  445. }
  446. else{
  447. $("#editIsActive").val(0); // False (No)
  448. }
  449. },
  450. error: function(xhr, status, error) {
  451. console.error('Get Data(category) error:', error);
  452. $("#editbtn").prop("disabled", false);
  453. $("#editbtn").html('<i class="ik ik-save"></i>Update');
  454. // Handle errors here
  455. }
  456. })
  457. }
  458. function updateCategory(){
  459. // Disable the button to prevent multiple clicks
  460. $("#editbtn").prop("disabled", true);
  461. // Show the loading icon on the button
  462. $("#editbtn").html('<i class="fas fa-spinner fa-spin"></i>Update');
  463. // Get form data
  464. var formData = {
  465. cId: $('#cId').val(),
  466. catName: $('#editCatName').val(),
  467. isActive: $('#editIsActive').val()
  468. };
  469. if (formData.catName.trim() !== '') {
  470. //alert(qrAssetFeedbackApiUrl);
  471. $.ajax({
  472. type: "POST",
  473. dataType: 'json',
  474. url: "/api/qrfeedback/category/edit/checkbyname",
  475. //contentType: 'application/json',
  476. data: formData,
  477. success: function(data){
  478. if(data==0){
  479. $('#editFormError').html("");
  480. callUpadteCategoryAPI();
  481. }
  482. else{
  483. $('#editFormError').html("<i class='ik ik-alert-triangle'></i> Asset Category Name `"+formData.catName+"` already exists!.");
  484. $("#editbtn").prop("disabled", false);
  485. $("#editbtn").html('<i class="ik ik-save"></i>Update');
  486. }
  487. },
  488. error: function(xhr, status, error) {
  489. console.error('Form submission error:', error);
  490. $("#editbtn").prop("disabled", false);
  491. $("#editbtn").html('<i class="ik ik-save"></i>Update');
  492. // Handle errors here
  493. }
  494. })
  495. }
  496. return false;
  497. }
  498. function callUpadteCategoryAPI(){
  499. // Get form data
  500. var formData = {
  501. cId: $('#cId').val(),
  502. catName: $('#editCatName').val(),
  503. isActive: $('#editIsActive').val()
  504. };
  505. if (formData.catName.trim() !== '') {
  506. //alert(qrAssetFeedbackApiUrl);
  507. $.ajax({
  508. type: "POST",
  509. dataType: 'json',
  510. url: "/api/qrfeedback/updateCategory",
  511. //contentType: 'application/json',
  512. data: formData,
  513. success: function(data){
  514. $('#editFormError').html("");
  515. Swal.fire(
  516. 'Update Category!',
  517. 'Category `'+formData.catName+'` updated successfully.',
  518. 'success'
  519. ).then(() => {
  520. formReset();
  521. $('#editForm').modal('hide');
  522. $("#editbtn").prop("disabled", false);
  523. $("#editbtn").html('<i class="ik ik-save"></i>Update');
  524. location.reload();
  525. });
  526. },
  527. error: function(xhr, status, error) {
  528. console.error('Update form submission error:', error);
  529. $("#editbtn").prop("disabled", false);
  530. $("#editbtn").html('<i class="ik ik-save"></i>Update');
  531. // Handle errors here
  532. }
  533. })
  534. }
  535. return false;
  536. }
  537. function closeModel(){
  538. formReset();
  539. $('#addForm').modal('hide');
  540. $('#editForm').modal('hide');
  541. }
  542. function formReset(){
  543. // For add form
  544. document.getElementById('addCategoryForm').reset();
  545. $('#addFormError').html("");
  546. $("#savebtn").prop("disabled", false);
  547. $("#savebtn").html('<i class="ik ik-save"></i>Save');
  548. // For edit form
  549. document.getElementById('editCategoryForm').reset();
  550. $('#editFormError').html("");
  551. $("#editbtn").prop("disabled", false);
  552. $("#editbtn").html('<i class="ik ik-save"></i>Update');
  553. }
  554. </script>
  555. </body>
  556. </html>