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(_("Sales Invoices"));
37 display_heading2(_("Credit Notes"));
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);
70 $th = array(_("#"), _("Ref"), _("Date"), _("Total"));
73 $sql = "SELECT * FROM ".TB_PREF."debtor_trans WHERE type=10 AND order_=" . $_GET['trans_no'];
74 $result = db_query($sql,"The related invoices could not be retreived");
79 while ($inv_row = db_fetch($result))
82 alt_table_row_color($k);
84 $this_total = $inv_row["ov_freight"] + $inv_row["ov_gst"] + $inv_row["ov_amount"];
85 $invoices_total += $this_total;
87 label_cell(get_customer_trans_view_str($inv_row["type"], $inv_row["trans_no"]));
88 label_cell($inv_row["reference"]);
89 label_cell(sql2date($inv_row["tran_date"]));
90 amount_cell($this_total);
95 label_row(null, number_format2($invoices_total,user_price_dec()), "", "colspan=4 align=right");
99 echo "</td><td valign='top'>";
100 start_table($table_style);
101 $th = array(_("#"), _("Ref"), _("Date"), _("Total"));
104 $sql = "SELECT * FROM ".TB_PREF."debtor_trans WHERE type=11 AND order_=" . $_GET['trans_no'];
105 $result = db_query($sql,"The related credit notes could not be retreived");
110 while ($credits_row = db_fetch($result))
113 alt_table_row_color($k);
115 $this_total = $credits_row["ov_freight"] + $credits_row["ov_gst"] + $credits_row["ov_amount"];
116 $credits_total += $this_total;
118 label_cell(get_customer_trans_view_str($credits_row["type"], $credits_row["trans_no"]));
119 label_cell($credits_row["reference"]);
120 label_cell(sql2date($credits_row["tran_date"]));
121 amount_cell(-$this_total);
126 label_row(null, "<font color=red>" . number_format2(-$credits_total,user_price_dec()) . "</font>",
127 "", "colspan=4 align=right");
137 display_heading2(_("Line Details"));
139 start_table("colspan=9 width=95% $table_style");
140 $th = array(_("Item Code"), _("Item Description"), _("Quantity"), _("Unit"),
141 _("Price"), _("Discount"), _("Total"), _("Quantity Delivered"));
144 $k = 0; //row colour counter
146 foreach ($_SESSION['Items']->line_items as $stock_item) {
148 $line_total = $stock_item->quantity * $stock_item->price * (1 - $stock_item->discount_percent);
150 alt_table_row_color($k);
152 label_cell($stock_item->stock_id);
153 label_cell($stock_item->item_description);
154 qty_cell($stock_item->quantity);
155 label_cell($stock_item->units);
156 amount_cell($stock_item->price);
157 amount_cell($stock_item->discount_percent * 100);
158 amount_cell($line_total);
160 qty_cell($stock_item->qty_inv);
164 $items_total = $_SESSION['Items']->get_items_total();
166 $display_total = number_format2($items_total + $_SESSION['Items']->freight_cost,user_price_dec());
168 label_row(_("Shipping"), number_format2($_SESSION['Items']->freight_cost,user_price_dec()),
169 "align=right colspan=6", "nowrap align=right");
170 label_row(_("Total Excluding Tax"), $display_total, "align=right colspan=6",
171 "nowrap align=right");