<?php
defined('BASEPATH') OR exit('No direct script access allowed');

class Front extends CI_Controller
{
    private $offers;

    public function __construct()
    {
        parent::__construct();
        $this->load->helper('url');
        $this->offers = include(APPPATH . 'data/offers_data.php');
    }
    public function index()
    {
        $data['offers'] = [
            'dubai-tour' => [
                'title' => 'Turkish-Airlines',
                'price' => 584,
                'image' => 'assets/img/destination/Turkish-Airlines.webp',
                'location' => 'Turki',
                'duration' => '6 Days - 5 Nights',
            ],
            'emirates-tour' => [
                'title' => 'Emirates Tour',
                'price' => 610,
                'image' => 'assets/img/destination/emirates.webp',
                'location' => 'Emirates',
                'duration' => '7 Days - 6 Nights',
            ],
            'cathay-pacific' => [
                'title' => 'China-Airlines',
                'price' => 410,
                'image' => 'assets/img/destination/China-Airlines.webp',
                'location' => 'China',
                'duration' => '4 Days - 3 Nights',
            ],
        ];
        $data['current_page'] = 'index';
    
        $this->load->view('inc/header', $data);
        $this->load->view('front/index', $data);
        $this->load->view('inc/footer', $data);
    }

    public function deals()
    {
        $data = [
            'current_page' => 'deals',
            'offers'       => $this->offers,
        ];
        $this->load->view('inc/header', $data);  // ← pass $data
        $this->load->view('front/deals', $data);
        $this->load->view('inc/footer');
    }

    public function contact()
    {
        $data = ['current_page' => 'contact'];
        $this->load->view('inc/header', $data);  // ← pass $data
        $this->load->view('front/contact');
        $this->load->view('inc/footer');
    }

    public function tour_details($slug = NULL)
    {
        if (empty($slug)) show_404();
        if (!isset($this->offers[$slug])) show_404();

        $offer = $this->offers[$slug];

        $data = [
            'current_page' => 'deals',
            'page_title'   => $offer['title'] . ' — Our Offers',
            'offer'        => $offer,
            'slug'         => $slug,
        ];

        $this->load->view('inc/header', $data);  // ← pass $data
        $this->load->view('front/tour_details', $data);
        $this->load->view('inc/footer');
    }
}