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


$id_crip = $_GET['id']; //Estocando o ID criptografado
$id = (int)base64_decode($id_crip); //decodificando o ID

?>

<!-- Nav tabs -->
<ul class="nav nav-tabs" role="tablist">
  <li role="presentation" class="active"><a href="#form1" aria-controls="form1" role="tab" data-toggle="tab">Dados Cadastrais</a></li>
  <!--
  <li role="presentation"><a href="#form2" aria-controls="form2" role="tab" data-toggle="tab">Form #2</a></li>
  <li role="presentation"><a href="#form3" aria-controls="form3" role="tab" data-toggle="tab">Form #3</a></li>
  <li role="presentation"><a href="#form4" aria-controls="form4" role="tab" data-toggle="tab">Form #4</a></li>
  -->
</ul>


<!-- 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_financeiro_plano_contas_ws.php">
  <div class=block>
    <div class=header>
      <h2>Incluir Plano de Contas Financeiro</h2>
      <div class="side pull-right"> <button class="btn btn-default btn-clean" onClick="clear_form('#validate_custom');" type=button>Clear form</button>          </div>
    </div>
    <?php
          $consulta = "select * from erpc_financeiro_plano_contas where id = $id";
          $sql = mysqli_query($conexao, $consulta) or die(mysqli_error($conexao));
          $resultado = mysqli_fetch_assoc ($sql);

          $id_exibe                 = $resultado['id'];
          $ds_codigo                = $resultado['ds_codigo'];
          $ds_plano                 = $resultado['ds_plano'];
          $id_classe_selecionada    = $resultado['id_classe'];
          $id_condicao_selecionada  = $resultado['id_condicao'];
          $st_bloqueado_selecionado = $resultado['st_bloqueado'];

          
          //Identificando o marcador checked
           $st_bloqueado_checked = ($st_bloqueado_selecionado == 1 ? 'checked' : '');  


        ?>
        
    <div class="content controls">
        
      <div class=form-row>
        <div class=col-md-3>ID:</div>
        <div class=col-md-9> <input type=text name="id_exibe" value=<?php echo $id_exibe ?> class="form-control" disabled/> </div>
        <input type=hidden name=id value=<?php echo $id_exibe ?>>
      </div>
      <div class=form-row>
        <div class=col-md-3>Codigo:</div>
        <div class=col-md-9> <input type=text name="ds_codigo" value=<?php echo $ds_codigo ?> class="form-control" /> </div>
      </div>
     <div class=form-row>
        <div class=col-md-3>Descrição do Plano:</div>
        <div class=col-md-9> <input type=text name="ds_plano" value=<?php echo $ds_plano ?> class="form-control" /> </div>
      </div>
    <!-- Elementos -->
      <!-- Inicio Select Classes -->
    <div class=form-row>
        <div class=col-md-3>Classe:</div>
        <div class=col-md-9> 
      
      <select name = id_classe class="form-control"> 
        <?php
            $consulta = "select * 
                           from erpc_financeiro_plano_classe
                          where st_ativo = 1 
                       order by id ";
            //echo $consulta;
            $resultado = mysqli_query($conexao, $consulta) or die ($erro = mysqli_error($conexao));
              if (mysqli_num_rows($resultado)>0) {
                  while ($registro = mysqli_fetch_assoc($resultado)){


                    $id_classe      = $registro['id'];
                    $id_classe_crip = base64_encode($id_classe);
                    $ds_classe      = $registro['ds_classe'];
                  
                     //Identificando o selecionado
                    $selected = ($id_classe_selecionada == $id_classe ? 'selected="selected"' : '');  
                    
                  echo "<option value=$id_classe_crip $selected >$ds_classe</option> ";
                  }
              }     
        ?>    
      </select>
    </div>
    </div>  
      <!-- Fim Select Classes -->     
      <!-- Inicio Select Condicao -->
        <div class=form-row>
        <div class=col-md-3>Condicao:</div>
        <div class=col-md-9> 
          <select name = id_condicao class="form-control"> 
            <?php
                $consulta = "select * 
                               from erpc_financeiro_plano_condicao
                              where st_ativo = 1 
                              order by id ";
                //echo $consulta;
                $resultado = mysqli_query($conexao, $consulta) or die ($erro = mysqli_error($conexao));
                  if (mysqli_num_rows($resultado)>0) {
                    while ($registro = mysqli_fetch_assoc($resultado)){

                      $id_condicao       = $registro['id'];
                      $id_condicao_crip  = base64_encode($id_condicao);
                      $ds_condicao       = $registro['ds_condicao'];

                      //Identificando o selecionado
                      $selected = ($id_condicao_selecionada == $id_condicao ? 'selected="selected"' : '');  
                      
                    echo "<option value = $id_condicao_crip $selected> $ds_condicao </option> ";
                    }
                }     
            ?>    
          </select>
    </div>
    </div>  

      <!-- Fim Select Condicao -->

      <!--Inicio Bloqueado-->   
      <div class=form-row>
        <div class=col-md-3>Situação:</div>
        <div class=col-md-9>
          <?php 
            echo "<div class=checkbox-inline> <label> <input type=checkbox class='form-control' name=st_bloqueado value='$st_bloqueado_selecionado' $st_bloqueado_checked /> Bloqueado </label>";
          ?>
          </div>
          <!--<div class=checkbox-inline> <label> <input name=vcheck value=0 type=checkbox disabled=disabled class="validate[required]"/> Disabled </label>              </div>-->
        </div>
      </div>
      <!-- Fim Bloqueado -->


      <!--<div class=form-row>
        <div class=col-md-3>Radio:</div>
        <div class=col-md-9>
          <div class=checkbox-inline> <label> <input type=radio class=validate[required] name=vradio value="1"/> Enabled </label> </div>
          <div class=checkbox-inline> <label> <input type=radio disabled=disabled class=validate[required] name=vradio value="0"/> Disabled </label>              </div>
        </div>
      </div>
      <div class=form-row>
        <div class=col-md-3>Datepicker:</div>
        <div class=col-md-9> <input type=text class="validate[required] datepicker form-control" /> <span class=help-block>Required</span> </div>
      </div>
      <div class=form-row>
        <div class=col-md-3>Group required:</div>
        <div class=col-md-9> <input class="validate[groupRequired[payments]] form-control" type=text name=credit id=credit /> <span class=help-block>Any of group fields must be filled</span>            </div>
      </div>
      <div class=form-row>
        <div class=col-md-3></div>
        <div class=col-md-9> <input class="validate[groupRequired[payments]] form-control" type=text name=paypal id=paypal /> <span class=help-block>Any of group fields must be filled</span>            </div>
      </div>
      <div class=form-row>
        <div class=col-md-3>Condition required:</div>
        <div class=col-md-9> <input type=text name=creditcard id=creditcard placeholder="Credit card" class="form-control" /> </div>
      </div>
      <div class=form-row>
        <div class=col-md-3></div>
        <div class=col-md-9> <input class="validate[condRequired[creditcard]] form-control" type=text id=ccv name=ccv placeholder="CCV" />
          <span
            class=help-block>This field is required if "Credit card" field is filled</span>
        </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="excluir" onClick="$('#validate_custom').validationEngine('hide');" name="excluir">Confirma a Exclusao</button>
			  <!--botao antigo
		<button class="btn btn-default" type=button onClick="$('#validate_custom').validationEngine('hide');">Hide prompts</button>            <button class="btn btn-success" type=submit>Submit</button> 
		-->
		</div>
      </div>
    </div>
  </div>
</form>

  </div>
  
</div>


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