@extends('layouts.master')

@section('content')
<link rel="stylesheet" href="{{ URL::asset('assets/css/jquery.datetimepicker.css') }}">
<script type="text/javascript" src="{{ URL::asset('assets/js/jquery.datetimepicker.full.min.js') }}"></script>
<!-- Main content -->
<section class="content">
    <!-- Main row -->
    <div class="row">
        <div class="col-md-12">
            
            <section class="panel tasks-widget">
                <header class="panel-heading" style="height:40px;">
                    <div class="pull-left">
                        {{$title}}
                    </div>
                </header>
                <?php
                    $users=array(
                            'Reza',
                            'Mamun',
                            'Golam Sayed',
                            'Akib',
                            'Masum',
                            'Helal',
                            'Zeba',
                            'Shabuj',
                            'Hasib',
                            'Tipu',
                            'Niloy',
                            'Nishat',
                            'Jamil',
                            'Shamim'
                        );
                ?>
                <div class="row">
                    <div class="col-md-12">
                        <div class="col-md-2" style="margin-top:2%">
                            <select class="form-control" id="user">
                                <option value="0"> Select User</option>
                                @foreach($users as $i=>$user)
                                    <option value="{{$i+1}}">{{ $user }}</option>
                                @endforeach
                            </select>
                        </div>
                        <div class="col-md-4" style="margin-top:2%">
                            <input name="date1" type="text" class="form-control" id="date1" placeholder="Select Start Date" required="">
                        </div>
                        <div class="col-md-4" style="margin-top:2%">
                            <input name="date2" type="text" class="form-control" id="date2" placeholder="Select End Date" required="">
                        </div>
                        <div class="col-md-2" style="margin-top:2%">
                            <span class="btn btn-sm btn-success pull-right" id="srch"><i class="fa fa-search"></i> Search</span>
                        </div>
                    </div>
                </div>
                
                <div class="table-responsive project-list" id="content_container">

                
                    
                </div>
                <div class="panel-body">
                    <div class=" add-task-row">
                    </div>
                    <div class="table-foot">
                        
                    </div>
                </div>
            </section>
        </div>
    </div>
</section>
<!-- row end -->
<!-- /.content -->





@endsection


@section('script')
<script type="text/javascript">
    $(document).ready(function(){
        $( "#date1" ).datetimepicker({});
        $( "#date2" ).datetimepicker({});
        $('#srch').on('click',function(){
            var user = $('#user').val();
            var start_date = $( "#date1" ).val();
            var end_date = $( "#date2" ).val();
            if(user !=0 && start_date !='' && end_date !='')
            {
                $.ajax({
                    url: "{{url('admin/report_content')}}",
                    type: 'POST',
                    data: {user: user,start_date: start_date,end_date: end_date},
                })
                .done(function(data) {
                    console.log(data);
                    $("#content_container").html(data);
                }); 
            } 
            else 
            {
                if(user ==0 && start_date !='' && end_date !='')
                {
                    alert("Please Select An User");
                }
                else if(start_date =='' && user !=0 && end_date !='')
                {
                    alert("Please Select Start Date");
                }
                else if(end_date =='' && user !=0 && start_date !='')
                {
                    alert("Please Select End Date");
                } 
                else if(user ==0 && start_date =='' && end_date =='')
                {
                    alert("Please Select Start Date,End Date and User");
                }
                
            }
            
        })
    });
    
</script>
@endsection
