@extends('Layout.Payslipmaster')

@section('title', 'Create a range')

@section('content')

    <section id="content">
        <form method="POST" role="form" class="vbox form-horizontal clearfix">
            {{ csrf_field() }}
            <section class="scrollable padder">
                <ul class="breadcrumb no-border no-radius b-b b-light pull-in">
                    <li><a href="."><i class="fa fa-home"></i>Home</a></li>
                    <li><a href="/ranges">Range manager</a></li>
                    <li>View a range</li>
                </ul>
                <section class="panel panel-default col-md-offset-4 col-md-4 no-padder" style="margin-right:30px;">
                    <header class="panel-heading font-semibold">
                        Range preview
                    </header>
                    <div class="panel-body range-preview clearfix">
                        @include('Layout.errors')
                        <div class="col-md-12">
                            <h3 style="margin-top:0;"><b>{{ $results->range_name }}</b></h3>
                            <h5 style="margin:20px 0;"><b>Category:</b>&emsp;
                                @if ($results->payroll_item == 1)
                                    Allowances
                                @elseif ($results->payroll_item == 2)
                                    Deductions
                                @endif
                            </h5>
                        </div>

                        <div class="range-title clearfix">
                            <div class="col-md-4"><b>Lower Limit</b></div>
                            <div class="col-md-4"><b>Upper Limit</b></div>
                            <div class="col-md-4"><b>Rate</b></div>
                        </div>
                        @foreach($range_config as $config)
                            <div class="range-item clearfix">
                                <div class="col-md-4">{{ $config->lower_limit }}</div>
                                <div class="col-md-4">{{ $config->upper_limit }}</div>
                                <div class="col-md-4">{{ $config->rate }}</div>
                            </div>
                        @endforeach
                        <div class="col-md-12" style="margin-top:10px;">
                            <div class="pull-right">
                                <a href="/ranges"  class="btn btn-default"><i class="fa fa-close"></i>Close</a>
                            </div>
                        </div>
                    </div>
                </section>
            </section>
            <a href="#" class="hide nav-off-screen-block" data-toggle="class:nav-off-screen, open" data-target="#nav,html"></a>
        </form>
    </section>

@endsection

@section('footer-include')
    <!-- fuelux -->
    <script src="/js/libs/underscore-min.js"></script>
    <script src="/js/fuelux/fuelux.js"></script>
    {{--<script src="js/fuelux/demo.datagrid.js"></script>--}}
    <!-- select2 -->
    <script src="/js/select2/select2.min.js"></script>
@endsection

@section('j-script')
    <!-- Jquery -->
    <script>
        $(document).on('ready', function(){
            $('.new-range').last().on('click', function(){
                let newRange = "" +
                    "<div class=\"range-class\">\n" +
                    "    <div class=\"col-md-4\">\n" +
                    "        <label class=\"control-label\">Lower limit</label>\n" +
                    "        <input type=\"number\" class=\"form-control {{ ($errors->has('range-lower-limit[]'))?'input-danger':'' }}\" name=\"range-lower-limit[]\" min=\"0\">\n" +
                    "    </div>\n" +
                    "    <div class=\"col-md-4\">\n" +
                    "        <label class=\"control-label\">Upper limit</label>\n" +
                    "        <input type=\"number\" class=\"form-control {{ ($errors->has('range-upper-limit[]'))?'input-danger':'' }}\" name=\"range-upper-limit[]\" min=\"0\">\n" +
                    "    </div>\n" +
                    "    <div class=\"col-md-4\">\n" +
                    "        <label class=\"control-label\">Rate/Amount</label>\n" +
                    "        <input type=\"number\" class=\"form-control {{ ($errors->has('range-rate[]'))?'input-danger':'' }}\" name=\"range-rate[]\" min=\"0\">\n" +
                    "    </div>\n" +
                    "</div>";
                $('.range-class-action-bar').before(newRange);
            });
        });
    </script>
@endsection