Beispiel #1
0
 public function export()
 {
     $period = SJB_Request::getVar('period', array());
     $statisticEvent = SJB_Request::getVar('filter', false);
     $listingTypeID = SJB_Request::getVar('listingTypeID', false);
     $sorting_field = SJB_Request::getVar('sorting_field', 'total');
     $sorting_order = SJB_Request::getVar('sorting_order', 'DESC');
     if (empty($statisticEvent)) {
         throw new Exception('EMPTY_PARAMETER');
     }
     $listingTypeSID = SJB_ListingTypeManager::getListingTypeSIDByID($listingTypeID);
     $statistics = SJB_Statistics::getGuestAlertsStatistics($period, $listingTypeSID, $statisticEvent, $sorting_field, $sorting_order);
     if (empty($statistics)) {
         throw new Exception('NOTHING_TO_EXPORT');
     }
     SJB_StatisticsExportController::createExportDirectory();
     $i18N = SJB_I18N::getInstance();
     $exportProperties['title'] = $i18N->gettext('Backend', 'Guest Email');
     $exportProperties['total'] = $i18N->gettext('Backend', 'Total');
     $exportProperties['percent'] = '%';
     $type = SJB_Request::getVar('type', 'csv');
     $fileName = 'guest_' . strtolower($listingTypeID . '_' . $statisticEvent) . '_statistics';
     $exportData = SJB_StatisticsExportController::getGuestAlertsExportData($statistics);
     switch ($type) {
         case 'csv':
             $ext = 'csv';
             SJB_StatisticsExportController::makeCSVExportFile($exportData, $fileName . '.' . $ext, "Guest {$listingTypeID} Alerts Statistics");
             break;
         default:
         case 'xls':
             $ext = 'xls';
             SJB_StatisticsExportController::makeXLSExportFile($exportData, $fileName . '.' . $ext, "Guest {$listingTypeID} Alerts Statistics");
             break;
     }
     SJB_StatisticsExportController::archiveAndSendExportFile($fileName, $ext);
 }