<?php
require("ed/.CONFIG");
$REGISTER_DIR = "ed/register";

$logincheck = new LoginChecker;
$utils = new Utils;
/*if (!$logincheck->accessCheck($CHANNEL_ADD_EXPEDITION))
{
	$url = $sess->self_url();
	$utils->redirect("/login/?url=$url");
	exit();
} 
else */
{
	//require("INCLUDES/htmlgenerator.inc");
	//$htm = new htmlgenerator;
	//$htm->head("Expeditions Online","yes");
	$expedition = new Expedition;
	$euser = new EUser;
	$utils = new Utils;

	if ($action == "new") {
	
		include("$REGISTER_DIR/register_start_form1.ell");
	
	} else if ($action == "createnew") {
	
		include("$REGISTER_DIR/register_start_part1.ell");
	
	} else if ($action == "edit") { 
		
		/* Error if expeditionno is not available */
	        if ($expeditionno == "") {
	        	$utils->redirect("/error.ell?errID=999&retQry=1&sURI=/ed");
	                exit();
	
	        }
	
	        /* Check if logon user is owner of expedition with expeditionno = $expeditionno */
	        if ( $expedition->checkIfOwner($erusername,$expeditionno) != "true") {
	        	/* Change this error message if possible */
	                $utils->redirect("/error.ell?errID=10&retQry=1&sURI=/ed");
	                exit();
	        }
	
		if ($part == 1) {
			list($expno,$liaison,$name,$email,$website,$phone,$fax,$startdate,$enddate,$curteamsize,				     $finteamsize,$totalexpense,$desc,$cat_ids,$ofldperiod,$exp_ID,$addfund,$classconnect,$pin,$cfmpin) = $expedition->getExpeditionInfo($expeditionno);
			include("$REGISTER_DIR/register_form1.php");
		} else if ($part == 2) {
	               include("$REGISTER_DIR/register_form2.php");
		} else if ($part == 3) {
			include("$REGISTER_DIR/register_form3.php");
		} else {
	               $utils->redirect("/error.ell?errID=999&retQry=1&sURI=/ed");
	               exit();
		}
	
	} else if ($action == "preview") {
	
	} else if ($action == "update") {
	
	        /* Error if expeditionno is not available */
	        if ($expeditionno == "") {
	        	$utils->redirect("/error.ell?errID=999&retQry=1&sURI=/ed");
	        	exit();	
	        }
	
	        /* Check if logon user is owner of expedition with expeditionno = $expeditionno */
	        if ( $expedition->checkIfOwner($erusername,$expeditionno) != "true") {
	                /* Change this error message if possible */
	        	$utils->redirect("/error.ell?errID=10&retQry=1&sURI=/ed");
	        	exit();
		}
	
		if ($part == 1) {
			include("$REGISTER_DIR/register_update_part1.ell");
		} else if ($part == 2) {
			include("$REGISTER_DIR/register_update_part2.ell");
		} else if ($part == 3) {
			include("$REGISTER_DIR/register_update_part3.ell");
		} else {
	                        $utils->redirect("/error.ell?errID=999&retQry=1&sURI=/ed");
	                        exit();
		}
	
	} else {
		$utils->redirect("/error.ell?errID=999&retQry=1&sURI=/ed");
	        exit();
	}
}

//$htm->closecell();
//$htm->closetable();
?>
