Commit 93a0cd0b2acfd877193bcee95aa0ffb976124297
1 parent
8904e372
Credits
Showing
2 changed files
with
591 additions
and
533 deletions
Show diff stats
models/Order.php
... | ... | @@ -54,6 +54,8 @@ |
54 | 54 | * @property string $city |
55 | 55 | * @property string $deliveryString |
56 | 56 | * @property boolean $published |
57 | + * @property float $credit_sum | |
58 | + * @property int $credit_month | |
57 | 59 | */ |
58 | 60 | class Order extends ActiveRecord |
59 | 61 | { |
... | ... | @@ -161,6 +163,22 @@ |
161 | 163 | ], |
162 | 164 | [ |
163 | 165 | [ |
166 | + 'credit_month', | |
167 | + ], | |
168 | + 'integer', | |
169 | + 'min' => 3, | |
170 | + 'max' => 36, | |
171 | + ], | |
172 | + [ | |
173 | + [ | |
174 | + 'credit_sum', | |
175 | + ], | |
176 | + 'number', | |
177 | + 'min' => 300, | |
178 | + 'max' => 25000, | |
179 | + ], | |
180 | + [ | |
181 | + [ | |
164 | 182 | 'deadline', |
165 | 183 | 'name', |
166 | 184 | 'numbercard', |
... | ... | @@ -246,6 +264,8 @@ |
246 | 264 | 'shipping_by' => Yii::t('app', 'Отправка за счет'), |
247 | 265 | 'city' => Yii::t('app', 'Город'), |
248 | 266 | 'numbercard' => Yii::t('app', '№ карточки'), |
267 | + 'credit_month' => Yii::t('app', 'Количество месяцев'), | |
268 | + 'credit_sum' => Yii::t('app', 'Сумма кредита'), | |
249 | 269 | ]; |
250 | 270 | } |
251 | 271 | ... | ... |
views/order/_form.php
... | ... | @@ -5,6 +5,7 @@ |
5 | 5 | use artweb\artbox\ecommerce\models\OrderPayment; |
6 | 6 | use artweb\artbox\ecommerce\models\OrderProduct; |
7 | 7 | use backend\models\SmsTemplate; |
8 | + use common\components\CreditHelper; | |
8 | 9 | use common\models\User; |
9 | 10 | use kartik\grid\GridView; |
10 | 11 | use kartik\grid\SerialColumn; |
... | ... | @@ -144,571 +145,608 @@ JS; |
144 | 145 | |
145 | 146 | <?php $form = ActiveForm::begin( |
146 | 147 | [ |
147 | - 'id' => 'main-form', | |
148 | -// 'options' => [ 'class' => 'form-inline' ], | |
148 | + 'id' => 'main-form', | |
149 | + // 'options' => [ 'class' => 'form-inline' ], | |
149 | 150 | ] |
150 | 151 | ); ?> |
151 | 152 | <div class="container"> |
152 | - <div class="form-group"> | |
153 | - <br> | |
154 | - <div class="row"> | |
155 | - <div class="col-sm-6"> | |
156 | - | |
157 | - <?= $form->field($model, 'deadline') | |
158 | - ->widget( | |
159 | - DatePicker::className(), | |
160 | - [ | |
161 | - | |
162 | - ] | |
163 | - ) ?> | |
164 | - | |
165 | - <?php | |
166 | - if ($user->isAdmin()) { | |
167 | - echo $form->field($model, 'pay') | |
168 | - ->widget( | |
169 | - SwitchInput::className(), | |
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', | |
170 | 308 | [ |
171 | - 'name' => 'pay', | |
172 | - 'pluginOptions' => [ | |
173 | - 'onText' => \Yii::t('app', 'Оплачено'), | |
174 | - 'offText' => \Yii::t('app', 'Не оплачено'), | |
175 | - ], | |
309 | + '1' => 'Первый номер', | |
310 | + '2' => 'Второй номер', | |
176 | 311 | ] |
177 | 312 | ); |
178 | - } | |
179 | - ?> | |
180 | - | |
181 | - <?= $form->field($model, 'reason') | |
182 | - ->dropDownList( | |
183 | - Order::REASONS, | |
184 | - [ 'prompt' => 'Выберите причину' ] | |
185 | - ) ?> | |
186 | - | |
187 | - <?= $form->field($model, 'label') | |
188 | - ->dropDownList( | |
189 | - ArrayHelper::map( | |
190 | - Label::find() | |
191 | - ->asArray() | |
192 | - ->all(), | |
193 | - 'id', | |
194 | - 'label' | |
195 | - ), | |
196 | - [ 'prompt' => 'Выберите метку' ] | |
197 | - ); ?> | |
198 | - | |
199 | - <?= $form->field($model, 'name') ?> | |
200 | - | |
201 | - <?= $form->field($model, 'phone') | |
202 | - ->textInput([ 'readonly' => $user->isAdmin() ? false : true ]) ?> | |
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> | |
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> | |
364 | + <span class="credit_value"> | |
365 | + <?php | |
366 | + echo CreditHelper::getCredit($model->total); | |
367 | + ?> | |
368 | + </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> | |
314 | 400 | </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 | - | |
338 | - <?= $form->field($model, 'insurance') ?> | |
339 | - | |
340 | - <?= $form->field($model, 'amount_imposed') ?> | |
341 | - | |
342 | - <?= $form->field($model, 'shipping_by') | |
343 | - ->dropDownList( | |
344 | - ArrayHelper::getColumn(Order::SHIPPING_BY, 'label'), | |
345 | - [ 'prompt' => 'Оплата доставки ...' ] | |
346 | - ); ?> | |
347 | - | |
348 | - <?= $form->field($model, 'city') ?> | |
349 | - | |
350 | - <?= $form->field($model, 'adress') ?> | |
351 | - | |
352 | - <?= $form->field($model, 'body') | |
353 | - ->textarea([ 'rows' => '3' ]) ?> | |
354 | - | |
355 | - <?= $form->field($model, 'check') ?> | |
356 | - | |
357 | - <?= $form->field($model, 'sms') ?> | |
358 | - | |
359 | - <?= $form->field($model, 'delivery_cost') ?> | |
360 | - | |
361 | - </div> | |
362 | 401 | </div> |
363 | - </div> | |
364 | 402 | </div> |
365 | 403 | |
366 | 404 | <?php ActiveForm::end(); ?> |
367 | 405 | <br> |
368 | 406 | <br> |
369 | 407 | <div class="container"> |
370 | - <div class="row"> | |
371 | - <?php | |
372 | - echo GridView::widget( | |
373 | - [ | |
374 | - 'dataProvider' => $dataProvider, | |
375 | - 'rowOptions' => function($model) { | |
376 | - if ($model->removed) { | |
377 | - return [ 'class' => 'danger' ]; | |
378 | - } else { | |
379 | - return []; | |
380 | - } | |
381 | - }, | |
382 | - 'layout' => '{items}{pager}', | |
383 | - 'columns' => [ | |
384 | - [ | |
385 | - 'class' => SerialColumn::className(), | |
386 | - ], | |
387 | - 'sku', | |
388 | - [ | |
389 | - 'attribute' => 'product_name', | |
390 | - 'content' => function($model) { | |
391 | - if (!empty($model->product_name)) { | |
408 | + <div class="row"> | |
409 | + <?php | |
410 | + echo GridView::widget( | |
411 | + [ | |
412 | + 'dataProvider' => $dataProvider, | |
413 | + 'rowOptions' => function ($model) { | |
414 | + if ($model->removed) { | |
415 | + return [ 'class' => 'danger' ]; | |
416 | + } else { | |
417 | + return []; | |
418 | + } | |
419 | + }, | |
420 | + 'layout' => '{items}{pager}', | |
421 | + 'columns' => [ | |
422 | + [ | |
423 | + 'class' => SerialColumn::className(), | |
424 | + ], | |
425 | + 'sku', | |
426 | + [ | |
427 | + 'attribute' => 'product_name', | |
428 | + 'content' => function ($model) { | |
429 | + if (!empty( $model->product_name )) { | |
430 | + | |
431 | + if (empty( $model->productVariant )) { | |
432 | + return ''; | |
433 | + } | |
434 | + | |
435 | + return Html::a( | |
436 | + StringHelper::truncate($model->product_name, 10, '...'), | |
437 | + '#', | |
438 | + [ | |
439 | + 'onclick' => 'event.preventDefault();', | |
440 | + 'data-toggle' => 'popover', | |
441 | + 'data-placement' => 'right', | |
442 | + 'data-html' => 'true', | |
443 | + 'data-content' => Html::img( | |
444 | + $model->productVariant->imageUrl, | |
445 | + [ | |
446 | + 'class' => 'img-rounded', | |
447 | + ] | |
448 | + ) . Html::tag('p', $model->product_name), | |
449 | + ] | |
450 | + ); | |
451 | + } else { | |
452 | + return ''; | |
453 | + } | |
454 | + }, | |
455 | + ], | |
456 | + [ | |
457 | + 'attribute' => 'productVariant.product.brand.lang.title', | |
458 | + 'label' => 'Брэнд', | |
459 | + ], | |
460 | + [ | |
461 | + 'attribute' => 'productVariant.lang.title', | |
462 | + 'label' => \Yii::t('app', 'Цвет'), | |
463 | + 'content' => function ($model) { | |
392 | 464 | |
393 | - if (empty($model->productVariant)) { | |
465 | + if (empty( $model->productVariant )) { | |
394 | 466 | return ''; |
395 | - } | |
396 | - | |
397 | - return Html::a( | |
398 | - StringHelper::truncate($model->product_name, 10, '...'), | |
399 | - '#', | |
400 | - [ | |
401 | - 'onclick' => 'event.preventDefault();', | |
402 | - 'data-toggle' => 'popover', | |
403 | - 'data-placement' => 'right', | |
404 | - 'data-html' => 'true', | |
405 | - 'data-content' => Html::img( | |
406 | - $model->productVariant->imageUrl, | |
407 | - [ | |
408 | - 'class' => 'img-rounded', | |
409 | - ] | |
410 | - ) . Html::tag('p', $model->product_name), | |
411 | - ] | |
412 | - ); | |
413 | - } else { | |
414 | - return ''; | |
415 | - } | |
416 | - }, | |
417 | - ], | |
418 | - [ | |
419 | - 'attribute' => 'productVariant.product.brand.lang.title', | |
420 | - 'label' => 'Брэнд', | |
421 | - ], | |
422 | - [ | |
423 | - 'attribute' => 'productVariant.lang.title', | |
424 | - 'label' => \Yii::t('app', 'Цвет'), | |
425 | - 'content' => function($model) { | |
426 | - | |
427 | - if (empty($model->productVariant)) { | |
428 | - return ''; | |
429 | - } | |
430 | - | |
431 | - if (preg_match('@.*\.(png|jpg|gif)@i', $model->productVariant->lang->title)) { | |
432 | - return ''; | |
433 | - } else { | |
434 | - return $model->productVariant->lang->title; | |
435 | - } | |
436 | - }, | |
437 | - ], | |
438 | - [ | |
439 | - 'attribute' => 'productVariant.size', | |
440 | - 'label' => 'Размер', | |
441 | - ], | |
442 | - 'price', | |
443 | - [ | |
444 | - 'class' => 'kartik\grid\EditableColumn', | |
445 | - 'attribute' => 'count', | |
446 | - 'editableOptions' => [ | |
447 | - 'header' => \Yii::t('app', 'Количество'), | |
448 | - 'inputType' => kartik\editable\Editable::INPUT_SPIN, | |
449 | - 'options' => [ | |
450 | - 'pluginOptions' => [ | |
451 | - 'min' => 0, | |
452 | - 'max' => 5000, | |
453 | - ], | |
454 | - ], | |
455 | - 'pluginEvents' => [ | |
456 | - 'editableSuccess' => 'function(event) { $.pjax.reload({container:"#order-products-grid"}); }', | |
457 | - ], | |
458 | - ], | |
459 | - 'format' => [ | |
460 | - 'decimal', | |
461 | - 0, | |
462 | - ], | |
463 | - 'pageSummary' => false, | |
464 | - ], | |
465 | - 'sum_cost', | |
466 | - [ | |
467 | - 'class' => 'kartik\grid\EditableColumn', | |
468 | - 'attribute' => 'booking', | |
469 | - 'editableOptions' => [ | |
470 | - 'header' => \Yii::t('app', 'Бронь'), | |
471 | - 'inputType' => kartik\editable\Editable::INPUT_TEXT, | |
472 | - 'options' => [ | |
473 | - 'class' => 'booking-typeahead', | |
474 | - 'pluginOptions' => [ | |
475 | - 'min' => 0, | |
476 | - 'max' => 20, | |
477 | - ], | |
478 | - ], | |
479 | - 'pluginEvents' => [ | |
480 | - 'editableSuccess' => 'function(event) { $.pjax.reload({container:"#order-products-grid"}); }', | |
481 | - ], | |
482 | - ], | |
483 | - 'format' => [ | |
484 | - 'text', | |
485 | - ], | |
486 | - 'pageSummary' => false, | |
487 | - ], | |
488 | - [ | |
489 | - 'class' => 'kartik\grid\EditableColumn', | |
490 | - 'attribute' => 'status', | |
491 | - 'editableOptions' => [ | |
492 | - 'header' => \Yii::t('app', 'Статус'), | |
493 | - 'inputType' => kartik\editable\Editable::INPUT_TEXT, | |
494 | - 'options' => [ | |
495 | - 'class' => 'status-typeahead', | |
496 | - 'pluginOptions' => [ | |
497 | - 'min' => 0, | |
498 | - 'max' => 20, | |
499 | - ], | |
500 | - ], | |
501 | - 'pluginEvents' => [ | |
502 | - 'editableSuccess' => 'function(event) { $.pjax.reload({container:"#order-products-grid"}); }', | |
503 | - ], | |
504 | - ], | |
505 | - 'format' => [ | |
506 | - 'text', | |
507 | - ], | |
508 | - 'pageSummary' => false, | |
509 | - ], | |
510 | - [ | |
511 | - 'class' => 'kartik\grid\EditableColumn', | |
512 | - 'attribute' => 'return', | |
513 | - 'editableOptions' => [ | |
514 | - 'header' => \Yii::t('app', 'Возврат'), | |
515 | - 'inputType' => kartik\editable\Editable::INPUT_CHECKBOX, | |
516 | - 'options' => [], | |
517 | - 'pluginEvents' => [ | |
518 | - 'editableSuccess' => 'function(event) { $.pjax.reload({container:"#order-products-grid"}); }', | |
519 | - ], | |
520 | - ], | |
521 | - 'format' => [ | |
522 | - 'boolean', | |
523 | - ], | |
524 | - 'pageSummary' => false, | |
525 | - ], | |
526 | - [ | |
527 | - 'content' => function($model) { | |
528 | - | |
529 | - if (empty($model->productVariant)) { | |
530 | - return '<i class="glyphicon glyphicon-remove"></i>'; | |
531 | - } | |
532 | - | |
533 | - $content = '<table class="table"><tbody><tr><th>Склад</th><th>кол.</th></tr>'; | |
534 | - foreach ($model->productVariant->variantStocks as $stock) { | |
535 | - $content .= '<tr><td>' . $stock->stock->title . '</td><td>' . $stock->quantity . '</td></tr>'; | |
536 | - } | |
537 | - return Html::a( | |
538 | - '<i class="glyphicon glyphicon-home"></i>', | |
539 | - '#', | |
540 | - [ | |
541 | - 'onclick' => 'event.preventDefault();', | |
542 | - 'data-toggle' => 'popover', | |
543 | - 'data-placement' => 'left', | |
544 | - 'data-html' => 'true', | |
545 | - 'data-content' => $content . '</tbody></table>', | |
546 | - ] | |
547 | - ); | |
548 | - }, | |
549 | - ], | |
550 | - [ | |
551 | - 'class' => 'yii\grid\ActionColumn', | |
552 | - 'template' => '{delete}', | |
553 | - 'buttons' => [ | |
554 | - 'delete' => function($url, $product) { | |
555 | - if ($product->removed) { | |
556 | - return ''; | |
557 | - } else { | |
558 | - return Html::a( | |
559 | - Html::tag('span', '', [ 'class' => 'glyphicon glyphicon-trash' ]), | |
560 | - [ | |
561 | - 'delete-product', | |
562 | - 'id' => $product->id, | |
563 | - ], | |
564 | - [ | |
565 | - 'class' => 'delete-button', | |
566 | - // 'data' => [ | |
567 | - // 'confirm' => 'Вы уверены, что хотите удалить этот элемент?', | |
568 | - // 'method' => 'GET', | |
569 | - // ], | |
570 | - ] | |
571 | - ); | |
572 | - } | |
573 | - }, | |
574 | - ], | |
575 | - ], | |
576 | - ], | |
577 | - 'responsive' => true, | |
578 | - 'hover' => true, | |
579 | - 'pjax' => true, | |
580 | - 'pjaxSettings' => [ | |
581 | - 'options' => [ | |
582 | - 'scrollTo' => 'false', | |
583 | - 'id' => 'order-products-grid', | |
584 | - ], | |
585 | - ], | |
586 | - ] | |
587 | - ); | |
588 | - ?> | |
589 | - </div> | |
467 | + } | |
468 | + | |
469 | + if (preg_match('@.*\.(png|jpg|gif)@i', $model->productVariant->lang->title)) { | |
470 | + return ''; | |
471 | + } else { | |
472 | + return $model->productVariant->lang->title; | |
473 | + } | |
474 | + }, | |
475 | + ], | |
476 | + [ | |
477 | + 'attribute' => 'productVariant.size', | |
478 | + 'label' => 'Размер', | |
479 | + ], | |
480 | + 'price', | |
481 | + [ | |
482 | + 'class' => 'kartik\grid\EditableColumn', | |
483 | + 'attribute' => 'count', | |
484 | + 'editableOptions' => [ | |
485 | + 'header' => \Yii::t('app', 'Количество'), | |
486 | + 'inputType' => kartik\editable\Editable::INPUT_SPIN, | |
487 | + 'options' => [ | |
488 | + 'pluginOptions' => [ | |
489 | + 'min' => 0, | |
490 | + 'max' => 5000, | |
491 | + ], | |
492 | + ], | |
493 | + 'pluginEvents' => [ | |
494 | + 'editableSuccess' => 'function(event) { $.pjax.reload({container:"#order-products-grid"}); }', | |
495 | + ], | |
496 | + ], | |
497 | + 'format' => [ | |
498 | + 'decimal', | |
499 | + 0, | |
500 | + ], | |
501 | + 'pageSummary' => false, | |
502 | + ], | |
503 | + 'sum_cost', | |
504 | + [ | |
505 | + 'class' => 'kartik\grid\EditableColumn', | |
506 | + 'attribute' => 'booking', | |
507 | + 'editableOptions' => [ | |
508 | + 'header' => \Yii::t('app', 'Бронь'), | |
509 | + 'inputType' => kartik\editable\Editable::INPUT_TEXT, | |
510 | + 'options' => [ | |
511 | + 'class' => 'booking-typeahead', | |
512 | + 'pluginOptions' => [ | |
513 | + 'min' => 0, | |
514 | + 'max' => 20, | |
515 | + ], | |
516 | + ], | |
517 | + 'pluginEvents' => [ | |
518 | + 'editableSuccess' => 'function(event) { $.pjax.reload({container:"#order-products-grid"}); }', | |
519 | + ], | |
520 | + ], | |
521 | + 'format' => [ | |
522 | + 'text', | |
523 | + ], | |
524 | + 'pageSummary' => false, | |
525 | + ], | |
526 | + [ | |
527 | + 'class' => 'kartik\grid\EditableColumn', | |
528 | + 'attribute' => 'status', | |
529 | + 'editableOptions' => [ | |
530 | + 'header' => \Yii::t('app', 'Статус'), | |
531 | + 'inputType' => kartik\editable\Editable::INPUT_TEXT, | |
532 | + 'options' => [ | |
533 | + 'class' => 'status-typeahead', | |
534 | + 'pluginOptions' => [ | |
535 | + 'min' => 0, | |
536 | + 'max' => 20, | |
537 | + ], | |
538 | + ], | |
539 | + 'pluginEvents' => [ | |
540 | + 'editableSuccess' => 'function(event) { $.pjax.reload({container:"#order-products-grid"}); }', | |
541 | + ], | |
542 | + ], | |
543 | + 'format' => [ | |
544 | + 'text', | |
545 | + ], | |
546 | + 'pageSummary' => false, | |
547 | + ], | |
548 | + [ | |
549 | + 'class' => 'kartik\grid\EditableColumn', | |
550 | + 'attribute' => 'return', | |
551 | + 'editableOptions' => [ | |
552 | + 'header' => \Yii::t('app', 'Возврат'), | |
553 | + 'inputType' => kartik\editable\Editable::INPUT_CHECKBOX, | |
554 | + 'options' => [], | |
555 | + 'pluginEvents' => [ | |
556 | + 'editableSuccess' => 'function(event) { $.pjax.reload({container:"#order-products-grid"}); }', | |
557 | + ], | |
558 | + ], | |
559 | + 'format' => [ | |
560 | + 'boolean', | |
561 | + ], | |
562 | + 'pageSummary' => false, | |
563 | + ], | |
564 | + [ | |
565 | + 'content' => function ($model) { | |
566 | + | |
567 | + if (empty( $model->productVariant )) { | |
568 | + return '<i class="glyphicon glyphicon-remove"></i>'; | |
569 | + } | |
570 | + | |
571 | + $content = '<table class="table"><tbody><tr><th>Склад</th><th>кол.</th></tr>'; | |
572 | + foreach ($model->productVariant->variantStocks as $stock) { | |
573 | + $content .= '<tr><td>' . $stock->stock->title . '</td><td>' . $stock->quantity . '</td></tr>'; | |
574 | + } | |
575 | + return Html::a( | |
576 | + '<i class="glyphicon glyphicon-home"></i>', | |
577 | + '#', | |
578 | + [ | |
579 | + 'onclick' => 'event.preventDefault();', | |
580 | + 'data-toggle' => 'popover', | |
581 | + 'data-placement' => 'left', | |
582 | + 'data-html' => 'true', | |
583 | + 'data-content' => $content . '</tbody></table>', | |
584 | + ] | |
585 | + ); | |
586 | + }, | |
587 | + ], | |
588 | + [ | |
589 | + 'class' => 'yii\grid\ActionColumn', | |
590 | + 'template' => '{delete}', | |
591 | + 'buttons' => [ | |
592 | + 'delete' => function ($url, $product) { | |
593 | + if ($product->removed) { | |
594 | + return ''; | |
595 | + } else { | |
596 | + return Html::a( | |
597 | + Html::tag('span', '', [ 'class' => 'glyphicon glyphicon-trash' ]), | |
598 | + [ | |
599 | + 'delete-product', | |
600 | + 'id' => $product->id, | |
601 | + ], | |
602 | + [ | |
603 | + 'class' => 'delete-button', | |
604 | + // 'data' => [ | |
605 | + // 'confirm' => 'Вы уверены, что хотите удалить этот элемент?', | |
606 | + // 'method' => 'GET', | |
607 | + // ], | |
608 | + ] | |
609 | + ); | |
610 | + } | |
611 | + }, | |
612 | + ], | |
613 | + ], | |
614 | + ], | |
615 | + 'responsive' => true, | |
616 | + 'hover' => true, | |
617 | + 'pjax' => true, | |
618 | + 'pjaxSettings' => [ | |
619 | + 'options' => [ | |
620 | + 'scrollTo' => 'false', | |
621 | + 'id' => 'order-products-grid', | |
622 | + ], | |
623 | + ], | |
624 | + ] | |
625 | + ); | |
626 | + ?> | |
627 | + </div> | |
590 | 628 | </div> |
591 | 629 | <div class="container"> |
592 | 630 | <?php Pjax::begin([ 'id' => 'total-cost' ]); ?> |
593 | - <h2>Сумма заказа : <span class="label label-success"><?php echo $model->total; ?><?php echo \Yii::t( | |
594 | - 'app', | |
595 | - 'грн' | |
596 | - ) ?></span></h2> | |
631 | + <h2>Сумма заказа : <span class="label label-success"><?php echo $model->total; ?><?php echo \Yii::t( | |
632 | + 'app', | |
633 | + 'грн' | |
634 | + ) ?></span></h2> | |
597 | 635 | <?php Pjax::end(); ?> |
598 | 636 | </div> |
599 | 637 | <div class="container"> |
600 | - <div class="row"> | |
601 | - <?php $newProductForm = ActiveForm::begin( | |
602 | - [ | |
603 | - 'action' => yii\helpers\Url::to([ 'add' ]), | |
604 | - 'id' => 'add-product-form', | |
605 | - ] | |
606 | - ); | |
607 | - $newOrderProduct = new OrderProduct(); | |
608 | - ?> | |
609 | - <div class="col-md-8"> | |
610 | - <?php echo $newProductForm->field($newOrderProduct, 'id') | |
611 | - ->widget( | |
612 | - Select2::className(), | |
613 | - [ | |
614 | - 'options' => [ 'placeholder' => 'Search for a product ...' ], | |
615 | - 'pluginOptions' => [ | |
616 | - 'allowClear' => true, | |
617 | - 'disabled' => $model->isNewRecord ? true : false, | |
618 | - 'minimumInputLength' => 3, | |
619 | - 'language' => [ | |
620 | - 'errorLoading' => new JsExpression( | |
621 | - "function () { return 'Waiting for results...'; }" | |
638 | + <div class="row"> | |
639 | + <?php $newProductForm = ActiveForm::begin( | |
640 | + [ | |
641 | + 'action' => yii\helpers\Url::to([ 'add' ]), | |
642 | + 'id' => 'add-product-form', | |
643 | + ] | |
644 | + ); | |
645 | + $newOrderProduct = new OrderProduct(); | |
646 | + ?> | |
647 | + <div class="col-md-8"> | |
648 | + <?php echo $newProductForm->field($newOrderProduct, 'id') | |
649 | + ->widget( | |
650 | + Select2::className(), | |
651 | + [ | |
652 | + 'options' => [ 'placeholder' => 'Search for a product ...' ], | |
653 | + 'pluginOptions' => [ | |
654 | + 'allowClear' => true, | |
655 | + 'disabled' => $model->isNewRecord ? true : false, | |
656 | + 'minimumInputLength' => 3, | |
657 | + 'language' => [ | |
658 | + 'errorLoading' => new JsExpression( | |
659 | + "function () { return 'Waiting for results...'; }" | |
660 | + ), | |
661 | + ], | |
662 | + 'ajax' => [ | |
663 | + 'url' => \yii\helpers\Url::to([ 'find-product' ]), | |
664 | + 'dataType' => 'json', | |
665 | + 'data' => new JsExpression( | |
666 | + 'function(params) { return {q:params.term}; }' | |
667 | + ), | |
668 | + ], | |
669 | + 'escapeMarkup' => new JsExpression( | |
670 | + 'function (markup) { return markup; }' | |
622 | 671 | ), |
623 | - ], | |
624 | - 'ajax' => [ | |
625 | - 'url' => \yii\helpers\Url::to([ 'find-product' ]), | |
626 | - 'dataType' => 'json', | |
627 | - 'data' => new JsExpression( | |
628 | - 'function(params) { return {q:params.term}; }' | |
672 | + 'templateResult' => new JsExpression( | |
673 | + 'function(data) { return data.sku; }' | |
674 | + ), | |
675 | + 'templateSelection' => new JsExpression( | |
676 | + 'function (data) { return data.sku; }' | |
629 | 677 | ), |
630 | 678 | ], |
631 | - 'escapeMarkup' => new JsExpression( | |
632 | - 'function (markup) { return markup; }' | |
633 | - ), | |
634 | - 'templateResult' => new JsExpression( | |
635 | - 'function(data) { return data.sku; }' | |
636 | - ), | |
637 | - 'templateSelection' => new JsExpression( | |
638 | - 'function (data) { return data.sku; }' | |
639 | - ), | |
640 | - ], | |
641 | - ] | |
642 | - ) | |
643 | - ->label('Артикул'); | |
644 | - | |
645 | - ?> | |
646 | - </div> | |
647 | - <div class="col-md-2"> | |
648 | - <?php echo $newProductForm->field( | |
649 | - $newOrderProduct, | |
650 | - 'count' | |
651 | - ) | |
652 | - ->input( | |
653 | - 'number', | |
679 | + ] | |
680 | + ) | |
681 | + ->label('Артикул'); | |
682 | + | |
683 | + ?> | |
684 | + </div> | |
685 | + <div class="col-md-2"> | |
686 | + <?php echo $newProductForm->field( | |
687 | + $newOrderProduct, | |
688 | + 'count' | |
689 | + ) | |
690 | + ->input( | |
691 | + 'number', | |
692 | + [ | |
693 | + 'disabled' => $model->isNewRecord ? true : false, | |
694 | + ] | |
695 | + ); ?> | |
696 | + </div> | |
697 | + <div class="col-md-2" style="margin-top: 23px"> | |
698 | + <?php echo Html::submitButton( | |
699 | + \Yii::t('app', 'Добавить'), | |
700 | + [ | |
701 | + 'class' => $model->isNewRecord ? 'btn btn-primary disabled' : 'btn btn-primary', | |
702 | + ] | |
703 | + ) ?> | |
704 | + </div> | |
705 | + <?php echo $newProductForm->field($newOrderProduct, 'order_id') | |
706 | + ->hiddenInput( | |
654 | 707 | [ |
655 | - 'disabled' => $model->isNewRecord ? true : false, | |
708 | + 'value' => $model->id, | |
656 | 709 | ] |
657 | - ); ?> | |
710 | + ) | |
711 | + ->label(false) ?> | |
712 | + <?php ActiveForm::end(); ?> | |
658 | 713 | </div> |
659 | - <div class="col-md-2" style="margin-top: 23px"> | |
660 | - <?php echo Html::submitButton( | |
661 | - \Yii::t('app', 'Добавить'), | |
714 | + | |
715 | + <br> | |
716 | + <div class="row"> | |
717 | + <?= Html::button( | |
718 | + $model->isNewRecord ? \Yii::t('app', 'Создать') : \Yii::t('app', 'Сохранить'), | |
719 | + [ | |
720 | + 'class' => $model->isNewRecord ? 'btn btn-success btn-lg' : 'btn btn-primary btn-lg', | |
721 | + 'id' => 'page-submit', | |
722 | + ] | |
723 | + ) ?> | |
724 | + <?= Html::a( | |
725 | + \Yii::t('app', 'Печать'), | |
726 | + yii\helpers\Url::to( | |
727 | + [ | |
728 | + 'order/print', | |
729 | + 'order_id' => $model->id, | |
730 | + ] | |
731 | + ), | |
662 | 732 | [ |
663 | - 'class' => $model->isNewRecord ? 'btn btn-primary disabled' : 'btn btn-primary', | |
733 | + 'class' => $model->isNewRecord ? 'btn btn-info disabled btn-lg' : 'btn btn-info btn-lg', | |
734 | + 'target' => '_blank', | |
735 | + ] | |
736 | + ) ?> | |
737 | + <?= Html::a( | |
738 | + \Yii::t('app', 'Выйти'), | |
739 | + yii\helpers\Url::to( | |
740 | + [ | |
741 | + 'close-order', | |
742 | + 'id' => $model->id, | |
743 | + ] | |
744 | + ), | |
745 | + [ | |
746 | + 'class' => $model->isNewRecord ? 'btn btn-info disabled btn-lg' : 'btn btn-info btn-lg', | |
664 | 747 | ] |
665 | 748 | ) ?> |
666 | 749 | </div> |
667 | - <?php echo $newProductForm->field($newOrderProduct, 'order_id') | |
668 | - ->hiddenInput( | |
669 | - [ | |
670 | - 'value' => $model->id, | |
671 | - ] | |
672 | - ) | |
673 | - ->label(false) ?> | |
674 | - <?php ActiveForm::end(); ?> | |
675 | - </div> | |
676 | - | |
677 | - <br> | |
678 | - <div class="row"> | |
679 | - <?= Html::button( | |
680 | - $model->isNewRecord ? \Yii::t('app', 'Создать') : \Yii::t('app', 'Сохранить'), | |
681 | - [ | |
682 | - 'class' => $model->isNewRecord ? 'btn btn-success btn-lg' : 'btn btn-primary btn-lg', | |
683 | - 'id' => 'page-submit', | |
684 | - ] | |
685 | - ) ?> | |
686 | - <?= Html::a( | |
687 | - \Yii::t('app', 'Печать'), | |
688 | - yii\helpers\Url::to( | |
689 | - [ | |
690 | - 'order/print', | |
691 | - 'order_id' => $model->id, | |
692 | - ] | |
693 | - ), | |
694 | - [ | |
695 | - 'class' => $model->isNewRecord ? 'btn btn-info disabled btn-lg' : 'btn btn-info btn-lg', | |
696 | - 'target' => '_blank', | |
697 | - ] | |
698 | - ) ?> | |
699 | - <?= Html::a( | |
700 | - \Yii::t('app', 'Выйти'), | |
701 | - yii\helpers\Url::to( | |
702 | - [ | |
703 | - 'close-order', | |
704 | - 'id' => $model->id, | |
705 | - ] | |
706 | - ), | |
707 | - [ | |
708 | - 'class' => $model->isNewRecord ? 'btn btn-info disabled btn-lg' : 'btn btn-info btn-lg', | |
709 | - ] | |
710 | - ) ?> | |
711 | - </div> | |
712 | 750 | |
713 | 751 | </div> |
714 | 752 | <br> | ... | ... |