<div class="card-body">
    <table class="table mb-0" id="aiz-data-table">
        <thead>
            <tr>
                <?php if(auth()->user()->can('product_delete')): ?>
                <th>
                    <div class="form-group">
                        <div class="aiz-checkbox-inline">
                            <label class="aiz-checkbox pt-5px d-block">
                                <input type="checkbox" class="check-all">
                                <span class="aiz-square-check"></span>
                            </label>
                        </div>
                    </div>
                </th>
                <?php else: ?>
                <th class="hide-lg">#</th>
                <?php endif; ?>
                <th class="text-uppercase fs-10 fs-md-12 fw-700 text-secondary"><?php echo e(translate('Order Code')); ?></th>
                <th class="text-uppercase fs-10 fs-md-12 fw-700 text-secondary ml-1 ml-lg-0"><?php echo e(translate('Products')); ?></th>
                <th class="hide-xs text-uppercase fs-10 fs-md-12 fw-700 text-secondary"><?php echo e(translate('Customer')); ?></th>
                <th class="hide-sm text-uppercase fs-12 fw-700 text-secondary"><?php echo e(translate('Seller')); ?></th>
                <th class="hide-md text-uppercase fs-12 fw-700 text-secondary"> <?php echo e(translate('Amount')); ?></th>
                <th class="hide-xl text-uppercase fs-12 fw-700 text-secondary"><?php echo e(translate('Delivery Status')); ?></th>
                <th class="hide-xxl text-uppercase fs-12 fw-700 text-secondary"><?php echo e(translate('Payment method')); ?></th>
                <th class="hide-xxl text-uppercase fs-12 fw-700 text-secondary"><?php echo e(translate('Payment Status')); ?></th>
                <?php if(addon_is_activated('refund_request')): ?>
                <th class="hide-xxl text-uppercase fs-12 fw-700 text-secondary"><?php echo e(translate('Refund')); ?></th>
                <?php endif; ?>
                <th class="text-right text-uppercase fs-10 fs-md-12 fw-700 text-secondary"><?php echo e(translate('Options')); ?></th>
            </tr>
        </thead>

        <tbody>
            <?php $__empty_1 = true; $__currentLoopData = $orders; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $key => $order): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); $__empty_1 = false; ?>
            <tr class="data-row">
                <td class="align-middle w-40px">
                    <div>
                        <button type="button"
                            class="toggle-plus-minus-btn border-0 bg-blue fs-14 fw-500 text-white p-0 align-items-center justify-content-center">+</button>
                    </div>
                    <?php if(auth()->user()->can('delete_order') || auth()->user()->can('export_order')): ?>
                    <div class="form-group d-inline-block">
                        <label class="aiz-checkbox">
                            <input type="checkbox" class="check-one" name="id[]" value="<?php echo e($order->id); ?>">
                            <span class="aiz-square-check mt-1"></span>
                        </label>
                    </div>
                    <?php else: ?>
                    <div class="form-group d-inline-block"><?php echo e($key + 1 + ($orders->currentPage() - 1) * $orders->perPage()); ?></div>
                    <?php endif; ?>
                </td>

                <td data-label="Order-Code" class="align-middle">
                    <a href="<?php echo e(route('all_orders.show', encrypt($order->id))); ?>" class="fw-600 text-primary">
                    <?php echo e($order->code); ?>

                    </a>
                    <?php if($order->shipping_method == 'shiprocket'): ?>
                        <br><span class="fw-bold"><?php echo e(translate('Shiprocket Order Id')); ?>:</span> <?php echo e($order->shiprocket_order_id); ?>

                    <?php elseif($order->shipping_method == 'steadfast'): ?>
                        <br><span class="fw-bold"><?php echo e(translate('Steadfast Consignment Id')); ?>:</span> <?php echo e($order->steadfast_consignment_id); ?>

                    <?php elseif($order->shipping_method == 'pathao'): ?>
                        <br><span class="fw-bold"><?php echo e(translate('Pathao Consignment Id')); ?>:</span> <?php echo e($order->pathao_consignment_id); ?>

                    <?php elseif($order->shipping_method == 'redx'): ?>
                        <br><span class="fw-bold"><?php echo e(translate('Redx Tracking Id')); ?>:</span> <?php echo e($order->redx_tracking_id); ?>

                    <?php endif; ?>
                    <?php if($order->viewed == 0): ?>
                    <span class="badge badge-inline badge-info"><?php echo e(translate('New')); ?></span>
                    <?php endif; ?>
                    <?php if(addon_is_activated('pos_system') && $order->order_from == 'pos'): ?>
                    <span class="badge badge-inline badge-danger"><?php echo e(translate('POS')); ?></span>
                    <?php
                        $source = strtolower($order->order_source);

                        $badgeClass = match($source) {
                            'walkin'   => 'badge-warning',
                            'facebook' => 'badge-primary',
                            'whatsapp' => 'badge-success',
                            default    => 'badge-danger',
                        };
                    ?>

                    <span class="badge badge-inline <?php echo e($badgeClass); ?>"><?php echo e(ucfirst($order->order_source)); ?></span>
                    <?php endif; ?>
                    <?php if($order->order_note != null): ?>
                    <span data-toggle="tooltip" data-placement="right" title="<?php echo e($order->order_note); ?>" class="">
                        <svg xmlns="http://www.w3.org/2000/svg" height="23px" viewBox="0 -960 960 960" width="24px" fill="#1492e6"><path d="M200-120q-33 0-56.5-23.5T120-200v-560q0-33 23.5-56.5T200-840h560q33 0 56.5 23.5T840-760v400L600-120H200Zm360-80 200-200H560v200ZM280-400h200v-80H280v80Zm0-160h400v-80H280v80Z"/></svg>
                    </span>
                    <?php endif; ?>
                </td>

                <td data-label="OrderCount" class="fw-600 align-middle">
                    <?php echo e(count($order->orderDetails)); ?>

                </td>

                <td class="hide-xs align-middle" data-label="Customer">
                    <span class="fs-12 fw-200 d-block pt-1">
                        <?php if($order->user != null): ?>
                        <?php echo e($order->user->name); ?>

                        <?php else: ?>
                        Guest (<?php echo e($order->guest_id); ?>)
                        <?php endif; ?>
                    </span>
                </td>

                <td class="hide-sm align-middle" data-label="Owner">
                    <?php $shop = optional($order->shop); ?>
                    
                    <a href="<?php echo e($shop->id ? route('sellers.profile', encrypt($shop->id)) : '#'); ?>" title="<?php echo e($shop->name ?? 'Inhouse Product'); ?>" class="fs-12 fs-md-14 fw-700 d-block">
                        <?php echo e(Str::limit($shop->name, 20)?? translate('Inhouse')); ?>

                    </a>
                </td>

                <td class="hide-md align-middle" data-label="Price Details">
                    <div class="border-width-3 border-left border-blue px-2 py-0 mb-1">
                        <p class="fs-14 fw-700 m-0"><?php echo e(single_price($order->grand_total)); ?></p>
                    </div>
                </td>

                <td class="hide-xl align-middle" data-label="Delivery Status">
                    <p class="fs-14 fw-700 m-0  <?php if( $order->delivery_status == 'delivered' ): ?> text-success <?php endif; ?>"><?php echo e(translate(ucfirst(str_replace('_', ' ', $order->delivery_status)))); ?></p>

                    <?php if($order->shipping_method == 'shiprocket'): ?>
                        <span class="fw-bold pt-10px"><?php echo e(translate('Shiprocket Status')); ?>:</span> <?php echo e(ucfirst(translate(str_replace('_', ' ', $order->shiprocket_status)))); ?>

                    <?php elseif($order->shipping_method == 'steadfast'): ?>
                        <span class="fw-bold pt-10px"><?php echo e(translate('Steadfast Status')); ?>:</span> <?php echo e(ucfirst(translate(str_replace('_', ' ', $order->steadfast_status)))); ?>

                    <?php elseif($order->shipping_method == 'pathao'): ?>
                        <span class="fw-bold pt-10px"><?php echo e(translate('Pathao Status')); ?>:</span> <?php echo e(ucfirst(translate(str_replace('_', ' ', $order->pathao_status)))); ?>

                    <?php elseif($order->shipping_method == 'redx'): ?>
                        <span class="fw-bold pt-10px"><?php echo e(translate('Redx Status')); ?>:</span> <?php echo e(ucfirst(translate(str_replace('_', ' ', $order->redx_status)))); ?>

                    <?php endif; ?>
                </td>

                <td class="hide-xxl align-middle" data-label="Payment method">
                    <?php echo e(translate(ucfirst(str_replace('_', ' ', $order->payment_type)))); ?>

                </td>

                <td class="hide-xxl align-middle" data-label="Payment Status">
                    <?php if($order->payment_status == 'paid'): ?>
                    <span class="badge badge-inline badge-success"><?php echo e(translate('Paid')); ?></span>
                    <?php else: ?>
                    <span class="badge badge-inline badge-danger"><?php echo e(translate('Unpaid')); ?></span>
                    <?php endif; ?>
                </td>

                <?php if(addon_is_activated('refund_request')): ?>
                <td class="hide-xxl align-middle" data-label="Refund">
                    <?php if(count($order->refund_requests) > 0): ?>
                    <?php echo e(count($order->refund_requests)); ?> <?php echo e(translate('Refund')); ?>

                    <?php else: ?>
                    <?php echo e(translate('No Refund')); ?>

                    <?php endif; ?>
                </td>
                <?php endif; ?>

                <td class="text-right align-middle">
                    <div class="dropdown float-right">
                        <button class="btn btn-light w-30px h-30px w-sm-35px h-sm-35px d-flex align-items-center justify-content-center action-toggle p-0" type="button"
                            data-toggle="dropdown">
                            <svg xmlns="http://www.w3.org/2000/svg" width="3" height="16" viewBox="0 0 3 16">
                                <circle cx="1.5" cy="1.5" r="1.5" transform="translate(0 6.5)" />
                                <circle cx="1.5" cy="1.5" r="1.5" transform="translate(0 0)" />
                                <circle cx="1.5" cy="1.5" r="1.5" transform="translate(0 13)" />
                            </svg>
                        </button>
                        <div class="dropdown-menu dropdown-menu-right">
                            <?php
                                $admin_user_id = get_admin()->id;
                                $thermal_printer = json_decode(get_setting('thermal_printer'), true) ?? [];
                            ?>
                            <?php if($order->seller_id == $admin_user_id || get_setting('product_manage_by_admin') == 1): ?>
                                <?php if (app(\Illuminate\Contracts\Auth\Access\Gate::class)->check('manage_order')): ?>
                                    <a href="#" data-order-id="<?php echo e($order->id); ?>" id="manage_order" class="dropdown-item">
                                        <i class="las la-cog mr-2"></i> <?php echo e(translate('Ouick Order Management')); ?>

                                    </a>
                                <?php endif; ?>
                            <?php endif; ?>
                            <?php if(addon_is_activated('pos_system') && $order->order_from == 'pos'): ?>
                            <a class="dropdown-item" href="<?php echo e(route('admin.invoice.thermal_printer', $order->id)); ?>" target="_blank">
                                <i class="las la-print mr-2"></i> <?php echo e(translate('Print')); ?>

                            </a>
                            <?php endif; ?>
                            <?php if (app(\Illuminate\Contracts\Auth\Access\Gate::class)->check('view_order_details')): ?>
                            <a href="<?php echo e(route('all_orders.show', encrypt($order->id))); ?>" class="dropdown-item">
                                <i class="las la-eye mr-2"></i> <?php echo e(translate('View Order')); ?>

                            </a>
                            <?php endif; ?>
                            <a class="dropdown-item" href="<?php echo e(route('invoice.download', $order->id)); ?>" target="_blank">
                                <i class="las la-download mr-2"></i> <?php echo e(translate('Download Invoice')); ?>

                            </a>
                            <a class="dropdown-item" href="<?php echo e(route('invoice.printer', $order->id)); ?>" target="_blank">
                                <i class="las la-download mr-2"></i> <?php echo e(translate('Print Invoice')); ?>

                            </a>
                            <?php if(isset($thermal_printer['generate_invoice_for_thermal_printer']) && $thermal_printer['generate_invoice_for_thermal_printer'] == 1): ?>
                            <a class="dropdown-item" href="<?php echo e(route('thermal_invoice.print', $order->id)); ?>" target="_blank">
                                <i class="las la-download mr-2"></i> <?php echo e(translate('Print Thermal Invoice')); ?>

                            </a>
                            <?php endif; ?>
                            <?php if (app(\Illuminate\Contracts\Auth\Access\Gate::class)->check('can_download_and_print_shipping_label')): ?>
                                <a class="dropdown-item" href="<?php echo e(route('shipping_label.download', $order->id)); ?>" target="_blank">
                                    <i class="las la-download mr-2"></i> <?php echo e(translate('Download Shipping Label')); ?>

                                </a>
                                <a class="dropdown-item" href="<?php echo e(route('shipping_label.print', $order->id)); ?>" target="_blank">
                                    <i class="las la-download mr-2"></i> <?php echo e(translate('Print Shipping Label')); ?>

                                </a>
                            <?php endif; ?>
                            <?php if(auth()->user()->can('unpaid_order_payment_notification_send') && $order->payment_status == 'unpaid' && $unpaid_order_payment_notification->status == 1): ?>
                            <a href="javascript:void(0);" onclick="unpaid_order_payment_notification('<?php echo e($order->id); ?>');" class="dropdown-item text-warnning" title="<?php echo e(translate('Unpaid Order Payment Notification')); ?>">
                                <i class="las la-bell mr-2"></i> <?php echo e(translate('Payment Notification')); ?>

                            </a>
                            <?php endif; ?>
                            <?php if (app(\Illuminate\Contracts\Auth\Access\Gate::class)->check('product_delete')): ?>
                            <a href="javascript:void(0);" onclick="singleDelete('<?php echo e($order->id); ?>');" class="dropdown-item text-danger">
                                <i class="las la-trash mr-2"></i> <?php echo e(translate('Delete')); ?>

                            </a>
                            <?php endif; ?>
                        </div>
                    </div>
                </td>
            </tr>
            <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); if ($__empty_1): ?>
            <tr>
                <td colspan="11" class="text-center py-5">
                    <div class="w-100">
                        <h5 class="fs-16 fw-bold text-gray"><?php echo e(translate('No Orders found!')); ?></h5>
                        <i class="las la-frown fs-48 text-soft-white"></i>
                    </div>
                </td>
            </tr>
            <?php endif; ?>
        </tbody>
    </table>

    <?php if($orders->hasPages()): ?>
    <div class="aiz-pagination mt-3" id="pagination">
        <?php echo e($orders->links()); ?>

    </div>
    <?php endif; ?>
</div><?php /**PATH /home/akhanei2/public_html/resources/views/backend/sales/orders_table.blade.php ENDPATH**/ ?>