<?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  VREOrderRestaurant  $reservation  The instance holding the restaurant reservation details.
 * @var  bool                $showtable    Whether the room and the table of the reservation should be displayed.
 */
extract($displayData);

?>

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

    <!-- STATUS -->

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

    <!-- CHECK-IN DATE -->

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

    <!-- TABLE -->

    <?php if (!empty($showtable)): ?>
        <div class="addon-order-room wide-row">
            <?php
            $tables = array_map(function($table) {
                return $table->name;
            }, $reservation->tables);

            echo $reservation->room_name . ' - ' . implode(', ', $tables);
            ?>
        </div>
    <?php endif; ?>

    <!-- CUSTOMER -->

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

    <!-- CHECK-IN TIME -->

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

    <!-- PEOPLE -->

    <div class="addon-order-people">
        <span class="addon-order-label">
            <?php echo \JText::translate('VRMANAGERESERVATION4'); ?>
        </span>
        <span class="addon-order-value">
            <?php echo $reservation->people; ?>
        </span>
    </div>

    <!-- BILL -->

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

</div>
