cdaeb3fe8514c4eac48d8e40e3dde7d04eafa6ac
[fa-stable.git] / purchasing / view / view_supp_credit.php
1 <?php
2 /**********************************************************************
3     Copyright (C) FrontAccounting, LLC.
4         Released under the terms of the GNU General Public License, GPL, 
5         as published by the Free Software Foundation, either version 3 
6         of the License, or (at your option) any later version.
7     This program is distributed in the hope that it will be useful,
8     but WITHOUT ANY WARRANTY; without even the implied warranty of
9     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  
10     See the License here <http://www.gnu.org/licenses/gpl-3.0.html>.
11 ***********************************************************************/
12 $page_security = 'SA_SUPPTRANSVIEW';
13 $path_to_root = "../..";
14
15 include_once($path_to_root . "/purchasing/includes/purchasing_db.inc");
16 include_once($path_to_root . "/includes/session.inc");
17
18 include_once($path_to_root . "/purchasing/includes/purchasing_ui.inc");
19
20 $js = "";
21 if ($use_popup_windows)
22         $js .= get_js_open_window(900, 500);
23 page(_($help_context = "View Supplier Credit Note"), true, false, "", $js);
24
25 if (isset($_GET["trans_no"]))
26 {
27         $trans_no = $_GET["trans_no"];
28 }
29 elseif (isset($_POST["trans_no"]))
30 {
31         $trans_no = $_POST["trans_no"];
32 }
33
34 $supp_trans = new supp_trans(ST_SUPPCREDIT);
35
36 read_supp_invoice($trans_no, ST_SUPPCREDIT, $supp_trans);
37
38 display_heading("<font color=red>" . _("SUPPLIER CREDIT NOTE") . " # " . $trans_no . "</font>");
39 echo "<br>";
40 start_table(TABLESTYLE, "width=95%");
41 start_row();
42 label_cells(_("Supplier"), $supp_trans->supplier_name, "class='tableheader2'");
43 label_cells(_("Reference"), $supp_trans->reference, "class='tableheader2'");
44 label_cells(_("Supplier's Reference"), $supp_trans->supp_reference, "class='tableheader2'");
45 end_row();
46 start_row();
47 label_cells(_("Invoice Date"), $supp_trans->tran_date, "class='tableheader2'");
48 label_cells(_("Due Date"), $supp_trans->due_date, "class='tableheader2'");
49 label_cells(_("Currency"), get_supplier_currency($supp_trans->supplier_id), "class='tableheader2'");
50 end_row();
51 comments_display_row(ST_SUPPCREDIT, $trans_no);
52 end_table(1);
53
54 $total_gl = display_gl_items($supp_trans, 3);
55 $total_grn = display_grn_items($supp_trans, 2);
56
57 $display_sub_tot = number_format2($total_gl+$total_grn,user_price_dec());
58
59 start_table(TABLESTYLE, "width=95%");
60 label_row(_("Sub Total"), $display_sub_tot, "align=right", "nowrap align=right width=17%");
61
62 $tax_items = get_trans_tax_details(ST_SUPPCREDIT, $trans_no);
63 display_supp_trans_tax_details($tax_items, 1);
64
65 $display_total = number_format2(-($supp_trans->ov_amount + $supp_trans->ov_gst),user_price_dec());
66 label_row("<font color=red>" . _("TOTAL CREDIT NOTE") . "</font", "<font color=red>$display_total</font>", 
67         "colspan=1 align=right", "nowrap align=right");
68
69 end_table(1);
70
71 $voided = is_voided_display(ST_SUPPCREDIT, $trans_no, _("This credit note has been voided."));
72
73 if (!$voided)
74 {
75         display_allocations_from(PT_SUPPLIER, $supp_trans->supplier_id, ST_SUPPCREDIT, $trans_no, -($supp_trans->ov_amount + $supp_trans->ov_gst));
76 }
77
78 end_page(true, false, false, ST_SUPPCREDIT, $trans_no);
79
80 ?>