@extends('admin.layouts.app')
@section('title', "پنل مدیریت | چاپ سفارش")
@section('content')
<div class="content-wrapper">
<div class="content-header">
<div class="container-fluid">
<div class="row mb-2">
<div class="col-sm-6">
<button class="btn btn-primary" type="button" id="print">
<span class="fa fa-print"></span> چاپ کن
</button>
</div>
<div class="col-sm-6">
<ol class="breadcrumb float-sm-left">
{{ Breadcrumbs::render('orders-show', $order) }}
</ol>
</div>
</div>
</div>
</div>
<section class="content" id="printable">
<div class="container-fluid">
<div class="row">
<div class="col-md-12">
<div class="card card-primary">
<div class="card-body">
<div class="table-responsive">
<table class="table table-hover table-condensed table-bordered table-striped tbl-card">
<thead class="thead">
<tr>
<th scope="col">خریدار</th>
<th scope="col">موبایل</th>
<th scope="col">کد پیگیری</th>
<th scope="col">قیمت (تومان)</th>
<th scope="col">نوع پرداخت</th>
<th scope="col">وضعیت</th>
<th scope="col">تاریخ ثبت سفارش</th>
</tr>
</thead>
<tbody>
<tr>
<td>{{ $order->user->name }}</td>
<td>{{ to_persian_numbers($order->user->mobile) }}</td>
<td>{{ $order->tracking_code }}</td>
<td>{{ to_persian_numbers(number_format($order->price)) }}</td>
<td>{{ $order->payment_type->description }}</td>
<td>{{ $order->status->description }}</td>
<td>{{ to_persian_numbers(jdate($order->created_at)) }}</td>
</tr>
</tbody>
</table>
</div>
<div class="table-responsive">
<table class="table table-hover table-condensed table-bordered table-striped tbl-card">
<thead>
<tr class="text-center">
<th>#</th>
<th>نام</th>
<th>کد</th>
<th>تعداد</th>
<th>قیمت واحد</th>
<th>تخفیف واحد</th>
<th>جمع کل</th>
</tr>
</thead>
<tbody>
@foreach($orderProducts as $orderProduct)
<tr class="text-center">
<td>{{ $loop->iteration }}</td>
<td>
@if($orderProduct->product->slug)
<a href="{{ route('products.show', $orderProduct->product->slug) }}"
class="text-dark"
target="_blank">
{{ $orderProduct->name }}
</a>
@else
{{ $orderProduct->name }}
@endif
</td>
<td>{{ $orderProduct->product->code }}</td>
<td>{{ to_persian_numbers($orderProduct->quantity) }}</td>
<td>{{ to_persian_numbers(number_format($orderProduct->price + $orderProduct->discount)) }}</td>
<td>{{ to_persian_numbers(number_format($orderProduct->discount)) }}</td>
<td>{{ to_persian_numbers(number_format($orderProduct->price * $orderProduct->quantity)) }}</td>
</tr>
@endforeach
</tbody>
<tfoot>
@if($order->discount_code_price)
<tr>
<th colspan="6">
کد تخفیف
@if($order->discountCode->title)
<a href="{{ route('admin.discounts.show', $order->discountCode->id) }}"
target="_blank">
({{ $order->discountCode->title }})
</a>
@endif
</th>
<td class="text-center">{{ to_persian_numbers(number_format($order->discount_code_price)) }}</td>
</tr>
@endif
@if($order->discount)
<tr>
<th colspan="6">مجموع تخفیف</th>
<td class="text-center">{{ to_persian_numbers(number_format($order->discount + $order->discount_code_price)) }}</td>
</tr>
@endif
<tr>
<th colspan="6">هزینه ارسال
({{ is_null($order->shipping_type) ? 'رایگان' : \App\Models\Order::SHIPPING_TRANSLATE[$order->shipping_type] }}
)
</th>
<td class="text-center">
{{ to_persian_numbers(number_format($order->shipping_price)) }}
</td>
</tr>
<tr>
<th colspan="6">جمع کل</th>
<td class="text-center">{{ to_persian_numbers(number_format($order->price)) }}</td>
</tr>
</tfoot>
</table>
</div>
<div class="table-responsive">
<table
class="table table-hover table-condensed table-bordered table-striped tbl-card">
<thead>
<tr>
<th>نام گیرنده</th>
<th>موبایل</th>
<th>کدملی</th>
<th>استان</th>
<th>شهر</th>
<th>کدپستی</th>
<th>پلاک</th>
<th>واحد</th>
</tr>
</thead>
<tbody>
<tr>
<td>{{ $address->name }}</td>
<td>{{ to_persian_numbers($address->mobile) }}</td>
<td>{{ to_persian_numbers($address->national_code) }}</td>
<td>{{ $address->city->province->name }}</td>
<td>{{ $address->city->name }}</td>
<td>{{ to_persian_numbers($address->postal_code) }}</td>
<td>{{ to_persian_numbers($address->plaque) }}</td>
<td>{{ to_persian_numbers($address->floor) }}</td>
</tr>
</tbody>
<tfoot>
<tr>
<th>آدرس کامل</th>
<td colspan="7">{{ $address->address }}</td>
</tr>
@if($order->delivery_date && $order->delivery_time)
<tr>
<th colspan="4">تاریخ تحویل</th>
<th colspan="4">زمان تحویل</th>
</tr>
<tr>
<td colspan="4">
{{ to_persian_numbers(jdate($order->delivery_date)->format('Y/m/d')) }}
</td>
<td colspan="4">
{{ to_persian_numbers($order->delivery_time) }}
</td>
</tr>
@endif
</tfoot>
</table>
</div>
@if($order->description)
<div>
<strong>توضیحات کاربر: </strong>
{{ $order->description }}
</div>
@endif
</div>
</div>
</div>
</div>
</div>
</section>
</div>
@endsection
@section('footer')
<script>
$(document).on('click', '#print', function () {
$('#printable').printThis({header: "", footer: ""});
});
</script>
@endsection