<section class="content-header">
    <h1><?= __('Payment confirmation') ?> #<?= $confirmation['id'] ?></h1>

    <div class="actions">
        <a data-ajax class="btn btn-default btn-sm" href="<?= admin_url_to('/orders/payment-confirmations') ?>"><?= __('List') ?></a>
    </div>
</section>

<section class="content">
    <div class="box box-default">
        <div class="box-body">
            <div class="section">
                <form data-ajax data-upload action="<?= admin_url_to('/orders/payment-confirmations/confirm/' . $confirmation['id']) ?>" method="post">
                    <?= csrf_field() ?>

                    <div class="row">
                        <div class="col-lg-3 col-md-3 col-sm-4 col-xs-12">
                            <h5><?= __('Confirmation') ?></h5>
                        </div>

                        <div class="col-lg-9 col-md-9 col-sm-8 col-xs-12">
                            <div class="row">
                                <div class="col-md-4">
                                    <div class="form-group">
                                        <label class="control-label"><?= __('Author') ?></label>
                                        <p class="form-control-static"><a data-ajax href="<?= admin_url_to('/accounts/edit/' . $confirmation['account']) ?>"><?= $confirmation['account'] ?></a></p>
                                    </div>
                                </div>

                                <div class="col-md-4">
                                    <div class="form-group">
                                        <label class="control-label"><?= __('Bank account') ?></label>
                                        <p class="form-control-static"><?= $confirmation['bank_account'] ?></p>
                                    </div>
                                </div>

                                <div class="col-md-4">
                                    <div class="form-group">
                                        <label class="control-label"><?= __('Status') ?></label>
                                        <p class="form-control-static"><?= util('Donate.PaymentConfirmation')->paymentStatus($confirmation['status']) ?></p>
                                    </div>
                                </div>
                            </div>

                            <div class="row">
                                <div class="col-md-4">
                                    <div class="form-group">
                                        <label class="control-label"><?= __('Created at') ?></label>
                                        <p class="form-control-static"><?= util('Date')->dateTime($confirmation['create_date']) ?></p>
                                    </div>
                                </div>

                                <div class="col-md-4">
                                    <div class="form-group">
                                        <label class="control-label"><?= __('Receipt') ?></label>

                                        <div class="form-control-static">
                                            <a target="_blank" href="<?= upload_to('/payments/' . $confirmation['images']) ?>"><?= $confirmation['images'] ?></a>
                                        </div>
                                    </div>
                                </div>
                            </div>

                            <div class="form-group">
                                <label class="control-label"><?= __('Message') ?></label>
                                <p class="form-control-static"><?= $confirmation['message'] ?></p>
                            </div>

                            <div class="form-group">
                                <label class="control-label"><?= __('Value') ?></label>
                                <?php if ($confirmation['status'] == 1): ?>
                                    <input type="text" name="value" class="form-control money" value="<?= util('Number')->currencyWithoutSymbol($confirmation['value']) ?>" />
                                <?php else: ?>
                                    <p class="form-control-static"><?= util('Number')->currency($confirmation['value']) ?></p>
                                <?php endif ?>
                            </div>

                            <?php if ($confirmation['status'] == 1): ?>
                                <div class="box-footer" style="padding-left:0">
                                    <input type="submit" class="btn btn-primary" value="<?= __('Release credits') ?>" />
                                    <a href="<?= admin_url_to('/orders/payment-confirmations/refuse/' . $confirmation['id']) ?>" data-ajax-action data-confirm="<?= __('Are you sure?') ?>" class="btn btn-danger"><?= __('Refuse') ?></a>
                                </div>
                            <?php endif ?>
                        </div>
                    </div>
                </form>
            </div>

            <div class="section">
                <div class="row">
                    <div class="col-lg-3 col-md-3 col-sm-4 col-xs-12">
                        <h5><?= __('Messages') ?></h5>
                    </div>

                    <div class="col-lg-9 col-md-9 col-sm-8 col-xs-12">
                        <ul class="list">
                            <?php foreach ($confirmation['messages'] as $message): ?>
                                <li>
                                    <div class="desc">
                                        <span class="name"><?= $message['account'] ?></span>
                                        <span class="created"><?= util('Date')->dateTime($message['create_date']) ?></span>
                                        <p><?= nl2br($message['message']) ?></p>
                                    </div>
                                </li>
                            <?php endforeach ?>
                        </ul>

                        <?php if ($confirmation['status'] == 1): ?>
                            <form data-ajax action="<?= admin_url_to('/orders/payment-confirmations/add_message/' . $confirmation['id']) ?>" method="post">
                                <?= csrf_field() ?>

                                <div class="form-group">
                                    <label class="control-label" for="ticket-message"><?= __('Message') ?> <span class="required">*</span></label>
                                    <textarea class="form-control" name="message" id="ticket-message"></textarea>
                                </div>

                                <div class="box-footer" style="padding-left:0">
                                    <input style="margin-bottom:10px;" type="submit" class="btn btn-primary" value="<?= __('Answer') ?>" />
                                </div>
                            </form>
                        <?php endif ?>
                    </div>
                </div>
            </div>

            <?php if (!empty($confirmations)): ?>
                <div class="section">
                    <div class="row">
                        <div class="col-lg-3 col-md-3 col-sm-4 col-xs-12">
                            <h5><?= __('Payment confirmations') ?></h5>
                        </div>

                        <div class="col-lg-9 col-md-9 col-sm-8 col-xs-12">
                            <table data-table class="table table-condensed table-hover table-striped">
                                <thead>
                                    <tr>
                                        <th width="40">#</th>
                                        <th><?= __('Value') ?></th>
                                        <th><?= __('Created at') ?></th>
                                        <th><?= __('Receipt') ?></th>
                                        <th><?= __('Status') ?></th>
                                    </tr>
                                </thead>

                                <tbody>
                                    <?php foreach ($confirmations as $t): ?>
                                        <tr>
                                            <td><?= $t['id'] ?></td>
                                            <td><?= util('Number')->currency($t['value']) ?></td>
                                            <td><?= util('Date')->date($t['create_date']) ?></td>
                                            <td><a target="_blank" href="<?= upload_to('/payments/' . $t['images']) ?>"><?= $t['images'] ?></a></td>
                                            <td><?= util('Donate.PaymentConfirmation')->paymentStatus($t['status']) ?></td>
                                        </tr>
                                    <?php endforeach ?>
                                </tbody>
                            </table>
                        </div>
                    </div>
                </div>
            <?php endif ?>
        </div>
    </div>
</section>