public static function getDetails() { $details = parent::getDetails(); $additionalDetails = array(array('id' => 'listing_type_sid', 'caption' => 'Listing Type', 'type' => 'list', 'list_values' => SJB_ListingTypeManager::getListingAllTypesForListType(), 'length' => '20', 'table_name' => 'products', 'is_required' => true, 'is_system' => true, 'order' => 1), array('id' => 'listing_duration', 'caption' => 'Listing Duration (days)', 'type' => 'integer', 'validators' => array('SJB_PlusValidator'), 'length' => '20', 'table_name' => 'products', 'is_required' => false, 'is_system' => true, 'order' => 2), array('id' => 'featured', 'caption' => 'Featured', 'type' => 'boolean', 'length' => '20', 'table_name' => 'products', 'is_required' => false, 'is_system' => true, 'order' => 3), array('id' => 'featured_period', 'caption' => 'Featured period', 'type' => 'integer', 'validators' => array('SJB_PlusValidator'), 'length' => '20', 'table_name' => 'products', 'is_required' => false, 'is_system' => true, 'order' => 4), array('id' => 'priority', 'caption' => 'Priority', 'type' => 'boolean', 'length' => '20', 'table_name' => 'products', 'is_required' => false, 'is_system' => true, 'order' => 5), array('id' => 'priority_period', 'caption' => 'Priority period', 'type' => 'integer', 'validators' => array('SJB_PlusValidator'), 'length' => '20', 'table_name' => 'products', 'is_required' => false, 'is_system' => true, 'order' => 6), array('id' => 'number_of_pictures', 'caption' => 'Number of pictures', 'type' => 'integer', 'validators' => array('SJB_PlusValidator'), 'length' => '20', 'table_name' => 'products', 'is_required' => false, 'is_system' => true, 'order' => 7), array('id' => 'video', 'caption' => 'Video', 'type' => 'boolean', 'length' => '20', 'table_name' => 'products', 'is_required' => false, 'is_system' => true, 'order' => 8), array('id' => 'price', 'caption' => 'Price', 'type' => 'float', 'validators' => array('SJB_PlusValidator'), 'length' => '20', 'table_name' => 'products', 'is_required' => false, 'is_system' => true, 'order' => 1), array('id' => 'number_of_listings', 'caption' => 'Number of Listings', 'type' => 'integer', 'validators' => array('SJB_PlusValidator'), 'length' => '20', 'comment' => 'Leave empty or 0 for unlimited posting', 'table_name' => 'products', 'is_required' => false, 'is_system' => true, 'order' => 2), array('id' => 'renewal_price', 'caption' => 'Renewal Price (per listing)', 'type' => 'float', 'validators' => array('SJB_PlusValidator'), 'length' => '20', 'table_name' => 'products', 'is_required' => false, 'is_system' => true, 'order' => 3), array('id' => 'upgrade_to_featured_listing_price', 'caption' => 'Upgrade to Featured Listing Price', 'type' => 'float', 'validators' => array('SJB_PlusValidator'), 'length' => '20', 'table_name' => 'products', 'is_required' => false, 'is_system' => true, 'order' => 7), array('id' => 'upgrade_to_priority_listing_price', 'caption' => 'Upgrade to Priority Listing Price', 'type' => 'float', 'validators' => array('SJB_PlusValidator'), 'length' => '20', 'table_name' => 'products', 'is_required' => false, 'is_system' => true, 'order' => 8), array('id' => 'expiration_period', 'caption' => 'Product Expiration', 'type' => 'integer', 'validators' => array('SJB_PlusValidator'), 'length' => '20', 'table_name' => 'products', 'comment' => 'Set empty or zero for never expire', 'is_required' => false, 'is_system' => true, 'order' => 1)); $details = array_merge($details, $additionalDetails); return $details; }
public function execute() { $this->tp = SJB_System::getTemplateProcessor(); $action = SJB_Request::getVar('action', 'search'); $template = SJB_Request::getVar('template', 'guest_alerts.tpl'); $errors = array(); try { switch ($action) { case 'export': $this->export(); break; case 'search': $this->search(); break; } } catch (Exception $e) { array_push($errors, $e->getMessage()); } $listingTypes = SJB_ListingTypeManager::getListingAllTypesForListType(); $this->tp->assign('listingTypes', $listingTypes); $this->tp->assign('errors', $errors); $this->tp->assign('action', $action); $this->tp->display($template); }
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); }
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); }
public static function generateGeneralGraph($dateStatistics, $filter = array()) { $listingTypes = SJB_ListingTypeManager::getListingAllTypesForListType(); $userGroups = SJB_UserGroupManager::getAllUserGroupsIDsAndCaptions(); $nameEvents = array(); $filterValues = is_array($filter) ? array_keys($filter) : array(); foreach ($filter as $blockName => $val) { switch ($blockName) { case 'popularity': $popularityEvents = array('siteView' => 'Number of Website Views', 'viewListing' => 'Number of #listingTypeName# Views'); $nameEvents = array_merge($nameEvents, $popularityEvents); break; case 'users': $usersEvents = array('addUser' => 'Number of #userGroupName# Registered', 'addSubAccount' => 'Number of Sub-Employers Registered', 'deleteUser' => 'Number of Profiles Deleted'); $nameEvents = array_merge($nameEvents, $usersEvents); break; case 'listings': $listingsEvents = array('addListing' => 'Number of #listingTypeName# Posted', 'deleteListing' => 'Number of #listingTypeName# Deleted'); $nameEvents = array_merge($nameEvents, $listingsEvents); break; case 'applications': $applyEvents = array('apply' => 'Number of Applications Made'); $nameEvents = array_merge($nameEvents, $applyEvents); break; case 'alerts': $alertsEvents = array('addAlert' => 'Number of Job Alerts #listingTypeName# for', 'sentAlert' => 'Number of #listingTypeName# Alerts Sent', SJB_GuestAlertStatistics::EVENT_SUBSCRIBED => 'Number of Guest #listingTypeName# Alerts subscribed for', SJB_GuestAlertStatistics::EVENT_SENT => 'Number of Guest #listingTypeName# Alerts Sent'); $nameEvents = array_merge($nameEvents, $alertsEvents); break; case 'sales': $salesEvents = array('payment' => 'Earnings from #userGroupName#', SJB_PromotionsManager::STATISTIC_EVENT => 'Promotion Discount'); $nameEvents = array_merge($nameEvents, $salesEvents); break; case 'plugins': $popularityEvents = array('viewMobileVersion' => 'Number of Mobile Version Views', 'partneringSites' => 'Number of Redirects to Partnering Sites'); $socialPlugins = SJB_SocialPlugin::getAvailablePlugins(); foreach ($socialPlugins as $socialPluginName) { $socialRegistrationEventName = 'addUser' . $socialPluginName; $popularityEvents[$socialRegistrationEventName] = 'Number of #userGroupName# Registered through ' . $socialPluginName; } $nameEvents = array_merge($nameEvents, $popularityEvents); break; } } $nameEvents = array_unique($nameEvents); $graph = array(); foreach ($nameEvents as $nameEvent => $title) { switch ($nameEvent) { case 'addAlert': case 'sentAlert': case SJB_GuestAlertStatistics::EVENT_SUBSCRIBED: case SJB_GuestAlertStatistics::EVENT_SENT: case 'deleteListing': case 'addListing': case 'viewListing': foreach ($listingTypes as $listingTypeInfo) { $listingType = $listingTypeInfo['caption']; $listingTypeID = $listingTypeInfo['id']; if ($nameEvent == 'addListing' || $nameEvent == 'deleteListing') { if ($listingTypeInfo['key'] == 'Job' || $listingTypeInfo['key'] == 'Resume') { $listingType = $listingTypeInfo['key'] . 's'; } else { $listingType = '"' . $listingType . '" listings '; } } $graph[$nameEvent . $listingTypeID]['title'] = str_replace('#listingTypeName#', $listingType, $title); if (!empty($dateStatistics[$nameEvent . $listingTypeID]['type']) && $dateStatistics[$nameEvent . $listingTypeID]['type'] == $listingTypeID) { $graph[$nameEvent . $listingTypeID]['statistic'] = $dateStatistics[$nameEvent . $listingTypeID]['count']; } else { $graph[$nameEvent . $listingTypeID]['statistic'] = 0; } if ($nameEvent == 'addListing') { $graph[$nameEvent . 'Featured' . $listingTypeID]['title'] = "Number of Featured {$listingType} Posted"; $graph[$nameEvent . 'Priority' . $listingTypeID]['title'] = "Number of Priority {$listingType} Posted"; $graph[$nameEvent . 'Featured' . $listingTypeID]['statistic'] = 0; $graph[$nameEvent . 'Priority' . $listingTypeID]['statistic'] = 0; if (!empty($dateStatistics[$nameEvent . $listingTypeID]['featured']) && $dateStatistics[$nameEvent . $listingTypeID]['featured'] == 1) { $graph[$nameEvent . 'Featured' . $listingTypeID]['statistic'] = $dateStatistics[$nameEvent . $listingTypeID]['count']; } if (!empty($dateStatistics[$nameEvent . $listingTypeID]['priority']) && $dateStatistics[$nameEvent . $listingTypeID]['priority'] == 1) { $graph[$nameEvent . 'Priority' . $listingTypeID]['statistic'] = $dateStatistics[$nameEvent . $listingTypeID]['count']; } } } break; case 'addUser': case 'addUserlinkedin': case 'addUserfacebook': case 'addUsergoogle': foreach ($userGroups as $userGroupInfo) { $userGroupID = $userGroupInfo['id']; $userGroup = $userGroupInfo['caption']; if ($userGroupInfo['key'] == 'JobSeeker' || $userGroupInfo['key'] == 'Employer') { $userGroup = $userGroupInfo['key'] . 's'; } else { $userGroup = '"' . $userGroup . '" Users'; } $graph[$nameEvent . $userGroupID]['title'] = str_replace('#userGroupName#', $userGroup, $title); if (!empty($dateStatistics[$nameEvent . $userGroupID]['type']) && $dateStatistics[$nameEvent . $userGroupID]['type'] == $userGroupID) { $graph[$nameEvent . $userGroupID]['statistic'] = $dateStatistics[$nameEvent . $userGroupID]['count']; } else { $graph[$nameEvent . $userGroupID]['statistic'] = 0; } } break; case 'deleteUser': $countUsers = 0; foreach ($userGroups as $userGroupInfo) { $userGroupID = $userGroupInfo['id']; if (!empty($dateStatistics[$nameEvent . $userGroupID]['type']) && $dateStatistics[$nameEvent . $userGroupID]['type'] == $userGroupID) { $countUsers += $dateStatistics[$nameEvent . $userGroupID]['count']; } } $graph['deleteUser']['title'] = $title; $graph['deleteUser']['statistic'] = $countUsers; break; case 'payment': $graph['totalAmount']['title'] = 'Total Sales'; $graph['totalAmount']['statistic'] = !empty($dateStatistics['totalAmount']['count']) ? $dateStatistics['totalAmount']['count'] : 0; foreach ($userGroups as $userGroupInfo) { $userGroupID = $userGroupInfo['id']; $userGroup = $userGroupInfo['caption']; if ($userGroupInfo['key'] == 'JobSeeker' || $userGroupInfo['key'] == 'Employer') { $userGroup = $userGroupInfo['key'] . 's'; } else { $userGroup = '"' . $userGroup . '" Users'; } $graph['amount_' . $userGroupID]['title'] = str_replace('#userGroupName#', $userGroup, $title); $graph['amount_' . $userGroupID]['statistic'] = !empty($dateStatistics['amount_' . $userGroupID]['count']) ? $dateStatistics['amount_' . $userGroupID]['count'] : 0; } break; case 'apply': $graph[$nameEvent]['title'] = $title; $graph[$nameEvent]['statistic'] = !empty($dateStatistics[$nameEvent]['count']) ? $dateStatistics[$nameEvent]['count'] : 0; $graph[$nameEvent . 'Approved']['title'] = "Number of Applications Approved"; $graph[$nameEvent . 'Rejected']['title'] = "Number of Applications Rejected"; $graph[$nameEvent . 'Approved']['statistic'] = 0; $graph[$nameEvent . 'Rejected']['statistic'] = 0; if (!empty($dateStatistics[$nameEvent]['approve']) && $dateStatistics[$nameEvent]['approve'] == 1) { $graph[$nameEvent . 'Approved']['statistic'] = $dateStatistics[$nameEvent]['count']; } if (!empty($dateStatistics[$nameEvent]['reject']) && $dateStatistics[$nameEvent]['reject'] == 1) { $graph[$nameEvent . 'Rejected']['statistic'] = $dateStatistics[$nameEvent]['count']; } break; default: $graph[$nameEvent]['title'] = $title; $graph[$nameEvent]['statistic'] = !empty($dateStatistics[$nameEvent]['count']) ? $dateStatistics[$nameEvent]['count'] : 0; break; } } return $graph; }