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_GLTRANSVIEW';
13 $path_to_root = "../..";
14 include_once($path_to_root . "/includes/session.inc");
16 page(_("General Ledger Transaction Details"), true);
18 include_once($path_to_root . "/includes/date_functions.inc");
19 include_once($path_to_root . "/includes/ui.inc");
21 include_once($path_to_root . "/gl/includes/gl_db.inc");
23 if (!isset($_GET['type_id']) || !isset($_GET['trans_no']))
24 { /*Script was not passed the correct parameters */
26 echo "<p>" . _("The script must be called with a valid transaction type and transaction number to review the general ledger postings for.") . "</p>";
30 function display_gl_heading($myrow)
32 global $table_style, $systypes_array;
33 $trans_name = $systypes_array[$_GET['type_id']];
34 start_table("$table_style width=95%");
35 $th = array(_("General Ledger Transaction Details"),
36 _("Date"), _("Person/Item"));
39 label_cell("$trans_name #" . $_GET['trans_no']);
40 label_cell(sql2date($myrow["tran_date"]));
41 label_cell(payment_person_name($myrow["person_type_id"],$myrow["person_id"]));
45 comments_display_row($_GET['type_id'], $_GET['trans_no']);
50 $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";
51 $result = db_query($sql,"could not get transactions");
52 //alert("sql = ".$sql);
54 if (db_num_rows($result) == 0)
56 echo "<p><center>" . _("No general ledger transactions have been created for") . " " .$systypes_array$_GET['type_id']]." " . _("number") . " " . $_GET['trans_no'] . "</center></p><br><br>";
61 /*show a table of the transactions returned by the sql */
62 $dim = get_company_pref('use_dimension');
65 $th = array(_("Account Code"), _("Account Name"), _("Dimension")." 1", _("Dimension")." 2",
66 _("Debit"), _("Credit"), _("Memo"));
68 $th = array(_("Account Code"), _("Account Name"), _("Dimension"),
69 _("Debit"), _("Credit"), _("Memo"));
71 $th = array(_("Account Code"), _("Account Name"),
72 _("Debit"), _("Credit"), _("Memo"));
73 $k = 0; //row colour counter
74 $heading_shown = false;
76 while ($myrow = db_fetch($result))
78 if ($myrow['amount'] == 0) continue;
81 display_gl_heading($myrow);
82 start_table("$table_style width=95%");
84 $heading_shown = true;
87 alt_table_row_color($k);
89 label_cell($myrow['account']);
90 label_cell($myrow['account_name']);
92 label_cell(get_dimension_string($myrow['dimension_id'], true));
94 label_cell(get_dimension_string($myrow['dimension2_id'], true));
96 display_debit_or_credit_cells($myrow['amount']);
97 label_cell($myrow['memo_']);
105 is_voided_display($_GET['type_id'], $_GET['trans_no'], _("This transaction has been voided."));