

<?php $__env->startSection('content'); ?>

<div class="container-fluid mt-4">

    
    <div class="d-flex justify-content-between align-items-center mb-3">
        <h4 class="mb-0">Order #<?php echo e($order->id); ?></h4>

        <a href="<?php echo e(url()->previous()); ?>" class="btn btn-outline-secondary btn-sm">
            ← Back
        </a>
    </div>

    
    <div class="row">

        
        <div class="col-md-4">
            <div class="card shadow-sm mb-3">
                <div class="card-header bg-white">
                    <strong>Order Information</strong>
                </div>

                <div class="card-body">
                    <p><strong>Order ID:</strong> #<?php echo e($order->id); ?></p>

                    <p>
                        <strong>Status:</strong>
                        <?php if($order->delivery_status == 'delivered'): ?>
                                 <span class="badge bg-success">Delivered</span>

                           <?php elseif($order->delivery_status == 'cancelled'): ?>
                                 <span class="badge bg-danger">Cancelled</span>

                           <?php else: ?>
                                 <span class="badge bg-warning">Pending</span>
                           <?php endif; ?>
                    </p>

                    <p>
                        <strong>Date:</strong>
                        <?php echo e(\Carbon\Carbon::createFromTimestamp($order->created_at)->format('d M Y h:i A')); ?>

                    </p>

                    <p>
                        <strong>Payment:</strong>
                        <?php echo e($order->payment_method ?? 'COD'); ?>

                    </p>

                    <p>
                        <strong>Total:</strong>
                        <span class="text-success fw-bold">
                            Rs <?php echo e(number_format($order->grand_total, 2)); ?>

                        </span>
                    </p>
                </div>
            </div>
        </div>

        
        <div class="col-md-4">
            <div class="card shadow-sm mb-3">
                <div class="card-header bg-white">
                    <strong>Customer Information</strong>
                </div>

                <div class="card-body">
                    <p>
                        <strong>Name:</strong>
                        <?php echo e($order->user->first_name ?? ''); ?> <?php echo e($order->user->last_name ?? ''); ?>

                    </p>

                    <p>
                        <strong>Email:</strong>
                        <?php echo e($order->user->email ?? ''); ?>

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

        
        <div class="col-md-4">
            <div class="card shadow-sm mb-3">
                <div class="card-header bg-white">
                    <strong>Shipping Address</strong>
                </div>

                <div class="card-body">
                    

                    <p><strong><?php echo e($order->shipping_address['name'] ?? ''); ?></strong></p>
                    <p><?php echo e($order->shipping_address['address'] ?? ''); ?></p>
                    <p><?php echo e($order->shipping_address['city'] ?? ''); ?>, <?php echo e($order->shipping_address['state'] ?? ''); ?></p>
                    <p><?php echo e($order->shipping_address['country'] ?? ''); ?> - <?php echo e($order->shipping_address['postal_code'] ?? ''); ?></p>
                    <p><strong>Phone:</strong> <?php echo e($order->shipping_address['phone'] ?? ''); ?></p>
                </div>
            </div>
        </div>

    </div>

    
    <div class="card shadow-sm mt-3">

        <div class="card-header bg-white">
            <strong>Ordered Products</strong>
        </div>

        <div class="card-body p-0">

            <div class="table-responsive">
                <table class="table table-hover align-middle mb-0">

                    <thead class="table-light">
                        <tr>
                            <th>#</th>
                            <th>Product</th>
                            <th>Price</th>
                            <th>Qty</th>
                            <th>Total</th>
                        </tr>
                    </thead>

                    <tbody>
                        <?php $grandTotal = 0; ?>

                        <?php $__currentLoopData = $order->orderDetails; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $key => $item): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>

                            <?php
                                $total = $item->price * $item->quantity;
                                $grandTotal += $total;
                            ?>

                            <tr>
                                <td><?php echo e($key + 1); ?></td>

                                <td>
                                    <strong><?php echo e($item->product->name ?? 'Deleted Product'); ?></strong>
                                    <small class="text-muted"> <?php echo e($item->variation ?? ''); ?>

                                </td>

                                <td>Rs. <?php echo e($item->price); ?></td>

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

                                <td class="text-success fw-bold">
                                    Rs. <?php echo e($total); ?>

                                </td>
                            </tr>

                        <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                    </tbody>

                    <tfoot class="table-light">
                        <tr>
                            <th colspan="4" class="text-end">Grand Total</th>
                            <th class="text-success">
                                Rs. <?php echo e($grandTotal); ?>

                            </th>
                        </tr>
                    </tfoot>

                </table>
            </div>

        </div>
    </div>

    

    <div class="card-footer text-end border-top pt-4">

    <button type="button"
        class="btn btn-success rounded-pill px-4"
        data-bs-toggle="modal"
        data-bs-target="#confirmOrderModal">
        <i class="las la-check-circle"></i> Confirm Order
    </button>

    <button type="button"
        class="btn btn-danger rounded-pill px-4 ms-2"
        data-bs-toggle="modal"
        data-bs-target="#cancelOrderModal">
        <i class="las la-times-circle"></i> Cancel Order
    </button>

     <a href="<?php echo e(route('admin.order.print', $order->id)); ?>"
       target="_blank"
       class="btn btn-info rounded-pill px-4">
        <i class="las la-print"></i> Print
    </a>

</div>

</div>



<div class="modal fade" id="confirmOrderModal" tabindex="-1">
    <div class="modal-dialog modal-dialog-centered">
        <div class="modal-content">

            <div class="modal-header">
                <h5 class="modal-title">Confirm Order</h5>
                <button type="button" class="btn-close" data-bs-dismiss="modal"></button>
            </div>

            <div class="modal-body">
                Are you sure you want to mark this order as Confirmed?
            </div>

            <div class="modal-footer">
                <button type="button"
                    class="btn btn-secondary"
                    data-bs-dismiss="modal">
                    No
                </button>

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

                    <button type="submit" class="btn btn-success">
                        Yes, Confirm
                    </button>
                </form>
            </div>

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


<div class="modal fade" id="cancelOrderModal" tabindex="-1">
    <div class="modal-dialog modal-dialog-centered">
        <div class="modal-content">

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

                <?php echo csrf_field(); ?>

                <div class="modal-header">
                    <h5 class="modal-title">Cancel Order</h5>
                    <button type="button"
                        class="btn-close"
                        data-bs-dismiss="modal"></button>
                </div>

                <div class="modal-body">

                    <div class="mb-3">
                        <label class="form-label">
                            Cancellation Reason
                        </label>

                        <textarea
                            name="feedback"
                            class="form-control"
                            rows="4"
                            placeholder="Enter cancellation reason..."
                            required></textarea>
                    </div>

                </div>

                <div class="modal-footer">
                    <button type="button"
                        class="btn btn-secondary"
                        data-bs-dismiss="modal">
                        Close
                    </button>

                    <button type="submit"
                        class="btn btn-danger">
                        Cancel Order
                    </button>
                </div>

            </form>

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

<?php $__env->stopSection(); ?>
<?php echo $__env->make('Admin.layout.app', array_diff_key(get_defined_vars(), ['__data' => 1, '__path' => 1]))->render(); ?><?php /**PATH C:\wamp64\www\ecommerce\resources\views/admin/partials/order/orderDetail.blade.php ENDPATH**/ ?>