public static function populate($XMLItem, $lists) { $new = new XMLFeedItem(); $new->internal_id = (int) $XMLItem['internal-id']; $new->appType = array_key_exists((string) $XMLItem->type, $lists['types']) ? $lists['types'][(string) $XMLItem->type] : null; $country = null; if (isset($XMLItem->location->country)) { $criteria = new CDbCriteria(); $criteria->compare('name_ru', (string) $XMLItem->location->country, true); $location = LocationCountry::model()->find($criteria); if ($location != null) { $country = $location->id; } else { $country = (string) $XMLItem->location->country; } } $region_item = isset($XMLItem->location->region) ? (string) $XMLItem->location->region : (string) $XMLItem->location->{'locality-name'}; if (isset($XMLItem->location->region)) { $region_item = explode(' ', $region_item); $region_item = $region_item[0]; } $criteria = new CDbCriteria(); $criteria->compare('name_ru', $region_item, true); $region = LocationRegion::model()->find($criteria); if ($region != null) { $region = $region->id; } else { $region = $region_item; } $city = null; if (isset($XMLItem->location->{'locality-name'})) { $criteria = new CDbCriteria(); $criteria->compare('name_ru', (string) $XMLItem->location->{'locality-name'}, true); $location = LocationCity::model()->find($criteria); if ($location != null) { $city = $location->id; } else { $city = (string) $XMLItem->location->{'locality-name'}; } } $title = (string) $XMLItem->type . ' ' . (string) $XMLItem->category; $new->attributes = array('type' => array_key_exists((string) $XMLItem->type, $lists['types']) ? $lists['types'][(string) $XMLItem->type] : (string) $XMLItem->type, 'category' => array_key_exists((string) $XMLItem->category, $lists['category']) ? (int) $lists['category'][(string) $XMLItem->category] : (string) $XMLItem->category, 'title' => $title, 'location_country' => $country, 'location_region' => $region, 'location_city' => $city, 'price' => (isset($XMLItem->price) and isset($XMLItem->price->value)) ? (double) $XMLItem->price->value : null, 'currency' => (isset($XMLItem->price) and isset($XMLItem->price->currency)) ? (string) $XMLItem->price->currency : 'RUR', 'address' => (isset($XMLItem->location) and isset($XMLItem->location->address)) ? (string) $XMLItem->location->address : null, 'rooms' => isset($XMLItem->rooms) ? (int) $XMLItem->rooms : 0, 'floor' => isset($XMLItem->floor) ? (int) $XMLItem->floor : null, 'floor_total' => isset($XMLItem->{'floors-total'}) ? (int) $XMLItem->{'floors-total'} : null, 'area' => (isset($XMLItem->area) and isset($XMLItem->area->value)) ? (double) $XMLItem->area->value : null, 'lot_area' => (isset($XMLItem->{'lot-area'}) and isset($XMLItem->{'lot-area'}->value)) ? (double) $XMLItem->{'lot-area'}->value : null, 'kitchen_space' => (isset($XMLItem->{'kitchen-space'}) and isset($XMLItem->{'kitchen-space'}->value)) ? (double) $XMLItem->{'kitchen-space'}->value : null, 'window_view' => array_key_exists((string) $XMLItem->{'window-view'}, $lists['window_view']) ? $lists['window_view'][(string) $XMLItem->{'window-view'}] : null, 'description' => isset($XMLItem->description) ? (string) $XMLItem->description : '', 'quality' => isset($XMLItem->quality) ? (string) $XMLItem->quality : null, 'phone' => (isset($XMLItem->{'sales-agent'}) and isset($XMLItem->{'sales-agent'}->phone)) ? (string) $XMLItem->{'sales-agent'}->phone : null, 'metro' => 0, 'with_pets' => (isset($XMLItem->{'with-pets'}) and (int) $XMLItem->{'with-pets'} == 1) ? 1 : 0, 'with_children' => (isset($XMLItem->{'with-children'}) and (int) $XMLItem->{'with-children'} == 1) ? 1 : 0, 'with_phone' => isset($XMLItem->phone) ? 1 : 0, 'internet' => isset($XMLItem->internet) ? 1 : 0, 'room_furniture' => (isset($XMLItem->{'room-furniture'}) and (int) $XMLItem->{'room-furniture'} == 1) ? 1 : 0, 'kitchen_furniture' => (isset($XMLItem->{'kitchen-furniture'}) and (int) $XMLItem->{'kitchen-furniture'} == 1) ? 1 : 0, 'television' => (isset($XMLItem->television) and (int) $XMLItem->{'television'} == 1) ? 1 : 0, 'washing_machine' => (isset($XMLItem->{'washing-machine'}) and (int) $XMLItem->{'washing-machine'} == 1) ? 1 : 0, 'refrigerator' => (isset($XMLItem->refrigerator) and (int) $XMLItem->{'refrigerator'} == 1) ? 1 : 0, 'balcony' => (isset($XMLItem->balcony) and (int) $XMLItem->{'balcony'} == 1) ? 1 : 0, 'bathroom_unit' => isset($XMLItem->{'bathroom-unit'}) ? (string) $XMLItem->{'bathroom-unit'} : null, 'floor_covering' => isset($XMLItem->{'floor-covering'}) ? (string) $XMLItem->{'floor-covering'} : null, 'lift' => isset($XMLItem->lift) ? 1 : 0); return $new; }
public function actionPlaceorder() { $country = Yii::app()->request->getParam('country'); $region = Yii::app()->request->getParam('region'); $objType = Yii::app()->request->getParam('objType'); $city = Yii::app()->request->getParam('city'); $price = !is_null(Yii::app()->request->getParam('price')) ? Yii::app()->request->getParam('price') : 0; $pricePoa = $price == 0 ? 1 : 0; $numOfRooms = !is_null(Yii::app()->request->getParam('numOfRooms')) ? Yii::app()->request->getParam('numOfRooms') : 1; $square = !($objType == 4 || $objType == 19) ? Yii::app()->request->getParam('square') : Yii::app()->request->getParam('squareOther'); $squareLive = !($objType == 4 || $objType == 19) ? Yii::app()->request->getParam('squareLive') : Yii::app()->request->getParam('squareLiveOther'); $squareKitchen = !($objType == 4 || $objType == 19) ? Yii::app()->request->getParam('squareKitchen') : Yii::app()->request->getParam('squareKitchenOther'); $floorTotal = !($objType == 4 || $objType == 19) ? Yii::app()->request->getParam('numOfFloors') : Yii::app()->request->getParam('numOfFloorsOther'); $floor = Yii::app()->request->getParam('floor'); $roomFormula = !($objType == 4 || $objType == 19) ? Yii::app()->request->getParam('roomFormula') : Yii::app()->request->getParam('roomFormulaOther'); $windowTo = !($objType == 4 || $objType == 19) ? Yii::app()->request->getParam('window') : Yii::app()->request->getParam('windowOther'); $apType = Yii::app()->request->getParam('renttype') ? Yii::app()->request->getParam('renttype') : 1; $moneyType = Yii::app()->request->getParam('moneyType'); if (Yii::app()->request->getParam('renttype') == 2) { $apType = 2; } $streetName = Yii::app()->request->getParam('street'); $metro = Yii::app()->request->getParam('metro'); $date = new \DateTime(); $createDate = $date->format('Y-m-d H:i:s'); $howLong = Yii::app()->request->getParam('rentlimit') ? Yii::app()->request->getParam('rentlimit') : 3; $limitDate = $date->add(new \DateInterval('P' . $howLong . 'D'))->format('Y-m-d'); $objectDescription = Yii::app()->request->getParam('additional'); $agentbonus = Yii::app()->request->getParam('agentbonus'); $clientbonus = Yii::app()->request->getParam('clientbonus'); $conditions = Yii::app()->request->getParam('condition'); $elevatorPass = Yii::app()->request->getParam('elevatorPass'); $elevatorCargo = Yii::app()->request->getParam('elevatorCargo'); $buildingType = !($objType == 4 || $objType == 19) ? Yii::app()->request->getParam('buildingType') : Yii::app()->request->getParam('buildingTypeOther'); $floorType = !($objType == 4 || $objType == 19) ? Yii::app()->request->getParam('floorType') : Yii::app()->request->getParam('floorTypeOther'); $facingType = !($objType == 4 || $objType == 19) ? Yii::app()->request->getParam('facingtype') : Yii::app()->request->getParam('facingtypeOther'); $balcony = !($objType == 4 || $objType == 19) ? Yii::app()->request->getParam('balcony') : Yii::app()->request->getParam('balconyOther'); $closet = !($objType == 4 || $objType == 19) ? Yii::app()->request->getParam('closet') : Yii::app()->request->getParam('closetOther'); $floorsHeight = Yii::app()->request->getParam('floorsHeight'); $bedrooms = Yii::app()->request->getParam('bedrooms'); $bathrooms = Yii::app()->request->getParam('bathrooms'); $pools = Yii::app()->request->getParam('pools'); $water = Yii::app()->request->getParam('water'); $center = Yii::app()->request->getParam('citycenter'); $mountains = Yii::app()->request->getParam('mountains'); $address = LocationCountry::getAllCountries()[$country] . "," . LocationRegion::getAllRegions()[$region] . "," . LocationCity::getCities()[$city]; if (!is_null($metro)) { $address .= $metro; } if (!is_null($streetName)) { $address .= $streetName; } $lat = Apartment::model()->getCoordinates($address)[0]; $lng = Apartment::model()->getCoordinates($address)[1]; $command = Yii::app()->db->createCommand(); $params = ['type' => $apType, 'obj_type_id' => $objType, 'loc_country' => $country, 'loc_region' => $region, 'loc_city' => $city, 'city_id' => 0, 'visits' => 0, 'date_updated' => $createDate, 'date_created' => $createDate, 'date_end_activity' => $limitDate, 'activity_always' => 1, 'is_price_poa' => $pricePoa, 'price' => $price, 'price_to' => 0, 'num_of_rooms' => $numOfRooms, 'floor' => $floor, 'floor_total' => $floorTotal, 'square' => $square, 'live_square' => $squareLive, 'land_square' => 0, 'ci_square' => $squareKitchen, 'squareFormula' => $roomFormula, 'window_to' => $windowTo, 'title_ru' => LocationCity::getCities()[$city] . ',' . $streetName, 'description_ru' => $objectDescription, 'description_near_ru' => $objectDescription, 'living_conditions' => 0, 'services' => 0, 'address_ru' => $streetName, 'berths' => 0, 'active' => 1, 'lat' => $lat, 'lng' => $lng, 'rating' => 0, 'date_up_search' => $createDate, 'is_special_offer' => 0, 'is_free_to' => $limitDate, 'price_type' => 1, 'sorter' => 1, 'owner_active' => 1, 'owner_id' => Yii::app()->user->id, 'exchange_to_ru' => 'exchange_not_available', 'note' => 'just note', 'phone' => Yii::app()->user->phone, 'autoVKPostId' => 'no', 'autoFBPostId' => 'no', 'autoTwitterPostId' => 'no', 'count_img' => 0, 'deleted' => 0, 'metro' => $metro, 'agentbonus' => $agentbonus, 'clientbonus' => $clientbonus, 'elevatorPass' => $elevatorPass, 'elevatorCargo' => $elevatorCargo, 'buildingType' => $buildingType, 'floorType' => $floorsHeight, 'floors' => $floorType, 'facingType' => $facingType, 'balcony' => $balcony, 'closet' => $closet, 'bedrooms' => $bedrooms, 'bathrooms' => $bathrooms, 'pools' => $pools, 'waterNear' => $water, 'centerNear' => $center, 'mountainsNear' => $mountains, 'moneyType' => $moneyType]; $command->insert('bt_apartment', $params); $apartmentId = Yii::app()->db->getLastInsertID(); foreach ($conditions as $key => $value) { $paramsList = ['apartment_id' => $apartmentId, 'conditionname' => $key]; $command->insert('bt_apartments_conditions', $paramsList); } $this->redirect('/usercpanel/main/rentorders'); }
</div> <div class="block-2"> <div class="col-1"> <img src="<?php echo Yii::app()->theme->baseUrl . '/images/content/col_1_addres.png'; ?> "> </div> <div class="col-2"> <?php $selectedCountryIndex = LocationCountry::getAllCountries()[0]; echo CHtml::dropDownList('country', $select, LocationCountry::getAllCountries(), ['class' => 'long-select', 'options' => [$selectedCoutryIndex => ['selected' => 'selected']]]); ?> <?php $selectedRegionIndex = LocationRegion::getAllRegions()[0]; echo CHtml::dropDownList('region', $select, LocationRegion::getAllRegions(), ['class' => 'long-select', 'options' => [$selectedRegionIndex => ['selected' => 'selected']]]); ?> <?php $selectedCityIndex = LocationCity::getCities()[0]; echo CHtml::dropDownList('city', $select, LocationCity::getCities(), ['class' => 'long-select', 'options' => [$selectedCityIndex => ['selected' => 'selected']]]); ?> <select class="long-select" name="streetname"> <option>Авиамоторная улица</option> </select> <select class="long-select"> <option>12</option> </select> </div> <div class="col-3"> <div class="map-search"></div> </div>