<?php require_once(THEME_ROOT . '/blocks/head.php'); ?>
<?php require_once(THEME_ROOT . '/blocks/top.php'); ?>

    <br><br>

    <div class="container">
        <div class="row">
            <div class="main" style="text-align:center;">
                <h3><?php echo T("Отзывы"); ?></h3>
            </div>


            <div class="container">
                <div class="row">
                    <?php foreach (get_reviews_confirm() as $item) { ?>
                        <div class="col-sm-12 col-md-8 col-md-offset-2">
                            <div class="panel panel-default">
                                <div class="panel-heading">
                                    <h3 class="panel-title">
                                        <?php echo T('Логин:'); ?>
                                        <?php echo escape($item["login"]); ?>
                                    </h3>
                                </div>
                                <?php $img_check = $settings_show_img_reviews && $item['img']; ?>
                                <div class="panel-body" style="<?php if ($img_check) { echo 'min-height: 170px;'; } ?> position: relative;">
                                    <p <?php if ($img_check) { echo 'style="padding-left: 160px;"'; } ?>>
                                        <?php echo escape($item["reviews"]); ?>
                                    </p>
                                    <?php if ($img_check) { ?>
                                        <img style="position: absolute; left: 10px; top: 10px;" alt="150x150" width="150px" height="150px" src="<?php echo images_thumbnail_resize($item["img"], 150, 150); ?>">
                                    <?php } ?>
                                </div>
                            </div>
                        </div>
                    <?php } ?>
                </div>
            </div>
            <?php if(!auth_is_login()) { ?>
                <div style="text-align:center;">
                    <p style="color:#f00;">
                        <?php echo T('Для добавления отзыва необходимо авторизоваться!'); ?>
                    </p>
                </div>
            <?php } else { ?>

                <div class="col-sm-12 col-md-6 col-md-offset-3">
                    <div class="panel panel-default">
                        <div class="panel-heading">
                            <h3 class="panel-title"><?php echo T('Оставить отзыв'); ?></h3>
                        </div>
                        <div class="panel-body">

                            <form method="post" action="/handlers/reviews.php" accept-charset="utf-8" enctype="multipart/form-data">
                                <?php echo flash_show('reviews'); ?>
                                <?php echo form_init(); ?>
                                <div class="input-group">
                                    <span class="input-group-addon">
                                        <span class="glyphicon glyphicon-envelope"></span>
                                    </span>
                                    <textarea
                                            name="text"
                                            class="form-control"
                                            placeholder="<?php echo T('Введите отзыв ...'); ?>"
                                            cols="50"
                                            rows="10"
                                            required
                                            autofocus></textarea>
                                </div>
                                <br>

                                <?php if($settings_show_img_reviews) { ?>
                                    <div class="input-group">
                                        <input type="file" name="img" class="form-control">
                                    </div>
                                    <br>
                                <?php } ?>

                                <input type="submit" value="<?php echo T('Отправить'); ?>" class="btn btn-default btn-md" style="width: 100%;">
                            </form>

                        </div>
                    </div>
                </div>
            <?php } ?>
        </div>
    </div>

<?php
require_once(THEME_ROOT."/blocks/footer.php");
?>