FIX_Minor issues
This commit is contained in:
parent
03608dbda4
commit
1fb60aece4
@ -110,13 +110,14 @@ input:checked + .slider:before {
|
||||
<div class="form-group col-md-4">
|
||||
<label for="client_name">Client Name<span
|
||||
class="text-danger">*</span></label>
|
||||
<input type="text" class="form-control" id="client_name"
|
||||
<input type="text" class="form-control" id="client_name" data-old-name="<?= isset($client['client_name']) ? $client['client_name'] : '' ?>"
|
||||
placeholder="Enter Client Name" value="<?= isset($client['client_name']) ? $client['client_name'] : '' ?>" name="client_name" required>
|
||||
</div>
|
||||
<div class="form-group col-md-4">
|
||||
<label for="short_name">Client Short Name<span
|
||||
class="text-danger">*</span></label>
|
||||
<input type="text" class="form-control" id="short_name"
|
||||
data-old-short="<?= isset($client['short_name']) ? $client['short_name'] : '' ?>"
|
||||
placeholder="Enter Short Name" value="<?= isset($client['short_name']) ? $client['short_name'] : '' ?>" name="short_name" onkeyup="validateInput(this, 'clients', 'short_name', 'clientBtnSubmit')" required>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@ -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();
|
||||
|
||||
@ -326,6 +326,11 @@ $(document).ready(function()
|
||||
extend: 'csv',
|
||||
text: '<i class="mdi mdi-file-delimited " ></i><span class=" btn-custom"> CSV </span>',
|
||||
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(`
|
||||
<span id="statusSwitchWrapper" class="dt-switch-wrapper">
|
||||
<span class="custom-switch" style="text-align: left;">
|
||||
<input type="checkbox" class="custom-control-input" id="toggleButtons">
|
||||
<input type="checkbox" class="custom-control-input" id="toggleButtons" checked>
|
||||
<label class="custom-control-label" for="toggleButtons" style="vertical-align: middle !important;">Group Client</label>
|
||||
</span>
|
||||
</span>
|
||||
`);
|
||||
$("#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 = '<?= base_url('client/typeList/') ?>' + 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 = '<?= base_url('client/typeList/') ?>' + 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) {
|
||||
|
||||
@ -332,7 +332,8 @@
|
||||
<li class="nav-item">
|
||||
<a href="#hr-access-tab" data-toggle="tab" aria-expanded="false" class="nav-link px-3 py-2" id="hr_access_tab" onclick="appendHrAccessControllHtml(this)">
|
||||
<span class="mr-1"><i class="mdi mdi-book-open-page-variant"></i></span>
|
||||
<span class="d-none d-sm-inline-block">HR Access Control</span>
|
||||
<span class="d-none d-sm-inline-block">Client Access Control</span>
|
||||
<!-- Name Changed "HR Access Controll" into "Client Access Control" -->
|
||||
</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
@ -563,7 +564,7 @@
|
||||
client_notification();
|
||||
});
|
||||
|
||||
//HR Access Controll
|
||||
//HR Access Controll also know as "Client Access Control"
|
||||
function appendHrAccessControllHtml(input) {
|
||||
console.log(input.id);
|
||||
let client_id = $('#general_PrimaryKey').val();
|
||||
|
||||
@ -200,7 +200,8 @@
|
||||
<span class="slider round" style="height: 27px;"></span>
|
||||
</label>
|
||||
|
||||
<label for="policy_visibility" style="position: relative;bottom: 5px;left: 85px;">Policy Visibilty in Enrollment App</label>
|
||||
<!-- <label for="policy_visibility" style="position: relative;bottom: 5px;left: 85px;">Policy Visibilty in Enrollment App</label> -->
|
||||
<label for="policy_visibility" style="position: relative;bottom: 5px;left: 85px;">Policy Visibilty in Employee App</label>
|
||||
</div>
|
||||
|
||||
<div class="form-group col-md-4 EB">
|
||||
|
||||
Loading…
Reference in New Issue
Block a user