<style>
    .card_reference {
        background: #fff !important;
        padding: 25px !important;
        color: #000 !important;
    }
</style>
@if(!empty($param['vip']))
<div class="pt-4">
    <div class="alert alert-dismissible text-black" role="alert" style="background-color:pink">
        <span class="fw-bolder">Attention!</span> {{$param['vip']->comments}}
		@if(Auth()->user()->id != 597511)
		<br><br>
        @if(!empty($param['manuscript_price']))

        @if($param['vip']->apc_discount == 100)
        <span class="fw-bolder f-16 bg-danger p-1">Listed APC: US$ 0</span>
        @else
        <span class="fw-bolder f-16 bg-danger p-1">Listed APC: US$ {{$param['manuscript_price']->sprice}}</span>
        @endif

        @if(!empty($param['vip']->apc_discount) && $param['vip']->apc_discount != 100)
        @php
        $originalPrice = $param['manuscript_price']->sprice;
        $discountPercentage = $param['vip']->apc_discount;
        $discount = $originalPrice * ($discountPercentage / 100);
		$discountedPrice    = $originalPrice - $discount;
        @endphp
        <span class="fw-bolder f-16 bg-secondary p-1">Applicable discounted APC: US$ {{$discountedPrice}}</span>
        @endif

        @else
        @php
        $originalPrice = $param['journal_apc']->service_journal_price;
        $discountPercentage = $param['vip']->apc_discount;
        $discount = round($originalPrice * ($discountPercentage / 100));
		$discountedPrice    = $originalPrice - $discount;
        @endphp
        <span class="fw-bolder f-16 bg-danger p-1">Listed APC: US$ {{$originalPrice}}</span>
        <span class="fw-bolder f-16 bg-secondary p-1">Applicable discounted APC: US$ {{$discountedPrice}}</span>
        @endif
		@endif
    </div>
</div>
@endif
@if ($message = Session::get('message'))
<div class="pt-4">
    <div class="alert alert-danger">{{ $message }}</div>
</div>
@endif

<h4 class="pt-3"><b>SUBMISSION DETAILS</b></h4>
<div class="card mb-4 detail_table">
    <div class="row">
        <div class="col-12 col-md-12">
            <h5 class="card-header card_reference border-bottom"><b>{{$manuscript_data->reference_number}}</b></h5>
        </div>
    </div>
    <div class="table-responsive overflow-v">
        <table class="memberTable">
            <tr>
                <th class="border-right">Submission Type</th>
                <td>Manuscript</td>
            </tr>
            <tr>
                <th class="border-right">Title</th>
                <td class="text-wrap">{{$manuscript_data->title}}</td>
            </tr>
            <tr>
                <th class="border-right">Abstract</th>
                <td> <button type="button" class="btn btn-pill btn-primary btn-air-primary text-white" data-toggle="modal" data-target="#modalAbstract">View Abstract</button>
                @if(!empty($param['article_data']))
                    <a target="_blank" type="button" class="btn btn-pill btn-primary btn-air-primary text-white" href="https://eurekaselect.com/article/{{$param['article_data']->article_id}}" style="background-color:#EC6608 !important;box-shadow: 0px 4px 15px rgba(236, 102, 8, 0.2) !important; border-color: #EC6608 !important;">View Online Version</button></a>

                    <form action="{{ route('download_article') }}" method="POST" class="mb-0 d-inline" id="download-form-{{ $param['article_data']->article_id }}">
						<input type="hidden" value="{{csrf_token()}}" name="_token">
						<input type="hidden" name="agree-flag" id="agree-flag" value="1">
						<input type="hidden" name="param" value="{{Crypt::encrypt($param['article_data']->article_id.'||'.'pdf'.'||'.'S'.'||'.' '.'||'.' ' )}}">
						<button type="submit" id="{{$param['article_data']->article_id}}" name="download{{$param['article_data']->article_id}}" class="btn btn-pill btn-success btn-air-primary text-white">Download PDF File</button>
					</form>
                    @elseif(!empty($param['jms_journal']))
                    <a target="_blank" type="button" class="btn btn-pill btn-primary btn-air-primary text-white" href="{{$param['jms_journal']->URL}}" style="background-color:#EC6608 !important;box-shadow: 0px 4px 15px rgba(236, 102, 8, 0.2) !important; border-color: #EC6608 !important;">View Online Version</button></a>
                @endif

                    @if(!empty($param['manuscript_file_id']))
                    <a target="_blank" type="button" class="btn btn-pill btn-primary btn-air-primary text-white" href="https://bentham.manuscriptpoint.com/DownloadFile/DownloadHere/{{$param['manuscript_file_id']}}" style="background-color:#EC6608 !important;box-shadow: 0px 4px 15px rgba(236, 102, 8, 0.2) !important; border-color: #EC6608 !important;">Download Manuscript File</button></a>
                    @endif

                <!-- Modal -->
                <div class="modal fade" id="modalAbstract" data-keyboard="false" tabindex="-1" aria-labelledby="staticBackdropLabel" aria-hidden="true">
                    <div class="modal-dialog modal-dialog-scrollable" role="document">
                        <div class="modal-content">
                            <div class="modal-header border-bottom">
                                <h5 class="modal-title fw-bolder" id="modalAbstractTitle">Abstract</h5>
                            </div>
                            <div class="modal-body">
                                <p class="text-wrap">{{$manuscript_data->abstract}}</p>
                            </div>
                            <div class="modal-footer">
                                <button type="button" class="btn btn-light" data-dismiss="modal">
                                    Close
                                </button>
                            </div>
                        </div>
                    </div>
                </div>
                </td>
            </tr>
            <tr>
                <th class="border-right">Submitted Date</th>
                <td>{{gmdate("d-m-Y", $manuscript_data->date_submitted)}}</td>
            </tr>
        </table>
    </div>
</div>

<div class="card detail_table">
    <div class="row align-items-center ">
        <div class="col-12">
            <h5 class="card-header card_reference"><b>AUTHORS</b> <small style="font-size:12px" class="text-danger">(* is Prinicipal Author)</small></h5>
        </div>
    </div>
    <div class="table-responsive overflow-v">
        <table class="memberTable">
            <thead>
                <tr>
                    <th>Sr No.</th>
                    <th>First Name</th>
                    <th>Middle Name</th>
                    <th>Last Name</th>
                    <th>Field of Expertise</th>
                    <th>Affiliation</th>
                </tr>
            </thead>
            <tbody>
                @if(count($authors_list)>0)
                @php $a=1; @endphp
                @foreach($authors_list as $authors)
                <tr @if($authors->institution_id == $param['grid_id']) class="table-info"
                    @endif>
                    <td>{{ $a }}</td>
                    @if($authors->is_principal == 1)
                    <td class="text-danger">*{{$authors->first_name}}</td>
                    @else
                    <td>{{$authors->first_name}}</td>
                    @endif
                    <td>{{$authors->middle_name}}</td>
                    <td>{{$authors->last_name}}</td>
                    <td>{{$authors->field_of_expertise}}</td>
                    <td><button type="button" class="btn btn-pill btn-primary btn-air-primary" style="background-color:#EC6608 !important;box-shadow: 0px 4px 15px rgba(236, 102, 8, 0.2) !important; border-color: #EC6608 !important;" data-toggle="modal" data-target="#affModal{{$authors->author_id}}" id="user_theme_button3">View</button></td>

                    <!-- Modal -->
                    <div class="modal fade" id="affModal{{$authors->author_id}}" tabindex="-1" aria-hidden="true">
                        <div class="modal-dialog modal-dialog-scrollable" role="document">
                            <div class="modal-content mb-0">
                                <div class="modal-header border-bottom">
                                    <h5 class="modal-title fw-bolder" id="affModalTitle">Author Affiliation</h5>
                                </div>
                                <div class="modal-body py-0">
                                    <div class="row">
                                        <div class="col-4 py-2 border-bottom bg-warning text-white">Institution</div>
                                        <div class="col-8 py-2 border-bottom text-wrap">{{$authors->institution}}</div>
                                    </div>
                                    <div class="row">
                                        <div class="col-4 py-2 border-bottom bg-warning text-white">Department</div>
                                        <div class="col-8 py-2 border-bottom text-wrap">{{$authors->department}}</div>
                                    </div>
                                    <div class="row">
                                        <div class="col-4 py-2 border-bottom bg-warning text-white">Address</div>
                                        <div class="col-8 py-2 border-bottom text-wrap">{{$authors->address}}</div>
                                    </div>
                                    <div class="row">
                                        <div class="col-4 py-2 border-bottom bg-warning text-white">Country</div>
                                        <div class="col-8 py-2 border-bottom">{{$authors->nicename}}</div>
                                    </div>
                                    <div class="row">
                                        <div class="col-4 py-2 border-bottom bg-warning text-white">State</div>
                                        <div class="col-8 py-2 border-bottom">{{$authors->state}}</div>
                                    </div>
                                    <div class="row">
                                        <div class="col-4 py-2 border-bottom bg-warning text-white">City</div>
                                        <div class="col-8 py-2 border-bottom">{{$authors->city}}</div>
                                    </div>
                                    <div class="row">
                                        <div class="col-4 py-2 border-bottom bg-warning text-white">Postal Code</div>
                                        <div class="col-8 py-2 border-bottom">{{$authors->postal_code}}</div>
                                    </div>
                                    <div class="row">
                                        <div class="col-4 py-2 border-bottom bg-warning text-white">Phone</div>
                                        <div class="col-8 py-2 border-bottom">{{$authors->phone}}</div>
                                    </div>
                                </div>
                                <div class="modal-footer">
                                    <button type="button" class="btn btn-light" data-dismiss="modal">
                                        Close
                                    </button>
                                </div>
                            </div>
                        </div>
                    </div>
                    <!-- Modal End-->

                </tr>
                @php $a++; @endphp
                @endforeach
                @else
                <tr>
                    <td colspan="6" class="text-center">No Record</td>
                </tr>
                @endif
            </tbody>
        </table>
    </div>
</div>

@if(!empty($param['btn_show']))
<div class="d-flex justify-content-center pt-4 mb-3">
    <button data-toggle="modal" data-id="{{$manuscript_data->manuscript_id}}" data-status-id="1" class="open-ConfirmManuscript btn btn-primary btn-air-primary text-white mr-2" href="#modalToggle">Approve</button>
    <button data-toggle="modal" data-id="{{$manuscript_data->manuscript_id}}" data-status-id="0" class="open-ConfirmManuscript btn btn-danger btn-air-danger text-white" href="#modalToggle">Reject</button>
</div>

<div class="modal fade" id="modalToggle">
    <div class="modal-dialog modal-dialog-centered">
        <div class="modal-content">
            <div class="modal-header border-bottom">
                <h5 class="modal-title text-danger" id="modalToggleLabel">Confirmation!</h5>
            </div>
            <form method="post" action="/member/add-manuscript" enctype="multipart/form-data">
                <div class="modal-body border-bottom">Are you sure?
                    <input type="hidden" name="_token" value="<?= csrf_token() ?>">
                    <input type="text" name="manuscriptId" id="manuscriptId" value="" hidden />
                    <input type="text" name="statusId" id="statusId" value="" hidden />
                </div>
                <div class="modal-footer">
                    <button type="submit" name="check" class="btn btn-primary btn-air-primary text-white" name="submit">YES</button>
                    <button id='closeModal' type="button" class="btn btn-light" data-dismiss="modal">NO</button>
                </div>
            </form>
        </div>
    </div>
</div>
<!-- Import jquery cdn -->
<script src="https://code.jquery.com/jquery-3.5.1.slim.min.js" integrity="sha384-DfXdz2htPH0lsSSs5nCTpuj/zy4C+OGpamoFVy38MVBnE+IbbVYUew+OrCXaRkfj" crossorigin="anonymous">
</script>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@4.5.3/dist/js/bootstrap.bundle.min.js" integrity="sha384-ho+j7jyWK8fNQe+A12Hb8AhRq26LrZ/JpcUGGOn+Y7RsweNrtN/tE3MoK7ZeZDyx" crossorigin="anonymous">
</script>
<script>
    $(document).on("click", ".open-ConfirmManuscript", function() {
        var mymanuscriptId = $(this).data('id');
        var mystatusId = $(this).data('status-id');
        $(".modal-body #manuscriptId").val(mymanuscriptId);
        $(".modal-body #statusId").val(mystatusId);
    });
</script>
@endif