Commit 8234a7dc by jomon

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

parents b17cfd31 9defc564
...@@ -45,3 +45,5 @@ FACEBOOK_CLIENT_SECRET = your-client-secret ...@@ -45,3 +45,5 @@ FACEBOOK_CLIENT_SECRET = your-client-secret
GLIDE_SIGN_KEY = <generated_key> GLIDE_SIGN_KEY = <generated_key>
GLIDE_MAX_IMAGE_SIZE = 4000000 GLIDE_MAX_IMAGE_SIZE = 4000000
GOOGLE_API_KEY = AIzaSyBcXUZ8SohRQzKnY4iYaa5_B2ix0b_OY9g
...@@ -37,3 +37,5 @@ GITHUB_CLIENT_SECRET = your-client-secret ...@@ -37,3 +37,5 @@ GITHUB_CLIENT_SECRET = your-client-secret
GLIDE_SIGN_KEY = <generated_key> GLIDE_SIGN_KEY = <generated_key>
GLIDE_MAX_IMAGE_SIZE = 4000000 GLIDE_MAX_IMAGE_SIZE = 4000000
GOOGLE_API_KEY = AIzaSyBcXUZ8SohRQzKnY4iYaa5_B2ix0b_OY9g
...@@ -46,6 +46,9 @@ $config = [ ...@@ -46,6 +46,9 @@ $config = [
], ],
'location' => [ 'location' => [
'class' => 'backend\modules\location\Module', 'class' => 'backend\modules\location\Module',
],
'website' => [
'class' => 'backend\modules\website\Module',
] ]
], ],
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
use yii\helpers\Html; use yii\helpers\Html;
use yii\widgets\ActiveForm; use yii\widgets\ActiveForm;
use common\widgets\PlacePicker; use common\widgets\PlacePicker\PlacePicker;
/* @var $this yii\web\View */ /* @var $this yii\web\View */
/* @var $model common\models\Business */ /* @var $model common\models\Business */
...@@ -104,7 +104,7 @@ use common\widgets\PlacePicker; ...@@ -104,7 +104,7 @@ use common\widgets\PlacePicker;
'pasteCallback' => new \yii\web\JsExpression("function(html){ return this.clean.getPlainText(html) ;}") 'pasteCallback' => new \yii\web\JsExpression("function(html){ return this.clean.getPlainText(html) ;}")
] ]
] ]
) ?> ) ?>
</div> </div>
</div> </div>
...@@ -126,27 +126,40 @@ use common\widgets\PlacePicker; ...@@ -126,27 +126,40 @@ use common\widgets\PlacePicker;
<div class="row"> <div class="row">
<div class="col-md-8"> <div class="col-md-8">
<?= PlacePicker::widget(['model' => $model, 'name' => 'map', 'lat' => 'latitude', 'lon' => 'longitude']) ?> <?= PlacePicker::widget([
'model' => $model,
'name' => 'map',
'latitudeFieldId' => 'latitude',
'longitudeFieldId' => 'longitude'
]) ?>
</div> </div>
</div> </div>
<div class="row"> <div class="row">
<div class="col-md-4"> <div class="col-md-4">
<?= $form->field($model, 'latitude')->textInput(['maxlength' => true, 'id' => 'latitude']) ?> <?= $form->field($model, 'latitude')->textInput(['maxlength' => true, 'id' => 'latitude']) ?>
</div> </div>
<div class="col-md-4"> <div class="col-md-4">
<?= $form->field($model, 'longitude')->textInput(['maxlength' => true, 'id' => 'longitude']) ?> <?= $form->field($model, 'longitude')->textInput(['maxlength' => true, 'id' => 'longitude']) ?>
</div> </div>
</div> </div>
<div class="row"> <div class="row">
<div class="col-md-4"> <div class="col-md-4">
<?= $form->field($model, 'status')->dropDownList($model::statuses()) ?> <?= $form->field($model, 'status')->dropDownList($model::statuses()) ?>
</div> </div>
</div> </div>
<div class="form-group"> <div class="form-group">
<?= 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>
<?php ActiveForm::end(); ?> <?php ActiveForm::end(); ?>
......
<?php
namespace backend\modules\website;
/**
* website module definition class
*/
class Module extends \yii\base\Module
{
/**
* @inheritdoc
*/
public $controllerNamespace = 'backend\modules\website\controllers';
/**
* @inheritdoc
*/
public function init()
{
parent::init();
// custom initialization code goes here
}
}
<?php
namespace backend\modules\website\controllers;
use yii\web\Controller;
/**
* Default controller for the `website` module
*/
class DefaultController extends Controller
{
/**
* Renders the index view for the module
* @return string
*/
public function actionIndex()
{
return $this->render('index');
}
}
<?php
namespace backend\modules\website\controllers;
use Yii;
use common\models\website;
use backend\modules\website\models\search\WebsiteSearch;
use yii\web\Controller;
use yii\web\NotFoundHttpException;
use yii\filters\VerbFilter;
/**
* WebsiteController implements the CRUD actions for website model.
*/
class WebsiteController extends Controller
{
public function behaviors()
{
return [
'verbs' => [
'class' => VerbFilter::className(),
'actions' => [
'delete' => ['post'],
],
],
];
}
/**
* Lists all website models.
* @return mixed
*/
public function actionIndex()
{
$searchModel = new WebsiteSearch();
$dataProvider = $searchModel->search(Yii::$app->request->queryParams);
return $this->render('index', [
'searchModel' => $searchModel,
'dataProvider' => $dataProvider,
]);
}
/**
* Displays a single website model.
* @param integer $id
* @return mixed
*/
public function actionView($id)
{
return $this->render('view', [
'model' => $this->findModel($id),
]);
}
/**
* Creates a new website model.
* If creation is successful, the browser will be redirected to the 'view' page.
* @return mixed
*/
public function actionCreate()
{
$model = new website();
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 website 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);
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 website 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 website model based on its primary key value.
* If the model is not found, a 404 HTTP exception will be thrown.
* @param integer $id
* @return website the loaded model
* @throws NotFoundHttpException if the model cannot be found
*/
protected function findModel($id)
{
if (($model = website::findOne($id)) !== null) {
return $model;
} else {
throw new NotFoundHttpException('The requested page does not exist.');
}
}
}
<?php
namespace backend\modules\website\models\search;
use Yii;
use yii\base\Model;
use yii\data\ActiveDataProvider;
use common\models\website;
/**
* WebsiteSearch represents the model behind the search form about `common\models\website`.
*/
class WebsiteSearch extends website
{
/**
* @inheritdoc
*/
public function rules()
{
return [
[['id', 'business_id', 'theme_id', 'status', 'expiry_date', 'created_at', 'updated_at'], 'integer'],
[['domain_name'], 'safe'],
];
}
/**
* @inheritdoc
*/
public function scenarios()
{
// bypass scenarios() implementation in the parent class
return Model::scenarios();
}
/**
* Creates data provider instance with search query applied
*
* @param array $params
*
* @return ActiveDataProvider
*/
public function search($params)
{
$query = website::find();
$dataProvider = new ActiveDataProvider([
'query' => $query,
]);
if (!($this->load($params) && $this->validate())) {
return $dataProvider;
}
$query->andFilterWhere([
'id' => $this->id,
'business_id' => $this->business_id,
'theme_id' => $this->theme_id,
'status' => $this->status,
'expiry_date' => $this->expiry_date,
'created_at' => $this->created_at,
'updated_at' => $this->updated_at,
]);
$query->andFilterWhere(['like', 'domain_name', $this->domain_name]);
return $dataProvider;
}
}
<div class="website-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>
<?php
use yii\helpers\Html;
use yii\bootstrap\ActiveForm;
/* @var $this yii\web\View */
/* @var $model common\models\website */
/* @var $form yii\bootstrap\ActiveForm */
?>
<div class="website-form">
<?php $form = ActiveForm::begin(); ?>
<?= $form->errorSummary($model); ?>
<div class="row">
<div class="col-md-4">
<?= $form->field($model, 'business_id')->textInput() ?>
</div>
</div>
<div class="row">
<div class="col-md-4">
<?= $form->field($model, 'theme_id')->textInput() ?>
</div>
</div>
<div class="row">
<div class="col-md-4">
<?= $form->field($model, 'domain_name')->textInput(['maxlength' => true]) ?>
</div>
</div>
<div class="row">
<div class="col-md-4">
<?= $form->field($model, 'status')->dropDownList($model::statuses()) ?>
</div>
</div>
<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']) ?>
</div>
<?php ActiveForm::end(); ?>
</div>
<?php
use yii\helpers\Html;
use yii\bootstrap\ActiveForm;
/* @var $this yii\web\View */
/* @var $model backend\modules\website\models\search\WebsiteSearch */
/* @var $form yii\bootstrap\ActiveForm */
?>
<div class="website-search">
<?php $form = ActiveForm::begin([
'action' => ['index'],
'method' => 'get',
]); ?>
<?= $form->field($model, 'id') ?>
<?= $form->field($model, 'business_id') ?>
<?= $form->field($model, 'theme_id') ?>
<?= $form->field($model, 'domain_name') ?>
<?= $form->field($model, 'status') ?>
<?php // echo $form->field($model, 'expiry_date') ?>
<?php // echo $form->field($model, 'created_at') ?>
<?php // echo $form->field($model, 'updated_at') ?>
<div class="form-group">
<?= Html::submitButton(Yii::t('backend', 'Search'), ['class' => 'btn btn-primary']) ?>
<?= Html::resetButton(Yii::t('backend', 'Reset'), ['class' => 'btn btn-default']) ?>
</div>
<?php ActiveForm::end(); ?>
</div>
<?php
use yii\helpers\Html;
/* @var $this yii\web\View */
/* @var $model common\models\website */
$this->title = Yii::t('backend', 'Create {modelClass}', [
'modelClass' => 'Website',
]);
$this->params['breadcrumbs'][] = ['label' => Yii::t('backend', 'Websites'), 'url' => ['index']];
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="website-create">
<?= $this->render('_form', [
'model' => $model,
]) ?>
</div>
<?php
use yii\helpers\Html;
use yii\grid\GridView;
/* @var $this yii\web\View */
/* @var $searchModel backend\modules\website\models\search\WebsiteSearch */
/* @var $dataProvider yii\data\ActiveDataProvider */
$this->title = Yii::t('backend', 'Websites');
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="website-index">
<?php // echo $this->render('_search', ['model' => $searchModel]); ?>
<p>
<?= Html::a(Yii::t('backend', 'Create {modelClass}', [
'modelClass' => 'Website',
]), ['create'], ['class' => 'btn btn-success']) ?>
</p>
<?= GridView::widget([
'dataProvider' => $dataProvider,
'filterModel' => $searchModel,
'columns' => [
['class' => 'yii\grid\SerialColumn'],
//'id',
'business_id',
'theme_id',
'domain_name',
[
'class'=>\common\grid\EnumColumn::className(),
'attribute'=>'status',
'enum'=>[
Yii::t('backend', 'In Active'),
Yii::t('backend', 'Active')
],
],
'expiry_date:datetime',
// 'created_at',
// 'updated_at',
['class' => 'yii\grid\ActionColumn',
'template' => '{update}{delete}'],
],
]); ?>
</div>
<?php
use yii\helpers\Html;
/* @var $this yii\web\View */
/* @var $model common\models\website */
$this->title = Yii::t('backend', 'Update {modelClass}: ', [
'modelClass' => 'Website',
]) . ' ' . $model->id;
$this->params['breadcrumbs'][] = ['label' => Yii::t('backend', 'Websites'), 'url' => ['index']];
$this->params['breadcrumbs'][] = ['label' => $model->id, 'url' => ['view', 'id' => $model->id]];
$this->params['breadcrumbs'][] = Yii::t('backend', 'Update');
?>
<div class="website-update">
<?= $this->render('_form', [
'model' => $model,
]) ?>
</div>
<?php
use yii\helpers\Html;
use yii\widgets\DetailView;
/* @var $this yii\web\View */
/* @var $model common\models\website */
$this->title = $model->id;
$this->params['breadcrumbs'][] = ['label' => Yii::t('backend', 'Websites'), 'url' => ['index']];
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="website-view">
<p>
<?= Html::a(Yii::t('backend', 'Update'), ['update', 'id' => $model->id], ['class' => 'btn btn-primary']) ?>
<?= Html::a(Yii::t('backend', 'Delete'), ['delete', 'id' => $model->id], [
'class' => 'btn btn-danger',
'data' => [
'confirm' => Yii::t('backend', 'Are you sure you want to delete this item?'),
'method' => 'post',
],
]) ?>
</p>
<?= DetailView::widget([
'model' => $model,
'attributes' => [
'id',
'business_id',
'theme_id',
'domain_name',
'status',
'expiry_date',
'created_at',
'updated_at',
],
]) ?>
</div>
...@@ -208,6 +208,12 @@ $bundle = BackendAsset::register($this); ...@@ -208,6 +208,12 @@ $bundle = BackendAsset::register($this);
'visible' => Yii::$app->user->can('administrator') 'visible' => Yii::$app->user->can('administrator')
], ],
[ [
'label' => Yii::t('backend', 'Website'),
'icon' => '<i class="fa fa-globe"></i>',
'url' => ['/website/website'],
'visible' => Yii::$app->user->can('administrator')
],
[
'label' => Yii::t('backend', 'Location'), 'label' => Yii::t('backend', 'Location'),
'icon' => '<i class="fa fa-map"></i>', 'icon' => '<i class="fa fa-map"></i>',
'url' => '#', 'url' => '#',
......
...@@ -38,7 +38,8 @@ class m160831_092919_business extends Migration ...@@ -38,7 +38,8 @@ class m160831_092919_business extends Migration
$this->createIndex('idx_business_domain_name', '{{%business}}', 'domain_name'); $this->createIndex('idx_business_domain_name', '{{%business}}', 'domain_name');
$this->createIndex('idx_business_email', '{{%business}}', 'email'); $this->createIndex('idx_business_email', '{{%business}}', 'email');
$this->addForeignKey('fk_category_id', '{{%business}}', 'category_id', '{{%category}}', 'id', 'RESTRICT', 'RESTRICT'); $this->addForeignKey('fk_category_id', '{{%business}}', 'category_id', '{{%category}}', 'id', 'RESTRICT',
'RESTRICT');
$this->addForeignKey('fk_district_id', '{{%business}}', 'district_id', '{{%district}}', 'id', 'RESTRICT', 'RESTRICT'); $this->addForeignKey('fk_district_id', '{{%business}}', 'district_id', '{{%district}}', 'id', 'RESTRICT', 'RESTRICT');
} }
......
<?php
use yii\db\Migration;
class m160907_100248_website extends Migration
{
public function safeUp()
{
$tableOptions = null;
if ($this->db->driverName === 'mysql') {
$tableOptions = 'CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE=InnoDB';
}
$this->createTable('{{%website}}', [
'id' => $this->primaryKey(),
'business_id' => $this->integer(),
'theme_id' => $this->integer(),
'domain_name' => $this->string(255)->notNull(),
'status' => $this->smallInteger(6),
'expiry_date' => $this->integer(11),
'created_at' => $this->integer(11),
'updated_at' => $this->integer(11),
], $tableOptions);
$this->createIndex('idx_domain_name', '{{%website}}', 'domain_name');
$this->addForeignKey('fk_theme_id', '{{%website}}', 'theme_id', '{{%theme}}', 'id', 'RESTRICT',
'RESTRICT');
}
public function safeDown()
{
$this->dropForeignKey('fk_theme_id', '{{%website}}');
$this->dropIndex('idx_domain_name', '{{%website}}');
$this->dropTable('{{%website}}');
}
}
<?php
namespace common\models;
use Yii;
use yii\behaviors\TimestampBehavior;
/**
* This is the model class for table "{{%website}}".
*
* @property integer $id
* @property integer $business_id
* @property integer $theme_id
* @property string $domain_name
* @property integer $status
* @property integer $expiry_date
* @property integer $created_at
* @property integer $updated_at
*
* @property Theme $theme
*/
class Website extends \yii\db\ActiveRecord
{
const STATUS_ACTIVE = 1;
const STATUS_IN_ACTIVE = 0;
/**
* @inheritdoc
*/
public static function tableName()
{
return '{{%website}}';
}
public function behaviors()
{
return [
[
'class' => TimestampBehavior::className(),
'createdAtAttribute' => 'created_at',
'updatedAtAttribute' => 'updated_at'
]
];
}
/**
* @inheritdoc
*/
public function rules()
{
return [
[['business_id', 'theme_id', 'status', 'expiry_date', 'created_at', 'updated_at'], 'integer'],
[['domain_name'], 'required'],
[['domain_name'], 'string', 'max' => 255],
[['theme_id'], 'exist', 'skipOnError' => true, 'targetClass' => Theme::className(), 'targetAttribute' => ['theme_id' => 'id']],
];
}
/**
* @inheritdoc
*/
public function attributeLabels()
{
return [
'id' => Yii::t('common', 'ID'),
'business_id' => Yii::t('common', 'Business ID'),
'theme_id' => Yii::t('common', 'Theme ID'),
'domain_name' => Yii::t('common', 'Domain Name'),
'status' => Yii::t('common', 'Status'),
'expiry_date' => Yii::t('common', 'Expiry Date'),
'created_at' => Yii::t('common', 'Created At'),
'updated_at' => Yii::t('common', 'Updated At'),
];
}
/**
* @return \yii\db\ActiveQuery
*/
public function getTheme()
{
return $this->hasOne(Theme::className(), ['id' => 'theme_id']);
}
/**
* @inheritdoc
* @return \common\models\query\WebsiteQuery the active query used by this AR class.
*/
public static function find()
{
return new \common\models\query\WebsiteQuery(get_called_class());
}
/**
* @return array
* status drop down list used in view
*/
public static function statuses()
{
return [
self::STATUS_ACTIVE => Yii::t('common', 'Active'),
self::STATUS_IN_ACTIVE => Yii::t('common', 'In Active'),
];
}
}
<?php
namespace common\models\query;
/**
* This is the ActiveQuery class for [[\common\models\Website]].
*
* @see \common\models\Website
*/
class WebsiteQuery extends \yii\db\ActiveQuery
{
/*public function active()
{
return $this->andWhere('[[status]]=1');
}*/
/**
* @inheritdoc
* @return \common\models\Website[]|array
*/
public function all($db = null)
{
return parent::all($db);
}
/**
* @inheritdoc
* @return \common\models\Website|array|null
*/
public function one($db = null)
{
return parent::one($db);
}
}
<?php
/**
* Author: Junaid Rahman <junaid.entero@gmail.com>
*/
namespace common\widgets\PlacePicker;
use yii\web\AssetBundle;
use yii\web\View;
class MapAsset extends AssetBundle
{
public $css = [
];
public $js = [
'http://ajax.googleapis.com/ajax/libs/jquery/1.10.1/jquery.min.js'
];
public $depends = [
'yii\web\JqueryAsset',
];
public $key = [
];
public $jsOptions = [
['position' => View::POS_HEAD]
];
public function init()
{
$this->sourcePath = __DIR__."/assets";
parent::init();
$this->js = [
'js/map-kit.js',
'https://maps.googleapis.com/maps/api/js?key=AIzaSyBcXUZ8SohRQzKnY4iYaa5_B2ix0b_OY9g&libraries=places',
];
}
}
<?php
namespace common\widgets\PlacePicker;
use yii\widgets\InputWidget;
use yii\helpers\Html;
use yii\helpers\Json;
use yii\helpers\ArrayHelper;
/*
* this widget can be used when a user have to tel his location details,
* this widget will display the google map and it provides search place option
*/
class PlacePicker extends InputWidget
{
/*
* @var string , variable to store the id of latitude input field
*/
public $latitudeFieldId;
/*
* @var string , variable to store the id of longitude input field
*/
public $longitudeFieldId;
/*
* @var string , variable to store the name of map canvas input field
*/
public $name;
/*
* array, which binds all client options in to single array
*/
public $clientOptions = [];
/*
* @var num, this variable is used to generate random number
* which can be used for generating unique place search field
*/
public $randNumber;
public function init()
{
MapAsset::register($this->view);
parent::init();
$randNumber = rand(1, 100);
$this->clientOptions = ArrayHelper::merge(
[
'latitudeFieldId' => $this->latitudeFieldId,
'longitudeFieldId' => $this->longitudeFieldId,
'mapName' => $this->name,
'searchTextField' => 'searchTextField' . $randNumber
],
$this->clientOptions
);
$options = Json::encode($this->clientOptions);
$this->getView()->registerJs("jQuery('#{$this->getId()}').yiiMapKit({$options});");
}
public function run()
{
echo Html::tag('br');
echo Html::textInput('Address', '',
['id' => $this->clientOptions['searchTextField'], 'class' => 'form-control', 'style' => 'width:90%;']);
echo Html::tag('br');
echo Html::beginTag('div', [
'id' => $this->clientOptions['mapName'],
'style' => 'height: 450px;width: 100%;margin: 0.6em;box-shadow: 5px 5px 5px #888888;'
]);
echo Html::endTag('div');
}
}
?>
\ No newline at end of file
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