<?php
/**********************************************************************
***********************************************************************/

$page_security = 'SA_CREATE_GATE_PASS';
// ----------------------------------------------------------------
// $ Revision:	2.0 $
// Creator:	Joe Hunt
// date_:	2005-05-19
// Title:	Purchase Remittance/SA_REP_PAY_VOUCHER
// ----------------------------------------------------------------
$path_to_root = "..";

include_once($path_to_root . "/includes/session.inc");
include_once($path_to_root . "/reporting/includes/ui/rep658_page_1_ui.inc"); 
include_once($path_to_root . "/reporting/includes/ui/rep658_page_2_ui.inc"); 
include_once($path_to_root . "/services/includes/db/job_orders_db.inc"); 
include_once($path_to_root . "/services/includes/db/job_order_repairs_db.inc"); 
include_once($path_to_root . "/inventory/includes/db/job_material_issues_db.inc"); 
include_once($path_to_root . "/payroll/includes/db/employees_db.inc"); 
include_once($path_to_root . "/assets/includes/db/assets_db.inc");  
include_once($path_to_root . "/includes/db/inventory_db.inc");  
include_once($path_to_root . "/purchasing/includes/db/direct_purchase_requisitions_db.inc");  

print_job_order_details();

function rep_get_job_order_labour_details($jo_id) {
    $sql = "SELECT la.*, emp.employee_reference 
            FROM ".TB_PREF."job_order_labours la  
                JOIN ".TB_PREF."employee_master emp   
                    ON la.employee_code = emp.employee_code   
            WHERE la.jo_id = ".db_escape($jo_id)."
            ORDER BY la.from_date";
        
	return db_query($sql, "rep_get_job_order_labour_details");
}

function print_job_order_details() {
    global $path_to_root, $systypes_array;

    include_once($path_to_root . "/reporting/includes/pdf_report.inc");
    
    $jo_id = trim($_POST['PARAM_0']);
    
    $job_row = get_job_order_record($jo_id);
        if (! is_array($job_row)) {
            display_error("Could not find ".$systypes_array[ST_JOB_ORDER]." #$jo_id.");
            return;
        }
    
        $x = 0;
        $cols = array($x, $x+=50, $x+=50, $x+=50, $x+=50, $x+=50, $x+=50, $x+=50, $x+=50, $x+=50, $x+=50, $x+=50, $x+=50, $x+=50, $x+=50, $x+=50, $x+=50);
        $headers = array('', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '');
        $aligns = array('left', 'left', 'left', 'left', 'left', 'left', 'left', 'left', 'left', 'left', 'left', 'left', 'left', 'left', 'left', 'left');

        $rep = new FrontReport(_('JOB CARD DETAILS PRINT'), "JobCardDetailsPrint", 'A4', 9, 'L');
    
            $jo_row = get_job_order_details($jo_id);
        
            $params = array(0 => $jo_id);
            $params['gate_pass_no'] = $jo_row['id'];

                $rep->SetHeaderType('form_658');
                $rep->Font();
                $rep->Info($params, $cols, $headers, $aligns);

                $rep->NewPage();
                
                $new_page = job_card_page_1($rep, $jo_id, $jo_row);
                
                job_card_page_2($rep, $jo_id, $new_page);
                    
            $rep->NewLine();

    $rep->End();
}

?>