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(_("Sales Order") . " #" . $_GET['trans_no']);
21 if (isset($_SESSION['Items']))
23 unset ($_SESSION['Items']);
26 $_SESSION['Items'] = new cart;
28 /*read in all the selected order into the Items cart */
29 read_sales_order($_GET['trans_no'], $_SESSION['Items']);
31 start_table("$table_style2 width=95%", 5);
32 echo "<tr valign=top><td>";
33 display_heading2(_("Order Information"));
35 display_heading2(_("Deliveries"));
37 display_heading2(_("Invoices/Credits"));
40 echo "<tr valign=top><td>";
42 start_table("$table_style width=95%");
43 label_row(_("Customer Name"), $_SESSION['Items']->customer_name, "class='tableheader2'",
46 label_cells(_("Customer Order Ref."), $_SESSION['Items']->cust_ref, "class='tableheader2'");
47 label_cells(_("Deliver To Branch"), $_SESSION['Items']->deliver_to, "class='tableheader2'");
50 label_cells(_("Ordered On"), $_SESSION['Items']->orig_order_date, "class='tableheader2'");
51 label_cells(_("Requested Delivery"), $_SESSION['Items']->delivery_date, "class='tableheader2'");
54 label_cells(_("Order Currency"), $_SESSION['Items']->customer_currency, "class='tableheader2'");
55 label_cells(_("Deliver From Location"), $_SESSION['Items']->location_name, "class='tableheader2'");
58 label_row(_("Delivery Address"), nl2br($_SESSION['Items']->delivery_address),
59 "class='tableheader2'", "colspan=3");
60 label_row(_("Telephone"), $_SESSION['Items']->phone, "class='tableheader2'", "colspan=3");
61 label_row(_("E-mail"), "<a href='mailto:" . $_SESSION['Items']->email . "'>" . $_SESSION['Items']->email . "</a>",
62 "class='tableheader2'", "colspan=3");
63 label_row(_("Comments"), $_SESSION['Items']->Comments, "class='tableheader2'", "colspan=3");
66 echo "</td><td valign='top'>";
68 start_table($table_style);
69 display_heading2(_("Delivery Notes"));
71 $th = array(_("#"), _("Ref"), _("Date"), _("Total"));
74 $sql = "SELECT * FROM ".TB_PREF."debtor_trans WHERE type=13 AND order_=" . $_GET['trans_no'];
75 $result = db_query($sql,"The related delivery notes could not be retreived");
80 while ($del_row = db_fetch($result))
83 alt_table_row_color($k);
85 $this_total = $del_row["ov_freight"] + $del_row["ov_gst"] + $del_row["ov_amount"];
86 $delivery_total += $this_total;
88 label_cell(get_customer_trans_view_str($del_row["type"], $del_row["trans_no"]));
89 label_cell($del_row["reference"]);
90 label_cell(sql2date($del_row["tran_date"]));
91 amount_cell($this_total);
96 label_row(null, number_format2($delivery_total,user_price_dec()), "", "colspan=4 align=right");
99 echo "</td><td valign='top'>";
101 start_table($table_style);
102 display_heading2(_("Sales Invoices"));
104 $th = array(_("#"), _("Ref"), _("Date"), _("Total"));
107 $sql = "SELECT * FROM ".TB_PREF."debtor_trans WHERE type=10 AND order_=" . $_GET['trans_no'];
108 $result = db_query($sql,"The related invoices could not be retreived");
113 while ($inv_row = db_fetch($result))
116 alt_table_row_color($k);
118 $this_total = $inv_row["ov_freight"] + $inv_row["ov_gst"] + $inv_row["ov_amount"];
119 $invoices_total += $this_total;
121 label_cell(get_customer_trans_view_str($inv_row["type"], $inv_row["trans_no"]));
122 label_cell($inv_row["reference"]);
123 label_cell(sql2date($inv_row["tran_date"]));
124 amount_cell($this_total);
129 label_row(null, number_format2($invoices_total,user_price_dec()), "", "colspan=4 align=right");
133 display_heading2(_("Credit Notes"));
135 start_table($table_style);
136 $th = array(_("#"), _("Ref"), _("Date"), _("Total"));
139 $sql = "SELECT * FROM ".TB_PREF."debtor_trans WHERE type=11 AND order_=" . $_GET['trans_no'];
140 $result = db_query($sql,"The related credit notes could not be retreived");
145 while ($credits_row = db_fetch($result))
148 alt_table_row_color($k);
150 $this_total = $credits_row["ov_freight"] + $credits_row["ov_gst"] + $credits_row["ov_amount"];
151 $credits_total += $this_total;
153 label_cell(get_customer_trans_view_str($credits_row["type"], $credits_row["trans_no"]));
154 label_cell($credits_row["reference"]);
155 label_cell(sql2date($credits_row["tran_date"]));
156 amount_cell(-$this_total);
161 label_row(null, "<font color=red>" . number_format2(-$credits_total,user_price_dec()) . "</font>",
162 "", "colspan=4 align=right");
172 display_heading2(_("Line Details"));
174 start_table("colspan=9 width=95% $table_style");
175 $th = array(_("Item Code"), _("Item Description"), _("Quantity"), _("Unit"),
176 _("Price"), _("Discount"), _("Total"), _("Quantity Delivered"));
179 $k = 0; //row colour counter
181 foreach ($_SESSION['Items']->line_items as $stock_item) {
183 $line_total = $stock_item->quantity * $stock_item->price * (1 - $stock_item->discount_percent);
185 alt_table_row_color($k);
187 label_cell($stock_item->stock_id);
188 label_cell($stock_item->item_description);
189 qty_cell($stock_item->quantity);
190 label_cell($stock_item->units);
191 amount_cell($stock_item->price);
192 amount_cell($stock_item->discount_percent * 100);
193 amount_cell($line_total);
195 qty_cell($stock_item->qty_done);
199 $items_total = $_SESSION['Items']->get_items_total();
201 $display_total = number_format2($items_total + $_SESSION['Items']->freight_cost,user_price_dec());
203 label_row(_("Shipping"), number_format2($_SESSION['Items']->freight_cost,user_price_dec()),
204 "align=right colspan=6", "nowrap align=right");
205 label_row(_("Total Excluding Tax"), $display_total, "align=right colspan=6",
206 "nowrap align=right");