Commit 59e20f91 by Junaid Rahman pv

Merge remote-tracking branch 'origin/development' into development

parents 3cbcf011 b2318ab4
...@@ -5,6 +5,7 @@ namespace backend\modules\theme\controllers; ...@@ -5,6 +5,7 @@ namespace backend\modules\theme\controllers;
use Yii; use Yii;
use common\models\Theme; use common\models\Theme;
use backend\modules\theme\models\search\ThemeSearch; use backend\modules\theme\models\search\ThemeSearch;
use yii\helpers\Html;
use yii\web\Controller; use yii\web\Controller;
use yii\web\NotFoundHttpException; use yii\web\NotFoundHttpException;
use yii\filters\VerbFilter; use yii\filters\VerbFilter;
...@@ -32,6 +33,8 @@ class ThemeController extends Controller ...@@ -32,6 +33,8 @@ class ThemeController extends Controller
*/ */
public function actionIndex() public function actionIndex()
{ {
$searchModel = new ThemeSearch(); $searchModel = new ThemeSearch();
$dataProvider = $searchModel->search(Yii::$app->request->queryParams); $dataProvider = $searchModel->search(Yii::$app->request->queryParams);
...@@ -60,15 +63,17 @@ class ThemeController extends Controller ...@@ -60,15 +63,17 @@ class ThemeController extends Controller
*/ */
public function actionCreate() public function actionCreate()
{ {
$model = new Theme(); $this->layout = '@backend/modules/theme/views/theme/layout.php';
$model = new Theme();
$model->status = $model::STATUS_ACTIVE;
if ($model->load(Yii::$app->request->post()) && $model->save()) { if ($model->load(Yii::$app->request->post()) && $model->save()) {
return $this->redirect(['view', 'id' => $model->id]); return $this->redirect(['view', 'id' => $model->id]);
} else { }
return $this->render('create', [ return $this->render('create', [
'model' => $model, 'model' => $model,
]); ]);
}
} }
/** /**
...@@ -79,6 +84,8 @@ class ThemeController extends Controller ...@@ -79,6 +84,8 @@ class ThemeController extends Controller
*/ */
public function actionUpdate($id) public function actionUpdate($id)
{ {
$this->layout = '@backend/modules/theme/views/theme/layout.php';
$model = $this->findModel($id); $model = $this->findModel($id);
if ($model->load(Yii::$app->request->post()) && $model->save()) { if ($model->load(Yii::$app->request->post()) && $model->save()) {
......
...@@ -16,7 +16,9 @@ use trntv\filekit\widget\Upload; ...@@ -16,7 +16,9 @@ use trntv\filekit\widget\Upload;
<div id="myTabContent" class="tab-content"> <div id="myTabContent" class="tab-content">
<div class="tab-pane fade in active" id="info"> <div class="tab-pane fade in active" id="info">
<div class="page-header"> <div class="page-header">
<h3> <?= Yii::t('backend', 'Info') ?> </h3> <h3> <?= Yii::t('backend', 'Info') ?> </h3>
</div> </div>
<div class="row"> <div class="row">
<div class="col-md-6"> <div class="col-md-6">
...@@ -41,12 +43,14 @@ use trntv\filekit\widget\Upload; ...@@ -41,12 +43,14 @@ use trntv\filekit\widget\Upload;
</div> </div>
<div class="row"> <div class="row">
<div class="col-md-6"> <div class="col-md-6">
<?= $form->field($model, 'image')->widget( <?= $form->field($model, 'image')->widget(
Upload::className(), Upload::className(),
[ [
'url' => ['/file-storage/upload'], 'url' => ['/file-storage/upload'],
])->label('Image'); ])->label('Image');
?> ?>
</div> </div>
</div> </div>
<div class="row"> <div class="row">
...@@ -55,8 +59,10 @@ use trntv\filekit\widget\Upload; ...@@ -55,8 +59,10 @@ use trntv\filekit\widget\Upload;
</div> </div>
</div> </div>
<div class="form-group"> <div class="form-group">
<?php echo Html::submitButton($model->isNewRecord ? Yii::t('backend', 'Create') : Yii::t('backend', <?php echo Html::submitButton($model->isNewRecord ? Yii::t('backend', 'Create') : Yii::t('backend',
'Update'), ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']) ?> 'Update'), ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']) ?>
</div> </div>
</div> </div>
<div class="tab-pane fade in" id="files"> <div class="tab-pane fade in" id="files">
......
...@@ -12,9 +12,6 @@ use wbraganca\dynamicform\DynamicFormWidget; ...@@ -12,9 +12,6 @@ use wbraganca\dynamicform\DynamicFormWidget;
<?php $form = ActiveForm::begin(['id' => 'dynamic-form']); ?> <?php $form = ActiveForm::begin(['id' => 'dynamic-form']); ?>
<div class="panel panel-default"> <div class="panel panel-default">
<div class="panel-heading">
<h4><i class="glyphicon glyphicon-envelope"></i> Addresses</h4>
</div>
<div class="panel-body"> <div class="panel-body">
<?php DynamicFormWidget::begin([ <?php DynamicFormWidget::begin([
'widgetContainer' => 'dynamicform_wrapper', // required: only alphanumeric characters plus "_" [A-Za-z0-9_] 'widgetContainer' => 'dynamicform_wrapper', // required: only alphanumeric characters plus "_" [A-Za-z0-9_]
......
...@@ -11,49 +11,60 @@ use yii\bootstrap\ActiveForm; ...@@ -11,49 +11,60 @@ use yii\bootstrap\ActiveForm;
<div class="theme-form"> <div class="theme-form">
<?php $form = ActiveForm::begin(); ?> <?php $form = ActiveForm::begin(); ?>
<div id="myTabContent" class="tab-content"> <div id="myTabContent" class="tab-content">
<div class="tab-pane fade in active" id="info"> <div class="tab-pane fade in active" id="info">
<div class="page-header"> <div class="page-header">
<h3> <?= Yii::t('backend', 'Info') ?> </h3> <h3> <?= Yii::t('backend', 'Info') ?> </h3>
</div> </div>
<div class="row"> <div class="row">
<div class="col-md-6"> <div class="col-md-6">
<?= $form->field($model, 'category_id')->textInput() ?>
<?= $form->field($model, 'category_id')->dropDownList(\common\models\Category::getAllCategories(), ['prompt' => '']) ?>
</div> </div>
</div> </div>
<div class="row"> <div class="row">
<div class="col-md-6"> <div class="col-md-6">
<?= $form->field($model, 'code')->textInput(['maxlength' => true]) ?> <?= $form->field($model, 'code')->textInput(['maxlength' => true]) ?>
</div> </div>
</div> </div>
<div class="row"> <div class="row">
<div class="col-md-6"> <div class="col-md-6">
<?= $form->field($model, 'slug')->textInput(['maxlength' => true]) ?> <?= $form->field($model, 'slug')->textInput(['maxlength' => true]) ?>
</div> </div>
</div> </div>
<div class="row"> <div class="row">
<div class="col-md-6"> <div class="col-md-6">
<?= $form->field($model, 'name')->textInput(['maxlength' => true]) ?> <?= $form->field($model, 'name')->textInput(['maxlength' => true]) ?>
</div> </div>
</div> </div>
<div class="row"> <div class="row">
<div class="col-md-6"> <div class="col-md-6">
<?= $form->field($model, 'description')->textInput(['maxlength' => true]) ?>
<?= $form->field($model, 'description')->textarea(['maxlength' => true]) ?>
</div> </div>
</div> </div>
<div class="row"> <div class="row">
<div class="col-md-6"> <div class="col-md-6">
<?= $form->field($model, 'status')->dropDownList($model::statuses(), ['prompt' => '']) ?> <?= $form->field($model, 'status')->dropDownList($model::statuses(), ['prompt' => '']) ?>
</div> </div>
</div> </div>
<div class="form-group"> <div class="form-group">
<?= Html::submitButton($model->isNewRecord ? Yii::t('backend', 'Create') : Yii::t('backend', 'Update'), ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']) ?> <?= Html::submitButton($model->isNewRecord ? Yii::t('backend', 'Create') : Yii::t('backend', 'Update'), ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']) ?>
</div>
<div class="tab-pane fade in" id="files">
<div class="page-header">
<h3>Files</h3>
</div>
</div> </div>
<?php ActiveForm::end(); ?> <?php ActiveForm::end(); ?>
......
<?php
/* @var $this yii\web\View */
/* @var $model common\models\Theme */
/* @var $modelFiles common\models\ThemeFiles */
$this->params['themeId'] = false;
$this->title = 'Create Theme File';
$this->params['breadcrumbs'][] = ['label' => Yii::t('backend', 'Theme'), 'url' => ['index']];
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="theme-create">
<?= $this->render('..\file\_form', [
'model' => $model,
'modelFiles' => $modelFiles,
]) ?>
</div>
<?php
use yii\widgets\Menu;
/* @var $this yii\web\View */
?>
<?php $this->beginContent('@backend/views/layouts/main.php'); ?>
<?=
Menu::widget([
'items' => [
[
'label' => 'Info',
'url' => $this->params['themeId'] ?
['theme/update', 'id' => $this->params['themeId']]
: ['theme/create'],
],
[
'label' => 'Files',
'url' => $this->params['themeId'] ?
['theme/files', 'id' => $this->params['themeId']]
: '#',
'options' => ['class' => $this->params['themeId'] ? '' : 'disabled']
],
],
'options' => [
'class' => 'nav nav-tabs',
'role' => 'tablist',
'id' => 'theme-form-tab',
],
]);
?>
<div class="tab-content">
<?= $content ?>
</div>
<?php $this->endContent(); ?>
...@@ -7,6 +7,7 @@ use common\models\query\CategoryQuery; ...@@ -7,6 +7,7 @@ use common\models\query\CategoryQuery;
use yii\behaviors\SluggableBehavior; use yii\behaviors\SluggableBehavior;
use yii\behaviors\TimestampBehavior; use yii\behaviors\TimestampBehavior;
use trntv\filekit\behaviors\UploadBehavior; use trntv\filekit\behaviors\UploadBehavior;
use yii\helpers\ArrayHelper;
/** /**
* This is the model class for table "{{%category}}". * This is the model class for table "{{%category}}".
...@@ -92,6 +93,16 @@ class Category extends \yii\db\ActiveRecord ...@@ -92,6 +93,16 @@ class Category extends \yii\db\ActiveRecord
]; ];
} }
public static function getAllCategories()
{
$models = static::find()->active()->all();
return ArrayHelper::map(
$models,
'id',
'name'
);
}
/** /**
* @return \yii\db\ActiveQuery * @return \yii\db\ActiveQuery
*/ */
...@@ -116,4 +127,5 @@ class Category extends \yii\db\ActiveRecord ...@@ -116,4 +127,5 @@ class Category extends \yii\db\ActiveRecord
self::STATUS_IN_ACTIVE => Yii::t('common', 'In Active'), self::STATUS_IN_ACTIVE => Yii::t('common', 'In Active'),
]; ];
} }
} }
...@@ -3,6 +3,8 @@ ...@@ -3,6 +3,8 @@
namespace common\models; namespace common\models;
use Yii; use Yii;
use yii\behaviors\SluggableBehavior;
use yii\behaviors\TimestampBehavior;
/** /**
* This is the model class for table "{{%theme}}". * This is the model class for table "{{%theme}}".
...@@ -38,7 +40,7 @@ class Theme extends \yii\db\ActiveRecord ...@@ -38,7 +40,7 @@ class Theme extends \yii\db\ActiveRecord
public function rules() public function rules()
{ {
return [ return [
[['category_id', 'code', 'slug', 'name', 'status'], 'required'], [['category_id', 'code', 'name', 'status'], 'required'],
[['category_id', 'status', 'created_at', 'updated_at'], 'integer'], [['category_id', 'status', 'created_at', 'updated_at'], 'integer'],
[['code', 'slug', 'name'], 'string', 'max' => 32], [['code', 'slug', 'name'], 'string', 'max' => 32],
[['description'], 'string', 'max' => 512], [['description'], 'string', 'max' => 512],
...@@ -46,6 +48,22 @@ class Theme extends \yii\db\ActiveRecord ...@@ -46,6 +48,22 @@ class Theme extends \yii\db\ActiveRecord
]; ];
} }
public function behaviors()
{
return [
[
'class' => SluggableBehavior::className(),
'attribute' => 'name',
],
[
'class' => TimestampBehavior::className(),
'createdAtAttribute' => 'created_at',
'updatedAtAttribute' => 'updated_at'
]
];
}
/** /**
* @inheritdoc * @inheritdoc
*/ */
......
...@@ -2,6 +2,8 @@ ...@@ -2,6 +2,8 @@
namespace common\models\query; namespace common\models\query;
use common\models\Category;
use yii\helpers\ArrayHelper;
/** /**
* This is the ActiveQuery class for [[Category]]. * This is the ActiveQuery class for [[Category]].
* *
...@@ -9,10 +11,16 @@ namespace common\models\query; ...@@ -9,10 +11,16 @@ namespace common\models\query;
*/ */
class CategoryQuery extends \yii\db\ActiveQuery class CategoryQuery extends \yii\db\ActiveQuery
{ {
/*public function active() // public function active()
// {
// return $this->andWhere('[[status]]=1');
// }
public function active()
{ {
return $this->andWhere('[[status]]=1'); $this->andWhere(['status' => Category::STATUS_ACTIVE]);
}*/ return $this;
}
/** /**
* @inheritdoc * @inheritdoc
......
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