<html>
<HEAD>
	<link rel='stylesheet' type='text/css' href='../CSS/Font.css'>
	<link rel='stylesheet' type='text/css' href='../CSS/HeaderContentFooter.css'>
	<link rel='stylesheet' type='text/css' href='../CSS/Buttons.css'>
</HEAD>
<BODY>
<center><h4>Install apps</h4></center>
<form method="post" action="add_apps.php?added=yes">
	<table>
		<tr>
			<td>
				Enter string to be displayed to user
			</td>
			<td>
				<input type="text" name="prompt" />
			</td>
		</tr>
		<tr>
			<td>
				Enter command line argument when this app will be run
			</td>
			<td>
				<input type="text" name="argument" />
			</td>
		</tr>
	</table>
	<table><tr><td>
		After adding this app here make sure the executable is present in the Projects folder, also make sure appropriate handling is done in FetchDataCron.php
	</td></tr>
	<tr><td align="center">
		<input type="submit" name="ok" value="save" />
		<input type="submit" name="cancel" value="cancel" />
	</td></tr>
	</table>
</form>
<center><h4>Generate input file template</h4></center>
<form method="post" action="add_apps.php?added=yes">
	under construction
</form>
<center><h4>Data fetch accelerator</h4></center>
<form method="post" action="add_apps.php?added=yes">
	under construction
</form>

<?php


if(isset($_POST[ok])){
	if($_POST[prompt] == "" || $_POST[argument] == "" || $_POST[prompt] == NULL || $_POST[argument] == NULL){
		echo "{$_POST[prompt]}   <br/>";
		echo "{$_POST[argument]} <br/>";
		echo "{$_POST[prompt]}   <br/>";
		echo "{$_POST[argument]} <br/>";
		$msg = "Not enough information given";
	}else{

		// Open app list file
		$handle = fopen("../2_Projects/AppList.txt","a");

		// append prompt and argument
		fwrite($handle,$_POST[prompt] . "," . $_POST[argument] . "\n");

		// Save app list file
		fclose($handle);

		// return with message
		$msg = "App added successfully";
	}
	header("location: SplashScreen/SplashScreen.html?message={$msg}");

}elseif(isset($_POST[cancel])){
	header("location: SplashScreen/SplashScreen.html");;
}














?>

</body>
</html>
