Commit 4994ab9ee16380b413a15b7c25aa72b98df07e6b

Authored by Eugeny Galkovskiy
1 parent 14955e34

150616

backend/controllers/OrdersController.php
@@ -8,7 +8,7 @@ use yii\web\Controller; @@ -8,7 +8,7 @@ use yii\web\Controller;
8 use yii\filters\VerbFilter; 8 use yii\filters\VerbFilter;
9 use yii\data\ActiveDataProvider; 9 use yii\data\ActiveDataProvider;
10 use yii\web\HttpException; 10 use yii\web\HttpException;
11 -use backend\models\Orders; 11 +use common\models\Orders;
12 use backend\models\OrdersProducts; 12 use backend\models\OrdersProducts;
13 use common\modules\product\models\ProductVariant; 13 use common\modules\product\models\ProductVariant;
14 use yii\web\NotFoundHttpException; 14 use yii\web\NotFoundHttpException;
@@ -93,7 +93,7 @@ class OrdersController extends Controller @@ -93,7 +93,7 @@ class OrdersController extends Controller
93 public function actionDelete(){ 93 public function actionDelete(){
94 $model = Orders::findOne($_GET['id']); 94 $model = Orders::findOne($_GET['id']);
95 $model->delete(); 95 $model->delete();
96 - return Yii::$app->response->redirect(['/admin/orders/index']); 96 + return Yii::$app->response->redirect(['/orders/index']);
97 } 97 }
98 98
99 99
@@ -115,12 +115,24 @@ class OrdersController extends Controller @@ -115,12 +115,24 @@ class OrdersController extends Controller
115 115
116 //return $this->render('add',['model'=>$model]); 116 //return $this->render('add',['model'=>$model]);
117 } 117 }
  118 +
  119 + public function actionCreate(){
  120 + $model = new Orders();
  121 +
  122 + if ($model->load(Yii::$app->request->post()) && $model->save()) {
  123 + return $this->redirect(['index']);
  124 + } else {
  125 + return $this->render('create', [
  126 + 'model' => $model,
  127 + ]);
  128 + }
  129 + }
118 130
119 public function actionDelete_product(){ 131 public function actionDelete_product(){
120 $model = OrdersProducts::findOne($_GET['id']); 132 $model = OrdersProducts::findOne($_GET['id']);
121 $model->delete(); 133 $model->delete();
122 return Yii::$app->response->redirect(['/admin/orders/show','id'=>$_GET['order_id']]); 134 return Yii::$app->response->redirect(['/admin/orders/show','id'=>$_GET['order_id']]);
123 - } 135 + }
124 136
125 protected function findModel($id) 137 protected function findModel($id)
126 { 138 {
backend/views/layouts/main-sidebar.php
@@ -5,6 +5,8 @@ use yii\widgets\Menu; @@ -5,6 +5,8 @@ use yii\widgets\Menu;
5 <!-- sidebar: style can be found in sidebar.less --> 5 <!-- sidebar: style can be found in sidebar.less -->
6 <section class="sidebar"> 6 <section class="sidebar">
7 <?php 7 <?php
  8 +//print_r($this->context->id);
  9 +// die();
8 10
9 $items = [ 11 $items = [
10 [ 12 [
@@ -17,6 +19,13 @@ use yii\widgets\Menu; @@ -17,6 +19,13 @@ use yii\widgets\Menu;
17 'label' => 'eCommerce', 19 'label' => 'eCommerce',
18 'template'=>'<a href="{url}"> <i class="glyphicon glyphicon-barcode"></i> <span>{label}</span></a>', 20 'template'=>'<a href="{url}"> <i class="glyphicon glyphicon-barcode"></i> <span>{label}</span></a>',
19 'url' => ['/product/manage'], 21 'url' => ['/product/manage'],
  22 + 'active' => preg_match('/^manage.*$/', $this->context->id) ||
  23 + preg_match('/^category.*$/', $this->context->id) ||
  24 + preg_match('/^brand.*$/', $this->context->id) ||
  25 + preg_match('/^product-unit.*$/', $this->context->id) ||
  26 + preg_match('/^import.*$/', $this->context->id) ||
  27 + preg_match('/^tax-group.*$/', $this->context->id) ||
  28 + preg_match('/^export.*$/', $this->context->id) ? true : false,
20 'options' => ['class'=>\Yii::$app->user->can('product') || \Yii::$app->user->can('category') || \Yii::$app->user->can('brand') || \Yii::$app->user->can('rubrication') ? '' :'hide'], 29 'options' => ['class'=>\Yii::$app->user->can('product') || \Yii::$app->user->can('category') || \Yii::$app->user->can('brand') || \Yii::$app->user->can('rubrication') ? '' :'hide'],
21 'items' => [ 30 'items' => [
22 [ 31 [
@@ -27,7 +36,8 @@ use yii\widgets\Menu; @@ -27,7 +36,8 @@ use yii\widgets\Menu;
27 [ 36 [
28 'label' => 'Категории', 37 'label' => 'Категории',
29 'url' => ['/category'], 38 'url' => ['/category'],
30 - 'options' => ['class'=>\Yii::$app->user->can('category') ? '' :'hide'] 39 + 'options' => ['class'=>\Yii::$app->user->can('category') ? '' :'hide'],
  40 +
31 ], 41 ],
32 [ 42 [
33 'label' => 'Бренды', 43 'label' => 'Бренды',
@@ -35,21 +45,11 @@ use yii\widgets\Menu; @@ -35,21 +45,11 @@ use yii\widgets\Menu;
35 'options' => ['class'=>\Yii::$app->user->can('brand') ? '' :'hide'], 45 'options' => ['class'=>\Yii::$app->user->can('brand') ? '' :'hide'],
36 ], 46 ],
37 [ 47 [
38 - 'label' => 'Характеристики',  
39 - 'url' => ['/rubrication/tax-group'],  
40 - 'options' => ['class'=>\Yii::$app->user->can('rubrication') ? '' :'hide'],  
41 - ],  
42 - [  
43 'label' => 'Единицы измерения', 48 'label' => 'Единицы измерения',
44 'url' => ['/product/product-unit'], 49 'url' => ['/product/product-unit'],
45 'options' => ['class'=>\Yii::$app->user->can('product') ? '' :'hide'], 50 'options' => ['class'=>\Yii::$app->user->can('product') ? '' :'hide'],
46 ], 51 ],
47 [ 52 [
48 - 'label' => 'Типы вариантов',  
49 - 'url' => ['/product/product-variant-type'],  
50 - 'options' => ['class'=>\Yii::$app->user->can('product') ? '' :'hide'],  
51 - ],  
52 - [  
53 'label' => 'Импорт товаров', 53 'label' => 'Импорт товаров',
54 'url' => ['/product/manage/import'], 54 'url' => ['/product/manage/import'],
55 'options' => ['class'=>\Yii::$app->user->can('product') ? '' :'hide'], 55 'options' => ['class'=>\Yii::$app->user->can('product') ? '' :'hide'],
@@ -59,12 +59,23 @@ use yii\widgets\Menu; @@ -59,12 +59,23 @@ use yii\widgets\Menu;
59 'url' => ['/product/manage/export'], 59 'url' => ['/product/manage/export'],
60 'options' => ['class'=>\Yii::$app->user->can('product') ? '' :'hide'], 60 'options' => ['class'=>\Yii::$app->user->can('product') ? '' :'hide'],
61 ], 61 ],
  62 + [
  63 + 'label' => 'Характеристики',
  64 + 'url' => ['/rubrication/tax-group'],
  65 + 'options' => ['class'=>\Yii::$app->user->can('rubrication') ? '' :'hide'],
  66 + ],
  67 + [
  68 + 'label' => 'Зависимости',
  69 + 'url' => ['/relation/manage'],
  70 + 'options' => ['class'=>\Yii::$app->user->can('relation') ? '' :'hide'],
  71 + ]
62 ] 72 ]
63 ], 73 ],
64 [ 74 [
65 'label' => 'Слайдер/Банеры', 75 'label' => 'Слайдер/Банеры',
66 'template'=>'<a href="{url}"> <i class="glyphicon glyphicon-picture"></i> <span>{label}</span></a>', 76 'template'=>'<a href="{url}"> <i class="glyphicon glyphicon-picture"></i> <span>{label}</span></a>',
67 'options' => ['class'=>\Yii::$app->user->can('banner') || \Yii::$app->user->can('slider') ? '' :'hide'], 77 'options' => ['class'=>\Yii::$app->user->can('banner') || \Yii::$app->user->can('slider') ? '' :'hide'],
  78 + 'active' => preg_match('/^slider.*$/', $this->context->id) || preg_match('/^banner.*$/', $this->context->id) ? true : false,
68 'items' => [ 79 'items' => [
69 [ 80 [
70 'label' => 'Слайдер', 81 'label' => 'Слайдер',
@@ -79,24 +90,6 @@ use yii\widgets\Menu; @@ -79,24 +90,6 @@ use yii\widgets\Menu;
79 ] 90 ]
80 ], 91 ],
81 [ 92 [
82 - 'label' => 'Характеристики',  
83 - 'template'=>'<a href="{url}"> <i class="glyphicon glyphicon-search"></i> <span>{label}</span></a>',  
84 - 'url' => ['/rubrication/tax-group'],  
85 - 'options' => ['class'=>\Yii::$app->user->can('rubrication') || \Yii::$app->user->can('relation') ? '' :'hide'],  
86 - 'items' => [  
87 - [  
88 - 'label' => 'Характеристики',  
89 - 'url' => ['/rubrication/tax-group'],  
90 - 'options' => ['class'=>\Yii::$app->user->can('rubrication') ? '' :'hide'],  
91 - ],  
92 - [  
93 - 'label' => 'Зависимости',  
94 - 'url' => ['/relation/manage'],  
95 - 'options' => ['class'=>\Yii::$app->user->can('relation') ? '' :'hide'],  
96 - ]  
97 - ]  
98 - ],  
99 - [  
100 'label' => 'Текстовые страницы', 93 'label' => 'Текстовые страницы',
101 'template'=>'<a href="{url}"> <i class="glyphicon glyphicon-duplicate"></i> <span>{label}</span></a>', 94 'template'=>'<a href="{url}"> <i class="glyphicon glyphicon-duplicate"></i> <span>{label}</span></a>',
102 'url' => ['/page/index'], 95 'url' => ['/page/index'],
@@ -117,6 +110,7 @@ use yii\widgets\Menu; @@ -117,6 +110,7 @@ use yii\widgets\Menu;
117 [ 110 [
118 'label' => 'SEO', 111 'label' => 'SEO',
119 'template'=>'<a href="{url}"> <i class="glyphicon glyphicon-search"></i> <span>{label}</span></a>', 112 'template'=>'<a href="{url}"> <i class="glyphicon glyphicon-search"></i> <span>{label}</span></a>',
  113 + 'active' => preg_match('/^seo.*$/', $this->context->id) || preg_match('/^seo-category.*$/', $this->context->id) ? true : false,
120 'options' => ['class'=>\Yii::$app->user->can('seo') || \Yii::$app->user->can('seo-category') ? '' :'hide'], 114 'options' => ['class'=>\Yii::$app->user->can('seo') || \Yii::$app->user->can('seo-category') ? '' :'hide'],
121 'items' => [ 115 'items' => [
122 [ 116 [
@@ -131,6 +125,7 @@ use yii\widgets\Menu; @@ -131,6 +125,7 @@ use yii\widgets\Menu;
131 ] 125 ]
132 ] 126 ]
133 ], 127 ],
  128 +
134 [ 129 [
135 'label' => 'Фон', 130 'label' => 'Фон',
136 'url' => ['/bg/index'], 131 'url' => ['/bg/index'],
@@ -152,6 +147,8 @@ use yii\widgets\Menu; @@ -152,6 +147,8 @@ use yii\widgets\Menu;
152 [ 147 [
153 'label' => 'Настройка ролей', 148 'label' => 'Настройка ролей',
154 'template'=>'<a href="{url}"> <i class="glyphicon glyphicon-cog"></i> <span>{label}</span></a>', 149 'template'=>'<a href="{url}"> <i class="glyphicon glyphicon-cog"></i> <span>{label}</span></a>',
  150 + 'active' => preg_match('/^user.*$/', $this->context->id)
  151 + || preg_match('/^access.*$/', $this->context->id) ? true : false,
155 'options' => ['class'=>\Yii::$app->user->can('user') || \Yii::$app->user->can('user') || \Yii::$app->user->can('permit') ? '' :'hide'], 152 'options' => ['class'=>\Yii::$app->user->can('user') || \Yii::$app->user->can('user') || \Yii::$app->user->can('permit') ? '' :'hide'],
156 'items' => [ 153 'items' => [
157 [ 154 [
backend/views/orders/_form.php 0 → 100644
  1 +<?php
  2 +
  3 +use yii\helpers\Html;
  4 +use yii\grid\GridView;
  5 +use yii\bootstrap\ActiveForm;
  6 +use yii\helpers\ArrayHelper;
  7 +use common\models\Delivery;
  8 +use yii\bootstrap\Modal;
  9 +use kartik\date\DatePicker;
  10 +
  11 +/* @var $this yii\web\View */
  12 +/* @var $model common\models\Slider */
  13 +/* @var $form yii\widgets\ActiveForm */
  14 +?>
  15 +
  16 + <?php $form = ActiveForm::begin(); ?>
  17 +<div class="container" style="margin-left: 0;">
  18 +<div class="col-sm-6">
  19 +
  20 +
  21 + <?= $form->field($model, 'name') ?>
  22 +
  23 +
  24 + <?= $form->field($model, 'phone') ?>
  25 +
  26 + <?= $form->field($model, 'phone2') ?>
  27 +
  28 + <?= $form->field($model, 'email') ?>
  29 +
  30 + <?= $form->field($model, 'numbercard') ?>
  31 +
  32 + <?= $form->field($model, 'body')->textArea(['rows' => '3']) ?>
  33 +<!-- --><?//= $form->field($model, 'delivery')->dropDownList(ArrayHelper::map(Delivery::find()->asArray()->all(), 'id', 'title')) ?>
  34 + <?= $form->field($model, 'declaration') ?>
  35 +
  36 + <?= $form->field($model, 'stock') ?>
  37 +
  38 + <?= $form->field($model, 'consignment') ?>
  39 +</div>
  40 +<div class="col-sm-6">
  41 +
  42 + <?=$form->field($model, 'payment')->dropDownList(['Оплатить наличными'=>'Оплатить наличными','Оплатить на карту Приват Банка'=>'Оплатить на карту Приват Банка','Оплатить по безналичному расчету'=>'Оплатить по безналичному расчету','Оплатить Правекс-телеграф'=>'Оплатить Правекс-телеграф','Наложенным платежом'=>'Наложенным платежом'],['prompt'=>'...']); ?>
  43 +
  44 + <?= $form->field($model, 'insurance') ?>
  45 +
  46 + <?= $form->field($model, 'amount_imposed') ?>
  47 +
  48 + <?= $form->field($model, 'shipping_by') ?>
  49 +
  50 + <?= $form->field($model, 'city') ?>
  51 +
  52 + <?= $form->field($model, 'adress') ?>
  53 +
  54 +
  55 + <?= $form->field($model, 'total') ?>
  56 +
  57 + <?=$form->field($model, 'status')->dropDownList(['Нет'=>'Нет','Обработан'=>'Обработан','На комплектации'=>'На комплектации','Укомплектован'=>'Укомплектован','Доставка'=>'Доставка','Выполнен'=>'Выполнен','Резерв оплачен'=>'Резерв оплачен','Резерв неоплачен'=>'Резерв неоплачен'],['prompt'=>'...']); ?>
  58 +
  59 + <?= $form->field($model, 'comment')->textArea(['rows' => '3']) ?>
  60 +</div>
  61 +</div>
  62 +<div class="form-group">
  63 + <?= Html::submitButton($model->isNewRecord ? 'Create' : 'Update', ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']) ?>
  64 +</div>
  65 + <?php ActiveForm::end(); ?>
  66 +
backend/views/orders/create.php 0 → 100644
  1 +<?php
  2 +use yii\helpers\Html;
  3 +use yii\grid\GridView;
  4 +use yii\bootstrap\ActiveForm;
  5 +
  6 +
  7 +$this->title = 'Добавить товар в заказ';
  8 +$this->params['breadcrumbs'][] = ['label' => 'Pages', 'url' => ['index']];
  9 +$this->params['breadcrumbs'][] = $this->title;
  10 +?>
  11 +
  12 +<div class="orders-create">
  13 + <h1><?= Html::encode($this->title) ?></h1>
  14 +
  15 + <?= $this->render('_form', [
  16 + 'model' => $model,
  17 + ]) ?>
  18 +</div>
  19 +
backend/views/orders/index.php
@@ -11,6 +11,9 @@ $this-&gt;title = &#39;Заказы&#39;; @@ -11,6 +11,9 @@ $this-&gt;title = &#39;Заказы&#39;;
11 $this->params['breadcrumbs'][] = $this->title; 11 $this->params['breadcrumbs'][] = $this->title;
12 ?> 12 ?>
13 <h1>Заказы</h1> 13 <h1>Заказы</h1>
  14 + <p>
  15 + <?= Html::a('Add Orders', ['create'], ['class' => 'btn btn-success']) ?>
  16 + </p>
14 <?php \yii\widgets\Pjax::begin( [ 17 <?php \yii\widgets\Pjax::begin( [
15 18
16 ]); ?> 19 ]); ?>