1786 lines
75 KiB
PHP
Executable File
1786 lines
75 KiB
PHP
Executable File
<!-- <style>
|
||
body {
|
||
.multiselect-native-select {
|
||
position: relative;
|
||
/* bottom: 32px; */
|
||
select {
|
||
border: 0 !important;
|
||
clip: rect(0 0 0 0) !important;
|
||
height: 1px !important;
|
||
margin: -1px -1px -1px -3px !important;
|
||
overflow: hidden !important;
|
||
padding: 0 !important;
|
||
position: absolute !important;
|
||
width: 1px !important;
|
||
left: 50%;
|
||
top: 30px;
|
||
}
|
||
}
|
||
|
||
.multiselect-container{
|
||
width: 100% !important;
|
||
}
|
||
|
||
.multiselect-selected-text{
|
||
float: left !important;
|
||
}
|
||
}
|
||
|
||
.table th,
|
||
.table td {
|
||
padding: 8px;
|
||
}
|
||
|
||
table.dataTable tbody td {
|
||
padding: 4px 4px !important;
|
||
}
|
||
</style> -->
|
||
|
||
<style>
|
||
/* body {
|
||
font-family: Arial, sans-serif;
|
||
padding: 20px;
|
||
} */
|
||
|
||
#mobile::placeholder,
|
||
#mobile_no::placeholder {
|
||
font-size: 13px;
|
||
}
|
||
|
||
.custom-select{
|
||
border-radius: 10px !important ;
|
||
background-color: #ECECEC !important ;
|
||
box-shadow: 0px 2px 4px 0px #00000024 !important;
|
||
}
|
||
|
||
.multiselect-native-select {
|
||
position: relative;
|
||
}
|
||
|
||
.multiselect-native-select select {
|
||
border: 0 !important;
|
||
clip: rect(0 0 0 0) !important;
|
||
height: 1px !important;
|
||
margin: -1px -1px -1px -3px !important;
|
||
overflow: hidden !important;
|
||
padding: 0 !important;
|
||
position: absolute !important;
|
||
width: 1px !important;
|
||
left: 50%;
|
||
top: 30px;
|
||
}
|
||
|
||
.multiselect-container {
|
||
width: 100% !important;
|
||
}
|
||
|
||
.multiselect-selected-text {
|
||
float: left !important;
|
||
}
|
||
|
||
.table th,
|
||
.table td {
|
||
padding: 8px;
|
||
}
|
||
|
||
table.dataTable tbody td {
|
||
padding: 4px 4px !important;
|
||
}
|
||
|
||
/* Tooltip Styles */
|
||
.tooltip-trigger {
|
||
color: #007bff;
|
||
cursor: pointer;
|
||
font-size: 16px;
|
||
display: inline-block;
|
||
}
|
||
|
||
.tooltip-trigger:hover {
|
||
color: #0056b3;
|
||
}
|
||
|
||
.tooltip-container {
|
||
position: fixed;
|
||
top: 0;
|
||
left: 0;
|
||
pointer-events: none;
|
||
z-index: 9999;
|
||
}
|
||
|
||
|
||
.tooltip {
|
||
visibility: hidden;
|
||
opacity: 0;
|
||
position: absolute;
|
||
background-color: white;
|
||
border: 1px solid #ddd;
|
||
border-radius: 8px;
|
||
box-shadow: 0 4px 12px rgba(0,0,0,0.15);
|
||
padding: 15px;
|
||
transition: opacity 0.3s, visibility 0.3s;
|
||
max-width: 600px;
|
||
min-width: 500px;
|
||
max-height: 600px; /* Limits height */
|
||
overflow-y: auto; /* Enables scrolling */
|
||
pointer-events: auto;
|
||
}
|
||
|
||
/* Optional: Custom scrollbar styling */
|
||
.tooltip::-webkit-scrollbar {
|
||
width: 8px;
|
||
}
|
||
|
||
.tooltip::-webkit-scrollbar-track {
|
||
background: #f1f1f1;
|
||
border-radius: 4px;
|
||
}
|
||
|
||
.tooltip::-webkit-scrollbar-thumb {
|
||
background: #c1c1c1;
|
||
border-radius: 4px;
|
||
}
|
||
|
||
.tooltip::-webkit-scrollbar-thumb:hover {
|
||
background: #a8a8a8;
|
||
}
|
||
|
||
/* .tooltip {
|
||
visibility: hidden;
|
||
opacity: 0;
|
||
position: absolute;
|
||
background-color: white;
|
||
border: 1px solid #ddd;
|
||
border-radius: 8px;
|
||
box-shadow: 0 4px 12px rgba(0,0,0,0.15);
|
||
padding: 15px;
|
||
transition: opacity 0.3s, visibility 0.3s;
|
||
max-width: 600px;
|
||
min-width: 500px;
|
||
pointer-events: auto;
|
||
} */
|
||
|
||
.tooltip::after {
|
||
content: "";
|
||
position: absolute;
|
||
border-width: 5px;
|
||
border-style: solid;
|
||
}
|
||
|
||
.tooltip.show {
|
||
visibility: visible;
|
||
opacity: 1;
|
||
}
|
||
|
||
.tooltip-table {
|
||
width: 100%;
|
||
border-collapse: collapse;
|
||
font-size: 12px;
|
||
margin: 0;
|
||
}
|
||
|
||
.tooltip-table th {
|
||
background-color: #f8f9fa;
|
||
font-weight: bold;
|
||
padding: 8px;
|
||
border: 1px solid #dee2e6;
|
||
text-align: left;
|
||
font-size: 11px;
|
||
}
|
||
|
||
.tooltip-table td {
|
||
padding: 6px 8px;
|
||
border: 1px solid #dee2e6;
|
||
vertical-align: top;
|
||
font-size: 11px;
|
||
line-height: 1.3;
|
||
}
|
||
|
||
.tooltip-table tbody tr:nth-child(even) {
|
||
background-color: #f8f9fa;
|
||
}
|
||
|
||
.tooltip-table tbody tr:hover {
|
||
background-color: #e3f2fd;
|
||
}
|
||
|
||
.team-cell {
|
||
font-weight: bold;
|
||
background-color: #e7f3ff !important;
|
||
}
|
||
|
||
/* Form styling for demo */
|
||
.form-group {
|
||
margin-bottom: 1rem;
|
||
}
|
||
|
||
.form-control {
|
||
display: block;
|
||
width: 100%;
|
||
padding: 0.375rem 0.75rem;
|
||
font-size: 1rem;
|
||
line-height: 1.5;
|
||
color: #495057;
|
||
background-color: #fff;
|
||
border: 1px solid #ced4da;
|
||
border-radius: 0.25rem;
|
||
}
|
||
|
||
label {
|
||
display: inline-block;
|
||
margin-bottom: 0.5rem;
|
||
font-weight: 600;
|
||
}
|
||
|
||
.text-danger {
|
||
color: #dc3545;
|
||
}
|
||
|
||
.btn-color{
|
||
background-color: rgba(52, 174, 178, 1);
|
||
color: white;
|
||
border:1px solid rgba(52, 174, 178, 1);
|
||
}
|
||
|
||
.btn-color:hover{
|
||
background-color: rgba(41, 139, 142, 1);
|
||
color: white;
|
||
border:1px solid rgba(41, 139, 142, 1);
|
||
}
|
||
|
||
.dt-buttons.btn-group{
|
||
display: grid;
|
||
grid-template-columns: 1fr .4fr .5fr .2fr;
|
||
}
|
||
|
||
#user-table_filter input{ width:100%; }
|
||
|
||
button.dt-button,
|
||
button.dt-button:focus,
|
||
button.dt-button:active,
|
||
button.dt-button:hover {
|
||
background: none !important;
|
||
border: none !important;
|
||
box-shadow: none !important;
|
||
padding: 0 !important;
|
||
margin: 0 !important;
|
||
}
|
||
|
||
|
||
/* main button wrapper */
|
||
.tab-button {
|
||
width: 201px;
|
||
height: 37px;
|
||
border-radius: 10px !important;
|
||
font-weight: 700;
|
||
font-size: 14px;
|
||
line-height: 100%;
|
||
border: 1px solid #BAF1F3;
|
||
background: #F5FFFF;
|
||
cursor: pointer;
|
||
transition: all 0.2s ease-in-out;
|
||
display: flex;
|
||
justify-content: center;
|
||
align-items: center;
|
||
gap: 6px;
|
||
}
|
||
|
||
/* divider style */
|
||
.divider-line {
|
||
color: #DBDBDB;
|
||
font-weight: 400;
|
||
}
|
||
|
||
/* active state */
|
||
.highlight-link.active {
|
||
color: #00999E;
|
||
}
|
||
|
||
/* inactive state */
|
||
.highlight-link:not(.active) {
|
||
color: #707070;
|
||
}
|
||
|
||
.no-files-message {
|
||
width: 900px;
|
||
height: 300px;
|
||
background: #ECECEC;
|
||
opacity: 1;
|
||
|
||
display: flex;
|
||
align-items: center;
|
||
justify-content: center;
|
||
|
||
font-weight: 500; /* Medium */
|
||
font-size: 18px;
|
||
line-height: 100%;
|
||
letter-spacing: 0;
|
||
color: #333; /* Adjust text color if needed */
|
||
text-align: center;
|
||
|
||
border-radius: 8px; /* optional for smooth edges */
|
||
margin: 13px; /* center horizontally */
|
||
}
|
||
|
||
#container {
|
||
max-height: 400px; /* set fixed height */
|
||
overflow-y: auto; /* enable vertical scroll */
|
||
overflow-x: hidden; /* prevent horizontal scroll */
|
||
}
|
||
|
||
|
||
.file-icon-box {
|
||
/* width: 40px;
|
||
height: 50px;
|
||
display: flex;
|
||
align-items: center;
|
||
justify-content: center; */
|
||
border-radius: 10px;
|
||
background: #F4F6F8;
|
||
border: 1px solid #ddd; /* matches border-width:1px */
|
||
padding: 3px;
|
||
}
|
||
|
||
</style>
|
||
|
||
<?php
|
||
|
||
$session = \Config\Services::session();
|
||
$currentLogInRole = $session->get()['userData']->role;
|
||
|
||
|
||
?>
|
||
|
||
<!-- End ADD and EDIT Page HTML -->
|
||
<div class="row" id="List-page">
|
||
<div class="col-12">
|
||
<div class="card">
|
||
<div class="card-body maincard">
|
||
<!-- <div class="row" style="margin-bottom:1rem;">
|
||
<div class="col-6" style="align-self: center;">
|
||
<h4 style="position: relative;">Users</h4>
|
||
</div>
|
||
</div> -->
|
||
<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>
|
||
<th class="font-weight-medium">Name</th>
|
||
<th class="font-weight-medium">Email</th>
|
||
<th class="font-weight-medium">Mobile No</th>
|
||
<th class="font-weight-medium">Role</th>
|
||
<th class="font-weight-medium">Status</th>
|
||
<th class="font-weight-medium">Action</th>
|
||
</tr>
|
||
</thead>
|
||
<tbody>
|
||
<?php foreach($UserList as $row) { ?>
|
||
<tr id="<?php echo $row->id;?>">
|
||
<td class="text-dark"><?php echo $row->first_name; ?></td>
|
||
<td><?php echo $row->email; ?></td>
|
||
<td><?php echo $row->mobile; ?></td>
|
||
<td><?php echo $row->user_role; ?></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 data-toggle="modal" data-target="#con-close-modal" class="dropdown-item btnEdit" data-id="<?php echo $row->id; ?>"><i data-id="<?php echo $row->id; ?>" class="mdi mdi-pencil mr-2 text-muted font-18 vertical-middle btnEdit"></i>Edit</a>
|
||
<a class="dropdown-item btnDelete" data-id="<?php echo $row->id; ?>"><i data-id="<?php echo $row->id; ?>" class="mdi mdi-delete mr-2 text-muted font-18 vertical-middle btnDelete"></i>Delete</a>
|
||
</div>
|
||
</div>
|
||
</td>
|
||
</tr>
|
||
<?php } ?>
|
||
</tbody>
|
||
|
||
</table>
|
||
<!-- <table data-custom-table-css="table" id="scroll-horizontal-datatable" class="table w-100 nowrap text-custom-black text-custom app-datatable">
|
||
<thead class="bg-light">
|
||
<tr>
|
||
<th>Ticket ID</th>
|
||
<th class="text-left">Name</th>
|
||
<th>Policy Number</th>
|
||
<th>Ticket Type</th>
|
||
<th>Subject</th>
|
||
<th>Status</th>
|
||
<th class="text-left">Assign To</th>
|
||
<th>Created At</th>
|
||
<th>Updated At</th>
|
||
</tr>
|
||
</thead>
|
||
<tbody class="app-table-body">
|
||
<?php if (isset($ticket_data)) { ?>
|
||
<?php foreach($ticket_data as $index => $row){ ?>
|
||
|
||
<tr data-id="<?= $row['thz_id']; ?>" style="cursor: pointer;">
|
||
<td class="text-right"><?php echo $row['thz_id']; ?></td>
|
||
<td class="text-left">
|
||
<?php echo $row['name']; ?>
|
||
<span class="text-custom-grey"><?php if (!empty($row['empcode'])): echo '('.$row['empcode'].')'; endif; ?></span><br>
|
||
<span class="text-custom-grey"><?php if (!empty($row['mobile'])): echo $row['mobile']; endif; ?></span>
|
||
</td>
|
||
<td class="text-center"><?php echo (!empty($row['policy_no']) && strtolower($row['policy_no']) !== 'null')
|
||
? $row['policy_no']
|
||
: 'N/A'; ?>
|
||
</td>
|
||
<td class="text-center"><?php echo $row['ticket_type'] ? $row['ticket_type'] : '-'; ?></td>
|
||
<td class="text-center wrap" title="<?php echo htmlspecialchars($row['subject']); ?>">
|
||
<?php
|
||
$subject = $row['subject'] ? $row['subject'] : 'N/A';
|
||
echo (strlen($subject) > 50)
|
||
? htmlspecialchars(substr($subject, 0, 50)) . "..."
|
||
: htmlspecialchars($subject);
|
||
?>
|
||
</td>
|
||
<td class="text-center"><?php echo $row['status'] ? $row['status'] : '-' ; ?></td>
|
||
<td class="text-left"><?php echo $row['assignee_name'] ? $row['assignee_name'] : '-'; ?></td>
|
||
<td class="text-left">
|
||
<?php if (!empty($row['created_at'])):
|
||
$cd = date("j F Y", strtotime($row['created_at']));
|
||
$ct = date("h:i a", strtotime($row['created_at']));
|
||
echo $cd . "<br><span class='time'> " . $ct . "</span>";
|
||
endif;
|
||
?>
|
||
</td>
|
||
<td class="text-left">
|
||
<?php if (!empty($row['updated_at'])):
|
||
$ud = date("j F Y", strtotime($row['updated_at']));
|
||
$ut = date("h:i a", strtotime($row['updated_at']));
|
||
echo $ud . "<br><span class='time'> " . $ut . "</span>";
|
||
endif;
|
||
?>
|
||
</td>
|
||
</tr>
|
||
<?php } ?>
|
||
<?php } ?>
|
||
</tbody> -->
|
||
</table>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
<!-- end col -->
|
||
</div>
|
||
<!-- end row-->
|
||
|
||
|
||
|
||
<!-- 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">Add User</h4>
|
||
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
|
||
</div>
|
||
|
||
<div class="modal-body p-4">
|
||
<div class="">
|
||
|
||
<form role="form" class="parsley-examples" method="post" id="UserForm" action="" enctype="multipart/form-data">
|
||
<input type="hidden" value="<?= csrf_hash() ?>" name="<?= csrf_token() ?>"/>
|
||
<input type="hidden" name="PrimaryKey" id="UserId"/>
|
||
<div class="form-group">
|
||
|
||
<div class="form-row">
|
||
<div class="form-group col-md-6">
|
||
<label for="emp_code">Employee Code<span class="text-danger">*</span></label>
|
||
<input type="text" class="form-control" id="emp_code" placeholder="Enter Code" name="emp_code" required>
|
||
</div>
|
||
<div class="form-group col-md-6">
|
||
<label for="first_name">Name<span class="text-danger">*</span></label>
|
||
<input type="text" class="form-control" id="first_name" placeholder="Ente Name" name="first_name" required>
|
||
</div>
|
||
</div>
|
||
|
||
|
||
<div class="form-row">
|
||
<div class="form-group col-md-6">
|
||
<label for="email">Email<span class="text-danger">*</span></label>
|
||
<input type="text" class="form-control" id="email" placeholder="Enter Email" name="email" data-parsley-trigger="change" data-parsley-type="email" required>
|
||
</div>
|
||
|
||
<div class="form-group col-md-6">
|
||
<label for="mobile">Mobile Number<span class="text-danger">*</span></label>
|
||
<input type="text" class="form-control" id="mobile" placeholder="Enter Mobile Number ( starting with 6, 7, 8, or 9 only. )" name="mobile" onkeypress = "return onlyNumbers(event)" maxlength="10" minlength="10" pattern="^[6-9]\d{9}$" data-parsley-type-message="Please enter a valid 10-digit mobile number starting with 6, 7, 8, or 9." data-parsley-required-message="Please enter a valid 10-digit mobile number starting with 6, 7, 8, or 9." required>
|
||
</div>
|
||
</div>
|
||
|
||
|
||
<div class="form-row">
|
||
<div class="form-group col-md-6">
|
||
<label for="emp_code">User Role<span class="text-danger">*</span>
|
||
<span class="tooltip-trigger mdi mdi-information-outline" id="roleAccessMatrixTrigger"></span>
|
||
</label>
|
||
<select class="form-control" id="role" name="role" required>
|
||
<option value="">Select Role</option>
|
||
|
||
<?php foreach($roleData as $value) {
|
||
|
||
// $headRoleValue = $value['id']??"";
|
||
|
||
// // we are showing head role only to head's who logged in
|
||
// if($headRoleValue == "5" && $currentLogInRole != "5" ){
|
||
// continue;
|
||
// }
|
||
|
||
?>
|
||
<option value="<?= $value['id'] ?>"><?= $value['role'] ?></option>
|
||
<?php } ?>
|
||
</select>
|
||
</div>
|
||
|
||
<div class="form-group col-md-6">
|
||
<label for="profile">User Team<span class="text-danger">*</span>
|
||
<span class="tooltip-trigger mdi mdi-information-outline" id="accessMatrixTrigger"></span>
|
||
</label>
|
||
<select hidden class="form-control" id="team" name="team[]" multiple required>
|
||
<?php foreach($teamData as $value) {
|
||
|
||
$teamValue = $value['id']??"";
|
||
|
||
// we are showing head role only to head's who logged in
|
||
if( ($teamValue == "4" || $teamValue =="6" ) && $currentLogInRole != "5" ){
|
||
continue;
|
||
}
|
||
|
||
?>
|
||
<option value="<?= $value['id'] ?>"><?= $value['name'] ?></option>
|
||
<?php } ?>
|
||
</select>
|
||
</div>
|
||
</div>
|
||
|
||
</div>
|
||
|
||
<div class="form-group text-right m-b-0">
|
||
<button class="btn app-btn-outline-secondary mr-2 " type="button" data-dismiss="modal" aria-hidden="true">Cancel</button>
|
||
<button class="btn app-btn-secondary waves-effect waves-light" id="btnSubmit">Submit</button>
|
||
<!-- <button type="button" class="btn btn-secondry waves-effect waves-light mr-1" data-dismiss="modal" aria-hidden="true">Close</button> -->
|
||
</div>
|
||
</form>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
</div><!-- /.modal -->
|
||
<div id="nhance-partner-modal" class="modal fade app-font-family" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true" style="display: none;">
|
||
<div class="modal-dialog modal-dialog-centered modal-lg">
|
||
<div class="modal-content">
|
||
<div class="modal-header">
|
||
<h4 class="modal-title">Add Nhance Partner </h4>
|
||
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
|
||
</div>
|
||
|
||
<div class="modal-body p-4">
|
||
<div class="">
|
||
|
||
<form role="form" class="parsley-examples" method="post" id="PartnerForm" action="" enctype="multipart/form-data">
|
||
<input type="hidden" value="<?= csrf_hash() ?>" name="<?= csrf_token() ?>"/>
|
||
<input type="hidden" name="PrimaryKey" id="partner_id" name="id"/>
|
||
<div class="form-group">
|
||
|
||
<div class="form-row">
|
||
<div class="form-group col-md-6">
|
||
<label for="partner_name">Name<span class="text-danger">*</span></label>
|
||
<input type="text" class="form-control" id="partner_name" placeholder="Ente Name" name="name" required>
|
||
</div>
|
||
<div class="form-group col-md-6">
|
||
<label for="mobile_no">Mobile Number<span class="text-danger">*</span></label>
|
||
<input type="text" class="form-control" id="mobile_no" placeholder="Enter Mobile Number ( starting with 6, 7, 8, or 9 only. )" name="mobile" onkeypress = "return onlyNumbers(event)" maxlength="10" minlength="10" pattern="^[6-9]\d{9}$" data-parsley-type-message="Please enter a valid 10-digit mobile number starting with 6, 7, 8, or 9." data-parsley-required-message="Please enter a valid 10-digit mobile number starting with 6, 7, 8, or 9." required>
|
||
</div>
|
||
</div>
|
||
|
||
<div class="form-row">
|
||
<div class="form-group col-md-6">
|
||
<label for="email_addr">Email<span class="text-danger">*</span></label>
|
||
<input type="text" class="form-control" id="email_addr" placeholder="Enter Email" name="email" data-parsley-trigger="change" data-parsley-type="email" required>
|
||
</div>
|
||
<div class="form-group col-md-6">
|
||
<label for="locn">Address</label>
|
||
<textarea class="form-control" id="locn" name="address" placeholder="Enter address" rows="3" maxlength="1500"></textarea>
|
||
</div>
|
||
|
||
|
||
</div>
|
||
|
||
</div>
|
||
|
||
<div class="form-group text-right m-b-0">
|
||
<button class="btn app-btn-outline-secondary mr-2 " type="button" data-dismiss="modal" aria-hidden="true">Cancel</button>
|
||
<button class="btn app-btn-secondary waves-effect waves-light" type="button" id="btnPartnerSubmit" onclick="submitPartner(event)">Submit</button>
|
||
</div>
|
||
</form>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
</div><!-- /.modal -->
|
||
<div id="upload-incentive-file-modal" class="modal fade app-font-family" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true" style="display: none;">
|
||
<div class="modal-dialog modal-dialog-centered modal-lg">
|
||
<div class="modal-content">
|
||
<div class="modal-header">
|
||
<h4 class="modal-title"></h4>
|
||
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
|
||
</div>
|
||
<div class="modal-body p-4">
|
||
<form role="form" class="parsley-examples" method="post" id="PartnerIncentiveForm" action="" enctype="multipart/form-data">
|
||
<input type="hidden" value="<?= csrf_hash() ?>" name="<?= csrf_token() ?>"/>
|
||
<input type="hidden" id="manager_id" name="manager_id" />
|
||
<div class="form-group">
|
||
|
||
<div class="form-row">
|
||
<div class="form-group col-md-5">
|
||
<label for="incentive_month">Date</label>
|
||
<div class="input-icon">
|
||
<input type="text" class="form-control" name="incentive_month" id="incentive_month" required>
|
||
<i class="mdi mdi-calendar-blank-outline additional-icon"></i>
|
||
</div>
|
||
</div>
|
||
<div class="form-group col-md-5">
|
||
<label for="incentive_file_name">Upload File</label>
|
||
<div class="input-icon">
|
||
<input type="file" class="form-control" name="incentive_file_name" id="incentive_file_name" required>
|
||
<i class="mdi mdi-upload additional-icon"></i>
|
||
</div>
|
||
</div>
|
||
<div class="form-group col-md-2 text-right" style="margin-top: 27px;">
|
||
<button class="btn app-btn-secondary waves-effect waves-light" type="button" id="btnPartnerIncentiveSubmit" onclick="submitIncentivePartner(event)">Submit</button>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
</form>
|
||
<!-- <div class="row">
|
||
<div class="col-2">
|
||
<label for="filter">Files </label>
|
||
</div>
|
||
<div class="offset-col-7 col-3">
|
||
<div class="input-icon text-right">
|
||
<input type="text" class="form-control" id="filter">
|
||
<i class="mdi mdi-magnify additional-icon"></i>
|
||
</div>
|
||
</div> -->
|
||
<div class="row align-items-center">
|
||
<div class="col-2">
|
||
<label for="filter" class="mb-0">Files</label>
|
||
</div>
|
||
<div class="col-5 ml-auto">
|
||
<div class="input-icon">
|
||
<input type="text" class="form-control" id="filter" placeholder="Search...">
|
||
<i class="mdi mdi-magnify additional-icon"></i>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
<div class="row" id="container"></div>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
</div><!-- /.modal -->
|
||
|
||
|
||
<!-- Tooltip container separate from trigger -->
|
||
<div class="tooltip-container" id="tooltipContainer">
|
||
<div class="tooltip" id="accessMatrixTooltip">
|
||
<table data-custom-table-css="table" class="tooltip-table" style="color: black;">
|
||
<thead>
|
||
<tr>
|
||
<th>Team</th>
|
||
<th>Module</th>
|
||
<th>Access Rights</th>
|
||
</tr>
|
||
</thead>
|
||
<tbody>
|
||
<tr>
|
||
<td class="team-cell">Management</td>
|
||
<td>BDS - All access</td>
|
||
<td>All access</td>
|
||
</tr>
|
||
<tr>
|
||
<td class="team-cell" rowspan="6">Accounts</td>
|
||
<td>BDS - Policy Transaction</td>
|
||
<td>Policy | Endorsement | Statement Upload</td>
|
||
</tr>
|
||
<tr>
|
||
<td>BDS - Report</td>
|
||
<td>TAT wise | ACM Status wise | ACM TAT wise</td>
|
||
</tr>
|
||
<tr>
|
||
<td>BDS - Policy Report</td>
|
||
<td>BDS | Variance | Outstanding | IRDA | Renewal | TAT Band </td>
|
||
</tr>
|
||
<tr>
|
||
<td>BDS - Pending Actions</td>
|
||
<td>Finance Team</td>
|
||
</tr>
|
||
<tr>
|
||
<td>BDS - Masters</td>
|
||
<td>Vehicle | CD | Insurer</td>
|
||
</tr>
|
||
<tr>
|
||
<td>BDS - Documents</td>
|
||
<td>✓</td>
|
||
</tr>
|
||
<!-- Temporary please don't delete (start's) -->
|
||
<!--
|
||
<tr>
|
||
<td class="team-cell" rowspan="5">Finance</td>
|
||
<td>BDS - Policy Transaction</td>
|
||
<td>Policy | Endorsement | Statement Upload</td>
|
||
</tr>
|
||
<tr>
|
||
<td>BDS - Report</td>
|
||
<td>TAT wise | ACM Status wise | ACM TAT wise</td>
|
||
</tr>
|
||
<tr>
|
||
<td>BDS - Pending Actions</td>
|
||
<td>Finance Team</td>
|
||
</tr>
|
||
<tr>
|
||
<td>BDS - Masters</td>
|
||
<td>Vehicle | CD</td>
|
||
</tr>
|
||
<tr>
|
||
<td>BDS - Documents</td>
|
||
<td>✓</td>
|
||
</tr>
|
||
<tr>
|
||
<td class="team-cell" rowspan="5">Business</td>
|
||
<td>BDS - Policy Transaction</td>
|
||
<td>Policy | Endorsement</td>
|
||
</tr>
|
||
<tr>
|
||
<td>BDS - Report</td>
|
||
<td>TAT wise | ACM Status wise | ACM TAT wise</td>
|
||
</tr>
|
||
<tr>
|
||
<td>BDS - Pending Actions</td>
|
||
<td>Business Team</td>
|
||
</tr>
|
||
<tr>
|
||
<td>BDS - Masters</td>
|
||
<td>Vehicle | CD</td>
|
||
</tr>
|
||
<tr>
|
||
<td>BDS - Documents</td>
|
||
<td>✓</td>
|
||
</tr>
|
||
-->
|
||
<!-- Temporary please don't delete (ends) -->
|
||
<tr>
|
||
<td class="team-cell" rowspan="2">POS</td>
|
||
<td>BDS - Policy Transaction</td>
|
||
<td>Policy | Endorsement</td>
|
||
</tr>
|
||
<tr>
|
||
<td>BDS - Report</td>
|
||
<td>BDS, TAT wise | ACM Status wise | ACM TAT wise</td>
|
||
</tr>
|
||
<tr>
|
||
<td class="team-cell">Enrollment</td>
|
||
<td>Inception File Upload</td>
|
||
<td>All access</td>
|
||
</tr>
|
||
<tr>
|
||
<td class="team-cell">Claims</td>
|
||
<td>Claims</td>
|
||
<td>All access</td>
|
||
</tr>
|
||
<tr>
|
||
<td class="team-cell">Sales</td>
|
||
<td>LEAD</td>
|
||
<td>Lead creation | RFQ creation</td>
|
||
</tr>
|
||
<tr>
|
||
<td class="team-cell">Business Support</td>
|
||
<td>LEAD</td>
|
||
<td>All access</td>
|
||
</tr>
|
||
</tbody>
|
||
</table>
|
||
</div>
|
||
</div>
|
||
|
||
<div class="tooltip-container" id="roleTooltipContainer">
|
||
<div class="tooltip" id="roleAccessMatrixTooltip">
|
||
<table data-custom-table-css="table" class="tooltip-table" style="color: black;">
|
||
<thead>
|
||
<tr>
|
||
<th>Team</th>
|
||
<th>Module</th>
|
||
<th>Access Rights</th>
|
||
</tr>
|
||
</thead>
|
||
<tbody>
|
||
<tr>
|
||
<td class="team-cell">Head</td>
|
||
<td>All modules</td>
|
||
<td>All access</td>
|
||
</tr>
|
||
<tr>
|
||
<td class="team-cell">Admin</td>
|
||
<td>All modules</td>
|
||
<td>All access</td>
|
||
</tr>
|
||
<tr>
|
||
<td class="team-cell">Manager</td>
|
||
<td>Access to all modules except the "Masters" module</td>
|
||
<td>All access</td>
|
||
</tr>
|
||
<tr>
|
||
<td class="team-cell">Account Manager</td>
|
||
<td>Access to all modules except the "Masters" module</td>
|
||
<td>All access without "Delete option"</td>
|
||
</tr>
|
||
<tr>
|
||
<td class="team-cell">Staff</td>
|
||
<td>Based on the "Teams"</td>
|
||
<td>Based on the "Teams"</td>
|
||
</tr>
|
||
</tbody>
|
||
</table>
|
||
</div>
|
||
</div>
|
||
|
||
<script>
|
||
var table;
|
||
$(document).ready(function () {
|
||
|
||
var incentiveMonthPicker = flatpickr("#incentive_month", {
|
||
dateFormat: "Y-m-d", // real value stored (hidden)
|
||
altInput: true, // show a user-friendly display
|
||
altFormat: "M Y", // what you want to display (Aug 2025)
|
||
allowInput: false,
|
||
});
|
||
|
||
table = $('#user-table').DataTable({
|
||
scrollX: true,
|
||
dom: "<'row'<'col-sm-3'f><'col-sm-9'B>>" +
|
||
"<'row'<'col-sm-12'tr>>" +
|
||
"<'row'<'col-sm-5'i><'col-sm-7'p>>",
|
||
buttons: [
|
||
// {
|
||
// extend: 'collection',
|
||
// text: '<i class="mdi mdi-account-multiple"></i><span class="btn-custom"> Load Data </span>',
|
||
// className: 'btn app-btn-primary mr-2',
|
||
// buttons: [
|
||
// {
|
||
// text: 'Load User',
|
||
// action: function () { loadUser(); }
|
||
// },
|
||
// {
|
||
// text: 'Load Nhance Partner',
|
||
// action: function () { loadPartner(); }
|
||
// }
|
||
// ]
|
||
// },
|
||
// {
|
||
// text: '<i class="mdi mdi-account-multiple"></i><span class="btn-custom">Load User</span>',
|
||
// className: 'btn app-btn-primary mr-2 toggleLoadBtn',
|
||
// action: function (e, dt, node, config) {
|
||
// let $btn = $(node).find('span.btn-custom');
|
||
// let currentText = $btn.text().trim();
|
||
// if (currentText === "Load User") {
|
||
// loadUser();
|
||
// $btn.text("Load user"); // toggle text
|
||
// } else {
|
||
// loadPartner();
|
||
// $btn.text("Load partner"); // toggle back
|
||
// }
|
||
// }
|
||
// },
|
||
// {
|
||
// text: '<i class="mdi mdi-account-multiple"></i><span class="btn-custom">Load User</span>',
|
||
// className: 'btn app-btn-primary mr-2 toggleLoadBtn',
|
||
// action: function (e, dt, node, config) {
|
||
// let $btn = $(node).find('span.btn-custom');
|
||
// // check current mode from button dataset (default: user)
|
||
// let currentMode = $btn.data("mode") || "user";
|
||
// if (currentMode === "user") {
|
||
// loadUser();
|
||
// $btn.text("Load Nhance Partner");
|
||
// $btn.data("mode", "partner"); // switch mode
|
||
// } else {
|
||
// loadPartner();
|
||
// $btn.text("Load User");
|
||
// $btn.data("mode", "user"); // switch back
|
||
// }
|
||
// }
|
||
// },
|
||
{
|
||
text: '<i class="mdi mdi-plus"></i><span class="btn-custom"> Add User </span>',
|
||
className: 'btn app-btn-primary mr-2',
|
||
attr: { id: 'btnAdd' }
|
||
},
|
||
{
|
||
text: '<i class="mdi mdi-plus"></i><span class="btn-custom"> Add Nhance Partner </span>',
|
||
className: 'btn app-btn-primary mr-2',
|
||
attr: { id: 'btnNhancePartnerAdd' }
|
||
},
|
||
{
|
||
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>',
|
||
className: 'app-btn-primary',
|
||
exportOptions: {
|
||
columns: ':not(:last-child)'
|
||
}
|
||
},
|
||
{
|
||
extend: 'excel',
|
||
text: '<i class="mdi mdi-file-excel"></i><span class="btn-custom"> EXCEL </span>',
|
||
exportOptions: { orthogonal: 'sort' },
|
||
className: 'app-btn-primary',
|
||
exportOptions: {
|
||
columns: ':not(:last-child)'
|
||
}
|
||
}
|
||
]
|
||
}
|
||
],
|
||
paging: true,
|
||
pageLength: 10,
|
||
language: {
|
||
search: `
|
||
<div class="datatable-search-wrapper">
|
||
_INPUT_
|
||
<i class="mdi mdi-magnify datatable-search-icon"></i>
|
||
</div>`,
|
||
searchPlaceholder: "Search"
|
||
},
|
||
initComplete: function () {
|
||
$(".dt-buttons").prepend(`
|
||
<div class="tab-button mr-2" id="toggleButton" style="float:left;">
|
||
<span id="btnUsers" class="highlight-link active">Users</span>
|
||
<span class="divider-line"> | </span>
|
||
<span id="btnPartners" class="highlight-link">Nhance Partner</span>
|
||
</div>
|
||
`);
|
||
|
||
$('#btnUsers').on('click', function () {
|
||
$('#btnPartners').removeClass('active');
|
||
$(this).addClass('active');
|
||
loadUser();
|
||
});
|
||
|
||
$('#btnPartners').on('click', function () {
|
||
$('#btnUsers').removeClass('active');
|
||
$(this).addClass('active');
|
||
loadPartner();
|
||
});
|
||
}
|
||
});
|
||
|
||
|
||
|
||
$('#team').multiselect({
|
||
nonSelectedText: 'Select Team',
|
||
enableFiltering: false,
|
||
enableCaseInsensitiveFiltering: false,
|
||
includeSelectAllOption : false,
|
||
buttonWidth:'100%',
|
||
dropUp: true
|
||
});
|
||
|
||
$('.close').click(function(){
|
||
$('#UserId').val('');
|
||
$('#first_name').val('');
|
||
$('#email').val('');
|
||
$('#mobile').val('');
|
||
$('#emp_code').val('');
|
||
$('#role').val('')
|
||
})
|
||
|
||
// $('body').on('click', '#btnUsers', function () {
|
||
// $('#btnPartners').removeClass('active');
|
||
// $(this).addClass('active');
|
||
// loadUser();
|
||
// });
|
||
|
||
// $('body').on('click', '#btnPartners', function () {
|
||
// $('#btnUsers').removeClass('active');
|
||
// $(this).addClass('active');
|
||
// loadPartner();
|
||
// });
|
||
|
||
$('body').on('click', '.btnEdit', function () {
|
||
var user_id = $(this).attr('data-id');
|
||
$.ajax({
|
||
url: '<?php echo base_url('user/getuser/');?>'+user_id,
|
||
type: "GET",
|
||
dataType: 'json',
|
||
success: function (res) {
|
||
console.log(res)
|
||
$('#updateModal').modal('show');
|
||
$('#role').val('')
|
||
$('#UserForm').attr('action', '<?php echo base_url('user/edit');?>');
|
||
$('#UserId').val(res.data.id);
|
||
$('#first_name').val(res.data.first_name);
|
||
$('#last_name').val(res.data.last_name);
|
||
$('#email').val(res.data.email);
|
||
$('#mobile').val(res.data.mobile);
|
||
$('#emp_code').val(res.data.emp_code);
|
||
$('#role option[value="' + res.data.role + '"]').prop('selected', true);
|
||
$('#btnSubmit').html('Update');
|
||
|
||
$.each(res.userTeamData, function(index, item) {
|
||
$('#team option[value="' + item.team_id + '"]').prop('selected', true);
|
||
$('#team').multiselect('refresh');
|
||
});
|
||
|
||
},
|
||
error: function (xhr, status, error) {
|
||
console.error("Error Details:");
|
||
console.error("Status Code:", xhr.status);
|
||
console.error("Status Text:", xhr.statusText);
|
||
console.error("Response Text:", xhr.responseText);
|
||
console.error("Ready State:", xhr.readyState);
|
||
console.error("Response Headers:", xhr.getAllResponseHeaders());
|
||
console.error("Error Thrown:", error);
|
||
console.error("Status:", status);
|
||
}
|
||
|
||
});
|
||
});
|
||
|
||
$('body').on('click', '.btnDelete', function () {
|
||
|
||
Swal.fire({
|
||
title: "Are you sure?",
|
||
text: "You need to remove this user",
|
||
icon: "info",
|
||
showCancelButton: true,
|
||
confirmButtonColor: "#3085d6",
|
||
confirmButtonText: "Yes",
|
||
}).then((result) => {
|
||
if (result.isConfirmed) {
|
||
|
||
var student_id = $(this).attr('data-id');
|
||
$.get('<?php echo base_url('user/deactive/');?>'+student_id, function (data) {
|
||
console.log(data);
|
||
toastr.success('User removed successfully', 'success');
|
||
window.location.reload()
|
||
})
|
||
}
|
||
});
|
||
});
|
||
|
||
$('body').on('click', '.btnPartnerEdit', function () {
|
||
let user = JSON.parse($(this).attr('data-obj')); // ✅ convert back to object
|
||
$('#PartnerForm').attr('action', '<?php echo base_url('/user/partner');?>');
|
||
$('#partner_id').val(user.id);
|
||
$('#partner_name').val(user.name);
|
||
$('#email_addr').val(user.email);
|
||
$('#mobile_no').val(user.mobile);
|
||
$('#locn').val(user.address);
|
||
// $('#btnPartnerSubmit').html('Update');
|
||
$('.modal-title').html('Update Nhance Partner');
|
||
let myModal = new bootstrap.Modal(document.getElementById('nhance-partner-modal'));
|
||
myModal.show(); // open modal
|
||
});
|
||
|
||
$('body').on('click', '.btnPartnerDelete', function () {
|
||
var partner_role = $(this).attr('data-role');
|
||
var alertText = "You need to remove this user";
|
||
if (partner_role == 2) {
|
||
alertText = "You need to remove this Staff";
|
||
} else if (partner_role == 1) {
|
||
alertText = "You need to remove this Manager and related agent and staff are also delete";
|
||
}
|
||
|
||
Swal.fire({
|
||
title: "Are you sure?",
|
||
text: alertText,
|
||
icon: "info",
|
||
showCancelButton: true,
|
||
confirmButtonColor: "#3085d6",
|
||
confirmButtonText: "Yes",
|
||
}).then((result) => {
|
||
if (result.isConfirmed) {
|
||
var partner_id = $(this).attr('data-id');
|
||
|
||
|
||
$.ajax({ url: "<?= base_url('user/partner') ?>",
|
||
type: "PUT",
|
||
data: { id: partner_id },
|
||
success: function(response) {
|
||
console.log("Deleted:", response);
|
||
toastr.success(response.message, 'Success');
|
||
loadPartner(); // refresh table
|
||
},
|
||
error: function(xhr) {
|
||
console.error("Delete Error:", xhr.responseText);
|
||
let res = xhr.responseJSON || {};
|
||
toastr.error(res.message || "Unable to delete staff", 'Error');
|
||
}
|
||
});
|
||
}
|
||
});
|
||
});
|
||
|
||
$('body').on('click', '.btnPartnerIncentive', function () {
|
||
let user = JSON.parse($(this).attr('data-obj'));
|
||
|
||
$('#PartnerIncentiveForm').attr('action', '<?= base_url('/user/partnerIncentive');?>');
|
||
$('#manager_id').val(user.id);
|
||
$('#incentive_file_name').val(user.incentive_file_name);
|
||
$('#incentive_month').val(user.incentive_month);
|
||
|
||
$('.modal-title').text(user.name);
|
||
|
||
// ✅ Load files separately
|
||
loadIncentiveFiles(user.id);
|
||
|
||
let myModal = new bootstrap.Modal(document.getElementById('upload-incentive-file-modal'));
|
||
myModal.show();
|
||
});
|
||
|
||
});
|
||
|
||
function onlyNumbers(event){
|
||
var charcode;
|
||
charcode = event.which || event.keyCode;
|
||
if(charcode>= 48 && charcode <= 57)return true;
|
||
return false;
|
||
}
|
||
|
||
var form = document.getElementById("UserForm");
|
||
|
||
// Add submit event listener to the form
|
||
form.addEventListener("submit", function(event) {
|
||
// Disable the submit button to avoid multiple submissions
|
||
// document.getElementById("btnSubmit").disabled = true;
|
||
});
|
||
|
||
function submitPartner(event) {
|
||
event.preventDefault();
|
||
|
||
var form = document.getElementById('PartnerForm');
|
||
var btn = document.getElementById('btnPartnerSubmit');
|
||
var myModal = new bootstrap.Modal(document.getElementById('nhance-partner-modal'));
|
||
|
||
// reset any old error styles
|
||
form.classList.remove('was-validated');
|
||
|
||
var name = document.getElementById('partner_name').value.trim();
|
||
var mobile = document.getElementById('mobile_no').value.trim();
|
||
var email = document.getElementById('email_addr').value.trim();
|
||
var address = document.getElementById('locn').value.trim();
|
||
|
||
// Validation checks
|
||
if (name === "" || mobile === "" || email === "") {
|
||
console.log(name);
|
||
console.log(mobile);
|
||
console.log(email);
|
||
toastr.warning('Please fill all required fields.', 'Warning');
|
||
form.classList.add('was-validated');
|
||
return;
|
||
}
|
||
|
||
if (address.length > 1500) {
|
||
toastr.error('Address cannot exceed 1500 characters', 'Warning');
|
||
form.classList.add('was-validated');
|
||
return;
|
||
}
|
||
|
||
var mobilePattern = /^[6-9]\d{9}$/; // must start with 6–9 and be 10 digits
|
||
if (!mobilePattern.test(mobile)) {
|
||
toastr.warning('Please enter a valid 10-digit mobile number starting with 6, 7, 8, or 9.', 'Warning');
|
||
document.getElementById('mobile').focus();
|
||
return;
|
||
}
|
||
|
||
var emailPattern = /^[^@\s]+@[^@\s]+\.[^@\s]+$/;
|
||
if (!emailPattern.test(email)) {
|
||
toastr.warning('Please enter a valid email address.', 'Warning');
|
||
document.getElementById('email').focus();
|
||
return;
|
||
}
|
||
|
||
// Disable button during submit
|
||
btn.disabled = true;
|
||
btn.innerText = "Saving...";
|
||
|
||
var formData = new FormData(form);
|
||
|
||
$.ajax({
|
||
url: "<?= base_url('user/partner') ?>",
|
||
type: "POST",
|
||
data: formData,
|
||
processData: false,
|
||
contentType: false,
|
||
dataType: 'json',
|
||
success: function(response) {
|
||
if (response.status === "success") {
|
||
toastr.success('Partner saved successfully!', 'Success');
|
||
myModal.hide();
|
||
form.reset(); // reset form after success
|
||
} else {
|
||
toastr.warning(response.message || 'Something went wrong.', 'Warning');
|
||
}
|
||
},
|
||
error: function(xhr) {
|
||
console.log("Error: " + xhr.statusText);
|
||
toastr.error('Server error occurred.', 'Error');
|
||
},
|
||
complete: function() {
|
||
btn.disabled = false;
|
||
btn.innerText = "Submit";
|
||
$('#nhance-partner-modal').removeClass('show').hide();
|
||
$('.modal-backdrop').remove();
|
||
loadPartner();
|
||
}
|
||
});
|
||
}
|
||
|
||
function submitIncentivePartner(event) {
|
||
event.preventDefault();
|
||
|
||
|
||
var form = document.getElementById('PartnerIncentiveForm');
|
||
var btn = document.getElementById('btnPartnerIncentiveSubmit');
|
||
var myModal = new bootstrap.Modal(document.getElementById('upload-incentive-file-modal'));
|
||
|
||
// reset any old error styles
|
||
form.classList.remove('was-validated');
|
||
|
||
|
||
var month = document.getElementById('incentive_month').value.trim();
|
||
var fileInput = document.getElementById('incentive_file_name');
|
||
|
||
if (month === "" || !fileInput.files.length) {
|
||
toastr.warning('Please fill all required fields.', 'Warning');
|
||
form.classList.add('was-validated');
|
||
return;
|
||
}
|
||
|
||
|
||
// Disable button during submit
|
||
btn.disabled = true;
|
||
btn.innerText = "Saving...";
|
||
|
||
var formData = new FormData(form);
|
||
|
||
$.ajax({
|
||
url: "<?= base_url('user/partnerIncentive') ?>",
|
||
type: "POST",
|
||
data: formData,
|
||
processData: false,
|
||
contentType: false,
|
||
dataType: 'json',
|
||
success: function(response) {
|
||
if (response.status === "success") {
|
||
toastr.success('Partner Incentive saved successfully!', 'Success');
|
||
form.reset();
|
||
|
||
// ✅ Reload incentive files list
|
||
let manager_id = $('#manager_id').val();
|
||
loadIncentiveFiles(manager_id);
|
||
} else {
|
||
toastr.warning(response.message || 'Something went wrong.', 'Warning');
|
||
}
|
||
},
|
||
error: function(xhr) {
|
||
console.log("Error: " + xhr.statusText);
|
||
toastr.error('Server error occurred.', 'Error');
|
||
},
|
||
complete: function() {
|
||
btn.disabled = false;
|
||
btn.innerText = "Submit";
|
||
}
|
||
|
||
});
|
||
}
|
||
|
||
function renderRows(data, type = 'user') {
|
||
table.clear(); // Remove old rows
|
||
|
||
if (Array.isArray(data) && data.length) {
|
||
data.forEach(row => {
|
||
let statusClass = row.is_active == 1 ? 'badge-success' : 'badge-danger';
|
||
let statusText = row.is_active == 1 ? 'Active' : 'In-Active';
|
||
|
||
let rowData = [];
|
||
if (type === 'user') {
|
||
rowData = [
|
||
row.first_name,
|
||
row.email,
|
||
row.mobile,
|
||
row.user_role,
|
||
`<span class="badge ${statusClass}">${statusText}</span>`,
|
||
`<div class="btn-group dropdown">
|
||
<a href="javascript:void(0);" class="dropdown-toggle arrow-none btn btn-light btn-sm" data-toggle="dropdown">
|
||
<i class="mdi mdi-dots-horizontal"></i>
|
||
</a>
|
||
<div class="dropdown-menu dropdown-menu-right">
|
||
<a data-toggle="modal" data-target="#con-close-modal" class="dropdown-item btnEdit" data-id="${row.id}">
|
||
<i data-id="${row.id}" class="mdi mdi-pencil mr-2 text-muted font-18 vertical-middle btnEdit"></i>Edit
|
||
</a>
|
||
<a class="dropdown-item btnDelete" data-id="${row.id}">
|
||
<i data-id="${row.id}" class="mdi mdi-delete mr-2 text-muted font-18 vertical-middle btnDelete"></i>Delete
|
||
</a>
|
||
</div>
|
||
</div>`
|
||
];
|
||
} else { // partner
|
||
rowData = [
|
||
row.name,
|
||
row.email,
|
||
row.mobile,
|
||
row.role_id == 1 ? "Manager" : "Staff",
|
||
`<span class="badge ${statusClass}">${statusText}</span>`,
|
||
`<div class="btn-group dropdown">
|
||
<a href="javascript:void(0);" class="dropdown-toggle arrow-none btn btn-light btn-sm" data-toggle="dropdown">
|
||
<i class="mdi mdi-dots-horizontal"></i>
|
||
</a>
|
||
<div class="dropdown-menu dropdown-menu-right">
|
||
<a data-toggle="modal" data-target="#nhance-partner-modal" class="dropdown-item btnPartnerEdit" data-obj='${JSON.stringify(row)}'>
|
||
<i data-obj='${JSON.stringify(row)}' class="mdi mdi-pencil mr-2 text-muted font-18 vertical-middle btnPartnerEdit"></i>Edit
|
||
</a>
|
||
<a class="dropdown-item btnPartnerDelete" data-id="${row.id}" data-role="${row.role_id}">
|
||
<i data-id="${row.id}" data-role="${row.role_id}" class="mdi mdi-delete mr-2 text-muted font-18 vertical-middle btnPartnerDelete"></i>Delete
|
||
</a>
|
||
<a class="dropdown-item btnPartnerPerformance" data-id="${row.id}">
|
||
<i data-id="${row.id}" class="mdi mdi-speedometer mr-2 text-muted font-18 vertical-middle btnPartnerPerformance"></i>View Performance
|
||
</a>
|
||
<a data-toggle="modal" data-target="#upload-incentive-file-modal" class="dropdown-item btnPartnerIncentive" data-obj='${JSON.stringify(row)}'>
|
||
<i data-obj='${JSON.stringify(row)}' class="mdi mdi-upload mr-2 text-muted font-18 vertical-middle btnPartnerIncentive"></i>Upload Incentive File
|
||
</a>
|
||
</div>
|
||
</div>`
|
||
];
|
||
}
|
||
|
||
table.row.add(rowData);
|
||
});
|
||
} else {
|
||
// Show placeholder if no data
|
||
table.row.add([
|
||
`<td colspan="6" class="text-center text-muted">No ${type === 'user' ? 'users' : 'partners'} found</td>`
|
||
]);
|
||
}
|
||
|
||
table.draw(); // Redraw table
|
||
}
|
||
|
||
// function loadUser() {
|
||
|
||
// let tbody = $('#loadDynamicDetails');
|
||
// tbody.empty();
|
||
// let users = <?= json_encode($UserList) ?>;
|
||
// users.forEach(row => {
|
||
// let statusClass = row.is_active == 1 ? 'badge-success' : 'badge-danger';
|
||
// let statusText = row.is_active == 1 ? 'Active' : 'In-Active';
|
||
|
||
// tbody.append(`
|
||
// <tr id="${row.id}">
|
||
// <td class="text-dark">${row.first_name}</td>
|
||
// <td>${row.email}</td>
|
||
// <td>${row.mobile}</td>
|
||
// <td>${row.user_role}</td>
|
||
// <td><span class="badge ${statusClass}">${statusText}</span></td>
|
||
// <td>
|
||
// <div class="btn-group dropdown">
|
||
// <a href="javascript:void(0);" class="dropdown-toggle arrow-none btn btn-light btn-sm" data-toggle="dropdown">
|
||
// <i class="mdi mdi-dots-horizontal"></i>
|
||
// </a>
|
||
// <div class="dropdown-menu dropdown-menu-right">
|
||
// <a data-toggle="modal" data-target="#con-close-modal" class="dropdown-item btnEdit" data-id="${row.id}">
|
||
// <i data-id="${row.id}" class="mdi mdi-pencil mr-2 text-muted font-18 vertical-middle btnEdit"></i>Edit
|
||
// </a>
|
||
// <a class="dropdown-item btnDelete" data-id="${row.id}">
|
||
// <i data-id="${row.id}" class="mdi mdi-delete mr-2 text-muted font-18 vertical-middle btnDelete"></i>Delete
|
||
// </a>
|
||
// </div>
|
||
// </div>
|
||
// </td>
|
||
// </tr>
|
||
// `);
|
||
// });
|
||
// }
|
||
function loadUser() {
|
||
let users = <?= json_encode($UserList) ?>;
|
||
renderRows(users, 'user');
|
||
}
|
||
|
||
// function loadPartner() {
|
||
// $.ajax({
|
||
// url: '<?= base_url("user/partner"); ?>',
|
||
// method: 'GET',
|
||
// success: function(response) {
|
||
// console.log(response); // {status: "success", data: [...]}
|
||
|
||
// if (response.status === "success" && Array.isArray(response.data)) {
|
||
// let tbody = $('#loadDynamicDetails');
|
||
// tbody.empty();
|
||
|
||
// response.data.forEach(row => {
|
||
// let statusClass = row.is_active == 1 ? 'badge-success' : 'badge-danger';
|
||
// let statusText = row.is_active == 1 ? 'Active' : 'In-Active';
|
||
|
||
// tbody.append(`
|
||
// <tr id="${row.id}">
|
||
// <td class="text-dark">${row.name}</td>
|
||
// <td>${row.email}</td>
|
||
// <td>${row.mobile}</td>
|
||
// <td>Staff</td>
|
||
// <td><span class="badge ${statusClass}">${statusText}</span></td>
|
||
// <td>
|
||
// <div class="btn-group dropdown">
|
||
// <a href="javascript:void(0);" class="dropdown-toggle arrow-none btn btn-light btn-sm" data-toggle="dropdown">
|
||
// <i class="mdi mdi-dots-horizontal"></i>
|
||
// </a>
|
||
// <div class="dropdown-menu dropdown-menu-right">
|
||
// <a data-toggle="modal" data-target="#nhance-partner-modal" class="dropdown-item btnPartnerEdit" data-obj='${JSON.stringify(row)}'>
|
||
// <i data-obj='${JSON.stringify(row)}' class="mdi mdi-pencil mr-2 text-muted font-18 vertical-middle btnPartnerEdit"></i>Edit
|
||
// </a>
|
||
// <a class="dropdown-item btnPartnerDelete" data-id="${row.id}">
|
||
// <i data-id="${row.id}" class="mdi mdi-delete mr-2 text-muted font-18 vertical-middle btnPartnerDelete"></i>Delete
|
||
// </a>
|
||
// <a class="dropdown-item btnPartnerPerformance" data-id="${row.id}">
|
||
// <i data-id="${row.id}" class="mdi mdi-speedometer mr-2 text-muted font-18 vertical-middle btnPartnerPerformance"></i>View Performance
|
||
// </a>
|
||
// <a data-toggle="modal" data-target="#upload-incentive-file-modal" class="dropdown-item btnPartnerIncentive" data-obj='${JSON.stringify(row)}'>
|
||
// <i data-obj='${JSON.stringify(row)}' class="mdi mdi-upload mr-2 text-muted font-18 vertical-middle btnPartnerIncentive"></i>Upload Incentive File
|
||
// </a>
|
||
// </div>
|
||
// </div>
|
||
// </td>
|
||
// </tr>
|
||
// `);
|
||
// });
|
||
// } else {
|
||
// console.warn("No partner data found");
|
||
// $('#loadDynamicDetails').html(`<tr><td colspan="6" class="text-center text-muted">No partners found</td></tr>`);
|
||
// }
|
||
// },
|
||
// error: function(xhr, status, error) {
|
||
// console.error("Error loading partners:", error);
|
||
// }
|
||
// });
|
||
// }
|
||
function loadPartner() {
|
||
$.ajax({
|
||
url: '<?= base_url("user/partner"); ?>',
|
||
method: 'GET',
|
||
success: function(response) {
|
||
if (response.status === "success" && Array.isArray(response.data)) {
|
||
renderRows(response.data, 'partner');
|
||
} else {
|
||
renderRows([], 'partner');
|
||
}
|
||
},
|
||
error: function(xhr, status, error) {
|
||
console.error("Error loading partners:", error);
|
||
renderRows([], 'partner');
|
||
}
|
||
});
|
||
}
|
||
|
||
function loadIncentiveFiles(manager_id) {
|
||
|
||
// let modal = $("#upload-incentive-file-modal");
|
||
// let container = modal.find(".container");
|
||
|
||
let container = $("#container");
|
||
container.html(`<div class="col-md-12 mt-2">
|
||
<div class="d-flex align-items-center justify-content-center p-2 bg-white">
|
||
<div class="text-muted small">Loading...</div>
|
||
</div></div>`);
|
||
|
||
|
||
$.ajax({
|
||
url: "<?= base_url('user/partnerIncentive') ?>",
|
||
method: 'GET',
|
||
data: { manager_id: manager_id }, // pass manager_id if required
|
||
success: function(response) {
|
||
container.empty();
|
||
|
||
if (response.status === "success" && response.data && response.data.length) {
|
||
response.data.forEach((file) => {
|
||
let date = new Date(file.updated_on);
|
||
let options = {
|
||
day: '2-digit',
|
||
month: 'short',
|
||
year: 'numeric',
|
||
hour: '2-digit',
|
||
minute: '2-digit',
|
||
hour12: false
|
||
};
|
||
let uploaded = date.toLocaleString('en-GB', options).replace(',', '');
|
||
let color = file.incentive_file_name ? "app-text-success" : "font-color-black";
|
||
let download_url = "<?= base_url('user/download-incentive-file/') ?>" + encodeURIComponent(file.id);
|
||
let im = file.incentive_month;
|
||
|
||
|
||
let card = `<div class="col-md-6 mt-2 file-card"
|
||
data-name="${file.incentive_file_name.toLowerCase()}"
|
||
data-date="${uploaded.toLowerCase()}">
|
||
<div class="d-flex align-items-center justify-content-between border rounded p-2 bg-white">
|
||
<div class="d-flex align-items-center">
|
||
<div class="file-icon-box d-flex align-items-center justify-content-center">
|
||
<i class="mdi mdi-file-document-outline font-color-black" style="font-size: 24px;"></i>
|
||
</div>
|
||
<div class="ml-2">
|
||
<div class="font-weight-bold font-color-black small text-truncate"
|
||
title="${file.incentive_file_name}"
|
||
style="max-width: 265px;">
|
||
${file.incentive_file_name}
|
||
</div>
|
||
<div class="text-muted small">Uploaded : ${im}</div>
|
||
</div>
|
||
</div>
|
||
<div>
|
||
<a href="${download_url}" target="_blank" class="text-decoration-none">
|
||
<i class="mdi mdi-download ${color}" style="font-size: 22px;"></i>
|
||
</a>
|
||
</div>
|
||
</div>
|
||
</div>`;
|
||
container.append(card);
|
||
});
|
||
} else {
|
||
container.append(`<div class="no-files-message">No Files have been Uploaded</div>`);
|
||
}
|
||
},
|
||
error: function (xhr, status, errorThrown) {
|
||
container.html(`<div class="no-files-message">No Files have been Uploaded</div>`);
|
||
console.log("Error: " + xhr.status + " - " + errorThrown);
|
||
if (xhr.status !== 404) toastr.error(errorThrown || xhr.responseText || 'Something went wrong', 'Error');
|
||
}
|
||
});
|
||
}
|
||
|
||
$('#filter').on('keyup', function () {
|
||
let value = $(this).val().toLowerCase().trim();
|
||
let cards = $("#container .file-card");
|
||
let matchCount = 0;
|
||
|
||
cards.each(function () {
|
||
let name = $(this).data('name');
|
||
let date = $(this).data('date');
|
||
|
||
if (name.includes(value) || date.includes(value)) {
|
||
$(this).show();
|
||
matchCount++;
|
||
} else {
|
||
$(this).hide();
|
||
}
|
||
});
|
||
|
||
// Handle "no files" message
|
||
$(".no-files-message").remove();
|
||
if (matchCount === 0) {
|
||
$("#container").append(`<div class="no-files-message col-12">No Files have been Uploaded</div>`);
|
||
}
|
||
});
|
||
|
||
|
||
</script>
|
||
|
||
<script>
|
||
|
||
function initializeTooltip() {
|
||
|
||
const trigger = document.getElementById('accessMatrixTrigger');
|
||
console.log(trigger);
|
||
const tooltip = document.getElementById('accessMatrixTooltip');
|
||
console.log(tooltip);
|
||
const tooltipContainer = document.getElementById('tooltipContainer');
|
||
console.log(tooltipContainer);
|
||
|
||
if (!trigger || !tooltip || !tooltipContainer) {
|
||
console.error('Tooltip elements not found');
|
||
return;
|
||
}
|
||
|
||
function positionTooltip(event) {
|
||
const triggerRect = trigger.getBoundingClientRect();
|
||
const tooltipRect = tooltip.getBoundingClientRect();
|
||
const viewportWidth = window.innerWidth;
|
||
const viewportHeight = window.innerHeight;
|
||
|
||
let left = triggerRect.right + 10; // 10px to the right of trigger
|
||
let top = triggerRect.top;
|
||
|
||
// Check if tooltip goes off-screen to the right
|
||
if (left + tooltipRect.width > viewportWidth) {
|
||
left = triggerRect.left - tooltipRect.width - 10; // Show to the left instead
|
||
}
|
||
|
||
// Check if tooltip goes off-screen at the bottom
|
||
if (top + tooltipRect.height > viewportHeight) {
|
||
top = viewportHeight - tooltipRect.height - 10;
|
||
}
|
||
|
||
// Ensure tooltip doesn't go above viewport
|
||
if (top < 10) {
|
||
top = 10;
|
||
}
|
||
|
||
tooltipContainer.style.left = left + 'px';
|
||
tooltipContainer.style.top = top + 'px';
|
||
|
||
// Position arrow
|
||
const arrow = tooltip.querySelector('::after');
|
||
if (left < triggerRect.left) {
|
||
// Tooltip is to the left, arrow should point right
|
||
tooltip.style.setProperty('--arrow-position', 'right');
|
||
} else {
|
||
// Tooltip is to the right, arrow should point left
|
||
tooltip.style.setProperty('--arrow-position', 'left');
|
||
}
|
||
}
|
||
|
||
// Show tooltip on hover
|
||
trigger.addEventListener('mouseenter', function(event) {
|
||
positionTooltip(event);
|
||
tooltip.classList.add('show');
|
||
});
|
||
|
||
// Hide tooltip when mouse leaves trigger
|
||
trigger.addEventListener('mouseleave', function() {
|
||
tooltip.classList.remove('show');
|
||
});
|
||
|
||
// Keep tooltip visible when hovering over the tooltip itself
|
||
tooltip.addEventListener('mouseenter', function() {
|
||
tooltip.classList.add('show');
|
||
});
|
||
|
||
tooltip.addEventListener('mouseleave', function() {
|
||
tooltip.classList.remove('show');
|
||
});
|
||
|
||
// Reposition on window resize
|
||
window.addEventListener('resize', function() {
|
||
if (tooltip.classList.contains('show')) {
|
||
positionTooltip();
|
||
}
|
||
});
|
||
}
|
||
|
||
function initializeRoleTooltip() {
|
||
|
||
const trigger = document.getElementById('roleAccessMatrixTrigger');
|
||
console.log(trigger);
|
||
const tooltip = document.getElementById('roleAccessMatrixTooltip');
|
||
console.log(tooltip);
|
||
const tooltipContainer = document.getElementById('roleTooltipContainer');
|
||
console.log(tooltipContainer);
|
||
|
||
if (!trigger || !tooltip || !tooltipContainer) {
|
||
console.error('Tooltip elements not found');
|
||
return;
|
||
}
|
||
|
||
function positionTooltip(event) {
|
||
const triggerRect = trigger.getBoundingClientRect();
|
||
const tooltipRect = tooltip.getBoundingClientRect();
|
||
const viewportWidth = window.innerWidth;
|
||
const viewportHeight = window.innerHeight;
|
||
|
||
let left = triggerRect.right + 10; // 10px to the right of trigger
|
||
let top = triggerRect.top;
|
||
|
||
// Check if tooltip goes off-screen to the right
|
||
if (left + tooltipRect.width > viewportWidth) {
|
||
left = triggerRect.left - tooltipRect.width - 10; // Show to the left instead
|
||
}
|
||
|
||
// Check if tooltip goes off-screen at the bottom
|
||
if (top + tooltipRect.height > viewportHeight) {
|
||
top = viewportHeight - tooltipRect.height - 10;
|
||
}
|
||
|
||
// Ensure tooltip doesn't go above viewport
|
||
if (top < 10) {
|
||
top = 10;
|
||
}
|
||
|
||
tooltipContainer.style.left = left + 'px';
|
||
tooltipContainer.style.top = top + 'px';
|
||
|
||
// Position arrow
|
||
const arrow = tooltip.querySelector('::after');
|
||
if (left < triggerRect.left) {
|
||
// Tooltip is to the left, arrow should point right
|
||
tooltip.style.setProperty('--arrow-position', 'right');
|
||
} else {
|
||
// Tooltip is to the right, arrow should point left
|
||
tooltip.style.setProperty('--arrow-position', 'left');
|
||
}
|
||
}
|
||
|
||
// Show tooltip on hover
|
||
trigger.addEventListener('mouseenter', function(event) {
|
||
positionTooltip(event);
|
||
tooltip.classList.add('show');
|
||
});
|
||
|
||
// Hide tooltip when mouse leaves trigger
|
||
trigger.addEventListener('mouseleave', function() {
|
||
tooltip.classList.remove('show');
|
||
});
|
||
|
||
// Keep tooltip visible when hovering over the tooltip itself
|
||
tooltip.addEventListener('mouseenter', function() {
|
||
tooltip.classList.add('show');
|
||
});
|
||
|
||
tooltip.addEventListener('mouseleave', function() {
|
||
tooltip.classList.remove('show');
|
||
});
|
||
|
||
// Reposition on window resize
|
||
window.addEventListener('resize', function() {
|
||
if (tooltip.classList.contains('show')) {
|
||
positionTooltip();
|
||
}
|
||
});
|
||
}
|
||
|
||
// Initialize when DOM is ready
|
||
if (document.readyState === 'loading') {
|
||
document.addEventListener('DOMContentLoaded', initializeTooltip);
|
||
document.addEventListener('DOMContentLoaded', initializeRoleTooltip);
|
||
} else {
|
||
initializeTooltip();
|
||
initializeRoleTooltip();
|
||
}
|
||
</script>
|
||
|
||
<script>
|
||
$(document).on('click', '#btnAdd', function(){
|
||
$('#first_name').val('');
|
||
$('#last_name').val('');
|
||
$('#email').val('');
|
||
$('#mobile').val('');
|
||
$('#emp_code').val('');
|
||
$('#UserForm').attr('action', '<?php echo base_url('/user/create');?>');
|
||
let myModal = new bootstrap.Modal(document.getElementById('con-close-modal'));
|
||
myModal.show(); // open modal
|
||
|
||
});
|
||
$(document).on('click', '#btnNhancePartnerAdd', function(){
|
||
$('#partner_name').val('');
|
||
$('#email_addr').val('');
|
||
$('#partner_id').val('');
|
||
$('#mobile_no').val('');
|
||
$('#locn').val('');
|
||
$('.modal-title').html('Add Nhance Partner');
|
||
$('#PartnerForm').attr('action', '<?php echo base_url('/user/partner');?>');
|
||
let myModal = new bootstrap.Modal(document.getElementById('nhance-partner-modal'));
|
||
myModal.show(); // open modal
|
||
|
||
});
|
||
|
||
|
||
</script>
|