<?php $__env->startSection('title', trans('policies.title.one')); ?>

<?php $__env->startSection('page_stylesheets'); ?>
    <link href="<?php echo e(asset('assets/libs/datepicker/datepicker.min.css')); ?>" rel="stylesheet">
    <link href="<?php echo e(asset('assets/libs/dropify/css/dropify.css')); ?>" rel="stylesheet">
    <link href="<?php echo e(asset('assets/libs/sweetalert/sweetalert.css')); ?>" rel="stylesheet">
<?php $__env->stopSection(); ?>

<?php $__env->startSection('extra_stylesheets'); ?>
    <link href="<?php echo e(asset('assets/css/split-page.css')); ?>" rel="stylesheet"/>
<?php $__env->stopSection(); ?>

<?php $__env->startSection('profile_bar'); ?>
        <!-- client profile -->
        <div class="ui segment white right-bar-profile right-bar-profile-bottom">
            <div class="user-profile m-b-15">
                <?php if($policy->client->profile_image_filename === 'default-profile.jpg'): ?>
                <div class="text-avatar" style="background-color:<?php echo e(collect(config('insura.colors'))->random()); ?>;"><?php echo e(strtoupper($policy->client->first_name[0] . $policy->client->last_name[0])); ?></div>
                <?php else: ?>
                <img src="<?php echo e(asset('uploads3/images/users/' . $policy->client->profile_image_filename)); ?>" alt="<?php echo e($policy->client->first_name . ' ' . $policy->client->last_name); ?>"/>
                <?php endif; ?>
                <h3><?php echo e($policy->client->first_name . ' ' . $policy->client->last_name); ?></h3>
                <span>
                    <?php if($policy->client->password === 'InsuraPasswordsAreLongButNeedToBeSetByInvitedUsersSuchAsThis'): ?>
                    <i class="ion-ios-circle-filled text-danger"></i> <?php echo e(trans('clients.status.inactive')); ?>

                    <?php else: ?>
                    <i class="ion-ios-circle-filled text-success"></i> <?php echo e(trans('clients.status.active')); ?>

                    <?php endif; ?>
                </span>
                <?php echo $__env->yieldContent('client_action'); ?>
            </div>
            <div class="scrollbar">
                <div class="user-more-data">
                    <div class="divider m-t-0"></div>
                    <!-- client details -->
                    <div class="user-contact">
                        <div>
                            <span><?php echo e(trans('clients.label.email')); ?></span>
                            <p><?php echo e($policy->client->email); ?></p>
                        </div>
                        <div>
                            <span><?php echo e(trans('clients.label.phone')); ?></span>
                            <p><?php echo e($policy->client->phone); ?></p>
                        </div>
                        <div>
                            <span><?php echo e(trans('clients.label.birthday')); ?></span>
                            <p><?php echo e(is_null($policy->client->birthday) ? '---------- --, ----' : date('jS F Y', strtotime($policy->client->birthday))); ?></p>
                        </div>
                        <div>
                            <span><?php echo e(trans('clients.label.address')); ?></span>
                            <p><?php echo e(isset($policy->client->address) ? $policy->client->address : '. . .'); ?></p>
                        </div>
                    </div>
                    <!-- end client details -->
                </div>
            </div>
        </div>
        <!-- end client profile -->
<?php $__env->stopSection(); ?>

<?php $__env->startSection('content'); ?>
        @parent
        <!-- half page content -->
        <div class="half-page-content">
            <?php echo $__env->make('global.status', array_except(get_defined_vars(), array('__data', '__path')))->render(); ?>
            <!-- Policy details -->

           

            <div class="ui segment white fs-16">
                <div class="segment-header">
                    <h3><?php echo e(trans('policies.label.details')); ?></h3>
                      <a href="#" onclick="printClientDetails(); return false;" class="btn btn-info" >
                                    <i class="print icon"></i> Print Details
                                </a>


                    <?php echo $__env->yieldContent('policy_actions'); ?>
                </div>
                <div class="policy-details">
                    <div class="row">
                        <div class="col-sm-3 col-md-4">
                            <span><?php echo e(trans('policies.label.ref_no')); ?></span>
                            <p><?php echo e($policy->ref_no); ?></p>
                        </div>
                        <div class="col-sm-6 col-md-4">
                            <span><?php echo e(trans('policies.label.product')); ?></span>
                            <p><?php echo e($policy->product->name); ?></p>
                        </div>
                        <div class="col-sm-3 col-md-4">
                            <span class="ui blue right ribbon huge label"><?php echo e(trans("policies.ribbon.type.{$policy->type}")); ?></span>
                        </div>
                    </div>
                    <div class="row">
                        <div class="col-sm-4 col-md-4">
                            <span><?php echo e(trans('policies.label.renewal')); ?></span>
                            <p><?php echo e(date('F d, Y', strtotime($policy->renewal))); ?></p>
                        </div>
                        <div class="col-sm-8 col-md-4">
                            <span><?php echo e(trans('policies.label.expiry')); ?></span>
                            <p><?php echo e(date('F d, Y', strtotime($policy->expiry))); ?></p>
                        </div>
                    </div>
                    <div class="row">
                        <div class="col-sm-4 col-md-4">
                            <span><?php echo e(trans('policies.label.payer')); ?></span>
                            <p><?php echo e($policy->payer); ?></p>
                        </div>
                        <div class="col-sm-3 col-md-3">
                            <span><?php echo e(trans('policies.label.premium')); ?></span>
                            <p>
                                <?php echo e($policy->currency_symbol); ?><?php echo e($policy->premium); ?>

                            </p>
                        </div>
                        <div class="col-sm-5 col-md-5">
                                <?php if($policy->premium <= $policy->paid && $policy->paid > 0): ?>
                                <span class="ui <?php echo e($policy->statusClass); ?> large tag label"> <strong><?php echo e(trans('policies.label.paid_in_full')); ?></strong> </span>
                                <?php elseif($policy->due > 0 && $policy->active): ?>
                                <span class="ui <?php echo e($policy->statusClass); ?> large tag label"> <strong><?php echo e(trans('policies.label.due')); ?> -</strong> <?php echo e($policy->currency_symbol); ?><?php echo e($policy->due); ?> </span>
                                <?php elseif($policy->due > 0 && !$policy->active): ?>
                                <span class="ui <?php echo e($policy->statusClass); ?> large tag label"> <strong><?php echo e(trans('policies.label.expired_and_due')); ?> -</strong> <?php echo e($policy->currency_symbol); ?><?php echo e($policy->due); ?> </span>
                                <?php elseif($policy->premium == $policy->paid && $policy->paid === 0): ?>
                                <span class="ui yellow large tag label"> <strong><?php echo e(trans('policies.label.free')); ?></strong> </span>
                                <?php endif; ?>
                        </div>
                    </div>
                    <div class="row">
                        <div class="col-md-12">
                            <span><?php echo e(trans('policies.label.beneficiaries')); ?></span>
                            <p><?php echo e($policy->beneficiaries); ?></p>
                        </div>
                    </div>
                    <div class="row">
                        <div class="col-md-12">
                            <span><?php echo e(trans('policies.label.special_remarks')); ?></span>
                            <p><?php echo $policy->special_remarks; ?></p>
                        </div>
                    </div>

                    <div class="divider"></div>

                    <div class="row">
                        <?php foreach($policy->customFields->all() as $custom_field): ?>
                        <div class="col-md-4">
                            <span><?php echo e($custom_field->label); ?></span>
                            <p><?php echo e(is_object($custom_field->value) ? $custom_field->value->choice : $custom_field->value); ?></p>
                        </div>
                        <?php endforeach; ?>
                    </div>
                </div>
            </div>

            <!-- attachments -->
            <div class="ui segment white fs-16">
                <div class="segment-header">
                    <h3><?php echo e(trans('policies.table.title.attachments')); ?></h3>
                    <button class="ui right floated button successish m-w-140" data-target="#newAttachmentModal" data-toggle="modal"><?php echo e(trans('attachments.button.new')); ?></button>
                </div>
                <table class="ui celled striped table">
                    <thead>
                        <tr>
                            <th> <?php echo e(trans('policies.table.header.file')); ?> </th>
                            <th> <?php echo e(trans('policies.table.header.date')); ?> </th>
                            <th> <?php echo e(trans('policies.table.header.uploader')); ?> </th>
                            <th class="center aligned"> <?php echo e(trans('policies.table.header.actions')); ?> </th>
                        </tr>
                    </thead>
                    <tbody>
                        <?php $__empty_1 = true; foreach($policy->attachments as $attachment): $__empty_1 = false; ?>
                        <tr>
                            <td>
                                <i class="file <?php echo e(array(
                                    'bmp'   => 'image',
                                    'doc'   => 'word',
                                    'docx'  => 'word',
                                    'gif'   => 'image',
                                    'jpeg'  => 'image',
                                    'jpg'   => 'image',
                                    'png'   => 'image',
                                    'ppt'   => 'powerpoint',
                                    'pptx'  => 'powerpoint',
                                    'pdf'   => 'pdf',
                                    'svg'   => 'image',
                                    'xls'   => 'excel',
                                    'xlsx'  => 'excel'
                                )[pathinfo(storage_path('app/attachments/' . $attachment->filename), PATHINFO_EXTENSION)]); ?> outline icon"></i> <?php echo e($attachment->name); ?>

                            </td>
                            <td><?php echo e(date('F d, Y', strtotime($attachment->created_at))); ?></td>
                            <td><?php echo e($attachment->uploader->first_name . ' ' . $attachment->uploader->last_name); ?></td>
                            <td class="center aligned">
                                <a class="ui tiny grey label" href="<?php echo e(url('uploads3/attachments/' . $attachment->filename)); ?>" target="_blank"> <?php echo e(trans('policies.table.data.action.view')); ?> </a>
                                <form action="<?php echo e(action('AttachmentController@delete', array($attachment->id))); ?>" method="POST" style="display:inline;">
                                    <?php echo e(csrf_field()); ?>

                                    <?php echo e(method_field('DELETE')); ?>

                                    <button class="delete label tiny red ui" style="cursor:pointer;" type="submit"><?php echo e(trans('policies.table.data.action.delete')); ?></button>
                                </form>
                            </td>
                        </tr>
                        <?php endforeach; if ($__empty_1): ?>
                        <tr>
                            <td class="center aligned" colspan="4"><?php echo e(trans('policies.table.message.empty.attachments', array(
                                'policy' => $policy->ref_no
                            ))); ?></td>
                        </tr>
                        <?php endif; ?>
                    </tbody>
                </table>
            </div>
            <!-- end attachments -->

            <!-- payments -->
            <div class="ui segment white">
                <div class="segment-header">
                    <h3><?php echo e(trans('policies.table.title.payments')); ?></h3>
                    <?php if($policy->due > 0): ?>
                        <?php echo $__env->yieldContent('payments_button'); ?>
                    <?php endif; ?>
                </div>
                <table class="ui striped table">
                    <thead>
                        <tr>
                            <th><?php echo e(trans('policies.table.header.number')); ?></th>
                            <th><?php echo e(trans('policies.table.header.amount')); ?></th>
                            <th><?php echo e(trans('policies.table.header.date')); ?></th>
                            <th><?php echo e(trans('policies.table.header.method')); ?></th>
                        </tr>
                    </thead>
                    <tbody>
                        <?php $__empty_1 = true; foreach($policy->payments as $key => $payment): $__empty_1 = false; ?>
                        <tr>
                            <td><?php echo e($key + 1); ?></td>
                            <td><?php echo e($policy->client->currency_symbol); ?><?php echo e($payment->amount); ?></td>
                            <td><?php echo e(date('F d, Y', strtotime($payment->date))); ?></td>
                            <td>
                                <i class="<?php echo e(array(
                                    'card'      => 'credit card alternative',
                                    'cash'      => 'money',
                                    'paypal'    => 'paypal card'
                                )[$payment->method]); ?> icon"></i> <?php echo e(array(
                                    'card'      => trans('clients.table.data.method.card'),
                                    'cash'      => trans('clients.table.data.method.cash'),
                                    'paypal'    => trans('clients.table.data.method.paypal')
                                )[$payment->method]); ?>

                            </td>
                        </tr>
                        <?php endforeach; if ($__empty_1): ?>
                        <tr>
                            <td class="center aligned" colspan="4"><?php echo e(trans('policies.table.message.empty.payments', array(
                                'name'  => $policy->client->first_name
                            ))); ?></td>
                        </tr>
                        <?php endif; ?>
                    </tbody>
                </table>
            </div>
            <!-- end payments -->
        </div>
        <!-- end half page content -->
<?php $__env->stopSection(); ?>

<?php $__env->startSection('modals'); ?>
    <!-- new attachment modal -->
    <div class="ui tiny modal" id="newAttachmentModal">
        <div class="header"><?php echo e(trans('attachments.modal.header.new')); ?></div>
        <div class="content">
            <form action="<?php echo e(action('AttachmentController@add')); ?>" enctype="multipart/form-data" method="POST">
                <?php echo e(csrf_field()); ?>

                <input type="hidden" name="attachee" value="<?php echo e($policy->id); ?>"/>
                <input type="hidden" name="attachee_type" value="policy"/>
                <div class="ui form">
                    <div class="field required">
                        <label><?php echo e(trans('attachments.input.label.name')); ?></label>
                        <input type="text" name="name" placeholder="<?php echo e(trans('attachments.input.placeholder.name')); ?>" required value="<?php echo e(old('name')); ?>"/>
                    </div>
                    <div class="field required">
                        <label><?php echo e(trans('attachments.input.label.attachment')); ?></label>
                        <input type="file" accept="image/*, application/pdf, .doc, .docx, .ppt, .pptx, .xls, .xlsx" class="file-upload" data-allowed-file-extensions="bmp doc docx gif jpeg jpg pdf png ppt pptx svg xls xlsx" name="attachment" required/>
                    </div>
                </div>
            </form>
        </div>
        <div class="actions">
            <div class="ui buttons">
                <button class="ui cancel button"><?php echo e(trans('attachments.modal.button.cancel.new')); ?></button>
                <div class="or" data-text="<?php echo e(trans('attachments.modal.button.or')); ?>"></div>
                <button class="ui positive primary button"><?php echo e(trans('attachments.modal.button.confirm.new')); ?></button>
            </div>
        </div>
    </div>
    <?php echo $__env->yieldContent('policy_modals'); ?>
<?php $__env->stopSection(); ?>

<?php $__env->startSection('page_scripts'); ?>


<script type="text/javascript">
    function printClientDetails() {
        var printContents = document.querySelector('.policy-details').innerHTML;
        var originalContents = document.body.innerHTML;

        document.body.innerHTML = printContents;

        window.print();

        document.body.innerHTML = originalContents;
    }
    </script>




    <script src="<?php echo e(asset('assets/libs/datepicker/datepicker.min.js')); ?>" type="text/javascript"></script>
    <script src="<?php echo e(asset('assets/libs/dropify/js/dropify.min.js')); ?>" type="text/javascript"></script>
    <script src="<?php echo e(asset('assets/libs/sweetalert/sweetalert.min.js')); ?>" type="text/javascript"></script>
    <script type="text/javascript">
        (function($insura, $) {
            $(document).ready(function() {
                if ($(window).width() > 992) {
                    getVisible();
                }else{
                    $('div.right-bar-profile div.scrollbar').removeAttr("style");
                }

                $(window).resize(function(){
                    if ($(window).width() > 992) {
                        getVisible();
                    }else {
                        $('.scrollbar').removeAttr("style");
                    }
                });

                $insura.helpers.initDatepicker('input.datepicker');
                $insura.helpers.initDropify('input.file-upload');
                $insura.helpers.initDropdown('div.dropdown, select.dropdown');
                $insura.helpers.initModal('div#newAttachmentModal', true);
                $insura.helpers.initScrollbar('div.scrollbar');
                $insura.helpers.initSwal('form button.delete', {
                    confirmButtonText: '<?php echo e(trans('attachments.swal.warning.delete.confirm')); ?>',
                    text: '<?php echo e(trans('attachments.swal.warning.delete.text')); ?>',
                    title: '<?php echo e(trans('attachments.swal.warning.delete.title')); ?>'
                });
                $insura.helpers.listenForChats();
                $insura.helpers.requireDropdownFields('div.required select, div.required div.dropdown input[type="hidden"]');
            });
        })(window.insura, window.jQuery);
    </script>

    
<?php $__env->stopSection(); ?>


<?php echo $__env->make('global.app', array_except(get_defined_vars(), array('__data', '__path')))->render(); ?>