Commit 5975a46b by Junaid Rahman pv

bug fixing

parent 73551b51
......@@ -4,6 +4,7 @@ use yii\helpers\Html;
use yii\widgets\ActiveForm;
use common\widgets\PlacePicker\PlacePicker;
use trntv\filekit\widget\Upload;
use yii\web\JsExpression;
/* @var $this yii\web\View */
/* @var $model common\models\Business */
......@@ -117,6 +118,7 @@ use trntv\filekit\widget\Upload;
[
'url' => ['/file-storage/upload'],
'maxFileSize' => 5000000, // 5 MiB
'acceptFileTypes' => new JsExpression('/(\.|\/)(gif|jpe?g|png)$/i'),
]);
?>
......
......@@ -43,7 +43,7 @@ $this->params['breadcrumbs'][] = $this->title;
// 'updated_at',
['class' => 'yii\grid\ActionColumn',
'template' => '{update}{delete}'],
'template' => '{update} {delete}'],
],
]); ?>
......
......@@ -68,8 +68,17 @@ class CategoryController extends Controller
$model = new Category();
$model->status = $model::STATUS_ACTIVE;
if ($model->load(Yii::$app->request->post()) && $model->save()) {
return $this->redirect(['view', 'id' => $model->id]);
if ($model->load(Yii::$app->request->post()) && $model->save() ) {
Yii::$app->getSession()->setFlash('success', [
'type' => 'success',
'duration' => 5000,
'icon' => 'fa fa-envira',
'message' => 'New Theme Category Created! ',
'title' => 'Category',
'positonY' => 'top',
'positonX' => 'right'
]);
return $this->redirect(['files', 'id' => $model->id]);
}
return $this->render('create', [
......@@ -89,7 +98,7 @@ class CategoryController extends Controller
$model = $this->findModel($id);
if ($model->load(Yii::$app->request->post()) && $model->save()) {
if ($model->load(Yii::$app->request->post()) && $model->save() && $model->validate()) {
return $this->redirect(['view', 'id' => $model->id]);
}
......@@ -150,8 +159,15 @@ class CategoryController extends Controller
if ($flag) {
$transaction->commit();
return $this->redirect(['index']);
Yii::$app->getSession()->setFlash('success', [
'type' => 'success',
'duration' => 5000,
'icon' => 'fa fa-file',
'message' => 'New File is added to Category Files list! ',
'title' => 'Category Files',
'positonY' => 'top',
'positonX' => 'right'
]);
}
} catch (Exception $e) {
$transaction->rollBack();
......
......@@ -3,6 +3,7 @@
use yii\helpers\Html;
use yii\bootstrap\ActiveForm;
use trntv\filekit\widget\Upload;
use yii\web\JsExpression;
/* @var $this yii\web\View */
/* @var $model common\models\Category */
......@@ -11,7 +12,9 @@ use trntv\filekit\widget\Upload;
<div class="category-form">
<?php $form = ActiveForm::begin(); ?>
<?php $form = ActiveForm::begin([
'options' => ['enctype' => 'multipart/form-data',],
]); ?>
<div id="myTabContent" class="tab-content">
<div class="tab-pane fade in active" id="info">
......@@ -48,6 +51,9 @@ use trntv\filekit\widget\Upload;
Upload::className(),
[
'url' => ['/file-storage/upload'],
'sortable' => true,
'maxFileSize' => 10000000, // 10 MiB
'acceptFileTypes' => new JsExpression('/(\.|\/)(gif|jpe?g|png)$/i')
])->label('Image');
?>
......@@ -73,4 +79,4 @@ use trntv\filekit\widget\Upload;
<?php ActiveForm::end(); ?>
</div>
</div>
......@@ -43,8 +43,22 @@ $this->params['breadcrumbs'][] = $this->title;
'created_at:datetime',
// 'updated_at',
['class' => 'yii\grid\ActionColumn',
'template' => '{update} {delete}'],
[
'class' => 'yii\grid\ActionColumn',
'template' => '{update} {delete}',
'buttons' => [
'download' => function ($url) {
return Html::a(
'<span class="glyphicon glyphicon-arrow-download"></span>',
$url,
[
'title' => 'Download',
'data-pjax' => '0',
]
);
},
],
],
],
]); ?>
......
......@@ -9,6 +9,7 @@ use yii\helpers\ArrayHelper;
use yii\helpers\Html;
use yii\helpers\Url;
use yii\widgets\Breadcrumbs;
use kartik\growl\Growl;
$bundle = BackendAsset::register($this);
?>
......@@ -203,7 +204,7 @@ $bundle = BackendAsset::register($this);
],
[
'label' => Yii::t('backend', 'Theme'),
'icon' => '<i class="fa fa-sitemap"></i>',
'icon' => '<i class="fa fa-envira"></i>',
'url' => ['/theme/theme/index'],
'visible' => Yii::$app->user->can('administrator')
],
......@@ -337,6 +338,25 @@ $bundle = BackendAsset::register($this);
'options' => ArrayHelper::getValue(Yii::$app->session->getFlash('alert'), 'options'),
]) ?>
<?php endif; ?>
<!-- //Get all flash messages and loop through them-->
<?php foreach (Yii::$app->session->getAllFlashes() as $message):; ?>
<?= Growl::widget([
'type' => (!empty($message['type'])) ? $message['type'] : 'danger',
'title' => (!empty($message['title'])) ? Html::encode($message['title']) : 'Title Not Set!',
'icon' => (!empty($message['icon'])) ? $message['icon'] : 'fa fa-info',
'body' => (!empty($message['message'])) ? Html::encode($message['message']) : 'Message Not Set!',
'showSeparator' => true,
'delay' => 1, //This delay is how long before the message shows
'pluginOptions' => [
'delay' => (!empty($message['duration'])) ? $message['duration'] : 3000, //This delay is how long the message shows for
'placement' => [
'from' => (!empty($message['positonY'])) ? $message['positonY'] : 'top',
'align' => (!empty($message['positonX'])) ? $message['positonX'] : 'right',
]
]
]);
?>
<?php endforeach; ?>
<?= $content ?>
</section><!-- /.content -->
</aside><!-- /.right-side -->
......
......@@ -52,7 +52,7 @@ $this->params['breadcrumbs'][] = $this->title;
[
'class' => 'yii\grid\ActionColumn',
'template' => '{update}{delete}'
'template' => '{update} {delete}'
],
],
]); ?>
......
......@@ -105,6 +105,7 @@ class Business extends \yii\db\ActiveRecord
'targetClass' => District::className(),
'targetAttribute' => ['district_id' => 'id']
],
['logo', 'file', 'extensions' => 'jpeg, gif, png'],
];
}
......
......@@ -47,10 +47,18 @@ class Category extends \yii\db\ActiveRecord
return [
[['name', 'status'], 'required'],
[['status', 'created_at', 'updated_at'], 'integer'],
[['name', 'slug'], 'string', 'max' => 32],
[['name', 'slug'], 'string', 'length' => [1,32]],
[['name', 'slug'],'trim'],
[
['name', 'slug'],
'match',
'pattern' => '/^[a-zA-Z\s0-9_-]+$/',
'message' => 'only, alphanumeric characters, underscores and dashes are allowed.'
],
['name', 'unique'],
[['description'], 'string', 'max' => 512],
[['image_url', 'image_path'], 'string', 'max' => 1024],
[['image'], 'safe']
[['image'], 'safe'],
];
}
......@@ -96,6 +104,7 @@ class Category extends \yii\db\ActiveRecord
public static function getAllCategories()
{
$models = static::find()->active()->all();
return ArrayHelper::map(
$models,
'id',
......
......@@ -54,6 +54,13 @@ class State extends \yii\db\ActiveRecord
return [
[['name'], 'required'],
[['name'], 'unique'],
[['name', 'slug'],'trim'],
[
['name', 'slug'],
'match',
'pattern' => '/^[a-zA-Z\s0-9_-]+$/',
'message' => 'only, alphanumeric characters, underscores and dashes are allowed.'
],
[['status', 'created_at', 'updated_at'], 'integer'],
[['name', 'slug'], 'string', 'max' => 1024],
];
......
......@@ -58,6 +58,13 @@ class Theme extends \yii\db\ActiveRecord
return [
[['category_id', 'code', 'slug', 'name', 'status'], 'required'],
[['category_id', 'status', 'created_at', 'updated_at'], 'integer'],
[['name', 'slug', 'code'],'trim'],
[
['name', 'slug', 'code'],
'match',
'pattern' => '/^[a-zA-Z\s0-9_-]+$/',
'message' => 'only, alphanumeric characters, underscores and dashes are allowed.'
],
[['code', 'slug', 'name'], 'string', 'max' => 32],
[['description'], 'string', 'max' => 512],
[['category_id'], 'exist', 'skipOnError' => true, 'targetClass' => Category::className(), 'targetAttribute' => ['category_id' => 'id']],
......
......@@ -53,6 +53,11 @@ class Website extends \yii\db\ActiveRecord
[['domain_name'], 'required'],
[['domain_name'], 'string', 'max' => 255],
[
['domain_name'],
'match',
'pattern' => '/^[a-zA-Z0-9][a-zA-Z0-9-_]{0,61}[a-zA-Z0-9]{0,1}\.([a-zA-Z]{1,6}|[a-zA-Z0-9-]{1,30}\.[a-zA-Z]{2,3})$/'
],
[
['theme_id'],
'exist',
'skipOnError' => true,
......
......@@ -38,11 +38,14 @@ class SiteController extends Controller
$domain = $_SERVER['HTTP_HOST'];
$website = Website::find()->where(['domain_name' =>$domain])->one();
$businessId = $website->business_id;
if(isEmpty($businessId)){
$businessId = 3;
}
$client = new Client();
$response = $client->createRequest()
->setMethod('get')
->setUrl('http://libromi.com/api/v1/business/view')
->setData(['id' => $businessId])
->setData(['id' => 2])
->send();
$data = $response->isOk ? $response->data : [];
return $this->render('index', ['data' => $data]);
......
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