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

include($path_to_root . "/includes/session.inc");

page(_($help_context = "View Inventory Transfer"), true);

include_once($path_to_root . "/includes/date_functions.inc");
include_once($path_to_root . "/includes/ui.inc");
include_once($path_to_root . "/gl/includes/gl_db.inc");
include_once($path_to_root . "/inventory/includes/db/transfers_db.inc"); 
include_once($path_to_root . "/inventory/includes/db/movement_types_db.inc"); 

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

display_heading($systypes_array[ST_LOCTRANSFER] . " #$trans_no");

$trnsfr_hed = get_stock_transfers_header($trans_no);

echo "<br>";
    start_outer_table(TABLESTYLE2, "width=60%");
    
        table_section(1, '50%');
            label_row(_("From Location:"), $trnsfr_hed['location_from_name'], "class='tableheader2'");
            label_row(_("To Location:"), $trnsfr_hed['location_to_name'], "class='tableheader2'");
            label_row(_("Project:"), $trnsfr_hed['project_description'], "class='tableheader2'");
            label_row(_("Reference:"), $trnsfr_hed['reference'], "class='tableheader2'");

        table_section(2, '50%');
            label_row(_("Date:"), sql2date($trnsfr_hed['tran_date']), "class='tableheader2'");
            label_row(_("Sample Items:"), $trnsfr_hed['sample_items'] > 0 ? 'Yes' : 'No', "class='tableheader2'");
            
            $mv_tp = get_movement_type($trnsfr_hed['movement_type']);
            label_row(_("Movement Type:"), $mv_tp['name'], "class='tableheader2'");

            global $inventory_movement_type_linked_fields;
            if ($trnsfr_hed['linked_field_type'] != IMLF_NOT_LINKED) {
                $link_field = get_movement_type_linked_field_values($trnsfr_hed['linked_field_type'], $trnsfr_hed['linked_field_id']);
                label_row(_($inventory_movement_type_linked_fields[$trnsfr_hed['linked_field_type']].':'), $link_field['value'], "class='tableheader2'");
            }
            
    end_outer_table(2);
    
    $comment = $trnsfr_hed['comments'];
                
                
        if (strlen($comment) > 0) {
            start_table(TABLESTYLE);
                label_row(_("Comment: "), nl2br($comment), "class='tableheader2'"); 
            end_table(2, false);

        }

    start_table(TABLESTYLE, "width=50%");

    $th = array(_("Item"), _("Description"), _("Quantity"), _("Units"));
    table_header($th);
        $transfer_items = get_stock_moves(ST_LOCTRANSFER, $trans_no);
        $k = 0;
        while ($item = db_fetch($transfer_items)) {
            if ($item['qty'] < 0) {
                continue;
            }
            alt_table_row_color($k);

                label_cell($item['stock_id']);
                label_cell($item['description']);
                qty_cell($item['qty'], false, get_qty_dec($item['stock_id']));
                label_cell($item['tran_unit']);
            end_row();
        }

    end_table(2);

is_voided_display(ST_LOCTRANSFER, $trans_no, _("This transfer has been voided."));

end_page(true, false, false, ST_LOCTRANSFER, $trans_no);

?>