

<?php $__env->startSection('client_action'); ?>
                <div class="m-t-25">
                    <a class="ui button positive" href="<?php echo e(action('ClientController@getOne', array($policy->client->id))); ?>"><i class="user outline icon"></i> <?php echo e(trans('policies.button.profile')); ?> </a>
                </div>
<?php $__env->stopSection(); ?>

<?php $__env->startSection('policy_actions'); ?>
                    <div class="ui right floated successish button top m-w-140 right pointing dropdown" data-inverted="" data-tooltip="<?php echo e(trans('policies.menu.header.tooltip')); ?>" data-position="left center">
                        <i class="ion-more icon"></i>
                        <span class="text"><?php echo e(trans('policies.menu.header.button')); ?></span>
                        <div class="menu">
                            <div class="header">
                                <?php echo e(trans('policies.menu.header.text')); ?>

                            </div>
                            <div class="divider"></div>
                            <div class="item">
                                <a href="#" data-target="#editPolicyModal" data-toggle="modal">
                                    <i class="write icon"></i> <?php echo e(trans('policies.menu.item.edit_policy')); ?> 
                                </a>
                            </div>
                            <form action="<?php echo e(action('PolicyController@delete', array($policy->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('policies.menu.item.delete')); ?> 
                                </a>
                            </form>
                        </div>
                    </div>
<?php $__env->stopSection(); ?>

<?php $__env->startSection('payments_button'); ?>
                    <button class="ui right floated button successish m-w-140" data-target="#newPaymentModal" data-toggle="modal"><?php echo e(trans('payments.button.new')); ?></button>
<?php $__env->stopSection(); ?>

<?php $__env->startSection('policy_modals'); ?>
    <!-- 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'  => $policy->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($policy->client->id); ?>"/>
                <input type="hidden" name="policy" value="<?php echo e($policy->id); ?>"/>
                <div class="ui form">
                    <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 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.amount')); ?></label>
                            <div class="ui labeled input">
                                <label for="amount" class="ui label"><?php echo e($policy->currency_symbol); ?></label>
                                <input type="number" id="amount" max="<?php echo e($policy->due); ?>" name="amount" placeholder="<?php echo e(trans('payments.input.placeholder.amount')); ?>" required value="<?php echo e(old('amount')); ?>"/>
                            </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>

    <!-- edit policy modal -->
    <div class="ui tiny modal" id="editPolicyModal">
        <div class="header"><?php echo e(trans('policies.modal.header.edit')); ?></div>
        <div class="scrolling content">
            <p><?php echo e(trans('policies.modal.instruction.edit')); ?></p>
            <form action="<?php echo e(action('PolicyController@edit', array($policy->id))); ?>" 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 class="ui fluid search dropdown" name="product" required value="<?php echo e(old('product') ?: $policy->product->id); ?>">
                                <option value=""><?php echo e(trans('policies.input.placeholder.product')); ?></option>
                                <?php $__empty_1 = true; foreach($policy->client->company->products as $product): $__empty_1 = false; ?>
                                <option<?php echo e(old('product') === $product->id || $policy->product->id === $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 class="ui fluid dropdown selection" name="type" required value="<?php echo e(old('type') ?: $policy->type); ?>">
                                <option value=""><?php echo e(trans('policies.input.placeholder.type')); ?></option>
                                <option<?php echo e(old('type') === 'annually' || $policy->type === 'annually' ? ' selected' : ''); ?> value="annually"><?php echo e(trans('policies.input.option.type.annually')); ?></option>
                                <option<?php echo e(old('type') === 'monthly' || $policy->type === 'monthly' ? ' selected' : ''); ?> value="monthly"><?php echo e(trans('policies.input.option.type.monthly')); ?></option>
                                <option<?php echo e(old('type') === 'weekly' || $policy->type === 'weekly' ? ' selected' : ''); ?> value="weekly"><?php echo e(trans('policies.input.option.type.weekly')); ?></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')); ?>" value="<?php echo e(old('expiry') ?: $policy->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')); ?>" value="<?php echo e(old('renewal') ?: $policy->renewal); ?>"/>
                            </div>
                        </div>
                    </div>
                    <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($policy->currency_symbol); ?></label>
                                <input type="number" id="premium" min="0" name="premium" placeholder="<?php echo e(trans('policies.input.placeholder.premium')); ?>" required value="<?php echo e(old('premium') ?: $policy->premium); ?>"/>
                            </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')); ?>" value="<?php echo e(old('payer') ?: $policy->payer); ?>"/>
                        </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')); ?>" required value="<?php echo e(old('beneficiaries') ?: $policy->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') ?: str_replace('<br/>', "\n", $policy->special_remarks)); ?></textarea>
                    </div>
                    <div class="divider"></div>
                    <?php foreach($policy->customFields->all() as $custom_field): ?>
                    <input type="hidden" name="custom_fields[C<?php echo e($policy->client->company->id); ?>F<?php echo e($custom_field->id); ?>][label]" value="<?php echo e($custom_field->label); ?>"/>
                    <input type="hidden" name="custom_fields[C<?php echo e($policy->client->company->id); ?>F<?php echo e($custom_field->id); ?>][type]" value="<?php echo e($custom_field->type); ?>"/>
                    <input type="hidden" name="custom_fields[C<?php echo e($policy->client->company->id); ?>F<?php echo e($custom_field->id); ?>][uuid]" value="<?php echo e($custom_field->uuid); ?>"/>
                        <?php if($custom_field->type === 'checkbox'): ?>
                    <div class="field<?php echo e(isset($custom_field->required) ? ' required' : ''); ?>">
                        <div class="ui checkbox">
                            <input type="checkbox"<?php echo e(isset($custom_field->value) ? ' checked' : ''); ?> name="custom_fields[C<?php echo e($policy->client->company->id); ?>F<?php echo e($custom_field->id); ?>][value]"<?php echo e(isset($custom_field->required) ? ' required' : ''); ?>>
                            <label><?php echo e($custom_field->label); ?></label>
                        </div>
                    </div>
                        <?php elseif($custom_field->type === 'date'): ?>
                    <div class="field<?php echo e(isset($custom_field->required) ? ' required' : ''); ?>">
                        <label><?php echo e($custom_field->label); ?></label>
                        <input type="text" class="datepicker" name="custom_fields[C<?php echo e($policy->client->company->id); ?>F<?php echo e($custom_field->id); ?>][value]""<?php echo e(isset($custom_field->required) ? ' required' : ''); ?> value="<?php echo e($custom_field->value); ?>">
                    </div>
                        <?php elseif($custom_field->type === 'email'): ?>
                    <div class="field<?php echo e(isset($custom_field->required) ? ' required' : ''); ?>">
                        <label><?php echo e($custom_field->label); ?></label>
                        <input type="email" name="custom_fields[C<?php echo e($policy->client->company->id); ?>F<?php echo e($custom_field->id); ?>][value]"<?php echo e(isset($custom_field->required) ? ' required' : ''); ?> value="<?php echo e($custom_field->value); ?>">
                    </div>
                        <?php elseif($custom_field->type === 'hidden'): ?>
                    <input type="hidden" name="custom_fields[C<?php echo e($policy->client->company->id); ?>F<?php echo e($custom_field->id); ?>][value]" value="<?php echo e($custom_field->value); ?>">
                        <?php elseif($custom_field->type === 'number'): ?>
                    <div class="field<?php echo e(isset($custom_field->required) ? ' required' : ''); ?>">
                        <label><?php echo e($custom_field->label); ?></label>
                        <input type="number" name="custom_fields[C<?php echo e($policy->client->company->id); ?>F<?php echo e($custom_field->id); ?>][value]""<?php echo e(isset($custom_field->required) ? ' required' : ''); ?> value="<?php echo e($custom_field->value); ?>">
                    </div>
                        <?php elseif($custom_field->type === 'select'): ?>
                            <?php foreach($custom_field->value->choices as $option): ?>
                    <input type="hidden" name="custom_fields[C<?php echo e($policy->client->company->id); ?>F<?php echo e($custom_field->id); ?>][value][choices][]" value="<?php echo e($option); ?>"/>
                            <?php endforeach; ?>
                            <?php if(count($custom_field->value->choices) > 2): ?>
                    <div class="field<?php echo e(isset($custom_field->required) ? ' required' : ''); ?>">
                        <label><?php echo e($custom_field->label); ?></label>
                        <select class="ui fluid search dropdown" name="custom_fields[C<?php echo e($policy->client->company->id); ?>F<?php echo e($custom_field->id); ?>][value][choice]">
                            <option value=""><?php echo e($custom_field->label); ?></option>
                                <?php foreach($custom_field->value->choices as $option): ?>
                            <option<?php echo e($option === $custom_field->value->choice ? ' selected' : ''); ?> value="<?php echo e(trim($option)); ?>"><?php echo e(trim($option)); ?></option>
                                <?php endforeach; ?>
                        </select>
                    </div>
                            <?php else: ?>
                    <div class="inline fields<?php echo e(isset($custom_field->required) ? ' required' : ''); ?>">
                        <label><?php echo e($custom_field->label); ?></label>
                                <?php foreach($custom_field->value->choices as $option): ?>
                        <div class="field">
                            <div class="ui radio checkbox">
                                <input type="radio"<?php echo e($option === $custom_field->value->choice ? ' checked' : ''); ?> name="custom_fields[C<?php echo e($company->id); ?>F<?php echo e($custom_field->id); ?>][value][choice]"<?php echo e(isset($custom_field->required) ? ' required' : ''); ?> value="<?php echo e(trim($option)); ?>">
                                <label><?php echo e(trim($option)); ?></label>
                            </div>
                        </div>
                                <?php endforeach; ?>
                    </div>
                            <?php endif; ?>
                        <?php elseif($custom_field->type === 'tel'): ?>
                    <div class="field<?php echo e(isset($custom_field->required) ? ' required' : ''); ?>">
                        <label><?php echo e($custom_field->label); ?></label>
                        <input type="tel" name="custom_fields[C<?php echo e($policy->client->company->id); ?>F<?php echo e($custom_field->id); ?>][value]"<?php echo e(isset($custom_field->required) ? ' required' : ''); ?> value="<?php echo e($custom_field->default); ?>">
                    </div>
                        <?php elseif($custom_field->type === 'text'): ?>
                    <div class="field">
                        <label><?php echo e($custom_field->label); ?></label>
                        <input type="text" name="custom_fields[C<?php echo e($policy->client->company->id); ?>F<?php echo e($custom_field->id); ?>][value]"<?php echo e(isset($custom_field->required) ? ' required' : ''); ?> value="<?php echo e($custom_field->value); ?>">
                    </div>
                        <?php else: ?>
                    <div class="field">
                        <label><?php echo e($custom_field->label); ?></label>
                        <textarea name="custom_fields[C<?php echo e($policy->client->company->id); ?>F<?php echo e($custom_field->id); ?>][value]"<?php echo e(isset($custom_field->required) ? ' required' : ''); ?> rows="2"><?php echo e($custom_field->default); ?></textarea>
                    </div>
                        <?php endif; ?>
                    <?php endforeach; ?>
                </div>
            </form>
        </div>
        <div class="actions">
            <div class="ui buttons">
                <button class="ui cancel button"><?php echo e(trans('policies.modal.button.cancel.edit')); ?></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.edit')); ?></button>
            </div>
        </div>
    </div>
<?php $__env->stopSection(); ?>

<?php $__env->startSection('extra_scripts'); ?>
    <script type="text/javascript">
        (function($insura, $) {
            $(document).ready(function() {
                $insura.helpers.initModal('div#newPaymentModal', true);
                $insura.helpers.initModal('div#editPolicyModal', false);
                $insura.helpers.initSwal('form a.delete', {
                    confirmButtonText: '<?php echo e(trans('policies.swal.warning.delete.confirm')); ?>',
                    text: '<?php echo e(trans('policies.swal.warning.delete.text')); ?>',
                    title: '<?php echo e(trans('policies.swal.warning.delete.title')); ?>'
                });
            });
        })(window.insura, window.jQuery);
    </script>
<?php $__env->stopSection(); ?>

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