コード例 #1
0
ファイル: MainController.php プロジェクト: barricade86/raui
 public function actionAddPaid($id = 0, $withDate = 0)
 {
     $model = new AddToAdForm();
     $paidServices = PaidServices::model()->findAll('id != ' . PaidServices::ID_ADD_FUNDS);
     $paidServicesArray = CHtml::listData($paidServices, 'id', 'name');
     $request = Yii::app()->request;
     $data = $request->getPost('AddToAdForm');
     if ($data) {
         $apartmentId = $request->getPost('ad_id');
         $withDate = $request->getPost('withDate');
         $model->attributes = $data;
         if ($model->validate()) {
             $apartment = Apartment::model()->findByPk($apartmentId);
             $paidService = PaidServices::model()->findByPk($model->paid_id);
             if (!$paidService || !$apartment) {
                 throw new CException('Not valid data');
             }
             if (PaidServices::applyToApartment($apartmentId, $paidService->id, $model->date_end)) {
                 echo CJSON::encode(array('status' => 'ok', 'apartmentId' => $apartmentId, 'html' => $apartment->getPaidHtml($withDate, true)));
                 Yii::app()->end();
             }
         } else {
             echo CJSON::encode(array('status' => 'err', 'html' => $this->renderPartial('_add_to_form', array('id' => $apartmentId, 'model' => $model, 'withDate' => $withDate, 'paidServicesArray' => $paidServicesArray), true)));
             Yii::app()->end();
         }
     }
     $renderData = array('id' => $id, 'model' => $model, 'withDate' => $withDate, 'paidServicesArray' => $paidServicesArray);
     if (Yii::app()->request->isAjaxRequest) {
         $this->renderPartial('_add_to_ad', $renderData);
     } else {
         $this->render('_add_to_ad', $renderData);
     }
 }
コード例 #2
0
ファイル: BeginRequest.php プロジェクト: alexjkitty/estate
 public static function checkStatusAd()
 {
     $activePaids = ApartmentPaid::model()->findAll('date_end <= NOW() AND status=' . ApartmentPaid::STATUS_ACTIVE);
     foreach ($activePaids as $paid) {
         $paid->status = ApartmentPaid::STATUS_NO_ACTIVE;
         if ($paid->paid_id == PaidServices::ID_SPECIAL_OFFER || $paid->paid_id == PaidServices::ID_UP_IN_SEARCH) {
             $apartment = Apartment::model()->findByPk($paid->apartment_id);
             if ($apartment) {
                 $apartment->scenario = 'update_status';
                 if ($paid->paid_id == PaidServices::ID_SPECIAL_OFFER) {
                     $apartment->is_special_offer = 0;
                     $apartment->update(array('is_special_offer'));
                 }
                 if ($paid->paid_id == PaidServices::ID_UP_IN_SEARCH) {
                     $apartment->date_up_search = new CDbExpression('NULL');
                     $apartment->update(array('date_up_search'));
                 }
             }
         }
         if (!$paid->update(array('status'))) {
             //deb($paid->getErrors());
         }
     }
     $adEndActivity = Apartment::model()->with('user')->findAll('t.date_end_activity <= NOW() AND t.activity_always != 1 AND (t.active=:status OR t.owner_active=:status)', array(':status' => Apartment::STATUS_ACTIVE));
     foreach ($adEndActivity as $ad) {
         $ad->scenario = 'update_status';
         if (isset($ad->user) && $ad->user->isAdmin == 1) {
             $ad->active = Apartment::STATUS_INACTIVE;
         } else {
             $ad->active = Apartment::STATUS_INACTIVE;
             $ad->owner_active = Apartment::STATUS_INACTIVE;
         }
         $ad->save(false);
     }
 }
コード例 #3
0
ファイル: SearchForm.php プロジェクト: barricade86/raui
 public static function apTypes()
 {
     $result = Apartment::getApTypes();
     if (Yii::app()->theme->name == 'atlas') {
         $types = array(0 => Yii::t('common', 'Type of listing'));
     } else {
         $types = array(0 => Yii::t('common', 'Please select'));
     }
     if (param('useTypeSale', 1)) {
         if (in_array(Apartment::PRICE_SALE, $result)) {
             $types[Apartment::PRICE_SALE] = utf8_ucfirst(tt('Sale', 'apartments'));
         }
     }
     if (param('useTypeBuy', 1)) {
         if (in_array(Apartment::PRICE_BUY, $result)) {
             $types[Apartment::PRICE_BUY] = utf8_ucfirst(tt('Buy a', 'apartments'));
         }
     }
     if (param('useTypeRenting', 1)) {
         if (in_array(Apartment::PRICE_RENTING, $result)) {
             $types[Apartment::PRICE_RENTING] = utf8_ucfirst(tt('Rent a', 'apartments'));
         }
     }
     if (param('useTypeChange', 1)) {
         if (in_array(Apartment::PRICE_CHANGE, $result)) {
             $types[Apartment::PRICE_CHANGE] = utf8_ucfirst(tt('Exchange', 'apartments'));
         }
     }
     if (param('useTypeRentDay', 1)) {
         if (in_array(Apartment::PRICE_PER_DAY, $result)) {
             $types[Apartment::PRICE_PER_DAY] = utf8_ucfirst(tc('rent by the day'));
         }
     }
     if (param('useTypeRentHour', 1)) {
         if (in_array(Apartment::PRICE_PER_HOUR, $result)) {
             $types[Apartment::PRICE_PER_HOUR] = utf8_ucfirst(tc('rent by the hour'));
         }
     }
     if (param('useTypeRentMonth', 1)) {
         if (in_array(Apartment::PRICE_PER_MONTH, $result)) {
             $types[Apartment::PRICE_PER_MONTH] = utf8_ucfirst(tc('rent by the month'));
         }
     }
     if (param('useTypeRentWeek', 1)) {
         if (in_array(Apartment::PRICE_PER_WEEK, $result)) {
             $types[Apartment::PRICE_PER_WEEK] = utf8_ucfirst(tc('rent by the week'));
         }
     }
     $return['propertyType'] = $types;
     if (issetModule('selecttoslider') && param('usePriceSlider') == 1) {
         $return['currencyTitle'] = array(Yii::t('common', 'Price range') . ':', Yii::t('common', 'Price range') . ':', Yii::t('common', 'Price range') . ':', Yii::t('common', 'Price range') . ':', Yii::t('common', 'Price range') . ':', Yii::t('common', 'Price range') . ':');
     } else {
         $return['currencyTitle'] = array(Yii::t('common', 'Payment to'), Yii::t('common', 'Payment to'), Yii::t('common', 'Fee up to'), Yii::t('common', 'Fee up to'), Yii::t('common', 'Fee up to'), Yii::t('common', 'Fee up to'));
     }
     return $return;
 }
コード例 #4
0
ファイル: SearchForm.php プロジェクト: alexjkitty/estate
 public static function apTypes()
 {
     $result = Apartment::getApTypes();
     $types = array(0 => Yii::t('common', 'Please select'));
     if (param('useTypeSale', 1)) {
         if (in_array(Apartment::PRICE_SALE, $result)) {
             $types[Apartment::PRICE_SALE] = tt('Sale', 'apartments');
         }
     }
     if (param('useTypeBuy', 1)) {
         if (in_array(Apartment::PRICE_BUY, $result)) {
             $types[Apartment::PRICE_BUY] = tt('Buy a', 'apartments');
         }
     }
     if (param('useTypeRenting', 1)) {
         if (in_array(Apartment::PRICE_RENTING, $result)) {
             $types[Apartment::PRICE_RENTING] = tt('Rent a', 'apartments');
         }
     }
     if (param('useTypeChange', 1)) {
         if (in_array(Apartment::PRICE_CHANGE, $result)) {
             $types[Apartment::PRICE_CHANGE] = tt('Exchange', 'apartments');
         }
     }
     if (param('useTypeMortgage', 1)) {
         if (in_array(Apartment::PRICE_MORTGAGE, $result)) {
             $types[Apartment::PRICE_MORTGAGE] = tt('Mortgage', 'apartments');
         }
     }
     if (param('useTypePrivatisation', 1)) {
         if (in_array(Apartment::PRICE_PRIVATISATION, $result)) {
             $types[Apartment::PRICE_PRIVATISATION] = tt('Privatisation', 'apartments');
         }
     }
     if (param('useTypeRent', 1)) {
         if (in_array(Apartment::PRICE_PER_DAY, $result)) {
             $types[Apartment::PRICE_PER_DAY] = tc('rent by the day');
         }
         if (in_array(Apartment::PRICE_PER_HOUR, $result)) {
             $types[Apartment::PRICE_PER_HOUR] = tc('rent by the hour');
         }
         if (in_array(Apartment::PRICE_PER_MONTH, $result)) {
             $types[Apartment::PRICE_PER_MONTH] = tc('rent by the month');
         }
         if (in_array(Apartment::PRICE_PER_WEEK, $result)) {
             $types[Apartment::PRICE_PER_WEEK] = tc('rent by the week');
         }
     }
     $return['propertyType'] = $types;
     if (issetModule('selecttoslider') && param('usePriceSlider') == 1) {
         $return['currencyTitle'] = array(Yii::t('common', 'Price range') . ':', Yii::t('common', 'Price range') . ':', Yii::t('common', 'Price range') . ':', Yii::t('common', 'Price range') . ':', Yii::t('common', 'Price range') . ':', Yii::t('common', 'Price range') . ':');
     } else {
         $return['currencyTitle'] = array(Yii::t('common', 'Payment to'), Yii::t('common', 'Payment to'), Yii::t('common', 'Fee up to'), Yii::t('common', 'Fee up to'), Yii::t('common', 'Fee up to'), Yii::t('common', 'Fee up to'));
     }
     return $return;
 }
コード例 #5
0
ファイル: Iecsv.php プロジェクト: barricade86/raui
 public function init()
 {
     $this->preparePaths();
     $this->publishAssets();
     $fileMaxSize['postSize'] = toBytes(ini_get('post_max_size'));
     $fileMaxSize['uploadSize'] = toBytes(ini_get('upload_max_filesize'));
     $this->fileMaxSize = min($fileMaxSize);
     $this->fileMaxSizeMessage = self::formatBytes($this->fileMaxSize);
     parent::init();
 }
コード例 #6
0
ファイル: Bookingcalendar.php プロジェクト: barricade86/raui
 public static function isUserAd($apartmentId = null, $ownerId = null)
 {
     if ($apartmentId && $ownerId) {
         if (Apartment::model()->findByAttributes(array('id' => $apartmentId, 'owner_id' => $ownerId))) {
             return true;
         }
         return false;
     }
     return false;
 }
コード例 #7
0
ファイル: MainController.php プロジェクト: barricade86/raui
 public function actionActivate()
 {
     $id = intval(Yii::app()->request->getQuery('id', 0));
     if ($id) {
         $action = Yii::app()->request->getQuery('action');
         $model = $this->loadModel($id);
         if ($model) {
             if ($model->name == 'useTypeRentHour' || $model->name == 'useTypeRentDay' || $model->name == 'useTypeRentWeek' || $model->name == 'useTypeRentMonth' || $model->name == 'useTypeSale' || $model->name == 'useTypeRenting' || $model->name == 'useTypeBuy' || $model->name == 'useTypeChange') {
                 if (count(Apartment::availableApTypesIds()) == 1 && $action == 'deactivate') {
                     if (!Yii::app()->request->isAjaxRequest) {
                         $this->redirect(isset($_POST['returnUrl']) ? $_POST['returnUrl'] : array('admin'));
                     }
                     Yii::app()->end;
                 }
             }
             // delete assets js cache
             ConfigurationModel::clearGenerateJSAssets();
             $model->value = $action == 'activate' ? 1 : 0;
             $model->update(array('value'));
             if ($model->name == 'useGoogleMap' && $model->value == 1) {
                 $modelToggle = ConfigurationModel::model()->findAllByAttributes(array('name' => array('useYandexMap', 'useOSMMap')));
                 if ($modelToggle) {
                     foreach ($modelToggle as $mToggle) {
                         $mToggle->value = 0;
                         $mToggle->update(array('value'));
                     }
                 }
             }
             if ($model->name == 'useYandexMap' && $model->value == 1) {
                 $modelToggle = ConfigurationModel::model()->findAllByAttributes(array('name' => array('useGoogleMap', 'useOSMMap')));
                 if ($modelToggle) {
                     foreach ($modelToggle as $mToggle) {
                         $mToggle->value = 0;
                         $mToggle->update(array('value'));
                     }
                 }
             }
             if ($model->name == 'useOSMMap' && $model->value == 1) {
                 $modelToggle = ConfigurationModel::model()->findAllByAttributes(array('name' => array('useYandexMap', 'useGoogleMap')));
                 if ($modelToggle) {
                     foreach ($modelToggle as $mToggle) {
                         $mToggle->value = 0;
                         $mToggle->update(array('value'));
                     }
                 }
             }
             if ($model->name == 'useLocation') {
                 echo 'reload';
             }
         }
     }
     if (!Yii::app()->request->isAjaxRequest) {
         $this->redirect(isset($_POST['returnUrl']) ? $_POST['returnUrl'] : array('admin'));
     }
 }
コード例 #8
0
 protected function FetchResults(sfWebRequest $request, $by_period = false)
 {
     $this->city = Doctrine_Core::getTable('City')->FindByNameLike($request->getParameter('city'));
     $this->features = Doctrine_Core::getTable('Feature')->GetByIds($request->getParameter('features'));
     if ($by_period) {
         $apps = Doctrine_Core::getTable('Apartment')->getApartmentsByFeatures($request->getParameter('features'), $this->city->getId());
         $this->apps = Apartment::AvalibilityInPeriod($apps, $request->getParameter('date_from'), $request->getParameter('date_to'));
     } else {
         $this->apps = Doctrine_Core::getTable('Apartment')->getApartmentsByFeatures($request->getParameter('features'), $this->city->getId());
     }
 }
コード例 #9
0
 public function CheckBookingPossibility(Apartment $app, $pax)
 {
     /* Avalibility check. Expecting TRUE or FALSE  */
     $avalibility = $app->CheckBookingsInPeriod($this->date_from, $this->date_to);
     /* Are dates valid for individual apartment ? */
     $dates = true;
     /* Minimum or maximum pax for individual apartment or ... ? */
     $pax_valid = false;
     if ($pax >= 1 && $pax <= $app->getMaxPax()) {
         $pax_valid = true;
     }
     /* Are there periods for dates... Can we get real price ? */
     $price = false;
     if (Booking::CalculatePrice($app, $this->date_from, $this->date_to) > 0) {
         $price = true;
     }
     if ($dates === true && $avalibility === false && $pax_valid === true && $price === true) {
         return $this;
     } else {
         return false;
     }
 }
コード例 #10
0
 /**
  * Show the form for editing the specified resource.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function edit($id, $request)
 {
     $apartment = Apartment::find($id);
     $profile = Auth::user()->profile;
     $block_no = $request->input('blockno');
     // get block_no from profileform
     $floor_no = $request->input('floorno');
     // get floor_no from profileform
     //        $profile->apartments()->updateExistingPivot($profile->defaultApartment , ['approved' => '1', 'block_no' => $block_no, 'floor_no' => $floor_no]);
     $profile->apartments()->detach($apartment);
     $profile->apartments()->attach($apartment, ['approved' => '1', 'block_no' => $block_no, 'floor_no' => $floor_no]);
     return redirect()->back()->withMessage('Block / Flat Number Updated')->withStatus('success');
 }
コード例 #11
0
ファイル: HApartment.php プロジェクト: barricade86/raui
 /** Сохраняем данные выбранных справочников
  * @return array
  */
 public static function getCategoriesForUpdate(Apartment $ad)
 {
     if (isset($_POST['category']) && is_array($_POST['category'])) {
         $ad->references = Apartment::getCategories(null, $ad->type);
         foreach ($_POST['category'] as $cat => $categoryArray) {
             foreach ($categoryArray as $key => $value) {
                 $ad->references[$cat]['values'][$key]['selected'] = true;
             }
         }
     } else {
         $ad->references = Apartment::getCategories($ad->id, $ad->type);
     }
     return $ad->references;
 }
コード例 #12
0
ファイル: MainController.php プロジェクト: barricade86/raui
 public function actionSetCount()
 {
     $sql = "SELECT COUNT(id) AS count_img, id_object FROM {{images}} GROUP BY id_object";
     $res = Yii::app()->db->createCommand($sql)->queryAll();
     foreach ($res as $item) {
         $model = Apartment::model()->findByPk($item['id_object']);
         if ($model) {
             $model->count_img = $item['count_img'];
             $model->update(array('count_img'));
         } else {
             echo 'not found model with id = ' . $item['id_object'] . '<br>';
         }
     }
     deb($res);
 }
コード例 #13
0
ファイル: RssWidget.php プロジェクト: barricade86/raui
 private function prepareItems($xmlWriter = null)
 {
     $this->criteria->limit = param('module_rss_itemsPerFeed', 20);
     $items = Apartment::model()->findAll($this->criteria);
     if ($items) {
         foreach ($items as $item) {
             $xmlWriter->startElement("item");
             $xmlWriter->writeElement('title', CHtml::encode($item->getStrByLang('title')));
             $xmlWriter->writeElement('link', $item->getUrl());
             $xmlWriter->writeElement('description', $this->getDescription($item));
             $xmlWriter->writeElement('pubDate', $this->getDateFormat(strtotime($item->date_updated)));
             $xmlWriter->endElement();
             // end item
         }
     }
 }
コード例 #14
0
 /**
  * Update the specified resource in storage.
  * Store Block / Flat and Floor Number.
  *
  * @param Request $request
  * @param  int $id
  * @return \Illuminate\Http\Response
  */
 public function update(Request $request, $id)
 {
     $apartment = Apartment::find($id);
     $profile = Auth::user()->profile;
     $block_no = $request->input('blockno');
     // get block_no from profileform
     $floor_no = $request->input('floorno');
     // get floor_no from profileform
     $isOwner = $request->input('isOwner');
     // get Owner from profileform
     $lock = $request->input('lock');
     // get lock status from profileform
     $profile->apartments()->detach($apartment);
     $profile->apartments()->attach($apartment, ['approved' => '1', 'block_no' => $block_no, 'floor_no' => $floor_no, 'isOwner' => $isOwner, 'lock' => $lock]);
     return redirect()->back()->withMessage('Block / Flat Number Updated')->withStatus('success');
 }
コード例 #15
0
ファイル: MainController.php プロジェクト: alexjkitty/estate
 public function actionIndex()
 {
     Yii::import('application.modules.apartments.helpers.apartmentsHelper');
     Yii::app()->getModule('referencecategories');
     $criteria = new CDbCriteria();
     $criteria->addInCondition('t.id', Yii::app()->controller->apInComparison);
     $result = apartmentsHelper::getApartments(param('countListingsInComparisonList', 5), 0, 0, $criteria);
     $apartments = null;
     if (array_key_exists('criteria', $result)) {
         $apartments = Apartment::findAllWithCache($result['criteria']);
     }
     if (!$apartments) {
         $this->redirect(Yii::app()->controller->createAbsoluteUrl('/'));
     }
     $this->render('index', array('apartments' => $apartments));
 }
コード例 #16
0
ファイル: MainController.php プロジェクト: barricade86/raui
 public function actionComplain($isFancy = 0)
 {
     $id = Yii::app()->request->getParam('id', 0);
     if (!$id) {
         throw404();
     }
     $model = new $this->modelName();
     $modelApartment = Apartment::model()->findByPk($id);
     if (!$modelApartment) {
         throw404();
     }
     if (isset($_POST[$this->modelName]) && BlockIp::checkAllowIp(Yii::app()->controller->currentUserIpLong)) {
         $model->attributes = $_POST[$this->modelName];
         $model->apartment_id = $id;
         $model->session_id = Yii::app()->session->sessionId;
         $model->user_id = 0;
         $model->user_ip = Yii::app()->controller->currentUserIp;
         $model->user_ip_ip2_long = Yii::app()->controller->currentUserIpLong;
         if (!Yii::app()->user->isGuest) {
             $model->email = Yii::app()->user->email;
             $model->name = Yii::app()->user->username;
             $model->user_id = Yii::app()->user->id;
         }
         if ($model->validate()) {
             if ($this->checkAlreadyComplain($model->apartment_id, $model->user_id, $model->session_id)) {
                 if ($model->save(false)) {
                     $notifier = new Notifier();
                     $notifier->raiseEvent('onNewComplain', $model);
                     Yii::app()->user->setFlash('success', tt('Thanks_for_complain', 'apartmentsComplain'));
                     $model = new $this->modelName();
                     // clear fields
                 }
             } else {
                 Yii::app()->user->setFlash('notice', tt('your_already_post_complain', 'apartmentsComplain'));
             }
         }
     }
     if ($isFancy) {
         Yii::app()->clientscript->scriptMap['jquery.js'] = false;
         Yii::app()->clientscript->scriptMap['jquery.min.js'] = false;
         Yii::app()->clientscript->scriptMap['jquery-ui.min.js'] = false;
         $this->renderPartial('complain_form', array('model' => $model, 'apId' => $id, 'isFancy' => true, 'modelApartment' => $modelApartment), false, true);
     } else {
         $this->render('complain_form', array('model' => $model, 'apId' => $id, 'modelApartment' => $modelApartment, 'wtf' => 'huilo'));
     }
 }
コード例 #17
0
ファイル: SimilarAds.php プロジェクト: alexjkitty/estate
 public function getSimilarAds($inCriteria = null)
 {
     if ($inCriteria === null) {
         $criteria = new CDbCriteria();
         $criteria->addCondition('active = ' . Apartment::STATUS_ACTIVE);
         if (param('useUserads')) {
             $criteria->addCondition('owner_active = ' . Apartment::STATUS_ACTIVE);
         }
         $criteria->order = $this->getTableAlias() . '.id ASC';
     } else {
         $criteria = $inCriteria;
     }
     Yii::import('application.modules.apartments.helpers.apartmentsHelper');
     $similarAds = array();
     $similarAds['apartments'] = Apartment::model()->cache(param('cachingTime', 1209600), Apartment::getImagesDependency())->with(array('images'))->findAll($criteria);
     return is_array($similarAds['apartments']) && count($similarAds['apartments']) ? $similarAds['apartments'] : '';
 }
コード例 #18
0
ファイル: ApartmentCity.php プロジェクト: barricade86/raui
    public static function getActiveCity()
    {
        if (self::$_activeCity === null) {
            $ownerActiveCond = '';
            if (param('useUserads')) {
                $ownerActiveCond = ' AND ap.owner_active = ' . Apartment::STATUS_ACTIVE . ' ';
            }
            $sql = 'SELECT ac.name_' . Yii::app()->language . ' AS name, ac.id AS id
					FROM {{apartment}} ap, {{apartment_city}} ac
					WHERE ac.id = ap.city_id
					AND ap.price_type IN (' . implode(',', array_keys(Apartment::getPriceArray(Apartment::PRICE_SALE, true))) . ')
					AND ap.active = ' . Apartment::STATUS_ACTIVE . ' ' . $ownerActiveCond . '
					ORDER BY ac.sorter';
            $results = Yii::app()->db->createCommand($sql)->queryAll();
            self::$_activeCity = CHtml::listData($results, 'id', 'name');
        }
        return self::$_activeCity;
    }
コード例 #19
0
ファイル: apartmentsHelper.php プロジェクト: barricade86/raui
 public static function getApartments($limit = 10, $usePagination = 1, $all = 1, $criteria = null)
 {
     $pages = array();
     Yii::app()->getModule('apartments');
     if ($criteria === null) {
         $criteria = new CDbCriteria();
     }
     if (!$all) {
         $criteria->addCondition('t.deleted = 0');
         $criteria->addCondition('t.active = ' . Apartment::STATUS_ACTIVE);
         if (param('useUserads')) {
             $criteria->addCondition('owner_active = ' . Apartment::STATUS_ACTIVE);
         }
     }
     $sort = new CSort('Apartment');
     $sort->attributes = array('price' => 'price', 'date_created' => 'date_created');
     if (!$criteria->order) {
         $sort->defaultOrder = 't.date_up_search DESC, t.sorter DESC';
     }
     $sort->applyOrder($criteria);
     $sorterLinks = self::getSorterLinks($sort);
     $criteria->addCondition('t.owner_id = 1 OR t.owner_active = 1');
     $criteria->addInCondition('t.type', Apartment::availableApTypesIds());
     $criteria->addInCondition('t.price_type', array_keys(Apartment::getPriceArray(Apartment::PRICE_SALE, true)));
     // find count
     $apCount = Apartment::model()->count($criteria);
     if ($usePagination) {
         $pages = new CPagination($apCount);
         $pages->pageSize = $limit;
         $pages->applyLimit($criteria);
     } else {
         $criteria->limit = $limit;
     }
     if (issetModule('seo')) {
         $criteria->with = array('seo');
     }
     //		$apartments = Apartment::model()
     //			->cache(param('cachingTime', 1209600), Apartment::getImagesDependency())
     //			->with(array('images'))
     //			->findAll($criteria);
     return array('pages' => $pages, 'sorterLinks' => $sorterLinks, 'apCount' => $apCount, 'criteria' => $criteria);
 }
コード例 #20
0
ファイル: main.php プロジェクト: alexjkitty/estate
                    <?php 
Yii::app()->controller->renderPartial('//site/index-search');
?>
		        </div>
				
				<div class="zayavka shadow">
				    <a href="<?php 
echo $baseUrl;
?>
/booking/request"><?php 
echo tt('Application selection', 'common');
?>
</a>
				</div>
                <?php 
$lastViewedApartmentCount = Apartment::getLastVisitedObjects();
if ($lastViewedApartmentCount[0] > 0) {
    ?>
                    <div class="zayavka shadow">
                        <a href="<?php 
    echo $baseUrl;
    ?>
/apartments/main/last"><?php 
    echo tt('My views', 'common') . ' (' . $lastViewedApartmentCount[0] . ')';
    ?>
</a>
                    </div>
				<?php 
}
?>
                <?php 
コード例 #21
0
ファイル: MainController.php プロジェクト: barricade86/raui
 public function actionDeleteImage($id)
 {
     $model = $this->checkOwnerImage($id);
     unset($model->sorter);
     $ad = Apartment::model()->findByPk($model->id_object);
     if ($model->delete() && $ad) {
         $ad->count_img--;
         $ad->update('count_img');
     }
     if ($model->is_main) {
         $sql = 'SELECT id FROM {{images}} WHERE is_main=1 AND id_object=:id';
         echo Yii::app()->db->createCommand($sql)->queryScalar(array(':id' => $model->id_object));
     }
 }
コード例 #22
0
				<?php 
    if (array_key_exists($item->id, $countImagesArr) && $countImagesArr[$item->id] > 1) {
        ?>
					<div class="apartment_count_img"><img src="<?php 
        echo Yii::app()->baseUrl;
        ?>
/images/photo_count.png"><b><?php 
        echo $countImagesArr[$item->id];
        ?>
</b></div>
				<?php 
    }
    ?>

				<div class="apartment_type"><?php 
    echo Apartment::getNameByType($item->type);
    ?>
</div>

				<?php 
    $res = Images::getMainThumb(150, 100, $item->images);
    $img = CHtml::image($res['thumbUrl'], $item->getStrByLang('title'), array('title' => $item->getStrByLang('title'), 'class' => 'apartment_type_img'));
    echo CHtml::link($img, $item->getUrl(), array('title' => $item->getStrByLang('title')));
    ?>

                </div>
			</div>
			<div class="offer-text">
				<div class="apartment-title">
						<?php 
    $title = CHtml::encode($item->getStrByLang('title'));
コード例 #23
0
ファイル: view_export.php プロジェクト: barricade86/raui
$this->adminTitle = tt('Export');
?>

<div>
	<p><?php 
echo tt('The file is exported to the UTP-8 without BOM charset.');
?>
</p>
	<p><?php 
echo tt('Separators are ";".');
?>
</p>
</div>

<?php 
$columns = array(array('class' => 'CCheckBoxColumn', 'header' => tt('Select'), 'id' => 'itemsSelectedExport'), array('name' => 'id', 'htmlOptions' => array('class' => 'apartments_id_column', 'style' => 'text-align: center;'), 'sortable' => false), array('name' => 'active', 'type' => 'raw', 'value' => 'Yii::app()->controller->returnControllerStatusHtml($data, "apartments-grid", 1)', 'htmlOptions' => array('class' => 'apartments_status_column'), 'filter' => Apartment::getModerationStatusArray(), 'sortable' => false), array('name' => 'type', 'type' => 'raw', 'value' => 'Apartment::getNameByType($data->type)', 'htmlOptions' => array('style' => 'width: 100px;'), 'filter' => Apartment::getTypesArray(), 'sortable' => false));
if (issetModule('location')) {
    $columns[] = array('name' => 'loc_country', 'value' => '$data->loc_country ? $data->locCountry->name : ""', 'htmlOptions' => array('style' => 'width: 150px;'), 'sortable' => false, 'filter' => Country::getCountriesArray(0, 1));
    $columns[] = array('name' => 'loc_region', 'value' => '$data->loc_region ? $data->locRegion->name : ""', 'htmlOptions' => array('style' => 'width: 150px;'), 'sortable' => false, 'filter' => Region::getRegionsArray($model->loc_country, 0, 1));
    $columns[] = array('name' => 'loc_city', 'value' => '$data->loc_city ? $data->locCity->name : ""', 'htmlOptions' => array('style' => 'width: 150px;'), 'sortable' => false, 'filter' => City::getCitiesArray($model->loc_region, 0, 1));
} else {
    $columns[] = array('name' => 'city_id', 'value' => '(isset($data->city ) && $data->city_id) ? $data->city->name : ""', 'htmlOptions' => array('style' => 'width: 150px;'), 'filter' => ApartmentCity::getAllCity(), 'sortable' => false);
}
$columns[] = array('name' => 'ownerEmail', 'htmlOptions' => array('style' => 'width: 150px;'), 'type' => 'raw', 'value' => '(isset($data->user) && $data->user->role != "admin") ? CHtml::link(CHtml::encode($data->user->email), array("/users/backend/main/view","id" => $data->user->id)) : tt("administrator", "common")');
$columns[] = array('header' => tc('Name'), 'name' => 'title_' . Yii::app()->language, 'type' => 'raw', 'value' => 'CHtml::link(CHtml::encode($data->{"title_".Yii::app()->language}), $data->getUrl())', 'sortable' => false);
?>


<div class="form">
	<?php 
$this->widget('CustomHistoryGridView', array('id' => 'export-grid', 'dataProvider' => $model->searchExport(), 'filter' => $model, 'selectableRows' => 2, 'selectionChanged' => 'js:selItemsSelected', 'columns' => $columns));
コード例 #24
0
ファイル: MainController.php プロジェクト: barricade86/raui
 public function actionNegatives()
 {
     $this->layout = '//layouts/negatives';
     $sql = "SELECT * FROM bt_apartment t1 WHERE t1.owner_id=" . HUser::getModel()->id . " AND EXISTS (select null FROM bt_apartment_complain t2 WHERE t2.apartment_id=t1.id AND t2.active=1)";
     $negatives = Apartment::model()->findAllBySql($sql);
     $this->render('negatives', ['negatives' => $negatives]);
 }
コード例 #25
0
<?php

if (empty($apartments)) {
    $apartments = Apartment::findAllWithCache($criteria);
}
?>

<?php 
foreach ($apartments as $item) {
    ?>




<!--Вывод результата-->

<?php 
    $title = CHtml::encode($item->getStrByLang('title'));
    if (utf8_strlen($title) > 30) {
        $title = utf8_substr($title, 0, 30) . '...';
    }
    // Обрезаем, если больше 20
    $description = '';
    if ($item->canShowInView('description')) {
        $description = $item->getStrByLang('description');
    }
    ?>



                    <div class="new-building-object-list">
コード例 #26
0
                </div>
                <!-- eof clientCard div -->
                <div class="col-sm-1"> <!-- leftMenu <=> right zone razdelitel vert poloska -->
                </div>
            </div>
            <!-- ################################# LEFT MENU ################################################# -->
            <div class="row pCab_leftMenuDiv"> <!-- left menu row -->
                <ul class="pCab_leftMenuItems">
                    <li id="lm1"><a href="#">Объявления</a>
                        <ul class="sub-menu">
                            <li><a href="/usercpanel/?type=1">Аренда</a><span><?php 
echo Apartment::model()->count('type=:typeId AND owner_id=:userId', [':typeId' => (int) $_GET['type'], ':userId' => $user->id]);
?>
</span></li>
                            <li><a href="/usercpanel/?type=3">Продажа</a><span><?php 
echo Apartment::model()->count('type=:typeId AND owner_id=:userId', [':typeId' => (int) $_GET['type'], ':userId' => $user->id]);
?>
</span></li>
                            <li><a href="#">Избранные</a><span>3</span></li>
                            <li><a href="/usercpanel/main/rentorders">Разместить</a></li>
                            <li><a href="/usercpanel/xmlfeed">XML-фид</a></li>
                        </ul>
                    </li>
                    <li id="lm2"><a href="#">Заявки</a>
                        <ul class="sub-menu">
                            <li><a href="/usercpanel/main/rentsdisplay/?type=1">Аренда</a><span><?php 
echo !is_null(ApartmentsRents::model()->findByAttributes(['type' => [1, 2], 'userFrom' => Yii::app()->user->id])) ? ApartmentsRents::model()->findByAttributes(['type' => [1, 2], 'userFrom' => Yii::app()->user->id])->count() : 0;
?>
</span></li>
                            <li><a href="/usercpanel/main/rentsdisplay/?type=3">Продажа</a><span><?php 
echo !is_null(ApartmentsRents::model()->findByAttributes(['type' => 3, 'userFrom' => Yii::app()->user->id])) ? ApartmentsRents::model()->findByAttributes(['type' => 3, 'userFrom' => Yii::app()->user->id])->count() : 0;
コード例 #27
0
ファイル: MainController.php プロジェクト: alexjkitty/estate
 public function getExistRooms()
 {
     return Apartment::getExistsRooms();
 }
コード例 #28
0
 public function actionActivate()
 {
     $field = isset($_GET['field']) ? $_GET['field'] : 'active';
     $useModuleUserAds = false;
     if (param('useUserads', 1) && Yii::app()->request->getParam('id') && Yii::app()->request->getParam('value') != null) {
         $useModuleUserAds = true;
         $this->scenario = 'update_status';
         $action = Yii::app()->request->getParam('value', null);
         $id = Yii::app()->request->getParam('id', null);
         $availableStatuses = Apartment::getModerationStatusArray();
         if (!array_key_exists($action, $availableStatuses)) {
             $action = 0;
         }
     } else {
         $action = $_GET['action'];
         $id = $_GET['id'];
     }
     if (!(!$id && $action === null)) {
         $model = $this->loadModel($id);
         if ($this->scenario) {
             $model->scenario = $this->scenario;
         }
         if ($model) {
             if ($useModuleUserAds) {
                 $model->{$field} = $action;
             } else {
                 $model->{$field} = $action == 'activate' ? 1 : 0;
             }
             $className = get_class($model);
             if ($model->{$field} == 1 && ($className == 'UserAds' || $className == 'Apartment')) {
                 $_POST['set_period_activity'] = 1;
             }
             $model->save(false);
         }
     }
     if (!Yii::app()->request->isAjaxRequest) {
         $this->redirect(isset($_POST['returnUrl']) ? $_POST['returnUrl'] : array('admin'));
     } elseif ($useModuleUserAds) {
         echo CHtml::link($availableStatuses[$action]);
     }
 }
コード例 #29
0
ファイル: _form.php プロジェクト: barricade86/raui
	<?php 
echo $form->labelEx($model, 'active');
?>
		<?php 
echo $form->dropDownList($model, 'active', array('1' => tt('Active', 'apartments'), '0' => tt('Inactive', 'apartments')), array('class' => 'width150'));
?>
	<?php 
echo $form->error($model, 'active');
?>

	<?php 
echo $form->labelEx($model, 'owner_active');
?>
	<?php 
echo $form->dropDownList($model, 'owner_active', Apartment::getApartmentsStatusArray(), array('class' => 'width150'));
?>
	<?php 
echo $form->error($model, 'owner_active');
?>

    <div class="tabbable">
        <ul class="nav nav-tabs" id="myTabs">
            <li class="active"><a href="#tab-main" data-toggle="tab"><?php 
echo tc('General');
?>
</a></li>
            <li><a href="#tab-extended" data-toggle="tab"><?php 
echo tc('Addition');
?>
</a></li>
コード例 #30
0
ファイル: MainController.php プロジェクト: alexjkitty/estate
    public function actionMainsearch($rss = null)
    {
        $countAjax = Yii::app()->request->getParam('countAjax');
        $href = Yii::app()->getBaseUrl(true) . '/' . Yii::app()->request->getPathInfo();
        Yii::app()->clientScript->registerLinkTag('canonical', null, $href);
        unset($href);
        if (Yii::app()->request->getParam('currency')) {
            setCurrency();
            $this->redirect(array('mainsearch'));
        }
        $criteria = new CDbCriteria();
        $criteria->addCondition('active = ' . Apartment::STATUS_ACTIVE);
        if (param('useUserads')) {
            $criteria->addCondition('owner_active = ' . Apartment::STATUS_ACTIVE);
        }
        $criteria->addInCondition('type', Apartment::availableApTypesIds());
        $this->sApId = (int) Yii::app()->request->getParam('sApId');
        if ($this->sApId) {
            $criteria->addCondition('id = :sApId');
            $criteria->params[':sApId'] = $this->sApId;
            $apCount = Apartment::model()->count($criteria);
            if ($countAjax && Yii::app()->request->isAjaxRequest) {
                $this->echoAjaxCount($apCount);
            }
            if ($apCount) {
                $apartmentModel = Apartment::model()->findByPk($this->sApId);
                Yii::app()->controller->redirect($apartmentModel->getUrl());
                Yii::app()->end();
            }
        }
        // rooms
        if (issetModule('selecttoslider') && param('useRoomSlider') == 1) {
            $roomsMin = Yii::app()->request->getParam('room_min');
            $roomsMax = Yii::app()->request->getParam('room_max');
            if ($roomsMin || $roomsMax) {
                $criteria->addCondition('num_of_rooms >= :roomsMin AND num_of_rooms <= :roomsMax');
                $criteria->params[':roomsMin'] = $roomsMin;
                $criteria->params[':roomsMax'] = $roomsMax;
                $this->roomsCountMin = $roomsMin;
                $this->roomsCountMax = $roomsMax;
            }
        } else {
            $rooms = Yii::app()->request->getParam('rooms');
            if ($rooms) {
                if ($rooms == 4) {
                    $criteria->addCondition('num_of_rooms >= :rooms');
                } else {
                    $criteria->addCondition('num_of_rooms = :rooms');
                }
                $criteria->params[':rooms'] = $rooms;
                $this->roomsCount = $rooms;
            }
        }
        // floor
        if (issetModule('selecttoslider') && param('useFloorSlider') == 1) {
            $floorMin = Yii::app()->request->getParam('floor_min');
            $floorMax = Yii::app()->request->getParam('floor_max');
            if ($floorMin || $floorMax) {
                $criteria->addCondition('floor >= :floorMin AND floor <= :floorMax');
                $criteria->params[':floorMin'] = $floorMin;
                $criteria->params[':floorMax'] = $floorMax;
                $this->floorCountMin = $floorMin;
                $this->floorCountMax = $floorMax;
            }
        } else {
            $floor = Yii::app()->request->getParam('floor');
            if ($floor) {
                $criteria->addCondition('floor = :floor');
                $criteria->params[':floor'] = $floor;
                $this->floorCount = $floor;
            }
        }
        // square
        if (issetModule('selecttoslider') && param('useSquareSlider') == 1) {
            $squareMin = Yii::app()->request->getParam('square_min');
            $squareMax = Yii::app()->request->getParam('square_max');
            if ($squareMin || $squareMax) {
                $criteria->addCondition('square >= :squareMin AND square <= :squareMax');
                $criteria->params[':squareMin'] = $squareMin;
                $criteria->params[':squareMax'] = $squareMax;
                $this->squareCountMin = $squareMin;
                $this->squareCountMax = $squareMax;
            }
        } else {
            $square = Yii::app()->request->getParam('square');
            if ($square) {
                $criteria->addCondition('square <= :square');
                $criteria->params[':square'] = $square;
                $this->squareCount = $square;
            }
        }
        $location = (int) Yii::app()->request->getParam('location_id');
        $subLocation = (int) Yii::app()->request->getParam('sublocation_id');
        $region = (int) Yii::app()->request->getParam('region_id');
        if ($subLocation) {
            if (empty($region)) {
                $criteria->addCondition('sublocation_id = :sublocation_id AND location_id = :location_id');
                $criteria->params[':sublocation_id'] = $subLocation;
                $criteria->params[':location_id'] = $location;
            } else {
                $criteria->addCondition('sublocation_id = :sublocation_id AND region_id = :region_id');
                $criteria->params[':sublocation_id'] = $subLocation;
                $criteria->params[':region_id'] = $region;
            }
        } elseif ($location) {
            $criteria->addCondition('location_id = :location_id');
            $criteria->params[':location_id'] = $location;
        }
        $landSquare = Yii::app()->request->getParam('land_square');
        if ($landSquare) {
            $criteria->addCondition('land_square <= :land_square');
            $criteria->params[':land_square'] = $landSquare;
            $this->landSquare = $landSquare;
        }
        if (issetModule('location') && param('useLocation', 1)) {
            $country = Yii::app()->request->getParam('country');
            if ($country) {
                $this->selectedCountry = $country;
                $criteria->compare('loc_country', $country);
            }
            $region = Yii::app()->request->getParam('region');
            if ($region) {
                $this->selectedRegion = $region;
                $criteria->compare('loc_region', $region);
            }
            $city = Yii::app()->request->getParam('city');
            if ($city) {
                $this->selectedCity = $city;
                $criteria->addInCondition('t.loc_city', $city);
            }
        } else {
            $city = Yii::app()->request->getParam('city');
            if ($city) {
                $this->selectedCity = $city;
                $criteria->addInCondition('t.city_id', $city);
            }
        }
        $this->objType = Yii::app()->request->getParam('objType');
        if ($this->objType) {
            $criteria->addCondition('obj_type_id = :objType');
            $criteria->params[':objType'] = $this->objType;
        }
        // type
        $this->apType = Yii::app()->request->getParam('apType');
        if ($this->apType) {
            $criteria->addCondition('price_type = :apType');
            $criteria->params[':apType'] = $this->apType;
        }
        $type = Yii::app()->request->getParam('type');
        if ($type) {
            $criteria->addCondition('type = :type');
            $criteria->params[':type'] = $type;
        }
        // price
        if (issetModule('selecttoslider') && param('usePriceSlider') == 1) {
            $priceMin = Yii::app()->request->getParam("price_min");
            $priceMax = Yii::app()->request->getParam("price_max");
            if ($priceMin || $priceMax) {
                $criteria->addCondition('(price >= :priceMin AND price <= :priceMax) OR (is_price_poa = 1)');
                if (issetModule('currency')) {
                    $criteria->params[':priceMin'] = floor(Currency::convertToDefault($priceMin));
                    $criteria->params[':priceMax'] = ceil(Currency::convertToDefault($priceMax));
                } else {
                    $criteria->params[':priceMin'] = $priceMin;
                    $criteria->params[':priceMax'] = $priceMax;
                }
                $this->priceSlider["min"] = $priceMin;
                $this->priceSlider["max"] = $priceMax;
            }
        } else {
            $price = Yii::app()->request->getParam('price');
            if (issetModule('currency')) {
                $priceDefault = ceil(Currency::convertToDefault($price));
            } else {
                $priceDefault = $price;
            }
            if ($priceDefault) {
                $criteria->addCondition('(price <= :price) OR (is_price_poa = 1)');
                $criteria->params[':price'] = $priceDefault;
                $this->price = $price;
            }
        }
        // ключевые слова
        $term = Yii::app()->request->getParam('term');
        $doTermSearch = Yii::app()->request->getParam('do-term-search');
        if ($term && $doTermSearch == 1) {
            $term = utf8_substr($term, 0, 50);
            $term = cleanPostData($term);
            if ($term && utf8_strlen($term) >= $this->minLengthSearch) {
                $this->term = $term;
                $words = explode(' ', $term);
                if (count($words) > 1) {
                    $searchString = '+' . implode('* +', $words) . '* ';
                    # https://dev.mysql.com/doc/refman/5.5/en/fulltext-boolean.html
                    $sql = 'SELECT id
					FROM {{apartment}}
					WHERE MATCH
						(title_' . Yii::app()->language . ', description_' . Yii::app()->language . ', description_near_' . Yii::app()->language . ', address_' . Yii::app()->language . ')
						AGAINST ("' . $searchString . '" IN BOOLEAN MODE)';
                } else {
                    $sql = 'SELECT id
					FROM {{apartment}}
					WHERE MATCH
						(title_' . Yii::app()->language . ', description_' . Yii::app()->language . ', description_near_' . Yii::app()->language . ', address_' . Yii::app()->language . ')
						AGAINST ("*' . $term . '*" IN BOOLEAN MODE)';
                }
                $resTerm = Yii::app()->db->createCommand($sql)->queryAll();
                if (is_array($resTerm) && count($resTerm) > 0) {
                    $resTerm = CHtml::listData($resTerm, 'id', 'relevance');
                    $criteria->addInCondition('t.id', array_keys($resTerm));
                } else {
                    $criteria->addInCondition('t.id', array(0));
                    # ничего не найдено
                }
            }
        }
        // поиск объявлений владельца
        $this->userListingId = Yii::app()->request->getParam('userListingId');
        if ($this->userListingId) {
            $criteria->addCondition('owner_id = :userListingId');
            $criteria->params[':userListingId'] = $this->userListingId;
        }
        $filterName = null;
        // Поиск по справочникам - клик в просмотре профиля анкеты
        if (param('useReferenceLinkInView')) {
            if (Yii::app()->request->getQuery('serviceId', false)) {
                $serviceId = Yii::app()->request->getQuery('serviceId', false);
                if ($serviceId) {
                    $serviceIdArray = explode('-', $serviceId);
                    if (is_array($serviceIdArray) && count($serviceIdArray) > 0) {
                        $value = (int) $serviceIdArray[0];
                        $sql = 'SELECT DISTINCT apartment_id FROM {{apartment_reference}} WHERE reference_value_id = ' . $value;
                        $apartmentIds = Yii::app()->db->cache(param('cachingTime', 1209600), Apartment::getDependency())->createCommand($sql)->queryColumn();
                        //$apartmentIds = Yii::app()->db->createCommand($sql)->queryColumn();
                        $criteria->addInCondition('t.id', $apartmentIds);
                        Yii::app()->getModule('referencevalues');
                        $sql = 'SELECT title_' . Yii::app()->language . ' FROM {{apartment_reference_values}} WHERE id = ' . $value;
                        $filterName = Yii::app()->db->cache(param('cachingTime', 1209600), ReferenceValues::getDependency())->createCommand($sql)->queryScalar();
                        if ($filterName) {
                            $filterName = CHtml::encode($filterName);
                        }
                    }
                }
            }
        }
        if (issetModule('formeditor')) {
            $newFieldsAll = FormDesigner::getNewFields();
            foreach ($newFieldsAll as $field) {
                $value = CHtml::encode(Yii::app()->request->getParam($field->field));
                if (!$value) {
                    continue;
                }
                $fieldString = $field->field;
                $this->newFields[$fieldString] = $value;
                switch ($field->compare_type) {
                    case FormDesigner::COMPARE_EQUAL:
                        $criteria->compare($fieldString, $value);
                        break;
                    case FormDesigner::COMPARE_LIKE:
                        $criteria->compare($fieldString, $value, true);
                        break;
                    case FormDesigner::COMPARE_FROM:
                        $value = intval($value);
                        $criteria->compare($fieldString, ">={$value}");
                        break;
                    case FormDesigner::COMPARE_TO:
                        $value = intval($value);
                        $criteria->compare($fieldString, "<={$value}");
                        break;
                }
            }
        }
        if ($rss && issetModule('rss')) {
            $this->widget('application.modules.rss.components.RssWidget', array('criteria' => $criteria));
        }
        // find count
        $apCount = Apartment::model()->count($criteria);
        if ($countAjax && Yii::app()->request->isAjaxRequest) {
            $this->echoAjaxCount($apCount);
        }
        $searchParams = $_GET;
        if (isset($searchParams['is_ajax'])) {
            unset($searchParams['is_ajax']);
        }
        Yii::app()->user->setState('searchUrl', Yii::app()->createUrl('/search', $searchParams));
        unset($searchParams);
        if (isset($_GET['is_ajax'])) {
            //			$modeListShow = User::getModeListShow();
            //			if ($modeListShow == 'table') {
            //				# нужны скрипты и стили, поэтому processOutput установлен в true только для table
            //				$this->renderPartial('index', array(
            //					'criteria' => $criteria,
            //					'apCount' => $apCount,
            //					'filterName' => $filterName,
            //				), false, true);
            //			}
            //			else {
            $this->renderPartial('index', array('criteria' => $criteria, 'apCount' => $apCount, 'filterName' => $filterName));
            //			}
        } else {
            $this->render('index', array('criteria' => $criteria, 'apCount' => $apCount, 'filterName' => $filterName));
        }
    }