5 include_once($path_to_root . "/includes/session.inc");
8 include_once($path_to_root . "/includes/date_functions.inc");
9 include_once($path_to_root . "/includes/ui.inc");
10 include_once($path_to_root . "/includes/data_checks.inc");
12 include_once($path_to_root . "/gl/includes/gl_db.inc");
14 $js = get_js_set_focus('account');
15 if ($use_popup_windows)
16 $js .= get_js_open_window(800, 500);
18 $js .= get_js_date_picker();
20 page(_("General Ledger Account Inquiry"), false, false, "setFocus()", $js);
22 //----------------------------------------------------------------------------------------------------
24 if (isset($_GET["account"]))
25 $_POST["account"] = $_GET["account"];
26 if (isset($_GET["TransFromDate"]))
27 $_POST["TransFromDate"] = $_GET["TransFromDate"];
28 if (isset($_GET["TransToDate"]))
29 $_POST["TransToDate"] = $_GET["TransToDate"];
30 if (isset($_GET["Dimension"]))
31 $_POST["Dimension"] = $_GET["Dimension"];
32 if (isset($_GET["Dimension2"]))
33 $_POST["Dimension2"] = $_GET["Dimension2"];
35 //----------------------------------------------------------------------------------------------------
37 function gl_inquiry_controls()
41 $dim = get_company_pref('use_dimension');
44 //start_table($table_style2);
45 start_table("class='tablestyle_noborder'");
48 gl_all_accounts_list_cells(_("Account:"), 'account', null);
50 date_cells(_("from:"), 'TransFromDate', null, -30);
51 date_cells(_("to:"), 'TransToDate');
52 submit_cells('Show',_("Show"));
57 dimensions_list_row(_("Dimension")." 1", 'Dimension', null, true, " ", false, 1);
59 dimensions_list_row(_("Dimension")." 2", 'Dimension2', null, true, " ", false, 2);
65 //----------------------------------------------------------------------------------------------------
67 function show_results()
69 global $path_to_root, $table_style;
71 if (!isset($_POST["account"]) || $_POST["account"] == "")
73 $act_name = get_gl_account_name($_POST["account"]);
74 $dim = get_company_pref('use_dimension');
76 /*Now get the transactions */
77 if (!isset($_POST['Dimension']))
78 $_POST['Dimension'] = 0;
79 if (!isset($_POST['Dimension2']))
80 $_POST['Dimension2'] = 0;
81 $result = get_gl_transactions($_POST['TransFromDate'], $_POST['TransToDate'], -1,
82 $_POST["account"], $_POST['Dimension'], $_POST['Dimension2']);
84 $colspan = ($dim == 2 ? "6" : ($dim == 1 ? "5" : "4"));
85 //echo "\nDimension =". $_POST['Dimension'];
86 display_heading($_POST["account"]. " ".$act_name);
88 start_table($table_style);
90 $th = array(_("Type"), _("#"), _("Date"), _("Dimension")." 1", _("Dimension")." 2",
91 _("Person/Item"), _("Debit"), _("Credit"), _("Balance"), _("Memo"));
93 $th = array(_("Type"), _("#"), _("Date"), _("Dimension"),
94 _("Person/Item"), _("Debit"), _("Credit"), _("Balance"), _("Memo"));
96 $th = array(_("Type"), _("#"), _("Date"),
97 _("Person/Item"), _("Debit"), _("Credit"), _("Balance"), _("Memo"));
99 if (is_account_balancesheet($_POST["account"]))
103 $begin = begin_fiscalyear();
104 if ($_POST['TransFromDate'] < $begin)
105 $begin = $_POST['TransFromDate'];
106 $begin = add_days($begin, -1);
109 $bfw = get_gl_balance_from_to($begin, $_POST['TransFromDate'], $_POST["account"], $_POST['Dimension'], $_POST['Dimension2']);
111 start_row("class='inquirybg'");
112 label_cell("<b>"._("Opening Balance")." - ".$_POST['TransFromDate']."</b>", "colspan=$colspan");
113 display_debit_or_credit_cells($bfw);
117 $running_total = $bfw;
119 $k = 0; //row colour counter
121 while ($myrow = db_fetch($result))
124 alt_table_row_color($k);
126 $running_total += $myrow["amount"];
128 $trandate = sql2date($myrow["tran_date"]);
130 label_cell(systypes::name($myrow["type"]));
131 label_cell(get_gl_view_str($myrow["type"], $myrow["type_no"], $myrow["type_no"], true));
132 label_cell($trandate);
134 label_cell(get_dimension_string($myrow['dimension_id'], true));
136 label_cell(get_dimension_string($myrow['dimension2_id'], true));
137 label_cell(payment_person_types::person_name($myrow["person_type_id"],$myrow["person_id"]));
138 display_debit_or_credit_cells($myrow["amount"]);
139 amount_cell($running_total);
140 label_cell($myrow['memo_']);
152 start_row("class='inquirybg'");
153 label_cell("<b>" . _("Ending Balance") ." - ".$_POST['TransToDate']. "</b>", "colspan=$colspan");
154 display_debit_or_credit_cells($running_total);
159 if (db_num_rows($result) == 0)
160 display_note(_("No general ledger transactions have been created for this account on the selected dates."), 0, 1);
163 //----------------------------------------------------------------------------------------------------
165 gl_inquiry_controls();
169 //----------------------------------------------------------------------------------------------------