<?php
include "koneksi.php";
$bulans = array("Jan", "Feb", "Mar", "Apr", "Mei", "Jun", "Jul", "Agu", "Sep", "Okt", "Nov", "Des");
$response = array();
$response["data"] = array();
$query2 = mysqli_query($koneksi, "SELECT * FROM dimensi ORDER BY id_dimensi");
while ($row2 = mysqli_fetch_array($query2)){
	$dimensi = array();
	$dimensi['id_dimensi'] = $row2['id_dimensi'];
	$dimensi['nama_dimensi'] = $row2['nama_dimensi'];
	$dimensi['gambar'] = $row2['gambar'];
	$dimensi['pernyataan'] = array();
	$query=mysqli_query($koneksi, "SELECT * FROM aturan a, pernyataan g WHERE a.id_pernyataan=g.id_pernyataan AND a.id_dimensi='".$row2['id_dimensi']."'");
	if(mysqli_num_rows($query)==0){
		$output = array();
		$output["id_pernyataan"]=-1;
		$output["nama_pernyataan"]="Tidak Ada Pernyataan...";
		$output["cf"]=0.0;
		array_push($dimensi["pernyataan"], $output);
	} else {
		while ($row = mysqli_fetch_array($query)){
			$output = array();
			$output["id_pernyataan"]=$row["id_pernyataan"];
			$output["nama_pernyataan"]=$row["nama_pernyataan"];
			$output["cf"]=$row["cf"];
			array_push($dimensi["pernyataan"], $output);
		}
	}
	array_push($response["data"], $dimensi);
}
echo json_encode($response);
?>
