<?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;
    }
    else
    {
        header("location:index.php");
    }

    $result_orcamentos = "SELECT * FROM tborcsint";
    $resultado_orcamentos = mysqli_query($con, $result_orcamentos);

?>




<html>
 <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" 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>


 </head>

 <body>

    <nav class="navbar fixed-top navbar-expand-lg navbar-dark" style="background-color: #3333ff;">
        <a class="navbar-brand" href="m.php">
            <img src="img/logomarca.png" width="50" height="40" class="d-inline-block align-center" alt="">
            SCA - Orçamentos - Manutenção de Orçamentos
        </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">
                <a href="morcamentos.php" style="color:inherit"> Voltar </a></button>
            </form>
        </div>
    </nav>

     <div class="container theme-showcase" role="main" style="margin-top: 5rem;">
      <div class="page-header">
        <h1>Orçamentos</h1>
      </div>
      <div class="pull-right">
        <button type="button" class="btn btn-xs btn-success btn-sm" data-toggle="modal" data-target="#myModalcad">Cadastrar</button>
      </div>

        <!-- Inicio Modal CADASTRO -->
        <div class="modal fade" id="myModalcad" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
        <div class="modal-dialog" role="document">
          <div class="modal-content">
            <div class="modal-header">
              <button type="button" class="close btn-sm" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
              <h4 class="modal-title w-100 text-center" id="myModalLabel">Cadastrar Orçamento</h4>
            </div>
            <div class="modal-body">
              <form method="POST" action="http://189.1.26.66/mbe/processa_cad.php" enctype="multipart/form-data">
                <div class="form-group">
                  <label for="recipient-name" class="control-label">Nome:</label>
                  <input name="aluno" type="text" class="form-control">
                </div>
                <div class="form-group">
                  <label for="message-text" class="control-label">Data Nescimento:</label>
                  <input name="nascimento" type="date" class="form-control">
                </div>
                <div class="form-group">
                  <label for="message-text" class="control-label">Situação:</label>
                  <!--<input name="situacao" type="text" class="form-control"> -->
                  <select class="form-control" id="situacao" required name="situacao">
                        <option value="Ativo">Ativo</option>
                        <option value="Inativo">Inativo</option>
                  </select>
                </div>
                <div class="modal-footer">
                  <button type="submit" class="btn btn-success btn-sm">Cadastrar</button>
                </div>
              </form>
            </div>
          </div>
        </div>
        </div>
          <!-- Fim Modal CADASTRO -->
        <div class="row">
            <div class="col-md-12">
              <table class="table">
                <thead>
                  <tr>
                    <th>Orçamento</th>
                    <th>Empresa</th>
                    <th>Paciente</th>
                    <th>Convênio</th>
                    <th>Hospital</th>
                    <th>Material</th>
                    <th>Valor R$</th>
                    <th>Status</th>
                  </tr>
                </thead>
                <tbody>
                  <?php while($rows_orcamentos = mysqli_fetch_assoc($resultado_orcamentos)){ ?>
                    <tr>
                      <td><?php echo $rows_orcamentos['NrOrcSistema']; ?></td>
                      <td><?php echo $rows_orcamentos['Empresa']; ?></td>
                      <td><?php echo $rows_orcamentos['paciente']; ?></td>
                      <td><?php echo $rows_orcamentos['Convenio']; ?></td>
                      <td><?php echo $rows_orcamentos['Hospital']; ?></td>
                      <td><?php echo $rows_orcamentos['Material']; ?></td>
                      <td><?php echo $rows_orcamentos['VlrOrc']; ?></td>
                      <td><?php echo $rows_orcamentos['SitOrcamento']; ?></td>
                      <td>
                        <button type="button" class="btn btn-primary btn-sm" data-toggle="modal" data-target="#myModal<P><?php echo $rows_orcamentos['NrOrcSistema']; ?></P>">Visualizar</button>
                        
                        <button type="button" class="btn btn-warning btn-sm" data-toggle="modal" data-target="#exampleModal" data-whatever="<?php echo $rows_orcamentos['NrOrcSistema']; ?>" data-whatevernascimento="<?php echo date("d/m/y", strtotime($rows_orcamentos['nascimento']));?>" data-whateverstatus="<?php echo $rows_orcamentos['status']; ?>" data-whatevermatricula="<?php echo $rows_orcamentos['matricula']; ?>">
                          Editar
                      </td>
                    </tr>
                    <!-- Modal VISUALIZA -->
                    <div class="modal fade" id="myModal<P><?php echo $rows_orcamentos['NrOrcSistema']; ?></P>" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
                      <div class="modal-dialog" role="document">
                        <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 w-100 text-center" id="myModalLabel"><?php echo $rows_orcamentos['NrOrcSistema']; ?></h4>
                          </div>
                          <div class="modal-body">
                            <P>Matrícula: <?php echo $rows_orcamentos['matricula']; ?></P>
                            <P>Nascimento: <?php echo date("d/m/y", strtotime($rows_orcamentos['nascimento']));?></P>
                            <P>Situação: <?php echo $rows_orcamentos['status']; ?></P>
                          </div>
                        </div>
                      </div>
                    </div>
                    <!-- FIM Modal VISUALIZA -->
                  <?php } ?>
                </tbody>
               </table>
            </div>
          </div>
    </div>    






</body>
