hjkhjkjhkhjkgjghjhgjhgjghjhghjghjhgjjnbvnvbnvk
bnmbnmbnhjkhjkhjkhjktyutyutyuytutyutyutyhgjgjghjgjghjguytutyry
/
home
/
wjcvelqp
/
public_html
/
vc
/
Upload FileeE
HOME
<?php require_once __DIR__ . '/includes/bootstrap.php'; $q = clean_string($_GET['q'] ?? '', 120); $category_id = (int)($_GET['category_id'] ?? 0); $state_id = (int)($_GET['state_id'] ?? 0); $page = max(1, (int)($_GET['page'] ?? 1)); $sql = "SELECT sv.*, u.full_name AS provider_name, st.name AS state_name, c.name AS category_name FROM services sv LEFT JOIN users u ON u.id = sv.user_id LEFT JOIN states st ON st.id = sv.state_id LEFT JOIN service_categories c ON c.id = sv.category_id WHERE sv.status = 'active'"; $params = []; if ($q !== '') { $sql .= " AND (sv.title LIKE ? OR sv.description LIKE ?)"; $params[] = "%$q%"; $params[] = "%$q%"; } if ($category_id > 0) { $sql .= " AND sv.category_id = ?"; $params[] = $category_id; } if ($state_id > 0) { $sql .= " AND sv.state_id = ?"; $params[] = $state_id; } $countSql = "SELECT COUNT(*) FROM services sv WHERE sv.status='active'"; $cp = []; if ($q !== '') { $countSql .= " AND (sv.title LIKE ? OR sv.description LIKE ?)"; $cp[] = "%$q%"; $cp[] = "%$q%"; } if ($category_id > 0) { $countSql .= " AND sv.category_id = ?"; $cp[] = $category_id; } if ($state_id > 0) { $countSql .= " AND sv.state_id = ?"; $cp[] = $state_id; } $total = 0; $items = []; $categories = []; $states = []; try { $st = db()->prepare($countSql); $st->execute($cp); $total = (int)$st->fetchColumn(); $p = paginate($total, $page); $sql .= " ORDER BY sv.id DESC LIMIT {$p['per_page']} OFFSET {$p['offset']}"; $st = db()->prepare($sql); $st->execute($params); $items = $st->fetchAll(); $categories = db()->query('SELECT id,name FROM service_categories ORDER BY name')->fetchAll(); $states = db()->query('SELECT id,name FROM states ORDER BY name')->fetchAll(); } catch (Throwable $e) { $p = paginate(0,1); } $query = $_GET; unset($query['page']); $baseUrl = url('services.php') . ($query ? '?'.http_build_query($query) : ''); $page_title = 'Services — ' . VC_APP_NAME; $nav = 'services'; include __DIR__ . '/includes/header.php'; ?> <div class="page"><div class="container"> <div class="page-header"><div class="breadcrumb"><a href="<?= e(url('index.php')) ?>">Home</a> / Services</div> <h1>Local services</h1></div> <div class="filters"><form method="get"> <div class="form-group"><label>Search</label><input name="q" value="<?= e($q) ?>"></div> <div class="form-group"><label>Category</label><select name="category_id"><option value="">All</option> <?php foreach ($categories as $c): ?><option value="<?= (int)$c['id'] ?>" <?= $category_id===(int)$c['id']?'selected':'' ?>><?= e($c['name']) ?></option><?php endforeach; ?> </select></div> <div class="form-group"><label>State</label><select name="state_id"><option value="">All</option> <?php foreach ($states as $s): ?><option value="<?= (int)$s['id'] ?>" <?= $state_id===(int)$s['id']?'selected':'' ?>><?= e($s['name']) ?></option><?php endforeach; ?> </select></div> <button class="btn btn-primary" type="submit">Filter</button> </form></div> <p class="muted"><?= (int)$total ?> result(s)</p> <?php if (!$items): ?><div class="empty">No services found.</div> <?php else: ?><div class="grid grid-2 grid-3"><?php foreach ($items as $sv): ?> <article class="card"><div class="card-body"> <h3><a href="<?= e(url('service-details.php?id='.(int)$sv['id'])) ?>"><?= e($sv['title']) ?></a></h3> <div class="meta"><?= e($sv['category_name']??'') ?> · <?= e($sv['state_name']??'') ?> · <?= e($sv['provider_name']??'') ?></div> <p class="muted"><?= e(truncate($sv['description'],120)) ?></p> </div></article> <?php endforeach; ?></div><?= pagination_html($p,$baseUrl) ?><?php endif; ?> </div></div> <?php include __DIR__ . '/includes/footer.php'; ?>