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

class Welcome extends CI_Controller {
    public function __construct(){
        parent::__construct();
        $this->load->library('session');
        $this->load->helper('url');
    }

    public function index()
    {


        // Jika SUDAH login, auto-redirect ke dashboard
        if ($this->session->userdata('logged_in')) {
            return redirect('dashboard');
        }
            $data['list_poli'] = $this->db->order_by('nama_poli', 'asc')->get('tb_poli')->result();
        $data['list_dokter'] = $this->db
            ->select('d.dokter_id, d.id_poli, p.nama_lengkap AS nama_dokter')
            ->from('tb_dokter d')
            ->join('tb_petugas p', 'p.petugas_id = d.id_petugas', 'left')
            ->where('p.status_aktif', 1)
            ->order_by('p.nama_lengkap', 'ASC')
            ->get()->result();

        $this->load->view('landing_page', $data);
    }
}
