Merged bugfixes upto [0000072] (version 2.0.3).
[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 if (isset($_SESSION['Items']))
25 {
26         unset ($_SESSION['Items']);
27 }
28
29 $purchase_order = new purch_order;
30
31 read_po($_GET['trans_no'], $purchase_order);
32 echo "<br>";
33 display_po_summary($purchase_order, true);
34
35 start_table("$table_style width=90%", 6);
36 echo "<tr><td valign=top>"; // outer table
37
38 display_heading2(_("Line Details"));
39
40 start_table("colspan=9 $table_style width=100%");
41
42 $th = array(_("Item Code"), _("Item Description"), _("Quantity"), _("Unit"), _("Price"),
43         _("Line Total"), _("Requested By"), _("Quantity Received"), _("Quantity Invoiced"));
44 table_header($th);
45 $total = $k = 0;
46 $overdue_items = false;
47
48 foreach ($purchase_order->line_items as $stock_item)
49 {
50
51         $line_total = $stock_item->quantity * $stock_item->price;
52
53         // if overdue and outstanding quantities, then highlight as so
54         if (($stock_item->quantity - $stock_item->qty_received > 0)     &&
55                 date1_greater_date2(Today(), $stock_item->req_del_date))
56         {
57         start_row("class='overduebg'");
58         $overdue_items = true;
59         }
60         else
61         {
62                 alt_table_row_color($k);
63         }
64
65         label_cell($stock_item->stock_id);
66         label_cell($stock_item->item_description);
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_cell($stock_item->price);
71         amount_cell($line_total);
72         label_cell($stock_item->req_del_date);
73         qty_cell($stock_item->qty_received, false, $dec);
74         qty_cell($stock_item->qty_inv, false, $dec);
75         end_row();
76
77         $total += $line_total;
78 }
79
80 $display_total = number_format2($total,user_price_dec());
81 label_row(_("Total Excluding Tax/Shipping"), $display_total,
82         "align=right colspan=5", "nowrap align=right");
83
84 end_table();
85
86 if ($overdue_items)
87         display_note(_("Marked items are overdue."), 0, 0, "class='overduefg'");
88
89 //----------------------------------------------------------------------------------------------------
90
91 $k = 0;
92
93 $grns_result = get_po_grns($_GET['trans_no']);
94
95 if (db_num_rows($grns_result) > 0)
96 {
97
98     echo "</td><td valign=top>"; // outer table
99
100     display_heading2(_("Deliveries"));
101     start_table($table_style);
102     $th = array(_("#"), _("Reference"), _("Delivered On"));
103     table_header($th);
104     while ($myrow = db_fetch($grns_result))
105     {
106                 alt_table_row_color($k);
107
108         label_cell(get_trans_view_str(25,$myrow["id"]));
109         label_cell($myrow["reference"]);
110         label_cell(sql2date($myrow["delivery_date"]));
111         end_row();
112     }
113     end_table();;
114 }
115
116 $invoice_result = get_po_invoices_credits($_GET['trans_no']);
117
118 $k = 0;
119
120 if (db_num_rows($invoice_result) > 0)
121 {
122
123     echo "</td><td valign=top>"; // outer table
124
125     display_heading2(_("Invoices/Credits"));
126     start_table($table_style);
127     $th = array(_("#"), _("Date"), _("Total"));
128     table_header($th);
129     while ($myrow = db_fetch($invoice_result))
130     {
131         alt_table_row_color($k);
132
133         label_cell(get_trans_view_str($myrow["type"],$myrow["trans_no"]));
134         label_cell(sql2date($myrow["tran_date"]));
135         amount_cell($myrow["Total"]);
136         end_row();
137     }
138     end_table();
139 }
140
141 echo "</td></tr>";
142
143 end_table(1); // outer table
144
145 //----------------------------------------------------------------------------------------------------
146
147 end_page(true);
148
149 ?>