*** empty log message ***
[fa-stable.git] / gl / view / gl_trans_view.php
1 <?php
2
3 $page_security = 8;
4 $path_to_root="../..";
5 include_once($path_to_root . "/includes/session.inc");
6
7 page(_("General Ledger Transaction Details"), true);
8
9 include_once($path_to_root . "/includes/date_functions.inc");
10 include_once($path_to_root . "/includes/ui.inc");
11
12 include_once($path_to_root . "/gl/includes/gl_db.inc");
13
14 if (!isset($_GET['type_id']) || !isset($_GET['trans_no'])) 
15 { /*Script was not passed the correct parameters */
16
17         echo "<p>" . _("The script must be called with a valid transaction type and transaction number to review the general ledger postings for.") . "</p>";
18         exit;
19 }
20
21 function display_gl_heading($myrow)
22 {
23         global $table_style;
24         $trans_name = systypes::name($_GET['type_id']);
25     start_table("$table_style width=95%");
26     $th = array(_("General Ledger Transaction Details"),
27         _("Date"), _("Person/Item"));
28     table_header($th);  
29     start_row();        
30     label_cell("$trans_name #" . $_GET['trans_no']);
31         label_cell(sql2date($myrow["tran_date"]));
32         label_cell(payment_person_types::person_name($myrow["person_type_id"],$myrow["person_id"]));
33         
34         end_row();
35
36         comments_display_row($_GET['type_id'], $_GET['trans_no']);
37
38     end_table(1);
39 }
40
41 $sql = "SELECT ".TB_PREF."gl_trans.*, account_name FROM ".TB_PREF."gl_trans, ".TB_PREF."chart_master WHERE ".TB_PREF."gl_trans.account = ".TB_PREF."chart_master.account_code AND type= " . $_GET['type_id'] . " AND type_no = " . $_GET['trans_no'] . " ORDER BY counter";
42 $result = db_query($sql,"could not get transactions");
43 //alert("sql = ".$sql);
44
45 if (db_num_rows($result) == 0)
46 {
47     echo "<p><center>" . _("No general ledger transactions have been created for") . " " .systypes::name($_GET['type_id'])." " . _("number") . " " . $_GET['trans_no'] . "</center></p><br><br>";
48         end_page(true);
49         exit;
50 }
51
52 /*show a table of the transactions returned by the sql */
53 $dim = get_company_pref('use_dimension');
54
55 if ($dim == 2)
56         $th = array(_("Account Code"), _("Account Name"), _("Dimension")." 1", _("Dimension")." 2",
57                 _("Debit"), _("Credit"), _("Memo"));
58 else if ($dim == 1)
59         $th = array(_("Account Code"), _("Account Name"), _("Dimension"),
60                 _("Debit"), _("Credit"), _("Memo"));
61 else            
62         $th = array(_("Account Code"), _("Account Name"),
63                 _("Debit"), _("Credit"), _("Memo"));
64 $k = 0; //row colour counter
65 $heading_shown = false;
66
67 while ($myrow = db_fetch($result)) 
68 {
69         if (!$heading_shown)
70         {
71                 display_gl_heading($myrow);
72                 start_table("$table_style width=95%");
73                 table_header($th);
74                 $heading_shown = true;
75         }       
76
77         alt_table_row_color($k);
78         
79     label_cell($myrow['account']);
80         label_cell($myrow['account_name']);
81         if ($dim >= 1)
82                 label_cell(get_dimension_string($myrow['dimension_id'], true));
83         if ($dim > 1)
84                 label_cell(get_dimension_string($myrow['dimension2_id'], true));
85
86         display_debit_or_credit_cells($myrow['amount']);
87         label_cell($myrow['memo_']);
88         end_row();
89
90 }
91 //end of while loop
92 if ($heading_shown)
93         end_table(1);
94
95 is_voided_display($_GET['type_id'], $_GET['trans_no'], _("This transaction has been voided."));
96
97 end_page(true);
98
99 ?>