<?php
include("../include/session.php");
include("../include/db.php");
	
	$query = "SELECT account_no FROM rad_tocotex ORDER BY account_no DESC LIMIT 1 ";
	$result = mySQL_query($query) or die ("Error in query:   $Query . * ". mySQL_error());
	$account_no = mysql_result($result, 0, "account_no");
	$account_no= $account_no+1;
	
	if (isset($_GET['new_button']) )
	   {
		 $action='tocotexWiz0.php';
	   }
		 
	if (isset($_GET['finish_button']) )
	  {
		$action='displayTocotex.php?account_no='.$account_no ;
	  }
	
	
	$d = date("d");
	$m = date("m");
	$y = date("Y");
	$modDate=date('Y-m-d');
	$active="1";
		
	$Comp = $_SESSION['name'];
	$Contact = $_SESSION['ContactText'];
	$Address1 = $_SESSION['AddressText1'];
	$Address2 = $_SESSION['AddressText2'];
	$Address = $Address1." ".$Address2;
	$Place = $_SESSION['PlaceText'];
	$Address3 = $_SESSION['AddressText3'];
	$Place2 = $_SESSION['PlaceText2'];
	$Country = $_SESSION['CountryText'];
	$Phone = $_SESSION['PhoneText'];
	$Fax = $_SESSION['FaxText'];
	$Cell = $_SESSION['CellText'];
	$email = $_SESSION['emailText'];
	$VAT = $_SESSION['VATText'];
	$Remarks = $_SESSION['RemarksText'];
	$created_by = $_SESSION['username'];
	date_default_timezone_set('Africa/Khartoum');
	$entryDate = date("Y-m-d H:i:s",time()-3600); 
	
	$custQuery = "INSERT INTO rad_tocotex (entry_date, account_no,  name, contact, post_address, post_place, phys_address, phys_place, country, phone, fax, cell, email, vat_no,  notes, entered_by) VALUES ('".$entryDate."' ,'".$account_no."' , '".$Comp."','".$Contact."', '".$Address."','".$Place."', '".$Address3."','".$Place2."' ,'".$Country."' , '".$Phone."','".$Fax."', '".$Cell."', '".$email."', '".$VAT."',  '".$Remarks."', '".$created_by."')";
	execsql($custQuery);
	
	$actionQuery = "INSERT INTO action_tracking (entry_date, user, action, details) VALUES ('".$entryDate."' ,'".$created_by."','New Tocotex account' ,'".$Comp."' )";
	execsql($actionQuery);
	
?>
<?php
    $_SESSION['customer_name'] ="";
     $_SESSION['AddressText1'] = "";
	 $_SESSION['AddressText2'] = "";
	 $_SESSION['PlaceText'] = "";
	 $_SESSION['AddressText3'] = "";
	 $_SESSION['PlaceText2'] = "";
	 $_SESSION['CountryText'] = "";
	 $_SESSION['ContactText'] = "";
	 $_SESSION['CellText'] = "";
	 $_SESSION['PhoneText'] = "";
	 $_SESSION['FaxText'] = "";
	 $_SESSION['emailText'] = "";
	 $_SESSION['VATText'] = "";
	 $_SESSION['RemarksText'] = "";
?>
<script language="javascript" type="text/javascript">
        <!--
		  window.location="<?php echo $action ?> ";
        -->
       </script>

