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 // ----------------------------------------------------------------
17 // Title: Fixed Assets Valuation
18 // ----------------------------------------------------------------
21 include_once($path_to_root . "/includes/session.inc");
22 include_once($path_to_root . "/includes/date_functions.inc");
23 include_once($path_to_root . "/includes/data_checks.inc");
24 include_once($path_to_root . "/gl/includes/gl_db.inc");
25 include_once($path_to_root . "/inventory/includes/db/items_category_db.inc");
26 include_once($path_to_root . "/fixed_assets/includes/fixed_assets_db.inc");
28 //----------------------------------------------------------------------------------------------------
30 print_fixed_assets_valuation_report();
32 //----------------------------------------------------------------------------------------------------
34 function print_fixed_assets_valuation_report()
36 global $path_to_root, $SysPrefs;
38 $date = $_POST['PARAM_0'];
39 $category = $_POST['PARAM_1'];
40 $location = $_POST['PARAM_2'];
41 $detail = $_POST['PARAM_3'];
42 $comments = $_POST['PARAM_4'];
43 $orientation = $_POST['PARAM_5'];
44 $destination = $_POST['PARAM_6'];
46 include_once($path_to_root . "/reporting/includes/excel_report.inc");
48 include_once($path_to_root . "/reporting/includes/pdf_report.inc");
50 $dec = user_price_dec();
52 $orientation = ($orientation ? 'L' : 'P');
53 if ($category == ALL_NUMERIC)
58 $cat = get_category_name($category);
60 if ($location == ALL_TEXT)
62 if ($location == 'all')
65 $loc = get_location_name($location);
67 $cols = array(0, 75, 225, 250, 350, 450, 515);
69 $headers = array(_('Class'), '', _('UOM'), _('Initial'), _('Depreciations'), _('Current'));
71 $aligns = array('left', 'left', 'left', 'right', 'right', 'right', 'right');
73 $params = array( 0 => $comments,
74 1 => array('text' => _('End Date'), 'from' => $date, 'to' => ''),
75 2 => array('text' => _('Category'), 'from' => $cat, 'to' => ''),
76 3 => array('text' => _('Location'), 'from' => $loc, 'to' => ''));
78 $rep = new FrontReport(_('Fixed Assets Valuation Report'), "FixedAssetsValReport", user_pagesize(), 9, $orientation);
79 if ($orientation == 'L')
80 recalculate_cols($cols);
82 $rep->Info($params, $cols, $headers, $aligns);
85 //$res = getTransactions($category, $location, $date);
86 $sql = get_sql_for_fixed_assets(true);
87 $res = db_query($sql,"No transactions were returned");
89 $total = $grandtotal = 0.0;
91 while ($trans=db_fetch($res))
93 if ($catt != $trans['description'])
100 $rep->TextCol(0, 4, _('Total'));
102 $rep->AmountCol(5, 6, $total, $dec);
105 $rep->Line($rep->row - 2);
111 $rep->TextCol(0, 2, $trans['description']);
112 $catt = $trans['description'];
116 $UnitCost = $trans['purchase_cost'];
117 $Depreciation = $trans['purchase_cost'] - $trans['material_cost'];;
118 $Balance = $trans['material_cost'];
122 $rep->TextCol(0, 1, $trans['stock_id']);
123 $rep->TextCol(1, 2, $trans['name'].($trans['inactive']==1 ? " ("._("Inactive").")" : ""), -1);
124 $rep->TextCol(2, 3, $trans['units']);
125 $rep->AmountCol(3, 4, $UnitCost, $dec);
126 $rep->AmountCol(4, 5, $Depreciation, $dec);
127 $rep->AmountCol(5, 6, $Balance, $dec);
130 $grandtotal += $Balance;
135 $rep->TextCol(0, 4, _('Total'));
137 $rep->Amountcol(5, 6, $total, $dec);
140 $rep->Line($rep->row - 2);
144 $rep->TextCol(0, 4, _('Grand Total'));
145 $rep->AmountCol(5, 6, $grandtotal, $dec);
146 $rep->Line($rep->row - 4);