17 require_once SQ_CORE_PACKAGE_PATH.
'/report/report_edit_fns.inc';
18 require_once SQ_FUDGE_PATH.
'/general/file_system.inc';
42 parent::__construct();
60 $am = $GLOBALS[
'SQ_SYSTEM']->am;
62 $owner = $am->getAsset($job->_running_vars[
'assetid'],
'report_asset_statuses');
64 $tables = Array(
'sq_ast a');
66 $root_link = $GLOBALS[
'SQ_SYSTEM']->am->getLink($owner->id, SQ_LINK_NOTICE,
'', FALSE,
'root');
67 if (!empty($root_link)) {
70 $bind_vars[
'root_link_minorid'] = $root_link[
'minorid'];
72 }
catch (Exception $e) {
73 throw new Exception(
'Unable to get tree id from minor id: '.$e->getMessage());
75 $where[] =
'SUBSTR(t.treeid, 1, '.strlen($parent_treeid).
') = '.
MatrixDAL::quote($parent_treeid);
76 $tables[] =
'sq_ast_lnk l';
77 $tables[] =
'sq_ast_lnk_tree t';
78 $where[] =
'l.linkid = t.linkid';
79 $where[] =
'a.assetid = l.minorid';
82 $search_status = str_replace(
'|',
', ', $owner->attr(
'search_status'));
83 if ($search_status != SQ_SC_STATUS_ALL) {
84 $where[] =
'a.status in ('.$search_status.
')';
87 $period_length = $owner->attr(
'status_change_period');
89 $operator = $owner->attr(
'status_change_comparator_more_than') ?
'<' :
'>';
90 $timestamp = time() - $period_length;
91 $where[] =
'a.status_changed '.$operator.
' '.db_extras_todate(
MatrixDAL::getDbType(), ts_iso8601($timestamp));
95 a.assetid, a.type_code, a.name, a.status, a.status_changed, a.status_changed_userid
97 '.implode(
', ', $tables).
'
99 ('.implode(
') AND (', $where).
')
105 if (empty($result)) {
106 $step_data[
'percent_done'] = 100;
107 $step_data[
'complete'] = TRUE;
108 $job->_addError(
'No assets were found matching your criteria', TRUE);
113 foreach ($result as $r) {
114 if (!empty($r[
'status_changed_userid']) && (FALSE === strpos($r[
'status_changed_userid'],
':'))) {
115 $userids[] = $r[
'status_changed_userid'];
118 $names = $GLOBALS[
'SQ_SYSTEM']->am->getAssetInfo($userids, Array(), FALSE,
'name');
119 foreach ($result as $i => $r) {
120 if (isset($names[$r[
'status_changed_userid']])) {
121 $result[$i][
'user_name'] = array_get_index($names, $r[
'status_changed_userid'],
'Unknown');
122 }
else if (!empty($r[
'status_changed_userid'])) {
123 $asset = $GLOBALS[
'SQ_SYSTEM']->am->getAsset($r[
'status_changed_userid']);
124 $result[$i][
'user_name'] = $asset->name;
126 $result[$i][
'user_name'] =
'Unknown';
131 $contents =
'<?xml version="1.0" encoding="'.SQ_CONF_DEFAULT_CHARACTER_SET.
'"?>'.
"\n";
132 $contents .=
'<asset_list>'.
"\n";
133 foreach ($result as $values) {
134 $contents .=
'<asset assetid="'.htmlSpecialChars($values[
'assetid']).
'" name="'.htmlSpecialChars($values[
'name']).
'" type_code="'.$values[
'type_code'].
'">'.
"\n";
135 $contents .=
' <status value="'.$values[
'status'].
'" changed="'.$values[
'status_changed'].
'" changed_userid="'.htmlSpecialChars($values[
'status_changed_userid']).
'" changed_user_name="'.htmlSpecialChars($values[
'user_name']).
'"/>'.
"\n";
136 $contents .=
'</asset>'.
"\n";
138 $contents .=
'</asset_list>';
140 $report_dir = $owner->data_path;
141 $xml_file_name = $report_dir.
'/report.xml';
143 if (!is_dir($report_dir)) {
144 if (!create_directory($report_dir)) {
145 trigger_localised_error(
'CORE0198', E_USER_WARNING);
151 $file_handler = fopen($xml_file_name,
'w');
152 if ($file_handler === FALSE) {
153 trigger_localised_error(
'CORE0017', E_USER_WARNING);
156 fwrite($file_handler, $contents);
157 fclose($file_handler);
159 $step_data[
'percent_done'] = 100;
160 $step_data[
'complete'] = TRUE;
162 unset($owner->_tmp[
'getAssetMapLinks']);
163 unset($owner->_tmp[
'getLinks']);
181 $write_access = $asset->writeAccess(
'attributes');
183 $comparator_attr = $asset->getAttribute(
'status_change_comparator_more_than');
184 $comparator_attr->setEditParam(
'true_text',
'more');
185 $comparator_attr->setEditParam(
'false_text',
'less');
186 $comparator_attr->paint($prefix.
'_comparator', !$write_access);
188 $comparator_attr = $asset->getAttribute(
'status_change_period');
189 $comparator_attr->paint($prefix.
'_period', !$write_access);
208 $comparator_attr = $asset->getAttribute(
'status_change_comparator_more_than');
209 $comparator_attr->process($prefix.
'_comparator');
210 $asset->setAttrValue(
'status_change_comparator_more_than', $comparator_attr->value);
211 $period_attr = $asset->getAttribute(
'status_change_period');
212 $period_attr->process($prefix.
'_period');
213 $asset->setAttrValue(
'status_change_period', $period_attr->value);
231 $am = $GLOBALS[
'SQ_SYSTEM']->am;
233 require_once SQ_INCLUDE_PATH.
'/general_occasional.inc';
234 $report_path = $asset->data_path.
'/report.xml';
236 if (!is_file($report_path)) {
237 echo
'This report has not been generated';
242 $root =
new SimpleXMLElement($report_path, LIBXML_NOCDATA, TRUE);
243 }
catch (Exception $e) {
244 throw new Exception(
'Unable to parse report file "'.$report_path.
'": '.$e->getMessage());
250 <table
class=
"sq-backend-table">
252 <th
class=
"sq-backend-table-header" style=
"width: 10ex"><?php echo translate(
'cms_reports_asset_statuses_asset_icon'); ?></th>
253 <th
class=
"sq-backend-table-header" style=
"width: 10ex"><?php echo translate(
'assetid'); ?></th>
254 <th
class=
"sq-backend-table-header"><?php echo translate(
'name'); ?></th>
255 <th
class=
"sq-backend-table-header"><?php echo translate(
'status'); ?></th>
256 <th
class=
"sq-backend-table-header"><?php echo translate(
'cms_reports_asset_statuses_last_status_change'); ?></th>
257 <th
class=
"sq-backend-table-header"><?php echo translate(
'cms_reports_asset_statuses_last_status_changer'); ?></th>
261 foreach ($root->asset as $asset_node) {
262 $assetid = (int) $asset_node->attributes()->assetid;
263 $name = (string) $asset_node->attributes()->name;
264 $type_code = (string) $asset_node->attributes()->type_code;
265 $type_icon = $am->getAssetIconURL($type_code);
267 $status = (int) $asset_node->status->attributes()->value;
268 $status_changed = (string) $asset_node->status->attributes()->changed;
269 $status_changed_userid = (int) $asset_node->status->attributes()->changed_userid;
270 $status_changed_user_name = (string) $asset_node->status->attributes()->changed_user_name;
274 <td
class=
"sq-backend-table-cell">
275 <script type=
"text/javascript">sq_print_icon(
"<?php echo $type_icon; ?>",
"16",
"16",
"");</script>
277 <td
class=
"sq-backend-table-cell">
278 <?php echo htmlspecialchars($assetid); ?>
280 <td
class=
"sq-backend-table-cell">
281 <?php echo htmlspecialchars($name); ?>
283 <td
class=
"sq-backend-table-cell">
284 <?php echo get_asset_status_icon($status); ?><?php echo get_status_description($status); ?>
286 <td
class=
"sq-backend-table-cell">
287 <?php echo $status_changed; ?>
289 <td
class=
"sq-backend-table-cell">
290 <?php echo htmlspecialchars($status_changed_user_name); ?> [<?php echo htmlspecialchars($status_changed_userid); ?>]
314 $write_access = $asset->writeAccess(
'attributes');
315 $current_statuses = explode(
'|',$asset->attr(
'search_status'));
318 $statuses = get_constant_values(
'SQ_STATUS');
320 foreach ($statuses as $constant => $value) {
321 $options[$value] = get_status_description($value);
323 combo_box($prefix.
'_statuses', $options, TRUE, $current_statuses);
325 if (empty($current_statuses)) {
326 echo translate(
'cms_listing_no_status_selected');
328 ?><ul style=
"margin: 1px 15px;"><?php
329 foreach ($current_statuses as $status) {
331 echo get_asset_status_icon($status);
332 echo get_status_description($status);
354 $new_statuses = Array();
355 if (isset($_REQUEST[$prefix.
'_statuses'])) {
356 $new_statuses = implode(
'|', $_REQUEST[$prefix.
'_statuses']);
357 $asset->setAttrValue(
'search_status', $new_statuses);