query($mysqli_query); if(mysqli_num_rows($mysqli_data) > 0){ while($result = mysqli_fetch_assoc($mysqli_data)){ $output .= ' '.$result['staff_idno'].' '.$result['staff_name'].' '; } }else{ $output .= ' No staffs found. '; } if($output != ''){ $return['status'] = 'success'; }else{ $return['status'] = 'failed'; } $return['html'] = $output; echo json_encode($return); exit; } if($_POST['send_email'] == 1){ $staff_list = $_POST['staff_list']; if(count($staff_list)>0 && $staff_list!=''){ include 'extensions/mailer.php'; include 'MPDF/mpdf.php' ; function monthFormat($date){ $month = date("M Y", strtotime($date)); return $month; } foreach($staff_list as $slip_id){ $html = ''; $query_slip = $mysqli->query("SELECT a.*, b.staff_email, b.staff_idno, b.staff_name, b.staff_image, b.branch_id, b.staff_icno, b.job_position_id, b.staff_date_joined FROM salary_slip a JOIN staff b ON (a.staff_id = b.staff_id) WHERE a.slip_id = '$slip_id' LIMIT 1") ; $result_slip = mysqli_fetch_assoc($query_slip); $branch_id = $result_slip['branch_id']; $query_branch = $mysqli->query("SELECT * FROM branch WHERE branch_id = '$branch_id' LIMIT 1"); while($result_branch = mysqli_fetch_assoc($query_branch)){ $letter_head = html_entity_decode(htmlspecialchars_decode($result_branch['branch_content'])); } $staff_id = $result_slip['staff_id']; $query_department = $mysqli->query("SELECT * FROM staff_department a JOIN setting_department b ON (a.department_id = b.department_id) WHERE a.staff_id = '$staff_id' LIMIT 1"); $result_department = mysqli_fetch_assoc($query_department); $job_position_id = $result_slip['job_position_id']; $query_position = $mysqli->query("SELECT * FROM setting_job_position WHERE job_position_id = '$job_position_id' LIMIT 1"); $result_position = mysqli_fetch_assoc($query_position); $total_earning = $result_slip['basic_salary'] + $result_slip['allowance'] + $result_slip['commission']; $total_deduction = $result_slip['staff_epf'] + $result_slip['staff_socso'] + $result_slip['staff_eis'] + $result_slip['staff_pcb'] + $result_slip['staff_zakat'] + $result_slip['deduction'] ; $commission_show = $socso_show = $eis_show = $zakat_show = $pcb_show = $deduction_show = $em_socso_show = $em_eis_show = 0; $html .= '
'.$letter_head.'
Payslip For '.strtoupper(monthFormat($result_slip['month'])).'
NAME : '.$result_slip['staff_name'].' NEW IC NO : '.$result_slip['staff_icno'].'
DESIGNATION : '.$result_position['job_position_desc'].' DATE JOINED : '.$result_slip['staff_date_joined'].'
DEPARTMENT : '.$result_department['department_desc'].'
'; if($result_slip['staff_epf'] > 0){ $html .= ' '; }else{ if($result_slip['staff_socso'] > 0){ $html .= ' '; $socso_show = 1; }else{ if($result_slip['staff_eis'] > 0){ $html .= ' '; $eis_show = 1; }else{ if($result_slip['staff_pcb'] > 0){ $html .= ' '; $pcb_show = 1; }else{ if($result_slip['staff_zakat'] > 0){ $html .= ' '; $zakat_show = 1; }else{ if($result_slip['deduction'] > 0){ $html .= ' '; $deduction_show = 1; }else{ $html .= ' '; } } } } } } $html .=' '; $html .=' '; }else{ if($result_slip['commission'] > 0){ $html .= ' COMMISSION '; $commission_show = 1; }else{ $html .= '   '; } } if($result_slip['staff_socso'] > 0 && $socso_show == 0){ $html .= ' '; $socso_show = 1; }else{ if($result_slip['staff_eis'] > 0 && $eis_show == 0){ $html .= ' '; $eis_show = 1; }else{ if($result_slip['staff_pcb'] > 0 && $pcb_show == 0){ $html .= ' '; $pcb_show = 1; }else{ if($result_slip['staff_zakat'] > 0 && $zakat_show == 0){ $html .= ' '; $zakat_show = 1; }else{ if($result_slip['deduction'] > 0 && $deduction_show == 0){ $html .= ' '; $deduction_show = 1; }else{ $html .= ' '; } } } } } $html .=' '; if($result_slip['commission'] > 0 && $commission_show == 0){ $html.=' '; }else{ $html .= ' '; } if($result_slip['staff_eis'] > 0 && $eis_show == 0){ $html .= ' '; $eis_show = 1; }else{ if($result_slip['staff_pcb'] > 0 && $pcb_show == 0){ $html .= ' '; $pcb_show = 1; }else{ if($result_slip['staff_zakat'] > 0 && $zakat_show == 0){ $html .= ' '; $zakat_show = 1; }else{ if($result_slip['deduction'] > 0 && $deduction_show == 0){ $html .= ' '; $deduction_show = 1; }else{ $html .= ' '; } } } } $html.=' '; if($result_slip['staff_pcb'] > 0 && $pcb_show == 0){ $html .= ' '; $pcb_show = 1; }else{ if($result_slip['staff_zakat'] > 0 && $zakat_show == 0){ $html .= ' '; $zakat_show = 1; }else{ if($result_slip['deduction'] > 0 && $deduction_show == 0){ $html .= ' '; $deduction_show = 1; }else{ $html .= ' '; } } } $html .=' '; if($result_slip['staff_zakat'] > 0 && $zakat_show == 0){ $html .= ' '; $zakat_show = 1; }else{ if($result_slip['deduction'] > 0 && $deduction_show == 0){ $html .= ' '; $deduction_show = 1; }else{ $html .= ' '; } } $html .=' '; if($result_slip['deduction'] > 0 && $deduction_show == 0){ $html .= ' '; $deduction_show = 1; }else{ $html .= ' '; } $html .=' '; if($result_slip['employer_epf'] > 0){ $html .= ' '; }else{ if($result_slip['employer_socso'] > 0){ $html .= ' '; $em_socso_show = 1; }else{ if($result_slip['employer_eis'] > 0){ $html .= ' '; $em_eis_show = 1; }else{ $html .= ' '; } } } $html .=' '; if($result_slip['employer_socso'] > 0 && $em_socso_show == 0){ $html .= ' '; $em_socso_show = 1; }else{ if($result_slip['employer_eis'] > 0 && $em_eis_show == 0){ $html .= ' '; $em_eis_show = 1; }else{ $html .= ' '; } } $html .=' '; if($result_slip['employer_eis'] > 0 && $em_eis_show == 0){ $html .= ' '; $em_eis_show = 1; }else{ $html .= ' '; } $html .='
GROSS EARNING Amount(RM) DEDUCTIONS Amount(RM)
WAGES '.number_format((float)$result_slip['basic_salary'], 2, '.', '').' EPF (EMPLOYEE) '.number_format((float)$result_slip['staff_epf'], 2, '.', '').' SOCSO (EMPLOYEE) '.number_format((float)$result_slip['staff_socso'], 2, '.', '').' EIS (EMPLOYEE) '.number_format((float)$result_slip['staff_eis'], 2, '.', '').' PCB '.number_format((float)$result_slip['staff_pcb'], 2, '.', '').' MUSLIM ZAKAT FUND '.number_format((float)$result_slip['staff_zakat'], 2, '.', '').' DEDUCTION '.number_format((float)$result_slip['staff_deduction'], 2, '.', '').'
'; if($result_slip['allowance'] > 0){ $html .= ' ALLOWANCE '.number_format((float)$result_slip['allowance'], 2, '.', '').' '.number_format((float)$result_slip['commission'], 2, '.', '').' SOCSO (EMPLOYEE) '.number_format((float)$result_slip['staff_socso'], 2, '.', '').' EIS (EMPLOYEE) '.number_format((float)$result_slip['staff_eis'], 2, '.', '').' PCB '.number_format((float)$result_slip['staff_pcb'], 2, '.', '').' MUSLIM ZAKAT FUND '.number_format((float)$result_slip['staff_zakat'], 2, '.', '').' DEDUCTION '.number_format((float)$result_slip['staff_deduction'], 2, '.', '').'
COMMISSION '.number_format((float)$result_slip['commission'], 2, '.', '').' COMMISSION EIS (EMPLOYEE) '.number_format((float)$result_slip['staff_eis'], 2, '.', '').' PCB '.number_format((float)$result_slip['staff_pcb'], 2, '.', '').' MUSLIM ZAKAT FUND '.number_format((float)$result_slip['staff_zakat'], 2, '.', '').' DEDUCTION '.number_format((float)$result_slip['deduction'], 2, '.', '').'
 PCB '.number_format((float)$result_slip['staff_pcb'], 2, '.', '').' MUSLIM ZAKAT FUND '.number_format((float)$result_slip['staff_zakat'], 2, '.', '').' DEDUCTION '.number_format((float)$result_slip['staff_deduction'], 2, '.', '').'
 MUSLIM ZAKAT FUND '.number_format((float)$result_slip['staff_zakat'], 2, '.', '').' DEDUCTION '.number_format((float)$result_slip['staff_deduction'], 2, '.', '').'
 DEDUCTION '.number_format((float)$result_slip['staff_deduction'], 2, '.', '').'
   
TOTAL EARNING /
INCOME
'.number_format((float)$total_earning, 2, '.', '').' TOTAL DEDUCTIONS '.number_format((float)$total_deduction, 2, '.', '').'
  EMPLOYER CONTRIBUTIONS
NET PAY '.number_format( (float)$result_slip['total'], 2, '.', '').' EPF '.number_format((float)$result_slip['employer_epf'], 2, '.', '').' SOCSO '.number_format((float)$result_slip['employer_socso'], 2, '.', '').' EIS '.number_format((float)$result_slip['employer_eis'], 2, '.', '').'
 SOCSO '.number_format((float)$result_slip['employer_socso'], 2, '.', '').' EIS '.number_format((float)$result_slip['employer_eis'], 2, '.', '').'
 EIS '.number_format((float)$result_slip['employer_eis'], 2, '.', '').'
' ; $html .= '
If you need further clarification, please contact Accounts Department.
This is computer generated document. No signature is required.
' ; // page header $header = '' ; $mpdf = new mPDF('utf-8', 'A5', '', 'freesans', 10, 10, 7, 5, 5, 5) ; ini_set("memory_limit", "99999M"); // Use different Odd/Even headers and footers and mirror margins $mpdf->mirrorMargins = 1 ; // set mpdf header $mpdf->SetHTMLHeader($header) ; $mpdf->SetHTMLHeader($header, 'E') ; // set mpdf footer $mpdf->SetHTMLFooter($footer) ; $mpdf->SetHTMLFooter($footer, 'E') ; //css $stylesheet = file_get_contents('css/salary_pdf.css'); // external css $mpdf->WriteHTML($stylesheet, 1); // write in html $mpdf->WriteHTML($html) ; // set filename $filename = 'Salary_Slip_'.date('Y-m', strtotime($result_slip['month'])).'.pdf' ; // turns all headers/footers off from new page onwards $mpdf->useAdobeCJK = true; if(file_exists($_SERVER['DOCUMENT_ROOT'].'/Salary_Slip/'.$filename)){ unlink($_SERVER['DOCUMENT_ROOT'].'/Salary_Slip/'.$filename); } $mpdf->Output( $_SERVER['DOCUMENT_ROOT'].'/Salary_Slip/'.$filename, 'F' ) ; $to = $result_slip['staff_email']; $title = COMPANY ; $body = '

Hello, kindly receive your monthly salary slip for '.date('Y-m', strtotime($result_slip['month'])).'

'; $mailer = new Mailer() ; $mailer->from = EMAILNOREPLY ; $mailer->to = [ $to ] ; $mailer->subject = $title ; $mailer->body = $body ; $mailer->sendAttachment($_SERVER['DOCUMENT_ROOT'].'/Salary_Slip/'.$filename, $filename); $send = $mailer->send() ; unlink($_SERVER['DOCUMENT_ROOT'].'/Salary_Slip/'.$filename); } $result['status'] = 'success'; }else{ $result['status'] = 'failed'; } echo json_encode($result); exit; } // get all branch $branch = [] ; $get_branch = $mysqli->query("SELECT * FROM branch WHERE deleted_at IS NULL".$user_branch_permission_sql) ; if ( $get_branch->num_rows > 0 ){ while ( $row_branch = $get_branch->fetch_assoc() ){ $branch[$row_branch['branch_id']] = $row_branch['branch_name'] ; } } // get month that has the salary slip $query_slip = $mysqli->query("SELECT a.month FROM salary_slip a LEFT JOIN staff b ON ( a.staff_id = b.staff_id ) WHERE a.deleted_at IS NULL ".$user_branch_permission_sql_b." GROUP BY a.month ORDER BY a.month DESC") ; $slip_month = [] ; if(mysqli_num_rows($query_slip) > 0){ while($row = mysqli_fetch_assoc($query_slip)){ $slip_month[] = $row['month']; } } include 'HR/salary-data.php' ; $boolean_role = true ; $boolean_edit = true ; // active page $active_main_menu = 'salary' ; $active_sub_menu = 'salary-list' ; // reset sort by type $sort_by_type = ( $sort_by_type == 'DESC' ? 'ASC' : 'DESC' ) ; ?>
= date('Y-m', strtotime(TODAYDAY)) ){}else{ ?>
0 ){ $c = 0; foreach ( $salary_slip as $slip_id => $slip ){ $c++; echo ' ' ; } }else{ echo ' '; } ?>
Remark
'.$slip['staff_idno'].'
'.ucwords($slip['staff_name']).'
'.number_format((float)$slip['basic_salary'], 2, '.', '').'
'.number_format((float)$slip['commission'], 2, '.', '').'
'.number_format((float)$slip['allowance'], 2, '.', '').'
'.number_format((float)$slip['deduction'], 2, '.', '').'
'.$slip['remark'].'
'.number_format((float)$slip['sub_total'], 2, '.', '').' '.number_format((float)$slip['staff_epf'], 2, '.', '').' '.number_format((float)$slip['staff_socso'], 2, '.', '').' '.number_format((float)$slip['staff_eis'], 2, '.', '').' '.number_format((float)$slip['staff_zakat'], 2, '.', '').' '.number_format((float)$slip['staff_pcb'], 2, '.', '').' '.number_format((float)$slip['total'], 2, '.', '').' '.number_format((float)$slip['employer_epf'], 2, '.', '').' '.number_format((float)$slip['employer_socso'], 2, '.', '').' '.number_format((float)$slip['employer_eis'], 2, '.', '').'
No data available