<?php
include("../include/session.php");
include("../include/db.php");
	
	$query = "SELECT account_no FROM nam_rad_suppliers 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='supplierWiz0.php';
	   }
		 
	if (isset($_GET['finish_button']) )
	  {
		$action='displaySupplier.php?account_no='.$account_no ;
	  }
	
	$d = date("d");
	$m = date("m");
	$y = date("Y");
	$active="1";
		
	$account_name = $_SESSION['account_name'];
	$credit_cash =$_SESSION['credit_cash'] ;
	$Address1 = $_SESSION['AddressText1'];
	$Address2 = $_SESSION['AddressText2'];
	$phys_address = $Address1." ".$Address2;
	$phys_place = $_SESSION['PlaceText'];
	$post_address = $_SESSION['AddressText3'];
	$post_place = $_SESSION['PlaceText2'];
	$country = $_SESSION['CountryText'];
	$phone = $_SESSION['PhoneText'];
	$fax = $_SESSION['FaxText'];
	$contact1 =$_SESSION['ContactText1'] ="";
	$cell1 =$_SESSION['CellText1'] ="";
	$email1 = $_SESSION['emailText1'];
	$contact2 =$_SESSION['ContactText21'] ="";
	$cell2 = $_SESSION['CellText2'];
	$email2 = $_SESSION['emailText2'];
	$VAT_no = $_SESSION['VATText'];
	$notes = $_SESSION['RemarksText'];
	$created_by = $_SESSION['username'];
	date_default_timezone_set('Africa/Khartoum');
	$entryDate = date("Y-m-d H:i:s",time()-3600); 
	
	
	
	
	$supplierQuery = "INSERT INTO nam_rad_suppliers (entry_date,  
											account_no, 
											account_name, 
											credit_cash, 
											phys_address, 
											phys_place,
											post_address,
											post_place, 
											country, 
											phone, 
											fax, 
											contact1, 
											cell1, 
											email1, 
											contact2,
											cell2, 
											email2, 
											VAT_no,  
											notes, 
											entered_by)
	                                        VALUES (
													'".$entryDate."' , 
													'".$account_no."' , 
													'".$account_name."' , 
													'".$credit_cash."' , 
													'".$phys_address."' , 
													'".$phys_place."' , 
													'".$post_address."' ,
													'".$post_place."' , 
													'".$country."' , 
													'".$phone."' , 
													'".$fax."' , 
													'".$contact1."' , 
													'".$cell1."' , 
													'".$email1."' ,
													'".$contact2."' , 
													'".$cell2."' , 
													'".$email2."' , 
													'".$VAT_no."' , 
													'".$notes."' , 
													'".$created_by."'
													)";
	execsql($supplierQuery);
	
                    

	
	$actionQuery = "INSERT INTO nam_action_tracking (entry_date, user, action, details) VALUES ('".$entryDate."' ,'".$created_by."','New supplier account' ,'".$account_name."' )";
	execsql($actionQuery);
	
?>
<?php
     $_SESSION['account_name'] ="";
	 $_SESSION['credit_cash'] ="";
     $_SESSION['AddressText1'] = "";
	 $_SESSION['AddressText2'] = "";
	 $_SESSION['PlaceText'] = "";
	 $_SESSION['AddressText3'] = "";
	 $_SESSION['PlaceText2'] = "";
	 $_SESSION['CountryText'] = "";
	 $_SESSION['ContactText'] = "";
	 $_SESSION['PhoneText'] = "";
	 $_SESSION['FaxText'] = "";
	 $_SESSION['VATText'] = "";
	 $_SESSION['ContactText1'] ="";
	 $_SESSION['CellText1'] = "";
	 $_SESSION['emailText1'] = "";
	 $_SESSION['ContactText2'] ="";
	 $_SESSION['CellText2'] = "";
	 $_SESSION['emailText2'] = "";
	 $_SESSION['RemarksText'] = "";
	 
?>
<script language="javascript" type="text/javascript">
        <!--
		  window.location="<?php echo $action ?> ";
        -->
       </script>

