<?php
include 'header.php';
include 'erpc_mapas_toolbar.php';
include 'connect.php';

$id_crip = $_GET['id'];
$id = base64_decode($id_crip);

?>

<script src="mapas/mapa.js"></script>
<script src="https://maps.googleapis.com/maps/api/js?key=AIzaSyDspbqBpIJXa-JUeVbSO1MgeWrox0viP8k&sensor=true"></script>
 <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
<!-- Tab panes -->
<div class="tab-content">
  <div role="tabpanel" class="tab-pane fade in active" id="form1">
  <form id=validate_custom method=POST action="erpc_categorias_produtos_ws.php" enctype="multipart/form-data">
  <input type="hidden" value="<?php echo $id; ?>" name="id" id="id">

  <div class=block>
    <div class=header>
      <h2>Editar Mapa</h2>
    </div>
  
    <div class="content controls">
	<?php
		$consulta = "select * from erpc_mapas where id = '$id'";

		$resultado = mysqli_query($conexao, $consulta) or die ($erro = mysqli_error($conexao));
		if (mysqli_num_rows($resultado)>0) {
		while ($registro = mysqli_fetch_assoc($resultado)){
      
			$ds_mapa	= $registro['ds_mapa'];
            $ds_url_mapa	= $registro['ds_url_mapa'];
            $st_ativo	= $registro['st_ativo'];
			}
		}
	//	$caminho_mapa = 'http://' . $_SERVER['HTTP_HOST'] . '/mapas/kml/areas_sp.kml';
		$caminho_mapa = 'http://' . $_SERVER['HTTP_HOST'] . $ds_url_mapa;
	?>
  <input type="hidden" name="id" value="<?php echo $id; ?>" />
  	  <div class=form-row>
          <div class=col-md-3>Nome Mapa:</div>
          <div class=col-md-6><input type=text name="$ds_mapa" class="form-control" value="<?php echo $ds_mapa; ?>" maxlength=50 class="validate[required]"/> </div>
        </div>
        
        <div class=form-row>
          <div class=col-md-3>Arquivo:</div>
          <div class=col-md-6>
          
              <?php
              if (!empty($ds_url_mapa)) {
                ?>
		<script>
            $(document).ready(function() {
                initialize(<?php echo "'$caminho_mapa'" ?>);
            });
		</script>
		<div id="mapa" style="height: 200px; width: 300px;">
        </div>
                <?php
              }
              ?>
          </div>
        </div>
        
        
         <div class=form-row>
        <div class=col-md-3>Ativar/Desativar Mapa:</div>
          <div class="col-md-2">
          <select name="st_ativo" id="st_ativo" required class="form-control">
            <?php              
            if($st_ativo == 1){
                   $ativo = "selected" ;
                   $inativo = "";
            }else{
                $ativo = "" ;
                $inativo = "selected";
            }
            
            ?>
            <option value ="1" <?php echo $ativo; ?> />Ativar</option>
            <option value ="0" <?php echo $inativo; ?> />Desativar</option>
          </select>
        </div>
        </div>
        
        
    </div>
    <div class=footer>
      <div class="side pull-right">
        <div class=btn-group>
		<button class="btn btn-default" type="button" onClick="window.history.go(-1)" value="Voltar">Voltar</button>
        <button class="btn btn-success" type="submit" value="editar" onClick="$('#validate_custom').validationEngine('hide');" name="editar">EDITAR</button>

		</div>
      </div>
    </div>
  </div>
</form>

  </div>

</div>

<?php include 'footer.php';?>
