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

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

<?php $__env->startSection('action_buttons'); ?>
            <div class="ui right floated segment transparent page-actions">
                <button class="ui labeled icon button primary open-modal" data-target="#newProductModal" data-toggle="modal">
                    <i class="ion-ios-plus-outline icon"></i> 
                    <?php echo e(trans('products.button.new')); ?> 
                </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>#</th>
                        <th><?php echo e(trans('products.table.header.name')); ?></th>
                        <th><?php echo e(trans('products.table.header.insurer')); ?></th>
                        <th><?php echo e(trans('products.table.header.category')); ?></th>
                        <th><?php echo e(trans('products.table.header.sub_category')); ?></th>
                        <th class="center aligned"><?php echo e(trans('products.table.header.policies')); ?></th>
                        <th class="center aligned"><?php echo e(trans('products.table.header.actions')); ?></th>
                    </tr>
                </thead>
                <tbody>
                    <?php $__empty_1 = true; foreach($products as $key => $product): $__empty_1 = false; ?>
                    <tr>
                        <td><?php echo e($products->lastOnPreviousPage + $key + 1); ?></td>
                        <td><?php echo e($product->name); ?></td>
                        <td><?php echo e($product->insurer); ?></td>
                        <td><?php echo e($product->category); ?> </td>
                        <td><?php echo e($product->sub_category); ?></td>
                        <td class="center aligned"><?php echo e($product->policies->count()); ?></td>
                        <td class="center aligned">
                            <a href="#" class="green label mini ui" data-target="#editProduct<?php echo e($product->id); ?>Modal" data-toggle="modal"> <?php echo e(trans('products.button.edit')); ?> </a>
                            <form action="<?php echo e(action('ProductController@delete', array($product->id))); ?>" method="POST" style="display:inline;">
                                <?php echo e(csrf_field()); ?>

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

                                <button class="delete label mini red ui" style="cursor:pointer;" type="submit"><?php echo e(trans('products.button.delete')); ?></button>
                            </form>
                        </td>
                    </tr>
                    <?php endforeach; if ($__empty_1): ?>
                    <tr>
                        <td colspan="7" style="text-align:center;"><?php echo e(trans('products.table.data.not_available')); ?></td>
                    </tr>
                <?php endif; ?>
                </tbody>  
                <tfoot>
                    <tr>
                        <th class="center aligned ui" colspan="2">
                            <?php echo e(trans('products.table.data.pagination', array(
                                'start' => $products->total() > 0 ? $products->lastOnPreviousPage + 1 : 0,
                                'stop'  => $products->lastOnPreviousPage + $products->count(),
                                'total' => $products->total()
                            ))); ?>

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

                        </th>
                    </tr>
                </tfoot>
            </table>
        </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.initDropdown('div.dropdown, select.dropdown');
                $insura.helpers.initModal('div#newProductModal', true);
                $insura.helpers.initModal('div[id^="editProduct"]', false);
                $insura.helpers.initScrollbar('div.scrollbar');
                $insura.helpers.initSwal('form button.delete', {
                    confirmButtonText: '<?php echo e(trans('products.swal.warning.delete.confirm')); ?>',
                    text: '<?php echo e(trans('products.swal.warning.delete.text')); ?>',
                    title: '<?php echo e(trans('products.swal.warning.delete.title')); ?>'
                });
                $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(); ?>