diff --git a/backend/assets/AppAsset.php b/backend/assets/AppAsset.php
index bb15c3c..3f9bf26 100755
--- a/backend/assets/AppAsset.php
+++ b/backend/assets/AppAsset.php
@@ -22,6 +22,7 @@ class AppAsset extends AssetBundle
];
public $js = [
'js/fieldWidget.js',
+ 'js/site.js',
];
public $depends = [
'yii\web\YiiAsset',
diff --git a/backend/controllers/OrdersController.php b/backend/controllers/OrdersController.php
old mode 100755
new mode 100644
index 53abb4c..03c0f37
--- a/backend/controllers/OrdersController.php
+++ b/backend/controllers/OrdersController.php
@@ -1,137 +1,145 @@
- [
- 'class' => AccessControl::className(),
- 'rules' => [
- [
- 'actions' => ['login', 'error','update','delete','create','view'],
- 'allow' => true,
- ],
- [
- 'actions' => ['logout', 'index'],
- 'allow' => true,
- 'roles' => ['@'],
- ],
- ],
- ],
- 'verbs' => [
- 'class' => VerbFilter::className(),
- 'actions' => [
- 'logout' => ['post'],
- ],
- ],
- ];
- }
- /**
- * Lists all Orders models.
- * @return mixed
- */
- public function actionIndex()
- {
- $searchModel = new OrdersSearch();
- $dataProvider = $searchModel->search(Yii::$app->request->queryParams);
-
- return $this->render('index', [
- 'searchModel' => $searchModel,
- 'dataProvider' => $dataProvider,
- ]);
- }
-
- /**
- * Displays a single Orders model.
- * @param integer $id
- * @return mixed
- */
- public function actionView($id)
- {
- return $this->render('view', [
- 'model' => $this->findModel($id),
- ]);
- }
-
- /**
- * Creates a new Orders model.
- * If creation is successful, the browser will be redirected to the 'view' page.
- * @return mixed
- */
- public function actionCreate()
- {
- $model = new Orders();
-
- if ($model->load(Yii::$app->request->post()) && $model->save()) {
- return $this->redirect(['view', 'id' => $model->order_id]);
- } else {
- return $this->render('create', [
- 'model' => $model,
- ]);
- }
- }
-
- /**
- * Updates an existing Orders model.
- * If update is successful, the browser will be redirected to the 'view' page.
- * @param integer $id
- * @return mixed
- */
- public function actionUpdate($id)
- {
- $model = $this->findModel($id);
-
- if ($model->load(Yii::$app->request->post()) && $model->save()) {
- return $this->redirect(['view', 'id' => $model->order_id]);
- } else {
- return $this->render('update', [
- 'model' => $model,
- ]);
- }
- }
-
- /**
- * Deletes an existing Orders model.
- * If deletion is successful, the browser will be redirected to the 'index' page.
- * @param integer $id
- * @return mixed
- */
- public function actionDelete($id)
- {
- $this->findModel($id)->delete();
-
- return $this->redirect(['index']);
- }
-
- /**
- * Finds the Orders model based on its primary key value.
- * If the model is not found, a 404 HTTP exception will be thrown.
- * @param integer $id
- * @return Orders the loaded model
- * @throws NotFoundHttpException if the model cannot be found
- */
- protected function findModel($id)
- {
- if (($model = Orders::findOne($id)) !== null) {
- return $model;
- } else {
- throw new NotFoundHttpException('The requested page does not exist.');
- }
- }
-}
+ [
+ 'class' => VerbFilter::className(),
+ 'actions' => [
+ 'delete' => ['POST'],
+ ],
+ ],
+ ];
+ }
+
+ public function actionIndex()
+ {
+ $searchModel = new Orders;
+ $searchModel->load(Yii::$app->request->queryParams);
+ $query = Orders::find();
+ if(!empty($searchModel->labels))$query->andWhere(['label'=>$searchModel->labels]);
+ //if(!empty($searchModel->date_time))$query->andFilterWhere(['like', 'date_time', $searchModel->date_time]);
+ if(!empty($searchModel->username))$query->andFilterWhere(['like', 'username', $searchModel->username]);
+ if(!empty($searchModel->id))$query->andFilterWhere(['like', 'id', $searchModel->id]);
+ if(!empty($searchModel->phone))$query->andFilterWhere(['like', 'phone', $searchModel->phone]);
+ if(!empty($searchModel->name))$query->andFilterWhere(['like', 'name', $searchModel->name]);
+ if(!empty($searchModel->surname))$query->andFilterWhere(['like', 'surname', $searchModel->surname]);
+ if(!empty($searchModel->total))$query->andFilterWhere(['like', 'total', $searchModel->total]);
+ if(!empty($searchModel->reserve))$query->andFilterWhere(['like', 'reserve', $searchModel->reserve]);
+ if(!empty($searchModel->status))$query->andFilterWhere(['like', 'status', $searchModel->status]);
+
+// var_dump($searchModel->name);
+// die;
+ $dataProvider = new ActiveDataProvider([
+ 'query' =>$query,
+ 'sort'=> ['defaultOrder' => ['id'=>SORT_DESC]],
+ 'pagination' => [
+ 'pageSize' => 20,
+ ],
+ ]);
+
+ return $this->render('index', [
+ 'dataProvider'=>$dataProvider,
+ 'searchModel'=>$searchModel,
+ ]);
+ }
+
+ public function actionShow($id)
+ {
+
+ $model = $this->findModel((int)$id);
+ $dataProvider = new ActiveDataProvider([
+ 'query' => OrdersProducts::find()->where(['order_id'=>(int)$_GET['id']]),
+ 'pagination' => [
+ 'pageSize' => 20,
+ ],
+ ]);
+ if ($model->load(Yii::$app->request->post()) && $model->save()) {
+ return $this->redirect(['index']);
+ } else {
+ $model_orderproducts = new OrdersProducts;
+
+
+ return $this->renderPartial('show', [
+ 'model' => $model,
+ 'model_orderproducts'=>$model_orderproducts,
+ 'dataProvider' => $dataProvider,
+ ]);
+ }
+ }
+
+ public function actionLabelupdate(){
+ $model = Orders::findOne($_POST['order_id']);
+ $model->label = $_POST['label_id'];
+ $model->save();
+ Yii::$app->and();
+ }
+
+ public function actionPayupdate(){
+ $model = Orders::findOne($_POST['order_id']);
+ $model->pay = $_POST['pay_id'];
+ $model->save();
+ Yii::$app->and();
+ }
+
+ public function actionDelete(){
+ $model = Orders::findOne($_GET['id']);
+ $model->delete();
+ return Yii::$app->response->redirect(['/admin/orders/index']);
+ }
+
+
+ public function actionAdd(){
+ $model = new OrdersProducts;
+ if ($model->load(Yii::$app->request->post())) {
+
+ if(!$modelMod = ProductVariant::find()->with(['product'])->where(['sku'=>$model->sku])->one())
+ throw new HttpException(404, 'Данного артикля не существует!');
+ $model->product_name = $modelMod->product->name;
+ $model->name = $modelMod->name;
+ $model->sku = $modelMod->sku;
+ $model->price = $modelMod->price;
+ $model->sum_cost = $model->count*$modelMod->price;
+ $model->mod_id = $modelMod->id;
+ $model->save();
+ //return Yii::$app->response->redirect(['/admin/orders/show','id'=>$_GET['order_id']]);
+ }
+
+ //return $this->render('add',['model'=>$model]);
+ }
+
+ public function actionDelete_product(){
+ $model = OrdersProducts::findOne($_GET['id']);
+ $model->delete();
+ return Yii::$app->response->redirect(['/admin/orders/show','id'=>$_GET['order_id']]);
+ }
+
+ protected function findModel($id)
+ {
+ if (($model = Orders::findOne($id)) !== null) {
+ return $model;
+ } else {
+ throw new NotFoundHttpException('The requested page does not exist.');
+ }
+ }
+}
diff --git a/backend/models/Label.php b/backend/models/Label.php
new file mode 100644
index 0000000..fbbc9f7
--- /dev/null
+++ b/backend/models/Label.php
@@ -0,0 +1,25 @@
+name;
+ }
+
+
+
+
+
+
+}
diff --git a/backend/models/Orders.php b/backend/models/Orders.php
new file mode 100644
index 0000000..abfcf55
--- /dev/null
+++ b/backend/models/Orders.php
@@ -0,0 +1,74 @@
+'jpg, gif, png', 'skipOnEmpty'=>true],
+ ];
+ }
+
+ public function attributeLabels()
+ {
+ return [
+ 'id'=>'№ заказа',
+ 'name'=>'Имя',
+ 'phone'=>'Телефон',
+ 'phone2'=>'Телефон 2',
+ 'adress'=>'Адрес',
+ 'body'=>'Сообщение',
+ 'reserve'=>'Резерв',
+ 'status'=>'Статус',
+ 'email'=>'E-mail',
+ 'patronymic'=>'Очество',
+ 'surname'=>'Фамилия',
+ 'total'=>'Сумма',
+ 'labels'=>'Метки',
+ 'label'=>'Метка',
+ 'comment'=>'Комментарий менеджера',
+ 'date_dedline'=>'Дедлайн',
+ 'numbercard'=>'№ карточки',
+ 'delivery'=>'Доставка',
+ 'declaration'=>'Декларация №',
+ 'stock'=>'№ склада',
+ 'consignment'=>'№ накладной',
+ 'payment'=>'Способ оплаты',
+ 'insurance'=>'Страховка',
+ 'amount_imposed'=>'Сумма наложенного',
+ 'shipping_by'=>'Отправка за счет',
+ 'city'=>'Город'
+ ];
+ }
+
+ public function beforeSave($insert) {
+ return parent::beforeSave($insert);
+ }
+
+ public function beforeDelete() {
+ return parent::beforeDelete();
+ }
+
+ public function getUser()
+ {
+ return $this->hasOne(Customer::className(), ['id' => 'user_id']);
+ }
+
+
+
+}
\ No newline at end of file
diff --git a/backend/models/OrdersProducts.php b/backend/models/OrdersProducts.php
new file mode 100644
index 0000000..503f311
--- /dev/null
+++ b/backend/models/OrdersProducts.php
@@ -0,0 +1,38 @@
+'Продукт',
+ 'name'=>'Вид',
+ 'art'=>'Артикул',
+ 'cost'=>'Цена за один',
+ 'count'=>'Кол.',
+ 'sum_cost'=>'Сумма',
+ ];
+ }
+
+ public function getMod()
+ {
+ return $this->hasOne(ProductVariant::className(), ['product_variant_id' => 'mod_id']);
+ }
+}
\ No newline at end of file
diff --git a/backend/views/orders/_form.php b/backend/views/orders/_form.php
deleted file mode 100755
index fab78b2..0000000
--- a/backend/views/orders/_form.php
+++ /dev/null
@@ -1,148 +0,0 @@
-
-
-
-
-
-
- = $form->field($model, 'name')->textInput(['maxlength' => true]) ?>
-
- = $form->field($model, 'email')->textInput(['maxlength' => true]) ?>
-
- = $form->field($model, 'phone')->textInput(['maxlength' => true]) ?>
-
- field($model, 'delivery', [
- ])->radioList([
- '1' => 'Курьерска доставка по Киеву и области',
- '2' => 'В любой регион Украины',
- '3' => 'Самовывоз (бесплатно)',
- ], [
- 'item' => function($index, $label, $name, $checked, $value) {
-
- $return = '
';
-
- return $return;
- },
- ]);
-
-
- ?>
-
- field($model, 'payment', [
- ])->radioList([
- '1' => 'Оплата наличными',
- '2' => 'Оплата по безналичному расчету. Код ЕГРПОУ',
- '3' => 'Приват 24',
- '4' => 'Согласовать с менеджером',
- ], [
- 'item' => function ($index, $label, $name, $checked, $value) use ($model) {
- if($index != 1){
-
- $return = '
';
-
- return $return;
- } else {
-
- $return = '
';
-
- return $return;
- }
-
- },
- ]);
-
-
- ?>
-
- = $form->field($model, 'status')->textInput() ?>
-
- = $form->field($model, 'created')->widget(DatePicker::classname(), [
- 'language' => 'ru',
- 'pluginOptions' => [
- 'format'=> 'yyyy-mm-d'
-
- ],
-
- ]) ?>
- = $form->field($model, 'updated')->widget(DatePicker::classname(), [
- 'language' => 'ru',
- 'pluginOptions' => [
- 'format'=> 'yyyy-mm-d'
-
- ],
-
- ]) ?>
-
- = $form->field($model, 'orderItems')->widget(MultipleInput::className(), [
- 'columns' => [
- [
- 'name' => 'order_items_id',
- 'type' => MultipleInputColumn::TYPE_HIDDEN_INPUT,
- ],
- [
- 'name' => 'item_id',
- 'type' => MultipleInputColumn::TYPE_TEXT_INPUT,
- 'title' => 'item id',
- ],
- [
- 'name' => 'item_name',
- 'type' => MultipleInputColumn::TYPE_TEXT_INPUT,
- 'title' => 'name',
- 'value' => function($data){
- if($data instanceof OrderItems){
- return $data->item->product->name .' '. $data->item->name;
- }
- },
- ],
- [
- 'name' => 'item_count',
- 'type' => MultipleInputColumn::TYPE_TEXT_INPUT,
- 'title' => 'item count',
- ],
- [
- 'name' => 'price',
- 'type' => MultipleInputColumn::TYPE_TEXT_INPUT,
- 'title' => 'Price',
- ],
- ],
- ]);
- ?>
-
-
-
-
- = Html::submitButton($model->isNewRecord ? Yii::t('app', 'Create') : Yii::t('app', 'Update'), ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']) ?>
-
-
-
-
-
diff --git a/backend/views/orders/_search.php b/backend/views/orders/_search.php
deleted file mode 100755
index 389440f..0000000
--- a/backend/views/orders/_search.php
+++ /dev/null
@@ -1,45 +0,0 @@
-
-
-
-
- ['index'],
- 'method' => 'get',
- ]); ?>
-
- = $form->field($model, 'order_id') ?>
-
- = $form->field($model, 'name') ?>
-
- = $form->field($model, 'email') ?>
-
- = $form->field($model, 'phone') ?>
-
- field($model, 'delivery') ?>
-
- field($model, 'payment') ?>
-
- field($model, 'code') ?>
-
- field($model, 'status') ?>
-
- field($model, 'created_at') ?>
-
- field($model, 'updated_at') ?>
-
-
- = Html::submitButton(Yii::t('app', 'Search'), ['class' => 'btn btn-primary']) ?>
- = Html::resetButton(Yii::t('app', 'Reset'), ['class' => 'btn btn-default']) ?>
-
-
-
-
-
diff --git a/backend/views/orders/add.php b/backend/views/orders/add.php
new file mode 100644
index 0000000..912df76
--- /dev/null
+++ b/backend/views/orders/add.php
@@ -0,0 +1,30 @@
+title = 'Добавить товар в заказ';
+$this->params['breadcrumbs'][] = $this->title;
+?>
+Добавить товар в заказ
+
+ 'reg-form',
+ 'options' => ['class' => 'form-vertical','enctype' => 'multipart/form-data'],
+ 'fieldConfig' => [
+ //'template' => "{label}\n{input}
\n{error}
",
+ //'labelOptions' => ['class' => 'col-lg-2 control-label'],
+ ],
+ ]); ?>
+
+= $form->field($model, 'art') ?>
+
+= $form->field($model, 'count') ?>
+
+ = $form->field($model, 'order_id')->hiddenInput(['value'=>$_GET['order_id']])->label(false); ?>
+
+
+ = Html::submitButton(' Сохранить ', ['class' => 'btn btn-primary', 'name' => 'login-button']) ?>
+
+
\ No newline at end of file
diff --git a/backend/views/orders/create.php b/backend/views/orders/create.php
deleted file mode 100755
index 9f99b3e..0000000
--- a/backend/views/orders/create.php
+++ /dev/null
@@ -1,21 +0,0 @@
-title = Yii::t('app', 'Create Orders');
-$this->params['breadcrumbs'][] = ['label' => Yii::t('app', 'Orders'), 'url' => ['index']];
-$this->params['breadcrumbs'][] = $this->title;
-?>
-
-
-
= Html::encode($this->title) ?>
-
- = $this->render('_form', [
- 'model' => $model,
- ]) ?>
-
-
diff --git a/backend/views/orders/index.php b/backend/views/orders/index.php
old mode 100755
new mode 100644
index 45a82f3..ca4f4da
--- a/backend/views/orders/index.php
+++ b/backend/views/orders/index.php
@@ -1,41 +1,123 @@
-title = Yii::t('app', 'Orders');
-$this->params['breadcrumbs'][] = $this->title;
-?>
-
-
-
= Html::encode($this->title) ?>
- render('_search', ['model' => $searchModel]); ?>
-
-
- = Html::a(Yii::t('app', 'Create Orders'), ['create'], ['class' => 'btn btn-success']) ?>
-
- = GridView::widget([
- 'dataProvider' => $dataProvider,
- 'filterModel' => $searchModel,
- 'columns' => [
- ['class' => 'yii\grid\SerialColumn'],
-
- 'order_id',
- 'name',
- 'email:email',
- 'phone',
- // 'delivery',
- // 'payment',
- // 'code',
- // 'status',
- // 'created_at',
- // 'updated_at',
-
- ['class' => 'yii\grid\ActionColumn'],
- ],
- ]); ?>
-
+registerJsFile('/app/modules/admin/assets/js/jquery-1.11.3.min.js');
+$this->registerJsFile('/app/modules/admin/assets/js/site.js');
+
+
+$this->title = 'Заказы';
+$this->params['breadcrumbs'][] = $this->title;
+?>
+Заказы
+
+ 'label-form','method'=>'get','action'=>['/admin/orders/index']]); ?>
+
+ orderBy('id')->all() as $item)
+ {
+ $arr[] = ['id'=>$item->id,'label'=>$item->label.'-'.$item->name];
+ }
+ echo $form->field($searchModel, 'labels')->inline(true)->checkboxList(ArrayHelper::map($arr, 'id', 'label'),['onClick'=>'$("#label-form").submit()']);
+ ?>
+
+
+
+= GridView::widget([
+ 'dataProvider' => $dataProvider,
+ 'filterModel' => $searchModel,
+ 'columns' => [
+ // ['class' => 'yii\grid\SerialColumn'],
+
+ [
+ 'attribute' => 'id',
+ 'format' => 'raw',
+ 'options' => ['class' => 'btn btn-warning'],
+ 'value' => function($model){
+ return Html::button($model->id, ['id'=>$model->id, 'class' => 'btn btn-warning']); '/admin/orders/show?id=47';
+ //return Html::a($model->id, ['/admin/orders/show', 'id'=>$model->id], ['class'=>'btn btn-warning'] );
+ // return Html::a($data->name, ['/admin/orders/show','id'=>$data->id]);
+ }
+
+ ],
+ /*[
+ 'attribute' =>'username',
+ 'value'=>function($data){
+ if(!empty($data->user->username))return Html::a($data->user->username, ['/admin/users/show','id'=>$data->user->id]);
+ },
+ 'format'=>'raw',
+ //'contentOptions'=>['style'=>'width: 160px;']
+ ], */
+ [
+ 'attribute' => 'date_time',
+ 'value'=>'date_time',
+ ],
+
+ [
+ 'attribute' => 'name',
+ 'value'=>'name',
+ 'format'=>'raw',
+ ],
+ [
+ 'attribute' => 'phone',
+ 'value'=>'phone',
+ //'contentOptions'=>['style'=>'max-width: 300px;']
+ ],
+ [
+ 'attribute' => 'total',
+ 'value'=>'total',
+ //'contentOptions'=>['style'=>'max-width: 300px;']
+ ],
+ [
+ 'attribute' => 'label',
+ 'value' => function ($model, $key, $index, $column) {
+ // var_dump($model); var_dump($key); exit;
+ return Html::activeDropDownList($model, 'label',
+ yii\helpers\ArrayHelper::map(Label::find()->orderBy('id')->asArray()->all(), 'id', 'label'),
+ [
+ 'prompt' => 'Нет',
+ 'onchange' => "$.ajax({
+ url: \"/admin/orders/labelupdate\",
+ type: \"post\",
+ data: { order_id: $model->id, label_id : this.value},
+ });"
+ ]
+
+ );
+ },
+ 'format' => 'raw',
+ ],
+ [
+ 'attribute' => 'pay',
+ 'value' => function ($model, $key, $index, $column) {
+ // var_dump($model); var_dump($key); exit;
+ return Html::activeDropDownList($model, 'pay',[0 => 'Нет',1=>'Да'],
+ [
+ // 'prompt' => 'Нет',
+ 'onchange' => "$.ajax({
+ url: \"/admin/orders/payupdate\",
+ type: \"post\",
+ data: { order_id: $model->id, pay_id : this.value},
+ });"
+ ]
+
+ );
+ },
+ 'format' => 'raw',
+ ],
+ [
+ 'attribute' => 'status',
+ 'value'=>'status',
+ 'contentOptions'=>['style'=>'width: 5px;']
+ ],
+ [
+ 'class' => 'yii\grid\ActionColumn',
+ 'template' => '{delete}',
+ 'contentOptions'=>['style'=>'width: 70px;']
+ ],
+ ],
+]) ?>
diff --git a/backend/views/orders/show.php b/backend/views/orders/show.php
new file mode 100644
index 0000000..dab4a48
--- /dev/null
+++ b/backend/views/orders/show.php
@@ -0,0 +1,190 @@
+registerCssFile('/app/modules/admin/assets/css/admin_order.css');
+
+
+// $this->title = 'Заказ №'.$model->id;
+// $this->params['breadcrumbs'][] = $this->title;
+?>
+
+
+
+
+
+
+
+ Заказ успешно сохранен!
+
+
+
+ 'reg-form',
+ 'layout' => 'horizontal',
+ 'options' => ['enctype' => 'multipart/form-data'],
+ 'fieldConfig' => [
+ //'template' => "{label}\n
{input}
\n
{error}
",
+ //'labelOptions' => ['class' => 'col-lg-2 control-label'],
+ ],
+ 'action' => [
+ 'orders/show',
+ 'id' => $model->id
+ ]
+ ]); ?>
+
+
+
+
+
Заказ №=$model->id?>
+
+ =$model->date_time?>
+
+= $form->field($model,'date_dedline')->widget(\yii\jui\DatePicker::className(),['clientOptions' => [],'options' => ['class'=>'form-control','style'=>'width:150px;'],'dateFormat' => 'yyyy-MM-dd',]) ?>
+
+
+= $form->field($model, 'name') ?>
+
+
+= $form->field($model, 'phone') ?>
+
+= $form->field($model, 'phone2') ?>
+
+= $form->field($model, 'email') ?>
+
+= $form->field($model, 'numbercard') ?>
+
+ = $form->field($model, 'body')->textArea(['rows' => '3']) ?>
+
+
+ = $form->field($model, 'delivery')->dropDownList(ArrayHelper::map(Delivery::find()->asArray()->all(), 'id', 'title')) ?>
+
+ = $form->field($model, 'declaration') ?>
+
+ = $form->field($model, 'stock') ?>
+
+ = $form->field($model, 'consignment') ?>
+
+=$form->field($model, 'payment')->dropDownList(['Оплатить наличными'=>'Оплатить наличными','Оплатить на карту Приват Банка'=>'Оплатить на карту Приват Банка','Оплатить по безналичному расчету'=>'Оплатить по безналичному расчету','Оплатить Правекс-телеграф'=>'Оплатить Правекс-телеграф','Наложенным платежом'=>'Наложенным платежом'],['prompt'=>'...']); ?>
+
+= $form->field($model, 'insurance') ?>
+
+= $form->field($model, 'amount_imposed') ?>
+
+= $form->field($model, 'shipping_by') ?>
+
+= $form->field($model, 'city') ?>
+
+= $form->field($model, 'adress') ?>
+
+
+= $form->field($model, 'total') ?>
+
+=$form->field($model, 'status')->dropDownList(['Нет'=>'Нет','Обработан'=>'Обработан','На комплектации'=>'На комплектации','Укомплектован'=>'Укомплектован','Доставка'=>'Доставка','Выполнен'=>'Выполнен','Резерв оплачен'=>'Резерв оплачен','Резерв неоплачен'=>'Резерв неоплачен'],['prompt'=>'...']); ?>
+
+= $form->field($model, 'comment')->textArea(['rows' => '3']) ?>
+
+
+
+
+
+
+= GridView::widget([
+ 'dataProvider' => $dataProvider,
+ 'columns' => [
+ [
+ 'attribute' => 'id',
+ 'value'=>'id',
+ 'contentOptions'=>['style'=>'width: 70px;']
+ ],
+ [
+ 'attribute' => 'sku',
+ 'value'=>'sku',
+ 'contentOptions'=>['style'=>'width: 50px;']
+ ],
+ [
+ 'attribute' => 'product_name',
+ 'value'=>'product_name',
+ 'contentOptions'=>['style'=>'max-width: 300px;']
+ ],
+// [
+// 'attribute' => 'size',
+// 'value'=>'mod.size',
+// 'contentOptions'=>['style'=>'width: 100px;']
+// ],
+// [
+// 'attribute' => 'size',
+// 'value'=>'mod.color',
+// 'contentOptions'=>['style'=>'width: 100px;']
+// ],
+ [
+ 'attribute' => 'price',
+ 'value'=>'price',
+ 'contentOptions'=>['style'=>'width: 100px;']
+ ],
+ [
+ 'attribute' => 'count',
+ 'value'=>'count',
+ 'contentOptions'=>['style'=>'width: 30px;']
+ ],
+ [
+ 'attribute' => 'sum_cost',
+ 'value'=>'sum_cost',
+ 'contentOptions'=>['style'=>'width: 100px;']
+ ],
+ [
+ 'class' => 'yii\grid\ActionColumn',
+ 'template' => '{delete}',
+ 'contentOptions'=>['style'=>'width: 20px;'],
+ 'buttons' => [
+ 'delete' => function ($url, $model) {
+ return Html::a('
', ['/admin/orders/delete_product','id'=>$model->id,'order_id'=>$_GET['id']],
+ [
+ 'title' => "Удалить",'data-confirm'=>'Удалить?',
+ ]);
+ }
+ ],
+ ],
+
+ ],
+]) ?>
+
+ = Html::submitButton(' Сохранить ', ['class' => 'btn btn-primary btn-lg btn-block', 'name' => 'login-button']) ?>
+
+
+
+
+
+
+
Добавить товар в заказ
+
+ false,
+ 'id' => 'add_mod',
+ 'options' => ['class' => 'form-vertical','enctype' => 'multipart/form-data'],
+ 'fieldConfig' => [
+ //'template' => "{label}\n
{input}
\n
{error}
",
+ //'labelOptions' => ['class' => 'col-lg-2 control-label'],
+ ],
+ ]); ?>
+
+ = $form->field($model_orderproducts, 'sku') ?>
+
+ = $form->field($model_orderproducts, 'count') ?>
+
+ = $form->field($model_orderproducts, 'order_id')->hiddenInput(['value'=>$model->id])->label(false); ?>
+
+
+ = Html::submitButton(' Добавить товар ', ['class' => 'btn btn-primary', 'name' => 'login-button']) ?>
+
+
+
+
+
+
+
+
diff --git a/backend/views/orders/update.php b/backend/views/orders/update.php
old mode 100755
new mode 100644
index f938ee4..e255d66
--- a/backend/views/orders/update.php
+++ b/backend/views/orders/update.php
@@ -1,23 +1,144 @@
-title = Yii::t('app', 'Update {modelClass}: ', [
- 'modelClass' => 'Orders',
-]) . ' ' . $model->name;
-$this->params['breadcrumbs'][] = ['label' => Yii::t('app', 'Orders'), 'url' => ['index']];
-$this->params['breadcrumbs'][] = ['label' => $model->name, 'url' => ['view', 'id' => $model->order_id]];
-$this->params['breadcrumbs'][] = Yii::t('app', 'Update');
-?>
-
-
-
= Html::encode($this->title) ?>
-
- = $this->render('_form', [
- 'model' => $model,
- ]) ?>
-
-
+title = 'Заказ №'.$model->id;
+$this->params['breadcrumbs'][] = $this->title;
+?>
+Заказ №=$model->id?>
+
+
+
+ Заказ успешно сохранен!
+
+
+
+ 'reg-form',
+ 'layout' => 'horizontal',
+ 'options' => ['enctype' => 'multipart/form-data'],
+ 'fieldConfig' => [
+ //'template' => "{label}\n{input}
\n{error}
",
+ //'labelOptions' => ['class' => 'col-lg-2 control-label'],
+ ],
+ ]); ?>
+
+
+
+
+
+ =$model->date_time?>
+
+= $form->field($model,'date_dedline')->widget(\yii\jui\DatePicker::className(),['clientOptions' => [],'options' => ['class'=>'form-control','style'=>'width:150px;'],'dateFormat' => 'yyyy-MM-dd',]) ?>
+
+= $form->field($model, 'surname') ?>
+
+= $form->field($model, 'name') ?>
+
+= $form->field($model, 'patronymic') ?>
+
+= $form->field($model, 'phone') ?>
+
+= $form->field($model, 'phone2') ?>
+
+= $form->field($model, 'email') ?>
+
+= $form->field($model, 'numbercard') ?>
+
+= $form->field($model, 'delivery')->dropDownList(ArrayHelper::map(Delivery::find()->asArray()->all(), 'id', 'title')) ?>
+
+= $form->field($model, 'declaration') ?>
+
+= $form->field($model, 'stock') ?>
+
+= $form->field($model, 'consignment') ?>
+
+
+=$form->field($model, 'payment')->dropDownList(['Оплатить наличными'=>'Оплатить наличными','Оплатить на карту Приват Банка'=>'Оплатить на карту Приват Банка','Оплатить по безналичному расчету'=>'Оплатить по безналичному расчету','Оплатить Правекс-телеграф'=>'Оплатить Правекс-телеграф','Наложенным платежом'=>'Наложенным платежом'],['prompt'=>'...']); ?>
+
+= $form->field($model, 'insurance') ?>
+
+= $form->field($model, 'amount_imposed') ?>
+
+= $form->field($model, 'shipping_by') ?>
+
+= $form->field($model, 'city') ?>
+
+= $form->field($model, 'adress') ?>
+
+= $form->field($model, 'body')->textArea(['rows' => '6']) ?>
+
+= $form->field($model, 'total') ?>
+
+=$form->field($model, 'status')->dropDownList(['Нет'=>'Нет','Обработан'=>'Обработан','На комплектации'=>'На комплектации','Укомплектован'=>'Укомплектован','Доставка'=>'Доставка','Выполнен'=>'Выполнен','Резерв оплачен'=>'Резерв оплачен','Резерв неоплачен'=>'Резерв неоплачен'],['prompt'=>'...']); ?>
+
+= $form->field($model, 'comment')->textArea(['rows' => '6']) ?>
+
+
+ = Html::submitButton(' Сохранить ', ['class' => 'btn btn-primary btn-lg btn-block', 'name' => 'login-button']) ?>
+
+
+
+
+= Html::a('Добавить товар', ['/admin/orders/add','order_id'=>$model->id], ['class'=>'btn btn-success']) ?>
+= GridView::widget([
+ 'dataProvider' => $dataProvider,
+ 'columns' => [
+ [
+ 'attribute' => 'id',
+ 'value'=>'id',
+ 'contentOptions'=>['style'=>'width: 70px;']
+ ],
+ [
+ 'attribute' => 'art',
+ 'value'=>'art',
+ 'contentOptions'=>['style'=>'width: 50px;']
+ ],
+ [
+ 'attribute' => 'product_name',
+ 'value'=>'product_name',
+ //'contentOptions'=>['style'=>'max-width: 300px;']
+ ],
+ [
+ 'attribute' => 'name',
+ 'value'=>'name',
+ //'contentOptions'=>['style'=>'max-width: 300px;']
+ ],
+ [
+ 'attribute' => 'cost',
+ 'value'=>'cost',
+ 'contentOptions'=>['style'=>'width: 100px;']
+ ],
+ [
+ 'attribute' => 'count',
+ 'value'=>'count',
+ 'contentOptions'=>['style'=>'width: 30px;']
+ ],
+ [
+ 'attribute' => 'sum_cost',
+ 'value'=>'sum_cost',
+ 'contentOptions'=>['style'=>'width: 100px;']
+ ],
+ [
+ 'class' => 'yii\grid\ActionColumn',
+ 'template' => '{delete}',
+ 'contentOptions'=>['style'=>'width: 20px;'],
+ 'buttons' => [
+ 'delete' => function ($url, $model) {
+ return Html::a('', ['/admin/orders/delete_product','id'=>$model->id,'order_id'=>$_GET['id']],
+ [
+ 'title' => "Удалить",'data-confirm'=>'Удалить?',
+ ]);
+ }
+ ],
+ ],
+
+ ],
+]) ?>
+
+
+
diff --git a/backend/views/orders/view.php b/backend/views/orders/view.php
deleted file mode 100755
index 3128633..0000000
--- a/backend/views/orders/view.php
+++ /dev/null
@@ -1,44 +0,0 @@
-title = $model->name;
-$this->params['breadcrumbs'][] = ['label' => Yii::t('app', 'Orders'), 'url' => ['index']];
-$this->params['breadcrumbs'][] = $this->title;
-?>
-
-
-
= Html::encode($this->title) ?>
-
-
- = Html::a(Yii::t('app', 'Update'), ['update', 'id' => $model->order_id], ['class' => 'btn btn-primary']) ?>
- = Html::a(Yii::t('app', 'Delete'), ['delete', 'id' => $model->order_id], [
- 'class' => 'btn btn-danger',
- 'data' => [
- 'confirm' => Yii::t('app', 'Are you sure you want to delete this item?'),
- 'method' => 'post',
- ],
- ]) ?>
-
-
- = DetailView::widget([
- 'model' => $model,
- 'attributes' => [
- 'order_id',
- 'name',
- 'email:email',
- 'phone',
- 'delivery',
- 'payment',
- 'code',
- 'status',
- 'created_at',
- 'updated_at',
- ],
- ]) ?>
-
-
diff --git a/backend/web/js/site.js b/backend/web/js/site.js
new file mode 100644
index 0000000..41781c3
--- /dev/null
+++ b/backend/web/js/site.js
@@ -0,0 +1,72 @@
+$(document).ready(function(){
+
+ var iii = true;
+
+ // console.log(ddd);
+ // if (ddd) {console.log('hello var ddd is correnct')
+ // }else {
+ // console.log('var ddd is not exist');
+ // };
+
+ console.log($('button'));
+ $('button').click(function(){
+
+ var testt = $(this);
+
+ var id = $(this).attr('id');
+
+ var ddd = document.getElementById('test_tr_class');
+
+ // $.post( "index.php?r=order%2Fupdate&id=1", function( data ) {
+
+ if (!ddd) {
+
+ testt.closest('tr').after(
+ '' +
+ '' +
+ 'data' +
+ ' | ' +
+ '
'
+ );
+
+ loadShow(testt,id);
+
+ }else{
+ document.getElementById('test_tr_class').remove();
+ };
+
+ iii = false;
+ console.log(iii);
+
+
+
+
+ });
+
+ function loadShow(testt,id){
+ $.post( "/admin/orders/show?id=" + id + '"', function( data ) {
+
+ $('#content_'+id).html(data);
+
+ $('#add_mod').submit(function() {
+ $.ajax({
+ type: "POST",
+ url: "/admin/orders/add?order_id="+id,
+ data: $(this).serialize(), // serializes the form's elements.
+ success: function(data)
+ {
+ loadShow(testt,id); // show response from the php script.
+ }
+ });
+ return false;
+ });
+
+ });
+
+ }
+
+
+
+
+
+});
\ No newline at end of file
diff --git a/common/models/Orders.php b/common/models/Orders.php
index 772a483..0df6d75 100755
--- a/common/models/Orders.php
+++ b/common/models/Orders.php
@@ -190,7 +190,12 @@ class Orders extends \yii\db\ActiveRecord
return $mod->price;
}
-
+ public function clearBasket ()
+ {
+ $session = new Session;
+ $session->open ();
+ $session['basket'] = null;
+ }
public function getUser()
{
return $this->hasOne(User::className(), ['id' => 'user_id']);
diff --git a/common/modules/product/models/ProductVariant.php b/common/modules/product/models/ProductVariant.php
index 123ccab..e6fbfbb 100755
--- a/common/modules/product/models/ProductVariant.php
+++ b/common/modules/product/models/ProductVariant.php
@@ -33,6 +33,7 @@ class ProductVariant extends \yii\db\ActiveRecord
public $translit;
public $translit_rubric;
private $data;
+
/** @var array $_images */
// public $imagesUpload = [];
/**
diff --git a/console/migrations/m160517_072059_delete_product_fk.php b/console/migrations/m160517_072059_delete_product_fk.php
new file mode 100644
index 0000000..28972f9
--- /dev/null
+++ b/console/migrations/m160517_072059_delete_product_fk.php
@@ -0,0 +1,30 @@
+dropForeignKey('orders_products_fk', '{{%orders_products}}');
+ $this->dropForeignKey('orders_products_items_fk', '{{%orders_products}}');
+ }
+
+ public function down()
+ {
+
+ $this->addForeignKey('orders_products_fk', '{{%orders_products}}', 'order_id', '{{%orders}}', 'id', 'CASCADE', 'CASCADE');
+ $this->addForeignKey('orders_products_items_fk', '{{%orders_products}}', 'id', '{{%product}}', 'product_id', 'RESTRICT', 'RESTRICT');
+ }
+
+ /*
+ // Use safeUp/safeDown to run migration code within a transaction
+ public function safeUp()
+ {
+ }
+
+ public function safeDown()
+ {
+ }
+ */
+}
diff --git a/console/migrations/m160517_073502_orders_label.php b/console/migrations/m160517_073502_orders_label.php
new file mode 100644
index 0000000..104048e
--- /dev/null
+++ b/console/migrations/m160517_073502_orders_label.php
@@ -0,0 +1,31 @@
+createTable('{{%orders_label}}', [
+ 'id' => $this->primaryKey(),
+ 'name' => $this->string(),
+ 'label' => $this->string()
+ ]);
+ }
+
+ public function down()
+ {
+ $this->dropTable('{{%orders_label}}');
+ }
+
+ /*
+ // Use safeUp/safeDown to run migration code within a transaction
+ public function safeUp()
+ {
+ }
+
+ public function safeDown()
+ {
+ }
+ */
+}
diff --git a/frontend/controllers/BasketController.php b/frontend/controllers/BasketController.php
index 460a7a1..11b07d5 100644
--- a/frontend/controllers/BasketController.php
+++ b/frontend/controllers/BasketController.php
@@ -26,19 +26,20 @@ class BasketController extends Controller
}
if(isset($_POST['update'])){
- foreach ($_POST['Mod'] as $index=>$row) {
+ foreach ($_POST['ProductVariant'] as $index=>$row) {
$modelOrder->updateBasket($row);
}
- }elseif(isset($_POST['Mod'])){
+ }elseif(isset($_POST['ProductVariant'])){
+// die(print_r($_POST));
$body = '';
- foreach ($_POST['Mod'] as $index=>$row) {
+ foreach ($_POST['ProductVariant'] as $index=>$row) {
$body .= $row['product_name'].' '.$row['name'].' Кол:'.$row['count'].' Цена:'.$row['sum_cost'];
$body .= "\n\r";
}
$body .= "\n\r";
if ($modelOrder->load(Yii::$app->request->post()) && $modelOrder->save() && $modelOrder->contact('borisenko.pavel@gmail.com',$body)) {
- foreach ($_POST['Mod'] as $index=>$row) {
+ foreach ($_POST['ProductVariant'] as $index=>$row) {
$modelOrdersProducts = new OrdersProducts();
$mod_id = $row['id'];
unset($row['id']);
@@ -59,7 +60,7 @@ class BasketController extends Controller
$modelUser->group_id = 2;
$modelUser->save();
}
- $modelMod->clearBasket();
+ $modelOrder->clearBasket();
return Yii::$app->response->redirect(['basket/success']);
}
}
--
libgit2 0.21.4