<script type="text/javascript" src="js/jquery.js"></script>

<script type="text/javascript">

var htmlobjek;

$(document).ready(function(){

  //apabila terjadi event onchange terhadap object <select id=propinsi>

  $("#iareat").change(function(){

    var iareat = $("#iareat").val();

    	$.ajax({

        	url: "data/masterarea.php",

        	data: "iareat="+iareat,

        	cache: false,

        	success: function(msg){$("#ibbws").html(msg);}

    	});

	});

});



$(document).ready(function(){

  //apabila terjadi event onchange terhadap object <select id=propinsi>

  $("#iareat").change(function(){

    var iareat = $("#iareat").val();

    	$.ajax({

        	url: "data/masterspv.php",

        	data: "iareat="+iareat,

        	cache: false,

        	success: function(msg){$("#ispv").html(msg);}

    	});

	});

});



$(document).ready(function(){

  //apabila terjadi event onchange terhadap object <select id=propinsi>

  $("#iareat").change(function(){

    var iareat = $("#iareat").val();

    	$.ajax({

        	url: "data/masterdas.php",

        	data: "iareat="+iareat,

        	cache: false,

        	success: function(msg){$("#das").html(msg);}

    	});

	});

});



$(document).ready(function(){

  //apabila terjadi event onchange terhadap object <select id=propinsi>

  $("#ispv").change(function(){

    var ispv = $("#ispv").val();

    $.ajax({

        url: "data/mastersales.php",

        data: "ispv="+ispv,

        cache: false,

        success: function(msg){

            //jika data sukses diambil dari server kita tampilkan

            //di <select id=kota>

            $("#isales").html(msg);

        }

    });

	});

});



</script>

<?php

//session_start();

include "../config/conn.php";

//if($_GET['v']=="cu"){

  $sql_bbws="SELECT * FROM m_bbws";

  $query_bbws=mysql_query($sql_bbws);



  $sql_prov="SELECT * FROM m_provinsi";

  $query_prov=mysql_query($sql_prov);



  $sql_merk="SELECT * FROM m_merk";

  $query_merk=mysql_query($sql_merk);



  $sql_kota="SELECT * FROM m_kota";

  $query_kota=mysql_query($sql_kota);



  $sql_das="SELECT * FROM m_das WHERE 1=1 ";

  if($_SESSION['id_level']==2 || $_SESSION['id_level']==3){

    $sql_das.=" AND id_bbws='".$_SESSION['id_bbws']."'";

  }

  $query_das=mysql_query($sql_das);

  

  if($_GET['lokasiid']!="undefined") { 

  	$sql_lokasi="SELECT * FROM m_lokasi WHERE id_lokasi='".$_GET['lokasiid']."'";	

  	$query_lokasi=mysql_query($sql_lokasi);

	$redit_detail=mysql_fetch_array($query_lokasi);

  }

//}

?>

<form id="upload_form" enctype="multipart/form-data" method="post">

<input type="hidden" id="idlokasi" name="idlokasi" value="<?php echo $redit_detail['id_lokasi'];?>" />

<!--strong><em>Form Input Lokasi</em></strong-->

<div class="row">

<div class="col-xs-4">

<table width="100%" border="0" cellpadding="3" cellspacing="3">

  <tr>

    <td width="13%" valign="top"><strong>Kode Pos</strong></td>

    <td width="40%" valign="top">:

      <input type="text" id="kode_lokasi" name="kode_lokasi" value="<?php echo $redit_detail['kode_lokasi'];?>" /></td>

    <td width="10%" valign="top">&nbsp;</td>

    <td width="11%" valign="top"><strong>Provinsi</strong></td>

    <td width="26%" valign="top">:

      <select id="iprov" name="iprov">

        <option value="">-Pilih -</option>

        <?php 

      while($rp=mysql_fetch_array($query_prov)){

      ?>

        <option value="<?php echo $rp['id_provinsi']; ?>"

        <?php if ($redit_detail['id_provinsi']==$rp['id_provinsi']) { echo 'selected="selected"';} ?>> <?php echo $rp['nama_provinsi']; ?> </option>

        <?php } ?>

      </select></td>

  </tr>

  <tr>

    <td valign="top"><strong>Nama Device</strong></td>

    <td valign="top">:

      <input type="text" id="nama_alat" name="nama_alat" value="<?php echo $redit_detail['nama_alat'];?>" style="width:88%;" /></td>

    <td valign="top">&nbsp;</td>

    <td valign="top"><strong>Kota</strong></td>

    <td valign="top">:

      <select id="ikota" name="ikota">

        <option value="">-Pilih-</option>

        <?php 

      while($rk=mysql_fetch_array($query_kota)){

      ?>

        <option value="<?php echo $rk['id_kota']; ?>"

        <?php if ($redit_detail['id_kota']==$rk['id_kota']) { echo 'selected="selected"';} ?>> <?php echo $rk['nama_kota']; ?> </option>

        <?php } ?>

      </select></td>

  </tr>

  <tr>

    <td valign="top"><strong>Nama Pos</strong></td>

    <td valign="top">:

      <?php if($redit_detail['nama_lokasi']!="") { echo $redit_detail['nama_lokasi']; } else { ?>

      <input type="text" id="nama_lokasi" name="nama_lokasi" value="<?php echo $redit_detail['nama_lokasi'];?>" style="width:88%;" />

      <?php } ?></td>

    <td valign="top">&nbsp;</td>

    <td valign="top"><strong>Kec / Desa </strong></td>

    <td valign="top">:

      <textarea name="kd" cols="30" id="kd"><?php echo $redit_detail['lokasi_alamat'];?></textarea></td>

  </tr>

  <tr>

    <td valign="top"><strong>BBWS</strong></td>

    <td valign="top">:

      <?php if ($_SESSION['id_level']=="2" || $_SESSION['id_level']=="3") { echo $_SESSION['nama_bbws'];

?>

      <input type="hidden" id="ibbws" value="<?php echo $_SESSION['id_bbws']?>" />

      <?php

 } else { ?>

      <select id="ibbws" name="ibbws">

        <option value="">-Pilih BBWS-</option>

        <?php 

	while($rt=mysql_fetch_array($query_bbws)){

	?>

        <option value="<?php echo $rt['id_bbws']; ?>" <?php if ($redit_detail['id_bbws']==$rt['id_bbws']) { echo 'selected="selected"';} ?>> <?php echo $rt['nama_bbws']; ?> </option>

        <?php } ?>

      </select>

      <?php } ?></td>

    <td valign="top">&nbsp;</td>

    <td valign="top"><strong>Type Pos </strong></td>

    <td valign="top">:

      <select id="itype" name="itype">

        <option value="">-Pilih-</option>

        <option value="PDA" <?php if($redit_detail['id_tipe']=="PDA") {echo 'selected="selected"';}?>>PDA</option>

        <option value="PCH" <?php if($redit_detail['id_tipe']=="PCH") {echo 'selected="selected"';}?>>PCH</option>

      </select></td>

  </tr>

  <tr>

    <td valign="top"><strong>Sungai</strong></td>

    <td valign="top">:

      <select id="idas" name="idas">

        <option value="">-Pilih-</option>

        <?php while($rd=mysql_fetch_array($query_das)){?>

        <option value="<?php echo $rd['id_das']; ?>"

                                        <?php if ($redit_detail['id_das']==$rd['id_das']) { echo 'selected="selected"';} ?>> <?php echo $rd['nama_das']; ?> </option>

        <?php } ?>

      </select></td>

    <td valign="top">&nbsp;</td>

    <td valign="top"><strong>Merk</strong></td>

    <td valign="top">:

      <select id="imerk" name="imerk">

        <option value="">-Pilih</option>

        <?php 

		while($rm=mysql_fetch_array($query_merk)){

		?>

        <option value="<?php echo $rm['code_merk']; ?>"

			<?php if ($redit_detail['id_merk']==$rm['code_merk']) { echo 'selected="selected"';} ?>> <?php echo $rm['code_merk']; ?></option>

        <?php } ?>

      </select></td>

  </tr>

  <tr>

    <td valign="top"><strong>Luas DAS</strong></td>

    <td valign="top">:

      <input type="text" id="ildas" name="ildas" value="<?php echo $redit_detail['ws'];?>" size="5" />

Km&sup2;</td>

    <td valign="top">&nbsp;</td>

    <td valign="top"><strong>Latitude</strong></td>

    <td valign="top">:

      <input type="text" id="lat" name="lat" size="15" value="<?php echo $redit_detail['lat'];?>" /></td>

  </tr>

  <tr>

    <td valign="top"><strong>No. Telepon</strong></td>

    <td valign="top">:

      <input type="text" id="tlp" name="tlp" value="<?php echo $redit_detail['no_hp'];?>" /></td>

    <td valign="top">&nbsp;</td>

    <td valign="top"><strong>Longtitude</strong></td>

    <td valign="top">:

      <input type="text" id="lng" name="lng" size="15" value="<?php echo $redit_detail['lng'];?>" />

      &nbsp;</td>

  </tr>

  <tr>

    <td valign="top"><strong>Tahun Bangun</strong></td>

    <td valign="top">:

      <input type="text" size="5" id="thn_bangun" name="thn_bangun" value="<?php echo $redit_detail['tahun_bangun'];?>" /></td>

    <td valign="top">&nbsp;</td>

    <td valign="top"><strong>Pengamat</strong></td>

    <td valign="top">:

      <input type="text" id="pengamat" name="pengamat" value="<?php echo $redit_detail['nama_pengamat'];?>" /></td>

  </tr>

  <tr>

    <td colspan="5" valign="top">&nbsp;</td>

    </tr>

  <tr>

    <td valign="top"><strong>Siaga</strong></td>

    <td valign="top">: I - 

      <input type="text" id="siaga1" name="siaga1" value="<?php echo $redit_detail['siaga1'];?>" size="5" />

      , II - 

      <input type="text" id="siaga2" name="siaga2" value="<?php echo $redit_detail['siaga2'];?>" size="5" />

      , III - 

      <input type="text" id="siaga3" name="siaga3" value="<?php echo $redit_detail['siaga3'];?>" size="5" />

      , IV - 

      <input type="text" id="siaga4" name="siaga4" value="<?php echo $redit_detail['siaga4'];?>" size="5" /></td>

    <td valign="top">&nbsp;</td>

    <td valign="top">Kalibrasi </td>

    <td valign="top">: <input type="text" id="kalibrasi" name="kalibrasi" value="<?php echo $redit_detail['kalibrasi'];?>" /></td>
    <td valign="top">Status Lokasi </td>
    <td valign="top">: <input type="text" id="statuslokasi" name="statuslokasi" value="<?php echo $redit_detail['status_lokasi'];?>" /></td>

  </tr>

  <tr>

    <td valign="top"><strong>Foto Pos</strong></td>

    <td valign="top">:
      <input type="file" name="filependukung" id="filependukung" value="" /></td>

    <td valign="top">&nbsp;</td>

    <td valign="top">&nbsp;</td>

    <td align="right" valign="top">&nbsp;</td>

  </tr>

  <tr>

    <td valign="top">&nbsp;</td>

    <td valign="top">&nbsp;</td>

    <td valign="top">&nbsp;</td>

    <td valign="top">&nbsp;</td>

    <td align="right" valign="top"><button type="button" data-dismiss="modal" class="refresh" onClick="rload()">Tutup</button>

      <input type="submit" id="simpan" name="simpan" class="simpan" value="Simpan" />

      </td>

  </tr>

</table>

<br />

</div>

</div>

<br />

<div class="modal-footer" align="right"></div>

</form>



<script type="text/javascript">

                                  function detailMaps(id){

                                    dataview = window.open("../ajax/view/detMaps.php?type=view&id=" + id, "dataview", "toolbar=no,menubar=no,scrollbars=no,width=600,height=400");                                    

                                  }

                                </script>

