@extends('admin.layouts.master')

@section('title')
    Developers Commission
@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> Developers Commission
            </h1>
            <ol class="breadcrumb">
                <li><a href="#"><i class="fa fa-users"></i> Admin Panel</a></li>
                <li class="active">Developers Commission</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>
                </ul>
            </div>--}}
            <div style="margin: 40px;"></div>

            <div>
            {{--style="border: solid #555555;padding:5px; border-radius: 7px;"--}}
            <form action="{{route('reports.commission.developers')}}" 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" style="padding:20px;">
                      <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" required="required" />
                          <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="month" class="not-required">Month:</label>
                       </div>
                      <div class="col-md-4 no-padding">
                      <select class="form-control" name="month" style="width: 120%;" required="required">
                        <option value=""></option>
                        @foreach($months as $month)
                            <option value="{{$month->id}}">{{$month->name}}</option>
                        @endforeach
                      </select>
                     </div>
                     <div class="clearfix"></div>
                 </div>

                 <div class="form-group width-100-percent" style="padding:50px;">
                    <div class="col-md-4 no-padding">
                          <label for="developer" class="not-required">Developer:</label>
                     </div>
                    <div class="col-md-6 no-padding">
                    <select class="form-control" id="developer" name="developer" style="width: 120%;">
                      <option ></option>
                       @foreach($devs as $dev)
                           <option value="{{$dev->id}}">{{$dev->name}}</option>
                       @endforeach
                    </select>
                   </div>

                   <div class="col-md-4 no-padding">
                         <label for="project" class="not-required">Project:</label>
                    </div>
                   <div class="col-md-6 no-padding">
                   <select class="form-control" id="project" name="project" style="width: 120%;">
                     <option ></option>
                     @foreach($projects as $prj)
                         <option value="{{$prj->id}}">{{$prj->name}}</option>
                     @endforeach
                   </select>
                  </div>
                 </div>

                <div class="form-group " style="padding-left:15px;">
                    <button type="submit" class="btn btn-success">Generate</button>
                </div>

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

            <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'
        });

        /*$('#developer').on('change', function () {
            var developer_id = $(this).find('option:selected').val();
            alert(developer_id);
            //alert($option.val());
            if(developer_id==''){
            $('#developer').val('');
                }
                else{
                    //$('#spinner').modal({backdrop: 'static', keyboard: false});
                        $.ajax({
                        url:"{{route('receivables.getRCVDDtls')}}",
                        method: 'get',
                        headers:  {'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')},
                        data:{
                          'developer_id':developer_id
                        },
                        dataType:'json',
                        success:function(data){
                            console.log(data);

                            $('#project').empty();
                            $('#project').append("<option selected disabled>Select Project</option>");
                            data.devs.forEach(function(prj){
                                $('#project').append('<option value="'+prj.id+'">'+prj.name+'</option>');
                            });
                            //$('#spinner').modal('toggle');
                    },
                    /*error:function(e){
                      console.log(e);
                    }*
                    error: function (jqXHR, exception) {
                        console.log(jqXHR);
                    }
                });
                } //end else
            });*/

        /*$('#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