public function actionSaveSort() { $objTypeId = Yii::app()->request->getParam('id', NULL); $sort = Yii::app()->request->getParam('sort'); if (count($sort) >= param('searchMaxField', 15)) { HAjax::jsonError(tt('Search max field ') . param('searchMaxField', 3)); } if ($objTypeId !== NULL && $sort && is_array($sort)) { $elements = SearchForm::getSearchFields(); $sql = "DELETE FROM {{search_form}} WHERE obj_type_id=:id AND status!=:status"; Yii::app()->db->createCommand($sql)->execute(array(':id' => $objTypeId, ':status' => SearchFormModel::STATUS_NOT_REMOVE)); $i = 3; foreach ($sort as $field) { if (!isset($elements[$field])) { continue; } $search = new SearchFormModel(); $search->attributes = array('obj_type_id' => $objTypeId, 'field' => $field, 'status' => $elements[$field]['status'], 'sorter' => $i, 'formdesigner_id' => isset($elements[$field]['formdesigner_id']) ? $elements[$field]['formdesigner_id'] : 0); $search->save(); $i++; } // delete assets js cache ConfigurationModel::clearGenerateJSAssets(); HAjax::jsonOk(); } HAjax::jsonError(); }
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')); } }
public function actionSetDefault() { if (demo()) { throw new CException(tc('Sorry, this action is not allowed on the demo server.')); } $id = (int) Yii::app()->request->getPost('id'); $model = Themes::model()->findByPk($id); $model->setDefault(); // delete assets js cache ConfigurationModel::clearGenerateJSAssets(); Yii::app()->end(); }
public function actionUpdate($id) { $model = $this->loadModel($id); $this->performAjaxValidation($model); if (isset($_POST[$this->modelName])) { $model->attributes = $_POST[$this->modelName]; $model->scenario = 'save_types'; if ($model->save()) { // delete assets js cache ConfigurationModel::clearGenerateJSAssets(); $this->redirect(array('admin')); } } $this->render('_setup_form', array('model' => $model)); }