<?php
$sql['get_combo_tipe_ruang']="
SELECT tipeRuangId AS id, tipeRuangNama AS name
FROM tipe_ruang_ref
";

$sql['get_list_ruang']="
SELECT ruId AS `key`, TRIM(ruNama) AS `label`
FROM e_ruang
WHERE ruNama LIKE %s
";

$sql['get_list_jadwal']="
SELECT FLOOR(RAND()*1000) AS `id`, TB1.*
FROM
(
	# Get Jadwal Kuliah
	SELECT 
		ruId AS unit_id,
		ruNama, 
		CONCAT('#',ruNama,' : ',mkkurNamaResmi,' [',klsNama,']') AS `text`,
		CONCAT(DATE(presklsTanggalTerjadwal),' ',jdkulJamMulai) AS start_date,
		CONCAT(DATE(presklsTanggalTerjadwal),' ',jdkulJamSelesai) AS end_date
	FROM s_presensi_kelas
	LEFT JOIN s_jadwal_kuliah ON jdkulKlsId = presklsKlsId
	LEFT JOIN e_ruang ON ruId = jdkulRuId
	LEFT JOIN s_kelas ON klsId = jdkulKlsId
	LEFT JOIN s_matakuliah_kurikulum ON mkkurId = klsMkkurId
	WHERE ruId IS NOT NULL
	# Get Jadwal Ujian
	UNION
	SELECT 
		ruId AS unit_id,
		ruNama,
		CONCAT('#',ruNama,' : <b>Ujian</b> ',mkkurNamaResmi,' [',klsNama,']') AS `text`,
		CONCAT(jdujiTanggal,' ',jdujiJamMulai) AS start_date,
		CONCAT(jdujiTanggal,' ',jdujiJamSelesai) AS end_date
	FROM s_ruang_ujian
	LEFT JOIN s_jadwal_ujian ON jdujiId = rujJdujiId
	LEFT JOIN e_ruang ON ruId = rujRuId
	LEFT JOIN s_kelas ON klsId = jdujiKlsId
	LEFT JOIN s_matakuliah_kurikulum ON mkkurId = klsMkkurId
) AS TB1
WHERE
	TB1.ruNama LIKE %s AND
	TB1.start_date >= %s AND TB1.end_date <= %s
ORDER BY TB1.start_date DESC
";

$sql['get_list_gedung']="
SELECT
	SQL_CALC_FOUND_ROWS 
	gedungId, gedungKode, gedungNama
FROM gedung
WHERE gedungNama LIKE %s OR gedungKode LIKE %s
LIMIT %s,%s
";

$sql['get_count']="
SELECT FOUND_ROWS() AS total
";
?>