From 1fb60aece4711850d86681f79834cfa77066c90d Mon Sep 17 00:00:00 2001 From: venba-Inspriron-3558 Date: Wed, 8 Oct 2025 18:25:13 +0530 Subject: [PATCH] FIX_Minor issues --- app/Views/client_basic_info.php | 3 +- app/Views/client_branch.php | 77 +++++++++++++++++++++++++++++++++ app/Views/client_list.php | 61 +++++++++++++------------- app/Views/client_onboarding.php | 5 ++- app/Views/client_policy.php | 3 +- 5 files changed, 115 insertions(+), 34 deletions(-) diff --git a/app/Views/client_basic_info.php b/app/Views/client_basic_info.php index f43c65ee..0af82f51 100755 --- a/app/Views/client_basic_info.php +++ b/app/Views/client_basic_info.php @@ -110,13 +110,14 @@ input:checked + .slider:before {
-
diff --git a/app/Views/client_branch.php b/app/Views/client_branch.php index 940cf017..038e9740 100755 --- a/app/Views/client_branch.php +++ b/app/Views/client_branch.php @@ -862,6 +862,83 @@ function checkMobileNumber(input) { } +// function generateShortName() { +// let clientName = $("#client_name").val().trim(); +// if (clientName.length > 0) { +// let shortName = clientName.substring(0, 10).replace(/\s+/g, '').toUpperCase(); // Take first 10 chars , space removed, converted caps +// $("#short_name").val(shortName); +// makeUniqueShortName(shortName); +// }else{ +// $("#short_name").val(''); +// } +// } + +let shortNameTimer; + +$("#client_name").on("input change keyup", function() { + clearTimeout(shortNameTimer); // cancel previous call + shortNameTimer = setTimeout(() => { + generateShortName(); // only runs after 200ms pause + }, 200); // adjust debounce delay as needed +}); + +function generateShortName() { + let clientInput = $("#client_name"); + let shortInput = $("#short_name"); + + let oldClientName = clientInput.data("old-name"); // from DB + let oldShortName = shortInput.data("old-short"); // from DB + let newClientName = clientInput.val().trim(); + console.log(`LN 882 : NEW - ${newClientName} | OLD - ${oldClientName} | OLD SN - ${oldShortName}`); + + if (newClientName.toUpperCase() === (oldClientName || '').toUpperCase()) { + shortInput.val(oldShortName); + return; + } + + if (newClientName.length == 0) { + shortInput.val(''); + return; + } + + if (newClientName.length > 0) { + let shortName = newClientName.substring(0, 10).replace(/\s+/g, '').toUpperCase(); + shortInput.val(shortName); + makeUniqueShortName(shortName); + } +} + + + +function makeUniqueShortName(baseName) { + let input = $("#short_name")[0]; // input element + checkDuplicateTableFieldValue("clients", "short_name", baseName, function(isDuplicate) { + if (isDuplicate) { + // Append sequence until unique + let counter = 1; + function tryNext() { + let padded = String(counter).padStart(3, '0'); // 001, 002, 003 + let newName = baseName + padded; + + checkDuplicateTableFieldValue("clients", "short_name", newName, function(exists) { + if (exists) { + counter++; + tryNext(); // keep checking + } else { + $("#short_name").val(newName); + validateInput(input, "clients", "short_name", "clientBtnSubmit"); + } + }); + } + tryNext(); + } else { + $("#short_name").val(baseName); + validateInput(input, "clients", "short_name", "clientBtnSubmit"); + } + }); +} + + function validateInput(input, table, field, submitButId){ let value = $(input).val(); diff --git a/app/Views/client_list.php b/app/Views/client_list.php index 4d7039b6..237c2752 100755 --- a/app/Views/client_list.php +++ b/app/Views/client_list.php @@ -326,6 +326,11 @@ $(document).ready(function() extend: 'csv', text: ' CSV ', title: 'Client-List', + // title: function() { + // return $('#toggleButtons').is(':checked') + // ? 'GC-Client-List' + // : 'RC-Client-List'; + // }, className: 'app-btn-primary ', exportOptions: { columns: ':not(:last-child)' @@ -357,43 +362,39 @@ $(document).ready(function() $(".datatable-buttons").prepend(` - + `); - $("#toggleButtons").prop("checked", true); // default checked. - $('#toggleButtons').on('change', function() { - if ($(this).is(':checked')) { - console.log("Checked na gro"); - loadTableData(1); - } else { - console.log("UnChecked na indi"); - loadTableData(2); - } - }); + $('#toggleButtons').on('change', function() { + let type = $(this).is(':checked') ? 1 : 2; + // $('div.col-6 h4').text( + // $(this).is(':checked') + // ? "GC Client List" + // : "RC Client List" + // ); + let url = '' + type; + + $.ajax({ + url: url, + method: 'GET', + success: function(response) { + if (response.status === "success" && Array.isArray(response.data)) { + renderRows(response.data); + } else { + renderRows([]); + } + }, + error: function(xhr, status, error) { + console.error("Error loading:", error); + renderRows([]); + } + }); + }); }) - function loadTableData(type) { - let url = '' + type - $.ajax({ - url: url, - method: 'GET', - success: function(response) { - if (response.status === "success" && Array.isArray(response.data)) { - renderRows(response.data); - } else { - renderRows([]); - } - }, - error: function(xhr, status, error) { - console.error("Error loading :", error); - renderRows([]); - } - }); - } - function renderRows(data) { table.clear(); if (Array.isArray(data) && data.length) { diff --git a/app/Views/client_onboarding.php b/app/Views/client_onboarding.php index e5da1242..567fc409 100755 --- a/app/Views/client_onboarding.php +++ b/app/Views/client_onboarding.php @@ -332,7 +332,8 @@