<?php $__env->startSection('title','Order Detail'); ?>

<?php $__env->startSection('main-content'); ?>
<div class="card">

  <h5 class="card-header">
Order

<?php if($order->shiprocket_invoice_url): ?>
<a href="<?php echo e($order->shiprocket_invoice_url); ?>"
target="_blank"
class="btn btn-sm btn-success shadow-sm float-right">
<i class="fas fa-download"></i> Shiprocket Invoice
</a>
<?php else: ?>
<span class="badge badge-secondary float-right">
Invoice Not Generated
</span>
<?php endif; ?>

</h5>
  <div class="card-body">
    <?php if($order): ?>
    <table class="table table-striped table-hover">
      <thead>
        <tr>
          <th>ID</th>
          <th>Order No</th>
          <th>Customer</th>
          <th>Payment</th>
          <th>Qty</th>
          <th>Subtotal</th>
          <th>Delivery</th>
          <th>Total</th>
          <th>Status</th>
        </tr>
      </thead>

      <tbody>
        <tr>
          <td><?php echo e($order->id); ?></td>

          <td><?php echo e($order->order_number); ?></td>

          <td>
            <?php echo e($order->first_name); ?> <?php echo e($order->last_name); ?>

            <br>
            <small><?php echo e($order->email); ?></small>
          </td>

          <td>
            <?php echo e($order->payment_method); ?>

            <br>
            <small><?php echo e($order->payment_status); ?></small>
          </td>

          <td><?php echo e($order->quantity); ?></td>

          <td>₹ <?php echo e(number_format($order->sub_total,2)); ?></td>

          <td>₹ <?php echo e(number_format($order->delivery_charge,2)); ?></td>

          <td><strong>₹ <?php echo e(number_format($order->total_amount,2)); ?></strong></td>

          <td>
            <?php if($order->status=='new'): ?>
            <span class="badge badge-primary">New</span>

            <?php elseif($order->status=='process'): ?>
            <span class="badge badge-warning">Processing</span>

            <?php elseif($order->status=='delivered'): ?>
            <span class="badge badge-success">Delivered</span>

            <?php else: ?>
            <span class="badge badge-danger">Cancelled</span>
            <?php endif; ?>
          </td>

        </tr>
      </tbody>
    </table>
    <section class="confirmation_part section_padding">
      <div class="order_boxes">
        <div class="row">
          <div class="col-lg-6 col-lx-4">
            <div class="order-info">
              <h4 class="text-center pb-4">ORDER INFORMATION</h4>

              <table class="table">

                <tr>
                  <td>Order Number</td>
                  <td><?php echo e($order->order_number); ?></td>
                </tr>

                <tr>
                  <td>Order Date</td>
                  <td><?php echo e($order->created_at->format('d M Y H:i')); ?></td>
                </tr>

                <tr>
                  <td>Subtotal</td>
                  <td>₹ <?php echo e(number_format($order->sub_total,2)); ?></td>
                </tr>

                <tr>
                  <td>Delivery Charge</td>
                  <td>₹  <?php echo e(number_format($order->delivery_charge,2)); ?></td>
                </tr>

                <tr>
                  <td>Coupon</td>
                  <td>₹  <?php echo e(number_format($order->coupon ?? 0,2)); ?></td>
                </tr>

                <tr>
                  <td>Total Amount</td>
                  <td><strong>₹<?php echo e(number_format($order->total_amount,2)); ?></strong></td>
                </tr>

                <tr>
                  <td>Quantity</td>
                  <td><?php echo e($order->quantity); ?></td>
                </tr>

                <tr>
                  <td>Payment Method</td>
                  <td><?php echo e($order->payment_method); ?></td>
                </tr>

                <tr>
                  <td>Payment Status</td>
                  <td><?php echo e($order->payment_status); ?></td>
                </tr>

              </table>
              <hr>
              <h4 class="text-center pb-4">PAYMENT DETAILS</h4>

              <table class="table">

                <tr>
                  <td>Razorpay Order ID</td>
                  <td><?php echo e($order->razorpay_order_id ?? 'N/A'); ?></td>
                </tr>

                <tr>
                  <td>Razorpay Payment ID</td>
                  <td><?php echo e($order->razorpay_payment_id ?? 'N/A'); ?></td>
                </tr>

                <tr>
                  <td>Signature</td>
                  <td><?php echo e($order->razorpay_signature ?? 'N/A'); ?></td>
                </tr>

              </table>
              <hr>


              <h4 class="text-center pb-4">SHIPMENT INFORMATION</h4>

              <table class="table">

                <tr>
                  <td>Shiprocket Order</td>
                  <td><?php echo e($order->shiprocket_order_ref ?? 'Not Created'); ?></td>
                </tr>

                <tr>
                  <td>Shipment ID</td>
                  <td><?php echo e($order->shipment_id ?? 'Not Created'); ?></td>
                </tr>

                <tr>
                  <td>Courier</td>
                  <td><?php echo e($order->courier_name ?? 'Not Assigned'); ?></td>
                </tr>

                <tr>
                  <td>AWB Code</td>
                  <td><?php echo e($order->awb_code ?? 'Not Generated'); ?></td>
                </tr>

                <tr>
                  <td>Status</td>
                  <td><?php echo e($order->shiprocket_status ?? 'Pending'); ?></td>
                </tr>

                <tr>
                  <td>Tracking</td>
                  <td>
                    <?php if($order->tracking_url): ?>
                    <a href="<?php echo e($order->tracking_url); ?>" target="_blank" class="btn btn-sm btn-info">
                      Track Shipment
                    </a>
                    <?php else: ?>
                    Not Available
                    <?php endif; ?>
                  </td>
                </tr>

<tr>
<td>Order Invoice</td>  
<td>
<?php if($order->shiprocket_invoice_url): ?>
<a href="<?php echo e($order->shiprocket_invoice_url); ?>" target="_blank" class="btn btn-sm btn-success">
Download Invoice
</a>
<?php else: ?>
<span class="text-muted">Invoice Not Generated</span>
<?php endif; ?>
</td>
</tr>

<tr>
<td>Shipping Label</td>
<td>
<?php if($order->label_url): ?>
<a href="<?php echo e($order->label_url); ?>" target="_blank" class="btn btn-sm btn-secondary">
Download Label
</a>
<?php else: ?>
Not Generated
<?php endif; ?>
</td>
</tr>




                <?php if(!$order->shipment_id): ?>

                <tr>
                  <td>Create Shipment</td>

                  <td>
                    <form method="POST" action="<?php echo e(route('admin.order.createShipment',$order->id)); ?>">
                      <?php echo csrf_field(); ?>
                      <button class="btn btn-primary">
                        Create Shiprocket Shipment
                      </button>
                    </form>
                  </td>

                </tr>

                <?php endif; ?>




                <tr>
                  <td colspan="2">
                    <hr>
                  </td>
                </tr>

                <?php if($order->return_shipment_id): ?>

                <tr>
                  <td>Return Shipment ID</td>
                  <td><?php echo e($order->return_shipment_id); ?></td>
                </tr>

                <tr>
                  <td>Return AWB</td>
                  <td><?php echo e($order->return_awb_code); ?></td>
                </tr>

                <?php endif; ?>

                <tr>
                  <td colspan="2">
                    <h4 class="text-center">EXCHANGE</h4>
                  </td>
                </tr>

                <?php if($order->exchange_requested && $order->exchange_status == 'requested'): ?>

                <tr>
                  <td>Exchange Request</td>

                  <td>
                    <form method="POST" action="<?php echo e(route('admin.order.schedulePickup',$order->id)); ?>">
                      <?php echo csrf_field(); ?>

                      <button class="btn btn-warning">
                        Schedule Return Pickup
                      </button>

                    </form>
                  </td>

                </tr>

                <?php endif; ?>

                <?php if($order->exchange_requested): ?>

                <tr>
                  <td>Exchange Status</td>
                  <td><?php echo e($order->exchange_status ?? 'Requested'); ?></td>
                </tr>

                <?php endif; ?>

                <?php if($order->exchange_status == 'pickup_scheduled' && !$order->shipment_id): ?>

                <tr>
                  <td>Create Replacement</td>

                  <td>
                    <form method="POST" action="<?php echo e(route('admin.order.exchange',$order->id)); ?>">
                      <?php echo csrf_field(); ?>

                      <button class="btn btn-primary">
                        Create Replacement Order
                      </button>

                    </form>
                  </td>

                </tr>

                <?php endif; ?>
              </table>
            </div>
          </div>

          <div class="col-lg-6 col-lx-4">
            <div class="shipping-info">
              <h4 class="text-center pb-4">CUSTOMER ADDRESS</h4>

              <table class="table">

                <tr>
                  <td>Name</td>
                  <td><?php echo e($order->first_name); ?> <?php echo e($order->last_name); ?></td>
                </tr>

                <tr>
                  <td>Email</td>
                  <td><?php echo e($order->email); ?></td>
                </tr>

                <tr>
                  <td>Phone</td>
                  <td><?php echo e($order->phone); ?></td>
                </tr>

                <tr>
                  <td>Country</td>
                  <td><?php echo e($order->country); ?></td>
                </tr>

                <tr>
                  <td>State</td>
                  <td><?php echo e($order->state ?? 'N/A'); ?></td>
                </tr>

                <tr>
                  <td>City</td>
                  <td><?php echo e($order->city ?? 'N/A'); ?></td>
                </tr>

                <tr>
                  <td>Postal Code</td>
                  <td><?php echo e($order->post_code ?? 'N/A'); ?></td>
                </tr>

                <tr>
                  <td>Address</td>
                  <td><?php echo e($order->address1); ?> <?php echo e($order->address2); ?></td>
                </tr>

              </table>
            </div>
          </div>
        </div>
      </div>
    </section>
    <?php endif; ?>

  </div>
</div>
<?php $__env->stopSection(); ?>

<?php $__env->startPush('styles'); ?>
<style>
  .order-info,
  .shipping-info {
    background: #ECECEC;
    padding: 20px;
  }

  .order-info h4,
  .shipping-info h4 {
    text-decoration: underline;
  }
</style>
<?php $__env->stopPush(); ?>
<?php echo $__env->make('backend.layouts.master', \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?><?php /**PATH /var/www/ecommerce_website/resources/views/backend/order/show.blade.php ENDPATH**/ ?>