Exemplo n.º 1
0
 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);
     }
 }
Exemplo n.º 2
0
 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);
     }
 }
Exemplo n.º 3
0
 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;
 }
Exemplo n.º 4
0
 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);
 }
Exemplo n.º 5
0
 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
         }
     }
 }
Exemplo n.º 6
0
 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'));
     }
 }
Exemplo n.º 7
0
 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'] : '';
 }
Exemplo n.º 8
0
 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);
 }
Exemplo n.º 9
0
 public function getLabel()
 {
     if ($this->standard_type == self::STANDARD_TYPE_NEW) {
         return $this->getStrByLang('label');
     } else {
         return Apartment::model()->getAttributeLabel($this->field);
     }
 }
Exemplo n.º 10
0
 public function actionIndex()
 {
     if (Yii::app()->user->isGuest) {
         throw404();
     }
     $this->setActiveMenu('my_payments');
     $request = Yii::app()->request;
     $ad_id = $request->getParam('id', 0);
     $paid_id = $request->getParam('paid_id');
     $isFancy = $request->getParam('isFancy', 0);
     $paySubmit = $request->getParam('pay_submit');
     $tariffId = $request->getParam('tariffid', 0);
     if ($paySubmit) {
         $optionId = $request->getParam('option_id');
         $paySystemId = $request->getParam('pay_id');
         $amount = $request->getParam('amount', 0);
         $error = 0;
         // Если это поплнение баланса
         if ($paid_id == PaidServices::ID_ADD_FUNDS && $amount <= 0) {
             $this->setActiveMenu('my_balance');
             Yii::app()->user->setFlash('error', tc('Please specify the amount of the payment'));
             $error = 1;
         }
         Yii::app()->getModule('payment');
         $paysystem = Paysystem::model()->findByPk($paySystemId);
         if (!$paysystem) {
             throw404();
         }
         # покупка тарифного плана
         if ($tariffId && issetModule('tariffPlans')) {
             $tariffPlanInfo = TariffPlans::getFullTariffInfoById($tariffId);
             $paidOption = new PaidOptions();
             $paidOption->id = 0;
             if (!$tariffPlanInfo || $tariffPlanInfo['active'] == TariffPlans::STATUS_INACTIVE) {
                 throw404();
             }
             if ($tariffPlanInfo['price'] && $tariffPlanInfo['price'] > 0) {
                 // Если оплата тарифа с баланса пользователя
                 if ($paySystemId == Paysystem::ID_BALANCE) {
                     $user = User::model()->findByPk(Yii::app()->user->id);
                     if ($user->balance < $tariffPlanInfo['price']) {
                         Yii::app()->user->setFlash('error', tc('Please refill the balance'));
                         $error = 2;
                         $this->redirect(array('/tariffPlans/main/index'));
                     }
                 }
             } else {
                 # бесплатный тариф
                 Yii::app()->user->setFlash('error', tt('Selected tariff plan is free. Please contact the site administrator for transit to this tariff.', 'tariffPlans'));
                 $error = 2;
                 $this->redirect(array('/tariffPlans/main/index'));
             }
         } else {
             if ($paid_id != PaidServices::ID_ADD_FUNDS) {
                 $ad = Apartment::model()->findByPk($ad_id);
                 $paidOption = PaidOptions::model()->findByPk($optionId);
                 if (!$ad || !$paidOption || !isset($paidOption->paidService)) {
                     throw404();
                 }
                 // Если оплата платной услуги с баланса пользователя
                 if ($paySystemId == Paysystem::ID_BALANCE) {
                     $user = User::model()->findByPk(Yii::app()->user->id);
                     if ($user->id != $ad->owner_id || $ad->deleted) {
                         throw404();
                     }
                     if ($user->balance < $paidOption->price) {
                         Yii::app()->user->setFlash('error', tc('Please refill the balance'));
                         $error = 2;
                     }
                 }
             }
         }
         $paysystem->createPayModel();
         if ($paysystem->payModel === null) {
             throw404();
         }
         if ($error == 0) {
             // Создаем платеж и ставим ему статус "Ожидает оплаты"
             $payment = new Payments();
             $payment->user_id = Yii::app()->user->id;
             $payment->paid_id = $paid_id;
             if ($paid_id != PaidServices::ID_ADD_FUNDS) {
                 $payment->paid_option_id = $paidOption->id;
             }
             $payment->apartment_id = $ad_id;
             $payment->tariff_id = $tariffId;
             if ($tariffId && issetModule('tariffPlans')) {
                 $payment->amount = $tariffPlanInfo['price'];
             } else {
                 $payment->amount = $paid_id == PaidServices::ID_ADD_FUNDS ? $amount : $paidOption->price;
             }
             $payment->currency_charcode = Currency::getDefaultCurrencyModel()->char_code;
             $payment->status = Payments::STATUS_WAITPAYMENT;
             $payment->paysystem_id = $paysystem->id;
             $payment->save();
             /*echo '<pre>';
             		print_r($payment->getErrors());
             		echo '</pre>';
             		exit;*/
             // Передаем платеж на обработку в модель платежки.
             // Приложение либо звершается (происходит редирект по нужному адресу),
             // либо выдает сообщение, которое будет отображено пользователю
             $return = $paysystem->payModel->processPayment($payment);
             switch ($return['status']) {
                 case Paysystem::RESULT_OK:
                     Yii::app()->user->setFlash('success', $return['message']);
                     $this->redirect(array('/usercpanel/main/payments'));
                     break;
                 case Paysystem::RESULT_NOTICE:
                     Yii::app()->user->setFlash('notice', $return['message']);
                     $this->redirect(array('/userads/main/update', 'id' => $payment->apartment_id));
                     break;
                 case Paysystem::RESULT_ERROR:
                     Yii::app()->user->setFlash('error', $return['message']);
                     $this->redirect(array('/userads/main/update', 'id' => $payment->apartment_id));
                     break;
                 default:
                     $this->render('result', array('payment' => $payment, 'paysystem' => $paysystem, 'message' => $return['message']));
             }
             echo 'Loading ... ';
             exit;
         }
     }
     if ($paid_id != PaidServices::ID_ADD_FUNDS) {
         $apartment = Apartment::model()->findByPk($ad_id);
         if ($apartment->active != Apartment::STATUS_ACTIVE || $apartment->owner_active != 1) {
             echo '<h2>' . tt('To apply a paid service for the listing, it should be active.', 'paidservices') . '</h2>';
             exit;
         }
     }
     $paidService = PaidServices::model()->findByPk($paid_id);
     if (!$paidService || !$paidService->active) {
         throw404();
     }
     if ($paid_id == PaidServices::ID_ADD_IN_SLIDER) {
         $img = Images::getMainImageData(null, $apartment->id);
         if (!$img) {
             Yii::app()->user->setFlash('error', tt('Error! You must upload the image for the ad.', 'paidservices'));
             if (!$isFancy) {
                 $this->redirect(array('/userads/main/update', 'id' => $ad_id));
             } else {
                 echo tt('Error! You must upload the image for the ad.', 'paidservices');
             }
             Yii::app()->end();
         }
     }
     if (!isset($user)) {
         $user = User::model()->findByPk(Yii::app()->user->id);
     }
     if ($isFancy || Yii::app()->request->isAjaxRequest) {
         $this->excludeJs();
         if ($tariffId && issetModule('tariffPlans')) {
             $this->redirect(array('/tariffPlans/main/index'));
         } else {
             $this->renderPartial('paidform', array('paidService' => $paidService, 'user' => $user, 'ad_id' => $ad_id, 'isFancy' => true), false, true);
         }
     } else {
         if ($tariffId && issetModule('tariffPlans')) {
             $this->redirect(array('/tariffPlans/main/index'));
         } else {
             $this->render('paidform', array('paidService' => $paidService, 'user' => $user, 'ad_id' => $ad_id, 'isFancy' => false));
         }
     }
 }
Exemplo n.º 11
0
 public function getLabel()
 {
     if ($this->type == self::TYPE_DEFAULT) {
         return Apartment::model()->getAttributeLabel($this->field);
     } else {
         return $this->getStrByLang('label');
     }
 }
Exemplo n.º 12
0
<p>
    <strong><?php 
echo tt('Settings for the field', 'formdesigner');
?>
</strong>: <?php 
echo Apartment::model()->getAttributeLabel($model->field);
?>
</p>

<?php 
/** @var CustomForm $form */
$form = $this->beginWidget('CustomForm', array('id' => 'form-designer-filter'));
echo $form->errorSummary($model);
echo CHtml::hiddenField('id', $model->id);
echo CHtml::hiddenField('FormDesigner[save]', $model->id);
echo $form->dropDownListRow($model, 'view_in', FormDesigner::getViewInList());
echo '<br>';
echo $form->checkBoxRow($model, 'visible');
echo '<br>';
echo $form->checkBoxListRow($model, 'objTypesArray', ApartmentObjType::getList());
echo '<br>';
$this->widget('application.modules.lang.components.langFieldWidget', array('model' => $model, 'field' => 'tip', 'type' => 'string'));
echo '<div class="clear"></div>';
echo '<br>';
$this->widget('bootstrap.widgets.TbButton', array('buttonType' => 'submit', 'type' => 'primary', 'icon' => 'ok white', 'label' => $model->isNewRecord ? tc('Add') : tc('Save')));
$this->endWidget();
Exemplo n.º 13
0
    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));
        }
    }
Exemplo n.º 14
0
 public function actionChooseNewOwner()
 {
     $apId = Yii::app()->request->getParam('id');
     if (!$apId) {
         throw404();
     }
     $modelApartment = Apartment::model()->findByPk($apId);
     if (!$modelApartment) {
         throw404();
     }
     $this->modelName = 'ChangeOwner';
     $model = new ChangeOwner();
     $modelUser = new User('search');
     $modelUser->resetScope();
     $modelUser->unsetAttributes();
     // clear any default values
     if (isset($_GET['User'])) {
         $modelUser->attributes = $_GET['User'];
     }
     $modelUser->active = 1;
     if (Yii::app()->request->isPostRequest) {
         if (isset($_POST)) {
             $futureOwner = isset($_POST['itemsSelected']) && isset($_POST['itemsSelected'][0]) ? $_POST['itemsSelected'][0] : '';
             $futureApartments = array($apId);
             $model->setAttributes(array('futureOwner' => $futureOwner, 'futureApartments' => array($apId)));
             if ($model->validate()) {
                 if ($futureOwner && is_array($futureApartments)) {
                     $sql = 'UPDATE {{apartment}} SET owner_id = ' . $futureOwner . ' WHERE id IN (' . implode(', ', $futureApartments) . ')';
                     Yii::app()->db->createCommand($sql)->execute();
                     $sql = 'UPDATE {{images}} SET id_owner = ' . $futureOwner . ' WHERE id_object IN (' . implode(', ', $futureApartments) . ')';
                     Yii::app()->db->createCommand($sql)->execute();
                     Yii::app()->cache->flush();
                     Yii::app()->user->setFlash('success', tc('Success'));
                     Yii::app()->controller->redirect(array('admin'));
                 }
             }
         }
     }
     $renderData = array('apId' => $apId, 'model' => $model, 'modelUser' => $modelUser, 'modelApartment' => $modelApartment);
     if (Yii::app()->request->isAjaxRequest) {
         $this->renderPartial('change_owner', $renderData, false, true);
     } else {
         $this->render('change_owner', $renderData);
     }
 }
Exemplo n.º 15
0
    if (isset($_GET['Apartment'])) {
        $modelAds->attributes = $_GET['Apartment'];
    }
    ?>
	<h1 class="title highlight-left-right">
	<span>
		<?php 
    echo tc('My listings');
    ?>
	</span>
	</h1>
	<div class="clear"></div><br />
	<?php 
    $user = HUser::getModel();
    $typeId = isset($_GET['type']) ? (int) $_GET['type'] : 1;
    $rentorders = Apartment::model()->findAll('type=:typeId AND owner_id=:userId', [':typeId' => $typeId, ':userId' => $user->id]);
    $this->renderPartial('//modules/userads/views/index', array('model' => $modelAds->onlyAuthOwner()->notDeleted(), 'rentorders' => $rentorders));
} else {
    $this->pageTitle .= ' - ' . tc('My data');
    $this->breadcrumbs = array(tc('Control panel') => Yii::app()->createUrl('/usercpanel'), tc('My data'));
    ?>

	<h1 class="title highlight-left-right">
	<span>
		<?php 
    echo tc('My data');
    ?>
	</span>
	</h1>
	<div class="clear"></div><br />
Exemplo n.º 16
0
    public static function checkDateEndActivity()
    {
        $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) AND
			t.active <> :draft', array(':status' => Apartment::STATUS_ACTIVE, ':draft' => Apartment::STATUS_DRAFT));
        foreach ($adEndActivity as $ad) {
            $ad->scenario = 'update_status';
            if (isset($ad->user) && $ad->user->role == User::ROLE_ADMIN) {
                $ad->active = Apartment::STATUS_INACTIVE;
            } else {
                $ad->active = Apartment::STATUS_INACTIVE;
                $ad->owner_active = Apartment::STATUS_INACTIVE;
            }
            $ad->save(false);
        }
    }
Exemplo n.º 17
0
 private function generateMap($isXml = false)
 {
     $map = array();
     $defaultLastMod = date($this->dateFormat, time());
     $articleAll = $menuAll = $newsAll = '';
     // apartments module
     if (issetModule('apartments')) {
         if ($isXml) {
             $dependencyApartment = new CDbCacheDependency('SELECT MAX(date_updated) FROM {{apartment}}');
         }
     }
     // article module
     if (issetModule('articles')) {
         $articlePage = Menu::model()->findByPk(Menu::ARTICLES_ID);
         if ($articlePage && $articlePage->active == 1) {
             Yii::import('application.modules.articles.models.Article');
             $dependencyArticle = new CDbCacheDependency('SELECT MAX(date_updated) FROM {{articles}}');
             $articleAll = Article::model()->cache(param('cachingTime', 1209600), $dependencyArticle)->findAll(array('condition' => 'active = 1'));
             if ($isXml) {
                 $sql = 'SELECT MAX(date_updated) as date_updated FROM {{articles}}';
                 $maxUpdatedArticles = Yii::app()->db->createCommand($sql)->queryRow();
                 $maxUpdatedArticles = isset($maxUpdatedArticles['date_updated']) ? date($this->dateFormat, strtotime($maxUpdatedArticles['date_updated'])) : $defaultLastMod;
             }
         }
     }
     // infopages module
     if (issetModule('menumanager')) {
         $dependencyInfoPages = new CDbCacheDependency('SELECT MAX(date_updated) as date_updated FROM {{menu}}');
         $menuAll = Menu::model()->cache(param('cachingTime', 1209600), $dependencyInfoPages)->findAll(array('order' => 'number', 'condition' => 'active = 1 AND (special = 0 OR id = 5)'));
         if ($isXml) {
             $sql = 'SELECT MAX(date_updated) as date_updated FROM {{menu}}';
             $maxUpdatedInfo = Yii::app()->db->createCommand($sql)->queryRow();
             $maxUpdatedInfo = isset($maxUpdatedInfo['date_updated']) ? date($this->dateFormat, strtotime($maxUpdatedInfo['date_updated'])) : $defaultLastMod;
         }
     }
     // news module
     if (issetModule('news')) {
         $newsPage = Menu::model()->findByPk(Menu::NEWS_ID);
         if ($newsPage && $newsPage->active == 1) {
             Yii::import('application.modules.news.models.News');
             $dependencyNews = new CDbCacheDependency('SELECT MAX(date_updated) FROM {{news}}');
             $newsAll = News::model()->cache(param('cachingTime', 1209600), $dependencyNews)->findAll();
             if ($isXml) {
                 $sql = 'SELECT MAX(date_updated) as date_updated FROM {{news}}';
                 $maxUpdatedNews = Yii::app()->db->createCommand($sql)->queryRow();
                 $maxUpdatedNews = isset($maxUpdatedNews['date_updated']) ? date($this->dateFormat, strtotime($maxUpdatedNews['date_updated'])) : $defaultLastMod;
             }
         }
     }
     ####################################### index page #######################################
     if ($isXml) {
         if ($this->activeLangs && is_array($this->activeLangs)) {
             foreach ($this->activeLangs as $keyLang => $valLang) {
                 $this->app->setLanguage($valLang);
                 $map['index_page']['title'][$keyLang] = tt('index_page');
                 $map['index_page']['url'][$keyLang] = Yii::app()->createAbsoluteUrl('/');
                 $map['index_page']['lastmod'][$keyLang] = isset($indexPageInfo) && isset($indexPageInfo->date_updated) ? date($this->dateFormat, strtotime($indexPageInfo->date_updated)) : $defaultLastMod;
             }
         }
         $this->app->setLanguage($this->defaultLang);
     } else {
         $map['index_page']['title'] = tt('index_page');
         $map['index_page']['url'] = Yii::app()->createAbsoluteUrl('/');
     }
     ####################################### contact form and booking form #######################################
     if ($isXml) {
         if ($this->activeLangs && is_array($this->activeLangs)) {
             foreach ($this->activeLangs as $keyLang => $valLang) {
                 $this->app->setLanguage($valLang);
                 $map['contact_form']['title'][$keyLang] = tt('contact_form');
                 $map['contact_form']['url'][$keyLang] = Yii::app()->createAbsoluteUrl('contactform/main/index');
                 $map['contact_form']['lastmod'][$keyLang] = isset($indexPageInfo) && isset($indexPageInfo->date_updated) ? date($this->dateFormat, strtotime($indexPageInfo->date_updated)) : $defaultLastMod;
                 $map['booking_form']['title'][$keyLang] = tt('booking_form');
                 $map['booking_form']['url'][$keyLang] = Yii::app()->createAbsoluteUrl('booking/main/mainform');
                 $map['booking_form']['lastmod'][$keyLang] = isset($indexPageInfo) && isset($indexPageInfo->date_updated) ? date($this->dateFormat, strtotime($indexPageInfo->date_updated)) : $defaultLastMod;
             }
         }
         $this->app->setLanguage($this->defaultLang);
     } else {
         $map['contact_form']['title'] = tt('contact_form');
         $map['contact_form']['url'] = Yii::app()->createAbsoluteUrl('contactform/main/index');
         $map['booking_form']['title'] = tt('booking_form');
         $map['booking_form']['url'] = Yii::app()->createAbsoluteUrl('booking/main/mainform');
     }
     ####################################### search #######################################
     if ($isXml) {
         if ($this->activeLangs && is_array($this->activeLangs)) {
             foreach ($this->activeLangs as $keyLang => $valLang) {
                 $this->app->setLanguage($valLang);
                 $map['quick_search']['title'][$keyLang] = tt('quick_search');
                 $map['quick_search']['url'][$keyLang] = Yii::app()->createAbsoluteUrl('quicksearch/main/mainsearch');
                 $sql = 'SELECT MAX(date_updated) as date_updated FROM {{apartment}}';
                 $maxUpdatedApartment = Yii::app()->db->createCommand($sql)->queryRow();
                 $maxUpdatedApartment = isset($maxUpdatedApartment['date_updated']) ? date($this->dateFormat, strtotime($maxUpdatedApartment['date_updated'])) : $defaultLastMod;
                 $map['quick_search']['lastmod'][$keyLang] = $maxUpdatedApartment;
             }
         }
         $this->app->setLanguage($this->defaultLang);
     } else {
         $map['quick_search']['title'] = tt('quick_search');
         $map['quick_search']['url'] = Yii::app()->createAbsoluteUrl('quicksearch/main/mainsearch');
     }
     ####################################### search subtypes #######################################
     $types = SearchForm::apTypes();
     if (is_array($types) && isset($types['propertyType'])) {
         $i = 0;
         foreach ($types['propertyType'] as $key => $value) {
             if ($key > 0) {
                 if ($isXml) {
                     $apartmentsByType = null;
                     $result = null;
                     $titles = array();
                     if ($this->activeLangs && is_array($this->activeLangs)) {
                         foreach ($this->activeLangs as $keyLang => $valLang) {
                             $titles[] = 'title_' . $valLang;
                         }
                     }
                     if (count($titles)) {
                         $titles = implode(',', $titles);
                         $sql = 'SELECT id, ' . $titles . ', date_updated FROM {{apartment}} WHERE price_type = ' . $key . ' AND active = ' . Apartment::STATUS_ACTIVE . ' AND owner_active = ' . Apartment::STATUS_ACTIVE . ' ORDER BY date_updated DESC';
                         $result = Yii::app()->db->createCommand($sql)->queryAll();
                     }
                     if ($result) {
                         foreach ($result as $item) {
                             $apartmentsByType[$item['id']] = $item;
                         }
                     }
                     $k = 0;
                     if (is_array($apartmentsByType) && count($apartmentsByType) > 0) {
                         $urls = array();
                         if ($this->activeLangs && is_array($this->activeLangs)) {
                             foreach ($this->activeLangs as $keyLang => $valLang) {
                                 $urls[] = 'url_' . $valLang;
                             }
                         }
                         if (issetModule('seo') && count($urls)) {
                             $urls = implode(',', $urls);
                             $sql = 'SELECT model_id, ' . $urls . ' FROM {{seo_friendly_url}} WHERE model_name="Apartment" GROUP BY model_id ORDER BY id ASC';
                             $resultSEO = Yii::app()->db->createCommand($sql)->queryAll();
                             if ($resultSEO) {
                                 foreach ($resultSEO as $item) {
                                     if (isset($apartmentsByType[$item['model_id']])) {
                                         $apartmentsByType[$item['model_id']] = CMap::mergeArray($apartmentsByType[$item['model_id']], $item);
                                     }
                                 }
                             }
                         }
                         foreach ($apartmentsByType as $value) {
                             if ($this->activeLangs && is_array($this->activeLangs)) {
                                 foreach ($this->activeLangs as $keyLang => $valLang) {
                                     $this->app->setLanguage($valLang);
                                     if (isset($value['title_' . $valLang]) && $value['title_' . $valLang]) {
                                         $map['quick_search']['subsection'][$i]['apartments'][$k]['title'][$keyLang] = $value['title_' . $valLang];
                                     }
                                     if (isset($value['url_' . $valLang]) && $value['url_' . $valLang]) {
                                         $map['quick_search']['subsection'][$i]['apartments'][$k]['url'][$keyLang] = Yii::app()->createAbsoluteUrl('/apartments/main/view', array('url' => $value['url_' . $valLang] . (param('urlExtension') ? '.html' : '')));
                                     } else {
                                         $map['quick_search']['subsection'][$i]['apartments'][$k]['url'][$keyLang] = Yii::app()->createAbsoluteUrl('/apartments/main/view', array('id' => $value['id']));
                                     }
                                     if (isset($value['date_updated']) && $value['date_updated']) {
                                         $map['quick_search']['subsection'][$i]['apartments'][$k]['lastmod'][$keyLang] = date($this->dateFormat, strtotime($value['date_updated']));
                                     }
                                 }
                             }
                             $this->app->setLanguage($this->defaultLang);
                             $k++;
                         }
                     }
                 } else {
                     //$map['apartment_types'][$i]['title'] = mb_convert_case($value, MB_CASE_TITLE, "UTF-8");
                     $map['quick_search']['subsection'][$i]['title'] = $value;
                     $map['quick_search']['subsection'][$i]['url'] = Yii::app()->createAbsoluteUrl('quicksearch/main/mainsearch', array('apType' => $key));
                 }
                 $i++;
             }
         }
     }
     ####################################### search object types #######################################
     $objTypes = Apartment::getObjTypesArray();
     if (is_array($objTypes)) {
         $i = 1;
         if (array_key_exists('subsection', $map['quick_search'])) {
             if ($isXml) {
                 $countSubsection = count($map['quick_search']['subsection']);
                 if ($this->activeLangs && is_array($this->activeLangs)) {
                     foreach ($this->activeLangs as $keyLang => $valLang) {
                         foreach ($objTypes as $key => $value) {
                             $this->app->setLanguage($valLang);
                             $map['quick_search']['subsection'][$countSubsection + $i]['title'][$keyLang] = $value;
                             $map['quick_search']['subsection'][$countSubsection + $i]['url'][$keyLang] = Yii::app()->createAbsoluteUrl('quicksearch/main/mainsearch', array('objType' => $key));
                             $i++;
                         }
                     }
                     $this->app->setLanguage($this->defaultLang);
                 }
             } else {
                 $countSubsection = count($map['quick_search']['subsection']);
                 foreach ($objTypes as $key => $value) {
                     $map['quick_search']['subsection'][$countSubsection + $i]['title'] = $value;
                     $map['quick_search']['subsection'][$countSubsection + $i]['url'] = Yii::app()->createAbsoluteUrl('quicksearch/main/mainsearch', array('objType' => $key));
                     $i++;
                 }
             }
         }
         // no in xml because all links to listings generated above in search subtypes section
         // duplication link is not needed.
     }
     ####################################### special offers  #######################################
     if (issetModule('specialoffers')) {
         $specialOfferPage = Menu::model()->findByPk(Menu::SPECIALOFFERS_ID);
         if ($specialOfferPage && $specialOfferPage->active == 1) {
             $i = 0;
             if ($isXml) {
                 $map['special_offers']['title'] = tt('special_offers');
                 $map['special_offers']['url'] = Yii::app()->createAbsoluteUrl('specialoffers/main/index');
                 $map['special_offers']['lastmod'] = $maxUpdatedApartment;
                 $specialOffers = Apartment::model()->cache(param('cachingTime', 1209600), $dependencyApartment)->findAllByAttributes(array('is_special_offer' => 1), 'active = :active AND owner_active = :ownerActive', array(':active' => Apartment::STATUS_ACTIVE, ':ownerActive' => Apartment::STATUS_ACTIVE));
                 $k = 0;
                 if (is_array($specialOffers) && count($specialOffers) > 0) {
                     foreach ($specialOffers as $value) {
                         if ($this->activeLangs && is_array($this->activeLangs)) {
                             foreach ($this->activeLangs as $keyLang => $valLang) {
                                 $this->app->setLanguage($valLang);
                                 $map['special_offers']['subsection'][$k]['title'][$keyLang] = $value->getStrByLang('title');
                                 $map['special_offers']['subsection'][$k]['url'][$keyLang] = $value->getUrl();
                                 $map['special_offers']['subsection'][$k]['lastmod'][$keyLang] = date($this->dateFormat, strtotime($value['date_updated']));
                             }
                         }
                         $this->app->setLanguage($this->defaultLang);
                         $k++;
                     }
                 }
             } else {
                 $map['special_offers']['title'] = tt('special_offers');
                 $map['special_offers']['url'] = Yii::app()->createAbsoluteUrl('specialoffers/main/index');
             }
         }
     }
     ####################################### get all info pages  #######################################
     if (is_array($menuAll) && $menuAll > 0) {
         $i = 0;
         if ($isXml) {
             if ($this->activeLangs && is_array($this->activeLangs)) {
                 foreach ($this->activeLangs as $keyLang => $valLang) {
                     $this->app->setLanguage($valLang);
                     $map['section_infopage']['title'][$keyLang] = tt('section_infopage');
                     $map['section_infopage']['url'][$keyLang] = null;
                     $map['section_infopage']['lastmod'][$keyLang] = $maxUpdatedInfo;
                     foreach ($menuAll as $value) {
                         // убираем из карты сайта типы "Простая ссылка" и "Простая ссылка в выпад. списке"
                         if ($value['type'] != Menu::LINK_NEW_MANUAL && $value['type'] != Menu::LINK_NONE) {
                             $title = $value->getTitle();
                             if ($title && $value['id'] != 1) {
                                 $map['section_infopage']['subsection'][$i]['title'][$keyLang] = $title;
                                 if ($value['type'] == Menu::LINK_NEW_INFO) {
                                     $href = $value->getUrl();
                                 } else {
                                     if ($value['id'] == Menu::SITEMAP_ID) {
                                         // sitemap
                                         $href = Yii::app()->controller->createAbsoluteUrl('/sitemap/main/index');
                                     }
                                 }
                                 $map['section_infopage']['subsection'][$i]['url'][$keyLang] = $href;
                                 $map['section_infopage']['subsection'][$i]['lastmod'][$keyLang] = date($this->dateFormat, strtotime($value['date_updated']));
                                 $i++;
                             }
                         }
                     }
                 }
             }
             $this->app->setLanguage($this->defaultLang);
         } else {
             $map['section_infopage']['title'] = tt('section_infopage');
             $map['section_infopage']['url'] = null;
             foreach ($menuAll as $value) {
                 $title = $value->getTitle();
                 if ($title && $value['id'] != Menu::MAIN_PAGE_ID && $value['type'] != Menu::LINK_NONE) {
                     $map['section_infopage']['subsection'][$i]['title'] = $title;
                     $href = '';
                     if ($value['type'] == Menu::LINK_NEW_INFO) {
                         $href = $value->getUrl();
                     } else {
                         if ($value['id'] == Menu::SITEMAP_ID) {
                             // sitemap
                             $href = Yii::app()->controller->createAbsoluteUrl('/sitemap/main/index');
                         } else {
                             $href = $value->getUrl();
                         }
                     }
                     if ($href) {
                         $map['section_infopage']['subsection'][$i]['url'] = $href;
                     }
                     $i++;
                 }
             }
         }
     }
     ####################################### get all news #######################################
     if (is_array($newsAll) && count($newsAll) > 0) {
         $i = 0;
         if ($isXml) {
             if ($this->activeLangs && is_array($this->activeLangs)) {
                 foreach ($this->activeLangs as $keyLang => $valLang) {
                     $this->app->setLanguage($valLang);
                     $map['section_news']['title'][$keyLang] = tt('section_news');
                     $map['section_news']['url'][$keyLang] = Yii::app()->createAbsoluteUrl('news/main/index');
                     $map['section_news']['lastmod'][$keyLang] = $maxUpdatedNews;
                     foreach ($newsAll as $value) {
                         $title = $value->getTitle();
                         if ($title) {
                             $map['section_news']['subsection'][$i]['title'][$keyLang] = $title;
                             $map['section_news']['subsection'][$i]['url'][$keyLang] = $value->getUrl();
                             $map['section_news']['subsection'][$i]['lastmod'][$keyLang] = date($this->dateFormat, strtotime($value['date_updated']));
                             $i++;
                         }
                     }
                 }
             }
             $this->app->setLanguage($this->defaultLang);
         } else {
             $map['section_news']['title'] = tt('section_news');
             $map['section_news']['url'] = Yii::app()->createAbsoluteUrl('news/main/index');
             foreach ($newsAll as $value) {
                 $title = $value->getTitle();
                 if ($title) {
                     $map['section_news']['subsection'][$i]['title'] = $title;
                     $map['section_news']['subsection'][$i]['url'] = $value->getUrl();
                     $i++;
                 }
             }
         }
     }
     ####################################### get all article #######################################
     if (is_array($articleAll) && count($articleAll) > 0) {
         $i = 0;
         if ($isXml) {
             if ($this->activeLangs && is_array($this->activeLangs)) {
                 foreach ($this->activeLangs as $keyLang => $valLang) {
                     $this->app->setLanguage($valLang);
                     $map['section_article']['title'] = tt('section_article');
                     $map['section_article']['url'] = Yii::app()->createAbsoluteUrl('articles/main/index');
                     $map['section_article']['lastmod'] = $maxUpdatedArticles;
                     foreach ($articleAll as $value) {
                         $title = $value->getPage_title();
                         if ($title) {
                             $map['section_article']['subsection'][$i]['title'] = $title;
                             $map['section_article']['subsection'][$i]['url'] = $value->getUrl();
                             $map['section_article']['subsection'][$i]['lastmod'] = date($this->dateFormat, strtotime($value['date_updated']));
                             $i++;
                         }
                     }
                 }
             }
             $this->app->setLanguage($this->defaultLang);
         } else {
             $map['section_article']['title'] = tt('section_article');
             $map['section_article']['url'] = Yii::app()->createAbsoluteUrl('articles/main/index');
             foreach ($articleAll as $value) {
                 $title = $value->getPage_title();
                 if ($title) {
                     $map['section_article']['subsection'][$i]['title'] = $title;
                     $map['section_article']['subsection'][$i]['url'] = $value->getUrl();
                     $i++;
                 }
             }
         }
     }
     ####################################### reviews  #######################################
     if (issetModule('reviews')) {
         $reviewsPage = Menu::model()->findByPk(Menu::REVIEWS_ID);
         if ($reviewsPage && $reviewsPage->active == 1) {
             $i = 0;
             if ($isXml) {
                 $sql = 'SELECT MAX(date_updated) as date_updated FROM {{reviews}}';
                 $maxUpdatedReviews = Yii::app()->db->createCommand($sql)->queryScalar();
                 if ($this->activeLangs && is_array($this->activeLangs)) {
                     foreach ($this->activeLangs as $keyLang => $valLang) {
                         $this->app->setLanguage($valLang);
                         $map['reviews']['title'][$keyLang] = tt('Reviews', 'reviews');
                         $map['reviews']['url'][$keyLang] = Yii::app()->createAbsoluteUrl('reviews/main/index');
                         $map['reviews']['lastmod'][$keyLang] = date($this->dateFormat, strtotime($maxUpdatedReviews));
                     }
                 }
                 $this->app->setLanguage($this->defaultLang);
             } else {
                 $map['reviews']['title'] = tt('Reviews', 'reviews');
                 $map['reviews']['url'] = Yii::app()->createAbsoluteUrl('reviews/main/index');
             }
         }
     }
     return $map;
 }
Exemplo n.º 18
0
 public function run()
 {
     $criteria = new CDbCriteria(array('limit' => 6, 'order' => 't.id DESC', 'condition' => 'active=:active', 'params' => array(':active' => Apartment::STATUS_ACTIVE)));
     $lastEstateObjects = Apartment::model()->findAll($criteria);
     $this->render('lastEstateObjects', array('lastEstateObjects' => $lastEstateObjects));
 }
Exemplo n.º 19
0
 public static function findAllWithCache($criteria)
 {
     return Apartment::model()->cache(param('cachingTime', 1209600), Apartment::getImagesDependency())->with(array('images', 'objType'))->findAll($criteria);
 }
Exemplo n.º 20
0
 public static function applyToApartment($apartmentId, $paidId, $dateEnd, $interval = null)
 {
     $apartment = Apartment::model()->findByPk($apartmentId);
     if (!$apartment) {
         throw new CHttpException('PaidService no valid data');
     }
     $data = Yii::app()->statePersister->load();
     if (isset($data['next_check_status'])) {
         $data['next_check_status'] = time() - BeginRequest::TIME_UPDATE;
         Yii::app()->statePersister->save($data);
     }
     unset($data);
     $apartment->scenario = 'update_status';
     $apartmentPaid = ApartmentPaid::model()->findByAttributes(array('paid_id' => $paidId, 'apartment_id' => $apartmentId, 'user_id' => $apartment->owner_id));
     if (!$apartmentPaid) {
         $apartmentPaid = new ApartmentPaid();
         $apartmentPaid->date_end = $dateEnd;
     } else {
         if (time() < strtotime($apartmentPaid->date_end) && $interval) {
             $apartmentPaid->date_end = new CDbExpression('date_end + ' . $interval);
         } else {
             $apartmentPaid->date_end = $dateEnd;
         }
     }
     $apartmentPaid->paid_id = $paidId;
     $apartmentPaid->apartment_id = $apartment->id;
     $apartmentPaid->user_id = $apartment->owner_id;
     $apartmentPaid->date_start = new CDbExpression('NOW()');
     $apartmentPaid->status = ApartmentPaid::STATUS_ACTIVE;
     $apartmentPaid->save();
     // reloading date_end field
     $apartmentPaid = ApartmentPaid::model()->findByPk($apartmentPaid->id);
     switch ($paidId) {
         case PaidServices::ID_SPECIAL_OFFER:
             $apartment->is_special_offer = 1;
             $apartment->is_free_to = $apartmentPaid->date_end;
             return $apartment->update(array('is_special_offer', 'is_free_to'));
             break;
         case PaidServices::ID_UP_IN_SEARCH:
             $apartment->date_up_search = new CDbExpression('NOW()');
             return $apartment->update('date_up_search');
             break;
         case PaidServices::ID_ADD_IN_SLIDER:
             return self::genImgForSlider($apartment->id);
             break;
     }
     return false;
 }
Exemplo n.º 21
0
 public function actionDeletePanorama($id = null, $apId = null)
 {
     if (Yii::app()->user->isGuest) {
         throw404();
     }
     if (!$id && !$apId) {
         throw404();
     }
     if (Yii::app()->user->checkAccess('backend_access')) {
         $modelPanorama = ApartmentPanorama::model()->findByPk($id);
         $modelPanorama->delete();
         $this->redirect(array('/apartments/backend/main/update', 'id' => $apId));
     } else {
         $modelApartment = Apartment::model()->findByPk($apId);
         if ($modelApartment->owner_id != Yii::app()->user->id) {
             throw404();
         }
         $modelPanorama = ApartmentPanorama::model()->findByPk($id);
         $modelPanorama->delete();
         $this->redirect(array('/userads/main/update', 'id' => $apId));
     }
 }
Exemplo n.º 22
0
 public function actionSendEmail($id, $isFancy = 0)
 {
     $apartment = Apartment::model()->findByPk($id);
     if (!$apartment) {
         throw404();
     }
     if (!param('use_module_request_property')) {
         throw404();
     }
     $model = new SendMailForm();
     if (isset($_POST['SendMailForm'])) {
         $model->attributes = $_POST['SendMailForm'];
         if (!Yii::app()->user->isGuest) {
             $model->senderEmail = Yii::app()->user->email;
             $model->senderName = Yii::app()->user->username;
         }
         $model->ownerId = $apartment->user->id;
         $model->ownerEmail = $apartment->user->email;
         $model->ownerName = $apartment->user->username;
         $model->apartmentUrl = $apartment->getUrl();
         if ($model->validate()) {
             $notifier = new Notifier();
             $notifier->raiseEvent('onRequestProperty', $model, array('forceEmail' => $model->ownerEmail));
             Yii::app()->user->setFlash('success', tt('Thanks_for_request', 'apartments'));
             $model = new SendMailForm();
             // clear fields
         } else {
             $model->unsetAttributes(array('verifyCode'));
             Yii::app()->user->setFlash('error', tt('Error_send_request', 'apartments'));
         }
     }
     if ($isFancy) {
         //Yii::app()->clientscript->scriptMap['*.js'] = false;
         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('send_email', array('apartment' => $apartment, 'isFancy' => true, 'model' => $model), false, true);
     } else {
         $this->render('send_email', array('apartment' => $apartment, 'isFancy' => false, 'model' => $model));
     }
 }
Exemplo n.º 23
0
 public static function deactivateUserAdsByTariffPlan($users = array())
 {
     if ($users && count($users)) {
         foreach ($users as $id) {
             $criteria = new CDbCriteria();
             $criteria->addCondition('owner_id = ' . $id);
             $criteria->addCondition('active <> ' . Apartment::STATUS_DRAFT);
             $criteria->addCondition('owner_active = ' . Apartment::STATUS_ACTIVE);
             $criteria->order = 'date_created DESC';
             $usersAds = Apartment::model()->findAll($criteria);
             if ($usersAds) {
                 $cntAds = count($usersAds);
                 $defaultTariffInfo = TariffPlans::getFullTariffInfoById(TariffPlans::DEFAULT_TARIFF_PLAN_ID);
                 $limit = $defaultTariffInfo['limitObjects'];
                 if ($limit && $cntAds > $limit) {
                     $adsToDeactivate = array_slice($usersAds, $limit);
                     if ($adsToDeactivate) {
                         foreach ($adsToDeactivate as $ad) {
                             if ($ad) {
                                 //$ad->active = Apartment::STATUS_INACTIVE;
                                 $ad->owner_active = Apartment::STATUS_INACTIVE;
                                 //$ad->update(array('active', 'owner_active'));
                                 $ad->update(array('owner_active'));
                             }
                         }
                     }
                 }
             }
         }
     }
 }
Exemplo n.º 24
0
 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]);
 }
Exemplo n.º 25
0
 public function actionView($id)
 {
     // get current apartment by ID
     $model = Apartment::model()->findByPk($id);
     $this->seoTitle = $model['title_ru'] . " - Golden Wall";
     // check if apartment is active
     if ($model && $model->owner_active == 1 && $model->active == 1) {
         $this->layout = '//layouts/catalog';
         // check user is logged?
         if (Yii::app()->user->getId()) {
             $views = new ApartmentViews();
             $views->apartment_id = Yii::app()->request->getParam('id');
             $views->user_id = Yii::app()->user->getId();
             $views->save();
         }
         // render view
         $this->render('view', array('item' => $model));
     } else {
         return $this->redirect('/catalog');
     }
 }
Exemplo n.º 26
0
 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));
     }
 }
Exemplo n.º 27
0
 private function getReferenceInfo($pk = '')
 {
     $comfort = $bathroom = $kitchen = $employment = $safety = $entertainment = $terms = $services = '';
     if (!isFree()) {
         Yii::app()->setLanguage($this->defLang);
         $apartmentInfo = Apartment::model()->getFullInformation($pk);
         Yii::app()->setLanguage($this->currLang);
     } else {
         $apartmentInfo = Apartment::model()->getFullInformation($pk);
     }
     if (is_array($apartmentInfo)) {
         foreach ($apartmentInfo as $key => $value) {
             switch ($key) {
                 case 1:
                     $comfort = implode($this->separatorElem, $value['values']);
                     break;
                 case 2:
                     $bathroom = implode($this->separatorElem, $value['values']);
                     break;
                 case 3:
                     $kitchen = implode($this->separatorElem, $value['values']);
                     break;
                 case 4:
                     $employment = implode($this->separatorElem, $value['values']);
                     break;
                 case 5:
                     $safety = implode($this->separatorElem, $value['values']);
                     break;
                 case 7:
                     $entertainment = implode($this->separatorElem, $value['values']);
                     break;
                 case 9:
                     $terms = implode($this->separatorElem, $value['values']);
                     break;
                 case 10:
                     $services = implode($this->separatorElem, $value['values']);
                     break;
                 default:
                     break;
             }
         }
     }
     return array('comfort' => $comfort, 'bathroom' => $bathroom, 'kitchen' => $kitchen, 'employment' => $employment, 'safety' => $safety, 'entertainment' => $entertainment, 'terms' => $terms, 'services' => $services);
 }
Exemplo n.º 28
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;
Exemplo n.º 29
0
} else {
    $columns[] = array('name' => 'city_id', 'value' => '($data->city_id && isset($data->city)) ? $data->city->name : ""', 'htmlOptions' => array('style' => 'width: 150px;'), 'sortable' => false, 'filter' => ApartmentCity::getAllCity());
}
$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(
//    'name' => 'ownerUsername',
//    'htmlOptions' => array(
//        'style' => 'width: 150px;',
//    ),
//    'value' => 'isset($data->user->username) ? $data->user->username : ""'
//);
$columns[] = array('header' => tc('Name'), 'name' => 'title_' . Yii::app()->language, 'type' => 'raw', 'value' => 'CHtml::encode($data->{"title_".Yii::app()->language})', 'sortable' => false);
if (issetModule('paidservices')) {
    $columns[] = array('name' => 'searchPaidService', 'value' => '$data->getPaidHtml(true, true)', 'type' => 'raw', 'htmlOptions' => array('style' => 'width: 200px;'), 'sortable' => false, 'filter' => $paidServicesArray);
}
$columns[] = array('class' => 'bootstrap.widgets.TbButtonColumn', 'template' => '{up}{down}{change_owner}{view}{update}{clone}{delete}{restore}', 'deleteConfirmation' => tc('Are you sure you want to delete this item?'), 'htmlOptions' => array('class' => 'width135'), 'buttons' => array('change_owner' => array('label' => '', 'url' => 'Yii::app()->createUrl("/apartments/backend/main/choosenewowner", array("id" => $data->id))', 'options' => array('class' => 'icon-user', 'title' => tt('Set the owner of the listing', 'apartments')), 'visible' => ' Yii::app()->user->checkAccess("apartments_admin") ? true : false'), 'delete' => array('visible' => '(!param("notDeleteListings", 0) || (param("notDeleteListings", 0) && !$data->deleted))'), 'view' => array('url' => '$data->getUrl()', 'options' => array('target' => '_blank')), 'up' => array('label' => tc('Move an item up'), 'imageUrl' => $url = Yii::app()->assetManager->publish(Yii::getPathOfAlias('zii.widgets.assets.gridview') . '/up.gif'), 'url' => 'Yii::app()->createUrl("/apartments/backend/main/move", array("id"=>$data->id, "direction" => "down", "catid" => "0"))', 'options' => array('class' => 'infopages_arrow_image_up'), 'visible' => '$data->sorter < "' . $maxSorter . '"', 'click' => "js: function() { ajaxMoveRequest(\$(this).attr('href'), 'apartments-grid'); return false;}"), 'clone' => array('label' => tc('Clone'), 'url' => 'Yii::app()->createUrl("/apartments/backend/main/clone", array("id" => $data->id))', 'imageUrl' => Yii::app()->request->baseUrl . '/images/interface/copy_admin.png', 'click' => "js: function() { ajaxMoveRequest(\$(this).attr('href'), 'apartments-grid'); return false;}"), 'restore' => array('label' => '', 'url' => 'Yii::app()->createUrl("/apartments/backend/main/restore", array("id" => $data->id))', 'options' => array('class' => 'icon-retweet', 'title' => tt('Restore', 'apartments')), 'click' => "js: function() { ajaxMoveRequest(\$(this).attr('href'), 'apartments-grid'); return false;}", 'visible' => '$data->deleted'), 'down' => array('label' => tc('Move an item down'), 'imageUrl' => $url = Yii::app()->assetManager->publish(Yii::getPathOfAlias('zii.widgets.assets.gridview') . '/down.gif'), 'url' => 'Yii::app()->createUrl("/apartments/backend/main/move", array("id"=>$data->id, "direction" => "up", "catid" => "0"))', 'options' => array('class' => 'infopages_arrow_image_down'), 'visible' => '$data->sorter > "' . $minSorter . '"', 'click' => "js: function() { ajaxMoveRequest(\$(this).attr('href'), 'apartments-grid'); return false;}")));
$this->widget('CustomGridView', array('id' => 'apartments-grid', 'dataProvider' => $model->search(), 'filter' => $model, 'afterAjaxUpdate' => 'function(){$("a[rel=\'tooltip\']").tooltip(); $("div.tooltip-arrow").remove(); $("div.tooltip-inner").remove(); reInstallSortable();}', 'rowCssClassExpression' => '"items[]_{$data->id}"', 'columns' => $columns));
$options = array('activate' => Yii::t('common', 'Activate'), 'deactivate' => Yii::t('common', 'Deactivate'), 'delete' => Yii::t('common', 'Delete'), 'clone' => Yii::t('common', 'Clone'));
if (Apartment::model()->countByAttributes(array('deleted' => 1))) {
    $options['restore'] = tt('Restore', 'apartments');
}
$this->renderPartial('//site/admin-select-items', array('url' => '/apartments/backend/main/itemsSelected', 'id' => 'apartments-grid', 'model' => $model, 'options' => $options));
?>

<?php 
$csrf_token_name = Yii::app()->request->csrfTokenName;
$csrf_token = Yii::app()->request->csrfToken;
$cs = Yii::app()->getClientScript();
$cs->registerCoreScript('jquery.ui');
$str_js = "\n\t\tvar fixHelper = function(e, ui) {\n\t\t\tui.children().each(function() {\n\t\t\t\t\$(this).width(\$(this).width());\n\t\t\t});\n\t\t\treturn ui;\n\t\t};\n\n\t\tfunction reInstallSortable(id, data) {\n\t\t\tinstallSortable();\n\t\t}\n\n\t\tfunction updateGrid() {\n\t\t\t\$.fn.yiiGridView.update('apartments-grid');\n\t\t}\n\n\t\tfunction installSortable() {\n\t\t\t\$('#apartments-grid table.items tbody').sortable({\n\t\t\t\tforcePlaceholderSize: true,\n\t\t\t\tforceHelperSize: true,\n\t\t\t\titems: 'tr',\n\t\t\t\tupdate : function () {\n\t\t\t\t\tserial = \$('#apartments-grid table.items tbody').sortable('serialize', {key: 'items[]', attribute: 'class'}) + '&{$csrf_token_name}={$csrf_token}';\n\t\t\t\t\t\$.ajax({\n\t\t\t\t\t\t'url': '" . $this->createUrl('/apartments/backend/main/sortitems') . "',\n\t\t\t\t\t\t'type': 'post',\n\t\t\t\t\t\t'data': serial,\n\t\t\t\t\t\t'success': function(data){\n\t\t\t\t\t\t\tupdateGrid();\n\t\t\t\t\t\t},\n\t\t\t\t\t\t'error': function(request, status, error){\n\t\t\t\t\t\t\talert('We are unable to set the sort order at this time.  Please try again in a few minutes.');\n\t\t\t\t\t\t}\n\t\t\t\t\t});\n\t\t\t\t},\n\t\t\t\thelper: fixHelper\n\t\t\t}).disableSelection();\n\t\t}\n\n\t\tinstallSortable();\n";
$cs->registerScript('sortable-project', $str_js);