From f3a0f534ab791de5294864a39d35fc7c385347c4 Mon Sep 17 00:00:00 2001 From: Ben Klang Date: Sun, 10 Jan 2010 16:17:36 -0500 Subject: [PATCH] Operator: Paginate the CDR results --- operator/search.php | 26 +++++++++++++++++----- .../templates/{search/header.inc => search.inc} | 20 +++++++++++++++++ operator/templates/search/footer.inc | 1 - operator/templates/search/row.inc | 12 ---------- 4 files changed, 40 insertions(+), 19 deletions(-) rename operator/templates/{search/header.inc => search.inc} (50%) delete mode 100644 operator/templates/search/footer.inc delete mode 100644 operator/templates/search/row.inc diff --git a/operator/search.php b/operator/search.php index 0cda93adc..c61ba98df 100644 --- a/operator/search.php +++ b/operator/search.php @@ -27,6 +27,10 @@ if (!$vars->exists('rowstart')) { $rowstart = 0; } +if (isset($_SESSION['operator']['lastdata'])) { + $data = $_SESSION['operator']['lastdata']; +} + $form = new SearchCDRForm(_("Search Call Detail Records"), $vars); if ($form->isSubmitted() && $form->validate($vars, true)) { $accountcode = $vars->get('accountcode'); @@ -52,6 +56,7 @@ if ($form->isSubmitted() && $form->validate($vars, true)) { 'dcontext' => $vars->get('dcontext'), 'startdate' => $vars->get('startdate'), 'enddate' => $vars->get('enddate')); + $_SESSION['operator']['lastdata'] = $data; } } else { if (isset($_SESSION['operator']['lastsearch']['params'])) { @@ -61,6 +66,20 @@ if ($form->isSubmitted() && $form->validate($vars, true)) { } } +// Create the Pager UI +$page = Horde_Util::getGet('page', 1); +$pager_vars = Horde_Variables::getDefaultVariables(); +$pager_vars->set('page', $page); +$perpage = $prefs->getValue('rowsperpage'); +$pager = new Horde_Ui_Pager('page', $pager_vars, + array('num' => count($data), + 'url' => 'search.php', + 'page_count' => 10, + 'perpage' => $perpage)); + +// Limit the domain list to the current page +$data = array_slice($data, $page*$perpage, $perpage); + $title = _("Search Call Detail Records"); Horde::addScriptFile('stripe.js', 'horde', true); @@ -71,12 +90,7 @@ $form->renderActive($renderer, $vars); $columns = unserialize($prefs->getValue('columns')); if (!empty($data)) { - require OPERATOR_TEMPLATES . '/search/header.inc'; - unset($data['count'], $data['minutes'], $data['failed']); - foreach ($data as $record) { - require OPERATOR_TEMPLATES . '/search/row.inc'; - } - require OPERATOR_TEMPLATES . '/search/footer.inc'; + require OPERATOR_TEMPLATES . '/search.inc'; } require $registry->get('templates', 'horde') . '/common-footer.inc'; diff --git a/operator/templates/search/header.inc b/operator/templates/search.inc similarity index 50% rename from operator/templates/search/header.inc rename to operator/templates/search.inc index 36127b06d..ad76612f2 100644 --- a/operator/templates/search/header.inc +++ b/operator/templates/search.inc @@ -13,3 +13,23 @@ foreach ($columns as $column) { } ?> + + +\n"; + foreach ($columns as $column) { + echo ""; + if ($column == 'amaflags') { + $record[$column] = Operator::getAMAFlagName($record[$column]); + } + echo $record[$column]; + echo "\n"; + } + echo "\n"; +} +?> + + + +render(); ?> diff --git a/operator/templates/search/footer.inc b/operator/templates/search/footer.inc deleted file mode 100644 index 000ca4b01..000000000 --- a/operator/templates/search/footer.inc +++ /dev/null @@ -1 +0,0 @@ - diff --git a/operator/templates/search/row.inc b/operator/templates/search/row.inc deleted file mode 100644 index c1359d062..000000000 --- a/operator/templates/search/row.inc +++ /dev/null @@ -1,12 +0,0 @@ - -"; - if ($column == 'amaflags') { - $record[$column] = Operator::getAMAFlagName($record[$column]); - } - echo $record[$column]; - echo ""; -} -?> - -- 2.11.0