<?php

function dispaly_employee_attendance_summary_controller() {
    div_start('emp_att_control');
        start_table(TABLESTYLE_NOBORDER);
            start_row();
                date_cells(_("From:"), 'from_date', '', null, -30);
                date_cells(_("To:"), 'to_date');

                submit_cells('SearchEmpAtt', _("Search"),'',_('Search'), 'default');
            end_row();
        end_table(1);
    div_end();
}

function dispaly_employee_attendance_summary_inquiry($from_date, $to_date) {   
    global $Ajax, $payroll_approval_statuses;
    
    $Ajax->activate('emp_att_details');
    div_start('emp_att_details');
        start_table(TABLESTYLE, "width=50%");

            $th = array(_("Date"), _("Total Employees"), _("Presents"), _("Absents"), _("Approval Status"));

            table_header($th);

                $k = 0;
                $result = get_employee_attendances_header(0, date2sql($from_date), date2sql($to_date));
                    while ($row = db_fetch($result)) {
                        alt_table_row_color($k); 
                            label_cell(get_payroll_trans_view_str(ST_EMPLOYEE_ATTENDANCE, $row['date'], sql2date($row['date'])), 'align=center');
                            label_cell($row['total_employees'], 'align=center');
                            
                            label_cell(get_payroll_trans_view_str(ST_EMPLOYEE_ATTENDANCE, $row['date'], $row['presents']), 'align=center');                            
//                            label_cell($row['presents'], 'align=center');
                            $absents = $row['total_employees'] - $row['presents'];
                            label_cell($absents, 'align=center');
                            label_cell($payroll_approval_statuses[$row['attendance_status_code']], 'align=center');
                        end_row();
                    }
                    
        end_table();
    div_end();
}