<?php
include_once '../auxiliar/validalogin.inc.php';
include_once '../auxiliar/login_fora_do_horario_guard.php';
include '../idiomas/config.inc';

login_fora_do_horario_guard();
?>

<!DOCTYPE html>
<html>

<head>

  <meta charset="utf-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <title>AFV 2 | <?php echo $p_cons;?></title>
  <!-- Tell the browser to be responsive to screen width -->
  <meta content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" name="viewport">
  <!-- Bootstrap 3.3.7 -->
  <link rel="stylesheet" href="./../web/bower_components/bootstrap/dist/css/bootstrap.min.css">
  <!-- Font Awesome -->
  <link rel="stylesheet" href="./../web/bower_components/font-awesome/css/font-awesome.min.css">
  <!-- Ionicons -->
  <link rel="stylesheet" href="./../web/bower_components/Ionicons/css/ionicons.min.css">
  <!-- Theme style -->
  <link rel="stylesheet" href="./../web/dist/css/AdminLTE.min.css">
  <!-- AdminLTE Skins. Choose a skin from the css/skins
       folder instead of downloading all of them to reduce the load. -->
  <link rel="stylesheet" href="./../web/dist/css/skins/_all-skins.min.css">

  <link rel="stylesheet" href="./../styles/custom.css">

  <!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries -->
  <!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
  <!--[if lt IE 9]>
  <script src="https://oss.maxcdn.com/html5shiv/3.7.3/html5shiv.min.js"></script>
  <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
  <![endif]-->

  <!-- Google Font -->
  <link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Source+Sans+Pro:300,400,600,700,300italic,400italic,600italic">

  <script>
    const {
      width
    } = screen;

    document.cookie ="width="+width + "; path=/";            
  
  </script>
</head>

<body class="hold-transition skin-blue sidebar-mini">
  <!-- Site wrapper -->
  <div class="wrapper">

    <header class="main-header">
      <!-- Logo -->
      <a href="../html/cadastro.php" class="logo">
        <!-- mini logo for sidebar mini 50x50 pixels -->
        <span class="logo-mini"><b>A</b>ADV</span>
        <!-- logo for regular state and mobile devices -->
        <span class="logo-lg"><b>AFV</b> - ADV Tecnologia </span>
      </a>
      <!-- Header Navbar: style can be found in header.less -->
      <nav class="navbar navbar-static-top">
        <!-- Sidebar toggle button-->
        <a href="#" class="sidebar-toggle" data-toggle="push-menu" role="button">
          <span class="sr-only">Toggle navigation</span>
          <span class="icon-bar"></span>
          <span class="icon-bar"></span>
          <span class="icon-bar"></span>
        </a>


      </nav>
    </header>

    <!-- =============================================== -->
    <!-- Inserir modal aqui-->
    <div class="modal fade" id="modal-ins-produtos">
      <div class="modal-dialog">
        <div class="modal-content">
          <div class="modal-header">
            <button type="button" class="close" data-dismiss="modal" aria-label="Close">
              <span aria-hidden="true">&times;</span></button>
            <h4 class="modal-title"><?php echo $m_relatorios;?></h4>
          </div>
          <div class="modal-body">
            <p>
              <div class="embed-responsive embed-responsive-16by9">
                <!-- <iframe class="embed-responsive-item" src="../php/buscalastvnd.php"></iframe> -->
              </div>
            </p>
          </div>
          <div class="modal-footer">
            <button type="button" class="btn btn-default pull-left" data-dismiss="modal"><?php echo $bt_fechar;?></button>
          </div>
        </div>
      </div>
    </div>
    <!-- /.modal -->
    <!--Modal -->
    <div class="modal fade" id="modal-sair-pedido">
      <div class="modal-dialog">
        <div class="modal-content">
          <div class="modal-header">
            <button type="button" class="close" data-dismiss="modal" aria-label="Close">
              <span aria-hidden="true">&times;</span></button>
            <h4 class="modal-title"><?php echo $p_cons_cancelar_pedido;?></h4>
          </div>
          <div class="modal-body">
            <p>
            <?php echo $msg_sair_pedido;?>
            </p>
          </div>
          <div class="modal-footer">
            <button type="button" class="btn btn-default pull-left" data-dismiss="modal"><?php echo $bt_fechar;?></button>
            <?php
            include_once '../bd/funcoes.inc';
            $p_codos = lecookie("codos");
            echo ("<a  a href='../php/sair.php' class='btn btn-default pull-right'>$bt_sair_salvar</a>");
            ?>
          </div>
        </div>
        <!-- /.modal-content -->
      </div>
      <!-- /.modal-dialog -->
    </div>
    <!--/Modal-->
    <!--Modal -->
    <div class="modal fade" id="modal-cancelar-pedido">
      <div class="modal-dialog">
        <div class="modal-content">
          <div class="modal-header">
            <button type="button" class="close" data-dismiss="modal" aria-label="Close">
              <span aria-hidden="true">&times;</span></button>
            <h4 class="modal-title"><?php echo $p_cons_cancelar_pedido;?></h4>
          </div>
          <div class="modal-body">
            <p>
            <?php echo $msg_cancelar_pedido;?>
            </p>
          </div>
          <div class="modal-footer">
            <button type="button" class="btn btn-default pull-left" data-dismiss="modal"><?php echo $bt_fechar;?></button>
            <?php
            include_once '../bd/funcoes.inc';
            $p_codos = lecookie("codos");
            echo ("<a  href='../php/encerra.php?encerra=cancela' class='btn btn-default pull-right'>$bt_cancelar</a>");
            ?>
          </div>
        </div>
        <!-- /.modal-content -->
      </div>
      <!-- /.modal-dialog -->
    </div>
    <!--/Modal-->
    <!-- Inserir modal aqui-->
    <div class="modal fade" id="modal-default">
      <div class="modal-dialog">
        <div class="modal-content">
          <div class="modal-header">
            <button type="button" class="close" data-dismiss="modal" aria-label="Close">
              <span aria-hidden="true">&times;</span></button>
            <h4 class="modal-title"><?php echo $m_relatorios;?></h4>
          </div>
          <div class="modal-body">
            <p>
              <?php
              include './../html/relatorios.php';
              ?>
            </p>
          </div>
          <div class="modal-footer">
            <button type="button" class="btn btn-default pull-left" data-dismiss="modal"><?php echo $bt_fechar;?></button>
          </div>
        </div>
        <!-- /.modal-content -->
      </div>
      <!-- /.modal-dialog -->
    </div>
    <!-- /.modal -->









    <div class="modal fade" id="modal-confirma-alteracao-preco-ao-selecionar-tabela">
      <div class="modal-dialog">
        <div class="modal-content">
          <div class="modal-header">
            <button type="button" class="close" data-dismiss="modal" aria-label="Close">
              <span aria-hidden="true">&times;</span></button>
            <h4 class="modal-title"><?php echo $msg_atencao;?></h4>
          </div>
          <div class="modal-body">
            <p>
            <?php echo $msg_alterar_preço_dos_itens;?>
            </p>
          </div>
          <div class="modal-footer">
            <button type="button" class="btn btn-danger pull-left" data-dismiss="modal" onclick="selectTabelaDePreco(false)"><?php echo $bt_nao;?></button>
            <button type="button" class="btn btn-primary pull-right" onclick="selectTabelaDePreco(true)" data-dismiss="modal"><?php echo $bt_sim;?></button>
          </div>
        </div>
        <!-- /.modal-content -->
      </div>
    </div>








    <?php if($p_filtra_produtos_por_marca==1): ?>
      <div class="modal fade" id="modal-busca-marca">
            <div class="modal-dialog">
                <div class="modal-content">
                    <div class="modal-header">
                        <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                            <span aria-hidden="true">&times;</span></button>
                        <h4 class="modal-title"><?php echo $p_cons_buscar_marca;?> </h4>
                    </div>
                    <div class="modal-body">
                        <div id="marcaSearchContainer"></div>
                    </div>
                    <div class="modal-footer">
                        <button type="button" class="btn btn-default pull-left" data-dismiss="modal"><?php echo $bt_sair;?></button>
                    </div>
                </div>
                <!-- /.modal-content -->
            </div>
            <!-- /.modal-dialog -->
        </div>
        <!-- /.modal -->
        <!-- -->
    <?php endif;?>








    <?php
    include_once '../bd/funcoes.inc';
    $modal = "<div class='modal fade' id='modal-buscarcliente'>
      <div class='modal-dialog'>
        <div class='modal-content'>
          <div class='modal-header'>
            <button type='button' class='close' data-dismiss='modal' aria-label='Close'>
              <span aria-hidden='true'>&times;</span></button>
            <h4 class='modal-title'>$b_busca_cliente_nova_venda</h4>
          </div>
          <div class='modal-body'>";

    $modal2 = "<form action='../php/buscacli.php' method='post' name='procuracadastro' id='procuracadastro'>
               
              <div class='box-body'>
                <div class='form-group'>
                  <label for='Razao'>$b_razao_social</label>
                  <input name='razao' class='form-control' id='razao' placeholder='$b_buscar_cliente' type='text'>
                </div>

                

                <script> document.procuracadastro.razao.focus();</script>  
              </div>
              
          </div>
          <div class='modal-footer'>
            <button type='button' class='btn btn-default pull-left' data-dismiss='modal'>$bt_fechar</button>
            <input type='submit' class='btn btn-primary pull-right' name='Enviar' value='$bt_localizar' alt='Localizar' />
          </div>
          </form>   
        </div>
        <!-- /.modal-content -->
      </div>
      <!-- /.modal-dialog -->
    </div>";

    $p_codos = lecookie("codos");

    if (!$p_codos) {
      echo ($modal);
      include_once '../bd/funcoes.inc';
      if (lecookie("codos")) {
        echo " <SCRIPT>
            self.location.href='../html/produtos_consulta.php';
          </SCRIPT>";
        exit;
      }
      echo ($modal2);
    }





    ?>

    <!-- Fim do modal -->

    <!-- Left side column. contains the sidebar -->
    <aside class="main-sidebar">
      <!-- sidebar: style can be found in sidebar.less -->
      <section class="sidebar">
        <!-- Sidebar user panel -->
        <div class="user-panel">
          <div class="pull-left image">
            <img src="./../icons/frame.png" class="img-circle" alt="User Image">
          </div>
          <div class="pull-left info">
            <p>
              <?php
              include_once '../bd/funcoes.inc';
              $p_codusu = lecookie("codusu");
              echo (TrazValorCampo('senhas', 'usuario', 'codusu', lecookie('codusu')));
              ?>
            </p>
          </div>
        </div>

        <!-- sidebar menu: : style can be found in sidebar.less -->
        <ul class="sidebar-menu" data-widget="tree">
          <li class="header"><?php echo $g_painel_navegacao;?></li>
          <li class="treeview">
            <a href="#">
              <i class="fa fa-dashboard"></i> <span><?php echo $m_vendas;?></span>
              <span class="pull-right-container">
                <i class="fa fa-angle-left pull-right"></i>
              </span>
            </a>
            <ul class="treeview-menu">
              <li><a href="./buscahistvnd.php"><i class="fa fa-circle-o"></i> <?php echo $m_historico_venda;?></a></li>
              <li><a href="#" data-toggle="modal" data-target="#modal-buscarcliente"><i class="fa fa-circle-o"></i> <?php echo $m_nova_venda;?></a></li>
            </ul>
          </li>
          <li class="treeview">
            <a href="#">
              <i class="glyphicon glyphicon-user"></i> <span><?php echo $m_clientes;?></span>
              <span class="pull-right-container">
                <i class="fa fa-angle-left pull-right"></i>
              </span>
            </a>
            <ul class="treeview-menu">
              <li><a href="./cadastronovo.php"><i class="fa fa-circle-o"></i> <?php echo $m_cadastrar_cliente;?></a></li>
              <li><a href="#" data-toggle="modal" data-target="#modal-buscarcliente"><i class="fa fa-circle-o"></i>
              <?php echo $m_localizar_cliente;?></a></li>
            </ul>
          </li>
          <li class="treeview">
            <a href="#" data-toggle="modal" data-target="#modal-default">
              <i class="fa fa-files-o"></i>
              <span><?php echo $m_relatorios;?></span>
            </a>
          </li>
          <li>
            <a href="./produtos_consulta.php">
              <i class="glyphicon glyphicon-search"></i> <span><?php echo $m_consulta_produtos;?></span>
            </a>
          </li>
          <li>
            <a href="./../php/logoff.php">
              <i class="glyphicon glyphicon-off"></i>
              <span><?php echo $m_Logout;?></span>
            </a>
          </li>
        </ul>
      </section>
      <!-- /.sidebar -->
    </aside>

    <!-- =============================================== -->

    <!-- Content Wrapper. Contains page content -->
    <div class="content-wrapper">
      <!-- Content Header (Page header) -->
      <?php
      include_once '../bd/bd_os.inc';
      include_once '../bd/bd_senhas.inc';
      include_once '../bd/funcoes.inc';
      include '../auxiliar/parametros.inc';

      $c_codos = lecookie("codos");
      $c_razao = lecookie("razao");
      $p_codusu = lecookie("codusu");
      $codusu = lecookie("codusu");
      $width = lecookie("width");
      $isMobileDevice = ($p_desabilita_layout_mobile <> 1) && isset($width) ? intval($width) <= 768 : null;

    


      if ($c_codos) {
        $p_numos = GetNumOs($c_codos);
      }
      echo ("
      <section class='content-header'>
        <h1>
        $p_cons_pedido_para $c_razao 
        </h1>");

        if ( (!$isMobileDevice) ) {
          echo (" <ol class='breadcrumb'>
              <!-- controle de paginas aqui-->
              <li><a href='#'><i class='fa fa-dashboard'></i> $g_inicio</a></li>"); 
            }
        ?>

      <?php if ($c_codos) {
        $GLOBALS['is_venda'] = true; ?>
        <!-- EXIBIR SELETOR DE PRAZO DE PAGAMENTO -->
      <?php if ( (!$isMobileDevice) ) { ?>
        <li><a href='#'><?php echo $bt_novo_pedido;?></a></li>
      <?php } } else {  ?>
      <?php if ( (!$isMobileDevice)  ) { ?>
        <li><a href='#'><?php echo $p_cons;?></a></li>
      <?php } } ?>

      </ol>
      </section>

      <!-- Main content -->

      <section class='content'>

        <!-- Default box -->
        <div class='box'>
          <div class='box-header with-border'>
            <h3 class='box-title'>
            <?php echo $p_cons_pedido_numero;?> <b><?php echo $p_numos ?> </b> &nbsp;&nbsp;&nbsp;
              
              <?php if (canEditVnd($p_codos)): ?>
                <?php include '../componentes/seletor-tabelas-de-preco.php'; ?>
              <?php endif;?>

              <!-- <div class="pull-right"> -->
              <?php include '../componentes/seletor-forma-pagamento-fvalle.php'; ?>
                <!-- </div> -->

              <?php if($p_usa_saldo_flex == 1): ?>
                  
                <?php 
                  $width = lecookie("width");
                  $isMobileDevice = ($p_desabilita_layout_mobile <> 1) &&  isset($width) ? intval($width) <= 768 : null;
                  if(($isMobileDevice) ){ echo "<p>";}?>
                    <b style="font-size: 14px"><?php echo $p_cons_saldo_flex;?> </b>
                  <?php 
                    $saldo = getSaldoFlex();
                    $saldoFormatado = number_format($saldo, 2, ',', '.');
                    if($saldo > 0) { ?>
                      <span class="description-percentage text-green"><i class="fa fa-caret-up"></i> <?php echo $saldoFormatado ?></span>
                    <?php } else { ?>
                      <span class="description-percentage text-red"><i class="fa fa-caret-down"></i> <?php echo $saldoFormatado ?></span>
                    <?php } ?>
                      
                  <?php if($p_habilita_media_mix == 1){
                    echo "&nbsp;&nbsp;&nbsp;<b style='font-size: 14px'> $p_cons_media_mix </b>";
                    $mediamix = getMediaMix();
                    $mediamixFormatado = number_format($mediamix, 3, ',', '.');
                    
                    echo "<span> $mediamixFormatado </span>";

                    } 
                  ?>
               

               <?php if(($isMobileDevice)  ){ echo "</p>";}?>
              <?php endif;?>

              <?php if($p_verifica_limite_credito == 1): ?>
                  <div >
                    <b style="font-size: 14px"><?php echo $p_cons_limite_credito;?> </b>
                    <?php 
                      include_once '../bd/bd_clientes.inc';
                      $codcli = lecookie("codcli");
                      $limite = getLimitCreditCliente($codcli);
                      $valorDeParcelasEmAberto = getValorDeParcelasEmAberto($codcli);
                      $saldo = $limite - $valorDeParcelasEmAberto;
                      $saldoFormatado = number_format($saldo, 2, ',', '.');
                      if($saldo > 0) { ?>
                        <span style="font-size: 16px" class="description-percentage text-green"><i class="fa fa-caret-up"></i> <?php echo $saldoFormatado ?></span>
                      <?php } else { ?>
                        <span style="font-size: 16px" class="description-percentage text-red"><i class="fa fa-caret-down"></i> <?php echo $saldoFormatado ?></span>
                      <?php } ?>
                    </div>
              <?php endif;?>
            </h3>


            <div class='box-tools pull-right'>
              <button type='button' class='btn btn-box-tool' data-widget='collapse' data-toggle='tooltip' title='Collapse'>
                <i class='fa fa-minus'></i></button>
              <button type='button' class='btn btn-box-tool' data-widget='remove' data-toggle='tooltip' title='Remove'>
                <i class='fa fa-times'></i></button>
            </div>
          </div>
          <div class='box-body'>
            <!-- Inserir aqui-->

            <?php if ($p_habilita_servicos == 1 && $p_esconde_aba_produtos != 1) : ?>
              <div class="nav-tabs-custom">

                <ul class="nav nav-tabs  ui-sortable-handle">
                  <li><a href="#produtos" id="btnTabProdutos" data-toggle="tab"><?php echo $b_produtos;?></a></li>

                  <li class="active"><a href="#servicos" id="btnTabServicos" data-toggle="tab"><?php echo $p_cons_servico;?></a></li>

                </ul>
              </div>
            <?php endif; ?>

            <div id="tabProdutos" class="tab" <?php echo ($p_habilita_servicos == 1) ? 'style="display: none"' : ''  ?>>
              <?php if ($p_esconde_aba_produtos != 1) : ?>
                <?php if (recebevar("msgerro")) { ?>

                  <div class='alert alert-warning alert-dismissible'>
                    <button type='button' class='close' data-dismiss='alert' aria-hidden='true'>×</button>
                    <h4><i class='icon fa fa-warning'></i> <?php echo $msg_atencao;?></h4>
                    <?php echo $msg_nenhum_produto_encontrado;?>
                  </div>

                <?php } ?>


                <form action='../php/buscaprod.php' method='post' name='selprodutos2'>
                  <input name='codos' type='hidden' id='increst' value='<?php echo $p_codos ?>' />

                  <div class="form-group">
                    <?php 

                    if (canEditVnd($p_codos)){
                      if ($p_consultaApenasCodigoOuDescricao != 0){
                        print("<label for='descricao' id='filtro'>$p_cons_consultar_prod</label>
                              <input class='form-control' name='codigo' type='text' /><br>
                              
                              <label for='descricao' id='filtro'>$p_cons_consultar_prod_desc</label>
                              <input class='form-control' name='descricao' type='text' />
                              ");
                        }else{
                          print("<label for='descricao' id='filtro'>$p_cons_produto_por_codigo</label>
                                 <input class='form-control' name='filtro' type='text' />
                          ");
                        }
                    }
                    
                    ?>
                  
                  
                  </div>
                    
                  <?php if($p_filtra_produtos_por_marca==1): ?>
                  <label for='descricao' id='filtro'><?php echo $p_cons_consultar_prod_marca;?></label><br />
                  <div class="col-sm-12 input-group">
                      <input name="razao" type="text" class="form-control" id="descricaoMarca" disabled="true">
                      <input name="marca" id="marca" type="hidden">
                      <span class="input-group-btn">
                          <button onclick="loadMarcaSearch()" data-toggle='modal' data-target='#modal-busca-marca' type="button" class="btn btn-success btn-flat"><?php echo $bt_pesquisar;?></button>
                      </span>
                      <span class="input-group-btn">
                          <button onclick="clearMarcaSearch()" type="button" class="btn btn-info btn-flat"><?php echo $bt_limpar;?></button>
                      </span>
                  </div>
                  <?php endif;?>


                  <?php
                  $p_codos = lecookie("codos");
                  if (!$p_codos) {
                    $p_ultped = "";
                  } ?>
                  
                  <?php if (canEditVnd($p_codos)): ?>
                    <input class='btn btn-primary' type='submit' name='Enviar' value='<?php echo $bt_procurar;?>' /><?php echo $p_ultped ?>
                  <?php endif;?>
                  
                </form>

                <script>
                  document.selprodutos2.filtro.focus();
                </script>
                <?php
                include "../auxiliar/parametros.inc";          
                $p_codos = lecookie("codos");
                if ($p_codos) { ?>

                  <div id='content'></div>

                <?php } ?>
              <?php endif; ?>
            </div>

            <div id="tabServicos" class="tab" <?php echo ($p_habilita_servicos != 1) ? 'style="display: none"' : ''  ?>>
              <?php if ($p_habilita_servicos == 1) : ?>
                <br>

                <?php if (canEditVnd($p_codos)): ?>
                    <div class='form-group'>
                      <label for='codigo' id='codigo'><?php echo $p_cons_servico_cod;?></label><br />
                      <input class='form-control' id='filtroServico' name='filtro-servico' type='text' class='campotexto' />
                    </div>
                
                    <!-- <div class="form-group">
                      <label for='descricao' id='descricao'>Consulta Serviço por Descrição</label>
                      <input class='form-control' id='filtroDescricaoServico' type='text' />
                    </div> -->
                    <br>
                
                    <div>
                      <input class='btn btn-primary' type='button' id="btnBuscarServicos" value='<?php echo $bt_procurar;?>' />
                    </div>
                    
                    <div style="clear: both;display:block"></div>
                    <br>
                    <hr>
                <?php endif; ?>
                <div id="viewServicos"></div>

              <?php else : ?>
                <div class="alert alert-warning">
                  <h2><?php echo $msg_comprtamento_nao_habilitado;?></h2>
                </div>

              <?php endif; ?>
            </div>

            <!-- Finalizar aqui-->
          </div>
          <!-- /.box-body -->

          <!-- /.box-footer-->
        </div>
        <!-- /.box -->

      </section>
      <!-- /.content -->
    </div>
    <!-- /.content-wrapper -->

    <?php  include_once '../html/footer.php'; ?>

  </div>
  <!-- ./wrapper -->

  <!-- jQuery 3 -->
  <script src="../web/bower_components/jquery/dist/jquery.min.js"></script>
  <!-- Bootstrap 3.3.7 -->
  <script src="../web/bower_components/bootstrap/dist/js/bootstrap.min.js"></script>
  <!-- SlimScroll -->
  <script src="../web/bower_components/jquery-slimscroll/jquery.slimscroll.min.js"></script>
  <!-- FastClick -->
  <script src="../web/bower_components/fastclick/lib/fastclick.js"></script>
  <!-- AdminLTE App -->
  <script src="../web/dist/js/adminlte.min.js"></script>
  <!-- AdminLTE for demo purposes -->
  <script src="../web/dist/js/demo.js"></script>

  <script src="../js/selectTabelaDePreco.js"></script>
  <?php if ($p_fvalle_prazo_pagamento == 1 || $p_fvalle_prazo_pagamento == 2) : ?>
    <script src="../js/selectFormaDePagamentoFValle.js"></script>
  <?php endif; ?>


  <script>
    $(document).ready(function() {
      $('.sidebar-menu').tree()
    })


    var loadMarcaSearch = function() {
        $('#marcaSearchContainer').html("<h3>Carregando ... </h3>");

        $('#marcaSearchContainer')
            .load('../php/busca_de_marcas.php');
    }


    var clearMarcaSearch = function() {
        $("#descricaoMarca").val('');
        $("#marca").val('');
    }
    
    $('#marcaSearchContainer').on("marca-selecionada", function(event, cliente) {
        $("#descricaoMarca").val(cliente.descricaoMarca);
        $("#marca").val(cliente.marca);
    })


    $(document).ready(function() {

      $("#btnTabProdutos").click(function() {
        $(".tab").hide();
        $("#tabProdutos").show();
      });


      $("#btnTabServicos").click(function() {
        $(".tab").hide();

        $("#viewServicos")
          .load("../php/servicos_por_os.php?codos=<?php echo $p_codos ?>");
        $("#tabServicos").show();
      });



      <?php if ($p_habilita_servicos == 1) : ?>
        $("#viewServicos")
          .load("../php/servicos_por_os.php?codos=<?php echo $p_codos ?>");
      <?php endif; ?>


      $("#btnBuscarServicos").click(function() {
        var filtro = $("#filtroServico").val();
        $("#viewServicos")
          .load("../php/consulta_servicos.php?filtro=" +
            encodeURIComponent(filtro) );
      });



      $('#content')
        .load('../php/carrinho.php?semlinks=1&' + '<?php echo $_SERVER['QUERY_STRING']; ?>', function() {
          applyMaskToDescontoGeral();
          $("#btnAplicarDesconto").removeAttr("disabled")

          $("#formDescontoGeral").submit(function(evt) {
            var $inputDescontoGeral = $("#inputDescontoGeral");
            var val = $inputDescontoGeral.val();
            var valSplit = val.split(",");
            var decimals = valSplit[1];
            var integer = valSplit[0];
            var sanitizedValue = integer.replace(/\./g, "") + "." + decimals;
            $inputDescontoGeral.val(sanitizedValue);
          })

        });



    });
  </script>

</body>

</html>
