<?php
//include "config/conn.php";
/*$sqljml="SELECT * FROM m_lokasi WHERE 1=1 AND id_tipe='PDA' AND id_bbws=".$_SESSION['id_bbws']." AND status_lokasi=1
		UNION
		SELECT * FROM m_lokasi WHERE 1=1 AND nama_lokasi IN ('Sawangan','PasarBaru','Manggarai') AND id_bbws=".$_SESSION['id_bbws']." AND status_lokasi=1 ORDER BY urutan_sungai ASC ";
$queryjml = mysql_query($sqljml);
$jml=mysql_num_rows($queryjml);
*/
?>
<form class="quick_search">
	<input type="text" value="Quick Search" onFocus="if(!this._haschanged){this.value=''};this._haschanged=true;">
</form>
		<h3>Data Lokasi (<?php echo $jml;?> Pos)</h3>
		<ul class="togEgle">
<?php
$sql="SELECT * FROM m_lokasi WHERE 1=1 AND id_tipe='PDA' AND id_bbws=".$_SESSION['id_bbws']." AND status_lokasi=1
		UNION
		SELECT * FROM m_lokasi WHERE 1=1 AND nama_lokasi IN ('Sawangan','PasarBaru','Manggarai') AND id_bbws=".$_SESSION['id_bbws']." AND status_lokasi=1 ORDER BY urutan_sungai ASC ";
        $query = mysql_query($sql);
			  $i=0;
//			  date_default_timezone_set('Asia/Jakarta');
//			  $tanggal= mktime(0,0,0,date('m'),date('d'),date('Y'));
//			  $hariini = date("Y-m-d", $tanggal);
			  //$hariini=date('Y-m-d');
              while ($row_detdata=mysql_fetch_array($query)){
              $i++;
//$sql1="SELECT ReceivedDate AS SamplingDate,ReceivedTime AS SamplingTime,WLevel, FORMAT(WLevel*100,0) AS klWLevel FROM ".$row_detdata['nama_lokasi']." WHERE 1=1 AND WLevel!=0 GROUP BY SamplingDate, SamplingTime ORDER BY SamplingDate DESC,SamplingTime DESC LIMIT 1";
//$query1=mysql_query($sql1);
//$row_detdata1=mysql_fetch_array($query1);
			  //echo $row_detdata['SamplingDate']."<br>";
			  //echo $row_detdata['WLevel']."<br>";
			  //echo $row_detdata['siaga4']."<br>";
			  //echo $row_detdata['siaga3'];
/*			  if($row_detdata['id_merk']=="RADIO") { $nilai=$row_detdata1['klWLevel']; } else {
						$nilai=number_format(str_replace(',','',$row_detdata1['WLevel']),0); }
						
  	  		  if(($row_detdata1['SamplingDate']==$hariini) && $nilai>=$row_detdata['siaga4'] && $nilai<$row_detdata['siaga3']) { 
					$sts='<img src="images/icon_online.png">'; 
				} else if(($row_detdata1['SamplingDate']==$hariini) && $nilai>=$row_detdata['siaga3'] && $nilai<$row_detdata['siaga2']) { 
					$sts='<img src="images/icon_online.png">'; 
				} else if(($row_detdata1['SamplingDate']==$hariini) && $nilai>=$row_detdata['siaga2'] && $nilai<$row_detdata['siaga1']) { 
					$sts='<img src="images/icon_online.png">'; 
				} else if(($row_detdata1['SamplingDate']==$hariini) && $nilai>=$row_detdata['siaga1']) { 
				
					if($row_detdata['nama_lokasi']=="awlr_bkt_1" || $row_detdata['nama_lokasi']=="awlr_bkt2" || $row_detdata['nama_lokasi']=="awlr_bkt3" || $row_detdata['nama_lokasi']=="MTHaryono" || $row_detdata['nama_lokasi']=="BendungBekasi") {
						$sts='<img src="images/icon_online.png">'; 
					} else { 
						$sts='<img src="images/icon_online.png">'; 
					}			
			
			} else if(($row_detdata['SamplingDate']==$hariini) && $nilai<$row_detdata['siaga4']  && $_SESSION['id_bbws']==1) { 
					$sts='<img src="images/icon_online.png">'; 
				} else if(($row_detdata1['SamplingDate']==$hariini) && $nilai<$row_detdata['siaga4']) { 
					$sts='<img src="images/icon_online.png">'; 
				} else if(($row_detdata1['SamplingDate']==$hariini) && $nilai<0) { 
					$sts='<img src="images/icon_online.png">'; 
		} else if(($row_detdata1['SamplingDate']==$hariini) && $nilai>=0 && $nilai<=$row_detdata['siaga4']) { 
					$sts='<img src="images/icon_online.png">'; 
				} else if($row_detdata1['SamplingDate']!=$hariini) {
					$sts='<img src="images/icon_offline.png">';
				}			
*/
				if($row_detdata['icon']=="mati") { $sts='<img src="images/icon_offline.png">';} else { $sts= '<img src="images/icon_online.png">';	} 
?>
            <li><a href="home.php?page=datapos&pos=<?php echo $row_detdata['nama_lokasi']; ?>&tpos=<?php echo $row_detdata['id_tipe']; ?>">
			<strong><?php echo $sts." ".strtoupper($row_detdata['nama_alat']);?> - <?php echo substr($row_detdata['id_merk'],0,1); ?></strong></a></li>
			<?php } ?>		
</ul>
		<!--h3>Admin</h3>
		<ul class="toggle">
			<li class="icn_settings"><a href="#">Options</a></li>
			<li class="icn_security"><a href="#">Security</a></li>
			<li class="icn_jump_back"><a href="#">Logout</a></li>
		</ul-->
		
		<!--footer>
			<hr />
			<p><strong>Copyright &copy; 2016 Bws Kaltim III</strong></p>
			<p>Theme by <a href="http://www.sdatelemetry.com">Konsultan</a></p>
		</footer-->
