<?php
/*
 * @package    ECLCDEK shipping plugin СДЭК to RadicalMart
 * @subpackage    ECLCDEK
 * @version    1.0.1
 * @author Econsult Lab.
 * @copyright  Copyright (c) 2025 Econsult Lab. All rights reserved.
 * @license    GNU/GPL license: https://www.gnu.org/copyleft/gpl.html
 * @link       https://econsultlab.ru
 */

use CdekSDK2\Dto\Tariff;
use Joomla\CMS\Language\Text;

extract($displayData);

/**
 * Layout variables
 * -----------------
 *
 * @var  Array   $address     	Данные адреса.
 * @var  string  $deliveryType     Тип доставки.
 * @var  Tariff  $tariff    Тариф доставки.
 *
 */
$pvs = match(true){
	$address['type'] === "POSTAMAT" => Text::_("PLG_RADICALMART_SHIPPING_ECLCDEK_TYPE_POSTAMAT"),
	$address['type'] === "PVZ" => Text::_("PLG_RADICALMART_SHIPPING_ECLCDEK_TYPE_PVZ"),
	default =>'',
};
?>
<?php if($address): ?>
    <div class="uk-card uk-card-default" id="cdek-tariffs-block">
        <div class = "uk-card-body">
			<?php if($deliveryType === "office"): ?>
                <div class = "uk-h4"><?php echo Text::sprintf("PLG_RADICALMART_SHIPPING_ECLCDEK_CUSTOMER_LAYOUT_RESULT_OFFICE_TITLE",$pvs,$address['code']);?></div>
                <div class = "uk-margin-small">
                    <div class = "uk-text-muted">
                        <div class = "uk-text-small">
							<?php echo Text::sprintf("PLG_RADICALMART_SHIPPING_ECLCDEK_LAYOUT_RESULT_ADDRESS",$address['region'],$address['city'], $address['address']);?>
                        </div>
                        <div class = "uk-text-small">
							<?php echo Text::sprintf("PLG_RADICALMART_SHIPPING_ECLCDEK_LAYOUT_RESULT_WORK_TIME",$address['work_time']);?>
                        </div>
                    </div>
                </div>
			<?php else: ?>
                <div class = "uk-h4"><?php echo Text::_("PLG_RADICALMART_SHIPPING_ECLCDEK_CUSTOMER_LAYOUT_RESULT_DOOR_TITLE");?></div>
                <div class = "uk-margin-small">
                    <div class = "uk-text-muted">
                        <div class = "uk-text-small">
							<?php echo Text::sprintf("PLG_RADICALMART_SHIPPING_ECLCDEK_LAYOUT_RESULT_ADDRESS",$address['region'],$address['city'], $address['address']);?>
                        </div>
                    </div>
                </div>
			<?php endif;?>
        </div>
    </div>
<?php endif;?>
