Cleanups (fixed obscure numeric references to some sql helpers results).
[fa-stable.git] / dimensions / view / view_dimension.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_DIMTRANSVIEW';
13 $path_to_root = "../..";
14
15 include_once($path_to_root . "/includes/session.inc");
16
17 $js = "";
18 if (user_use_date_picker())
19         $js .= get_js_date_picker();
20 page(_($help_context = "View Dimension"), true, false, "", $js);
21
22 include_once($path_to_root . "/includes/date_functions.inc");
23 include_once($path_to_root . "/includes/data_checks.inc");
24
25 include_once($path_to_root . "/dimensions/includes/dimensions_db.inc");
26 include_once($path_to_root . "/dimensions/includes/dimensions_ui.inc");
27
28 //-------------------------------------------------------------------------------------------------
29
30 if (isset($_GET['trans_no']) && $_GET['trans_no'] != "")
31 {
32         $id = $_GET['trans_no'];
33 }
34
35 if (isset($_POST['Show']))
36 {
37         $id = $_POST['trans_no'];
38         $Ajax->activate('_page_body');
39 }
40
41
42 display_heading($systypes_array[ST_DIMENSION] . " # " . $id);
43
44 br(1);
45 $myrow = get_dimension($id, true);
46
47 if ($myrow == false)
48 {
49         echo _("The dimension number sent is not valid.");
50     exit;
51 }
52
53 start_table(TABLESTYLE);
54
55 $th = array(_("#"), _("Reference"), _("Name"), _("Type"), _("Date"), _("Due Date"));
56 table_header($th);
57
58 start_row();
59 label_cell($myrow["id"]);
60 label_cell($myrow["reference"]);
61 label_cell($myrow["name"]);
62 label_cell($myrow["type_"]);
63 label_cell(sql2date($myrow["date_"]));
64 label_cell(sql2date($myrow["due_date"]));
65 end_row();
66
67 comments_display_row(ST_DIMENSION, $id);
68
69 end_table();
70
71 if ($myrow["closed"] == true)
72 {
73         display_note(_("This dimension is closed."));
74 }
75
76 start_form();
77
78 start_table(TABLESTYLE_NOBORDER);
79 start_row();
80
81 if (!isset($_POST['TransFromDate']))
82         $_POST['TransFromDate'] = begin_fiscalyear();
83 if (!isset($_POST['TransToDate']))
84         $_POST['TransToDate'] = Today();
85 date_cells(_("from:"), 'TransFromDate');
86 date_cells(_("to:"), 'TransToDate');
87 submit_cells('Show',_("Show"), '', false, 'default');
88
89 end_row();
90
91 end_table();
92 hidden('trans_no', $id);
93 end_form();
94
95 display_dimension_balance($id, $_POST['TransFromDate'], $_POST['TransToDate']);
96
97 br(1);
98
99 end_page(true, false, false, ST_DIMENSION, $id);
100