<!DOCTYPE html>
<html lang="en">

<?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");
    }
?>


<head>

  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
  <meta name="description" content="Controle SCA">
  <meta name="author" content="Fabio Freitas">

  <title>SCA - Acompanhamento de Orçamentos</title>

  <!-- Bootstrap core CSS -->
  <link href="../vendor/bootstrap/css/bootstrap.min.css" rel="stylesheet">
  <!--<link href="vendor/bootstrap/css/bootstrap.min.css" rel="stylesheet">-->

  <!-- Custom styles for this template -->
  <link href="../css/simple-sidebar.css" rel="stylesheet">

</head>

<body>

  <div class="d-flex" id="wrapper">

    <!-- Sidebar -->
    <div class="bg-light border-right" id="sidebar-wrapper">
      <div class="sidebar-heading">SCA - Orçamentos </div>
      <div class="list-group list-group-flush">
        <a href="#" class="list-group-item list-group-item-action bg-light">Dashboard</a>
        <a href="apontorcamento.php" class="list-group-item list-group-item-action bg-light">Apontamentos</a>
        <a href="#" class="list-group-item list-group-item-action bg-light">Workflow</a>
        <!--<a href="#" class="list-group-item list-group-item-action bg-light">Events</a>
        <a href="#" class="list-group-item list-group-item-action bg-light">Profile</a>
        <a href="#" class="list-group-item list-group-item-action bg-light">Status</a> -->
      </div>
    </div>
    <!-- /#sidebar-wrapper -->

    <!-- Page Content -->
    <div id="page-content-wrapper">

      <nav class="navbar navbar-expand-lg navbar-light bg-light border-bottom">
        <button class="btn btn-primary" id="menu-toggle">Ocultar Menu</button>

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

        <div class="collapse navbar-collapse" id="navbarSupportedContent">
          <ul class="navbar-nav ml-auto mt-2 mt-lg-0">
            <li class="nav-item active">
              <a class="nav-link" href="#">Home <span class="sr-only">(current)</span></a>
            </li>
            <li class="nav-item">
              <a class="nav-link" href="#">Link</a>
            </li>
           <!-- <li class="nav-item dropdown">
              <a class="nav-link dropdown-toggle" href="#" id="navbarDropdown" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
                Dropdown
              </a>
              <div class="dropdown-menu dropdown-menu-right" aria-labelledby="navbarDropdown">
                <a class="dropdown-item" href="#">Action</a>
                <a class="dropdown-item" href="#">Another action</a>
                <div class="dropdown-divider"></div>
                <a class="dropdown-item" href="#">Something else here</a>
              </div> 
            </li>-->
          </ul>
        </div>
      </nav>

      <div class="container-fluid">
        <h1 class="mt-4">Orçamentos em Pós-Cirúrgico</h1>
        
        <?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();}


                $result= mysqli_query($connect, "SELECT *,TIMESTAMPDIFF(DAY,`dtAprovacao`,NOW()) AS Dias FROM tborcamentocirurgia WHERE motivoRepro = 'POS CIRURGICO' ORDER BY cliente");
            ?>

             <div style="margin-top: 2rem">    
                <div class="row mx-5"> 
               <!-- <div class="container"> -->
                    <!--<h4 class="page-header">Veículos Cadastrados</h4> --> 
                    <div class="table-responsive">
                            <!--<table style="font-size: 9px;" class="table table-striped table-bordered table-hover table-condensed"> -->
                            <table style="font-size: 10px; overflow: auto; font-color:#0000FF; " class="table table-striped table-responsive-md btn-table table-hover table-bordered">
                                <thead class="table-info">
                                    <tr>
                                       <!-- <th>Id</th> -->
                                        <th>Orç.</th>
                                        <th>Dt.Orçamento</th>
                                        <th>Dt.Cirurg</th>
                                        <th>Dt.Aprov.</th>
                                        <th>Cliente</th>
                                        <th>Hospital</th>
                                        <th>Médico</th>
                                        <th>Convênio</th>
                                        <th>Paciente</th>
                                        <th>R$ Orçado</th>
                                        <th>Dias</th>

                                    </tr>
                                </thead>
                                <?php while($rows = mysqli_fetch_array($result)): ?>
                                <tr>
                                   <!-- <td style="width: 30px;"><?php echo $rows['id']; ?></td> -->
                                    <!--<td style="text-align: center;vertical-align:middle"><?php echo date ("d/m/y", strtotime($rows['data'])); ?></td> -->
                                    <td style="text-align: center;vertical-align:middle"><?php echo $rows['nrorc']; ?></td>
                                    <td style="text-align: center;vertical-align:middle"><?php echo date("d/m/y",strtotime($rows['dtOrcamento'])); ?></td>
                                    <td style="text-align: center;vertical-align:middle"><?php echo date("d/m/y",strtotime($rows['dtCirurgia'])); ?></td>
                                    <td style="text-align: center;vertical-align:middle"><?php echo date("d/m/y",strtotime($rows['dtAprovacao'])); ?></td>
                                    <td style="text-align: center;vertical-align:middle"><?php echo $rows['cliente']; ?></td>
                                    <td style="text-align: center;vertical-align:middle"><?php echo $rows['hospital']; ?></td>
                                    <td style="text-align: center;vertical-align:middle"><?php echo $rows['medico']; ?></td>
                                    <td style="text-align: center;vertical-align:middle"><?php echo $rows['planoSaude']; ?></td>
                                    <td style="text-align: center;vertical-align:middle"><?php echo $rows['paciente']; ?></td>
                                    <td style="text-align: right;vertical-align:middle"><?php echo number_format(($rows['vlrOrcado']),2, ',', '.'); ?></td>
                                    <td style="text-align: center;vertical-align:middle"><?php echo $rows['Dias']; ?></td>
                                </tr>
                                <?php endwhile; ?>
                            </table>
                           
                    </div>
                </div>
          </div>



      </div>
    </div>
    <!-- /#page-content-wrapper -->

  </div>
  <!-- /#wrapper -->

  <!-- Bootstrap core JavaScript -->
  <script src="../vendor/jquery/jquery.min.js"></script>
  <script src="../vendor/bootstrap/js/bootstrap.bundle.min.js"></script>

  <!-- Menu Toggle Script -->
  <script>
    $("#menu-toggle").click(function(e) {
      e.preventDefault();
      $("#wrapper").toggleClass("toggled");
    });
  </script>

</body>

</html>

