Commit 61b7d3705258c3828a24649b6abbd3e7df311624
Merge remote-tracking branch 'origin/Yarik'
Showing
39 changed files
with
2094 additions
and
2 deletions
Show diff stats
backend/config/main.php
common/config/main.php
| @@ -6,7 +6,7 @@ return [ | @@ -6,7 +6,7 @@ return [ | ||
| 6 | 'class' => 'yii\caching\FileCache', | 6 | 'class' => 'yii\caching\FileCache', |
| 7 | ], | 7 | ], |
| 8 | 'urlManager' => [ | 8 | 'urlManager' => [ |
| 9 | - 'enablePrettyUrl' => true, | 9 | + 'enablePrettyUrl' => false, |
| 10 | 'showScriptName' => false, | 10 | 'showScriptName' => false, |
| 11 | 'class'=> 'common\components\LangUrlManager', | 11 | 'class'=> 'common\components\LangUrlManager', |
| 12 | 'rules'=>[ | 12 | 'rules'=>[ |
| 1 | +-- -------------------------------------------------------- | ||
| 2 | +-- Хост: 127.0.0.1 | ||
| 3 | +-- Версия сервера: 5.6.26 - MySQL Community Server (GPL) | ||
| 4 | +-- ОС Сервера: Win32 | ||
| 5 | +-- HeidiSQL Версия: 9.3.0.4984 | ||
| 6 | +-- -------------------------------------------------------- | ||
| 7 | + | ||
| 8 | +/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; | ||
| 9 | +/*!40101 SET NAMES utf8mb4 */; | ||
| 10 | +/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */; | ||
| 11 | +/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */; | ||
| 12 | + | ||
| 13 | +-- Дамп структуры для таблица artbox_db.option | ||
| 14 | +CREATE TABLE IF NOT EXISTS `option` ( | ||
| 15 | + `option_id` int(11) NOT NULL AUTO_INCREMENT, | ||
| 16 | + `model` varchar(200) NOT NULL, | ||
| 17 | + `model_id` int(11) NOT NULL, | ||
| 18 | + `name` varchar(200) NOT NULL, | ||
| 19 | + `template` varchar(200) NOT NULL, | ||
| 20 | + `parent_id` int(11) DEFAULT NULL, | ||
| 21 | + PRIMARY KEY (`option_id`), | ||
| 22 | + KEY `FK_option_option` (`parent_id`), | ||
| 23 | + CONSTRAINT `FK_option_option` FOREIGN KEY (`parent_id`) REFERENCES `option` (`option_id`) | ||
| 24 | +) ENGINE=InnoDB AUTO_INCREMENT=26 DEFAULT CHARSET=utf8; | ||
| 25 | + | ||
| 26 | +-- Дамп данных таблицы artbox_db.option: ~6 rows (приблизительно) | ||
| 27 | +/*!40000 ALTER TABLE `option` DISABLE KEYS */; | ||
| 28 | +INSERT INTO `option` (`option_id`, `model`, `model_id`, `name`, `template`, `parent_id`) VALUES | ||
| 29 | + (20, 'user', 10, 'phone', 'input', NULL), | ||
| 30 | + (21, 'user', 10, 'adres', 'input', 20), | ||
| 31 | + (22, 'user', 10, 'phone', 'input', NULL), | ||
| 32 | + (23, 'user', 10, 'adres', 'input', 22), | ||
| 33 | + (24, 'user', 10, 'phone', 'input', NULL), | ||
| 34 | + (25, 'user', 10, 'adres', 'input', 24); | ||
| 35 | +/*!40000 ALTER TABLE `option` ENABLE KEYS */; | ||
| 36 | + | ||
| 37 | + | ||
| 38 | +-- Дамп структуры для таблица artbox_db.option_lang | ||
| 39 | +CREATE TABLE IF NOT EXISTS `option_lang` ( | ||
| 40 | + `primary` int(11) NOT NULL AUTO_INCREMENT, | ||
| 41 | + `id` int(11) NOT NULL, | ||
| 42 | + `lang_id` int(11) NOT NULL, | ||
| 43 | + `value` text NOT NULL, | ||
| 44 | + PRIMARY KEY (`primary`), | ||
| 45 | + KEY `Индекс 1` (`id`), | ||
| 46 | + KEY `Индекс 2` (`lang_id`) | ||
| 47 | +) ENGINE=InnoDB AUTO_INCREMENT=36 DEFAULT CHARSET=utf8; | ||
| 48 | + | ||
| 49 | +-- Дамп данных таблицы artbox_db.option_lang: ~16 rows (приблизительно) | ||
| 50 | +/*!40000 ALTER TABLE `option_lang` DISABLE KEYS */; | ||
| 51 | +INSERT INTO `option_lang` (`primary`, `id`, `lang_id`, `value`) VALUES | ||
| 52 | + (20, 20, 0, 'phone'), | ||
| 53 | + (21, 20, 1, 'phone111ukr'), | ||
| 54 | + (22, 20, 2, 'phone111ru'), | ||
| 55 | + (23, 21, 0, 'adres111'), | ||
| 56 | + (24, 21, 1, 'adres111'), | ||
| 57 | + (25, 21, 2, 'adres222'), | ||
| 58 | + (26, 22, 0, 'phone222'), | ||
| 59 | + (27, 22, 1, 'phone222uk'), | ||
| 60 | + (28, 23, 0, 'adres111'), | ||
| 61 | + (29, 23, 1, 'adres111'), | ||
| 62 | + (30, 23, 2, 'adres111'), | ||
| 63 | + (31, 24, 0, 'phone333'), | ||
| 64 | + (32, 24, 2, 'phone333ru'), | ||
| 65 | + (33, 25, 0, 'adres111'), | ||
| 66 | + (34, 25, 1, 'adres111'), | ||
| 67 | + (35, 25, 2, 'adres111'); | ||
| 68 | +/*!40000 ALTER TABLE `option_lang` ENABLE KEYS */; | ||
| 69 | +/*!40101 SET SQL_MODE=IFNULL(@OLD_SQL_MODE, '') */; | ||
| 70 | +/*!40014 SET FOREIGN_KEY_CHECKS=IF(@OLD_FOREIGN_KEY_CHECKS IS NULL, 1, @OLD_FOREIGN_KEY_CHECKS) */; | ||
| 71 | +/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */; |
frontend/assets/AppAsset.php
| @@ -26,4 +26,7 @@ class AppAsset extends AssetBundle | @@ -26,4 +26,7 @@ class AppAsset extends AssetBundle | ||
| 26 | 'yii\web\YiiAsset', | 26 | 'yii\web\YiiAsset', |
| 27 | 'yii\bootstrap\BootstrapAsset', | 27 | 'yii\bootstrap\BootstrapAsset', |
| 28 | ]; | 28 | ]; |
| 29 | + public $jsOptions = array( | ||
| 30 | + 'position' => \yii\web\View::POS_HEAD | ||
| 31 | + ); | ||
| 29 | } | 32 | } |
| 1 | +<?php | ||
| 2 | + | ||
| 3 | +namespace frontend\controllers; | ||
| 4 | + | ||
| 5 | +use Yii; | ||
| 6 | +use frontend\models\Option; | ||
| 7 | +use frontend\models\OptionSearch; | ||
| 8 | +use yii\web\Controller; | ||
| 9 | +use yii\web\NotFoundHttpException; | ||
| 10 | +use yii\filters\VerbFilter; | ||
| 11 | +use frontend\models\OptionLang; | ||
| 12 | + | ||
| 13 | +/** | ||
| 14 | + * OptionController implements the CRUD actions for Option model. | ||
| 15 | + */ | ||
| 16 | +class OptionController extends Controller | ||
| 17 | +{ | ||
| 18 | + public function behaviors() | ||
| 19 | + { | ||
| 20 | + return [ | ||
| 21 | + 'verbs' => [ | ||
| 22 | + 'class' => VerbFilter::className(), | ||
| 23 | + 'actions' => [ | ||
| 24 | + 'delete' => ['post'], | ||
| 25 | + ], | ||
| 26 | + ], | ||
| 27 | + ]; | ||
| 28 | + } | ||
| 29 | + | ||
| 30 | + /** | ||
| 31 | + * Lists all Option models. | ||
| 32 | + * @return mixed | ||
| 33 | + */ | ||
| 34 | + public function actionIndex() | ||
| 35 | + { | ||
| 36 | + $searchModel = new OptionSearch(); | ||
| 37 | + $dataProvider = $searchModel->search(Yii::$app->request->queryParams); | ||
| 38 | + | ||
| 39 | + return $this->render('index', [ | ||
| 40 | + 'searchModel' => $searchModel, | ||
| 41 | + 'dataProvider' => $dataProvider, | ||
| 42 | + ]); | ||
| 43 | + } | ||
| 44 | + | ||
| 45 | + /** | ||
| 46 | + * Displays a single Option model. | ||
| 47 | + * @param integer $id | ||
| 48 | + * @return mixed | ||
| 49 | + */ | ||
| 50 | + public function actionView($id) | ||
| 51 | + { | ||
| 52 | + return $this->render('view', [ | ||
| 53 | + 'model' => $this->findModel($id), | ||
| 54 | + ]); | ||
| 55 | + } | ||
| 56 | + | ||
| 57 | + /** | ||
| 58 | + * Creates a new Option model. | ||
| 59 | + * If creation is successful, the browser will be redirected to the 'view' page. | ||
| 60 | + * @return mixed | ||
| 61 | + */ | ||
| 62 | + public function actionCreate() | ||
| 63 | + { | ||
| 64 | + $model = new Option(); | ||
| 65 | + $modellang = new OptionLang(); | ||
| 66 | + $modeldb = 'user'; | ||
| 67 | + $model_id = '10'; | ||
| 68 | + $fields = [['name' => 'phone', 'template' => 'input'], ['name' => 'adres', 'template' => 'input']]; | ||
| 69 | + $post = \Yii::$app->request->post(); | ||
| 70 | + if(!empty($post['Option'])) { | ||
| 71 | + $ok = 1; | ||
| 72 | + $parentid = null; | ||
| 73 | + $models = array(); | ||
| 74 | + foreach($post['Option'] as $index => $option) { | ||
| 75 | + if(in_array($index, array('model', 'model_id')) && $index !== 0) { continue; } | ||
| 76 | + $first = 1; | ||
| 77 | + foreach($option['value'] as $key => $value) { | ||
| 78 | + $models[$index][$key] = new Option(); | ||
| 79 | + $models[$index][$key]->model = $post['Option']['model']; | ||
| 80 | + $models[$index][$key]->model_id = $post['Option']['model_id']; | ||
| 81 | + $models[$index][$key]->template = $option['template']; | ||
| 82 | + $models[$index][$key]->name = $key; | ||
| 83 | + if(!$first) { | ||
| 84 | + $models[$index][$key]->parent_id = $parentid; | ||
| 85 | + } | ||
| 86 | + $modelslang[$index][$key][0] = new OptionLang(); | ||
| 87 | + if(!empty($value) && $models[$index][$key]->save()) { | ||
| 88 | + if($first) { | ||
| 89 | + $parentid = $models[$index][$key]->option_id; | ||
| 90 | + } | ||
| 91 | + $modelslang[$index][$key][0]->id = $models[$index][$key]->option_id; | ||
| 92 | + $modelslang[$index][$key][0]->lang_id = 0; | ||
| 93 | + $modelslang[$index][$key][0]->value = $value; | ||
| 94 | + if($modelslang[$index][$key][0]->save()) { | ||
| 95 | + if(!empty($option['lang'][$key])) { | ||
| 96 | + foreach($option['lang'][$key] as $code => $lang) { | ||
| 97 | + if(!empty($lang)) { | ||
| 98 | + $modelslang[$index][$key][$code] = new OptionLang(); | ||
| 99 | + $modelslang[$index][$key][$code]->id = $models[$index][$key]->option_id; | ||
| 100 | + $modelslang[$index][$key][$code]->lang_id = $code; | ||
| 101 | + $modelslang[$index][$key][$code]->value = $lang; | ||
| 102 | + if(!$modelslang[$index][$key][$code]->save()) { | ||
| 103 | + $ok = 0; | ||
| 104 | + } | ||
| 105 | + } | ||
| 106 | + } | ||
| 107 | + } | ||
| 108 | + } | ||
| 109 | + } else { | ||
| 110 | + $models[$index][$key]->validate(); | ||
| 111 | + $modelslang[$index][$key][0]->validate(); | ||
| 112 | + $modelslang[$index][$key][0]; | ||
| 113 | + if(!empty($option['lang'][$key])) { | ||
| 114 | + foreach($option['lang'][$key] as $code => $lang) { | ||
| 115 | + if(!empty($lang)) { | ||
| 116 | + $modelslang[$index][$key][$code] = new OptionLang(); | ||
| 117 | + $modelslang[$index][$key][$code]->id = $models[$index][$key]->option_id; | ||
| 118 | + $modelslang[$index][$key][$code]->lang_id = $code; | ||
| 119 | + $modelslang[$index][$key][$code]->value = $lang; | ||
| 120 | + } | ||
| 121 | + } | ||
| 122 | + } | ||
| 123 | + $ok = 0; | ||
| 124 | + } | ||
| 125 | + $first = 0; | ||
| 126 | + } | ||
| 127 | + } | ||
| 128 | + if($ok) { | ||
| 129 | + return $this->redirect(['view', 'id' => $parentid]); | ||
| 130 | + } else { | ||
| 131 | + return $this->render('create', [ | ||
| 132 | + 'model' => $model, | ||
| 133 | + 'models' => $models, | ||
| 134 | + 'modellang' => $modelslang, | ||
| 135 | + 'modeldb' => $modeldb, | ||
| 136 | + 'model_id' => $model_id, | ||
| 137 | + 'fields' => $fields | ||
| 138 | + ]); | ||
| 139 | + } | ||
| 140 | + } | ||
| 141 | + if ($model->load(Yii::$app->request->post()) && $model->save()) { | ||
| 142 | + return $this->redirect(['view', 'id' => $model->option_id]); | ||
| 143 | + } else { | ||
| 144 | + return $this->render('create', [ | ||
| 145 | + 'model' => $model, | ||
| 146 | + 'modeldb' => $modeldb, | ||
| 147 | + 'model_id' => $model_id, | ||
| 148 | + 'fields' => $fields | ||
| 149 | + ]); | ||
| 150 | + } | ||
| 151 | + } | ||
| 152 | + | ||
| 153 | + /** | ||
| 154 | + * Updates an existing Option model. | ||
| 155 | + * If update is successful, the browser will be redirected to the 'view' page. | ||
| 156 | + * @param integer $id | ||
| 157 | + * @return mixed | ||
| 158 | + */ | ||
| 159 | + public function actionUpdate($id) | ||
| 160 | + { | ||
| 161 | + $models[$id] = Option::findOne($id); | ||
| 162 | + $modellang[$id] = array(); | ||
| 163 | + $langs = OptionLang::findAll(['id' => $id]); | ||
| 164 | + foreach($langs as $lang) { | ||
| 165 | + $modellang[$id][$lang->lang_id] = $lang; | ||
| 166 | + } | ||
| 167 | + $children = (new Option())->find()->where(['parent_id' => $id])->all(); | ||
| 168 | + foreach($children as $child) { | ||
| 169 | + $models[$child->option_id] = $child; | ||
| 170 | + $modellang[$child->option_id] = array(); | ||
| 171 | + $langs = OptionLang::findAll(['id' =>$child->option_id]); | ||
| 172 | + foreach($langs as $lang) { | ||
| 173 | + $modellang[$child->option_id][$lang->lang_id] = $lang; | ||
| 174 | + } | ||
| 175 | + } | ||
| 176 | + $modeldb = 'user'; | ||
| 177 | + $model_id = '10'; | ||
| 178 | + $fields = [['name' => 'phone', 'template' => 'input'], ['name' => 'adres', 'template' => 'input']]; | ||
| 179 | + $post = \Yii::$app->request->post(); | ||
| 180 | + $ok = 1; | ||
| 181 | + if(!empty($post)) { | ||
| 182 | + foreach($post['Option'] as $key => $option) { | ||
| 183 | + if(in_array($key, array('model', 'model_id'))) { continue; } | ||
| 184 | + $modellang[$key][0]->value = $option['value'][$models[$key]->name]; | ||
| 185 | + if(!$modellang[$key][0]->save()) { | ||
| 186 | + $ok = 0; | ||
| 187 | + } | ||
| 188 | + foreach($option['lang'] as $lang_id => $lang) { | ||
| 189 | + if(empty($modellang[$key][$lang_id])) { | ||
| 190 | + $modellang[$key][$lang_id] = new OptionLang(); | ||
| 191 | + $modellang[$key][$lang_id]->id = $models[$key]->option_id; | ||
| 192 | + $modellang[$key][$lang_id]->lang_id = $lang_id; | ||
| 193 | + $modellang[$key][$lang_id]->value = $lang; | ||
| 194 | + } else { | ||
| 195 | + $modellang[$key][$lang_id]->value = $lang; | ||
| 196 | + } | ||
| 197 | + if(!$modellang[$key][$lang_id]->save()) { | ||
| 198 | + $ok = 0; | ||
| 199 | + } | ||
| 200 | + } | ||
| 201 | + } | ||
| 202 | + if($ok) { | ||
| 203 | + return $this->redirect(['view', 'id' => $id]); | ||
| 204 | + } else { | ||
| 205 | + return $this->render('update', [ | ||
| 206 | + 'models' => $models, | ||
| 207 | + 'modellang' => $modellang, | ||
| 208 | + 'modeldb' => $modeldb, | ||
| 209 | + 'model_id' => $model_id | ||
| 210 | + ]); | ||
| 211 | + } | ||
| 212 | + } | ||
| 213 | + return $this->render('update', [ | ||
| 214 | + 'models' => $models, | ||
| 215 | + 'modellang' => $modellang, | ||
| 216 | + 'modeldb' => $modeldb, | ||
| 217 | + 'model_id' => $model_id | ||
| 218 | + ]); | ||
| 219 | + } | ||
| 220 | + | ||
| 221 | + /** | ||
| 222 | + * Deletes an existing Option model. | ||
| 223 | + * If deletion is successful, the browser will be redirected to the 'index' page. | ||
| 224 | + * @param integer $id | ||
| 225 | + * @return mixed | ||
| 226 | + */ | ||
| 227 | + public function actionDelete($id) | ||
| 228 | + { | ||
| 229 | + $this->findModel($id)->delete(); | ||
| 230 | + | ||
| 231 | + return $this->redirect(['index']); | ||
| 232 | + } | ||
| 233 | + | ||
| 234 | + /** | ||
| 235 | + * Finds the Option model based on its primary key value. | ||
| 236 | + * If the model is not found, a 404 HTTP exception will be thrown. | ||
| 237 | + * @param integer $id | ||
| 238 | + * @return Option the loaded model | ||
| 239 | + * @throws NotFoundHttpException if the model cannot be found | ||
| 240 | + */ | ||
| 241 | + protected function findModel($id) | ||
| 242 | + { | ||
| 243 | + if (($model = Option::findOne($id)) !== null) { | ||
| 244 | + return $model; | ||
| 245 | + } else { | ||
| 246 | + throw new NotFoundHttpException('The requested page does not exist.'); | ||
| 247 | + } | ||
| 248 | + } | ||
| 249 | +} |
| 1 | +<?php | ||
| 2 | + | ||
| 3 | +namespace frontend\controllers; | ||
| 4 | + | ||
| 5 | +use Yii; | ||
| 6 | +use frontend\models\OptionValues; | ||
| 7 | +use frontend\models\OptionValuesSearch; | ||
| 8 | +use yii\web\Controller; | ||
| 9 | +use yii\web\NotFoundHttpException; | ||
| 10 | +use yii\filters\VerbFilter; | ||
| 11 | + | ||
| 12 | +/** | ||
| 13 | + * OptionValuesController implements the CRUD actions for OptionValues model. | ||
| 14 | + */ | ||
| 15 | +class OptionValuesController extends Controller | ||
| 16 | +{ | ||
| 17 | + public function behaviors() | ||
| 18 | + { | ||
| 19 | + return [ | ||
| 20 | + 'verbs' => [ | ||
| 21 | + 'class' => VerbFilter::className(), | ||
| 22 | + 'actions' => [ | ||
| 23 | + 'delete' => ['post'], | ||
| 24 | + ], | ||
| 25 | + ], | ||
| 26 | + ]; | ||
| 27 | + } | ||
| 28 | + | ||
| 29 | + /** | ||
| 30 | + * Lists all OptionValues models. | ||
| 31 | + * @return mixed | ||
| 32 | + */ | ||
| 33 | + public function actionIndex() | ||
| 34 | + { | ||
| 35 | + $searchModel = new OptionValuesSearch(); | ||
| 36 | + $dataProvider = $searchModel->search(Yii::$app->request->queryParams); | ||
| 37 | + return $this->render('index', [ | ||
| 38 | + 'searchModel' => $searchModel, | ||
| 39 | + 'dataProvider' => $dataProvider, | ||
| 40 | + ]); | ||
| 41 | + } | ||
| 42 | + | ||
| 43 | + /** | ||
| 44 | + * Displays a single OptionValues model. | ||
| 45 | + * @param integer $id | ||
| 46 | + * @return mixed | ||
| 47 | + */ | ||
| 48 | + public function actionView($id) | ||
| 49 | + { | ||
| 50 | + return $this->render('view', [ | ||
| 51 | + 'model' => $this->findModel($id), | ||
| 52 | + ]); | ||
| 53 | + } | ||
| 54 | + | ||
| 55 | + /** | ||
| 56 | + * Creates a new OptionValues model. | ||
| 57 | + * If creation is successful, the browser will be redirected to the 'view' page. | ||
| 58 | + * @return mixed | ||
| 59 | + */ | ||
| 60 | + public function actionCreate() | ||
| 61 | + { | ||
| 62 | + $post = \Yii::$app->request->post(); | ||
| 63 | + if(is_array($post['OptionValues']['option_value_text'])) { | ||
| 64 | + $ok = 0; | ||
| 65 | + $first = 0; | ||
| 66 | + $id = 0; | ||
| 67 | + $models = array(); | ||
| 68 | + foreach($post['OptionValues']['option_value_text'] as $lang => $value) { | ||
| 69 | + $models[$lang] = new OptionValues(); | ||
| 70 | + $models[$lang]->load(Yii::$app->request->post()); | ||
| 71 | + $models[$lang]->option_lang_id = $lang; | ||
| 72 | + $models[$lang]->option_value_text = $value; | ||
| 73 | + if($first && $id) { | ||
| 74 | + $models[$lang]->option_value_parent = $id; | ||
| 75 | + } | ||
| 76 | + if($models[$lang]->save()) { | ||
| 77 | + $ok = 1; | ||
| 78 | + if(!$first) { | ||
| 79 | + $first = 1; | ||
| 80 | + $id = $models[$lang]->option_value_id; | ||
| 81 | + } | ||
| 82 | + } else { | ||
| 83 | + unset($models[$lang]); | ||
| 84 | + } | ||
| 85 | + } | ||
| 86 | + if($ok) { | ||
| 87 | + return $this->redirect(['view', 'id' => $id]); | ||
| 88 | + } | ||
| 89 | + } | ||
| 90 | + $model = new OptionValues(); | ||
| 91 | + if ($model->load(Yii::$app->request->post()) && $model->save()) { | ||
| 92 | + return $this->redirect(['view', 'id' => $model->option_value_id]); | ||
| 93 | + } else { | ||
| 94 | + return $this->render('create', [ | ||
| 95 | + 'model' => $model, | ||
| 96 | + ]); | ||
| 97 | + } | ||
| 98 | + } | ||
| 99 | + | ||
| 100 | + /** | ||
| 101 | + * Updates an existing OptionValues model. | ||
| 102 | + * If update is successful, the browser will be redirected to the 'view' page. | ||
| 103 | + * @param integer $id | ||
| 104 | + * @return mixed | ||
| 105 | + */ | ||
| 106 | + public function actionUpdate($id) | ||
| 107 | + { | ||
| 108 | + $model = $this->findModel($id); | ||
| 109 | + | ||
| 110 | + if ($model->load(Yii::$app->request->post()) && $model->save()) { | ||
| 111 | + return $this->redirect(['view', 'id' => $model->option_value_id]); | ||
| 112 | + } else { | ||
| 113 | + return $this->render('update', [ | ||
| 114 | + 'model' => $model, | ||
| 115 | + ]); | ||
| 116 | + } | ||
| 117 | + } | ||
| 118 | + | ||
| 119 | + /** | ||
| 120 | + * Deletes an existing OptionValues model. | ||
| 121 | + * If deletion is successful, the browser will be redirected to the 'index' page. | ||
| 122 | + * @param integer $id | ||
| 123 | + * @return mixed | ||
| 124 | + */ | ||
| 125 | + public function actionDelete($id) | ||
| 126 | + { | ||
| 127 | + $this->findModel($id)->delete(); | ||
| 128 | + | ||
| 129 | + return $this->redirect(['index']); | ||
| 130 | + } | ||
| 131 | + | ||
| 132 | + /** | ||
| 133 | + * Finds the OptionValues model based on its primary key value. | ||
| 134 | + * If the model is not found, a 404 HTTP exception will be thrown. | ||
| 135 | + * @param integer $id | ||
| 136 | + * @return OptionValues the loaded model | ||
| 137 | + * @throws NotFoundHttpException if the model cannot be found | ||
| 138 | + */ | ||
| 139 | + protected function findModel($id) | ||
| 140 | + { | ||
| 141 | + if (($model = OptionValues::findOne($id)) !== null) { | ||
| 142 | + return $model; | ||
| 143 | + } else { | ||
| 144 | + throw new NotFoundHttpException('The requested page does not exist.'); | ||
| 145 | + } | ||
| 146 | + } | ||
| 147 | +} |
| 1 | +<?php | ||
| 2 | + | ||
| 3 | +namespace frontend\controllers; | ||
| 4 | + | ||
| 5 | +use Yii; | ||
| 6 | +use frontend\models\Options; | ||
| 7 | +use frontend\models\OptionsSearch; | ||
| 8 | +use yii\web\Controller; | ||
| 9 | +use yii\web\NotFoundHttpException; | ||
| 10 | +use yii\filters\VerbFilter; | ||
| 11 | + | ||
| 12 | +/** | ||
| 13 | + * OptionsController implements the CRUD actions for Options model. | ||
| 14 | + */ | ||
| 15 | +class OptionsController extends Controller | ||
| 16 | +{ | ||
| 17 | + public function behaviors() | ||
| 18 | + { | ||
| 19 | + return [ | ||
| 20 | + 'verbs' => [ | ||
| 21 | + 'class' => VerbFilter::className(), | ||
| 22 | + 'actions' => [ | ||
| 23 | + 'delete' => ['post'], | ||
| 24 | + ], | ||
| 25 | + ], | ||
| 26 | + ]; | ||
| 27 | + } | ||
| 28 | + | ||
| 29 | + /** | ||
| 30 | + * Lists all Options models. | ||
| 31 | + * @return mixed | ||
| 32 | + */ | ||
| 33 | + public function actionIndex() | ||
| 34 | + { | ||
| 35 | + $searchModel = new OptionsSearch(); | ||
| 36 | + $dataProvider = $searchModel->search(Yii::$app->request->queryParams); | ||
| 37 | + | ||
| 38 | + return $this->render('index', [ | ||
| 39 | + 'searchModel' => $searchModel, | ||
| 40 | + 'dataProvider' => $dataProvider, | ||
| 41 | + ]); | ||
| 42 | + } | ||
| 43 | + | ||
| 44 | + /** | ||
| 45 | + * Displays a single Options model. | ||
| 46 | + * @param integer $id | ||
| 47 | + * @return mixed | ||
| 48 | + */ | ||
| 49 | + public function actionView($id) | ||
| 50 | + { | ||
| 51 | + return $this->render('view', [ | ||
| 52 | + 'model' => $this->findModel($id), | ||
| 53 | + ]); | ||
| 54 | + } | ||
| 55 | + | ||
| 56 | + /** | ||
| 57 | + * Creates a new Options model. | ||
| 58 | + * If creation is successful, the browser will be redirected to the 'view' page. | ||
| 59 | + * @return mixed | ||
| 60 | + */ | ||
| 61 | + public function actionCreate() | ||
| 62 | + { | ||
| 63 | + $model = new Options(); | ||
| 64 | + | ||
| 65 | + if ($model->load(Yii::$app->request->post()) && $model->save()) { | ||
| 66 | + return $this->redirect(['view', 'id' => $model->option_id]); | ||
| 67 | + } else { | ||
| 68 | + return $this->render('create', [ | ||
| 69 | + 'model' => $model, | ||
| 70 | + ]); | ||
| 71 | + } | ||
| 72 | + } | ||
| 73 | + | ||
| 74 | + /** | ||
| 75 | + * Updates an existing Options model. | ||
| 76 | + * If update is successful, the browser will be redirected to the 'view' page. | ||
| 77 | + * @param integer $id | ||
| 78 | + * @return mixed | ||
| 79 | + */ | ||
| 80 | + public function actionUpdate($id) | ||
| 81 | + { | ||
| 82 | + $model = $this->findModel($id); | ||
| 83 | + | ||
| 84 | + if ($model->load(Yii::$app->request->post()) && $model->save()) { | ||
| 85 | + return $this->redirect(['view', 'id' => $model->option_id]); | ||
| 86 | + } else { | ||
| 87 | + return $this->render('update', [ | ||
| 88 | + 'model' => $model, | ||
| 89 | + ]); | ||
| 90 | + } | ||
| 91 | + } | ||
| 92 | + | ||
| 93 | + /** | ||
| 94 | + * Deletes an existing Options model. | ||
| 95 | + * If deletion is successful, the browser will be redirected to the 'index' page. | ||
| 96 | + * @param integer $id | ||
| 97 | + * @return mixed | ||
| 98 | + */ | ||
| 99 | + public function actionDelete($id) | ||
| 100 | + { | ||
| 101 | + $this->findModel($id)->delete(); | ||
| 102 | + | ||
| 103 | + return $this->redirect(['index']); | ||
| 104 | + } | ||
| 105 | + | ||
| 106 | + /** | ||
| 107 | + * Finds the Options model based on its primary key value. | ||
| 108 | + * If the model is not found, a 404 HTTP exception will be thrown. | ||
| 109 | + * @param integer $id | ||
| 110 | + * @return Options the loaded model | ||
| 111 | + * @throws NotFoundHttpException if the model cannot be found | ||
| 112 | + */ | ||
| 113 | + protected function findModel($id) | ||
| 114 | + { | ||
| 115 | + if (($model = Options::findOne($id)) !== null) { | ||
| 116 | + return $model; | ||
| 117 | + } else { | ||
| 118 | + throw new NotFoundHttpException('The requested page does not exist.'); | ||
| 119 | + } | ||
| 120 | + } | ||
| 121 | +} |
frontend/controllers/SiteController.php
| @@ -7,11 +7,15 @@ use frontend\models\PasswordResetRequestForm; | @@ -7,11 +7,15 @@ use frontend\models\PasswordResetRequestForm; | ||
| 7 | use frontend\models\ResetPasswordForm; | 7 | use frontend\models\ResetPasswordForm; |
| 8 | use frontend\models\SignupForm; | 8 | use frontend\models\SignupForm; |
| 9 | use frontend\models\ContactForm; | 9 | use frontend\models\ContactForm; |
| 10 | +use frontend\models\Options; | ||
| 11 | +use frontend\models\OptionValues; | ||
| 10 | use yii\base\InvalidParamException; | 12 | use yii\base\InvalidParamException; |
| 11 | use yii\web\BadRequestHttpException; | 13 | use yii\web\BadRequestHttpException; |
| 12 | use yii\web\Controller; | 14 | use yii\web\Controller; |
| 13 | use yii\filters\VerbFilter; | 15 | use yii\filters\VerbFilter; |
| 14 | use yii\filters\AccessControl; | 16 | use yii\filters\AccessControl; |
| 17 | +use frontend\models\OptionsToValues; | ||
| 18 | +use yii\validators\EmailValidator; | ||
| 15 | 19 | ||
| 16 | use common\models\Page; | 20 | use common\models\Page; |
| 17 | 21 | ||
| @@ -241,4 +245,45 @@ class SiteController extends Controller | @@ -241,4 +245,45 @@ class SiteController extends Controller | ||
| 241 | 'model' => $model, | 245 | 'model' => $model, |
| 242 | ]); | 246 | ]); |
| 243 | } | 247 | } |
| 248 | + public function actionOptions() { | ||
| 249 | + $option_model = new Options(); | ||
| 250 | + $option_list = $option_model->find()->where(1)->all(); | ||
| 251 | + $option_values = array(); | ||
| 252 | + $post = \Yii::$app->request->post(); | ||
| 253 | + if(!empty(\Yii::$app->request->post())) { | ||
| 254 | + $options_to_values = array(); | ||
| 255 | + $hasErrors = false; | ||
| 256 | + foreach($post['options'] as $key => $val) { | ||
| 257 | + $options_to_values[$key] = new OptionsToValues(); | ||
| 258 | + $options_to_values[$key]['option_id'] = $val['option_id']; | ||
| 259 | + $options_to_values[$key]->loadDefaultValues(); | ||
| 260 | + if($options_to_values[$key]->save()) { | ||
| 261 | + $option_values[$key] = new OptionValues(); | ||
| 262 | + $option_values[$key]['option_value_id'] = $options_to_values[$key]->getAttribute('option_value_id'); | ||
| 263 | + $option_values[$key]['option_value_text'] = $val['option_value']; | ||
| 264 | + if($options_to_values[$key]->option->getAttribute('option_translatable') == 0 || empty($val['option_lang_id'])) { | ||
| 265 | + $option_values[$key]['option_lang_id'] = 0; | ||
| 266 | + } else { | ||
| 267 | + $option_values[$key]['option_lang_id'] = $val['option_lang_id']; | ||
| 268 | + } | ||
| 269 | + if(!$option_values[$key]->save()) { | ||
| 270 | + $options_to_values[$key]->delete(); | ||
| 271 | + $hasErrors = true; | ||
| 272 | + } | ||
| 273 | + } | ||
| 274 | + } | ||
| 275 | + if(hasErrors) { | ||
| 276 | + $data['option_values'] = $option_values; | ||
| 277 | + return $this->render('options', ['options' => $data, 'post' => $post]); | ||
| 278 | + } else { | ||
| 279 | + var_dump($data); | ||
| 280 | + } | ||
| 281 | + } else { | ||
| 282 | + foreach($option_list as $index => $option) { | ||
| 283 | + $option_values[$option->getAttribute('option_id')] = new OptionValues(); | ||
| 284 | + } | ||
| 285 | + $data['option_values'] = $option_values; | ||
| 286 | + return $this->render('options', ['options' => $data, 'post' => $post]); | ||
| 287 | + } | ||
| 288 | + } | ||
| 244 | } | 289 | } |
| 1 | +<?php | ||
| 2 | + | ||
| 3 | +namespace frontend\controllers; | ||
| 4 | + | ||
| 5 | +use Yii; | ||
| 6 | +use frontend\models\TranslateLang; | ||
| 7 | +use frontend\models\TranslateLangSearch; | ||
| 8 | +use yii\web\Controller; | ||
| 9 | +use yii\web\NotFoundHttpException; | ||
| 10 | +use yii\filters\VerbFilter; | ||
| 11 | + | ||
| 12 | +/** | ||
| 13 | + * TranslateLangController implements the CRUD actions for TranslateLang model. | ||
| 14 | + */ | ||
| 15 | +class TranslateLangController extends Controller | ||
| 16 | +{ | ||
| 17 | + public function behaviors() | ||
| 18 | + { | ||
| 19 | + return [ | ||
| 20 | + 'verbs' => [ | ||
| 21 | + 'class' => VerbFilter::className(), | ||
| 22 | + 'actions' => [ | ||
| 23 | + 'delete' => ['post'], | ||
| 24 | + ], | ||
| 25 | + ], | ||
| 26 | + ]; | ||
| 27 | + } | ||
| 28 | + | ||
| 29 | + /** | ||
| 30 | + * Lists all TranslateLang models. | ||
| 31 | + * @return mixed | ||
| 32 | + */ | ||
| 33 | + public function actionIndex() | ||
| 34 | + { | ||
| 35 | + $searchModel = new TranslateLangSearch(); | ||
| 36 | + $dataProvider = $searchModel->search(Yii::$app->request->queryParams); | ||
| 37 | + | ||
| 38 | + return $this->render('index', [ | ||
| 39 | + 'searchModel' => $searchModel, | ||
| 40 | + 'dataProvider' => $dataProvider, | ||
| 41 | + ]); | ||
| 42 | + } | ||
| 43 | + | ||
| 44 | + /** | ||
| 45 | + * Displays a single TranslateLang model. | ||
| 46 | + * @param integer $id | ||
| 47 | + * @return mixed | ||
| 48 | + */ | ||
| 49 | + public function actionView($id) | ||
| 50 | + { | ||
| 51 | + return $this->render('view', [ | ||
| 52 | + 'model' => $this->findModel($id), | ||
| 53 | + ]); | ||
| 54 | + } | ||
| 55 | + | ||
| 56 | + /** | ||
| 57 | + * Creates a new TranslateLang model. | ||
| 58 | + * If creation is successful, the browser will be redirected to the 'view' page. | ||
| 59 | + * @return mixed | ||
| 60 | + */ | ||
| 61 | + public function actionCreate() | ||
| 62 | + { | ||
| 63 | + $model = new TranslateLang(); | ||
| 64 | + | ||
| 65 | + if ($model->load(Yii::$app->request->post()) && $model->save()) { | ||
| 66 | + return $this->redirect(['view', 'id' => $model->translate_value_id]); | ||
| 67 | + } else { | ||
| 68 | + return $this->render('create', [ | ||
| 69 | + 'model' => $model, | ||
| 70 | + ]); | ||
| 71 | + } | ||
| 72 | + } | ||
| 73 | + | ||
| 74 | + /** | ||
| 75 | + * Updates an existing TranslateLang model. | ||
| 76 | + * If update is successful, the browser will be redirected to the 'view' page. | ||
| 77 | + * @param integer $id | ||
| 78 | + * @return mixed | ||
| 79 | + */ | ||
| 80 | + public function actionUpdate($id) | ||
| 81 | + { | ||
| 82 | + $model = $this->findModel($id); | ||
| 83 | + | ||
| 84 | + if ($model->load(Yii::$app->request->post()) && $model->save()) { | ||
| 85 | + return $this->redirect(['view', 'id' => $model->translate_value_id]); | ||
| 86 | + } else { | ||
| 87 | + return $this->render('update', [ | ||
| 88 | + 'model' => $model, | ||
| 89 | + ]); | ||
| 90 | + } | ||
| 91 | + } | ||
| 92 | + | ||
| 93 | + /** | ||
| 94 | + * Deletes an existing TranslateLang model. | ||
| 95 | + * If deletion is successful, the browser will be redirected to the 'index' page. | ||
| 96 | + * @param integer $id | ||
| 97 | + * @return mixed | ||
| 98 | + */ | ||
| 99 | + public function actionDelete($id) | ||
| 100 | + { | ||
| 101 | + $this->findModel($id)->delete(); | ||
| 102 | + | ||
| 103 | + return $this->redirect(['index']); | ||
| 104 | + } | ||
| 105 | + | ||
| 106 | + /** | ||
| 107 | + * Finds the TranslateLang model based on its primary key value. | ||
| 108 | + * If the model is not found, a 404 HTTP exception will be thrown. | ||
| 109 | + * @param integer $id | ||
| 110 | + * @return TranslateLang the loaded model | ||
| 111 | + * @throws NotFoundHttpException if the model cannot be found | ||
| 112 | + */ | ||
| 113 | + protected function findModel($id) | ||
| 114 | + { | ||
| 115 | + if (($model = TranslateLang::findOne($id)) !== null) { | ||
| 116 | + return $model; | ||
| 117 | + } else { | ||
| 118 | + throw new NotFoundHttpException('The requested page does not exist.'); | ||
| 119 | + } | ||
| 120 | + } | ||
| 121 | +} |
| 1 | +<?php | ||
| 2 | + | ||
| 3 | +namespace frontend\models; | ||
| 4 | + | ||
| 5 | +use Yii; | ||
| 6 | + | ||
| 7 | +/** | ||
| 8 | + * This is the model class for table "language". | ||
| 9 | + * | ||
| 10 | + * @property integer $language_id | ||
| 11 | + * @property string $lang_code | ||
| 12 | + * @property integer $is_default | ||
| 13 | + * | ||
| 14 | + * @property LanguageLang[] $languageLangs | ||
| 15 | + * @property OptionValues[] $optionValues | ||
| 16 | + */ | ||
| 17 | +class Language extends \yii\db\ActiveRecord | ||
| 18 | +{ | ||
| 19 | + /** | ||
| 20 | + * @inheritdoc | ||
| 21 | + */ | ||
| 22 | + public static function tableName() | ||
| 23 | + { | ||
| 24 | + return 'language'; | ||
| 25 | + } | ||
| 26 | + | ||
| 27 | + /** | ||
| 28 | + * @inheritdoc | ||
| 29 | + */ | ||
| 30 | + public function rules() | ||
| 31 | + { | ||
| 32 | + return [ | ||
| 33 | + [['lang_code', 'is_default'], 'required'], | ||
| 34 | + [['is_default'], 'integer'], | ||
| 35 | + [['lang_code'], 'string', 'max' => 4] | ||
| 36 | + ]; | ||
| 37 | + } | ||
| 38 | + | ||
| 39 | + /** | ||
| 40 | + * @inheritdoc | ||
| 41 | + */ | ||
| 42 | + public function attributeLabels() | ||
| 43 | + { | ||
| 44 | + return [ | ||
| 45 | + 'language_id' => Yii::t('app', 'Language ID'), | ||
| 46 | + 'lang_code' => Yii::t('app', 'Lang Code'), | ||
| 47 | + 'is_default' => Yii::t('app', 'Is Default'), | ||
| 48 | + ]; | ||
| 49 | + } | ||
| 50 | + | ||
| 51 | + /** | ||
| 52 | + * @return \yii\db\ActiveQuery | ||
| 53 | + */ | ||
| 54 | + public function getLanguageLangs() | ||
| 55 | + { | ||
| 56 | + return $this->hasMany(LanguageLang::className(), ['language_id' => 'language_id']); | ||
| 57 | + } | ||
| 58 | + | ||
| 59 | + /** | ||
| 60 | + * @return \yii\db\ActiveQuery | ||
| 61 | + */ | ||
| 62 | + public function getOptionValues() | ||
| 63 | + { | ||
| 64 | + return $this->hasMany(OptionValues::className(), ['option_lang_id' => 'language_id']); | ||
| 65 | + } | ||
| 66 | +} |
| 1 | +<?php | ||
| 2 | + | ||
| 3 | +namespace frontend\models; | ||
| 4 | + | ||
| 5 | +use Yii; | ||
| 6 | + | ||
| 7 | +/** | ||
| 8 | + * This is the model class for table "language_lang". | ||
| 9 | + * | ||
| 10 | + * @property integer $language_id | ||
| 11 | + * @property string $lang_title | ||
| 12 | + * @property integer $lang_id | ||
| 13 | + * | ||
| 14 | + * @property Language $language | ||
| 15 | + */ | ||
| 16 | +class LanguageLang extends \yii\db\ActiveRecord | ||
| 17 | +{ | ||
| 18 | + /** | ||
| 19 | + * @inheritdoc | ||
| 20 | + */ | ||
| 21 | + public static function tableName() | ||
| 22 | + { | ||
| 23 | + return 'language_lang'; | ||
| 24 | + } | ||
| 25 | + | ||
| 26 | + /** | ||
| 27 | + * @inheritdoc | ||
| 28 | + */ | ||
| 29 | + public function rules() | ||
| 30 | + { | ||
| 31 | + return [ | ||
| 32 | + [['language_id', 'lang_title'], 'required'], | ||
| 33 | + [['language_id'], 'integer'], | ||
| 34 | + [['lang_title'], 'string', 'max' => 256] | ||
| 35 | + ]; | ||
| 36 | + } | ||
| 37 | + | ||
| 38 | + /** | ||
| 39 | + * @inheritdoc | ||
| 40 | + */ | ||
| 41 | + public function attributeLabels() | ||
| 42 | + { | ||
| 43 | + return [ | ||
| 44 | + 'language_id' => Yii::t('app', 'Language ID'), | ||
| 45 | + 'lang_title' => Yii::t('app', 'Lang Title'), | ||
| 46 | + 'lang_id' => Yii::t('app', 'Lang ID'), | ||
| 47 | + ]; | ||
| 48 | + } | ||
| 49 | + | ||
| 50 | + /** | ||
| 51 | + * @return \yii\db\ActiveQuery | ||
| 52 | + */ | ||
| 53 | + public function getLanguage() | ||
| 54 | + { | ||
| 55 | + return $this->hasOne(Language::className(), ['language_id' => 'language_id']); | ||
| 56 | + } | ||
| 57 | +} |
| 1 | +<?php | ||
| 2 | + | ||
| 3 | +namespace frontend\models; | ||
| 4 | + | ||
| 5 | +use Yii; | ||
| 6 | + | ||
| 7 | +/** | ||
| 8 | + * This is the model class for table "option". | ||
| 9 | + * | ||
| 10 | + * @property integer $option_id | ||
| 11 | + * @property string $model | ||
| 12 | + * @property integer $model_id | ||
| 13 | + * @property string $name | ||
| 14 | + * @property string $template | ||
| 15 | + * @property integer $parent_id | ||
| 16 | + */ | ||
| 17 | +class Option extends \yii\db\ActiveRecord | ||
| 18 | +{ | ||
| 19 | + /** | ||
| 20 | + * @inheritdoc | ||
| 21 | + */ | ||
| 22 | + public static function tableName() | ||
| 23 | + { | ||
| 24 | + return 'option'; | ||
| 25 | + } | ||
| 26 | + | ||
| 27 | + /** | ||
| 28 | + * @inheritdoc | ||
| 29 | + */ | ||
| 30 | + public function rules() | ||
| 31 | + { | ||
| 32 | + return [ | ||
| 33 | + [['model', 'model_id', 'name', 'template'], 'required'], | ||
| 34 | + [['model_id', 'parent_id'], 'integer'], | ||
| 35 | + [['model', 'name', 'template'], 'string', 'max' => 200] | ||
| 36 | + ]; | ||
| 37 | + } | ||
| 38 | + | ||
| 39 | + /** | ||
| 40 | + * @inheritdoc | ||
| 41 | + */ | ||
| 42 | + public function attributeLabels() | ||
| 43 | + { | ||
| 44 | + return [ | ||
| 45 | + 'option_id' => Yii::t('app', 'Option ID'), | ||
| 46 | + 'model' => Yii::t('app', 'Model'), | ||
| 47 | + 'model_id' => Yii::t('app', 'Model ID'), | ||
| 48 | + 'name' => Yii::t('app', 'Name'), | ||
| 49 | + 'template' => Yii::t('app', 'Template'), | ||
| 50 | + 'parent_id' => Yii::t('app', 'Parent ID'), | ||
| 51 | + ]; | ||
| 52 | + } | ||
| 53 | + public function getLangs() { | ||
| 54 | + return (new Language())->find()->where(['>', 'language_id', 0])->asArray()->all(); | ||
| 55 | + } | ||
| 56 | +} |
| 1 | +<?php | ||
| 2 | + | ||
| 3 | +namespace frontend\models; | ||
| 4 | + | ||
| 5 | +use Yii; | ||
| 6 | + | ||
| 7 | +/** | ||
| 8 | + * This is the model class for table "option_lang". | ||
| 9 | + * | ||
| 10 | + * @property integer $id | ||
| 11 | + * @property integer $lang_id | ||
| 12 | + * @property string $value | ||
| 13 | + */ | ||
| 14 | +class OptionLang extends \yii\db\ActiveRecord | ||
| 15 | +{ | ||
| 16 | + /** | ||
| 17 | + * @inheritdoc | ||
| 18 | + */ | ||
| 19 | + public static function tableName() | ||
| 20 | + { | ||
| 21 | + return 'option_lang'; | ||
| 22 | + } | ||
| 23 | + | ||
| 24 | + /** | ||
| 25 | + * @inheritdoc | ||
| 26 | + */ | ||
| 27 | + public function rules() | ||
| 28 | + { | ||
| 29 | + return [ | ||
| 30 | + [['id', 'lang_id'], 'required'], | ||
| 31 | + [['id', 'lang_id'], 'integer'], | ||
| 32 | + [['value'], 'string'] | ||
| 33 | + ]; | ||
| 34 | + } | ||
| 35 | + | ||
| 36 | + /** | ||
| 37 | + * @inheritdoc | ||
| 38 | + */ | ||
| 39 | + public function attributeLabels() | ||
| 40 | + { | ||
| 41 | + return [ | ||
| 42 | + 'id' => Yii::t('app', 'ID'), | ||
| 43 | + 'lang_id' => Yii::t('app', 'Lang ID'), | ||
| 44 | + 'value' => Yii::t('app', 'Value'), | ||
| 45 | + ]; | ||
| 46 | + } | ||
| 47 | +} |
| 1 | +<?php | ||
| 2 | + | ||
| 3 | +namespace frontend\models; | ||
| 4 | + | ||
| 5 | +use Yii; | ||
| 6 | +use yii\base\Model; | ||
| 7 | +use yii\data\ActiveDataProvider; | ||
| 8 | +use frontend\models\Option; | ||
| 9 | + | ||
| 10 | +/** | ||
| 11 | + * OptionSearch represents the model behind the search form about `frontend\models\Option`. | ||
| 12 | + */ | ||
| 13 | +class OptionSearch extends Option | ||
| 14 | +{ | ||
| 15 | + /** | ||
| 16 | + * @inheritdoc | ||
| 17 | + */ | ||
| 18 | + public function rules() | ||
| 19 | + { | ||
| 20 | + return [ | ||
| 21 | + [['option_id', 'model_id', 'parent_id'], 'integer'], | ||
| 22 | + [['model', 'name', 'template'], 'safe'], | ||
| 23 | + ]; | ||
| 24 | + } | ||
| 25 | + | ||
| 26 | + /** | ||
| 27 | + * @inheritdoc | ||
| 28 | + */ | ||
| 29 | + public function scenarios() | ||
| 30 | + { | ||
| 31 | + // bypass scenarios() implementation in the parent class | ||
| 32 | + return Model::scenarios(); | ||
| 33 | + } | ||
| 34 | + | ||
| 35 | + /** | ||
| 36 | + * Creates data provider instance with search query applied | ||
| 37 | + * | ||
| 38 | + * @param array $params | ||
| 39 | + * | ||
| 40 | + * @return ActiveDataProvider | ||
| 41 | + */ | ||
| 42 | + public function search($params) | ||
| 43 | + { | ||
| 44 | + $query = Option::find(); | ||
| 45 | + | ||
| 46 | + $dataProvider = new ActiveDataProvider([ | ||
| 47 | + 'query' => $query, | ||
| 48 | + ]); | ||
| 49 | + | ||
| 50 | + $this->load($params); | ||
| 51 | + | ||
| 52 | + if (!$this->validate()) { | ||
| 53 | + // uncomment the following line if you do not want to return any records when validation fails | ||
| 54 | + // $query->where('0=1'); | ||
| 55 | + return $dataProvider; | ||
| 56 | + } | ||
| 57 | + | ||
| 58 | + $query->andFilterWhere([ | ||
| 59 | + 'option_id' => $this->option_id, | ||
| 60 | + 'model_id' => $this->model_id, | ||
| 61 | + 'parent_id' => $this->parent_id, | ||
| 62 | + ]); | ||
| 63 | + | ||
| 64 | + $query->andFilterWhere(['like', 'model', $this->model]) | ||
| 65 | + ->andFilterWhere(['like', 'name', $this->name]) | ||
| 66 | + ->andFilterWhere(['like', 'template', $this->template]); | ||
| 67 | + | ||
| 68 | + return $dataProvider; | ||
| 69 | + } | ||
| 70 | +} |
| 1 | +<?php | ||
| 2 | + | ||
| 3 | +namespace frontend\models; | ||
| 4 | + | ||
| 5 | +use Yii; | ||
| 6 | + | ||
| 7 | +/** | ||
| 8 | + * This is the model class for table "option_values". | ||
| 9 | + * | ||
| 10 | + * @property integer $option_value_id | ||
| 11 | + * @property string $option_key | ||
| 12 | + * @property string $option_value_text | ||
| 13 | + * @property integer $option_lang_id | ||
| 14 | + * @property integer $option_value_parent | ||
| 15 | + * @property integer $option_user | ||
| 16 | + * | ||
| 17 | + * @property Language $optionLang | ||
| 18 | + */ | ||
| 19 | +class OptionValues extends \yii\db\ActiveRecord | ||
| 20 | +{ | ||
| 21 | + /** | ||
| 22 | + * @inheritdoc | ||
| 23 | + */ | ||
| 24 | + public static function tableName() | ||
| 25 | + { | ||
| 26 | + return 'option_values'; | ||
| 27 | + } | ||
| 28 | + | ||
| 29 | + /** | ||
| 30 | + * @inheritdoc | ||
| 31 | + */ | ||
| 32 | + public function rules() | ||
| 33 | + { | ||
| 34 | + return [ | ||
| 35 | + [['option_key', 'option_value_text'], 'required'], | ||
| 36 | + [['option_lang_id', 'option_value_parent', 'option_user'], 'integer'], | ||
| 37 | + [['option_key'], 'string', 'max' => 200] | ||
| 38 | + ]; | ||
| 39 | + } | ||
| 40 | + | ||
| 41 | + /** | ||
| 42 | + * @inheritdoc | ||
| 43 | + */ | ||
| 44 | + public function attributeLabels() | ||
| 45 | + { | ||
| 46 | + return [ | ||
| 47 | + 'option_value_id' => Yii::t('app', 'Option Value ID'), | ||
| 48 | + 'option_key' => Yii::t('app', 'Option Key'), | ||
| 49 | + 'option_value_text' => Yii::t('app', 'Option Value Text'), | ||
| 50 | + 'option_lang_id' => Yii::t('app', 'Option Lang ID'), | ||
| 51 | + 'option_value_parent' => Yii::t('app', 'Option Value Parent'), | ||
| 52 | + 'option_user' => Yii::t('app', 'Option User'), | ||
| 53 | + ]; | ||
| 54 | + } | ||
| 55 | + | ||
| 56 | + /** | ||
| 57 | + * @return \yii\db\ActiveQuery | ||
| 58 | + */ | ||
| 59 | + public function getOptionLang() | ||
| 60 | + { | ||
| 61 | + return $this->hasOne(Language::className(), ['language_id' => 'option_lang_id']); | ||
| 62 | + } | ||
| 63 | + public function getLanguages() { | ||
| 64 | + return (new LanguageLang())->find()->orderBy('language_id ASC')->asArray()->all(); | ||
| 65 | + } | ||
| 66 | + public function getLanguagesCodes() { | ||
| 67 | + return (new Language())->find()->orderBy('language_id ASC')->asArray()->all(); | ||
| 68 | + } | ||
| 69 | + public function getDropDownArray() { | ||
| 70 | + $langs = array(); | ||
| 71 | + foreach($this->getLanguages() as $lang) { | ||
| 72 | + $langs[$lang['language_id']] = $lang['lang_title']; | ||
| 73 | + } | ||
| 74 | + return $langs; | ||
| 75 | + } | ||
| 76 | + public function beforeSave($insert) { | ||
| 77 | + if (parent::beforeSave($insert)) { | ||
| 78 | + $this->option_user = \Yii::$app->user->getId(); | ||
| 79 | + if($this->option_value_parent == 0) { | ||
| 80 | + unset($this->option_value_parent); | ||
| 81 | + } | ||
| 82 | + return true; | ||
| 83 | + } else { | ||
| 84 | + return false; | ||
| 85 | + } | ||
| 86 | + } | ||
| 87 | + public function getUserOptions() { | ||
| 88 | + return (new OptionValues())->find()->where('option_user=:user')->addParams([':user' => \Yii::$app->user->getID()])->andWhere(['not', ['option_user' => null]])->asArray()->all(); | ||
| 89 | + } | ||
| 90 | + public function getUserOptionsArray() { | ||
| 91 | + $options = array('0' => Yii::t('app', 'Default Parent')); | ||
| 92 | + foreach($this->getUserOptions() as $option) { | ||
| 93 | + $options[$option['option_value_id']] = $option['option_key'].' - '.$option['option_value_text']; | ||
| 94 | + } | ||
| 95 | + return $options; | ||
| 96 | + } | ||
| 97 | +} |
| 1 | +<?php | ||
| 2 | + | ||
| 3 | +namespace frontend\models; | ||
| 4 | + | ||
| 5 | +use Yii; | ||
| 6 | +use yii\base\Model; | ||
| 7 | +use yii\data\ActiveDataProvider; | ||
| 8 | +use frontend\models\OptionValues; | ||
| 9 | + | ||
| 10 | +/** | ||
| 11 | + * OptionValuesSearch represents the model behind the search form about `frontend\models\OptionValues`. | ||
| 12 | + */ | ||
| 13 | +class OptionValuesSearch extends OptionValues | ||
| 14 | +{ | ||
| 15 | + /** | ||
| 16 | + * @inheritdoc | ||
| 17 | + */ | ||
| 18 | + public function rules() | ||
| 19 | + { | ||
| 20 | + return [ | ||
| 21 | + [['option_value_id', 'option_lang_id', 'option_value_parent', 'option_user'], 'integer'], | ||
| 22 | + [['option_key', 'option_value_text'], 'safe'], | ||
| 23 | + ]; | ||
| 24 | + } | ||
| 25 | + | ||
| 26 | + /** | ||
| 27 | + * @inheritdoc | ||
| 28 | + */ | ||
| 29 | + public function scenarios() | ||
| 30 | + { | ||
| 31 | + // bypass scenarios() implementation in the parent class | ||
| 32 | + return Model::scenarios(); | ||
| 33 | + } | ||
| 34 | + | ||
| 35 | + /** | ||
| 36 | + * Creates data provider instance with search query applied | ||
| 37 | + * | ||
| 38 | + * @param array $params | ||
| 39 | + * | ||
| 40 | + * @return ActiveDataProvider | ||
| 41 | + */ | ||
| 42 | + public function search($params) | ||
| 43 | + { | ||
| 44 | + $query = OptionValues::find(); | ||
| 45 | + | ||
| 46 | + $dataProvider = new ActiveDataProvider([ | ||
| 47 | + 'query' => $query, | ||
| 48 | + ]); | ||
| 49 | + | ||
| 50 | + $this->load($params); | ||
| 51 | + | ||
| 52 | + if (!$this->validate()) { | ||
| 53 | + // uncomment the following line if you do not want to return any records when validation fails | ||
| 54 | + // $query->where('0=1'); | ||
| 55 | + return $dataProvider; | ||
| 56 | + } | ||
| 57 | + | ||
| 58 | + $query->andFilterWhere([ | ||
| 59 | + 'option_value_id' => $this->option_value_id, | ||
| 60 | + 'option_lang_id' => $this->option_lang_id, | ||
| 61 | + 'option_value_parent' => $this->option_value_parent, | ||
| 62 | + 'option_user' => $this->option_user, | ||
| 63 | + ]); | ||
| 64 | + | ||
| 65 | + $query->andFilterWhere(['like', 'option_key', $this->option_key]) | ||
| 66 | + ->andFilterWhere(['like', 'option_value_text', $this->option_value_text]); | ||
| 67 | + | ||
| 68 | + return $dataProvider; | ||
| 69 | + } | ||
| 70 | +} |
| 1 | +<?php | ||
| 2 | + | ||
| 3 | +namespace frontend\models; | ||
| 4 | + | ||
| 5 | +use Yii; | ||
| 6 | + | ||
| 7 | +/** | ||
| 8 | + * This is the model class for table "options". | ||
| 9 | + * | ||
| 10 | + * @property integer $option_id | ||
| 11 | + * @property string $option_key | ||
| 12 | + * @property integer $option_parent | ||
| 13 | + * @property integer $option_translatable | ||
| 14 | + * @property string $option_format | ||
| 15 | + * | ||
| 16 | + * @property OptionValues[] $optionValues | ||
| 17 | + * @property Options $optionParent | ||
| 18 | + * @property Options[] $options | ||
| 19 | + */ | ||
| 20 | +class Options extends \yii\db\ActiveRecord | ||
| 21 | +{ | ||
| 22 | + /** | ||
| 23 | + * @inheritdoc | ||
| 24 | + */ | ||
| 25 | + public static function tableName() | ||
| 26 | + { | ||
| 27 | + return 'options'; | ||
| 28 | + } | ||
| 29 | + | ||
| 30 | + /** | ||
| 31 | + * @inheritdoc | ||
| 32 | + */ | ||
| 33 | + public function rules() | ||
| 34 | + { | ||
| 35 | + return [ | ||
| 36 | + [['option_key'], 'required'], | ||
| 37 | + [['option_parent', 'option_translatable'], 'integer'], | ||
| 38 | + [['option_key', 'option_format'], 'string', 'max' => 200] | ||
| 39 | + ]; | ||
| 40 | + } | ||
| 41 | + | ||
| 42 | + /** | ||
| 43 | + * @inheritdoc | ||
| 44 | + */ | ||
| 45 | + public function attributeLabels() | ||
| 46 | + { | ||
| 47 | + return [ | ||
| 48 | + 'option_id' => Yii::t('app', 'Option ID'), | ||
| 49 | + 'option_key' => Yii::t('app', 'Option Key'), | ||
| 50 | + 'option_parent' => Yii::t('app', 'Option Parent'), | ||
| 51 | + 'option_translatable' => Yii::t('app', 'Option Translatable'), | ||
| 52 | + 'option_format' => Yii::t('app', 'Option Format'), | ||
| 53 | + ]; | ||
| 54 | + } | ||
| 55 | + | ||
| 56 | + /** | ||
| 57 | + * @return \yii\db\ActiveQuery | ||
| 58 | + */ | ||
| 59 | + public function getOptionValues() | ||
| 60 | + { | ||
| 61 | + return $this->hasMany(OptionValues::className(), ['option_id' => 'option_id']); | ||
| 62 | + } | ||
| 63 | + | ||
| 64 | + /** | ||
| 65 | + * @return \yii\db\ActiveQuery | ||
| 66 | + */ | ||
| 67 | + public function getOptionParent() | ||
| 68 | + { | ||
| 69 | + return $this->hasOne(Options::className(), ['option_id' => 'option_parent']); | ||
| 70 | + } | ||
| 71 | + | ||
| 72 | + /** | ||
| 73 | + * @return \yii\db\ActiveQuery | ||
| 74 | + */ | ||
| 75 | + public function getOptions() | ||
| 76 | + { | ||
| 77 | + return $this->hasMany(Options::className(), ['option_parent' => 'option_id']); | ||
| 78 | + } | ||
| 79 | +} |
| 1 | +<?php | ||
| 2 | + | ||
| 3 | +namespace frontend\models; | ||
| 4 | + | ||
| 5 | +use Yii; | ||
| 6 | +use yii\base\Model; | ||
| 7 | +use yii\data\ActiveDataProvider; | ||
| 8 | +use frontend\models\Options; | ||
| 9 | + | ||
| 10 | +/** | ||
| 11 | + * OptionsSearch represents the model behind the search form about `frontend\models\Options`. | ||
| 12 | + */ | ||
| 13 | +class OptionsSearch extends Options | ||
| 14 | +{ | ||
| 15 | + /** | ||
| 16 | + * @inheritdoc | ||
| 17 | + */ | ||
| 18 | + public function rules() | ||
| 19 | + { | ||
| 20 | + return [ | ||
| 21 | + [['option_id', 'option_parent', 'option_translatable'], 'integer'], | ||
| 22 | + [['option_key', 'option_format'], 'safe'], | ||
| 23 | + ]; | ||
| 24 | + } | ||
| 25 | + | ||
| 26 | + /** | ||
| 27 | + * @inheritdoc | ||
| 28 | + */ | ||
| 29 | + public function scenarios() | ||
| 30 | + { | ||
| 31 | + // bypass scenarios() implementation in the parent class | ||
| 32 | + return Model::scenarios(); | ||
| 33 | + } | ||
| 34 | + | ||
| 35 | + /** | ||
| 36 | + * Creates data provider instance with search query applied | ||
| 37 | + * | ||
| 38 | + * @param array $params | ||
| 39 | + * | ||
| 40 | + * @return ActiveDataProvider | ||
| 41 | + */ | ||
| 42 | + public function search($params) | ||
| 43 | + { | ||
| 44 | + $query = Options::find(); | ||
| 45 | + | ||
| 46 | + $dataProvider = new ActiveDataProvider([ | ||
| 47 | + 'query' => $query, | ||
| 48 | + ]); | ||
| 49 | + | ||
| 50 | + $this->load($params); | ||
| 51 | + | ||
| 52 | + if (!$this->validate()) { | ||
| 53 | + // uncomment the following line if you do not want to return any records when validation fails | ||
| 54 | + // $query->where('0=1'); | ||
| 55 | + return $dataProvider; | ||
| 56 | + } | ||
| 57 | + | ||
| 58 | + $query->andFilterWhere([ | ||
| 59 | + 'option_id' => $this->option_id, | ||
| 60 | + 'option_parent' => $this->option_parent, | ||
| 61 | + 'option_translatable' => $this->option_translatable, | ||
| 62 | + ]); | ||
| 63 | + | ||
| 64 | + $query->andFilterWhere(['like', 'option_key', $this->option_key]) | ||
| 65 | + ->andFilterWhere(['like', 'option_format', $this->option_format]); | ||
| 66 | + | ||
| 67 | + return $dataProvider; | ||
| 68 | + } | ||
| 69 | +} |
| 1 | +<?php | ||
| 2 | + | ||
| 3 | +use yii\helpers\Html; | ||
| 4 | +use yii\widgets\ActiveForm; | ||
| 5 | + | ||
| 6 | +/* @var $this yii\web\View */ | ||
| 7 | +/* @var $model frontend\models\OptionValues */ | ||
| 8 | +/* @var $form yii\widgets\ActiveForm */ | ||
| 9 | +?> | ||
| 10 | + | ||
| 11 | +<div class="option-values-form"> | ||
| 12 | + | ||
| 13 | + <?php $form = ActiveForm::begin(); ?> | ||
| 14 | + | ||
| 15 | + <?= $form->field($model, 'option_key')->textInput(['maxlength' => true]) ?> | ||
| 16 | + | ||
| 17 | + <div class="optionvalues-option_value_text-active"> | ||
| 18 | + <?= $form->field($model, 'option_value_text', ['enableClientValidation' => false])->label($model->getAttributeLabel('option_key').' | <span class="glyphicon glyphicon-globe add-langs"></span>')->textInput() ?> | ||
| 19 | + | ||
| 20 | + <?= $form->field($model, 'option_lang_id')->dropDownList($model->getDropDownArray()) ?> | ||
| 21 | + </div> | ||
| 22 | + | ||
| 23 | + <?= $form->field($model, 'option_value_parent')->dropDownList($model->getUserOptionsArray()) ?> | ||
| 24 | + | ||
| 25 | + <div class="form-group"> | ||
| 26 | + <?= Html::submitButton($model->isNewRecord ? Yii::t('app', 'Create') : Yii::t('app', 'Update'), ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']) ?> | ||
| 27 | + </div> | ||
| 28 | + | ||
| 29 | + <?php ActiveForm::end(); ?> | ||
| 30 | + | ||
| 31 | +</div> | ||
| 32 | +<div class="reserved_inputs"> | ||
| 33 | + <div class="lang-inputs form-group optionvalues-option_value_text-lang"> | ||
| 34 | + <label for="OptionValues[option_value_text][0]" class="col-xs-12 optionvalues-option_value_text" data-group="optionvalues-option_value_text"><?php echo $model->getAttributeLabel('option_key'); ?> | <span class="glyphicon glyphicon-globe remove-langs"></span></label> | ||
| 35 | + <?php foreach($model->getLanguagesCodes() as $lang) { | ||
| 36 | + ?> | ||
| 37 | + <div class="col-xs-1 text-right"><span><?=$lang['lang_code']?></span></div> | ||
| 38 | + <div class="col-xs-11"><input type="text" id="optionvalues-<?=$lang['lang_code']?>-option_value_text" class="form-control" name="OptionValues[option_value_text][<?=$lang['language_id']?>]" /></div> | ||
| 39 | + <?php | ||
| 40 | + }?> | ||
| 41 | + <div class="clearfix"></div> | ||
| 42 | + </div> | ||
| 43 | +</div> | ||
| 44 | +<script> | ||
| 45 | + $(function() { | ||
| 46 | + $(document).on('click', '.add-langs', function() { | ||
| 47 | + var group = $(this).parent().attr('for'); | ||
| 48 | + $(this).parent().parent().appendTo('.reserved_inputs'); | ||
| 49 | + $('.field-optionvalues-option_lang_id').appendTo('.reserved_inputs'); | ||
| 50 | + $('.'+group+'-lang').appendTo('.'+group+'-active'); | ||
| 51 | + }); | ||
| 52 | + $(document).on('click', '.remove-langs', function() { | ||
| 53 | + var group = $(this).parent().data('group'); | ||
| 54 | + $(this).parent().parent().appendTo('.reserved_inputs'); | ||
| 55 | + console.log('field-'+group); | ||
| 56 | + $('.reserved_inputs .field-'+group).appendTo('.'+group+'-active'); | ||
| 57 | + $('.field-optionvalues-option_lang_id').appendTo('.'+group+'-active'); | ||
| 58 | + }); | ||
| 59 | + }); | ||
| 60 | +</script> | ||
| 0 | \ No newline at end of file | 61 | \ No newline at end of file |
| 1 | +<?php | ||
| 2 | + | ||
| 3 | +use yii\helpers\Html; | ||
| 4 | +use yii\widgets\ActiveForm; | ||
| 5 | + | ||
| 6 | +/* @var $this yii\web\View */ | ||
| 7 | +/* @var $model frontend\models\OptionValuesSearch */ | ||
| 8 | +/* @var $form yii\widgets\ActiveForm */ | ||
| 9 | +?> | ||
| 10 | + | ||
| 11 | +<div class="option-values-search"> | ||
| 12 | + | ||
| 13 | + <?php $form = ActiveForm::begin([ | ||
| 14 | + 'action' => ['index'], | ||
| 15 | + 'method' => 'get', | ||
| 16 | + ]); ?> | ||
| 17 | + | ||
| 18 | + <?= $form->field($model, 'option_value_id') ?> | ||
| 19 | + | ||
| 20 | + <?= $form->field($model, 'option_key') ?> | ||
| 21 | + | ||
| 22 | + <?= $form->field($model, 'option_value_text') ?> | ||
| 23 | + | ||
| 24 | + <?= $form->field($model, 'option_lang_id') ?> | ||
| 25 | + | ||
| 26 | + <?= $form->field($model, 'option_value_parent') ?> | ||
| 27 | + | ||
| 28 | + <?php // echo $form->field($model, 'option_user') ?> | ||
| 29 | + | ||
| 30 | + <div class="form-group"> | ||
| 31 | + <?= Html::submitButton(Yii::t('app', 'Search'), ['class' => 'btn btn-primary']) ?> | ||
| 32 | + <?= Html::resetButton(Yii::t('app', 'Reset'), ['class' => 'btn btn-default']) ?> | ||
| 33 | + </div> | ||
| 34 | + | ||
| 35 | + <?php ActiveForm::end(); ?> | ||
| 36 | + | ||
| 37 | +</div> |
| 1 | +<?php | ||
| 2 | + | ||
| 3 | +use yii\helpers\Html; | ||
| 4 | + | ||
| 5 | + | ||
| 6 | +/* @var $this yii\web\View */ | ||
| 7 | +/* @var $model frontend\models\OptionValues */ | ||
| 8 | + | ||
| 9 | +$this->title = Yii::t('app', 'Create Option Values'); | ||
| 10 | +$this->params['breadcrumbs'][] = ['label' => Yii::t('app', 'Option Values'), 'url' => ['index']]; | ||
| 11 | +$this->params['breadcrumbs'][] = $this->title; | ||
| 12 | +?> | ||
| 13 | +<div class="option-values-create"> | ||
| 14 | + | ||
| 15 | + <h1><?= Html::encode($this->title) ?></h1> | ||
| 16 | + | ||
| 17 | + <?= $this->render('_form', [ | ||
| 18 | + 'model' => $model, | ||
| 19 | + ]) ?> | ||
| 20 | + | ||
| 21 | +</div> |
| 1 | +<?php | ||
| 2 | + | ||
| 3 | +use yii\helpers\Html; | ||
| 4 | +use yii\grid\GridView; | ||
| 5 | + | ||
| 6 | +/* @var $this yii\web\View */ | ||
| 7 | +/* @var $searchModel frontend\models\OptionValuesSearch */ | ||
| 8 | +/* @var $dataProvider yii\data\ActiveDataProvider */ | ||
| 9 | + | ||
| 10 | +$this->title = Yii::t('app', 'Option Values'); | ||
| 11 | +$this->params['breadcrumbs'][] = $this->title; | ||
| 12 | +?> | ||
| 13 | +<div class="option-values-index"> | ||
| 14 | + | ||
| 15 | + <h1><?= Html::encode($this->title) ?></h1> | ||
| 16 | + <?php // echo $this->render('_search', ['model' => $searchModel]); ?> | ||
| 17 | + | ||
| 18 | + <p> | ||
| 19 | + <?= Html::a(Yii::t('app', 'Create Option Values'), ['create'], ['class' => 'btn btn-success']) ?> | ||
| 20 | + </p> | ||
| 21 | + | ||
| 22 | + <?= GridView::widget([ | ||
| 23 | + 'dataProvider' => $dataProvider, | ||
| 24 | + 'filterModel' => $searchModel, | ||
| 25 | + 'columns' => [ | ||
| 26 | + ['class' => 'yii\grid\SerialColumn'], | ||
| 27 | + | ||
| 28 | + 'option_value_id', | ||
| 29 | + 'option_key', | ||
| 30 | + 'option_value_text:ntext', | ||
| 31 | + 'option_lang_id', | ||
| 32 | + 'option_value_parent', | ||
| 33 | + // 'option_user', | ||
| 34 | + | ||
| 35 | + ['class' => 'yii\grid\ActionColumn'], | ||
| 36 | + ], | ||
| 37 | + ]); ?> | ||
| 38 | + | ||
| 39 | +</div> |
| 1 | +<?php | ||
| 2 | + | ||
| 3 | +use yii\helpers\Html; | ||
| 4 | + | ||
| 5 | +/* @var $this yii\web\View */ | ||
| 6 | +/* @var $model frontend\models\OptionValues */ | ||
| 7 | + | ||
| 8 | +$this->title = Yii::t('app', 'Update {modelClass}: ', [ | ||
| 9 | + 'modelClass' => 'Option Values', | ||
| 10 | +]) . ' ' . $model->option_value_id; | ||
| 11 | +$this->params['breadcrumbs'][] = ['label' => Yii::t('app', 'Option Values'), 'url' => ['index']]; | ||
| 12 | +$this->params['breadcrumbs'][] = ['label' => $model->option_value_id, 'url' => ['view', 'id' => $model->option_value_id]]; | ||
| 13 | +$this->params['breadcrumbs'][] = Yii::t('app', 'Update'); | ||
| 14 | +?> | ||
| 15 | +<div class="option-values-update"> | ||
| 16 | + | ||
| 17 | + <h1><?= Html::encode($this->title) ?></h1> | ||
| 18 | + | ||
| 19 | + <?= $this->render('_form', [ | ||
| 20 | + 'model' => $model, | ||
| 21 | + ]) ?> | ||
| 22 | + | ||
| 23 | +</div> |
| 1 | +<?php | ||
| 2 | + | ||
| 3 | +use yii\helpers\Html; | ||
| 4 | +use yii\widgets\DetailView; | ||
| 5 | + | ||
| 6 | +/* @var $this yii\web\View */ | ||
| 7 | +/* @var $model frontend\models\OptionValues */ | ||
| 8 | + | ||
| 9 | +$this->title = $model->option_value_id; | ||
| 10 | +$this->params['breadcrumbs'][] = ['label' => Yii::t('app', 'Option Values'), 'url' => ['index']]; | ||
| 11 | +$this->params['breadcrumbs'][] = $this->title; | ||
| 12 | +?> | ||
| 13 | +<div class="option-values-view"> | ||
| 14 | + | ||
| 15 | + <h1><?= Html::encode($this->title) ?></h1> | ||
| 16 | + | ||
| 17 | + <p> | ||
| 18 | + <?= Html::a(Yii::t('app', 'Update'), ['update', 'id' => $model->option_value_id], ['class' => 'btn btn-primary']) ?> | ||
| 19 | + <?= Html::a(Yii::t('app', 'Delete'), ['delete', 'id' => $model->option_value_id], [ | ||
| 20 | + 'class' => 'btn btn-danger', | ||
| 21 | + 'data' => [ | ||
| 22 | + 'confirm' => Yii::t('app', 'Are you sure you want to delete this item?'), | ||
| 23 | + 'method' => 'post', | ||
| 24 | + ], | ||
| 25 | + ]) ?> | ||
| 26 | + </p> | ||
| 27 | + | ||
| 28 | + <?= DetailView::widget([ | ||
| 29 | + 'model' => $model, | ||
| 30 | + 'attributes' => [ | ||
| 31 | + 'option_value_id', | ||
| 32 | + 'option_key', | ||
| 33 | + 'option_value_text:ntext', | ||
| 34 | + 'option_lang_id', | ||
| 35 | + 'option_value_parent', | ||
| 36 | + 'option_user', | ||
| 37 | + ], | ||
| 38 | + ]) ?> | ||
| 39 | + | ||
| 40 | +</div> |
| 1 | +<?php | ||
| 2 | + | ||
| 3 | +use yii\helpers\Html; | ||
| 4 | +use yii\widgets\ActiveForm; | ||
| 5 | + | ||
| 6 | +/* @var $this yii\web\View */ | ||
| 7 | +/* @var $model frontend\models\Option */ | ||
| 8 | +/* @var $form yii\widgets\ActiveForm */ | ||
| 9 | +?> | ||
| 10 | + | ||
| 11 | +<div class="option-form"> | ||
| 12 | + <?php $form = ActiveForm::begin(); ?> | ||
| 13 | + <input type="hidden" name="Option[model]" value="<?=$modeldb?>"/> | ||
| 14 | + <input type="hidden" name="Option[model_id]" value="<?=$model_id?>"/> | ||
| 15 | + <p class="text-right"><span class="glyphicon glyphicon-plus add_row"></span></p> | ||
| 16 | + <?php if(empty($models)) { | ||
| 17 | + ?> | ||
| 18 | + <div class="form-group" id="main_row"> | ||
| 19 | + <?php foreach($fields as $field) { | ||
| 20 | + ?> | ||
| 21 | + <label for="Option[0][<?=$field['name']?>]"><?php echo Yii::t('app', $field['name']); ?></label> | ||
| 22 | + <input type="hidden" name="Option[0][template]" value="<?=$field['template']?>"/> | ||
| 23 | + <input type="<?=$field['template']?>" name="Option[0][value][<?=$field['name']?>]" class="form-control required" required/> | ||
| 24 | + <?php | ||
| 25 | + foreach($model->getLangs() as $lang) { | ||
| 26 | + ?> | ||
| 27 | + <div class="form-group"> | ||
| 28 | + <div class="col-xs-1"><?=$lang['lang_code']?></div> | ||
| 29 | + <div class="col-xs-11"><input type="<?=$field['template']?>" name="Option[0][lang][<?=$field['name']?>][<?=$lang['language_id']?>]" class="form-control" /></div> | ||
| 30 | + </div> | ||
| 31 | + <?php | ||
| 32 | + } | ||
| 33 | + }?> | ||
| 34 | + </div> | ||
| 35 | + <?php | ||
| 36 | + } else { | ||
| 37 | + $first = 1; | ||
| 38 | + foreach($models as $index => $row) { | ||
| 39 | + foreach($row as $key => $value) { | ||
| 40 | + if(!$modellang[$index][$key][0]->hasErrors('value')) { | ||
| 41 | + continue; | ||
| 42 | + } | ||
| 43 | + if($first) { | ||
| 44 | + ?> | ||
| 45 | + <div class="form-group" id="main_row"> | ||
| 46 | + <?php | ||
| 47 | + } | ||
| 48 | + ?> | ||
| 49 | + <label for="Option[0][<?=$key?>]"><?php echo Yii::t('app', $key); ?></label> | ||
| 50 | + <input type="hidden" name="Option[0][template]" value="<?=$value->template?>"/> | ||
| 51 | + <input type="<?=$value->template?>" name="Option[0][value][<?=$key?>]" class="form-control required" required value="<?=$modellang[$index][$key][0]->value?>"/> | ||
| 52 | + <div class="help-block"><?=$modellang[$index][$key][0]->getFirstError('value')?></div> | ||
| 53 | + <?php | ||
| 54 | + foreach($value->getLangs() as $lang) { | ||
| 55 | + ?> | ||
| 56 | + <div class="form-group"> | ||
| 57 | + <div class="col-xs-1"><?=$lang['lang_code']?></div> | ||
| 58 | + <div class="col-xs-11"><input type="<?=$value->template?>" name="Option[0][lang][<?=$key?>][<?=$lang['language_id']?>]" class="form-control" value="<?=$modellang[$index][$key][$lang['language_id']]->value?>"/></div> | ||
| 59 | + </div> | ||
| 60 | + <?php | ||
| 61 | + } | ||
| 62 | + if($first) { | ||
| 63 | + ?> | ||
| 64 | + </div> | ||
| 65 | + <?php | ||
| 66 | + $first = 0; | ||
| 67 | + } | ||
| 68 | + } | ||
| 69 | + } | ||
| 70 | + }?> | ||
| 71 | + | ||
| 72 | + <div class="form-group"> | ||
| 73 | + <?= Html::submitButton($model->isNewRecord ? Yii::t('app', 'Create') : Yii::t('app', 'Update'), ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']) ?> | ||
| 74 | + </div> | ||
| 75 | + | ||
| 76 | + <?php ActiveForm::end(); ?> | ||
| 77 | + <script> | ||
| 78 | + $(function() { | ||
| 79 | + var counter = 0; | ||
| 80 | + $(document).on('click', '.add_row', function() { | ||
| 81 | + counter++; | ||
| 82 | + var clone = $('#main_row').clone().html().replace(new RegExp("Option\\[0\\]", 'g'), "Option["+counter+"]"); | ||
| 83 | + $(clone).appendTo('#<?=$form->getId()?>'); | ||
| 84 | + $('#<?=$form->getId()?> button[type=submit]').parent().appendTo('#<?=$form->getId()?>'); | ||
| 85 | + }); | ||
| 86 | + }); | ||
| 87 | + </script> | ||
| 88 | +</div> |
| 1 | +<?php | ||
| 2 | + | ||
| 3 | +use yii\helpers\Html; | ||
| 4 | +use yii\widgets\ActiveForm; | ||
| 5 | + | ||
| 6 | +/* @var $this yii\web\View */ | ||
| 7 | +/* @var $model frontend\models\Option */ | ||
| 8 | +/* @var $form yii\widgets\ActiveForm */ | ||
| 9 | +?> | ||
| 10 | + | ||
| 11 | +<div class="option-form"> | ||
| 12 | + <?php $form = ActiveForm::begin(); ?> | ||
| 13 | + <input type="hidden" name="Option[model]" value="<?=$modeldb?>"/> | ||
| 14 | + <input type="hidden" name="Option[model_id]" value="<?=$model_id?>"/> | ||
| 15 | + <?php foreach($models as $id => $row) { | ||
| 16 | + ?> | ||
| 17 | + <label for="Option[<?=$id?>][<?=$key?>]"><?php echo Yii::t('app', $key); ?></label> | ||
| 18 | + <input type="hidden" name="Option[<?=$id?>][id]" value="<?=$id?>" /> | ||
| 19 | + <input type="hidden" name="Option[<?=$id?>][template]" value="<?=$row->template?>"/> | ||
| 20 | + <input type="<?=$row->template?>" name="Option[<?=$id?>][value][<?=$row->name?>]" class="form-control required" required value="<?=$modellang[$id][0]->value?>"/> | ||
| 21 | + <?php if($row->hasErrors()) { ?><div class="help-block"><?php echo $modellang[$id][0]->getFirstError('value');?></div> <?php } ?> | ||
| 22 | + <?php | ||
| 23 | + foreach($row->getLangs() as $lang_id => $lang) { | ||
| 24 | + ?> | ||
| 25 | + <div class="form-group"> | ||
| 26 | + <div class="col-xs-1"><?=$lang['lang_code']?></div> | ||
| 27 | + <div class="col-xs-11"><input type="<?=$row->template?>" name="Option[<?=$id?>][lang][<?=$lang['language_id']?>]" class="form-control" value="<?=$modellang[$id][$lang['language_id']]->value?>"/></div> | ||
| 28 | + </div> | ||
| 29 | + <?php | ||
| 30 | + } | ||
| 31 | + }?> | ||
| 32 | + | ||
| 33 | + <div class="form-group"> | ||
| 34 | + <?= Html::submitButton($model->isNewRecord ? Yii::t('app', 'Create') : Yii::t('app', 'Update'), ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']) ?> | ||
| 35 | + </div> | ||
| 36 | + | ||
| 37 | + <?php ActiveForm::end(); ?> | ||
| 38 | +</div> |
| 1 | +<?php | ||
| 2 | + | ||
| 3 | +use yii\helpers\Html; | ||
| 4 | +use yii\widgets\ActiveForm; | ||
| 5 | + | ||
| 6 | +/* @var $this yii\web\View */ | ||
| 7 | +/* @var $model frontend\models\OptionSearch */ | ||
| 8 | +/* @var $form yii\widgets\ActiveForm */ | ||
| 9 | +?> | ||
| 10 | + | ||
| 11 | +<div class="option-search"> | ||
| 12 | + | ||
| 13 | + <?php $form = ActiveForm::begin([ | ||
| 14 | + 'action' => ['index'], | ||
| 15 | + 'method' => 'get', | ||
| 16 | + ]); ?> | ||
| 17 | + | ||
| 18 | + <?= $form->field($model, 'option_id') ?> | ||
| 19 | + | ||
| 20 | + <?= $form->field($model, 'model') ?> | ||
| 21 | + | ||
| 22 | + <?= $form->field($model, 'model_id') ?> | ||
| 23 | + | ||
| 24 | + <?= $form->field($model, 'name') ?> | ||
| 25 | + | ||
| 26 | + <?= $form->field($model, 'template') ?> | ||
| 27 | + | ||
| 28 | + <?php // echo $form->field($model, 'parent_id') ?> | ||
| 29 | + | ||
| 30 | + <div class="form-group"> | ||
| 31 | + <?= Html::submitButton(Yii::t('app', 'Search'), ['class' => 'btn btn-primary']) ?> | ||
| 32 | + <?= Html::resetButton(Yii::t('app', 'Reset'), ['class' => 'btn btn-default']) ?> | ||
| 33 | + </div> | ||
| 34 | + | ||
| 35 | + <?php ActiveForm::end(); ?> | ||
| 36 | + | ||
| 37 | +</div> |
| 1 | +<?php | ||
| 2 | + | ||
| 3 | +use yii\helpers\Html; | ||
| 4 | + | ||
| 5 | + | ||
| 6 | +/* @var $this yii\web\View */ | ||
| 7 | +/* @var $model frontend\models\Option */ | ||
| 8 | + | ||
| 9 | +$this->title = Yii::t('app', 'Create Option'); | ||
| 10 | +$this->params['breadcrumbs'][] = ['label' => Yii::t('app', 'Options'), 'url' => ['index']]; | ||
| 11 | +$this->params['breadcrumbs'][] = $this->title; | ||
| 12 | +?> | ||
| 13 | +<div class="option-create"> | ||
| 14 | + | ||
| 15 | + <h1><?= Html::encode($this->title) ?></h1> | ||
| 16 | + | ||
| 17 | + <?= $this->render('_form', [ | ||
| 18 | + 'model' => $model, | ||
| 19 | + 'models' => $models, | ||
| 20 | + 'modellang' => $modellang, | ||
| 21 | + 'modeldb' => $modeldb, | ||
| 22 | + 'model_id' => $model_id, | ||
| 23 | + 'fields' => $fields | ||
| 24 | + ]) ?> | ||
| 25 | + | ||
| 26 | +</div> |
| 1 | +<?php | ||
| 2 | + | ||
| 3 | +use yii\helpers\Html; | ||
| 4 | +use yii\grid\GridView; | ||
| 5 | + | ||
| 6 | +/* @var $this yii\web\View */ | ||
| 7 | +/* @var $searchModel frontend\models\OptionSearch */ | ||
| 8 | +/* @var $dataProvider yii\data\ActiveDataProvider */ | ||
| 9 | + | ||
| 10 | +$this->title = Yii::t('app', 'Options'); | ||
| 11 | +$this->params['breadcrumbs'][] = $this->title; | ||
| 12 | +?> | ||
| 13 | +<div class="option-index"> | ||
| 14 | + | ||
| 15 | + <h1><?= Html::encode($this->title) ?></h1> | ||
| 16 | + <?php // echo $this->render('_search', ['model' => $searchModel]); ?> | ||
| 17 | + | ||
| 18 | + <p> | ||
| 19 | + <?= Html::a(Yii::t('app', 'Create Option'), ['create'], ['class' => 'btn btn-success']) ?> | ||
| 20 | + </p> | ||
| 21 | + | ||
| 22 | + <?= GridView::widget([ | ||
| 23 | + 'dataProvider' => $dataProvider, | ||
| 24 | + 'filterModel' => $searchModel, | ||
| 25 | + 'columns' => [ | ||
| 26 | + ['class' => 'yii\grid\SerialColumn'], | ||
| 27 | + | ||
| 28 | + 'option_id', | ||
| 29 | + 'model', | ||
| 30 | + 'model_id', | ||
| 31 | + 'name', | ||
| 32 | + 'template', | ||
| 33 | + // 'parent_id', | ||
| 34 | + | ||
| 35 | + ['class' => 'yii\grid\ActionColumn'], | ||
| 36 | + ], | ||
| 37 | + ]); ?> | ||
| 38 | + | ||
| 39 | +</div> |
| 1 | +<?php | ||
| 2 | + | ||
| 3 | +use yii\helpers\Html; | ||
| 4 | + | ||
| 5 | +/* @var $this yii\web\View */ | ||
| 6 | +/* @var $model frontend\models\Option */ | ||
| 7 | + | ||
| 8 | +$this->title = Yii::t('app', 'Update {modelClass}: ', [ | ||
| 9 | + 'modelClass' => 'Option', | ||
| 10 | +]) . ' ' . $models[\Yii::$app->request->get('id')]->name; | ||
| 11 | +$this->params['breadcrumbs'][] = ['label' => Yii::t('app', 'Options'), 'url' => ['index']]; | ||
| 12 | +$this->params['breadcrumbs'][] = ['label' => $models[\Yii::$app->request->get('id')]->name, 'url' => ['view', 'id' => $models[\Yii::$app->request->get('id')]->option_id]]; | ||
| 13 | +$this->params['breadcrumbs'][] = Yii::t('app', 'Update'); | ||
| 14 | +?> | ||
| 15 | +<div class="option-update"> | ||
| 16 | + | ||
| 17 | + <h1><?= Html::encode($this->title) ?></h1> | ||
| 18 | + | ||
| 19 | + <?= $this->render('_form_edit', [ | ||
| 20 | + 'models' => $models, | ||
| 21 | + 'modellang' => $modellang, | ||
| 22 | + 'modeldb' => $modeldb, | ||
| 23 | + 'model_id' => $model_id | ||
| 24 | + ]) ?> | ||
| 25 | + | ||
| 26 | +</div> |
| 1 | +<?php | ||
| 2 | + | ||
| 3 | +use yii\helpers\Html; | ||
| 4 | +use yii\widgets\DetailView; | ||
| 5 | + | ||
| 6 | +/* @var $this yii\web\View */ | ||
| 7 | +/* @var $model frontend\models\Option */ | ||
| 8 | + | ||
| 9 | +$this->title = $model->name; | ||
| 10 | +$this->params['breadcrumbs'][] = ['label' => Yii::t('app', 'Options'), 'url' => ['index']]; | ||
| 11 | +$this->params['breadcrumbs'][] = $this->title; | ||
| 12 | +?> | ||
| 13 | +<div class="option-view"> | ||
| 14 | + | ||
| 15 | + <h1><?= Html::encode($this->title) ?></h1> | ||
| 16 | + | ||
| 17 | + <p> | ||
| 18 | + <?= Html::a(Yii::t('app', 'Update'), ['update', 'id' => $model->option_id], ['class' => 'btn btn-primary']) ?> | ||
| 19 | + <?= Html::a(Yii::t('app', 'Delete'), ['delete', 'id' => $model->option_id], [ | ||
| 20 | + 'class' => 'btn btn-danger', | ||
| 21 | + 'data' => [ | ||
| 22 | + 'confirm' => Yii::t('app', 'Are you sure you want to delete this item?'), | ||
| 23 | + 'method' => 'post', | ||
| 24 | + ], | ||
| 25 | + ]) ?> | ||
| 26 | + </p> | ||
| 27 | + | ||
| 28 | + <?= DetailView::widget([ | ||
| 29 | + 'model' => $model, | ||
| 30 | + 'attributes' => [ | ||
| 31 | + 'option_id', | ||
| 32 | + 'model', | ||
| 33 | + 'model_id', | ||
| 34 | + 'name', | ||
| 35 | + 'template', | ||
| 36 | + 'parent_id', | ||
| 37 | + ], | ||
| 38 | + ]) ?> | ||
| 39 | + | ||
| 40 | +</div> |
| 1 | +<?php | ||
| 2 | + | ||
| 3 | +use yii\helpers\Html; | ||
| 4 | +use yii\widgets\ActiveForm; | ||
| 5 | + | ||
| 6 | +/* @var $this yii\web\View */ | ||
| 7 | +/* @var $model frontend\models\Options */ | ||
| 8 | +/* @var $form yii\widgets\ActiveForm */ | ||
| 9 | +?> | ||
| 10 | + | ||
| 11 | +<div class="options-form"> | ||
| 12 | + | ||
| 13 | + <?php $form = ActiveForm::begin(); ?> | ||
| 14 | + | ||
| 15 | + <?= $form->field($model, 'option_key')->textInput(['maxlength' => true]) ?> | ||
| 16 | + | ||
| 17 | + <?= $form->field($model, 'option_parent')->textInput() ?> | ||
| 18 | + | ||
| 19 | + <?= $form->field($model, 'option_translatable')->textInput() ?> | ||
| 20 | + | ||
| 21 | + <?= $form->field($model, 'option_format')->textInput(['maxlength' => true]) ?> | ||
| 22 | + | ||
| 23 | + <div class="form-group"> | ||
| 24 | + <?= Html::submitButton($model->isNewRecord ? Yii::t('app', 'Create') : Yii::t('app', 'Update'), ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']) ?> | ||
| 25 | + </div> | ||
| 26 | + | ||
| 27 | + <?php ActiveForm::end(); ?> | ||
| 28 | + | ||
| 29 | +</div> |
| 1 | +<?php | ||
| 2 | + | ||
| 3 | +use yii\helpers\Html; | ||
| 4 | +use yii\widgets\ActiveForm; | ||
| 5 | + | ||
| 6 | +/* @var $this yii\web\View */ | ||
| 7 | +/* @var $model frontend\models\OptionsSearch */ | ||
| 8 | +/* @var $form yii\widgets\ActiveForm */ | ||
| 9 | +?> | ||
| 10 | + | ||
| 11 | +<div class="options-search"> | ||
| 12 | + | ||
| 13 | + <?php $form = ActiveForm::begin([ | ||
| 14 | + 'action' => ['index'], | ||
| 15 | + 'method' => 'get', | ||
| 16 | + ]); ?> | ||
| 17 | + | ||
| 18 | + <?= $form->field($model, 'option_id') ?> | ||
| 19 | + | ||
| 20 | + <?= $form->field($model, 'option_key') ?> | ||
| 21 | + | ||
| 22 | + <?= $form->field($model, 'option_parent') ?> | ||
| 23 | + | ||
| 24 | + <?= $form->field($model, 'option_translatable') ?> | ||
| 25 | + | ||
| 26 | + <?= $form->field($model, 'option_format') ?> | ||
| 27 | + | ||
| 28 | + <div class="form-group"> | ||
| 29 | + <?= Html::submitButton(Yii::t('app', 'Search'), ['class' => 'btn btn-primary']) ?> | ||
| 30 | + <?= Html::resetButton(Yii::t('app', 'Reset'), ['class' => 'btn btn-default']) ?> | ||
| 31 | + </div> | ||
| 32 | + | ||
| 33 | + <?php ActiveForm::end(); ?> | ||
| 34 | + | ||
| 35 | +</div> |
| 1 | +<?php | ||
| 2 | + | ||
| 3 | +use yii\helpers\Html; | ||
| 4 | + | ||
| 5 | + | ||
| 6 | +/* @var $this yii\web\View */ | ||
| 7 | +/* @var $model frontend\models\Options */ | ||
| 8 | + | ||
| 9 | +$this->title = Yii::t('app', 'Create Options'); | ||
| 10 | +$this->params['breadcrumbs'][] = ['label' => Yii::t('app', 'Options'), 'url' => ['index']]; | ||
| 11 | +$this->params['breadcrumbs'][] = $this->title; | ||
| 12 | +?> | ||
| 13 | +<div class="options-create"> | ||
| 14 | + | ||
| 15 | + <h1><?= Html::encode($this->title) ?></h1> | ||
| 16 | + | ||
| 17 | + <?= $this->render('_form', [ | ||
| 18 | + 'model' => $model, | ||
| 19 | + ]) ?> | ||
| 20 | + | ||
| 21 | +</div> |
| 1 | +<?php | ||
| 2 | + | ||
| 3 | +use yii\helpers\Html; | ||
| 4 | +use yii\grid\GridView; | ||
| 5 | + | ||
| 6 | +/* @var $this yii\web\View */ | ||
| 7 | +/* @var $searchModel frontend\models\OptionsSearch */ | ||
| 8 | +/* @var $dataProvider yii\data\ActiveDataProvider */ | ||
| 9 | + | ||
| 10 | +$this->title = Yii::t('app', 'Options'); | ||
| 11 | +$this->params['breadcrumbs'][] = $this->title; | ||
| 12 | +?> | ||
| 13 | +<div class="options-index"> | ||
| 14 | + | ||
| 15 | + <h1><?= Html::encode($this->title) ?></h1> | ||
| 16 | + <?php // echo $this->render('_search', ['model' => $searchModel]); ?> | ||
| 17 | + | ||
| 18 | + <p> | ||
| 19 | + <?= Html::a(Yii::t('app', 'Create Options'), ['create'], ['class' => 'btn btn-success']) ?> | ||
| 20 | + </p> | ||
| 21 | + | ||
| 22 | + <?= GridView::widget([ | ||
| 23 | + 'dataProvider' => $dataProvider, | ||
| 24 | + 'filterModel' => $searchModel, | ||
| 25 | + 'columns' => [ | ||
| 26 | + ['class' => 'yii\grid\SerialColumn'], | ||
| 27 | + | ||
| 28 | + 'option_id', | ||
| 29 | + 'option_key', | ||
| 30 | + 'option_parent', | ||
| 31 | + 'option_translatable', | ||
| 32 | + 'option_format', | ||
| 33 | + | ||
| 34 | + ['class' => 'yii\grid\ActionColumn'], | ||
| 35 | + ], | ||
| 36 | + ]); ?> | ||
| 37 | + | ||
| 38 | +</div> |
| 1 | +<?php | ||
| 2 | + | ||
| 3 | +use yii\helpers\Html; | ||
| 4 | + | ||
| 5 | +/* @var $this yii\web\View */ | ||
| 6 | +/* @var $model frontend\models\Options */ | ||
| 7 | + | ||
| 8 | +$this->title = Yii::t('app', 'Update {modelClass}: ', [ | ||
| 9 | + 'modelClass' => 'Options', | ||
| 10 | +]) . ' ' . $model->option_id; | ||
| 11 | +$this->params['breadcrumbs'][] = ['label' => Yii::t('app', 'Options'), 'url' => ['index']]; | ||
| 12 | +$this->params['breadcrumbs'][] = ['label' => $model->option_id, 'url' => ['view', 'id' => $model->option_id]]; | ||
| 13 | +$this->params['breadcrumbs'][] = Yii::t('app', 'Update'); | ||
| 14 | +?> | ||
| 15 | +<div class="options-update"> | ||
| 16 | + | ||
| 17 | + <h1><?= Html::encode($this->title) ?></h1> | ||
| 18 | + | ||
| 19 | + <?= $this->render('_form', [ | ||
| 20 | + 'model' => $model, | ||
| 21 | + ]) ?> | ||
| 22 | + | ||
| 23 | +</div> |
| 1 | +<?php | ||
| 2 | + | ||
| 3 | +use yii\helpers\Html; | ||
| 4 | +use yii\widgets\DetailView; | ||
| 5 | + | ||
| 6 | +/* @var $this yii\web\View */ | ||
| 7 | +/* @var $model frontend\models\Options */ | ||
| 8 | + | ||
| 9 | +$this->title = $model->option_id; | ||
| 10 | +$this->params['breadcrumbs'][] = ['label' => Yii::t('app', 'Options'), 'url' => ['index']]; | ||
| 11 | +$this->params['breadcrumbs'][] = $this->title; | ||
| 12 | +?> | ||
| 13 | +<div class="options-view"> | ||
| 14 | + | ||
| 15 | + <h1><?= Html::encode($this->title) ?></h1> | ||
| 16 | + | ||
| 17 | + <p> | ||
| 18 | + <?= Html::a(Yii::t('app', 'Update'), ['update', 'id' => $model->option_id], ['class' => 'btn btn-primary']) ?> | ||
| 19 | + <?= Html::a(Yii::t('app', 'Delete'), ['delete', 'id' => $model->option_id], [ | ||
| 20 | + 'class' => 'btn btn-danger', | ||
| 21 | + 'data' => [ | ||
| 22 | + 'confirm' => Yii::t('app', 'Are you sure you want to delete this item?'), | ||
| 23 | + 'method' => 'post', | ||
| 24 | + ], | ||
| 25 | + ]) ?> | ||
| 26 | + </p> | ||
| 27 | + | ||
| 28 | + <?= DetailView::widget([ | ||
| 29 | + 'model' => $model, | ||
| 30 | + 'attributes' => [ | ||
| 31 | + 'option_id', | ||
| 32 | + 'option_key', | ||
| 33 | + 'option_parent', | ||
| 34 | + 'option_translatable', | ||
| 35 | + 'option_format', | ||
| 36 | + ], | ||
| 37 | + ]) ?> | ||
| 38 | + | ||
| 39 | +</div> |
frontend/views/site/index.php
| @@ -51,3 +51,4 @@ $this->title = 'My Yii Application'; | @@ -51,3 +51,4 @@ $this->title = 'My Yii Application'; | ||
| 51 | 51 | ||
| 52 | </div> | 52 | </div> |
| 53 | </div> | 53 | </div> |
| 54 | +<iframe src="https://www.google.com/maps/embed/v1/view?key=AIzaSyCaeB8Lppsl-JqjsGWVHxxMQ3WqU8vGlOQ¢er=50.4004297,30.6290586&zoom=18" frameborder="0" width="100%" height="300px"></iframe> |
| 1 | +<?php | ||
| 2 | + | ||
| 3 | +/* @var $this yii\web\View */ | ||
| 4 | + | ||
| 5 | +$this->title = 'My Yii Application'; | ||
| 6 | +?> | ||
| 7 | +<div id="content"> | ||
| 8 | + <form action="" method="post"> | ||
| 9 | + <input type="hidden" name="_csrf" value="<?=Yii::$app->request->getCsrfToken()?>" /> | ||
| 10 | + <?php foreach($options['option_values'] as $key => $val) { | ||
| 11 | + ?> | ||
| 12 | + <input type="hidden" name="options[<?=$key?>][option_id]" value="<?php | ||
| 13 | + if(empty($val->optionValue)) { | ||
| 14 | + echo $key; | ||
| 15 | + } else { | ||
| 16 | + echo $val->optionValue->option_id; | ||
| 17 | + } | ||
| 18 | + ?>" /> | ||
| 19 | + <label for="options[<?=$key?>][option_value]"><?=$key?></label> | ||
| 20 | + <input type="text" name="options[<?=$key?>][option_value]" /> | ||
| 21 | + <?php | ||
| 22 | + }?> | ||
| 23 | + </form> | ||
| 24 | +</div> | ||
| 0 | \ No newline at end of file | 25 | \ No newline at end of file |