Added feature to create new list on phpInterface
This commit is contained in:
		| @@ -24,9 +24,9 @@ | ||||
| 		} | ||||
| 	} | ||||
|  | ||||
| 	if(isset($_GET['command']) && $_GET['command'] == "printRhasspyProductList") | ||||
| 	if(isset($_GET['command']) && $_GET['command'] == "printProductList") | ||||
| 	{ | ||||
| 		printRhasspyProductList(); | ||||
| 		displayProductList(); | ||||
| 		exit(0); | ||||
| 	} | ||||
|  | ||||
| @@ -64,13 +64,16 @@ | ||||
| 				$productId = $_POST['productToRemove']; | ||||
| 				removeFromList($productId); | ||||
| 				break; | ||||
| 			case "printShoppingList": | ||||
| 				printShoppingList(); | ||||
| 			case "displayShoppingList": | ||||
| 				displayShoppingList(); | ||||
| 				break; | ||||
| 			case "createNewShoppingList": | ||||
| 				createNewShoppingList(); | ||||
| 				break; | ||||
| 		} | ||||
| 	} | ||||
| 	 | ||||
| 	printShoppingList(); | ||||
| 	displayShoppingList(); | ||||
|  | ||||
| 	echo "</body></html>"; | ||||
|  | ||||
| @@ -118,7 +121,6 @@ | ||||
| 	} | ||||
|  | ||||
|  | ||||
|  | ||||
| 	function oneListExists() | ||||
| 	{ | ||||
| 		$SQL_command = "SELECT COUNT(id) as listAmount FROM lists"; | ||||
| @@ -133,10 +135,14 @@ | ||||
| 	} | ||||
|  | ||||
|  | ||||
|  | ||||
|  | ||||
| 	function printShoppingList() | ||||
| 	function displayShoppingList() | ||||
| 	{ | ||||
| 		echo "	<form action=\"".$_SERVER['PHP_SELF']."\" method=\"POST\" onSubmit=\"if(!confirm('Are you sure you want to create a new list?')){return false;}\"> | ||||
| 					<input type=\"hidden\" id=\"command\" name=\"command\" value=\"createNewShoppingList\" /> | ||||
| 					<input type=\"submit\" value=\"Create new list\" /> | ||||
| 				</form>"; | ||||
|  | ||||
|  | ||||
| 		echo "	<form action=\"".$_SERVER['PHP_SELF']."\" method=\"POST\"> | ||||
| 					<input type=\"hidden\" id=\"command\" name=\"command\" value=\"addToList\" /> | ||||
| 					<select name=\"productToAdd\" id=\"productToAdd\"> | ||||
| @@ -192,7 +198,7 @@ | ||||
| 	} | ||||
|  | ||||
|  | ||||
| 	function printRhasspyProductList() | ||||
| 	function displayProductList() | ||||
| 	{ | ||||
| 		$SQL_Befehl = "SELECT name, synonyms FROM products ORDER BY products.name ASC"; | ||||
| 		 | ||||
| @@ -209,4 +215,17 @@ | ||||
| 		} | ||||
| 	} | ||||
|  | ||||
|  | ||||
| 	function createNewShoppingList() | ||||
| 	{ | ||||
| 		$date = new DateTime(); | ||||
|  | ||||
| 		$SQL_command = "INSERT INTO lists (creationTime) VALUES (".($date->getTimestamp() * 1000).")"; | ||||
|  | ||||
| 		if (DBLink::getDbLink()->query($SQL_command)) | ||||
| 			echo "New list has been created.<br>"; | ||||
| 		else | ||||
| 			echo "Error creating new list.<br>"; | ||||
| 	} | ||||
|  | ||||
| ?> | ||||
		Reference in New Issue
	
	Block a user