<?php $__env->startSection('modals'); ?>
<!-- new client modal -->
    <div class="ui tiny modal" id="newClientModal">
        <div class="header"><?php echo e(trans('clients.modal.header.new')); ?></div>
        <div class="scrolling content">
            <p><?php echo e(trans('clients.modal.instruction.new')); ?></p>
            <form action="<?php echo e(action('ClientController@add')); ?>" enctype="multipart/form-data" method="POST">
                <?php echo e(csrf_field()); ?>

                <div class="ui form">
                    <div class="two fields">
                        <div class="field required">
                            <label><?php echo e(trans('clients.input.label.first_name')); ?></label>
                            <input type="text" name="first_name" placeholder="<?php echo e(trans('clients.input.placeholder.first_name')); ?>" required value="<?php echo e(old('first_name')); ?>"/>
                        </div>
                        <div class="field">
                            <label><?php echo e(trans('clients.input.label.last_name')); ?></label>
                            <input type="text" name="last_name" placeholder="<?php echo e(trans('clients.input.placeholder.last_name')); ?>" value="<?php echo e(old('last_name')); ?>"/>
                        </div>
                    </div>
                    <div class="two fields">
                        <div class="field required">
                            <label><?php echo e(trans('clients.input.label.email')); ?></label>
                            <input type="email" name="email" placeholder="<?php echo e(trans('clients.input.placeholder.email')); ?>" required value="<?php echo e(old('email')); ?>"/>
                        </div>
                        <div class="field">
                            <label><?php echo e(trans('clients.input.label.phone')); ?></label>
                            <input type="tel" placeholder="<?php echo e(trans('clients.input.placeholder.phone')); ?>" value="<?php echo e(old('phone')); ?>"/>
                        </div>
                    </div>
                    <div class="two fields">
                        <div class="field">
                            <label><?php echo e(trans('clients.input.label.birthday')); ?></label>
                            <input type="text" class="datepicker" name="birthday" placeholder="<?php echo e(trans('clients.input.placeholder.birthday')); ?>" value="<?php echo e(old('birthday')); ?>"/>
                        </div>
                        <div class="field">
                            <label><?php echo e(trans('clients.input.label.address')); ?></label>
                            <input type="text" name="address" placeholder="<?php echo e(trans('clients.input.placeholder.address')); ?>" value="<?php echo e(old('address')); ?>"/>
                        </div>
                    </div>
                    <div class="field required">
                        <label><?php echo e(trans('clients.input.label.inviter')); ?></label>
                        <div class="ui selection dropdown">
                            <input type="hidden" name="product" value="<?php echo e(old('product_id') ?: $user->id); ?>"/>
                            <div class="default text"><?php echo e(trans('policies.input.placeholder.inviter')); ?></div>
                            <i class="dropdown icon"></i>
                            <div class="menu">
                                <div class="header">
                                    <?php echo e(trans('clients.input.option.header.company')); ?>

                                </div>
                                <div class="item<?php echo e(!empty(old('inviter_id')) && old('inviter_id') === $user->company->admin->id || empty(old('company_id')) && $user->company->admin->id === $user->id ? ' selected' : ''); ?>" data-value="<?php echo e($user->company->admin->id); ?>">
                                    <i class="building icon"></i>
                                    <?php echo e($user->company->name); ?> <?php echo e($user->company->admin->id === $user->id ? trans('clients.input.option.you') : ''); ?>

                                </div>
                                <div class="divider"></div>
                                <div class="header">
                                    <?php echo e(trans('clients.input.option.header.staff')); ?>

                                </div>
                                <?php $__empty_1 = true; foreach($user->company->staff as $staff): $__empty_1 = false; ?>
                                <div class="item<?php echo e(!empty(old('inviter_id')) && old('inviter_id') === $staff->id || empty(old('inviter_id')) && $staff->id === $user->id ? ' selected' : ''); ?>" data-value="<?php echo e($staff->id); ?>">
                                    <i class="address book icon"></i>
                                    <?php echo e($staff->first_name); ?> - <?php echo e($staff->email); ?> <?php echo e($staff->id === $user->id ? trans('clients.input.option.you') : ''); ?>

                                </div>
                                <?php endforeach; if ($__empty_1): ?>
                                <div class="disabled item" data-value="">
                                    <?php echo e(trans('clients.input.option.empty.brokers', array(
                                        'company_name'  => $user->company->name
                                    ))); ?>

                                </div>
                                <?php endif; ?>
                                <div class="divider"></div>
                                <div class="header">
                                    <?php echo e(trans('clients.input.option.header.brokers')); ?>

                                </div>
                                <?php $__empty_1 = true; foreach($user->company->brokers as $broker): $__empty_1 = false; ?>
                                <div class="item<?php echo e(!empty(old('inviter_id')) && old('inviter_id') === $broker->id || empty(old('inviter_id')) && $broker->id === $user->id ? ' selected' : ''); ?>" data-value="<?php echo e($broker->id); ?>">
                                    <i class="briefcase icon"></i>
                                    <?php echo e($broker->first_name); ?> - <?php echo e($broker->email); ?> <?php echo e($broker->id === $user->id ? trans('clients.input.option.you') : ''); ?>

                                </div>
                                <?php endforeach; if ($__empty_1): ?>
                                <div class="disabled item" data-value="">
                                    <?php echo e(trans('clients.input.option.empty.staff', array(
                                        'company_name'  => $user->company->name
                                    ))); ?>

                                </div>
                                <?php endif; ?>
                            </div>
                        </div>
                    </div>
                    <div class="divider"></div>
                    <?php foreach(collect(json_decode($user->company->custom_fields_metadata ?: '[]'))->where('model', 'client')->all() as $key => $field): ?>
                    <input type="hidden" name="custom_fields[C<?php echo e($user->company->id); ?>F<?php echo e($key); ?>][label]" value="<?php echo e($field->label); ?>"/>
                    <input type="hidden" name="custom_fields[C<?php echo e($user->company->id); ?>F<?php echo e($key); ?>][type]" value="<?php echo e($field->type); ?>"/>
                    <input type="hidden" name="custom_fields[C<?php echo e($user->company->id); ?>F<?php echo e($key); ?>][uuid]" value="<?php echo e($field->uuid); ?>"/>
                        <?php if($field->type === 'checkbox'): ?>
                    <div class="field<?php echo e(isset($field->required) ? ' required' : ''); ?>">
                        <div class="ui checkbox">
                            <input type="checkbox"<?php echo e(isset($field->default) ? ' checked' : ''); ?> name="custom_fields[C<?php echo e($user->company->id); ?>F<?php echo e($key); ?>][value]"<?php echo e(isset($field->required) ? ' required' : ''); ?>>
                            <label><?php echo e($field->label); ?></label>
                        </div>
                    </div>
                        <?php elseif($field->type === 'date'): ?>
                    <div class="field<?php echo e(isset($field->required) ? ' required' : ''); ?>">
                        <label><?php echo e($field->label); ?></label>
                        <input type="text" class="datepicker" name="custom_fields[C<?php echo e($user->company->id); ?>F<?php echo e($key); ?>][value]""<?php echo e(isset($field->required) ? ' required' : ''); ?> value="<?php echo e($field->default); ?>">
                    </div>
                        <?php elseif($field->type === 'email'): ?>
                    <div class="field<?php echo e(isset($field->required) ? ' required' : ''); ?>">
                        <label><?php echo e($field->label); ?></label>
                        <input type="email" name="custom_fields[C<?php echo e($user->company->id); ?>F<?php echo e($key); ?>][value]"<?php echo e(isset($field->required) ? ' required' : ''); ?> value="<?php echo e($field->default); ?>">
                    </div>
                        <?php elseif($field->type === 'hidden'): ?>
                    <input type="hidden" name="<?php echo e($field->label); ?>" value="<?php echo e($field->default); ?>">
                        <?php elseif($field->type === 'number'): ?>
                    <div class="field<?php echo e(isset($field->required) ? ' required' : ''); ?>">
                        <label><?php echo e($field->label); ?></label>
                        <input type="number" name="custom_fields[C<?php echo e($user->company->id); ?>F<?php echo e($key); ?>][value]""<?php echo e(isset($field->required) ? ' required' : ''); ?> value="<?php echo e($field->default); ?>">
                    </div>
                        <?php elseif($field->type === 'select'): ?>
                            <?php foreach($field->default->choices as $option): ?>
                    <input type="hidden" name="custom_fields[C<?php echo e($company->id); ?>F<?php echo e($key); ?>][value][choices][]" value="<?php echo e($option); ?>"/>
                            <?php endforeach; ?>
                            <?php if(count($field->default->choices) > 2): ?>
                    <div class="field<?php echo e(isset($field->required) ? ' required' : ''); ?>">
                        <label><?php echo e($field->label); ?></label>
                        <select class="ui fluid search dropdown" name="custom_fields[C<?php echo e($company->id); ?>F<?php echo e($key); ?>][value][choice]">
                            <option value=""><?php echo e($field->label); ?></option>
                                <?php foreach($field->default->choices as $option): ?>
                            <option<?php echo e($option === $field->default->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($field->required) ? ' required' : ''); ?>">
                        <label><?php echo e($field->label); ?></label>
                                <?php foreach($field->default->choices as $option): ?>
                        <div class="field">
                            <div class="ui radio checkbox">
                                <input type="radio"<?php echo e($option === $field->default->choice ? ' checked' : ''); ?> name="custom_fields[C<?php echo e($company->id); ?>F<?php echo e($key); ?>][value][choice]"<?php echo e(isset($field->required) ? ' required' : ''); ?> value="<?php echo e(trim($option)); ?>">
                                <label><?php echo e($option); ?></label>
                            </div>
                        </div>
                                <?php endforeach; ?>
                    </div>
                            <?php endif; ?>
                        <?php elseif($field->type === 'tel'): ?>
                    <div class="field<?php echo e(isset($field->required) ? ' required' : ''); ?>">
                        <label><?php echo e($field->label); ?></label>
                        <input type="tel" name="custom_fields[C<?php echo e($user->company->id); ?>F<?php echo e($key); ?>][value]"<?php echo e(isset($field->required) ? ' required' : ''); ?> value="<?php echo e($field->default); ?>">
                    </div>
                        <?php elseif($field->type === 'text'): ?>
                    <div class="field">
                        <label><?php echo e($field->label); ?></label>
                        <input type="tel" name="custom_fields[C<?php echo e($user->company->id); ?>F<?php echo e($key); ?>][value]"<?php echo e(isset($field->required) ? ' required' : ''); ?> value="<?php echo e($field->default); ?>">
                    </div>
                        <?php else: ?>
                    <div class="field">
                        <label><?php echo e($field->label); ?></label>
                        <textarea name="custom_fields[C<?php echo e($user->company->id); ?>F<?php echo e($key); ?>][value]"<?php echo e(isset($field->required) ? ' required' : ''); ?> rows="2"><?php echo e($field->default); ?></textarea>
                    </div>
                        <?php endif; ?>
                    <?php endforeach; ?>
                    <div class="field">
                        <label><?php echo e(trans('clients.input.label.profile_image')); ?></label>
                        <input type="file" accept="image/*" data-allowed-file-extensions="bmp gif jpeg jpg png svg" class="file-upload" data-default-file="<?php echo e(asset('uploads3/images/users/default-profile.jpg')); ?>" name="profile_image"/>
                    </div>
                </div>
            </form>
        </div>
        <div class="actions">
            <div class="ui buttons">
                <button class="ui cancel button"><?php echo e(trans('clients.modal.button.cancel.new')); ?></button>
                <div class="or" data-text="<?php echo e(trans('products.modal.button.or')); ?>"></div>
                <button class="ui positive primary button"><?php echo e(trans('clients.modal.button.confirm.new')); ?></button>
            </div>
        </div>
    </div>
<?php $__env->stopSection(); ?>
<?php echo $__env->make('templates.clients.all', array_except(get_defined_vars(), array('__data', '__path')))->render(); ?>