<?php
$PID = "grafik_cekout";
$SC = $_SERVER["SCRIPT_NAME"];

require_once("lib/dbconn.php");
require_once("lib/form.php");
require_once("lib/functions.php");
?>
<br/>
<form>
<input type="hidden" name="p" value="<?php echo $PID;?>"/>

<table class="gridtable_form" width="40%">
	<tr>
		<td><b>Date</b></td>
		<td><input type="text" name="tgl1" class="tgl1" value="<?php echo $_GET["tgl1"]; ?>" ></td>
	</tr>
	<tr>
		<td><b>s/d</b></td>
		<td><input type="text" name="tgl2" class="tgl2" value="<?php echo $_GET["tgl2"]; ?>" ></td>
	</tr>
	<tr>
		<td>&nbsp;</td>
		<td><input type="submit" value="Tampilkan"/></td>
	</tr>
</table>
</form>

<?php
$sql = "select a.id, a.keterangan,
		(select count(b.id_booking) as id from tbl_booking b where b.jns_room = a.id 
		and b.status_booking in ('cekout') and (b.tgl_cekout between '".$_GET[tgl1]."' and '".$_GET[tgl2]."')) as jml
		from tbl_referensi a
		where a.id != '000' and kd = 'ROM'";
$r = mysql_query($sql);
?>

<script type='text/javascript'>
$(function () {
    $('#container').highcharts({
        title: {
            text: 'Grafik Booking by Jenis Room'
        },
        xAxis: {
            categories: ['']
        },
        labels: {
            items: [{
                html: '',
                style: {
                    left: '50px',
                    top: '18px',
                    color: (Highcharts.theme && Highcharts.theme.textColor) || 'black'
                }
            }]
        },
        series: [
        <?php
		    while ($row = mysql_fetch_array($r)) {
        echo "{
            type: 'column',
            name: '".$row[keterangan] . "',
            data: [ ".$row[jml] . "]
        }, ";
        }
        ?>
        
        ]
    });
});

</script>

<script src="grafik/highcharts.js"></script>
<script src="grafik/modules/exporting.js"></script>
<?php if (isset($_GET[tgl1])){ ?>
	<div id="container" style="min-width: 310px; height: 400px; margin: 0 auto"></div>
<?php } ?>
