<?php
include "koneksi.php";


// db settings
date_default_timezone_set('Asia/Jakarta'); //Menyesuaikan waktu dengan tempat kita tinggal

// db connection
// $con = mysqli_connect($hostname, $username, $password, $database) or die("Error " . mysqli_error($con));

// fetch records

$sql = "SELECT id, id_pasien,atribut, nama,announcer,ann_tujuan FROM tb_announcer WHERE announcer='1'";
$result = mysqli_query($open, $sql);
$array = array();
$no = 0;
$statuscode = '200';
while ($data = mysqli_fetch_assoc($result)) {
    $no++;
    // $tsql = "SELECT * FROM datapasien INNER JOIN tb_tindakan ON datapasien.id_pasien = tb_tindakan.id_pasien WHERE id_pasien='$data[id_pasien]' AND ruang='$nama_login'AND masalah='belum'";
    // $sqlcount = mysqli_num_rows(mysqli_query($open, $tsql));
    // if ($sqlcount > 0) {
    //     $count = '<span class="position-absolute top-0 start-100 translate-middle badge rounded-pill bg-danger">-</span>';
    // } else {
    //     $count = '<span class="position-absolute top-0 start-100 translate-middle badge rounded-pill bg-success"></span>';
    // }

   
    $sub_array['no'] = "<a style='font-size: 9px;'>$no</a>";
    $sub_array['triage'] = "<p  style='font-size: 9pt;'>$data[atribut]</p>";
    $sub_array['nama'] = "<a style='font-size: 9pt;' >$data[nama]</a>";
    // $sub_array['perawat'] = "<p style='font-size: 9px;' >$data[perawat_ppa]</p>";
    $sub_array['register'] = "<p style='font-size: 9pt;' >-</p>";
    // $sub_array['smf'] = "<p style='font-size: 9px;' >$data[smf]</p>";
    $sub_array['pengkajian'] = "<a style='font-size: 9pt;'>$data[ann_tujuan]</a>";
    // $sub_array['rencana'] = "<a style='font-size: 9px;' >$data[id_pasien]</a>";
    $sub_array['keluar'] = "<a style='font-size: 9pt;' >$data[announcer]</a>";
    $sub_array['waktu_tunggu'] = "<form action='./action_announcer.php' method='post'><input  type='hidden' name='id' value='$data[id]'><input class='btn btn-primary' type='submit'value='tutup' id='submit' name='submit'></form>";
    $array[] = $sub_array;
}


$dataset = array(
    "echo" => 1,
    "totalrecords" => count($array),
    "totaldisplayrecords" => count($array),
    "data" => $array
);

echo json_encode($dataset);
