From 2d3486ba46aa3d84a5d2c3bc2c0aad3c9203fc9a Mon Sep 17 00:00:00 2001 From: Flatlogic Bot Date: Sun, 8 Mar 2026 06:12:11 +0000 Subject: [PATCH] add countries to shipments --- api/get_cities.php | 20 ++++++++++++ shipment_detail.php | 9 +++--- shipper_dashboard.php | 75 +++++++++++++++++++++++++++++++++++++++++-- 3 files changed, 98 insertions(+), 6 deletions(-) create mode 100644 api/get_cities.php diff --git a/api/get_cities.php b/api/get_cities.php new file mode 100644 index 0000000..bc2a11b --- /dev/null +++ b/api/get_cities.php @@ -0,0 +1,20 @@ +prepare("SELECT id, name_en, name_ar FROM cities WHERE country_id = ? ORDER BY name_en ASC"); + $stmt->execute([$countryId]); + $cities = $stmt->fetchAll(PDO::FETCH_ASSOC); + echo json_encode($cities); +} catch (Exception $e) { + echo json_encode(['error' => $e->getMessage()]); +} diff --git a/shipment_detail.php b/shipment_detail.php index bc04268..109ea2e 100644 --- a/shipment_detail.php +++ b/shipment_detail.php @@ -22,7 +22,8 @@ $isShipper = $userRole === 'shipper'; $isTruckOwner = $userRole === 'truck_owner'; // Platform Fee Configuration -const PLATFORM_FEE_PERCENTAGE = 0.05; // 5% +$settings = get_settings(); +$platformFeePercentage = (float)($settings['platform_charge_percentage'] ?? 0) / 100; // Handle POST actions if ($_SERVER['REQUEST_METHOD'] === 'POST') { @@ -52,7 +53,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') { } elseif ($action === 'accept_offer' && $isShipper) { if ($shipment && $shipment['status'] === 'offered' && $shipment['offer_price'] > 0) { $offerPrice = (float)$shipment['offer_price']; - $platformFee = $offerPrice * PLATFORM_FEE_PERCENTAGE; + $platformFee = $offerPrice * $platformFeePercentage; $totalPrice = $offerPrice + $platformFee; $stmt = db()->prepare( @@ -186,7 +187,7 @@ render_header(t('shipment_detail')); 0): ?>
@@ -197,7 +198,7 @@ render_header(t('shipment_detail')); $
- Platform Fee (5%) + Platform Fee (%) $

diff --git a/shipper_dashboard.php b/shipper_dashboard.php index 118a444..2ec95fc 100644 --- a/shipper_dashboard.php +++ b/shipper_dashboard.php @@ -96,6 +96,12 @@ try { } } catch (Throwable $e) {} +// Fetch countries for dropdowns +$countries = []; +try { + $countries = db()->query("SELECT * FROM countries ORDER BY name_en ASC")->fetchAll(); +} catch (Throwable $e) {} + render_header(t('shipper_dashboard'), 'shipper'); $flash = get_flash(); ?> @@ -155,13 +161,38 @@ $flash = get_flash();
+
+ + +
- + +
+
+ +
+
+ +
- +
@@ -255,4 +286,44 @@ $flash = get_flash(); + + \ No newline at end of file