<?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.email')); ?></p>
            <form action="<?php echo e(action('EmailController@add')); ?>" method="POST">
                <?php echo e(csrf_field()); ?>

                <div class="ui form">
                    <div class="field required">
                        <label><?php echo e(trans('communication.input.label.recipients')); ?></label>
                        <select name="recipient" class="ui fluid search dropdown" required>
                            <option value=""><?php echo e(trans('communication.input.option.default')); ?></option>
                            <?php if($user->company->brokers->count() > 0): ?>
                            <option<?php echo e(old('recipient') === 'brokers' ? ' selected' : ''); ?> value="brokers"><?php echo e(trans('communication.input.option.brokers')); ?></option>
                            <?php endif; ?>
                            <?php if($user->company->clients->count() > 0): ?>
                            <option<?php echo e(old('recipient') === 'clients' ? ' selected' : ''); ?> value="clients"><?php echo e(trans('communication.input.option.clients')); ?></option>
                            <?php endif; ?>
                            <?php if($user->company->staff->count() > 0): ?>
                            <option<?php echo e(old('recipient') === 'staff' ? ' selected' : ''); ?> value="staff"><?php echo e(trans('communication.input.option.staff')); ?></option>
                            <?php endif; ?>
                            <?php $__empty_1 = true; foreach($user->company->users->keyBy('id')->except($user->id) as $company_user): $__empty_1 = false; ?>
                            <option<?php echo e(old('recipient') == $company_user->id ? ' selected' : ''); ?> value="<?php echo e($company_user->id); ?>"><?php echo e($company_user->first_name . ' ' . $company_user->last_name); ?> - <?php echo e(studly_case($company_user->role)); ?></option>
                            <?php endforeach; if ($__empty_1): ?>
                            <option value=""><?php echo e(trans('communication.input.option.empty', array(
                                'company_name'  => $user->company->name
                            ))); ?></option>
                            <?php endif; ?>
                        </select>
                    </div>
                    <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.text')); ?></p>
            <form action="<?php echo e(action('TextController@add')); ?>" method="POST">
                <?php echo e(csrf_field()); ?>

                <div class="ui form">
                    <div class="field required">
                        <label><?php echo e(trans('communication.input.label.recipients')); ?></label>
                        <select name="recipient" class="ui fluid search dropdown" required>
                            <option value=""><?php echo e(trans('communication.input.option.default')); ?></option>
                            <?php if($user->company->brokers->count() > 0): ?>
                            <option<?php echo e(old('recipient') === 'brokers' ? ' selected' : ''); ?> value="brokers"><?php echo e(trans('communication.input.option.brokers')); ?></option>
                            <?php endif; ?>
                            <?php if($user->company->clients->count() > 0): ?>
                            <option<?php echo e(old('recipient') === 'clients' ? ' selected' : ''); ?> value="clients"><?php echo e(trans('communication.input.option.clients')); ?></option>
                            <?php endif; ?>
                            <?php if($user->company->staff->count() > 0): ?>
                            <option<?php echo e(old('recipient') === 'staff' ? ' selected' : ''); ?> value="staff"><?php echo e(trans('communication.input.option.staff')); ?></option>
                            <?php endif; ?>
                            <?php $__empty_1 = true; foreach($user->company->users->keyBy('id')->except($user->id) as $company_user): $__empty_1 = false; ?>
                            <option<?php echo e(old('recipient') == $company_user->id ? ' selected' : ''); ?> value="<?php echo e($company_user->id); ?>"><?php echo e($company_user->first_name . ' ' . $company_user->last_name); ?> - <?php echo e(studly_case($company_user->role)); ?></option>
                            <?php endforeach; if ($__empty_1): ?>
                            <option value=""><?php echo e(trans('communication.input.option.empty', array(
                                'company_name'  => $user->company->name
                            ))); ?></option>
                            <?php endif; ?>
                        </select>
                    </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>
<?php $__env->stopSection(); ?>

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