<?php
/**
 * @var int $order_id
 * @var string $id
 */

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


use Inspire_Labs\Alsendo_Connect\Service_Structure_Helper;
use Inspire_Labs\Alsendo_Connect\Shipping_Method_Alsendo_Connect;
$zalat              = new \Inspire_Labs\Alsendo_Connect\Zaslat();
$meta               = alsendo_connect()->get_order_meta_data( $order_id );
$tracking_url       = '';
$zaslat_order_id    = '';
$zaslat_shipment_id = '';
$operator           = '';
$preloader          = alsendo_connect()->get_plugin_img_url() . '/animation-round-small.gif';
$shipping_method    = ! empty( $meta['alsendo_order']['shipping_method'] ) ? $meta['alsendo_order']['shipping_method'] : '';
$is_courier         = ! empty( $meta['alsendo_order']['is_courier'] ) ? true : false;
if ( ! empty( $meta['alsendo_order']['id'] ) ) {

	if ( ! empty( $meta['alsendo_order']['shipment'] ) ) {
		$zaslat_shipment_id = $meta['alsendo_order']['shipment'];
		$tracking_url       = $zalat->get_tracking_url( $zaslat_shipment_id );
	}

	if ( ! empty( $meta['alsendo_order']['order_number'] ) ) {
		$zaslat_order_id = $meta['alsendo_order']['order_number'];
	}

	if ( ! empty( $meta['alsendo_order']['operator'] ) ) {
		$operator = $meta['alsendo_order']['operator'];
	}
}
?>
<h3>
	<?php esc_html_e( 'Your order has been placed on Zaslat.cz', 'alsendo-connect' ); ?>
</h3>


<h4><?php esc_html_e( 'The shipment number is:', 'alsendo-connect' ); ?>
	<strong>
		<a target="_blank" href="<?php echo esc_url( $tracking_url ); ?>">
			<?php echo esc_attr( $zaslat_shipment_id ); ?>
		</a>
	</strong>
</h4>

<?php if ( ! empty( $operator ) ) { ?>
	<h4><?php esc_html_e( 'Carrier:', 'alsendo-connect' ); ?>
		<strong id="zaslat_choosed_carrier_id" style="color:#36aa27">
			<?php echo esc_attr( $operator ); ?>
		</strong>
	</h4>
<?php } ?>
<br/>

<button
		class="button-primary"
		id="zaslat_get_waybill"
		data-zaslat-id="<?php echo esc_attr( $zaslat_shipment_id ); ?>">
		<?php
		esc_html_e( 'Download waybill', 'alsendo-connect' );
		?>
</button>

<br/>
<br/>
<button class="button-primary zaslat_cancel" id="zaslat_cancel"  data-zaslat-id="<?php echo esc_attr( $zaslat_shipment_id ); ?>">
		<?php esc_html_e( 'Cancel parcel', 'alsendo-connect' ); ?>
</button>
<button class="button-primary zaslat_get_order_details"
		id="zaslat_get_order_details"
		data-zaslat-id="<?php echo esc_attr( $zaslat_shipment_id ); ?>">
		<?php
		esc_html_e(
			'Get package details',
			'alsendo-connect'
		);
		?>
</button>


<span style="margin-top: 10px;" id="alsendo_connect_preloader"><img src="<?php echo esc_url( $preloader ); ?>"></span>
<input type="hidden" id="ecolet_wc_order_id" data-id="<?php echo esc_attr( $order_id ); ?>">
<pre id="json-display-alsendo"></pre>
<?php
