<?php
defined( 'ABSPATH' ) || exit( 'No Access!' );

$order_statuses = $options->get_option( 'order-status' );
$order_statuses = $order_statuses ? $order_statuses : [];
?>
<div class="irk-settings-area irk-settings-order-tracking">
    <h2 class="irk-settings-title">
        <span class="irk-title-icon"><span uk-icon="search"></span></span>
        <strong><?php _e( 'Order tracking', 'irk' ); ?></strong>
    </h2>
    <div class="uk-margin">
        <label class="uk-form-label"><?php _e( 'Active', 'irk' ); ?></label>
        <div class="uk-margin-small">
            <label>
                <input class="uk-checkbox" type="checkbox" name="order-tracking" value="1" <?php echo checked( $options->get_option( 'order-tracking' ), 1 ); ?>>
				<?php _e( 'Yes', 'irk' ); ?>
            </label>
        </div>
    </div>
    <div class="uk-margin">
        <label class="uk-form-label"><?php _e( 'Order details', 'irk' ); ?></label>
        <div class="uk-margin-small">
            <label>
                <input class="uk-checkbox" type="checkbox" name="order-tracking-details" value="1" <?php echo checked( $options->get_option( 'order-tracking-details' ), 1 ); ?>>
				<?php _e( 'Active', 'irk' ); ?>
            </label>
        </div>
    </div>
    <div class="irk-sortable uk-margin">
		<?php if ( count( $order_statuses ) ): ?>
			<?php foreach ( $order_statuses as $key => $status ): ?>
				<?php
				$image = $status['image'] ?? null;
				$title = $status['title'] ?? null;
				$description = $status['description'] ?? null;
				?>
                <div class="irk-order-status-item irk-item uk-margin-small">
                    <div class="irk-actions">
                        <span class="move" uk-icon="move" uk-tooltip="title: <?php _e( 'Move', 'irk' ); ?>"></span>
                        <span class="remove" uk-icon="close" uk-tooltip="title: <?php _e( 'Remove', 'irk' ); ?>"></span>
                    </div>
                    <div class="uk-margin-small">
                        <input type="text" class="uk-input" name="order-status[<?php echo $key; ?>][image]" value="<?php echo esc_attr( $image ); ?>" placeholder="<?php _e( 'Image', 'irk' ); ?>">
                    </div>
                    <div class="uk-margin-small">
                        <input type="text" class="uk-input" name="order-status[<?php echo $key; ?>][title]" value="<?php echo esc_attr( $title ); ?>" placeholder="<?php _e( 'Title', 'irk' ); ?>">
                    </div>
                    <div class="uk-margin-small">
                        <textarea class="uk-textarea" name="order-status[<?php echo $key; ?>][description]" placeholder="<?php _e( 'Description', 'irk' ); ?>" rows="4"><?php echo esc_textarea( $description ); ?></textarea>
                    </div>
                </div>
			<?php endforeach; ?>
		<?php endif; ?>
        <a href="#" class="irk-new-order-status uk-button uk-button-default uk-button-small"><?php _e( 'New item', 'irk' ); ?></a>
    </div>
</div>