<?php
global $installComplete;
if(!isset($installComplete)){
	$installComplete=false;
}
if(!isset($pass)){ $pass=1; }
if(!empty($error)){ 
	?>
	<p>Final clean-up failed. It should have:</p>
    <ul>
        <li>Scheduled the backup to run every night (in root's crontab) if a backup directory was configured</li>
    </ul>
    <p>...and, if Formulatrix imagers were configured:</p>
    <ul>
        <li>Mounted the image stores for any Formulatrix imagers under /mnt/Formulatrix</li>
        <li>Written a .smbcredentials file to the same location</li>
        <li>Scheduled the image importer to run every 5 minutes (in root's crontab)</li>
    </ul>
	<p>You should investigate the reason for the failure, and complete these steps manually.</p>
	<?php 
} else
	global $installComplete;
    if($installComplete){
		?>
	<h2>Installation complete</h2>
	<p>ICEBEAR should now be configured and ready for use.</p>
	<p>You can <a href="/">log in to ICEBEAR</a>.</p>
    <p>The final part of the installer should have renamed the installation directory. If the link above redirects you
        back to this page, that rename failed. You will need to rename or remove the installation directory manually.</p>
	<h3>Passwords</h3>
	<p>Other than the default administrator account you created earlier, any user accounts imported from the imagers will
        have the following password, which all users should change as soon as they have logged in: <b><?php echo DEFAULT_PASSWORD; ?></b>

    <?php
    global $icebearSessionStarted;
    if(!$icebearSessionStarted){
        startIceBearSession();
    }
    if(1==config::get('fx_hasimagers')){ ?>
        <h3>Imager integration</h3>
        <p>Your Formulatrix imagers have been connected, but the importer has not yet run. At the moment, there are no plate
            inspections in IceBear, and the imager loading is unknown. The importer is scheduled to run every 5 minutes, so you
            should see plate inspections and imager loading within about 10 minutes.</p>
        <p>There may be differences between the way your imagers connect to their server and the way IceBear does it. This
            typically happens because the imagers and their controller PCs are isolated from the wider network. To work around
            some issues caused by this, there are two entries in /etc/fstab for each Formulatrix image store: One with the path
            found in the RockMaker database, the other using the database server name you gave during installation. Ideally, you
            should remove the unneeded one, since it will cause errors to appear on reboot - but you can leave it.</p>
        <p>If your plate inspections have no images, the image store mounting is the first place to look.</p>
    <?php } ?>

	<?php 
} else {
	echo '<input type="hidden" name="pass" value="'.$pass.'"/>';
	echo '<p>Finishing up the installation - just waiting for the server to tidy up.</p>';
	echo '<p style="border:1px solid #666"><span style="background-color:black;color:black;">';
	for($i=0;$i<$pass;$i++){
		echo '**';
	}
	echo '</span></p><script type="text/javascript">document.body.onload=function(){ window.setTimeout(function(){ document.forms[0].submit() }, 5000); }</script>';
}
?>
