<style type="text/css">
  .close{
    opacity: 0.8;
    color: #ffffff;
  }
  .text-white{
    color: #ffffff;
  }

</style>
<!-- Trigger the modal with a button -->
<button type="button" class="btn btn-primary" data-toggle="modal" data-target="#view_{{ $value->id }}">Details</button>

<!-- Modal -->
<div id="view_{{ $value->id }}" class="modal fade" role="dialog">
<div class="modal-dialog modal-lg">

<!-- Modal content-->
<div class="modal-content scroll-y">
<div class="modal-header bg-primary">
<button type="button" class="close" data-dismiss="modal">&times;</button>
<h4 class="modal-title">JMS Import Article</h4>
</div>
<div class="modal-body pre-scrollable">
<div class="row">
<?php   
if(!empty($value->content))
  { 
    $jsonData = json_decode($value->content);
    if(isset($jsonData->manuscript))
    {
    ?>
      <div class="panel panel-default">
        <div class="panel-heading">
          <h3 class="panel-title">
            Article Details
          </h3>
          <span class="pull-right clickable">
            <i class="glyphicon glyphicon-chevron-up"></i>
          </span>
        </div>
        <div class="panel-body">
          <div class="panel-group" id="accordion<?=$value->id?>" role="tablist" aria-multiselectable="true">
              <div class="panel panel-default">
                  <div class="panel-heading" role="tab" id="headingOne<?=$value->id?>">
                          <a role="button" data-toggle="collapse" data-parent="#accordion<?=$value->id?>" href="#collapseOne<?=$value->id?>" aria-expanded="true" aria-controls="collapseOne<?=$value->id?>">
                              <h4 class="panel-title">Manuscript</h4>
                          </a>
                  </div>
                  <div id="collapseOne<?=$value->id?>" class="panel-collapse collapse in" role="tabpanel" aria-labelledby="headingOne<?=$value->id?>">
                    <div class="panel-body">
                        <div class="portlet box info">
                            <div class="portlet-body">
                                <div class="table-scrollable">
                                    <table class="table table-striped table-bordered table-advance table-hover">
                                        </tbody>
                                          <tr>
                                              <td><strong>Journal</strong></td>
                                              <td>{{$value->title}}</td>
                                          </tr>
                                          <tr>
                                              <td><strong>Journal Code</strong></td>
                                              <td>{{$value->journal_code}}</td>
                                          </tr>
                                          @if(!empty($value->policy))
                                          <tr>
                                              <td><strong>Journal Policy</strong></td>
                                              <td style="background-color: lightblue;">{!! $value->policy !!}</td>
                                          </tr>
                                          @endif
                                          <tr>
                                              <td><strong>Article Title</strong></td>
                                              <td>{!! $jsonData->manuscript->manuscript_title !!}</td>
                                          </tr>
                                          <tr>
                                              <td><strong>Abstract</strong></td>
                                              <td>{!! $jsonData->manuscript->abstract !!}</td>
                                          </tr>
                                          <tr>
                                              <td><strong>Article Type</strong></td>
                                              <td>{{$value->art_type}}</td>
                                          </tr>
                                          <tr>
                                              <td><strong>Keywords</strong></td>
                                              <td>{{$jsonData->manuscript->keyword}}</td>
                                          </tr>
                                          <tr>
                                              <td><strong>JMS Reference No.</strong></td>
                                              <td>{{$value->jms_ref_no}}</td>
                                          </tr>
                                          <tr>
                                              <td><strong>Received Date</strong></td>
                                              <td>
                                                @if(isset($jsonData->manuscript->submission_date))
                                                  {{strftime('%Y-%m-%d',$jsonData->manuscript->submission_date)}}
                                                @else
                                                  &nbsp;
                                                @endif  
                                              </td>
                                          </tr>
                                          <tr>
                                              <td><strong>Revision Date</strong></td>
                                              <td>
                                                @if(isset($jsonData->manuscript->revision_date))
                                                  {{strftime('%Y-%m-%d',$jsonData->manuscript->revision_date)}}
                                                @else
                                                  &nbsp;
                                                @endif  
                                              </td>
                                          </tr>
                                          <tr>
                                              <td><strong>Acceptance Date</strong></td>
                                              <td>
                                                @if($jsonData->manuscript->acceptance_date)
                                                  {{strftime('%Y-%m-%d',$jsonData->manuscript->acceptance_date)}}
                                                @else
                                                  &nbsp;
                                                @endif    
                                              </td>
                                          </tr>
                                        </tbody>
                                    </table>
                                </div>
                            </div>
                        </div>
                    </div>
                  </div>
              </div>
              @if(is_array($jsonData->manuscript->structure_abstract))
              <div class="panel panel-default">
                  <div class="panel-heading" role="tab" id="headingTwo<?=$value->id?>">
                      <a class="collapsed" role="button" data-toggle="collapse" data-parent="#accordion<?=$value->id?>" href="#collapseTwo<?=$value->id?>" aria-expanded="false" aria-controls="collapseTwo<?=$value->id?>">
                          <h4 class="panel-title">
                          Structure Abstract
                          </h4>
                        </a>
                  </div>
                  <div id="collapseTwo<?=$value->id?>" class="panel-collapse collapse" role="tabpanel" aria-labelledby="headingTwo<?=$value->id?>">
                      <div class="panel-body">
                          <div class="table-scrollable">
                              <table class="table table-striped table-bordered table-advance table-hover">
                                  </tbody>
                                  @for($a=0; $a < sizeof($jsonData->manuscript->structure_abstract); $a++)
                                    <tr>
                                        <td class="bg-primary text-white"><strong>Sequance</strong></td>
                                        <td>{{ $jsonData->manuscript->structure_abstract[$a]->sequence }}</td>
                                    </tr>
                                    <tr>
                                        <td><strong>Field Name</strong></td>
                                        <td>{{ $jsonData->manuscript->structure_abstract[$a]->field_name }}</td>
                                    </tr>
                                    <tr>
                                        <td><strong>Field Description</strong></td>
                                        <td>{{ $jsonData->manuscript->structure_abstract[$a]->field_description }}</td>
                                    </tr>
                                  @endfor    
                                  </tbody>
                              </table>
                          </div>
                      </div>
                  </div>
              </div>
              @endif
              @if(is_array($jsonData->manuscript->funders))
              <div class="panel panel-default">
                  <div class="panel-heading" role="tab" id="headingThree<?=$value->id?>">
                          <a class="collapsed" role="button" data-toggle="collapse" data-parent="#accordion<?=$value->id?>" href="#collapseThree<?=$value->id?>" aria-expanded="false" aria-controls="collapseThree<?=$value->id?>">
                              <h4 class="panel-title"> Funders</h4>
                          </a>
                  </div>
                  <div id="collapseThree<?=$value->id?>" class="panel-collapse collapse" role="tabpanel" aria-labelledby="headingThree<?=$value->id?>">
                      <div class="panel-body">
                          <div class="table-scrollable">
                              <table class="table table-striped table-bordered table-advance table-hover">
                                  </tbody>
                                  @for($a=0; $a < sizeof($jsonData->manuscript->funders); $a++)
                                    <tr>
                                        <td class="bg-primary text-white"><strong>Funder Name</strong></td>
                                        <td>{{ $jsonData->manuscript->funders[$a]->funder_name }}</td>
                                    </tr>
                                    @if(is_array($jsonData->manuscript->funders[$a]->funder_awards))
                                    <tr>
                                        <td><strong>Awards</strong></td>
                                        <td>
                                          <table class="table table-striped table-bordered table-advance table-hover">
                                              </tbody>
                                            @for($b=0; $b < sizeof($jsonData->manuscript->funders[$a]->funder_awards); $b++)
                                                <tr>
                                                    <td>{{$jsonData->manuscript->funders[$a]->funder_awards[$b]->award}}</td>
                                                </tr>
                                            @endfor          
                                          </table>
                                        </td>
                                    </tr>
                                    @endif
                                  @endfor    
                                  </tbody>
                              </table>
                          </div>
                      </div>
                  </div>
              </div>
              @endif
              @if(is_array($jsonData->manuscript->authors))
              <div class="panel panel-default">
                  <div class="panel-heading" role="tab" id="headingFour<?=$value->id?>">
                          <a class="collapsed" role="button" data-toggle="collapse" data-parent="#accordion<?=$value->id?>" href="#collapseFour<?=$value->id?>" aria-expanded="false" aria-controls="collapseFour<?=$value->id?>">
                              <h4 class="panel-title"> Authors</h4>
                          </a>
                  </div>
                  <div id="collapseFour<?=$value->id?>" class="panel-collapse collapse" role="tabpanel" aria-labelledby="headingFour">
                      <div class="panel-body">
                          <div class="table-scrollable">
                              <table class="table table-striped table-bordered table-advance table-hover">
                                  </tbody>
                                  @for($a=0; $a < sizeof($jsonData->manuscript->authors); $a++)
                                    <tr>
                                        <td class="bg-primary text-white"><strong>Sequance</strong></td>
                                        <td>{{ $jsonData->manuscript->authors[$a]->sequence }}</td>
                                    </tr>
                                    <tr>
                                        <td><strong>First Name</strong></td>
                                        <td>{{ $jsonData->manuscript->authors[$a]->first_name }}</td>
                                    </tr>
                                    <tr>
                                        <td><strong>Middle Name</strong></td>
                                        <td>{{ $jsonData->manuscript->authors[$a]->middle_name }}</td>
                                    </tr>
                                    <tr>
                                        <td><strong>Last Name</strong></td>
                                        <td>{{ $jsonData->manuscript->authors[$a]->last_name }}</td>
                                    </tr>
                                    <tr>
                                        <td><strong>Email</strong></td>
                                        <td>{{ $jsonData->manuscript->authors[$a]->email }}</td>
                                    </tr>
                                    <tr>
                                        <td><strong>Is Principal</strong></td>
                                        <td> @if($jsonData->manuscript->authors[$a]->is_principal == 1)
                                              Yes
                                              @else
                                              No
                                              @endif
                                        </td>
                                    </tr>
                                    <tr>
                                        <td><strong>orcid</strong></td>
                                        <td>{{ $jsonData->manuscript->authors[$a]->orcid }}</td>
                                    </tr>
                                    <tr>
                                        <td><strong>H-Index</strong></td>
                                        <td>{{ $jsonData->manuscript->authors[$a]->h_index }}</td>
                                    </tr>
                                    <tr>
                                        <td><strong>Country</strong></td>
                                        <td>{{ $jsonData->manuscript->authors[$a]->country }}</td>
                                    </tr>
                                    @if(is_array($jsonData->manuscript->authors[$a]->affiliation))
                                    <tr>
                                        <td><strong>Affiliation</strong></td>
                                        <td>
                                          <table class="table table-striped table-bordered table-advance table-hover">
                                              </tbody>
                                            @for($b=0; $b < sizeof($jsonData->manuscript->authors[$a]->affiliation); $b++)
                                                <tr>
                                                    <td class="bg-primary text-white"><strong>Institute ID</strong></td>
                                                    <td>{{$jsonData->manuscript->authors[$a]->affiliation[$b]->institution_id}}</td>
                                                </tr>
                                                <tr>
                                                    <td><strong>Institution</strong></td>
                                                    <td>{{$jsonData->manuscript->authors[$a]->affiliation[$b]->institution}}</td>
                                                </tr>
                                                <tr>
                                                    <td><strong>Department</strong></td>
                                                    <td>{{$jsonData->manuscript->authors[$a]->affiliation[$b]->department}}</td>
                                                </tr>
                                                <tr>
                                                    <td><strong>Address</strong></td>
                                                    <td>{{$jsonData->manuscript->authors[$a]->affiliation[$b]->address}}</td>
                                                </tr>
                                                <tr>
                                                    <td><strong>Postal Code</strong></td>
                                                    <td>{{$jsonData->manuscript->authors[$a]->affiliation[$b]->postal_code}}</td>
                                                </tr>
                                                <tr>
                                                    <td><strong>Phone</strong></td>
                                                    <td>{{$jsonData->manuscript->authors[$a]->affiliation[$b]->phone}}</td>
                                                </tr>
                                                <tr>
                                                    <td><strong>Fax</strong></td>
                                                    <td>{{$jsonData->manuscript->authors[$a]->affiliation[$b]->fax}}</td>
                                                </tr>
                                                <tr>
                                                    <td><strong>City</strong></td>
                                                    <td>{{$jsonData->manuscript->authors[$a]->affiliation[$b]->city}}</td>
                                                </tr>
                                                <tr>
                                                    <td><strong>Country</strong></td>
                                                    <td>{{$jsonData->manuscript->authors[$a]->affiliation[$b]->country}}</td>
                                                </tr>
                                            @endfor          
                                          </table>
                                        </td>
                                    </tr>
                                    @endif
                                  @endfor    
                                  </tbody>
                              </table>
                          </div>
                      </div>
                  </div>
              </div>
              @endif
          </div>

        </div>
      </div>
  <?php  
    }
  }

  if($value->status == 0)
  {
      $param = array();
      $param['journal_id'] = $value->journal_id;
      $volume                = \App\Models\Volume::GetVolumeTitleById($param);
?> 
        @if(isset($value->volume_id))
        <form method="POST" action="{{ url('admin/jmscontent/' . $value->article_id) }}" id="articleForm" class="form-inline" enctype="multipart/form-data">
              <input type="hidden" name="_method" value="PUT">  
        @else
        <form method="POST" action="{{ route('jmscontent.store') }}" class="form-inline">
        @endif
		@csrf
        
       
          <div class="form-group col-md-4">
            <label for="volume_id">Volume</label>
            
              <select required class="form-control m-l-10" name="volume_id" id="volume_id"  @if(isset($value->volume_id)) disabled="true" @endif>
                <option selected="true" disabled="disabled" hidden >Select Volume</option>
                  @if ($volume)
                    @foreach($volume as $volume)
                      <option value="{{$volume->volume_id}}" @if($volume->volume_id == $value->volume_id) Selected @endif>{{$volume->volume_name}}</option>
                    @endforeach
                  @endif
              </select>
            
          </div>
        
        
          <div class="form-group col-md-4">
            <label for="volume_id">Article Type</label>
            
              <select required class="form-control w-150p m-l-10"  name="art_type" id="art_type"  @if(isset($value->article_type_id)) disabled="true" @endif>
                <option selected="true" disabled="disabled" hidden >Article Type</option>
                  @if ($article_type)
                    @foreach($article_type as $article_type)
                      <option value="{{$article_type->art_type_id}}" @if($article_type->art_type_id == $value->article_type_id) Selected @endif>{{$article_type->type_name}}</option>
                    @endforeach
                  @endif
              </select>
           
          </div>
       

       <div class="col-md-4">
          <input name="id" type="hidden" value="{{$value->id}}">
          <input name="journal_id" type="hidden" value="{{$value->journal_id}}">

          @if(isset($value->volume_id))
           
          <input name="art_type" type="hidden" value="{{$value->article_type_id}}">
          <input name="volume_id" type="hidden" value="{{$value->volume_id}}">

          <input type="submit" class="btn btn-primary btn-sm" name="update_status" value="Update Status">

          <input type="submit" class="btn btn-success btn-sm" name="update_article" value="Update Article">

   
          @else
               
          <input type="submit" class="btn btn-primary btn-sm" value="Import Article">
        
          @endif
        </div>
          </form> 
        
<?php } ?>          



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

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




