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_asset_rollback_table =
'<br /><table class="sq-backend-table">
81 <th class="sq-backend-table-header" width="45%%">Rollback asset entries currently in the system</th>
82 <td align="right">'.$report[
'num_asset_rb_entries_today'].
'</td>
86 $current_link_rollback_table =
'<br /><table class="sq-backend-table">
88 <th class="sq-backend-table-header" width="45%%">Rollback link entries currently in the system</th>
89 <td align="right">'.$report[
'num_link_rb_entries_today'].
'</td>
94 $asset_report = $report[
'asset_date_report'];
95 foreach ($asset_report as $date_description => $date_data) {
96 $row_string .= sprintf($row_format, $date_description, $date_data[
'num_assets']);
99 $table_format =
'<table class="sq-backend-table">
101 <th class="sq-backend-table-header">Period</th>
102 <th class="sq-backend-table-header" width="35%%" align="right">Rollback %s entries in the system</th>
107 $asset_report_table = sprintf($table_format,
'asset', $row_string);
110 $link_report = $report[
'link_date_report'];
111 foreach ($link_report as $date_description => $date_data) {
112 $row_string .= sprintf($row_format, $date_description, $date_data[
'num_assets']);
115 $link_report_table = sprintf($table_format,
'link', $row_string);
117 $am = $GLOBALS[
'SQ_SYSTEM']->am;
119 $table_format =
'<table class="sq-backend-table">
121 <th class="sq-backend-table-header">Icon</th>
122 <th class="sq-backend-table-header">Asset ID</th>
123 <th class="sq-backend-table-header">Name</th>
124 <th class="sq-backend-table-header">First Rollback Entry</th>
125 <th class="sq-backend-table-header">Last Rollback Entry</th>
126 <th class="sq-backend-table-header">Total Entries</th>
132 <td class="sq-backend-table-cell">
135 <td class="sq-backend-table-cell">
138 <td class="sq-backend-table-cell">
141 <td class="sq-backend-table-cell">
144 <td class="sq-backend-table-cell">
147 <td class="sq-backend-table-cell" align="right">
154 $most_asset_rollback_entries_report = $report[
'most_asset_rb_entries_report'];
155 foreach ($most_asset_rollback_entries_report as $asset_data) {
156 $row_string .= sprintf($row_format, $am->getAssetIconURL($asset_data[
'type_code']), $asset_data[
'assetid'],
157 $asset_data[
'name'], $asset_data[
'first_rb_entry'], $asset_data[
'last_rb_entry'],
158 $asset_data[
'total']);
161 $most_asset_rollback_entries_table = sprintf($table_format, $row_string);
166 echo
'<br />'.$current_asset_rollback_table;
167 echo $asset_report_table;
169 if (!empty($rows_string)) {
170 echo $most_asset_rollback_entries_table;
173 echo
'<br />'.$current_link_rollback_table;
174 echo $link_report_table;
193 $year = date(
'Y', $today);
194 $month = date(
'm', $today);
195 $date = date(
'd', $today);
197 $last_month = str_pad(date(
'm', $today) - 1, 2,
'0', STR_PAD_LEFT);
199 $date_yesterday = date(
'Y-m-d', $today - (24*3600));
200 $last_week_date = date(
'Y-m-d', $today - (24*3600*7));
201 $last_month_date = date(
'Y-m-d', $today - (30*24*3600));
202 $last_quarter_date = date(
'Y-m-d', $today - (90*24*3600));
203 $last_semester_date = date(
'Y-m-d', $today - (180*24*3600));
204 $last_year_date = date(
'Y-m-d', $today - (365*24*3600));
206 $asset_date_report = Array(
207 'Yesterday' => Array(
208 'date' => $date_yesterday,
211 'Last week' => Array(
212 'date' => $last_week_date,
215 'Last month' => Array(
216 'date' => $last_month_date,
219 'Last three months' => Array(
220 'date' => $last_quarter_date,
223 'Last six months' => Array(
224 'date' => $last_semester_date,
227 'Last year' => Array(
228 'date' => $last_year_date,
233 $link_date_report = $asset_date_report;
235 $assets_since_last_period = Array();
237 $num_asset_rb_entries_today = Report_Rollback::_getTotalAssetRollbackEntries();
238 $num_link_rb_entries_today = Report_Rollback::_getTotalLinkRollbackEntries();
243 $remove_date_entries = Array();
244 foreach ($asset_date_report as $date_description => $date_data) {
245 if ($last_period == 1) {
247 }
else if ($last_period > 1) {
248 $remove_date_entries[] = $date_description;
252 $num_assets = Report_Rollback::_getTotalAssetRollbackEntries($date_data[
'date']);
253 $asset_date_report[$date_description][
'num_assets'] = $num_asset_rb_entries_today - $num_assets;
254 $total += $asset_date_report[$date_description][
'num_assets'];
255 if ($total == $num_asset_rb_entries_today) {
260 foreach ($remove_date_entries as $date_description) {
261 unset($asset_date_report[$date_description]);
268 $remove_date_entries = Array();
269 foreach ($link_date_report as $date_description => $date_data) {
270 if ($last_period == 1) {
272 }
else if ($last_period > 1) {
273 $remove_date_entries[] = $date_description;
277 $num_assets = Report_Rollback::_getTotalLinkRollbackEntries($date_data[
'date']);
278 $link_date_report[$date_description][
'num_assets'] = $num_link_rb_entries_today - $num_assets;
279 $total += $link_date_report[$date_description][
'num_assets'];
280 if ($total == $num_link_rb_entries_today) {
285 foreach ($remove_date_entries as $date_description) {
286 unset($link_date_report[$date_description]);
291 $most_asset_rb_entries_report = Report_Rollback::_getMostAssetRollbackEntries();
294 'generated' => $today,
295 'report_data' => Array(
296 'num_asset_rb_entries_today' => $num_asset_rb_entries_today,
297 'num_link_rb_entries_today' => $num_link_rb_entries_today,
298 'asset_date_report' => $asset_date_report,
299 'link_date_report' => $link_date_report,
300 'most_asset_rb_entries_report' => $most_asset_rb_entries_report,
318 private static function _getMostAssetRollbackEntries()
321 $sql =
'SELECT r.assetid, a.name, a.type_code, MIN(r.sq_eff_from) AS first_rb_entry, MAX(r.sq_eff_to) AS last_rb_entry, '.
322 'COUNT(*) AS total '.
323 'FROM sq_rb_ast r, sq_ast a '.
324 'WHERE a.assetid = r.assetid '.
325 'GROUP BY r.assetid, a.name, a.type_code '.
326 'ORDER BY total DESC, first_rb_entry DESC, last_rb_entry DESC';
343 private static function _getTotalAssetRollbackEntries($after_date=
'')
345 $after_date_query =
'';
346 if ($after_date !=
'') {
347 $after_date_query =
' WHERE sq_eff_from >= '.MatrixDAL::quote($after_date);
351 $sql =
'SELECT COUNT(*) AS total '.
352 'FROM sq_rb_ast'.$after_date_query;
368 private static function _getTotalLinkRollbackEntries($after_date=
'')
370 $after_date_query =
'';
371 if ($after_date !=
'') {
372 $after_date_query =
' WHERE sq_eff_from >= '.MatrixDAL::quote($after_date);
376 $sql =
'SELECT COUNT(*) AS total '.
377 'FROM sq_rb_ast_lnk'.$after_date_query;