summaryrefslogtreecommitdiff
path: root/kolab.org/www/drupal-7.18/sites/all/modules/checklistapi/checklistapi.admin.inc
diff options
context:
space:
mode:
Diffstat (limited to 'kolab.org/www/drupal-7.18/sites/all/modules/checklistapi/checklistapi.admin.inc')
-rw-r--r--kolab.org/www/drupal-7.18/sites/all/modules/checklistapi/checklistapi.admin.inc56
1 files changed, 31 insertions, 25 deletions
diff --git a/kolab.org/www/drupal-7.18/sites/all/modules/checklistapi/checklistapi.admin.inc b/kolab.org/www/drupal-7.18/sites/all/modules/checklistapi/checklistapi.admin.inc
index 041612a..382e566 100644
--- a/kolab.org/www/drupal-7.18/sites/all/modules/checklistapi/checklistapi.admin.inc
+++ b/kolab.org/www/drupal-7.18/sites/all/modules/checklistapi/checklistapi.admin.inc
@@ -13,6 +13,7 @@
* @ingroup forms
*/
function checklistapi_report_form() {
+ // Define table header.
$header = array(
t('Checklist'),
t('Progress'),
@@ -20,31 +21,36 @@ function checklistapi_report_form() {
t('Last updated by'),
t('Operations'),
);
+
+ // Build table rows.
+ $rows = array();
$definitions = checklistapi_get_checklist_info();
- if (count($definitions)) {
- $rows = array();
- foreach ($definitions as $id => $definition) {
- $checklist = checklistapi_checklist_load($id);
- $row = array();
- $row[] = array(
- 'data' => ($checklist->userHasAccess()) ? l($checklist->title, $checklist->path) : drupal_placeholder($checklist->title),
- 'title' => (!empty($checklist->description)) ? $checklist->description : '',
- );
- $row[] = t('@completed of @total (@percent%) complete', array(
- '@completed' => $completed = (!empty($checklist->savedProgress['#completed_items'])) ? $checklist->savedProgress['#completed_items'] : 0,
- '@total' => $checklist->totalItems,
- '@percent' => round($completed / $checklist->totalItems * 100),
- ));
- $row[] = (!empty($checklist->savedProgress['#changed'])) ? format_date($checklist->savedProgress['#changed']) : t('n/a');
- $row[] = (isset($checklist->savedProgress['#changed_by'])) ? theme('username', array('account' => user_load($checklist->savedProgress['#changed_by']))) : t('n/a');
- $row[] = ($checklist->userHasAccess('edit') && $checklist->hasSavedProgress()) ? l(t('clear saved progress'), $checklist->path . '/clear', array(
- 'query' => array('destination' => 'admin/reports/checklistapi'),
- )) : '';
- $rows[] = $row;
- }
- }
- else {
- $rows[][] = array('data' => t('No checklists available.'), 'colspan' => 5);
+ foreach ($definitions as $id => $definition) {
+ $checklist = checklistapi_checklist_load($id);
+ $row = array();
+ $row[] = array(
+ 'data' => ($checklist->userHasAccess()) ? l($checklist->title, $checklist->path) : drupal_placeholder($checklist->title),
+ 'title' => (!empty($checklist->description)) ? $checklist->description : '',
+ );
+ $row[] = t('@completed of @total (@percent%)', array(
+ '@completed' => $checklist->getNumberCompleted(),
+ '@total' => $checklist->getNumberOfItems(),
+ '@percent' => round($checklist->getPercentComplete()),
+ ));
+ $row[] = $checklist->getLastUpdatedDate();
+ $row[] = $checklist->getLastUpdatedUser();
+ $row[] = ($checklist->userHasAccess('edit') && $checklist->hasSavedProgress()) ? l(t('clear saved progress'), $checklist->path . '/clear', array(
+ 'query' => array('destination' => 'admin/reports/checklistapi'),
+ )) : '';
+ $rows[] = $row;
}
- return theme('table', array('header' => $header, 'rows' => $rows));
+
+ // Compile table.
+ $table = array(
+ 'header' => $header,
+ 'rows' => $rows,
+ 'empty' => t('No checklists available.'),
+ );
+
+ return theme('table', $table);
}