FIX_UI_support_Search_with_icon
This commit is contained in:
parent
291037fdaa
commit
5bcab5b7a5
@ -452,6 +452,58 @@ if (isset($selected_lead_type)) {
|
|||||||
$('#salse_person_id').trigger('change');
|
$('#salse_person_id').trigger('change');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// $('#client_name').on('input', generateShortName);
|
||||||
|
|
||||||
|
let shortNameTimer;
|
||||||
|
|
||||||
|
$('#client_name').on('input', function() {
|
||||||
|
clearTimeout(shortNameTimer);
|
||||||
|
shortNameTimer = setTimeout(generateShortName, 200);
|
||||||
|
});
|
||||||
|
|
||||||
|
function generateShortName() {
|
||||||
|
let clientInput = $("#client_name");
|
||||||
|
let shortInput = $("#client_short_name");
|
||||||
|
let newClientName = clientInput.val().trim();
|
||||||
|
|
||||||
|
console.log(`LN : NEW - ${newClientName}`);
|
||||||
|
if (newClientName.length == 0) {
|
||||||
|
shortInput.val('');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
let shortName = newClientName.substring(0, 10).replace(/\s+/g, '').toUpperCase();
|
||||||
|
makeUniqueShortName(shortName);
|
||||||
|
}
|
||||||
|
|
||||||
|
function makeUniqueShortName(baseName) {
|
||||||
|
let input = $("#client_short_name")[0];
|
||||||
|
|
||||||
|
checkDuplicateTableFieldValue("clients", "short_name", baseName, function(isDuplicate) {
|
||||||
|
if (isDuplicate) {
|
||||||
|
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();
|
||||||
|
} else {
|
||||||
|
$("#client_short_name").val(newName);
|
||||||
|
validateInput(input, "clients", "short_name");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
tryNext();
|
||||||
|
} else {
|
||||||
|
$("#client_short_name").val(baseName);
|
||||||
|
validateInput(input, "clients", "short_name");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
function validateInput(input, table, field){
|
function validateInput(input, table, field){
|
||||||
|
|
||||||
let client_type = $('#client_type').val();
|
let client_type = $('#client_type').val();
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user