<?php
/**
 * @var array $calculate
 * @var mixed $apaczka_order
 */

if ( ! defined( 'ABSPATH' ) ) {
	exit; // Exit if accessed directly.
}

$single_offer = false;
$selected = '';
if( is_array($calculate) && 1 === count($calculate) ) {
    $single_offer = true;
}

?>

<fieldset id="apaczka_calculate_radio">
	<?php $first = true; ?>
	<?php $i = 0; ?>
	<?php foreach ( $calculate as $k => $service ) : ?>
		<?php if( $single_offer ) {
            $selected = ' selected';
        } ?>
		<label class="apaczka-calculate-item <?php echo esc_attr( $selected ); ?>"
				data-item="<?php echo esc_attr( $i ); ?>"
				data-pickup_courier="<?php // echo esc_attr( $service['pickup_courier'] ); ?>"
				data-service_id="<?php echo esc_attr( $k ); ?>"
				data-supplier="<?php // echo esc_attr( $service['supplier'] ); ?>">
			<p class="apaczka-logo-wrapper <?php echo 'service_id_' . esc_attr( $k ); ?>">
				<?php

				$logo     = alsendo_connect()->get_logo_ecolet( $k );
				$logo_src = '';
				if ( $logo ) {
					$logo_src = alsendo_connect()->get_plugin_img_url() . '/' . $logo . '.png';
				}
				?>
				<img class="apaczka-service-logo" src="<?php echo esc_url( $logo_src ); ?>" style="">
			</p>
			<p class="ecolet-service-name-wrapper">
				<?php
				echo esc_attr( $service['name'] );
				?>
			</p>
			<div class="apaczka-calculate-item-price-wrapper">
				<p>
					<?php echo esc_html( $service['price'] ); ?>
					RON netto
				</p>
				<p>
					<?php echo esc_html( $service['price_gross'] ); ?>
					RON brutto
				</p>
				<input
						type="radio"
						value="<?php echo esc_attr( $k ); ?>"
						id="apaczka_calculate_radio_<?php echo esc_attr( $k ); ?>"
						class="apaczka_calculate_radio"
						name="apaczka_calculate_radio"
				>
				<?php ++$i; ?>
			</div>
		</label>
		<?php $first = false; ?>
	<?php endforeach; ?>

</fieldset>
<?php