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

<br><br>
    <?php
    $appeal = support_get_appeal_by_id((int)get('id'));
    if ($appeal['login'] !== session('login')) {
        redirect('/user/');
    } ?>

    <div class="container">
        <div class="row">
            <div class="main" style="text-align:center;">
                <h3><?php echo T('Раздел Поддержки'); ?></h3>
                <a href="/user/tickets" class="top-link-active">
                    <i class="fa fa-arrow-circle-o-down"></i>
                     <?php echo T('Мои тикеты'); ?>
                </a>
                <a href="/user/new_ticket" class="top-link">
                    <i class="fa fa-arrow-circle-o-up"></i>
                     <?php echo T('Создать тикет'); ?>
                </a>
            </div>
            <div class="row">
                <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/user/send_answer_ticker.php">
                                <?php echo form_init(); ?>
                                <?php echo flash_show('send_answer_ticker'); ?>

                                <div class="input-group">
                                    <span class="input-group-addon">
                                        <span class="glyphicon glyphicon glyphicon-text-size"></span>
                                    </span>
                                    <textarea
                                            name="text"
                                            style="resize:none;"
                                            rows='10'
                                            class="form-control"
                                            placeholder="<?php echo T('Поле для ввода ответа...'); ?>"></textarea>
                                </div>
                                <br>
                                <input name="support_add_message" type="submit" value="<?php echo T('Отправить'); ?>" class="btn btn-default btn-md" style="width: 100%;">
                                <input type="hidden" value="<?php echo (int)$appeal['id']; ?>" name="id">
                            </form>
                        </div>
                    </div>
                </div>
            </div>
            <div class="col-sm-12 col-md-12">
                <div class="panel panel-default">
                    <div class="panel-heading">
                        <h3 class="panel-title">
                            <?php echo T('История переписки'); ?>
                        </h3>
                    </div>
                    <div class="table-responsive">
                        <table class="table table-bordered-off table-striped-off table-hover-off" style="margin-bottom: 0px; text-align: center;">
                            <thead>
                                <tr class="active" style="font-weight: 600;">
                                    <td><?php echo T('От кого'); ?></td>
                                    <td><?php echo T('Дата'); ?></td>
                                    <td><?php echo T('Сообщение'); ?></td>
                                </tr>
                            </thead>
                            <tbody>
                                <?php foreach (support_get_messages_list($appeal['id']) as $row) { ?>
                                    <tr>
                                        <?php if ($login === $row['login']) { ?>
                                            <td>
                                                <a href="#">You</a>
                                            </td>
                                        <?php } else { ?>
                                            <td>
                                                <a href="#">Support</a>
                                            </td>
                                        <?php } ?>
                                        <td>
                                            <?php echo format_date($row['date']); ?>
                                        </td>
                                        <td>
                                            <?php echo escape($row['text']); ?>
                                        </td>
                                    </tr>
                                <?php } ?>
                            </tbody>
                        </table>
                    </div>
                </div>
            </div>
        </div>
    </div>

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


