5 include_once($path_to_root . "/sales/includes/cart_class.inc");
7 include_once($path_to_root . "/includes/session.inc");
8 include_once($path_to_root . "/includes/date_functions.inc");
10 include_once($path_to_root . "/sales/includes/sales_ui.inc");
11 include_once($path_to_root . "/sales/includes/sales_db.inc");
14 if ($use_popup_windows)
15 $js .= get_js_open_window(900, 600);
17 page(_("View Sales Order"), true, false, "", $js);
19 display_heading(sprintf(_("Sales Order #%d"),$_GET['trans_no']));
21 if (isset($_SESSION['Items']))
23 unset ($_SESSION['Items']);
26 $_SESSION['Items'] = new Cart(30, $_GET['trans_no'], true);
28 start_table("$table_style2 width=95%", 5);
29 echo "<tr valign=top><td>";
30 display_heading2(_("Order Information"));
32 display_heading2(_("Deliveries"));
34 display_heading2(_("Invoices/Credits"));
37 echo "<tr valign=top><td>";
39 start_table("$table_style width=95%");
40 label_row(_("Customer Name"), $_SESSION['Items']->customer_name, "class='tableheader2'",
43 label_cells(_("Customer Order Ref."), $_SESSION['Items']->cust_ref, "class='tableheader2'");
44 label_cells(_("Deliver To Branch"), $_SESSION['Items']->deliver_to, "class='tableheader2'");
47 label_cells(_("Ordered On"), $_SESSION['Items']->document_date, "class='tableheader2'");
48 label_cells(_("Requested Delivery"), $_SESSION['Items']->due_date, "class='tableheader2'");
51 label_cells(_("Order Currency"), $_SESSION['Items']->customer_currency, "class='tableheader2'");
52 label_cells(_("Deliver From Location"), $_SESSION['Items']->location_name, "class='tableheader2'");
55 label_row(_("Delivery Address"), nl2br($_SESSION['Items']->delivery_address),
56 "class='tableheader2'", "colspan=3");
57 label_row(_("Telephone"), $_SESSION['Items']->phone, "class='tableheader2'", "colspan=3");
58 label_row(_("E-mail"), "<a href='mailto:" . $_SESSION['Items']->email . "'>" . $_SESSION['Items']->email . "</a>",
59 "class='tableheader2'", "colspan=3");
60 label_row(_("Comments"), $_SESSION['Items']->Comments, "class='tableheader2'", "colspan=3");
63 echo "</td><td valign='top'>";
65 start_table($table_style);
66 display_heading2(_("Delivery Notes"));
68 $th = array(_("#"), _("Ref"), _("Date"), _("Total"));
71 $sql = "SELECT * FROM ".TB_PREF."debtor_trans WHERE type=13 AND order_=" . $_GET['trans_no'];
72 $result = db_query($sql,"The related delivery notes could not be retreived");
77 while ($del_row = db_fetch($result))
80 alt_table_row_color($k);
82 $this_total = $del_row["ov_freight"]+ $del_row["ov_amount"] + $del_row["ov_freight_tax"] + $del_row["ov_gst"] ;
83 $delivery_total += $this_total;
85 label_cell(get_customer_trans_view_str($del_row["type"], $del_row["trans_no"]));
86 label_cell($del_row["reference"]);
87 label_cell(sql2date($del_row["tran_date"]));
88 amount_cell($this_total);
93 label_row(null, number_format2($delivery_total,user_price_dec()), "", "colspan=4 align=right");
96 echo "</td><td valign='top'>";
98 start_table($table_style);
99 display_heading2(_("Sales Invoices"));
101 $th = array(_("#"), _("Ref"), _("Date"), _("Total"));
104 $sql = "SELECT * FROM ".TB_PREF."debtor_trans WHERE type=10 AND order_=" . $_GET['trans_no'];
105 $result = db_query($sql,"The related invoices could not be retreived");
110 while ($inv_row = db_fetch($result))
113 alt_table_row_color($k);
115 $this_total = $inv_row["ov_freight"] + $inv_row["ov_freight_tax"] + $inv_row["ov_gst"] + $inv_row["ov_amount"];
116 $invoices_total += $this_total;
118 label_cell(get_customer_trans_view_str($inv_row["type"], $inv_row["trans_no"]));
119 label_cell($inv_row["reference"]);
120 label_cell(sql2date($inv_row["tran_date"]));
121 amount_cell($this_total);
126 label_row(null, number_format2($invoices_total,user_price_dec()), "", "colspan=4 align=right");
130 display_heading2(_("Credit Notes"));
132 start_table($table_style);
133 $th = array(_("#"), _("Ref"), _("Date"), _("Total"));
136 $sql = "SELECT * FROM ".TB_PREF."debtor_trans WHERE type=11 AND order_=" . $_GET['trans_no'];
137 $result = db_query($sql,"The related credit notes could not be retreived");
142 while ($credits_row = db_fetch($result))
145 alt_table_row_color($k);
147 $this_total = $credits_row["ov_freight"] + $credits_row["ov_freight_tax"] + $credits_row["ov_gst"] + $credits_row["ov_amount"];
148 $credits_total += $this_total;
150 label_cell(get_customer_trans_view_str($credits_row["type"], $credits_row["trans_no"]));
151 label_cell($credits_row["reference"]);
152 label_cell(sql2date($credits_row["tran_date"]));
153 amount_cell(-$this_total);
158 label_row(null, "<font color=red>" . number_format2(-$credits_total,user_price_dec()) . "</font>",
159 "", "colspan=4 align=right");
169 display_heading2(_("Line Details"));
171 start_table("colspan=9 width=95% $table_style");
172 $th = array(_("Item Code"), _("Item Description"), _("Quantity"), _("Unit"),
173 _("Price"), _("Discount"), _("Total"), _("Quantity Delivered"));
176 $k = 0; //row colour counter
178 foreach ($_SESSION['Items']->line_items as $stock_item) {
180 $line_total = $stock_item->quantity * $stock_item->price * (1 - $stock_item->discount_percent);
182 alt_table_row_color($k);
184 label_cell($stock_item->stock_id);
185 label_cell($stock_item->item_description);
186 qty_cell($stock_item->quantity);
187 label_cell($stock_item->units);
188 amount_cell($stock_item->price);
189 amount_cell($stock_item->discount_percent * 100);
190 amount_cell($line_total);
192 qty_cell($stock_item->qty_done);
196 $items_total = $_SESSION['Items']->get_items_total();
198 $display_total = number_format2($items_total + $_SESSION['Items']->freight_cost,user_price_dec());
200 label_row(_("Shipping"), number_format2($_SESSION['Items']->freight_cost,user_price_dec()),
201 "align=right colspan=6", "nowrap align=right");
202 label_row(_("Total Order Value"), $display_total, "align=right colspan=6",
203 "nowrap align=right");