overtime listing and leave application

This commit is contained in:
VE10-Sanjeev 2025-03-26 12:51:42 +00:00
parent 6b8dba5cbc
commit c34cb64325
12 changed files with 1097 additions and 27 deletions

View File

@ -195,6 +195,10 @@ $routes->post('monthlypay/addper', 'Monthlypay::addper');
$routes->post('monthlypay/saveAttendance', 'Monthlypay::saveAttendance');
$routes->post('monthlypay/savePublicHolidays', 'Monthlypay::savePublicHolidays');
$routes->post('monthlypay/deletePublicHoliday', 'Monthlypay::deletePublicHoliday');
$routes->get('leaveApplicationForm', 'Monthlypay::leaveApplicationForm');
$routes->post('fetchLeaveApplicationForm', 'Monthlypay::fetchLeaveApplicationForm');
$routes->get('deleteLeaveApplicationForm', 'Monthlypay::deleteLeaveApplicationForm');
$routes->match(['GET', 'POST'], 'overTimeDetails', 'Monthlypay::overTimeDetails');
$routes->get('emppaydate/addemppaydate', 'Emppaydate::addemppaydate');
$routes->post('emppaydate/addNewemppay', 'Emppaydate::addNewemppay');

View File

@ -174,6 +174,7 @@ class Driver extends BaseController
$data['input_driver_id'] = $input_driver_id;
$data['input_diesel_amount'] = isset($amount->diesel_amount) ? $amount->diesel_amount : 0 ;
$data['input_shed_amount'] = isset($amount->shed_amount) ? $amount->shed_amount : 0 ;
$data['payslip_id'] = $this->driver_model->checkPayslipDetails($input_driver_id,"$month-$year");
$this->global['pageTitle'] = 'Driver Attendance List';
$this->loadViews("driverAttendance", $this->global, $data, NULL);

View File

@ -871,8 +871,8 @@ class Employeedetails extends BaseController
$HRA_Amount = $this->request->getPost('HRA_Amount');
$PF_Rate = $this->request->getPost('PF_Rate');
$ESI_Rate = $this->request->getPost('ESI_Rate');
$CreateBy = $this->session->get('userId');
$emppay = array('EmpID' => $EmpId, 'TotalSalary' => $Total_Salary, 'Basic_Pay' => $Basic_Pay, 'HRA_Rate' => $HRA_Rate, 'HRA_Amount' => $HRA_Amount, 'PF_Rate' => $PF_Rate, 'ESI_Rate' => $ESI_Rate, 'Created_By' => $CreateBy);
$Last_Mod_By = $this->session->get('userId');
$emppay = array('EmpID' => $EmpId, 'TotalSalary' => $Total_Salary, 'Basic_Pay' => $Basic_Pay, 'HRA_Rate' => $HRA_Rate, 'HRA_Amount' => $HRA_Amount, 'PF_Rate' => $PF_Rate, 'ESI_Rate' => $ESI_Rate, 'Last_Mod_By' => $Last_Mod_By);
$empPayUpdate = $this->emppaydate_model->editemppay($emppay);

View File

@ -927,4 +927,79 @@ class Monthlypay extends BaseController
$data['productionsalary'] = $this->monthlypay_model->cost($ab, $from, $to);
$this->loadviews('salarycostforproduction', $this->global, $data, NULL);
}
function leaveApplicationForm(){
$this->global['pageTitle'] = 'Employee Leave Application Form';
$data['leave_info'] = $this->monthlypay_model->getheringleaveApplicationForm();
$data['employee_info'] = $this->monthlypay_model->getheringemployeeinformation();
$data['status_info'] = ["Draft","Approved"];
$this->loadviews('employeeLeaveApplicationForm', $this->global, $data, NULL);
}
public function fetchLeaveApplicationForm(){
$userId = $this->session->get('userId');
$id = $this->request->getPost('leave_application_id');
$emp_id = $this->request->getPost('emp_id');
$start_date = $this->request->getPost('start_date');
$end_date = $this->request->getPost('end_date');
$no_of_days = $this->request->getPost('no_of_days');
$reason = $this->request->getPost('reason');
$status = $this->request->getPost('status');
$data = ['status' => false, 'message' => 'An error occurred while creating Leave Applicationform details'];
$leave_details = ['emp_id' => $emp_id,'start_date' =>$start_date,'end_date' =>$end_date,'no_of_days' =>$no_of_days,'reason' =>$reason,'status' => $status];
if ((int)$id == 0) {
$leave_details['created_by'] = $userId;
$affectedRows = $this->monthlypay_model->saveleaveApplicationForm($leave_details,$id);
if ($affectedRows > 0) {
$data = ['status' => true, 'message' => 'Leave Applicationform details created successfully.'];
}
} else {
$leave_details['leave_application_id'] = $id;
$leave_details['updated_by'] = $userId;
$affectedRows = $this->monthlypay_model->saveleaveApplicationForm($leave_details,$id);
if ($affectedRows > 0) {
$data = ['status' => true, 'message' => 'Leave Applicationform details updated successfully.'];
}else{
$data = ['status' => true, 'message' => 'There is no changes in Leave Applicationform details.'];
}
}
return $this->response->setJSON($data);
}
function deleteLeaveApplicationForm()
{
$leave_application_id = $this->request->getGet('leave_application_id') ? $this->request->getGet('leave_application_id') : '';
if(!empty($leave_application_id)){
$data = ['isactive' => 0,'updated_by' => $this->session->get('userId')];
$affectedRows = $this->monthlypay_model->saveleaveApplicationForm($data,$leave_application_id);
$message = ($affectedRows > 0) ? "Leave Applicationform deleted successfully." : "Leave Applicationform already deleted.";
}else{
$message = "Leave Applicationform details not available.";
}
$this->session->setFlashdata('success', $message);
return redirect()->to(base_url('leaveApplicationForm'));
}
public function overTimeDetails()
{
$current = $this->request->getPost('monthyear') ? $this->request->getPost('monthyear') :date("m-Y");
$data['month'] = $this->monthlypay_model->monthlyListing($current);
$data['dropdownvalue'] = $current;
$data['fresh'] = $this->monthlypay_model->getEmpPayDetailsforOTListing($current);
$this->global['pageTitle'] = 'OverTime Details';
$this->loadviews('overTimeDetails', $this->global, $data, NULL);
}
}

View File

@ -47,15 +47,13 @@ class Driver_model extends Model
return $this->table . '.' . $field;
}, $this->allowedFields));
$selectFields = "CONCAT_WS(' ', t_employee_details.FirstName, t_employee_details.LastName) AS FullName, t_employee_details.IsActive as employee_isactive, CONCAT_WS(' ', driver.FirstName, driver.LastName) AS driver_name,ip_clients.client_name as customer,ip_invoices.received_qty as quantity,t_driver_payroll.id as payroll_id,t_driver_payroll.PayOn," . $fields;
$selectFields = "CONCAT_WS(' ', t_employee_details.FirstName, t_employee_details.LastName) AS FullName, t_employee_details.IsActive as employee_isactive, CONCAT_WS(' ', driver.FirstName, driver.LastName) AS driver_name,t_driver_payroll.id as payroll_id,t_driver_payroll.PayOn," . $fields;
$month_year = get_date_time_dynamical_format('Y-m-d','m-Y',"$from");
return $this->select($selectFields)
->join('t_employee_details as driver', 'driver.EmpID = ' . $this->table . '.driver_id', 'left')
->join('tbl_users', 'tbl_users.userId = ' . $this->table . '.created_by', 'left')
->join('t_employee_details', 'tbl_users.EmpID = t_employee_details.EmpID', 'left')
->join('ip_invoices', 'ip_invoices.invoice_number = ' . $this->table . '.invoice_number', 'left')
->join('ip_clients', 'ip_clients.client_id = ip_invoices.client_id', 'left')
->join('t_driver_payroll', 't_driver_payroll.driver_id = '.$this->table.'.driver_id and t_driver_payroll.PayOn = "'.$month_year.'"', 'left')
->where($this->table.'.date BETWEEN "'.$from.'" AND "'.$to.'"')
->where($this->table . '.driver_id', $driver_id)
@ -64,6 +62,19 @@ class Driver_model extends Model
->findAll();
}
function checkPayslipDetails($input_driver_id,$month_year){
$builder = $this->db->table('t_driver_payroll')
->where('t_driver_payroll.driver_id', $input_driver_id)
->where('t_driver_payroll.PayOn', $month_year);
$query = $builder->get();
$result = $query->getRowArray();
if (!empty($result['id'])) {
return $result['id'];
}else{
return 0;
}
}
function getInvoiceInfo()
{
$builder = $this->db->table('ip_invoices')

View File

@ -518,4 +518,88 @@ where Month_Year = ? and att.EmpID in (select EmpID from t_attendance)";
$query = $this->db->query($sql);
return $query->getResult();
}
public function getheringleaveApplicationForm(){
$sql = "select leavetable.* ,Dep.DepartmentName as department,Emp.Designation as designation,
CONCAT_WS(' ', Emp.FirstName, Emp.LastName) AS employeeFullName ,
CONCAT_WS(' ', Emp2.FirstName, Emp2.LastName) AS creatorFullName
from t_employee_leave_application_form as leavetable
left join tbl_users as user on user.userId = leavetable.created_by
left join t_employee_details as Emp2 on Emp2.EmpID = user.EmpID
left join t_employee_details as Emp on Emp.EmpID = leavetable.emp_id
left join t_departmentdetails as Dep on Emp.Departmentcode = Dep.DEPCode
where leavetable.isactive = 1";
$query = $this->db->query($sql);
return $query->getResultArray();
}
public function getheringemployeeinformation(){
$builder = $this->db->table("t_employee_details as Emp")
->select("Emp.EmpID,Emp.Designation,Emp.Departmentcode,Dep.DEPCode,Emp.Designation,Emp.Departmentcode,Dep.DEPCode,Dep.DepartmentName as DepartmentNamee,Dep.DepartmentName as DepartmentName")
->select("CONCAT_WS(' ', Emp.FirstName, Emp.LastName) AS FullName")
->join("t_departmentdetails as Dep", "Emp.Departmentcode = Dep.DEPCode", "left")
->orderBy("Emp.EmpID", "asc");
$query = $builder->get();
$result = $query->getResult();
return $result;
}
public function saveleaveApplicationForm($data,$id){
if ($id == 0) {
$builder = $this->db->table('t_employee_leave_application_form');
$builder->insert($data);
return $this->db->affectedRows();
} else if ($id != 0) {
$this->db->table('t_employee_leave_application_form')
->where('leave_application_id', $id)
->update($data);
return $this->db->affectedRows();
}
}
function getEmpPayDetailsforOTListing($current = "")
{
//$month = '0'.$current;
$month = $current;
if (strlen($month) == 6) {
$month = '0' . $month;
}
$current = '01-' . $current;
//echo $current;
$current = format_date($current);//3rd
//echo 'Final'.$current;
$month_val = date('m', strtotime($current));
$year_val = date('Y', strtotime($current));
$date_val = cal_days_in_month(CAL_GREGORIAN, $month_val, $year_val);
//$monthyear_val = date('Y-m',strtotime($current));
$lastdate = $year_val . '-' . $month_val . '-' . $date_val;
//echo $lastdate;
//left join t_payroll on t_employee_details.EmpID = t_payroll.EmpID and month(t_payroll.PayOn) = month(?) and year(t_payroll.PayOn) = year(?)
$sql = "select t_emp_pay_data.EmpID,t_emp_pay_data.*,t_employee_details.FirstName,t_attendance.Days_Worked as Days_worked,t_attendance.Absent as LOP_Days,t_attendance.Paid_Leave as Paid_leave,t_attendance.Total_OTHrs as OT_Hrs_Worked,t_attendance.NoofDays,t_employee_details.is_management_team
from t_emp_pay_data
left join t_employee_details on t_employee_details.EmpID = t_emp_pay_data.EmpID
left join t_attendance on t_emp_pay_data.EmpID = t_attendance.EmpID
left join t_monthly_pay_inputs on t_monthly_pay_inputs.EmpID = t_emp_pay_data.EmpID and t_monthly_pay_inputs.Month_Year = ?
where t_employee_details.DateofJoining <= ?
and month(t_attendance.Month_Year) = month(?) and year(t_attendance.Month_Year) = year(?)
and t_attendance.Total_OTHrs != '0.00'
and t_employee_details.is_driver = 0
order by t_employee_details.EmpID";
$query = $this->db->query($sql, array($month, $lastdate, $current, $current));
// Get the last executed query
// $last_query = $this->db->getLastQuery();
// echo $last_query;
// die;
return $query->getResult();
}
}

View File

@ -73,10 +73,14 @@ $datefordropdown = format_date($datefordropdown, 0, 'M-Y');
</form>
</div>
<div class="col-4 text-right" id="savebutton">
<?php if(isset($driver_attendance_list) || $driver_attendance_list[0]['payroll_id'] == ''){ ?>
<?php if($payslip_id == 0){ ?>
<button type="button" style="margin-top:0px;" class="btn btn-success" data-target="#attendanceModal" data-id="0" data-toggle="modal">
Add Trip details
</button>
<?php }else { ?>
<span style="color: green;">Payslip Generated</span>
<?php } ?>
</div>
</div></br>
@ -161,7 +165,7 @@ $datefordropdown = format_date($datefordropdown, 0, 'M-Y');
<th></th>
<th></th>
<th>Diesel</th>
<th><input type="text" class="editable" data-column="diesel_amount"></th>
<th><input type="text" class="editable" data-column="diesel_amount" <?php echo ($payslip_id != 0) ? 'readonly' : ''; ?> ></th>
<th></th>
<th></th>
</tr>
@ -175,7 +179,7 @@ $datefordropdown = format_date($datefordropdown, 0, 'M-Y');
<th></th>
<th></th>
<th>Shed Amount</th>
<th><input type="text" class="editable" data-column="shed_amount"></th>
<th><input type="text" class="editable" data-column="shed_amount" <?php echo ($payslip_id != 0) ? 'readonly' : ''; ?> ></th>
<th></th>
<th></th>
</tr>

View File

@ -1736,11 +1736,16 @@ if (!empty($EmpDetails)) {
}
$(document).ready(function () {
var driverChecked = "<?php echo $is_driver; ?>";
if (driverChecked) {
if (driverChecked == "1") {
$('#Total_salary').prop('required', false);
$('#Total_salary').prop('readonly', true);
}
}
else{
$('#Total_salary').prop('required', true);
$('#Total_salary').prop('readonly', false);
}
if ($("#currentaddress").val().trim() === $("#permanentaddress").val().trim()) {
$("#checksame").prop("disabled", false); // Enable checkbox
$("#checksame").prop("checked", true); // Optionally check it

View File

@ -0,0 +1,491 @@
<div class="content-wrapper"></div>
<div class="content-page">
<div class="content">
<!-- Start Content-->
<div class="container-fluid">
<!-- start page title -->
<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"><a href="javascript: void(0);">Leave</a></li>
<li class="breadcrumb-item active">
<h4 class="page-title">Leave Application Form</h4>
</li>
</ol>
</div>
<a data-toggle="modal" href="#applicationModal" data-id="0" data-name=""
class="btn btn-success">Add Leave Application Form</a>
</div>
</div>
</div><!-- /.end 1st r o w -->
<div class="row">
<div class="col-12">
<div class="card">
<!-- <form class="Date-filter-form" id="DateRangeFilter"
style="margin-top: 14px;margin-bottom: -11px;margin-left: 33px;">
<input type="hidden" name="table" value="requisition">
<label for="fromDate">From:</label>
<input class="form-control date_range form-date-search" id="fromDate" name="fromDate"
placeholder="Select From Date" autocomplete="off" required>
<label for="toDate">To:</label>
<input class="form-control date_range to-date-search" id="toDate" name="toDate"
placeholder="Select To Date" autocomplete="off" required>
<button type="submit" class="range_search_button"><i class="fe-search" aria-hidden="true"
class="icon-button" title="Search"></i></button>
<i class="fe-rotate-cw range_reset_button" aria-hidden="true" class="icon-button"
id="resetButton" title="Reset"></i>
<div class="error" id="error"></div>
</form> -->
<!-- <div style="margin-left:auto">
<div class="form-check" style="margin-right: 25px;">
<form id="archiveFormId" action="<?php // echo base_url()?>/transporterListing" method="post">
<input class="form-check-input" type="checkbox" id="showArchiveId"
name="showArchive" value="1" <?php // echo $showArchive ? "checked" : " " ?>
style="width: 18px; height: 18px;">
<label class="form-check-label" for="showArchiveId"
style="font-size: 1rem; margin-left: 8px;">
Show Archive
</label>
</form>
</div>
</div> -->
<div class="card-body" style="overflow-x:scroll;">
<div class="card-body">
<div class="box">
<div class="box-header">
<div class="box-tools"></div>
</div>
<div class="box-body">
<div class="table-responsive" style="overflow-x:scroll;">
<table id="leave_app_listing" class="table dt-responsive nowrap w-100">
<thead>
<tr>
<th>Create Date</th>
<th>Create By</th>
<th>Employee Name</th>
<th>Number Of Days</th>
<th>Status</th>
<th>Action</th>
</tr>
</thead>
<tbody>
<?php
if (!empty($leave_info)) :
foreach ($leave_info as $d) {
$createdat = new DateTime($d['created_on']);
$crdate = $createdat->format('d-m-Y');
$crtime = $createdat->format('h:i A');
?>
<tr>
<td><?= esc($crdate) ?></td>
<td><?= esc($d['creatorFullName']) ?></td>
<td><?= esc($d['employeeFullName']) ?></td>
<td><?= esc($d['no_of_days']) ?></td>
<td><?= esc($d['status']) ?></td>
<td><?php if($d['leave_application_id']){ ?>
<a data-toggle="modal" href="#applicationModal" data-arr='<?php echo json_encode($d); ?>' data-id='<?= esc($d['leave_application_id']) ?>'>
<i class="fas fa-edit"></i>&nbsp;&nbsp;&nbsp;
</a>
<a onclick="confirmDelete(event)" style="cursor:pointer;" href="<?php echo base_url() . 'deleteLeaveApplicationForm?leave_application_id=' . esc($d['leave_application_id']); ?>">
<i class="fa fa-trash"></i>&nbsp;&nbsp;&nbsp;
</a>
<?php } ?>
</td>
</tr>
<?php } ?>
<?php endif; ?>
</tbody>
</table>
</div>
<p>&nbsp;</p>
</div><!-- /. end b o x-b o d y -->
</div><!-- /.end b o x -->
</div> <!-- end c a r d b o d y-->
</div> <!-- /. end c a r d -->
</div><!-- /. end c o l-->
</div> <!-- /.end 2nd r o w -->
</div> <!-- /.end c o n t a i n e r -->
</div> <!-- /.end c o n t e n t -->
</div>
<!-- leave Application entries modal -->
<div class="modal fade" id="applicationModal" tabindex="-1" role="dialog" aria-labelledby="applicationformTitle" aria-hidden="true">
<div class="modal-dialog modal-xl" style="width:900px;">
<div class="modal-content">
<div class="modal-header">
<h4 class="modal-title" id="applicationformTitle">Add Application</h4>
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
</div>
<div class="modal-body">
<form id="applicationForm" class="form-horizontal" role="form">
<input type="hidden" class="form-control" id="leave_application_id" name="leave_application_id">
<div class="row mt-2">
<div class="col-md-3" style="text-align: end; align-content: center;">
<label class="form" for="emp_name">Employee Name</label>
</div>
<div class="col-md-9">
<select class="form-control" id="emp_name" name="emp_name" onchange="fetchemployees(this);">
<option value="">Select</option>
<?php foreach ($employee_info as $key => $value) { ?>
<option value="<?= $value->EmpID; ?>"
data-department="<?= $value->DepartmentName; ?>"
data-designation="<?= $value->Designation; ?>">
<?= $value->FullName; ?>
</option>
<?php } ?>
</select>
</div>
</div><!--/. r o w 1 -->
<div class="row mt-2">
<div class="col-md-3" style="text-align: end; align-content: center;">
<label class="form" for="emp_id">Employee ID</label>
</div>
<div class="col-md-9">
<input type="text" class="form-control" id="emp_id" name="emp_id" readonly>
</div>
</div><!--/. r o w 2-->
<div class="row mt-2">
<div class="col-md-3" style="text-align: end; align-content: center;">
<label class="form" for="department">Department</label>
</div>
<div class="col-md-9">
<input type="text" class="form-control" id="department" name="department" readonly>
</div>
</div><!--/. r o w 3 -->
<div class="row mt-2">
<div class="col-md-3" style="text-align: end; align-content: center;">
<label class="form" for="designation">Designation </label>
</div>
<div class="col-md-9">
<input type="text" class="form-control" id="designation" name="designation" readonly>
</div>
</div><!--/. r o w 4 -->
<div class="row mt-2">
<div class="col-md-3" style="text-align: end; align-content: center;">
<label class="form" for="No. of days">No. of days </label>
</div>
<div class="col-md-3">
<label class="form" for="start_date">from Date</label>
<input type="date" class="form-control" id="start_date" name="start_date" required>
</div>
<div class="col-md-3">
<label class="form" for="end_date">to Date</label>
<input type="date" class="form-control" id="end_date" name="end_date" required>
</div>
<div class="col-md-3">
<label class="form" for="no_of_days">No's Days </label>
<input type="text" class="form-control" id="no_of_days" name="no_of_days">
</div>
</div><!--/. r o w 5 -->
<div class="row mt-2">
<div class="col-md-3" style="text-align: end; align-content: center;">
<label class="form" for="status_val">Status</label>
</div>
<div class="col-md-9">
<select class="form-control" id="status_val" name="status_val">
<option value="">Select</option>
<?php foreach ($status_info as $key => $value) { ?>
<option value="<?= $value; ?>"> <?= $value; ?> </option>
<?php } ?>
</select>
</div>
</div><!--/. r o w 6 -->
<div class="row mt-2">
<div class="col-md-3" style="text-align: end; align-content: center;">
<label class="form" for="reason">Reason</label>
</div>
<div class="col-md-9">
<textarea class="form-control" id="reason" name="reason" ></textarea>
</div>
</div><!--/. r o w 7 -->
</form>
</div><!-- /. m o d a l b o d y -->
<div class="modal-footer">
<button type="button" class="btn btn-secondary waves-effect" data-dismiss="modal"
value="Cancel">Cancel</button>
<button type="button" class="btn btn-info waves-effect waves-light tempClick"
id="tempClick">Submit</button>
</div>
</div><!-- /. m o d a l-c o n t e n t -->
</div><!-- /.m o d a l-d i a l o g -->
</div>
<script type="text/javascript" src="<?php echo base_url(); ?>public/assets/js/common.js" charset="utf-8"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/xlsx/0.18.5/xlsx.full.min.js"></script>
<script>
$(document).ready(function () {
$('#start_date, #end_date').change(function() {
const start = new Date($('#start_date').val());
const end = new Date($('#end_date').val());
if (!isNaN(start) && !isNaN(end)) {
const days = Math.floor((end - start) / 86400000) + 1;
$('#no_of_days').val(days > 0 ? days : 1);
} else {
$('#no_of_days').val('');
}
});
$("#applicationModal").on("shown.bs.modal", function (e) {
var id = $(e.relatedTarget).data('id');
let fields = ['leave_application_id','emp_id','start_date','end_date','no_of_days','reason','status_val','emp_name','department','designation'];
fields.forEach(function(field) {
$("#" + field).val("");
});
if (id == 0) {
$('#applicationformTitle').html("Add Leave Application Form");
$("#leave_application_id").val(0);
} else {
var arr = $(e.relatedTarget).data('arr');
fields.forEach(function(field) {
$("#" + field).val(arr && arr[field] ? arr[field] : "");
if(field == 'emp_name'){
$("#emp_name").val(arr && arr['emp_id']);
}
if(field == 'status_val'){
$("#status_val").val(arr && arr['status']);
}
});
$('#applicationformTitle').html("Edit Leave Application Form");
}
});
$('#tempClick').click(function () {
if ($('#emp_id').val() === '') {
alert('Please Select the Valid Employee');
return;
}
if ($('#start_date').val() === '') {
alert('Please Enter the Valid From Date');
return;
}
if ($('#end_date').val() === '') {
alert('Please Enter the Valid To Date');
return;
}
if ($('#reason').val() === '') {
alert('Please Enter the Reason');
return;
}
if ($('#status_val').val() === '') {
alert('Please Select Status');
return;
}
var formData = {
leave_application_id:$('#leave_application_id').val(),
emp_id:$('#emp_id').val(),
start_date:$('#start_date').val(),
end_date:$('#end_date').val(),
no_of_days:$('#no_of_days').val(),
reason:$('#reason').val(),
status:$('#status_val').val(),
};
$('#loader').show();
$.ajax({
type: 'POST',
url: "<?php echo base_url(); ?>fetchLeaveApplicationForm",
data: formData,
dataType: 'json',
success: function (response) {
$('#loader').hide();
if (response.status) {
alert(response.message);
location.reload();
} else {
alert(response.message);
}
},
error: function (xhr, status, error) {
$('#loader').hide();
console.error('An error occurred: ' + error);
},
complete: function () {
$('#loader').hide();
console.log("ajax call completed");
}
});
});
$.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 = $('#leave_app_listing').DataTable({
dom: 'Blfrtip',
buttons: [
'excel', 'pdf'
],
pageLength: 10,
lengthMenu: [
[10, 20, 30, 50, -1],
[10, 20, 30, 50, "All"]
],
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
}
}
});
// Date range filter function
$.fn.dataTable.ext.search.push(
function (settings, data, dataIndex) {
var fromDate = $('#fromDate').val();
var toDate = $('#toDate').val();
if (!fromDate || !toDate) {
return true; // If no dates selected, don't filter
}
// Convert the fromDate and toDate from dd-mm-yyyy to Date objects
var fromParts = fromDate.split("-");
var toParts = toDate.split("-");
var startDate = new Date(fromParts[2], fromParts[1] - 1, fromParts[0]); // Year, month (0-based), day
var endDate = new Date(toParts[2], toParts[1] - 1, toParts[0]);
// Adjust startDate to include the day before the selected fromDate
startDate.setDate(startDate.getDate() - 1);
// Ensure endDate includes the entire end date by setting time to the end of the day
endDate.setHours(23, 59, 59, 999);
// Get the date from the DataTable row (assuming it's in the first column in dd-mm-yyyy format)
var dateStr = data[0];
var dateParts = dateStr.split("-");
var rowDate = new Date(dateParts[2], dateParts[1] - 1, dateParts[0]);
// Return true if the row date is within the range
return rowDate >= startDate && rowDate <= endDate;
}
);
// Handle form submission for the date range filter
// $("#DateRangeFilter").submit(function (e) {
// e.preventDefault();
// table.draw(); // Redraw the table to apply the filter
// });
// Reset button functionality
// $("#resetButton").click(function () {
// $("#fromDate").val('');
// $("#toDate").val('');
// table.draw(); // Redraw the table to clear the filter
// });
// Automatically focus and open the To Date picker when From Date is selected
// document.getElementById('fromDate').addEventListener('change', function () {
// var fromDate = this.value;
// var toDateInput = document.getElementById('toDate');
// // Set the min attribute of the To Date input to the selected From Date
// toDateInput.min = fromDate;
// // Optionally reset the To Date input if the current value is before the new min date
// if (toDateInput.value < fromDate) {
// toDateInput.value = fromDate;
// }
// });
});
</script>
<script>
$(window).on('load', function () {
function flashMessage() {
// Fetch the flash data from PHP and encode it for JavaScript
let message = <?= json_encode(session()->getFlashdata('success')) ?>;
if (message) {
alert(message);
}
}
flashMessage();
})
function confirmDelete(event) {
let result = confirm(` Do you Confirm to Delete the Leave Applicationform Detail?`);
if (result) { return result; } else { event.preventDefault(); }
}
function confirmReActivate(event) {
let result = confirm(` Do you Confirm to Re-activate the Leave Applicationform Detail?`);
if (result) { return result; } else { event.preventDefault(); }
}
function fetchemployees(selectElement){
$('#emp_id').val("");
$('#department').val("");
$('#designation').val("");
const selectedOption = selectElement.options[selectElement.selectedIndex];
let empId = selectedOption.value;
// Check if nothing is selected
if (empId === "") {
alert("Please select an employee!");
return; // Exit the function early
}
let department = selectedOption.getAttribute('data-department');
let position = selectedOption.getAttribute('data-designation');
$('#emp_id').val(empId);
$('#department').val(department);
$('#designation').val(position);
}
</script>

View File

@ -779,21 +779,10 @@
<a href="<?php echo base_url(); ?>ViewPay" class="dropdown-item">PaySlip Generator</a>
<!-- <a href="<?php echo base_url(); ?>PaysilpListing" class="dropdown-item">Edit Payslip</a> -->
<a href="<?php echo base_url(); ?>emppayListings" class="dropdown-item">Employee Loan Details</a>
<a href="<?php echo base_url(); ?>overTimeDetails" class="dropdown-item">OverTime Details</a>
</div>
</div>
<!-- <div class="dropdown">
<a class="dropdown-item dropdown-toggle arrow-none" href="#" id="topnav-payslip"
role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
<i class="ri-secure-payment-line align-middle mr-1"></i> Driver PaySlip <div class="arrow-down"></div>
</a>
<div class="dropdown-menu" aria-labelledby="topnav-payslip">
<a href="<?php echo base_url(); ?>driverMonthlyPayInputs" class="dropdown-item">Monthly Pay Information </a>
<a href="<?php echo base_url(); ?>driverViewPay" class="dropdown-item">PaySlip Generator</a>
</div>
</div> -->
<div class="dropdown">
<a class="dropdown-item dropdown-toggle arrow-none" href="#" id="topnav-leave"
role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
@ -801,8 +790,8 @@
</a>
<div class="dropdown-menu" aria-labelledby="topnav-leave">
<a href="<?php echo base_url(); ?>publicholidays" class="dropdown-item">Public Holidays</a>
<a href="<?php echo base_url(); ?>leaveApplicationForm" class="dropdown-item">Leave Application Form</a>
<a href="<?php echo base_url(); ?>leavereports" class="dropdown-item"> Reports</a>
</div>
</div>

View File

@ -577,8 +577,10 @@
<?php echo number_format(0.00, 2, '.', ''); ?>
</td>
<td id="ttlsalary<?php echo $inx ?>" style="max-width:80px;text-align:right;" data-empid="<?php echo $record->EmpID; ?>" onclick="openDriverLoad(this)">
<td id="ttlsalary<?php echo $inx ?>" style="max-width:80px;text-align:right;" data-empid="<?php echo $record->EmpID; ?>">
<a href="#" onclick="openDriverLoad(this)">
<?php echo number_format($sum_of_amount, 2, '.', ''); $totalsalary[] = $sum_of_amount; ?>
</a>
</td>
<td style="max-width:80px;text-align:right;">
@ -703,9 +705,16 @@
<tfoot>
<tr>
<th></th> <th></th> <th></th> <th></th> <th></th>
<th></th> <th></th> <th></th> <th></th> <th></th>
<th style=" background-color: #ffffff;"></th>
<th style=" background-color: #ffffff;"></th>
<th style=" background-color: #ffffff;"></th>
<th style=" background-color: #ffffff;"></th>
<th style=" background-color: #ffffff;"></th>
<th style=" background-color: #ffffff;"></th>
<th style=" background-color: #ffffff;"></th>
<th style=" background-color: #ffffff;"></th>
<th style=" background-color: #ffffff;"></th>
<th style=" background-color: #ffffff;"></th>
<th style="text-align:right;">
<?php echo isset($totalsalary) ? number_format(array_sum($totalsalary), 2) : ''; ?>
</th>

397
app/Views/overTimeDetails.php Executable file
View File

@ -0,0 +1,397 @@
<style>
.celda_encabezado_general {
background-color: #00a65a;
border: 1px solid #ccc;
color: #ffffff;
font-weight: bold;
padding: 2px 4px;
text-align: center;
}
.fht-table th:nth-child(1),
.fht-table th:nth-child(2),
.fht-table th:nth-child(3) {
position: sticky;
left: 0;
top: 0;
background-color: #00a65a;
z-index: 7 !important;
border-right: 2px solid #ddd;
color: #ffffff;
}
.fht-table td:nth-child(1),
.fht-table td:nth-child(2),
.fht-table td:nth-child(3) {
position: sticky;
left: 0;
background-color: #ffffff;
z-index: 2;
border-right: 2px solid #ddd;
color: #0e0b0b;
}
.table-responsive {
overflow-y: auto;
max-height: 450px;
}
.fht-table thead th {
position: sticky;
top: 0;
z-index: 5 !important;
}
</style>
<?php
$sample = $fresh;
$ex = explode('-', $dropdownvalue);
if (strlen($ex[0]) == '2') {
if ($ex[0] < 10) {
$ex1 = substr($ex[0], 1);
} else {
$ex1 = $ex[0];
}
} else {
$ex1 = $ex[0];
}
$drop = $ex1 . '-' . $ex[1];
?>
<script>
$('html').bind('keypress', function(e) {
//alert('Key Pressed');
if (e.keyCode == 13) {
return false;
}
});
</script>
<style type="text/css">
.num {
text-align: right;
}
</style>
<div class="content-wrapper">
<!-- Content Header (Page header) -->
<section class="content-header">
<h1>
<center></center>
</h1>
</section>
<section class="content">
<input type="hidden" id="paydate" value="<?php echo $drop; ?>" />
<div class="row">
<div class="col-xs-12">
</div>
</div>
</section>
</div>
<div class="content-page">
<div class="content">
<!-- Start Content-->
<div class="container-fluid">
<!-- start page title -->
<div>
<div class="row">
<div class="col-6">
<div class="page-title-box page-title-box-alt">
<div class="page-title-right">
<ol class="breadcrumb mt-2 mb-2.5">
<li class="breadcrumb-item"><a href="javascript: void(0);">HR</a></li>
<li class="breadcrumb-item"><a href="javascript: void(0);">PaySlip</a></li>
<li class="breadcrumb-item active">
<h4 class="page-title">Overtime Details</h4>
</li>
</ol>
</div>
</div>
</div>
</div>
<div class="row">
<div class="col-12">
<div class="card" id="fullscreenDiv">
<div class="card-body">
<div id="successMessage" style="display: none; position: absolute; top: 10px; left: 50%; transform: translateX(-50%);background: green; color: white; padding: 10px; border-radius: 5px; z-index: 1000;"></div>
<div class="box">
<div class="box-header">
<!--<center><h3 class="box-title">-->
<div class="box-tools"></div>
<!--</h3></center>-->
</div><!-- /.b o x-h e a d e r -->
<?php
$year = date("Y");
$current = date("m-Y");
$month = date("m");
if ($month < 10) {
$month = substr($month, 1);
}
$currentselection = $month . "-" . $year;
$options = array();
$monthsoptions = array("1" => "Jan", "2" => "Feb", "3" => "Mar", "4" => "Apr", "5" => "May", "6" => "June", "7" => "July", "8" => "Aug", "9" => "Sep", "10" => "Oct", "11" => "Nov", "12" => "Dec");
$currentmontharray = array(array($month . "-" . $year => $monthsoptions[$month] . "-" . $year));
// For find out Next and previous month and year from current year
$aftersix = array();
for ($i = 0; $i < 3; $i++) {
$month++;
if ($month > 12) {
$month = 1;
$year = $year + 1;
}
$aftersix[] = array($month . "-" . $year => $monthsoptions[$month] . "-" . $year);
}
$year = date("Y");
$month = date("m");
$beforesix = array();
for ($i = 3; $i > 0; $i--) {
$month--;
if ($month < 1) {
$month = 12;
$year = $year - 1;
}
$beforesix[] = array($month . "-" . $year => $monthsoptions[$month] . "-" . $year);
}
$beforesix = array_reverse($beforesix);
$options = array_merge($options, $beforesix);
//echo count($options);
$options = array_merge($options, $currentmontharray);
$options = array_merge($options, $aftersix);
$ot = array();
foreach ($options as $o) {
foreach ($o as $key => $value) {
$ot[$key] = $value;
}
}
?>
<div class="box-body">
<div class="row" style="margin-bottom:10px">
<div class="col-md-3">
<form id="formid">
<?php echo form_dropdown('monthyear', $ot, set_value('monthyear', $currentselection), 'id="monthyear"', 'class="form-control select2'); ?>
</form>
</div>
<div class="col-3"></div>
<div class="col-3"></div>
<div class="col-3"></div>
</div>
<div class="table-responsive" id="table-responsive" style="overflow-x:scroll;">
<table id="monthlylistings" class="table table-bordered table-hover fht-table"
style="background-color:#fff;font-size:12px;white-space: nowrap;">
<thead style="background-color: #ddd;">
<tr>
<th class="celda_encabezado_general">S.No</th>
<th class="celda_encabezado_general">Emp ID </th>
<th class="celda_encabezado_general">Employee </th>
<th class="celda_encabezado_general">Salary</th>
<th class="celda_encabezado_general">Per Day Salary</th>
<th class="celda_encabezado_general">Per hr Salary</th>
<th class="celda_encabezado_general">Over Time Hrs</th>
<th class="celda_encabezado_general">Over Time Amount</th>
</tr>
</thead>
<tbody>
<?php
if (!empty($fresh)) {
foreach ($fresh as $i => $record) {
// print_r($record);
?>
<tr class="lastvalue">
<td style="text-align:right;" style="background-color:blue;"><?php echo $i+1; ?></td>
<td style="max-width:80px"><?php echo $record->EmpID; ?></td>
<td><?php echo $record->FirstName; ?></td>
<td style="max-width:80px;text-align:right;">
<?php echo $record->TotalSalary;
$totalsalary[] = $record->TotalSalary; ?>
</td>
<td style="max-width:80px;text-align:right;">
<?php $perDaySalary = $record->TotalSalary / $record->NoofDays;
echo number_format($perDaySalary, 2, '.', '');
$totalperdaySalary[] = $perDaySalary; ?>
</td>
<td style="max-width:80px;text-align:right;">
<?php $perHrSalary = $perDaySalary / 8;
echo number_format($perHrSalary, 2);
$totalperhrSalary[] = $perHrSalary; ?>
</td>
<td style="max-width:80px;text-align:right;">
<?php $OT = $record->OT_Hrs_Worked;
echo $OT;
$totalovertimehrs[] = $record->OT_Hrs_Worked;
?>
</td>
<td style="max-width:80px;text-align:right;">
<?php
// $NoofDays = $record->NoofDays;
// $HRA_Amount = $record->HRA_Amount;
// $Basic_Pay = $record->Basic_Pay;
// $OT_Hrs_Worked = $record->OT_Hrs_Worked;
// $dayBasic = $Basic_Pay / $NoofDays;
// $dayHra = $HRA_Amount / $NoofDays;
// $oneHoursSalary = ($dayBasic + $dayHra) / 8;
// $OTSalary = ($OT_Hrs_Worked != 0) ? $OT_Hrs_Worked * $oneHoursSalary : 0;
$OTSalary = $OT * $perHrSalary;
echo number_format($OTSalary, 2);
$totalovertimeamounts[] = $OTSalary;
?>
</td>
</tr>
<?php
}
}?>
</tbody>
<tfoot>
<tr>
<th style=" background-color: #ffffff;"></th>
<th style=" background-color: #ffffff;"></th>
<th style=" background-color: #ffffff;"></th>
<th>Total</th>
<th style=" background-color: #ffffff;"></th>
<th style=" background-color: #ffffff;"></th>
<th style="text-align:right;">
<?php echo isset($totalovertimehrs) ? number_format(array_sum($totalovertimehrs), 2) : ''; ?>
</th>
<th style="text-align:right;">
<?php echo isset($totalovertimeamounts) ? number_format(array_sum($totalovertimeamounts), 2) : ''; ?>
</th>
</tr>
</tfoot>
</table>
</div>
<p>&nbsp;</p>
</div><!-- /.b o x-b o d y -->
</div><!-- /.b o x -->
</div> <!--/. c a r d b o d y-->
</div> <!-- /. e n d c a r d -->
</div><!--/. e n d c o l-->
</div>
</div>
</div> <!--/. c o n t a i n e r -->
</div> <!-- c o n t e n t -->
</div>
<script type="text/javascript" src="<?php echo base_url(); ?>public/assets/js/common.js" charset="utf-8"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/xlsx/0.18.5/xlsx.full.min.js"></script>
<script type="text/javascript">
$('#monthyear').attr('class', 'form-control');
var estTotal = [];
var totalotherDet = [];
var totalmonthloan = [];
$("#monthyear").change(function() {
$s = $('#monthyear').val();
$("#formid").attr("method", "post");
$("#formid").attr("action", "<?php echo base_url() ?>overTimeDetails");
$('#formid').submit();
});
function toggleDivFullscreen() {
let div = document.getElementById("fullscreenDiv");
let tableResponsive = document.getElementById("table-responsive"); // Select the table container inside div
if (!document.fullscreenElement) {
div.requestFullscreen().then(() => {
div.style.width = "100vw"; // Full viewport width
div.style.height = "100vh"; // Full viewport height
// If .table-responsive exists, set its height to 90vh
if (tableResponsive) {
tableResponsive.style.maxHeight = "90vh";
tableResponsive.style.overflowY = "auto"; // Allow scrolling if needed
}
}).catch(err => console.log("Error enabling fullscreen:", err));
} else {
document.exitFullscreen().then(() => {
div.style.width = "100%";
div.style.height = "100%";
// Reset .table-responsive height when exiting fullscreen
if (tableResponsive) {
tableResponsive.style.height = "auto";
}
}).catch(err => console.log("Error exiting fullscreen:", err));
}
}
</script>