<?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_fornecedor="select nomefor from tbfornecedor order by nomefor asc";
$r_fornecedor= mysql_query($c_fornecedor);

//$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="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js" type="text/javascript"></script>
    <script src="jquery.maskMoney.js" type="text/javascript"></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">Orçamento Cirúrgico</h4>
              <!--<h6 class="card-subtitle mb2 text-muted ">Placa: <?php echo $row_veiculo['srvplaca']; ?></h6>
              <p>Km Atual: <?php echo $row_veiculo['srvkmatual']; ?>
              
              </p> -->
            </div>
          </div>
          <div class="row mt-2 mx-5">
            <div class="card-body border border-dark rounded">
              <h4 class="card-title">Parâmetros para Cálculo</h4>
              <form method="POST" action="srvatualiza.php" enctype="multipart/form-data">
                <div class="form-row">
	                <div class="col-md-2 mb-3">
	                    <label for="txthospital">Custo Hospital:</label>
	                    <input type="text" class="form-control" id="txthospital" name="txthospital" placeholder="0.0 %" required>
	                </div>
	                <div class="col-md-2 mb-3">
	                    <label for="txtmedico">Custo Produção:</label>
	                    <input type="text" class="form-control" id="txtmedico" name="txtmedico" placeholder="0.0 %" required>
	                </div>
	                <div class="col-md-2 mb-3">
	                    <label for="txtmedico">Apoio Médico:</label>
	                    <input type="text" class="form-control" id="txtmedico" name="txtmedico" placeholder="0.0 %" required>
	                </div>
	              	<div class="col-md-3 mb-3">
	                    <label for="txtimportacao">Custo Importação:</label>
	                    <input type="text" class="form-control" id="txtimportacao" name="txtimportacao" placeholder="0.0 %" required>
	            	</div>
	                <div class="col-md-3 mb-3">
	                    <label for="txtinstrumentadores">Instrumentadores:</label>
	                    <input type="text" class="form-control" id="txtinstrumentadores" name="txtinstrumentadores" placeholder="1" required>
	                </div>
	                <div class="col-md-3 mb-3">
	                    <label for="txtvlrintru">Valor por Instrumentador R$:</label>
	                    <input type="text" class="form-control" id="txtvlrintru" name="txtvlrintru" placeholder="R$ 1.00" required>
	                </div>
	                <div class="col-md-3 mb-3">
	                    <label for="txtimposto">Impostos e Tributos:</label>
	                    <input type="text" class="form-control" id="txtimposto" name="txtimposto" placeholder="0.0 %" required>
	                </div>
	                <div class="col-md-3 mb-3">
	                    <label for="txtfrete">Fretes:</label>
	                    <input type="text" class="form-control" id="txtfrete" name="txtfrete" placeholder="0.0 %" required>
	                </div>
	                <div class="col-md-3 mb-3">
	                    <label for="txtvendedor">% Vendedor:</label>
	                    <input type="text" class="form-control" id="txtvendedor" name="txtvendedor" placeholder="0.0 %" required>
	                </div>
	                <div class="col-md-3 mb-3">
	                    <label for="txtadm">% Administrativo Financeiro:</label>
	                    <input type="text" class="form-control" id="txtadm" name="txtadm" placeholder="0.0 %" required>
	                </div>
	                <div class="col-md-3 mb-3">
	                    <label for="txtoutro">Outros Custos Não Informados R$:</label>
	                    <input type="text" class="form-control" id="txtoutro" name="txtoutro" placeholder="0.00" required>
	                </div>
	                <div class="col-md-3 mb-3">
	                    <label for="txtvideo">Video Monitorização R$:</label>
	                    <input type="text" class="form-control" id="txtvideo" name="txtvideo" placeholder="0.00" required>
	                </div>
	                <div class="col-md-3 mb-3">
	                    <label for="txtperda">Perdas R$:</label>
	                    <input type="text" class="form-control" id="txtperda" name="txtperda" placeholder="0.00" required>
	                </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();}
             // $resultpecas= mysqli_query($connect, "SELECT * FROM tbitensestoque WHERE codigo='".$id."' ORDER BY idpeca");
          ?>

          <div class="row mt-2 mx-5">
            <div class="card-body border border-dark rounded" style="background-color:#E8E8E8">
              <h4 class="card-title">Material e Serviço</h4>
              <button type="button" class="btn btn-info btn-sm mb-2 data" data-toggle="modal"  data-target="#MymodalCad">+ Material</button>
              <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$ Custo Unit</th>
                              <th style="text-align: center;vertical-align:middle">R$ Custo Total</th>
                              <th style="text-align: center;vertical-align:middle">R$ Venda Unit</th>
                              <th style="text-align: center;vertical-align:middle">R$ Venda Total</th>
                              <th style="text-align: center;vertical-align:middle">ICMS</th>
                          </tr>
                      </thead> 
                      <!--
                      <?php while($rowsp = mysqli_fetch_array($resultpecas)): ?>
                      <tr>
                          
                          <td style="text-align: left;vertical-align:middle"><?php echo $rowsp['srvpeca']; ?></td>
                          <td style="text-align: center;vertical-align:middle"><?php echo $rowsp['srvqtdpeca']; ?></td>



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

          </div>

          <!-- Início da Janela Modal -->

          <div class="modal fade" tabindex="-1" role="dialog" id="MymodalCad">
            <div class="modal-dialog" role="document">
              <div class="modal-content">
                <div class="modal-header">
                  <h4 class="modal-title text-center" id="myModalLabel">Inclusão de Material</h4>
                  <button type="button" class="close" data-dismiss="modal" aria-label="Fechar">
                    <span aria-hidden="true">&times;</span>
                  </button>
                </div>
                <div class="modal-body">
                <form method="POST" action="srvitemcadastrado.php" enctype="multipart/form-data">
                  <div class="form-group">  
                      <label for="txtdescricao">Descrição:</label>
                      <input type="hidden" name="txtcodigoos" value="<?php echo $row_veiculo['codigo']; ?>">
                      <input type="text" class="form-control" id="txtdescricaoitem" name="txtdescricaoitem" placeholder="Descriçao da Peça" required>
                  </div>
                   <div class="form-group">  
                      <label for="txtdescricao">Quantidade:</label>
                      <input type="text" class="form-control" id="txtqtditem" name="txtqtditem" placeholder="1" required>
                  </div>
                   <div class="form-group">  
                      <label for="txtdescricao">Valor Unitário R$:</label>
                      <input type="text" class="form-control" id="txtvlrunit" name="txtvlrunit" placeholder="1,00" required>
                  </div>
                  <div class="modal-footer">
                  <button type="button" class="btn btn-secondary" data-dismiss="modal">Fechar</button>
                  <button type="submit" class="btn btn-primary">Incluir Peça</button>
                </div>
                </form>
                </div>
                
              </div>
            </div>
          </div>

          <!-- Fim da Janela Modal -->
          <div class="row mt-2 mx-5">
            <div class="card-body border border-dark rounded">
              <h4 class="card-title">Resultados das Margens</h4>
              <form method="POST" action="srvatualiza.php" enctype="multipart/form-data">
                <div class="form-row">
                	<div class="col-md-2 mb-3">
                    	<label for="txtCustoTotM">Custo Total do Material R$:</label>
                    	<input type="text" class="form-control" id="txtCustoTotM" name="txtCustoTotM" placeholder="0.00" required>
                  	</div>
                  	<div class="col-md-2 mb-3">
                    	<label for="txtCustoTotM">Custo Total da Instrumentação R$:</label>
                    	<input type="text" class="form-control" id="txtCustoTotM" name="txtCustoTotM" placeholder="0.00" required>
                  	</div>
                  	<div class="col-md-2 mb-3">
                    	<label for="txtCustoTotM">Custo Total da Comiss.Vendas R$:</label>
                    	<input type="text" class="form-control" id="txtCustoTotM" name="txtCustoTotM" placeholder="0.00" required>
                  	</div>
                  	<div class="col-md-2 mb-3">
                    	<label for="txtCustoTotM">Custo Total da Comiss.Vendas R$:</label>
                    	<input type="text" class="form-control" id="txtCustoTotM" name="txtCustoTotM" placeholder="0.00" required>
                  	</div>
                  	<div class="col-md-2 mb-3">
                    	<label for="txtCustoTotM">Custo Total da Desp.Adm R$:</label>
                    	<input type="text" class="form-control" id="txtCustoTotM" name="txtCustoTotM" placeholder="0.00" required>
                  	</div>
                  	<div class="col-md-2 mb-3">
                    	<label for="txtCustoTotM">Outros Custos R$:</label>
                    	<input type="text" class="form-control" id="txtCustoTotM" name="txtCustoTotM" placeholder="0.00" required>
                  	</div>
                  	<div class="col-md-2 mb-3">
                    	<label for="txtCustoTotM">Impostos S/Vendas R$:</label>
                    	<input type="text" class="form-control" id="txtCustoTotM" name="txtCustoTotM" placeholder="0.00" required>
                  	</div>
                  	<div class="col-md-2 mb-3">
                    	<label for="txtCustoTotM">Valor Total da Venda R$:</label>
                    	<input type="text" class="form-control" id="txtCustoTotM" name="txtCustoTotM" placeholder="0.00" required>
                  	</div>
                  	<div class="col-md-2 mb-3">
                    	<label for="txtCustoTotM">Resultado R$:</label>
                    	<input type="text" class="form-control" id="txtCustoTotM" name="txtCustoTotM" placeholder="0.00" required>
                  	</div>
                </div>
              </form>
            </div>
          </div>






          <?php
          //$result_pecas_veiculo = "SELECT SUM((srvqtdpeca * srvqvlrunitpeca)) AS total FROM tbservicospecas WHERE codigo='".$id."'";
          
          //$resultado_pecas = mysqli_query($con,$result_pecas_veiculo);
          //$rstotal = mysqli_fetch_assoc($resultado_pecas);

          ?>
        </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>
