<?php 
$step = get_step();

$navigation = array(
		1 => "Suche läuft",
		2 => "Suche abgeschlossen",
		3 => "Treffer gefunden",
		4 => "Gefahrstoff-Prüfung",
		5 => "Gefahrgut-Prüfung",
		6 => "Fertig"
);
$links = array(
		0 => "index-smartify.php",
		1 => "step1.php",
		2 => "step2.php",
		3 => "step3.php",
		4 => "step4.php",
		5 => "step5.php",
		6 => "step6.php"
);
?>

<?php if ($step > 0): ?>
	<ol class="ch-ggs-web-suite-order-steps row mb-7">
		<?php for ($i = 1; $i <= 6; $i++): ?>
			<li class="col-md-6 col-lg-4 <?php echo ($i == $step && $i != 1 ? ' active' : '') ?> <?php echo ($i < $step && $step != 1 ? ' done' : '') ?> <?php echo ($step == 1 && $i == 1 ? ' loading' : '') ?><?php echo ($step == 2 && $i == 2 ? ' error' : '') ?>">
				<a href="<?php echo $links[$i]?>" class="nav-link">
					<?php if ($step == 1 && $i == 1): ?>
						<div class="ch-ggs-web-suite-order-steps-loader spinner-border text-white" role="status">
						  <span class="sr-only">Loading...</span>
						</div>
					<?php endif ?>
					<span class="d-inline-block">
						<span class="d-block nav-link-title"><?php echo $navigation[$i] ?></span>
					</span>
				</a>
			</li>
		<?php endfor; ?>
	</ol>
<?php endif ?>

<?php 
function get_step() {
	$phpself = explode('/', $_SERVER['PHP_SELF']);
	
	if (count($phpself) == 0) return 1;
	
	$script = array_pop($phpself);
	$script = str_replace(array('.php', 'step'), '', $script);
	
	if ($script == 'index-smartify') return 1;
	
	return intval($script);
	
}

?>