<?php
date_default_timezone_set('Asia/Jakarta');
defined('BASEPATH') or exit('No direct script access allowed');

class Ikbs extends CI_Controller
{

    public function index()
    {
        $this->load->view('ikbs/tampil_antrian_ikbs');
    }

    public function get_jadwal_operasi()
    {
        $curl = curl_init();

        // Mengambil data yang dikirimkan melalui POST jika diperlukan
        $data = $this->input->post();

        curl_setopt_array($curl, array(
            CURLOPT_URL => '103.255.241.146/api/d_reg_online/tampil_jadwal_operasi',
            CURLOPT_RETURNTRANSFER => true,
            CURLOPT_ENCODING => '',
            CURLOPT_MAXREDIRS => 10,
            CURLOPT_TIMEOUT => 0,
            CURLOPT_FOLLOWLOCATION => true,
            CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
            CURLOPT_CUSTOMREQUEST => 'POST',
            CURLOPT_POSTFIELDS => $data,  // Mengirimkan data POST jika ada
        ));

        $response = curl_exec($curl);
        curl_close($curl);

        $json = str_replace('\r\n     ', "---0", $response);
        $json = str_replace('\r\n', "---", $json);
        $json = json_decode($json);

        // Mengembalikan data dalam format JSON
        echo json_encode($json->response);
    }
}
