<?php require_once('topo.php');?>
<?php require_once('lateral.php');?>
      <!-- Right side column. Contains the navbar and content of the page -->
      <div class="content-wrapper">
        <!-- Content Header (Page header) -->
        <section class="content-header">
          <h1>
            Recebimentos
            <small>relatório de recebimentos cadastradas</small>
          </h1>
          <ol class="breadcrumb">
            <li><a href="index.php"><i class="fa fa-dashboard"></i> Home</a></li>
            <li><a href="relatorio_recebimentos_clientes.php">Recebimentos</a></li>
            <li class="active">Listagem</li>
          </ol>
        </section>

        <!-- Main content -->
        <section class="content">
          <div class="row">
            <div class="col-xs-12"><!-- /.box -->

              <div class="box">
                <div class="box-header">
                  <h3 class="box-title">Relatório de Recebimentos</h3>
                </div><!-- /.box-header -->
                <div class="box-body">
                  <table id="example1" class="table table-bordered table-striped">
                    <thead>
                      <tr>
                        <th style="cursor:pointer">Data Venda</th>
                        <th style="cursor:pointer">Cliente</th>
                        <th style="cursor:pointer">Vendas</th>                        
                        <th style="cursor:pointer">Pago</th>
                        <th style="cursor:pointer">À Receber</th> 
                      </tr>
                    </thead>
                    <tbody>
                    <?php
					$Seleciona = Seleciona("vendas", "", "ORDER BY datavenda DESC");
					while($linha = mysql_fetch_array($Seleciona)){
						$idvenda = $linha['idvenda'];
					
					//TOTAL VENDA					
					
				$selec = "select sum(valor_total_servico) AS soma FROM vendas_produtos WHERE idvenda='$idvenda'";
				$exec = mysql_query($selec, $conexao) or die(mysql_error());       
				while($areceberpago=mysql_fetch_array($exec)) {
				$ValorTotal = $areceberpago['soma'];	
				}					
					
					?>
                      <tr style="cursor:pointer" onclick="location.href='manutencao_vendas.php?idvenda=<?php echo $linha['idvenda'];?>';">
                        <td><?php echo InverteDataNovoSeparador($linha['datavenda'], "-", "/");?></td>
                        <td><?php echo $linha['idvenda'];?></td>                        
                        <td><?php echo $linha['nome'];?></td>

                        <td><?php echo "R$ " . number_format($ValorTotal, 2, ',', '.');?></td>
                        <td></td>                      
                      </tr>
                      <?php 
					  $ValorTotal = "";

					  }?>
                    </tbody>
                    <tfoot>
                      <tr>
                        <th style="cursor:pointer">Data Venda</th>
                        <th style="cursor:pointer">Cliente</th>
                        <th style="cursor:pointer">Vendas</th>                        
                        <th style="cursor:pointer">Pago</th>
                        <th style="cursor:pointer">À Receber</th>                        
                      </tr>
                    </tfoot>
                  </table>
                </div><!-- /.box-body -->
              </div><!-- /.box -->
            </div><!-- /.col -->
          </div><!-- /.row -->
        </section><!-- /.content -->
      </div><!-- /.content-wrapper -->
<?php require_once('rodape.php');?>