<?php
/**********************************************************************
***********************************************************************/
$page_security = 'SA_JOB_CARD_VIEW';
$path_to_root = "../..";

include($path_to_root . "/includes/session.inc");
include_once($path_to_root . "/includes/ui.inc");
include_once($path_to_root . "/services/includes/db/job_orders_db.inc"); 
include_once($path_to_root . "/services/includes/ui/job_order_entry_ui.inc");  
include_once($path_to_root . "/services/includes/ui/job_order_repairs_ui.inc"); 
include_once($path_to_root . "/services/includes/db/job_order_repairs_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 . "/admin/db/list_values_db.inc"); 
include_once($path_to_root . "/projects/includes/db/projects_db.inc");  

$js = "";
$js .= get_js_open_window(800, 500);

global $systypes_array;

page(_($help_context = "View ".$systypes_array[ST_JOB_ORDER]), true, false, "", $js);

$jo_id = 0;
if (isset($_GET["trans_no"])) {
    $jo_id = $_GET["trans_no"];
}

br();

global $systypes_array;

    $hd_name = '';
    $row = get_job_orders_by_filters(jo_id: $jo_id, fetch: true);
        if (! (isset($row['id']) && $row > 0)) {
            display_error(("Could not find Job Crad #$jo_id."));
            display_footer_exit();
        } else {
            $pro_msg = get_department_approval_project($row['department_id']);

            $user_id = $_SESSION['wa_current_user']->user;
            $cap = can_access_project($pro_msg['project_id'], $user_id);
                if ($cap['success'] !== true) {
                    display_error($cap["message"]);
                    display_footer_exit();
                    exit;
                }
        }
    
        if (is_array($row) && $row['parent_jo_id'] > 0) {
            $hd_name = 'Sub ';
        } 
        
        
    $tp_name = $systypes_array[ST_JOB_ORDER];
    
        display_heading("$hd_name $tp_name #$jo_id");        br();
    
        view_job_order_header($jo_id);        br();
        
        view_job_order_repairs($jo_id);

end_page(true, false, false, ST_JOB_ORDER, $jo_id);

?>