<?php

Include("includes/con_cliente.php");

 require_once('connection.php');
    session_start();

    if(isset($_SESSION['User']))
    {
        $query="select * from tbusuario where nomeuser='".$_SESSION['User']."'";
        $result=mysqli_query($con,$query);
        $resultado = mysqli_fetch_assoc($result);
        $r_resultado = $resultado;
        //echo $resultado["nome"] .'<br>';
    }
    else
    {
        header("location:index.php");
    }

$c_nf="SELECT nota FROM `tbnf` where empresa = '1' ORDER by nota DESC";
$r_nf= mysql_query($c_nf);

//$id = $_GET['id'];



//$result_veiculo = "SELECT * FROM tbservicos WHERE codigo = '".$id."'";
//$resultado_veiculo = mysqli_query($con,$result_veiculo);
//$row_veiculo = mysqli_fetch_assoc($resultado_veiculo);


?>



<html lang="pt-br">

    <head>
        <meta charset="utf-8" />
        <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
        <title>Sistema SCA - Grupo BRO</title>

        <link rel="stylesheet" href="node_modules/bootstrap/compiler/bootstrap.css">
        <link rel="stylesheet" href="node_modules/bootstrap/compiler/styler.css">

        <!--<link rel="stylesheet" type="text/css" media="screen" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.1/css/bootstrap.min.css" /> -->
        <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.3.0/css/font-awesome.min.css">
        <link rel="stylesheet" href="https://cdn.rawgit.com/Eonasdan/bootstrap-datetimepicker/e8bddc60e73c1ec2475f827be36e1957af72e2ea/build/css/bootstrap-datetimepicker.css" />

<!--        <script type="text/javascript" src="https://code.jquery.com/jquery-2.1.1.min.js"></script>
        <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.9.0/moment-with-locales.js"></script>
        <script type="text/javascript" src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.1/js/bootstrap.min.js"></script>
        <script type="text/javascript" src="https://cdn.rawgit.com/Eonasdan/bootstrap-datetimepicker/e8bddc60e73c1ec2475f827be36e1957af72e2ea/src/js/bootstrap-datetimepicker.js"></script> -->


        <script src="https://code.jquery.com/jquery-3.2.1.slim.min.js"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery.mask/1.14.15/jquery.mask.min.js"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js"></script>
    <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js"></script>
    
    <script src="jquery.maskMoney.js" type="text/javascript"></script>


    <script src="https://code.jquery.com/jquery-1.12.4.min.js"></script>
    <script type="text/javascript">
        $(document).ready(function(){
            $("button[type='button']").click(function(){
                var radioValue = $("input[name='gender']:checked").val();
                if(radioValue){
                    alert("Your are a - " + radioValue);
                }
            });
            
        });
    </script>


    </head>
    <body>
        
        <nav class="navbar fixed-top navbar-expand-lg navbar-dark" style="background-color: #3333ff;">
          <!--<a class="navbar-brand" href="#">SCA</a> -->
          <a class="navbar-brand" href="menu.php">
                <img src="img/logomarca.png" width="50" height="40" class="d-inline-block align-center" alt="">
                SCA - Orçamentos - Validação de Margens de Venda
          </a>

          <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarTogglerDemo02" aria-controls="navbarTogglerDemo02" aria-expanded="false" aria-label="Toggle navigation">
            <span class="navbar-toggler-icon"></span>

          </button>
          <div class="collapse navbar-collapse" id="navbarTogglerDemo02">
            <ul class="navbar-nav mr-auto mt-2 mt-lg-0">
            </ul>
            <form class="form-inline my-2 my-lg-0">
              <button class="btn btn-primary btn-sm my-2 my-sm-0" type="submit">
                <a href="m.php" style="color:inherit"> Sair </a></button>
              </button>
            </form>
          </div>
        </nav>

        
        <div style="margin-top: 4rem;" >
        <!--  <div class="row mx-5">
            <div class="card-body border border-dark rounded" style="background-color:#EEE8AA">
              <h4 class="card-title">Seleção de Unidade de Negócios</h4>
              <form>
                <div class="custom-control custom-radio custom-control-inline">
                  <input type="radio" class="custom-control-input" id="brasil" name="gender" value="1">
                  <label class="custom-control-label" for="brasil">Brasil Ortopedia</label> 
                </div>
                <div class="custom-control custom-radio custom-control-inline">
                  <input type="radio" class="custom-control-input" id="orthomac" name="gender" value="2">
                  <label class="custom-control-label" for="orthomac">Orthomac</label>
                </div>
                <div class="custom-control custom-radio custom-control-inline">
                  <input type="radio" class="custom-control-input" id="ajumed" name="gender" value="3">
                  <label class="custom-control-label" for="ajumed">Ajumed</label>
                </div>
                <div class="custom-control custom-radio custom-control-inline">
                  <input type="radio" class="custom-control-input" id="bestcare" name="gender" value="4">
                  <label class="custom-control-label" for="bestcare">Best Care</label>
                </div>
              </form>
              <button class="btn btn-success mt-2" type="button" value="Selecionar Empresa">Selecionar Empresa</button>
            </div>
          </div>
        </div> -->

        <div style="margin-top: 1rem;" >
          <div class="row mx-5">
            <div class="card-body border border-dark rounded" >
              <form>
                <div class="form-row">
                  <div class="col-md-2 mb-3">
                    <input type="hidden" name="txtcodigoos" value="<?php echo $row_veiculo['codigo']; ?>">
                    <label for="txtsituacao">Selecione a Empresa:</label>
                    <select class="custom-select" id="txtsituacao" name="txtosituacao">
                      <option value="1">Brasil Ortopedia</option>
                      <option value="2">Orthomac</option>
                      <option value="3">Ajumed</option>
                      <option value="4">Best Care</option>
                    </select>
                  </div>
                  <div class="col-md-2 mb-3">
                    <label for="txtsituacao">Seleção de Nota Fiscal:</label>
                    <select class="custom-select " id="CirHospital" required name="clientehospital">
                      <option value="">Selecione a Nota...</option>
                        <?php
                          while($l_nf=mysql_fetch_array($r_nf)){
                                echo "<option value='" .$l_nf['0']."'>".$l_nf['0']."</option>";
                          }
                        ?>
                    </select>
                  </div>
                </div>
              </form>
            </div>
          </div>

          <?php
              $connect = mysqli_connect('127.0.0.1', 'root', 'fcf2778@', 'administrativo');
              if(mysqli_connect_errno($connect)){
              echo 'Falha ao conectar com o Banco de Dados !'.mysqli_connect_error();}
              $resultnf= mysqli_query($connect, "SELECT tbnf.empresa, tbnf.nota, tbnf.cliente, tbitensnf.produto ,tbitensnf.descricao ,tbitensnf.qtditem, tbitensnf.vlrunit ,tbitensnf.vlrtotal ,tbitensnf.toticms, tbitensnf.customeduni, tbitensnf.customedtot from tbnf INNER JOIN tbitensnf ON tbnf.nota = tbitensnf.nota WHERE tbnf.nota = 34149");
          ?>

          <div class="row mt-2 mx-5">
            <div class="card-body border border-dark rounded" style="background-color:#E8E8E8">
              <h4 class="card-title">Produtos da Nota Fiscal</h4>
              <div class="container">
                <div class="table-responsive">
                  <table style="overflow: auto;" class="table table-striped table-responsive-md btn-table table-hover table-bordered">
                      <thead class="table-warning">
                          <tr>
                              
                              <th style="text-align: center;vertical-align:middle">Codigo</th>
                              <th style="text-align: center;vertical-align:middle">Descrição</th>
                              <th style="text-align: center;vertical-align:middle">Qtd</th>
                              <th style="text-align: center;vertical-align:middle">R$ Unit</th>
                              <th style="text-align: center;vertical-align:middle">R$ Tot</th>
                              <th style="text-align: center;vertical-align:middle">ICMS</th>
                              <th style="text-align: center;vertical-align:middle">C.Unint</th>
                              <th style="text-align: center;vertical-align:middle">C.Total</th>
                          </tr>
                      </thead>
                      <?php while($rowsp = mysqli_fetch_array($resultnf)): ?>
                      <tr>
                          
                          <td style="text-align: left;vertical-align:middle"><?php echo $rowsp['produto']; ?></td>
                          <td style="text-align: center;vertical-align:middle"><?php echo $rowsp['descricao']; ?></td>
                          <td style="text-align: right;vertical-align:middle"><?php echo $rowsp['qtditem']; ?></td>
                          <td style="text-align: right;vertical-align:middle"><?php echo $rowsp['vlrunit']; ?></td>
                          <td style="text-align: right;vertical-align:middle"><?php echo $rowsp['vlrtotal']; ?></td>
                          <td style="text-align: right;vertical-align:middle"><?php echo $rowsp['toticms']; ?></td>
                          <td style="text-align: right;vertical-align:middle"><?php echo $rowsp['customeduni']; ?></td>
                          <td style="text-align: right;vertical-align:middle"><?php echo $rowsp['customedtot']; ?></td>

                      </tr>
                      <?php endwhile; ?>
                  </table>
                </div>
              </div>
            </div>

          </div>







        </div>



    <link rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/morris.js/0.5.1/morris.css">
    </body>
    <footer class="page-footer font-small text-primary "style="margin-top: 6rem">
          <div class="footer-copyright text-center py-3">© 2019 Copyright: Brasil Ortopedia
          </div>
    </footer>
</html>
