<?php $__env->startSection('title'); ?>
    <?php echo e($details->request->request); ?>

<?php $__env->stopSection(); ?>
<?php $__env->startSection('content'); ?>
    <div class="media">
        <div class="media-body">
            <h4 class="media-heading">Policy: <?php echo e($details->request->request); ?></h4>
            <br>
            <strong class="h4">Sender:<?php if(Auth::user()->id == $details->request->user_id): ?>
                    You <?php else: ?> <?php echo e($details->request->name); ?> <?php endif; ?></strong><br><br>
            <strong class="h4">Sent:</strong>
            <strong><?php echo e(\Carbon\Carbon::parse($details->request->request_date)->diffForHumans()); ?></strong><br><br>

            <?php if($details->request->type == 'leave'): ?>
                <span class="h4">From:</span> <strong><?php echo e($details->request->from_date); ?></strong><br><br>
                <span class="h4">To:</span> <strong><?php echo e($details->request->to_date); ?></strong><br><br>
            <?php endif; ?>
            <?php if($details->request->status != ''): ?>
                <span class="h4">Status:</span><strong><?php echo e($details->request->status); ?></strong><br><br>
            <?php endif; ?>
            <span class="h4">Details:</span><br>

            <strong><?php echo e($details->request->description); ?></strong>
            <?php if($details->request->attachment || count($details->request->attachments)): ?>
                <hr>
                <strong class="h4">Attachments: </strong>
            <?php endif; ?>
            <?php $count = 1;?>
            <?php /* oldAPI: This section exists to support the old Attachment API */ ?>
            <?php if($details->request->attachment): ?>
                <a href="<?php echo e(URL::asset($details->request->attachment)); ?>" class="btn btn-green"> Download [#<?php echo e($count); ?>

                    ] </a>
                <?php $count++; ?>
            <?php endif; ?>
            <?php /* ./oldAPI */ ?>
            <?php if($details->request->attachments): ?>
                <?php foreach($details->request->attachments as $attachment): ?>
                    <a href="<?php echo e($attachment); ?>" class="btn btn-green"> <i class="fa fa-download"></i> Download
                        [#<?php echo e($count); ?>] </a>
                    <?php $count++ ?>
                <?php endforeach; ?>
            <?php endif; ?>
        </div>
    </div>
    <hr>
    <div class="h3">Status</div>
    <?php foreach($details->statusHistory as $status): ?>
        <div class="announcement bg-dark">
            <div class="announcement-icon">
                <i class="icon icon-company-settings"></i>
            </div>
            <div class="details">
                <?php echo e($status->name); ?> <?php if($status->title): ?>| <?php echo e($status->title); ?><?php endif; ?>
                <br>
                Status: <strong><?php echo e(ucfirst($status->status)); ?></strong>
                <br>
                <?php if($status->comment != null): ?>
                    <p class="comment">
                        Comment: <?php echo e($status->comment); ?>

                    </p>
                <?php endif; ?>
            </div>
            <div class="time">
                On: <?php echo e($status->date); ?>

            </div>
        </div>
    <?php endforeach; ?>
    <div class="form-actions">
        <?php if(isset($details->currentCycle) && $details->request->status == 'pending'
        && ($details->currentCycle->current_user_id == \Auth::user()->id ||
        ($details->currentCycle->current_user_id == null && \Auth::user()->getRole()=="HRAdmin"))): ?>
            <?php $request_cycle = $details->currentCycle; ?>
            <?php if($request_cycle->approval_type == "review"): ?>
                <div class="btn-group btn-group-justified">
                    <a data-toggle="modal"
                       href="#review_modal"
                       class="btn btn-green">
                        Review
                    </a>
                    <a href="<?php echo e(URL::previous()); ?>" class="btn btn-dark">
                        Later
                    </a>
                </div>
                <div class="modal" id="review_modal">
                    <div class="modal-dialog">
                        <div class="modal-content">
                            <div class="modal-body">
                                <form method="post"
                                      action="<?php echo e(URL::action('UserController@postRequestAction')); ?>">
                                    <input type="hidden" name="requestId"
                                           value="<?php echo e($details->request->id); ?>">
                                    <?php echo csrf_field(); ?>

                                    <input type="hidden" name="response" value="reviewed">

                                    <div class="form-group">
                                        <label class="control-label">
                                            Add a comment
                                        </label>
                                        <textarea name="comment" class="form-control"></textarea>
                                    </div>
                                    <div class="form-actions">
                                        <button class="btn btn-green">
                                            Review
                                        </button>
                                        <button data-target="#review_modal"
                                                class="btn btn-dark" data-dismiss="modal">
                                            Cancel
                                        </button>
                                    </div>
                                </form>
                            </div>
                        </div>
                    </div>
                </div>
            <?php else: ?>
                <div class="btn-group btn-group-justified">
                    <a class="btn btn-green"
                       href="#accept_modal"
                       data-toggle="modal">
                        <i class="fa fa-thumbs-up"></i> Accept
                    </a>
                    <a class="btn btn-red"
                       href="#reject_modal"
                       data-toggle="modal">
                        <i class="fa fa-thumbs-down"></i> Reject
                    </a>
                    <a href="<?php echo e(URL::previous()); ?>" class="btn btn-dark">
                        Later
                    </a>
                </div>

                <div class="modal" id="accept_modal">
                    <div class="modal-dialog">
                        <div class="modal-content">
                            <div class="modal-body">
                                <form method="post"
                                      action="<?php echo e(URL::action('UserController@postRequestAction')); ?>">
                                    <input type="hidden" name="requestId"
                                           value="<?php echo e($details->request->id); ?>">
                                    <?php echo csrf_field(); ?>

                                    <input type="hidden" name="response" value="accepted">

                                    <div class="form-group">
                                        <label class="control-label">
                                            Add a comment
                                        </label>
                                        <textarea name="comment" class="form-control"></textarea>
                                    </div>
                                    <div class="form-actions">
                                        <button class="btn btn-green">
                                            Accept
                                        </button>
                                        <button data-target="#accept_modal"
                                                class="btn btn-dark" data-dismiss="modal">
                                            Cancel
                                        </button>
                                    </div>
                                </form>
                            </div>
                        </div>
                    </div>
                </div>

                <div class="modal" id="reject_modal">
                    <div class="modal-dialog">
                        <div class="modal-content">
                            <div class="modal-body">
                                <form method="post"
                                      action="<?php echo e(URL::action('UserController@postRequestAction')); ?>">
                                    <input type="hidden" name="requestId"
                                           value="<?php echo e($details->request->id); ?>">
                                    <?php echo csrf_field(); ?>

                                    <input type="hidden" name="response" value="denied">

                                    <div class="form-group">
                                        <label class="control-label">
                                            Add a comment
                                        </label>
                                        <textarea name="comment" class="form-control"></textarea>
                                    </div>
                                    <div class="form-actions">
                                        <button class="btn btn-red">
                                            Reject
                                        </button>
                                        <button data-target="#reject_modal"
                                                class="btn btn-dark" data-dismiss="modal">
                                            Cancel
                                        </button>
                                    </div>
                                </form>
                            </div>
                        </div>
                    </div>
                </div>
            <?php endif; ?>
        <?php endif; ?>
        <?php if($details->request->user_id == Auth::user()->id): ?>
            <?php if($details->request->status == 'pending'): ?>
                <form method="post"
                      action="<?php echo e(URL::action('UserController@postCancelRequest')); ?>">
                    <?php echo csrf_field(); ?>

                    <input type="hidden" name="request_id" value="<?php echo e($details->request->id); ?>">
                    <button type="submit" class="btn btn-red btn-block" style="margin-top:5px;">Cancel</button>
                </form>
            <?php endif; ?>
        <?php endif; ?>
    </div>
<?php $__env->stopSection(); ?>
<?php echo $__env->make('layout', array_except(get_defined_vars(), array('__data', '__path')))->render(); ?>