diff --git a/controllers/OrderController.php b/controllers/OrderController.php index 2354cd2..29a4ddf 100755 --- a/controllers/OrderController.php +++ b/controllers/OrderController.php @@ -204,7 +204,7 @@ ); } } - + /** * Updates an existing Order model. * If update is successful, the browser will be redirected to the 'view' page. @@ -212,10 +212,15 @@ * @param integer $id * * @return mixed + * @throws \yii\base\InvalidConfigException */ public function actionUpdate($id) { $model = $this->findModel($id); + /** + * @var \backend\components\Incust $incust; + */ + $incust = \Yii::$app->get('incust'); if ($model->load(Yii::$app->request->post()) && $model->save() && !empty( \Yii::$app->request->post( @@ -224,6 +229,22 @@ )) { //print_r(\Yii::$app->request->post('OrderProduct')); die(); OrderProduct::saveItems(\Yii::$app->request->post('OrderProduct'), $id); + if ($model->paid) { + $check = $incust->generateCheck($model); + $data = $incust->processCheck($check); + if (is_array($data) and !empty($data)) { + \Yii::info('The check process ID' . $model->id); + $model->save(true, [ 'status_incust' => 'process_check' ]); + $data = $incust->finalCheck($data); + if (!empty($data) and is_array($data)){ + $model->status_incust = 'final_check'; + $model->id_incust = $data['id']; + $model->bonuses_add = $data['bonuses_added']; + \Yii::info('The check final ID'.$model->id); + $model->save(); + } + } + } return $this->redirect( [ 'index', diff --git a/models/Order.php b/models/Order.php index 97a139b..03e1583 100755 --- a/models/Order.php +++ b/models/Order.php @@ -117,6 +117,10 @@ 'targetClass' => Payment::className(), 'targetAttribute' => [ 'payment_id' => 'id' ], ], + [ + ['paid'], 'boolean', + ] + ]; } diff --git a/views/order/_form.php b/views/order/_form.php index f87277e..ff51300 100755 --- a/views/order/_form.php +++ b/views/order/_form.php @@ -91,6 +91,10 @@ ], ]) ?> +
+ field($model, 'paid')->checkbox(['class' => 'flat'])?> +
+
@@ -195,7 +199,7 @@
Итого: " . $sum . "" ); + echo( "
Итого: " . ($model->bonuses_write_off !== null ? $sum-$model->bonuses_write_off.' ('.$sum.'-'.$model->bonuses_write_off.')' :$sum) . "
" ); ?> -- libgit2 0.21.4