<?php $__env->startSection('title', 'Users - Balance #' . $user->id); ?>

<?php $__env->startSection('content_header', 'Users <small>user balance</small>'); ?>

<?php $__env->startSection('content'); ?>
    <div class="row">
        <section class="col-lg-12">
            <div class="nav-tabs-custom">
                <?php echo $__env->make('admin.users._partials.tabs', array_except(get_defined_vars(), array('__data', '__path')))->render(); ?>
                <div class="tab-content">
                    <div class="tab-pane active">
                        <?php if(count($errors) > 0): ?>
                            <div class="alert alert-danger alert-dismissable">
                                <button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button>
                                <h4><i class="icon fa fa-ban"></i> <strong>Whoops!</strong> There were some problems with your input.</h4>
                                <ul>
                                    <?php foreach($errors->all() as $error): ?>
                                        <li><?php echo e($error); ?></li>
                                    <?php endforeach; ?>
                                </ul>
                            </div>
                        <?php endif; ?>
                        <div class="text-center">
                            <p class="form-control-static">
                                <strong>Balance:</strong>
                                <span class="<?php if($balance->amount < 0): ?> text-danger <?php elseif($balance->amount > 0): ?> text-success <?php else: ?> text-muted <?php endif; ?>"><?php echo e(format_balance($balance->amount)); ?></span>
                            </p>
                        </div
                        </div>
                        <hr>
                        <div class="row">
                            <form class="form-horizontal" method="POST" action="<?php echo e(route('admin.users.balance.process', $user->id)); ?>">
                                <input type="hidden" name="_token" value="<?php echo e(csrf_token()); ?>">
                                <div class="form-group <?php if($errors->has('amount')): ?> has-error <?php endif; ?>">
                                    <label for="inputAmount" class="col-md-4 control-label">Amount*</label>
                                    <div class="col-md-6">
                                        <input id="inputAmount" type="text" class="form-control" name="amount" <?php if($errors): ?> value="<?php echo e(old('amount')); ?>" <?php endif; ?> placeholder="0.00">
                                    </div>
                                </div>
                                <div class="form-group <?php if($errors->has('note')): ?> has-error <?php endif; ?>">
                                    <label for="inputNote" class="col-md-4 control-label">Note</label>
                                    <div class="col-md-6">
                                        <input id="inputNote" type="text" class="form-control" name="note" <?php if($errors): ?> value="<?php echo e(old('note')); ?>" <?php endif; ?> >
                                    </div>
                                </div>
                                <div class="form-group">
                                    <div class="col-md-6 col-md-offset-4">
                                        <button type="submit" class="btn btn-success confirm-action" name="type" value="in"><i class="fa fa-arrow-up"></i> Add</button>
                                        <button type="submit" class="btn btn-danger confirm-action" name="type" value="out"><i class="fa fa-arrow-down"></i> Charge</button>
                                    </div>
                                </div>
                            </form>
                        </div>
                        <hr>
                        <?php if(count($history) > 0): ?>
                            <table class="table table-hover no-margin">
                                <thead>
                                    <tr>
                                        <th>#</th>
                                        <th>Type</th>
                                        <th>Amount</th>
                                        <th>Amount before</th>
                                        <th>Amount after</th>
                                        <th>Description</th>
                                        <th>Date</th>
                                    </tr>
                                </thead>
                                <tbody>
                                    <?php foreach($history as $item): ?>
                                        <tr>
                                            <td><?php echo e($item->id); ?></td>
                                            <td>
                                                <?php if($item->type == 'in'): ?>
                                                    <span class="label label-success"><i class="fa fa-arrow-up"></i></span>
                                                <?php else: ?>
                                                    <span class="label label-danger"><i class="fa fa-arrow-down"></i></span>
                                                <?php endif; ?>
                                            </td>
                                            <td><span class="<?php if($item->type == 'out'): ?> text-danger <?php else: ?> text-success <?php endif; ?>"><?php echo e(format_balance($item->amount)); ?></span></td>
                                            <td><span class="<?php if($item->amount_before < 0): ?> text-danger <?php elseif($item->amount_before > 0): ?> text-success <?php else: ?> text-muted <?php endif; ?>"><?php echo e(format_balance($item->amount_before)); ?></span></td>
                                            <td><span class="<?php if($item->amount_after < 0): ?> text-danger <?php elseif($item->amount_after > 0): ?> text-success <?php else: ?> text-muted <?php endif; ?>"><?php echo e(format_balance($item->amount_after)); ?></span></td>
                                            <td><?php echo e($item->historable->getHistoryTitle()); ?></td>
                                            <td><?php echo e($item->created_at); ?></td>
                                        </tr>
                                    <?php endforeach; ?>
                                </tbody>
                            </table>
                            <?php if($history->hasPages()): ?>
                                <div class="box-footer">
                                    <?php echo $history->render(); ?>

                                </div>
                            <?php endif; ?>
                        <?php else: ?>
                            <div class="box-body">
                                <div class="alert alert-info">No actions were performed.</div>
                            </div>
                        <?php endif; ?>
                    </div>
                </div>
            </div>
        </section>
    </div>
<?php $__env->stopSection(); ?>
<?php echo $__env->make('admin.app', array_except(get_defined_vars(), array('__data', '__path')))->render(); ?>