<?php $__env->startSection('title'); ?>
    <title>Application Users</title>
<?php $__env->stopSection(); ?>
<?php $__env->startSection('banner'); ?>
    <?php echo $__env->make('backend.partials.banner', array_except(get_defined_vars(), array('__data', '__path')))->render(); ?>
<?php $__env->stopSection(); ?>

<?php $__env->startSection('menu'); ?>
    <div class="col-md-10 col-md-offset-1" style="background-color: #7ebb7b">
        <div class="breadcrumbs">
            <div class="container">
                <div class="row">
                    <div class="col-sm-8">
                        <ul>
                            <li><a href="<?php echo url('admin/home'); ?>">Home</a></li>
                            <li class="active">Customers</li>
                        </ul><!-- end breadcrumb -->
                    </div><!-- end col -->
                </div><!-- end row -->
            </div><!-- end container -->
        </div><!-- end breadcrumbs -->
    </div>
<?php $__env->stopSection(); ?>

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

    <meta name="csrf-token" content="<?php echo e(csrf_token()); ?>">

    
    
    
    
    


    <div>

        <div class="container spark-screen">
            <div class="row">
                <div class="col-md-4 col-md-offset-4 col-sm-4 text-center">
                    <br/>
                    <div><h3>CREDIT CUSTOMERS</h3></div>
                    <div style="background-color: #ff0000;height: 2px">&nbsp;</div>
                    <br/>
                </div>

            </div>
        </div>
    </div>

    <div class="row">
        <div class="col-md-10 col-md-offset-1">
            
            <div class="pull-left">
                <input type="hidden" name="addData" id="addData" value=<?php echo 1; ?>>
                
                
                <button type="button" class="btn btn-new btn-success"><i class="glyphicon glyphicon-plus"></i>New</button>
            </div>
        </div>
    </div>

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

    <!-- Create Item Modal -->

    <div class="modal fade" id="modal-register" tabindex="-1" role="dialog" data-backdrop="false" aria-labelledby="modal-register-label" aria-hidden="true">
        <div class="modal-dialog">
            <div class="modal-content">

                <div class="modal-header">
                    <h3 class="modal-title" id="modal-register-label">New Customer</h3>
                </div>
                <form class="form-horizontal" role="form" method="POST" action="<?php echo e(url('customers.data.new')); ?>">
                    <?php echo e(csrf_field()); ?>

                    <div class="modal-body">

                        <legend style="font-size: large;"><b> Company Details : </b><span style="font-size: medium">basic information on this company</span> </legend>

                        <div class="form-group<?php echo e($errors->has('name') ? ' has-error' : ''); ?>">
                            <label for="name" class="col-md-4 control-label">Company Name</label>
                            <div class="col-md-6">
                                <?php echo Form::text('name', null, array('id' => 'name', 'class' => 'form-control','required','autofocus')); ?>

                                <?php if($errors->has('name')): ?>
                                    <span class="help-block">
                                        <strong><?php echo e($errors->first('name')); ?></strong>
                                    </span>
                                <?php endif; ?>
                            </div>
                        </div>

                        
                        

                        
                        
                        
                        
                        
                        
                        
                        
                        

                        
                        
                        
                        
                        
                        
                        
                        
                        
                        
                        

                        <div class="form-group<?php echo e($errors->has('tax_number') ? ' has-error' : ''); ?>">
                            <label for="tax_number" class="col-md-4 control-label">Company Tax Number</label>
                            <div class="col-md-6">
                                <?php echo Form::text('tax_number', null, array('id' => 'tax_number', 'class' => 'form-control')); ?>

                                <?php if($errors->has('tax_number')): ?>
                                    <span class="help-block">
                                        <strong><?php echo e($errors->first('tax_number')); ?></strong>
                                    </span>
                                <?php endif; ?>
                            </div>
                        </div>

                        <div class="form-group<?php echo e($errors->has('glcode') ? ' has-error' : ''); ?>">
                            <label for="glcode" class="col-md-4 control-label">Company GL Code</label>
                            <div class="col-md-6">
                                <?php echo Form::text('glcode', null, array('id' => 'glcode', 'class' => 'form-control')); ?>

                                <?php if($errors->has('glcode')): ?>
                                    <span class="help-block">
                                        <strong><?php echo e($errors->first('glcode')); ?></strong>
                                    </span>
                                <?php endif; ?>
                            </div>
                        </div>

                        <div class="form-group<?php echo e($errors->has('phone_number') ? ' has-error' : ''); ?>">
                            <label for="phone_number" class="col-md-4 control-label">Company Phone Number</label>
                            <div class="col-md-6">
                                <?php echo Form::text('phone_number', null, array('id' => 'phone_number', 'class' => 'form-control')); ?>

                                <?php if($errors->has('phone_number')): ?>
                                    <span class="help-block">
                                        <strong><?php echo e($errors->first('phone_number')); ?></strong>
                                    </span>
                                <?php endif; ?>
                            </div>
                        </div>

                        <div class="form-group<?php echo e($errors->has('website') ? ' has-error' : ''); ?>">
                            <label for="website" class="col-md-4 control-label">Company Website</label>
                            <div class="col-md-6">
                                <?php echo Form::text('website', null, array('id' => 'website', 'class' => 'form-control')); ?>

                                <?php if($errors->has('website')): ?>
                                    <span class="help-block">
                                        <strong><?php echo e($errors->first('website')); ?></strong>
                                    </span>
                                <?php endif; ?>
                            </div>
                        </div>

                        <div class="form-group<?php echo e($errors->has('email') ? ' has-error' : ''); ?>">
                            <label for="email" class="col-md-4 control-label">Company Email Address</label>
                            <div class="col-md-6">
                                <?php echo Form::text('email', null, array('id' => 'email', 'class' => 'form-control')); ?>

                                <?php if($errors->has('email')): ?>
                                    <span class="help-block">
                                        <strong><?php echo e($errors->first('email')); ?></strong>
                                    </span>
                                <?php endif; ?>
                            </div>
                        </div>

                        
                        

                        
                        
                        
                        
                        
                        
                        
                        
                        


                        <legend style="font-size: large;"><b> Company Address : </b><span style="font-size: medium">Add an address to this company, for use in your Sales Orders, Invoices and Purchase order</span> </legend>

                        <div class="form-group<?php echo e($errors->has('street') ? ' has-error' : ''); ?>">
                            <label for="street" class="col-md-4 control-label">Street</label>
                            <div class="col-md-6">
                                <?php echo Form::text('street', null, array('id' => 'street', 'class' => 'form-control')); ?>

                                <?php if($errors->has('street')): ?>
                                    <span class="help-block">
                                        <strong><?php echo e($errors->first('street')); ?></strong>
                                    </span>
                                <?php endif; ?>
                            </div>
                        </div>

                        <div class="form-group<?php echo e($errors->has('address') ? ' has-error' : ''); ?>">
                            <label for="address" class="col-md-4 control-label">Address</label>
                            <div class="col-md-6">
                                <?php echo Form::text('address', null, array('id' => 'address', 'class' => 'form-control')); ?>

                                <?php if($errors->has('address')): ?>
                                    <span class="help-block">
                                        <strong><?php echo e($errors->first('address')); ?></strong>
                                    </span>
                                <?php endif; ?>
                            </div>
                        </div>

                        <div class="form-group<?php echo e($errors->has('city') ? ' has-error' : ''); ?>">
                            <label for="city" class="col-md-4 control-label">City</label>
                            <div class="col-md-6">
                                <?php echo Form::text('city', null, array('id' => 'city', 'class' => 'form-control')); ?>

                                <?php if($errors->has('city')): ?>
                                    <span class="help-block">
                                        <strong><?php echo e($errors->first('city')); ?></strong>
                                    </span>
                                <?php endif; ?>
                            </div>
                        </div>

                        <div class="form-group<?php echo e($errors->has('state') ? ' has-error' : ''); ?>">
                            <label for="city" class="col-md-4 control-label">State</label>
                            <div class="col-md-6">
                                <?php echo Form::text('state', null, array('id' => 'state', 'class' => 'form-control')); ?>

                                <?php if($errors->has('state')): ?>
                                    <span class="help-block">
                                        <strong><?php echo e($errors->first('state')); ?></strong>
                                    </span>
                                <?php endif; ?>
                            </div>
                        </div>

                        <div class="form-group<?php echo e($errors->has('zipcode') ? ' has-error' : ''); ?>">
                            <label for="zipcode" class="col-md-4 control-label">Zip Code</label>
                            <div class="col-md-6">
                                <?php echo Form::text('zipcode', null, array('id' => 'zipcode', 'class' => 'form-control')); ?>

                                <?php if($errors->has('zipcode')): ?>
                                    <span class="help-block">
                                        <strong><?php echo e($errors->first('zipcode')); ?></strong>
                                    </span>
                                <?php endif; ?>
                            </div>
                        </div>

                        <div class="form-group<?php echo e($errors->has('country') ? ' has-error' : ''); ?>">
                            <label for="country" class="col-md-4 control-label">Country</label>

                            <div class="col-md-6">
                                <?php echo Form::select('country', $countries , null , array('id' => 'type', 'class' => 'form-control', 'placeholder'=>'Please Select')); ?>

                                <?php if($errors->has('country')): ?>
                                    <span class="help-block">
                                        <strong><?php echo e($errors->first('country')); ?></strong>
                                    </span>
                                <?php endif; ?>
                            </div>
                        </div>

                    </div>
                    <div class="modal-footer">
                        <button type="submit" class="btn btn-primary">Save</button>
                        <button type="submit" class="btn btn-default pull-left" data-dismiss="modal">Close</button>
                    </div>
                </form>
            </div>



        </div>
    </div>



    <div class="row">
        <div class="col-md-10 col-md-offset-1" style="overflow-x:auto;">
            <table class="table table-bordered table-hover" id="categories-table">
                <thead style="background-color: #b0b0b0">
                <tr>
                    <th>Id</th>
                    <th>Name</th>
                    
                    <th>Street </th>
                    <th>Address </th>
                    <th>Phone No</th>
                    <th>Status</th>
                    <th>Action</th>
                </tr>
                </thead>
            </table>
        </div>
    </div>

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

<?php $__env->startPush('scripts'); ?>

<script>
    $(function() {
        var table= $('#categories-table').DataTable({
            processing: true,
            serverSide: true,
            autoWidth: false,
            responsive: true,
            ajax: 'customers.data.get',
            columns: [
                { data: 'id', name: 'id' },
                { data: 'name', name: 'name' },
//                { data: 'type', name: 'type' },
                { data: 'street', name: 'street' },
                { data: 'address', name: 'address' },
                { data: 'phone_number', name: 'phone_number' },
                { data: 'status', name: 'status', orderable: false, searchable: false, printable: false},
                { data: 'action', name: 'action', orderable: false, searchable: false, printable: false}
            ]
        });
    });

    $('#categories-table').on('click', '.btn-delete[data-remote]', function (e) {
        e.preventDefault();

        if(document.getElementById('deleteData').value == 0)
        {
            alert('You Do Not Have Permission. Please Contact Administrator')
            return false
        }

        $.ajaxSetup({
            headers: {
                'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
            }
        });
        var url = $(this).data('remote');
        // confirm then
        $.ajax({
            url: url,
            type: 'DELETE',
            dataType: 'json',
            data: {method: '_DELETE', submit: true},

            error: function (request, status, error) {
                alert(request.responseText);
            }

        }).always(function (data) {
            $('#categories-table').DataTable().draw(false);
        });
    });

    $('#categories-table').on('click', '.btn-edit', function (e) {
        e.preventDefault();

        if(document.getElementById('editData').value == 0)
        {
            alert('You Do Not Have Edit Permission. Please Contact Administrator')
            return false
        }
    });

    $(document).ready ( function () {
        //replace document below with enclosing container but below will work too
        $(document).on('click', '.btn-new', function () {
            if(document.getElementById('addData').value == 1)
            {
                $("#modal-register").modal()
            }else {
                alert('You Do Not Have Permission. Please Contact Administrator')
                return false
            }
        });
    });


</script>

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


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