コード例 #1
0
ファイル: promotions.php プロジェクト: Maxlander/shixi
 public function search()
 {
     $action = SJB_Request::getVar('action');
     $period = SJB_Request::getVar('period', array());
     $sorting_field = SJB_Request::getVar('sorting_field', 'usageCount');
     $sorting_order = SJB_Request::getVar('sorting_order', 'DESC');
     $i18n = SJB_I18N::getInstance();
     $statistics = array();
     if ($action) {
         if (!empty($period['from']) && !empty($period['to'])) {
             $from = $i18n->getInput('date', $period['from']);
             $to = $i18n->getInput('date', $period['to']);
             if (strtotime($from) > strtotime($to)) {
                 throw new Exception('SELECTED_PERIOD_IS_INCORRECT');
             }
         }
         $statistics = SJB_Statistics::getPromotionsStatistics($period, $sorting_field, $sorting_order);
     }
     $periodView = array();
     foreach ($period as $key => $value) {
         $periodView[$key] = $i18n->getInput('date', $period[$key]);
     }
     $this->tp->assign('currency', SJB_CurrencyManager::getDefaultCurrency());
     $this->tp->assign('action', $action);
     $this->tp->assign('period', $period);
     $this->tp->assign('periodView', $periodView);
     $this->tp->assign('statistics', $statistics);
     $this->tp->assign('countResult', count($statistics));
     $this->tp->assign('sorting_field', $sorting_field);
     $this->tp->assign('sorting_order', $sorting_order);
 }
コード例 #2
0
 public function execute()
 {
     $tp = SJB_System::getTemplateProcessor();
     $currentUser = SJB_UserManager::getCurrentUser();
     $products = array();
     if (!empty($_SESSION['products'])) {
         $products = $_SESSION['products'];
     }
     if (SJB_UserManager::isUserLoggedIn()) {
         foreach ($products as $product) {
             if (!empty($product['product_info'])) {
                 $productInfo = unserialize($product['product_info']);
                 if ($currentUser->getUserGroupSID() != $productInfo['user_group_sid']) {
                     SJB_Session::unsetValue('products');
                     SJB_HelperFunctions::redirect(SJB_System::getSystemSettings('SITE_URL') . "/shopping-cart/?error=user_group");
                 } else {
                     SJB_ShoppingCart::addToShoppingCart($productInfo, $currentUser->getSID());
                 }
             }
         }
         SJB_Session::unsetValue('products');
         $products = SJB_ShoppingCart::getAllProductsByUserSID($currentUser->getSID());
     }
     $total_price = 0;
     foreach ($products as $product) {
         $productInfo = unserialize($product['product_info']);
         $product = new SJB_Product($productInfo, $productInfo['product_type']);
         $number_of_listings = !empty($productInfo['number_of_listings']) ? $productInfo['number_of_listings'] : 1;
         $product->setNumberOfListings($number_of_listings);
         $productInfo['price'] = $product->getPrice();
         $total_price += $productInfo['price'];
         if ($productInfo['pricing_type'] != 'volume_based' && $productInfo['code_info']) {
             $total_price += $productInfo['code_info']['promoAmount'];
         }
     }
     $tp->assign('products_number', count($products));
     $tp->assign('total_price', $total_price);
     $tp->assign("currency", SJB_CurrencyManager::getDefaultCurrency());
     $tp->display('show_shopping_cart.tpl');
 }
コード例 #3
0
ファイル: promotions_log.php プロジェクト: Maxlander/shixi
 public function execute()
 {
     $this->tp = SJB_System::getTemplateProcessor();
     $passedParametersViaUri = SJB_UrlParamProvider::getParams();
     $promotionSID = array_shift($passedParametersViaUri);
     $promotionCodeInfo = SJB_PromotionsManager::getCodeInfoBySID($promotionSID);
     $this->tp->assign('promotionInfo', $promotionCodeInfo);
     if (!$promotionCodeInfo) {
         array_push($this->errors, 'INVALID_ID');
     }
     $page = SJB_Request::getInt('page', 1);
     $itemsPerPage = SJB_Request::getInt('items_per_page', 50);
     $itemsCount = SJB_PromotionsManager::getHistoryCountBySID($promotionSID);
     $this->assignParametersForPagination($page, $itemsPerPage, $itemsCount);
     $promotions = SJB_PromotionsManager::getHistoryBySID($promotionSID, $page, $itemsPerPage);
     SJB_PromotionsManager::preparePromotionsInfoForLog($promotions);
     $currency = SJB_CurrencyManager::getDefaultCurrency();
     $this->tp->assign('currency', $currency);
     $this->tp->assign('promotions', $promotions);
     $this->tp->assign('errors', $this->errors);
     $this->tp->display('promotions_log.tpl');
 }
コード例 #4
0
 public static function getUserProfileFieldInfoBySID($user_profile_field_sid)
 {
     $field_info = parent::getObjectInfo("user_profile_fields", $user_profile_field_sid);
     if (in_array($field_info['type'], array('list', 'multilist'))) {
         if (!empty($field_info['parent_sid'])) {
             if ($field_info['id'] == 'Country') {
                 $displayAS = !empty($field_info['display_as']) ? $field_info['display_as'] : 'country_name';
                 $field_info['list_values'] = SJB_CountriesManager::getAllCountriesCodesAndNames(true, $displayAS);
             }
         } else {
             $field_info['list_values'] = SJB_UserProfileFieldDBManager::getListValuesBySID($user_profile_field_sid);
         }
     } elseif ($field_info['type'] == 'tree') {
         $field_info['tree_values'] = SJB_UserProfileFieldTreeManager::getTreeValuesBySID($user_profile_field_sid);
         $field_info['tree_depth'] = SJB_UserProfileFieldTreeManager::getTreeDepthBySID($user_profile_field_sid);
     } elseif ($field_info['type'] == 'monetary') {
         $field_info['currency_values'] = SJB_CurrencyManager::getActiveCurrencyList();
     } elseif ($field_info['type'] == 'location') {
         $field_info['fields'] = SJB_UserProfileFieldManager::getUserProfileFieldsInfoByParentSID($user_profile_field_sid);
     }
     return $field_info;
 }
コード例 #5
0
ファイル: ListingManager.php プロジェクト: Maxlander/shixi
 public static function newValueFromSearchCriteria($listing_structure, $search_criteria_structure)
 {
     foreach ($search_criteria_structure as $key => $criteria) {
         if (isset($criteria['monetary']) && array_key_exists($key, $listing_structure)) {
             $currency = isset($criteria['monetary']['currency']) ? SJB_CurrencyManager::getCurrencyByCurrCode($criteria['monetary']['currency']) : false;
             $course = SJB_Array::get($listing_structure[$key], 'course');
             if (is_array($listing_structure[$key]) && $course && isset($listing_structure[$key]['add_parameter']) && !empty($currency) && $currency['sid'] != $listing_structure[$key]['add_parameter'] && is_numeric($listing_structure[$key]['value'])) {
                 $listing_structure[$key]['value'] = round($listing_structure[$key]['value'] / $course * $currency['course']);
                 $listing_structure[$key]['currency_sign'] = $currency['currency_sign'];
             }
         }
     }
     return $listing_structure;
 }
コード例 #6
0
ファイル: import_listings.php プロジェクト: Maxlander/shixi
 public function execute()
 {
     ini_set('max_execution_time', 0);
     $tp = SJB_System::getTemplateProcessor();
     $file_info = isset($_FILES['import_file']) ? $_FILES['import_file'] : null;
     $encodingFromCharset = SJB_Request::getVar('encodingFromCharset', 'UTF-8');
     $listingTypeID = SJB_Request::getVar('listing_type_id', null);
     $productSID = SJB_Request::getVar('product_sid', 0);
     $errors = array();
     if ($listingTypeID && $productSID) {
         $acl = SJB_Acl::getInstance();
         $resource = 'post_' . strtolower($listingTypeID);
         if (!$acl->isAllowed($resource, $productSID, 'product')) {
             $errors[] = 'You cannot import listings of this type under the selected product';
         }
     }
     if (!empty($file_info)) {
         $extension = SJB_Request::getVar('file_type');
         if (!SJB_ImportFile::isValidFileExtensionByFormat($extension, $file_info)) {
             $errors['DO_NOT_MATCH_SELECTED_FILE_FORMAT'] = true;
         }
     }
     if (empty($file_info) || $file_info['error'] || $errors) {
         if (isset($file_info['error']) && $file_info['error'] > 0) {
             $errors[SJB_UploadFileManager::getErrorId($file_info['error'])] = 1;
         }
         $listing_types = SJB_ListingTypeManager::getAllListingTypesInfo();
         $products = SJB_ProductsManager::getProductsByProductType('post_listings');
         $tp->assign("uploadMaxFilesize", SJB_UploadFileManager::getIniUploadMaxFilesize());
         $tp->assign('listing_types', $listing_types);
         $tp->assign('products', $products);
         $tp->assign('errors', $errors);
         $tp->assign('charSets', SJB_HelperFunctions::getCharSets());
         $tp->display('import_listings.tpl');
     } else {
         $i18n = SJB_I18N::getInstance();
         $csv_delimiter = SJB_Request::getVar('csv_delimiter', null);
         $activeStatus = SJB_Request::getVar('active', 0);
         $activationDate = SJB_Request::getVar('activation_date', date('Y-m-d'));
         $activationDate = $i18n->getInput('date', $activationDate);
         $non_existed_values_flag = SJB_Request::getVar('non_existed_values', null);
         $productInfo = SJB_ProductsManager::getProductInfoBySID($productSID);
         if (empty($productInfo['listing_duration'])) {
             $expirationDate = '';
         } else {
             $timestamp = strtotime($activationDate . ' + ' . $productInfo['listing_duration'] . ' days');
             $expirationDate = $i18n->getDate(date('Y-m-d', $timestamp));
         }
         $extension = $_REQUEST['file_type'];
         if ($extension == 'xls') {
             $import_file = new SJB_ImportFileXLS($file_info);
         } elseif ($extension == 'csv') {
             $import_file = new SJB_ImportFileCSV($file_info, $csv_delimiter);
         }
         $import_file->parse($encodingFromCharset);
         $listing = $this->CreateListing(array(), $listingTypeID);
         $imported_data = $import_file->getData();
         $isFileImported = true;
         $count = 0;
         $addedListingsSids = array();
         $nonExistentUsers = array();
         foreach ($imported_data as $key => $importedColumn) {
             if ($key == 1) {
                 $imported_data_processor = new SJB_ImportedDataProcessor($importedColumn, $listing);
                 continue;
             }
             if (!$importedColumn) {
                 continue;
             }
             $count++;
             $listingInfo = $imported_data_processor->getData($non_existed_values_flag, $importedColumn);
             $doc = new DOMDocument();
             foreach ($listing->getProperties() as $property) {
                 if ($property->getType() == 'complex' && !empty($listingInfo[$property->id])) {
                     $childFields = SJB_ListingComplexFieldManager::getListingFieldsInfoByParentSID($property->sid);
                     $doc->loadXML($listingInfo[$property->id]);
                     $results = $doc->getElementsByTagName($property->id . 's');
                     $listingInfo[$property->id] = array();
                     foreach ($results as $complexparent) {
                         $i = 1;
                         foreach ($complexparent->getElementsByTagName($property->id) as $result) {
                             $resultXML = simplexml_import_dom($result);
                             foreach ($childFields as $childField) {
                                 if (isset($resultXML->{$childField}['id'])) {
                                     $listingInfo[$property->id][$childField['id']][$i] = XML_Util::reverseEntities((string) $resultXML->{$childField}['id']);
                                 }
                             }
                             $i++;
                         }
                     }
                 } elseif ($property->getType() == 'monetary' && !empty($listingInfo[$property->id])) {
                     $value = $listingInfo[$property->id];
                     $listingInfo[$property->id] = array();
                     $listingInfo[$property->id]['value'] = $value;
                     $defaultCurrency = SJB_CurrencyManager::getDefaultCurrency();
                     $currencyCode = !empty($listingInfo[$property->id . "Currency"]) ? $listingInfo[$property->id . "Currency"] : $defaultCurrency['currency_code'];
                     $currency = SJB_CurrencyManager::getCurrencyByCurrCode($currencyCode);
                     $listingInfo[$property->id]['add_parameter'] = !empty($currency['sid']) ? $currency['sid'] : '';
                     if (isset($listingInfo[$property->id . "Currency"])) {
                         unset($listingInfo[$property->id . "Currency"]);
                     }
                 } elseif ($property->getType() == 'location') {
                     $locationFields = array($property->id . '.Country', $property->id . '.State', $property->id . '.City', $property->id . '.ZipCode');
                     $locationFieldAdded = array();
                     foreach ($locationFields as $locationField) {
                         if (array_key_exists($locationField, $listingInfo)) {
                             switch ($locationField) {
                                 case $property->id . '.Country':
                                     $value = SJB_CountriesManager::getCountrySIDByCountryName($listingInfo[$locationField]);
                                     if (!$value) {
                                         $value = SJB_CountriesManager::getCountrySIDByCountryCode($listingInfo[$locationField]);
                                     }
                                     break;
                                 case $property->id . '.State':
                                     $value = SJB_StatesManager::getStateSIDByStateName($listingInfo[$locationField]);
                                     if (!$value) {
                                         $value = SJB_StatesManager::getStateSIDByStateCode($listingInfo[$locationField]);
                                     }
                                     break;
                                 default:
                                     $value = $listingInfo[$locationField];
                                     break;
                             }
                             $listingInfo[$property->id][str_replace($property->id . '.', '', $locationField)] = $value;
                             $locationFieldAdded[] = str_replace($property->id . '.', '', $locationField);
                         }
                     }
                     if ($property->id == 'Location') {
                         $locationFields = array('Country', 'State', 'City', 'ZipCode');
                         foreach ($locationFields as $locationField) {
                             if (array_key_exists($locationField, $listingInfo) && !in_array($locationField, $locationFieldAdded) && !$listing->getProperty($locationField)) {
                                 switch ($locationField) {
                                     case 'Country':
                                         $value = SJB_CountriesManager::getCountrySIDByCountryName($listingInfo[$locationField]);
                                         if (!$value) {
                                             $value = SJB_CountriesManager::getCountrySIDByCountryCode($listingInfo[$locationField]);
                                         }
                                         break;
                                     case 'State':
                                         $value = SJB_StatesManager::getStateSIDByStateName($listingInfo[$locationField]);
                                         if (!$value) {
                                             $value = SJB_StatesManager::getStateSIDByStateCode($listingInfo[$locationField]);
                                         }
                                         break;
                                     default:
                                         $value = $listingInfo[$locationField];
                                         break;
                                 }
                                 $listingInfo[$property->id][$locationField] = $value;
                             }
                         }
                     }
                 }
             }
             $listing = $this->CreateListing($listingInfo, $listingTypeID);
             $pictures = array();
             if (isset($listingInfo['pictures'])) {
                 $listing->addPicturesProperty();
                 $explodedPictures = explode(';', $listingInfo['pictures']);
                 foreach ($explodedPictures as $picture) {
                     if (!empty($picture)) {
                         $pictures[] = $picture;
                     }
                 }
                 $listing->setPropertyValue('pictures', count($pictures));
             }
             $listing->addActiveProperty($activeStatus);
             $listing->addActivationDateProperty($activationDate);
             $listing->addExpirationDateProperty($expirationDate);
             SJB_ListingDBManager::setListingExpirationDateBySid($listing->sid);
             $listing->setProductInfo(SJB_ProductsManager::getProductExtraInfoBySID($productSID));
             $listing->setPropertyValue('access_type', 'everyone');
             $listing->setPropertyValue('status', 'approved');
             foreach ($listing->getProperties() as $property) {
                 if ($property->getType() == 'tree' && $property->value !== '') {
                     try {
                         $treeImportHelper = new SJB_FieldTreeImportHelper($property->value);
                         $treeValues = $treeImportHelper->parseAndGetValues();
                         $listing->setPropertyValue($property->id, $treeValues);
                         $listing->details->properties[$property->id]->type->property_info['value'] = $treeValues;
                     } catch (Exception $e) {
                         $listing->setPropertyValue($property->id, '');
                         $listing->details->properties[$property->id]->type->property_info['value'] = '';
                         SJB_Error::writeToLog('Listing Import. Tree Field Value Error: ' . $e->getMessage());
                     }
                 } elseif ($property->id == 'ApplicationSettings' && !empty($listingInfo['ApplicationSettings'])) {
                     if (preg_match("^[a-z0-9\\._-]+@[a-z0-9\\._-]+\\.[a-z]{2,}\$^iu", $listingInfo['ApplicationSettings'])) {
                         $listingInfo['ApplicationSettings'] = array('value' => $listingInfo['ApplicationSettings'], 'add_parameter' => 1);
                     } elseif (preg_match("^(https?:\\/\\/)^", $listingInfo['ApplicationSettings'])) {
                         $listingInfo['ApplicationSettings'] = array('value' => $listingInfo['ApplicationSettings'], 'add_parameter' => 2);
                     } else {
                         $listingInfo['ApplicationSettings'] = array('value' => '', 'add_parameter' => '');
                     }
                     //put empty if not valid email or url
                     $listing->details->properties[$property->id]->type->property_info['value'] = $listingInfo['ApplicationSettings'];
                 } elseif ($property->getType() == 'complex') {
                     $childFields = SJB_ListingComplexFieldManager::getListingFieldsInfoByParentSID($property->sid);
                     $complexChildValues = $property->value;
                     foreach ($childFields as $childField) {
                         if ($childField['type'] == 'complexfile' && !empty($complexChildValues[$childField['id']])) {
                             $fieldInfo = SJB_ListingComplexFieldManager::getFieldInfoBySID($childField['sid']);
                             if (!SJB_UploadFileManager::fileImport($listingInfo, $fieldInfo, $property->id)) {
                                 $isFileImported = false;
                             }
                         }
                         if ($property->type->complex->details->properties[$childField['id']]->value == null) {
                             $property->type->complex->details->properties[$childField['id']]->value = array(1 => '');
                             $property->type->complex->details->properties[$childField['id']]->type->property_info['value'] = array(1 => '');
                         }
                     }
                 }
                 // The import of files at import of listings
                 if (in_array($property->getType(), array('file', 'logo', 'video')) && $property->value !== '') {
                     $fieldInfo = SJB_ListingFieldDBManager::getListingFieldInfoByID($property->id);
                     if (!SJB_UploadFileManager::fileImport($listingInfo, $fieldInfo)) {
                         $isFileImported = false;
                     }
                 }
             }
             if ($non_existed_values_flag == 'add') {
                 $this->UpdateListValues($listing);
             }
             if ($listing->getUserSID()) {
                 SJB_ListingManager::saveListing($listing);
                 $listingSid = $listing->getSID();
                 SJB_Statistics::addStatistics('addListing', $listing->getListingTypeSID(), $listingSid);
                 SJB_ListingManager::activateListingBySID($listingSid, false);
                 if (!$this->fillGallery($listingSid, $pictures)) {
                     $isFileImported = false;
                 }
                 $addedListingsSids[] = $listingSid;
             } else {
                 $nonExistentUsers[] = $listingInfo['username'];
                 $count--;
             }
         }
         SJB_BrowseDBManager::addListings($addedListingsSids);
         SJB_ProductsManager::incrementPostingsNumber($productSID, count($addedListingsSids));
         if ($isFileImported && file_exists(SJB_System::getSystemSettings('IMPORT_FILES_DIRECTORY'))) {
             SJB_Filesystem::delete(SJB_System::getSystemSettings('IMPORT_FILES_DIRECTORY'));
         }
         $tp->assign('imported_listings_count', $count);
         $tp->assign('nonExistentUsers', $nonExistentUsers);
         $tp->display('import_listings_result.tpl');
     }
 }
コード例 #7
0
ファイル: PromotionsDetails.php プロジェクト: Maxlander/shixi
 public static function getDetails()
 {
     $currency = SJB_CurrencyManager::getDefaultCurrency();
     return array(array('id' => 'code', 'caption' => 'Promotion Code', 'type' => 'unique_string', 'length' => '20', 'table_name' => 'promotions', 'validators' => array('SJB_IdValidator', 'SJB_UniqueSystemValidator'), 'is_required' => true, 'is_system' => true), array('id' => 'discount', 'caption' => 'Discount', 'type' => 'float', 'length' => '10', 'table_name' => 'promotions', 'validators' => array('SJB_PlusValidator'), 'is_required' => true, 'is_system' => true), array('id' => 'type', 'caption' => 'Type', 'type' => 'list', 'length' => '10', 'table_name' => 'promotions', 'is_required' => true, 'is_system' => true, 'list_values' => array(array('id' => 'percentage', 'caption' => '%'), array('id' => 'fixed', 'caption' => $currency['currency_sign']))), array('id' => 'product_sid', 'caption' => 'Applies to', 'type' => 'multilist', 'table_name' => 'promotions', 'is_required' => false, 'is_system' => true, 'list_values' => self::getProductList()), array('id' => 'maximum_uses', 'caption' => 'Maximum Uses', 'type' => 'integer', 'table_name' => 'promotions', 'comment' => 'Leave empty or zero for unlimited uses', 'is_required' => false, 'is_system' => true), array('id' => 'start_date', 'caption' => 'Start Date', 'type' => 'date', 'length' => '20', 'table_name' => 'promotions', 'comment' => 'Leave blank to disable start date restrictions', 'is_required' => false, 'is_system' => true), array('id' => 'end_date', 'caption' => 'End Date', 'type' => 'date', 'length' => '20', 'table_name' => 'promotions', 'comment' => 'Leave blank for none', 'is_required' => false, 'is_system' => true), array('id' => 'active', 'caption' => 'Active', 'type' => 'boolean', 'table_name' => 'promotions', 'is_required' => false, 'is_system' => true));
 }
コード例 #8
0
ファイル: job_import.php プロジェクト: Maxlander/shixi
 public function execute()
 {
     $tp = SJB_System::getTemplateProcessor();
     $listing_type_id = SJB_Request::getVar('listing_type_id', false);
     $action = SJB_Request::getVar('action', false);
     $type = SJB_Request::getVar('type', false);
     $encodingFromCharset = SJB_Request::getVar('encodingFromCharset', 'UTF-8');
     $supportedFormats = array('xlsx', 'xls', 'csv');
     $warning = false;
     $error = '';
     if ($action == 'example' && $type) {
         $listing_type_sid = SJB_ListingTypeManager::getListingTypeSIDByID($listing_type_id);
         $listing_field_manager = new SJB_ListingFieldManager();
         $common_details = $listing_field_manager->getCommonListingFieldsInfo();
         $extra_details = $listing_field_manager->getListingFieldsInfoByListingType($listing_type_sid);
         $listing_fields = array_merge($common_details, $extra_details);
         $directory_to_export = SJB_System::getSystemSettings('EXPORT_FILES_DIRECTORY');
         $export_properties = array();
         $export_data = array();
         foreach ($listing_fields as $listing_field) {
             $export_properties[$listing_field['id']] = $listing_field['id'];
             $export_data[0][$listing_field['id']] = '';
         }
         SJB_ExportController::createExportDirectoriesForExample();
         switch ($type) {
             case 'exl':
                 SJB_ExportController::makeExportFile($export_data, 'example.xls');
                 $export_files_dir = SJB_Path::combine($directory_to_export, 'example.xls');
                 for ($i = 0; $i < ob_get_level(); $i++) {
                     ob_end_clean();
                 }
                 header('Content-type: application/vnd.ms-excel');
                 header('Content-disposition: attachment; filename=example.xls');
                 header('Content-Length: ' . filesize($export_files_dir));
                 readfile($export_files_dir);
                 break;
             case 'csv':
                 $export_files_dir = SJB_Path::combine($directory_to_export, 'example.csv');
                 $fp = fopen($export_files_dir, 'w');
                 fputcsv($fp, explode(',', implode(',', $export_properties)));
                 fclose($fp);
                 for ($i = 0; $i < ob_get_level(); $i++) {
                     ob_end_clean();
                 }
                 header('Content-type: application/vnd.ms-excel');
                 header('Content-disposition: attachment; filename=example.csv');
                 header('Content-Length: ' . filesize($export_files_dir));
                 readfile($export_files_dir);
                 break;
         }
         SJB_Filesystem::delete($directory_to_export);
         exit;
     }
     if ($productsInfo = $this->canCurrentUserAddListing($error)) {
         $acl = SJB_Acl::getInstance();
         if ($acl->isAllowed('bulk_job_import') == true) {
             $fileInfo = null;
             if (isset($_FILES['import_file'])) {
                 $extension = strtolower(substr(strrchr($_FILES['import_file']['name'], '.'), 1));
                 if (empty($_FILES['import_file']['name']) || !in_array($extension, $supportedFormats)) {
                     $warning = 'Please choose Excel or csv file';
                 } else {
                     $fileInfo = $_FILES['import_file'];
                 }
             }
             $contractID = SJB_Request::getVar('contract_id', false);
             $current_user = SJB_UserManager::getCurrentUser();
             if ($contractID) {
                 $contract = new SJB_Contract(array('contract_id' => $contractID));
             } elseif (count($productsInfo) == 1) {
                 $productInfo = array_pop($productsInfo);
                 $contractID = $productInfo['contract_id'];
                 $contract = new SJB_Contract(array('contract_id' => $contractID));
             } else {
                 $tp->assign("products_info", $productsInfo);
                 $tp->assign("listing_type_id", $listing_type_id);
                 $tp->display("listing_product_choice.tpl");
             }
             if ($contractID && $listing_type_id) {
                 $listing_type_sid = SJB_ListingTypeManager::getListingTypeSIDByID($listing_type_id);
                 if ($fileInfo) {
                     switch ($extension) {
                         case 'xls':
                         case 'xlsx':
                             $import_file = new SJB_ImportFileXLS($fileInfo);
                             break;
                         case 'csv':
                             $import_file = new SJB_ImportFileCSV($fileInfo, ',');
                             break;
                     }
                     $import_file->parse($encodingFromCharset);
                     $bulkPermissionParam = $this->acl->getPermissionParams('post_' . $listing_type_id, $contract->getID(), 'contract');
                     $imported_data = $import_file->getData();
                     $countData = 0;
                     foreach ($imported_data as $val) {
                         if ($val) {
                             $countData++;
                         }
                     }
                     if (empty($bulkPermissionParam) || $bulkPermissionParam - $contract->getPostingsNumber() - ($countData - 1) >= 0) {
                         $listing = new SJB_Listing(array(), $listing_type_sid);
                         $count = 0;
                         $listingSIDs = array();
                         foreach ($imported_data as $key => $importedColumn) {
                             if ($key == 1) {
                                 $imported_data_processor = new SJB_ImportedDataProcessor($importedColumn, $listing);
                                 continue;
                             }
                             if (!$importedColumn) {
                                 continue;
                             }
                             $count++;
                             $listing_info = $imported_data_processor->getData('ignore', $importedColumn);
                             $doc = new DOMDocument();
                             foreach ($listing->getProperties() as $property) {
                                 if ($property->getType() == 'complex' && !empty($listing_info[$property->id])) {
                                     $childFields = SJB_ListingComplexFieldManager::getListingFieldsInfoByParentSID($property->sid);
                                     $doc->loadXML($listing_info[$property->id]);
                                     $results = $doc->getElementsByTagName($property->id . 's');
                                     $listing_info[$property->id] = array();
                                     foreach ($results as $complexparent) {
                                         $i = 0;
                                         foreach ($complexparent->getElementsByTagName($property->id) as $result) {
                                             $resultXML = simplexml_import_dom($result);
                                             foreach ($childFields as $childField) {
                                                 if (isset($resultXML->{$childField}['id'])) {
                                                     $listing_info[$property->id][$childField['id']][$i] = (string) $resultXML->{$childField}['id'];
                                                 }
                                             }
                                             $i++;
                                         }
                                     }
                                 } elseif ($property->getType() == 'location') {
                                     $locationFields = array($property->id . '.Country', $property->id . '.State', $property->id . '.City', $property->id . '.ZipCode');
                                     $locationFieldAdded = array();
                                     foreach ($locationFields as $locationField) {
                                         if (array_key_exists($locationField, $listing_info)) {
                                             switch ($locationField) {
                                                 case $property->id . '.Country':
                                                     $value = SJB_CountriesManager::getCountrySIDByCountryName($listing_info[$locationField]);
                                                     if (!$value) {
                                                         $value = SJB_CountriesManager::getCountrySIDByCountryCode($listing_info[$locationField]);
                                                     }
                                                     break;
                                                 case $property->id . '.State':
                                                     $value = SJB_StatesManager::getStateSIDByStateName($listing_info[$locationField]);
                                                     if (!$value) {
                                                         $value = SJB_StatesManager::getStateSIDByStateCode($listing_info[$locationField]);
                                                     }
                                                     break;
                                                 default:
                                                     $value = $listing_info[$locationField];
                                                     break;
                                             }
                                             $listing_info[$property->id][str_replace($property->id . '.', '', $locationField)] = $value;
                                             $locationFieldAdded[] = str_replace($property->id . '.', '', $locationField);
                                         }
                                     }
                                     if ($property->id == 'Location') {
                                         $locationFields = array('Country', 'State', 'City', 'ZipCode');
                                         foreach ($locationFields as $locationField) {
                                             if (array_key_exists($locationField, $listing_info) && !in_array($locationField, $locationFieldAdded) && !$listing->getProperty($locationField)) {
                                                 switch ($locationField) {
                                                     case 'Country':
                                                         $value = SJB_CountriesManager::getCountrySIDByCountryName($listing_info[$locationField]);
                                                         if (!$value) {
                                                             $value = SJB_CountriesManager::getCountrySIDByCountryCode($listing_info[$locationField]);
                                                         }
                                                         break;
                                                     case 'State':
                                                         $value = SJB_StatesManager::getStateSIDByStateName($listing_info[$locationField]);
                                                         if (!$value) {
                                                             $value = SJB_StatesManager::getStateSIDByStateCode($listing_info[$locationField]);
                                                         }
                                                         break;
                                                     default:
                                                         $value = $listing_info[$locationField];
                                                         break;
                                                 }
                                                 $listing_info[$property->id][$locationField] = $value;
                                             }
                                         }
                                     }
                                 }
                             }
                             $field_info = null;
                             $listing = new SJB_Listing($listing_info, $listing_type_sid);
                             foreach ($listing->getProperties() as $property) {
                                 if ($property->getType() == 'tree' && $property->value !== '') {
                                     $treeValues = explode(',', $property->value);
                                     $treeSIDs = array();
                                     foreach ($treeValues as $treeValue) {
                                         $info = SJB_ListingFieldTreeManager::getItemInfoByCaption($property->sid, trim($treeValue));
                                         $treeSIDs[] = $info['sid'];
                                     }
                                     $listing->setPropertyValue($property->id, implode(',', $treeSIDs));
                                     $listing->details->properties[$property->id]->type->property_info['value'] = implode(',', $treeSIDs);
                                 } elseif ($property->getType() == 'monetary') {
                                     $currency = SJB_CurrencyManager::getDefaultCurrency();
                                     $listing->details->properties[$property->id]->type->property_info['value']['add_parameter'] = $currency['sid'];
                                 } elseif ($property->id == 'ApplicationSettings' && !empty($listing_info['ApplicationSettings'])) {
                                     if (preg_match("^[a-z0-9\\._-]+@[a-z0-9\\._-]+\\.[a-z]{2,}\$^iu", $listing_info['ApplicationSettings'])) {
                                         $listing_info['ApplicationSettings'] = array('value' => $listing_info['ApplicationSettings'], 'add_parameter' => 1);
                                     } elseif (preg_match("^(https?:\\/\\/)^iu", $listing_info['ApplicationSettings'])) {
                                         $listing_info['ApplicationSettings'] = array('value' => $listing_info['ApplicationSettings'], 'add_parameter' => 2);
                                     } else {
                                         $listing_info['ApplicationSettings'] = array('value' => '', 'add_parameter' => '');
                                     }
                                     $listing->details->properties[$property->id]->type->property_info['value'] = $listing_info['ApplicationSettings'];
                                 } elseif ($property->getType() == 'complex' && is_array($property->value)) {
                                     $childFields = SJB_ListingComplexFieldManager::getListingFieldsInfoByParentSID($property->sid);
                                     $complexChildValues = $property->value;
                                     foreach ($childFields as $childField) {
                                         if ($childField['type'] == 'complexfile' && !empty($complexChildValues[$childField['id']])) {
                                             $field_info = SJB_ListingComplexFieldManager::getFieldInfoBySID($childField['sid']);
                                             if (isset($listing_info[$property->id][$field_info['id']]) && file_exists($listing_info[$property->id][$field_info['id']])) {
                                                 SJB_UploadFileManager::fileImport($listing_info, $field_info, $property->id);
                                             }
                                         }
                                     }
                                 }
                                 // The import of files at import of listings
                                 if (in_array($property->getType(), array('file', 'logo', 'picture', 'video')) && $property->value !== '') {
                                     $field_info = SJB_ListingFieldDBManager::getListingFieldInfoByID($property->id);
                                     if (isset($listing_info[$field_info['id']]) && file_exists($listing_info[$field_info['id']])) {
                                         SJB_UploadFileManager::fileImport($listing_info, $field_info);
                                     }
                                 }
                             }
                             $listing->deleteProperty('featured');
                             $listing->deleteProperty('priority');
                             $listing->deleteProperty('status');
                             $listing->deleteProperty('reject_reason');
                             $listing->addProperty(array('id' => 'contract_id', 'type' => 'id', 'value' => $contract->getID(), 'is_system' => true));
                             $extraInfo = $contract->extra_info;
                             $listing->setProductInfo($extraInfo);
                             $listing->setPropertyValue('access_type', 'everyone');
                             $listing->setUserSID($current_user->sid);
                             if ($current_user->isSubuser()) {
                                 $subuserInfo = $current_user->getSubuserInfo();
                                 $listing->addSubuserProperty($subuserInfo['sid']);
                             }
                             SJB_ListingManager::saveListing($listing);
                             SJB_Statistics::addStatistics('addListing', $listing->getListingTypeSID(), $listing->getSID(), false, $extraInfo['featured'], $extraInfo['priority']);
                             $contract->incrementPostingsNumber();
                             SJB_ProductsManager::incrementPostingsNumber($contract->product_sid);
                             if (!empty($extraInfo['featured'])) {
                                 SJB_ListingManager::makeFeaturedBySID($listing->getSID());
                             }
                             if (!empty($extraInfo['priority'])) {
                                 SJB_ListingManager::makePriorityBySID($listing->getSID());
                             }
                             $this->FillGallery($listing, $listing_info);
                             $listingSIDs[] = $listing->getSID();
                         }
                         SJB_ListingManager::activateListingBySID($listingSIDs);
                         $tp->assign('listingsNum', count($listingSIDs));
                         $tp->display('job_import_complete.tpl');
                     } else {
                         $tp->assign('charSets', SJB_HelperFunctions::getCharSets());
                         $error = 'LISTINGS_NUMBER_LIMIT_EXCEEDED';
                         $tp->assign('listing_type_id', $listing_type_id);
                         $tp->assign('error', $error);
                         $tp->display('job_import.tpl');
                     }
                 } else {
                     $tp->assign('charSets', SJB_HelperFunctions::getCharSets());
                     $tp->assign('warning', $warning);
                     $tp->assign('contract_id', $contractID);
                     $tp->assign('listing_type_id', $listing_type_id);
                     $tp->display('job_import.tpl');
                 }
             }
         } else {
             $error = $acl->getPermissionMessage('bulk_job_import');
             if (empty($error)) {
                 $error = 'This action is not allowed within your current product';
             }
             $tp->assign('error', $error);
             $tp->assign('charSets', SJB_HelperFunctions::getCharSets());
             $tp->assign('listing_type_id', $listing_type_id);
             $tp->display('job_import.tpl');
         }
     } else {
         if ($error == 'NO_CONTRACT') {
             if ($_GET) {
                 $getParam = '?';
                 foreach ($_GET as $key => $val) {
                     $getParam .= $key . '=' . $val . '&';
                 }
                 $getParam = substr($getParam, 0, -1);
             }
             $page = base64_encode(SJB_System::getURI() . $getParam);
             SJB_HelperFunctions::redirect(SJB_System::getSystemSettings('SITE_URL') . '/my-products/?page=' . $page);
         }
         $tp->assign('charSets', SJB_HelperFunctions::getCharSets());
         $tp->assign('listing_type_id', $listing_type_id);
         $tp->assign('error', $error);
         $tp->display('job_import.tpl');
     }
 }
コード例 #9
0
ファイル: currency.php プロジェクト: Maxlander/shixi
 public function execute()
 {
     $tp = SJB_System::getTemplateProcessor();
     $errors = array();
     $action = SJB_Request::getVar('action', 'list');
     $submit = SJB_Request::getVar('submit', null);
     $currencyInfo = array();
     $sid = SJB_Request::getVar('sid', null);
     switch ($action) {
         case 'add':
             $tp->assign('button', 'Add');
             break;
         case 'edit':
             $currencyInfo = SJB_CurrencyDBManager::getCurrencyInfoBySID($sid);
             $tp->assign('button', 'Edit');
             $tp->assign('sid', $sid);
             $action = 'add';
             break;
         case 'delete':
             SJB_CurrencyDBManager::deleteCurrencyBySID($sid);
             $action = 'list';
             break;
         case 'default':
             SJB_CurrencyDBManager::makeDefaultCurrencyBySID($sid);
             $action = 'list';
             break;
         case 'deactivate':
             SJB_CurrencyDBManager::updateStatusCurrencyBySID($sid, 0);
             $action = 'list';
             break;
         case 'activate':
             SJB_CurrencyDBManager::updateStatusCurrencyBySID($sid, 1);
             $action = 'list';
             break;
     }
     $currencyInfo = array_merge($currencyInfo, $_REQUEST);
     $currency = new SJB_CurrencyManager($currencyInfo);
     if (isset($sid) && !is_null($sid)) {
         $currency->setSID($sid);
     }
     $addCurrencyForm = new SJB_Form($currency);
     $addCurrencyForm->registerTags($tp);
     $form_submitted = SJB_Request::getVar('click');
     $form_fields = $addCurrencyForm->getFormFieldsInfo();
     $tp->assign("form_fields", $form_fields);
     $metaDataProvider = SJB_ObjectMother::getMetaDataProvider();
     $tp->assign("METADATA", array("form_fields" => $metaDataProvider->getFormFieldsMetadata($form_fields)));
     $error = array();
     if ($currency->getPropertyValue('course') <= 0) {
         $currencyCourse = $currency->getProperty('course');
         $error[$currencyCourse->caption] = 'CAN_NOT_EQUAL_NULL';
     }
     switch ($submit) {
         case 'Add':
             if ($addCurrencyForm->isDataValid($errors) && !$error) {
                 SJB_CurrencyDBManager::saveCurrency($currency);
                 $action = 'list';
             } else {
                 $errors = array_merge($errors, $error);
                 $tp->assign('button', 'Add');
                 $action = 'add';
             }
             break;
         case 'Edit':
             if ($addCurrencyForm->isDataValid($errors) && !$error) {
                 SJB_CurrencyDBManager::saveCurrency($currency);
                 $tp->assign('button', 'Edit');
                 $action = 'list';
                 if ($form_submitted == 'apply') {
                     $action = 'add';
                     $tp->assign('sid', $sid);
                     $tp->assign('button', 'Edit');
                 }
             } else {
                 $errors = array_merge($errors, $error);
                 $tp->assign('button', 'Edit');
                 $tp->assign('sid', $_REQUEST['sid']);
                 $action = 'add';
             }
             $currency->setFloatNumbersIntoValidFormat();
             break;
     }
     if ($action == 'list') {
         $tp->assign('currency', SJB_CurrencyManager::getCurrencyList());
     }
     $tp->assign('action', $action);
     $tp->assign('errors', $errors);
     $tp->display('currency.tpl');
 }
コード例 #10
0
 public static function setComplexFields(&$listing_field_info)
 {
     switch ($listing_field_info['type']) {
         case 'list':
         case 'multilist':
             if (!empty($listing_field_info['parent_sid'])) {
                 if ($listing_field_info['id'] == 'Country') {
                     $displayAS = !empty($listing_field_info['display_as']) ? $listing_field_info['display_as'] : 'country_name';
                     $listing_field_info['list_values'] = SJB_CountriesManager::getAllCountriesCodesAndNames(true, $displayAS);
                 }
             } else {
                 $listing_field_info['list_values'] = SJB_ListingFieldDBManager::getListValuesBySID($listing_field_info['sid']);
             }
             break;
         case 'tree':
             $listing_field_info['tree_values'] = SJB_ListingFieldDBManager::getTreeValuesBySID($listing_field_info['sid']);
             $listing_field_info['tree_depth'] = SJB_ListingFieldDBManager::getTreeDepthBySID($listing_field_info['sid']);
             break;
         case 'monetary':
             $listing_field_info['currency_values'] = SJB_CurrencyManager::getActiveCurrencyList();
             break;
         case 'complex':
             $listing_field_info['fields'] = SJB_ListingFieldDBManager::getListingFieldsInfoByParentSID($listing_field_info['sid']);
             $listing_field_info['table_name'] = 'listings';
             break;
         case 'location':
             $listing_field_info['fields'] = SJB_ListingFieldManager::getListingFieldsInfoByParentSID($listing_field_info['sid']);
             break;
         case 'geo':
             if (isset($listing_field_info['parent_sid'])) {
                 $parentID = SJB_DB::queryValue("SELECT `id` FROM `listing_fields` WHERE `sid` = ?n", $listing_field_info['parent_sid']);
                 $listing_field_info['parentID'] = $parentID;
             }
             break;
     }
     $listing_field_info['is_classifieds'] = 1;
 }
コード例 #11
0
ファイル: manage_promotions.php プロジェクト: Maxlander/shixi
 public function execute()
 {
     $tp = SJB_System::getTemplateProcessor();
     $action = SJB_Request::getVar('action', false);
     $template = 'manage_promotions.tpl';
     $errors = array();
     switch ($action) {
         case 'add':
             $promotionCodeInfo = $_REQUEST;
             $formSubmitted = SJB_Request::getVar('event', false);
             $formSubmitted = $formSubmitted == 'save_code' ? true : false;
             $template = 'add_promotion.tpl';
             if (!isset($promotionCodeInfo['active'])) {
                 $promotionCodeInfo['active'] = 1;
             }
             $promotionCode = new SJB_Promotions($promotionCodeInfo);
             $addCodeForm = new SJB_Form($promotionCode);
             $addCodeForm->registerTags($tp);
             if ($formSubmitted && $addCodeForm->isDataValid($errors)) {
                 SJB_PromotionsManager::savePromotionCode($promotionCode);
                 SJB_HelperFunctions::redirect(SJB_System::getSystemSettings('SITE_URL') . "/promotions/");
             }
             $formFields = $addCodeForm->getFormFieldsInfo();
             $tp->assign("form_fields", $formFields);
             $metaDataProvider = SJB_ObjectMother::getMetaDataProvider();
             $tp->assign("METADATA", array("form_fields" => $metaDataProvider->getFormFieldsMetadata($formFields)));
             break;
         case 'edit':
             $template = 'edit_promotion.tpl';
             $promotionSID = SJB_Request::getVar('sid', false);
             $formSubmitted = SJB_Request::getVar('event', false);
             $formSubmitted = $formSubmitted == 'save_code' ? true : false;
             $promotionCodeInfo = SJB_PromotionsManager::getCodeInfoBySID($promotionSID);
             if ($promotionCodeInfo) {
                 $promotionCodeInfo = array_merge($promotionCodeInfo, $_REQUEST);
                 $promotionCode = new SJB_Promotions($promotionCodeInfo);
                 $addCodeForm = new SJB_Form($promotionCode);
                 $addCodeForm->registerTags($tp);
                 $promotionCode->setSID($promotionCodeInfo['sid']);
                 $i18n = SJB_I18N::getInstance();
                 $endDate = !empty($promotionCodeInfo['end_date']) ? $i18n->getInput('date', $promotionCodeInfo['end_date']) : '';
                 if ($formSubmitted && $addCodeForm->isDataValid($errors) && (empty($endDate) || $endDate >= date('Y-m-d') || !$promotionCodeInfo['active'])) {
                     SJB_PromotionsManager::savePromotionCode($promotionCode);
                     SJB_HelperFunctions::redirect(SJB_System::getSystemSettings('SITE_URL') . "/promotions/");
                 } elseif ($formSubmitted && $promotionCodeInfo['active'] == 1 && $endDate < date('Y-m-d')) {
                     $errors["'Active'"] = 'Please change the expiration date first';
                 }
                 $formFields = $addCodeForm->getFormFieldsInfo();
                 $tp->assign("form_fields", $formFields);
                 $tp->assign("sid", $promotionSID);
                 $metaDataProvider = SJB_ObjectMother::getMetaDataProvider();
                 $tp->assign("METADATA", array("form_fields" => $metaDataProvider->getFormFieldsMetadata($formFields)));
             } else {
                 SJB_HelperFunctions::redirect(SJB_System::getSystemSettings('SITE_URL') . "/promotions/");
             }
             break;
         case 'delete':
             $promotionSID = SJB_Request::getVar('sid', 0);
             SJB_PromotionsManager::deleteCodeBySID($promotionSID);
             SJB_HelperFunctions::redirect(SJB_System::getSystemSettings('SITE_URL') . "/promotions/");
             break;
         case 'deactivate':
             $promotionSID = SJB_Request::getVar('sid', false);
             SJB_PromotionsManager::deactivateCodeBySID($promotionSID);
             SJB_HelperFunctions::redirect(SJB_System::getSystemSettings('SITE_URL') . "/promotions/");
             break;
         case 'setting':
             $enablePromotionCodes = SJB_Request::getVar('enable_promotion_codes', 0);
             SJB_Settings::updateSetting('enable_promotion_codes', $enablePromotionCodes);
             SJB_HelperFunctions::redirect(SJB_System::getSystemSettings('SITE_URL') . "/promotions/");
             break;
         case 'activate':
             $promotionSID = SJB_Request::getVar('sid', false);
             $promotionCodeInfo = SJB_PromotionsManager::getCodeInfoBySID($promotionSID);
             if (empty($promotionCodeInfo['end_date']) || $promotionCodeInfo['end_date'] > date('Y-m-d')) {
                 $currentUses = SJB_PromotionsManager::getUsesCodeBySID($promotionSID);
                 $maxUses = $promotionCodeInfo['maximum_uses'];
                 if (!$maxUses || $maxUses > $currentUses) {
                     SJB_PromotionsManager::activateCodeBySID($promotionSID);
                     SJB_HelperFunctions::redirect(SJB_System::getSystemSettings('SITE_URL') . "/promotions/");
                 } else {
                     $errors['MAX_USES_ACHIEVED'] = true;
                 }
             } else {
                 $errors['DATE_IS_NOT_VALID'] = true;
                 $tp->assign('errors', $errors);
             }
         default:
             $promotions = SJB_PromotionsManager::getAllPromotionsInfo();
             foreach ($promotions as $key => $promotion) {
                 $promotions[$key]['uses'] = SJB_PromotionsManager::getUsesCodeBySID($promotion['sid']);
                 if ($promotions[$key]['uses'] >= $promotions[$key]['maximum_uses'] && $promotions[$key]['maximum_uses'] != 0) {
                     $promotions[$key]['active'] = 'used';
                 }
             }
             $currency = SJB_CurrencyManager::getDefaultCurrency();
             $tp->assign('currency', $currency);
             $tp->assign('promotions', $promotions);
             break;
     }
     $tp->assign('errors', $errors);
     $tp->display($template);
 }
コード例 #12
0
 private static function getCurrencyCode()
 {
     $default_currency = SJB_CurrencyManager::getDefaultCurrency();
     $currency_code = $default_currency['currency_code'];
     return $currency_code;
 }
コード例 #13
0
 public static function getSalesExportData($statistics, $exportProperties)
 {
     $export_data = array();
     $currency = SJB_CurrencyManager::getDefaultCurrency();
     foreach ($statistics as $key => $statistic) {
         foreach ($exportProperties as $fieldName => $property) {
             if ($fieldName == 'percent') {
                 $export_data[$key][$fieldName] = $statistic[$fieldName] . '%';
             } elseif ($fieldName == 'total') {
                 $export_data[$key][$fieldName] = $currency['currency_sign'] . $statistic[$fieldName];
             } else {
                 $export_data[$key][$fieldName] = $statistic[$fieldName];
             }
         }
     }
     return $export_data;
 }
コード例 #14
0
ファイル: SearchCriterion.php プロジェクト: Maxlander/shixi
 function getSystemSQL($table = '')
 {
     if (!$this->isValid()) {
         return null;
     }
     $value = $this->value;
     $currency = $this->value['currency'];
     $id = SJB_DB::quote($this->property_name);
     $search = array('%', '_');
     $replace = array('\\%', '\\_');
     if ($currency) {
         $course = SJB_CurrencyManager::getCurrencyByCurrCode($currency);
     }
     $course = isset($course['course']) ? $course['course'] : 1;
     if (!empty($value['not_less']) && !is_numeric($value['not_less'])) {
         $value['not_less'] = SJB_DB::quote($value['not_less']);
         $value['not_less'] = str_replace($search, $replace, $value['not_less']);
         return "(`{$id}` LIKE '%{$value['not_less']}%')";
     }
     if (!empty($value['not_more']) && !is_numeric($value['not_more'])) {
         $value['not_more'] = SJB_DB::quote($value['not_more']);
         $value['not_more'] = str_replace($search, $replace, $value['not_more']);
         return "(`{$id}` LIKE '%{$value['not_more']}%')";
     }
     $notLess = intval($value['not_less'] / $course);
     $notMore = intval($value['not_more'] / $course);
     $allCurrency = SJB_CurrencyManager::getActiveCurrencyList();
     $where = '';
     if (count($allCurrency) > 0) {
         $where = '(';
         foreach ($allCurrency as $currency) {
             if ($this->value['currency']) {
                 $notLessVal = $notLess * $currency['course'];
                 $notMoreVal = $notMore * $currency['course'];
                 $addCurrency = "AND `{$id}_parameter`={$currency['sid']}";
             } else {
                 $notLessVal = $notLess;
                 $notMoreVal = $notMore;
                 $addCurrency = '';
             }
             if ($notLessVal > 0 && $notMoreVal > 0) {
                 $where .= "((`{$id}` BETWEEN {$notLessVal} AND {$notMoreVal}) {$addCurrency}) OR ";
             } elseif ($notLessVal > 0) {
                 $where .= "(`{$id}` >= {$notLessVal} {$addCurrency}) OR ";
             } elseif ($notMoreVal > 0) {
                 $where .= "(`{$id}` BETWEEN 1 AND {$notMoreVal} {$addCurrency}) OR ";
             } else {
                 $where .= "(`{$id}` >= '0') OR ";
             }
         }
         $where = substr($where, 0, -4);
         $where .= ')';
     }
     return "{$where}";
 }