@extends('admin/layouts/default')

{{-- Page title --}}
@section('title')
Downloads Report CSV
@parent
@stop

{{-- page level styles --}}
@section('header_styles')
     @include('admin.layouts.css')

@stop

{{-- Page content --}}
@section('content')

<section class="content-header">
                <!--section starts-->
               <h1>Counter Report Release 5</h1>               
                <ol class="breadcrumb">
                    <li>
                        <a href="{{ route('admin.dashboard') }}">
                            <i class="livicon" data-name="home" data-size="14" data-loop="true"></i>
                            Dashboard
                        </a>
                    </li>
                    <li ><a href="{{ URL::to('admin/counter_report/R5') }}">Counter Report</a></li>
                    <li class="active">Counter Report</li>
                </ol>
            </section>
            <!--section ends-->
<section class="content paddingleft_right15">
    <!--main content-->
    <div class="row">
        <div class="panel panel-primary ">
            <div class="panel-heading">
                <h3 class="panel-title">
                    <i class="livicon" data-name="gear" data-size="16" data-loop="true" data-c="#fff" data-hc="white"></i>
                    Counter Report
                </h3>
                <span class="pull-right clickable">
                    <i class="glyphicon glyphicon-chevron-up"></i>
                </span>
            </div>
            <div class="panel-body">               
                <form name="first" method="post" action="{{ route('counter_reportr5.export') }}" enctype="multipart/form-data">                
                <input type="hidden" name="_token" value="<?=csrf_token()?>">
                <input type="hidden" name="user_id" id="user_id" value="">
             @if ($errors->any())
                <div class="row">
                    <div class="col-md-9 col-lg-offset-3 col-md-offset-3 pd-r lert alert-danger">
                        <strong>Whoops!</strong> There were some problems with your input.<br>
                        <ul>
                            @foreach ($errors->all() as $error)
                                <li>{{ $error }}</li>
                            @endforeach
                        </ul>
                    </div>
                </div>
                @endif                    
                                  
                    <div class="col-md-8 pd-r">
                    
                        
                                        <div class="form-group  {{ $errors->first('user_name', 'has-error') }}">
                                            <label for="user_name" class="control-label">User name:</label>
                                            <div class="input-group">                                             
                                             <input type="text" name="user_name" id="user_name" class="form-control input-md d-inline" placeholder="user name" value="{{ old('user_name') }}" onblur="javascript: CheckUserExist(this.value);">
                                              <div class="input-group-addon"><i id="loader"  class="fa fa-spinner d-inline"></i></div>
                                            </div>

                                        </div>
                                        <div class="form-group">
                                            <input type="radio" name="exportrange" id="exportrange1" class="-md" value="0" onclick="javascript: disabledebook(this.id,1);">
                                            <label>Complete eBook</label>
                                            <input type="radio" name="exportrange" id="exportrange2" style="margin-left: 50px;"  class="" value="1" onclick="javascript: disabledebook(this.id,1);">
                                            <label>Chapter(s)</label>
                                            <input type="radio" name="exportrange" id="exportrange3" style="margin-left: 50px;"  class="" value="2" onclick="javascript: disabledebook(this.id,1);">
                                            <label>Journals</label>
                                            <input type="radio" name="exportrange" id="exportrange4" style="margin-left: 50px;"  class="" value="3" onclick="javascript: disabledebook(this.id,1);">
                                            <label>Platform</label>
                                        </div>
                                        <div class="form-group {{ $errors->first('reporttype', 'has-error') }}">
                                            <label for="reporttype" class="control-label">Report Type:</label>
                                            <select name="reporttype" class="form-control" id="reporttype" onchange="javascript: LoadTRDetail(this.value)">
                                                
                                            </select>
                                            <div>
                                                <span class="text-danger">{{ $errors->first('reporttype') }}</span>
                                            </div>
                                        </div>
                                        <div class="col-md-12" id="mtcolumn">
                                            <div class="row">
                                                <div class="col-md-5">
                                                    <div class="form-item" >
                                                        <label for="Metric-Type">Metric Types: </label>
                                                        <select name="Metric_Type[]" multiple="multiple" class="form-select select2" id="Metric-Type">
                                                           <option value="" selected disabled>Please select</option>
                                                            <option title="Total_Item_Requests" value="Total_Item_Requests">Total_Item_Requests</option>
                                                            <option title="Unique_Item_Requests" value="Unique_Item_Requests">Unique_Item_Requests</option>
                                                            <option title="No_License" value="No_License">No_License</option>
                                                            <option title="Searches_Platform" value="Searches_Platform">Searches_Platform</option>
                                                            <option title="Total_Item_Investigations" value="Total_Item_Investigations">Total_Item_Investigations</option>
                                                            <option title="Unique_Item_Investigations" value="Unique_Item_Investigations">Unique_Item_Investigations</option>
                                                        </select>
                                                    </div>
                                                </div>
                                                <div class="col-md-5">
                                                    <input type="checkbox" checked="checked " disabled="" value="1" name="mtcolumn" style="margin-top: 45px;"> Include column
                                                </div>
                                            </div>
                                        </div>
                                        <div class="col-md-12" id="dtcolumn">
                                            <div class="row">
                                                <div class="col-md-5">
                                                    <div class="form-item" >
                                                        <label for="Data-Type">Data Type: </label>
                                                        <select name="Data_Type" class="form-select select2" id="Data-Type">
                                                            <option title="Journal" value="Journal">Journal</option>
                                                        </select>
                                                    </div>
                                                </div>
                                                <div class="col-md-5">
                                                    <input type="checkbox" checked="checked "  value="1" name="dtcolumn" style="margin-top: 45px;"> Include column
                                                </div>
                                            </div>
                                        </div>
                                        <div class="col-md-12" id="atcolumn">
                                            <div class="row">
                                                <div class="col-md-5">
                                                    <div class="form-item" >
                                                        <label for="Access-Type">Access Type: </label>
                                                        <select name="Access_Type" class="form-select select2" id="Access-Type">
                                                        <option title="Controlled" value="Controlled">Controlled</option>
                                                        <option title="OA_Gold" value="OA_Gold">OA_Gold</option>
                                                        </select>
                                                    </div>
                                                </div>
                                                <div class="col-md-5">
                                                    <input type="checkbox" checked="checked " value="1" name="atcolumn" style="margin-top: 45px;"> Include column
                                                </div>
                                            </div>
                                        </div>
                                        <div class="col-md-12" id="amcolumn">
                                            <div class="row">
                                                <div class="col-md-5">
                                                    <div class="form-item" >
                                                        <label for="Access-Method">Access Method: </label>
                                                        <select name="Access_Method" class="form-select select2" id="Access-Method">
                                                            <option title="Regular" value="Regular">Regular</option>
                                                        </select>
                                                    </div>
                                                </div>
                                                <div class="col-md-5">
                                                    <input type="checkbox" checked="checked " value="1" name="amcolumn" style="margin-top: 45px;"> Include column
                                                </div>
                                            </div>
                                        </div>

                                        <div class="col-md-12" id="yopcolumn">
                                            <div class="row">
                                                <div class="col-md-5">
                                                    <div class="form-item" >
                                                        <label for="YOP">YOP: </label>
                                                       <input type="text" maxlength="128" name="YOP" id="YOP" size="60" value="" class="form-control ">
                                                    </div>
                                                </div>
                                                <div class="col-md-5">
                                                    <input type="checkbox" checked="checked " value="1" name="yopcolumn" style="margin-top: 45px;"> Include column
                                                </div>
                                            </div>
                                        </div>
                                        <div class="col-md-12" id="emcolumn">
                                            <div class="row">
                                                <label class="option" for="Exclude-Monthly">
                                                    <input type="checkbox" name="Exclude_Monthly" id="Exclude-Monthly" value="1" class="form-checkbox "> Exclude Monthly Detail
                                                </label>
                                            </div>
                                        </div>
                                        
                                        <div class="form-group col-md-12">
                                            <div class="col-md-3">
                                                <label for="frommonthwise" class="control-label">From Month:</label>
                                                <select name="frommonthwise" class="form-control select2" id="frommonthwise">
                                                    <option title="January" value="1">January</option>
                                                    <option title="February" value="2">February</option>
                                                    <option title="March" value="3">March</option>
                                                    <option title="April" value="4">April</option>
                                                    <option title="May" value="5">May</option>
                                                    <option title="June" value="6">June</option>
                                                    <option title="July" value="7">July</option>
                                                    <option title="August" value="8">August</option>
                                                    <option title="September" value="9">September</option>
                                                    <option title="October" value="10">October</option>
                                                    <option title="November" value="11">November</option>
                                                    <option title="December" value="12">December</option>
                                                </select>                                            
                                            </div>
                                            <div class="col-md-3">
                                                <label for="tomonthwise" class="control-label">To Month:</label>
                                                <select name="tomonthwise" class="form-control select2" id="tomonthwise">
                                                    <option title="January" value="1">January</option>
                                                    <option title="February" value="2">February</option>
                                                    <option title="March" value="3">March</option>
                                                    <option title="April" value="4">April</option>
                                                    <option title="May" value="5">May</option>
                                                    <option title="June" value="6">June</option>
                                                    <option title="July" value="7">July</option>
                                                    <option title="August" value="8">August</option>
                                                    <option title="September" value="9">September</option>
                                                    <option title="October" value="10">October</option>
                                                    <option title="November" value="11">November</option>
                                                    <option title="December" value="12">December</option>
                                                </select>                                            
                                            </div>
                                        </div>  
                                        <div class="form-group col-md-12">
                                            <div class="col-md-3">
                                                <label for="toyearwise" class="control-label">For Year:</label>
                                                <select name="toyearwise" class="form-control select2" id="toyearwise">
                                                    @for($i=date("Y");$i>=2012;$i--)
                                                            <option title="{{$i}}" value="{{$i}}">{{$i}}</option>  
                                                    @endfor
                                                </select>                                            
                                            </div>                                      
                                                
                                        </div>
                                        <div class="form-group">
                                            <label for="toyearwise" class="control-label">Select Export Type:</label><br>
                                            <input type="radio" name="exporttype" id="exporttype1" value="0" checked="checked" >
                                            <label>CSV</label>
                                            <input type="radio" name="exporttype" id="exporttype2" style="margin-left: 50px;" value="1" >
                                            <label>Excel</label>
                                        </div>
                                      
                        <button class="btn btn-primary" id="exportbtn"  style="display: none;" type="submit">Export</button>
                        </div> 
                        
                </form>   
                </div>
                
            
        </div>
    </div>
   
    <!--main content ends--> </section>
            <!-- content --> 
    @stop

{{-- page level scripts --}}
@section('footer_scripts')

    @include('admin.layouts.js')
     <script>
        $(".select2").select2({
            theme:"bootstrap",
            placeholder:"Please Select",
            width: '100%'
        });

        function CheckUserExist(user){

                $.ajax({
                        type: "GET",
                        url: '/admin/CheckUser/'+user,
                        data: {},
                        beforeSend: function (){
                            
                            $('#loader').addClass('fa-spin');
                        },
                        success: function( msg ) 
                        {
                            console.log(msg);
                            if(msg=="0"){    

                                $('#exportbtn').hide();
                                $('.input-group').addClass('has-error');
                                $('#user_id').val('');
                                
                            }else{
                                
                                $('#exportbtn').show();
                                $('.input-group').removeClass('has-error');
                                $('#user_id').val(msg);
                            }
                        },
                        
                        complete: function() {
                              
                               $('#loader').removeClass('fa-spin');  

                        },
                    }); 

        }
        $(document).ready(function(){
            //$('input:radio[name=select_search_mode]:checked').val() == 'basic_search'
            $('#mtcolumn').hide();
            $('#dtcolumn').hide();
            $('#atcolumn').hide();
            $('#amcolumn').hide();
            $('#yopcolumn').hide();
            $('#emcolumn').hide();
            
                 
        });


function disabledebook(v,uid){

        //
        
        $('#mtcolumn').hide();
        $('#dtcolumn').hide();
        $('#atcolumn').hide();
        $('#amcolumn').hide();
        $('#yopcolumn').hide();
        $('#emcolumn').hide();
        
        var journal = ['TR_J1','TR_J2','TR_J3','TR_J4','Title Report'];
        var ebook = ['TR_B1','TR_B2'];
        var chapter = ['BR2'];
        var platform = ['PR_P1','PR'];

            var x = document.getElementById("reporttype");
            for (i = 0; i < x.length; ) { 
                x.remove(x.length -1);
            }
            
            var a;
            if (v=='exportrange1'){
                a = ebook;
            } else if (v=='exportrange2'){
                a = chapter;
            } else if (v=='exportrange3'){
                a = journal;
            }
             else if (v=='exportrange4'){
                a = platform;
            }

            for (i = 0; i < a.length; ++i)
             {
                var option = document.createElement("option");
                option.text = a[i];
                if(v=='exportrange1'){
                option.value = '';                      
                    option.value = i+6;
                    x.add(option);
                }if(v=='exportrange2'){
                    option.value = '';
                    option.value = 7;
                    x.add(option);
                }
                if(v=='exportrange3')
                {
                        option.value = '';                      
                option.value = i+1;
                x.add(option);                  
            }
                if(v=='exportrange4')
                {
                        option.value = '';                      
                        option.value = i+8;
                x.add(option);                 
                }
                x.add(option);                 
            }

            
    }

    function LoadTRDetail(id){

        if(id==5 || id==9){
            $('#mtcolumn').show();
            $('#dtcolumn').show();
            $('#atcolumn').show();
            $('#amcolumn').show();
            $('#yopcolumn').show();
            $('#emcolumn').show();
            
        }else{

            $('#mtcolumn').hide();
            $('#dtcolumn').hide();
            $('#atcolumn').hide();
            $('#amcolumn').hide();
            $('#yopcolumn').hide();
            $('#emcolumn').hide();
            
        }
    }
    </script>
@stop
