17 require_once SQ_SYSTEM_ROOT.
'/core/assets/system/simple_report/simple_report.inc';
44 parent::__construct($assetid);
68 $generated = $report[
'generated'];
69 $report = $report[
'report_data'];
72 <td class="sq-backend-table-cell">
75 <td class="sq-backend-table-cell">
78 <td class="sq-backend-table-cell" align="right">
81 <td class="sq-backend-table-cell" align="right">
84 <td class="sq-backend-table-cell" align="right">
91 $trigger_manager = $GLOBALS[
'SQ_SYSTEM']->am->getSystemAsset(
'trigger_manager');
93 foreach ($report as $key => $trigger_info) {
94 if (($key ==
'num_triggers') || ($key ==
'num_active_triggers'))
continue;
96 foreach ($trigger_info as $trigger_weighted_info) {
98 if ($trigger_weighted_info[
'active'] == 1) {
102 $rows_string .= sprintf($row_format, sq_web_path(
'lib').
'/web/images/icons/header/'.$icon.
'.png', $trigger_weighted_info[
'name'].
' (Id: '.$trigger_manager->id.
':'.$trigger_weighted_info[
'id'].
')', $trigger_weighted_info[
'events'], $trigger_weighted_info[
'conditions'], $trigger_weighted_info[
'actions']);
106 $table_format =
'<table class="sq-backend-table">
108 <th class="sq-backend-table-header">State</th>
109 <th class="sq-backend-table-header">Trigger</th>
110 <th class="sq-backend-table-header" align="right">Events</th>
111 <th class="sq-backend-table-header" align="right">Conditions</th>
112 <th class="sq-backend-table-header" align="right">Actions</th>
117 $table = sprintf($table_format, $rows_string);
123 <table
class=
"sq-backend-table">
125 if ($report[
'num_triggers'] > 0) {
128 <th
class=sq-backend-table-header
">Total Active Triggers</th>
129 <td class="sq-backend-table-cell
" align="right
"><?php echo $report['num_active_triggers']; ?></td>
132 <th class=sq-backend-table-header">Total Triggers</th>
133 <td
class=
"sq-backend-table-cell" align=
"right"><?php echo $report[
'num_triggers']; ?></td>
139 <td
class=
"sq-backend-table-cell">There are no Triggers in the system</td>
148 if (!empty($rows_string)) echo $table;
166 $trigger_report = Report_Triggers::_getTriggerInfo();
169 'generated' => $today,
170 'report_data' => $trigger_report,
186 private static function _getTriggerInfo()
189 $trigger_info_sorted = Array();
191 $num_triggers = count($trigger_info);
192 $num_active_triggers = 0;
194 foreach ($trigger_info as $trigger) {
195 $trigger_data = unserialize($trigger[
'data']);
197 $num_events = count($trigger_data[
'events']);
198 $num_conditions = count($trigger_data[
'conditions']);
199 $num_actions = count($trigger_data[
'actions']);
201 $weighting = ($num_events * 20) + ($num_conditions * 10) + $num_actions;
203 $trigger_info_sorted[$weighting][] = Array(
204 'id' => $trigger[
'id'],
205 'name' => $trigger[
'name'],
206 'events' => $num_events,
207 'conditions' => $num_conditions,
208 'actions' => $num_actions,
209 'active' => $trigger[
'active'],
212 if ($trigger[
'active']) $num_active_triggers++;
215 ksort($trigger_info_sorted);
217 $trigger_info_sorted[
'num_active_triggers'] = $num_active_triggers;
218 $trigger_info_sorted[
'num_triggers'] = $num_triggers;
220 return $trigger_info_sorted;