@extends('layouts.app')
@section('title')
{{ $user->name }}
@parent
@stop
@section('header_styles')
<meta name="csrf_token" content="{{ csrf_token() }}">
<link href="{{ asset('assets/vendors/jasny-bootstrap/css/jasny-bootstrap.css') }}" rel="stylesheet"/>
<link href="{{ asset('assets/vendors/x-editable/css/bootstrap-editable.css') }}" rel="stylesheet"/>
<link href="{{ asset('assets/css/pages/user_profile.css') }}" rel="stylesheet"/>
<style type="text/css">
.text-warning{
  color: var(--orange) !important;
}

.text-success{
  color: var(--teal) !important;
}

  .card:hover,
  .text-success:hover,
  .text-warning:hover {
  opacity: 0.9;
  color: inherit;
}

  .accordion-item {
    margin-bottom: 10px;
  }

  .accordion-header {
    cursor: pointer;
    display: flex;
    align-items: center;
    background-color: white;
    padding: 10px 20px;
  }

  .accordion-header h3 {
    margin: 0;
    font-size: 20px;
    font-weight: bold !important;
  }

  .accordion-icon {
    font-size: 20px;
  }

  .accordion-content {
    display: none;
  }

  .loader-container {
    background: rgba(0, 0, 0, 0.7);
    z-index: 9999;
    display: flex;
    position: fixed;
    inset: 0;
    width: 100%;
    height: 100%;
    justify-content: center;
    align-items: center;
  }

  .loader {
    border: 16px solid #f3f3f3;
    border-radius: 50%;
    border-top: 16px solid #3498db;
    width: 120px;
    height: 120px;
    -webkit-animation: spin 2s linear infinite;
    /* Safari */
    animation: spin 2s linear infinite;
  }

  .d-none {
    display: none;
  }

  /* Safari */
  @-webkit-keyframes spin {
    0% {
      -webkit-transform: rotate(0deg);
    }

    100% {
      -webkit-transform: rotate(360deg);
    }
  }

  @keyframes spin {
    0% {
      transform: rotate(0deg);
    }

    100% {
      transform: rotate(360deg);
    }
  }
</style>
@stop

{{-- Page content --}}
@section('content')
<main id="users_ac">
   <!--section ends-->
   <section>
      <div class="container">
         <div class="row">
            
            <div class="col-md-12 mt-xs-5">
                @if ($message = Session::get('error'))
                  <div class="alert alert-danger alert-dismissible fade show" role="alert">
                    <strong>Sorry !!!</strong>{{ $message }}
                    <button type="button" class="close" data-dismiss="alert" aria-label="Close">
                      <span aria-hidden="true">&times;</span>
                    </button>
                  </div>
                @endif
               <h2 class="h4 p-3 bg-dark-light text-primary-light">
                 <a href="{{route('crm.dashboard')}}"><i class="fa fa-home"></i> Dashboard </a>  
               </h2>
               <div class="row font-18">
                  <div class="col-md-3">
                     <div class="card card-body hvr-icon-bob w-100 bigbox-hvr-slow text-center mt-4">
                        <a class="text-danger" href="{{route('crm.risk')}}">
                          
                              <div class="d-flex justify-content-between">
                            <div class="col-9 text-left">
                                  <p class="my-2"><strong class="small font-weight-bold">At Risk <hr class="my-1"> &nbsp;</strong>
                            </div>  
                            <i  class="fa-solid hvr-icon fa-triangle-exclamation fa-3x mb-auto"></i>
                          </div>

                         
                        </a>
                     </div>
                  </div>
                  
                  <div class="col-md-3">
                     <div class="card card-body hvr-icon-bob w-100 bigbox-hvr-slow text-center mt-4">
                        <a  class="text-warning" href="{{route('crm.opportunity')}}">
                          
                            <div class="d-flex justify-content-between">
                            <div class="col-9 text-left">
                                <p class="my-2"><strong class="small font-weight-bold">Opportunity <hr class="my-1"> &nbsp; </strong>
                            </div>
                              <i class="fas hvr-icon fa-lightbulb fa-3x mb-auto"></i>
                            </div> 

                          
                        </a>
                     </div>
                  </div>

                  <div class="col-md-3">
                     <div class="card card-body hvr-icon-bob w-100 bigbox-hvr-slow text-center mt-4">
                        <a  class="text-success" href="#" data-toggle="modal" data-target="#marc_mdl">
                          <div class="d-flex justify-content-between">
                            <div class="col-9 text-left">
                              <p class="my-2"><strong class="small font-weight-bold">MARC Record <hr class="my-1"> Journals & ebooks</strong>
                            </div>  
                            <i class="fa hvr-icon fa-area-chart fa-3x mb-auto"></i>
                          </div>
                        </a>
                     </div>
                  </div>
                  <div class="col-md-3">
                     <div class="card card-body hvr-icon-bob w-100 bigbox-hvr-slow text-center mt-4">
                        <a  class="text-info" href="#" data-toggle="modal" data-target="#kbart_mdl">
                          <div class="d-flex justify-content-between">
                            <div class="col-9 text-left">
                              <p class="my-2"><strong class="small font-weight-bold">KBART <hr class="my-1"> Journals & ebooks</strong>
                            </div>  
                            <i class="fa-solid fa-chart-column hvr-icon fa-3x mb-auto"></i>
                          </div>
                        </a>
                     </div>
                  </div>

            <div class="col-md-12">
              <div class="card card-body bg-siteblue text-white hvr-icon-bob w-100 bigbox-hvr-slow text-center mt-4">
                <a class="text-white" href="#" data-toggle="collapse" data-target="#subsc_clp" aria-expanded="false" aria-controls="subsc_clp">
                  <div class="d-flex justify-content-between">
                    <div class="col-9 text-left">
                      <p class="my-2"><strong class="large font-weight-bold">CUSTOMERS </strong>
                        <hr class="my-1"> <small>List of subscribers Corporate or Trial</small>
                    </div>
                    <i class="fa-solid fa-users-line hvr-icon fa-3x mb-auto"></i>
                  </div>
                </a>
              </div>
            </div>

          </div>
          <div class="collapse  @if(!empty($customers)) show @endif" id="subsc_clp">
            <hr>

            <form action="{{route('crm.dashboard')}}" method="GET" class="form-group">
              @csrf
              <div class="form-row">
                <div class="form-group col-md-2">
                  <label for="by_customer"><strong>Customer Type</strong></label>
                  <select class="form-control" id="customer_type" name="customer_type">
                    <option value="Org" @if('Org'==$customer_type || $customer_type =='') {{ 'selected' }} @endif>Organization</option>
                    <option value="user" @if('user'==$customer_type) {{ 'selected' }} @endif>User</option>
                  </select>
                </div>
                <div class="form-group col-md-3">
                  <label for="by_country"><strong>By Country</strong></label>
                  <select class="form-control" id="by_country" name="by_country">
                    <option value="" hidden="true">-- Select Country --</option>
                    @foreach (getCountrires() as $key => $country)
                    <option value="{{$key}}" {{ $country_id == $key ? "selected" : "" }}> {{$country}}</option>
                    @endforeach
                  </select>
                </div>
                <div class="form-group col-md-3">
                  <label for="by_customer"><strong>By Customer Name</strong></label>
                  <input type="text" name="by_customer" class="form-control" placeholder="Search by customer...." value="{{$customer_name}}">
                </div>
                <div class="form-group col-md-2">
                  <label for="by_customer"><strong>By Organization Name</strong></label>
                  <input type="text" name="by_organization" class="form-control" placeholder="Search by organization name...." value="{{$organization_name}}">
                </div>
                <div class="form-group col-md-2 mt-1">
                  <div class="row">
                    <div class="col-6 pt-4 px-1 pl-3">
                      <button type="submit" class="btn btn-primary btn-block" name="filter" value="filter"><i class="fas fa-filter"></i> Filter</button>
                    </div>
                    <div class="col-6 pt-4 px-1">
                      <a href="{{route('crm.dashboard')}}" class="btn btn-warning btn-block text-white"><i class="far fa-times-circle"></i> Reset </a>
                    </div>
                  </div>
                </div>
              </div>
            </form>

            @if (!empty($organization_list))
			<div class="col-md-12"><h3>Total Found: {{$organization_list->count()}}</h3></div>
            @foreach($organization_list as $key => $value)
            <div class="accordion">
              <div class="accordion-item" href="#{{$value->access_organization_id}}">
                <a class="accordion-header">
                  <span class="accordion-icon p-1">+</span>
                  <h3>{{$value->organization_name}}</h3>
                </a>

                <div class="accordion-content" id="{{$value->access_organization_id}}">
               <table class="table table-striped  font-14">
                  <thead>
                    <tr bgcolor="#01547d" class="text-white">
                      <th>S.No</th>
                      <th>Name</th>
                      <th>Country</th>
                      <th>Organization</th>
                      <th>Access Type</th>
					  <th>Status</th>
                      <th width="12%">Action</th>
                    </tr>
                  </thead>
				  	@php $cnt = 1; @endphp
                    @foreach($customers as $row)
                    @if ($value->access_organization_id==$row->access_organization_id)
                    <tbody>
                            <tr>
                              <td>{{$cnt++}}</td>
                              <td>{{$row->display_name}} ({{$row->name}})</td>
                              <td>{{$row->country_name}}</td>
                              <td>
                                  {{$row->organization_name}}
                              </td>
                              <td>{{$row->access_type_title}} ({{$row->access_type_on}})
                                <br>
                                @if($row->perpetual == "0")
                              <p class="mt-2 mb-0 text-secondary"> <b>From : </b> {{gmdate("d-m-Y", $row->access_date_from)}}
                            <b>To : </b>{{gmdate("d-m-Y", $row->access_date_to)}}
                          </p>
                                @else
                                  <p class="mt-2 mb-0 text-secondary">{{"Perpetual"}}</p>
                                @endif
                              </td>
							 <td>
								@if($row->user_access_status == "1")
								<span class="badge badge-success">Active</span>
								@else
								<span class="badge badge-danger">Expire</span>
								@endif
							 </td>
                              <td>
                                <div class="dropdown">
                                  <a class="btn btn-primary  btn-sm dropdown-toggle" href="#" role="button" id="bt-normal-dd" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
                                   Reports
                                  </a>
                                  <div class="dropdown-menu font-14" aria-labelledby="bt-norma-dd">
                                  <a class="dropdown-item" href="javascript:get_openathens_form('{{$row->name}}','{{encrypt($row->id)}}','{{$row->display_name}}','{{$row->openathensOrganisationId}}','{{$row->openathensrealmName}}','{{$row->openathensderivedEduPersonScope}}')"><i class="fa-solid fa-gears hvr-icon"></i> Openathens/Shibboleth</a>  
                                    <a class="dropdown-item" href="javascript:get_usage_form('{{$row->name}}','{{$row->id}}')"><i class="fa-solid fa-chart-column hvr-icon"></i> Counter Report</a>
                              @if(($row->access_type_id == "444" || $row->access_type_id == "555" || $row->access_type_id == "666") && ($row->user_access_status == "1"))
                              <a class="btn dropdown-item" data-toggle="modal" id="tokenButton" data-target="#tokenModal" data-attr="{{ route('crm.user_token_report',[$row->id])}}"><i class="fa-solid fa-chart-column hvr-icon"></i> Token Report</a>
                              @endif
                                    <a class="dropdown-item" href="{{route('crm.combinereport',['param'=>\Crypt::encryptString($row->ingenta_id),'year'=>date('Y'),'eurekausername'=>\Crypt::encryptString($row->name)]    )}}"><i class="fa-solid fa-chart-column hvr-icon"></i> Eureka & Ingenta Analytics</a>

                              @if($row->access_type_on != "ebook_volume")
                              <a class="dropdown-item" href="{{route('crm.user.subscribejournal',['param'=>\Crypt::encryptString($row->id),'type'=>\Crypt::encryptString($row->access_type_id),'access_on'=>\Crypt::encryptString($row->access_type_on)])}}"><i class="fa-solid fa-chart-column hvr-icon"></i>View Subscribed Journals List</a>
                              @endif
                              @if($row->access_type_on != "ebook_volume")
                                    <a class="dropdown-item" href="{{route('user.marcdata.subscribejournal',\Crypt::encryptString($row->id))}}" target="_blanck"><i class="fa-solid fa-chart-column hvr-icon"></i>Subscribed Journal MARC Record</a>
                              @endif
                                    <a class="dropdown-item" href="{{route('user.marcdata.subscribeebook',\Crypt::encryptString($row->id))}}" target="_blanck"><i class="fa-solid fa-chart-column hvr-icon"></i> Subscribed Ebook MARC Record</a>
                              @if($row->access_type_on != "ebook_volume")
                                     <a class="dropdown-item" href="{{route('user.marcdata.subscribeebook',\Crypt::encryptString($row->id))}}" target="_blanck"><i class="fa-solid fa-chart-column hvr-icon"></i> Subscribed Journal KBRT Record</a>
                              @endif
                                      <a class="dropdown-item" href="{{route('user.marcdata.subscribeebook',\Crypt::encryptString($row->id))}}" target="_blanck"><i class="fa-solid fa-chart-column hvr-icon"></i> Subscribed Ebook KBRT Record</a>
                                    <a class="dropdown-item" href="{{route('crm.agent.authors',\Crypt::encryptString($row->id))}}"><i class="fa-solid fa-chart-column hvr-icon"></i> Authors</a>
                                    <a class="dropdown-item" href="#"><i class="fa-solid fa-chart-column hvr-icon"></i> Ambassador</a>
                              <a class="dropdown-item" href="javascript:get_sushi_link('{{$row->name}}')"><i class="fa-solid fa-chart-column hvr-icon"></i> SUSHI Report Link</a>
                                  </div>
                                </div>
                              </td>
                            </tr>
                  </tbody>
                    @endif
                    @endforeach
               </table>
                </div>
              </div>
            </div>
            @endforeach
			@else
			<div class="text-center">No Customer(s) Assign !!!</div>
            @endif
            </div>
         </div>
      </div>
      </div>
   </section>
</main>

<!-- ******************************************* COUNTER REPORT ******************************************** -->
    
<div class="modal fade bd-example-modal-lg"  role="dialog" id="usagereportformmodal" aria-hidden="true">
  <div class="modal-dialog modal-lg">
    <div class="modal-content">
        <div class="modal-body">
         
            <div class="col-md-12 mt-xs-5">

     <h2 class="h4 p-3 bg-dark-light text-primary-light">Counter Report </h2>

          <div class="card card-primary ">

          <div class="card-body">               

          @include('includes.usagereportform') 

          </div>

          </div>

          </div>

          <div class="modal-footer">
            <button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
          </div>   
        </div>
        
    </div>

  </div>
</div>

    <div class="modal fade bd-example-modal-lg"  role="dialog" id="openathensformmodal" aria-hidden="true">
      <div class="modal-dialog modal-lg">
        <div class="modal-content">
            <div class="modal-body">
             
                <div class="col-md-12 mt-xs-5">

         <h2 class="h4 p-3 bg-dark-light text-primary-light">Update Openathens/Shibboleth Access</h2>

              <div class="card card-primary ">

              <div class="card-body">               

              <form name="first" method="post" action="{{ route('profile') }}" enctype="multipart/form-data">    
                <input type="hidden" name="_token" value="<?=csrf_token()?>">                
                <input type="hidden" name="utm" id="utm" value="">
                <input type="hidden" name="by_country" id="by_country" value="{{Request()->by_country}}">
                <input type="hidden" name="by_customer" id="by_customer" value="{{Request()->by_customer}}">
                <div class="form-group col-md-12 {{ $errors->first('name', 'has-error') }}">
                  <label for="name" class="control-label">User Name *</label>
                  <span id="oausername">{!! old('name', $user->name) !!}</span>
                </div>
                <div class="form-group col-md-12 {{ $errors->first('display_name', 'has-error') }}">
                  <label for="display_name" class="control-label">Display Name *</label>
                    <input id="display_name" name="display_name" type="text" placeholder="Display Name" class="form-control required" value="{!! old('display_name', $user->display_name) !!}"/>
                                {!! $errors->first('display_name', '<span class="text-danger">:message</span>') !!} 
                </div>                 
                <div class="form-group col-md-12 {{ $errors->first('openathensOrganisationId', 'has-error') }}">
                  <label for="openathensOrganisationId" class="control-label">Openathens Organisation Id </label>
                    <input id="openathensOrganisationId" name="openathensOrganisationId" type="text" placeholder="openathens Organisation Id" class="form-control required" value="{!! old('openathensOrganisationId', $user->openathensOrganisationId) !!}"/>
                  {!! $errors->first('openathensOrganisationId', '<span class="text-danger">:message</span>') !!} 
                </div>     
                <div class="form-group col-md-12 {{ $errors->first('openathensrealmName', 'has-error') }}">
                  <label for="openathensrealmName" class="control-label">Openathens idp/entity </label>
                    <input id="openathensrealmName" name="openathensrealmName" type="text" placeholder="Openathens idp/entity" class="form-control required" value="{!! old('openathensrealmName', $user->openathensrealmName) !!}"/>
                  {!! $errors->first('openathensrealmName', '<span class="text-danger">:message</span>') !!} 
                </div>
                <div class="form-group col-md-12 {{ $errors->first('openathensderivedEduPersonScope', 'has-error') }}">
                  <label for="openathensderivedEduPersonScope" class="control-label">Openathens Affiliation Scope </label>
                    <input id="openathensderivedEduPersonScope" name="openathensderivedEduPersonScope" type="text" placeholder="comma separated values" class="form-control required" value="{!! old('openathensderivedEduPersonScope', $user->openathensderivedEduPersonScope) !!}"/>
                  {!! $errors->first('openathensderivedEduPersonScope', '<span class="text-danger">:message</span>') !!} 
                </div>            
                
                <button class="btn btn-primary" id="oaSave" type="submit">Save</button>
              </form>     
              </div>

              </div>

              </div>

              <div class="modal-footer">
                <button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
              </div>   
            </div>
            
        </div>

      </div>
    </div>

<!-- ******************************************* MARC REPORT ******************************************** -->
<div class="modal fade bd-example-modal-lg" role="dialog" id="marc_mdl" aria-hidden="true">
  <div class="modal-dialog modal-lg">
    <div class="modal-content">
        <div class="modal-body">
           @include('admin.marcdata.includes.marc_form')
           <div class="modal-footer">
            <button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
          </div>  
        </div>
    </div>
  </div>
</div>

<!-- ******************************************* KBART REPORT ******************************************** -->
<div class="modal fade bd-example-modal-lg" role="dialog" id="kbart_mdl" aria-hidden="true">
  <div class="modal-dialog modal-lg">
    <div class="modal-content">
        <div class="modal-body">
           @include('admin.kbart.includes.kbart_form')
           <div class="modal-footer">
            <button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
          </div>  
        </div>
    </div>
  </div>
</div>

<!-- ******************************************* Token Report Modal ******************************************** -->
<div class="modal fade" id="tokenModal" tabindex="-1" role="dialog" aria-labelledby="tokenModalLabel" aria-hidden="true">
  <div class="modal-dialog modal-lg" role="document">
    <div class="modal-content">
      <div class="modal-body" id="tokenBody">
        <!-- the result to be displayed here -->
      </div>
    </div>
  </div>
</div>
<div class="loader-container" id="loader" style="display: none;">
  <div class="loader">
  </div>
</div>

<!-- ******************************************* SUSHI Link Modal ******************************************** -->
<div class="modal fade bd-example-modal-lg" role="dialog" id="opensushimodal" aria-hidden="true">
  <div class="modal-dialog modal-xl">
    <div class="modal-content">
      <div class="modal-body">
        <div class="col-md-12 mt-xs-5">
          <h2 class="h4 p-3 bg-dark-light text-primary-light">SUSHI Links</h2>
          <div class="card card-primary ">
            <div class="card-body">
              <div class="form-group col-md-12">
                <h5 class="control-label">TR J1</h5>
                <div class="form-control h-auto " style="word-break: break-all;" id="j1_report"></div>
              </div>
              <div class="form-group col-md-12">
                <h5 class="control-label">TR J2</h5>
                <div class="form-control h-auto " style="word-break: break-all;" id="j2_report"></div>
              </div>
              <div class="form-group col-md-12">
                <h5 class="control-label">TR J3</h5>
                <div class="form-control h-auto " style="word-break: break-all;" id="j3_report"></div>
              </div>
              <div class="form-group col-md-12">
                <h5 class="control-label">TR J4</h5>
                <div class="form-control h-auto " style="word-break: break-all;" id="j4_report"></div>
              </div>
              <div class="form-group col-md-12">
                <h5 class="control-label">Title Report</h5>
                <div class="form-control h-auto " style="word-break: break-all;" id="tr_report"></div>
              </div>
              <div class="form-group col-md-12">
                <h5 class="control-label">Platform Master Report</h5>
                <div class="form-control h-auto " style="word-break: break-all;" id="pr_report"></div>
              </div>
            </div>
          </div>
        </div>
        <div class="modal-footer border-0">
          <button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
        </div>
      </div>
    </div>
  </div>
</div>

@stop
<script>
  function get_usage_form(username,userid) {
    $("#user_name").val(username);
	$("#user_id").val(userid);
    
    $('#usagereportformmodal').modal('toggle');

  $('#usagereportformmodal').modal('show');

    CheckUserExist(userid);
  }

  function get_openathens_form(username,userid,displayname,openathensOrganisationId,openathensrealmName,openathensderivedEduPersonScope) {
    $("#oausername").html(username);
    $("#utm").val(userid);
    $("#display_name").val(displayname);
    $("#openathensOrganisationId").val(openathensOrganisationId);
    $("#openathensrealmName").val(openathensrealmName);
    $("#openathensderivedEduPersonScope").val(openathensderivedEduPersonScope);
    
    $('#openathensformmodal').modal('toggle');

    $('#openathensformmodal').modal('show');

    //CheckUserExist(userid);
  }
</script>
@section('footer_scripts') 

 
     <script>
        $(".select2").select2({
            theme:"bootstrap",
            placeholder:"Please Select",
            width: '100%',
           
        });
        
        $(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 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');
                               
                            }
                        },

                        complete: function() {

                               $('#loader').removeClass('fa-spin');

                        },
                    });

        }

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>    

<script>
  // Get all the accordion items
  const accordionItems = document.querySelectorAll('.accordion-item');

  // Add click event listener to each accordion item
  accordionItems.forEach(item => {
    const header = item.querySelector('.accordion-header');
    const icon = item.querySelector('.accordion-icon');

    header.addEventListener('click', () => {
      // Toggle the content visibility
      const content = item.querySelector('.accordion-content');
      content.style.display = content.style.display === 'block' ? 'none' : 'block';

      // Change the icon
      icon.textContent = icon.textContent === '+' ? '-' : '+';
    });
  });
</script>

<script>
  // display a token modal
  $(document).on('click', '#tokenButton', function(event) {
    event.preventDefault();
    let href = $(this).attr('data-attr');
    $.ajax({
      url: href,
      beforeSend: function() {
        $('#loader').show();
      },
      // return the result
      success: function(result) {
        $("#loader").hide();
        $('#tokenModal').modal("show");
        $('#tokenBody').html(result).show();
      },
    })
  });
</script>

<script>
  function get_sushi_link(name) {

    let date =  new Date().getFullYear();

    first = 'https://www.eurekaselect.com/tool/sushi/R5/reports/tr_j1?customer_id='+ name +'&requestor_id=counter001&begin_date='+ date +'-01&end_date='+ date +'-12'

    $("#j1_report").html(first);

    first = 'https://www.eurekaselect.com/tool/sushi/R5/reports/tr_j2?customer_id='+ name +'&requestor_id=counter001&begin_date='+ date +'-01&end_date='+ date +'-12'
    
    $("#j2_report").html(first);

    first = 'https://www.eurekaselect.com/tool/sushi/R5/reports/tr_j3?customer_id='+ name +'&requestor_id=counter001&begin_date='+ date +'-01&end_date='+ date +'-12'
    
    $("#j3_report").html(first);

    first = 'https://www.eurekaselect.com/tool/sushi/R5/reports/tr_j4?customer_id='+ name +'&requestor_id=counter001&begin_date='+ date +'-01&end_date='+ date +'-12'
    
    $("#j4_report").html(first);

    first = 'https://www.eurekaselect.com/tool/sushi/R5/reports/tr?requestor_id=counter001&customer_id='+ name +'&begin_date='+ date +'-01&end_date='+ date +'-12&metric_type=Total_Item_Requests|Unique_Item_Requests|Total_Item_Investigations|Unique_Item_Investigations|Unique_Item_Requests&access_type=Controlled|OA_Gold&data_type=Journal&access_method=Regular'
    
    $("#tr_report").html(first);

    first = 'https://www.eurekaselect.com/tool/sushi/R5/reports/pr?requestor_id=counter001&customer_id='+ name +'&begin_date='+ date +'-01&end_date='+ date +'-12&metric_type=Total_Item_Requests|Unique_Item_Requests|Total_Item_Investigations|Unique_Item_Investigations|Unique_Title_Investigations|Unique_Title_Requests|Searches_Platform&access_type=Controlled|OA_Gold&data_type=Book&access_method=Regular'
    
    $("#pr_report").html(first);

    $('#opensushimodal').modal('toggle');

    $('#opensushimodal').modal('show');
  }
</script>

@stop
