<?php
include 'header.php';
include 'erpc_pedidos_venda_toolbar.php';
require_once 'inc/orcamento_venda.php';
require_once 'inc/usuario.php';

checkLogin('login.php');


$pedidos_venda = pedidos_venda_create();

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

  $id_sai_crip= $_GET['id_saida'];
  $id_saida   = base64_decode($id_sai_crip);

  $pedidos_venda = pedidos_venda_getById($id, $id_saida);

  /*
  echo "<pre>";
  print_r($pedidos_venda);
  echo "</pre>";
  exit;
  */
}

?>
<form method="post" action="erpc_pedidos_venda_ws.php" id=validate_custom>
  <div class="block">
    <div class="header">
      <!-- <h2>Pedido de Venda / Orçamento Número: <?=$pedidos_venda['id'];?> - Documento Saída:</h2>-->
      <?
      echo "<h2>Pedido de Venda / Orçamento Número: $id";
      if($id_saida!=''){
        echo "- Documento Saída: $id_saida ";
      }
      echo "</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">Dados</a></li>
    <li role="presentation"><a href="#form2" aria-controls="form2" role="tab" data-toggle="tab">Comissão</a></li>
    <li role="presentation"><a href="#form3" aria-controls="form3" role="tab" data-toggle="tab">Mensagens</a></li>
    <li role="presentation"><a href="#form4" aria-controls="form4" role="tab" data-toggle="tab">Veículo</a></li>
    <li role="presentation"><a href="#form9" aria-controls="form9" role="tab" data-toggle="tab">Status</a></li>
  </ul>

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

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

  <div role="tabpanel" class="tab-pane fade in" id="form3">
    <? include "erpc_pedidos_venda_edit_3_mensagens.php" ?>
  </div> <!-- tab-pane -->

  <div role="tabpanel" class="tab-pane fade in" id="form4">
    <? include "erpc_pedidos_venda_edit_4_veiculo.php" ?>
  </div> <!-- tab-pane -->

  <div role="tabpanel" class="tab-pane fade in" id="form9">
    <? include "erpc_pedidos_venda_edit_10_status.php" ?>
  </div> <!-- tab-pane -->

</div> <!-- 1o tab-content -->

    <!-- Itens dos produtos -->
    <? include "erpc_pedidos_venda_edit_5_produto.php" ?>

  <ul class="nav nav-tabs" role="tablist">
    <li role="presentation" class="active"><a href="#form5" aria-controls="form5" role="tab" data-toggle="tab">Totais</a></li>
    <li role="presentation"><a href="#form6" aria-controls="form6" role="tab" data-toggle="tab">Desconto/Frete/Despesas</a></li>
    <li role="presentation"><a href="#form7" aria-controls="form7" role="tab" data-toggle="tab">Impostos</a></li>
    <li role="presentation"><a href="#form8" aria-controls="form8" role="tab" data-toggle="tab">Titulos a receber</a></li>
  </ul>
<!-- Tab panes -->
<div class="tab-content">

  <div role="tabpanel" class="tab-pane fade in active" id="form5">
    <? include "erpc_pedidos_venda_edit_6_totais.php" ?>
  </div> <!-- tab-pane -->

  <div role="tabpanel" class="tab-pane fade in" id="form6">
    <? include "erpc_pedidos_venda_edit_7_descontos.php" ?>
  </div> <!-- tab-pane -->

  <div role="tabpanel" class="tab-pane fade in" id="form7">
    <? include "erpc_pedidos_venda_edit_8_impostos.php" ?>
  </div> <!-- tab-pane -->

  <div role="tabpanel" class="tab-pane fade in" id="form8">
    <? include "erpc_pedidos_venda_edit_9_titulos.php" ?>
  </div> <!-- tab-pane -->
</div>


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

<?php include 'inc/helper_modal_div.php'; ?>
<?php include 'footer.php'; ?>
<script type='text/javascript' src='js\pedidos_venda.js' ></script>
<style>
  .input-group {
    min-width:130px;// if you want width please write here //
    text-align:left;
  }
</style>
