Commit 0a66f601 by Junaid Rahman pv

modified state,district and business module

parent 5034d186
...@@ -2,12 +2,15 @@ ...@@ -2,12 +2,15 @@
namespace backend\modules\business\controllers; namespace backend\modules\business\controllers;
use common\models\Category;
use common\models\District;
use Yii; use Yii;
use common\models\Business; use common\models\Business;
use backend\modules\business\models\search\BusinessSearch; use backend\modules\business\models\search\BusinessSearch;
use yii\web\Controller; use yii\web\Controller;
use yii\web\NotFoundHttpException; use yii\web\NotFoundHttpException;
use yii\filters\VerbFilter; use yii\filters\VerbFilter;
use yii\helpers\ArrayHelper;
/** /**
* BusinessController implements the CRUD actions for Business model. * BusinessController implements the CRUD actions for Business model.
...@@ -37,10 +40,14 @@ class BusinessController extends Controller ...@@ -37,10 +40,14 @@ class BusinessController extends Controller
{ {
$searchModel = new BusinessSearch(); $searchModel = new BusinessSearch();
$dataProvider = $searchModel->search(Yii::$app->request->queryParams); $dataProvider = $searchModel->search(Yii::$app->request->queryParams);
$categories = ArrayHelper::map(Category::find()->all(), 'id', 'name');
$districts = ArrayHelper::map(District::find()->all(), 'id', 'name');
return $this->render('index', [ return $this->render('index', [
'searchModel' => $searchModel, 'searchModel' => $searchModel,
'dataProvider' => $dataProvider, 'dataProvider' => $dataProvider,
'categories' => $categories,
'districts' => $districts,
]); ]);
} }
...@@ -68,8 +75,13 @@ class BusinessController extends Controller ...@@ -68,8 +75,13 @@ class BusinessController extends Controller
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 { } else {
$categories = ArrayHelper::map(Category::find()->all(), 'id', 'name');
$districts = ArrayHelper::map(District::find()->all(), 'id', 'name');
return $this->render('create', [ return $this->render('create', [
'model' => $model, 'model' => $model,
'categories' => $categories,
'districts' => $districts,
]); ]);
} }
} }
...@@ -87,8 +99,12 @@ class BusinessController extends Controller ...@@ -87,8 +99,12 @@ class BusinessController extends Controller
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 { } else {
$categories = ArrayHelper::map(Category::find()->all(), 'id', 'name');
$districts = ArrayHelper::map(District::find()->all(), 'id', 'name');
return $this->render('update', [ return $this->render('update', [
'model' => $model, 'model' => $model,
'categories' => $categories,
'districts' => $districts,
]); ]);
} }
} }
......
...@@ -2,121 +2,120 @@ ...@@ -2,121 +2,120 @@
use yii\helpers\Html; use yii\helpers\Html;
use yii\widgets\ActiveForm; use yii\widgets\ActiveForm;
//use common\widgets\GooglePlaceComplete\PlaceComplete;
/* @var $this yii\web\View */ /* @var $this yii\web\View */
/* @var $model common\models\Business */ /* @var $model common\models\Business */
/* @var $form yii\widgets\ActiveForm */ /* @var $form yii\widgets\ActiveForm */
/* @var $categories array */
/* @var $districts array */
?> ?>
<div class="business-form"> <div class="business-form">
<?php $form = ActiveForm::begin(); ?> <?php $form = ActiveForm::begin(); ?>
<div id="myTabContent" class="tab-content">
<div class="tab-pane fade in active" id="info">
<div class="page-header">
<h3>Info</h3>
</div>
<div class="row"> <div class="row">
<div class="col-md-6"> <div class="col-md-4">
<?= $form->field($model, 'category_id')->textInput() ?> <?= $form->field($model, 'category_id')->dropDownList($categories,['prompt' => ' ']) ?>
</div> </div>
</div> <div class="col-md-4">
<div class="row">
<div class="col-md-6">
<?= $form->field($model, 'district_id')->textInput() ?> <?= $form->field($model, 'district_id')->dropDownList($districts,['prompt' => ' '])?>
</div> </div>
</div> </div>
<div class="row"> <div class="row">
<div class="col-md-6"> <div class="col-md-4">
<?= $form->field($model, 'domain_name')->textInput(['maxlength' => true]) ?> <?= $form->field($model, 'domain_name')->textInput(['maxlength' => true]) ?>
</div> </div>
</div> </div>
<div class="row"> <div class="row">
<div class="col-md-6"> <div class="col-md-4">
<?= $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-4">
<?= $form->field($model, 'slug')->textInput(['maxlength' => true]) ?> <?= $form->field($model, 'slug')
->hint(Yii::t('backend',
'If you\'ll leave this field empty, slug will be generated automatically'))
->textInput(['maxlength' => true]) ?>
</div> </div>
</div> </div>
<div class="row"> <div class="row">
<div class="col-md-6"> <div class="col-md-4">
<?= $form->field($model, 'address')->textInput(['maxlength' => true]) ?> <?= $form->field($model, 'address')->textarea(['rows' => 6]) ?>
</div> </div>
</div> </div>
<div class="row"> <div class="row">
<div class="col-md-6"> <div class="col-md-4">
<?= $form->field($model, 'landmark')->textInput(['maxlength' => true]) ?> <?= $form->field($model, 'landmark')->textInput(['maxlength' => true]) ?>
</div> </div>
</div> </div>
<div class="row"> <div class="row">
<div class="col-md-6"> <div class="col-md-4">
<?= $form->field($model, 'mobile_no')->textInput(['maxlength' => true]) ?> <?= $form->field($model, 'mobile_no')->textInput(['maxlength' => true]) ?>
</div> </div>
</div> </div>
<div class="row"> <div class="row">
<div class="col-md-6"> <div class="col-md-4">
<?= $form->field($model, 'toll_free_no')->textInput(['maxlength' => true]) ?> <?= $form->field($model, 'toll_free_no')->textInput(['maxlength' => true]) ?>
</div> </div>
</div> </div>
<div class="row"> <div class="row">
<div class="col-md-6"> <div class="col-md-4">
<?= $form->field($model, 'contact_no')->textInput(['maxlength' => true]) ?> <?= $form->field($model, 'contact_no')->textInput(['maxlength' => true]) ?>
</div> </div>
</div> </div>
<div class="row"> <div class="row">
<div class="col-md-6"> <div class="col-md-4">
<?= $form->field($model, 'fax')->textInput(['maxlength' => true]) ?> <?= $form->field($model, 'fax')->textInput(['maxlength' => true]) ?>
</div> </div>
</div> </div>
<div class="row"> <div class="row">
<div class="col-md-6"> <div class="col-md-4">
<?= $form->field($model, 'email')->textInput(['maxlength' => true]) ?> <?= $form->field($model, 'email')->textInput(['maxlength' => true]) ?>
</div> </div>
</div> </div>
<div class="row"> <div class="row">
<div class="col-md-6"> <div class="col-md-4">
<?= $form->field($model, 'description')->textarea(['rows' => 6]) ?> <?= $form->field($model, 'description')->textarea(['rows' => 6]) ?>
</div> </div>
</div> </div>
<div class="row"> <div class="row">
<div class="col-md-6"> <div class="col-md-4">
<?= $form->field($model, 'logo_base_url')->textInput(['maxlength' => true]) ?> <?= $form->field($model, 'logo_base_url')->textInput(['maxlength' => true]) ?>
</div> </div>
</div> </div>
<div class="row"> <div class="row">
<div class="col-md-6"> <div class="col-md-4">
<?= $form->field($model, 'logo_path')->textInput(['maxlength' => true]) ?> <?= $form->field($model, 'logo_path')->textInput(['maxlength' => true]) ?>
...@@ -124,21 +123,23 @@ use yii\widgets\ActiveForm; ...@@ -124,21 +123,23 @@ use yii\widgets\ActiveForm;
</div> </div>
<div class="row"> <div class="row">
<div class="col-md-6"> <div class="col-md-6">
<?= $form->field($model, 'latitude')->textInput(['maxlength' => true]) ?>
</div> </div>
</div> </div>
<div class="row"> <div class="row">
<div class="col-md-6"> <div class="col-md-10">
<div id="myMap" style="height: 350px;width: 680px"></div>
<?= $form->field($model, 'logitude')->textInput(['maxlength' => true]) ?>
</div> </div>
</div> </div>
<div class="row"> <div class="row">
<div class="col-md-3"> <div class="col-md-4">
<?php echo $form->field($model, 'latitude')->textInput([['maxlength' => true]]) ?>
</div>
<div class="col-md-4">
<?php echo $form->field($model, 'logitude')->textInput(['maxlength' => true]) ?>
</div>
</div>
<div class="row">
<div class="col-md-4">
<?= $form->field($model, 'status')->dropDownList($model::statuses()) ?> <?= $form->field($model, 'status')->dropDownList($model::statuses()) ?>
</div> </div>
</div> </div>
...@@ -146,9 +147,6 @@ use yii\widgets\ActiveForm; ...@@ -146,9 +147,6 @@ use yii\widgets\ActiveForm;
<?= Html::submitButton($model->isNewRecord ? Yii::t('backend', 'Create') : Yii::t('backend', <?= 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>
<?php ActiveForm::end(); ?> <?php ActiveForm::end(); ?>
......
...@@ -5,6 +5,8 @@ use yii\helpers\Html; ...@@ -5,6 +5,8 @@ use yii\helpers\Html;
/* @var $this yii\web\View */ /* @var $this yii\web\View */
/* @var $model common\models\Business */ /* @var $model common\models\Business */
/* @var $categories array */
/* @var $districts array */
$this->title = Yii::t('backend', 'Create Business'); $this->title = Yii::t('backend', 'Create Business');
$this->params['breadcrumbs'][] = ['label' => Yii::t('backend', 'Businesses'), 'url' => ['index']]; $this->params['breadcrumbs'][] = ['label' => Yii::t('backend', 'Businesses'), 'url' => ['index']];
...@@ -15,6 +17,8 @@ $this->params['breadcrumbs'][] = $this->title; ...@@ -15,6 +17,8 @@ $this->params['breadcrumbs'][] = $this->title;
<?= $this->render('_form', [ <?= $this->render('_form', [
'model' => $model, 'model' => $model,
'categories' => $categories,
'districts' => $districts,
]) ?> ]) ?>
</div> </div>
...@@ -6,6 +6,8 @@ use yii\grid\GridView; ...@@ -6,6 +6,8 @@ use yii\grid\GridView;
/* @var $this yii\web\View */ /* @var $this yii\web\View */
/* @var $searchModel backend\modules\business\models\search\BusinessSearch */ /* @var $searchModel backend\modules\business\models\search\BusinessSearch */
/* @var $dataProvider yii\data\ActiveDataProvider */ /* @var $dataProvider yii\data\ActiveDataProvider */
/* @var $districts array */
/* @var $categories array */
$this->title = Yii::t('backend', 'Businesses'); $this->title = Yii::t('backend', 'Businesses');
$this->params['breadcrumbs'][] = $this->title; $this->params['breadcrumbs'][] = $this->title;
...@@ -25,8 +27,22 @@ $this->params['breadcrumbs'][] = $this->title; ...@@ -25,8 +27,22 @@ $this->params['breadcrumbs'][] = $this->title;
['class' => 'yii\grid\SerialColumn'], ['class' => 'yii\grid\SerialColumn'],
//'id', //'id',
'category_id', [
'district_id', 'attribute' => 'category_id',
'value' => function ($model) {
return $model->category->name;
},
'filter' => Html::activeDropDownList($searchModel, 'category_id',
$categories, ['class' => 'form-control', 'prompt' => ' ']),
],
[
'attribute' => 'district_id',
'value' => function ($model) {
return $model->category->name;
},
'filter' => Html::activeDropDownList($searchModel, 'district_id',
$districts, ['class' => 'form-control', 'prompt' => ' ']),
],
'domain_name', 'domain_name',
'name', 'name',
// 'slug', // 'slug',
...@@ -37,17 +53,26 @@ $this->params['breadcrumbs'][] = $this->title; ...@@ -37,17 +53,26 @@ $this->params['breadcrumbs'][] = $this->title;
// 'contact_no', // 'contact_no',
// 'fax', // 'fax',
// 'email:email', // 'email:email',
// 'description:ntext', 'description:ntext',
// 'logo_base_url:url', // 'logo_base_url:url',
// 'logo_path', // 'logo_path',
// 'latitude', // 'latitude',
// 'logitude', // 'logitude',
// 'status', [
'class' => \common\grid\EnumColumn::className(),
'attribute' => 'status',
'enum' => [
Yii::t('backend', 'In Active'),
Yii::t('backend', 'Active')
],
],
// 'created_at', // 'created_at',
// 'updated_at', // 'updated_at',
['class' => 'yii\grid\ActionColumn', [
'template' => '{update}{delete}'], 'class' => 'yii\grid\ActionColumn',
'template' => '{update}{delete}'
],
], ],
]); ?> ]); ?>
</div> </div>
...@@ -4,6 +4,8 @@ use yii\helpers\Html; ...@@ -4,6 +4,8 @@ use yii\helpers\Html;
/* @var $this yii\web\View */ /* @var $this yii\web\View */
/* @var $model common\models\Business */ /* @var $model common\models\Business */
/* @var $categories array */
/* @var $districts array */
$this->title = Yii::t('backend', 'Update {modelClass}: ', [ $this->title = Yii::t('backend', 'Update {modelClass}: ', [
'modelClass' => 'Business', 'modelClass' => 'Business',
...@@ -18,6 +20,8 @@ $this->params['breadcrumbs'][] = Yii::t('backend', 'Update'); ...@@ -18,6 +20,8 @@ $this->params['breadcrumbs'][] = Yii::t('backend', 'Update');
<?= $this->render('_form', [ <?= $this->render('_form', [
'model' => $model, 'model' => $model,
'categories' => $categories,
'districts' => $districts,
]) ?> ]) ?>
</div> </div>
...@@ -39,10 +39,11 @@ class DistrictController extends Controller ...@@ -39,10 +39,11 @@ class DistrictController extends Controller
{ {
$searchModel = new DistrictSearch(); $searchModel = new DistrictSearch();
$dataProvider = $searchModel->search(Yii::$app->request->queryParams); $dataProvider = $searchModel->search(Yii::$app->request->queryParams);
$states = ArrayHelper::map(State::find()->all(), 'id', 'name');
return $this->render('index', [ return $this->render('index', [
'searchModel' => $searchModel, 'searchModel' => $searchModel,
'dataProvider' => $dataProvider, 'dataProvider' => $dataProvider,
'states' => $states,
]); ]);
} }
......
...@@ -18,8 +18,8 @@ class DistrictSearch extends District ...@@ -18,8 +18,8 @@ class DistrictSearch extends District
public function rules() public function rules()
{ {
return [ return [
[['id', 'state_id', 'status', 'created_at', 'updated_at'], 'integer'], [['id', 'status', 'created_at', 'updated_at'], 'integer'],
[['name', 'slug'], 'safe'], [['name', 'state_id', 'slug'], 'safe'],
]; ];
} }
......
...@@ -16,7 +16,7 @@ use yii\widgets\ActiveForm; ...@@ -16,7 +16,7 @@ use yii\widgets\ActiveForm;
<div class="row"> <div class="row">
<div class="col-md-3"> <div class="col-md-3">
<?= $form->field($model, 'state_id')->dropDownList($states) ?> <?= $form->field($model, 'state_id')->dropDownList($states,['prompt' => ' ']) ?>
</div> </div>
</div> </div>
...@@ -30,7 +30,9 @@ use yii\widgets\ActiveForm; ...@@ -30,7 +30,9 @@ use yii\widgets\ActiveForm;
<div class="row"> <div class="row">
<div class="col-md-3"> <div class="col-md-3">
<?= $form->field($model, 'slug')->textInput(['maxlength' => true]) ?> <?= $form->field($model, 'slug')
->hint(Yii::t('backend', 'If you\'ll leave this field empty, slug will be generated automatically'))
->textInput(['maxlength' => true]) ?>
</div> </div>
</div> </div>
......
...@@ -6,6 +6,7 @@ use yii\grid\GridView; ...@@ -6,6 +6,7 @@ use yii\grid\GridView;
/* @var $this yii\web\View */ /* @var $this yii\web\View */
/* @var $searchModel backend\modules\location\models\search\DistrictSearch */ /* @var $searchModel backend\modules\location\models\search\DistrictSearch */
/* @var $dataProvider yii\data\ActiveDataProvider */ /* @var $dataProvider yii\data\ActiveDataProvider */
/* @var $states array */
$this->title = Yii::t('backend', 'Districts'); $this->title = Yii::t('backend', 'Districts');
$this->params['breadcrumbs'][] = $this->title; $this->params['breadcrumbs'][] = $this->title;
...@@ -25,22 +26,34 @@ $this->params['breadcrumbs'][] = $this->title; ...@@ -25,22 +26,34 @@ $this->params['breadcrumbs'][] = $this->title;
['class' => 'yii\grid\SerialColumn'], ['class' => 'yii\grid\SerialColumn'],
//'id', //'id',
'state_id',
'name', 'name',
'slug',
[ [
'class'=>\common\grid\EnumColumn::className(), 'attribute' => 'state_id',
'attribute'=>'status', 'value' => function ($model) {
'enum'=>[ return $model->state->name;
},
'filter' => Html::activeDropDownList($searchModel, 'state_id',
$states, ['class' => 'form-control', 'prompt' => ' ']),
],
[
'class' => \common\grid\EnumColumn::className(),
'attribute' => 'status',
'enum' => [
Yii::t('backend', 'In Active'), Yii::t('backend', 'In Active'),
Yii::t('backend', 'Active') Yii::t('backend', 'Active')
], ],
], ],
// 'created_at', ['attribute' => 'created_at',
'format' => ['date', 'php:d-m-Y'],
'filter' => false
],
//'created_at:datetime',
// 'updated_at', // 'updated_at',
['class' => 'yii\grid\ActionColumn', [
'template' => '{update}{delete}'], 'class' => 'yii\grid\ActionColumn',
'template' => '{update}{delete}'
],
], ],
]); ?> ]); ?>
</div> </div>
...@@ -22,7 +22,9 @@ use yii\widgets\ActiveForm; ...@@ -22,7 +22,9 @@ use yii\widgets\ActiveForm;
<div class="row"> <div class="row">
<div class="col-md-3"> <div class="col-md-3">
<?= $form->field($model, 'slug')->textInput(['maxlength' => true]) ?> <?= $form->field($model, 'slug')
->hint(Yii::t('backend', 'If you\'ll leave this field empty, slug will be generated automatically'))
->textInput(['maxlength' => true]) ?>
</div> </div>
</div> </div>
......
...@@ -28,7 +28,6 @@ $this->params['breadcrumbs'][] = $this->title; ...@@ -28,7 +28,6 @@ $this->params['breadcrumbs'][] = $this->title;
//'id', //'id',
'name', 'name',
'slug',
[ [
'class'=>\common\grid\EnumColumn::className(), 'class'=>\common\grid\EnumColumn::className(),
'attribute'=>'status', 'attribute'=>'status',
...@@ -37,7 +36,10 @@ $this->params['breadcrumbs'][] = $this->title; ...@@ -37,7 +36,10 @@ $this->params['breadcrumbs'][] = $this->title;
Yii::t('backend', 'Active') Yii::t('backend', 'Active')
], ],
], ],
//'created_at', ['attribute' => 'created_at',
'format' => ['date', 'php:d-m-Y'],
'filter' => false
],
// 'updated_at', // 'updated_at',
['class' => 'yii\grid\ActionColumn', ['class' => 'yii\grid\ActionColumn',
......
...@@ -29,7 +29,7 @@ class m160831_092919_business extends Migration ...@@ -29,7 +29,7 @@ class m160831_092919_business extends Migration
'logo_base_url' => $this->string(1024), 'logo_base_url' => $this->string(1024),
'logo_path' => $this->string(1024), 'logo_path' => $this->string(1024),
'latitude' => $this->string(30), 'latitude' => $this->string(30),
'logitude' => $this->string(30), 'longitude' => $this->string(30),
'status' => $this->smallInteger(6), 'status' => $this->smallInteger(6),
'created_at' => $this->integer(11), 'created_at' => $this->integer(11),
'updated_at' => $this->integer(11), 'updated_at' => $this->integer(11),
......
...@@ -91,8 +91,8 @@ class Business extends \yii\db\ActiveRecord ...@@ -91,8 +91,8 @@ class Business extends \yii\db\ActiveRecord
{ {
return [ return [
'id' => Yii::t('common', 'ID'), 'id' => Yii::t('common', 'ID'),
'category_id' => Yii::t('common', 'Category ID'), 'category_id' => Yii::t('common', 'Category'),
'district_id' => Yii::t('common', 'District ID'), 'district_id' => Yii::t('common', 'District'),
'domain_name' => Yii::t('common', 'Domain Name'), 'domain_name' => Yii::t('common', 'Domain Name'),
'name' => Yii::t('common', 'Name'), 'name' => Yii::t('common', 'Name'),
'slug' => Yii::t('common', 'Slug'), 'slug' => Yii::t('common', 'Slug'),
......
...@@ -47,7 +47,8 @@ ...@@ -47,7 +47,8 @@
"bower-asset/html5shiv": "^3.0", "bower-asset/html5shiv": "^3.0",
"bower-asset/jquery-slimscroll": "^1.3", "bower-asset/jquery-slimscroll": "^1.3",
"bower-asset/flot": "^0.8", "bower-asset/flot": "^0.8",
"symfony/process": "^3.0" "symfony/process": "^3.0",
"petrabarus/yii2-googleplacesautocomplete": "dev-master"
}, },
"require-dev": { "require-dev": {
"yiisoft/yii2-debug": "^2.0.0", "yiisoft/yii2-debug": "^2.0.0",
...@@ -58,6 +59,8 @@ ...@@ -58,6 +59,8 @@
"codeception/specify": "^0.4.3", "codeception/specify": "^0.4.3",
"codeception/verify": "^0.3.0" "codeception/verify": "^0.3.0"
}, },
"minimum-stability": "dev",
"opauth/openid": "dev-master",
"suggest": { "suggest": {
"trntv/yii2-debug-xhprof": "dev-master@dev" "trntv/yii2-debug-xhprof": "dev-master@dev"
}, },
......
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