<?php

function job_order_salvages(&$jo_id) {
    global $path_to_root, $Ajax, $systypes_array;
    
    $Ajax->activate('job_order_salvages');
    div_start('job_order_salvages');
        display_job_order_salvages($jo_id);

        start_table();
            hyperlink_params_separate($path_to_root . "/inventory/salvage_returns.php", "Create a New ".$systypes_array[ST_SALVAGE_RETURN], "jo_id=$jo_id");
        end_table();
    div_end();
}

function display_job_order_salvages($jo_id) {
    global $approval_statuses, $path_to_root, $systypes_array;
    
    display_heading($systypes_array[ST_SALVAGE_RETURN]." Headers");    
    
	start_table(TABLESTYLE, "width=70%");
        
            $th = array(_("Id"), _("Trans #"), _("Location"), _("Date"), _("Approval Status"), _("")); 
            table_header($th);
            
            $k = 0;  
            $result = get_job_material_issue_headers_by_filters($jo_id, type: ST_SALVAGE_RETURN);
                while ($row = db_fetch($result)) {
                    alt_table_row_color($k);

                        $id = $row['id'];
			label_cell($id, 'align=center');
			label_cell(get_inventory_trans_view_str($row['type'], $row['trans_no']), 'align=center');
			label_cell($row['location_name']);
			label_cell(sql2date($row['tran_date']), 'align=center');
			label_cell($approval_statuses[$row['approval_status']], 'align=center');
                        if (in_array($row['approval_status'], array(AS_NEW, AS_WITH_THE_APPROVER, AS_AWAITING_APPROVAL, AS_BACK_TO_ORIGINATOR))) {
                            $link = "<a target='_blank' href='$path_to_root/inventory/salvage_returns.php?ModifySLRT_No=$id'>Edit</a>";
                            label_cell($link, 'align=center');
                        } else {
                            label_cell('');
                        }
                        
                    end_row();
                }

    end_table(2);
}

?>