17 require_once SQ_SYSTEM_ROOT.
'/core/assets/system/simple_report/simple_report.inc';
43 parent::__construct($assetid);
67 $generated = $report[
'generated'];
68 $report = $report[
'report_data'];
71 <td class="sq-backend-table-cell">
74 <td class="sq-backend-table-cell" align="right">
79 $current_day_assets_table =
'<table class="sq-backend-table">
81 <th class="sq-backend-table-header" width="30%%">Assets currently in the system</th>
82 <td align="right">'.$report[
'num_assets_today'].
'</td>
87 $report = $report[
'date_report'];
88 foreach ($report as $date_description => $date_data) {
89 $row_string .= sprintf($row_format, $date_description, $date_data[
'num_assets']);
92 $table_format =
'<table class="sq-backend-table">
94 <th class="sq-backend-table-header">Period</th>
95 <th class="sq-backend-table-header" width="35%%" align="right">Assets in the system</th>
100 $table = sprintf($table_format, $row_string);
103 Report_Total_Assets::_paintSystemInstallDate();
104 echo $current_day_assets_table;
124 $year = date(
'Y', $today);
125 $month = date(
'm', $today);
126 $date = date(
'd', $today);
128 $last_month = str_pad(date(
'm', $today) - 1, 2,
'0', STR_PAD_LEFT);
130 $date_yesterday = date(
'Y-m-d', $today - (24*3600));
131 $last_week_date = date(
'Y-m-d', $today - (24*3600*7));
132 $last_month_date = date(
'Y-m-d', $today - (30*24*3600));
133 $last_quarter_date = date(
'Y-m-d', $today - (90*24*3600));
134 $last_semester_date = date(
'Y-m-d', $today - (180*24*3600));
135 $last_year_date = date(
'Y-m-d', $today - (365*24*3600));
137 $date_report = Array(
138 'Yesterday' => Array(
139 'date' => $date_yesterday,
142 'Last week' => Array(
143 'date' => $last_week_date,
146 'Last month' => Array(
147 'date' => $last_month_date,
150 'Last three months' => Array(
151 'date' => $last_quarter_date,
154 'Last six months' => Array(
155 'date' => $last_semester_date,
158 'Last year' => Array(
159 'date' => $last_year_date,
164 $num_assets_today = Report_Total_Assets::_getTotalAssets();
165 $last_period = FALSE;
166 $remove_date_items = Array();
168 foreach ($date_report as $date_description => $date_data) {
170 $remove_date_items[] = $date_description;
174 $num_assets = Report_Total_Assets::_getTotalAssets($date_data[
'date']);
175 $date_report[$date_description][
'num_assets'] = $num_assets_today - $num_assets;
177 if ($date_report[$date_description][
'num_assets'] === 0) {
182 foreach ($remove_date_items as $date_description) {
183 unset($date_report[$date_description]);
187 'generated' => $today,
188 'report_data' => Array(
189 'num_assets_today' => $num_assets_today,
190 'date_report' => $date_report,
210 private static function _getTotalAssets($after_date=
'')
212 $after_date_query =
'';
213 if ($after_date !=
'') {
214 $after_date_query =
' WHERE created >= '.MatrixDAL::quote($after_date);
218 $sql =
'SELECT count(*) AS total '.
219 'FROM sq_ast'.$after_date_query;
235 private static function _paintSystemInstallDate()
237 $table_format =
'<table class="sq-backend-table">
239 <th class="sq-backend-table-header" width="30%%">System Install Date</th>
240 <td class="sq-backend-table-cell" align="right">%s</td>
244 $time = strtotime(Report_Total_Assets::_getSystemInstallDate());
245 $date = date(
'd M Y, H:i:s', $time);
247 $table = sprintf($table_format, $date);
260 private static function _getSystemInstallDate()
263 $sql =
'SELECT MIN(created)FROM sq_ast';
267 return $first_asset_date;