<?php
include 'header.php';
include 'erpc_clientes_toolbar.php';
require_once 'inc/clientes.php';
require_once 'inc/usuario.php';

checkLogin('login.php');

$clientes = clientes_create();

$id = 0;
$id_crip = 0;

// captura o ID atravez do GET
if(isset($_GET['id'])){
  $id_crip=$_GET['id'];
  $id = base64_decode($id_crip);
  $clientes = clientes_getById($id);
}

?>

<form id=validate_custom method="post" action="erpc_clientes_ws.php">
  <div class="block">
    <div class="header">
      <h2>Cliente - Editar</h2>
    </div>
    <div class="block">
      <div class="content">
        <?php
        displayMessagesAndErrors(true);
        ?>
      </div>
    </div>
  </div>

  <ul class="nav nav-tabs" role="tablist">
    <li role="presentation" class="active"><a href="#form1" aria-controls="form1" role="tab" data-toggle="tab">Cadastro</a></li>
    <li role="presentation"><a href="#form2" aria-controls="form2" role="tab" data-toggle="tab">Impostos</a></li>
    <li role="presentation"><a href="#form3" aria-controls="form3" role="tab" data-toggle="tab">Comercial</a></li>
    <li role="presentation"><a href="#form4" aria-controls="form4" role="tab" data-toggle="tab">Miscelanea</a></li>
    <li role="presentation"><a href="#form5" aria-controls="form5" role="tab" data-toggle="tab">Atendimentos</a></li>
  </ul>

  <!-- Tab panes -->
  <div class="tab-content">
    <div role="tabpanel" class="tab-pane fade in active" id="form1">
      <? include_once "erpc_clientes_cadastro.php";?>
    </div> <!-- tab-pane -->

    <div role="tabpanel" class="tab-pane fade in" id="form2">
      <? include_once "erpc_clientes_imposto.php";?>
    </div> <!-- tab-pane -->

    <div role="tabpanel" class="tab-pane fade in" id="form3">
      <? include_once "erpc_clientes_comercial.php"; ?>
    </div> <!-- tab-pane -->
    
    <div role="tabpanel" class="tab-pane fade in" id="form4">
      <? include_once "erpc_clientes_miscelanea.php"; ?>
    </div> <!-- tab-pane -->
    
    <div role="tabpanel" class="tab-pane fade in" id="form5">
      <? include_once "erpc_clientes_atendimentos.php"; ?>
    </div> <!-- tab-pane -->
    
  </div> <!-- tab-content -->

  <div class="block">
    <div class="content controls">
      <div class="form-row">
        <div class="col-md-12 text-right">
          <button name="btn-edit"   id="btn-edit"   class="btn btn-primary btn-cleanx" type="submit" onClick="$('#validate_custom').validationEngine('hide');">Editar</button>
          <button name="btn-voltar" id="btn-voltar" class="btn btn-default btn-cleanx" type="button" onClick="window.history.go(-1)">Voltar</button>
        </div>
      </div>
    </div>
  </div>
</form>

<script type='text/javascript' src='js\jquery-3.1.1.min.js' ></script>
<script type='text/javascript' src='js\busca_CEP.js' ></script>
<script type='text/javascript' src='js\validar_form.js' ></script>

<?php include 'inc/helper_modal_div.php'; ?>
<?php include 'footer.php';?>

<script type="text/javascript" >

    //$("#clientes[ds_ie]").keyup(function(){
    $("[name='clientes[ds_ie]']").keyup(function(){
    	$(this).val($(this).val().replace(".", ""));
    });
    $("[name='clientes[ds_ie]']").blur(function(){
    	$(this).val($(this).val().replace(".", ""));
    });
   
    
</script>
<script type="text/javascript" src="js/caracteres.js"></script>
<script type="text/javascript" src="js/verifica_cnpj_cpf.js"></script>
<script type="text/javascript" src="js/busca_CEP.js"></script>