Exemplo n.º 1
0
 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);
 }
Exemplo n.º 2
0
 public function execute()
 {
     $tp = SJB_System::getTemplateProcessor();
     $action = SJB_Request::getVar('action', 'search');
     $filter = SJB_Request::getVar('filter', array());
     $template = SJB_Request::getVar('template', 'general_statistics.tpl');
     $errors = array();
     switch ($action) {
         case 'export':
             $period = SJB_Request::getVar('period', false);
             $groupBy = SJB_Request::getVar('group_by', 'day');
             $statistics = SJB_Statistics::getGeneralStatistics($period, $groupBy, $filter);
             if (!empty($statistics['errors'])) {
                 $errors[] = $statistics['errors'];
             }
             if (!$errors && $statistics) {
                 $type = SJB_Request::getVar('type', 'csv');
                 $listingTypes = SJB_ListingTypeManager::getListingAllTypesForListType();
                 $userGroups = SJB_UserGroupManager::getAllUserGroupsIDsAndCaptions();
                 SJB_StatisticsExportController::createExportDirectory();
                 switch ($type) {
                     case 'csv':
                         $exportData = SJB_StatisticsExportController::getGeneralExportData($statistics, $userGroups, $listingTypes, $filter);
                         $fileName = 'general_statistics.csv';
                         SJB_StatisticsExportController::makeCSVExportFile($exportData, $fileName, 'General Statistics');
                         SJB_StatisticsExportController::archiveAndSendExportFile('general_statistics', 'csv');
                         break;
                     case 'xls':
                         $exportData = SJB_StatisticsExportController::getGeneralExportData($statistics, $userGroups, $listingTypes, $filter);
                         $fileName = 'general_statistics.xls';
                         SJB_StatisticsExportController::makeXLSExportFile($exportData, $fileName, 'General Statistics');
                         SJB_StatisticsExportController::archiveAndSendExportFile('general_statistics', 'xls');
                         break;
                 }
                 break;
             }
         case 'search':
             $search = SJB_Request::getVar('search', false);
             $period = SJB_Request::getVar('period', false);
             $groupBy = SJB_Request::getVar('group_by', 'day');
             $statistics = array();
             if ($search) {
                 $i18n = SJB_I18N::getInstance();
                 $from = $i18n->getInput('date', $period['from']);
                 $to = $i18n->getInput('date', $period['to']);
                 if (!empty($period['from']) && !empty($period['to']) && strtotime($from) > strtotime($to)) {
                     $errors[] = 'SELECTED_PERIOD_IS_INCORRECT';
                 } else {
                     if (count($filter) > 1) {
                         $statistics = SJB_Statistics::getGeneralStatistics($period, $groupBy, $filter);
                         if (!empty($statistics['errors'])) {
                             $errors[] = $statistics['errors'];
                         }
                     } else {
                         $errors[] = 'EMPTY_PARAMETER';
                     }
                 }
             }
             $listingTypes = SJB_ListingTypeManager::getListingAllTypesForListType();
             $userGroups = SJB_UserGroupManager::getAllUserGroupsIDsAndCaptions();
             $listPlugins = SJB_PluginManager::getAllPluginsList();
             $tp->assign('listPlugins', $listPlugins);
             $tp->assign('countItems', count($statistics) + 2);
             $tp->assign('userGroups', $userGroups);
             $tp->assign('listingTypes', $listingTypes);
             $tp->assign('errors', $errors);
             $tp->assign('groupBy', $groupBy);
             $tp->assign('statistics', $statistics);
             $tp->assign('period', $period);
             break;
     }
     $tp->assign('filter', $filter);
     $tp->assign('action', $action);
     $tp->display($template);
 }
Exemplo n.º 3
0
 public function execute()
 {
     $tp = SJB_System::getTemplateProcessor();
     $action = SJB_Request::getVar('action', 'search');
     $template = SJB_Request::getVar('template', 'listings_statistics.tpl');
     $errors = array();
     $userGroups = SJB_UserGroupManager::getAllUserGroupsIDsAndCaptions();
     foreach ($userGroups as $key => $userGroup) {
         unset($userGroups[$key]);
         $userGroups[$userGroup['id']] = $userGroup;
     }
     switch ($action) {
         case 'export':
             $period = SJB_Request::getVar('period', array());
             $filter = SJB_Request::getVar('filter', false);
             $listingTypeSID = SJB_Request::getVar('listingTypeSID', false);
             $listingTypeID = SJB_ListingTypeManager::getListingTypeIDBySID($listingTypeSID);
             $sorting_field = SJB_Request::getVar('sorting_field', 'total');
             $sorting_order = SJB_Request::getVar('sorting_order', 'DESC');
             $statistics = array();
             if ($filter) {
                 $statistics = SJB_Statistics::getListingsStatistics($period, $listingTypeSID, $filter, $sorting_field, $sorting_order);
                 if (!empty($statistics['errors'])) {
                     $errors = $statistics['errors'];
                 }
             } else {
                 $errors[] = 'EMPTY_PARAMETER';
             }
             $columnTitle = '';
             if (strstr($filter, 'userGroup_')) {
                 $userGroupSID = str_replace('userGroup_', '', $filter);
                 if ($userGroups[$userGroupSID]['key'] == 'Employer') {
                     $columnTitle = 'Company Name';
                 } else {
                     $columnTitle = $userGroups[$userGroupSID]['caption'] . ' Name';
                 }
             } else {
                 $fieldInfo = SJB_ListingFieldDBManager::getListingFieldInfoByID($filter);
                 $columnTitle = $fieldInfo['caption'];
             }
             if (!$errors && $statistics) {
                 $type = SJB_Request::getVar('type', 'csv');
                 $listingTypes = SJB_ListingTypeManager::getListingAllTypesForListType();
                 SJB_StatisticsExportController::createExportDirectory();
                 $exportProperties['title'] = $columnTitle;
                 $exportProperties['regular'] = '';
                 if ($listingTypeID == 'Job') {
                     $exportProperties['featured'] = '';
                 }
                 $exportProperties['priority'] = '';
                 $exportProperties['total'] = 'Total';
                 $exportProperties['percent'] = '%';
                 foreach ($listingTypes as $listingType) {
                     if ($listingType['id'] == $listingTypeSID) {
                         switch ($listingType['key']) {
                             case 'Job':
                                 $featuredTitle = "Number of Featured {$listingType['key']}s Posted";
                                 $exportProperties['featured'] = $featuredTitle;
                             case 'Resume':
                                 $regularTitle = "Number of Regular {$listingType['key']}s Posted";
                                 $exportProperties['regular'] = $regularTitle;
                                 $priorityTitle = "Number of Priority {$listingType['key']}s Posted";
                                 $exportProperties['priority'] = $priorityTitle;
                                 break;
                             default:
                                 $regularTitle = 'Number of Regular "' . $listingType['caption'] . '" Listings Posted';
                                 $exportProperties['regular'] = $regularTitle;
                                 $priorityTitle = 'Number of Priority "' . $listingType['caption'] . '" Listings Posted';
                                 $exportProperties['priority'] = $priorityTitle;
                                 break;
                         }
                     }
                 }
                 switch ($type) {
                     case 'csv':
                         $exportData = SJB_StatisticsExportController::getListingExportData($statistics, $listingTypeID);
                         $fileName = strtolower($listingTypeID) . '_statistics.csv';
                         SJB_StatisticsExportController::makeCSVExportFile($exportData, $fileName, "{$listingTypeID} Statistics");
                         SJB_StatisticsExportController::archiveAndSendExportFile(strtolower($listingTypeID) . '_statistics', 'csv');
                         break;
                     case 'xls':
                         $exportData = SJB_StatisticsExportController::getListingExportData($statistics, $listingTypeID);
                         $fileName = strtolower($listingTypeID) . '_statistics.xls';
                         SJB_StatisticsExportController::makeXLSExportFile($exportData, $fileName, "{$listingTypeID} Statistics");
                         SJB_StatisticsExportController::archiveAndSendExportFile(strtolower($listingTypeID) . '_statistics', 'xls');
                         break;
                 }
                 break;
             }
         case 'search':
             $search = SJB_Request::getVar('search', false);
             $period = SJB_Request::getVar('period', array());
             $filter = SJB_Request::getVar('filter', false);
             $listingTypeSID = SJB_Request::getVar('listingTypeSID', false);
             $sorting_field = SJB_Request::getVar('sorting_field', 'total');
             $sorting_order = SJB_Request::getVar('sorting_order', 'DESC');
             $statistics = array();
             if ($search) {
                 $i18n = SJB_I18N::getInstance();
                 $from = $i18n->getInput('date', $period['from']);
                 $to = $i18n->getInput('date', $period['to']);
                 if (!empty($period['from']) && !empty($period['to']) && strtotime($from) > strtotime($to)) {
                     $errors[] = 'SELECTED_PERIOD_IS_INCORRECT';
                 } else {
                     if ($filter) {
                         $statistics = SJB_Statistics::getListingsStatistics($period, $listingTypeSID, $filter, $sorting_field, $sorting_order);
                         if (!empty($statistics['errors'])) {
                             $errors = $statistics['errors'];
                         }
                     } else {
                         $errors[] = 'EMPTY_PARAMETER';
                     }
                 }
             }
             $columnTitle = '';
             if (strstr($filter, 'userGroup_')) {
                 $userGroupSID = str_replace('userGroup_', '', $filter);
                 if ($userGroups[$userGroupSID]['key'] == 'Employer') {
                     $columnTitle = 'Company Name';
                 } else {
                     $columnTitle = $userGroups[$userGroupSID]['caption'] . ' Name';
                 }
                 $tp->assign('link', 'user');
             } else {
                 if (in_array($filter, array('Location_Country', 'Location_State', 'Location_City'))) {
                     $fieldInfo = SJB_ListingFieldDBManager::getLocationFieldsInfoById($filter);
                 } else {
                     $fieldInfo = SJB_ListingFieldDBManager::getListingFieldInfoByID($filter);
                 }
                 $columnTitle = $fieldInfo['caption'];
             }
             $i18n = SJB_I18N::getInstance();
             $periodView = array();
             foreach ($period as $key => $value) {
                 $periodView[$key] = $i18n->getInput('date', $period[$key]);
             }
             $tp->assign('filter', $filter);
             $tp->assign('search', $search);
             $tp->assign('columnTitle', $columnTitle);
             $tp->assign('listingTypeSID', $listingTypeSID);
             $tp->assign('period', $period);
             $tp->assign('periodView', $periodView);
             $tp->assign('statistics', $statistics);
             $tp->assign('countResult', count($statistics));
             $tp->assign('sorting_field', $sorting_field);
             $tp->assign('sorting_order', $sorting_order);
             break;
     }
     $listingTypes = SJB_ListingTypeManager::getListingAllTypesForListType();
     $products = SJB_ProductsManager::getAllProductsInfo();
     $acl = SJB_Acl::getInstance();
     foreach ($listingTypes as $key => $listingType) {
         $userGroup = array();
         foreach ($products as $productInfo) {
             if ($acl->isAllowed('post_' . strtolower($listingType['key']), $productInfo['sid'], 'product') && !in_array($productInfo['user_group_sid'], $userGroup)) {
                 $userGroup[] = $productInfo['user_group_sid'];
             }
         }
         $listingTypes[$listingType['id']] = $listingType;
         $listingTypes[$listingType['id']]['userGroups'] = $userGroup;
         unset($listingTypes[$key]);
     }
     $tp->assign('userGroups', $userGroups);
     $tp->assign('listingTypes', $listingTypes);
     $tp->assign('errors', $errors);
     $tp->assign('action', $action);
     $tp->display($template);
 }
Exemplo n.º 4
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);
 }
Exemplo n.º 5
0
 public function execute()
 {
     $tp = SJB_System::getTemplateProcessor();
     $action = SJB_Request::getVar('action', 'search');
     $template = SJB_Request::getVar('template', 'sales.tpl');
     $errors = array();
     $userGroups = SJB_UserGroupManager::getAllUserGroupsIDsAndCaptions();
     foreach ($userGroups as $key => $userGroup) {
         unset($userGroups[$key]);
         $userGroups[$userGroup['id']] = $userGroup;
     }
     switch ($action) {
         case 'export':
             $period = SJB_Request::getVar('period', array());
             $filter = SJB_Request::getVar('filter', false);
             $sorting_field = SJB_Request::getVar('sorting_field', 'total');
             $sorting_order = SJB_Request::getVar('sorting_order', 'DESC');
             $statistics = array();
             if ($filter) {
                 $statistics = SJB_Statistics::getSalesStatistics($period, $filter, $sorting_field, $sorting_order);
                 if (!empty($statistics['errors'])) {
                     $errors = $statistics['errors'];
                 }
             } else {
                 $errors[] = 'EMPTY_PARAMETER';
             }
             $columnTitle = '';
             if (strstr($filter, 'userGroup_')) {
                 $userGroupSID = str_replace('userGroup_', '', $filter);
                 if ($userGroups[$userGroupSID]['key'] == 'Employer') {
                     $columnTitle = 'Company Name';
                 } else {
                     $columnTitle = $userGroups[$userGroupSID]['caption'] . ' Name';
                 }
                 $exportProperties['generalColumn'] = $columnTitle;
             } elseif ($filter == 'sid') {
                 $columnTitle = 'Product Name';
                 $exportProperties['generalColumn'] = 'Product Name';
                 $exportProperties['product_type'] = 'Product Type';
                 $tp->assign('link', 'product');
             } else {
                 $fieldInfo = SJB_ListingFieldDBManager::getListingFieldInfoByID($filter);
                 $exportProperties['generalColumn'] = $fieldInfo['caption'];
             }
             $exportProperties['units_sold'] = 'Units Sold';
             $exportProperties['total'] = 'Income';
             $exportProperties['percent'] = '%';
             if (!$errors && $statistics) {
                 $type = SJB_Request::getVar('type', 'csv');
                 SJB_StatisticsExportController::createExportDirectory();
                 switch ($type) {
                     case 'csv':
                         $exportData = SJB_StatisticsExportController::getSalesExportData($statistics, $exportProperties);
                         $fileName = 'sales.csv';
                         SJB_StatisticsExportController::makeCSVExportFile($exportData, $fileName, 'App & Views');
                         SJB_StatisticsExportController::archiveAndSendExportFile('sales', 'csv');
                         break;
                     case 'xls':
                         $exportData = SJB_StatisticsExportController::getSalesExportData($statistics, $exportProperties);
                         $fileName = 'sales.xls';
                         SJB_StatisticsExportController::makeXLSExportFile($exportData, $fileName, 'App & Views');
                         SJB_StatisticsExportController::archiveAndSendExportFile('sales', 'xls');
                         break;
                 }
                 break;
             }
         case 'search':
             $search = SJB_Request::getVar('search', false);
             $period = SJB_Request::getVar('period', array());
             $filter = SJB_Request::getVar('filter', false);
             $sorting_field = SJB_Request::getVar('sorting_field', 'total');
             $sorting_order = SJB_Request::getVar('sorting_order', 'DESC');
             $statistics = array();
             if ($search) {
                 if (!empty($period['from']) && !empty($period['to']) && strtotime($period['from']) > strtotime($period['to'])) {
                     $errors[] = 'SELECTED_PERIOD_IS_INCORRECT';
                 } else {
                     if ($filter) {
                         $statistics = SJB_Statistics::getSalesStatistics($period, $filter, $sorting_field, $sorting_order);
                         if (!empty($statistics['errors'])) {
                             $errors = $statistics['errors'];
                         }
                     } else {
                         $errors[] = 'EMPTY_PARAMETER';
                     }
                 }
             }
             $columnTitle = '';
             if (strstr($filter, 'userGroup_')) {
                 $userGroupSID = str_replace('userGroup_', '', $filter);
                 if ($userGroups[$userGroupSID]['key'] == 'Employer') {
                     $columnTitle = 'Company Name';
                 } else {
                     $columnTitle = $userGroups[$userGroupSID]['caption'] . ' Name';
                 }
                 $tp->assign('link', 'user');
             } else {
                 if ($filter == 'sid') {
                     $columnTitle = 'Product Name';
                     $tp->assign('link', 'product');
                 } else {
                     if (in_array($filter, array('Location_Country', 'Location_State', 'Location_City'))) {
                         $fieldInfo = SJB_ListingFieldDBManager::getLocationFieldsInfoById($filter);
                     } else {
                         $fieldInfo = SJB_ListingFieldDBManager::getListingFieldInfoByID($filter);
                     }
                     $columnTitle = $fieldInfo['caption'];
                 }
             }
             $i18n = SJB_I18N::getInstance();
             $periodView = array();
             foreach ($period as $key => $value) {
                 $periodView[$key] = $i18n->getInput('date', $period[$key]);
             }
             $tp->assign('search', $search);
             $tp->assign('filter', $filter);
             $tp->assign('columnTitle', $columnTitle);
             $tp->assign('period', $period);
             $tp->assign('periodView', $periodView);
             $tp->assign('statistics', $statistics);
             $tp->assign('countResult', count($statistics));
             $tp->assign('sorting_field', $sorting_field);
             $tp->assign('sorting_order', $sorting_order);
             break;
     }
     $tp->assign('userGroups', $userGroups);
     $tp->assign('errors', $errors);
     $tp->assign('action', $action);
     $tp->display($template);
 }