<?php
namespace ONLINE_ADAv4;
if ( !defined( 'ABSPATH' ) ) exit;

$screen = get_current_screen();

// When on the wcag_scan page, get the queried scan and show a message if a different scan is active.
if ( isset($screen->id) && $screen->id == 'wcag_scan' ) {
	$this_scan = get_queried_scan();

	if ( !$this_scan ) return;

	// If a different scan is in progress, show a link to that scan.
	$active_scan = get_active_scan();
	$other_scan_active = false;

	if ( $active_scan && $active_scan->ID !== $this_scan->ID && $active_scan->status == "in-progress" ) {
		$other_scan_active = true;
		?>
		<div class="wcag-warning wcag-warning-other-scan-in-progress">
			<p><strong>A different audit is in progress.</strong> You may only have one audit active at a time.</p>

			<p><a href="<?php echo esc_attr( get_edit_post_link($active_scan->ID) ); ?>" class="button button-secondary">Go to the active audit</a></p>
		</div>
		<?php
		return;
	}
}else{
	$this_scan = get_active_scan();
}

if ( !$this_scan ) return;

echo '<div class="wcag-progress wcag-progress-' . esc_attr($this_scan->status) . '">';

echo "<input type='hidden' name='wcag_scan_id' id='wcag_scan_id' value='" . esc_attr($this_scan->ID) . "' />";

switch( $this_scan->status ) {
	case 'pending':
		break; // this template is not loaded if the scan is pending.
	case 'in-progress':
		include( 'progress/in-progress.php' );
		break;
}
echo '</div>';
