public function actionViewBook() { $this->layout = 'editor'; $ref = Yii::$app->request->get('ref'); $id = Yii::$app->request->get('id'); $selected_style_id = Yii::$app->request->get('style_id', 0); if (!empty($ref) && !empty($id)) { $user_id = AlphaId::id($ref, true); $pb_id = AlphaId::id($id, true); if ($user_id != Yii::$app->user->identity->getId()) { Yii::$app->getSession()->setFlash('error', Yii::t('app', 'Страница не найдена')); $this->redirect(Url::toRoute(['photobooks/index'])); return; } $model = new PhotobookForm(); if (!$model->loadById($pb_id)) { Yii::$app->getSession()->setFlash('error', Yii::t('app', 'Фотокнига не найдена')); $this->redirect(Url::toRoute(['photobooks/index'])); return; } if (empty($model->data['pages'])) { Yii::$app->getSession()->setFlash('error', Yii::t('app', 'В фотокниги нет ни одного разворота')); $this->redirect(Url::toRoute(['photobooks/index', 'status' => $model->status])); return; } $style_id = $model->style_id; $style = new StyleForm(); if (!$style->loadById($style_id)) { Yii::$app->getSession()->setFlash('error', Yii::t('app', 'Стиль для данной фотокниги не найден.')); $this->redirect(Url::toRoute(['photobooks/index'])); return; } $selected_cover = new CoverForm(); if (!$selected_cover->loadById($model->cover_id)) { Yii::$app->getSession()->setFlash('error', Yii::t('app', 'Обложка для данной фотокниги не найден.')); $this->redirect(Url::toRoute(['photobooks/index'])); return; } $covers = Cover::find()->where(['status' => 1])->all(); $new_covers = []; foreach ($covers as $key => $cover) { $new_covers[$cover->material_type][] = $cover; } $pages = $model->data['pages']; $base_price = (count($pages) - 2) * $style->price_spread; $cover_price_sign = $selected_cover->price_sign; $selected_cover->price; $total_price = $base_price; if ($cover_price_sign == "=") { $total_price = $selected_cover->price; } else { if ($cover_price_sign == "+") { $total_price += $selected_cover->price; } else { if ($cover_price_sign == "-") { $total_price -= $selected_cover->price; } } } $user = User::findOne(['id' => $user_id]); $total_price = CurrencyConvertor::conv($total_price, $user->default_currency); $curse = CurrencyConvertor::getCurse($user->default_currency); return $this->render('viewBook', ['model' => $model, 'ref' => $ref, 'id' => $id, 'pb_id' => $pb_id, 'user_id' => $user_id, 'pages' => $pages, 'style' => $style, 'selected_cover' => $selected_cover, 'covers' => $new_covers, 'total_price' => $total_price, 'default_currency' => $user->default_currency, 'cover_price_sign' => $cover_price_sign, 'cover_price' => $selected_cover->price, 'price_spread' => $style->price_spread, 'curse' => $curse]); } else { Yii::$app->getSession()->setFlash('error', Yii::t('app', 'Страница не найдена')); $this->redirect(Url::toRoute(['photobooks/index'])); } }
<tr> <td> </td> <td> </td> <td> </td> <td style="text-align: center;"> Итого: </td> <td align="right" id="totalDisplay"> <?php printf('%.2f', CurrencyConvertor::conv($total, $default_currency)); ?> <?php echo $default_currency; ?> </td> <td></td> </tr> </tbody> </table> </div> <h3><?php echo Yii::t('app', 'Адрес доставки и телефон контактного лица:');