shopping-list/public_html/php/edit-recipes.php

43 lines
1,007 B
PHP
Raw Permalink Normal View History

2018-10-24 15:00:27 +02:00
<?php
include $_SESSION["docroot"].'/php/classes.recipe.php';
$book = new cookbook;
2018-11-20 09:59:59 +01:00
switch ($_GET["function"]) {
2018-10-24 15:00:27 +02:00
case 'del':
$book->removeRecipe($_POST["id"]);
break;
case 'new':
$book->newRecipe($_POST["recipeName"], $_POST["recipeDuration"], $_POST["recipeDescription"], $_POST["ingredient"]);
header('Location: /recipes');
break;
case 'auto':
2019-05-21 09:21:59 +02:00
$book->getAllIngredientsContaining($_POST["q"]);
2018-10-24 15:00:27 +02:00
break;
case 'edit':
$book->getRecipe($_POST["id"]);
echo json_encode($book->sites[0]);
break;
case 'update':
$book->updateRecipe($_POST["id"], $_POST["recipeName"], $_POST["recipeDuration"], $_POST["recipeDescription"], $_POST["ingredient"]);
header(("Location: /recipe/".$_POST["id"]));
break;
2018-10-29 22:14:56 +01:00
case 'export':
$book->fillCookbook();
echo json_encode($book);
break;
2018-11-14 16:08:36 +01:00
case 'import':
$book->importCookbook();
break;
2018-10-24 15:00:27 +02:00
default:
// code...
break;
}
?>