shopping-list/cont/manageRecipe.php

74 lines
3 KiB
PHP
Raw Normal View History

2019-05-19 18:37:00 +02:00
<?php
if($_SERVER["REQUEST_URI"]!="/new-recipe"){
$submitFunction = "update";
$title = "Bearbeiten";
$script = '<script src="/bin/edit-recipe.js" charset="utf-8"></script>';
$additionalInput = "<input type='hidden' name='id' value=''>";
}
else{
$submitFunction = "new";
$title = "Neu";
$script = '';
$additionalInput = "";
}
?>
2019-05-19 20:31:37 +02:00
<script src="/bin/bootstrap.autocomplete.js" charset="utf-8"></script>
2018-10-24 15:00:27 +02:00
<script src="/bin/manageRecipe.js" charset="utf-8"></script>
2019-05-19 18:37:00 +02:00
<?php echo $script; ?>
<div class="container mt-5">
<h1><?php echo $title ?></h1>
</div>
<form action="/api/recipes/<?php echo $submitFunction; ?>" method="post">
<?php echo $additionalInput; ?>
<div class="form-group">
<label for="recipeName">Titel</label>
<input type="text" class="form-control" id="recipeName" name="recipeName" aria-describedby="recipeHelp" placeholder="Titel" required>
<small id="recipeHelp" class="form-text text-muted">Titel des Rezepts, wird in der Rezepteübersicht angezeigt.</small>
</div>
<div class="form-group">
<label for="recipeDuration">Dauer</label>
<input type="number" class="form-control" id="recipeDuration" name="recipeDuration" aria-describedby="durationHelp" placeholder="30 min" min="0" step="0.1" required>
<small id="durationHelp" class="form-text text-muted">Zubereitungszeit in Minuten.</small>
</div>
<div class="form-group">
<label for="recipeDescription">Beschreibung</label>
<textarea class="form-control" id="recipeDescription" name="recipeDescription" rows="3" rows="8" cols="80" spellcheck="true" required></textarea>
</div>
<label>Zutaten</label>
<div class="ingredientRow form-group d-flex flex-row">
<input type="number" class="form-control col-2" name="ingredient[1][Amount]" value="1" min="0" step="0.1">
<select class="ingredientUnit col-2 ml-1 mr-1 rounded" name="ingredient[1][Unit]">
<?php
include $_SESSION["docroot"].'/php/classes.recipe.php';
$unitList = new unitList;
foreach ($unitList->units as $unit) {
if($unit->Standard){$selected="selected";}else{$selected=NULL;}
echo "<option value='$unit->ID' $selected>$unit->Name</option>";
}
?>
</select>
<div class="input-group">
2019-05-19 20:31:37 +02:00
<input type="text" class="autocomplete-ingredient form-control" name="ingredient[1][Name]" placeholder="Zutat" autocomplete="off" required>
2019-05-19 18:37:00 +02:00
<div class="input-group-append">
<span class="input-group-text p-0"><button onclick="removeItem(this);" class="removeItem fas fa-trash-alt bg-transparent rounded-right border-0 p-2 pl-3 pr-3 text-danger"></button></span>
2018-10-24 15:00:27 +02:00
</div>
</div>
</div>
2019-05-19 18:37:00 +02:00
<div class="form-group">
<button type="button" data-count="1" class="btn btn-secondary" id="addItem"><i class="fas fa-plus"></i> Zutat</button>
</div>
<div class="form-group float-right">
<a class="btn btn-danger text-light" id="cancel">Abbrechen</a>
<button type="submit" class="btn btn-primary">Speichern</button>
</div>
</form>