33 lines
965 B
PHP
33 lines
965 B
PHP
<?php
|
|
// food/merchant/browse.php — تصفح المطاعم النشطة في مدينة الزبون
|
|
require_once __DIR__ . '/../connect_app.php';
|
|
|
|
$city = filterRequest('city');
|
|
if (!$city) jsonError('city is required');
|
|
|
|
$category = filterRequest('category');
|
|
|
|
$sql = "SELECT id, name_ar, name_en, logo_url, cover_url, city, category,
|
|
min_order_amount, avg_prep_minutes, rating_avg, rating_count,
|
|
is_open_override, working_hours
|
|
FROM food_merchants WHERE city=? AND status='active'";
|
|
$params = [$city];
|
|
|
|
if ($category) {
|
|
$sql .= " AND category=?";
|
|
$params[] = $category;
|
|
}
|
|
$sql .= " ORDER BY rating_avg DESC, rating_count DESC";
|
|
|
|
$st = $food_con->prepare($sql);
|
|
$st->execute($params);
|
|
$merchants = $st->fetchAll();
|
|
|
|
foreach ($merchants as &$m) {
|
|
$m['is_open'] = foodIsMerchantOpen($m);
|
|
unset($m['working_hours'], $m['is_open_override']);
|
|
}
|
|
unset($m);
|
|
|
|
jsonSuccess(['merchants' => $merchants]);
|