<?php
include "config/conn.php";
if($_POST['cari']=="Cari") {
$hariini=$_POST['tgl'];
} else { 
$hariini=date('Y-m-d');
//	$tgls = date('Y-m-d',strtotime('-1 day',strtotime($tglf))) ;
}


?>
        <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>
<div class="pages">
  <div data-page="features" class="page no-toolbar no-navbar">
    <div class="page-content">
    
	<div class="navbarpages navbarpagesbg">
                            <div class="navbar_left">
                                <div class="logo_text"><a href="index.html"><em></em></a></div>
                            </div>
			    					<div class="navbar_right navbar_right_menu">
					<a href="#" data-panel="left" class="open-panel"><img src="images/icons/white/menu.png" alt="" title="" /></a>
					</div>			
					<div class="navbar_right">
					<a href="#" data-panel="right" class="open-panel"><img src="images/icons/white/phone.png" alt="" title="" /></a>
					</div>
					<!--div class="navbar_right">
					<a href="cart.html" data-view=".view-main"><img src="images/icons/white/cart.png" alt="" title="" /><span>3</span></a>
					</div-->
			
	</div>
     
     
<div id="pages_maincontent">
<!-- AWAL HALAMAN -->
<h2 class="page_title">
DATA MANUAL MUKA AIR TANGGAL : <form method="post" action=""><input type="text" id="tgl" name="tgl" value="<?php echo $hariini;?>" style="width:13%;" /><input type="submit" name="cari" id="cari" value="Cari" /></form>
<!--?PHP echo date('d-m-Y',strtotime($hariini));?--></h2>
 <table width="100%" style="border:0px solid #003;">
                           <thead>
                                <tr>
                                    <!--th style="border:1px solid #003;" rowspan="2">#</th-->
                                    <th style="border:1px solid #003;" rowspan="2" align="center" valign="middle">NAMA POS</th>
                                    <th align="center" rowspan="2" style="border:1px solid #003;" >TANGGAL</th>
                                    <th colspan="3" align="center"style="border:1px solid #003;" >JAM PENCATATAN</th>
                                    <th align="center" style="border:1px solid #003;" rowspan="2" >STATUS<br />LAPORAN</th>
                                </tr>
                            </thead>
                           <thead>
                                <tr>
                                    <th align="center" style="border:1px solid #003;"></th>
                                    <th align="center" style="border:1px solid #003;"></th>
                                    <th align="center" style="border:1px solid #003;">07:00</th>
                                    <th align="center" style="border:1px solid #003;"> 12:00</th>
                                    <th align="center" style="border:1px solid #003;"> 17:00</th>
                                    <th align="center" style="border:1px solid #003;"></th>
                                 </tr>
                            </thead>
							<?php
							$tglkemaren = date('Y-m-d', strtotime('-1 days', strtotime($hariini)));
$sqllocation=mysql_query("SELECT * FROM m_lokasi WHERE 1=1 AND id_bbws=".$_SESSION['id_bbws']." AND status_lokasi=1 AND id_tipe='PDA' ORDER BY id_tipe DESC");
$i=0;

							while($rowlocation=mysql_fetch_array($sqllocation)){
							$i++;
				$select_data7=mysql_query("select DISTINCT * from ".$rowlocation['nama_lokasi']." WHERE ReceivedDate='".$hariini."' AND ML='50' AND ReceivedTime='07:00:00' LIMIT 1"); 				$rowdata7=mysql_fetch_array($select_data7);
							
				$select_data12=mysql_query("select DISTINCT * from ".$rowlocation['nama_lokasi']." WHERE ReceivedDate='".$hariini."' AND ML='50' AND ReceivedTime='12:00:00'  LIMIT 1");
							$rowdata12=mysql_fetch_array($select_data12);
							
				$select_data17=mysql_query("select DISTINCT * from ".$rowlocation['nama_lokasi']." WHERE ReceivedDate='".$hariini."' AND ML='50' AND ReceivedTime='17:00:00'  LIMIT 1");
							$rowdata17=mysql_fetch_array($select_data17);
							
							$jml7=mysql_num_rows($select_data7);
							$jml12=mysql_num_rows($select_data12);
							$jml17=mysql_num_rows($select_data17);
							
							if($jml7!=0 && $jml12==0 && $jml17==0){ $sts="SUDAH"; $color='style="background-color:#09F; color:#FFF;"'; } 
							else if($jml7!=0 && $jml12!=0  && $jml17==0){ $sts="SUDAH"; $color='style="background-color:#FF0; color:#FFF;"'; } 
							else if($jml7!=0 && $jml12!=0 && $jml17!=0){ $sts="LENGKAP"; $color='style="background-color:#0C0; color:#FFF;"'; } 
							else 
								{ $color='style="background-color:#F00; color:#FFF;"'; $sts="BELUM"; }
							if($jml7!=0 || $jml12!=0 || $jml17!=0){	
								$tgl=date('d/m/y',strtotime($rowdata7['ReceivedDate']));
							} else { $tgl="-";}
							?>
                            <tr <?php echo $color;?>>
                               	<!--td style="border:1px solid #003;"><?php echo $i; ?></td-->
                   	<td style="border:1px solid #003; padding-left:4px;"><a href="manualformma.php" style="color:#FFF;"><?php echo $rowlocation['nama_alat'];?></a></td>
                               	<td align="center" style="border:1px solid #003; color:#000;"><?php echo $tgl;?></td>
                               <td align="center" style="border:1px solid #003; color:#000; background-color:#09F;"><?php echo number_format($rowdata7['WLevel'],0);?></td>
                              <td align="center" style="border:1px solid #003; color:#000; background-color:#FF0;"><?php echo number_format($rowdata12['WLevel'],0);?></td>                              <td align="center" style="border:1px solid #003; color:#000; background-color:#0C0;"><?php echo number_format($rowdata17['WLevel'],0);?></td>
                               	<td align="center" style="border:1px solid #003; color:#000;"><?php echo $sts;?></td>
                             </tr>
                            <?php }?>
                        </table>  
<!-- AKHIR HALAMAN--->
</div>
</div>
</div>
</div>