Пример #1
0
 public function actionUpdate($id)
 {
     $this->_model = $this->loadModel($id);
     if (!$this->_model) {
         throw404();
     }
     $oldStatus = $this->_model->active;
     if (issetModule('bookingcalendar')) {
         $this->_model = $this->_model->with(array('bookingCalendar'));
     }
     if (isset($_GET['type'])) {
         $this->_model->type = HApartment::getRequestType();
     }
     if (isset($_POST[$this->modelName])) {
         $this->_model->attributes = $_POST[$this->modelName];
         if ($this->_model->type != Apartment::TYPE_BUY && $this->_model->type != Apartment::TYPE_RENTING) {
             // video, panorama, lat, lon
             HApartment::saveOther($this->_model);
         }
         $this->_model->scenario = 'savecat';
         $isUpdate = Yii::app()->request->getPost('is_update');
         $this->_model->isAjaxLoadOnUpdate = $isUpdate;
         if ($isUpdate) {
             $this->_model->active = $oldStatus;
             $this->_model->save(false);
         } elseif ($this->_model->validate()) {
             $this->_model->save(false);
             Yii::app()->user->setFlash('success', tc('Success'));
             $this->redirect(array('update', 'id' => $this->_model->id));
         }
     }
     HApartment::getCategoriesForUpdate($this->_model);
     if ($this->_model->active == Apartment::STATUS_DRAFT) {
         Yii::app()->user->setState('menu_active', 'apartments.create');
         $this->render('create', array('model' => $this->_model, 'supportvideoext' => ApartmentVideo::model()->supportExt, 'supportvideomaxsize' => ApartmentVideo::model()->fileMaxSize));
         return;
     }
     $this->render('update', array('model' => $this->_model, 'supportvideoext' => ApartmentVideo::model()->supportExt, 'supportvideomaxsize' => ApartmentVideo::model()->fileMaxSize));
 }
Пример #2
0
 public function actionUpdate($id)
 {
     $this->setActiveMenu('add_ad');
     $model = $this->loadModelUserAd($id);
     if (issetModule('bookingcalendar')) {
         $model = $model->with(array('bookingCalendar'));
     }
     $this->performAjaxValidation($model);
     if (isset($_GET['type'])) {
         $model->type = HApartment::getRequestType();
     }
     if (isset($_POST[$this->modelName])) {
         $originalActive = $model->active;
         $model->attributes = $_POST[$this->modelName];
         if ($model->type != Apartment::TYPE_BUY && $model->type != Apartment::TYPE_RENTING) {
             // video, panorama, lat, lon
             HApartment::saveOther($model);
         }
         $model->scenario = 'savecat';
         $model->owner_active = Apartment::STATUS_ACTIVE;
         if (issetModule('tariffPlans') && issetModule('paidservices')) {
             $return = TariffPlans::checkAllowUserActivateAd(Yii::app()->user->id, true, '>=');
             if ($return === false) {
                 $model->owner_active = Apartment::STATUS_INACTIVE;
             }
         }
         $isUpdate = Yii::app()->request->getPost('is_update');
         $model->isAjaxLoadOnUpdate = $isUpdate;
         if ($isUpdate) {
             $model->save(false);
         } elseif ($model->validate()) {
             if (param('useUseradsModeration', 1)) {
                 $model->active = Apartment::STATUS_MODERATION;
             } else {
                 $model->active = Apartment::STATUS_ACTIVE;
             }
             if ($model->save(false)) {
                 if ($model->owner_active == Apartment::STATUS_INACTIVE) {
                     $this->redirect(array('/usercpanel/main/index'));
                 } else {
                     $this->redirect(array('/apartments/main/view', 'id' => $model->id));
                 }
             }
         } else {
             $model->active = $originalActive;
         }
     }
     HApartment::getCategoriesForUpdate($model);
     if ($model->active == Apartment::STATUS_DRAFT) {
         Yii::app()->user->setState('menu_active', 'apartments.create');
         $this->render('create', array('model' => $model, 'supportvideoext' => ApartmentVideo::model()->supportExt, 'supportvideomaxsize' => ApartmentVideo::model()->fileMaxSize));
         return;
     }
     $this->render('update', array('model' => $model, 'supportvideoext' => ApartmentVideo::model()->supportExt, 'supportvideomaxsize' => ApartmentVideo::model()->fileMaxSize));
 }
Пример #3
0
    </div>

    <?php 
echo $form->error($model, 'price');
?>
</div>
<div class="clear"></div>
<?php 
$this->widget('application.modules.lang.components.langFieldWidget', array('model' => $model, 'field' => 'title', 'type' => 'string'));
echo '<br/>';
if ($model->type == Apartment::TYPE_CHANGE) {
    echo '<div class="clear">&nbsp;</div>';
    $this->widget('application.modules.lang.components.langFieldWidget', array('model' => $model, 'field' => 'exchange_to', 'type' => 'text'));
}
$rows = HFormEditor::getGeneralFields();
HFormEditor::renderFormRows($rows, $model);
$canSet = $model->canSetPeriodActivity() ? 1 : 0;
echo '<div class="rowold" id="set_period" ' . (!$canSet ? 'style="display: none;"' : '') . '>';
echo $form->labelEx($model, 'period_activity');
echo $form->dropDownList($model, 'period_activity', HApartment::getPeriodActivityList());
echo CHtml::hiddenField('set_period_activity', $canSet);
echo $form->error($model, 'period_activity');
echo '</div>';
if (!$canSet) {
    echo '<div id="date_end_activity"><b>' . Yii::t('common', 'The listing will be active till {DATE}', array('{DATE}' => $model->getDateEndActivityLongFormat())) . '</b>';
    echo '&nbsp;' . CHtml::link(tc('Change'), 'javascript:;', array('onclick' => '$("#date_end_activity").hide(); $("#set_period_activity").val(1); $("#set_period").show();'));
    echo '</div>';
}
?>

</div>
Пример #4
0
 public static function getEnumListForKey($key)
 {
     $list = array('apartment_periodActivityDefault' => HApartment::getPeriodActivityList(), 'mode_list_show' => HApartment::getModeShowList(), 'mailSMTPSecure' => array('' => '', 'tls' => 'tls', 'ssl' => 'ssl'), 'user_registrationMode' => User::getRegistrationModeList());
     return isset($list[$key]) ? $list[$key] : array();
 }