[ 'page_title' => 'Επεξεργασία Παραγγελίας', 'customer_name' => 'Ονοματεπώνυμο Πελάτη *', 'email' => 'Email *', 'phone' => 'Τηλέφωνο *', 'status' => 'Κατάσταση Παραγγελίας', 'status_pending' => 'Εκκρεμεί', 'status_completed' => 'Ολοκληρώθηκε', 'status_cancelled' => 'Απορρίφθηκε', 'address' => 'Διεύθυνση / Πόλη', 'products_title' => 'Προϊόντα Παραγγελίας', 'prod_col' => 'Προϊόν', 'price_col' => 'Τιμή Μονάδας', 'qty_col' => 'Ποσότητα', 'total_col' => 'Σύνολο', 'grand_total' => 'Συνολικό Ποσό:', 'btn_save' => 'Αποθήκευση Αλλαγών', 'btn_back' => 'Επιστροφή στη Λίστα', 'msg_ok' => 'Η παραγγελία ενημερώθηκε επιτυχώς!', 'msg_err' => 'Παρακαλώ συμπληρώστε τα υποχρεωτικά πεδία.' ], 'en' => [ 'page_title' => 'Edit Order', 'customer_name' => 'Customer Name *', 'email' => 'Email *', 'phone' => 'Phone *', 'status' => 'Order Status', 'status_pending' => 'Pending', 'status_completed' => 'Completed', 'status_cancelled' => 'Cancelled', 'address' => 'Address / City', 'products_title' => 'Order Products', 'prod_col' => 'Product', 'price_col' => 'Unit Price', 'qty_col' => 'Quantity', 'total_col' => 'Total', 'grand_total' => 'Grand Total:', 'btn_save' => 'Save Changes', 'btn_back' => 'Back to List', 'msg_ok' => 'Order updated successfully!', 'msg_err' => 'Please fill in required fields.' ] ]; $t = $translations[$current_lang]; header('Content-Type: text/html; charset=utf-8'); $message = ''; $order_id = isset($_GET['id']) ? (int)$_GET['id'] : 0; if ($order_id === 0) { header("Location: orders.php"); exit; } if ($_SERVER['REQUEST_METHOD'] === 'POST') { $customer_name = trim($_POST['customer_name']); $customer_email = trim($_POST['customer_email']); $customer_phone = trim($_POST['customer_phone']); $shipping_address = trim($_POST['shipping_address']); $status = $_POST['status']; if (!empty($customer_name) && !empty($customer_email) && !empty($customer_phone)) { try { $stmt = $pdo->prepare("UPDATE orders SET customer_name = ?, customer_email = ?, customer_phone = ?, shipping_address = ?, status = ? WHERE id = ?"); $stmt->execute([$customer_name, $customer_email, $customer_phone, $shipping_address, $status, $order_id]); $message = "
{$t['msg_ok']}
"; } catch (Exception $e) { $message = "
Σφάλμα: " . $e->getMessage() . "
"; } } else { $message = "
{$t['msg_err']}
"; } } $stmt = $pdo->prepare("SELECT * FROM orders WHERE id = ?"); $stmt->execute([$order_id]); $order = $stmt->fetch(PDO::FETCH_ASSOC); if (!$order) { die("Order not found."); } $itemsStmt = $pdo->prepare(" SELECT oi.*, p.title FROM order_items oi JOIN products p ON oi.product_id = p.id WHERE oi.order_id = ? "); $itemsStmt->execute([$order_id]); $items = $itemsStmt->fetchAll(PDO::FETCH_ASSOC); ?> <?php echo $t['page_title']; ?> #<?php echo $order['id']; ?> - Hockey CMS

#

€ €

€