<?php
require_once '../../config/config.php';
require_once '../../includes/auth.php';

requireCompanyLogin();

$companyId = $_SESSION['company_id'];
$id = $_GET['id'] ?? 0;

$stmt = $pdo->prepare("SELECT * FROM services WHERE id = ? AND company_id = ?");
$stmt->execute([$id, $companyId]);
$service = $stmt->fetch();

if (!$service) {
    setFlashMessage('error', 'Hizmet bulunamadı.');
    redirect('index.php');
}

// Resmi sil
if ($service['image']) {
    $imagePath = str_replace(UPLOAD_URL, UPLOAD_PATH, $service['image']);
    deleteImage($imagePath);
}

// Hizmeti sil
$stmt = $pdo->prepare("DELETE FROM services WHERE id = ? AND company_id = ?");
$stmt->execute([$id, $companyId]);

setFlashMessage('success', 'Hizmet başarıyla silindi.');
redirect('index.php');








