<?php
/** 
 * @package     VikRestaurants
 * @subpackage  core
 * @author      E4J s.r.l.
 * @copyright   Copyright (C) 2023 E4J s.r.l. All Rights Reserved.
 * @license     http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL
 * @link        https://vikwp.com
 */

// No direct access
defined('ABSPATH') or die('No script kiddies please!');

/**
 * Layout variables
 * -----------------
 * @var  VREOrderTakeaway  $order     The instance holding the take-away order details.
 * @var  bool              $showfood  Whether the food of the order should be displayed.
 */
extract($displayData);

?>

<div class="addon-order-summary">

    <!-- STATUS -->

    <div class="addon-order-status">
        <?php echo \JHtml::fetch('vrehtml.status.display', $order->status, 'badge'); ?>
    </div>

    <!-- CHECK-IN DATE -->

    <div class="addon-order-checkin-date align-right">
        <span class="addon-order-label">
            <?php echo \JText::translate('VRMANAGETKRES10'); ?>
        </span>
        <span class="addon-order-value">
            <?php echo $order->checkin_date; ?>
        </span>
    </div>

    <!-- FOOD -->

    <?php if (!empty($showfood)): ?>
        <div class="addon-order-food wide-row">
            <?php foreach (array_slice($order->items, 0, 3) as $item): ?>
                <div class="addon-order-food-item">
                    <small class="item-qty"><?php echo $item->quantity; ?>x</small>
                    <span class="item-name"><?php echo $item->name; ?></span>
                </div>
            <?php endforeach; ?>

            <?php if (($remaining = count($order->items) - 3) > 0): ?>
                <div class="addon-order-food-item">
                    <small class="item-name"><?php echo JText::plural('VRWIZARDOTHER_N_ITEMS', $remaining); ?></small>
                </div>
            <?php endif; ?>
        </div>
    <?php endif; ?>

    <!-- CUSTOMER -->

    <div class="addon-order-customer">
        <span class="addon-order-label">
            <?php echo \JText::translate('VRMANAGETKRES24'); ?>
        </span>
        <span class="addon-order-value">
            <?php echo ($order->purchaser_nominative ?: $order->purchaser_mail ?: '--'); ?>
        </span>
    </div>

    <!-- CHECK-IN TIME -->

    <div class="addon-order-checkin-time align-right">
        <span class="addon-order-label">
            <?php echo \JText::translate('VRMANAGETKRES11'); ?>
        </span>
        <span class="addon-order-value">
            <?php echo $order->checkin_time; ?>
        </span>
    </div>

    <!-- SERVICE -->

    <div class="addon-order-service">
        <span class="addon-order-label">
            <?php echo \JText::translate('VRMANAGETKRES13'); ?>
        </span>
        <span class="addon-order-value">
            <?php echo \JHtml::fetch('vikrestaurants.tkservice', $order->service); ?>
        </span>
    </div>

    <!-- TOTAL COST -->

    <div class="addon-order-total align-right">
        <span class="addon-order-label">
            <?php echo \JText::translate('VRTKCARTOPTION3'); ?>
        </span>
        <span class="addon-order-value">
            <?php echo \VREFactory::getCurrency()->format($order->total_to_pay); ?>
        </span>
    </div>

</div>
