This portal only for GCC Officers. Based on there roles and Group ID they can view there module`s Like PGR, QR Public Asset Feedback, Makkalai Thedi Mayor,etc...
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.

703 lines
25 KiB

​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  1. <!DOCTYPE html>
  2. <html lang="en" dir="ltr">
  3. <html xmlns:th="http://www.thymeleaf.org">
  4. <head th:replace="~{fragments/modules/base/head :: head}">
  5. <title>Add Furniture Asset In Master</title>
  6. <link href="https://cdn.jsdelivr.net/npm/select2@4.1.0-rc.0/dist/css/select2.min.css" rel="stylesheet" />
  7. <script src="https://cdn.jsdelivr.net/npm/select2@4.1.0-rc.0/dist/js/select2.min.js"></script>
  8. <script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
  9. <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-icons/font/bootstrap-icons.css">
  10. </head> <head th:replace="~{fragments/modules/base/head :: head}"></head>
  11. <style>
  12. /* Remove background image from the container itself */
  13. .select2-container--default .select2-selection--multiple {
  14. padding-right: 30px;
  15. min-height: 38px;
  16. display: flex;
  17. flex-wrap: wrap;
  18. align-items: center;
  19. position: relative; /* important for the ::after */
  20. background-image: none;
  21. }
  22. /* Add the dropdown arrow via a pseudo-element */
  23. .select2-container--default .select2-selection--multiple::after {
  24. content: "";
  25. position: absolute;
  26. top: 50%;
  27. right: 8px;
  28. width: 14px;
  29. height: 14px;
  30. transform: translateY(-50%);
  31. background-image: url("data:image/svg+xml;utf8,<svg fill='gray' height='20' viewBox='0 0 24 24' width='20' xmlns='http://www.w3.org/2000/svg'><path d='M7 10l5 5 5-5z'/></svg>");
  32. background-repeat: no-repeat;
  33. background-size: contain;
  34. pointer-events: none;
  35. }
  36. /* Each selected tag */
  37. .select2-container--default .select2-selection--multiple .select2-selection__choice {
  38. display: flex;
  39. align-items: center;
  40. justify-content: space-between;
  41. padding: 5px 10px;
  42. margin: 4px 4px 0 0;
  43. background-color: #f5f5f5;
  44. border: 1px solid #ccc;
  45. border-radius: 4px;
  46. font-size: 13px;
  47. line-height: 1.4;
  48. max-width: 100%;
  49. white-space: nowrap;
  50. overflow: hidden;
  51. text-overflow: ellipsis;
  52. }
  53. /* The text inside the tag */
  54. .select2-container--default .select2-selection--multiple .select2-selection__choice__display {
  55. overflow: hidden;
  56. text-overflow: ellipsis;
  57. white-space: nowrap;
  58. flex: 1;
  59. margin-right: 8px;
  60. }
  61. /* The "X" close icon */
  62. .select2-container--default .select2-selection--multiple .select2-selection__choice__remove {
  63. position: static;
  64. transform: none;
  65. color: #333;
  66. font-size: 14px;
  67. font-weight: bold;
  68. cursor: pointer;
  69. background: transparent;
  70. border: none;
  71. line-height: 1;
  72. }
  73. </style>
  74. <body>
  75. <div class="wrapper">
  76. <header th:replace="~{fragments/modules/base/header :: header}"></header>
  77. <div class="page-wrap">
  78. <div th:replace="~{fragments/modules/base/menu :: menu}"></div>
  79. <div class="card">
  80. <div class="main-content" style="background-color: white;">
  81. <div class="container">
  82. <!-- Card 2: Other Details -->
  83. <div class="col-md-12">
  84. <div style="padding: 0px;margin-top:-58px;margin-left: -233px;">
  85. <div class="card-header d-flex justify-content-between align-items-center">
  86. <b>List of Furniture Assets</b>
  87. <button type="button" class="btn btn-primary add-fbtn"> <i class="ik ik-plus"></i>Add Assets</button>
  88. </div>
  89. <div class="card-body" style="padding: 5px;">
  90. <table id="FAssetManageDatatable"
  91. class="table table-striped table-bordered table-hover dataTable" role="grid"
  92. style="width: 100%">
  93. <thead class="thead-dark">
  94. <tr>
  95. <th>S.NO</th>
  96. <th>ASSET TYPE</th>
  97. <th>MASTER QTY</th>
  98. <th>MAPPED QTY</th>
  99. <th>UNMAPPED QTY</th>
  100. <th>ACTION</th>
  101. </tr>
  102. </thead>
  103. <tbody>
  104. </tbody>
  105. </table>
  106. </div>
  107. </div>
  108. </div>
  109. </div>
  110. <div id="pageLoader"
  111. 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;">
  112. <div style="position: relative; top: 50%; transform: translateY(-50%);">
  113. <div class="spinner-border text-primary" role="status" style="width: 3rem; height: 3rem;">
  114. <span class="sr-only">Loading...</span>
  115. </div>
  116. <!-- Add the 'Please wait' text below the spinner -->
  117. <p style="margin-top: 1rem; font-size: 1.2rem; color: #007bff;">Please wait...</p>
  118. </div>
  119. </div>
  120. </div>
  121. </div>
  122. </div>
  123. </div>
  124. <div class="modal fade" id="AddFAssetModal" tabindex="-1" role="dialog" aria-labelledby="AddFAssetModalLabel" aria-hidden="true" data-bs-backdrop="static" data-bs-keyboard="false">
  125. <div class="modal-dialog modal-lg" role="document">
  126. <div class="modal-content">
  127. <div class="modal-header">
  128. <h5 class="modal-title">
  129. Add Furniture Assets
  130. </h5>
  131. <button type="button" class="close" data-bs-dismiss="modal" aria-label="Close">
  132. <span aria-hidden="true">&times;</span>
  133. </button>
  134. </div>
  135. <div class="modal-body">
  136. <div class="row">
  137. <div class="form-group col-6">
  138. <label>Select Asset <span style="color: red;">*</span></label>
  139. <select id="FsubAssetType" class="form-control" multiple></select>
  140. </div>
  141. </div>
  142. <div id="selectedFAssetsContainer" class="mt-3"></div>
  143. <div class="row pb-2 mt-4" id="savingcontainerf" style="display: none;">
  144. <div class="col-12 d-flex justify-content-center">
  145. <button type="button" class="btn btn-primary" id="savingFAsset">Save</button>
  146. </div>
  147. </div>
  148. </div>
  149. <div class="modal-footer">
  150. <button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Close</button>
  151. </div>
  152. </div>
  153. </div>
  154. </div>
  155. <div class="modal fade" id="EditFAssetModal" tabindex="-1" role="dialog" aria-labelledby="EditFAssetModalLabel" aria-hidden="true" data-bs-backdrop="static" data-bs-keyboard="false">
  156. <div class="modal-dialog modal-lg" role="document">
  157. <div class="modal-content">
  158. <div class="modal-header">
  159. <h5 class="modal-title">
  160. <span id="Feditassetname"></span> - Edit Furniture Asset
  161. </h5>
  162. <button type="button" class="close" data-bs-dismiss="modal" aria-label="Close">
  163. <span aria-hidden="true">&times;</span>
  164. </button>
  165. </div>
  166. <div class="modal-body">
  167. <span id="Feditid" style="display: none;"></span>
  168. <div class="row">
  169. <div class="form-group col-6">
  170. <label for="Fmaster_qty">Master Quantity&nbsp;(&nbsp;Already in master&nbsp;<span id="AFmaster_qty" style="font-style: italic;font-weight: bold;"></span>&nbsp;)<span class="text-danger">*</span></label>
  171. <input type="text" class="form-control" id="Fmaster_qty" name="Fmaster_qty">
  172. </div>
  173. <div class="form-group col-6">
  174. <label for="Fmapped_qty">Mapped Quantity</label>
  175. <input type="text" class="form-control" id="Fmapped_qty" name="Fmapped_qty" readonly>
  176. </div>
  177. <div class="form-group col-6">
  178. <label for="Funmapped_qty">Unmapped Quantity</label>
  179. <input type="text" class="form-control" id="Funmapped_qty" name="Funmapped_qty" readonly>
  180. </div>
  181. </div>
  182. <div class="row pb-2 mt-4">
  183. <div class="col-12 d-flex justify-content-center">
  184. <button type="button" class="btn btn-primary" id="UpdatingFAsset">Update</button>
  185. </div>
  186. </div>
  187. </div>
  188. <div class="modal-footer">
  189. <button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Close</button>
  190. </div>
  191. </div>
  192. </div>
  193. </div>
  194. <script th:replace="~{fragments/modules/base/script :: script}"></script>
  195. <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0-alpha1/dist/js/bootstrap.bundle.min.js"></script>
  196. <script type="text/javascript">
  197. console.log("hi..furniture asset");
  198. $(document).ready(function () {
  199. let FurnitureAsseturlParams = new URLSearchParams(window.location.search);
  200. let FAssetschoolId = FurnitureAsseturlParams.get("schoolId");
  201. loadFAsset(FAssetschoolId);
  202. // Only run after DOM and libraries are ready
  203. $('#FsubAssetType').on('select2:opening', function() {
  204. setTimeout(() => {
  205. $('.select2-search__field').prop('readonly', true); // disable typing
  206. }, 0);
  207. });
  208. if (!window.FassetEventsBound) {
  209. $(document).on('click', '.add-fbtn', function () {
  210. handleAddFAsset(FAssetschoolId);
  211. });
  212. $(document).on('click', '#savingFAsset', function () {
  213. handleSaveFAsset(FAssetschoolId);
  214. });
  215. $(document).on('click', '.edit-btnf', handleFAssetEdit);
  216. $(document).on('click', '#UpdatingFAsset', handelEditFAsset);
  217. window.FassetEventsBound = true;
  218. }
  219. $('#FsubAssetType').on('change', function () {
  220. console.log("hi...");
  221. const selectedOptions = $(this).find('option:selected');
  222. const $container = $('#selectedFAssetsContainer');
  223. $container.empty(); // Clear previous entries
  224. if (selectedOptions.length >= 1) {
  225. $('#savingcontainerf').show();
  226. } else {
  227. $('#savingcontainerf').hide();
  228. }
  229. let labelRow = '';
  230. let inputRow = '';
  231. let counter = 0;
  232. selectedOptions.each(function (index) {
  233. const assetName = $(this).text();
  234. const assetId = $(this).val();
  235. // Start new row every 3 items
  236. if (counter % 3 === 0) {
  237. if (labelRow || inputRow) {
  238. labelRow += '</div>';
  239. inputRow += '</div>';
  240. $container.append(labelRow);
  241. $container.append(inputRow);
  242. }
  243. labelRow = '<div class="row mb-1">';
  244. inputRow = '<div class="row mb-3">';
  245. }
  246. labelRow += `
  247. <div class="col-md-4">
  248. <label><b>${assetName}</b></label>
  249. </div>
  250. `;
  251. inputRow += `
  252. <div class="col-md-4">
  253. <input type="number" class="form-control" name="assetQuantity_${assetId}" placeholder="Enter Quantity" min="0">
  254. </div>
  255. `;
  256. counter++;
  257. });
  258. // Append remaining items
  259. if (labelRow || inputRow) {
  260. labelRow += '</div>';
  261. inputRow += '</div>';
  262. $container.append(labelRow);
  263. $container.append(inputRow);
  264. }
  265. });
  266. });
  267. function handleFAssetEdit(){
  268. console.log("Button clicked");
  269. let id = $(this).data('id');
  270. console.log("id=" + id);
  271. $.ajax({
  272. type: "GET",
  273. url: "/gcc/api/gccschool/schoolproperty/getAssetMasterById",
  274. data: { assetMasterId: id,asset_id:3 },
  275. success: function (response) {
  276. if (response.status === "Success" && response.data) {
  277. let data = response.data;
  278. // Populate modal fields
  279. $('#Feditassetname').text(data.asset_name || '');
  280. //$('#Fmaster_qty').val(data.master_qty || '');
  281. $('#Fmapped_qty').val(data.mapped_qty || '');
  282. $('#Funmapped_qty').val(data.unmapped_qty || '');
  283. $('#Feditid').val(data.furniture_master_id);
  284. $('#AFmaster_qty').text(data.master_qty || '');
  285. // Show the modal
  286. $('#EditFAssetModal').modal('show');
  287. } else {
  288. Swal.fire('Error', 'Unable to fetch Furniture asset details.', 'error');
  289. }
  290. },
  291. error: function (xhr, status, error) {
  292. console.error('Error fetching Furniture asset:', error);
  293. Swal.fire('Error', 'Server error while fetching Furniture asset.', 'error');
  294. }
  295. });
  296. }
  297. function loadFAsset(schoolId) {
  298. //console.log("vvvvvvvvvv");
  299. var buttons = [
  300. {
  301. extend: 'pageLength',
  302. className: 'btn btn-warning'
  303. },
  304. {
  305. title: 'Data export',
  306. extend: 'copyHtml5',
  307. text: 'Copy',
  308. className: 'btn btn-secondary',
  309. id: 'copyBtn'
  310. },
  311. {
  312. extend: 'excelHtml5',
  313. text: 'Excel',
  314. className: 'btn btn-secondary',
  315. id: 'excelBtn',
  316. title: 'Furniture Asset List'
  317. },
  318. {
  319. extend: 'csvHtml5',
  320. text: 'CSV',
  321. className: 'btn btn-secondary',
  322. id: 'csvBtn',
  323. title: 'Furniture Asset List'
  324. },
  325. {
  326. extend: 'pdfHtml5',
  327. text: 'PDF',
  328. className: 'btn btn-secondary',
  329. id: 'pdfBtn',
  330. title: 'Furniture Asset List'
  331. },
  332. {
  333. extend: 'print',
  334. text: 'Print',
  335. className: 'btn btn-secondary',
  336. id: 'printBtn',
  337. title: 'Furniture Asset List',
  338. exportOptions: {
  339. columns: ':visible:not(.no-print)' // Exclude columns with class 'no-print' from print view
  340. }
  341. }
  342. ];
  343. $.get('/gcc/api/gccschool/schoolproperty/getAssetMaster', {school_id: schoolId,asset_id:3}, res => {
  344. if ($.fn.DataTable.isDataTable('#FAssetManageDatatable')) {
  345. $('#FAssetManageDatatable').DataTable().clear().destroy(true);
  346. }
  347. //console.log("hello");
  348. let tableData = [];
  349. if (res.status === "Success" && Array.isArray(res.data)) {
  350. //console.log("res.data="+res.data);
  351. tableData = res.data;
  352. }
  353. $('#FAssetManageDatatable').DataTable({
  354. data: tableData,
  355. columns: [
  356. {data: null, render: (d, t, r, m) => m.row + 1, className: 'text-center'},
  357. {data: 'asset_name',className: 'text-center'},
  358. {data: 'master_qty',className: 'text-center'},
  359. {
  360. data: 'mapped_qty',className: 'text-center',
  361. render: data => data != null ? data : '-'
  362. },
  363. {
  364. data: 'unmapped_qty',className: 'text-center',
  365. render: data => data != null ? data : '-'
  366. },
  367. {
  368. data: 'furniture_master_id',
  369. render: (data, t, row) => `
  370. <div class="text-center">
  371. <button class="btn btn-sm btn-success edit-btnf" data-id="${row.furniture_master_id}" ><i class="ik ik-edit-2" style="font-size:medium;margin-left:5px;"></i></button>
  372. </div>`, className: 'text-center'
  373. }
  374. ],
  375. lengthMenu: [
  376. [50, 100, 200, 500, -1],
  377. ['50 rows', '100 rows', '200 rows', '500 rows', 'Show all']
  378. ],
  379. dom: 'Bftip',
  380. //fixedColumns: {left: 0, right: 0},
  381. scrollY: '70vh',
  382. scrollX: true,
  383. autoWidth: true,
  384. paging: true,
  385. info: true,
  386. buttons: buttons,
  387. responsive: false,
  388. searching: true,
  389. select: false,
  390. processing: false,
  391. language: {
  392. emptyTable: '<span class="text-danger">No Details found</span>'
  393. }
  394. });
  395. });
  396. }
  397. function loadfsubassets(schoolId) {
  398. $.ajax({
  399. url: '/gcc/api/gccschool/dropdown/getSplSubAssetType',
  400. type: 'GET',
  401. data: { school_id:schoolId,assetid: 3 },
  402. success: function (response) {
  403. const $court = $('#FsubAssetType');
  404. $court.empty();
  405. if (response.status === 'OK' && Array.isArray(response.data)) {
  406. response.data.forEach(item => {
  407. $court.append(`<option value="${item.sub_asset_id}">${item.asset_name}</option>`);
  408. });
  409. } else {
  410. $court.append('<option value="">No Data Found</option>');
  411. }
  412. if ($court.hasClass("select2-hidden-accessible")) {
  413. $court.select2('destroy');
  414. }
  415. $court.select2({
  416. placeholder: "Select Asset",
  417. width: '100%',
  418. minimumResultsForSearch: Infinity,
  419. closeOnSelect: false
  420. });
  421. },
  422. error: function () {
  423. const $court = $('#FsubAssetType');
  424. $court.empty().append('<option value="">Error loading data</option>');
  425. if ($court.hasClass("select2-hidden-accessible")) {
  426. $court.select2('destroy');
  427. }
  428. $court.select2({
  429. placeholder: "Select Asset",
  430. width: '100%',
  431. minimumResultsForSearch: Infinity,
  432. closeOnSelect: false
  433. });
  434. alert("Something went wrong while fetching asset sub types.");
  435. }
  436. });
  437. }
  438. function handleAddFAsset(schoolId) {
  439. $('#savingcontainerf ').hide();
  440. $('#FsubAssetType').empty();
  441. $('#selectedFAssetsContainer').empty();
  442. loadfsubassets(schoolId);
  443. // Then show the modal
  444. $('#AddFAssetModal').modal('show');
  445. }
  446. function handleSaveFAsset(FAssetschoolId) {
  447. $('#savingFAsset').prop('disabled', true).text('Saving...');
  448. const selectedAssets = $('#FsubAssetType').val(); // array of selected sub_asset_id
  449. const assetData = [];
  450. if (!selectedAssets || selectedAssets.length === 0) {
  451. $('#savingFAsset').prop('disabled', false).text('Save');
  452. Swal.fire({
  453. icon: 'warning',
  454. title: 'Missing Field',
  455. text: 'Please select at least one asset.',
  456. });
  457. return;
  458. }
  459. let hasError = false;
  460. let hasZero = false;
  461. let errorAssets = [];
  462. let zeroAssets = [];
  463. selectedAssets.forEach(function (subAssetId) {
  464. const quantityInput = $(`input[name="assetQuantity_${subAssetId}"]`);
  465. const quantity = quantityInput.val();
  466. const assetName = $(`#subAssetType option[value="${subAssetId}"]`).text(); // Get asset name
  467. if (!quantity || isNaN(quantity) || parseInt(quantity) < 0) {
  468. hasError = true;
  469. errorAssets.push(assetName);
  470. } else if (parseInt(quantity) === 0) {
  471. hasZero = true;
  472. zeroAssets.push(assetName);
  473. } else {
  474. assetData.push({
  475. sub_asset_id: subAssetId,
  476. master_qty: parseInt(quantity)
  477. });
  478. }
  479. });
  480. if (hasError) {
  481. $('#savingFAsset').prop('disabled', false).text('Save');
  482. Swal.fire({
  483. icon: 'warning',
  484. title: 'Validation Error',
  485. html: `Please enter a valid quantity for the following assets:<br><b>${errorAssets.join(', ')}</b>`,
  486. });
  487. return;
  488. }
  489. if (hasZero) {
  490. $('#savingFAsset').prop('disabled', false).text('Save');
  491. Swal.fire({
  492. icon: 'warning',
  493. title: 'Zero Quantity Error',
  494. html: `You have entered 0 for the following assets:<br><b>${zeroAssets.join(', ')}</b><br>Please remove them from the selection or enter a valid quantity.`,
  495. allowOutsideClick: false,
  496. allowEscapeKey: false,
  497. showConfirmButton: true
  498. });
  499. return;
  500. }
  501. const payload = {
  502. school_id: FAssetschoolId,
  503. asset_id: "3", // electrical asset
  504. data: assetData
  505. };
  506. console.log("Final Payload to Save:", payload);
  507. $.ajax({
  508. url: '/gcc/api/gccschool/schoolproperty/saveAssetMaster',
  509. type: 'POST',
  510. contentType: 'application/json',
  511. data: JSON.stringify(payload),
  512. success: function(response) {
  513. $('#savingFAsset').prop('disabled', false).text('Save');
  514. if (response.status === 'OK') {
  515. //Swal.fire('Success', response.message, 'success');
  516. //$('#AddEAssetModal').modal('hide');
  517. Swal.fire({
  518. allowOutsideClick: false,
  519. allowEscapeKey: false,
  520. allowEnterKey: false,
  521. icon: 'success',
  522. title: 'Success',
  523. text: response.message
  524. }).then(() => {
  525. location.reload();
  526. });
  527. } else {
  528. Swal.fire('Error', response.message, 'error');
  529. }
  530. },
  531. error: function() {
  532. $('#savingFAsset').prop('disabled', false).text('Save');
  533. Swal.fire('Error', 'Something went wrong while saving assets.', 'error');
  534. }
  535. });
  536. }
  537. function handelEditFAsset(){
  538. let fmaster_qty = $('#Fmaster_qty').val();
  539. let fassetMasterId = $('#Feditid').val();
  540. console.log("fmaster_qty"+fmaster_qty);
  541. console.log("fassetMasterId"+fassetMasterId);
  542. if (!fmaster_qty || isNaN(fmaster_qty)) {
  543. Swal.fire({
  544. icon: 'warning',
  545. title: 'Invalid Quantity',
  546. text: 'Please enter a valid Master Quantity',
  547. });
  548. return;
  549. }
  550. if (!fassetMasterId || isNaN(fassetMasterId)) {
  551. Swal.fire({
  552. icon: 'warning',
  553. title: 'Missing ID',
  554. text: 'Furniture Asset ID is missing or invalid.',
  555. });
  556. return;
  557. }
  558. $.ajax({
  559. type: "POST",
  560. url: "/gcc/api/gccschool/schoolproperty/updateAssetMaster", // your endpoint
  561. data: {
  562. master_qty: parseInt(fmaster_qty),
  563. assetMasterId: parseInt(fassetMasterId),
  564. asset_id:3
  565. },
  566. success: function (response) {
  567. if (response === "Success") {
  568. Swal.fire({
  569. allowOutsideClick: false,
  570. allowEscapeKey: false,
  571. allowEnterKey: false,
  572. icon: 'success',
  573. title: 'Asset Updated',
  574. text: 'Asset Updated successfully!'
  575. }).then(() => {
  576. location.reload();
  577. });
  578. } else {
  579. Swal.fire({
  580. icon: 'error',
  581. title: 'Error',
  582. text: 'Something went wrong while updating asset.'
  583. });
  584. }
  585. },
  586. error: function (xhr, status, error) {
  587. console.error('Error updating assets:', error);
  588. Swal.fire({
  589. icon: 'error',
  590. title: 'Request Failed',
  591. text: 'Unable to send request to the server.'
  592. });
  593. }
  594. });
  595. }
  596. </script>
  597. </body>
  598. </html>