Commit e715ad66776673618e0a51f947addb5491362b18
1 parent
f884421b
incust final
Showing
3 changed files
with
31 additions
and
2 deletions
Show diff stats
controllers/OrderController.php
@@ -204,7 +204,7 @@ | @@ -204,7 +204,7 @@ | ||
204 | ); | 204 | ); |
205 | } | 205 | } |
206 | } | 206 | } |
207 | - | 207 | + |
208 | /** | 208 | /** |
209 | * Updates an existing Order model. | 209 | * Updates an existing Order model. |
210 | * If update is successful, the browser will be redirected to the 'view' page. | 210 | * If update is successful, the browser will be redirected to the 'view' page. |
@@ -212,10 +212,15 @@ | @@ -212,10 +212,15 @@ | ||
212 | * @param integer $id | 212 | * @param integer $id |
213 | * | 213 | * |
214 | * @return mixed | 214 | * @return mixed |
215 | + * @throws \yii\base\InvalidConfigException | ||
215 | */ | 216 | */ |
216 | public function actionUpdate($id) | 217 | public function actionUpdate($id) |
217 | { | 218 | { |
218 | $model = $this->findModel($id); | 219 | $model = $this->findModel($id); |
220 | + /** | ||
221 | + * @var \backend\components\Incust $incust; | ||
222 | + */ | ||
223 | + $incust = \Yii::$app->get('incust'); | ||
219 | 224 | ||
220 | if ($model->load(Yii::$app->request->post()) && $model->save() && !empty( | 225 | if ($model->load(Yii::$app->request->post()) && $model->save() && !empty( |
221 | \Yii::$app->request->post( | 226 | \Yii::$app->request->post( |
@@ -224,6 +229,22 @@ | @@ -224,6 +229,22 @@ | ||
224 | )) { | 229 | )) { |
225 | //print_r(\Yii::$app->request->post('OrderProduct')); die(); | 230 | //print_r(\Yii::$app->request->post('OrderProduct')); die(); |
226 | OrderProduct::saveItems(\Yii::$app->request->post('OrderProduct'), $id); | 231 | OrderProduct::saveItems(\Yii::$app->request->post('OrderProduct'), $id); |
232 | + if ($model->paid) { | ||
233 | + $check = $incust->generateCheck($model); | ||
234 | + $data = $incust->processCheck($check); | ||
235 | + if (is_array($data) and !empty($data)) { | ||
236 | + \Yii::info('The check process ID' . $model->id); | ||
237 | + $model->save(true, [ 'status_incust' => 'process_check' ]); | ||
238 | + $data = $incust->finalCheck($data); | ||
239 | + if (!empty($data) and is_array($data)){ | ||
240 | + $model->status_incust = 'final_check'; | ||
241 | + $model->id_incust = $data['id']; | ||
242 | + $model->bonuses_add = $data['bonuses_added']; | ||
243 | + \Yii::info('The check final ID'.$model->id); | ||
244 | + $model->save(); | ||
245 | + } | ||
246 | + } | ||
247 | + } | ||
227 | return $this->redirect( | 248 | return $this->redirect( |
228 | [ | 249 | [ |
229 | 'index', | 250 | 'index', |
models/Order.php
@@ -117,6 +117,10 @@ | @@ -117,6 +117,10 @@ | ||
117 | 'targetClass' => Payment::className(), | 117 | 'targetClass' => Payment::className(), |
118 | 'targetAttribute' => [ 'payment_id' => 'id' ], | 118 | 'targetAttribute' => [ 'payment_id' => 'id' ], |
119 | ], | 119 | ], |
120 | + [ | ||
121 | + ['paid'], 'boolean', | ||
122 | + ] | ||
123 | + | ||
120 | ]; | 124 | ]; |
121 | } | 125 | } |
122 | 126 |
views/order/_form.php
@@ -91,6 +91,10 @@ | @@ -91,6 +91,10 @@ | ||
91 | ], | 91 | ], |
92 | ]) ?> | 92 | ]) ?> |
93 | </div> | 93 | </div> |
94 | + <div class="wrapp-blocks-edit-page"> | ||
95 | + <?=$form->field($model, 'paid')->checkbox(['class' => 'flat'])?> | ||
96 | + </div> | ||
97 | + | ||
94 | </div> | 98 | </div> |
95 | 99 | ||
96 | <div class="x_panel"> | 100 | <div class="x_panel"> |
@@ -195,7 +199,7 @@ | @@ -195,7 +199,7 @@ | ||
195 | 199 | ||
196 | </div> | 200 | </div> |
197 | <?php | 201 | <?php |
198 | - echo( " <div class='sum_all col-xs-12'>Итого: <strong id='total-sum'>" . $sum . "</strong></div>" ); | 202 | + echo( " <div class='sum_all col-xs-12'>Итого: <strong id='total-sum'>" . ($model->bonuses_write_off !== null ? $sum-$model->bonuses_write_off.' ('.$sum.'-'.$model->bonuses_write_off.')' :$sum) . "</strong></div>" ); |
199 | ?> | 203 | ?> |
200 | </div> | 204 | </div> |
201 | </div> | 205 | </div> |