 
<?php $__env->startSection('content'); ?>
<div class="row">
    <div class="col-lg-12">
        <h1 class="page-header">Customers</h1>
    </div>
</div>

<div class="row">
    <div class="col-lg-12">
        <div class="panel panel-default">
            <?php if(session('status')): ?>
            <div class="alert alert-success">
                <?php echo e(session('status')); ?>

            </div>
            <?php endif; ?>

            <?php if(count($errors) > 0): ?>
            <div class="alert alert-danger">
                <strong>Whoops!</strong> There were some problems with your input.<br><br>
                <ul>
                    <?php foreach($errors->all() as $error): ?>
                    <li><?php echo e($error); ?></li>
                    <?php endforeach; ?>
                </ul>
            </div>
            <?php endif; ?>
            <div class="panel-heading">
                Customers 	
                <a href="<?php echo e(url('uadmin/customers/add')); ?>"> <i class="fa fa-plus fa-fw" style="float: right; padding-left: 10px;" title="Add Customer"></i></a>
                <?php /* <a href="" data-toggle="modal" data-target="#importCustomersModal"> <i class="fa fa-upload fa-fw" style="float: right;" title="Import Customers"></i></a> */ ?>
            </div>
            <!-- /.panel-heading -->
            <div class="panel-body">
                <div class="dataTable_wrapper">
                    <table class="table table-striped table-bordered table-hover display nowrap" width="100%" id="dataTables-example2">
                        <thead>
                            <tr>
                                <th data-priority="1">Name</th>
                                <th>Phone Number</th>
                                <th>Main Address</th>
                                <th>Circuits</th>
                                <th data-priority="2">Action</th>
                            </tr>
                        </thead>
                        <tbody>
                            <?php $count = 0; ?>
                            <?php foreach($customers as $customer): ?>
                            <?php if($customer->status==1): ?>
                            <?php $count++; ?>
                            <?php if($count % 2 == 1): ?>
                            <tr class="odd">
                            <?php else: ?>
                            <tr class="even">
                            <?php endif; ?>
                                <td>
                                    <a href='<?php echo e(url('uadmin/customers/edit/'.$customer->id)); ?>'><?php echo e($customer->company_name); ?>

                                    </a>
                                </td>
                                <td>
                                    <?php if($customer->directory_phone): ?>
                                    <?php echo e($customer->directory_phone); ?>

                                    <?php else: ?>
                                    --
                                    <?php endif; ?>
                                </td>
                                <td>
                                    <?php if($customer->directory_address): ?>
                                    <?php echo e($customer->directory_address.', '.$customer->directory_city.', '.$customer->directory_state.' '.$customer->directory_zip); ?>

                                    <?php elseif($customer->directory_city): ?>
                                    <?php echo e($customer->directory_city); ?>

                                    <?php elseif(count($customer->locations)>0): ?>
                                    Multiple Locations
                                    <?php else: ?>
                                    --
                                    <?php endif; ?>
                                </td>
                                <td>
                                    <?php if($customer->circuits): ?>
                                    <?php echo e($customer->circuits); ?>

                                    <?php else: ?>
                                    --
                                    <?php endif; ?>
                                </td>
                                <td style="text-align: center;">
                                    <a href='<?php echo e(url('uadmin/customers/edit/'.$customer->id)); ?>'>
                                        <i class="fa fa-edit fa-fw" style="text-align: left;"></i>
                                    </a>
                                    &nbsp
                                    <form style="display: inline;" role="form" method="POST" action="<?php echo e(url('admin/customers/delete')); ?>" 
                                        onsubmit="return confirm('Are you sure you want to remove customer (<?php echo e($customer->company_name); ?>)? \nThis will erase all tickets associated with it.')">
                                        <input type="hidden" name="_token" value="<?php echo e(csrf_token()); ?>">
                                        <input type="hidden" name="customer_id" value="<?php echo e($customer->id); ?>">
                                        <button type="submit" style="border: none; background: none; padding: 0;">
                                            <i class="fa fa-trash-o fa-fw" style="text-align: right;"></i>
                                        </button>
                                    </form>
                                </td>
                            </tr>
                            <?php endif; ?>
                            <?php endforeach; ?>
                        </tbody>
                    </table>
                </div>
            </div>
        </div>
    </div>
</div>

<!-- Import Customers Modal -->
<div id="importCustomersModal" class="modal fade" role="dialog">
    <div class="modal-dialog">
        <!-- Modal content-->
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal">&times;</button>
                <h4 class="modal-title">Import Customers</h4>
            </div>
            <form id="theForm" class="form-horizontal" style="margin-bottom: 0px;" role="form" method="POST" enctype="multipart/form-data" action="<?php echo e(url('admin/customers/import')); ?>">
                <div class="modal-body">
                    <input type="hidden" name="_token" value="<?php echo e(csrf_token()); ?>">

                    <div class="form-group">
                        <div class="col-sm-12 morePadding morePadding2">
                            <input type="file" class="form-control" id="attachment" name="attachment" title="Attachment">
                        </div>
                    </div>
                </div>
                <div class="modal-footer">
                    <button type="submit" class="btn btn-primary" style="float: right;">
                        Import
                    </button>
                </div>
            </form>
        </div>
    </div>
</div>

<?php $__env->stopSection(); ?>

<?php $__env->startSection('extras'); ?>
	<!-- DataTables CSS -->
    <link rel="stylesheet" type="text/css" href="https://cdn.datatables.net/t/bs/pdfmake-0.1.18,dt-1.10.11,b-1.1.2,b-flash-1.1.2,b-html5-1.1.2,b-print-1.1.2/datatables.min.css"/>
    
    <!-- DataTables Responsiveness CSS -->
    <link rel="stylesheet" type="text/css" href="https://cdn.datatables.net/responsive/2.2.3/css/responsive.dataTables.min.css"/>

    <style>
    	a:hover{
    		text-decoration: none;
    	}
    	.odd .subBack {
    		background-color: #f0fcff;
    	}
    	.even .subBack {
    		background-color: #ecf7fa;
    	}
    	.floatLeft
    	{
    		float: left;
    	}

        .dtr-data{
            display: block;
        }

    </style>

    <style>
    /* Always set the map height explicitly to define the size of the div
    * element that contains the map. */
    #map {
        height: 500px;
        width: 100%;
    }

    @media (min-width: 650px)
    {
        .map-window {
            max-width: 500px;
        }
    }

    @media (max-width: 650px)
    {
        .map-window {
            max-width: 250px;
        }
    }
    </style>
<?php $__env->stopSection(); ?>

<?php $__env->startSection('bottom'); ?>

    <!-- DataTables JavaScript -->
	<script type="text/javascript" src="https://cdn.datatables.net/t/bs/pdfmake-0.1.18,dt-1.10.11,b-1.1.2,b-flash-1.1.2,b-html5-1.1.2,b-print-1.1.2/datatables.min.js"></script>
     
    <!-- DataTables Responsiveness JavaScript -->
    <script type="text/javascript" src="https://cdn.datatables.net/responsive/2.2.3/js/dataTables.responsive.min.js"></script>

    <!-- Page-Level Demo Scripts - Tables - Use for reference -->
    <script>
    $(document).ready(function() {
    var table1 =    $('#dataTables-example2').dataTable( {
					"pageLength": 50,
					"order": [ 0, 'asc' ],
					"stateSave" : false,
					"scrollX" : window.innerWidth < 800 ? true : false,
                    "responsive": true
        } );  
    });
    
    var customers = (<?php echo json_encode($customers); ?>);

    if ( typeof $.fn.dataTable == "function" && typeof $.fn.dataTableExt.fnVersionCheck == "function" && $.fn.dataTableExt.fnVersionCheck('1.9.2')/*older versions should work too*/ )
    {
        $.fn.dataTableExt.oApi.clearSearch = function ( oSettings )
        {
            var table = this;
             
            //no image file needed, css embedding must be supported by browser
            var clearSearch = $('<i class="fa fa-times-circle-o fa-fw" style="vertical-align:text-bottom;cursor:pointer;color: gray;"></i>');
            $(clearSearch).click( function ()
                    {
                          table.fnFilter('');
                    });
            $(oSettings.nTableWrapper).find('div.dataTables_filter').append(clearSearch);
            $(oSettings.nTableWrapper).find('div.dataTables_filter label').css('margin-right', '-16px');//16px the image width
            $(oSettings.nTableWrapper).find('div.dataTables_filter input').css('padding-right', '16px');
        }
     
        //auto-execute, no code needs to be added
        $.fn.dataTable.models.oSettings['aoInitComplete'].push( {
            "fn": $.fn.dataTableExt.oApi.clearSearch,
            "sName": 'whatever'
        } );
    }
    </script>

<?php $__env->stopSection(); ?>

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