<?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">Taxes</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>PRODUCT TAXES</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 col-sm-10 col-sm-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 TAXES</button>
            </div>
        </div>
    </div>

    <!-- 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">Add New TAXES</h3>
                </div>

                <form class="form-horizontal" role="form" method="POST" action="<?php echo e(url('admin.tax.add')); ?>">
                    <?php echo e(csrf_field()); ?>


                    <div class="modal-body">

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

                            <div class="col-md-6">
                                <?php echo Form::select('locale', array('0' => 'Please Select', 'en-US' => 'English', 'bn-BD' => 'বাংলা'), null , array('id' => 'locale', 'class' => 'form-control')); ?>

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

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

                            <div class="col-md-6">
                                <input id="name" type="text" class="form-control" name="name" value="" 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('applicableOn') ? ' has-error' : ''); ?>">
                            <label for="applicableOn" class="col-md-4 control-label">Applicable On</label>

                            <div class="col-md-6">
                                <?php echo Form::select('applicable_on', array('0' => 'Please Select', 'S' => 'Sales', 'P' => 'Purchase', 'B' => 'Both'), null , array('id' => 'applicable_on', 'class' => 'form-control')); ?>

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


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

                            <div class="col-md-6">
                                <input id="rate" type="text" class="form-control" name="rate" value="" required>

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

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

                            <div class="col-md-6">
                                <?php echo Form::select('calculating_mode', array('0' => 'Please Select', 'P' => 'Purcentage', 'F' => 'Fixed'), null , array('id' => 'calculating_mode', 'class' => 'form-control')); ?>

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


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

                            <div class="col-md-6">
                                <input id="description" type="text" class="form-control" name="description" value="" required>

                                <?php if($errors->has('description')): ?>
                                    <span class="help-block">
                                        <strong><?php echo e($errors->first('description')); ?></strong>
                                    </span>
                                <?php endif; ?>
                            </div>
                        </div>
                    </div>
                    <div class="modal-footer">
                        
                            <button type="submit" class="btn btn-primary pull-right">Submit</button>
                            <button type="button" class="btn btn-danger pull-left" data-dismiss="modal">Cancel</button>
                        
                    </div>
                </form>
            </div>
        </div>
    </div>

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

    <div class="row">
        <div class="col-md-10 col-md-offset-1 col-sm-10 col-sm-offset-1" style="overflow-x:auto;">
            <table class="table table-bordered table-hover" id="users-table">
                <thead style="background-color: #b0b0b0">
                <tr>
                    <th>Code</th>
                    <th>Tax Name</th>
                    <th>Applicable On</th>
                    <th>Rate</th>
                    <th>Mode</th>
                    <th>Description</th>
                    <th>Active</th>
                    <th>Action</th>
                </tr>
                </thead>
            </table>
        </div>
    </div>

    <div class="row">
        <div class="col-md-10 col-md-offset-1 col-sm-10 col-sm-offset-1" style="overflow-x:auto;">
            <p>Applicable On : S = Sales; P = Purchase; B = Both</p>
            <p style="text-align: left">Calculating Mode: P = Percentage; F = Fixed </p>
        </div>
    </div>

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

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

<script>
    $(function() {
        var table= $('#users-table').DataTable({
            processing: true,
            serverSide: true,
            autoWidth: false,
            responsive: true,
            ajax: 'admin.tax.data',
            columns: [
                { data: 'id', name: 'id' },
                { data: 'name', name: 'name' },
                { data: 'applicable_on', name: 'applicable_on' },
                { data: 'rate', name: 'rate' },
                { data: 'calculating_mode', name: 'calculating_mode' },
                { data: 'description', name: 'description' },
                { data: 'status', name: 'status',orderable: false, searchable: false, printable: false},
                { data: 'action', name: 'action', orderable: false, searchable: false, printable: false}
            ]
        });
    });

    $('#users-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) {
            $('#users-table').DataTable().draw(false);
        });
    });

    $('#users-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(); ?>