Added Purchase Delivery edition.
[fa-stable.git] / purchasing / view / view_grn.php
1 <?php
2 /**********************************************************************
3     Copyright (C) FrontAccounting, LLC.
4         Released under the terms of the GNU General Public License, GPL, 
5         as published by the Free Software Foundation, either version 3 
6         of the License, or (at your option) any later version.
7     This program is distributed in the hope that it will be useful,
8     but WITHOUT ANY WARRANTY; without even the implied warranty of
9     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  
10     See the License here <http://www.gnu.org/licenses/gpl-3.0.html>.
11 ***********************************************************************/
12 $page_security = 'SA_SUPPTRANSVIEW';
13 $path_to_root = "../..";
14 include($path_to_root . "/purchasing/includes/po_class.inc");
15
16 include($path_to_root . "/includes/session.inc");
17
18 $js = "";
19 if ($SysPrefs->use_popup_windows)
20         $js .= get_js_open_window(900, 500);
21 page(_($help_context = "View Purchase Order Delivery"), true, false, "", $js);
22
23 include($path_to_root . "/purchasing/includes/purchasing_ui.inc");
24
25 if (!isset($_GET['trans_no']))
26 {
27         die ("<BR>" . _("This page must be called with a Purchase Order Delivery number to review."));
28 }
29
30 $purchase_order = new purch_order;
31 read_grn($_GET["trans_no"], $purchase_order);
32
33 display_heading(_("Purchase Order Delivery") . " #" . $_GET['trans_no']);
34 echo "<BR>";
35 display_grn_summary($purchase_order);
36
37 display_heading2(_("Line Details"));
38
39 start_table(TABLESTYLE, "width='90%'");
40 $th = array(_("Item Code"), _("Item Description"), _("Required by"), _("Quantity"),
41         _("Unit"), _("Price"), _("Line Total"), _("Quantity Invoiced"));
42
43 table_header($th);
44
45 $total = 0;
46 $k = 0;  //row colour counter
47 $overdue_items = false;
48
49 foreach ($purchase_order->line_items as $stock_item)
50 {
51         $line_total = $stock_item->quantity * $stock_item->price;
52
53         // if overdue and outstanding quantities, then highlight as so
54         if (date1_greater_date2($purchase_order->orig_order_date, $stock_item->req_del_date))
55         {
56         start_row("class='overduebg'");
57         $overdue_items = true;
58         }
59         else
60         {
61                 alt_table_row_color($k);
62         }
63
64         label_cell($stock_item->stock_id);
65         label_cell($stock_item->item_description);
66         label_cell($stock_item->req_del_date, "nowrap align=right");
67         $dec = get_qty_dec($stock_item->stock_id);
68         qty_cell($stock_item->quantity, false, $dec);
69         label_cell($stock_item->units);
70         amount_decimal_cell($stock_item->price);
71         amount_cell($line_total);
72         qty_cell($stock_item->qty_inv, false, $dec);
73         end_row();
74
75         $total += $line_total;
76 }
77
78 $display_sub_tot = number_format2($total,user_price_dec());
79 label_row(_("Sub Total"), $display_sub_tot,
80         "align=right colspan=6", "nowrap align=right", 1);
81
82 $taxes = $purchase_order->get_taxes();
83 $tax_total = display_edit_tax_items($taxes, 6, $purchase_order->tax_included, 1);
84
85 $display_total = price_format(($total + $tax_total));
86
87 start_row();
88 label_cells(_("Amount Total"), $display_total, "colspan=6 align='right'","align='right'");
89 label_cell('');
90 end_row();
91
92
93 end_table(1);
94
95 if ($overdue_items)
96         display_note(_("Marked items were delivered overdue."), 0, 0, "class='overduefg'");
97
98 is_voided_display(ST_SUPPRECEIVE, $_GET['trans_no'], _("This delivery has been voided."));
99
100 end_page(true, false, false, ST_SUPPRECEIVE, $_GET['trans_no']);
101