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_ASSETSANALYTIC';
13 $path_to_root = "../..";
14 include($path_to_root . "/includes/db_pager.inc");
15 include($path_to_root . "/includes/session.inc");
17 include($path_to_root . "/purchasing/includes/purchasing_ui.inc");
18 include($path_to_root . "/reporting/includes/reporting.inc");
19 include($path_to_root . "/fixed_assets/includes/fixed_assets_db.inc");
22 if ($SysPrefs->use_popup_windows)
23 $js .= get_js_open_window(900, 500);
24 if (user_use_date_picker())
25 $js .= get_js_date_picker();
26 page(_($help_context = "Fixed Assets Inquiry"), false, false, "", $js);
28 if (isset($_GET['location']))
30 $_POST['location'] = $_GET['location'];
33 //------------------------------------------------------------------------------------------------
37 start_table(TABLESTYLE_NOBORDER);
39 //locations_list_cells(_("From Location:"), 'location', null, false, false, true);
40 check_cells( _("Show inactive:"), 'show_inactive', null);
41 submit_cells('RefreshInquiry', _("Search"),'',_('Refresh Inquiry'), 'default');
46 //------------------------------------------------------------------------------------------------
48 if(get_post('RefreshInquiry'))
50 $Ajax->activate('totals_tbl');
53 function gl_view($row)
55 $row = get_fixed_asset_move($row['stock_id'], ST_JOURNAL);
60 //return get_journal_trans_view_str(ST_JOURNAL, $row["trans_no"], sql2date($row["tran_date"]));
61 return get_gl_view_str(ST_JOURNAL, $row["trans_no"]);
64 function fa_link($row)
66 $url = "inventory/manage/items.php?FixedAsset=1&stock_id=".$row['stock_id'];
68 return viewer_link($row['stock_id'], $url);
71 function depr_method_title($row) {
72 global $depreciation_methods;
73 return $depreciation_methods[$row['depreciation_method']];
76 function depr_par($row) {
77 if ($row['depreciation_method'] == 'D')
78 return $row['depreciation_rate']*$row['depreciation_factor'].'%';
79 elseif ($row['depreciation_method'] == 'N')
80 return $row['depreciation_rate'].' '._('years'
83 return $row['depreciation_rate'].'%';
86 function status_title($row) {
88 if ($row['inactive'] || ($row['disposal_date'] !== NULL))
89 return _("Disposed"); // disposed or saled
90 elseif ($row['purchase_date'] === NULL)
91 return _("Purchasable"); // not yet purchased
93 return _("Active"); // purchased
97 function purchase_link($row)
100 if ($row['purchase_date'] === null)
103 return get_supplier_trans_view_str(ST_SUPPRECEIVE, $row["purchase_no"], sql2date($row["purchase_date"]));
106 function disposal_link($row)
108 switch ($row['disposal_type']) {
110 return get_inventory_trans_view_str(ST_INVADJUST, $row["disposal_no"], sql2date($row["disposal_date"]));
111 case ST_CUSTDELIVERY:
112 return get_customer_trans_view_str(ST_CUSTDELIVERY, $row["disposal_no"], sql2date($row["disposal_date"]));
118 function amount_link($row)
120 return price_format($row['purchase_cost']);
123 function depr_link($row)
125 return price_format($row['purchase_cost'] - $row['material_cost']);
128 function balance_link($row)
130 return price_format($row['material_cost']);
134 //------------------------------------------------------------------------------------------------
136 $sql = get_sql_for_fixed_assets(get_post('show_inactive'));
139 //_("Type") => array('fun'=>'systype_name', 'ord'=>''),
140 //_("#") => array('fun'=>'trans_view', 'ord'=>''),
141 _("#") => array('fun' => 'fa_link'),
143 _("UOM") => array('align' => 'center'),
145 _("Rate or Lifecycle") => array('fun' => 'depr_par'),
146 _("Method") => array('fun' => 'depr_method_title'),
147 _("Status") => array('fun' => 'status_title'),
148 _("Purchased") => array('fun' => 'purchase_link'),
149 _("Initial") => array('align'=>'right', 'fun' => 'amount_link'),
150 _("Depreciations") => array('align'=>'right', 'fun' => 'depr_link'),
151 _("Current") => array('align'=>'right', 'fun' => 'balance_link'),
152 _("Liquidation or Sale") => array('align' => 'center', 'fun' => 'disposal_link'),
153 //array('insert'=>true, 'fun'=>'gl_view'),
154 //array('insert'=>true, 'fun'=>'rm_link'),
155 //array('insert'=>true, 'fun'=>'edit_link'),
156 //array('insert'=>true, 'fun'=>'prt_link'),
159 //------------------------------------------------------------------------------------------------
161 /*show a table of the transactions returned by the sql */
162 $table =& new_db_pager('fixed_assets_tbl', $sql, $cols);
164 $table->width = "85%";
166 display_db_pager($table);