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

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

<?php $__env->startSection('profile_bar'); ?>
        <div class="ui segment white right-bar-profile">
            <!-- client profile -->
            <div class="user-profile m-b-15">
                <?php if($recipient->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($recipient->first_name[0] . $recipient->last_name[0])); ?></div>
                <?php else: ?>
                <img src="<?php echo e(asset('uploads/images/users/' . $recipient->profile_image_filename)); ?>" alt="<?php echo e($recipient->first_name . ' ' . $recipient->last_name); ?>"/>
                <?php endif; ?>
                <h3><?php echo e($recipient->first_name . ' ' . $recipient->last_name); ?></h3>
                <span>
                    <?php if($recipient->status): ?>
                    <i class="ion-ios-circle-filled text-success"></i> <?php echo e(trans('communication.status.active', array(
                        'role'  => studly_case($recipient->role),
                    ))); ?>

                    <?php else: ?>
                    <i class="ion-ios-circle-filled text-danger"></i> <?php echo e(trans('communication.status.inactive', array(
                        'role'  => studly_case($recipient->role),
                    ))); ?>

                    <?php endif; ?>
                </span>
                <div class="m-t-25">
                    <?php if(in_array($user->role, array('super', 'admin')) && in_array($recipient->role, array('broker', 'client', 'staff'))): ?>
                    <a class="ui button positive" href="<?php echo e(action(studly_case($recipient->role) . 'Controller@getOne', array($recipient->id))); ?>"><i class="user outline icon"></i> <?php echo e(trans('communication.button.profile')); ?> </a>
                    <?php endif; ?>
                </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('communication.label.email')); ?></span>
                            <p><?php echo e($recipient->email); ?></p>
                        </div>
                        <div>
                            <span><?php echo e(trans('communication.label.phone')); ?></span>
                            <p><?php echo e(isset($recipient->phone) ? $recipient->phone : '(---) ---- --- ---'); ?></p>
                        </div>
                        <div>
                            <span><?php echo e(trans('communication.label.birthday')); ?></span>
                            <p><?php echo e(is_null($recipient->birthday) ? '---------- --, ----' : date('jS F Y', strtotime($recipient->birthday))); ?></p>
                        </div>
                        <div>
                            <span><?php echo e(trans('communication.label.address')); ?></span>
                            <p><?php echo e(isset($recipient->address) ? $recipient->address : '. . .'); ?></p>
                        </div>
                    </div>
                    <!-- end client details -->
                </div>
            </div>
        </div>
<?php $__env->stopSection(); ?>

<?php $__env->startSection('content'); ?>
        @parent
        <div class="half-page-content">
            <?php echo $__env->make('global.status', array_except(get_defined_vars(), array('__data', '__path')))->render(); ?>
            <!-- Policy details -->
            <div class="ui segment white fs-16">
                <div class="segment-header">
                    <h3><?php echo e(trans('communication.table.title.texts', array(
                            'name'  => $recipient->first_name
                        ))); ?></h3>
                    <button class="ui right floated button successish m-w-140" data-target="#newTextModal" data-toggle="modal"<?php echo e(is_null($user->company->text_provider) || is_null($recipient->phone) ? ' disabled' : ''); ?>><?php echo e(trans('communication.button.text')); ?></button>
                </div>
                <div class="sms-list">
                    <?php $__empty_1 = true; foreach($texts as $text): $__empty_1 = false; ?>
                    <div class="sms-item text-<?php echo e($text->status ? 'success' : 'danger'); ?>">
                        <h4><?php echo e(trans('communication.table.header.from')); ?>: <span><?php echo e($text->sender->phone); ?> - <?php echo e($text->sender->first_name); ?></span></h4>
                        <form action="<?php echo e(action('TextController@delete', array($text->id))); ?>" class="delete-sms" data-tooltip="<?php echo e(trans('communication.table.data.action.delete')); ?>" data-position="left center" method="POST">
                            <?php echo e(csrf_field()); ?>

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

                            <i class="ion-ios-close-empty icon"></i>
                        </form>
                        <p>
                            <?php echo e($text->message); ?><br/>
                            <span><?php echo e(date('F d, Y H:i', strtotime($text->created_at))); ?></span>
                        </p>
                    </div>
                    <?php endforeach; if ($__empty_1): ?>
                    <div class="sms-item">
                        <p class="text-center"><?php echo e(trans('communication.table.message.empty')); ?></p>
                    </div>
                    <?php endif; ?>
                </div>
            </div>
        </div>
<?php $__env->stopSection(); ?>

<?php $__env->startSection('modals'); ?>
    <!-- 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'  => $recipient->first_name . ' ' . $recipient->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($recipient->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>
<?php $__env->stopSection(); ?>

<?php $__env->startSection('page_scripts'); ?>
    <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() {
                $insura.helpers.initModal('div.modal', true);
                $insura.helpers.initScrollbar('div.scrollbar');
                $insura.helpers.initSwal('form i.ion-ios-close-empty', {
                    confirmButtonText: '<?php echo e(trans('communication.swal.warning.delete.confirm')); ?>',
                    text: '<?php echo e(trans('communication.swal.warning.delete.text', array(
                        'type'  => 'text / SMS'
                    ))); ?>',
                    title: '<?php echo e(trans('communication.swal.warning.delete.title')); ?>'
                });
                $insura.helpers.listenForChats();
            });
        })(window.insura, window.jQuery);
    </script>
<?php $__env->stopSection(); ?>

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