Fix Setting

parent 206245f5
......@@ -90,18 +90,24 @@ class SettingsController extends AdminController
*/
public function actionCreate($module_id)
{
return $this->actionUpdate($module_id);
die('---');
$model = new Settings();
$model = new Settings;
if ($model->load(Yii::$app->request->post()) && $model->save()) {
return $this->redirect(['view', 'id' => $model->id]);
} else {
return $this->render('create', [
'model' => $model,
]);
}
Yii::$app->controller->page_title = 'Создание свойства для модуля <small>' .\Yii::$app->getModule($module_id)->name(). '</small>';
Yii::$app->controller->breadcrumbs = [
['Свойства модуля ' .\Yii::$app->getModule($module_id)->name() => \yii\helpers\Url::toRoute(['manage', 'module_id'=>$module_id])],
'Создание свойства для модуля ' .\Yii::$app->getModule($module_id)->name(),
];
if ($model->load(Yii::$app->request->post()) && $model->save())
{
return $this->redirect(['manage', 'module_id' => $module_id]);
}
$form = new \common\components\BaseForm('/backend/forms/SettingsForm', $model);
return $this->render('create', [
'model' => $model,
'form' => $form->out
]);
}
/**
......@@ -110,45 +116,27 @@ class SettingsController extends AdminController
* @param string $id
* @return mixed
*/
public function actionUpdate($module_id, $id = null)
{
//die(print_r(\common\components\AppManager::getSettingsParam('scoring_low')));
if(!empty($id)) {
$model = $this->findModel($id);
\yii::$app->controller->page_title = 'Редактирование свойства для модуля <small>' .\Yii::$app->getModule($module_id)->name(). '</small>';
\yii::$app->controller->breadcrumbs = [
['Свойства модуля ' .\Yii::$app->getModule($module_id)->name() => \yii\helpers\Url::toRoute(['manage', 'module_id'=>$module_id])],
'Редактирование свойства для модуля ' .\Yii::$app->getModule($module_id)->name(),
];
}
else {
$model = new Settings();
$model->module_id = $module_id;
\yii::$app->controller->page_title = 'Добавление свойства для модуля <small>' .\Yii::$app->getModule($module_id)->name(). '</small>';
\yii::$app->controller->breadcrumbs = [
['Свойства модуля ' .\Yii::$app->getModule($module_id)->name() => \yii\helpers\Url::toRoute(['manage', 'module_id'=>$module_id])],
'Добавление свойства для модуля ' .\Yii::$app->getModule($module_id)->name(),
];
}
if ($model->load(Yii::$app->request->post()) && $model->save()) {
return $this->redirect(['manage', 'module_id' => $module_id]);
} else {
if($model->hasErrors())
\Yii::$app->getSession()->setFlash('error', $model->getErrors());
public function actionUpdate($id)
{
$model = $this->findModel($id);
Yii::$app->controller->page_title = 'Редактирование свойства для модуля <small>' .\Yii::$app->getModule($model->module_id)->name(). '</small>';
Yii::$app->controller->breadcrumbs = [
['Свойства модуля ' .\Yii::$app->getModule($model->module_id)->name() => \yii\helpers\Url::toRoute(['manage', 'module_id'=>$model->module_id])],
'Редактирование свойства для модуля ' .\Yii::$app->getModule($model->module_id)->name(),
];
if($id == 87)
$form = new \common\components\BaseForm('/backend/forms/SettingsForm1', $model);
else
$form = new \common\components\BaseForm('/backend/forms/SettingsForm', $model);
if ($model->load(Yii::$app->request->post()) && $model->save())
{
return $this->redirect(['manage', 'module_id' => $model->module_id]);
}
else
{
$form = new \common\components\BaseForm('/backend/forms/SettingsForm', $model);
return $this->render('update', [
//'model' => $model,
'model' => $model,
'form' => $form->out,
//'module_id' => $module_id
]);
}
}
......
......@@ -17,13 +17,11 @@ return [
'value' => ['type' => 'text', 'class' => 'form-control'],
'element' => [
'type' => 'dropdownlist',
'items' => ['editor','text','textarea'],
'items' => ['editor', 'text', 'textarea'],
'class' => 'form-control',
],
'description' => ['type' => 'text', 'class' => 'form-control'],
'hidden' => ['type' => 'checkbox'],
// 'created_at' => ['type' => 'text', 'class' => 'form-control'],
// 'updated_at' => ['type' => 'text', 'class' => 'form-control'],
],
'buttons' => [
'submit' => ['type' => 'submit', 'value' => 'Cохранить']
......
......@@ -14,15 +14,10 @@ return [
'name' => ['type' => 'text', 'class' => 'form-control'],
'value' => ['type' => 'text', 'class' => 'form-control'],
'element' => [
/*'type' => 'dropdownlist',
'items' => ['editor','text','textarea'],
'class' => 'form-control',*/
'type' => 'hidden',
],
'description' => ['type' => 'hidden', 'class' => 'form-control'],
'hidden' => ['type' => 'hidden'],
// 'created_at' => ['type' => 'text', 'class' => 'form-control'],
// 'updated_at' => ['type' => 'text', 'class' => 'form-control'],
],
'buttons' => [
'submit' => ['type' => 'submit', 'value' => 'Cохранить']
......
<?php
use yii\helpers\Html;
/* @var $this yii\web\View */
/* @var $model common\models\Settings */
$this->title = Yii::t('app', 'Create Settings');
$this->params['breadcrumbs'][] = ['label' => Yii::t('app', 'Settings'), 'url' => ['index']];
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="settings-create">
<h1><?= Html::encode($this->title) ?></h1>
<?= $this->render('_form', [
'model' => $model,
]) ?>
</div>
echo $form;
\ No newline at end of file
<?php
use yii\helpers\Html;
echo $form
?>
echo $form;
......@@ -54,13 +54,13 @@ class Settings extends \common\components\ActiveRecordModel
{
return [
'id' => Yii::t('app', 'ID'),
'module_id' => Yii::t('app', 'Module ID'),
'code' => Yii::t('app', 'Code'),
'name' => Yii::t('app', 'Name'),
'value' => Yii::t('app', 'Value'),
'element' => Yii::t('app', 'Element'),
'hidden' => Yii::t('app', 'Hidden'),
'description' => Yii::t('app', 'Description'),
'module_id' => 'Модуль',
'code' => 'Код',
'name' => 'Название',
'value' => 'Значение',
'element' => 'Элемент',
'hidden' => 'Скрытый',
'description' => 'Описание',
];
}
}
<?php
namespace common\modules\main\controllers;
use Yii;
use common\modules\main\models\Counts;
use common\modules\main\models\CountsSearch;
use common\components\AdminController;
use yii\helpers\Url;
use yii\web\NotFoundHttpException;
use yii\filters\VerbFilter;
/**
* CountsController implements the CRUD actions for Counts model.
*/
class CountsController extends AdminController
{
public function behaviors()
{
return [
'verbs' => [
'class' => VerbFilter::className(),
'actions' => [
'delete' => ['post'],
],
],
];
}
public static function actionsTitles() {
return [
'Index' => '',
'Create' => '',
'Update' => '',
'Delete' => '',
'View' => '',
];
}
/**
* Lists all Counts models.
* @return mixed
*/
public function actionIndex()
{
\yii::$app->controller->page_title = 'Счетчики';
\yii::$app->controller->breadcrumbs = [
'Счетчики'
];
$searchModel = new CountsSearch();
$dataProvider = $searchModel->search(Yii::$app->request->queryParams);
return $this->render('index', [
'searchModel' => $searchModel,
'dataProvider' => $dataProvider,
]);
}
/**
* Displays a single Counts model.
* @param integer $id
* @return mixed
*/
public function actionView($id)
{
$model = $this->findModel($id);
\yii::$app->controller->page_title = 'Редактировать счетчик ' . $model->name;
\yii::$app->controller->breadcrumbs = [
['Счетчики' => Url::toRoute('/main/counts/index')],
'Редактировать счетчик ' . $model->name
];
return $this->render('view', [
'model' => $model,
]);
}
/**
* Creates a new Counts model.
* If creation is successful, the browser will be redirected to the 'view' page.
* @return mixed
*/
public function actionCreate()
{
$model = new Counts();
\yii::$app->controller->page_title = 'Добавить счетчик';
\yii::$app->controller->breadcrumbs = [
['Счетчики' => Url::toRoute('/main/counts/index')],
'Добавить счетчик'
];
if ($model->load(Yii::$app->request->post()) && $model->save()) {
return $this->redirect(['view', 'id' => $model->id]);
} else {
return $this->render('create', [
'model' => $model,
]);
}
}
/**
* Updates an existing Counts model.
* If update is successful, the browser will be redirected to the 'view' page.
* @param integer $id
* @return mixed
*/
public function actionUpdate($id)
{
$model = $this->findModel($id);
\yii::$app->controller->page_title = 'Редактировать счетчик ' . $model->name;
\yii::$app->controller->breadcrumbs = [
['Счетчики' => Url::toRoute('/main/counts/index')],
'Редактировать счетчик ' . $model->name
];
if ($model->load(Yii::$app->request->post()) && $model->save()) {
return $this->redirect(['view', 'id' => $model->id]);
} else {
return $this->render('update', [
'model' => $model,
]);
}
}
/**
* Deletes an existing Counts model.
* If deletion is successful, the browser will be redirected to the 'index' page.
* @param integer $id
* @return mixed
*/
public function actionDelete($id)
{
$this->findModel($id)->delete();
return $this->redirect(['index']);
}
/**
* Finds the Counts model based on its primary key value.
* If the model is not found, a 404 HTTP exception will be thrown.
* @param integer $id
* @return Counts the loaded model
* @throws NotFoundHttpException if the model cannot be found
*/
protected function findModel($id)
{
if (($model = Counts::findOne($id)) !== null) {
return $model;
} else {
throw new NotFoundHttpException('The requested page does not exist.');
}
}
}
<?php
namespace common\modules\main\controllers;
use yii\web\Controller;
class DefaultController extends Controller
{
public function actionIndex()
{
return $this->render('index');
}
public function actionTest() {
error_reporting(E_ALL);
ini_set('display_errors', 1);
$model = new \common\models\Enctest();
//$model->data = 'Druppov_A@mail.ru';
$model->data = 'YQE4W2rOGog=u0TcCx3Lpr1LBkBHEplEuPxJ8+Sq77oQ';
$model->save();
$model = \common\models\Enctest::find()->where(['id'=>19])->one();
print_r($model->attributes);
}
}
......@@ -2,9 +2,6 @@
namespace common\modules\main\controllers;
use common\modules\request\models\CronWork;
use common\models\Settings;
class MainAdminController extends \common\components\AdminController
{
//public $layout = '\main';
......@@ -13,12 +10,6 @@ class MainAdminController extends \common\components\AdminController
{
return array(
'Index' => 'Просмотр главной страницы',
'Modules' => 'Просмотр списка модулей',
'ChangeOrder' => 'Сортировка',
'SessionPerPage' => 'Установки кол-ва элементов на странице',
'SessionLanguage' => 'Установка языка',
'AdminLinkProcess' => 'Переход по ссылке в админ панель',
'Calculatepercent' => '',
);
}
......@@ -27,17 +18,4 @@ class MainAdminController extends \common\components\AdminController
return $this->render('index');
}
public function actionCalculatepercent()
{
\console\controllers\PercentController::actionCalculate();
return $this->redirect('index');
}
public function actionSessionPerPage($model, $per_page, $back_url)
{die($model.' -- '.$per_page.' -- '.$back_url);
\Yii::$app->session["{$model}PerPage"] = $per_page;
$this->redirect(base64_decode($back_url));
}
}
<?php
namespace common\modules\main\controllers;
use Yii;
use yii\filters\AccessControl;
use yii\web\Controller;
use common\models\LoginForm;
use yii\filters\VerbFilter;
//class MainAdminController extends \common\components\AdminController
class MAINAdminController extends Controller
{
public function init() {
die($this->context->module->id);
}
public function actionIndex()
{
error_reporting(E_ALL);
ini_set('display_errors', 1);
return $this->render('\common\modules\main\mainAdmin\index');
}
}
<?php
use yii\helpers\Html;
use yii\widgets\ActiveForm;
/* @var $this yii\web\View */
/* @var $model common\modules\main\models\Counts */
/* @var $form yii\widgets\ActiveForm */
?>
<div class="counts-form">
<?php $form = ActiveForm::begin(); ?>
<?= $form->field($model, 'name')->textInput(['maxlength' => true]) ?>
<?= $form->field($model, 'count')->textarea(['rows' => 6]) ?>
<div class="form-group">
<?= Html::submitButton($model->isNewRecord ? 'Добавить' : 'Обновить', ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']) ?>
</div>
<?php ActiveForm::end(); ?>
</div>
<?php
use yii\helpers\Html;
use yii\widgets\ActiveForm;
/* @var $this yii\web\View */
/* @var $model common\modules\main\models\CountsSearch */
/* @var $form yii\widgets\ActiveForm */
?>
<div class="counts-search">
<?php $form = ActiveForm::begin([
'action' => ['index'],
'method' => 'get',
]); ?>
<?= $form->field($model, 'id') ?>
<?= $form->field($model, 'name') ?>
<?= $form->field($model, 'count') ?>
<?= $form->field($model, 'created_at') ?>
<?= $form->field($model, 'updated_at') ?>
<div class="form-group">
<?= Html::submitButton('Search', ['class' => 'btn btn-primary']) ?>
<?= Html::resetButton('Reset', ['class' => 'btn btn-default']) ?>
</div>
<?php ActiveForm::end(); ?>
</div>
<?php
use yii\helpers\Html;
/* @var $this yii\web\View */
/* @var $model common\modules\main\models\Counts */
?>
<div class="counts-create">
<?= $this->render('_form', [
'model' => $model,
]) ?>
</div>
<?php
use yii\helpers\Html;
use yii\grid\GridView;
/* @var $this yii\web\View */
/* @var $searchModel common\modules\main\models\CountsSearch */
/* @var $dataProvider yii\data\ActiveDataProvider */
?>
<div class="counts-index">
<?php // echo $this->render('_search', ['model' => $searchModel]); ?>
<p>
<?= Html::a('Добавить счетчик', ['create'], ['class' => 'btn btn-success']) ?>
</p>
<?= \common\components\zii\AdminGrid::widget([
'dataProvider' => $dataProvider,
'filterModel' => $searchModel,
'columns' => [
//['class' => 'yii\grid\SerialColumn'],
//'id',
'name',
'count:ntext',
/*'created_at',
'updated_at',*/
['class' => 'yii\grid\ActionColumn'],
],
]); ?>
</div>
<?php
use yii\helpers\Html;
/* @var $this yii\web\View */
/* @var $model common\modules\main\models\Counts */
$this->title = 'Update Counts: ' . ' ' . $model->name;
$this->params['breadcrumbs'][] = ['label' => 'Counts', 'url' => ['index']];
$this->params['breadcrumbs'][] = ['label' => $model->name, 'url' => ['view', 'id' => $model->id]];
$this->params['breadcrumbs'][] = 'Update';
?>
<div class="counts-update">
<h1><?= Html::encode($this->title) ?></h1>
<?= $this->render('_form', [
'model' => $model,
]) ?>
</div>
<?php
use yii\helpers\Html;
use yii\widgets\DetailView;
/* @var $this yii\web\View */
/* @var $model common\modules\main\models\Counts */
?>
<div class="counts-view">
<p>
<?= Html::a('Редактировать', ['update', 'id' => $model->id], ['class' => 'btn btn-primary']) ?>
<?= Html::a('Удалить', ['delete', 'id' => $model->id], [
'class' => 'btn btn-danger',
'data' => [
'confirm' => 'Вы уверены?',
'method' => 'post',
],
]) ?>
</p>
<?= DetailView::widget([
'model' => $model,
'attributes' => [
//'id',
'name',
'count:ntext',
/*'created_at',
'updated_at',*/
],
]) ?>
</div>
<div class="mainModule-default-index">
<h1><?= $this->context->action->uniqueId ?></h1>
<p>
This is the view content for action "<?= $this->context->action->id ?>".
The action belongs to the controller "<?= get_class($this->context) ?>"
in the "<?= $this->context->module->id ?>" module.
</p>
<p>
You may customize this page by editing the following file:<br>
<code><?= __FILE__ ?></code>
</p>
</div>
......@@ -27,7 +27,7 @@ AppAsset::register($this);
<nav class="menu">
<div class="toggle_block"><a href="#" class="toggle-mnu"><span></span></a></div>
<div class="phone_menu">8-495-961-42-29</div>
<div class="phone_menu">8-495-749-29-69</div>
<ul>
<li><a href="/about" class="link">О компании</a></li>
<li><a href="#" class="link">Кейсы</a></li>
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment