Commit e6b208eae448e6313f0eb0f7d684dbd15c4aa0ab

Authored by Yarik
2 parents 93a0cd0b 38614a3c

Merge branch 'master' into Credits

# Conflicts:
#	views/order/_form.php
controllers/ManageController.php
@@ -11,6 +11,7 @@ @@ -11,6 +11,7 @@
11 use artweb\artbox\ecommerce\models\Product; 11 use artweb\artbox\ecommerce\models\Product;
12 use artweb\artbox\ecommerce\models\ProductSearch; 12 use artweb\artbox\ecommerce\models\ProductSearch;
13 use yii\db\ActiveQuery; 13 use yii\db\ActiveQuery;
  14 + use yii\helpers\Html;
14 use yii\helpers\VarDumper; 15 use yii\helpers\VarDumper;
15 use yii\web\Controller; 16 use yii\web\Controller;
16 use yii\web\NotFoundHttpException; 17 use yii\web\NotFoundHttpException;
@@ -220,13 +221,27 @@ @@ -220,13 +221,27 @@
220 */ 221 */
221 public function actionIsTop($id) 222 public function actionIsTop($id)
222 { 223 {
223 - $model = $this->findModel($id);  
224 -  
225 - $model->is_top = intval(empty( $model->is_top ));  
226 -  
227 - $model->save(false, [ 'is_top' ]);  
228 -  
229 - return $this->redirect([ 'index' ]); 224 + \Yii::$app->response->format = Response::FORMAT_JSON;
  225 + $product = Product::findOne($id);
  226 + $product->is_top = !$product->is_top;
  227 + if ($product->save()) {
  228 + if ($product->is_top) {
  229 + $tag = Html::tag('span', '', [
  230 + 'class' => 'glyphicon glyphicon-star',
  231 + ]);
  232 + } else {
  233 + $tag = Html::tag('span', '', [
  234 + 'class' => 'glyphicon glyphicon-star-empty',
  235 + ]);
  236 + }
  237 + return [
  238 + 'success' => true,
  239 + 'tag' => $tag,
  240 + 'message' => 'Статус ТОП успешно изменен',
  241 + ];
  242 + } else {
  243 + return [];
  244 + }
230 } 245 }
231 246
232 /** 247 /**
@@ -238,13 +253,27 @@ @@ -238,13 +253,27 @@
238 */ 253 */
239 public function actionIsNew($id) 254 public function actionIsNew($id)
240 { 255 {
241 - $model = $this->findModel($id);  
242 -  
243 - $model->is_new = intval(empty( $model->is_new ));  
244 -  
245 - $model->save(false, [ 'is_new' ]);  
246 -  
247 - return $this->redirect([ 'index' ]); 256 + \Yii::$app->response->format = Response::FORMAT_JSON;
  257 + $product = Product::findOne($id);
  258 + $product->is_new = !$product->is_new;
  259 + if ($product->save()) {
  260 + if ($product->is_new) {
  261 + $tag = Html::tag('span', '', [
  262 + 'class' => 'glyphicon glyphicon-heart',
  263 + ]);
  264 + } else {
  265 + $tag = Html::tag('span', '', [
  266 + 'class' => 'glyphicon glyphicon-heart-empty',
  267 + ]);
  268 + }
  269 + return [
  270 + 'success' => true,
  271 + 'tag' => $tag,
  272 + 'message' => 'Статус НОВЫЙ успешно изменен',
  273 + ];
  274 + } else {
  275 + return [];
  276 + }
248 } 277 }
249 278
250 /** 279 /**
@@ -256,13 +285,27 @@ @@ -256,13 +285,27 @@
256 */ 285 */
257 public function actionIsDiscount($id) 286 public function actionIsDiscount($id)
258 { 287 {
259 - $model = $this->findModel($id);  
260 -  
261 - $model->is_discount = intval(empty( $model->is_discount ));  
262 -  
263 - $model->save(false, [ 'is_discount' ]);  
264 -  
265 - return $this->redirect([ 'index' ]); 288 + \Yii::$app->response->format = Response::FORMAT_JSON;
  289 + $product = Product::findOne($id);
  290 + $product->is_discount = !$product->is_discount;
  291 + if ($product->save()) {
  292 + if ($product->is_discount) {
  293 + $tag = Html::tag('span', '', [
  294 + 'class' => 'glyphicon glyphicon-tags',
  295 + ]);
  296 + } else {
  297 + $tag = Html::tag('span', '', [
  298 + 'class' => 'glyphicon glyphicon-tag',
  299 + ]);
  300 + }
  301 + return [
  302 + 'success' => true,
  303 + 'tag' => $tag,
  304 + 'message' => 'Статус АКЦИОННЫЙ успешно изменен',
  305 + ];
  306 + } else {
  307 + return [];
  308 + }
266 } 309 }
267 310
268 /** 311 /**
controllers/StatisticsController.php 0 → 100755
  1 +<?php
  2 +
  3 + namespace artweb\artbox\ecommerce\controllers;
  4 +
  5 + use yii\web\Controller;
  6 +
  7 + /**
  8 + * BrandController implements the CRUD actions for Brand model.
  9 + */
  10 + class StatisticsController extends Controller
  11 + {
  12 + public function actionIndex()
  13 + {
  14 + return $this->render('index');
  15 + }
  16 + }
views/manage/index.php
@@ -120,7 +120,7 @@ @@ -120,7 +120,7 @@
120 ], 120 ],
121 [ 121 [
122 'class' => 'yii\grid\ActionColumn', 122 'class' => 'yii\grid\ActionColumn',
123 - 'template' => '{items} {view} |{is_top} {is_new} {is_discount} | {update} {delete}', 123 + 'template' => '{items} {view} | {is_top} {is_new} {is_discount} | {update} {delete}',
124 'buttons' => [ 124 'buttons' => [
125 'is_top' => function ($url, $model) { 125 'is_top' => function ($url, $model) {
126 return Html::a( 126 return Html::a(
@@ -128,6 +128,7 @@ @@ -128,6 +128,7 @@
128 $url, 128 $url,
129 [ 129 [
130 'title' => Yii::t('product', ( $model->is_top ? 'Set not is top' : 'Set is top' )), 130 'title' => Yii::t('product', ( $model->is_top ? 'Set not is top' : 'Set is top' )),
  131 + 'class' => 'toggle-status',
131 ] 132 ]
132 ); 133 );
133 }, 134 },
@@ -137,6 +138,7 @@ @@ -137,6 +138,7 @@
137 $url, 138 $url,
138 [ 139 [
139 'title' => Yii::t('product', ( $model->is_new ? 'Set not is new' : 'Set is new' )), 140 'title' => Yii::t('product', ( $model->is_new ? 'Set not is new' : 'Set is new' )),
  141 + 'class' => 'toggle-status',
140 ] 142 ]
141 ); 143 );
142 }, 144 },
@@ -149,6 +151,7 @@ @@ -149,6 +151,7 @@
149 'product', 151 'product',
150 ( $model->is_discount ? 'Set not is promotion' : 'Set is promotion' ) 152 ( $model->is_discount ? 'Set not is promotion' : 'Set is promotion' )
151 ), 153 ),
  154 + 'class' => 'toggle-status',
152 ] 155 ]
153 ); 156 );
154 }, 157 },
@@ -179,7 +182,7 @@ @@ -179,7 +182,7 @@
179 case 'is_top': 182 case 'is_top':
180 return \yii\helpers\Url::to( 183 return \yii\helpers\Url::to(
181 [ 184 [
182 - 'manage/is_top', 185 + 'manage/is-top',
183 'id' => $model->id, 186 'id' => $model->id,
184 ] 187 ]
185 ); 188 );
@@ -187,7 +190,7 @@ @@ -187,7 +190,7 @@
187 case 'is_new': 190 case 'is_new':
188 return \yii\helpers\Url::to( 191 return \yii\helpers\Url::to(
189 [ 192 [
190 - 'manage/is_new', 193 + 'manage/is-new',
191 'id' => $model->id, 194 'id' => $model->id,
192 ] 195 ]
193 ); 196 );
views/order/_form.php
@@ -150,255 +150,254 @@ JS; @@ -150,255 +150,254 @@ JS;
150 ] 150 ]
151 ); ?> 151 ); ?>
152 <div class="container"> 152 <div class="container">
153 - <div class="form-group">  
154 - <br>  
155 - <div class="row">  
156 - <div class="col-sm-6">  
157 -  
158 - <?= $form->field($model, 'deadline')  
159 - ->widget(  
160 - DatePicker::className(),  
161 - [  
162 -  
163 - ]  
164 - ) ?>  
165 -  
166 - <?php  
167 - if ($user->isAdmin()) {  
168 - echo $form->field($model, 'pay')  
169 - ->widget(  
170 - SwitchInput::className(),  
171 - [  
172 - 'name' => 'pay',  
173 - 'pluginOptions' => [  
174 - 'onText' => \Yii::t('app', 'Оплачено'),  
175 - 'offText' => \Yii::t('app', 'Не оплачено'),  
176 - ],  
177 - ]  
178 - );  
179 - }  
180 - ?>  
181 -  
182 - <?= $form->field($model, 'reason')  
183 - ->dropDownList(  
184 - Order::REASONS,  
185 - [ 'prompt' => 'Выберите причину' ]  
186 - ) ?>  
187 -  
188 - <?= $form->field($model, 'label')  
189 - ->dropDownList(  
190 - ArrayHelper::map(  
191 - Label::find()  
192 - ->asArray()  
193 - ->all(),  
194 - 'id',  
195 - 'label'  
196 - ),  
197 - [ 'prompt' => 'Выберите метку' ]  
198 - ); ?>  
199 -  
200 - <?= $form->field($model, 'name') ?>  
201 -  
202 - <?= $form->field($model, 'phone')  
203 - ->textInput([ 'readonly' => $user->isAdmin() ? false : true ]) ?>  
204 -  
205 - <?= $form->field($model, 'phone2') ?>  
206 -  
207 - <?= $form->field($model, 'email')  
208 - ->textInput([ 'readonly' => $user->isAdmin() ? false : true ]) ?>  
209 -  
210 - <?= $form->field(  
211 - $model,  
212 - 'numbercard'  
213 - )  
214 - ->textInput([ 'readonly' => true ]) ?>  
215 -  
216 - <?= $form->field($model, 'comment')  
217 - ->textarea([ 'rows' => '3' ]) ?>  
218 - <?= $form->field($model, 'delivery')  
219 - ->dropDownList(  
220 - ArrayHelper::map(  
221 - Delivery::find()  
222 - ->joinWith('lang')  
223 - ->asArray()  
224 - ->all(),  
225 - 'id',  
226 - 'lang.title'  
227 - ),  
228 - [ 'prompt' => \Yii::t('app', 'Выберите доставку ...') ]  
229 - ) ?>  
230 -  
231 - <?php  
232 -  
233 - if ($user->isAdmin()) {  
234 - echo $form->field($model, 'manager_id')  
235 - ->dropDownList(  
236 - ArrayHelper::map(  
237 - User::find()  
238 - ->asArray()  
239 - ->all(),  
240 - 'id',  
241 - 'username'  
242 - ),  
243 - [ 'prompt' => \Yii::t('app', 'Менеджер') ]  
244 - );  
245 - }  
246 - ?>  
247 -  
248 - <h2><?php echo \Yii::t('app', 'Отправить смс'); ?></h2>  
249 - <?php  
250 - echo Select2::widget(  
251 - [  
252 - 'id' => 'sms-template-selector',  
253 - 'name' => 'select-sms-template',  
254 - 'data' => ArrayHelper::map(  
255 - SmsTemplate::find()  
256 - ->asArray()  
257 - ->all(),  
258 - 'text',  
259 - 'title'  
260 - ),  
261 - 'options' => [ 'placeholder' => \Yii::t('app', 'Выберите шаблон') ],  
262 - 'pluginOptions' => [  
263 - 'allowClear' => true,  
264 - ],  
265 - ]  
266 - );  
267 -  
268 - ?>  
269 - <br>  
270 - <?php  
271 - echo Html::textarea(  
272 - 'sms-text',  
273 - '',  
274 - [  
275 - 'rows' => 3,  
276 - 'id' => 'sms-text-area',  
277 - 'class' => 'form-control',  
278 - ]  
279 - );  
280 - ?>  
281 - <br>  
282 - <div class="row">  
283 - <div class="col-md-6">  
284 - <?php  
285 - if ($model->isNewRecord) {  
286 - echo Html::button(  
287 - \Yii::t('app', 'Отправить'),  
288 - [  
289 - 'class' => 'btn btn-warning disabled',  
290 - ]  
291 - );  
292 - } else {  
293 - echo Html::button(  
294 - \Yii::t('app', 'Отправить'),  
295 - [  
296 - 'class' => 'btn btn-warning',  
297 - 'id' => 'send-sms-action',  
298 - ]  
299 - );  
300 - }  
301 - ?>  
302 - </div>  
303 - <div class="col-md-6">  
304 - <?php  
305 - echo Html::radioList(  
306 - 'send-phone',  
307 - '1', 153 + <div class="form-group">
  154 + <br>
  155 + <div class="row">
  156 + <div class="col-sm-6">
  157 +
  158 + <?= $form->field($model, 'deadline')
  159 + ->widget(
  160 + DatePicker::className(),
  161 + [
  162 +
  163 + ]
  164 + ) ?>
  165 +
  166 + <?php
  167 + if ($user->isAdmin()) {
  168 + echo $form->field($model, 'pay')
  169 + ->widget(
  170 + SwitchInput::className(),
308 [ 171 [
309 - '1' => 'Первый номер',  
310 - '2' => 'Второй номер', 172 + 'name' => 'pay',
  173 + 'pluginOptions' => [
  174 + 'onText' => \Yii::t('app', 'Оплачено'),
  175 + 'offText' => \Yii::t('app', 'Не оплачено'),
  176 + ],
311 ] 177 ]
312 ); 178 );
313 - ?>  
314 - </div>  
315 - </div>  
316 -  
317 - </div>  
318 - <div class="col-sm-6">  
319 -  
320 - <?= $form->field($model, 'declaration') ?>  
321 -  
322 - <?= $form->field($model, 'stock') ?>  
323 -  
324 - <?= $form->field($model, 'consignment') ?>  
325 -  
326 - <?= $form->field($model, 'payment')  
327 - ->dropDownList(  
328 - ArrayHelper::map(  
329 - OrderPayment::find()  
330 - ->where([ 'status' => OrderPayment::ACTIVE ])  
331 - ->asArray()  
332 - ->all(),  
333 - 'id',  
334 - 'short'  
335 - ),  
336 - [ 'prompt' => 'Способ оплаты ...' ]  
337 - ); ?>  
338 - <?php  
339 - if ($model->payment == 10) {  
340 - ?>  
341 - <div>  
342 - <div class="col-xs-6">  
343 - <?php  
344 - echo $form->field($model, 'credit_sum')  
345 - ->textInput(  
346 - [  
347 - 'class' => 'form-control credit_input',  
348 - ]  
349 - );  
350 - ?>  
351 - </div>  
352 - <div class="col-xs-6">  
353 - <?php  
354 - echo $form->field($model, 'credit_month')  
355 - ->textInput(  
356 - [  
357 - 'class' => 'form-control credit_input',  
358 - ]  
359 - );  
360 - ?>  
361 - </div>  
362 - <div class="clearfix"></div>  
363 - <p> 179 + }
  180 + ?>
  181 +
  182 + <?= $form->field($model, 'reason')
  183 + ->dropDownList(
  184 + Order::REASONS,
  185 + [ 'prompt' => 'Выберите причину' ]
  186 + ) ?>
  187 +
  188 + <?= $form->field($model, 'label')
  189 + ->dropDownList(
  190 + ArrayHelper::map(
  191 + Label::find()
  192 + ->asArray()
  193 + ->all(),
  194 + 'id',
  195 + 'label'
  196 + ),
  197 + [ 'prompt' => 'Выберите метку' ]
  198 + ); ?>
  199 +
  200 + <?= $form->field($model, 'name') ?>
  201 +
  202 + <?= $form->field($model, 'phone') ?>
  203 +
  204 + <?= $form->field($model, 'phone2') ?>
  205 +
  206 + <?= $form->field($model, 'email')
  207 + ->textInput([ 'readonly' => $user->isAdmin() ? false : true ]) ?>
  208 +
  209 + <?= $form->field(
  210 + $model,
  211 + 'numbercard'
  212 + )
  213 + ->textInput([ 'readonly' => true ]) ?>
  214 +
  215 + <?= $form->field($model, 'comment')
  216 + ->textarea([ 'rows' => '3' ]) ?>
  217 + <?= $form->field($model, 'delivery')
  218 + ->dropDownList(
  219 + ArrayHelper::map(
  220 + Delivery::find()
  221 + ->joinWith('lang')
  222 + ->asArray()
  223 + ->all(),
  224 + 'id',
  225 + 'lang.title'
  226 + ),
  227 + [ 'prompt' => \Yii::t('app', 'Выберите доставку ...') ]
  228 + ) ?>
  229 +
  230 + <?php
  231 +
  232 + if ($user->isAdmin()) {
  233 + echo $form->field($model, 'manager_id')
  234 + ->dropDownList(
  235 + ArrayHelper::map(
  236 + User::find()
  237 + ->asArray()
  238 + ->all(),
  239 + 'id',
  240 + 'username'
  241 + ),
  242 + [ 'prompt' => \Yii::t('app', 'Менеджер') ]
  243 + );
  244 + }
  245 + ?>
  246 +
  247 + <h2><?php echo \Yii::t('app', 'Отправить смс'); ?></h2>
  248 + <?php
  249 + echo Select2::widget(
  250 + [
  251 + 'id' => 'sms-template-selector',
  252 + 'name' => 'select-sms-template',
  253 + 'data' => ArrayHelper::map(
  254 + SmsTemplate::find()
  255 + ->asArray()
  256 + ->all(),
  257 + 'text',
  258 + 'title'
  259 + ),
  260 + 'options' => [ 'placeholder' => \Yii::t('app', 'Выберите шаблон') ],
  261 + 'pluginOptions' => [
  262 + 'allowClear' => true,
  263 + ],
  264 + ]
  265 + );
  266 +
  267 + ?>
  268 + <br>
  269 + <?php
  270 + echo Html::textarea(
  271 + 'sms-text',
  272 + '',
  273 + [
  274 + 'rows' => 3,
  275 + 'id' => 'sms-text-area',
  276 + 'class' => 'form-control',
  277 + ]
  278 + );
  279 + ?>
  280 + <br>
  281 + <div class="row">
  282 + <div class="col-md-6">
  283 + <?php
  284 + if ($model->isNewRecord) {
  285 + echo Html::button(
  286 + \Yii::t('app', 'Отправить'),
  287 + [
  288 + 'class' => 'btn btn-warning disabled',
  289 + ]
  290 + );
  291 + } else {
  292 + echo Html::button(
  293 + \Yii::t('app', 'Отправить'),
  294 + [
  295 + 'class' => 'btn btn-warning',
  296 + 'id' => 'send-sms-action',
  297 + ]
  298 + );
  299 + }
  300 + ?>
  301 + </div>
  302 + <div class="col-md-6">
  303 + <?php
  304 + echo Html::radioList(
  305 + 'send-phone',
  306 + '1',
  307 + [
  308 + '1' => 'Первый номер',
  309 + '2' => 'Второй номер',
  310 + ]
  311 + );
  312 + ?>
  313 + </div>
  314 + </div>
  315 +
  316 + </div>
  317 + <div class="col-sm-6">
  318 +
  319 + <?= $form->field($model, 'declaration') ?>
  320 +
  321 + <?= $form->field($model, 'stock') ?>
  322 +
  323 + <?= $form->field($model, 'consignment') ?>
  324 +
  325 + <?= $form->field($model, 'payment')
  326 + ->dropDownList(
  327 + ArrayHelper::map(
  328 + OrderPayment::find()
  329 + ->where([ 'status' => OrderPayment::ACTIVE ])
  330 + ->asArray()
  331 + ->all(),
  332 + 'id',
  333 + 'short'
  334 + ),
  335 + [ 'prompt' => 'Способ оплаты ...' ]
  336 + ); ?>
  337 + <?php
  338 + if ($model->payment == 10) {
  339 + ?>
  340 + <div>
  341 + <div class="col-xs-6">
  342 + <?php
  343 + echo $form->field($model, 'credit_sum')
  344 + ->textInput(
  345 + [
  346 + 'class' => 'form-control credit_input',
  347 + ]
  348 + );
  349 + ?>
  350 + </div>
  351 + <div class="col-xs-6">
  352 + <?php
  353 + echo $form->field($model, 'credit_month')
  354 + ->textInput(
  355 + [
  356 + 'class' => 'form-control credit_input',
  357 + ]
  358 + );
  359 + ?>
  360 + </div>
  361 + <div class="clearfix"></div>
  362 + <p>
364 <span class="credit_value"> 363 <span class="credit_value">
365 <?php 364 <?php
366 echo CreditHelper::getCredit($model->total); 365 echo CreditHelper::getCredit($model->total);
367 ?> 366 ?>
368 </span> 367 </span>
369 - <span>грн/мес</span>  
370 - </p>  
371 - </div>  
372 - <?php  
373 - }  
374 - ?>  
375 -  
376 - <?= $form->field($model, 'insurance') ?>  
377 -  
378 - <?= $form->field($model, 'amount_imposed') ?>  
379 -  
380 - <?= $form->field($model, 'shipping_by')  
381 - ->dropDownList(  
382 - ArrayHelper::getColumn(Order::SHIPPING_BY, 'label'),  
383 - [ 'prompt' => 'Оплата доставки ...' ]  
384 - ); ?>  
385 -  
386 - <?= $form->field($model, 'city') ?>  
387 -  
388 - <?= $form->field($model, 'adress') ?>  
389 -  
390 - <?= $form->field($model, 'body')  
391 - ->textarea([ 'rows' => '3' ]) ?>  
392 -  
393 - <?= $form->field($model, 'check') ?>  
394 -  
395 - <?= $form->field($model, 'sms') ?>  
396 -  
397 - <?= $form->field($model, 'delivery_cost') ?>  
398 -  
399 - </div>  
400 - </div> 368 + <span>грн/мес</span>
  369 + </p>
  370 + </div>
  371 + <?php
  372 + }
  373 + ?>
  374 +
  375 + <?= $form->field($model, 'insurance') ?>
  376 +
  377 + <?= $form->field($model, 'amount_imposed') ?>
  378 +
  379 + <?= $form->field($model, 'shipping_by')
  380 + ->dropDownList(
  381 + ArrayHelper::getColumn(Order::SHIPPING_BY, 'label'),
  382 + [ 'prompt' => 'Оплата доставки ...' ]
  383 + ); ?>
  384 +
  385 + <?= $form->field($model, 'city') ?>
  386 +
  387 + <?= $form->field($model, 'adress') ?>
  388 +
  389 + <?= $form->field($model, 'body')
  390 + ->textarea([ 'rows' => '3' ]) ?>
  391 +
  392 + <?= $form->field($model, 'check') ?>
  393 +
  394 + <?= $form->field($model, 'sms') ?>
  395 +
  396 + <?= $form->field($model, 'delivery_cost') ?>
  397 +
  398 + </div>
401 </div> 399 </div>
  400 + </div>
402 </div> 401 </div>
403 402
404 <?php ActiveForm::end(); ?> 403 <?php ActiveForm::end(); ?>
views/statistics/index.php 0 → 100644
  1 +<?php
  2 + use yii\web\View;
  3 +
  4 + /**
  5 + * @var View $this
  6 + */
  7 +
  8 +?>
  9 +
  10 +<div class="box box-default">
  11 + <div class="box-header with-border">
  12 + <h3 class="box-title">Collapsable</h3>
  13 + <div class="box-tools pull-right">
  14 + <button class="btn btn-box-tool" data-widget="collapse"><i class="fa fa-minus"></i></button>
  15 + </div><!-- /.box-tools -->
  16 + </div><!-- /.box-header -->
  17 + <div class="box-body">
  18 + The body of the box
  19 + </div><!-- /.box-body -->
  20 +</div><!-- /.box -->