Merge branch 'dev' of bitbucket.org:jubilian/nhance into dev

This commit is contained in:
VENKATESHWARAN 2025-12-01 12:35:13 +05:30
commit 72be50bd3e
7 changed files with 393 additions and 14 deletions

View File

@ -677,6 +677,12 @@
->where('user_profiles.is_active', 1)
->findAll();
// Fetch Partner Agent
$data['partner_agent'] = db_connect()->table('partner_agent')
->where('is_active', 1)
->get()
->getResultArray();
// Fetch ACM
$data['ACM'] = $this->userModel
->where('role', 3) // Assuming `role` is in `user_profiles`

View File

@ -20,6 +20,7 @@ use App\Models\AuthHistoryModel;
use App\Models\UserActivityHistoryModel;
use App\Models\PartnerStaffModel;
use App\Models\PartnerManagerIncentiveFileModel;
use App\Models\NhanceBranchModel;
class UserController extends AdminController
@ -36,6 +37,7 @@ class UserController extends AdminController
protected $userActivityHistoryModel;
protected $partnerStaffModel;
protected $partnerManagerIncentiveFileModel;
protected $nhanceBranchModel;
public function __construct()
{
@ -51,6 +53,7 @@ class UserController extends AdminController
$this->userActivityHistoryModel = new UserActivityHistoryModel();
$this->partnerStaffModel = new PartnerStaffModel();
$this->partnerManagerIncentiveFileModel = new PartnerManagerIncentiveFileModel();
$this->nhanceBranchModel = new NhanceBranchModel();
}
public function list()
@ -63,6 +66,7 @@ class UserController extends AdminController
// print_r($data); die;
$data['roleData'] = $this->roleModel->select('id, role')->findAll();
$data['teamData'] = $this->teamModel->select('id, name')->where('is_active',1)->findAll();
$data['NHanceBranchData'] = $this->nhanceBranchModel->select('id, branch_name')->where('is_active',1)->findAll();
$this->loadLayout('UserList', $data);
}
@ -70,6 +74,7 @@ class UserController extends AdminController
public function create()
{
$this->myLogger->logme('error', 'User create function called');
dd($this->request->getPost());
$teams = $this->request->getPost('team');
//if this is get method return to user creation page

View File

@ -27,6 +27,7 @@ class UserModel extends Model
"updated_by",
"updated_at",
"is_active",
"nhance_branch_id",
];
// Dates

View File

@ -487,6 +487,18 @@ table.dataTable tbody td {
<input type="hidden" name="PrimaryKey" id="UserId"/>
<div class="form-group">
<div class="form-row">
<div class="form-group col-md-12">
<label for="nhance_branch_id">NHance Branch<span class="text-danger">*</span></label>
<select class="form-control" id="nhance_branch_id" name="nhance_branch_id" required>
<option value="">Select NHance Branch</option>
<?php foreach($NHanceBranchData as $value) { ?>
<option value="<?= $value['id'] ?>"><?= $value['branch_name'] ?></option>
<?php } ?>
</select>
</div>
</div>
<div class="form-row">
<div class="form-group col-md-6">
<label for="emp_code">Employee Code<span class="text-danger">*</span></label>
@ -850,6 +862,13 @@ table.dataTable tbody td {
var table;
$(document).ready(function () {
$('#nhance_branch_id').select2();
$('#nhance_branch_id')
.val(null) // ✅ MUST be null
.trigger('change.select2'); // ✅ correct trigger
var incentiveMonthPicker = flatpickr("#incentive_month", {
dateFormat: "Y-m-d", // real value stored (hidden)
altInput: true, // show a user-friendly display
@ -988,6 +1007,18 @@ table.dataTable tbody td {
}
});
// IMPORTANT — DataTables draw event REF: TTS
table.on('draw.dt', function () {
let rowCount = $('#scroll-horizontal-datatable').DataTable().rows({ filter: 'applied' }).count();
if (rowCount <= 2) {
$('.dataTables_scrollBody').css('overflow', 'inherit');
} else {
$('.dataTables_scrollBody').css('overflow', 'auto');
}
});
$('#team').multiselect({
@ -1027,7 +1058,8 @@ table.dataTable tbody td {
type: "GET",
dataType: 'json',
success: function (res) {
console.log(res)
console.log(":():",res);
console.log(":():",res.data.nhance_branch_id);
$('#updateModal').modal('show');
$('#role').val('')
$('#UserForm').attr('action', '<?php echo base_url('user/edit');?>');
@ -1038,6 +1070,18 @@ table.dataTable tbody td {
$('#mobile').val(res.data.mobile);
$('#emp_code').val(res.data.emp_code);
$('#role option[value="' + res.data.role + '"]').prop('selected', true);
if (res.data.nhance_branch_id !== null &&
res.data.nhance_branch_id !== "" &&
res.data.nhance_branch_id !== 0) {
$('#nhance_branch_id')
.val(res.data.nhance_branch_id)
.trigger('change.select2'); // ✅ correct trigger
} else {
$('#nhance_branch_id')
.val(null) // ✅ MUST be null
.trigger('change.select2'); // ✅ correct trigger
}
$('#btnSubmit').html('Update');
$.each(res.userTeamData, function(index, item) {
@ -1774,6 +1818,7 @@ table.dataTable tbody td {
$('#email').val('');
$('#mobile').val('');
$('#emp_code').val('');
$('#nhance_branch_id').val('0');
$('#UserForm').attr('action', '<?php echo base_url('/user/create');?>');
let myModal = new bootstrap.Modal(document.getElementById('con-close-modal'));
myModal.show(); // open modal

View File

@ -0,0 +1,319 @@
<style>
.dataTables_filter {
position: absolute;
}
.dataTables_length label {height: 21px !important;}
</style>
<!-- End ADD and EDIT Page HTML -->
<div class="row" id="List-page">
<div class="col-12">
<div class="card">
<div class="card-body maincard">
<table data-custom-table-css="table" class="table table-sm m-0 table-centered dt-responsive nowrap w-100" cellspacing="a" id="user-table">
<thead class="bg-light">
<tr>
<!-- `content` `notes` -->
<th class="font-weight-medium">S.No.</th>
<th class="font-weight-medium">Type</th>
<th class="font-weight-medium">Content Section</th>
<th class="font-weight-medium">Heading</th>
<!-- <th class="font-weight-medium">Status</th> -->
<th class="font-weight-medium">Action</th>
</tr>
</thead>
<tbody>
<?php if(isset($test)) { $slno = 1; ?>
<?php foreach($test as $index => $row) { ?>
<tr>
<td class="text-center"><?= $slno++; ?></td>
<td><?= $row['type']; ?></td>
<td><?= $row['content_section']; ?></td>
<td><?= $row['heading']; ?></td>
<!-- <td>
<span class="<?php if($row['is_active'] == 1){ echo 'badge badge-primary'; }else{ echo 'badge badge-danger'; } ?>">
<?php if($row['is_active'] == 1){ echo 'Active'; }else{ echo 'In-Active'; } ?>
</span>
</td> -->
<td>
<div class="btn-group dropdown" style="position: relative !important;left:0px !important;top:0px !important;">
<a href="javascript: void(0);" class="dropdown-toggle arrow-none btn btn-light btn-sm" data-toggle="dropdown" aria-expanded="false"><i class="mdi mdi-dots-horizontal"></i></a>
<div class="dropdown-menu dropdown-menu-right" style="cursor: pointer;">
<a class="dropdown-item" data-id="<?= $row['id']; ?>" onclick="handleSaveEditAndDelete('edit', this)">
<i class="mdi mdi-pencil mr-2 text-muted font-18 vertical-middle"></i>Edit
</a>
<?php if ($row['is_active'] == 1): ?>
<a class="dropdown-item" data-id="<?= $row['id']; ?>" onclick="handleSaveEditAndDelete('remove', this)">
<i class="mdi mdi-delete mr-2 text-muted font-18 vertical-middle"></i>Delete
</a>
<?php endif; ?>
</div>
</div>
</td>
</tr>
<?php } ?>
<?php } else { ?>
<tr>
<td colspan="3" class="text-center">No data available</td>
</tr>
<?php } ?>
</tbody>
</table>
</div>
</div>
</div>
</div>
<!-- modal content -->
<div id="con-close-modal" class="modal fade app-font-family" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true" style="display: none;" data-backdrop="static">
<div class="modal-dialog modal-dialog-centered modal-lg">
<div class="modal-content">
<div class="modal-header">
<h4 class="modal-title" id="modalLabel">Add Front End Content</h4>
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
</div>
<div class="modal-body p-4">
<form id="frontEndContentForm" enctype="multipart/form-data">
<input type="hidden" name="pk" id="fe_id"/>
<div class="form-group">
<div class="form-row">
<div class="col-md-4">
<label for="type">Type<span class="text-danger">*</span></label>
<input type="text" class="form-control" id="type" name="type" placeholder="Enter Type" required>
</div>
<div class="col-md-4">
<label for="content_section">Content Section<span class="text-danger">*</span></label>
<input type="text" class="form-control" id="content_section" name="content_section" placeholder="Enter Content Section" required>
</div>
<div class="col-md-4">
<label for="branch_name">Heading<span class="text-danger">*</span></label>
<input type="text" class="form-control" id="heading" name="heading" placeholder="Enter Heading" required>
</div>
</div>
</div>
<button type="button" class="btn app-btn-secondary waves-effect waves-light text-end" onclick="AddContentsAndNotes()">Add Contents And Notes</button>
<table>
</table>
<div class="form-group text-right m-b-0">
<button type="button" class="btn app-btn-secondary waves-effect waves-light" id="btnSubmit" onclick="handleSaveEditAndDelete('submit')">Submit</button>
</div>
</form>
</div>
</div>
</div>
</div>
<script>
var table;
$(document).ready(function () {
var ticketsTable = $('#user-table');
ticketsTable.DataTable({
scrollX: true,
// dom: "<'row'<'col-sm-7'f><'col-sm-5 text-right'B>>" + // Filter left, buttons right
// "<'row'<'col-sm-12'tr>>" +
// "<'row'<'col-sm-5'i><'col-sm-7'p>>", // Pagination at the bottom, without page length selector
dom: "<'row'<'col-sm-7'f><'col-sm-5 text-right'B>>" + // Filter left, buttons right
"<'row'<'col-sm-12'tr>>" +
"<'row align-items-center'<'col-5 text-start'i><'col-7 d-flex justify-content-end align-items-center'<'me-2'l>p>>",
lengthMenu: [[10, 20, 50, 100], [10, 20, 50, 100]],
buttons: [
{
text: 'Add',
className: 'btn app-btn-primary mr-2',
action: function(e, dt, node, config) {
openModal()
}
},
{
extend: 'collection',
text: '<span class=" btn-custom"> Export </span><i class="mdi mdi-menu-down"></i>',
className: 'btn app-btn-secondary ',
buttons: [
{
extend: 'csv',
text: '<i class="mdi mdi-file-delimited " ></i><span class=" btn-custom"> CSV </span>',
title: 'Front End Content',
className: 'app-btn-primary ',
exportOptions: {
columns: ':not(:last-child)'
},
}
]
}
],
language: {
search: `
<div class="datatable-search-wrapper" style="position:relative; display:inline-block;">
_INPUT_
<i class="mdi mdi-magnify datatable-search-icon"
style="position:absolute; right:10px; top:50%; transform:translateY(-50%); color:#666;"></i>
<i class="mdi mdi-close-circle datatable-clear-icon"
style="position:absolute; right:10px; top:50%; transform:translateY(-50%); color:#666; display:none;"></i>
</div>`,
searchPlaceholder: "Search",
emptyTable: '<div class="text-center text-muted">No Data found</div>'
},
paging: true, // Enable pagination
pageLength: 10, // Set default number of rows per page (optional)
// ordering: false,
});
});
$('.close').click(function(){
resetValues()
})
function openModal(){
var myModal = new bootstrap.Modal(document.getElementById('con-close-modal'));
myModal.show();
}
// old Version
// function handleSaveEditAndDelete(type = 'submit', pk = null){
// let url = '<?= base_url('util/nhanceBranchMaster') ?>';
// let method = "POST";
// let requestData = {};
// $('#modalLabel').text('Add Front End Content');
// requestData.pk = pk;
// if(type == 'submit'){
// $("#frontEndContentForm").find("input, select, textarea").each(function () {
// let name = $(this).attr("name");
// let value = $.trim($(this).val());
// if (name) requestData[name] = value;
// });
// }
// if(type == 'remove'){
// method = "DELETE";
// }else if (type == 'edit'){
// method = "GET"
// }
// console.log("type", type)
// console.log("url", url)
// console.log("method", method)
// console.log("requestData", requestData)
// $('.loader').fadeIn();
// $('.loader-mask').fadeIn();
// // Send AJAX request
// sendAjaxRequestForGlobal(url, method, requestData, function(response) {
// console.log('Data fetched successfully:', response);
// if (response.status) {
// if(type == 'edit'){
// $('#modalLabel').text('Edit Front End Content');
// appendEditData(response.data);
// }else{
// toastr.success(response.message, 'SUCCESS');
// }
// } else {
// toastr.warning(response.message, 'WARNING');
// }
// $('.loader').fadeOut();
// $('.loader-mask').delay(350).fadeOut('slow');
// }, function(xhr, status, error) {
// console.error('Error fetching data:', error);
// console.error(xhr.responseText);
// $('.loader').fadeOut();
// $('.loader-mask').delay(350).fadeOut('slow');
// });
// }
function handleSaveEditAndDelete(type = 'submit', el = null) {
let url = '<?= base_url('util/nhanceBranchMaster') ?>';
let method = "POST";
let requestData = {};
let pk = null;
// If element is passed (from edit/remove button), get its data-id
if (el) { pk = $(el).data('id'); }
requestData.pk = pk;
if(type == 'submit'){
$("#frontEndContentForm").find("input, select, textarea").each(function () {
let name = $(this).attr("name");
let value = $.trim($(this).val());
if (name) requestData[name] = value;
});
}
if(type == 'remove'){
method = "DELETE";
} else if (type == 'edit'){
method = "GET";
$('#modalLabel').text('Edit Front End Content');
$('#frontEndContentForm')[0].reset();
}
console.log("type", type)
console.log("url", url)
console.log("method", method)
console.log("requestData", requestData)
$('.loader').fadeIn();
$('.loader-mask').fadeIn();
// Send AJAX request
sendAjaxRequestForGlobal(url, method, requestData, function(response) {
console.log('Data fetched successfully:', response);
if (response.status) {
if(type == 'edit'){
appendEditData(response.data);
} else if(type == 'remove'){
toastr.success(response.message, 'Success');
if(el) $(el).closest('tr').remove();
window.location.reload();
} else if(type == 'submit'){
toastr.success(response.message, 'Success');
var myModal = new bootstrap.Modal(document.getElementById('con-close-modal'));
myModal.hide();
$('#frontEndContentForm')[0].reset();
window.location.reload();
}
} else {
toastr.warning(response.message, 'Warning');
}
$('.loader').fadeOut();
$('.loader-mask').delay(350).fadeOut('slow');
}, function(xhr, status, error) {
console.error('Error fetching data:', error);
console.error(xhr.responseText);
$('.loader').fadeOut();
$('.loader-mask').delay(350).fadeOut('slow');
});
}
function resetValues(){
$('#modalLabel').text('Add Front End Content');
$('#frontEndContentForm')[0].reset();
}
function appendEditData(data){
$('#fe_id').val(data[0]['id']);
$('#branch_name').val(data[0]['branch_name']);
openModal()
}
</script>

View File

@ -317,7 +317,7 @@ table.dataTable tbody td {
<tr>
<td class="text-center"><?php echo $index+1; ?></td>
<td><?php echo $issuer[$row['issuer']]; ?></td>
<td><?php echo $issuing_type[$row['issue_type']] ?: 'N/A'; ?></td>
<td><?php echo $issuing_type[$row['issue_type']] ?? 'N/A'; ?></td>
<td><?php echo $client_type[$row['client_type']] ?? 'N/A'; ?></td>
<td><?php echo $row['client_type'] == 2 ? $row['client_name'] . " - " . (!empty($row['pan']) ? $row['pan'] : 'N/A') : $row['client_short_name'] . ' - ' . $row['client_branch_name']; ?></td>
<td><?php echo $row['insurer_short_name'] ?: 'N/A'; ?></td>
@ -328,7 +328,7 @@ table.dataTable tbody td {
<td><?php echo empty($row['policy_issue_date']) ? 'N/A' : date('d/m/Y', strtotime($row['policy_end_date'])); ?></td>
<td class="right-align-input"><?php echo $row['emp_count'] ?: '0'; ?></td>
<td class="right-align-input"><?php echo $row['dependent_count'] ?: '0'; ?></td>
<td><?php echo $policy_status[$row['status']] ?: 'N/A'; ?></td>
<td><?php echo $policy_status[$row['status']] ?? 'N/A'; ?></td>
<td><?php echo $row['user_name'] ?: 'N/A'; ?></td>
<td>
<div class="btn-group dropdown">

View File

@ -1,20 +1,20 @@
<style>
/** CSS changes are not applying on the Client Onboarding screen . so i implement this CSS fixes . */
.modal-dialog {
/* #New_Ticket_modal .modal-dialog {
max-width: 500px !important;
margin: 1.75rem auto !important;
}
@media (min-width: 576px) {
.modal-dialog {
max-width: 500px;
margin: 1.75rem auto;
#New_Ticket_modal .modal-dialog {
max-width: 500px !important;
margin: 1.75rem auto !important;
}
}
} */
</style>
<div class="modal fade" id="New_Ticket_modal" tabindex="-1" role="dialog" aria-hidden="true">
<div class="modal-dialog modal-dialog-centered">
<div class="modal-content" style="height: 200px !important;">
<div class="modal-content"> <!-- style="height: 200px !important;" -->
<div class="modal-header">
<h4 class="modal-title" id="myCenterModalLabel"></h4>
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
@ -32,12 +32,15 @@
</select>
</div>
</div>
<div class="form-row">
<div class="form-group col-md-12 text-right">
<!-- <div class="form-group col-md-12 text-end"> -->
<!--
<div class="form-row">
<div class="form-group col-md-12 text-right"><!- text-end ->
<button type="button" class="btn btn-primary mt-1" onclick="submitToRedirectTicketNewUrl(this)">Submit</button>
</div>
</div>
</div>-->
</div>
<div class="modal-footer">
<button type="button" class="btn btn-primary" onclick="submitToRedirectTicketNewUrl(this)">Submit</button>
</div>
</div>
</div>