Commit 03c7b7bca03c91ca1ebad17d2d5264269f7d5247
1 parent
bfd98631
Credit v2
Showing
3 changed files
with
28 additions
and
7 deletions
Show diff stats
controllers/OrderController.php
... | ... | @@ -4,6 +4,7 @@ |
4 | 4 | |
5 | 5 | use artweb\artbox\components\SmsSender; |
6 | 6 | use artweb\artbox\ecommerce\models\OrderSearch; |
7 | + use common\components\CreditHelper; | |
7 | 8 | use common\models\User; |
8 | 9 | use phpDocumentor\Reflection\Types\Null_; |
9 | 10 | use Yii; |
... | ... | @@ -11,6 +12,7 @@ |
11 | 12 | use yii\helpers\ArrayHelper; |
12 | 13 | use yii\helpers\Json; |
13 | 14 | use yii\helpers\VarDumper; |
15 | + use yii\validators\NumberValidator; | |
14 | 16 | use yii\web\Controller; |
15 | 17 | use yii\filters\VerbFilter; |
16 | 18 | use yii\data\ActiveDataProvider; |
... | ... | @@ -281,7 +283,7 @@ |
281 | 283 | return $this->renderPartial( |
282 | 284 | 'print', |
283 | 285 | [ |
284 | - 'order' => $order, | |
286 | + 'order' => $order, | |
285 | 287 | 'dataProvider' => $dataProvider, |
286 | 288 | ] |
287 | 289 | ); |
... | ... | @@ -323,6 +325,18 @@ |
323 | 325 | |
324 | 326 | $model = $this->findModel($id); |
325 | 327 | |
328 | + if ($model->payment == 10) { | |
329 | + $model->validators->append( | |
330 | + new NumberValidator( | |
331 | + [ | |
332 | + 'attributes' => 'credit_sum', | |
333 | + 'max' => $model->total - CreditHelper::MIN_CREDIT_SUM, | |
334 | + 'min' => $model->total - CreditHelper::MAX_CREDIT_SUM, | |
335 | + ] | |
336 | + ) | |
337 | + ); | |
338 | + } | |
339 | + | |
326 | 340 | /** |
327 | 341 | * @var User $user |
328 | 342 | */ | ... | ... |
models/Order.php
... | ... | @@ -201,8 +201,7 @@ |
201 | 201 | 'credit_sum', |
202 | 202 | ], |
203 | 203 | 'number', |
204 | - 'min' => 300, | |
205 | - 'max' => 25000, | |
204 | + 'min' => 0, | |
206 | 205 | ], |
207 | 206 | [ |
208 | 207 | [ |
... | ... | @@ -292,7 +291,7 @@ |
292 | 291 | 'city' => Yii::t('app', 'Город'), |
293 | 292 | 'numbercard' => Yii::t('app', '№ карточки'), |
294 | 293 | 'credit_month' => Yii::t('app', 'Количество месяцев'), |
295 | - 'credit_sum' => Yii::t('app', 'Сумма кредита'), | |
294 | + 'credit_sum' => Yii::t('app', 'Первоначальный взнос'), | |
296 | 295 | ]; |
297 | 296 | } |
298 | 297 | ... | ... |
views/order/_form.php
... | ... | @@ -338,17 +338,25 @@ JS; |
338 | 338 | if ($model->payment == 10) { |
339 | 339 | ?> |
340 | 340 | <div> |
341 | - <div class="col-xs-6"> | |
341 | + <div class="col-xs-4"> | |
342 | 342 | <?php |
343 | 343 | echo $form->field($model, 'credit_sum') |
344 | 344 | ->textInput( |
345 | 345 | [ |
346 | 346 | 'class' => 'form-control credit_input', |
347 | + 'data-sum' => $model->total, | |
347 | 348 | ] |
348 | 349 | ); |
349 | 350 | ?> |
350 | 351 | </div> |
351 | - <div class="col-xs-6"> | |
352 | + <div class="col-xs-4"> | |
353 | + <?php | |
354 | + echo Html::tag('span', $model->total - $model->credit_sum, [ | |
355 | + 'class' => 'credit_value_full', | |
356 | + ]); | |
357 | + ?> | |
358 | + </div> | |
359 | + <div class="col-xs-4"> | |
352 | 360 | <?php |
353 | 361 | echo $form->field($model, 'credit_month') |
354 | 362 | ->textInput( |
... | ... | @@ -362,7 +370,7 @@ JS; |
362 | 370 | <p> |
363 | 371 | <span class="credit_value"> |
364 | 372 | <?php |
365 | - echo CreditHelper::getCredit($model->total); | |
373 | + echo CreditHelper::getCredit($model->total - $model->credit_sum, $model->credit_month); | |
366 | 374 | ?> |
367 | 375 | </span> |
368 | 376 | <span>грн/мес</span> | ... | ... |