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");
27 include_once($path_to_root . "/fixed_assets/includes/fa_classes_db.inc");
29 //----------------------------------------------------------------------------------------------------
31 print_fixed_assets_valuation_report();
33 //----------------------------------------------------------------------------------------------------
35 function print_fixed_assets_valuation_report()
37 global $path_to_root, $SysPrefs;
39 $date = $_POST['PARAM_0'];
40 $class = $_POST['PARAM_1'];
41 $location = $_POST['PARAM_2'];
42 $detail = $_POST['PARAM_3'];
43 $comments = $_POST['PARAM_4'];
44 $orientation = $_POST['PARAM_5'];
45 $destination = $_POST['PARAM_6'];
47 include_once($path_to_root . "/reporting/includes/excel_report.inc");
49 include_once($path_to_root . "/reporting/includes/pdf_report.inc");
51 $dec = user_price_dec();
53 $orientation = ($orientation ? 'L' : 'P');
54 if ($class == ALL_NUMERIC)
59 $cln = get_fixed_asset_classname($class);
61 if ($location == ALL_TEXT)
63 if ($location == 'all')
66 $loc = get_location_name($location);
68 $cols = array(0, 75, 225, 250, 350, 450, 515);
70 $headers = array(_('Class'), '', _('UOM'), _('Initial'), _('Depreciations'), _('Current'));
72 $aligns = array('left', 'left', 'left', 'right', 'right', 'right', 'right');
74 $params = array( 0 => $comments,
75 1 => array('text' => _('End Date'), 'from' => $date, 'to' => ''),
76 2 => array('text' => _('Class'), 'from' => $cln, 'to' => ''),
77 3 => array('text' => _('Location'), 'from' => $loc, 'to' => ''));
79 $rep = new FrontReport(_('Fixed Assets Valuation Report'), "FixedAssetsValReport", user_pagesize(), 9, $orientation);
80 if ($orientation == 'L')
81 recalculate_cols($cols);
83 $rep->Info($params, $cols, $headers, $aligns);
86 //$res = getTransactions($category, $location, $date);
87 $sql = get_sql_for_fixed_assets(true);
88 $res = db_query($sql,"No transactions were returned");
90 $total = $grandtotal = 0.0;
92 while ($trans=db_fetch($res))
94 $d = sql2date($trans['purchase_date']);
95 if (date1_greater_date2($d, $date))
97 if ($class != 0 && $cln != $trans['description'])
99 if ($catt != $trans['description'])
106 $rep->TextCol(0, 4, _('Total'));
108 $rep->AmountCol(5, 6, $total, $dec);
111 $rep->Line($rep->row - 2);
117 $rep->TextCol(0, 2, $trans['description']);
118 $catt = $trans['description'];
122 $UnitCost = $trans['purchase_cost'];
123 $Depreciation = $trans['purchase_cost'] - $trans['material_cost'];;
124 $Balance = $trans['material_cost'];
128 $rep->TextCol(0, 1, $trans['stock_id']);
129 $rep->TextCol(1, 2, $trans['name'].($trans['inactive']==1 ? " ("._("Inactive").")" : ""), -1);
130 $rep->TextCol(2, 3, $trans['units']);
131 $rep->AmountCol(3, 4, $UnitCost, $dec);
132 $rep->AmountCol(4, 5, $Depreciation, $dec);
133 $rep->AmountCol(5, 6, $Balance, $dec);
136 $grandtotal += $Balance;
141 $rep->TextCol(0, 4, _('Total'));
143 $rep->Amountcol(5, 6, $total, $dec);
146 $rep->Line($rep->row - 2);
150 $rep->TextCol(0, 4, _('Grand Total'));
151 $rep->AmountCol(5, 6, $grandtotal, $dec);
152 $rep->Line($rep->row - 4);