<?php



function display_item_alternate_units($stock_id)
{
    display_heading2("Units of this item");

    
    $alternate_units = get_alternate_unit_all_details($stock_id);
    $item = get_item($stock_id);
    $item_unit = get_item_unit($item['units']);


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

    $th = array("", _("Alt Unit"), "", _("Conversion"), _("Base Unit"),_("Inactive"));
    //inactive_control_column($th);
    table_header($th);
    $k = 0; //row colour counter
    $calculated = false;

    while ($myrow = db_fetch($alternate_units))
    {
        alt_table_row_color($k);

        label_cell(spaces(2)."1".spaces(2), "align=center");
        label_cell($myrow["alternate_unit_name"], "align=center");
        label_cell(spaces(2)."=".spaces(2), "align=center");
    //    amount_decimal_cell($myrow["convertion_factor"]);
        label_cell($myrow["convertion_factor"], "align=right");
        label_cell($myrow["base_unit_name"], "align=center");

        if($myrow["inactive"] == 0){
            $inactive = 'No';
        }
        else{
            $inactive = 'Yes';
        }
        label_cell($inactive, "align=center");

        
    //    delete_button_cell("Delete".$myrow['id'], _("Delete"));
        end_row();
    }
    
    end_table();
    
    return $item_unit['name'];
    
}



function display_previous_grn_lines($item_code)
{
    display_heading2("Previous 5 GRN unit costs");
    $result = get_stock_item_previous_grn_lines($item_code);

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

    $th = array("PO#", _("GRN#"), "GRN Date", "GRN Unit Cost");

    table_header($th);
    $k = 0; //row colour counter

    while ($myrow = db_fetch($result))
    {
        alt_table_row_color($k);

        $po_link = get_supplier_trans_view_str(ST_PURCHORDER, $myrow["purch_order_no"]);
        label_cell($po_link, "align=center");

        $grn_link = get_supplier_trans_view_str(ST_SUPPRECEIVE, $myrow["grn_batch_id"]);
        label_cell($grn_link, "align=center");
        label_cell(sql2date($myrow["delivery_date"]), "align=center");
        amount_decimal_cell($myrow["unit_cost"]);

        
        end_row();
    }
    
    end_table();
}


?>