Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public static function getObjTypesArray($with_all = false, $apartmentType = null, $apartmentPriceType = null) {
- $objTypes = $objTypesJsonData = array();
- $objTypeModel = ApartmentObjType::model()->findAll(array(
- 'order' => 'sorter'
- ));
- foreach ($objTypeModel as $type) {
- $objTypes[$type->id] = $type->name;
- $objTypesJsonData[$type->id] = $type->json_data;
- }
- if (!empty($apartmentType) || !empty($apartmentPriceType)) {
- // в функцию передаётся только $apartmentType нужно type конвертнуть в price_type
- # Т.е аренда - это вся аренда: посуточно, помесячно и т.д
- # продажа - продажа
- # Рё С‚.Рї
- if (empty($apartmentPriceType)) {
- $apartmentPriceType = HApartment::getPriceArray($apartmentType, false, false);
- $apartmentPriceType = array_keys($apartmentPriceType);
- if (count($apartmentPriceType) == 1) {
- $apartmentPriceType = $apartmentPriceType[0];
- }
- }
- foreach($objTypesJsonData as $key => $value) {
- $enable = false;
- if (!empty($value)) {
- $valueArr = CJSON::decode($value);
- if (!empty($valueArr) && isset($valueArr['price_types']) && !empty($valueArr['price_types'])) {
- if (!empty($apartmentPriceType)) {
- if (!is_array($apartmentPriceType)) {
- if (is_numeric(array_search($apartmentPriceType, $valueArr['price_types']))) {
- $enable = true;
- }
- }
- else {
- if (!empty(array_intersect($valueArr['price_types'], $apartmentPriceType))) {
- $enable = true;
- }
- }
- }
- }
- }
- if (!$enable) {
- if (isset($objTypes[$key])) {
- unset($objTypes[$key]);
- }
- }
- }
- }
- if ($with_all) {
- $objTypes[0] = tt('All object', 'apartments');
- }
- return $objTypes;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement