withdraw and employ list

This commit is contained in:
heama 2024-01-30 15:19:40 +05:30
parent 2f8556de64
commit 4c331afa21
6 changed files with 562 additions and 92 deletions

View File

@ -1,4 +1,4 @@
<div class="col-md-3 left_col menu_fixed">
<div class="col-md-3 left_col menu_fixed">
<div class="left_col scroll-view">
<div class="navbar nav_title" style="border: 0;">
<a class="site_title">
@ -23,11 +23,11 @@
<?php if(user()->profile_image == '' || user()->profile_image == null) { ?>
<img src="<?php echo base_url(); ?>/assets/uploads/profile_picture/profile.jpg" alt="..." class="img-circle profile_img">
<?php } else { ?>
<img src="<?php echo base_url(); ?>/assets/uploads/profile_picture/<?php echo user()->profile_image; ?>"
<img src="<?php echo base_url(); ?>/assets/uploads/profile_picture/<?php echo user()->profile_image; ?>"
alt="..." class="img-circle profile_img">
<?php } ?>
</div>
<div class="profile_info">
<span>Welcome,</span>
@ -48,20 +48,20 @@
<?php if(check_auth() && Employee_group()) { ?>
<li><a href="<?php echo base_url();?>Asset/assetLandingPage" ><i class="fa fa-university"></i> Assets <span class="fa fa-chevron-down"></span></a></li>
<?php } ?>
<?php } ?>
<!-- <?php if(check_auth() && Employee_group()) { ?>
<li><a href="<?php echo base_url();?>Asset/depreciation_report" ><i class="fa fa-clipboard"></i> Reports <span class="fa fa-chevron-down"></span></a></li>
<?php } ?> -->
<?php } ?> -->
<?php if(check_auth() && is_admin() || is_superadmin() || is_user() ) { ?>
<?php if(check_auth() && is_admin() || is_superadmin() || is_user() ) { ?>
<li><a><i class="fa fa-group"></i> Employees <span class="fa fa-chevron-down"></span></a>
<ul class="nav child_menu">
<li><a href="<?php echo base_url();?>Employee/empList">Employee List</a></li>
<li><a href="<?php echo base_url();?>Employee/addEmployee">Add Employee</a></li>
</ul>
@ -76,46 +76,46 @@
<ul class="nav child_menu">
<li><a href="<?php echo base_url();?>Leave/leavehistory">My Leaves</a></li>
<li><a href="<?php echo base_url();?>Leave/applyLeave">Apply Leave</a></li>
<li><a href="<?php echo base_url();?>Leave/manager_approvel">My Approvals</a></li>
</ul>
</li>
<?php } ?>
<?php if(check_auth() && is_admin() || is_superadmin() ) { ?>
<li><a><i class="fa fa-calendar-times-o"></i> Leaves <span class="fa fa-chevron-down"></span></a>
<ul class="nav child_menu">
<li><a href="<?php echo base_url();?>Leave/leavedashboard">Dashboard</a></li>
<li><a href="<?php echo base_url();?>Leave/leavehistory">My Leaves</a></li>
<li><a href="<?php echo base_url();?>Leave/applyLeave">Apply Leave</a></li>
<li><a href="<?php echo base_url();?>Leave/leaveList">My Approvals</a></li>
</ul>
</li>
<?php } ?>
<?php if(check_auth() && is_user() || user()->role == null ) { ?>
<li><a><i class="fa fa-money"></i> Expense <span class="fa fa-chevron-down"></span></a>
<ul class="nav child_menu">
<li><a href="<?php echo base_url();?>Expence/emp_expence_list">My Claims</a></li>
<li><a href="<?php echo base_url();?>Expence/expence_form">New Claim</a></li>
<li><a href="<?php echo base_url();?>Expence/expence_list">My Approvals</a></li>
</ul>
</li>
<?php } ?>
<?php if(check_auth() && is_admin() || is_superadmin() ) { ?>
@ -124,14 +124,14 @@
<ul class="nav child_menu">
<li><a href="<?php echo base_url();?>Expence/emp_expence_list">My Claims</a></li>
<li><a href="<?php echo base_url();?>Expence/expence_form">New Claim</a></li>
<li><a href="<?php echo base_url();?>Expence/expence_list">My Approvals</a></li>
</ul>
</li>
<?php } ?>
<?php if(check_auth() && is_user() || user()->role == null ) { ?>
@ -140,12 +140,12 @@
<ul class="nav child_menu">
<li><a href="<?php echo base_url();?>Delegation/Delegation_list">Delegation List</a></li>
<li><a href="<?php echo base_url();?>Delegation/Delegation/Delegation_form">Assign Delegation</a></li>
</ul>
</li>
<?php } ?>
<?php if(check_auth() && is_admin() || is_superadmin() ) { ?>
@ -154,12 +154,12 @@
<ul class="nav child_menu">
<li><a href="<?php echo base_url();?>Delegation/Delegation_list">Delegation List</a></li>
<li><a href="<?php echo base_url();?>Delegation/Delegation/Delegation_form">Assign Delegation</a></li>
</ul>
</li>
<?php } ?>
</ul>
@ -187,5 +187,4 @@
</div>
<!-- /menu footer buttons -->
</div>

View File

@ -596,6 +596,15 @@ public function cancled()
$this->session->set_flashdata('Success', 'Leave canceled Successfully');
redirect('Leave/LeaveHistory');
}
public function withdraw()
{
$id=$this->input->get('id');
$data['status'] = 'withdraw-pending';
$data['cancled_at'] = date('d-m-Y H:i:s');
$this->Leave_model->Leavecanceaprove($id, $data);
$this->session->set_flashdata('Success', 'Leave canceled Successfully');
redirect('Leave/LeaveHistory');
}
public function LeaveHistory()
{
@ -629,6 +638,110 @@ public function manager_approvel()
$this->layout->render('Employee_Layout');
}
public function DeclinewithdrawLeave()
{
$id=$this->input->post('id');
$business_id = user()->business_id;
$emp_id = $this->Leave_model->get_emp_id($id);
$no_of_days = $this->Leave_model->get_Leave_nodays($id,);
$leave_year = date('Y', strtotime($no_of_days->from_date));
$leave_type = $this->Leave_model->get_leave_data_using_leave_id($id);
if($leave_type->leave_code !== 'permission')
$data['status'] = 'Withdraw-declined';
$data['declined_by']= user()->id;
$data['declined_at'] = date('d-m-Y H:i:s');
$data['DReason'] = $this->input->post('declinedata');
$leave_approve = $this->Leave_model->LeavewithdrawDecline($id, $data);
$emp_id = $this->Leave_model->get_emp_id($id);
$this->Leave_model->emp_leave_days_update($emp_id, $days, $leave_year, user()->business_id, $leave_data->type);
if($leave_approve){
if($leave_type->leave_code === 'permission'){
$code = 'APPROVE_Withdraw';
}
else{
$code = 'DECLINE_WITHDRAW_LEAVE';
}
$type = 'Email';
$this->notification->sendNotification($id, $code, $type);
}
redirect('Leave/leaveList');
}
public function ApprovewithdrawLeave()
{
$id = $this->input->post('id');
$leave_data = $this->Leave_model->get_Leave_nodays($id);
$data['status'] = 'Withdraw-Approved';
$data['approved_by'] = user()->name;
$data['approved_at'] = date('d-m-Y H:i:s');
// Update leave balance
$emp_id = $this->Leave_model->get_emp_id($id);
$leave_year = date('Y', strtotime($leave_data->from_date));
$remaining_days = $this->Leave_model->remaining_days($emp_id, user()->business_id, $leave_year, $leave_data->type);
$balance_days = $remaining_days[0]->remaining_days + $leave_data->no_of_days;
$data['leave_bal'] = $balance_days;
$days['remaining_days'] = $balance_days;
$this->Leave_model->emp_leave_days_update($emp_id, $days, $leave_year, user()->business_id, $leave_data->type);
// Approve the leave withdrawal
$leave_approve = $this->Leave_model->LeavewithdrawApproved($id, $data);
// Send notification
$leave_type = $this->Leave_model->get_leave_data_using_leave_id($id);
if ($leave_approve) {
if ($leave_type->leave_code === 'permission') {
$code = 'APPROVE_Withdraw';
} else {
$code = 'APPROVE_WITHDRAW_LEAVE';
}
$type = 'Email';
$this->notification->sendNotification($id, $code, $type);
}
redirect('Leave/leaveList');
}
// public function dashboard()
// {
// $business_id = user()->business_id;
// // Replace 123 with the actual business_id
// // $this->load->view('Leave/dashboard', $data);
// $data['leaveData'] = $this->Leave_model->get_all_leave_data($business_id);
// $this->layout->buffer('main_content', 'Leave/dashboard',$data);
// $this->layout->render('Employee_Layout');
// }
// public function leavedashboard()
// {
// redirect('Leave/dashboard');
// }
public function dashboard()
{
$business_id = user()->business_id;
// Replace 123 with the actual business_id
// $this->load->view('Leave/dashboard', $data);
$data['weekData'] = $this->Leave_model->get_approved_leaves_cur_week($business_id);
$this->layout->buffer('main_content', 'Leave/dashboard',$data);
$this->layout->render('Employee_Layout');
}
public function leavedashboard()
{
redirect('Leave/dashboard');
}
}

View File

@ -13,7 +13,7 @@ public function get_leave_with_emp_name($business_id)
$this->db->order_by('A.id','DESC');
$this->db->where('A.is_active', 1);
$query = $this->db->get();
$query = $query->result();
$query = $query->result();
return $query;
}
@ -35,7 +35,7 @@ public function get_leave_data_using_leave_id($leave_id)
if ($query->num_rows() > 0) {
return $row = $query->row();
} else {
return false;
return false;
}
}
@ -50,7 +50,7 @@ public function get_template_data_using_code($code, $type){
if ($query->num_rows() > 0) {
return $query->row();
} else {
return false;
return false;
}
}
@ -61,12 +61,12 @@ public function get_user_name($user_id){
$this->db->from('users');
$this->db->where('id', $user_id);
$query = $this->db->get();
// $query = $query->result();
// $query = $query->result();
if ($query->num_rows() > 0) {
$row = $query->row();
return $row->name;
} else {
return false;
return false;
}
// return $query;
@ -87,7 +87,7 @@ public function get_all_leave_request_by_manager_id($business_id, $user_id)
$this->db->order_by('A.id','DESC');
$this->db->where('A.is_active', 1);
$query = $this->db->get();
$query = $query->result();
$query = $query->result();
return $query;
}
@ -101,7 +101,7 @@ public function get_delegated_user_id($business_id, $user_id){
$query = $this->db->get();
$result_array = $query->result_array();
$emp_ids = array_column($result_array, 'emp_id');
return $emp_ids;
return $emp_ids;
}
public function get_all_leave_request_by_manager_id_with_delegation($business_id, $loggeduserid)
@ -129,11 +129,11 @@ public function get_all_leave_request_by_manager_id_with_delegation($business_id
$this->db->order_by('A.id','DESC');
$this->db->where('A.is_active', 1);
$query = $this->db->get();
$query = $query->result();
$query = $query->result();
return $query;
}
}
}
@ -146,9 +146,9 @@ public function get_count($emp_id, $business_id, $type_id)
$this->db->where('type', $type_id);
$this->db->where('is_active', 1);
$query = $this->db->get();
$query = $query->result();
$query = $query->result();
return $query;
}
public function remaining_days($emp_id, $business_id, $leave_year, $type)
@ -161,7 +161,7 @@ public function remaining_days($emp_id, $business_id, $leave_year, $type)
$this->db->where('type', $type);
$this->db->where('is_active', 1);
$query = $this->db->get();
$query = $query->result();
$query = $query->result();
return $query;
}
@ -175,7 +175,7 @@ public function remaining_days($emp_id, $business_id, $leave_year, $type)
// $this->db->where('type', $type);
// $this->db->where('is_active', 1);
// $query = $this->db->get();
// $query = $query->row();
// $query = $query->row();
// return $query;
// }
@ -187,9 +187,9 @@ function get_id($id,$business_id,$table)
$this->db->where('business_id', $business_id);
$this->db->where('is_active', 1);
$query = $this->db->get();
$query = $query->result();
$query = $query->result();
return $query;
}
}
function get_by_type($type,$business_id,$table)
{
@ -199,13 +199,13 @@ function get_by_type($type,$business_id,$table)
$this->db->where('business_id', $business_id);
$this->db->where('is_active', 1);
$query = $this->db->get();
$query = $query->result();
$query = $query->result();
return $query;
}
}
public function get_employee($business_id)
{
$this->db->select('users.name, employees.user_id, employees.manager');
$this->db->from('users');
$this->db->join('employees', 'employees.user_id = users.id');
@ -231,7 +231,7 @@ public function get_leave($id , $business_id , $table, $leave_year, $type)
$this->db->where('year', $leave_year);
$this->db->where('is_active', 1);
$query = $this->db->get();
$query = $query->result();
$query = $query->result();
return $query;
}
@ -246,7 +246,7 @@ public function get_leave_based_on_tpye($id , $type , $business_id , $table, $ye
$this->db->order_by('id','DESC');
$this->db->where('is_active', 1);
$query = $this->db->get();
$query = $query->result();
$query = $query->result();
return $query;
}
@ -258,9 +258,9 @@ public function get_leave_by_md5_id($id,$business_id,$table)
$this->db->where('md5(id)', $id);
$this->db->where('is_active', 1);
$query = $this->db->get();
$query = $query->row();
$query = $query->row();
return $query;
}
}
function update_leave($action,$id,$table,$current_year,$type_id){
$this->db->where('emp_id',$id);
@ -268,7 +268,7 @@ function update_leave($action,$id,$table,$current_year,$type_id){
$this->db->where('year', $current_year);
$this->db->update($table,$action);
return;
}
}
public function LeaveApprove($id, $data)
{
@ -277,6 +277,23 @@ public function LeaveApprove($id, $data)
$this->db->update('leave_list', $data);
return true;
}
public function LeavewithdrawDecline($id, $data)
{
$this->db->where('id',$id);
// $this->db->update('emp_leave_days', $data);
$this->db->update('leave_list', $data);
return true;
}
public function LeavewithdrawApproved($id, $data)
{
$this->db->where('id',$id);
$this->db->update('leave_list', $data);
return true;
}
public function LeaveDecline($id, $data)
@ -294,7 +311,13 @@ public function Leavecancle($id, $data)
$this->db->update('leave_list', $data);
return;
}
public function Leavecanceaprove($id, $data)
{
$this->db->where('md5(id)',$id);
$this->db->where('status', 'Approved');
$this->db->update('leave_list', $data);
return;
}
public function getLeaveType($business_id)
@ -305,7 +328,7 @@ public function getLeaveType($business_id)
$this->db->where('business_id', $business_id);
$this->db->where('is_active', 1);
return $this->db->get()->result();
}
@ -316,8 +339,8 @@ public function get_Leave_nodays($id)
$this->db->where('id',$id);
$this->db->where('is_active', 1);
$query = $this->db->get();
$query = $query->row();
return $query;
$query = $query->row();
return $query;
}
public function emp_leave_days_update($id, $days, $current_year, $business_id, $type)
@ -337,7 +360,7 @@ public function emp_leave_days_update($id, $days, $current_year, $business_id, $
// $this->db->where('type', $type);
// $this->db->update('emp_leave_days', $days);
// }
public function get_emp_id($id)
{
$this->db->select('emp_id');
@ -348,9 +371,9 @@ public function get_emp_id($id)
$row = $query->row();
$empId = $row->emp_id;
return $empId;
}
}
@ -380,7 +403,7 @@ public function editleave($id)
public function decline_dropdown($business_id)
{
$this->db->select('*');
$this->db->from('enum');
$this->db->where('enum_type', 'decline');
@ -401,7 +424,7 @@ public function Get_delegation_id($business_id)
$this->db->where('business_id', $business_id);
$this->db->where('is_active', 1);
$query = $this->db->get();
return $query->result();
return $query->result();
}
public function get_emp_leave_count($type_id, $emp_id)
@ -412,9 +435,9 @@ public function get_emp_leave_count($type_id, $emp_id)
$this->db->where('type', $type_id);
$this->db->where('is_active', 1);
$query = $this->db->get();
return $query->result();
}
return $query->result();
}
public function get_leave_master($business_id)
{
@ -423,7 +446,7 @@ public function get_leave_master($business_id)
$this->db->where('(business_id = 0 OR business_id = ' . $business_id . ')');
$this->db->where('is_active', 1);
$query = $this->db->get();
$result = $query->result();
$result = $query->result();
return $result;
}
@ -436,7 +459,7 @@ public function get_leave_master_count($type_id, $business_id)
$this->db->where('id', $type_id);
$this->db->where('is_active', 1);
$query = $this->db->get();
$query = $query->result();
$query = $query->result();
return $query;
}
@ -449,7 +472,7 @@ public function get_emp_joing_year_month($emp_id, $business_id)
$this->db->where('A.user_id', $emp_id);
$this->db->where('A.is_active', 1);
$query = $this->db->get();
$query = $query->result();
$query = $query->result();
return $query;
}
@ -460,12 +483,12 @@ public function get_leave_type($business_id)
$this->db->where('business_id', $business_id);
$this->db->where('is_active', 1);
$query = $this->db->get();
$query = $query->result();
$query = $query->result();
return $query;
}
public function get_from_date($emp_id, $from_date, $to_date)
{
{
$this->db->select('*');
$this->db->from('leave_list');
@ -494,4 +517,102 @@ public function get_emp_data_by_emp_id($emp_id){
$query = $query->result();
return $query;
}
}
public function get_approved_leaves_cur_week()
{
$currentWeekStart = date('Y-m-d', strtotime('monday this week'));
$currentWeekEnd = date('Y-m-d', strtotime('sunday this week'));
$this->db->select('leave_list.*, users.name as emp_name');
$this->db->from('leave_list');
$this->db->join('users', 'users.id = leave_list.emp_id', 'left');
$this->db->group_start();
$this->db->where("STR_TO_DATE(from_date, '%d-%m-%Y') <= '$currentWeekEnd'");
$this->db->where("STR_TO_DATE(to_date, '%d-%m-%Y') >= '$currentWeekStart'");
$this->db->or_where("STR_TO_DATE(perm_date, '%d-%m-%Y') <= '$currentWeekEnd'");
$this->db->or_where("STR_TO_DATE(perm_date, '%d-%m-%Y') >= '$currentWeekStart'");
$this->db->group_end();
$this->db->where('leave_list.status', 'approved');
$query = $this->db->get();
$approvedLeaveRecords = $query->result();
// Organize approved leave records into columns based on days of the week
$weekData = [];
foreach ($approvedLeaveRecords as $leave) {
$leaveStartDate = ($leave->from_date) ? date('Y-m-d', strtotime($leave->from_date)) : date('Y-m-d', strtotime($leave->perm_date));
$leaveEndDate = ($leave->to_date) ? date('Y-m-d', strtotime($leave->to_date)) : date('Y-m-d', strtotime($leave->perm_date));
// Use from_time and to_time if available
$fromTime = ($leave->from_time) ? ' ' . $leave->from_time : '';
$toTime = ($leave->to_time) ? ' ' . $leave->to_time : '';
// Iterate over each day in the leave period
$currentDate = $leaveStartDate;
while ($currentDate <= $leaveEndDate) {
$dayOfWeek = date('l', strtotime($currentDate));
$weekData[$dayOfWeek][] = [
'emp_id' => $leave->emp_id,
'emp_name' => $leave->emp_name,
'from_time' => $fromTime,
'to_time' => $toTime,
];
$currentDate = date('Y-m-d', strtotime($currentDate . ' +1 day'));
}
}
// print_r($weekData);
return $weekData;
}
// public function get_all_leave_data($business_id){
// $this->db->select('leave_list.*, employees.*, users.*, leave_master.*, (SELECT MAX(remaining_days) FROM emp_leave_days WHERE emp_id = leave_list.emp_id) as leave_balance');
// $this->db->from('leave_list');
// $this->db->join('users', 'leave_list.emp_id = users.id', 'left');
// $this->db->join('employees', 'leave_list.emp_id = employees.user_id', 'left');
// $this->db->join('leave_master', 'leave_list.type = leave_master.id', 'left');
// $this->db->select_sum('leave_list.no_of_days', 'total_leave_days');
// $this->db->select('SUM(CASE WHEN leave_master.type = "permission" THEN 1 ELSE 0 END) as permission_count');
// $this->db->group_by('leave_list.emp_id');
// $query = $this->db->get();
// print_r($this->db->last_query());
// return $query->result();
// }
// public function get_all_leave_data($business_id) {
// $this->db->select('leave_list.*, employees.*, users.*, leave_master.*, leave_list.leave_bal');
// $this->db->from('leave_list');
// $this->db->join('users', 'leave_list.emp_id = users.id', 'left');
// $this->db->join('employees', 'leave_list.emp_id = employees.user_id', 'left');
// $this->db->join('leave_master', 'leave_list.type = leave_master.id', 'left');
// // Subquery to get the last inserted leave balance for each employee
// $subquery = $this->db->select('MAX(id) as max_id')
// ->from('leave_list ll')
// ->where('ll.emp_id = leave_list.emp_id', null, false)
// ->get_compiled_select();
// $this->db->join("($subquery) as latest_leave", 'leave_list.id = latest_leave.max_id', 'left');
// $this->db->group_by('leave_list.emp_id');
// $query = $this->db->get();
// print_r($this->db->last_query());
// return $query->result();
// }
}

View File

@ -0,0 +1,175 @@
<!DOCTYPE html>
<html lang="en">
<head>
<link rel='stylesheet' href='https://cdn.jsdelivr.net/npm/bootstrap-icons@1.7.2/font/bootstrap-icons.css'>
<style>
.alert-success {
background-color: #dff0d8;
color: #3c763d;
border-color: #d6e9c6;
}
.flash-message {
padding: 10px;
margin-bottom: 10px;
border-radius: 5px;
margin-left: 650px;
}
div.dataTables_wrapper div.dataTables_filter {
margin-top: -30px !important;
}
/* Add a CSS class for highlighting the current date */
table#datatables th {
background-color: #C8E4E7;
}
/* Set the background color of the current date heading */
table#datatables th.current-date {
background-color: #A8E7CF;
}
/* table#datatables th:not(.current-date):first-child,
table#datatables td:first-child:not(.current-date) {
background-color: #BEEEE6;
} */
</style>
</head>
<body>
<div class="col-md-12 col-sm-12 ">
<div class="x_panel">
<div class="x_title">
<button hidden id="button" class="btn btn-secondary source" onclick="new PNotify({
text: '<html><h2>Submited for Approval.<h2></html>',
type: 'success',
styling: 'bootstrap3'
});">Success</button>
<input type="hidden" id="error" value="<?php echo $this->session->userdata('Success'); ?>">
<?php $this->session->unset_userdata('Success'); ?>
<script>
$(document).ready(function () {
if ($('#error').val() == 1) {
$('#button').click();
}
})
</script>
<ul class="nav navbar-right panel_toolbox"></ul>
<h1>Employ Leave List</h1>
<div class="clearfix"></div>
</div>
<div class="x_content">
<div class="row">
<div class="col-sm-12">
<table id="datatables" class="table table-striped table-bordered" width="100%">
<tr>
<?php
// Get the start date of the current week
$currentDate = date('Y-m-d', strtotime('monday this week'));
// Iterate over the days of the current week
for ($i = 0; $i < 7; $i++) {
$dayOfWeek = date('l', strtotime($currentDate));
$formattedDate = date('d-m-Y', strtotime($currentDate));
// Add a CSS class for the current date
$class = ($currentDate == date('Y-m-d')) ? ' class="current-date"' : '';
// Display the date and day, but skip Sunday
if ($dayOfWeek !== 'Sunday') {
echo '<th' . $class . '><h2>' . $dayOfWeek . '</h2><span>(' . $formattedDate . ')</span></th>';
}
// Move to the next day
$currentDate = date('Y-m-d', strtotime($currentDate . ' +1 day'));
}
?>
</tr>
<tr>
<?php
// Reset the current date to the start date of the current week
$currentDate = date('Y-m-d', strtotime('monday this week'));
// Iterate over the days of the current week
for ($i = 0; $i < 7; $i++) {
$dayOfWeek = date('l', strtotime($currentDate));
// Skip Sunday
if ($dayOfWeek !== 'Sunday') {
echo '<td>';
// Check if there are leave records for the current day
if (array_key_exists($dayOfWeek, $weekData)) {
foreach ($weekData[$dayOfWeek] as $leaveRecord) {
if (empty($leaveRecord['from_time']) && empty($leaveRecord['to_time'])) {
// Display leave records for the day
echo $leaveRecord['emp_name'] . '<br>' . $leaveRecord['from_time'] . $leaveRecord['to_time'] . '<br>';
}
}
} else {
// No leave records for the day
}
echo '</td>';
}
// Move to the next day
$currentDate = date('Y-m-d', strtotime($currentDate . ' +1 day'));
}
?>
</tr>
<tr>
<?php
// Reset the current date to the start date of the current week
$currentDate = date('Y-m-d', strtotime('monday this week'));
// Iterate over the days of the current week
for ($i = 0; $i < 7; $i++) {
$dayOfWeek = date('l', strtotime($currentDate));
// Skip Sunday
if ($dayOfWeek !== 'Sunday') {
echo '<td>';
// Check if there are leave records for the current day
if (array_key_exists($dayOfWeek, $weekData)) {
foreach ($weekData[$dayOfWeek] as $leaveRecord) {
if (!empty($leaveRecord['from_time']) && !empty($leaveRecord['to_time'])) {
echo $leaveRecord['emp_name'] . '<br>' . $leaveRecord['from_time'] . $leaveRecord['to_time'] . '<br>';
}
}
} else {
// No leave records for the day
// echo 'No Leave';
}
echo '</td>';
}
// Move to the next day
$currentDate = date('Y-m-d', strtotime($currentDate . ' +1 day'));
}
?>
</tr>
</table>
</div>
</div>
</div>
</div>
</div>
<br />
<!-- Large modal -->
<div class="modal fade bs-example-modal-lg" id="ItemModal" tabindex="-1" role="dialog" aria-hidden="true"></div>
<div class="modal bs-example-modal-sm" tabindex="-1" role="dialog" aria-hidden="true" id="popup"> </div>
<div style="display:none" id="sub-value"></div>
</body>
</html>

View File

@ -32,7 +32,7 @@
}
div.dataTables_wrapper div.dataTables_filter {
margin-top: -30px !important;
margin-top: -30px !important;
}
</style>
@ -110,6 +110,18 @@
<?php }
else if($value->status == 'canceled'){ ?>
<td style="color:darkcyan;"><?php echo $value->status; ?></td>
<?php }
else if($value->status == 'withdraw-pending'){ ?>
<td style="color:#e68a00"><?php echo $value->status; ?></td>
<?php }
else if($value->status == 'Withdraw-declined'){ ?>
<td style="color:red;"><?php echo $value->status; ?> By
<?php echo $value->declined_by; ?> <br>" <?php echo $value->DReason; ?> "</td></td>
<?php }
else if($value->status == 'Withdraw-Approved'){ ?>
<td style="color:green"><?php echo $value->status; ?> By
<?php echo $value->ApproveBy; ?><br><?php echo $value->approved_at; ?></td>
<?php }
else{
}?>
@ -120,7 +132,13 @@
<a><i class="fa fa-check approveleave" data-toggle="modal" data-target=".bs-example-modal-sm" title="Approve" id="<?php echo $value->id;?>"></i></a>&nbsp;
<a><i class="fa fa-times test" data-toggle="modal" data-target=".bs-example-modal-sm" title="Decline" id="<?php echo $value->id;?>"></i></a>&nbsp;
<!-- <a href="#"><i class="fa fa-times test" aria-hidden="true" title="Decline" onclick="showCustomPrompt()" id="<?php echo $value->id; ?>"></i></a>&nbsp; -->
<?php } ?>
<?php } else if ($value->status == 'withdraw-pending') { ?>
<a><i class="fa fa-check approveleave1" data-toggle="modal" data-target=".bs-example-modal-sm" title="Approve" id="<?php echo $value->id;?>"></i></a>&nbsp;
<a><i class="fa fa-times test1" data-toggle="modal" data-target=".bs-example-modal-sm" title="Decline" id="<?php echo $value->id;?>"></i></a>&nbsp;
<?php } ?>
</td>
</tr>
<?php } } } ?>
@ -173,6 +191,21 @@
}
});
});
$('.approveleave1').click(function() {
var id = $(this).attr('id');
var url = "<?php echo base_url()?>Leave/ApprovewithdrawLeave";
$.ajax({
url: "<?php echo base_url()?>Leave/getDeleteConfirmationPopup",
type: "GET",
success: function(data) {
$('#popup').html(JSON.parse(data));
$('.delete_id').attr('value', id);
$('.delete_url').attr('action', url);
}
});
});
$('.test').click(function() {
var id = $(this).attr('id');
@ -188,6 +221,20 @@
}
});
});
$('.test1').click(function() {
var id = $(this).attr('id');
var url = "<?php echo base_url()?>Leave/DeclinewithdrawLeave";
$.ajax({
url: "<?php echo base_url()?>Leave/getDeclineConfirmationPopup",
type: "GET",
success: function(data) {
$('#popup').html(JSON.parse(data));
$('.delete_id').attr('value', id);
$('.delete_url').attr('action', url);
}
});
});
$(document).on('click', '.bi-card-list', function() {
@ -306,4 +353,4 @@ function confirmAction() {
</div>
</div>

View File

@ -1,10 +1,10 @@
<head>
<link rel='stylesheet' href='https://cdn.jsdelivr.net/npm/bootstrap-icons@1.7.2/font/bootstrap-icons.css'>
<link rel='stylesheet' href='https://cdn.jsdelivr.net/npm/bootstrap-icons@1.7.2/font/bootstrap-icons.css'>
<style>
.alert-success {
background-color: #dff0d8;
color: #3c763d;
border-color: #d6e9c6;
border-color: #d6e9c6;
}
.flash-message {
@ -15,7 +15,7 @@
}
div.dataTables_wrapper div.dataTables_filter{
margin-top: -30px !important;
margin-top: -30px !important;
}
</style>
</head>
@ -28,7 +28,7 @@
type: 'success',
styling: 'bootstrap3'
});">Success</button>
<input type="hidden" id="error" value="<?php echo $this->session->userdata('Success');?>" >
<input type="hidden" id="error" value="<?php echo $this->session->userdata('Success');?>" >
<?php $this->session->unset_userdata('Success');?>
<script>
$(document).ready(function(){
@ -41,7 +41,7 @@
</script>
<ul class="nav navbar-right panel_toolbox">
<a href="<?php echo base_url();?>Leave/applyLeave" class="btn btn-sm btn-primary" style="margin-top: 20px;">Apply Leave</a>
@ -52,9 +52,9 @@
<?php if(is_admin()) { ?>
<a href="<?php echo base_url();?>Leave/leaveList" class="btn btn-sm btn-warning" style="margin-top: 20px;">My Approvals</a>
<?php }?>
</ul>
<h1>My Leaves</h1>
<div class="clearfix"></div>
@ -65,8 +65,8 @@
<table id="datatables" class="table table-striped table-bordered" width="100%">
<thead>
<tr class="headings">
<th hidden class="column-title">id</th>
<th class="column-title">Created Date/Time</th>
<th hidden class="column-title">id</th>
<th class="column-title">Created Date/Time</th>
<th class="column-title">Leave Type </th>
<th class="column-title">Leave Duration</th>
<th class="column-title">No of Days </th>
@ -80,7 +80,7 @@
<?php if( user()->id == $value->emp_id) { ?>
<?php foreach ($leave_type as $leave => $type) { ?>
<?php if($type->id === $value->type ) { ?>
<tr class="even pointer">
<td hidden class=" "><?php echo $value->id; ?></td>
<td class=" "><?php echo $value->created_date; ?><br><?php echo $value->created_time; ?></td>
@ -88,18 +88,18 @@
<?php if($value->from_date == "" && $value->to_date == "") { ?>
<td class="">
<?php echo dateFormat('d-m-Y',$value->perm_date);?><br>
<?php echo timeFormat('h:i a', $value->from_time); ?> to
<?php echo timeFormat('h:i a', $value->from_time); ?> to
<?php echo timeFormat('h:i a', $value->to_time);; ?>
</td>
<?php } else { ?>
<td class=" "> <?php echo dateFormat('d-m-Y',$value->from_date); echo ' to ';?> <?php echo dateFormat('d-m-Y',$value->to_date);?> </td>
<?php } ?>
<?php if($value->no_of_days == 0){ ?>
<td class=" ">---</td>
<?php } else { ?>
<td class=""><?php echo $value->no_of_days; ?></td>
<?php } ?>
<?php } ?>
<?php if($value->status == 'pending'){ ?>
<td style="color:#e68a00"><?php echo $value->status; ?></td>
<?php }
@ -112,18 +112,33 @@
else if($value->status == 'canceled'){ ?>
<td style="color:darkcyan;"><?php echo $value->status; ?></td>
<?php }
else if($value->status == 'withdraw-pending'){ ?>
<td style="color:#e68a00"><?php echo $value->status; ?></td>
<?php }
else if($value->status == 'Withdraw-declined'){ ?>
<td style="color:red"><?php echo $value->status; ?> By <?php echo $value->DeclineBy; ?> <br> <?php echo $value->DReason; ?></td>
<?php }
else if($value->status == 'Withdraw-Approved'){ ?>
<td style="color:green;"><?php echo $value->status; ?></td>
<?php }
else{
}?>
<td style=" text-align: center; font-size: 16px;">
<?php if($value->status == 'pending') { ?>
<a href="<?php echo base_url('Leave/edit_leave_function')?>?id=<?php echo md5($value->id);?> "><i class="fa fa-edit" aria-hidden="true"title="Edit"></i></a> &nbsp;
<a href="<?php echo base_url('Leave/cancled')?>?id=<?php echo md5($value->id);?> "><i class="fa fa-ban" aria-hidden="true"title="Cancel"></i></a> &nbsp;
<?php } else if ($value->status == 'Approved') { ?>
<a href="<?php echo base_url('Leave/withdraw')?>?id=<?php echo md5($value->id);?> "><i class="fa fa-ban" aria-hidden="true"title="Cancel"></i></a> &nbsp;
<?php } ?>
<?php } ?>
</td>
@ -151,13 +166,13 @@
var id = $(this).attr('id');
var url = "<?php echo base_url()?>Employee/deleteEmp";
$.ajax({
$.ajax({
url: "<?php echo base_url()?>Employee/getDeleteConfirmationPopup",
type:"GET",
success:function(data){
$('#popup').html(JSON.parse(data));
$('.delete_id').attr('value',id);
$('.delete_url').attr('action',url);
$('.delete_url').attr('action',url);
}
});
});
@ -165,7 +180,7 @@
$(document).on('click','.bi-card-list',function(){
var id = $(this).attr("id")
$.ajax({
$.ajax({
type: "get",
url: "<?php echo base_url()?>Employee/view_emp_history/"+id,
success: function(response) {