<?php $__env->startSection('title', trans('clients.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/intl-tel-input/css/intlTelInput.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">
            <div class="user-profile m-b-15">
                <div class="circular ui icon button top right pointing dropdown edit-profile-btn" data-inverted="" data-tooltip="<?php echo e(trans('clients.menu.header.tooltip')); ?>" data-position="left center">
                    <i class="icon ion-more"></i>
                    <div class="menu">
                        <div class="header"><?php echo e(trans('clients.menu.header.text')); ?></div>
                        <div class="divider"></div>
                        <div class="item">
                            <a href="#" data-target="#editClientModal" data-toggle="modal"><i class="write icon"></i> <?php echo e(trans('clients.menu.item.edit_profile')); ?></a>
                        </div>
                        <div class="item">
                            <a href="<?php echo e(action('InboxController@getAll', array(
                                'chatee'  => $client->id
                            ))); ?>"><i class="comments icon"></i> <?php echo e(trans('clients.menu.item.chat')); ?></a>
                        </div>
                        <form action="<?php echo e(action('ClientController@delete', array($client->id))); ?>" class="item negative" method="POST">
                            <?php echo e(csrf_field()); ?>

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

                            <a href="#" class="delete"><i class="trash icon"></i><?php echo e(trans('clients.menu.item.delete')); ?></a>
                        </form>
                    </div>
                </div>
                <?php if($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($client->first_name[0] . (isset($client->last_name) ? $client->last_name[0] : ''))); ?></div>
                <?php else: ?>
                <img src="<?php echo e(asset('uploads/images/users/' . $client->profile_image_filename)); ?>" alt="<?php echo e($client->first_name . ' ' . $client->last_name); ?>"/>
                <?php endif; ?>
                <h3><?php echo e($client->first_name . ' ' . $client->last_name); ?></h3>
                <span>
                    <?php if($client->status): ?>
                    <i class="ion-ios-circle-filled text-success"></i> <?php echo e(trans('clients.status.active')); ?>

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

                    <?php endif; ?>
                </span>
                <div class="m-t-25">
                    <button class="ui button primarish" data-target="#newTextModal" data-toggle="modal"<?php echo e(is_null($user->company->text_provider) || is_null($client->phone) ? ' disabled' : ''); ?>><i class="comment icon"></i> <?php echo e(trans('clients.button.text')); ?> </button>
                    <button class="ui button primarish" data-target="#newEmailModal" data-toggle="modal"><i class="mail icon"></i> <?php echo e(trans('clients.button.email')); ?> </button>
                </div>
            </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($client->email); ?></p>
                        </div>
                        <div>
                            <span><?php echo e(trans('clients.label.phone')); ?></span>
                            <p><?php echo e(isset($client->phone) ? $client->phone : '(---) ---- --- ---'); ?></p>
                        </div>
                        <div>
                            <span><?php echo e(trans('clients.label.birthday')); ?></span>
                            <p><?php echo e(is_null($client->birthday) ? '---------- --, ----' : date('jS F Y', strtotime($client->birthday))); ?></p>
                        </div>
                        <div>
                            <span><?php echo e(trans('clients.label.address')); ?></span>
                            <p><?php echo e(isset($client->address) ? $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(); ?>
            <!-- Client details -->
            <div class="ui segment white fs-16 client-details">
                <div class="segment-header">
                    <h3><?php echo e(trans('clients.label.details')); ?></h3>
                    <div class="ui right floated successish button top m-w-140 right pointing dropdown" data-inverted="" data-tooltip="<?php echo e(trans('clients.menu.header.tooltip')); ?>" data-position="left center">
                        <i class="ion-more icon"></i>
                        <span><?php echo e(trans('clients.menu.header.button')); ?></span>
                        <div class="menu">
                            <div class="header">
                                <?php echo e(trans('clients.menu.header.text')); ?>

                            </div>
                            <div class="divider"></div>
                            <div class="item">
                                <a href="#" data-target="#editClientModal" data-toggle="modal">
                                    <i class="write icon"></i> <?php echo e(trans('clients.menu.item.edit_profile')); ?> 
                                </a>
                            </div>
                            <div class="item">
                                <a href="<?php echo e(action('InboxController@getAll', array(
                                    'chatee'  => $client->id
                                ))); ?>"><i class="comments icon"></i> <?php echo e(trans('clients.menu.item.chat')); ?></a>
                            </div>
                            <form action="<?php echo e(action('ClientController@delete', array($client->id))); ?>" class="item negative" method="POST">
                                <?php echo e(csrf_field()); ?>

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

                                <a href="#" class="delete">
                                    <i class="trash icon"></i> <?php echo e(trans('clients.menu.item.delete')); ?> 
                                </a>
                            </form>
                            <div class="item">
                                <a href="#" data-target="#newEmailModal" data-toggle="modal">
                                    <i class="mail icon"></i> <?php echo e(trans('clients.menu.item.email')); ?> 
                                </a>
                            </div>
                            <div class="item<?php echo e(is_null($user->company->text_provider) || is_null($client->phone) ? ' disabled' : ''); ?>">
                                <a href="#" data-target="#newTextModal" data-toggle="modal">
                                    <i class="comment icon"></i> <?php echo e(trans('clients.menu.item.text')); ?> 
                                </a>
                            </div>
                        </div>
                    </div>
                </div>
                <div class="policy-details">
                    <div class="row">
                        <div class="col-sm-3 col-md-4">
                            <span><?php echo e(trans('clients.label.name')); ?></span>
                            <p><?php echo e($client->first_name . ' ' . $client->last_name); ?></p>
                        </div>
                        <div class="col-sm-5 col-md-4">
                            <span><?php echo e(trans('clients.label.policies')); ?></span>
                            <p><?php echo e($client->policies->count()); ?></p>
                        </div>
                        <div class="col-sm-4 col-md-4">
                            <?php if($client->policies->sum('premium') <= $client->policies->sum('paid') && $client->policies->sum('paid') > 0): ?>
                            <span class="ui green large tag label"> <strong><?php echo e(trans('policies.label.paid_in_full')); ?></strong> </span>
                            <?php elseif($client->policies->sum('due') > 0 && $client->policies->where('statusClass', 'warning')->count() > ($client->policies->count() / 3)): ?>
                            <span class="ui orange large tag label"> <strong><?php echo e(trans('policies.label.due')); ?> -</strong> <?php echo e($client->currency_symbol); ?><?php echo e($client->policies->sum('due')); ?> </span>
                            <?php elseif($client->policies->sum('due') > 0 && $client->policies->where('statusClass', 'negative')->count() > ($client->policies->count() / 3)): ?>
                            <span class="ui red large tag label"> <strong><?php echo e(trans('policies.label.due')); ?> -</strong> <?php echo e($client->currency_symbol); ?><?php echo e($client->policies->sum('due')); ?> </span>
                            <?php endif; ?>
                        </div>
                    </div>
                    <div class="row">
                        <div class="col-sm-4 col-md-4">
                            <span><?php echo e(trans('clients.label.email')); ?></span>
                            <p><?php echo e($client->email); ?></p>
                        </div>
                        <div class="col-sm-8 col-md-4">
                            <span><?php echo e(trans('clients.label.birthday')); ?></span>
                            <p><?php echo e(is_null($client->birthday) ? '---------- --, ----' : date('jS F Y', strtotime($client->birthday))); ?></p>
                        </div>
                    </div>
                    <div class="row">
                        <div class="col-sm-4 col-md-4">
                            <span><?php echo e(trans('clients.label.phone')); ?></span>
                            <p><?php echo e(isset($client->phone) ? $client->phone : '(---) ---- --- ---'); ?></p>
                        </div>
                        <div class="col-sm-4 col-md-4">
                            <span><?php echo e(trans('clients.label.address')); ?></span>
                            <p><?php echo e(isset($client->address) ? $client->address : '. . .'); ?></p>
                        </div>
                    </div>

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

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

            <!-- notes -->
            <div class="ui segment white fs-16">
                <div class="segment-header">
                    <h3><?php echo e(trans('clients.table.title.notes', array(
                        'name'  => $client->first_name
                    ))); ?></h3>
                    <button class="ui right floated button successish m-w-140" data-target="#newNoteModal" data-toggle="modal"><?php echo e(trans('clients.button.notes')); ?></button>
                </div>
                <table class="ui celled striped table">
                    <thead>
                        <tr>
                            <th> <?php echo e(trans('clients.table.header.from')); ?> </th>
                            <th> <?php echo e(trans('clients.table.header.message')); ?> </th>
                            <th> <?php echo e(trans('clients.table.header.date')); ?> </th>
                            <th class="center aligned"> <?php echo e(trans('clients.table.header.actions')); ?> </th>
                        </tr>
                    </thead>
                    <tbody>
                       <?php $__empty_1 = true; foreach($client->notes as $note): $__empty_1 = false; ?>
                        <tr>
                            <td><?php echo e($note->writer->id === $user->id ? 'You': $note->writer->first_name); ?></td>
                            <td class="text-ellipsis"><?php echo e($note->message); ?></td>
                            <td><?php echo e(date('F d, Y', strtotime($note->created_at))); ?></td>
                            <td class="center aligned">
                                <a href="#" class="ui tiny grey label" data-target="#readNote<?php echo e($note->id); ?>Modal" data-toggle="modal"> <?php echo e(trans('clients.table.data.action.read')); ?> </a>
                                <form action="<?php echo e(action('NoteController@delete', array($note->id))); ?>" class="delete-note" method="POST" style="display:inline;">
                                    <?php echo e(csrf_field()); ?>

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

                                    <button href="#" class="ui red tiny label delete" style="cursor:pointer;" type="submit"> <?php echo e(trans('clients.table.data.action.delete')); ?> </button>
                                </form>
                            </td>
                        </tr>
                        <?php endforeach; if ($__empty_1): ?>
                        <tr>
                            <td class="text-center" colspan="4"><?php echo e(trans('clients.table.message.empty.notes', array(
                                'name' => $client->first_name
                            ))); ?></td>
                        </tr>
                        <?php endif; ?>
                    </tbody>
                </table>
            </div>
            <!-- end notes -->

            <!-- attachments -->
            <div class="ui segment white fs-16">
                <div class="segment-header">
                    <h3><?php echo e(trans('clients.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('clients.table.header.file')); ?> </th>
                            <th> <?php echo e(trans('clients.table.header.date')); ?> </th>
                            <th> <?php echo e(trans('clients.table.header.uploader')); ?> </th>
                            <th class="center aligned"> <?php echo e(trans('clients.table.header.actions')); ?> </th>
                        </tr>
                    </thead>
                    <tbody>
                        <?php $__empty_1 = true; foreach($client->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 href="<?php echo e(url('uploads/attachments/' . $attachment->filename)); ?>" class="ui tiny grey label" target="_blank"> <?php echo e(trans('clients.table.data.action.view')); ?> </a>
                                <form action="<?php echo e(action('AttachmentController@delete', array($attachment->id))); ?>" class="delete-attachment" 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('clients.table.data.action.delete')); ?></button>
                                </form>
                            </td>
                        </tr>
                        <?php endforeach; if ($__empty_1): ?>
                        <tr>
                            <td class="center aligned" colspan="4"><?php echo e(trans('clients.table.message.empty.attachments', array(
                                'name' => $client->first_name
                            ))); ?></td>
                        </tr>
                        <?php endif; ?>
                    </tbody>
                </table>
            </div>
            <!-- end attachments -->

            <!-- policies -->
            <div class="ui segment white">
                <div class="segment-header">
                    <h3><?php echo e(trans('clients.table.title.policies')); ?></h3>
                    <button class="ui right floated button successish m-w-140" data-target="#newPolicyModal" data-toggle="modal"><?php echo e(trans('clients.table.button.policies')); ?></button>
                </div>
                <table class="ui table">
                    <thead>
                        <tr>
                            <th><?php echo e(trans('clients.table.header.ref_no')); ?></th>
                            <th><?php echo e(trans('clients.table.header.product')); ?></th>
                            <th><?php echo e(trans('clients.table.header.insurer')); ?></th>
                            <th><?php echo e(trans('clients.table.header.premium')); ?></th>
                            <th><?php echo e(trans('clients.table.header.due')); ?></th>
                            <th class="center aligned"><?php echo e(trans('clients.table.header.status')); ?></th>
                            <th class="center aligned"><?php echo e(trans('clients.table.header.action')); ?></th>
                        </tr>
                    </thead>
                    <tbody>
                        <?php $__empty_1 = true; foreach($policies as $policy): $__empty_1 = false; ?>
                        <tr class="<?php echo e($policy->statusClass); ?>">
                            <td><?php echo e($policy->ref_no); ?></td>
                            <td class="text-ellipsis"><?php echo e($policy->product->name); ?></td>
                            <td><?php echo e($policy->product->insurer); ?></td>
                            <td><?php echo e($client->currency_symbol); ?><?php echo e($policy->premium + 0); ?></td>
                            <td><?php echo e($client->currency_symbol); ?><?php echo e($policy->due); ?></td>
                            <td class="center aligned">
                                <?php if($policy->premium <= $policy->paid && $policy->paid > 0): ?>
                                <div class="ui green mini label"> <?php echo e(trans('clients.table.data.status.paid')); ?></div>
                                <?php elseif($policy->premium > $policy->paid && $policy->paid > 0): ?>
                                <div class="ui orange mini label"> <?php echo e(trans('clients.table.data.status.partial')); ?></div>
                                <?php elseif($policy->premium == $policy->paid && $policy->paid === 0): ?>
                                <div class="ui yellow mini label"> <?php echo e(trans('clients.table.data.status.free')); ?></div>
                                <?php else: ?>
                                <div class="ui red mini label"> <?php echo e(trans('clients.table.data.status.unpaid')); ?></div>
                                <?php endif; ?>
                            </td>
                            <td class="center aligned">
                                <a class="ui mini grey label" href="<?php echo e(action('PolicyController@getOne', array($policy->id))); ?>"> <?php echo e(trans('clients.table.data.action.view')); ?> </a>
                            </td>
                        </tr>
                        <?php endforeach; if ($__empty_1): ?>
                        <tr>
                            <td class="center aligned" colspan="7"><?php echo e(trans('clients.table.message.empty.policies', array(
                                'name'  => $client->first_name
                            ))); ?></td>
                        </tr>
                        <?php endif; ?>
                    </tbody>
                    <tfoot>
                        <tr>
                            <th><?php echo e(trans('clients.table.header.total')); ?></th>
                            <th></th>
                            <th></th>
                            <th><?php echo e($client->currency_symbol); ?><?php echo e($policies->sum('premium')); ?></th>
                            <th><?php echo e($client->currency_symbol); ?><?php echo e($policies->sum('due')); ?></th>
                            <th></th>
                            <th></th>
                        </tr>
                    </tfoot>
                </table>
            </div>
            <!-- end policies -->

            <!-- payments -->
            <div class="ui segment white">
                <div class="segment-header">
                    <h3><?php echo e(trans('clients.table.title.payments')); ?></h3>
                    <button class="ui right floated button successish m-w-140" data-target="#newPaymentModal" data-toggle="modal"<?php echo e($policies->count() > 0 ? '' : ' disabled'); ?>><?php echo e(trans('payments.button.new')); ?></button>
                </div>
                <table class="ui striped table">
                    <thead>
                        <tr>
                            <th><?php echo e(trans('clients.table.header.number')); ?></th>
                            <th><?php echo e(trans('clients.table.header.policy')); ?></th>
                            <th><?php echo e(trans('clients.table.header.amount')); ?></th>
                            <th><?php echo e(trans('clients.table.header.date')); ?></th>
                            <th><?php echo e(trans('clients.table.header.method')); ?></th>
                        </tr>
                    </thead>
                    <tbody>
                        <?php $__empty_1 = true; foreach($client->payments as $key => $payment): $__empty_1 = false; ?>
                        <tr>
                            <td><?php echo e($key + 1); ?></td>
                            <td><?php echo e($payment->policy->ref_no); ?></td>
                            <td><?php echo e($client->currency_symbol); ?><?php echo e($payment->amount + 0); ?></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="5"><?php echo e(trans('clients.table.message.empty.payments', array(
                                'name'  => $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 email modal -->
    <div class="ui tiny modal" id="newEmailModal">
        <div class="header"><?php echo e(trans('communication.modal.header.email')); ?></div>
        <div class="content">
            <p><?php echo e(trans('communication.modal.instruction.send', array(
                'name'  => $client->first_name . ' ' . $client->last_name,
                'type'  => 'an email'
            ))); ?></p>
            <form action="<?php echo e(action('EmailController@add')); ?>" method="POST">
                <?php echo e(csrf_field()); ?>

                <input type="hidden" name="recipient" value="<?php echo e($client->id); ?>"/>
                <div class="ui form">
                    <div class="field required">
                        <label><?php echo e(trans('communication.input.label.subject')); ?></label>
                        <input type="text" name="subject" placeholder="<?php echo e(trans('communication.input.placeholder.subject')); ?>" required value="<?php echo e(old('subject')); ?>"/>
                    </div>
                    <div class="field required">
                        <label><?php echo e(trans('communication.input.label.message')); ?></label>
                        <textarea rows="5" name="message" placeholder="<?php echo e(trans('communication.input.placeholder.message')); ?>" required><?php echo e(session('text') ? '' : old('message')); ?></textarea>
                    </div>
                </div>
            </form>
        </div>
        <div class="actions">
            <div class="ui buttons">
                <button class="ui cancel button"><?php echo e(trans('communication.modal.button.cancel')); ?></button>
                <div class="or" data-text="<?php echo e(trans('communication.modal.button.or')); ?>"></div>
                <button class="ui positive primary button"><?php echo e(trans('communication.modal.button.confirm')); ?></button>
            </div>
        </div>
    </div>

    <!-- new text modal -->
    <div class="ui tiny modal" id="newTextModal">
        <div class="header"><?php echo e(trans('communication.modal.header.text')); ?></div>
        <div class="content">
            <p><?php echo e(trans('communication.modal.instruction.send', array(
                'name'  => $client->first_name . ' ' . $client->last_name,
                'type'  => 'a text message'
            ))); ?></p>
            <form action="<?php echo e(action('TextController@add')); ?>" method="POST">
                <?php echo e(csrf_field()); ?>

                <input type="hidden" name="recipient" value="<?php echo e($client->id); ?>"/>
                <div class="ui form">
                    <div class="field required">
                        <label><?php echo e(trans('communication.input.label.message')); ?></label>
                        <textarea rows="5" name="message" placeholder="<?php echo e(trans('communication.input.placeholder.message')); ?>" required><?php echo e(session('text') ? old('message') : ''); ?></textarea>
                    </div>
                </div>
            </form>
        </div>
        <div class="actions">
            <div class="ui buttons">
                <button class="ui cancel button"><?php echo e(trans('communication.modal.button.cancel')); ?></button>
                <div class="or" data-text="<?php echo e(trans('communication.modal.button.or')); ?>"></div>
                <button class="ui positive primary button"><?php echo e(trans('communication.modal.button.confirm')); ?></button>
            </div>
        </div>
    </div>

    <!-- 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($client->id); ?>"/>
                <input type="hidden" name="attachee_type" value="client"/>
                <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" data-allowed-file-extensions="bmp doc docx gif jpeg jpg pdf png ppt pptx svg xls xlsx" name="attachment" class="file-upload" 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>
    
    <!-- new note modal -->
    <div class="ui tiny modal" id ="newNoteModal">
        <div class="header"><?php echo e(trans('notes.modal.header.new')); ?></div>
        <div class="content">
            <form action="<?php echo e(action('NoteController@add')); ?>" method="POST">
                <?php echo e(csrf_field()); ?>

                <input type="hidden" name="client" value="<?php echo e($client->id); ?>"/>
                <div class="ui form">
                    <div class="field">
                        <label><?php echo e(trans('notes.input.label.message')); ?></label>
                        <textarea name="message" placeholder="<?php echo e(trans('notes.input.placeholder.message')); ?>" rows="5" required rows="5"><?php echo e(old('message')); ?></textarea>
                    </div>
                </div>
            </form>
        </div>
        <div class="actions">
            <div class="ui buttons">
                <button class="ui cancel button"><?php echo e(trans('notes.modal.button.cancel.new')); ?></button>
                <div class="or" data-text="<?php echo e(trans('notes.modal.button.or')); ?>"></div>
                <button class="ui positive primary button"><?php echo e(trans('notes.modal.button.confirm.new')); ?></button>
            </div>
        </div>
    </div>

    <!-- new payment modal -->
    <div class="ui tiny modal" id="newPaymentModal">
        <div class="header"><?php echo e(trans('payments.modal.header.new')); ?></div>
        <div class="content">
            <p><?php echo e(trans('payments.modal.instruction.new', array(
                'name'  => $client->first_name
            ))); ?></p>
            <form action="<?php echo e(action('PaymentController@add')); ?>"method="POST">
                <?php echo e(csrf_field()); ?>

                <input type="hidden" name="client" value="<?php echo e($client->id); ?>"/>
                <div class="ui form">
                    <div class="two fields">
                        <div class="field required">
                            <label><?php echo e(trans('payments.input.label.policy')); ?></label>
                            <select name="policy" class="ui fluid search dropdown" required>
                                <?php $__empty_1 = true; foreach($policies->filter(function($policy) {
                                    return $policy->due > 0;
                                }) as $policy): $__empty_1 = false; ?>
                                <option data-policy-due="<?php echo e($policy->due); ?>" <?php echo e(old('policy') == $policy->id ? 'selected' : null); ?> value="<?php echo e($policy->id); ?>"><?php echo e($policy->ref_no); ?> - <?php echo e($policy->product->name); ?></option>
                                <?php endforeach; if ($__empty_1): ?>
                                <option disabled value=""><?php echo e(trans('payments.input.option.empty.policy', array(
                                    'name'  => $client->first_name
                                ))); ?></option>
                                <?php endif; ?>
                            </select>
                        </div>
                        <div class="field required">
                            <label><?php echo e(trans('payments.input.label.amount')); ?></label>
                            <div class="ui labeled input">
                                <label for="amount" class="ui label"><?php echo e($client->currency_symbol); ?></label>
                                <input type="number" id="amount" name="amount" placeholder="<?php echo e(trans('payments.input.placeholder.amount')); ?>" required value="<?php echo e(old('amount')); ?>"/>
                            </div>
                        </div>
                    </div>
                    <div class="two fields">
                        <div class="field required">
                            <label><?php echo e(trans('payments.input.label.date')); ?></label>
                            <div class="ui labeled input">
                                <label for="paymentDate" class="ui label"><i class="calendar icon"></i></label>
                                <input type="text" class="datepicker" id="paymentDate" name="date" placeholder="<?php echo e(trans('payments.input.placeholder.date')); ?>" required value="<?php echo e(old('date')); ?>"/>
                            </div>
                        </div>
                        <div class="field required">
                            <label><?php echo e(trans('payments.input.label.method')); ?></label>
                            <div class="ui selection dropdown">
                                <input type="hidden" name="method">
                                <div class="default text"><?php echo e(trans('payments.input.placeholder.method')); ?></div>
                                <i class="dropdown icon"></i>
                                <div class="menu">
                                    <div class="item<?php echo e(old('method') === 'card' ? ' selected' : null); ?>" data-value="card">
                                        <i class="credit card alternative icon"></i>
                                        <?php echo e(trans('payments.input.option.method.card')); ?>

                                    </div>
                                    <div class="item<?php echo e(old('method') === 'cash' ? ' selected' : null); ?>" data-value="cash">
                                        <i class="money icon"></i>
                                        <?php echo e(trans('payments.input.option.method.cash')); ?>

                                    </div>
                                    <div class="item<?php echo e(old('method') === 'paypal' ? ' selected' : null); ?>" data-value="paypal">
                                        <i class="paypal card icon"></i>
                                        <?php echo e(trans('payments.input.option.method.paypal')); ?>

                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </form>
        </div>
        <div class="actions">
            <div class="ui buttons">
                <button class="ui cancel button"><?php echo e(trans('payments.modal.button.cancel.new')); ?></button>
                <div class="or" data-text="<?php echo e(trans('payments.modal.button.or')); ?>"></div>
                <button class="ui positive primary button"><?php echo e(trans('payments.modal.button.confirm.new')); ?></button>
            </div>
        </div>
    </div>

    <!-- new policy modal -->
    <div class="ui tiny modal" id="newPolicyModal">
        <div class="header"><?php echo e(trans('policies.modal.header.new')); ?></div>
        <div class="scrolling content">
            <p><?php echo e(trans('policies.modal.instruction.new')); ?> <?php echo e(trans('clients.modal.instruction.policy', array(
                'name'  => $client->first_name
            ))); ?></p>
            <form action="<?php echo e(action('PolicyController@add')); ?>" method="POST">
                <?php echo e(csrf_field()); ?>

                <div class="ui form">
                    <div class="two fields">
                        <div class="field required">
                            <label><?php echo e(trans('policies.input.label.product')); ?></label>
                            <select name="product" class="ui fluid search dropdown" required value="<?php echo e(old('product')); ?>">
                                <option value=""><?php echo e(trans('policies.input.placeholder.product')); ?></option>
                                <?php $__empty_1 = true; foreach($client->company->products as $product): $__empty_1 = false; ?>
                                <option<?php echo e(old('product') === $product->id ? ' selected' : ''); ?> value="<?php echo e($product->id); ?>"><?php echo e($product->name); ?></option>
                                <?php endforeach; if ($__empty_1): ?>
                                <option disabled value=""><?php echo e(trans('policies.input.option.empty.product')); ?></option>
                                <?php endif; ?>
                            </select>
                        </div>
                        <div class="field required">
                            <label><?php echo e(trans('policies.input.label.type')); ?></label>
                            <select name="type" class="ui fluid search dropdown" required value="<?php echo e(old('type')); ?>">
                                <option value=""><?php echo e(trans('policies.input.placeholder.type')); ?></option>
                                <option<?php echo e(old('type') === 'annually' ? ' selected' : ''); ?> value="annually"><?php echo e(trans('policies.input.option.type.annually')); ?></option>
                                <option<?php echo e(old('type') === 'monthly' ? ' selected' : ''); ?> value="monthly"><?php echo e(trans('policies.input.option.type.monthly')); ?></option>
                            </select>
                        </div>
                    </div>
                    <div class="two fields">
                        <div class="field">
                            <label><?php echo e(trans('policies.input.label.expiry')); ?></label>
                            <div class="ui labeled input">
                                <label for="expiry" class="ui label"><i class="calendar icon"></i></label>
                                <input type="text" id="expiry" class="datepicker" name="expiry" placeholder="<?php echo e(trans('policies.input.placeholder.expiry')); ?>" required value="<?php echo e(old('expiry')); ?>"/>
                            </div>
                        </div>
                        <div class="field">
                            <label><?php echo e(trans('policies.input.label.renewal')); ?></label>
                            <div class="ui labeled input">
                                <label for="renewal" class="ui label"><i class="calendar icon"></i></label>
                                <input type="text" id="renewal" class="datepicker" name="renewal" placeholder="<?php echo e(trans('policies.input.placeholder.renewal')); ?>" required value="<?php echo e(old('renewal')); ?>"/>
                            </div>
                        </div>
                    </div>
                    <input type="hidden" name="owners[]" value="<?php echo e($client->id); ?>"/>
                    <div class="two fields">
                        <div class="field required">
                            <label><?php echo e(trans('policies.input.label.premium')); ?></label>
                            <div class="ui labeled input">
                                <label for="premium" class="ui label"><?php echo e($client->currency_symbol); ?></label>
                                <input type="number" id="premium" min="0" name="premium[<?php echo e($client->id); ?>]" placeholder="<?php echo e(trans('policies.input.placeholder.premium')); ?>" required value="<?php echo e(old('premium')[$client->id]); ?>"/>
                            </div>
                        </div>
                        <div class="field">
                            <label><?php echo e(trans('policies.input.label.payer')); ?></label>
                            <input type="text" maxlength="64" name="payer" placeholder="<?php echo e(trans('policies.input.placeholder.payer')); ?>" required value="<?php echo e(old('payer') ?: $client->first_name . ' ' . $client->last_name); ?>"/>
                        </div>
                    </div>
                    <div class="divider"></div>
                    <div class="field required">
                        <label><?php echo e(trans('policies.input.label.beneficiaries')); ?></label>
                        <input type="text" name="beneficiaries" placeholder="<?php echo e(trans('policies.input.placeholder.beneficiaries')); ?>" value="<?php echo e(old('beneficiaries')); ?>"/>
                    </div>
                    <div class="field">
                        <label><?php echo e(trans('policies.input.label.special_remarks')); ?></label>
                        <textarea name="special_remarks" placeholder="<?php echo e(trans('policies.input.placeholder.special_remarks')); ?>" rows="4"><?php echo e(old('special_remarks')); ?></textarea>
                    </div>
                    <h5 class="ui dividing header disabled"><?php echo e(trans('policies.input.label.payments', array(
                        'name'  => $client->first_name . ' ' . $client->last_name
                    ))); ?></h5>
                    <div class="three fields">
                        <div class="field">
                            <label><?php echo e(trans('policies.input.label.amount')); ?></label>
                            <div class="ui labeled input">
                                <label for="amount" class="ui label"><?php echo e($client->currency_symbol); ?></label>
                                <input type="number" id="amount" min="0" name="amount[<?php echo e($client->id); ?>]" placeholder="<?php echo e(trans('policies.input.placeholder.amount')); ?>" value="<?php echo e(old('amount')[$client->id]); ?>"/>
                            </div>
                        </div>
                        <div class="field">
                            <label><?php echo e(trans('policies.input.label.payment_date')); ?></label>
                            <input type="text" class="datepicker" name="date[<?php echo e($client->id); ?>]" placeholder="<?php echo e(trans('policies.input.placeholder.payment_date')); ?>" value="<?php echo e(old('date')[$client->id]); ?>"/>
                        </div>
                        <div class="field">
                            <label><?php echo e(trans('policies.input.label.payment_method')); ?></label>
                            <div class="ui selection dropdown">
                                <input type="hidden" name="method[<?php echo e($client->id); ?>]" value="<?php echo e(old('method')[$client->id]); ?>"/>
                                <div class="default text"><?php echo e(trans('policies.input.placeholder.payment_method')); ?></div>
                                <i class="dropdown icon"></i>
                                <div class="menu">
                                    <div class="item" data-value="card">
                                        <i class="credit card alternative icon"></i>
                                        <?php echo e(trans('policies.input.option.method.card')); ?>

                                    </div>
                                    <div class="item" data-value="cash">
                                        <i class="money icon"></i>
                                        <?php echo e(trans('policies.input.option.method.cash')); ?>

                                    </div>
                                    <div class="item" data-value="paypal">
                                        <i class="paypal card icon"></i>
                                        <?php echo e(trans('policies.input.option.method.paypal')); ?>

                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </form>
        </div>
        <div class="actions">
            <div class="ui buttons">
                <button class="ui cancel button"><?php echo e(trans('policies.modal.button.cancel.new')); ?></button>
                <div class="or" data-text="<?php echo e(trans('policies.modal.button.or')); ?>"></div>
                <button class="ui positive primary button"><?php echo e(trans('policies.modal.button.confirm.new')); ?></button>
            </div>
        </div>
    </div>

    <?php foreach($client->notes as $note): ?>
    <div class="ui tiny modal" id="readNote<?php echo e($note->id); ?>Modal">
        <div class="ui icon header">
            <i class="edit outline icon"></i>
            <?php echo e(date('D d F, `y', strtotime($note->created_at))); ?>

        </div>
        <div class="scrolling content">
            <p><?php echo e($note->message); ?></p>
            <p>
                <i>~<?php echo e($note->writer->first_name . ' ' . $note->writer->last_name); ?></i>
            </p>
        </div>
        <div class="actions">
            <div class="ui red cancel button">
                <i class="remove icon"></i>
                <?php echo e(trans('notes.modal.button.dismiss')); ?>

            </div>
        </div>
    </div>
    <?php endforeach; ?>

    <?php echo $__env->yieldContent('client_modals'); ?>
<?php $__env->stopSection(); ?>

<?php $__env->startSection('page_scripts'); ?>
    <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/intl-tel-input/js/intlTelInput.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.initDropdown('div.dropdown, select.dropdown');
                $insura.helpers.initDropify('input.file-upload');
                $insura.helpers.initModal('div#newAttachmentModal, div#newEmailModal, div#newNoteModal, div#newPaymentModal, div#newPolicyModal, div#newTextModal', true);
                $insura.helpers.initModal('div#editClientModal', false);
                $insura.helpers.initScrollbar('div.scrollbar');
                $insura.helpers.initSwal('form a.delete', {
                    confirmButtonText: '<?php echo e(trans('clients.swal.warning.delete.confirm')); ?>',
                    text: '<?php echo e(trans('clients.swal.warning.delete.text')); ?>',
                    title: '<?php echo e(trans('clients.swal.warning.delete.title')); ?>'
                });
                $insura.helpers.initSwal('form.delete-attachment 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.initSwal('form.delete-note button.delete', {
                    confirmButtonText: '<?php echo e(trans('notes.swal.warning.delete.confirm')); ?>',
                    text: '<?php echo e(trans('notes.swal.warning.delete.text')); ?>',
                    title: '<?php echo e(trans('notes.swal.warning.delete.title')); ?>'
                });
                $insura.helpers.initTelInput('input[type="tel"]');
                $insura.helpers.listenForChats();
                $insura.helpers.requireDropdownFields('form div.required select, form div.required div.dropdown input[type="hidden"]');

                $('div#newPaymentModal select[name="policy"]').change(function() {
                    var select = $(this);
                    var policyDue = select.find('option:selected').attr('data-policy-due');
                    select.closest('div.modal').find('input[name="amount"]').attr('max', policyDue);
                }).change();
                $('div#newPolicyModal input[name^="premium["]').change(function() {
                    var input = $(this);
                    input.closest('div.modal').find('input[name^="amount["]').attr('max', input.val());
                }).change();
            });
        })(window.insura, window.jQuery);
    </script>
<?php $__env->stopSection(); ?>

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