Este es todo mi codigo, asi lo llevo ahora
Código PHP:
<div class="col-md-12">
<div class="widget">
<header class="widget-header">
<h4 class="widget-title">Reporte de Ventas</h4>
</header><!-- .widget-header -->
<hr class="widget-separator">
<div class="widget-body">
<form action="cashier_report.php" method="get" class="form-horizontal">
<center><strong>De : <input type="text" style="width: 223px; padding:14px;" name="d1" class="tcal" value="" placeholder="mm/dd/aaaa" /> A: <input type="text" style="width: 223px; padding:14px;" name="d2" class="tcal" value="" placeholder="mm/dd/aaaa" />
<select name="cashier" class="form-horizontal" data-plugin="select2" class="tcal" value="">
<option></option>
<?php
include('config/connect.php');
$result = $db->prepare("SELECT * FROM loggeous");
$result->bindParam(':userid', $res);
$result->execute();
for($i=0; $row = $result->fetch(); $i++){
?>
<option><?php echo $row['nombre']; ?></option>
<?php
}
?>
</select>
<button class="btn btn-info" style="width: 123px; height:50px; margin-top:-8px;margin-left:8px;" type="submit"> Ver Reporte</button>
<a href="cashier_report.php?d1=0&d2=0&cashier="><button class="btn btn-danger" style="width: 145px; height:50px; margin-top:-8px;margin-left:8px;"> Limpiar Reporte</button></a>
</strong></center>
</form>
<div class="content" id="content">
<div style="font-weight:bold; text-align:center;font-size:14px;margin-bottom: 15px;">
Reporte Ventas de <?php echo $_GET['d1'] ?> a <?php echo $_GET['d2'] ?> del Cajero: <?php echo $_GET['cashier'] ?>
</div>
<div class="table-responsive">
<table class="table table-bordered table-hover table-striped table-responsive" data-plugin="DataTable" id="resultTable" style="text-align: left;" cellspacing="0" width="100%">
<thead>
<tr>
<th width="10%"> ID Trans. </th>
<th width="10%"> Fecha Trans. </th>
<th width="10%"> Nombre Cliente </th>
<th width="10%"> Num de Boleta </th>
<th width="10%"> Cantidad </th>
<th width="10%"> Ganancia </th>
</tr>
</thead>
<tbody>
<?php
include('config/connect.php');
$d1=$_GET['d1'];
$d2=$_GET['d2'];
$cashier=$_GET['cashier'];
$result = $db->prepare("SELECT * FROM sales WHERE date BETWEEN :a AND :b AND :c ORDER by transaction_id DESC ");
$result->bindParam(':a', $d1);
$result->bindParam(':b', $d2);
$result->bindParam(':c', $cashier);
$result->execute();
for($i=0; $row = $result->fetch(); $i++){
?>
<tr class="record">
<td>STI-00<?php echo $row['transaction_id']; ?></td>
<td><?php echo $row['date']; ?></td>
<td><?php echo $row['name']; ?></td>
<td><?php echo $row['invoice_number']; ?></td>
<td style="text-align:right"><?php echo $row['amount']; ?></td>
<td style="text-align:right">
<?php echo $row['profit']; ?></td>
</tr>
<?php
}
?>
</tbody>
<thead>
<tr>
<th colspan="4" style="border-top:1px solid #999999" ><p align="left"> Total: </th>
<th colspan="1" style="border-top:1px solid #999999"> <p align="right">$
<?php
function formatMoney($number, $fractional=false) {
if ($fractional) {
$number = sprintf('%.2f', $number);
}
while (true) {
$replaced = preg_replace('/(-?\d+)(\d\d\d)/', '$1,$2', $number);
if ($replaced != $number) {
$number = $replaced;
} else {
break;
}
}
return $number;
}
$d1=$_GET['d1'];
$d2=$_GET['d2'];
$results = $db->prepare("SELECT sum(amount) FROM sales WHERE date BETWEEN :a AND :b");
$results->bindParam(':a', $d1);
$results->bindParam(':b', $d2);
$results->execute();
for($i=0; $rows = $results->fetch(); $i++){
$dsdsd=$rows['sum(amount)'];
echo formatMoney($dsdsd, true);
}
?>
</th>
<th colspan="1" style="border-top:1px solid #999999"> <p align="right">$
<?php
$resultia = $db->prepare("SELECT sum(profit) FROM sales WHERE date BETWEEN :c AND :d");
$resultia->bindParam(':c', $d1);
$resultia->bindParam(':d', $d2);
$resultia->execute();
for($i=0; $cxz = $resultia->fetch(); $i++){
$zxc=$cxz['sum(profit)'];
echo formatMoney($zxc, true);
}
?>
</th>
</tr>
</thead>
</table>
</div>
</div>