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 static function getConnectSettings() { return array(array('id' => 'fb_appID', 'caption' => 'Facebook App ID', 'type' => 'string', 'length' => '255', 'is_required' => true, 'is_system' => true, 'order' => -1, 'comment' => 'To get these credentials you need to create an application in <a href="https://developers.facebook.com/" target="_blank">Facebook Developers Console</a>.<br /><br />Follow the <a target="_blank" href="http://wiki.smartjobboard.com/display/sjb42/Facebook#Facebook-GettingFacebookCredentials">User Manual instructions</a> on how to do this.'), array('id' => 'fb_appSecret', 'caption' => 'Facebook App Secret', 'type' => 'string', 'length' => '255', 'is_required' => true, 'is_system' => true, 'order' => -0), array('id' => 'facebook_userGroup', 'caption' => 'User Group', 'type' => 'multilist', 'list_values' => SJB_UserGroupManager::getAllUserGroupsIDsAndCaptions(), 'is_required' => false, 'is_system' => true, 'order' => 1, 'comment' => 'Please select user groups which will use Facebook connect'), array('id' => 'facebook_resumeAutoFillSync', 'caption' => 'Allow Resume auto filling/synchronizing for Job Seekers', 'type' => 'boolean', 'is_required' => false, 'is_system' => true, 'order' => 1), array('id' => 'fb_likeJob', 'caption' => 'Display "Like" FaceBook icon for Jobs', 'type' => 'boolean', 'is_required' => false, 'is_system' => true, 'order' => 1), array('id' => 'fb_likeResume', 'caption' => 'Display "Like" FaceBook icon for Resumes', 'type' => 'boolean', 'is_required' => false, 'is_system' => true, 'order' => 1)); }
public static function getConnectSettings() { return array(array('id' => 'oauth2_client_id', 'caption' => 'Client ID for Web Application', 'type' => 'string', 'length' => '25', 'is_required' => true, 'order' => null, 'comment' => 'To get these credentials you need to register an application in <a href="https://cloud.google.com/console" target="_blank">Google API Console</a>.<br/><br/>Follow the <a href="http://wiki.smartjobboard.com/display/sjb42/Google+Plus#GooglePlus-GettingGoogle+Credentials" target="_blank">User Manual instructions</a> on how to do this.'), array('id' => 'client_secret', 'caption' => 'Client Secret for Web Application', 'type' => 'string', 'length' => '25', 'is_required' => true, 'order' => null, 'comment' => ''), array('id' => 'developer_key', 'caption' => 'API Key for Browser Applications', 'type' => 'string', 'length' => '25', 'is_required' => true, 'order' => null, 'comment' => ''), array('id' => 'google_plus_userGroup', 'caption' => 'User Group', 'type' => 'multilist', 'list_values' => SJB_UserGroupManager::getAllUserGroupsIDsAndCaptions(), 'is_required' => false, 'is_system' => true, 'order' => 1, 'comment' => 'Please select user groups which will use Google+ login/registration'), array('id' => 'enable_job_sharing_for_users_googleplus', 'caption' => 'Enable job sharing for users', 'type' => 'boolean', 'is_required' => false, 'is_system' => true, 'order' => null, 'comment' => 'Users allowed to post jobs on Social Networks will be able to post jobs on $networkName.')); }
/** * @return array */ public static function getConnectSettings() { return array(array('id' => 'li_apiKey', 'caption' => 'Linkedin API Key', 'type' => 'string', 'length' => '255', 'is_required' => true, 'is_system' => true, 'order' => 1, 'comment' => 'To get these credentials you need to create an application in <a href="https://www.linkedin.com/secure/developer" target="_blank">Linkedin Developer Network</a>.<br /><br />Follow the <a href="http://wiki.smartjobboard.com/display/sjb42/Linkedin#Linkedin-GettingLinkedinCredentials" target="_blank">User Manual instructions</a> on how to do this.'), array('id' => 'li_secKey', 'caption' => 'Linkedin Secret Key', 'type' => 'string', 'length' => '255', 'is_required' => true, 'is_system' => true, 'order' => 2), array('id' => 'linkedin_userGroup', 'caption' => 'User Group', 'type' => 'multilist', 'list_values' => SJB_UserGroupManager::getAllUserGroupsIDsAndCaptions(), 'is_required' => false, 'is_system' => true, 'order' => 3, 'comment' => 'Please select user groups which will use LinkedIn login/registration'), array('id' => 'linkedin_resumeAutoFillSync', 'caption' => 'Allow Resume auto filling/synchronizing for Job Seekers', 'type' => 'boolean', 'is_required' => false, 'is_system' => true, 'order' => 4), array('id' => 'li_allowShareJobs', 'caption' => 'Allow Job Seekers to share Jobs on LinkedIn', 'type' => 'boolean', 'is_required' => false, 'is_system' => true, 'order' => 5), array('id' => 'li_memberProfileWidget', 'caption' => 'Display "Member Profile" widget in User Info block', 'type' => 'boolean', 'is_required' => false, 'is_system' => true, 'order' => 6), array('id' => 'li_companyInsiderWidget', 'caption' => 'Display "Company Insider" widget on Company Profile page', 'type' => 'boolean', 'is_required' => false, 'is_system' => true, 'order' => 8), array('id' => 'li_companyProfileWidget', 'caption' => 'Display "Company Profile" widget in Company Info block', 'type' => 'boolean', 'is_required' => false, 'is_system' => true, 'order' => 9)); }
public static function getDetails() { $details = array(array('id' => 'name', 'caption' => 'Name', 'type' => 'unique_string', 'length' => '20', 'table_name' => 'products', 'validators' => array('SJB_UniqueSystemValidator'), 'unique' => '1', 'is_required' => true, 'is_system' => true, 'order' => 1), array('id' => 'short_description', 'caption' => 'Short Description', 'type' => 'text', 'length' => '20', 'table_name' => 'products', 'is_required' => false, 'is_system' => true, 'order' => 2), array('id' => 'detailed_description', 'caption' => 'Detailed Description', 'type' => 'text', 'length' => '20', 'table_name' => 'products', 'is_required' => false, 'is_system' => true, 'order' => 3), array('id' => 'user_group_sid', 'caption' => 'User Group', 'type' => 'list', 'length' => '20', 'table_name' => 'products', 'list_values' => SJB_UserGroupManager::getAllUserGroupsIDsAndCaptions(true), 'is_required' => true, 'is_system' => true, 'order' => 4), array('id' => 'active', 'caption' => 'Active', 'type' => 'boolean', 'length' => '20', 'table_name' => 'products', 'is_required' => false, 'is_system' => true, 'order' => 5), array('id' => 'availability_from', 'caption' => 'Availability', 'type' => 'date', 'length' => '20', 'table_name' => 'products', 'is_required' => false, 'is_system' => true, 'order' => 6), array('id' => 'availability_to', 'caption' => 'AvailabilityTo', 'type' => 'date', 'length' => '20', 'table_name' => 'products', 'is_required' => false, 'is_system' => true, 'order' => 7), array('id' => 'trial', 'caption' => 'Trial Product', 'type' => 'boolean', 'length' => '20', 'table_name' => 'products', 'comment' => 'Trial Product will not be available for a user after the 1st purchase', 'is_required' => false, 'is_system' => true, 'order' => 8), array('id' => 'welcome_email', 'caption' => 'Welcome Email', 'type' => 'list', 'list_values' => SJB_TemplateEditor::getTemplatesByGroupForListType(SJB_NotificationGroups::GROUP_ID_PRODUCT), 'length' => '20', 'table_name' => 'products', 'comment' => 'You can create more email templates for different products from Admin Panel > Email Templates > Product Emails', 'is_required' => false, 'is_system' => true, 'order' => 9)); return $details; }
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 function execute() { $tp = SJB_System::getTemplateProcessor(); $template = SJB_Request::getVar('template', 'users.tpl'); $searchTemplate = SJB_Request::getVar('search_template', 'user_search_form.tpl'); $passedParametersViaUri = SJB_UrlParamProvider::getParams(); $userGroupID = $passedParametersViaUri ? array_shift($passedParametersViaUri) : false; $userGroupSID = $userGroupID ? SJB_UserGroupManager::getUserGroupSIDByID($userGroupID) : null; $errors = array(); /********** A C T I O N S W I T H U S E R S **********/ $action = SJB_Request::getVar('action_name'); if (!empty($action)) { $users_sids = SJB_Request::getVar('users', array()); $_REQUEST['restore'] = 1; switch ($action) { case 'approve': foreach ($users_sids as $user_sid => $value) { $username = SJB_UserManager::getUserNameByUserSID($user_sid); SJB_UserManager::setApprovalStatusByUserName($username, 'Approved'); SJB_UserManager::activateUserByUserName($username); SJB_UserDBManager::deleteActivationKeyByUsername($username); if (!SJB_SocialPlugin::getProfileSocialID($user_sid)) { SJB_Notifications::sendUserWelcomeLetter($user_sid); } else { SJB_Notifications::sendUserApprovedLetter($user_sid); } } SJB_HelperFunctions::redirect(SJB_System::getSystemSettings('SITE_URL') . SJB_Navigator::getURI()); break; case 'reject': $rejection_reason = SJB_Request::getVar('rejection_reason', ''); foreach ($users_sids as $user_sid => $value) { $username = SJB_UserManager::getUserNameByUserSID($user_sid); SJB_UserManager::setApprovalStatusByUserName($username, 'Rejected', $rejection_reason); SJB_UserManager::deactivateUserByUserName($username); SJB_Notifications::sendUserRejectedLetter($user_sid); } SJB_HelperFunctions::redirect(SJB_System::getSystemSettings('SITE_URL') . SJB_Navigator::getURI()); break; case 'activate': foreach ($users_sids as $user_sid => $value) { $username = SJB_UserManager::getUserNameByUserSID($user_sid); $userinfo = SJB_UserManager::getUserInfoByUserName($username); SJB_UserManager::activateUserByUserName($username); if ($userinfo['approval'] == 'Approved') { SJB_UserDBManager::deleteActivationKeyByUsername($username); SJB_Notifications::sendUserApprovedLetter($user_sid); } } SJB_HelperFunctions::redirect(SJB_System::getSystemSettings('SITE_URL') . SJB_Navigator::getURI()); break; case 'deactivate': foreach ($users_sids as $user_sid => $value) { $username = SJB_UserManager::getUserNameByUserSID($user_sid); SJB_UserManager::deactivateUserByUserName($username); } SJB_HelperFunctions::redirect(SJB_System::getSystemSettings('SITE_URL') . SJB_Navigator::getURI()); break; case 'delete': foreach (array_keys($users_sids) as $user_sid) { try { SJB_UserManager::deleteUserById($user_sid); } catch (Exception $e) { $errors[] = $e->getMessage(); } } SJB_HelperFunctions::redirect(SJB_System::getSystemSettings('SITE_URL') . SJB_Navigator::getURI()); break; case 'send_activation_letter': foreach ($users_sids as $user_sid => $value) { SJB_Notifications::sendUserActivationLetter($user_sid); } SJB_HelperFunctions::redirect(SJB_System::getSystemSettings('SITE_URL') . SJB_Navigator::getURI()); break; case 'change_product': $productToChange = SJB_Request::getVar('product_to_change'); if (empty($productToChange)) { $productToChange = 0; } foreach ($users_sids as $user_sid => $value) { $user = SJB_UserManager::getObjectBySID($user_sid); // UNSUBSCRIBE selected if ($productToChange == 0) { SJB_ContractManager::deleteAllContractsByUserSID($user_sid); } else { $productInfo = SJB_ProductsManager::getProductInfoBySID($productToChange); $listingNumber = SJB_Request::getVar('number_of_listings', null); if (is_null($listingNumber) && !empty($productInfo['number_of_listings'])) { $listingNumber = $productInfo['number_of_listings']; } $contract = new SJB_Contract(array('product_sid' => $productToChange, 'numberOfListings' => $listingNumber, 'is_recurring' => 0)); $contract->setUserSID($user_sid); $contract->saveInDB(); if ($contract->isFeaturedProfile()) { SJB_UserManager::makeFeaturedBySID($user_sid); } } } SJB_HelperFunctions::redirect(SJB_System::getSystemSettings('SITE_URL') . SJB_Navigator::getURI()); break; case 'ban_ip': $cantBanUsers = array(); foreach ($users_sids as $user_sid => $value) { $user = SJB_UserManager::getUserInfoBySID($user_sid); if ($user['ip'] && !SJB_IPManager::getBannedIPByValue($user['ip'])) { SJB_IPManager::makeIPBanned($user['ip']); } else { $cantBanUsers[] = $user['username']; } } if ($cantBanUsers) { $tp->assign('cantBanUsers', $cantBanUsers); } else { SJB_HelperFunctions::redirect(SJB_System::getSystemSettings('SITE_URL') . SJB_Navigator::getURI()); } break; case 'unban_ip': $cantUnbanIPs = array(); foreach ($users_sids as $user_sid => $value) { $user = SJB_UserManager::getUserInfoBySID($user_sid); if ($user['ip'] !== '') { if (SJB_IPManager::getBannedIPByValue($user['ip'])) { SJB_IPManager::makeIPEnabledByValue($user['ip']); } elseif (SJB_UserManager::checkBan($errors, $user['ip'])) { $cantUnbanIPs[] = $user['ip']; } } } if ($cantUnbanIPs) { $tp->assign('rangeIPs', $cantUnbanIPs); } else { SJB_HelperFunctions::redirect(SJB_System::getSystemSettings('SITE_URL') . SJB_Navigator::getURI()); } break; default: unset($_REQUEST['restore']); break; } if (empty($errors)) { SJB_HelperFunctions::redirect(SJB_System::getSystemSettings('SITE_URL') . SJB_Navigator::getURI()); } } /***************************************************************/ $_REQUEST['action'] = 'search'; $user = new SJB_User(array(), $userGroupSID); $user->addProperty(array('id' => 'user_group', 'type' => 'list', 'value' => '', 'is_system' => true, 'list_values' => SJB_UserGroupManager::getAllUserGroupsIDsAndCaptions())); $user->addProperty(array('id' => 'registration_date', 'type' => 'date', 'value' => '', 'is_system' => true)); $user->addProperty(array('id' => 'approval', 'caption' => 'Approval', 'type' => 'list', 'list_values' => array(array('id' => 'Pending', 'caption' => 'Pending'), array('id' => 'Approved', 'caption' => 'Approved'), array('id' => 'Rejected', 'caption' => 'Rejected')), 'length' => '10', 'is_required' => false, 'is_system' => true)); // get array of accessible products $productsSIDs = SJB_ProductsManager::getProductsIDsByUserGroupSID($userGroupSID); $products = array(); foreach ($productsSIDs as $key => $productSID) { $product = SJB_ProductsManager::getProductInfoBySID($productSID); $products[$key] = $product; if (!empty($product['pricing_type']) && $product['pricing_type'] == 'volume_based' && !empty($product['volume_based_pricing'])) { $volumeBasedPricing = $product['volume_based_pricing']; $minListings = min($volumeBasedPricing['listings_range_from']); $maxListings = max($volumeBasedPricing['listings_range_to']); $countListings = array(); for ($i = $minListings; $i <= $maxListings; $i++) { $countListings[] = $i; } $products[$key]['count_listings'] = $countListings; } } $user->addProperty(array('id' => 'product', 'type' => 'list', 'value' => '', 'list_values' => $products, 'is_system' => true)); $aliases = new SJB_PropertyAliases(); $aliases->addAlias(array('id' => 'user_group', 'real_id' => 'user_group_sid', 'transform_function' => 'SJB_UserGroupManager::getUserGroupSIDByID')); $aliases->addAlias(array('id' => 'product', 'real_id' => 'product_sid')); $_REQUEST['user_group']['equal'] = $userGroupSID; $search_form_builder = new SJB_SearchFormBuilder($user); $criteria_saver = new SJB_UserCriteriaSaver(); if (isset($_REQUEST['restore'])) { $_REQUEST = array_merge($_REQUEST, $criteria_saver->getCriteria()); } $criteria = $search_form_builder->extractCriteriaFromRequestData($_REQUEST, $user); $search_form_builder->setCriteria($criteria); $search_form_builder->registerTags($tp); $userGroupInfo = SJB_UserGroupManager::getUserGroupInfoBySID($userGroupSID); if (SJB_Request::getVar('online', '') == '1') { $tp->assign("online", true); } $tp->assign('userGroupInfo', $userGroupInfo); $tp->assign('products', $products); $tp->assign('selectedProduct', isset($_REQUEST['product']['simple_equal']) ? $_REQUEST['product']['simple_equal'] : ''); $tp->display($searchTemplate); /********************** S O R T I N G *********************/ $paginator = new SJB_UsersPagination($userGroupInfo, SJB_Request::getVar('online', ''), $template); $firstLastName = ''; if (!empty($_REQUEST['FirstName']['equal'])) { $name['FirstName']['any_words'] = $name['LastName']['any_words'] = $_REQUEST['FirstName']['equal']; $firstLastName = $_REQUEST['FirstName']; unset($_REQUEST['FirstName']); $_REQUEST['FirstName']['fields_or'] = $name; } $criteria = $search_form_builder->extractCriteriaFromRequestData($_REQUEST, $user); $inner_join = false; // if search by product field if (isset($_REQUEST['product']['simple_equal']) && $_REQUEST['product']['simple_equal'] != '') { $inner_join = array('contracts' => array('join_field' => 'user_sid', 'join_field2' => 'sid', 'join' => 'INNER JOIN')); } if (SJB_Request::getVar('online', '') == '1') { $maxLifeTime = ini_get("session.gc_maxlifetime"); $currentTime = time(); $innerJoinOnline = array('user_session_data_storage' => array('join_field' => 'user_sid', 'join_field2' => 'sid', 'select_field' => 'session_id', 'join' => 'INNER JOIN', 'where' => "AND unix_timestamp(`user_session_data_storage`.`last_activity`) + {$maxLifeTime} > {$currentTime}")); if ($inner_join) { $inner_join = array_merge($inner_join, $innerJoinOnline); } else { $inner_join = $innerJoinOnline; } } $searcher = new SJB_UserSearcher(array('limit' => ($paginator->currentPage - 1) * $paginator->itemsPerPage, 'num_rows' => $paginator->itemsPerPage), $paginator->sortingField, $paginator->sortingOrder, $inner_join); $found_users = array(); $found_users_sids = array(); if (SJB_Request::getVar('action', '') == 'search') { $found_users = $searcher->getObjectsSIDsByCriteria($criteria, $aliases); $criteria_saver->setSession($_REQUEST, $searcher->getFoundObjectSIDs()); } elseif (isset($_REQUEST['restore'])) { $found_users = $criteria_saver->getObjectsFromSession(); } foreach ($found_users as $id => $userID) { $user_info = SJB_UserManager::getUserInfoBySID($userID); $contractInfo = SJB_ContractManager::getAllContractsInfoByUserSID($user_info['sid']); $user_info['products'] = count($contractInfo); $found_users[$id] = $user_info; } $paginator->setItemsCount($searcher->getAffectedRows()); $sorted_found_users_sids = $found_users_sids; /****************************************************************/ $tp->assign("userGroupInfo", $userGroupInfo); $tp->assign("found_users", $found_users); $searchFields = ''; foreach ($_REQUEST as $key => $val) { if (is_array($val)) { foreach ($val as $fieldName => $fieldValue) { if (is_array($fieldValue)) { foreach ($fieldValue as $fieldSubName => $fieldSubValue) { $searchFields .= "&{$key}[{$fieldSubName}]=" . array_pop($fieldSubValue); } } else { $searchFields .= "&{$key}[{$fieldName}]={$fieldValue}"; } } } } $tp->assign('paginationInfo', $paginator->getPaginationInfo()); $tp->assign("searchFields", $searchFields); $tp->assign("found_users_sids", $sorted_found_users_sids); $tp->assign('errors', $errors); $tp->display($template); }
public static function getDetails() { $i18n = SJB_I18N::getInstance(); return array(array('id' => 'language', 'caption' => 'Language', 'type' => 'list', 'length' => '20', 'list_values' => $i18n->getActiveFrontendLanguagesData(), 'is_required' => false, 'is_system' => true), array('id' => 'question', 'caption' => 'Question', 'type' => 'text', 'length' => '20', 'is_required' => true, 'is_system' => true), array('id' => 'user_group_sid', 'caption' => 'User Group', 'type' => 'list', 'length' => '20', 'list_values' => SJB_UserGroupManager::getAllUserGroupsIDsAndCaptions(), 'is_required' => false, 'is_system' => true), array('id' => 'start_date', 'caption' => 'Start Date', 'type' => 'date', 'length' => '20', 'is_required' => true, 'is_system' => true), array('id' => 'end_date', 'caption' => 'End Date', 'type' => 'date', 'length' => '20', 'comment' => 'Leave this field empty to set Never Expire', 'is_required' => false, 'is_system' => true), array('id' => 'display_results', 'caption' => 'Display Results for Users', 'type' => 'boolean', 'length' => '20', 'is_required' => false, 'is_system' => true), array('id' => 'show_total_votes', 'caption' => 'Show Total Votes', 'type' => 'boolean', 'length' => '20', 'is_required' => false, 'is_system' => true)); }
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); }
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; }
private function prepareTplVarsForUser($onlyUserGroupID = false) { $userGroups = SJB_UserGroupManager::getAllUserGroupsIDsAndCaptions(); foreach ($userGroups as $key => &$userGroupInfo) { if ($onlyUserGroupID && $userGroupInfo['key'] != $onlyUserGroupID) { unset($userGroups[$key]); continue; } $user = SJB_ObjectMother::createUser(array(), $userGroupInfo['id']); $fields = SJB_UserManager::createTemplateStructureForUser($user); unset($fields['METADATA']); unset($fields['password']); $userGroupInfo['fields'] = $this->echoVars($fields); } $this->tp->assign('userGroups', $userGroups); }