<?php
/**
 * Webkul Software.
 *
 * @category  Webkul
 * @package   Webkul_Marketplace
 * @author    Webkul
 * @copyright Copyright (c) Webkul Software Private Limited (https://webkul.com)
 * @license   https://store.webkul.com/license.html
 */
$partner=[];
$helper = $this->helper(\Webkul\Marketplace\Helper\Data::class);
$partner = $helper->getSeller();
$isPartner = $helper->isSeller();
if ($isPartner == 1) { ?>
    <div class="wk-mp-design">
        <fieldset class="fieldset info wk-mp-fieldset">
            <legend class="legend"><span><?= /* @noEscape */ __('Order Details of Product : %1', $block->getProduct()->getName())?></span></legend>
            <div class="order-details-items ordered">
                <div class="table-wrapper order-items">
                    <table class="data table table-order-items" summary="<?= /* @noEscape */ __('Order List Per Product') ?>">
                        <thead>
                            <tr>
                                <th class="col price"><?= /* @noEscape */ __('Order #') ?></th>
                                <?php if ($helper->getSellerProfileDisplayFlag()) { ?>
                                    <th class="col price"><?= /* @noEscape */ __('Buyer Name') ?></th>
                                <?php } ?>
                                <th class="col price"><?= /* @noEscape */ __('Sold on') ?></th>
                                <th class="col price"><?= /* @noEscape */ __('Action') ?></th>
                                <th class="col price"><?= /* @noEscape */ __('Download') ?></th>
                            </tr>
                        </thead>
                        <tbody>
                            <?php
                            $i = 0;
                            foreach ($block->getCollection() as $marketplace_order) {
                                $i++;
                                $order_id = $marketplace_order->getOrderId();
                                $order = $block->getOrderById($order_id);
                                $shipment_id = 0;
                                $invoice_id = 0;
                                $invoice_id=$marketplace_order->getInvoiceId();
                                $shipment_id=$marketplace_order->getShipmentId();
                                ?>
                                <tr class="border">
                                    <td class="col price" data-th="<?= /* @noEscape */ __('Order #') ?>">
                                        <?= $block->escapeHtml($order['increment_id']);?>
                                    </td>
                                    <?php if ($helper->getSellerProfileDisplayFlag()) { ?>
                                        <td class="col price" data-th="<?= /* @noEscape */ __('Buyer Name') ?>">
                                            <?= $block->escapeHtml($order->getCustomerName());?>
                                        </td>
                                    <?php } ?>
                                    <td class="col price" data-th="<?= /* @noEscape */ __('Sold on') ?>">
                                        <?= /* @noEscape */ $block->formatDate($marketplace_order->getCreatedAt());?>
                                    </td>
                                    <td class="col price" data-th="<?= /* @noEscape */ __('View') ?>">
                                        <a href="<?= $block->escapeUrl($block->getUrl('marketplace/order/view', ['id'=>$order_id, '_secure' => $this->getRequest()->isSecure()]))?>">
                                            <?= /* @noEscape */ __('View Order');?>
                                        </a>
                                    </td>
                                    <td class="col price" data-th="<?= /* @noEscape */ __('Action') ?>">
                                        <?php if ($shipment_id) { ?>
                                            <a href="<?= $block->escapeUrl($block->getUrl('marketplace/order_shipment/printpdf', ['order_id'=>$order_id,'shipment_id'=>$shipment_id, '_secure' => $this->getRequest()->isSecure()]));?>" class="action">
                                                <?= /* @noEscape */ __('Shipping Slip');?>
                                            </a>
                                            <?php
                                        } else { ?>
                                            <span class="action">
                                                <?= /* @noEscape */ __('Shipping Slip');?>
                                            </span>
                                            <?php
                                        }
                                        if ($invoice_id) { ?>
                                            <a href="<?= $block->escapeUrl($block->getUrl('marketplace/order_invoice/printpdf', ['order_id'=>$order_id,'invoice_id'=>$invoice_id, '_secure' => $this->getRequest()->isSecure()]));?>"  class="action">
                                                <?= /* @noEscape */ __('Invoice Slip');?>
                                            </a>
                                            <?php
                                        } else { ?>
                                            <span class="action">
                                                <?= /* @noEscape */ __('Invoice Slip');?>
                                            </span>
                                            <?php
                                        } ?>
                                    </td>
                                </tr>
                                <?php
                            }?>
                        </tbody>
                    </table>
                </div>
            </div>
            <?php if ($block->getPagerHtml()): ?>
                <div class="order-products-toolbar toolbar bottom"><?= $block->getPagerHtml(); ?></div>
            <?php endif ?>
        </fieldset>
    </div>
    <div class="buttons-set">
        <p class="back-link">
            <a href="javascript:;" onclick="javascript: window.history.back();" class="left">&laquo; <?= /* @noEscape */ __('Back') ?></a>
        </p>
    </div>
    <?php
} else { ?>
    <h2 class="wk-mp-error_msg">
        <?= /* @noEscape */ __("To Become Seller Please Contact to Admin."); ?>
    </h2>
    <?php
} ?>
