public function execute() { $guestAlert = new SJB_GuestAlert(array()); $guestAlert->addSubscriptionDateProperty(); $guestAlert->addStatusProperty(); $search_form_builder = new SJB_SearchFormBuilder($guestAlert); $criteria_saver = new SJB_GuestAlertCriteriaSaver(); $criteria = $search_form_builder->extractCriteriaFromRequestData($criteria_saver->getCriteria(), $guestAlert); $sortingField = SJB_Request::getVar('sorting_field', 'subscription_date'); $sortingOrder = SJB_Request::getVar('sorting_order', 'DESC'); $searcher = new SJB_GuestAlertSearcher(false, $sortingField, $sortingOrder); $foundGuestAlerts = $searcher->getObjectsSIDsByCriteria($criteria); foreach ($foundGuestAlerts as $id => $guestAlertSID) { $foundGuestAlerts[$id] = SJB_GuestAlertManager::getGuestAlertInfoBySID($guestAlertSID); } $type = SJB_Request::getVar('type', 'csv'); $fileName = 'guest_alerts_' . date('Y-m-d'); SJB_StatisticsExportController::createExportDirectory(); switch ($type) { case 'csv': $ext = 'csv'; SJB_StatisticsExportController::makeCSVExportFile($foundGuestAlerts, $fileName . '.' . $ext, 'Guest Alerts'); break; default: case 'xls': $ext = 'xls'; SJB_StatisticsExportController::makeXLSExportFile($foundGuestAlerts, $fileName . '.' . $ext, 'Guest Alerts'); break; } SJB_StatisticsExportController::archiveAndSendExportFile($fileName, $ext); }
public function showResults() { if (SJB_Request::getVar('action', '') == 'search') { $_REQUEST['restore'] = 1; } $paginator = new SJB_GuestAlertsManagePagination(); $limit = array('limit' => ($paginator->currentPage - 1) * $paginator->itemsPerPage, 'num_rows' => $paginator->itemsPerPage); $searcher = new SJB_GuestAlertSearcher($limit, $paginator->sortingField, $paginator->sortingOrder); $foundGuestAlerts = $searcher->getObjectsSIDsByCriteria($this->criteria); $this->criteriaSaver->setSession($_REQUEST, $searcher->getFoundObjectSIDs()); foreach ($foundGuestAlerts as $id => $guestAlertSID) { $foundGuestAlerts[$id] = SJB_GuestAlertManager::getGuestAlertInfoBySID($guestAlertSID); } $paginator->setItemsCount($searcher->getAffectedRows()); $this->tp->assign('paginationInfo', $paginator->getPaginationInfo()); $this->tp->assign('searchFields', $this->getSearchFieldsForTemplate()); $this->tp->assign('errors', $this->errors); $this->tp->assign('guestAlerts', $foundGuestAlerts); $this->tp->display('manage.tpl'); }