@extends('layouts.app')

@section('content')
<div class="container">
    <div class="row">
        <div class="col-md-12">
            <div class="card">
                <nav aria-label="breadcrumb">
                    <ol class="breadcrumb pb-3">
                      <li class="breadcrumb-item"><a href="{{ route('home') }}">Home</a></li>
                      <li class="breadcrumb-item"><a href="{{ route('laporan') }}">Laporan</a></li>
                      <li class="breadcrumb-item active" aria-current="page">Audit Customer</li>
                    </ol>
                  </nav>

                <div class="card-body text-center">
                    <div class="row form-group">
                        <div class="col-md-2">
                        </div>
                        <div class="col-md-10">
                        </div>
                    </div>

                    @if(session()->has('errormessage'))
                  <div class="alert alert-danger">
                      {{ session()->get('errormessage') }}
                  </div>
                @endif

                    <div class="container">
                        <div class="row">
                            <div class="col-md-10">
                                <form action="{{ route('laporan.auditcustomercetak') }}" method="post">
                                    @csrf
                                    <div class="input-group mb-3">
                                        <div class="input-group-prepend">
                                            <span class="input-group-text" id="basic-addon1">Mula</span>
                                        </div>
                                        <input type="text" class="form-control" placeholder="Pilih Tarikh" aria-label="Tarikh" id="datemula" name="datemula">

                                        <div class="input-group-prepend">
                                            <span class="input-group-text" id="basic-addon1">Hingga</span>
                                        </div>
                                        <input type="text" class="form-control" placeholder="Pilih Tarikh" aria-label="Tarikh" id="datehingga" name="datehingga">
                                        <input type="submit" class="btn btn-primary ml-md-5" id="submit_button" name="submit_button" value="Cetak">
                                    </div>
                                
                            </div>
                        </div>
                    </form>
                    </div>

                </div>
            </div>
        </div>
    </div>
</div>
<script type="text/javascript">

    var tablecustomers = $('#myTable').DataTable({
        "ordering": false
    });

    $(document).ready( function () {
        var today = new Date();

        $("#datemula").datepicker({
            format: 'dd-mm-yyyy',
            autoclose: true,
        }).on('changeDate', function (selected) {
            var startDate = new Date(selected.date.valueOf());
            var tempDate = new Date(selected.date.valueOf());
            var restrictDate = tempDate.setMonth(tempDate.getMonth() + 1);
            restrictDate = new Date(restrictDate);
            $('#datehingga').datepicker('setStartDate', startDate);
            $('#datehingga').datepicker('setEndDate', restrictDate);
        }).on('clearDate', function (selected) {
            $('#datehingga').datepicker('setEndDate', null);
            $('#datehingga').datepicker('setStartDate', null);
        });

        $("#datehingga").datepicker({
            format: 'dd-mm-yyyy',
            autoclose: true,
        }).on('changeDate', function (selected) {
            var endDate = new Date(selected.date.valueOf());
            var tempDate = new Date(selected.date.valueOf());
            var restrictDate = tempDate.setMonth(tempDate.getMonth() - 1);
            restrictDate = new Date(restrictDate);
            $('#datemula').datepicker('setStartDate', restrictDate);
            $('#datemula').datepicker('setEndDate', endDate);
        }).on('clearDate', function (selected) {
            $('#datemula').datepicker('setStartDate', null);
            $('#datemula').datepicker('setEndDate', null);
        });

    });
   
</script>
@endsection

