Commit 1772b98410506d07e6f9a02e91b4479072430f21

Authored by Karnovsky A
2 parents cbcf466f 78a56c44

Merge remote-tracking branch 'origin/master'

backend/assets/AppAsset.php
@@ -22,6 +22,7 @@ class AppAsset extends AssetBundle @@ -22,6 +22,7 @@ class AppAsset extends AssetBundle
22 ]; 22 ];
23 public $js = [ 23 public $js = [
24 'js/fieldWidget.js', 24 'js/fieldWidget.js',
  25 + 'js/site.js',
25 ]; 26 ];
26 public $depends = [ 27 public $depends = [
27 'yii\web\YiiAsset', 28 'yii\web\YiiAsset',
backend/controllers/OrdersController.php 100755 → 100644
1 -<?php  
2 -  
3 -namespace backend\controllers;  
4 -  
5 -use Yii;  
6 -use common\models\Orders;  
7 -use common\models\OrdersSearch;  
8 -use yii\web\Controller;  
9 -use yii\web\NotFoundHttpException;  
10 -use yii\filters\VerbFilter;  
11 -use yii\filters\AccessControl;  
12 -/**  
13 - * OrdersController implements the CRUD actions for Orders model.  
14 - */  
15 -class OrdersController extends Controller  
16 -{  
17 - /**  
18 - * @inheritdoc  
19 - */  
20 - public function behaviors()  
21 - {  
22 - return [  
23 - 'access' => [  
24 - 'class' => AccessControl::className(),  
25 - 'rules' => [  
26 - [  
27 - 'actions' => ['login', 'error','update','delete','create','view'],  
28 - 'allow' => true,  
29 - ],  
30 - [  
31 - 'actions' => ['logout', 'index'],  
32 - 'allow' => true,  
33 - 'roles' => ['@'],  
34 - ],  
35 - ],  
36 - ],  
37 - 'verbs' => [  
38 - 'class' => VerbFilter::className(),  
39 - 'actions' => [  
40 - 'logout' => ['post'],  
41 - ],  
42 - ],  
43 - ];  
44 - }  
45 - /**  
46 - * Lists all Orders models.  
47 - * @return mixed  
48 - */  
49 - public function actionIndex()  
50 - {  
51 - $searchModel = new OrdersSearch();  
52 - $dataProvider = $searchModel->search(Yii::$app->request->queryParams);  
53 -  
54 - return $this->render('index', [  
55 - 'searchModel' => $searchModel,  
56 - 'dataProvider' => $dataProvider,  
57 - ]);  
58 - }  
59 -  
60 - /**  
61 - * Displays a single Orders model.  
62 - * @param integer $id  
63 - * @return mixed  
64 - */  
65 - public function actionView($id)  
66 - {  
67 - return $this->render('view', [  
68 - 'model' => $this->findModel($id),  
69 - ]);  
70 - }  
71 -  
72 - /**  
73 - * Creates a new Orders model.  
74 - * If creation is successful, the browser will be redirected to the 'view' page.  
75 - * @return mixed  
76 - */  
77 - public function actionCreate()  
78 - {  
79 - $model = new Orders();  
80 -  
81 - if ($model->load(Yii::$app->request->post()) && $model->save()) {  
82 - return $this->redirect(['view', 'id' => $model->order_id]);  
83 - } else {  
84 - return $this->render('create', [  
85 - 'model' => $model,  
86 - ]);  
87 - }  
88 - }  
89 -  
90 - /**  
91 - * Updates an existing Orders model.  
92 - * If update is successful, the browser will be redirected to the 'view' page.  
93 - * @param integer $id  
94 - * @return mixed  
95 - */  
96 - public function actionUpdate($id)  
97 - {  
98 - $model = $this->findModel($id);  
99 -  
100 - if ($model->load(Yii::$app->request->post()) && $model->save()) {  
101 - return $this->redirect(['view', 'id' => $model->order_id]);  
102 - } else {  
103 - return $this->render('update', [  
104 - 'model' => $model,  
105 - ]);  
106 - }  
107 - }  
108 -  
109 - /**  
110 - * Deletes an existing Orders model.  
111 - * If deletion is successful, the browser will be redirected to the 'index' page.  
112 - * @param integer $id  
113 - * @return mixed  
114 - */  
115 - public function actionDelete($id)  
116 - {  
117 - $this->findModel($id)->delete();  
118 -  
119 - return $this->redirect(['index']);  
120 - }  
121 -  
122 - /**  
123 - * Finds the Orders model based on its primary key value.  
124 - * If the model is not found, a 404 HTTP exception will be thrown.  
125 - * @param integer $id  
126 - * @return Orders the loaded model  
127 - * @throws NotFoundHttpException if the model cannot be found  
128 - */  
129 - protected function findModel($id)  
130 - {  
131 - if (($model = Orders::findOne($id)) !== null) {  
132 - return $model;  
133 - } else {  
134 - throw new NotFoundHttpException('The requested page does not exist.');  
135 - }  
136 - }  
137 -} 1 +<?php
  2 +
  3 +namespace backend\controllers;
  4 +
  5 +use Yii;
  6 +use yii\web\Controller;
  7 +use yii\filters\AccessControl;
  8 +use yii\filters\VerbFilter;
  9 +use yii\data\ActiveDataProvider;
  10 +use yii\web\HttpException;
  11 +use backend\models\Orders;
  12 +use backend\models\OrdersProducts;
  13 +use common\modules\product\models\ProductVariant;
  14 +
  15 +
  16 +
  17 +class OrdersController extends Controller
  18 +{
  19 + /**
  20 + * @inheritdoc
  21 + */
  22 + public function behaviors()
  23 + {
  24 + return [
  25 + 'verbs' => [
  26 + 'class' => VerbFilter::className(),
  27 + 'actions' => [
  28 + 'delete' => ['POST'],
  29 + ],
  30 + ],
  31 + ];
  32 + }
  33 +
  34 + public function actionIndex()
  35 + {
  36 + $searchModel = new Orders;
  37 + $searchModel->load(Yii::$app->request->queryParams);
  38 + $query = Orders::find();
  39 + if(!empty($searchModel->labels))$query->andWhere(['label'=>$searchModel->labels]);
  40 + //if(!empty($searchModel->date_time))$query->andFilterWhere(['like', 'date_time', $searchModel->date_time]);
  41 + if(!empty($searchModel->username))$query->andFilterWhere(['like', 'username', $searchModel->username]);
  42 + if(!empty($searchModel->id))$query->andFilterWhere(['like', 'id', $searchModel->id]);
  43 + if(!empty($searchModel->phone))$query->andFilterWhere(['like', 'phone', $searchModel->phone]);
  44 + if(!empty($searchModel->name))$query->andFilterWhere(['like', 'name', $searchModel->name]);
  45 + if(!empty($searchModel->total))$query->andFilterWhere(['like', 'total', $searchModel->total]);
  46 + if(!empty($searchModel->reserve))$query->andFilterWhere(['like', 'reserve', $searchModel->reserve]);
  47 + if(!empty($searchModel->status))$query->andFilterWhere(['like', 'status', $searchModel->status]);
  48 +
  49 +// var_dump($searchModel->name);
  50 +// die;
  51 + $dataProvider = new ActiveDataProvider([
  52 + 'query' =>$query,
  53 + 'sort'=> ['defaultOrder' => ['id'=>SORT_DESC]],
  54 + 'pagination' => [
  55 + 'pageSize' => 20,
  56 + ],
  57 + ]);
  58 +
  59 + return $this->render('index', [
  60 + 'dataProvider'=>$dataProvider,
  61 + 'searchModel'=>$searchModel,
  62 + ]);
  63 + }
  64 +
  65 + public function actionShow($id)
  66 + {
  67 +
  68 + $model = $this->findModel((int)$id);
  69 + $dataProvider = new ActiveDataProvider([
  70 + 'query' => OrdersProducts::find()->where(['order_id'=>(int)$_GET['id']]),
  71 + 'pagination' => [
  72 + 'pageSize' => 20,
  73 + ],
  74 + ]);
  75 + if ($model->load(Yii::$app->request->post()) && $model->save()) {
  76 + return $this->redirect(['index']);
  77 + } else {
  78 + $model_orderproducts = new OrdersProducts;
  79 +
  80 +
  81 + return $this->renderPartial('show', [
  82 + 'model' => $model,
  83 + 'model_orderproducts'=>$model_orderproducts,
  84 + 'dataProvider' => $dataProvider,
  85 + ]);
  86 + }
  87 + }
  88 +
  89 + public function actionLabelupdate(){
  90 + $model = Orders::findOne($_POST['order_id']);
  91 + $model->label = $_POST['label_id'];
  92 + $model->save();
  93 + Yii::$app->and();
  94 + }
  95 +
  96 + public function actionPayupdate(){
  97 + $model = Orders::findOne($_POST['order_id']);
  98 + $model->pay = $_POST['pay_id'];
  99 + $model->save();
  100 + Yii::$app->and();
  101 + }
  102 +
  103 + public function actionDelete(){
  104 + $model = Orders::findOne($_GET['id']);
  105 + $model->delete();
  106 + return Yii::$app->response->redirect(['/admin/orders/index']);
  107 + }
  108 +
  109 +
  110 + public function actionAdd(){
  111 + $model = new OrdersProducts;
  112 + if ($model->load(Yii::$app->request->post())) {
  113 +
  114 + if(!$modelMod = ProductVariant::find()->with(['product'])->where(['sku'=>$model->sku])->one())
  115 + throw new HttpException(404, 'Данного артикля не существует!');
  116 + $model->product_name = $modelMod->product->name;
  117 + $model->name = $modelMod->name;
  118 + $model->sku = $modelMod->sku;
  119 + $model->price = $modelMod->price;
  120 + $model->sum_cost = $model->count*$modelMod->price;
  121 + $model->mod_id = $modelMod->id;
  122 + $model->save();
  123 + //return Yii::$app->response->redirect(['/admin/orders/show','id'=>$_GET['order_id']]);
  124 + }
  125 +
  126 + //return $this->render('add',['model'=>$model]);
  127 + }
  128 +
  129 + public function actionDelete_product(){
  130 + $model = OrdersProducts::findOne($_GET['id']);
  131 + $model->delete();
  132 + return Yii::$app->response->redirect(['/admin/orders/show','id'=>$_GET['order_id']]);
  133 + }
  134 +
  135 + protected function findModel($id)
  136 + {
  137 + if (($model = Orders::findOne($id)) !== null) {
  138 + return $model;
  139 + } else {
  140 + throw new NotFoundHttpException('The requested page does not exist.');
  141 + }
  142 + }
  143 +}
backend/models/Label.php 0 → 100644
  1 +<?php
  2 +
  3 +namespace backend\models;
  4 +use Yii;
  5 +
  6 +
  7 +class Label extends \yii\db\ActiveRecord
  8 +{
  9 +
  10 + public static function tableName()
  11 + {
  12 + return 'orders_label';
  13 + }
  14 +
  15 +
  16 + public function getNl(){
  17 + return $this->name;
  18 + }
  19 +
  20 +
  21 +
  22 +
  23 +
  24 +
  25 +}
backend/models/Orders.php 0 → 100644
  1 +<?php
  2 +
  3 +namespace backend\models;
  4 +use common\models\Customer;
  5 +use Yii;
  6 +
  7 +class Orders extends \yii\db\ActiveRecord
  8 +{
  9 + public $labels;
  10 + public static function tableName()
  11 + {
  12 + return 'orders';
  13 + }
  14 +
  15 + public function rules()
  16 + {
  17 + return [
  18 + [['name'], 'required'],
  19 + [['user_id','adress','body','total','status','email','patronymic','surname',
  20 + 'comment','labels','pay','date_dedline','phone','phone2','numbercard','delivery',
  21 + 'declaration','stock','consignment','payment', 'insurance',
  22 + 'amount_imposed','shipping_by','city','date_time', 'id' ], 'safe'],
  23 + //[['image'], 'file', 'extensions'=>'jpg, gif, png', 'skipOnEmpty'=>true],
  24 + ];
  25 + }
  26 +
  27 + public function attributeLabels()
  28 + {
  29 + return [
  30 + 'id'=>'№ заказа',
  31 + 'name'=>'Имя',
  32 + 'phone'=>'Телефон',
  33 + 'phone2'=>'Телефон 2',
  34 + 'adress'=>'Адрес',
  35 + 'body'=>'Сообщение',
  36 + 'reserve'=>'Резерв',
  37 + 'status'=>'Статус',
  38 + 'email'=>'E-mail',
  39 + 'patronymic'=>'Очество',
  40 + 'surname'=>'Фамилия',
  41 + 'total'=>'Сумма',
  42 + 'labels'=>'Метки',
  43 + 'label'=>'Метка',
  44 + 'comment'=>'Комментарий менеджера',
  45 + 'date_dedline'=>'Дедлайн',
  46 + 'numbercard'=>'№ карточки',
  47 + 'delivery'=>'Доставка',
  48 + 'declaration'=>'Декларация №',
  49 + 'stock'=>'№ склада',
  50 + 'consignment'=>'№ накладной',
  51 + 'payment'=>'Способ оплаты',
  52 + 'insurance'=>'Страховка',
  53 + 'amount_imposed'=>'Сумма наложенного',
  54 + 'shipping_by'=>'Отправка за счет',
  55 + 'city'=>'Город'
  56 + ];
  57 + }
  58 +
  59 + public function beforeSave($insert) {
  60 + return parent::beforeSave($insert);
  61 + }
  62 +
  63 + public function beforeDelete() {
  64 + return parent::beforeDelete();
  65 + }
  66 +
  67 + public function getUser()
  68 + {
  69 + return $this->hasOne(Customer::className(), ['id' => 'user_id']);
  70 + }
  71 +
  72 +
  73 +
  74 +}
0 \ No newline at end of file 75 \ No newline at end of file
backend/models/OrdersProducts.php 0 → 100644
  1 +<?php
  2 +
  3 +namespace backend\models;
  4 +use common\modules\product\models\ProductVariant;
  5 +use Yii;
  6 +
  7 +class OrdersProducts extends \yii\db\ActiveRecord
  8 +{
  9 +
  10 + public static function tableName()
  11 + {
  12 + return 'orders_products';
  13 + }
  14 +
  15 + public function rules()
  16 + {
  17 + return [
  18 + [['sku','count','order_id'], 'required'],
  19 + ];
  20 + }
  21 +
  22 + public function attributeLabels()
  23 + {
  24 + return [
  25 + 'product_name'=>'Продукт',
  26 + 'name'=>'Вид',
  27 + 'art'=>'Артикул',
  28 + 'cost'=>'Цена за один',
  29 + 'count'=>'Кол.',
  30 + 'sum_cost'=>'Сумма',
  31 + ];
  32 + }
  33 +
  34 + public function getMod()
  35 + {
  36 + return $this->hasOne(ProductVariant::className(), ['product_variant_id' => 'mod_id']);
  37 + }
  38 +}
0 \ No newline at end of file 39 \ No newline at end of file
backend/views/orders/_form.php deleted
1 -<?php  
2 -  
3 -use common\models\OrderItems;  
4 -use yii\helpers\Html;  
5 -use yii\widgets\ActiveForm;  
6 -use kartik\date\DatePicker;  
7 -use unclead\widgets\MultipleInput;  
8 -use unclead\widgets\MultipleInputColumn;  
9 -/* @var $this yii\web\View */  
10 -/* @var $model common\models\Orders */  
11 -/* @var $form yii\widgets\ActiveForm */  
12 -?>  
13 -  
14 -<div class="orders-form">  
15 -  
16 - <?php $form = ActiveForm::begin(); ?>  
17 -  
18 - <?= $form->field($model, 'name')->textInput(['maxlength' => true]) ?>  
19 -  
20 - <?= $form->field($model, 'email')->textInput(['maxlength' => true]) ?>  
21 -  
22 - <?= $form->field($model, 'phone')->textInput(['maxlength' => true]) ?>  
23 -  
24 - <?php  
25 -  
26 -  
27 - echo $form->field($model, 'delivery', [  
28 - ])->radioList([  
29 - '1' => 'Курьерска доставка по Киеву и области',  
30 - '2' => 'В любой регион Украины',  
31 - '3' => 'Самовывоз (бесплатно)',  
32 - ], [  
33 - 'item' => function($index, $label, $name, $checked, $value) {  
34 -  
35 - $return = '<div><label class="modal-radio">';  
36 - $return .= Html::radio($name, $checked, ['value' => $value]);  
37 - $return .= '<i></i>';  
38 - $return .= '<span>' . ucwords($label) . '</span>';  
39 - $return .= '</label></div>';  
40 -  
41 - return $return;  
42 - },  
43 - ]);  
44 -  
45 -  
46 - ?>  
47 -  
48 - <?php  
49 -  
50 -  
51 - echo $form->field($model, 'payment', [  
52 - ])->radioList([  
53 - '1' => 'Оплата наличными',  
54 - '2' => 'Оплата по безналичному расчету. Код ЕГРПОУ',  
55 - '3' => 'Приват 24',  
56 - '4' => 'Согласовать с менеджером',  
57 - ], [  
58 - 'item' => function ($index, $label, $name, $checked, $value) use ($model) {  
59 - if($index != 1){  
60 -  
61 - $return = '<div><label class="modal-radio">';  
62 - $return .= Html::radio($name, $checked, ['value' => $value]);  
63 - $return .= '<i></i>';  
64 - $return .= '<span>' . ucwords($label) . '</span>';  
65 - $return .= '</label></div>';  
66 -  
67 - return $return;  
68 - } else {  
69 -  
70 - $return = '<div><label class="modal-radio">';  
71 - $return .= Html::radio($name, $checked, ['value' => $value]);  
72 - $return .= '<i></i>';  
73 - $return .= '<span>' . ucwords($label) . '</span>';  
74 - $return .= Html::activeTextInput($model,'code');  
75 - $return .= '</label></div>';  
76 -  
77 - return $return;  
78 - }  
79 -  
80 - },  
81 - ]);  
82 -  
83 -  
84 - ?>  
85 -  
86 - <?= $form->field($model, 'status')->textInput() ?>  
87 -  
88 - <?= $form->field($model, 'created')->widget(DatePicker::classname(), [  
89 - 'language' => 'ru',  
90 - 'pluginOptions' => [  
91 - 'format'=> 'yyyy-mm-d'  
92 -  
93 - ],  
94 -  
95 - ]) ?>  
96 - <?= $form->field($model, 'updated')->widget(DatePicker::classname(), [  
97 - 'language' => 'ru',  
98 - 'pluginOptions' => [  
99 - 'format'=> 'yyyy-mm-d'  
100 -  
101 - ],  
102 -  
103 - ]) ?>  
104 -  
105 - <?= $form->field($model, 'orderItems')->widget(MultipleInput::className(), [  
106 - 'columns' => [  
107 - [  
108 - 'name' => 'order_items_id',  
109 - 'type' => MultipleInputColumn::TYPE_HIDDEN_INPUT,  
110 - ],  
111 - [  
112 - 'name' => 'item_id',  
113 - 'type' => MultipleInputColumn::TYPE_TEXT_INPUT,  
114 - 'title' => 'item id',  
115 - ],  
116 - [  
117 - 'name' => 'item_name',  
118 - 'type' => MultipleInputColumn::TYPE_TEXT_INPUT,  
119 - 'title' => 'name',  
120 - 'value' => function($data){  
121 - if($data instanceof OrderItems){  
122 - return $data->item->product->name .' '. $data->item->name;  
123 - }  
124 - },  
125 - ],  
126 - [  
127 - 'name' => 'item_count',  
128 - 'type' => MultipleInputColumn::TYPE_TEXT_INPUT,  
129 - 'title' => 'item count',  
130 - ],  
131 - [  
132 - 'name' => 'price',  
133 - 'type' => MultipleInputColumn::TYPE_TEXT_INPUT,  
134 - 'title' => 'Price',  
135 - ],  
136 - ],  
137 - ]);  
138 - ?>  
139 -  
140 -  
141 -  
142 - <div class="form-group">  
143 - <?= Html::submitButton($model->isNewRecord ? Yii::t('app', 'Create') : Yii::t('app', 'Update'), ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']) ?>  
144 - </div>  
145 -  
146 - <?php ActiveForm::end(); ?>  
147 -  
148 -</div>  
backend/views/orders/_search.php deleted
1 -<?php  
2 -  
3 -use yii\helpers\Html;  
4 -use yii\widgets\ActiveForm;  
5 -  
6 -/* @var $this yii\web\View */  
7 -/* @var $model common\models\OrdersSearch */  
8 -/* @var $form yii\widgets\ActiveForm */  
9 -?>  
10 -  
11 -<div class="orders-search">  
12 -  
13 - <?php $form = ActiveForm::begin([  
14 - 'action' => ['index'],  
15 - 'method' => 'get',  
16 - ]); ?>  
17 -  
18 - <?= $form->field($model, 'order_id') ?>  
19 -  
20 - <?= $form->field($model, 'name') ?>  
21 -  
22 - <?= $form->field($model, 'email') ?>  
23 -  
24 - <?= $form->field($model, 'phone') ?>  
25 -  
26 - <?php // echo $form->field($model, 'delivery') ?>  
27 -  
28 - <?php // echo $form->field($model, 'payment') ?>  
29 -  
30 - <?php // echo $form->field($model, 'code') ?>  
31 -  
32 - <?php // echo $form->field($model, 'status') ?>  
33 -  
34 - <?php // echo $form->field($model, 'created_at') ?>  
35 -  
36 - <?php // echo $form->field($model, 'updated_at') ?>  
37 -  
38 - <div class="form-group">  
39 - <?= Html::submitButton(Yii::t('app', 'Search'), ['class' => 'btn btn-primary']) ?>  
40 - <?= Html::resetButton(Yii::t('app', 'Reset'), ['class' => 'btn btn-default']) ?>  
41 - </div>  
42 -  
43 - <?php ActiveForm::end(); ?>  
44 -  
45 -</div>  
backend/views/orders/add.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'][] = $this->title;
  9 +?>
  10 +<h1>Добавить товар в заказ</h1>
  11 +
  12 + <?php $form = ActiveForm::begin([
  13 + 'id' => 'reg-form',
  14 + 'options' => ['class' => 'form-vertical','enctype' => 'multipart/form-data'],
  15 + 'fieldConfig' => [
  16 + //'template' => "{label}\n<div class=\"col-lg-5\">{input}</div>\n<div class=\"col-lg-8\">{error}</div>",
  17 + //'labelOptions' => ['class' => 'col-lg-2 control-label'],
  18 + ],
  19 + ]); ?>
  20 +
  21 +<?= $form->field($model, 'art') ?>
  22 +
  23 +<?= $form->field($model, 'count') ?>
  24 +
  25 + <?= $form->field($model, 'order_id')->hiddenInput(['value'=>$_GET['order_id']])->label(false); ?>
  26 +
  27 +<div class="form-group">
  28 + <?= Html::submitButton(' Сохранить ', ['class' => 'btn btn-primary', 'name' => 'login-button']) ?>
  29 +</div>
  30 + <?php ActiveForm::end(); ?>
0 \ No newline at end of file 31 \ No newline at end of file
backend/views/orders/create.php deleted
1 -<?php  
2 -  
3 -use yii\helpers\Html;  
4 -  
5 -  
6 -/* @var $this yii\web\View */  
7 -/* @var $model common\models\Orders */  
8 -  
9 -$this->title = Yii::t('app', 'Create Orders');  
10 -$this->params['breadcrumbs'][] = ['label' => Yii::t('app', 'Orders'), 'url' => ['index']];  
11 -$this->params['breadcrumbs'][] = $this->title;  
12 -?>  
13 -<div class="orders-create">  
14 -  
15 - <h1><?= Html::encode($this->title) ?></h1>  
16 -  
17 - <?= $this->render('_form', [  
18 - 'model' => $model,  
19 - ]) ?>  
20 -  
21 -</div>  
backend/views/orders/index.php 100755 → 100644
1 -<?php  
2 -  
3 -use yii\helpers\Html;  
4 -use yii\grid\GridView;  
5 -  
6 -/* @var $this yii\web\View */  
7 -/* @var $searchModel common\models\OrdersSearch */  
8 -/* @var $dataProvider yii\data\ActiveDataProvider */  
9 -  
10 -$this->title = Yii::t('app', 'Orders');  
11 -$this->params['breadcrumbs'][] = $this->title;  
12 -?>  
13 -<div class="orders-index">  
14 -  
15 - <h1><?= Html::encode($this->title) ?></h1>  
16 - <?php // echo $this->render('_search', ['model' => $searchModel]); ?>  
17 -  
18 - <p>  
19 - <?= Html::a(Yii::t('app', 'Create Orders'), ['create'], ['class' => 'btn btn-success']) ?>  
20 - </p>  
21 - <?= GridView::widget([  
22 - 'dataProvider' => $dataProvider,  
23 - 'filterModel' => $searchModel,  
24 - 'columns' => [  
25 - ['class' => 'yii\grid\SerialColumn'],  
26 -  
27 - 'order_id',  
28 - 'name',  
29 - 'email:email',  
30 - 'phone',  
31 - // 'delivery',  
32 - // 'payment',  
33 - // 'code',  
34 - // 'status',  
35 - // 'created_at',  
36 - // 'updated_at',  
37 -  
38 - ['class' => 'yii\grid\ActionColumn'],  
39 - ],  
40 - ]); ?>  
41 -</div> 1 +<?php
  2 +use yii\helpers\Html;
  3 +use yii\grid\GridView;
  4 +use yii\bootstrap\ActiveForm;
  5 +use yii\helpers\ArrayHelper;
  6 +use backend\models\Label;
  7 +use yii\bootstrap\Modal;
  8 +$this->registerJsFile('/app/modules/admin/assets/js/jquery-1.11.3.min.js');
  9 +$this->registerJsFile('/app/modules/admin/assets/js/site.js');
  10 +
  11 +
  12 +$this->title = 'Заказы';
  13 +$this->params['breadcrumbs'][] = $this->title;
  14 +?>
  15 +<h1>Заказы</h1>
  16 +
  17 + <?php $form = ActiveForm::begin(['id' => 'label-form','method'=>'get','action'=>['/admin/orders/index']]); ?>
  18 +
  19 + <?php
  20 + $arr = [];
  21 + foreach(Label::find()->orderBy('id')->all() as $item)
  22 + {
  23 + $arr[] = ['id'=>$item->id,'label'=>$item->label.'-'.$item->name];
  24 + }
  25 + echo $form->field($searchModel, 'labels')->inline(true)->checkboxList(ArrayHelper::map($arr, 'id', 'label'),['onClick'=>'$("#label-form").submit()']);
  26 + ?>
  27 +
  28 + <?php ActiveForm::end(); ?>
  29 +
  30 +<?= GridView::widget([
  31 + 'dataProvider' => $dataProvider,
  32 + 'filterModel' => $searchModel,
  33 + 'columns' => [
  34 + // ['class' => 'yii\grid\SerialColumn'],
  35 +
  36 + [
  37 + 'attribute' => 'id',
  38 + 'format' => 'raw',
  39 + 'options' => ['class' => 'btn btn-warning'],
  40 + 'value' => function($model){
  41 + return Html::button($model->id, ['id'=>$model->id, 'class' => 'btn btn-warning']); '/admin/orders/show?id=47';
  42 + //return Html::a($model->id, ['/admin/orders/show', 'id'=>$model->id], ['class'=>'btn btn-warning'] );
  43 + // return Html::a($data->name, ['/admin/orders/show','id'=>$data->id]);
  44 + }
  45 +
  46 + ],
  47 + /*[
  48 + 'attribute' =>'username',
  49 + 'value'=>function($data){
  50 + if(!empty($data->user->username))return Html::a($data->user->username, ['/admin/users/show','id'=>$data->user->id]);
  51 + },
  52 + 'format'=>'raw',
  53 + //'contentOptions'=>['style'=>'width: 160px;']
  54 + ], */
  55 + [
  56 + 'attribute' => 'date_time',
  57 + 'value'=>'date_time',
  58 + ],
  59 +
  60 + [
  61 + 'attribute' => 'name',
  62 + 'value'=>'name',
  63 + 'format'=>'raw',
  64 + ],
  65 + [
  66 + 'attribute' => 'phone',
  67 + 'value'=>'phone',
  68 + //'contentOptions'=>['style'=>'max-width: 300px;']
  69 + ],
  70 + [
  71 + 'attribute' => 'total',
  72 + 'value'=>'total',
  73 + //'contentOptions'=>['style'=>'max-width: 300px;']
  74 + ],
  75 + [
  76 + 'attribute' => 'label',
  77 + 'value' => function ($model, $key, $index, $column) {
  78 + // var_dump($model); var_dump($key); exit;
  79 + return Html::activeDropDownList($model, 'label',
  80 + yii\helpers\ArrayHelper::map(Label::find()->orderBy('id')->asArray()->all(), 'id', 'label'),
  81 + [
  82 + 'prompt' => 'Нет',
  83 + 'onchange' => "$.ajax({
  84 + url: \"/admin/orders/labelupdate\",
  85 + type: \"post\",
  86 + data: { order_id: $model->id, label_id : this.value},
  87 + });"
  88 + ]
  89 +
  90 + );
  91 + },
  92 + 'format' => 'raw',
  93 + ],
  94 + [
  95 + 'attribute' => 'pay',
  96 + 'value' => function ($model, $key, $index, $column) {
  97 + // var_dump($model); var_dump($key); exit;
  98 + return Html::activeDropDownList($model, 'pay',[0 => 'Нет',1=>'Да'],
  99 + [
  100 + // 'prompt' => 'Нет',
  101 + 'onchange' => "$.ajax({
  102 + url: \"/admin/orders/payupdate\",
  103 + type: \"post\",
  104 + data: { order_id: $model->id, pay_id : this.value},
  105 + });"
  106 + ]
  107 +
  108 + );
  109 + },
  110 + 'format' => 'raw',
  111 + ],
  112 + [
  113 + 'attribute' => 'status',
  114 + 'value'=>'status',
  115 + 'contentOptions'=>['style'=>'width: 5px;']
  116 + ],
  117 + [
  118 + 'class' => 'yii\grid\ActionColumn',
  119 + 'template' => '{delete}',
  120 + 'contentOptions'=>['style'=>'width: 70px;']
  121 + ],
  122 + ],
  123 +]) ?>
backend/views/orders/show.php 0 → 100644
  1 +<?php
  2 +use yii\helpers\Html;
  3 +use yii\grid\GridView;
  4 +use yii\bootstrap\ActiveForm;
  5 +use yii\helpers\ArrayHelper;
  6 +use common\models\Delivery;
  7 +use yii\bootstrap\Modal;
  8 +
  9 +$this->registerCssFile('/app/modules/admin/assets/css/admin_order.css');
  10 +
  11 +
  12 +// $this->title = 'Заказ №'.$model->id;
  13 +// $this->params['breadcrumbs'][] = $this->title;
  14 +?>
  15 +<div class="show_style">
  16 +
  17 +
  18 +
  19 +
  20 +<?php if(!empty($_GET['success'])):?>
  21 +<div class="alert alert-success">
  22 + Заказ успешно сохранен!
  23 +</div>
  24 +<?php endif;?>
  25 +
  26 + <?php $form = ActiveForm::begin([
  27 + 'id' => 'reg-form',
  28 + 'layout' => 'horizontal',
  29 + 'options' => ['enctype' => 'multipart/form-data'],
  30 + 'fieldConfig' => [
  31 + //'template' => "{label}\n<div class=\"col-lg-5\">{input}</div>\n<div class=\"col-lg-8\">{error}</div>",
  32 + //'labelOptions' => ['class' => 'col-lg-2 control-label'],
  33 + ],
  34 + 'action' => [
  35 + 'orders/show',
  36 + 'id' => $model->id
  37 + ]
  38 + ]); ?>
  39 +
  40 +<div class="row">
  41 +<div class="col-sm-6">
  42 + <div class="form-group .new_styles_ddd">
  43 + <h5>Заказ №<?=$model->id?></h5>
  44 + <label class="control-label col-sm-3">Дата</label>
  45 + <?=$model->date_time?>
  46 + </div>
  47 +<?= $form->field($model,'date_dedline')->widget(\yii\jui\DatePicker::className(),['clientOptions' => [],'options' => ['class'=>'form-control','style'=>'width:150px;'],'dateFormat' => 'yyyy-MM-dd',]) ?>
  48 +
  49 +
  50 +<?= $form->field($model, 'name') ?>
  51 +
  52 +
  53 +<?= $form->field($model, 'phone') ?>
  54 +
  55 +<?= $form->field($model, 'phone2') ?>
  56 +
  57 +<?= $form->field($model, 'email') ?>
  58 +
  59 +<?= $form->field($model, 'numbercard') ?>
  60 +
  61 + <?= $form->field($model, 'body')->textArea(['rows' => '3']) ?>
  62 +</div>
  63 +<div class="col-sm-6">
  64 + <?= $form->field($model, 'delivery')->dropDownList(ArrayHelper::map(Delivery::find()->asArray()->all(), 'id', 'title')) ?>
  65 +
  66 + <?= $form->field($model, 'declaration') ?>
  67 +
  68 + <?= $form->field($model, 'stock') ?>
  69 +
  70 + <?= $form->field($model, 'consignment') ?>
  71 +
  72 +<?=$form->field($model, 'payment')->dropDownList(['Оплатить наличными'=>'Оплатить наличными','Оплатить на карту Приват Банка'=>'Оплатить на карту Приват Банка','Оплатить по безналичному расчету'=>'Оплатить по безналичному расчету','Оплатить Правекс-телеграф'=>'Оплатить Правекс-телеграф','Наложенным платежом'=>'Наложенным платежом'],['prompt'=>'...']); ?>
  73 +
  74 +<?= $form->field($model, 'insurance') ?>
  75 +
  76 +<?= $form->field($model, 'amount_imposed') ?>
  77 +
  78 +<?= $form->field($model, 'shipping_by') ?>
  79 +
  80 +<?= $form->field($model, 'city') ?>
  81 +
  82 +<?= $form->field($model, 'adress') ?>
  83 +
  84 +
  85 +<?= $form->field($model, 'total') ?>
  86 +
  87 +<?=$form->field($model, 'status')->dropDownList(['Нет'=>'Нет','Обработан'=>'Обработан','На комплектации'=>'На комплектации','Укомплектован'=>'Укомплектован','Доставка'=>'Доставка','Выполнен'=>'Выполнен','Резерв оплачен'=>'Резерв оплачен','Резерв неоплачен'=>'Резерв неоплачен'],['prompt'=>'...']); ?>
  88 +
  89 +<?= $form->field($model, 'comment')->textArea(['rows' => '3']) ?>
  90 +</div></div><div class="both"></div>
  91 +
  92 +<hr />
  93 +&nbsp;
  94 +
  95 +
  96 +<?= GridView::widget([
  97 + 'dataProvider' => $dataProvider,
  98 + 'columns' => [
  99 + [
  100 + 'attribute' => 'id',
  101 + 'value'=>'id',
  102 + 'contentOptions'=>['style'=>'width: 70px;']
  103 + ],
  104 + [
  105 + 'attribute' => 'sku',
  106 + 'value'=>'sku',
  107 + 'contentOptions'=>['style'=>'width: 50px;']
  108 + ],
  109 + [
  110 + 'attribute' => 'product_name',
  111 + 'value'=>'product_name',
  112 + 'contentOptions'=>['style'=>'max-width: 300px;']
  113 + ],
  114 +// [
  115 +// 'attribute' => 'size',
  116 +// 'value'=>'mod.size',
  117 +// 'contentOptions'=>['style'=>'width: 100px;']
  118 +// ],
  119 +// [
  120 +// 'attribute' => 'size',
  121 +// 'value'=>'mod.color',
  122 +// 'contentOptions'=>['style'=>'width: 100px;']
  123 +// ],
  124 + [
  125 + 'attribute' => 'price',
  126 + 'value'=>'price',
  127 + 'contentOptions'=>['style'=>'width: 100px;']
  128 + ],
  129 + [
  130 + 'attribute' => 'count',
  131 + 'value'=>'count',
  132 + 'contentOptions'=>['style'=>'width: 30px;']
  133 + ],
  134 + [
  135 + 'attribute' => 'sum_cost',
  136 + 'value'=>'sum_cost',
  137 + 'contentOptions'=>['style'=>'width: 100px;']
  138 + ],
  139 + [
  140 + 'class' => 'yii\grid\ActionColumn',
  141 + 'template' => '{delete}',
  142 + 'contentOptions'=>['style'=>'width: 20px;'],
  143 + 'buttons' => [
  144 + 'delete' => function ($url, $model) {
  145 + return Html::a('<span class="glyphicon glyphicon-trash"></span>', ['/admin/orders/delete_product','id'=>$model->id,'order_id'=>$_GET['id']],
  146 + [
  147 + 'title' => "Удалить",'data-confirm'=>'Удалить?',
  148 + ]);
  149 + }
  150 + ],
  151 + ],
  152 +
  153 + ],
  154 +]) ?>
  155 +<div class="form-group">
  156 + <?= Html::submitButton(' Сохранить ', ['class' => 'btn btn-primary btn-lg btn-block', 'name' => 'login-button']) ?>
  157 + </div>
  158 +
  159 + <?php ActiveForm::end(); ?>
  160 +
  161 + <div class="row">
  162 + <div class="col-sm-6">
  163 + <h1>Добавить товар в заказ</h1>
  164 +
  165 + <?php $form = ActiveForm::begin([
  166 + 'enableClientScript' => false,
  167 + 'id' => 'add_mod',
  168 + 'options' => ['class' => 'form-vertical','enctype' => 'multipart/form-data'],
  169 + 'fieldConfig' => [
  170 + //'template' => "{label}\n<div class=\"col-lg-5\">{input}</div>\n<div class=\"col-lg-8\">{error}</div>",
  171 + //'labelOptions' => ['class' => 'col-lg-2 control-label'],
  172 + ],
  173 + ]); ?>
  174 +
  175 + <?= $form->field($model_orderproducts, 'sku') ?>
  176 +
  177 + <?= $form->field($model_orderproducts, 'count') ?>
  178 +
  179 + <?= $form->field($model_orderproducts, 'order_id')->hiddenInput(['value'=>$model->id])->label(false); ?>
  180 +
  181 + <div class="form-group">
  182 + <?= Html::submitButton(' Добавить товар ', ['class' => 'btn btn-primary', 'name' => 'login-button']) ?>
  183 + </div>
  184 + <?php ActiveForm::end(); ?>
  185 + </div></div>
  186 +
  187 + </div>
  188 +
  189 +
  190 +
backend/views/orders/update.php 100755 → 100644
1 -<?php  
2 -  
3 -use yii\helpers\Html;  
4 -  
5 -/* @var $this yii\web\View */  
6 -/* @var $model common\models\Orders */  
7 -  
8 -$this->title = Yii::t('app', 'Update {modelClass}: ', [  
9 - 'modelClass' => 'Orders',  
10 -]) . ' ' . $model->name;  
11 -$this->params['breadcrumbs'][] = ['label' => Yii::t('app', 'Orders'), 'url' => ['index']];  
12 -$this->params['breadcrumbs'][] = ['label' => $model->name, 'url' => ['view', 'id' => $model->order_id]];  
13 -$this->params['breadcrumbs'][] = Yii::t('app', 'Update');  
14 -?>  
15 -<div class="orders-update">  
16 -  
17 - <h1><?= Html::encode($this->title) ?></h1>  
18 -  
19 - <?= $this->render('_form', [  
20 - 'model' => $model,  
21 - ]) ?>  
22 -  
23 -</div> 1 +<?php
  2 +use yii\helpers\Html;
  3 +use yii\grid\GridView;
  4 +use yii\bootstrap\ActiveForm;
  5 +use yii\helpers\ArrayHelper;
  6 +use app\modules\admin\models\Delivery;
  7 +
  8 +
  9 +$this->title = 'Заказ №'.$model->id;
  10 +$this->params['breadcrumbs'][] = $this->title;
  11 +?>
  12 +<h1>Заказ №<?=$model->id?></h1>
  13 +
  14 +<?php if(!empty($_GET['success'])):?>
  15 +<div class="alert alert-success">
  16 + Заказ успешно сохранен!
  17 +</div>
  18 +<?php endif;?>
  19 +
  20 + <?php $form = ActiveForm::begin([
  21 + 'id' => 'reg-form',
  22 + 'layout' => 'horizontal',
  23 + 'options' => ['enctype' => 'multipart/form-data'],
  24 + 'fieldConfig' => [
  25 + //'template' => "{label}\n<div class=\"col-lg-5\">{input}</div>\n<div class=\"col-lg-8\">{error}</div>",
  26 + //'labelOptions' => ['class' => 'col-lg-2 control-label'],
  27 + ],
  28 + ]); ?>
  29 +
  30 +
  31 +<div class="col-sm-6">
  32 + <div class="form-group">
  33 + <label class="control-label col-sm-3">Дата</label>
  34 + <?=$model->date_time?>
  35 + </div>
  36 +<?= $form->field($model,'date_dedline')->widget(\yii\jui\DatePicker::className(),['clientOptions' => [],'options' => ['class'=>'form-control','style'=>'width:150px;'],'dateFormat' => 'yyyy-MM-dd',]) ?>
  37 +
  38 +<?= $form->field($model, 'surname') ?>
  39 +
  40 +<?= $form->field($model, 'name') ?>
  41 +
  42 +<?= $form->field($model, 'patronymic') ?>
  43 +
  44 +<?= $form->field($model, 'phone') ?>
  45 +
  46 +<?= $form->field($model, 'phone2') ?>
  47 +
  48 +<?= $form->field($model, 'email') ?>
  49 +
  50 +<?= $form->field($model, 'numbercard') ?>
  51 +
  52 +<?= $form->field($model, 'delivery')->dropDownList(ArrayHelper::map(Delivery::find()->asArray()->all(), 'id', 'title')) ?>
  53 +
  54 +<?= $form->field($model, 'declaration') ?>
  55 +
  56 +<?= $form->field($model, 'stock') ?>
  57 +
  58 +<?= $form->field($model, 'consignment') ?>
  59 +</div>
  60 +<div class="col-sm-6">
  61 +<?=$form->field($model, 'payment')->dropDownList(['Оплатить наличными'=>'Оплатить наличными','Оплатить на карту Приват Банка'=>'Оплатить на карту Приват Банка','Оплатить по безналичному расчету'=>'Оплатить по безналичному расчету','Оплатить Правекс-телеграф'=>'Оплатить Правекс-телеграф','Наложенным платежом'=>'Наложенным платежом'],['prompt'=>'...']); ?>
  62 +
  63 +<?= $form->field($model, 'insurance') ?>
  64 +
  65 +<?= $form->field($model, 'amount_imposed') ?>
  66 +
  67 +<?= $form->field($model, 'shipping_by') ?>
  68 +
  69 +<?= $form->field($model, 'city') ?>
  70 +
  71 +<?= $form->field($model, 'adress') ?>
  72 +
  73 +<?= $form->field($model, 'body')->textArea(['rows' => '6']) ?>
  74 +
  75 +<?= $form->field($model, 'total') ?>
  76 +
  77 +<?=$form->field($model, 'status')->dropDownList(['Нет'=>'Нет','Обработан'=>'Обработан','На комплектации'=>'На комплектации','Укомплектован'=>'Укомплектован','Доставка'=>'Доставка','Выполнен'=>'Выполнен','Резерв оплачен'=>'Резерв оплачен','Резерв неоплачен'=>'Резерв неоплачен'],['prompt'=>'...']); ?>
  78 +
  79 +<?= $form->field($model, 'comment')->textArea(['rows' => '6']) ?>
  80 +</div>
  81 +<div class="form-group">
  82 + <?= Html::submitButton(' Сохранить ', ['class' => 'btn btn-primary btn-lg btn-block', 'name' => 'login-button']) ?>
  83 + </div>
  84 +
  85 + <?php ActiveForm::end(); ?>
  86 +<hr />
  87 +<?= Html::a('Добавить товар', ['/admin/orders/add','order_id'=>$model->id], ['class'=>'btn btn-success']) ?>
  88 +<?= GridView::widget([
  89 + 'dataProvider' => $dataProvider,
  90 + 'columns' => [
  91 + [
  92 + 'attribute' => 'id',
  93 + 'value'=>'id',
  94 + 'contentOptions'=>['style'=>'width: 70px;']
  95 + ],
  96 + [
  97 + 'attribute' => 'art',
  98 + 'value'=>'art',
  99 + 'contentOptions'=>['style'=>'width: 50px;']
  100 + ],
  101 + [
  102 + 'attribute' => 'product_name',
  103 + 'value'=>'product_name',
  104 + //'contentOptions'=>['style'=>'max-width: 300px;']
  105 + ],
  106 + [
  107 + 'attribute' => 'name',
  108 + 'value'=>'name',
  109 + //'contentOptions'=>['style'=>'max-width: 300px;']
  110 + ],
  111 + [
  112 + 'attribute' => 'cost',
  113 + 'value'=>'cost',
  114 + 'contentOptions'=>['style'=>'width: 100px;']
  115 + ],
  116 + [
  117 + 'attribute' => 'count',
  118 + 'value'=>'count',
  119 + 'contentOptions'=>['style'=>'width: 30px;']
  120 + ],
  121 + [
  122 + 'attribute' => 'sum_cost',
  123 + 'value'=>'sum_cost',
  124 + 'contentOptions'=>['style'=>'width: 100px;']
  125 + ],
  126 + [
  127 + 'class' => 'yii\grid\ActionColumn',
  128 + 'template' => '{delete}',
  129 + 'contentOptions'=>['style'=>'width: 20px;'],
  130 + 'buttons' => [
  131 + 'delete' => function ($url, $model) {
  132 + return Html::a('<span class="glyphicon glyphicon-trash"></span>', ['/admin/orders/delete_product','id'=>$model->id,'order_id'=>$_GET['id']],
  133 + [
  134 + 'title' => "Удалить",'data-confirm'=>'Удалить?',
  135 + ]);
  136 + }
  137 + ],
  138 + ],
  139 +
  140 + ],
  141 +]) ?>
  142 +
  143 +
  144 +
backend/views/orders/view.php deleted
1 -<?php  
2 -  
3 -use yii\helpers\Html;  
4 -use yii\widgets\DetailView;  
5 -  
6 -/* @var $this yii\web\View */  
7 -/* @var $model common\models\Orders */  
8 -  
9 -$this->title = $model->name;  
10 -$this->params['breadcrumbs'][] = ['label' => Yii::t('app', 'Orders'), 'url' => ['index']];  
11 -$this->params['breadcrumbs'][] = $this->title;  
12 -?>  
13 -<div class="orders-view">  
14 -  
15 - <h1><?= Html::encode($this->title) ?></h1>  
16 -  
17 - <p>  
18 - <?= Html::a(Yii::t('app', 'Update'), ['update', 'id' => $model->order_id], ['class' => 'btn btn-primary']) ?>  
19 - <?= Html::a(Yii::t('app', 'Delete'), ['delete', 'id' => $model->order_id], [  
20 - 'class' => 'btn btn-danger',  
21 - 'data' => [  
22 - 'confirm' => Yii::t('app', 'Are you sure you want to delete this item?'),  
23 - 'method' => 'post',  
24 - ],  
25 - ]) ?>  
26 - </p>  
27 -  
28 - <?= DetailView::widget([  
29 - 'model' => $model,  
30 - 'attributes' => [  
31 - 'order_id',  
32 - 'name',  
33 - 'email:email',  
34 - 'phone',  
35 - 'delivery',  
36 - 'payment',  
37 - 'code',  
38 - 'status',  
39 - 'created_at',  
40 - 'updated_at',  
41 - ],  
42 - ]) ?>  
43 -  
44 -</div>  
backend/web/js/site.js 0 → 100644
  1 +$(document).ready(function(){
  2 +
  3 + var iii = true;
  4 +
  5 + // console.log(ddd);
  6 + // if (ddd) {console.log('hello var ddd is correnct')
  7 + // }else {
  8 + // console.log('var ddd is not exist');
  9 + // };
  10 +
  11 + console.log($('button'));
  12 + $('button').click(function(){
  13 +
  14 + var testt = $(this);
  15 +
  16 + var id = $(this).attr('id');
  17 +
  18 + var ddd = document.getElementById('test_tr_class');
  19 +
  20 + // $.post( "index.php?r=order%2Fupdate&id=1", function( data ) {
  21 +
  22 + if (!ddd) {
  23 +
  24 + testt.closest('tr').after(
  25 + '<tr id="test_tr_class">' +
  26 + '<td colspan="12" id="content_'+id+'">' +
  27 + 'data' +
  28 + '</td>' +
  29 + '</tr>'
  30 + );
  31 +
  32 + loadShow(testt,id);
  33 +
  34 + }else{
  35 + document.getElementById('test_tr_class').remove();
  36 + };
  37 +
  38 + iii = false;
  39 + console.log(iii);
  40 +
  41 +
  42 +
  43 +
  44 + });
  45 +
  46 + function loadShow(testt,id){
  47 + $.post( "/admin/orders/show?id=" + id + '"', function( data ) {
  48 +
  49 + $('#content_'+id).html(data);
  50 +
  51 + $('#add_mod').submit(function() {
  52 + $.ajax({
  53 + type: "POST",
  54 + url: "/admin/orders/add?order_id="+id,
  55 + data: $(this).serialize(), // serializes the form's elements.
  56 + success: function(data)
  57 + {
  58 + loadShow(testt,id); // show response from the php script.
  59 + }
  60 + });
  61 + return false;
  62 + });
  63 +
  64 + });
  65 +
  66 + }
  67 +
  68 +
  69 +
  70 +
  71 +
  72 +});
0 \ No newline at end of file 73 \ No newline at end of file
common/components/Mailer.php
@@ -6,7 +6,7 @@ use yii\base\Widget; @@ -6,7 +6,7 @@ use yii\base\Widget;
6 6
7 class Mailer extends Widget{ 7 class Mailer extends Widget{
8 public $message; 8 public $message;
9 - public $email = 'dockdep@gmail.com'; 9 + public $email;
10 public $text; 10 public $text;
11 public $subject; 11 public $subject;
12 12
@@ -30,6 +30,7 @@ class Mailer extends Widget{ @@ -30,6 +30,7 @@ class Mailer extends Widget{
30 $mail->MsgHTML($this->text); 30 $mail->MsgHTML($this->text);
31 $address = "dockdep@gmail.com"; 31 $address = "dockdep@gmail.com";
32 $mail->AddAddress($address); 32 $mail->AddAddress($address);
  33 + $mail->AddAddress($this->email);
33 if(!$mail->send()) { 34 if(!$mail->send()) {
34 \Yii::$app->getSession()->setFlash('error', 'Mailer Error: ' . $mail->ErrorInfo); 35 \Yii::$app->getSession()->setFlash('error', 'Mailer Error: ' . $mail->ErrorInfo);
35 return 'Mailer Error: ' . $mail->ErrorInfo; 36 return 'Mailer Error: ' . $mail->ErrorInfo;
common/models/Customer.php
1 <?php 1 <?php
2 2
3 namespace common\models; 3 namespace common\models;
  4 +use common\components\Mailer;
4 use Yii; 5 use Yii;
5 6
6 class Customer extends \yii\db\ActiveRecord implements \yii\web\IdentityInterface 7 class Customer extends \yii\db\ActiveRecord implements \yii\web\IdentityInterface
@@ -75,43 +76,32 @@ class Customer extends \yii\db\ActiveRecord implements \yii\web\IdentityInterfac @@ -75,43 +76,32 @@ class Customer extends \yii\db\ActiveRecord implements \yii\web\IdentityInterfac
75 } 76 }
76 77
77 public function sendMsg(){ 78 public function sendMsg(){
78 - $body = 'Вас приветствует сайт Rukzachok';  
79 - $body .= "\n\r";  
80 - $body .= 'Ваш логин: '.$this->username;  
81 - $body .= "\n\r";  
82 - $body .= 'Ваш пароль: '.$this->password;  
83 -  
84 -  
85 - Yii::$app->mailer->compose()  
86 - ->setTo($this->username)  
87 - ->setFrom(['send@artweb.ua' => 'send'])  
88 - ->setSubject('Rukzachok Ваш пароль')  
89 - ->setTextBody($body)  
90 - ->send(); 79 + $body = 'Вас приветствует сайт Rukzachok';
  80 + $body .= "\n\r";
  81 + $body .= 'Ваш логин: '.$this->username;
  82 + $body .= "\n\r";
  83 + $body .= 'Ваш пароль: '.$this->password;
  84 +
  85 + Mailer::widget(['text'=> $body, 'subject'=> 'Спасибо за регистрацию', 'email' => $this->username ]);
91 86
92 } 87 }
93 88
94 - public function afterSave($insert, $changedAttributes)  
95 - {  
96 - parent::afterSave($insert, $changedAttributes);  
97 -/*  
98 -$auth = new DbManager;  
99 -$auth->init();  
100 -$role = $auth->createRole('company');  
101 -$auth->add($role);  
102 -$role = $auth->createRole('customer');  
103 -$auth->add($role);  
104 -*/  
105 - // установка роли пользователя  
106 - $auth = Yii::$app->authManager;  
107 - $role = $auth->getRole($this->role);  
108 - if (!$insert) {  
109 - $auth->revokeAll($this->id);  
110 - }  
111 - $auth->assign($role, $this->id);  
112 -  
113 - $this->sendMsg();  
114 - } 89 + public function afterSave($insert, $changedAttributes)
  90 + {
  91 + parent::afterSave($insert, $changedAttributes);
  92 +
  93 + // установка роли пользователя
  94 + $auth = Yii::$app->authManager;
  95 + $role = $auth->getRole($this->role);
  96 + if (!$insert) {
  97 + $auth->revokeAll($this->id);
  98 + }
  99 + $auth->assign($role, $this->id);
  100 +
  101 + if($this->isNewRecord){
  102 + $this->sendMsg();
  103 + }
  104 + }
115 105
116 public function beforeSave($insert) { 106 public function beforeSave($insert) {
117 107
@@ -135,37 +125,32 @@ $auth-&gt;add($role); @@ -135,37 +125,32 @@ $auth-&gt;add($role);
135 return parent::beforeSave($insert); 125 return parent::beforeSave($insert);
136 } 126 }
137 127
138 - public function beforeDelete() {  
139 - //$this->deleteImage($this->image);  
140 - return parent::beforeDelete();  
141 - }  
142 -  
143 - public function deleteImage($file){  
144 - if(!empty($file)){  
145 - @unlink('upload/profile/'.$file);  
146 - @unlink('upload/profile/ico/'.$file);  
147 - // @unlink('upload/fotos/big/'.$file);  
148 - }  
149 - }  
150 -  
151 -  
152 - public function getOld(){  
153 - if(empty($this->birth_year) || empty($this->birth_mouth) || empty($this->birth_day))return;  
154 - $birthday = $this->birth_year.'-'.$this->birth_mouth.'-'.$this->birth_day;  
155 - if($birthday=="0000-00-00")return;  
156 - $birthday_timestamp = strtotime($birthday);  
157 - $age = date('Y') - date('Y', $birthday_timestamp);  
158 - if (date('md', $birthday_timestamp) > date('md')) {  
159 - $age--;  
160 - }  
161 - return $age;  
162 - 128 + public function beforeDelete() {
  129 + //$this->deleteImage($this->image);
  130 + return parent::beforeDelete();
  131 + }
  132 +
  133 + public function deleteImage($file){
  134 + if(!empty($file)){
  135 + @unlink('upload/profile/'.$file);
  136 + @unlink('upload/profile/ico/'.$file);
  137 + // @unlink('upload/fotos/big/'.$file);
  138 + }
  139 + }
  140 +
  141 +
  142 + public function getOld(){
  143 + if(empty($this->birth_year) || empty($this->birth_mouth) || empty($this->birth_day))return;
  144 + $birthday = $this->birth_year.'-'.$this->birth_mouth.'-'.$this->birth_day;
  145 + if($birthday=="0000-00-00")return;
  146 + $birthday_timestamp = strtotime($birthday);
  147 + $age = date('Y') - date('Y', $birthday_timestamp);
  148 + if (date('md', $birthday_timestamp) > date('md')) {
  149 + $age--;
163 } 150 }
164 -  
165 -// public function getOfferCustomer(){  
166 -// return $this->hasMany(OfferCustomer::className(), ['service_user_id' => 'id'])->where(['done'=>1]);  
167 -// }  
168 -// 151 + return $age;
  152 +
  153 + }
169 154
170 /** 155 /**
171 * @inheritdoc 156 * @inheritdoc
common/models/Orders.php
@@ -18,7 +18,7 @@ class Orders extends \yii\db\ActiveRecord @@ -18,7 +18,7 @@ class Orders extends \yii\db\ActiveRecord
18 return [ 18 return [
19 [['name', 'phone'], 'required','whenClient' => true], 19 [['name', 'phone'], 'required','whenClient' => true],
20 //['email', 'email'], 20 //['email', 'email'],
21 - [['total','body','patronymic','surname','email','phone2','delivery','payment'], 'safe'], 21 + [['total','body','email','phone2','delivery','payment'], 'safe'],
22 [['email'],'email'], 22 [['email'],'email'],
23 ]; 23 ];
24 } 24 }
@@ -26,14 +26,12 @@ class Orders extends \yii\db\ActiveRecord @@ -26,14 +26,12 @@ class Orders extends \yii\db\ActiveRecord
26 public function attributeLabels() 26 public function attributeLabels()
27 { 27 {
28 return [ 28 return [
29 - 'name' => 'Имя', 29 + 'name' => 'Ф.И.О',
30 'phone'=>'Телефон', 30 'phone'=>'Телефон',
31 'phone2'=>'Дополнительный телефон', 31 'phone2'=>'Дополнительный телефон',
32 'body'=>'Сообщение', 32 'body'=>'Сообщение',
33 'adress'=>'Адрес', 33 'adress'=>'Адрес',
34 'city'=>'Город', 34 'city'=>'Город',
35 - 'patronymic'=>'Отчество',  
36 - 'surname'=>'Фамилия',  
37 'email'=>'E-mail', 35 'email'=>'E-mail',
38 'date_time'=>'Дата', 36 'date_time'=>'Дата',
39 'total'=>'Сума', 37 'total'=>'Сума',
@@ -60,10 +58,6 @@ class Orders extends \yii\db\ActiveRecord @@ -60,10 +58,6 @@ class Orders extends \yii\db\ActiveRecord
60 $body .= "\n\r"; 58 $body .= "\n\r";
61 $body .= 'Имя: '.$this->name; 59 $body .= 'Имя: '.$this->name;
62 $body .= "\n\r"; 60 $body .= "\n\r";
63 - $body .= 'Фамилия: '.$this->surname;  
64 - $body .= "\n\r";  
65 - $body .= 'Отчество: '.$this->patronymic;  
66 - $body .= "\n\r";  
67 $body .= 'E-mail: '.$this->email; 61 $body .= 'E-mail: '.$this->email;
68 $body .= "\n\r"; 62 $body .= "\n\r";
69 $body .= 'Телефон: '.$this->phone; 63 $body .= 'Телефон: '.$this->phone;
@@ -190,7 +184,12 @@ class Orders extends \yii\db\ActiveRecord @@ -190,7 +184,12 @@ class Orders extends \yii\db\ActiveRecord
190 184
191 return $mod->price; 185 return $mod->price;
192 } 186 }
193 - 187 + public function clearBasket ()
  188 + {
  189 + $session = new Session;
  190 + $session->open ();
  191 + $session['basket'] = null;
  192 + }
194 public function getUser() 193 public function getUser()
195 { 194 {
196 return $this->hasOne(User::className(), ['id' => 'user_id']); 195 return $this->hasOne(User::className(), ['id' => 'user_id']);
common/modules/product/models/ProductVariant.php
@@ -24,6 +24,16 @@ use Yii; @@ -24,6 +24,16 @@ use Yii;
24 */ 24 */
25 class ProductVariant extends \yii\db\ActiveRecord 25 class ProductVariant extends \yii\db\ActiveRecord
26 { 26 {
  27 +
  28 + /**just for rukzachok**/
  29 + public $count;
  30 + public $sum_cost;
  31 + public $product_name;
  32 + //public $image;
  33 + public $translit;
  34 + public $translit_rubric;
  35 + private $data;
  36 +
27 /** @var array $_images */ 37 /** @var array $_images */
28 // public $imagesUpload = []; 38 // public $imagesUpload = [];
29 /** 39 /**
console/migrations/m160517_072059_delete_product_fk.php 0 → 100644
  1 +<?php
  2 +
  3 +use yii\db\Migration;
  4 +
  5 +class m160517_072059_delete_product_fk extends Migration
  6 +{
  7 + public function up()
  8 + {
  9 + $this->dropForeignKey('orders_products_fk', '{{%orders_products}}');
  10 + $this->dropForeignKey('orders_products_items_fk', '{{%orders_products}}');
  11 + }
  12 +
  13 + public function down()
  14 + {
  15 +
  16 + $this->addForeignKey('orders_products_fk', '{{%orders_products}}', 'order_id', '{{%orders}}', 'id', 'CASCADE', 'CASCADE');
  17 + $this->addForeignKey('orders_products_items_fk', '{{%orders_products}}', 'id', '{{%product}}', 'product_id', 'RESTRICT', 'RESTRICT');
  18 + }
  19 +
  20 + /*
  21 + // Use safeUp/safeDown to run migration code within a transaction
  22 + public function safeUp()
  23 + {
  24 + }
  25 +
  26 + public function safeDown()
  27 + {
  28 + }
  29 + */
  30 +}
console/migrations/m160517_073502_orders_label.php 0 → 100644
  1 +<?php
  2 +
  3 +use yii\db\Migration;
  4 +
  5 +class m160517_073502_orders_label extends Migration
  6 +{
  7 + public function up()
  8 + {
  9 + $this->createTable('{{%orders_label}}', [
  10 + 'id' => $this->primaryKey(),
  11 + 'name' => $this->string(),
  12 + 'label' => $this->string()
  13 + ]);
  14 + }
  15 +
  16 + public function down()
  17 + {
  18 + $this->dropTable('{{%orders_label}}');
  19 + }
  20 +
  21 + /*
  22 + // Use safeUp/safeDown to run migration code within a transaction
  23 + public function safeUp()
  24 + {
  25 + }
  26 +
  27 + public function safeDown()
  28 + {
  29 + }
  30 + */
  31 +}
console/migrations/m160518_185644_change_order.php 0 → 100644
  1 +<?php
  2 +
  3 +use yii\db\Migration;
  4 +
  5 +class m160518_185644_change_order extends Migration
  6 +{
  7 + public function up()
  8 + {
  9 + $this->dropColumn('orders', 'surname');
  10 + $this->dropColumn('orders', 'patronymic');
  11 + }
  12 +
  13 + public function down()
  14 + {
  15 + $this->addColumn('orders', 'surname','string');
  16 + $this->addColumn('orders', 'patronymic','string');
  17 + }
  18 +
  19 + /*
  20 + // Use safeUp/safeDown to run migration code within a transaction
  21 + public function safeUp()
  22 + {
  23 + }
  24 +
  25 + public function safeDown()
  26 + {
  27 + }
  28 + */
  29 +}
frontend/assets/AppAsset.php
@@ -19,7 +19,7 @@ class AppAsset extends AssetBundle @@ -19,7 +19,7 @@ class AppAsset extends AssetBundle
19 public $baseUrl = '@web'; 19 public $baseUrl = '@web';
20 public $css = [ 20 public $css = [
21 'css/style.css', 21 'css/style.css',
22 - 'http://fonts.googleapis.com/css?family=Ubuntu', 22 + 'http://fonts.googleapis.com/css?family=Roboto',
23 ]; 23 ];
24 public $js = [ 24 public $js = [
25 ]; 25 ];
frontend/config/main.php
@@ -85,6 +85,8 @@ return [ @@ -85,6 +85,8 @@ return [
85 'brends' => 'brends/index', 85 'brends' => 'brends/index',
86 'blog' => 'articles/index', 86 'blog' => 'articles/index',
87 'blog/<translit:[\w\-]+>-<id:\d+>' => 'articles/show', 87 'blog/<translit:[\w\-]+>-<id:\d+>' => 'articles/show',
  88 + 'event' => 'event/index',
  89 + 'event/<alias:[\w\-]+>-<id:\d+>' => 'event/show',
88 '<language:(ru|ua|en)>/<module:\w+>/<controller:\w+>/<action:\w+>' => '<module>/<controller>/<action>', 90 '<language:(ru|ua|en)>/<module:\w+>/<controller:\w+>/<action:\w+>' => '<module>/<controller>/<action>',
89 '<language:(ru|ua|en)>/<controller:\w+>/<action:\w+>' => '<controller>/<action>', 91 '<language:(ru|ua|en)>/<controller:\w+>/<action:\w+>' => '<controller>/<action>',
90 '<language:(ru|ua|en)>/admin' => 'admin/default/index', 92 '<language:(ru|ua|en)>/admin' => 'admin/default/index',
frontend/controllers/BasketController.php
@@ -26,19 +26,20 @@ class BasketController extends Controller @@ -26,19 +26,20 @@ class BasketController extends Controller
26 } 26 }
27 27
28 if(isset($_POST['update'])){ 28 if(isset($_POST['update'])){
29 - foreach ($_POST['Mod'] as $index=>$row) { 29 + foreach ($_POST['ProductVariant'] as $index=>$row) {
30 $modelOrder->updateBasket($row); 30 $modelOrder->updateBasket($row);
31 } 31 }
32 - }elseif(isset($_POST['Mod'])){ 32 + }elseif(isset($_POST['ProductVariant'])){
  33 +// die(print_r($_POST));
33 $body = ''; 34 $body = '';
34 - foreach ($_POST['Mod'] as $index=>$row) { 35 + foreach ($_POST['ProductVariant'] as $index=>$row) {
35 $body .= $row['product_name'].' '.$row['name'].' Кол:'.$row['count'].' Цена:'.$row['sum_cost']; 36 $body .= $row['product_name'].' '.$row['name'].' Кол:'.$row['count'].' Цена:'.$row['sum_cost'];
36 $body .= "\n\r"; 37 $body .= "\n\r";
37 } 38 }
38 $body .= "\n\r"; 39 $body .= "\n\r";
39 40
40 if ($modelOrder->load(Yii::$app->request->post()) && $modelOrder->save() && $modelOrder->contact('borisenko.pavel@gmail.com',$body)) { 41 if ($modelOrder->load(Yii::$app->request->post()) && $modelOrder->save() && $modelOrder->contact('borisenko.pavel@gmail.com',$body)) {
41 - foreach ($_POST['Mod'] as $index=>$row) { 42 + foreach ($_POST['ProductVariant'] as $index=>$row) {
42 $modelOrdersProducts = new OrdersProducts(); 43 $modelOrdersProducts = new OrdersProducts();
43 $mod_id = $row['id']; 44 $mod_id = $row['id'];
44 unset($row['id']); 45 unset($row['id']);
@@ -49,7 +50,7 @@ class BasketController extends Controller @@ -49,7 +50,7 @@ class BasketController extends Controller
49 $modelOrdersProducts->load($data); 50 $modelOrdersProducts->load($data);
50 $modelOrdersProducts->save(); 51 $modelOrdersProducts->save();
51 } 52 }
52 - if(!Yii::$app->user->id){ 53 + if(!Yii::$app->user->id && !empty($modelOrder->email)){
53 $modelUser = new Customer(); 54 $modelUser = new Customer();
54 $modelUser->role = 'person'; 55 $modelUser->role = 'person';
55 $modelUser->username = $modelOrder->email; 56 $modelUser->username = $modelOrder->email;
@@ -59,7 +60,7 @@ class BasketController extends Controller @@ -59,7 +60,7 @@ class BasketController extends Controller
59 $modelUser->group_id = 2; 60 $modelUser->group_id = 2;
60 $modelUser->save(); 61 $modelUser->save();
61 } 62 }
62 - $modelMod->clearBasket(); 63 + $modelOrder->clearBasket();
63 return Yii::$app->response->redirect(['basket/success']); 64 return Yii::$app->response->redirect(['basket/success']);
64 } 65 }
65 } 66 }
@@ -71,7 +72,6 @@ class BasketController extends Controller @@ -71,7 +72,6 @@ class BasketController extends Controller
71 $modelOrder->email = $user->username; 72 $modelOrder->email = $user->username;
72 $modelOrder->phone = $user->phone; 73 $modelOrder->phone = $user->phone;
73 $modelOrder->name = $user->name; 74 $modelOrder->name = $user->name;
74 - $modelOrder->surname = $user->surname;  
75 } 75 }
76 76
77 return $this->render('index', [ 77 return $this->render('index', [
frontend/controllers/EventController.php 100755 → 100644
1 -<?php  
2 -  
3 -namespace frontend\controllers;  
4 -  
5 -use Yii;  
6 -use common\models\Event;  
7 -use yii\web\Controller;  
8 -use yii\web\NotFoundHttpException;  
9 -use yii\data\ActiveDataProvider;  
10 -  
11 -  
12 -  
13 -class EventController extends Controller  
14 -{  
15 -  
16 - public function actionIndex()  
17 - {  
18 -  
19 - $dataProvider = new ActiveDataProvider([  
20 - 'query' => Event::find() ]);  
21 -  
22 - return $this->render('index', [  
23 - 'dataProvider' => $dataProvider,  
24 - ]);  
25 - }  
26 -  
27 -  
28 -  
29 - public function actionView($alias)  
30 - {  
31 -  
32 - return $this->render('view', [  
33 - 'model' => $this->findModel($alias),  
34 - ]);  
35 - }  
36 -  
37 -  
38 - protected function findModel($alias)  
39 - {  
40 - if (($model = Event::findOne(["alias"=>$alias])) !== null) {  
41 - return $model;  
42 - } else {  
43 - throw new NotFoundHttpException('The requested page does not exist.');  
44 - }  
45 - }  
46 -  
47 - 1 +<?php
  2 +
  3 +namespace frontend\controllers;
  4 +
  5 +use Yii;
  6 +use common\models\Event;
  7 +use yii\web\Controller;
  8 +use yii\web\NotFoundHttpException;
  9 +use yii\data\ActiveDataProvider;
  10 +
  11 +
  12 +
  13 +class EventController extends Controller
  14 +{
  15 +
  16 + public function actionIndex()
  17 + {
  18 +
  19 + $dataProvider = new ActiveDataProvider([
  20 + 'query' => Event::find() ]);
  21 +
  22 + return $this->render('index', [
  23 + 'dataProvider' => $dataProvider,
  24 + ]);
  25 + }
  26 +
  27 +
  28 +
  29 + public function actionShow($alias)
  30 + {
  31 +
  32 + return $this->render('show', [
  33 + 'model' => $this->findModel($alias),
  34 + ]);
  35 + }
  36 +
  37 +
  38 + protected function findModel($alias)
  39 + {
  40 + if (($model = Event::findOne(["alias"=>$alias])) !== null) {
  41 + return $model;
  42 + } else {
  43 + throw new NotFoundHttpException('The requested page does not exist.');
  44 + }
  45 + }
  46 +
  47 +
48 } 48 }
49 \ No newline at end of file 49 \ No newline at end of file
frontend/views/basket/index.php
@@ -43,12 +43,10 @@ $(&#39;#order-delivery input[type=\&quot;radio\&quot;]&#39;).click(function(){ @@ -43,12 +43,10 @@ $(&#39;#order-delivery input[type=\&quot;radio\&quot;]&#39;).click(function(){
43 <?= Html::a('Вернуться в каталог', ['/site/index'], ['class'=>'btn-success']) ?> 43 <?= Html::a('Вернуться в каталог', ['/site/index'], ['class'=>'btn-success']) ?>
44 <?php $form = ActiveForm::begin(['enableClientScript' => false]); ?> 44 <?php $form = ActiveForm::begin(['enableClientScript' => false]); ?>
45 <div class="rightbar"> 45 <div class="rightbar">
46 - <div class="form-order">  
47 -<?php echo $form->field($modelOrder,'surname'); ?> 46 + <div class="form-order">
48 <?php echo $form->field($modelOrder,'name'); ?> 47 <?php echo $form->field($modelOrder,'name'); ?>
49 -<?php echo $form->field($modelOrder,'patronymic'); ?>  
50 <?php echo $form->field($modelOrder,'phone'); ?> 48 <?php echo $form->field($modelOrder,'phone'); ?>
51 -<?php echo $form->field($modelOrder,'phone2'); ?> 49 +<?php echo $form->field($modelOrder,'phone2'); ?>
52 <?php echo $form->field($modelOrder,'city'); ?> 50 <?php echo $form->field($modelOrder,'city'); ?>
53 <?php echo $form->field($modelOrder,'adress'); ?> 51 <?php echo $form->field($modelOrder,'adress'); ?>
54 <?php echo $form->field($modelOrder,'email'); ?> 52 <?php echo $form->field($modelOrder,'email'); ?>
frontend/views/event/_objects.php 100755 → 100644
@@ -2,37 +2,10 @@ @@ -2,37 +2,10 @@
2 use yii\helpers\Html; 2 use yii\helpers\Html;
3 use frontend\helpers\TextHelper; 3 use frontend\helpers\TextHelper;
4 use yii\helpers\Url; 4 use yii\helpers\Url;
5 - 5 +use frontend\components\Text;
6 ?> 6 ?>
7 -<div class="portfolio-portfolio">  
8 - <div class="portfolio-portfolio-overflow">  
9 -  
10 - <div class="portfolio-portfolio-img-wrap">  
11 - <div class="portfolio-portfolio-img">  
12 - <?= Html::a(Html::img($model->minImg($model->image, '200','200')),Url::toRoute(['event/view', 'alias' =>$model->alias ])) ?>  
13 - </div>  
14 - </div>  
15 -  
16 - <div class="portfolio-portfolio-text-wrap">  
17 -  
18 -  
19 - <div class="portfolio-category-name"><?= Html::a($model->name,Url::toRoute(['event/view', 'alias' =>$model->alias ])) ?></div>  
20 - <div class="date_end">  
21 - Срок действия по: <?= $model->end_at?>  
22 - </div>  
23 - <div class="portfolio-text-name">  
24 - <p>  
25 - <span><?= TextHelper::truncateHtmlText($model->body, 200, '...') ?></span>  
26 - </p>  
27 - </div>  
28 - <table class="tov-tb-3" cellspacing="0" cellpadding="0" border="0">  
29 - <tbody>  
30 - <tr>  
31 - <td height="25"><img src="/images/ico-2.jpg" alt=""></td>  
32 - <td height="25"></td><td><a class="consultation_btn" href="#" style="margin-left: 11px; font-size: 13px; font-family: arial; color: #6b7b9d; border-bottom: 1px dotted;">Заказать консультацию</a></td>  
33 - </tr>  
34 - </tbody>  
35 - </table>  
36 - </div>  
37 - </div> 7 +<div class="news_item">
  8 + <a href="<?=Url::to(['event/show','alias'=>$model->alias,'id'=>$model->primaryKey])?>"><img src="<?=Yii::$app->request->baseUrl.'/storage/articles/ico/'.$model->image?>" width="180" height="125" border="0" align="left" /></a>
  9 + <a href="<?=Url::to(['event/show','alias'=>$model->alias,'id'=>$model->primaryKey])?>" class="name"><?=$model->name?></a><br />
  10 + <?=Text::getShort($model->body,600);?><div class="both"></div>
38 </div> 11 </div>
39 \ No newline at end of file 12 \ No newline at end of file
frontend/views/event/index.php
1 <?php 1 <?php
  2 +use yii\helpers\Url;
  3 +use yii\widgets\Breadcrumbs;
  4 +//use app\models\News;
  5 +use yii\widgets\LinkPager;
  6 +
2 use yii\widgets\ListView; 7 use yii\widgets\ListView;
3 -use frontend\widgets\Seo;  
4 -$this->params['breadcrumbs'][] = ['label' => 'Акции', 'url' => ['index']];  
5 -$this->params['seo']['seo_text'] = 'TEST SEO TEXT';  
6 -$this->params['seo']['h1'] = 'TEST H1';  
7 -$this->params['seo']['description'] = 'TEST DESCRIPTION';  
8 -$this->params['seo']['fields']['name'] = 'TEST NAME FROM FIELD';  
9 -?>  
10 8
  9 +?>
11 <?php 10 <?php
12 - echo ListView::widget( [  
13 - 'dataProvider' => $dataProvider,  
14 - 'itemView'=>'_objects',  
15 - 'summary'=>'',  
16 - 'layout' => "<div class='portfolio-block-left'>{items}</div>  
17 - <div class='pager-block' id='pager-block-single'>{pager}</div>"  
18 - ] ); 11 +$this->title = 'Акции';
  12 +$this->registerMetaTag(['name' => 'description', 'content' => 'Акции']);
  13 +$this->registerMetaTag(['name' => 'keywords', 'content' => 'Акции']);
19 ?> 14 ?>
20 -<div class="seo-text">  
21 - <?= Seo::widget(['row'=>'seo_text'])?>  
22 -</div> 15 +
  16 + <nav class="bread-crumbs">
  17 + <?= Breadcrumbs::widget([
  18 + 'links' => [
  19 + 'Акции'
  20 + ],
  21 + ]) ?>
  22 + <div class="both"></div>
  23 + </nav>
  24 +
  25 +<div class="layout">
  26 +
  27 + <div class="content">
  28 + <h1>Акции</h1>
  29 + <?php
  30 + echo ListView::widget( [
  31 + 'dataProvider' => $dataProvider,
  32 + 'itemView'=>'_objects',
  33 + 'summary'=>''
  34 + ] );
  35 + ?>
  36 +
  37 + <div class="both"></div>
  38 +
  39 +
  40 + </div>
  41 +
  42 +</div>
23 \ No newline at end of file 43 \ No newline at end of file
frontend/views/event/show.php 0 → 100755
  1 +<?php
  2 +use yii\helpers\Url;
  3 +use yii\widgets\Breadcrumbs;
  4 +?>
  5 +<?php
  6 +$this->title = $model->name;
  7 +
  8 +?>
  9 +
  10 + <nav class="bread-crumbs">
  11 + <?= Breadcrumbs::widget([
  12 + 'links' => [
  13 + ['label'=>'Акции','url'=>['news/index']],
  14 + $model->name
  15 + ],
  16 + ]) ?>
  17 + <div class="both"></div>
  18 + </nav>
  19 +
  20 +<div class="layout">
  21 +
  22 + <div class="content">
  23 + <h1><?=$model->name?></h1>
  24 +
  25 + <img src="<?=Yii::$app->request->baseUrl.'/storage/articles/big/'.$model->image?>" width="400" height="400" border="0" align="left" class='pic' />
  26 + <?=$model->body?>
  27 + </div>
  28 +
  29 +</div>
0 \ No newline at end of file 30 \ No newline at end of file
frontend/views/event/view.php deleted
1 -<?php  
2 -  
3 -use yii\helpers\Html;  
4 -use yii\widgets\DetailView;  
5 -use frontend\widgets\Seo;  
6 -/* @var $this yii\web\View */  
7 -/* @var $model common\models\Stone */  
8 -  
9 -$this->title = $model->name;  
10 -$this->params['breadcrumbs'][] = ['label' => 'Акции', 'url' => ['index']];  
11 -$this->params['breadcrumbs'][] = $this->title;  
12 -$this->params['name'] = $this->title;  
13 -?>  
14 -<div class="events-one-item">  
15 - <h1><?= $model->name?></h1>  
16 - <?= Html::img($model->minImg($model->image, '940','480')) ?>  
17 - <div class="date_end">  
18 - Срок действия по: <?= $model->end_at?>  
19 - </div>  
20 - <div class="content-last-block-text-wrap">  
21 - <?= $model->body?>  
22 - </div>  
23 - <?php  
24 - echo \common\modules\comment\widgets\CommentWidget::widget([  
25 - 'context' => $this,  
26 - 'model' => $model->className(),  
27 - 'model_id' => $model->event_id,  
28 - 'comment_class' => \common\modules\comment\models\Comment::className(),  
29 - 'rating_class' => \common\modules\comment\models\Rating::className(),  
30 - 'class_options' => [  
31 - 'scenario' => is_int(\Yii::$app->user->getId()) ? \common\modules\comment\models\Comment::SCENARIO_USER : \common\modules\comment\models\Comment::SCENARIO_GUEST,  
32 - 'user_id' => \Yii::$app->user->getId(),  
33 - 'guestComment' => true,  
34 - 'status' => \common\modules\comment\models\Comment::STATUS_ACTIVE,  
35 - ],  
36 - 'list_options' => [  
37 - 'view' => 'list-comment-review',  
38 - ],  
39 - 'form_options' => [  
40 - 'view' => 'form-comment-review',  
41 - 'tag' => 'span',  
42 - ],  
43 - 'options' => [  
44 - 'class' => 'proektant-comments-wr style',  
45 - ],  
46 - ]);  
47 - ?>  
48 -</div>  
49 -<div class="seo-text">  
50 - <?= Seo::widget(['row'=>'seo_text'])?>  
51 -</div>  
frontend/views/layouts/main-menu.php 0 → 100644
  1 +<?php
  2 +use common\modules\product\models\Category;
  3 +use yii\helpers\Url;
  4 +use yii\widgets\Menu;
  5 +
  6 +
  7 +foreach (Category::find ()->all () as $category){
  8 + $categoryObject = Yii::$app->request->get('category');
  9 + $menu[] = ['label' => $category->name ,
  10 + 'url' => Url::to(['catalog/category', 'category' => $category]),
  11 + 'active' => isset($categoryObject) && $categoryObject->alias == $category->alias ? true : false ];
  12 +}
  13 +
  14 +$main_menu = Menu::widget([
  15 + 'items' => $menu,
  16 +]);
  17 +?>
  18 +
  19 +<?=$main_menu?>
  20 +<div class="fr">
  21 + <ul>
  22 + <li class="akciya"><a href="<?= Url::to (['event/index',]) ?>">Акции</a></li>
  23 + <li class="brands"><a href="<?= Url::to (['brand/index']) ?>">Бренды</a></li>
  24 + </ul>
  25 +</div>
frontend/views/layouts/main.php
@@ -154,19 +154,7 @@ @@ -154,19 +154,7 @@
154 154
155 155
156 <div class="menu"> 156 <div class="menu">
157 - <ul>  
158 - <?php foreach (Category::find ()->all () as $category): ?>  
159 - <li><a href="<?= \yii\helpers\Url::to(['catalog/category', 'category' => $category])?>"><?= $category->name ?></a>  
160 - </li>  
161 - <?php endforeach; ?>  
162 - </ul>  
163 -  
164 - <div class="fr">  
165 - <ul>  
166 - <li class="akciya"><a href="<?= Url::to (['text/index', 'translit' => 'akcii']) ?>">Акции</a></li>  
167 - <li class="brands"><a href="<?= Url::to (['brand/index']) ?>">Бренды</a></li>  
168 - </ul>  
169 - </div> 157 + <?= $this->render('main-menu', Category::find ()->all())?>
170 <div class="both"></div> 158 <div class="both"></div>
171 </div> 159 </div>
172 160
@@ -306,7 +294,7 @@ @@ -306,7 +294,7 @@
306 <li><a href="<?= Url::to (['text/index', 'translit' => 'oplata_i_dostavka']) ?>">Оплата и 294 <li><a href="<?= Url::to (['text/index', 'translit' => 'oplata_i_dostavka']) ?>">Оплата и
307 доставка</a></li> 295 доставка</a></li>
308 <li><a href="<?= Url::to (['iam/index']) ?>">Личный кабинет</a></li> 296 <li><a href="<?= Url::to (['iam/index']) ?>">Личный кабинет</a></li>
309 - <li><a href="#">Акции</a></li> 297 + <li><a href="<?= Url::to (['event/index']) ?>">Акции</a></li>
310 <li><a href="<?= Url::to (['text/index', 'translit' => 'about']) ?>">О магазине</a></li> 298 <li><a href="<?= Url::to (['text/index', 'translit' => 'about']) ?>">О магазине</a></li>
311 </ul> 299 </ul>
312 300
frontend/web/css/style.css
1 html,form, 1 html,form,
2 -body { padding:0px;margin:0px;  
3 -font-family: 'Ubuntu',Arial, Tahoma, Helvetica, sans-serif;font-size:14px;color:#1d1d1b;height:100%; 2 +body { padding:0;margin:0;
  3 + font-family: 'Roboto';font-size:14px;color:#1d1d1b;height:100%;
4 } 4 }
5 h1,h2,h3{margin:0px;padding:0px 0px 10px 0px;} 5 h1,h2,h3{margin:0px;padding:0px 0px 10px 0px;}
6 .fl{float:left;} 6 .fl{float:left;}
@@ -8,7 +8,7 @@ h1,h2,h3{margin:0px;padding:0px 0px 10px 0px;} @@ -8,7 +8,7 @@ h1,h2,h3{margin:0px;padding:0px 0px 10px 0px;}
8 .fotter .wrap .fr img{position: absolute; top: 50%; margin-top: -10px; right: 0;} 8 .fotter .wrap .fr img{position: absolute; top: 50%; margin-top: -10px; right: 0;}
9 .fotter .wrap .fl {line-height: 50px;} 9 .fotter .wrap .fl {line-height: 50px;}
10 .both{clear:both;} 10 .both{clear:both;}
11 -h1{margin:10px 0px;font-size:24px;} 11 +h1{margin:10px 0;font-size:24px;}
12 h3{margin-bottom:30px;} 12 h3{margin-bottom:30px;}
13 p{margin:3px 0px;padding:0px;} 13 p{margin:3px 0px;padding:0px;}
14 14
@@ -21,9 +21,9 @@ a:hover{color:#799920;} @@ -21,9 +21,9 @@ a:hover{color:#799920;}
21 .f{background: #ffffff;} 21 .f{background: #ffffff;}
22 22
23 .br{-webkit-box-shadow: -1px 5px 14px 0px rgba(50, 46, 50, 0.46); 23 .br{-webkit-box-shadow: -1px 5px 14px 0px rgba(50, 46, 50, 0.46);
24 --moz-box-shadow: -1px 5px 14px 0px rgba(50, 46, 50, 0.46);  
25 -box-shadow: -1px 5px 14px 0px rgba(50, 46, 50, 0.46);  
26 -padding:20px;} 24 + -moz-box-shadow: -1px 5px 14px 0px rgba(50, 46, 50, 0.46);
  25 + box-shadow: -1px 5px 14px 0px rgba(50, 46, 50, 0.46);
  26 + padding:20px;}
27 27
28 nav.top{background:#f5f5f5;padding:10px 0px;border-bottom:1px solid #d2d2d2;font-size:12px;} 28 nav.top{background:#f5f5f5;padding:10px 0px;border-bottom:1px solid #d2d2d2;font-size:12px;}
29 nav.top ul{list-style:none;margin:0px;padding:0px;} 29 nav.top ul{list-style:none;margin:0px;padding:0px;}
@@ -64,10 +64,14 @@ nav input[type=&quot;submit&quot;]{width:35px;height:29px;border:none;background:url(&#39;../i @@ -64,10 +64,14 @@ nav input[type=&quot;submit&quot;]{width:35px;height:29px;border:none;background:url(&#39;../i
64 .basket a:link,.basket a:visited{text-decoration:none;color:#000000;font-size:18px;} 64 .basket a:link,.basket a:visited{text-decoration:none;color:#000000;font-size:18px;}
65 65
66 .basket span.more {margin-bottom: -1px} 66 .basket span.more {margin-bottom: -1px}
67 -.menu{background:#596065;border:1px solid #e8e8e8;} 67 +.menu{
  68 + background:#596065;
  69 + /*border:1px solid #e8e8e8;*/
  70 +}
68 .menu ul{margin:0px;padding:0px;list-style:none;} 71 .menu ul{margin:0px;padding:0px;list-style:none;}
69 -.menu ul li{float:left;border-right:1px solid #e8e8e8;}  
70 -.menu ul li a{float:left;padding:15px 20px 15px 20px;text-transform: uppercase;color:#ffffff;font-size:14px;font-weight:bold;text-decoration: none;} 72 +.menu ul li{float:left;border-left:1px solid #e8e8e8;}
  73 +.menu ul li:first-child{border-left:none;}
  74 +.menu ul li a{float:left;padding:15px 20px 15px 20px;text-transform: uppercase;color:#ffffff;font-size:14px;text-decoration: none;}
71 .menu ul li a:hover{color:#e5e4e4;} 75 .menu ul li a:hover{color:#e5e4e4;}
72 .menu ul li.active a{background:#f5f5f5;color:#596065;} 76 .menu ul li.active a{background:#f5f5f5;color:#596065;}
73 77
@@ -79,7 +83,7 @@ nav input[type=&quot;submit&quot;]{width:35px;height:29px;border:none;background:url(&#39;../i @@ -79,7 +83,7 @@ nav input[type=&quot;submit&quot;]{width:35px;height:29px;border:none;background:url(&#39;../i
79 83
80 .fr ul li{border:none;} 84 .fr ul li{border:none;}
81 .akciya a{background:#f75d50;color:#ffffff;} 85 .akciya a{background:#f75d50;color:#ffffff;}
82 -.brends a{background:#95ba2f;color:#ffffff;} 86 +.brands a{background:#95ba2f;color:#ffffff;}
83 87
84 a.myorders{color:#f75d50} 88 a.myorders{color:#f75d50}
85 89
@@ -197,26 +201,26 @@ ul.product_colors li img{border:1px solid #d2d2d2;} @@ -197,26 +201,26 @@ ul.product_colors li img{border:1px solid #d2d2d2;}
197 201
198 202
199 .modal_box{ 203 .modal_box{
200 - position: fixed;  
201 - left: 0;  
202 - top: 0;  
203 - width: 100%;  
204 - height: 100%;  
205 - z-index: 999;  
206 -  
207 - background: #000;  
208 -filter:progid:DXImageTransform.Microsoft.Alpha(opacity=50); /* IE 5.5+*/  
209 --moz-opacity: 0.5; /* Mozilla 1.6 Р С‘ РЅРёР¶Рµ */  
210 --khtml-opacity: 0.5; /* Konqueror 3.1, Safari 1.1 */  
211 -opacity: 0.5;  
212 - 204 + position: fixed;
  205 + left: 0;
  206 + top: 0;
  207 + width: 100%;
  208 + height: 100%;
  209 + z-index: 999;
  210 +
  211 + background: #000;
  212 + filter:progid:DXImageTransform.Microsoft.Alpha(opacity=50); /* IE 5.5+*/
  213 + -moz-opacity: 0.5; /* Mozilla 1.6 Р С‘ РЅРёР¶Рµ */
  214 + -khtml-opacity: 0.5; /* Konqueror 3.1, Safari 1.1 */
  215 + opacity: 0.5;
  216 +
213 } 217 }
214 #data_box{position:absolute;top:100px;z-index:1000;width:400px;background:#ffffff; 218 #data_box{position:absolute;top:100px;z-index:1000;width:400px;background:#ffffff;
215 - -webkit-box-shadow: 0 0 15px #000;  
216 - -moz-box-shadow: 0 0 15px #000;  
217 - box-shadow: 0 0 15px #000;  
218 - border:7px solid #1b9bb6;  
219 - border-radius:5px; 219 + -webkit-box-shadow: 0 0 15px #000;
  220 + -moz-box-shadow: 0 0 15px #000;
  221 + box-shadow: 0 0 15px #000;
  222 + border:7px solid #1b9bb6;
  223 + border-radius:5px;
220 } 224 }
221 #data_box .data_wrp{padding:25px 15px 15px 15px;} 225 #data_box .data_wrp{padding:25px 15px 15px 15px;}
222 #data_box .data_wrp h1{text-transform: uppercase;} 226 #data_box .data_wrp h1{text-transform: uppercase;}
@@ -229,10 +233,10 @@ opacity: 0.5; @@ -229,10 +233,10 @@ opacity: 0.5;
229 .rightbar .control-label{float:left;width:80px;padding-top:5px;} 233 .rightbar .control-label{float:left;width:80px;padding-top:5px;}
230 .form-control{outline:0;border:1px solid #d8d6d6;border-radius:5px;padding:5px 0px 5px 0px;font-size:14px;text-indent:10px;margin-bottom:3px;width:250px;} 234 .form-control{outline:0;border:1px solid #d8d6d6;border-radius:5px;padding:5px 0px 5px 0px;font-size:14px;text-indent:10px;margin-bottom:3px;width:250px;}
231 .form-control:focus { 235 .form-control:focus {
232 -border:#1b9bb6 1px solid;  
233 -box-shadow: 0 0 10px #1b9bb6;  
234 --webkit-box-shadow: 0 0 10px #1b9bb6;  
235 --moz-box-shadow: 0 0 10px #1b9bb6; 236 + border:#1b9bb6 1px solid;
  237 + box-shadow: 0 0 10px #1b9bb6;
  238 + -webkit-box-shadow: 0 0 10px #1b9bb6;
  239 + -moz-box-shadow: 0 0 10px #1b9bb6;
236 } 240 }
237 .help-block{color:red;font-size:12px;margin-bottom:5px;} 241 .help-block{color:red;font-size:12px;margin-bottom:5px;}
238 242
@@ -337,22 +341,22 @@ ul.social {margin-top: 20px;} @@ -337,22 +341,22 @@ ul.social {margin-top: 20px;}
337 transition: all 0.5s ease-out; 341 transition: all 0.5s ease-out;
338 } 342 }
339 .social .fb{background-position:-44px 0; 343 .social .fb{background-position:-44px 0;
340 -cursor: pointer; 344 + cursor: pointer;
341 } 345 }
342 .social .vk{ 346 .social .vk{
343 -cursor: pointer; 347 + cursor: pointer;
344 } 348 }
345 .social .vk:hover{background-color:#5B7FA6;} 349 .social .vk:hover{background-color:#5B7FA6;}
346 .social .fb:hover{background-color:#354f89; 350 .social .fb:hover{background-color:#354f89;
347 } 351 }
348 .social .gp{background-position:-132px 0; 352 .social .gp{background-position:-132px 0;
349 -cursor: pointer;} 353 + cursor: pointer;}
350 .social .gp:hover{background-color:#c72f21;} 354 .social .gp:hover{background-color:#c72f21;}
351 .social .tw{background-position:-144px 0; 355 .social .tw{background-position:-144px 0;
352 -cursor: pointer;} 356 + cursor: pointer;}
353 .social .tw:hover{background-color:#6398c9;} 357 .social .tw:hover{background-color:#6398c9;}
354 .social .ok{background-position:-89px 0; 358 .social .ok{background-position:-89px 0;
355 -cursor: pointer;} 359 + cursor: pointer;}
356 .social .ok:hover{background-color:#f88f15;} 360 .social .ok:hover{background-color:#f88f15;}
357 .social ul li a:hover{ 361 .social ul li a:hover{
358 background-color:#065baa; 362 background-color:#065baa;
@@ -802,4 +806,32 @@ a.active{font-weight:bold;text-decoration: underline;} @@ -802,4 +806,32 @@ a.active{font-weight:bold;text-decoration: underline;}
802 display: inline-block; 806 display: inline-block;
803 margin-right: 3px; 807 margin-right: 3px;
804 margin-top: 3px; 808 margin-top: 3px;
  809 +}
  810 +
  811 +.sort_block {
  812 + display: inline-block;
  813 +}
  814 +.sort_block ul {
  815 + display: inline-block;
  816 + margin: 0;
  817 + padding: 0;
  818 +}
  819 +.sort_block ul li {
  820 + display: inline-block;
  821 + margin: 0 0.5em;
  822 + list-style: none;
  823 +}
  824 +.sort_block ul li a:after {
  825 + display: inline-block;
  826 + /*font-family: 'Glyphicons Halflings';*/
  827 + font-style: normal;
  828 + font-weight: normal;
  829 + line-height: 1;
  830 + -webkit-font-smoothing: antialiased;
  831 +}
  832 +.sort_block ul li a.asc:after {
  833 + content: "↓";
  834 +}
  835 +.sort_block ul li a.desc:after {
  836 + content: "↑";
805 } 837 }
806 \ No newline at end of file 838 \ No newline at end of file