0) { try { $pdo->beginTransaction(); $sql = "INSERT INTO " . DB_PREFIX . "orders (product_name, quantity, purchase_place, price_per_unit, delivery_date, notes, recipient, delivery_address, company, status) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, 'nowe')"; $stmt = $pdo->prepare($sql); $stmt->execute([$product_name, $quantity, $purchase_place, $price, $delivery_date, $notes, $recipient, $delivery_address, $company]); $order_id = $pdo->lastInsertId(); $hist_sql = "INSERT INTO " . DB_PREFIX . "order_history (order_id, user_id, action) VALUES (?, ?, ?)"; $hist_stmt = $pdo->prepare($hist_sql); $hist_stmt->execute([$order_id, $_SESSION['user_id'], 'Utworzono nowe zamówienie.']); $pdo->commit(); $message = "
Zamówienie dodane pomyślnie!
"; } catch (PDOException $e) { $pdo->rollBack(); $message = "
Błąd: " . $e->getMessage() . "
"; } } else { $message = "
Wypełnij nazwę produktu i ilość.
"; } } ?> Dodaj zamówienie - <?php echo APP_NAME; ?>
Nowe zamówienie
Powrót do listy