ss
This commit is contained in:
parent
cb1287ce35
commit
549dc11a9c
@ -78,7 +78,7 @@
|
||||
'hostname' => 'localhost',
|
||||
'username' => 'root',
|
||||
'password' => '',
|
||||
'database' => 'testbbone',
|
||||
'database' => 'venbaehn_ams',
|
||||
// 'hostname' => '119.18.54.85',
|
||||
// 'username' => 'venbaehn_ams',
|
||||
// 'password' => 'L;nD7Z@f)1ZT',
|
||||
|
||||
@ -19,37 +19,37 @@ function send_emails($to, $subject, $body, $aliasName = '', $cc = null, $bcc = n
|
||||
|
||||
$mailer->isSMTP();
|
||||
$mailer->CharSet = 'utf-8';
|
||||
$mailer->Host=business()->mail_hostname;
|
||||
$mailer->SMTPSecure = business()->mail_security;
|
||||
$mailer->Host= 'mail.venbait.in';
|
||||
$mailer->SMTPSecure = 'ssl';
|
||||
$mailer->SMTPAuth =true;
|
||||
$mailer->SMTPDebug = 2;
|
||||
$mailer->Username=business()->mail_username;
|
||||
$mailer->Password=business()->mail_password;
|
||||
$mailer->Port=business()->mail_port_no;
|
||||
$mailer->SMTPDebug = false;
|
||||
$mailer->Username='bbone@venbait.in';
|
||||
$mailer->Password='xk!L(N_-R#};';
|
||||
$mailer->Port=465;
|
||||
$mailer->setFrom(business()->sender_mail, $aliasName);
|
||||
$mailer->addAddress($to);
|
||||
$mailer->addAddress('suseendhiran13@gmail.com');
|
||||
|
||||
// Add CC recipients
|
||||
if ($cc !== null) {
|
||||
if (is_array($cc)) {
|
||||
foreach ($cc as $ccRecipient) {
|
||||
$mailer->addCC($ccRecipient);
|
||||
}
|
||||
} else {
|
||||
$mailer->addCC($cc);
|
||||
}
|
||||
}
|
||||
// if ($cc !== null) {
|
||||
// if (is_array($cc)) {
|
||||
// foreach ($cc as $ccRecipient) {
|
||||
// $mailer->addCC($ccRecipient);
|
||||
// }
|
||||
// } else {
|
||||
// $mailer->addCC($cc);
|
||||
// }
|
||||
// }
|
||||
|
||||
// Add BCC recipients
|
||||
if ($bcc !== null) {
|
||||
if (is_array($bcc)) {
|
||||
foreach ($bcc as $bccRecipient) {
|
||||
$mailer->addBCC($bccRecipient);
|
||||
}
|
||||
} else {
|
||||
$mailer->addBCC($bcc);
|
||||
}
|
||||
}
|
||||
// if ($bcc !== null) {
|
||||
// if (is_array($bcc)) {
|
||||
// foreach ($bcc as $bccRecipient) {
|
||||
// $mailer->addBCC($bccRecipient);
|
||||
// }
|
||||
// } else {
|
||||
// $mailer->addBCC($bcc);
|
||||
// }
|
||||
// }
|
||||
|
||||
$mailer->Subject=$subject;
|
||||
$mailer->isHTML(true);
|
||||
|
||||
@ -74,8 +74,9 @@ public function rise_expence_request()
|
||||
}else{
|
||||
$emp_id = user()->id;
|
||||
}
|
||||
// echo $emp_id;die;
|
||||
$get_manager_id = $this->Expence_model->get_manager_id($emp_id);
|
||||
|
||||
// echo $get_manager_id[0]->manager;die;
|
||||
if($get_manager_id[0]->manager == null){
|
||||
|
||||
$manager = 0;
|
||||
@ -96,7 +97,9 @@ public function rise_expence_request()
|
||||
$table="expense";
|
||||
$create_Expence = $this->MY_Model->insert($data1,$table);
|
||||
|
||||
$count = count($this->input->post('date_of_expence'));
|
||||
// $count = count($this->input->post('date_of_expence'));
|
||||
$count = ($this->input->post('date_of_expence_new')) ? count($this->input->post('date_of_expence_new')) : 1;
|
||||
// echo json_encode($this->input->post());die;
|
||||
for($i=0;$i<$count;$i++)
|
||||
{
|
||||
|
||||
@ -106,7 +109,8 @@ public function rise_expence_request()
|
||||
'business_id' => user()->business_id,
|
||||
'manager_id' => $manager,
|
||||
'status' => 'Draft',
|
||||
'date_of_expense'=> $this->input->post('date_of_expence')[$i],
|
||||
// 'date_of_expense'=> $this->input->post('date_of_expence')[$i],
|
||||
'date_of_expense_new'=> $this->input->post('date_of_expence_new')[$i],
|
||||
'amount' => $this->input->post('amount')[$i],
|
||||
'description' => $this->input->post('description')[$i],
|
||||
);
|
||||
|
||||
@ -202,7 +202,7 @@
|
||||
<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 ?>" autocomplete='off'/><i class="fa fa-calendar" style=" position: absolute; right: 25px; top: 12px;z-index: 0;"></i>
|
||||
<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>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
@ -144,7 +144,7 @@
|
||||
<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[]" value="<?php echo $value->date_of_expense ?>" autocomplete='off' /><i class="fa fa-calendar"></i>
|
||||
<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>
|
||||
</div>
|
||||
|
||||
<input type="hidden" name="expense_pid" value="<?php echo $expense_data[0]->id; ?>">
|
||||
@ -184,7 +184,7 @@
|
||||
<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='text' id='ExpenseDate' class="form-control" placeholder="DD-MM-YYYY" required name="date_of_expence[]" value="" autocomplete='off'/>
|
||||
<input type='text' id='ExpenseDate' class="form-control" placeholder="DD-MM-YYYY" required name="date_of_expence_new[]" value="" autocomplete='off'/>
|
||||
<i class="fa fa-calendar" style=" position: absolute; right: 25px; top: 12px;z-index: 0;"></i>
|
||||
</div>
|
||||
|
||||
@ -397,7 +397,7 @@ function createAndAppendFormGroup() {
|
||||
html1 += '<br><div class="x_title"></div><br>'
|
||||
html1 += '<div class="item form-group">';
|
||||
html1 += '<label class="control-label col-md-1 col-sm-1 label-align" for="first-name"> Date of Expense<a style="color:red;">*</a></label>';
|
||||
html1 += '<div class="col-md-5 col-sm-5 "><div class="form-group"><input type="text" id="datepicker'+i+'" class="form-control date-picker" placeholder="DD-MM-YYYY" name="date_of_expence[]" value="" autocomplete="off" required/><i class="fa fa-calendar" style=" position: absolute; right: 25px; top: 12px;z-index: 0;"></i></div></div>';
|
||||
html1 += '<div class="col-md-5 col-sm-5 "><div class="form-group"><input type="text" id="datepicker'+i+'" class="form-control date-picker" placeholder="DD-MM-YYYY" name="date_of_expence_new[]" value="" autocomplete="off" required/><i class="fa fa-calendar" style=" position: absolute; right: 25px; top: 12px;z-index: 0;"></i></div></div>';
|
||||
html1 += '<label class="control-label col-md-1 col-sm-1 label-align" for="first-name"> Amount <a style="color:red;">*</a></label>';
|
||||
html1 += '<div class="col-md-5 col-sm-5 "><input id="cost" name="amount[]" required class="form-control" onkeypress="return matchnum(event)" type="number" name="middle-name" autocomplete="off"></div>';
|
||||
html1 += '</div>';
|
||||
|
||||
@ -80,7 +80,7 @@
|
||||
<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>
|
||||
|
||||
@ -96,7 +96,9 @@
|
||||
<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>
|
||||
|
||||
<?php if(check_auth() && is_admin()) { ?>
|
||||
<li><a href="<?php echo base_url();?>Leave/leave_list_report">Leave Report</a></li>
|
||||
<?php } ?>
|
||||
</ul>
|
||||
</li>
|
||||
|
||||
|
||||
@ -64,6 +64,36 @@ public function leaveList()
|
||||
$this->layout->render('Employee_Layout');
|
||||
}
|
||||
|
||||
public function leave_list_report()
|
||||
{
|
||||
$business_id = user()->business_id;
|
||||
$leave_list = $this->Leave_model->get_all_leave(user()->business_id);
|
||||
$resultArray = [];
|
||||
|
||||
foreach ($leave_list as $entry) {
|
||||
$key = $entry->emp_id . '_' . $entry->type.'_'. date('m-Y', strtotime($entry->from_date_new));
|
||||
if (!isset($resultArray[$key])) {
|
||||
if($entry->from_date_new != '') $entry->from_date_new = '( '.date('d-m-Y', strtotime($entry->from_date_new)).', '.date('d-m-Y', strtotime($entry->to_date_new)).' )';
|
||||
$resultArray[$key] = $entry;
|
||||
} else {
|
||||
foreach ($entry as $field => $value) {
|
||||
if ($field == 'from_date_new' && $value != '') {
|
||||
$resultArray[$key]->$field .= '( '.date('d-m-Y', strtotime($entry->from_date_new)).', '.date('d-m-Y', strtotime($entry->to_date_new)).' )';
|
||||
}
|
||||
if ($field == 'no_of_days') {
|
||||
$resultArray[$key]->$field += $value;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$result = array_values($resultArray);
|
||||
// echo json_encode( $result, JSON_PRETTY_PRINT);die;
|
||||
$this->layout->set('leave_list', $result);
|
||||
$this->layout->buffer('main_content', 'Leave/leave_list_report');
|
||||
$this->layout->render('Employee_Layout');
|
||||
}
|
||||
|
||||
public function applyLeave($update = null)
|
||||
{
|
||||
$business_id = user()->business_id;
|
||||
@ -116,179 +146,196 @@ public function get_emp_name()
|
||||
public function createLeave()
|
||||
{
|
||||
//permission type create part
|
||||
|
||||
if(!empty($this->input->post('from_time')))
|
||||
{
|
||||
$perm_data = $this->input->post();
|
||||
if(isset($perm_data['emp_id'])){
|
||||
$emp_id =$this->input->post('emp_id');
|
||||
}else{
|
||||
$emp_id = user()->id;
|
||||
}
|
||||
$perm_data['emp_id'] = $emp_id;
|
||||
if($perm_data['manager']==""){
|
||||
if(employee()->manager == null)
|
||||
{
|
||||
$manager = 0;
|
||||
}
|
||||
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_time'] = date('H:i A');
|
||||
unset($perm_data['from_date']);
|
||||
unset($perm_data['to_date']);
|
||||
$table="leave_list";
|
||||
// print_r($perm_data);die;
|
||||
$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['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)
|
||||
{
|
||||
$manager = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
$manager = employee()->manager;
|
||||
}
|
||||
|
||||
}else{
|
||||
|
||||
$manager = $this->input->post('manager');
|
||||
}
|
||||
$data['manager'] = $manager;
|
||||
$data['business_id'] = user()->business_id;
|
||||
$data['status'] = 'pending';
|
||||
$data['created_date'] = date('d-m-Y');
|
||||
$data['created_time'] = date('H:i A');
|
||||
$leave_year = date('Y', strtotime($this->input->post('from_date')));
|
||||
|
||||
//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')) - strtotime($this->input->post('from_date'))) / 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)
|
||||
try {
|
||||
// echo base_url();die;
|
||||
// echo json_encode($this->input->post());die;
|
||||
if(!empty($this->input->post('from_time')))
|
||||
{
|
||||
$perm_data = $this->input->post();
|
||||
if(isset($perm_data['emp_id'])){
|
||||
$emp_id =$this->input->post('emp_id');
|
||||
}else{
|
||||
$emp_id = user()->id;
|
||||
}
|
||||
$perm_data['emp_id'] = $emp_id;
|
||||
if($perm_data['manager']==""){
|
||||
if(employee()->manager == null)
|
||||
{
|
||||
$manager = 0;
|
||||
}
|
||||
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_time'] = date('H:i A');
|
||||
unset($perm_data['from_date']);
|
||||
unset($perm_data['to_date']);
|
||||
unset($perm_data['from_date_new']);
|
||||
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)
|
||||
{
|
||||
$manager = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
$manager = employee()->manager;
|
||||
}
|
||||
|
||||
}else{
|
||||
|
||||
$manager = $this->input->post('manager');
|
||||
}
|
||||
$data['manager'] = $manager;
|
||||
$data['business_id'] = user()->business_id;
|
||||
$data['status'] = 'pending';
|
||||
// $data['created_date'] = date('d-m-Y');
|
||||
$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");
|
||||
|
||||
if($noofdays > $emp_leave_count[0]->remaining_days)
|
||||
{
|
||||
$this->session->set_flashdata('error', '1');
|
||||
redirect('Leave/applyLeave/'.'update');
|
||||
}
|
||||
else
|
||||
{
|
||||
//this part is update if date inculeded in emp_leave_days table
|
||||
$data['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'));
|
||||
}
|
||||
|
||||
|
||||
|
||||
// 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');
|
||||
redirect('Leave/applyLeave/'.'update');
|
||||
}
|
||||
else
|
||||
{
|
||||
//this part is update if date inculeded in emp_leave_days table
|
||||
$data['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'));
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
if($noofdays > $leave_master_count[0]->days)
|
||||
{
|
||||
$this->session->set_flashdata('error', '1');
|
||||
redirect('Leave/applyLeave/'.'update');
|
||||
}
|
||||
else
|
||||
{
|
||||
$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') ));
|
||||
$data['to_date_new'] = date("Y-m-d", strtotime( $this->input->post('to_date_new') ));
|
||||
// echo json_encode($data);die;
|
||||
$create_leave = $this->MY_Model->insert($data,$table);
|
||||
} 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)
|
||||
{
|
||||
//set id $ table name for audit history
|
||||
$this->audit->set('id',$create_leave);
|
||||
$this->audit->set('table',$table);
|
||||
//fetch new_data after post data insert
|
||||
$this->audit->fetch('new_data');
|
||||
//audit history generation for insert
|
||||
$test = $this->audit->create_history('insert');
|
||||
}
|
||||
$this->session->set_flashdata('Success', '1');
|
||||
// $this->LeaveHistory();
|
||||
redirect('Leave/LeaveHistory');
|
||||
} catch (Exception $e) {
|
||||
echo "An error occurred: " . $e->getMessage();
|
||||
}
|
||||
else
|
||||
{
|
||||
if($noofdays > $leave_master_count[0]->days)
|
||||
{
|
||||
$this->session->set_flashdata('error', '1');
|
||||
redirect('Leave/applyLeave/'.'update');
|
||||
}
|
||||
else
|
||||
{
|
||||
$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);
|
||||
// print_r($get_emp_data[0]->j_date); die;
|
||||
|
||||
$from_date = new DateTime($this->input->post('from_date'));
|
||||
$j_date = new DateTime($get_emp_data[0]->j_date);
|
||||
$to_date = new DateTime($this->input->post('to_date'));
|
||||
|
||||
|
||||
if ($from_date >= $j_date && $from_date <= $to_date) {
|
||||
$table="leave_list";
|
||||
$create_leave = $this->MY_Model->insert($data,$table);
|
||||
} else {
|
||||
$this->session->set_flashdata('error', '1');
|
||||
redirect('Leave/applyLeave/'.'update');
|
||||
|
||||
}
|
||||
|
||||
if($create_leave){
|
||||
$code = 'APPLY_LEAVE';
|
||||
$type = 'Email';
|
||||
$this->notification->sendNotification($create_leave, $code, $type);
|
||||
}
|
||||
|
||||
//audit
|
||||
if($create_leave)
|
||||
{
|
||||
//set id $ table name for audit history
|
||||
$this->audit->set('id',$create_leave);
|
||||
$this->audit->set('table',$table);
|
||||
//fetch new_data after post data insert
|
||||
$this->audit->fetch('new_data');
|
||||
//audit history generation for insert
|
||||
$test = $this->audit->create_history('insert');
|
||||
}
|
||||
$this->session->set_flashdata('Success', '1');
|
||||
redirect('Leave/LeaveHistory');
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -725,16 +772,17 @@ public function ApprovewithdrawLeave()
|
||||
// {
|
||||
// redirect('Leave/dashboard');
|
||||
// }
|
||||
public function dashboard()
|
||||
public function dashboard()
|
||||
{
|
||||
$business_id = user()->business_id;
|
||||
|
||||
|
||||
// Replace 123 with the actual 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);
|
||||
|
||||
// $data['weekData'] = $this->Leave_model->get_approved_leaves_cur_week($business_id);
|
||||
$data['weekData'] = $this->Leave_model->get_week_leave_count($business_id);
|
||||
// echo print_r($data['weekData']);die;
|
||||
$this->layout->buffer('main_content', 'Leave/dashboard',$data);
|
||||
$this->layout->render('Employee_Layout');
|
||||
}
|
||||
|
||||
@ -1,6 +1,24 @@
|
||||
<?php
|
||||
class Leave_model extends MY_Model {
|
||||
|
||||
public function get_all_leave($business_id)
|
||||
{
|
||||
$this->db->select('A.* ,U1.name as emp_name, U2.name as ApproveBy, l1.type as leavetype');
|
||||
$this->db->from('leave_list A');
|
||||
$this->db->join('users U1', 'U1.id = A.emp_id', 'left');
|
||||
$this->db->join('users U2', 'U2.id = A.approved_by', 'left');
|
||||
$this->db->join('leave_master l1', 'l1.id = A.type', 'left');
|
||||
$this->db->where('A.business_id', $business_id);
|
||||
$this->db->where('A.is_active', 1);
|
||||
$this->db->where('A.approved_by !=', '');
|
||||
$this->db->order_by('A.id','DESC');
|
||||
// $this->db->group_by('A.type,A.emp_id');
|
||||
$query = $this->db->get();
|
||||
$query = $query->result();
|
||||
return $query;
|
||||
|
||||
}
|
||||
|
||||
public function get_leave_with_emp_name($business_id)
|
||||
{
|
||||
$this->db->select('A.* ,U1.name as emp_name, U2.name as ApproveBy, U3.name as DeclineBy, U4.name as Risedby');
|
||||
@ -564,55 +582,56 @@ public function get_approved_leaves_cur_week()
|
||||
|
||||
|
||||
|
||||
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');
|
||||
$this->db->where('A.business_id', $business_id);
|
||||
$this->db->where("(A.from_date_new BETWEEN '$startOfWeek' AND '$endOfWeek' OR A.to_date_new BETWEEN '$startOfWeek' AND '$endOfWeek' OR (A.from_date_new < '$startOfWeek' AND A.to_date_new > '$endOfWeek'))");
|
||||
$this->db->join('users U1', 'U1.id = A.emp_id', 'left');
|
||||
$query = $this->db->get();
|
||||
$leaveRecords = $query->result();
|
||||
// echo json_encode($leaveRecords);die;
|
||||
// Initialize an array to store leave counts for each day of the week
|
||||
$weeklyLeaveCounts = array(
|
||||
'sunday' => [],
|
||||
'monday' => [],
|
||||
'tuesday' => [],
|
||||
'wednesday' => [],
|
||||
'thursday' => [],
|
||||
'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)
|
||||
{
|
||||
$record->from_date_new = $startOfWeek;
|
||||
}
|
||||
|
||||
if($record->to_date_new > $endOfWeek)
|
||||
{
|
||||
$record->to_date_new = $endOfWeek;
|
||||
}
|
||||
|
||||
|
||||
// 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();
|
||||
// }
|
||||
|
||||
|
||||
|
||||
|
||||
$startDate = date('l', strtotime($record->from_date_new));
|
||||
$endDate = date('l', strtotime($record->to_date_new));
|
||||
// Increment leave counts for each day within the leave period
|
||||
while ($startDate !== $endDate) {
|
||||
array_push($weeklyLeaveCounts[strtolower($startDate)], $record->employee_name);
|
||||
$startDate = date('l', strtotime($startDate . ' +1 day'));
|
||||
}
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -183,7 +183,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="" required autocomplete="off" />
|
||||
<input type='text' class="form-control" placeholder="DD-MM-YYYY" id="fromdate" name="from_date_new" value="" required autocomplete="off" />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@ -191,7 +191,7 @@
|
||||
<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="" required autocomplete="off"/>
|
||||
<input type='text' class="form-control" placeholder="DD-MM-YYYY" id="todate" name= "to_date_new" value="" required autocomplete="off"/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@ -209,7 +209,7 @@
|
||||
<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="" id='perm_id'/></div>
|
||||
<input type='text' class="form-control" required name="perm_date_new" placeholder="DD-MM-YYYY" value="" id='perm_id'/></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
@ -23,12 +23,18 @@
|
||||
/* Add a CSS class for highlighting the current date */
|
||||
table#datatables th {
|
||||
background-color: #C8E4E7;
|
||||
text-align: center;
|
||||
padding: 5px 5px;
|
||||
}
|
||||
|
||||
/* Set the background color of the current date heading */
|
||||
table#datatables th.current-date {
|
||||
background-color: #A8E7CF;
|
||||
}
|
||||
|
||||
td {
|
||||
padding: 5px;
|
||||
}
|
||||
/* table#datatables th:not(.current-date):first-child,
|
||||
table#datatables td:first-child:not(.current-date) {
|
||||
background-color: #BEEEE6;
|
||||
@ -57,7 +63,7 @@
|
||||
|
||||
<ul class="nav navbar-right panel_toolbox"></ul>
|
||||
|
||||
<h1>Employ Leave List</h1>
|
||||
<h1>Leave Dashboard</h1>
|
||||
|
||||
<div class="clearfix"></div>
|
||||
</div>
|
||||
@ -80,7 +86,7 @@
|
||||
|
||||
// Display the date and day, but skip Sunday
|
||||
if ($dayOfWeek !== 'Sunday') {
|
||||
echo '<th' . $class . '><h2>' . $dayOfWeek . '</h2><span>(' . $formattedDate . ')</span></th>';
|
||||
echo '<th' . $class . '><p style="margin:0;">' . $dayOfWeek . '</p><span>(' . $formattedDate . ')</span></th>';
|
||||
}
|
||||
|
||||
// Move to the next day
|
||||
@ -88,74 +94,24 @@
|
||||
}
|
||||
?>
|
||||
</tr>
|
||||
<tr>
|
||||
<?php
|
||||
// Reset the current date to the start date of the current week
|
||||
$currentDate = date('Y-m-d', strtotime('monday this week'));
|
||||
|
||||
<?php
|
||||
// Remove duplicate
|
||||
foreach ($weekData as &$dayData) {
|
||||
$dayData = array_unique($dayData);
|
||||
}
|
||||
// Assuming $weekData contains the array of arrays you provided
|
||||
echo '<tr>';
|
||||
echo '<td>' . implode(',<br>', $weekData['monday']) . '</td>';
|
||||
echo '<td>' . implode(',<br>', $weekData['tuesday']) . '</td>';
|
||||
echo '<td>' . implode(',<br>', $weekData['wednesday']) . '</td>';
|
||||
echo '<td>' . implode(',<br>', $weekData['thursday']) . '</td>';
|
||||
echo '<td>' . implode(',<br>', $weekData['friday']) . '</td>';
|
||||
echo '<td>' . implode(',<br>', $weekData['saturday']) . '</td>';
|
||||
echo '</tr>';
|
||||
|
||||
// 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>
|
||||
@ -163,13 +119,5 @@
|
||||
</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>
|
||||
|
||||
@ -73,20 +73,20 @@
|
||||
<?php if($type->id === $value->type ) { ?>
|
||||
<tr class="even pointer">
|
||||
<td hidden><?php echo $value->id; ?></td>
|
||||
<td class=" "><?php echo $value->created_date; ?><br><?php echo $value->created_time; ?>
|
||||
<td class=" "><?php echo dateFormat('d-m-Y',$value->created_date_new); ?><br><?php echo $value->created_time; ?>
|
||||
</td>
|
||||
<td class=" "><?php echo $value->emp_name; ?></td>
|
||||
<td class=" "><?php echo $value->comments; ?></td>
|
||||
<?php if($value->from_date == "" && $value->to_date == "") { ?>
|
||||
<?php if($value->from_date_new == "" && $value->to_date_new == "") { ?>
|
||||
<td class="">
|
||||
<?php echo dateFormat('d-m-Y',$value->perm_date);?><br>
|
||||
<?php echo dateFormat('d-m-Y',$value->perm_date_new);?><br>
|
||||
<?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>
|
||||
<td class=" "> <?php echo dateFormat('d-m-Y',$value->from_date_new); echo ' to ';?>
|
||||
<?php echo dateFormat('d-m-Y',$value->to_date_new);?> </td>
|
||||
<?php } ?>
|
||||
|
||||
<td class=" "><?php echo $type->type; ?></td>
|
||||
|
||||
127
application/modules/Leave/views/leave_list_report.php
Normal file
127
application/modules/Leave/views/leave_list_report.php
Normal file
@ -0,0 +1,127 @@
|
||||
<head>
|
||||
<link rel='stylesheet' href='https://cdn.jsdelivr.net/npm/bootstrap-icons@1.7.2/font/bootstrap-icons.css'>
|
||||
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.6.3/jquery.min.js"></script>
|
||||
<script src="https://cdn.jsdelivr.net/npm/sweetalert2@11"></script>
|
||||
<script src="https://cdn.datatables.net/1.11.5/js/jquery.dataTables.min.js"></script>
|
||||
<script src="https://cdn.datatables.net/1.11.5/js/dataTables.bootstrap4.min.js"></script>
|
||||
<link rel="stylesheet" href="https://cdn.datatables.net/1.11.5/css/dataTables.bootstrap4.min.css">
|
||||
</head>
|
||||
<div class="col-md-12 col-sm-12">
|
||||
<div class="x_panel">
|
||||
<div class="x_title">
|
||||
<h1>Leave Report</h1>
|
||||
<div class="clearfix"></div>
|
||||
</div>
|
||||
<div class="x_content">
|
||||
<div class="row">
|
||||
<div class="col-sm-12" style="overflow: auto;">
|
||||
<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">Employee Id</th>
|
||||
<th class="column-title">Employee Name </th>
|
||||
<th class="column-title">Start - End (Date)</th>
|
||||
<th class="column-title">Leave Count </th>
|
||||
<th class="column-title">Leave Type</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php foreach ($leave_list as $key => $value) { ?>
|
||||
<tr>
|
||||
<td hidden><?php echo $value->id; ?></td>
|
||||
<td><?php echo $value->emp_id; ?></td>
|
||||
<td><?php echo $value->emp_name; ?></td>
|
||||
<td>
|
||||
<?php
|
||||
if($value->leavetype == 'Permission')
|
||||
{
|
||||
echo dateFormat('d-m-Y',$value->perm_date_new).' - '.timeFormat('h:i a', $value->from_time). ' to ' .timeFormat('h:i a', $value->to_time);
|
||||
}
|
||||
else
|
||||
{
|
||||
echo $value->from_date_new;
|
||||
}
|
||||
?>
|
||||
</td>
|
||||
<td><?php echo $value->no_of_days; ?></td>
|
||||
<td><?php echo $value->leavetype; ?></td>
|
||||
</tr>
|
||||
<?php } ?>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
$(document).ready(function() {
|
||||
var table = $('#datatables').DataTable({
|
||||
"order": [
|
||||
[0, 'desc']
|
||||
],
|
||||
"dom": 'Bfrtip',
|
||||
buttons: [{
|
||||
extend: 'pdfHtml5',
|
||||
title: 'Leave',
|
||||
text: 'PDF',
|
||||
customize: function(doc) {
|
||||
doc.content[1].table.body.forEach(function(row) {
|
||||
// Remove the first and last columns
|
||||
row.splice(0, 1);
|
||||
row.pop();
|
||||
});
|
||||
}
|
||||
},
|
||||
{
|
||||
extend: 'excelHtml5',
|
||||
text: 'Excel',
|
||||
title: 'Leave',
|
||||
exportOptions: {
|
||||
columns: ':not(:last-child)'
|
||||
}
|
||||
}
|
||||
],
|
||||
"searching": true
|
||||
});
|
||||
|
||||
var currentDate = new Date();
|
||||
var currentYear = currentDate.getFullYear();
|
||||
var currentMonth = currentDate.getMonth() + 1; // Note: January is 0
|
||||
var dateList = [];
|
||||
var dateListView = [];
|
||||
|
||||
var monthNames = ["January", "February", "March", "April", "May", "June",
|
||||
"July", "August", "September", "October", "November", "December"
|
||||
];
|
||||
|
||||
// Generate the past months of the current year
|
||||
for (var month = currentMonth; month > 0; month--) {
|
||||
dateList.push(currentYear + '-' + (month < 10 ? '0' + month : month));
|
||||
dateListView.push(monthNames[month - 1] + ' ' + currentYear);
|
||||
}
|
||||
|
||||
// Append the current month
|
||||
dateList.push((currentMonth < 10 ? '0' + currentMonth : currentMonth)+ '-' +currentYear );
|
||||
dateListView.push(monthNames[currentMonth - 1] + ' ' + currentYear);
|
||||
|
||||
// Create dropdown list
|
||||
var select = $('<select class="form-control form-control-sm" style="width: 20%;"><option value="">All</option></select>')
|
||||
.appendTo($('#datatables_wrapper .dataTables_filter'))
|
||||
.on('change', function() {
|
||||
table.column(3).search($(this).val()).draw();
|
||||
});
|
||||
|
||||
// Populate dropdown list options
|
||||
$.each(dateList, function(index, value) {
|
||||
if(index != 0)
|
||||
select.append('<option value="' + value + '">' + dateListView[index] + '</option>');
|
||||
});
|
||||
// });
|
||||
|
||||
|
||||
|
||||
});
|
||||
</script>
|
||||
@ -83,17 +83,17 @@
|
||||
|
||||
<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>
|
||||
<td class=" "><?php echo dateFormat('d-m-Y',$value->created_date_new); ?><br><?php echo $value->created_time; ?></td>
|
||||
<td class=" "><?php echo $type->type; ?></td>
|
||||
<?php if($value->from_date == "" && $value->to_date == "") { ?>
|
||||
<?php if($value->from_date_new == "" && $value->to_date_new == "") { ?>
|
||||
<td class="">
|
||||
<?php echo dateFormat('d-m-Y',$value->perm_date);?><br>
|
||||
<?php echo dateFormat('d-m-Y',$value->perm_date_new);?><br>
|
||||
<?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>
|
||||
<td class=" "> <?php echo dateFormat('d-m-Y',$value->from_date_new); echo ' to ';?> <?php echo dateFormat('d-m-Y',$value->to_date_new);?> </td>
|
||||
<?php } ?>
|
||||
<?php if($value->no_of_days == 0){ ?>
|
||||
<td class=" ">---</td>
|
||||
|
||||
@ -35,75 +35,81 @@ public function __construct()
|
||||
### The second parameter (optional) is used to call the method.
|
||||
$this->load->model('MY_Model','MY_Model');
|
||||
$this->load->model('Notification_model','Notification_model');
|
||||
$this->load->helper('mail_helper');
|
||||
}
|
||||
|
||||
|
||||
// Function for Mail Send
|
||||
public function prepareNotificationData($body,$templateData,$Data,$type,$code){
|
||||
|
||||
$getBusinessData = $this->Notification_model->get_admin_and_hr_mail_id(user()->business_id);
|
||||
$managerID = $Data->ManagerId;
|
||||
$managerMail = $this->Notification_model->get_user_data($managerID);
|
||||
try
|
||||
{
|
||||
// echo 1;die;
|
||||
$getBusinessData = $this->Notification_model->get_admin_and_hr_mail_id(user()->business_id);
|
||||
$managerID = $Data->ManagerId;
|
||||
$managerMail = $this->Notification_model->get_user_data($managerID);
|
||||
|
||||
|
||||
$cc_mail_data = [$getBusinessData->admin_email, $getBusinessData->hr_email, $Data->managerEmail, $Data->delegatePersonEmail];
|
||||
if($Data->delegatePersonEmail == NULL)
|
||||
{
|
||||
if($Data->managerEmail == NULL){
|
||||
|
||||
$cc_mail_data = [$getBusinessData->admin_email, $getBusinessData->hr_email];
|
||||
}
|
||||
else{
|
||||
$cc_mail_data = [$getBusinessData->admin_email, $getBusinessData->hr_email, $Data->managerEmail];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$cc_mail_data = [$getBusinessData->admin_email, $getBusinessData->hr_email, $Data->managerEmail, $Data->delegatePersonEmail];
|
||||
if($Data->delegatePersonEmail == NULL)
|
||||
{
|
||||
if($Data->managerEmail == NULL){
|
||||
if($type === 'Email'){
|
||||
|
||||
if($code === 'APPLY_LEAVE' || $code === 'LEAVE_PERMISSION'){
|
||||
|
||||
$to = $getBusinessData->hr_email;
|
||||
$cc = $cc_mail_data;
|
||||
$subject = $templateData->subject;
|
||||
$aliasName = $Data->emp_name;
|
||||
$result = send_emails($to, $subject, $body, $aliasName, $cc);
|
||||
// echo $result; die;
|
||||
return $result;
|
||||
}
|
||||
else if($code === 'APPROVE_LEAVE' || $code === 'APPROVE_PERMISSION'){
|
||||
|
||||
$to = $Data->emp_email;
|
||||
$cc = $cc_mail_data;
|
||||
$subject = $templateData->subject;
|
||||
$aliasName = 'HR';
|
||||
$result = send_emails($to, $subject, $body, $aliasName, $cc);
|
||||
// echo $result; die;
|
||||
return $result;
|
||||
}
|
||||
else if($code === 'DECLINE_LEAVE' || $code === 'DECLINE_PERMISSION'){
|
||||
|
||||
$to = $Data->emp_email;
|
||||
$cc = $cc_mail_data;
|
||||
$subject = $templateData->subject;
|
||||
$aliasName = 'HR';
|
||||
$result = send_emails($to, $subject, $body, $aliasName, $cc);
|
||||
// echo $result; die;
|
||||
return $result;
|
||||
}
|
||||
else{
|
||||
|
||||
$to = $Data->emp_email;
|
||||
$cc = $cc_mail_data;
|
||||
$subject = $templateData->subject;
|
||||
$aliasName = 'HR';
|
||||
$result = send_emails($to, $subject, $body, $aliasName, $cc);
|
||||
// echo $result; die;
|
||||
return $result;
|
||||
}
|
||||
|
||||
$cc_mail_data = [$getBusinessData->admin_email, $getBusinessData->hr_email];
|
||||
}
|
||||
else{
|
||||
$cc_mail_data = [$getBusinessData->admin_email, $getBusinessData->hr_email, $Data->managerEmail];
|
||||
}
|
||||
} catch (Exception $e) {
|
||||
echo "An error occurred: " . $e->getMessage();
|
||||
}
|
||||
|
||||
|
||||
if($type === 'Email'){
|
||||
|
||||
if($code === 'APPLY_LEAVE' || $code === 'LEAVE_PERMISSION'){
|
||||
|
||||
$to = $getBusinessData->hr_email;
|
||||
$cc = $cc_mail_data;
|
||||
$subject = $templateData->subject;
|
||||
$aliasName = $Data->emp_name;
|
||||
$result = send_emails($to, $subject, $body, $aliasName, $cc);
|
||||
// echo $result; die;
|
||||
return $result;
|
||||
}
|
||||
else if($code === 'APPROVE_LEAVE' || $code === 'APPROVE_PERMISSION'){
|
||||
|
||||
$to = $Data->emp_email;
|
||||
$cc = $cc_mail_data;
|
||||
$subject = $templateData->subject;
|
||||
$aliasName = 'HR';
|
||||
$result = send_emails($to, $subject, $body, $aliasName, $cc);
|
||||
// echo $result; die;
|
||||
return $result;
|
||||
}
|
||||
else if($code === 'DECLINE_LEAVE' || $code === 'DECLINE_PERMISSION'){
|
||||
|
||||
$to = $Data->emp_email;
|
||||
$cc = $cc_mail_data;
|
||||
$subject = $templateData->subject;
|
||||
$aliasName = 'HR';
|
||||
$result = send_emails($to, $subject, $body, $aliasName, $cc);
|
||||
// echo $result; die;
|
||||
return $result;
|
||||
}
|
||||
else{
|
||||
|
||||
$to = $Data->emp_email;
|
||||
$cc = $cc_mail_data;
|
||||
$subject = $templateData->subject;
|
||||
$aliasName = 'HR';
|
||||
$result = send_emails($to, $subject, $body, $aliasName, $cc);
|
||||
// echo $result; die;
|
||||
return $result;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public function prepareNotificationDataForDelegation($body,$templateData,$Data,$type,$code){
|
||||
@ -184,21 +190,23 @@ public function prepareNotificationDataForExpence($body,$templateData,$Data,$typ
|
||||
|
||||
//Send Mail For Apply Leave and apply Permission also Approve and Decline
|
||||
public function sendNotification($leave_id, $code, $type){
|
||||
try {
|
||||
$leaveData = collectLeaveData($leave_id);
|
||||
$templateData = getTempleteData($code, $type);
|
||||
if($code === 'APPLY_LEAVE' || $code === 'LEAVE_PERMISSION'){
|
||||
|
||||
$leaveData = collectLeaveData($leave_id);
|
||||
$templateData = getTempleteData($code, $type);
|
||||
if($code === 'APPLY_LEAVE' || $code === 'LEAVE_PERMISSION'){
|
||||
|
||||
$FormettedTemplateData = $this->preprocessTemplateData($leaveData,$templateData);
|
||||
$FormettedTemplateData = $this->preprocessTemplateData($leaveData,$templateData);
|
||||
}
|
||||
else if($code === 'APPROVE_LEAVE' || $code === 'APPROVE_PERMISSION'){
|
||||
$FormettedTemplateData = $this->preprocessTemplateDataForLeaveApprove($leaveData,$templateData);
|
||||
}
|
||||
else if($code === 'DECLINE_LEAVE' || $code === 'DECLINE_PERMISSION'){
|
||||
$FormettedTemplateData = $this->preprocessTemplateDataForLeaveDecline($leaveData,$templateData);
|
||||
}
|
||||
return $this->prepareNotificationData($FormettedTemplateData,$templateData,$leaveData,$type, $code);
|
||||
} catch (Exception $e) {
|
||||
echo "An error occurred: " . $e->getMessage();
|
||||
}
|
||||
else if($code === 'APPROVE_LEAVE' || $code === 'APPROVE_PERMISSION'){
|
||||
$FormettedTemplateData = $this->preprocessTemplateDataForLeaveApprove($leaveData,$templateData);
|
||||
}
|
||||
else if($code === 'DECLINE_LEAVE' || $code === 'DECLINE_PERMISSION'){
|
||||
$FormettedTemplateData = $this->preprocessTemplateDataForLeaveDecline($leaveData,$templateData);
|
||||
}
|
||||
return $this->prepareNotificationData($FormettedTemplateData,$templateData,$leaveData,$type, $code);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -425,4 +433,4 @@ public function preprocessTemplateDataForExpenseDecline($Data, $templateData, $e
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@ -98,8 +98,8 @@
|
||||
break;
|
||||
|
||||
case 'testing':
|
||||
ini_set('display_errors', 1);
|
||||
//error_reporting(-1);
|
||||
// ini_set('display_errors', 1);
|
||||
// error_reporting(-1);
|
||||
// if (version_compare(PHP_VERSION, '5.3', '>=')) {
|
||||
// error_reporting(E_ALL & ~E_NOTICE & ~E_DEPRECATED & ~E_STRICT & ~E_USER_NOTICE & ~E_USER_DEPRECATED);
|
||||
// } else {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user