5 include_once($path_to_root . "/includes/session.inc");
7 include_once($path_to_root . "/includes/date_functions.inc");
8 include_once($path_to_root . "/includes/ui.inc");
10 include_once($path_to_root . "/sales/includes/sales_db.inc");
13 if ($use_popup_windows)
14 $js .= get_js_open_window(900, 500);
15 page(_("View Credit Note"), true, false, "", $js);
17 if (isset($_GET["trans_no"]))
19 $trans_id = $_GET["trans_no"];
21 elseif (isset($_POST["trans_no"]))
23 $trans_id = $_POST["trans_no"];
26 $myrow = get_customer_trans($trans_id, 11);
28 $branch = get_branch($myrow["branch_code"]);
30 display_heading("<font color=red>" . sprintf(_("CREDIT NOTE #%d"), $trans_id). "</font>");
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(_("Customer"));
41 label_row(null, $myrow["DebtorName"] . "<br>" . nl2br($myrow["address"]), "nowrap");
44 /*end of the small table showing charge to account details */
46 echo "</td><td>"; // outer table
48 start_table("$table_style width=100%");
49 $th = array(_("Branch"));
52 label_row(null, $branch["br_name"] . "<br>" . nl2br($branch["br_address"]), "nowrap");
55 echo "</td><td>"; // outer table
57 start_table("$table_style width=100%");
59 label_cells(_("Ref"), $myrow["reference"], "class='tableheader2'");
60 label_cells(_("Date"), sql2date($myrow["tran_date"]), "class='tableheader2'");
61 label_cells(_("Currency"), $myrow["curr_code"], "class='tableheader2'");
64 label_cells(_("Sales Type"), $myrow["sales_type"], "class='tableheader2'");
65 label_cells(_("Shipping Company"), $myrow["shipper_name"], "class='tableheader2'");
67 comments_display_row(11, $trans_id);
71 end_table(1); // outer table
75 $result = get_customer_trans_details(11, $trans_id);
77 start_table("$table_style width=95%");
79 if (db_num_rows($result) > 0)
81 $th = array(_("Item Code"), _("Item Description"), _("Quantity"),
82 _("Unit"), _("Price"), _("Discount %"), _("Total"));
85 $k = 0; //row colour counter
88 while ($myrow2 = db_fetch($result))
91 alt_table_row_color($k);
93 $value = ((1 - $myrow2["discount_percent"]) * $myrow2["unit_price"] * $myrow2["quantity"]);
96 if ($myrow2["discount_percent"] == 0)
98 $display_discount = "";
102 $display_discount = number_format2($myrow2["discount_percent"]*100,user_percent_dec()) . "%";
105 label_cell($myrow2["stock_id"]);
106 label_cell($myrow2["StockDescription"]);
107 qty_cell($myrow2["quantity"]);
108 label_cell($myrow2["units"], "align=right");
109 amount_cell($myrow2["unit_price"]);
110 label_cell($display_discount, "align=right");
113 } //end while there are line items to print out
116 display_note(_("There are no line items on this credit note."), 1, 2);
118 $display_sub_tot = number_format2($sub_total,user_price_dec());
119 $display_freight = number_format2($myrow["ov_freight"],user_price_dec());
121 $credit_total = $myrow["ov_freight"]+$myrow["ov_gst"]+$myrow["ov_amount"]+$myrow["ov_freight_tax"];
122 $display_total = number_format2($credit_total,user_price_dec());
124 /*Print out the invoice text entered */
126 label_row(_("Sub Total"), $display_sub_tot, "colspan=6 align=right",
127 "nowrap align=right width=15%");
128 label_row(_("Shipping"), $display_freight, "colspan=6 align=right", "nowrap align=right");
130 $tax_items = get_customer_trans_tax_details(11, $trans_id);
131 display_customer_trans_tax_details($tax_items, 6);
133 label_row("<font color=red>" . _("TOTAL CREDIT") . "</font",
134 "<font color=red>$display_total</font>", "colspan=6 align=right", "nowrap align=right");
137 $voided = is_voided_display(11, $trans_id, _("This credit note has been voided."));
140 display_allocations_from(payment_person_types::customer(),
141 $myrow['debtor_no'], 11, $trans_id, $credit_total);
143 /* end of check to see that there was an invoice record to print */