tracker issue and leave mster
This commit is contained in:
parent
702ba6dd05
commit
3dac74521d
@ -110,10 +110,11 @@ public function rise_expence_request()
|
||||
'manager_id' => $manager,
|
||||
'status' => 'Draft',
|
||||
// 'date_of_expense'=> $this->input->post('date_of_expence')[$i],
|
||||
'date_of_expense_new'=> $this->input->post('date_of_expence_new')[$i],
|
||||
'date_of_expense_new' => date('Y-m-d', strtotime($this->input->post('date_of_expence_new')[$i])),
|
||||
'amount' => $this->input->post('amount')[$i],
|
||||
'description' => $this->input->post('description')[$i],
|
||||
);
|
||||
// print_r($data2);die;
|
||||
$this->load->library('upload');
|
||||
|
||||
$config['upload_path'] = APPPATH. '../assets/uploads/Expence_Bill/';
|
||||
|
||||
@ -11,7 +11,7 @@
|
||||
.alert-success {
|
||||
background-color: #dff0d8;
|
||||
color: #3c763d;
|
||||
border-color: #d6e9c6;
|
||||
border-color: #d6e9c6;
|
||||
}
|
||||
|
||||
.flash-message {
|
||||
@ -22,7 +22,7 @@
|
||||
}
|
||||
|
||||
.hide-arrow {
|
||||
|
||||
|
||||
-webkit-appearance: none;
|
||||
-moz-appearance: none;
|
||||
appearance: none;
|
||||
@ -76,7 +76,7 @@
|
||||
text: 'Only change and Update',
|
||||
styling: 'bootstrap3'
|
||||
});">Success</button>
|
||||
<input type="hidden" id="error" value="<?php echo $this->session->userdata('remove_row');?>" >
|
||||
<input type="hidden" id="error" value="<?php echo $this->session->userdata('remove_row');?>" >
|
||||
<?php $this->session->unset_userdata('remove_row');?>
|
||||
<script>
|
||||
$(document).ready(function(){
|
||||
@ -93,12 +93,12 @@
|
||||
<a href="<?php echo base_url();?>Expence/emp_expence_list" class="btn btn-primary" style="margin-top: 20px; font-size: small;">Back</a>
|
||||
</ul>
|
||||
|
||||
<h3>
|
||||
|
||||
<h3>
|
||||
|
||||
<?php if($expense_data[0]->status == 'Draft') { ?>
|
||||
|
||||
Edit Expense - <?php if(isset($expense_data[0]->id)){echo $expense_data[0]->expense_name; } ?>
|
||||
|
||||
|
||||
<?php } else { echo $expense_data[0]->expense_name; } ?>
|
||||
|
||||
</h3>
|
||||
@ -109,20 +109,20 @@
|
||||
<br />
|
||||
<form id="" data-parsley-validate class="form-horizontal form-label-left" method="post" action="<?php echo base_url();?>Expence/edit_rise_expence_request" enctype="multipart/form-data">
|
||||
|
||||
<input type="hidden" name="<?php echo $this->security->get_csrf_token_name();?>" value="<?php echo $this->security->get_csrf_hash();?>">
|
||||
<input type="hidden" name="<?php echo $this->security->get_csrf_token_name();?>" value="<?php echo $this->security->get_csrf_hash();?>">
|
||||
|
||||
<div class="x_panel">
|
||||
<div class="item form-group">
|
||||
|
||||
<label class="control-label col-md-2 col-sm-2" for="last-name">Expense Requisted For</label>
|
||||
|
||||
<label class="control-label col-md-2 col-sm-2" for="last-name">Expense Requested For</label>
|
||||
<div class="col-md-4 col-sm-4 ">
|
||||
|
||||
|
||||
<input type="radio" name="created_by" value="self (<?php echo user()->id;?>)"style="margin:10px;"checked /><b>Self</b>
|
||||
|
||||
<input type="radio" name="created_by" value="<?php echo user()->name;?> (<?php echo user()->id;?>)" style="margin: 10px;" /><b>Others</b>
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
<label class="control-label col-md-1 col-sm-1 " for="last-name"> Employee Name <a style="color:red;">*</a></label>
|
||||
<div class="col-md-5 col-sm-5 ">
|
||||
<select id="user_dropdown" name="emp_id" style="margin-top: 10px;padding-bottom: 10px;" class="form-control manager" > </select>
|
||||
@ -139,18 +139,18 @@
|
||||
<input type='text' class="form-control" name="expense_name" value="<?php if(isset($expense_data[0]->id)){echo $expense_data[0]->expense_name; } ?>" autocomplete='off' required />
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
<label class="control-label col-md-1 col-sm-1 " for="first-name">Business Reason</label>
|
||||
<div class="col-md-5 col-sm-5 ">
|
||||
<div class="form-group">
|
||||
<input type='text' class="form-control" name="business_reason" value="<?php if(isset($expense_data[0]->id)){echo $expense_data[0]->business_reason; } ?>" autocomplete='off'/>
|
||||
|
||||
|
||||
<input type="hidden" id="expense_id" name="expense_pid" value="<?php echo $expense_data[0]->id; ?>">
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@ -158,7 +158,7 @@
|
||||
|
||||
<div class="x_panel">
|
||||
<div class="x_title">
|
||||
<!-- <ul class="nav navbar-right panel_toolbox">
|
||||
<!-- <ul class="nav navbar-right panel_toolbox">
|
||||
<button type="button" id="add-button" onclick="createAndAppendFormGroup()" class="btn btn-info" style="font-size:small;" >Add</button>
|
||||
</ul> -->
|
||||
<div class="clearfix"></div>
|
||||
@ -182,18 +182,18 @@
|
||||
else if($value->status == "Cancelled")
|
||||
{
|
||||
echo $value->status.' at '.date('d-m-Y h:i:s', strtotime($value->cancelled_at));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
echo $value->status;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
|
||||
">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
@ -202,9 +202,14 @@
|
||||
<label class="control-label col-md-1 col-sm-1 " for="first-name"> Date of Expense<a style="color:red;">*</a></label>
|
||||
<div class="col-md-5 col-sm-5 ">
|
||||
<div class="form-group">
|
||||
<input type='text' id="ExpenseDate<?php echo $i;?>" class="form-control date" placeholder="DD-MM-YYYY" required name="date_of_expence[]" value="<?php echo $value->date_of_expense_new ?>" autocomplete='off'/><i class="fa fa-calendar" style=" position: absolute; right: 25px; top: 12px;z-index: 0;"></i>
|
||||
<?php
|
||||
// Assuming $leave->perm_date_new is in the 'Y-m-d' format
|
||||
$formatted_date = date('d-m-y', strtotime($value->date_of_expense_new));
|
||||
?>
|
||||
|
||||
<input type='text' id="ExpenseDate<?php echo $i;?>" class="form-control date" placeholder="DD-MM-YYYY" required name="date_of_expence_new[]" value="<?php echo $formatted_date ?>" autocomplete='off'/><i class="fa fa-calendar" style=" position: absolute; right: 25px; top: 12px;z-index: 0;"></i>
|
||||
</div>
|
||||
|
||||
|
||||
</div>
|
||||
<label class="control-label col-md-1 col-sm-1 " for="first-name">Amount<a style="color:red;">*</a></label>
|
||||
<div class="col-md-5 col-sm-5">
|
||||
@ -220,14 +225,14 @@
|
||||
<textarea id="comments" name="description[]" value="" class="form-control" style="height:50px !important;" type="text" ><?php echo $value->description ?></textarea>
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
<label class="control-label col-md-1 col-sm-1" required for="first-name">Recipt</label>
|
||||
<div class="col-md-5 col-sm-5 ">
|
||||
<input id="formFile" name="bill[]" onchange="validateFile(this)" class="typeFile" type="file" value="<?php echo $value->bill ?>" multiple><br>
|
||||
|
||||
<a href="<?php echo base_url(); ?>assets/uploads/Expence_Bill/<?php echo $value->bill; ?>" target="_blank" class="float-right" style="font-size: x-small; color: darkblue; margin-top: 7px;"><b>View Recipt(<?php echo $value->bill; ?>)</b></a></div>
|
||||
|
||||
<?php if($expense_data[0]->status == 'Draft') { ?>
|
||||
<?php if($expense_data[0]->status == 'Draft') { ?>
|
||||
|
||||
<div class="col-12"><button type="button" class="float-right btn btn-danger deleteexpense hidebtn" data-toggle="modal" data-target=".bs-example-modal-sm" id="<?php echo $value->id;?>"><i class="fa fa-trash"></i></button>
|
||||
|
||||
@ -242,13 +247,13 @@
|
||||
<script>
|
||||
|
||||
flatpickr($('#ExpenseDate'+<?php echo $i;?>), {
|
||||
dateFormat: 'd-m-Y',
|
||||
dateFormat: 'd-m-Y',
|
||||
changeYear: true,
|
||||
yearRange: '2000:' + new Date().getFullYear(),
|
||||
maxDate: new Date(),
|
||||
autoclose:true,
|
||||
allowInput: false,
|
||||
|
||||
|
||||
onChange: function(selectedDates, dateStr) {
|
||||
console.log('Selected date: ', dateStr);
|
||||
instance._input.removeAttribute("readonly");
|
||||
@ -267,7 +272,7 @@
|
||||
<div class="ln_solid"></div>
|
||||
<div class="item form-group">
|
||||
<div class=" offset-md-8">
|
||||
<?php if($expense_data[0]->status == 'Draft') { ?>
|
||||
<?php if($expense_data[0]->status == 'Draft') { ?>
|
||||
<a href="<?php echo base_url();?>Expence/emp_expence_list" class="btn btn-secondary">Cancel</a>
|
||||
<button type="submit" class="btn btn-success" name="update" value="update">Update</button>
|
||||
<?php } ?>
|
||||
@ -278,8 +283,8 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
@ -295,10 +300,10 @@
|
||||
<!-- /Body page content -->
|
||||
|
||||
<script>
|
||||
|
||||
// hide the dropdown arrow
|
||||
|
||||
$(document).ready(function() {
|
||||
|
||||
// hide the dropdown arrow
|
||||
|
||||
$(document).ready(function() {
|
||||
|
||||
$("#user_dropdown").addClass("hide-arrow");
|
||||
$("input[name='created_by']").on("change", function() {
|
||||
@ -327,16 +332,16 @@
|
||||
// console.log(datepickerInput);
|
||||
|
||||
// flatpickr(datepickerInput, {
|
||||
// dateFormat: 'd-m-Y',
|
||||
// dateFormat: 'd-m-Y',
|
||||
// maxDate: new Date(),
|
||||
|
||||
|
||||
// onChange: function(selectedDates, dateStr) {
|
||||
// console.log('Selected date: ', dateStr);
|
||||
// }
|
||||
// });
|
||||
|
||||
// });
|
||||
|
||||
|
||||
|
||||
function validateFile(input) {
|
||||
const file = input.files[0];
|
||||
@ -370,17 +375,17 @@ function matchnum(event)
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
|
||||
$(document).ready(function(){
|
||||
|
||||
var currentUserName = '<?php echo user()->name; ?>';
|
||||
var currentUserId = '<?php echo user()->id; ?>';
|
||||
$('#user_dropdown').append('<option value="' + currentUserId + '">' +
|
||||
$('#user_dropdown').append('<option value="' + currentUserId + '">' +
|
||||
currentUserName + '</option>');
|
||||
$('#user_dropdown').prop('disabled', true);
|
||||
|
||||
$('#user_dropdown').on('change',function() {
|
||||
|
||||
|
||||
});
|
||||
|
||||
$('input[type="radio"][name="created_by"]').change(function() {
|
||||
@ -392,7 +397,7 @@ function matchnum(event)
|
||||
$userDropdown.empty();
|
||||
|
||||
if (selectedValue === 'self (<?php echo user()->id;?>)') {
|
||||
|
||||
|
||||
var currentUserName = '<?php echo user()->name; ?>';
|
||||
var currentUserId = '<?php echo user()->id; ?>';
|
||||
$userDropdown.append('<option value="' + currentUserId + '">' + currentUserName + '</option>');
|
||||
@ -400,7 +405,7 @@ function matchnum(event)
|
||||
} else if (selectedValue === '<?php echo user()->name; ?> (<?php echo user()->id;?>)') {
|
||||
|
||||
$.ajax({
|
||||
url: '<?php echo base_url('Expence/get_emp_name/')?>"',
|
||||
url: '<?php echo base_url('Expence/get_emp_name/')?>"',
|
||||
method: 'GET',
|
||||
dataType: 'json',
|
||||
success: function(response) {
|
||||
@ -414,13 +419,13 @@ function matchnum(event)
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
});
|
||||
|
||||
</script>
|
||||
|
||||
<script>
|
||||
|
||||
|
||||
//get manager id from the dropdown employee assign the value to $("#manager_id") input field
|
||||
|
||||
$("#user_dropdown").on("change", function(){
|
||||
@ -430,7 +435,7 @@ function matchnum(event)
|
||||
|
||||
$("#manager_id").val(manager_id);
|
||||
|
||||
|
||||
|
||||
})
|
||||
</script>
|
||||
|
||||
@ -463,10 +468,10 @@ function createAndAppendFormGroup() {
|
||||
//formContainer.innerHTML += html1;
|
||||
formContainer.insertAdjacentHTML('beforeend', html1);
|
||||
|
||||
|
||||
|
||||
const datepickerInput = document.getElementById('datepicker'+i);
|
||||
flatpickr(datepickerInput, {
|
||||
dateFormat: 'd-m-Y',
|
||||
dateFormat: 'd-m-Y',
|
||||
maxDate: new Date(),
|
||||
autoclose:true,
|
||||
allowInput: false,
|
||||
@ -474,9 +479,9 @@ function createAndAppendFormGroup() {
|
||||
onChange: function(selectedDates, dateStr) {
|
||||
console.log('Selected date: ', dateStr);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
function removebutton(index) {
|
||||
@ -496,14 +501,14 @@ function removebutton(index) {
|
||||
var expence_id = document.getElementById('expense_id').value;
|
||||
var url = "<?php echo base_url()?>Expence/remove_row";
|
||||
|
||||
$.ajax({
|
||||
$.ajax({
|
||||
url: "<?php echo base_url()?>Expence/getCancelConfirmationPopup",
|
||||
type:"GET",
|
||||
success:function(data){
|
||||
$('#popup').html(JSON.parse(data));
|
||||
$('.delete_id').attr('value',id);
|
||||
$('.expence_id').attr('value',expence_id);
|
||||
$('.delete_url').attr('action',url);
|
||||
$('.delete_url').attr('action',url);
|
||||
}
|
||||
});
|
||||
});
|
||||
@ -513,19 +518,19 @@ function removebutton(index) {
|
||||
|
||||
// var id = document.getElementById('expense_id').value;
|
||||
// alert(id)
|
||||
|
||||
|
||||
// $('.hidebtn').disable()
|
||||
|
||||
// // $.ajax({
|
||||
// // data:{id : id},
|
||||
// // $.ajax({
|
||||
// // data:{id : id},
|
||||
// // url: "<?php echo base_url()?>Expence/get_expense_child_count",
|
||||
// // type:"GET",
|
||||
// // success:function(data){
|
||||
// // $('#popup').html(JSON.parse(data));
|
||||
// // $('.delete_id').attr('value',id);
|
||||
// // $('.expence_id').attr('value',expence_id);
|
||||
// // $('.delete_url').attr('action',url);
|
||||
// // $('.delete_url').attr('action',url);
|
||||
// // }
|
||||
// // });
|
||||
// });
|
||||
</script>
|
||||
</script>
|
||||
|
||||
@ -144,7 +144,12 @@
|
||||
<label class="control-label col-md-1 col-sm-1 label-align" for="first-name"> Date of Expense<a style="color:red;">*</a></label>
|
||||
<div class="col-md-5 col-sm-5 ">
|
||||
<div class="form-group">
|
||||
<input type='date' id='ExpenseDate' class="form-control" placeholder="DD-MM-YYYY" required name="date_of_expence_new[]" value="<?php echo $value->date_of_expense ?>" autocomplete='off' /><i class="fa fa-calendar"></i>
|
||||
<?php
|
||||
// Assuming $leave->perm_date_new is in the 'Y-m-d' format
|
||||
$formatted_date = date('d-m-y', strtotime($value->date_of_expense_new));
|
||||
?>
|
||||
|
||||
<input type='date' id='ExpenseDate' class="form-control" placeholder="DD-MM-YYYY" required name="date_of_expence_new[]" value="<?php echo $formatted_date ?>" autocomplete='off' /><i class="fa fa-calendar"></i>
|
||||
</div>
|
||||
|
||||
<input type="hidden" name="expense_pid" value="<?php echo $expense_data[0]->id; ?>">
|
||||
|
||||
@ -198,7 +198,7 @@
|
||||
<tr class="even pointer">
|
||||
<td hidden><?php echo $value->id; ?></td>
|
||||
<td><?php echo date('d-m-Y', strtotime($value->created_on));?></td>
|
||||
<td class=" "><?php echo date('d-m-Y', strtotime($value->date_of_expense)) ?></td>
|
||||
<td class=" "><?php echo date('d-m-Y', strtotime($value->date_of_expense_new)) ?></td>
|
||||
<td class=" "><?php echo $value->amount; ?></td>
|
||||
<td class=" "><?php echo $value->description; ?></td>
|
||||
<?php if($value->status == 'pending'){ ?>
|
||||
|
||||
@ -86,7 +86,7 @@ public function leave_list_report()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$result = array_values($resultArray);
|
||||
// echo json_encode( $result, JSON_PRETTY_PRINT);die;
|
||||
$this->layout->set('leave_list', $result);
|
||||
@ -165,19 +165,20 @@ public function createLeave()
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
|
||||
$manager = employee()->manager;
|
||||
}
|
||||
|
||||
|
||||
}else{
|
||||
|
||||
|
||||
$manager = $this->input->post('manager');
|
||||
}
|
||||
$perm_data['manager'] = $manager;
|
||||
$perm_data['business_id'] = user()->business_id;
|
||||
$perm_data['status'] = 'pending';
|
||||
// $perm_data['created_date'] = date('d-m-Y');
|
||||
$perm_data['created_date_new'] = date('d-m-Y');
|
||||
$perm_data['created_date_new'] = date('Y-m-d');
|
||||
|
||||
$perm_data['created_time'] = date('H:i A');
|
||||
unset($perm_data['from_date']);
|
||||
unset($perm_data['to_date']);
|
||||
@ -185,35 +186,36 @@ public function createLeave()
|
||||
unset($perm_data['to_date_new']);
|
||||
$table="leave_list";
|
||||
$perm_data['perm_date_new'] = date("Y-m-d", strtotime( $this->input->post('perm_date_new') ));
|
||||
|
||||
$create_permission = $this->MY_Model->insert($perm_data,$table);
|
||||
|
||||
|
||||
//for notification
|
||||
if($create_permission){
|
||||
$code = 'LEAVE_PERMISSION';
|
||||
$type = 'Email';
|
||||
$this->notification->sendNotification($create_permission, $code, $type);
|
||||
}
|
||||
|
||||
|
||||
$this->session->set_flashdata('Success', '1');
|
||||
redirect('Leave/LeaveHistory');
|
||||
}
|
||||
//end of permission
|
||||
|
||||
|
||||
|
||||
|
||||
//Leave create part
|
||||
$data = $this->input->post();
|
||||
unset($data['perm_date']);
|
||||
unset($data['perm_date_new']);
|
||||
unset($data['from_time']);
|
||||
unset($data['to_time']);
|
||||
|
||||
|
||||
if(isset($data['emp_id'])){
|
||||
$emp_id =$this->input->post('emp_id');
|
||||
}else{
|
||||
$emp_id = user()->id;
|
||||
}
|
||||
$data['emp_id'] = $emp_id;
|
||||
|
||||
|
||||
if($data['manager']==""){
|
||||
if(employee()->manager == null)
|
||||
{
|
||||
@ -221,12 +223,12 @@ public function createLeave()
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
|
||||
$manager = employee()->manager;
|
||||
}
|
||||
|
||||
|
||||
}else{
|
||||
|
||||
|
||||
$manager = $this->input->post('manager');
|
||||
}
|
||||
$data['manager'] = $manager;
|
||||
@ -236,23 +238,23 @@ public function createLeave()
|
||||
$perm_data['created_date_new'] = date('d-m-Y');
|
||||
$data['created_time'] = date('H:i A');
|
||||
$leave_year = date('Y', strtotime($this->input->post('from_date_new')));
|
||||
|
||||
|
||||
//get employee's leave count
|
||||
$emp_leave_count = $this->Leave_model->get_leave( $emp_id , user()->business_id , "emp_leave_days", $leave_year, $this->input->post('type'));
|
||||
$leave_master_count = $this->Leave_model->get_by_type( $this->input->post('type') , user()->business_id , "leave_master");
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// count number of days between two dates
|
||||
$days_between = ceil(abs(strtotime($this->input->post('to_date_new')) - strtotime($this->input->post('from_date_new'))) / 86400);
|
||||
$data['no_of_days'] = $days_between + 1;
|
||||
$noofdays = $days_between + 1;
|
||||
|
||||
|
||||
|
||||
|
||||
//this part is create and update leave data
|
||||
if (count($emp_leave_count) != 0)
|
||||
{
|
||||
|
||||
|
||||
if($noofdays > $emp_leave_count[0]->remaining_days)
|
||||
{
|
||||
$this->session->set_flashdata('error', '1');
|
||||
@ -265,7 +267,7 @@ public function createLeave()
|
||||
$days['remaining_days'] = $emp_leave_count[0]->remaining_days;
|
||||
$this->Leave_model->update_leave($days, $emp_id , 'emp_leave_days', $leave_year, $this->input->post('type'));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -279,26 +281,26 @@ public function createLeave()
|
||||
$all_leave_count = $this->Leave_model->get_by_type( $this->input->post('type') , user()->business_id , "leave_master");
|
||||
$data['leave_bal'] = $all_leave_count[0]->days;
|
||||
$days['remaining_days'] = $all_leave_count[0]->days;
|
||||
|
||||
|
||||
$days['business_id'] = user()->business_id;
|
||||
$days['emp_id'] = $emp_id;
|
||||
$days['total_days'] = $all_leave_count[0]->days;
|
||||
$days['type'] = $all_leave_count[0]->id;
|
||||
$days['year'] = $leave_year;
|
||||
$this->MY_Model->insert($days,'emp_leave_days');
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$get_emp_data = $this->Leave_model->get_emp_data_by_emp_id($emp_id);
|
||||
// echo json_encode( $get_emp_data);die;
|
||||
// print_r($get_emp_data[0]->j_date); die;
|
||||
|
||||
|
||||
$from_date = new DateTime($this->input->post('from_date_new'));
|
||||
$j_date = new DateTime($get_emp_data[0]->j_date);
|
||||
$to_date = new DateTime($this->input->post('to_date_new'));
|
||||
|
||||
|
||||
|
||||
|
||||
if ($from_date >= $j_date && $from_date <= $to_date) {
|
||||
$table="leave_list";
|
||||
$data['from_date_new'] = date("Y-m-d", strtotime( $this->input->post('from_date_new') ));
|
||||
@ -308,15 +310,15 @@ public function createLeave()
|
||||
} else {
|
||||
$this->session->set_flashdata('error', '1');
|
||||
redirect('Leave/applyLeave/'.'update');
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
if($create_leave){
|
||||
$code = 'APPLY_LEAVE';
|
||||
$type = 'Email';
|
||||
$mailres = $this->notification->sendNotification($create_leave, $code, $type);
|
||||
}
|
||||
|
||||
|
||||
//audit
|
||||
if($create_leave)
|
||||
{
|
||||
@ -334,8 +336,8 @@ public function createLeave()
|
||||
} catch (Exception $e) {
|
||||
echo "An error occurred: " . $e->getMessage();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -351,7 +353,7 @@ public function edit_leave_function()
|
||||
// print_r($leavetype);
|
||||
// print_r($id);
|
||||
// print_r($editleave);
|
||||
// // // print_r($emp);
|
||||
// print_r($emp);
|
||||
// die;
|
||||
$this->layout->set('emp', $emp);
|
||||
$this->layout->set('editleave', $editleave);
|
||||
@ -367,8 +369,8 @@ public function editleave()
|
||||
if($this->input->post('type') === '1')
|
||||
{
|
||||
$action = $this->input->post();
|
||||
unset($action['from_date']);
|
||||
unset($action['to_date']);
|
||||
unset($action['from_date_new']);
|
||||
unset($action['to_date_new']);
|
||||
$id = $this->input->post('id');
|
||||
|
||||
if(isset($action['emp_id'])){
|
||||
@ -385,10 +387,13 @@ public function editleave()
|
||||
$action['manager'] = $manager;
|
||||
$action['business_id'] = user()->business_id;
|
||||
$action['status'] = 'pending';
|
||||
$action['perm_date_new'] = date('Y-m-d', strtotime($this->input->post('perm_date_new')));
|
||||
|
||||
$action['created_date'] = date('d-m-Y');
|
||||
$action['created_time'] = date('H:i A');
|
||||
$table="leave_list";
|
||||
$create_permission = $this->MY_Model->edit_option($action, $id, $table);
|
||||
|
||||
$this->session->set_flashdata('update', '0');
|
||||
redirect('Leave/LeaveHistory');
|
||||
}
|
||||
@ -405,27 +410,37 @@ public function editleave()
|
||||
$action['emp_id'] = $emp_id;
|
||||
$action['business_id'] = user()->business_id;
|
||||
$action['status'] = 'pending';
|
||||
$leave_year = date('Y', strtotime($this->input->post('from_date')));
|
||||
$action['from_date_new'] = date('Y-m-d', strtotime($this->input->post('from_date_new')));
|
||||
$action['to_date_new'] = date('Y-m-d', strtotime($this->input->post('to_date_new')));
|
||||
|
||||
|
||||
|
||||
$leave_year = date('Y', strtotime($this->input->post('from_date_new')));
|
||||
$emp_leave_count = $this->Leave_model->get_leave( $emp_id , user()->business_id , "emp_leave_days", $leave_year, $this->input->post('type'));
|
||||
$leave_master_count = $this->Leave_model->get_by_type( $this->input->post('type') , user()->business_id , "leave_master");
|
||||
|
||||
|
||||
// count number of days between two dates
|
||||
$days_between = ceil(abs(strtotime($this->input->post('to_date')) - strtotime($this->input->post('from_date'))) / 86400);
|
||||
$days_between = ceil(abs(strtotime(date('Y-m-d', strtotime($this->input->post('to_date_new')))) - strtotime(date('Y-m-d', strtotime($this->input->post('from_date_new'))))) / 86400);
|
||||
|
||||
$action['no_of_days'] = $days_between + 1;
|
||||
$noofdays = $days_between + 1;
|
||||
$leave_id = $this->input->post('id');
|
||||
if (count($emp_leave_count) != 0)
|
||||
{
|
||||
|
||||
if($noofdays > $emp_leave_count[0]->remaining_days)
|
||||
{
|
||||
|
||||
$this->session->set_flashdata('error', '1');
|
||||
redirect('Leave/edit_leave_function?id='.md5($leave_id));
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
//this part is update if date inculeded in emp_leave_days table
|
||||
$action['leave_bal'] = $emp_leave_count[0]->remaining_days;
|
||||
|
||||
$days['remaining_days'] = $emp_leave_count[0]->remaining_days;
|
||||
$this->Leave_model->update_leave($days, $emp_id , 'emp_leave_days', $leave_year, $this->input->post('type'));
|
||||
}
|
||||
@ -433,11 +448,15 @@ public function editleave()
|
||||
else
|
||||
{
|
||||
if($noofdays > $leave_master_count[0]->days)
|
||||
{ $this->session->set_flashdata('error', '1');
|
||||
{
|
||||
|
||||
$this->session->set_flashdata('error', '1');
|
||||
redirect('Leave/edit_leave_function?id='.md5($leave_id));
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
echo "else stss";
|
||||
$all_leave_count = $this->Leave_model->get_by_type( $this->input->post('type') , user()->business_id , "leave_master");
|
||||
$data['leave_bal'] = $all_leave_count[0]->days;
|
||||
$days['remaining_days'] = $all_leave_count[0]->days;
|
||||
@ -452,14 +471,16 @@ public function editleave()
|
||||
}
|
||||
}
|
||||
|
||||
$get_from_date = $this->Leave_model->get_from_date($emp_id, $this->input->post('from_date'), $this->input->post('to_date'));
|
||||
$get_from_date = $this->Leave_model->get_from_date($emp_id, $this->input->post('from_date_new'), $this->input->post('to_date_new'));
|
||||
// echo "<pre>";
|
||||
// print_r($get_from_date); die();
|
||||
|
||||
|
||||
if($get_from_date == 0)
|
||||
{
|
||||
echo"update fun:";
|
||||
$table="leave_list";
|
||||
$update_leave = $this->MY_Model->edit_option($action,$id,$table);
|
||||
|
||||
$this->session->set_flashdata('update', '0');
|
||||
redirect('Leave/LeaveHistory');
|
||||
}
|
||||
@ -488,6 +509,7 @@ public function get_all_leave_count()
|
||||
{
|
||||
$id = $this->input->get('type_id');
|
||||
$all_leave_count = $this->Leave_model->get_id( $id , user()->business_id , "leave_master");
|
||||
|
||||
echo json_encode($all_leave_count);
|
||||
|
||||
}
|
||||
@ -512,14 +534,16 @@ public function ApproveLeave()
|
||||
$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_year = date('Y', strtotime($no_of_days->from_date_new));
|
||||
$leave_type = $this->Leave_model->get_leave_data_using_leave_id($id);
|
||||
|
||||
// print_r($leave_year);
|
||||
|
||||
if($leave_type->leave_code !== 'permission')
|
||||
{
|
||||
$remaining_days = $this->Leave_model->remaining_days($emp_id, user()->business_id, $leave_year, $no_of_days->type);
|
||||
$remaining_days = $this->Leave_model->remaining_days($emp_id,$business_id, $leave_year, $no_of_days->type);
|
||||
$balance_days = $remaining_days[0]->remaining_days - $no_of_days->no_of_days;
|
||||
|
||||
// print_r($balance_days);die;
|
||||
$data['leave_bal'] = $balance_days;
|
||||
$days['remaining_days'] = $balance_days;
|
||||
$this->Leave_model->emp_leave_days_update($emp_id, $days, $leave_year, $business_id, $no_of_days->type);
|
||||
@ -556,7 +580,7 @@ public function ManagerLeaveApprove()
|
||||
$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_year = date('Y', strtotime($no_of_days->from_date_new));
|
||||
$leave_type = $this->Leave_model->get_leave_data_using_leave_id($id);
|
||||
|
||||
$remaining_days = $this->Leave_model->remaining_days($emp_id, user()->business_id, $leave_year, $no_of_days->type);
|
||||
@ -691,7 +715,7 @@ public function DeclinewithdrawLeave()
|
||||
$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_year = date('Y', strtotime($no_of_days->from_date_new));
|
||||
$leave_type = $this->Leave_model->get_leave_data_using_leave_id($id);
|
||||
|
||||
if($leave_type->leave_code !== 'permission')
|
||||
@ -730,7 +754,7 @@ public function ApprovewithdrawLeave()
|
||||
|
||||
// Update leave balance
|
||||
$emp_id = $this->Leave_model->get_emp_id($id);
|
||||
$leave_year = date('Y', strtotime($leave_data->from_date));
|
||||
$leave_year = date('Y', strtotime($leave_data->from_date_new));
|
||||
$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;
|
||||
|
||||
|
||||
@ -180,6 +180,7 @@ public function remaining_days($emp_id, $business_id, $leave_year, $type)
|
||||
$this->db->where('is_active', 1);
|
||||
$query = $this->db->get();
|
||||
$query = $query->result();
|
||||
// print_r($this->db->last_query());
|
||||
return $query;
|
||||
}
|
||||
|
||||
@ -511,8 +512,8 @@ public function get_from_date($emp_id, $from_date, $to_date)
|
||||
$this->db->select('*');
|
||||
$this->db->from('leave_list');
|
||||
$this->db->where('emp_id', $emp_id);
|
||||
$this->db->where('from_date >=', $from_date);
|
||||
$this->db->where('to_date <=', $to_date);
|
||||
$this->db->where('from_date_new >=', $from_date);
|
||||
$this->db->where('to_date_new <=', $to_date);
|
||||
$query = $this->db->count_all_results();
|
||||
return $query;
|
||||
}
|
||||
@ -544,8 +545,8 @@ public function get_approved_leaves_cur_week()
|
||||
$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->where("STR_TO_DATE(from_date_new, '%d-%m-%Y') <= '$currentWeekEnd'");
|
||||
$this->db->where("STR_TO_DATE(to_date_new, '%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();
|
||||
@ -556,8 +557,8 @@ public function get_approved_leaves_cur_week()
|
||||
// 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));
|
||||
$leaveStartDate = ($leave->from_date_new) ? date('Y-m-d', strtotime($leave->from_date_new)) : date('Y-m-d', strtotime($leave->perm_date));
|
||||
$leaveEndDate = ($leave->to_date_new) ? date('Y-m-d', strtotime($leave->to_date_new)) : date('Y-m-d', strtotime($leave->perm_date));
|
||||
|
||||
// Use from_time and to_time if available
|
||||
$fromTime = ($leave->from_time) ? ' ' . $leave->from_time : '';
|
||||
@ -586,7 +587,7 @@ public function get_week_leave_count($business_id)
|
||||
{
|
||||
$startOfWeek = date('Y-m-d', strtotime('monday this week'));
|
||||
$endOfWeek = date('Y-m-d', strtotime('sunday this week'));
|
||||
|
||||
|
||||
// Query to get leave records for the specified employee within the current week
|
||||
$this->db->select('A.*, U1.name as employee_name');
|
||||
$this->db->from('leave_list A');
|
||||
@ -606,7 +607,7 @@ public function get_week_leave_count($business_id)
|
||||
'friday' => [],
|
||||
'saturday' => []
|
||||
);
|
||||
|
||||
|
||||
// Iterate over the leave records to count leaves for each day of the week
|
||||
foreach ($leaveRecords as $key => $record) {
|
||||
if($record->from_date_new < $startOfWeek)
|
||||
@ -628,10 +629,10 @@ public function get_week_leave_count($business_id)
|
||||
}
|
||||
array_push($weeklyLeaveCounts[strtolower($startDate)], $record->employee_name); // Increment for the last day
|
||||
}
|
||||
|
||||
|
||||
// Return the array with leave counts for each day of the week
|
||||
return $weeklyLeaveCounts;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -143,7 +143,7 @@
|
||||
|
||||
<label class="control-label col-md-1 col-sm-1 " for="first-name"> Balance</label>
|
||||
<div class="col-md-1 col-sm-1 ">
|
||||
<input type="text" id="leave_bal" name="" value="" style="width:90px;" class="form-control " readonly>
|
||||
<input type="text" id="leave_bal" name="" value="<?php echo $leave->leave_bal; ?>" style="width:90px;" class="form-control " readonly>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
@ -154,7 +154,7 @@
|
||||
<label class="control-label col-md-2 col-sm-2 " for="first-name"> From Date<a style="color:red;">*</a> </label>
|
||||
<div class="col-md-2 col-sm-2 ">
|
||||
<div class='input-group date'>
|
||||
<input type='text' class="form-control" placeholder="DD-MM-YYYY" id="fromdate" name="from_date" value="<?php echo dateFormat('d-m-Y', $leave->from_date); ?>" required />
|
||||
<input type='text' class="form-control" placeholder="DD-MM-YYYY" id="fromdate" name="from_date_new" value="<?php echo dateFormat('d-m-Y', $leave->from_date_new); ?>" required />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@ -162,14 +162,14 @@
|
||||
<label class="control-label col-md-1 col-sm-1" for="last-name">To Date<a style="color:red;">*</a> </label>
|
||||
<div class="col-md-2 col-sm-2 ">
|
||||
<div class='input-group date' >
|
||||
<input type='text' class="form-control" placeholder="DD-MM-YYYY" id="todate" name= "to_date" value="<?php echo dateFormat('d-m-Y', $leave->to_date); ?>" required />
|
||||
<input type='text' class="form-control" placeholder="DD-MM-YYYY" id="todate" name= "to_date_new" value="<?php echo dateFormat('d-m-Y', $leave->to_date_new); ?>" required />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<label class="control-label col-md-1 col-sm-1 " for="last-name"></label>
|
||||
<div class="col-md-2 col-sm-2 ">
|
||||
<input id="dateDifference" value="" readonly class="form-control" style="width:90px;" type="text" >
|
||||
<input id="dateDifference" value="<?php echo $leave->no_of_days; ?>days" readonly class="form-control" style="width:90px;" type="text" >
|
||||
</div>
|
||||
|
||||
</div>
|
||||
@ -179,7 +179,12 @@
|
||||
<label class="control-label col-md-2 col-sm-2 " for="first-name">Date<a style="color:red;">*</a> </label>
|
||||
<div class="col-md-5 col-sm-5 ">
|
||||
<div class='input-group date'>
|
||||
<input type='text' class="form-control" required name="perm_date" placeholder="DD-MM-YYYY" value="<?php echo $leave->perm_date; ?>" id='myDatepicker'/></div>
|
||||
<?php
|
||||
// Assuming $leave->perm_date_new is in the 'Y-m-d' format
|
||||
$formatted_date = date('d-m-y', strtotime($leave->perm_date_new));
|
||||
?>
|
||||
<input type='text' class="form-control" required name="perm_date_new" placeholder="DD-MM-YYYY" value="<?php echo $formatted_date; ?>" id='myDatepicker' />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
@ -117,7 +117,7 @@
|
||||
<?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 echo $value->DeclineBy; ?> <br>" <?php echo $value->DReason; ?> "</td></td>
|
||||
<?php }
|
||||
else if($value->status == 'Withdraw-Approved'){ ?>
|
||||
<td style="color:green"><?php echo $value->status; ?> By
|
||||
|
||||
Loading…
Reference in New Issue
Block a user