<?php
include 'header.php';
include 'erpc_condicao_pagamento_toolbar.php';
include_once 'connect.php';

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

  $consulta = "select * from erpc_condicao_pagamento where id = '$id' and st_ativo =1";

  $resultado = mysqli_query($conexao, $consulta) or die ($erro = mysqli_error($conexao));
  if (mysqli_num_rows($resultado)>0) {
  while ($registro = mysqli_fetch_assoc($resultado)){

    $ds_condicao = $registro['ds_condicao'];
    $id_tipo = $registro['id_tipo'];
    $nr_qtde_parcelas = $registro['nr_qtde_parcelas'];
    $nr_dia = $registro['nr_dia'];
    $ds_estrutura = $registro['ds_estrutura'];
    $fl_cheque = $registro['fl_cheque'];
    $id_icm_solidario = $registro['id_icm_solidario'];
    $id_ipi = $registro['id_ipi'];
    $vl_perc_juros_adicionais = $registro['vl_perc_juros_adicionais'];

    }
  }
?>

<!-- Nav tabs -->
<ul class="nav nav-tabs" role="tablist">
  <li role="presentation" class="active"><a id="mform1" href="#form1" aria-controls="form1" role="tab" data-toggle="tab">Cadastro</a></li>
  <li role="presentation"><a id="mform2" href="#form2" aria-controls="form2" role="tab" data-toggle="tab">Simulação</a></li>
</ul>

<form id=validate_custom method=POST action="erpc_condicao_pagamento_ws.php" >
  <input name="id" id="id" value="<?echo $id?>" hidden/>
<!-- Tab panes -->
<div class="tab-content">
  <div role="tabpanel" class="tab-pane fade in active" id="form1">
    <div class="block">
    <div class="content controls">

      <div class=form-row>
         <div class=col-md-2><label>Descrição do Tipo</label></div>
         <div class=col-md-6><input disabled value="<?echo $ds_condicao?>" name="ds_condicao" id="ds_condicao"></div>
      </div>

      <div class="form-row">
        <div class="col-md-2"><label>Tipo</label></div>
        <div class="col-md-2">
          <div class="input-group">
          <input disabled name="id_tipo" id="id_tipo" value="<?echo $id_tipo?>"/>
            <div class="input-group-addon">
                <a href="helper-dom-tipo-condicao_pagamento.php" class='input-helper' data-remote="false" data-toggle="modal" data-target="#helper-modal-div" data-value="#id_tipo" data-description="#ds_tipo" data-title="Selecione:">
                <span class="fa fa-search"></span></a>
            </div>
          </div>
        </div>
        <div class="col-md-4"><input disabled id="ds_tipo" readonly></div>
      </div>

      <div class=form-row>
         <div class=col-md-2><label>Quantidade de Parcelas</label></div>
         <div class=col-md-2><input disabled value="<?echo $nr_qtde_parcelas?>" type=number name="nr_qtde_parcelas" id="nr_qtde_parcelas" min="0" ></div>
      </div>

      <div class=form-row>
         <div class=col-md-2><label>Dia</label></div>
         <div class=col-md-2><input disabled value="<?echo $nr_dia?>" name="nr_dia" id="nr_dia" min="0" max="31" ></div>
      </div>

      <div class=form-row>
         <div class=col-md-2><label>Estrutura</label></div>
         <div class=col-md-2><input disabled value="<?echo $ds_estrutura?>" name="ds_estrutura" id="ds_estrutura"></div>
      </div>

      <div class="form-row">
        <div class="col-md-2"><label>Cheque</label></div>
        <div class="col-md-4">
          <select name="fl_cheque" id="fl_cheque" disabled >
            <option value="1" <?if($fl_cheque=="1"){echo "selected";}?>>Sim</option>
            <option value="0" <?if($fl_cheque=="0"){echo "selected";}?>>Não</option>
          </select>
        </div>
      </div>


      <div class="form-row">
        <div class="col-md-2"><label>ICMS Solid</label></div>
        <div class="col-md-4">
          <select name="id_icm_solidario" id="id_icm_solidario" disabled >
            <option value="1" <?if($id_icm_solidario=="0"){echo "selected";}?>>Normal</option>
            <option value="2" <?if($id_icm_solidario=="1"){echo "selected";}?>>Junto</option>
            <option value="3" <?if($id_icm_solidario=="2"){echo "selected";}?>>Separado</option>
          </select>
        </div>
      </div>

      <div class="form-row">
        <div class="col-md-2"><label>IPI Solid</label></div>
        <div class="col-md-4">
          <select name="id_ipi" id="id_ipi" disabled >
            <option value="1" <?if($id_ipi=="0"){echo "selected";}?>>Normal</option>
            <option value="2" <?if($id_ipi=="1"){echo "selected";}?>>Junto</option>
            <option value="3" <?if($id_ipi=="2"){echo "selected";}?>>Separado</option>
          </select>
        </div>
      </div>


      <div class=form-row>
         <div class=col-md-2><label>% Juros Adicionais</label></div>
         <div class=col-md-2><input disabled value="<?echo $vl_perc_juros_adicionais?>" name="vl_perc_juros_adicionais" id="vl_perc_juros_adicionais" min="0" step="0.01" ></div>
      </div>
    </div>
    </div>
  </div>


  <div role="tabpanel" class="tab-pane fade" id="form2">
    <div class="block">
      <div class="content controls">
        <div class="form-row">
          <div class="col-md-2"><label>Valor de Referencia</label></div>
          <div class="col-md-2"><input disabled type=number name="nr_valor_referencia" id="nr_valor_referencia" min=0 step="0.01"/></div>
        </div>

        <div class="form-row">
          <div class="col-md-2"><label>Data de Referencia</label></div>
          <div class="col-md-2"><input disabled name="dt_referencia" id="dt_referencia" class="datepicker"/></div>
        </div>

        <div class="form-row">
          <div class="col-md-2"><label>Valor de IPI</label></div>
          <div class="col-md-2"><input disabled type=number name="nr_valor_ipi" id="nr_valor_ipi" min=0 step="0.01"/></div>
        </div>

        <div class="form-row">
          <div class="col-md-2"><label>Valor de ICMS Solid</label></div>
          <div class="col-md-2"><input disabled type=number name="nr_valor_icms" id="nr_valor_icms" min=0 step="0.01"/></div>
        </div>

        <div class="form-row">
          <div class="col-md-2">
            <button type="button" disabled name="btn-simular" id="btn-simular"/></button>
          </div>
        </div>

        <div class="form-row">
          <div class="col-md-2"><label>Resultado</label></div>
          <div class="col-md-4"><input name="tx_resultado" id="tx_resultado" readonly/></div>
        </div>
      </div>
    </div>
  </div>

  <!-- Botão submit -->
  <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-warning" type="submit" value="excluir" onClick="$('#validate_custom').validationEngine('hide');" name="excluir">Confirma a exclusão?</button>
        </div>
      </div>
    </div>

</div>
</form>

<?php include 'footer.php'; ?>
<script type="text/javascript" src="js/acme.js"></script>
