<!DOCTYPE html>
<html lang="en">
<?php
Include("../includes/con_cliente.php");
 require_once('../includes/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_alunos = "SELECT `empresa`, sum(`valor`) as valor , count(`documento`) as titulos FROM `crm_processo_fatura_titulos`GROUP BY empresa ORDER BY valor DESC";
    $resultado_alunos = mysqli_query($con, $result_alunos);



 ?>


<head>
    <title>SCA - Módulo CRM</title>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">

    <link href="https://fonts.googleapis.com/css?family=Poppins:300,400,500,600,700,800,900" rel="stylesheet">
    
    <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css">
    <link rel="stylesheet" href="css/style.css">
  </head>
  <body>
    
    <div class="wrapper d-flex align-items-stretch">
      <nav id="sidebar" class="active">
        <h1><a href="index.html" class="logo">CRM</a></h1>
        <ul class="list-unstyled components mb-5">
          <li class="active">
           <a href="#" data-toggle="modal" data-target="#myModalcad"><span class="fa fa-legal"></span> Nova Fatura</a> 

           <!-- <button type="button" class="btn btn-xs btn-success btn-sm" data-toggle="modal" data-target="#myModalcad">Novo</button>-->

          </li>
         <!-- <li>
              <a href="#"><span class="fa fa-briefcase"></span> Vales</a>
          </li>
          <li>
            <a href="#"><span class="fa fa-legal"></span> Administração</a>
          </li>
          <li>
            <a href="#"><span class="fa fa-line-chart"></span> Dashboard</a>
          </li> -->
          <li>
            <a href="fatura01.php"><span class="fa fa-reply-all"></span> Voltar</a>
          </li>
        </ul>

        <div class="footer">
          <p>
            Copyright &copy;<script>document.write(new Date().getFullYear());</script> All rights reserved - Fábio Freitas <a href="https://colorlib.com" target="_blank">Colorlib.com</a>
          </p>
        </div>
      </nav>


       

     
        <!-- Page Content  -->
      <div id="content" class="p-4 p-md-5">

      <!--  <nav class="navbar navbar-expand-lg navbar-light bg-light">
          <div class="container-fluid">

            <button type="button" id="sidebarCollapse" class="btn btn-primary">
              <i class="fa fa-bars"></i>
              <span class="sr-only">Toggle Menu</span>
            </button>
            

            
          </div>
        </nav> -->

        <h2 class="mb-4">Faturas em Aberto (Grupo) </h2>

        <div class="container">
          <div class="table-responsive-xl">
            <!--<table class="table table-sm"> -->
            <table style="overflow: auto;" class="table table-striped table-responsive-md btn-table table-hover table-bordered">
              <thead>
                <tr class="info">
                  <th style="text-align: center;vertical-align:middle">Empresa</th>
                  <th style="text-align: center;vertical-align:middle">Valor em Aberto</th>
                  <th style="text-align: center;vertical-align:middle">Titulos</th>
                  
                </tr>
              </thead>
              <tbody>
                <?php while($rows_alunos = mysqli_fetch_assoc($resultado_alunos)){ ?>
                  <!--<tr onclick="location.href = 'detalheprocesso.php?id=<?php echo $rows_alunos['id']; ?>'" style="cursor: hand;"> -->
                  <tr>
                    <td style="text-align: center;vertical-align:middle"><?php echo $rows_alunos['empresa']; ?></td>
                    <td style="text-align: right;vertical-align:middle"><?php echo number_format(($rows_alunos['valor']),2, ',', '.'); ?></td>
                    <td style="text-align: center;vertical-align:middle"><?php echo number_format(($rows_alunos['titulos']),0, ',', '.'); ?></td>
                    
                  </tr>
                <?php } ?>
              </tbody>
             </table>
          </div>
      </div> 
        
      </div>
    </div>

    <!-- Modal para alteração do contrato -->

   
    <script src="js/jquery.min.js"></script>
    <script src="js/popper.js"></script>
    <script src="js/bootstrap.min.js"></script>
    <script src="js/main.js"></script>
    


  </body>
</html>
