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

<?php $__env->startSection('action_buttons'); ?>
            <div class="ui right floated segment transparent page-actions">
                <button class="ui labeled icon button positive" data-target="#newTextModal" data-toggle="modal"<?php echo e(is_null($user->company->text_provider) ? ' disabled' : ''); ?>> <i class="ion-ios-plus-outline icon"></i> New SMS </button>
                <button class="ui labeled icon button primary" data-target="#newEmailModal" data-toggle="modal"> <i class="ion-email icon"></i> New Email </button>
            </div>
<?php $__env->stopSection(); ?>

<?php $__env->startSection('content'); ?>
        @parent
        <?php echo $__env->make('global.status', array_except(get_defined_vars(), array('__data', '__path')))->render(); ?>
        <div class="ui segment white">
            <table class="ui celled striped table">
                <thead>
                    <tr>
                        <th><?php echo e(trans('communication.table.header.number')); ?></th>
                        <th><?php echo e(trans('communication.table.header.name')); ?></th>
                        <th><?php echo e(trans('communication.table.header.type')); ?></th>
                        <th class="center aligned"><?php echo e(trans('communication.table.header.email')); ?></th>
                        <th class="center aligned"><?php echo e(trans('communication.table.header.text')); ?></th>
                        <th class="center aligned" colspan="2"><?php echo e(trans('communication.table.header.actions')); ?></th>
                    </tr>
                </thead>
                <tbody>
                    <?php $__empty_1 = true; foreach($contacts as $key => $contact): $__empty_1 = false; ?>
                    <tr>
                        <td><?php echo e($key + 1); ?></td>
                        <td><?php echo e($contact->first_name . ' ' . $contact->last_name); ?></td>
                        <td><?php echo e(studly_case($contact->role)); ?></td>
                        <td class="center aligned"><?php echo e($contact->incomingEmails->where('sender_id', $user->id)->count() + $user->incomingEmails->where('sender_id', $contact->id)->count()); ?></td>
                        <td class="center aligned"><?php echo e($contact->incomingTexts->where('sender_id', $user->id)->count() + $user->incomingTexts->where('sender_id', $contact->id)->count()); ?></td>
                        <td class="center aligned">
                            <a href="<?php echo e(action('EmailController@getAll', array($contact->id))); ?>" class="ui large blue label"> <?php echo e(trans('communication.table.data.action.emails')); ?> </a>
                        </td>
                        <td class="center aligned">
                            <a href="<?php echo e(action('TextController@getAll', array($contact->id))); ?>" class="ui large green label"> <?php echo e(trans('communication.table.data.action.texts')); ?> </a>
                        </td>
                    </tr>
                    <?php endforeach; if ($__empty_1): ?>
                    <tr>
                        <td class="center aligned text-center" colspan="7">
                            <?php echo e(trans('communication.table.message.empty')); ?>

                        </td>
                    </tr>
                    <?php endif; ?>
                </tbody>  
                <tfoot>
                    <tr>
                        <th class="center aligned" colspan="2">
                            <?php echo e(trans('communication.table.data.pagination.showing', array(
                                'start' => $contacts->total() > 0 ? ((($contacts->currentPage() - 1) * $contacts->count()) + 1) : 0,
                                'stop'  => $contacts->currentPage() * $contacts->count(),
                                'total' => $contacts->total()
                            ))); ?>

                        </th>
                        <th colspan="5" class="ui center aligned">
                            <?php echo $contacts->render($presenter); ?>

                        </th>
                    </tr>
                </tfoot>
            </table>
        </div>
<?php $__env->stopSection(); ?>

<?php $__env->startSection('page_scripts'); ?>
    <script type="text/javascript">
        (function($insura, $) {
            $(document).ready(function() {
                $insura.helpers.initModal('div.modal', true);
                $insura.helpers.initDropdown('div.dropdown, select.dropdown');
                $insura.helpers.listenForChats();
                $insura.helpers.requireDropdownFields('form div.required select');
            });
        })(window.insura, window.jQuery);
    </script>
<?php $__env->stopSection(); ?>

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