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 | 204 | ); |
| 205 | 205 | } |
| 206 | 206 | } |
| 207 | - | |
| 207 | + | |
| 208 | 208 | /** |
| 209 | 209 | * Updates an existing Order model. |
| 210 | 210 | * If update is successful, the browser will be redirected to the 'view' page. |
| ... | ... | @@ -212,10 +212,15 @@ |
| 212 | 212 | * @param integer $id |
| 213 | 213 | * |
| 214 | 214 | * @return mixed |
| 215 | + * @throws \yii\base\InvalidConfigException | |
| 215 | 216 | */ |
| 216 | 217 | public function actionUpdate($id) |
| 217 | 218 | { |
| 218 | 219 | $model = $this->findModel($id); |
| 220 | + /** | |
| 221 | + * @var \backend\components\Incust $incust; | |
| 222 | + */ | |
| 223 | + $incust = \Yii::$app->get('incust'); | |
| 219 | 224 | |
| 220 | 225 | if ($model->load(Yii::$app->request->post()) && $model->save() && !empty( |
| 221 | 226 | \Yii::$app->request->post( |
| ... | ... | @@ -224,6 +229,22 @@ |
| 224 | 229 | )) { |
| 225 | 230 | //print_r(\Yii::$app->request->post('OrderProduct')); die(); |
| 226 | 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 | 248 | return $this->redirect( |
| 228 | 249 | [ |
| 229 | 250 | 'index', | ... | ... |
models/Order.php
views/order/_form.php
| ... | ... | @@ -91,6 +91,10 @@ |
| 91 | 91 | ], |
| 92 | 92 | ]) ?> |
| 93 | 93 | </div> |
| 94 | + <div class="wrapp-blocks-edit-page"> | |
| 95 | + <?=$form->field($model, 'paid')->checkbox(['class' => 'flat'])?> | |
| 96 | + </div> | |
| 97 | + | |
| 94 | 98 | </div> |
| 95 | 99 | |
| 96 | 100 | <div class="x_panel"> |
| ... | ... | @@ -195,7 +199,7 @@ |
| 195 | 199 | |
| 196 | 200 | </div> |
| 197 | 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 | 204 | </div> |
| 201 | 205 | </div> | ... | ... |