5 include_once($path_to_root . "/includes/session.inc");
7 page(_("View Sales Invoice"), true);
9 include_once($path_to_root . "/sales/includes/sales_ui.inc");
11 include_once($path_to_root . "/sales/includes/sales_db.inc");
13 if (isset($_GET["trans_no"]))
15 $trans_id = $_GET["trans_no"];
17 elseif (isset($_POST["trans_no"]))
19 $trans_id = $_POST["trans_no"];
22 // 3 different queries to get the information - what a JOKE !!!!
24 $myrow = get_customer_trans($trans_id, 10);
26 $branch = get_branch($myrow["branch_code"]);
28 $sales_order = get_sales_order($myrow["order_"]);
30 display_heading(_("SALES INVOICE") . " #$trans_id");
33 start_table("$table_style2 width=95%");
34 echo "<tr valign=top><td>"; // outer table
36 /*Now the customer charged to details in a sub table*/
37 start_table("$table_style width=100%");
38 $th = array(_("Charge To"));
41 label_row(null, $myrow["DebtorName"] . "<br>" . nl2br($myrow["address"]), "nowrap");
45 /*end of the small table showing charge to account details */
47 echo "</td><td>"; // outer table
49 /*end of the main table showing the company name and charge to details */
51 start_table("$table_style width=100%");
52 $th = array(_("Charge Branch"));
55 label_row(null, $branch["br_name"] . "<br>" . nl2br($branch["br_address"]), "nowrap");
58 echo "</td><td>"; // outer table
60 start_table("$table_style width=100%");
61 $th = array(_("Delivered To"));
64 label_row(null, $sales_order["deliver_to"] . "<br>" . nl2br($sales_order["delivery_address"]),
68 echo "</td><td>"; // outer table
70 start_table("$table_style width=100%");
72 label_cells(_("Reference"), $myrow["reference"], "class='tableheader2'");
73 label_cells(_("Currency"), $sales_order["curr_code"], "class='tableheader2'");
74 label_cells(_("Our Order No"),
75 get_customer_trans_view_str(systypes::sales_order(),$sales_order["order_no"]), "class='tableheader2'");
78 label_cells(_("Customer Order Ref."), $sales_order["customer_ref"], "class='tableheader2'");
79 label_cells(_("Shipping Company"), $myrow["shipper_name"], "class='tableheader2'");
80 label_cells(_("Sales Type"), $myrow["sales_type"], "class='tableheader2'");
83 label_cells(_("Invoice Date"), sql2date($myrow["tran_date"]), "class='tableheader2'", "nowrap");
84 label_cells(_("Due Date"), sql2date($myrow["due_date"]), "class='tableheader2'", "nowrap");
86 comments_display_row(10, $trans_id);
90 end_table(1); // outer table
93 $result = get_customer_trans_details(10, $trans_id);
95 start_table("$table_style width=95%");
97 if (db_num_rows($result) > 0)
99 $th = array(_("Item Code"), _("Item Description"), _("Quantity"),
100 _("Unit"), _("Price"), _("Discount %"), _("Total"));
103 $k = 0; //row colour counter
105 while ($myrow2 = db_fetch($result))
108 alt_table_row_color($k);
110 $net = ((1 - $myrow2["discount_percent"]) * $myrow2["FullUnitPrice"] * -$myrow2["quantity"]);
113 if ($myrow2["discount_percent"] == 0)
115 $display_discount = "";
119 $display_discount = number_format2($myrow2["discount_percent"]*100,user_percent_dec()) . "%";
122 label_cell($myrow2["stock_id"]);
123 label_cell($myrow2["StockDescription"]);
124 qty_cell(-$myrow2["quantity"]);
125 label_cell($myrow2["units"], "align=right");
126 amount_cell($myrow2["FullUnitPrice"]);
127 label_cell($display_discount, "nowrap align=right");
130 } //end while there are line items to print out
134 display_note(_("There are no line items on this invoice."), 1, 2);
136 $display_sub_tot = number_format2($sub_total,user_price_dec());
137 $display_freight = number_format2($myrow["ov_freight"],user_price_dec());
139 /*Print out the invoice text entered */
140 label_row(_("Sub-total"), $display_sub_tot, "colspan=6 align=right",
141 "nowrap align=right width=15%");
142 label_row(_("Shipping"), $display_freight, "colspan=6 align=right", "nowrap align=right");
144 $tax_items = get_customer_trans_tax_details(10, $trans_id);
145 display_customer_trans_tax_details($tax_items, 6);
147 $display_total = number_format2($myrow["ov_freight"]+$myrow["ov_gst"]+$myrow["ov_amount"],user_price_dec());
149 label_row(_("TOTAL INVOICE"), $display_total, "colspan=6 align=right",
150 "nowrap align=right");
153 is_voided_display(10, $trans_id, _("This invoice has been voided."));