<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js">
 </script>
 <script>
 $(document).ready(function(){
 setInterval(function(){cache_clear()},18000000); //30menit
 });
 function cache_clear()
{
 window.location.reload(true);
}
</script>
        <link rel="stylesheet" href="Highcharts/nesw2/images/style.css" type="text/css">
	    <link type="text/css" href="css/jquery-ui-1.8.6.custom.css" rel="stylesheet" />	
		<script type="text/javascript" src="js/jquery-1.4.2.min.js"></script>
		<script type="text/javascript" src="js/jquery-ui-1.8.6.custom.min.js"></script>
		<script type="text/javascript">
		jQuery(function($){
		$.datepicker.regional['vi'] = {
			closeText: 'Tutup',
			prevText: 'Sebelum',
			nextText: 'Sesudah',
			currentText: 'Sekarang',
			monthNames: ['Januari', 'Februari', 'Maret', 'April', 'Mei', 'Juni',
			'Juli', 'Agustus', 'September', 'Oktober', 'November', 'Desember'],
			monthNamesShort: ['Jan', 'Feb', 'Mar', 'Apr', 'Mei', 'Jun',
			'Jul', 'Ags', 'Sep', 'Okt', 'Nov', 'Des'],
			dayNames: ['Minggu', 'Senin', 'Selasa', 'Rabu', 'Kamis', 'Jum&acute;at', 'Sabtu'],
			dayNamesShort: ['Min', 'Sen', 'Sel', 'Rab', 'Kam', 'Jum', 'Sbt'],
			dayNamesMin: ['Mg', 'Sn', 'Sl', 'Rb', 'Km', 'Jm', 'Sb' ],
			dateFormat: 'yy-mm-dd',
			firstDay: 0,
			isRTL: false,
			showMonthAfterYear: false,
			changeMonth: true,
			changeYear: true,
			yearSuffix: ''};

		$.datepicker.setDefaults($.datepicker.regional['vi']);

	  	$(function(){

				$('#tgl').datepicker({

					inline: true

				});

	    });

		$(function(){

				$('#tglf').datepicker({

					inline: true

				});

	    });

       });
</script>


<?php

include "config/conn.php";

date_default_timezone_set('Asia/Jakarta');
$tanggal= mktime(0,0,0,date('m'),date('d'),date('Y'));
if($_POST['cari']=="Cari") {
$hariini=$_POST['tgl'];
} else { 
$hariini = date("Y-m-d", $tanggal);
}
?>

          <title>.:: SIS BANJIR | CILIWUNG CISADANE ::.</title>
          <table width="100%">
    <thead>
			  	<tr>
                <th><img src="images/logo.png" /></th>
                 <th colspan="25" style="background-color:#FC0; background-image:'images/logo.png' color:#000; font-family:'Courier New', Courier, monospace; font-size:14px; padding-left:50px;" align="left">INFORMASI CURAH HUJAN (mm/jam) <br />BALAI BESAR WILAYAH SUNGAI CILIWUNG CISADANE<br />TANGGAL : <form method="post" action=""><input type="text" id="tgl" name="tgl" value="<?php echo $hariini;?>" /><input type="submit" name="cari" id="cari" value="Cari" /></form></th> 
                 <th>
                 <table width="250px" style="font-size:12px;">
	<tr>
	    <td colspan="2">KETERANGAN :</td>
    </tr>
	<tr>
	    <td bgcolor="#66CCCC" width="30px"></td>
	    <td >Sangat Ringan (&lt;1mm/jam)</td>
    </tr>
	<tr>
	    <td bgcolor="#00FF00" width="30px"></td>
	    <td >Ringan (1 - 5 mm/jam)</td>
    </tr>
	<tr>
	    <td bgcolor="#FFFF00" width="30px"></td>
	    <td >Sedang ( 5 - 10 mm/jam)</td>
    </tr>
	<tr>
	    <td bgcolor="#FF9900" width="30px"></td>
	    <td >Lebat (10 - 20 mm/jam)</td>
    </tr>
	<tr>
	    <td bgcolor="#FF0000" width="30px"></td>
	    <td >Sangat Lebat (&gt; 20 mm/jam)</td>
    </tr>
</table>

                 </th> 
                </tr>
              </thead>	 
		  </table>
<table width="100%">
              <thead>
              <tr>
                    <th style="background-color:#FC0; color:#000; font-size:12px;">LOKASI</th>
                    <th style="background-color:#FC0; color:#000; font-size:12px;">SUNGAI</th>
                    <?php
					$sql_jam=mysql_query("SELECT DATE_FORMAT(jam_value,'%H:00') AS jam FROM m_jam ORDER BY jam_value ASC");
					while($rjam=mysql_fetch_array($sql_jam)){
					?>
                    	<th style="background-color:#FC0; color:#000; font-size:12px;"><?php echo $rjam['jam'];?></th>
					<?php
					}
                    ?>
                    <th style="background-color:#FC0; color:#000; font-size:12px;">TOTAL</th>
               </tr>
               </thead>
              <?php 
			  $sql="(SELECT * FROM m_lokasi WHERE 1=1 AND nama_lokasi='gunungmas')
UNION ALL
(SELECT * FROM m_lokasi WHERE 1=1 AND nama_lokasi='bdgkatulampa')
UNION ALL
(SELECT * FROM m_lokasi WHERE 1=1 AND id_bbws=1 AND id_tipe='PCH' AND id_merk!='MANUAL' AND status_lokasi=1 and nama_lokasi NOT IN ('gunungmas') ORDER BY urutan_sungai ASC)";
//			  $sql="SELECT * FROM m_lokasi WHERE 1=1 AND id_bbws=1 AND id_tipe='PCH' AND status_lokasi=1 ORDER BY urutan_sungai ASC";
              $query = mysql_query($sql);
			  $i=0;
              while ($row_detdata=mysql_fetch_array($query)){
              $i++;
			?>
              <tr>
                  	<td style="background-color:#FC0; color:#000;  font-size:12px;">
                    <?php echo str_replace('awlr_','',$row_detdata['nama_alat']);?>
                   	</td>
                  	<td style="background-color:#FC0; color:#000;  font-size:12px;">
                    <?php echo $row_detdata['ws'];?>
                   	</td>
  <?php
					$sql_jam=mysql_query("SELECT DATE_FORMAT(jam_value,'%H:00') AS jam FROM m_jam ORDER BY jam_value ASC");
$tot=0;
while($rjam=mysql_fetch_array($sql_jam)){

$date = date_create($hariini." ".$rjam['jam']);
date_add($date, date_interval_create_from_date_string('+1 hours'));
$datef=date_format($date, 'H:i:s');

$sqlR="SELECT SUM(Rain) Hujan FROM ".$row_detdata['nama_lokasi']."
WHERE 1=1 AND ReceivedDate='".$hariini."' AND ML!='50' AND ReceivedTime>='".$rjam['jam']."' AND ReceivedTime<'".$datef."'";

						$sqlWL=mysql_query($sqlR);						
						$rWL=mysql_fetch_array($sqlWL);
						
$hjn=$rWL['Hujan'];
$tot=$tot+$hjn;
if($hjn==0) {$status="Cerah"; $sts="style='background-color:#FFF; color:#000; border:1px solid #003; font-size:12px;'";   } 
				  else if($hjn>=0.1 && $hjn<=1) { $status="Ringan"; $sts="style='background-color:#6F9;color:#000;  font-size:12px;border:1px solid #003;'";  } 
				  else if($hjn>1 && $hjn<=5) { $status="Ringan"; $sts="style='background-color:#00CC00;color:#000;  font-size:12px;border:1px solid #003;'";  } 
				  else if($hjn>5 && $hjn<=10) { $status="Sedang"; $sts="style='background-color:#FFFF00;color:#000; border:1px solid #003; font-size:12px;'";} 
				  else if($hjn>10  && $hjn<=20) { $status="Lebat"; $sts="style='background-color:#F90; color:#000; border:1px solid #003; font-size:12px;'";}
				  else if($hjn>20) { $status="Lebat"; $sts="style='background-color:red; color:#000; border:1px solid #003; font-size:12px;'";}
						?>
                        <td <?php echo $sts;?> align="center">
						<?php echo number_format($rWL['Hujan'],1); ?>
						</td>
					<?php
					}
                    ?>
                    <td style="background:#FC0; color:#000; font-size:12px;" align="center"><?php echo $tot;?></td>
              </tr>

              </tbody>
              <?php
              }
              ?> 	
            </table>
</div></div>