Commit 8df8067a31e97d00c32814356b168ec0d1df9d21
1 parent
a8fc4348
basket
Showing
19 changed files
with
916 additions
and
465 deletions
Show diff stats
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', |
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 | +// public $layout = 'update'; | ||
20 | + /** | ||
21 | + * @inheritdoc | ||
22 | + */ | ||
23 | + public function behaviors() | ||
24 | + { | ||
25 | + return [ | ||
26 | + 'verbs' => [ | ||
27 | + 'class' => VerbFilter::className(), | ||
28 | + 'actions' => [ | ||
29 | + 'delete' => ['POST'], | ||
30 | + ], | ||
31 | + ], | ||
32 | + ]; | ||
33 | + } | ||
34 | + | ||
35 | + public function actionIndex() | ||
36 | + { | ||
37 | + $searchModel = new Orders; | ||
38 | + $searchModel->load(Yii::$app->request->queryParams); | ||
39 | + $query = Orders::find(); | ||
40 | + if(!empty($searchModel->labels))$query->andWhere(['label'=>$searchModel->labels]); | ||
41 | + //if(!empty($searchModel->date_time))$query->andFilterWhere(['like', 'date_time', $searchModel->date_time]); | ||
42 | + if(!empty($searchModel->username))$query->andFilterWhere(['like', 'username', $searchModel->username]); | ||
43 | + if(!empty($searchModel->id))$query->andFilterWhere(['like', 'id', $searchModel->id]); | ||
44 | + if(!empty($searchModel->phone))$query->andFilterWhere(['like', 'phone', $searchModel->phone]); | ||
45 | + if(!empty($searchModel->name))$query->andFilterWhere(['like', 'name', $searchModel->name]); | ||
46 | + if(!empty($searchModel->surname))$query->andFilterWhere(['like', 'surname', $searchModel->surname]); | ||
47 | + if(!empty($searchModel->total))$query->andFilterWhere(['like', 'total', $searchModel->total]); | ||
48 | + if(!empty($searchModel->reserve))$query->andFilterWhere(['like', 'reserve', $searchModel->reserve]); | ||
49 | + if(!empty($searchModel->status))$query->andFilterWhere(['like', 'status', $searchModel->status]); | ||
50 | + | ||
51 | +// var_dump($searchModel->name); | ||
52 | +// die; | ||
53 | + $dataProvider = new ActiveDataProvider([ | ||
54 | + 'query' =>$query, | ||
55 | + 'sort'=> ['defaultOrder' => ['id'=>SORT_DESC]], | ||
56 | + 'pagination' => [ | ||
57 | + 'pageSize' => 20, | ||
58 | + ], | ||
59 | + ]); | ||
60 | + | ||
61 | + return $this->render('index', [ | ||
62 | + 'dataProvider'=>$dataProvider, | ||
63 | + 'searchModel'=>$searchModel, | ||
64 | + ]); | ||
65 | + } | ||
66 | + | ||
67 | + public function actionShow($id) | ||
68 | + { | ||
69 | + | ||
70 | + $model = $this->findModel((int)$id); | ||
71 | + $dataProvider = new ActiveDataProvider([ | ||
72 | + 'query' => OrdersProducts::find()->where(['order_id'=>(int)$_GET['id']]), | ||
73 | + 'pagination' => [ | ||
74 | + 'pageSize' => 20, | ||
75 | + ], | ||
76 | + ]); | ||
77 | + if ($model->load(Yii::$app->request->post()) && $model->save()) { | ||
78 | + return $this->redirect(['index']); | ||
79 | + } else { | ||
80 | + $model_orderproducts = new OrdersProducts; | ||
81 | + | ||
82 | + | ||
83 | + return $this->renderPartial('show', [ | ||
84 | + 'model' => $model, | ||
85 | + 'model_orderproducts'=>$model_orderproducts, | ||
86 | + 'dataProvider' => $dataProvider, | ||
87 | + ]); | ||
88 | + } | ||
89 | + } | ||
90 | + | ||
91 | + public function actionLabelupdate(){ | ||
92 | + $model = Orders::findOne($_POST['order_id']); | ||
93 | + $model->label = $_POST['label_id']; | ||
94 | + $model->save(); | ||
95 | + Yii::$app->and(); | ||
96 | + } | ||
97 | + | ||
98 | + public function actionPayupdate(){ | ||
99 | + $model = Orders::findOne($_POST['order_id']); | ||
100 | + $model->pay = $_POST['pay_id']; | ||
101 | + $model->save(); | ||
102 | + Yii::$app->and(); | ||
103 | + } | ||
104 | + | ||
105 | + public function actionDelete(){ | ||
106 | + $model = Orders::findOne($_GET['id']); | ||
107 | + $model->delete(); | ||
108 | + return Yii::$app->response->redirect(['/admin/orders/index']); | ||
109 | + } | ||
110 | + | ||
111 | + | ||
112 | + public function actionAdd(){ | ||
113 | + $model = new OrdersProducts; | ||
114 | + if ($model->load(Yii::$app->request->post())) { | ||
115 | + | ||
116 | + if(!$modelMod = ProductVariant::find()->with(['product'])->where(['sku'=>$model->sku])->one()) | ||
117 | + throw new HttpException(404, 'Данного артикля не существует!'); | ||
118 | + $model->product_name = $modelMod->product->name; | ||
119 | + $model->name = $modelMod->name; | ||
120 | + $model->sku = $modelMod->sku; | ||
121 | + $model->price = $modelMod->price; | ||
122 | + $model->sum_cost = $model->count*$modelMod->price; | ||
123 | + $model->mod_id = $modelMod->id; | ||
124 | + $model->save(); | ||
125 | + //return Yii::$app->response->redirect(['/admin/orders/show','id'=>$_GET['order_id']]); | ||
126 | + } | ||
127 | + | ||
128 | + //return $this->render('add',['model'=>$model]); | ||
129 | + } | ||
130 | + | ||
131 | + public function actionDelete_product(){ | ||
132 | + $model = OrdersProducts::findOne($_GET['id']); | ||
133 | + $model->delete(); | ||
134 | + return Yii::$app->response->redirect(['/admin/orders/show','id'=>$_GET['order_id']]); | ||
135 | + } | ||
136 | + | ||
137 | + protected function findModel($id) | ||
138 | + { | ||
139 | + if (($model = Orders::findOne($id)) !== null) { | ||
140 | + return $model; | ||
141 | + } else { | ||
142 | + throw new NotFoundHttpException('The requested page does not exist.'); | ||
143 | + } | ||
144 | + } | ||
145 | +} |
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 | +} |
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 |
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> |
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> |
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 | +]) ?> |
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 | + | ||
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 | + |
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> |
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/models/Orders.php
@@ -190,7 +190,12 @@ class Orders extends \yii\db\ActiveRecord | @@ -190,7 +190,12 @@ class Orders extends \yii\db\ActiveRecord | ||
190 | 190 | ||
191 | return $mod->price; | 191 | return $mod->price; |
192 | } | 192 | } |
193 | - | 193 | + public function clearBasket () |
194 | + { | ||
195 | + $session = new Session; | ||
196 | + $session->open (); | ||
197 | + $session['basket'] = null; | ||
198 | + } | ||
194 | public function getUser() | 199 | public function getUser() |
195 | { | 200 | { |
196 | return $this->hasOne(User::className(), ['id' => 'user_id']); | 201 | return $this->hasOne(User::className(), ['id' => 'user_id']); |
common/modules/product/models/ProductVariant.php
@@ -33,6 +33,7 @@ class ProductVariant extends \yii\db\ActiveRecord | @@ -33,6 +33,7 @@ class ProductVariant extends \yii\db\ActiveRecord | ||
33 | public $translit; | 33 | public $translit; |
34 | public $translit_rubric; | 34 | public $translit_rubric; |
35 | private $data; | 35 | private $data; |
36 | + | ||
36 | /** @var array $_images */ | 37 | /** @var array $_images */ |
37 | // public $imagesUpload = []; | 38 | // public $imagesUpload = []; |
38 | /** | 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 | +} |
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 | +} |
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']); |
@@ -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 | } |