323 lines
15 KiB
PHP
Executable File
323 lines
15 KiB
PHP
Executable File
<style>
|
|
#datatable_filter {
|
|
float: inline-end;
|
|
}
|
|
|
|
#datatable_wrapper .row .col-sm-4 {
|
|
flex-basis: 50%;
|
|
float: inline-end;
|
|
}
|
|
|
|
#datatable_paginate .pagination {
|
|
flex-basis: 50%;
|
|
float: inline-end;
|
|
margin: 0 0 15px;
|
|
}
|
|
|
|
#datatable_wrapper .row:nth-child(3),
|
|
#datatable_wrapper .row:nth-child(1) {
|
|
padding: 0 15px;
|
|
}
|
|
|
|
#datatable_info {
|
|
margin-top: 5px;
|
|
}
|
|
|
|
.dataTables_wrapper {
|
|
padding-bottom: 0;
|
|
}
|
|
|
|
.Date-filter-form {
|
|
display: flex;
|
|
align-items: center;
|
|
gap: 10px;
|
|
/* Adjust the gap as needed */
|
|
}
|
|
|
|
.Date-filter-form input,
|
|
.Date-filter-form button {
|
|
padding: 5px;
|
|
font-size: 14px;
|
|
}
|
|
|
|
.Date-filter-form button {
|
|
background-color: #007bff;
|
|
color: white;
|
|
border: none;
|
|
cursor: pointer;
|
|
}
|
|
|
|
.Date-filter-form button:hover {
|
|
background-color: #0056b3;
|
|
}
|
|
|
|
.icon-button {
|
|
background: none;
|
|
border: none;
|
|
cursor: pointer;
|
|
color: #007bff;
|
|
font-size: 18px;
|
|
}
|
|
|
|
.icon-button:hover {
|
|
color: #0056b3;
|
|
}
|
|
</style>
|
|
|
|
|
|
|
|
|
|
|
|
<div class="content-page">
|
|
<div class="content">
|
|
<!-- Start Content-->
|
|
<div class="container-fluid">
|
|
<!-- start page title -->
|
|
<div>
|
|
<?php
|
|
helper('form');
|
|
$error = session()->getFlashdata('error');
|
|
if ($error) {
|
|
$type = "error";
|
|
echo show_alert($type, $error);
|
|
}
|
|
$success = session()->getFlashdata('success');
|
|
if ($success) {
|
|
$type = "success";
|
|
echo show_alert($type, $success);
|
|
}
|
|
?>
|
|
<div class="row">
|
|
<div class="col-12">
|
|
<div class="page-title-box page-title-box-alt">
|
|
<div class="page-title-right">
|
|
<ol class="breadcrumb m-0">
|
|
<li class="breadcrumb-item"><a href="javascript: void(0);">HR</a></li>
|
|
<li class="breadcrumb-item active">
|
|
<h4 class="page-title">Employee Details</h4>
|
|
</li>
|
|
</ol>
|
|
</div>
|
|
|
|
<a class="btn btn-success" href="<?php echo base_url(); ?>addemployee">Add New Employee</a>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div class="row">
|
|
<div class="col-12">
|
|
<div class="card">
|
|
|
|
<div class="card-body" style="overflow-x:scroll;">
|
|
|
|
<table id="datatable" class="table table-hover table-bordered" style="background-color:#fff;">
|
|
<thead>
|
|
<tr>
|
|
<th >Emp ID</th>
|
|
<th>Employee Name</th>
|
|
<th>Contact Number</th>
|
|
<th>Designation</th>
|
|
<th>Date Of Joining</th>
|
|
<th>Department</th>
|
|
<th>Active</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
<?php
|
|
if (!empty($userRecords)) {
|
|
foreach ($userRecords as $record) {
|
|
$dateOfJoining = new DateTime($record->DateofJoining);
|
|
$dateOfJoining = $dateOfJoining->format('d-m-Y');
|
|
|
|
?>
|
|
<tr>
|
|
<?php if (date('d-m-Y', strtotime($record->Created_date)) == "30-11--0001") {
|
|
$cdate = '00-00-0000';
|
|
} else {
|
|
$cdate = date('d-m-Y', strtotime($record->Created_date));
|
|
} ?>
|
|
<td>
|
|
<a class="a_tag_link" href="<?php echo base_url() . 'employeedetails/ViewEmployee/?EmpID=' . $record->EmpID; ?>" data-toggle="tooltip" title="<?php echo $record->EmpID; ?> - Click here to view Employee details"><?php echo $record->EmpID ?> </a></u>
|
|
|
|
|
|
<a href="<?php echo base_url() . 'employeedetails/downloadEmployeeDetails/?EmpID=' . $record->EmpID; ?>">
|
|
<i class="fas fa-download"></i>
|
|
</a>
|
|
|
|
<a href="#" data-toggle="modal" data-target="#accordion-modal" data-emp="<?php echo $record->EmpID ?>">
|
|
<i class="fas fa-history"style="text-align: center;"></i>
|
|
</a>
|
|
|
|
</td>
|
|
<td><?php echo $record->FirstName; ?></td>
|
|
<td><?php echo $record->ContactNumber ?></td>
|
|
<td><?php echo $record->Designation ?></td>
|
|
<td><?php echo $dateOfJoining?></td>
|
|
<td><?php echo $record->DepartmentName ?></td>
|
|
|
|
<td><?php echo ($record->IsActive == 1) ? ' Active ' : ' In Active '; ?></td>
|
|
</tr>
|
|
<?php
|
|
}
|
|
}
|
|
?>
|
|
|
|
</tbody>
|
|
</table>
|
|
</div> <!-- end card body-->
|
|
</div> <!-- end card -->
|
|
</div><!-- end col-->
|
|
</div>
|
|
</div>
|
|
</div> <!-- container -->
|
|
</div> <!-- content -->
|
|
</div>
|
|
|
|
<div id="accordion-modal" class="modal fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true" style="display: none;">
|
|
<div class="modal-dialog modal-lg">
|
|
<div class="modal-content p-0">
|
|
<div id="accordion">
|
|
<div class="card mb-0">
|
|
<div class="card-header" id="headingOne">
|
|
<h5 class="m-0">
|
|
<a href="#collapseOne" class="text-dark" data-toggle="collapse" aria-expanded="true" aria-controls="collapseOne">
|
|
Salary History #1
|
|
</a>
|
|
</h5>
|
|
</div>
|
|
|
|
<div id="collapseOne" class="collapse show" aria-labelledby="headingOne" data-parent="#accordion">
|
|
<div class="card-body">
|
|
<div id="HisStatement1"></div>
|
|
</div>
|
|
</div>
|
|
</div><!-- /.c a r d 1 -->
|
|
<div class="card mb-0">
|
|
<div class="card-header" id="headingTwo">
|
|
<h5 class="m-0">
|
|
<a href="#collapseTwo" class="collapsed text-dark" data-toggle="collapse" aria-expanded="false" aria-controls="collapseTwo">
|
|
Active and Deactivate History #2
|
|
</a>
|
|
</h5>
|
|
</div>
|
|
<div id="collapseTwo" class="collapse" aria-labelledby="headingTwo" data-parent="#accordion">
|
|
<div class="card-body">
|
|
<div id="HisStatement2"></div>
|
|
</div>
|
|
</div>
|
|
</div><!-- /.c a r d 2 -->
|
|
</div><!-- /.a c c o r d i o n -->
|
|
</div><!-- /.modal-content -->
|
|
</div><!-- /.modal-dialog -->
|
|
</div><!-- /.modal -->
|
|
|
|
<script type="text/javascript" src="<?php echo base_url(); ?>public/assets/js/common.js" charset="utf-8"></script>
|
|
|
|
<script>
|
|
$(document).ready(function() {
|
|
$.fn.dataTable.ext.type.order['date-eu-pre'] = function(date) {
|
|
var dateSplit = date.split('-');
|
|
return (dateSplit[2] + dateSplit[1] + dateSplit[0]) * 1;
|
|
};
|
|
// Initialize the DataTable
|
|
|
|
var table = $('#datatable').DataTable({
|
|
dom: 'Blfrtip',
|
|
buttons: [
|
|
'excel', 'pdf'
|
|
],
|
|
pageLength: 10,
|
|
lengthMenu: [ [10, 20, 30, 50, -1], [10, 20, 30, 50, "All"] ], // Rows per page options
|
|
responsive: false,
|
|
order: false,
|
|
language: {
|
|
paginate: {
|
|
next: '<i class="fas fa-angle-right"></i>', // Next button icon
|
|
previous: '<i class="fas fa-angle-left"></i>' // Previous button icon
|
|
}
|
|
}
|
|
});
|
|
|
|
|
|
// Handle form submission
|
|
$("#DateRangeFilter").submit(function(e) {
|
|
e.preventDefault();
|
|
table.draw();
|
|
});
|
|
});
|
|
$(document).ready(function() {
|
|
$("#accordion-modal").on("shown.bs.modal", function(e) {
|
|
var emp = $(e.relatedTarget).data('emp');
|
|
var noData = '<p style="text-align: center;">No History Data Available</p>';
|
|
$("#HisStatement1").empty();
|
|
$("#HisStatement2").empty();
|
|
|
|
|
|
|
|
if (emp !== "") {
|
|
$.ajax({
|
|
data: {
|
|
emp: emp
|
|
},
|
|
type: "POST",
|
|
url: "<?php echo base_url() ?>employeeHistory",
|
|
success: function(data) {
|
|
var output1 = '';
|
|
var output2 = '';
|
|
|
|
if (data && data.length > 0) {
|
|
let salaryArr = data.filter(d => d.column_name == "TotalSalary");
|
|
let activeArr = data.filter(d => d.column_name != "TotalSalary");
|
|
|
|
if (salaryArr && salaryArr.length > 0) {
|
|
salaryArr.forEach(function(record) {
|
|
// Declare statement inside the loop to reset for each record
|
|
let statement1 = "Salary Changed from <b> `" + record.old_value + "` </b> to <b> `" + record.new_value + "` </b> by " + record.updater_name +
|
|
" on " + record.indian_date + " at " + record.indian_time;
|
|
output1 += '<p style="font-size:13px;"> • ' + statement1 + '</p>';
|
|
});
|
|
}else{
|
|
output1 = noData;
|
|
|
|
}
|
|
|
|
if (activeArr && activeArr.length > 0) {
|
|
activeArr.forEach(function(record, index) {
|
|
if (record.column_name === "IsActive" && index % 2 === 0) { // Even index for "IsActive"
|
|
let action = record.new_value === "0" ? "Deactivated" : "Activated";
|
|
statement2 = "User " + action + " by " + record.updater_name +
|
|
" on " + record.indian_date + " at " + record.indian_time;
|
|
}
|
|
|
|
if (record.column_name === "reason" && index % 2 !== 0) { // Odd index for "reason"
|
|
statement2 += " Reason " + " ( " + record.new_value + " ) ";
|
|
output2 += '<p style="font-size:13px;"> • ' + statement2 + '</p>';
|
|
}
|
|
|
|
|
|
});
|
|
}else{
|
|
output2 = noData;
|
|
}
|
|
}else{
|
|
output1 = noData;
|
|
output2 = noData;
|
|
}
|
|
|
|
$("#HisStatement1").html(output1);
|
|
$("#HisStatement2").html(output2);
|
|
|
|
},
|
|
error: function(xhr, status, error) {
|
|
$("#HisStatement1").html(noData);
|
|
$("#HisStatement1").html(noData);
|
|
console.error('AJAX Error: ' + status + error);
|
|
}
|
|
});
|
|
} else {
|
|
$("#HisStatement1").html(noData);
|
|
$("#HisStatement2").html(noData);
|
|
}
|
|
});
|
|
});
|
|
|
|
</script>
|