From c1349af904f070014dda2c324c2981d8cae6c5dc Mon Sep 17 00:00:00 2001 From: Flatlogic Bot Date: Tue, 24 Mar 2026 05:58:53 +0000 Subject: [PATCH] adding shipment types --- admin_shipment_edit.php | 16 ++++++++++++--- admin_shipments.php | 3 +++ .../add_shipment_type_to_shipments.php | 17 ++++++++++++++++ includes/app.php | 10 +++++++++- shipment_detail.php | 4 ++++ shipper_dashboard.php | 20 +++++++++++++++++-- 6 files changed, 64 insertions(+), 6 deletions(-) create mode 100644 db/migrations/add_shipment_type_to_shipments.php diff --git a/admin_shipment_edit.php b/admin_shipment_edit.php index 257023a..25c3462 100644 --- a/admin_shipment_edit.php +++ b/admin_shipment_edit.php @@ -69,6 +69,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') { validate_csrf_token(); // These are now selected from dropdowns, but the value is still the city name $origin_city = trim($_POST['origin_city'] ?? ''); $destination_city = trim($_POST['destination_city'] ?? ''); + $shipment_type = trim($_POST['shipment_type'] ?? 'Dry'); $cargo_description = trim($_POST['cargo_description'] ?? ''); $weight_tons = (float)($_POST['weight_tons'] ?? 0); $pickup_date = trim($_POST['pickup_date'] ?? ''); @@ -84,13 +85,13 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') { validate_csrf_token(); $updateSql = " UPDATE shipments SET shipper_name = ?, shipper_company = ?, origin_city = ?, destination_city = ?, - cargo_description = ?, weight_tons = ?, pickup_date = ?, delivery_date = ?, + shipment_type = ?, cargo_description = ?, weight_tons = ?, pickup_date = ?, delivery_date = ?, payment_method = ?, status = ? WHERE id = ? "; db()->prepare($updateSql)->execute([ $shipper_name, $shipper_company, $origin_city, $destination_city, - $cargo_description, $weight_tons, $pickup_date, $delivery_date, + $shipment_type, $cargo_description, $weight_tons, $pickup_date, $delivery_date, $payment_method, $status, $id ]); $flash = t('shipment_updated_success'); @@ -251,7 +252,16 @@ if (!$isAjax): -
+
+ + +
+ +
diff --git a/admin_shipments.php b/admin_shipments.php index d23c3a2..554e1f0 100644 --- a/admin_shipments.php +++ b/admin_shipments.php @@ -146,6 +146,9 @@ render_header(t('manage_shipments'), 'admin', true);
+ +
+
diff --git a/db/migrations/add_shipment_type_to_shipments.php b/db/migrations/add_shipment_type_to_shipments.php new file mode 100644 index 0000000..f45b1b2 --- /dev/null +++ b/db/migrations/add_shipment_type_to_shipments.php @@ -0,0 +1,17 @@ +query("SHOW COLUMNS FROM shipments LIKE 'shipment_type'"); + if ($stmt->fetch()) { + echo "Column 'shipment_type' already exists in 'shipments'.\n"; + } else { + $pdo->exec("ALTER TABLE shipments ADD COLUMN shipment_type VARCHAR(50) DEFAULT 'Dry' AFTER cargo_description"); + echo "Added 'shipment_type' column to 'shipments' table.\n"; + } +} catch (PDOException $e) { + echo "Error: " . $e->getMessage() . "\n"; +} + diff --git a/includes/app.php b/includes/app.php index 6576da3..3afb3e8 100644 --- a/includes/app.php +++ b/includes/app.php @@ -329,6 +329,10 @@ $translations = [ 'reg_expiry' => 'Reg. Expiry', 'ins_expiry' => 'Ins. Expiry', 'registration_doc' => 'Registration Doc', + 'shipment_type' => 'Shipment Type', + 'type_frozen' => 'Frozen', + 'type_cold' => 'Cold', + 'type_dry' => 'Dry', ), "ar" => array ( 'app_name' => 'CargoLink', @@ -646,6 +650,10 @@ $translations = [ 'reg_expiry' => 'انتهاء التسجيل', 'ins_expiry' => 'انتهاء التأمين', 'registration_doc' => 'وثيقة التسجيل', + 'shipment_type' => 'نوع الشحنة', + 'type_frozen' => 'مجمد', + 'type_cold' => 'مبرد', + 'type_dry' => 'جاف', ) ]; @@ -908,4 +916,4 @@ try { if ($tz && in_array($tz, DateTimeZone::listIdentifiers())) { date_default_timezone_set($tz); } -} catch (Throwable $e) {} \ No newline at end of file +} catch (Throwable $e) {} diff --git a/shipment_detail.php b/shipment_detail.php index 32891a9..0f6ad7c 100644 --- a/shipment_detail.php +++ b/shipment_detail.php @@ -215,6 +215,10 @@ render_header(t('shipment_detail'));
+
+
+
+
diff --git a/shipper_dashboard.php b/shipper_dashboard.php index 7f7e782..f9e79c8 100644 --- a/shipper_dashboard.php +++ b/shipper_dashboard.php @@ -28,6 +28,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST' && ($_POST['action'] ?? '') === 'creat $shipperCompany = trim($_POST['shipper_company'] ?? ''); $origin = trim($_POST['origin_city'] ?? ''); $destination = trim($_POST['destination_city'] ?? ''); + $shipmentType = trim($_POST['shipment_type'] ?? 'Dry'); $cargo = trim($_POST['cargo_description'] ?? ''); $weight = trim($_POST['weight_tons'] ?? ''); $pickupDate = trim($_POST['pickup_date'] ?? ''); @@ -44,8 +45,8 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST' && ($_POST['action'] ?? '') === 'creat $shipperId = isset($_SESSION['user_id']) ? (int)$_SESSION['user_id'] : null; $stmt = db()->prepare( - "INSERT INTO shipments (shipper_id, shipper_name, shipper_company, origin_city, destination_city, cargo_description, weight_tons, pickup_date, delivery_date, payment_method) - VALUES (:shipper_id, :shipper_name, :shipper_company, :origin_city, :destination_city, :cargo_description, :weight_tons, :pickup_date, :delivery_date, :payment_method)" + "INSERT INTO shipments (shipper_id, shipper_name, shipper_company, origin_city, destination_city, shipment_type, cargo_description, weight_tons, pickup_date, delivery_date, payment_method) + VALUES (:shipper_id, :shipper_name, :shipper_company, :origin_city, :destination_city, :shipment_type, :cargo_description, :weight_tons, :pickup_date, :delivery_date, :payment_method)" ); $stmt->execute([ ':shipper_id' => $shipperId, @@ -53,6 +54,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST' && ($_POST['action'] ?? '') === 'creat ':shipper_company' => $shipperCompany, ':origin_city' => $origin, ':destination_city' => $destination, + ':shipment_type' => $shipmentType, ':cargo_description' => $cargo, ':weight_tons' => $weight, ':pickup_date' => $pickupDate, @@ -215,6 +217,15 @@ $flash = get_flash();
+
+ + +
+
@@ -280,6 +291,11 @@ $flash = get_flash();
+ +
+ +
+