@extends('admin.layouts.master')

@section('title')
    Sales Report
@stop

@section('style')

    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-datetimepicker/4.17.47/css/bootstrap-datetimepicker.min.css" />

    <style>
    thead input {
        width: 100%;
    }
    .fstyle {
        text-align: center;
        width: 90%;
        padding:5px;
    }
    </style>
@stop

@section('content')
    <!-- Content Wrapper. Contains page content -->
    <div class="content-wrapper">
        <!-- Content Header (Page header) -->
        <section class="content-header">
            <h1>
                <span class="fa fa-users"></span> Sales Report
            </h1>
            <ol class="breadcrumb">
                <li><a href="#"><i class="fa fa-users"></i> Admin Panel</a></li>
                <li class="active">Sales Report</li>
            </ol>
        </section>
        <div style="margin: 20px;"></div>

        <!-- Main content -->
        <section class="content">
            {{--<div class="page-header">
                <a href="{{route('reports.sales')}}" class="btn btn-primary"><i class="fa fa-plus-circle"></i> Generate Report</a>
            </div>--}}
            <div class="btn-group dropdown">
                <button type="button" class="btn btn-info">Action Options</button>
                <button type="button" class="btn btn-info dropdown-toggle" id="mydp" data-toggle="dropdown" aria-haspopup="true" >
                    <span class="caret"></span>
                    <span class="sr-only">Action option</span>
                </button>
                <ul class="dropdown-menu" role="menu" aria-labelledby="mydp">
                    <li><a href="#">View PDF</a></li>
                    <li><a href="#">Export to Excel</a></li>
                    {{--<li><a href="#">Another action</a>
                    <li class="divider"></li>
                    <li><a href="#">Separated link</a>
                    </li>--}}
                </ul>
            </div>
            <div style="margin: 40px;"></div>

            <form action="{{route('reports.sales.all')}}" method="post" class="form-inline form-template">
              {{ csrf_field() }}
              <div class="clearfix"></div>
                  <div class="col-lg-12">
                     <div class="form-group width-100-percent">
                          <div class="col-md-4 no-padding">
                            <label for="" class="not-required">Year:</label>
                          </div>
                          <div class="col-md-6 no-padding">
                           <div class='input-group date' id='year-datetimepicker'>
                              <input type='text' name="year" id="year" class="form-control"/>
                              <span class="input-group-addon">
                                  <i class="fa fa-calendar" aria-hidden="true"></i>
                              </span>
                           </div>
                          </div>
                           <div class="col-md-4 no-padding">
                               <label for="" class="not-required">Period:</label>
                             </div>
                             <div class="col-md-4 no-padding">
                              <select class="form-control" name="period" style="width: 120%;">
                                <option value=""></option>
                                <option value="1">1st Quarter</option>
                                <option value="2">2nd Quarter</option>
                                <option value="3">3rd Quarter</option>
                                <option value="4">4th Quarter</option>
                              </select>
                             </div>

                     <div class="clearfix"></div>
                   </div>

                   </div>

                    <div class="clearfix"></div>
              <div class="clearfix" style="height: 30px"></div>
               <button type="submit" class="btn btn-primary">GENERATE</button>
            </form>
            <div class="clearfix"></div>
            @if(Session('info'))
                <div class="row">
                    <div class="col-md-6 col-md-offset-3 text-center">
                        <div class="tem alert alert-success navbar-fixed-bottom"><span class="glyphicon glyphicon-ok-circle"></span> {{Session('info')}}</div>
                    </div>
                </div>
            @endif
        </section>

    </div>
@stop

@section('script')
    <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.10.6/moment.min.js"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-datetimepicker/4.17.47/js/bootstrap-datetimepicker.min.js"></script>

    <script>

    $(document).ready(function() {

        $('#year-datetimepicker').datetimepicker({
             format: 'YYYY'
        });

        $('#from-datetimepicker').datetimepicker({
             format: 'MMMM/DD/YYYY'
        });

        $('#to-datetimepicker').datetimepicker({
             format: 'MMMM/DD/YYYY'
        });

         $("#user_table").dataTable().fnDestroy();
         $('#user_table').DataTable( {
                initComplete: function () {
                    this.api().columns().every( function () {
                        var column = this;
                        var select = $('<select class="fstyle"><option value=""></option></p>')
                            .appendTo( $(column.footer()).empty() )
                            .on( 'change', function () {
                                var val = $.fn.dataTable.util.escapeRegex(
                                    $(this).val()
                                );
                                column
                                    .search( val ? '^'+val+'$' : '', true, false )
                                    .draw();
                            } );

                        column.data().unique().sort().each( function ( d, j ) {
                            select.append( '<option value="'+d+'">'+d+'</option>' )
                        } );
                    } );
                }
            } );

        });

    </script>
@stop