<style>
.ui-datepicker-calendar {
    display: none;
    }
</style>
<?php
$PID = "grafik_banding";
$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;?>"/>
<input type="hidden" name="jml_hr" class="jml_hr" value="<?php echo $_GET["jml_hr"]; ?>"/>

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

<?php
$r = mysql_query("select a.id, a.keterangan,
(select count(b.id_booking) as id from tbl_booking b where b.jns_room = a.id and b.jns_room = '001' and (b.tgl_booking between '2015-10-26' and '2015-11-01')) as jml1
from tbl_referensi a
where a.id != '000' and kd = 'ROM'");

?>
<script type="text/javascript">
	function daysInMonth(month, year) {
	    return new Date(year, month, 0).getDate();
	}

$(function () {
	var nm_id = $("#bln_thn").val();
    var thn = nm_id[0];
    var bln = nm_id[1];
    var jml_hr = daysInMonth(bln, thn);
    var i = 1;
        
    $('#container').highcharts({
    	
        title: {
            text: 'Grafik Perbandingan Jenis Room perBulan'
        },
        xAxis: {
            categories: [
	            <?php
			    for ($i = 1; $i <= $_GET[jml_hr]; $i++) {
			        echo "'Tgl: " . $i . "', ";
			    }
			    ?>
            ]
        },
        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: [ ";
            for ($i = 1; $i <= 31; $i++) {
            		$day = str_pad(((int) $i), 2, "0", STR_PAD_LEFT);
			        $jlm = getFromTable("select count(b.id_booking) as id from tbl_booking b where b.jns_room = '".$row[id]."' and tgl_booking = '".$_GET[tgl1]."-".$day."' ");
			        echo $jlm." ,";
			        
			    }
            echo "]
        }, ";
	        
	    }
	    ?>
        
        ]
    });
});


</script>

<script src="grafik/highcharts.js"></script>
<script src="grafik/modules/exporting.js"></script>

<div id="container" style="min-width: 310px; height: 400px; margin: 0 auto"></div>


