2 /**********************************************************************
3 Copyright (C) FrontAccounting, LLC.
4 Released under the terms of the GNU Affero General Public License,
5 AGPL, as published by the Free Software Foundation, either version
6 3 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/agpl-3.0.html>.
11 ***********************************************************************/
13 $path_to_root="../..";
14 include($path_to_root . "/purchasing/includes/po_class.inc");
16 include($path_to_root . "/includes/session.inc");
17 include($path_to_root . "/purchasing/includes/purchasing_ui.inc");
20 if ($use_popup_windows)
21 $js .= get_js_open_window(900, 500);
22 page(_("View Purchase Order"), true, false, "", $js);
25 if (!isset($_GET['trans_no']))
27 die ("<br>" . _("This page must be called with a purchase order number to review."));
30 display_heading(_("Purchase Order") . " #" . $_GET['trans_no']);
32 $purchase_order = new purch_order;
34 read_po($_GET['trans_no'], $purchase_order);
36 display_po_summary($purchase_order, true);
38 start_table("$table_style width=90%", 6);
39 echo "<tr><td valign=top>"; // outer table
41 display_heading2(_("Line Details"));
43 start_table("colspan=9 $table_style width=100%");
45 $th = array(_("Item Code"), _("Item Description"), _("Quantity"), _("Unit"), _("Price"),
46 _("Line Total"), _("Requested By"), _("Quantity Received"), _("Quantity Invoiced"));
49 $overdue_items = false;
51 foreach ($purchase_order->line_items as $stock_item)
54 $line_total = $stock_item->quantity * $stock_item->price;
56 // if overdue and outstanding quantities, then highlight as so
57 if (($stock_item->quantity - $stock_item->qty_received > 0) &&
58 date1_greater_date2(Today(), $stock_item->req_del_date))
60 start_row("class='overduebg'");
61 $overdue_items = true;
65 alt_table_row_color($k);
68 label_cell($stock_item->stock_id);
69 label_cell($stock_item->item_description);
70 $dec = get_qty_dec($stock_item->stock_id);
71 qty_cell($stock_item->quantity, false, $dec);
72 label_cell($stock_item->units);
73 amount_cell($stock_item->price);
74 amount_cell($line_total);
75 label_cell($stock_item->req_del_date);
76 qty_cell($stock_item->qty_received, false, $dec);
77 qty_cell($stock_item->qty_inv, false, $dec);
80 $total += $line_total;
83 $display_total = number_format2($total,user_price_dec());
84 label_row(_("Total Excluding Tax/Shipping"), $display_total,
85 "align=right colspan=5", "nowrap align=right");
90 display_note(_("Marked items are overdue."), 0, 0, "class='overduefg'");
92 //----------------------------------------------------------------------------------------------------
96 $grns_result = get_po_grns($_GET['trans_no']);
98 if (db_num_rows($grns_result) > 0)
101 echo "</td><td valign=top>"; // outer table
103 display_heading2(_("Deliveries"));
104 start_table($table_style);
105 $th = array(_("#"), _("Reference"), _("Delivered On"));
107 while ($myrow = db_fetch($grns_result))
109 alt_table_row_color($k);
111 label_cell(get_trans_view_str(25,$myrow["id"]));
112 label_cell($myrow["reference"]);
113 label_cell(sql2date($myrow["delivery_date"]));
119 $invoice_result = get_po_invoices_credits($_GET['trans_no']);
123 if (db_num_rows($invoice_result) > 0)
126 echo "</td><td valign=top>"; // outer table
128 display_heading2(_("Invoices/Credits"));
129 start_table($table_style);
130 $th = array(_("#"), _("Date"), _("Total"));
132 while ($myrow = db_fetch($invoice_result))
134 alt_table_row_color($k);
136 label_cell(get_trans_view_str($myrow["type"],$myrow["trans_no"]));
137 label_cell(sql2date($myrow["tran_date"]));
138 amount_cell($myrow["Total"]);
146 end_table(1); // outer table
148 //----------------------------------------------------------------------------------------------------