Cleanup: removed all closing tags in php files.
[fa-stable.git] / gl / view / accrual_trans.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_ACCRUALS';
13 $path_to_root = "../..";
14 include_once($path_to_root . "/includes/session.inc");
15
16 $_SESSION['page_title'] = _($help_context = _("Search General Ledger Transactions for account: ").$_GET['act']);
17
18 page($_SESSION['page_title'], true);
19
20 include_once($path_to_root . "/includes/date_functions.inc");
21 include_once($path_to_root . "/includes/ui.inc");
22
23 include_once($path_to_root . "/gl/includes/gl_db.inc");
24
25 $js ="\n<script type='text/javascript'>\n"
26                 . "<!--\n"
27                 . " function WindowClose(amount_, date__)\n"
28                 . "{\n"
29                 . " opener.document.getElementsByName('amount')[0].value = amount_; \n"
30                 . " opener.document.getElementsByName('date_')[0].value = date__; \n"
31                 . " window.close();\n"
32                 . " return true;\n"
33                 . "}\n"
34                 . "-->\n"
35                 . "</script>\n";
36 echo $js;
37
38 if (!isset($_GET['act']) || !isset($_GET['date']))
39 { /*Script was not passed the correct parameters */
40
41         echo "<p>" . _("The script must be called with a valid transaction type and transaction number to review the general ledger postings for.") . "</p>";
42         exit;
43 }
44
45 display_heading($_SESSION['page_title']. " ".get_gl_account_name($_GET['act']));
46
47 br();
48
49 start_table(TABLESTYLE);
50 $dim = get_company_pref('use_dimension');
51
52 $first_cols = array(_("Type"), "#", _("Date"));
53 if ($dim == 2)
54         $dim_cols = array(_("Dimension")." 1", _("Dimension")." 2");
55 else if ($dim == 1)
56         $dim_cols = array(_("Dimension"));
57 else
58         $dim_cols = array();
59
60 $remaining_cols = array(_("Person/Item"), _("Debit"), _("Credit"), _("Memo"));
61
62 $th = array_merge($first_cols, $dim_cols, $remaining_cols);
63
64 table_header($th);
65 $end = $_GET['date'];
66 $account = $_GET['act'];
67 $begin = add_days($end, -$_SESSION["wa_current_user"]->prefs->transaction_days());
68
69 $result = get_gl_transactions($begin, $end, -1, $account, 0, 0, null);
70 $j = 0;
71 $k = 1;
72 while ($myrow = db_fetch($result))
73 {
74         alt_table_row_color($k);
75
76         $trandate = sql2date($myrow["tran_date"]);
77
78         label_cell($systypes_array[$myrow["type"]]);
79         $amount = price_format($myrow["amount"]);
80         $str = "<a href='#' onclick='return WindowClose(\"$amount\", \"$trandate\");' >".$myrow['type_no']."</a>";
81         label_cell($str);
82         label_cell($trandate);
83
84         if ($dim >= 1)
85                 label_cell(get_dimension_string($myrow['dimension_id'], true));
86         if ($dim > 1)
87                 label_cell(get_dimension_string($myrow['dimension2_id'], true));
88         label_cell(payment_person_name($myrow["person_type_id"],$myrow["person_id"]));
89         display_debit_or_credit_cells($myrow["amount"]);
90         label_cell($myrow['memo_']);
91         end_row();
92
93         $j++;
94         if ($j == 12)
95         {
96                 $j = 1;
97                 table_header($th);
98         }
99 }
100 //end of while loop
101
102
103 //end of while loop
104 end_table(1);
105
106 end_page(true);
107