|
|
|
|
@ -4,6 +4,9 @@ require_once 'includes/auth.php';
|
|
|
|
|
checkAuth();
|
|
|
|
|
|
|
|
|
|
$message = '';
|
|
|
|
|
if (isset($_GET['saved']) && $_GET['saved'] === '1') {
|
|
|
|
|
$message = "<div class='alert alert-success'>Zamówienie dodane pomyślnie. Możesz dodać kolejne.</div>";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ($_SERVER["REQUEST_METHOD"] === "POST") {
|
|
|
|
|
requireCsrfToken();
|
|
|
|
|
@ -17,6 +20,7 @@ if ($_SERVER["REQUEST_METHOD"] === "POST") {
|
|
|
|
|
$recipient = trim($_POST['recipient'] ?? '');
|
|
|
|
|
$delivery_address = trim($_POST['delivery_address'] ?? '');
|
|
|
|
|
$company = trim($_POST['company'] ?? '');
|
|
|
|
|
$submit_action = $_POST['submit_action'] ?? 'save_and_list';
|
|
|
|
|
|
|
|
|
|
if ($product_name !== '' && $quantity > 0) {
|
|
|
|
|
try {
|
|
|
|
|
@ -35,7 +39,12 @@ if ($_SERVER["REQUEST_METHOD"] === "POST") {
|
|
|
|
|
$hist_stmt->execute([$order_id, $_SESSION['user_id'], 'Utworzono nowe zamówienie.']);
|
|
|
|
|
|
|
|
|
|
$pdo->commit();
|
|
|
|
|
$message = "<div class='alert alert-success'>Zamówienie dodane pomyślnie.</div>";
|
|
|
|
|
if ($submit_action === 'save_and_add_new') {
|
|
|
|
|
header("Location: add_order.php?saved=1");
|
|
|
|
|
exit();
|
|
|
|
|
}
|
|
|
|
|
header("Location: index.php");
|
|
|
|
|
exit();
|
|
|
|
|
} catch (PDOException $e) {
|
|
|
|
|
$pdo->rollBack();
|
|
|
|
|
error_log($e->getMessage());
|
|
|
|
|
@ -119,7 +128,10 @@ if ($_SERVER["REQUEST_METHOD"] === "POST") {
|
|
|
|
|
|
|
|
|
|
<div class="d-flex justify-content-between">
|
|
|
|
|
<a href="index.php" class="btn btn-secondary">Powrót do listy</a>
|
|
|
|
|
<button type="submit" class="btn btn-primary"><i class="bi bi-check-lg"></i> Zapisz zamówienie</button>
|
|
|
|
|
<div class="d-flex gap-2">
|
|
|
|
|
<button type="submit" name="submit_action" value="save_and_list" class="btn btn-primary"><i class="bi bi-check-lg"></i> Zapisz zamówienie</button>
|
|
|
|
|
<button type="submit" name="submit_action" value="save_and_add_new" class="btn btn-outline-primary"><i class="bi bi-plus-lg"></i> Dodaj nowe</button>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</form>
|
|
|
|
|
</div>
|
|
|
|
|
|