Commit 0a66f601 by Junaid Rahman pv

modified state,district and business module

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