diff --git a/application/config/testing/database.php b/application/config/testing/database.php index 365385b..5b03786 100644 --- a/application/config/testing/database.php +++ b/application/config/testing/database.php @@ -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', diff --git a/application/helpers/mail_helper.php b/application/helpers/mail_helper.php index 9cf17b4..a05ee07 100644 --- a/application/helpers/mail_helper.php +++ b/application/helpers/mail_helper.php @@ -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); diff --git a/application/modules/Expence/controllers/Expence.php b/application/modules/Expence/controllers/Expence.php index 243b6c9..964ebb2 100644 --- a/application/modules/Expence/controllers/Expence.php +++ b/application/modules/Expence/controllers/Expence.php @@ -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], ); diff --git a/application/modules/Expence/views/edit_expence.php b/application/modules/Expence/views/edit_expence.php index 7393033..e259a81 100644 --- a/application/modules/Expence/views/edit_expence.php +++ b/application/modules/Expence/views/edit_expence.php @@ -202,7 +202,7 @@
- +
diff --git a/application/modules/Expence/views/expence_form.php b/application/modules/Expence/views/expence_form.php index 17a4bf4..ffea43c 100644 --- a/application/modules/Expence/views/expence_form.php +++ b/application/modules/Expence/views/expence_form.php @@ -144,7 +144,7 @@
- +
@@ -184,7 +184,7 @@
- +
@@ -397,7 +397,7 @@ function createAndAppendFormGroup() { html1 += '

' html1 += '
'; html1 += ''; - html1 += '
'; + html1 += '
'; html1 += ''; html1 += '
'; html1 += '
'; diff --git a/application/modules/Layout/views/includes/employee_menu.php b/application/modules/Layout/views/includes/employee_menu.php index b38f90c..6fc2399 100644 --- a/application/modules/Layout/views/includes/employee_menu.php +++ b/application/modules/Layout/views/includes/employee_menu.php @@ -80,7 +80,7 @@
  • Apply Leave
  • My Approvals
  • - + @@ -96,7 +96,9 @@
  • Apply Leave
  • My Approvals
  • - + +
  • Leave Report
  • + diff --git a/application/modules/Leave/controllers/Leave.php b/application/modules/Leave/controllers/Leave.php index 9b9cf22..594e48b 100644 --- a/application/modules/Leave/controllers/Leave.php +++ b/application/modules/Leave/controllers/Leave.php @@ -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'); } diff --git a/application/modules/Leave/models/Leave_model.php b/application/modules/Leave/models/Leave_model.php index 5bc9810..3ce8051 100644 --- a/application/modules/Leave/models/Leave_model.php +++ b/application/modules/Leave/models/Leave_model.php @@ -1,6 +1,24 @@ 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; + } + } diff --git a/application/modules/Leave/views/apply_leave.php b/application/modules/Leave/views/apply_leave.php index 1b5d030..16dc329 100644 --- a/application/modules/Leave/views/apply_leave.php +++ b/application/modules/Leave/views/apply_leave.php @@ -183,7 +183,7 @@
    - +
    @@ -191,7 +191,7 @@
    - +
    @@ -209,7 +209,7 @@
    -
    +
    diff --git a/application/modules/Leave/views/dashboard.php b/application/modules/Leave/views/dashboard.php index 8c76249..d1f9364 100644 --- a/application/modules/Leave/views/dashboard.php +++ b/application/modules/Leave/views/dashboard.php @@ -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 @@ -

    Employ Leave List

    +

    Leave Dashboard

    @@ -80,7 +86,7 @@ // Display the date and day, but skip Sunday if ($dayOfWeek !== 'Sunday') { - echo '

    ' . $dayOfWeek . '

    (' . $formattedDate . ')'; + echo '

    ' . $dayOfWeek . '

    (' . $formattedDate . ')'; } // Move to the next day @@ -88,74 +94,24 @@ } ?> - - '; + echo '' . implode(',
    ', $weekData['monday']) . ''; + echo '' . implode(',
    ', $weekData['tuesday']) . ''; + echo '' . implode(',
    ', $weekData['wednesday']) . ''; + echo '' . implode(',
    ', $weekData['thursday']) . ''; + echo '' . implode(',
    ', $weekData['friday']) . ''; + echo '' . implode(',
    ', $weekData['saturday']) . ''; + echo ''; - // 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 ''; - - // 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'] . '
    ' . $leaveRecord['from_time'] . $leaveRecord['to_time'] . '
    '; - } - } - } else { - // No leave records for the day - - } - - echo ''; - } - - // Move to the next day - $currentDate = date('Y-m-d', strtotime($currentDate . ' +1 day')); - } - ?> - - - - '; - - // 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'] . '
    ' . $leaveRecord['from_time'] . $leaveRecord['to_time'] . '
    '; - } - } - } else { - // No leave records for the day - // echo 'No Leave'; - } - - echo ''; - } - - // Move to the next day - $currentDate = date('Y-m-d', strtotime($currentDate . ' +1 day')); - } - ?> - + ?> + @@ -163,13 +119,5 @@ -
    - - - - - - - diff --git a/application/modules/Leave/views/leave_list.php b/application/modules/Leave/views/leave_list.php index 33380c0..950941d 100644 --- a/application/modules/Leave/views/leave_list.php +++ b/application/modules/Leave/views/leave_list.php @@ -73,20 +73,20 @@ id === $value->type ) { ?> id; ?> - created_date; ?>
    created_time; ?> + created_date_new); ?>
    created_time; ?> emp_name; ?> comments; ?> - from_date == "" && $value->to_date == "") { ?> + from_date_new == "" && $value->to_date_new == "") { ?> - perm_date);?>
    + perm_date_new);?>
    from_time); ?> to to_time);?> - from_date); echo ' to ';?> - to_date);?> + from_date_new); echo ' to ';?> + to_date_new);?> type; ?> diff --git a/application/modules/Leave/views/leave_list_report.php b/application/modules/Leave/views/leave_list_report.php new file mode 100644 index 0000000..7acc5f7 --- /dev/null +++ b/application/modules/Leave/views/leave_list_report.php @@ -0,0 +1,127 @@ + + + + + + + + +
    +
    +
    +

    Leave Report

    +
    +
    +
    +
    +
    + + + + + + + + + + + + + $value) { ?> + + + + + + + + + + +
    Employee IdEmployee Name Start - End (Date)Leave Count Leave Type
    emp_id; ?>emp_name; ?> + 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; + } + ?> + no_of_days; ?>leavetype; ?>
    +
    +
    +
    +
    +
    + + diff --git a/application/modules/Leave/views/leavehistory.php b/application/modules/Leave/views/leavehistory.php index e7b1d75..48f6813 100644 --- a/application/modules/Leave/views/leavehistory.php +++ b/application/modules/Leave/views/leavehistory.php @@ -83,17 +83,17 @@ id; ?> - created_date; ?>
    created_time; ?> + created_date_new); ?>
    created_time; ?> type; ?> - from_date == "" && $value->to_date == "") { ?> + from_date_new == "" && $value->to_date_new == "") { ?> - perm_date);?>
    + perm_date_new);?>
    from_time); ?> to to_time);; ?> - from_date); echo ' to ';?> to_date);?> + from_date_new); echo ' to ';?> to_date_new);?> no_of_days == 0){ ?> --- diff --git a/application/modules/Notification/controllers/Notification.php b/application/modules/Notification/controllers/Notification.php index d2c6a77..ed6607d 100644 --- a/application/modules/Notification/controllers/Notification.php +++ b/application/modules/Notification/controllers/Notification.php @@ -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 -} \ No newline at end of file +} diff --git a/index.php b/index.php index dbf74da..8962b7c 100644 --- a/index.php +++ b/index.php @@ -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 {