<?php
/**
 * Campo select de tipo producto.
 *
 * @package Logistica
 *
 * @var string $field_name
 * @var string $field_value
 * @var string $select_attr
 * @var bool   $required
 */

if ( ! defined( 'ABSPATH' ) ) {
	exit;
}

$field_name    = isset( $field_name ) ? (string) $field_name : 'tipo_producto';
$field_value   = isset( $field_value ) ? (string) $field_value : '';
$select_attr   = isset( $select_attr ) ? (string) $select_attr : 'data-etiqueta-tipo-select';
$required      = ! isset( $required ) || ! empty( $required );
$type_options  = Logistica_Label_Etiqueta_Tipos::get_option_labels();
?>
<div class="logistica-etiqueta-tipo-field">
	<label><?php esc_html_e( 'Tipo producto', 'logistica' ); ?>
		<select name="<?php echo esc_attr( $field_name ); ?>" <?php echo $select_attr; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?> <?php echo $required ? 'required' : ''; ?>>
			<option value=""><?php esc_html_e( '— Seleccionar —', 'logistica' ); ?></option>
			<?php foreach ( $type_options as $type_key => $type_label ) : ?>
				<option value="<?php echo esc_attr( $type_key ); ?>" <?php selected( $field_value, $type_key ); ?>><?php echo esc_html( $type_label ); ?></option>
			<?php endforeach; ?>
		</select>
	</label>
</div>
