<?php

//doctor_action.php

include('../class/Appointment.php');

$object = new Appointment;
if (isset($_POST["action"])) {
    if ($_POST["action"] == 'fetch') {
        $main_query = "
		SELECT unit_kerja, COUNT(no_urut) as Total FROM arsip_dimanis where ruang is not null GROUP BY unit_kerja ";

        $object->query = $main_query;

        $object->execute();

        $result = $object->get_result();

        $data = array();

        foreach ($result as $row) {
            $data[] = array(
                'unit_kerja'        =>    $row["unit_kerja"],
                'total'            =>    $row["Total"],
                'color'            =>    '#' . rand(100000, 999999) . ''
            );
        }

        echo json_encode($data);
    }
}
