@extends('web.layouts.layout')
@section('content')

    <main>
        <!-- Start section -->
        @include('web.layouts.header')

        <section class="order_det_pg section py-5">
            <div class="container">
                <div class="order-details" id="printable">
                    <div class="row justify-content-center">
                        <div class="col-lg-10">
                            <div class="order-head">
                                <ul>
                                    <li>
                                        <p> {{ __('web.order_number') }}   : <span>{{$order->id}}</span></p>
                                    </li>
                                    <li>
                                        <p>{{ __('web.date') }}   : <span>{{$order->date}}</span></p>
                                    </li>
                                    <li>
                                        <p>{{ __('web.state') }}    : <span>{{__('web.'.$order->status)}}</span></p>
                                    </li>
                                    <li>
                                        <p>{{ __('web.payment_status') }}    : <span>{{$order->payment ? __('web.'.$order->payment->status) : ''}} @if($order->payment->status == 'installment') - {{$order->payment->installment->descriptions()->name}} @endif</span></p>
                                    </li>
                                    
                                    <li>
                                        <p>{{ __('web.shipping_method') }}    : <span>{{$order->shipping ? ($order->shipping->shipping_id ? $order->shipping->shipping->currentDescription->name : __('web.'.$order->shipping->shipping_status)) : ''}}</span></p>
                                    </li>
                                    @if( ($order->payment ? ($order->payment->cobon_status == 'birthday' ? 1 : 0) : ($order->payment->cobon_id ? 1 : 0 ) ) != 0)
                                        <li>
                                            <p>  {{ __('web.cobon') }}  : <span> {{$order->payment->cobon_status == 'birthday' ? __('web.cobon_birthday') : ($order->payment ? $order->payment->cobon->code : '')}} </span></p>
                                        </li>
                                    @endif
                                    @if($order->payment)
                                        <li>
                                            <p>  {{ __('web.payment_status') }} : <span>{{__('web.'.$order->payment->user_status_paid)}}</span></p>
                                        </li>
                                    @endif
                                    @if($order->address)
                                    <li>
                                        <p>{{ __('web.location') }}      : <span> {{$order->address->address->country->currentDescription->name}} - {{$order->address->address->city->currentDescription->name}} </span>
                                        </p>
                                    </li>
                                    @endif
                                </ul>
                            </div>
                        </div>
                    </div>
                    <div class="order-body">
                        <div class="table_box mb-5 py-0">
                            <div class="table-responsive">
                                <table class="table table-bordered mb-0">
                                    <thead>
                                    <tr>
                                        <th scope="col">  {{ __('web.product') }}  </th>
                                        <th scope="col">{{ __('web.product_name') }}  </th>
                                        <th scope="col">{{ __('web.quantity') }}</th>
                                        <th scope="col">{{ __('web.price') }} </th>
                                        <th scope="col"> {{ __('web.rating') }}  </th>
                                    </tr>
                                    </thead>
                                    <tbody>
                                    @foreach($products as $product)
                                        <tr>
                                        <td>
                                            <div class="img">
                                                <img src="{{asset($product->product->image)}}" alt="">
                                            </div>
                                        </td>
                                        <td>{{$product->product->currentDescription->name}}  </td>
                                        <td>{{$product->count}}</td>
                                        <td>{{currencyConvert($product->total)}} {{$currency->abbr}}</td>
                                        <td>
                                            @if($product->product->checkRate())
                                                <a @if($order->status == 'recieved') href="#" class="small color-primary" data-id="{{route('rating.product',$product->product_id)}}" onclick="rateProduct(this)" data-bs-toggle="modal" data-bs-target="#rateModal" @endif>
                                                    {{__('web.rate')}}
                                                </a>
                                                
                                            @else
                                                <a  class="small color-primary" >
                                                    {{__('web.rated')}}
                                                </a>
                                            @endif
                                        </td>
                                    </tr>
                                    @endforeach

                                    </tbody>
                                </table>
                            </div>
                        </div>
                        <div class="row justify-content-between">
                            <div class="col-lg-7">
                                <div class="pay_box">
                                    <ul>
                                        <li>
                                            <span> {{ __('web.product_costs') }} </span>
                                            <strong> {{$order->payment ? round(currencyConvert($order->payment->total_products - $order->payment->total_product_tax),2) : ''}} {{$currency->abbr}} </strong>
                                        </li>
                                        <li>
                                            <span> {{ __('web.tax') }} </span>
                                            <strong> {{$order->payment ? round(currencyConvert($order->payment->total_product_tax),2) : ''}} {{$currency->abbr}} </strong>
                                        </li>
                                        <li>
                                            <span> {{ __('web.total_product') }} </span>
                                            <strong> {{$order->payment ? round(currencyConvert($order->payment->total_products),2) : ''}} {{$currency->abbr}} </strong>
                                        </li>
                                        @if($order->payment->cobon_discount != 0)
                                            <li>
                                                <span> {{ __('web.cobon') }} </span>
                                                <strong> {{$order->payment ? round(currencyConvert($order->payment->cobon_discount),2) : ''}} {{$currency->abbr}} </strong>
                                            </li>
                                        @endif
                                        @if($order->payment->shipping_cost != 0)
                                            <li>
                                                <span> {{ __('web.shipping_cost') }} </span>
                                                <strong> {{round(currencyConvert($order->payment->shipping_cost),2)}} {{$currency->abbr}} </strong>
                                            </li>
                                        @endif
                                        @if($order->payment->status == 'when_recieving')
                                            <li>
                                                <span> {{ __('web.on_hand_payment') }} </span>
                                                <strong> {{round(currencyConvert($order->payment->on_hand_payment),2)}} {{$currency->abbr}} </strong>
                                            </li>
                                        @endif
                                        <li>
                                            <span> {{ __('web.total') }} </span>
                                            <strong> {{$order->payment ? round(currencyConvert($order->payment->total),2) : ''}} {{$currency->abbr}} </strong>
                                        </li>
                                    </ul>
                                </div>
                            </div>
                            <div class="col-lg-5">
                                <!--<div class="qr_box">-->
                                <!--    <img src="{{url('')}}/assets/web/images/qr_1.png" alt="" class="qr_img sec-img"/>-->
                                <!--</div>-->
                            </div>
                        </div>
                    </div>
                    <div class="col-lg-3 col-md-5 mt-5 m-auto">

                    </div>
                    <div class="text-center mt-5">
                        <button type="button" class="butn primary_butn d-inline-block" id="printButn"> {{ __('web.print') }}   </button>
                    </div>
                </div>
            </div>
        </section>
        <!-- Start section -->
        @include('web.layouts.newsletter')
    </main>

    <div class="modal  rateModal fade" id="rateModal" tabindex="-1" aria-labelledby="exampleModalLabel" aria-hidden="true">
        <div class="modal-dialog modal-dialog-centered modal-lg">
            <div class="modal-content">
                <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
                <div class="modal-body">
                    <img src="{{url('')}}/assets/web/images/modals/rate-1.png" alt="" class="img"/>
                    <div class="content text-center mt-4">
                        <h4 class="title text-dark mb-4"><b>{{ __('web.rate_product') }}  </b></h4>
                        <form id="form_rate" method="post" onsubmit="formAction(this)">
                            @CSRF
                            <div class="stars-content mb-5">
                                <div class="star-rating">
                                    <input type="radio" id="5-stars" name="rate" value="5" />
                                    <label for="5-stars" class="star"><i class="fas fa-star"></i></label>
                                    <input type="radio" id="4-stars" name="rate" value="4" />
                                    <label for="4-stars" class="star"><i class="fas fa-star"></i></label>
                                    <input type="radio" id="3-stars" name="rate" value="3" />
                                    <label for="3-stars" class="star"><i class="fas fa-star"></i></label>
                                    <input type="radio" id="2-stars" name="rate" value="2" />
                                    <label for="2-stars" class="star"><i class="fas fa-star"></i></label>
                                    <input type="radio" id="1-star" name="rate" value="1" />
                                    <label for="1-star" class="star"><i class="fas fa-star"></i></label>
                                </div>
                            </div>
                            <div class="form-group col-md-10 m-auto">
                                <h6 class="title mb-3">{{ __('web.write_comment') }}  </h6>
                                <textarea class="form-control" name="comment" placeholder="Write here  " rows="7"></textarea>
                            </div>
                            <div class="inFlex justify-content-center mt-5">
                                <button type="button" class="butn btn-secondary mx-1" data-bs-dismiss="modal">{{ __('web.close') }} </button>
                                <button type="submit" class="butn primary_butn mx-1">{{ __('web.submit') }} </button>
                            </div>
                        </form>
                    </div>
                </div>
            </div>
        </div>
    </div>
@section('inject_js')
<script src="{{url('')}}/assets/web/js/lib/jQuery.print.min.js"></script>
<script>
        $('#printButn').on('click', function() 
        {
            $("#printable").print();
        });
</script>
    <script>

            
        
        function rateProduct(elem)
        {
            let url = $(elem).attr('data-id');
            $('#form_rate').attr('action',url);
        }
    </script>
@endsection

@stop
