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