Code cleanup.
[fa-stable.git] / purchasing / view / view_po.php
1 <?php
2
3
4 $page_security = 2;
5 $path_to_root="../..";
6 include($path_to_root . "/purchasing/includes/po_class.inc");
7
8 include($path_to_root . "/includes/session.inc");
9 include($path_to_root . "/purchasing/includes/purchasing_ui.inc");
10
11 $js = "";
12 if ($use_popup_windows)
13         $js .= get_js_open_window(900, 500);
14 page(_("View Purchase Order"), true, false, "", $js);
15
16
17 if (!isset($_GET['trans_no']))
18 {
19         die ("<br>" . _("This page must be called with a purchase order number to review."));
20 }
21
22 display_heading(_("Purchase Order") . " #" . $_GET['trans_no']);
23
24 $purchase_order = new purch_order;
25
26 read_po($_GET['trans_no'], $purchase_order);
27 echo "<br>";
28 display_po_summary($purchase_order, true);
29
30 start_table("$table_style width=90%", 6);
31 echo "<tr><td valign=top>"; // outer table
32
33 display_heading2(_("Line Details"));
34
35 start_table("colspan=9 $table_style width=100%");
36
37 $th = array(_("Item Code"), _("Item Description"), _("Quantity"), _("Unit"), _("Price"),
38         _("Line Total"), _("Requested By"), _("Quantity Received"), _("Quantity Invoiced"));
39 table_header($th);
40 $total = $k = 0;
41 $overdue_items = false;
42
43 foreach ($purchase_order->line_items as $stock_item)
44 {
45
46         $line_total = $stock_item->quantity * $stock_item->price;
47
48         // if overdue and outstanding quantities, then highlight as so
49         if (($stock_item->quantity - $stock_item->qty_received > 0)     &&
50                 date1_greater_date2(Today(), $stock_item->req_del_date))
51         {
52         start_row("class='overduebg'");
53         $overdue_items = true;
54         }
55         else
56         {
57                 alt_table_row_color($k);
58         }
59
60         label_cell($stock_item->stock_id);
61         label_cell($stock_item->item_description);
62         $dec = get_qty_dec($stock_item->stock_id);
63         qty_cell($stock_item->quantity, false, $dec);
64         label_cell($stock_item->units);
65         amount_cell($stock_item->price);
66         amount_cell($line_total);
67         label_cell($stock_item->req_del_date);
68         qty_cell($stock_item->qty_received, false, $dec);
69         qty_cell($stock_item->qty_inv, false, $dec);
70         end_row();
71
72         $total += $line_total;
73 }
74
75 $display_total = number_format2($total,user_price_dec());
76 label_row(_("Total Excluding Tax/Shipping"), $display_total,
77         "align=right colspan=5", "nowrap align=right");
78
79 end_table();
80
81 if ($overdue_items)
82         display_note(_("Marked items are overdue."), 0, 0, "class='overduefg'");
83
84 //----------------------------------------------------------------------------------------------------
85
86 $k = 0;
87
88 $grns_result = get_po_grns($_GET['trans_no']);
89
90 if (db_num_rows($grns_result) > 0)
91 {
92
93     echo "</td><td valign=top>"; // outer table
94
95     display_heading2(_("Deliveries"));
96     start_table($table_style);
97     $th = array(_("#"), _("Reference"), _("Delivered On"));
98     table_header($th);
99     while ($myrow = db_fetch($grns_result))
100     {
101                 alt_table_row_color($k);
102
103         label_cell(get_trans_view_str(25,$myrow["id"]));
104         label_cell($myrow["reference"]);
105         label_cell(sql2date($myrow["delivery_date"]));
106         end_row();
107     }
108     end_table();;
109 }
110
111 $invoice_result = get_po_invoices_credits($_GET['trans_no']);
112
113 $k = 0;
114
115 if (db_num_rows($invoice_result) > 0)
116 {
117
118     echo "</td><td valign=top>"; // outer table
119
120     display_heading2(_("Invoices/Credits"));
121     start_table($table_style);
122     $th = array(_("#"), _("Date"), _("Total"));
123     table_header($th);
124     while ($myrow = db_fetch($invoice_result))
125     {
126         alt_table_row_color($k);
127
128         label_cell(get_trans_view_str($myrow["type"],$myrow["trans_no"]));
129         label_cell(sql2date($myrow["tran_date"]));
130         amount_cell($myrow["Total"]);
131         end_row();
132     }
133     end_table();
134 }
135
136 echo "</td></tr>";
137
138 end_table(1); // outer table
139
140 //----------------------------------------------------------------------------------------------------
141
142 end_page(true);
143
144 ?>