<!DOCTYPE html>
<html lang="es">
<head>
	<meta charset="UTF-8">
	<title>Lista Informes Citologicos</title>
	<link rel="stylesheet" type="text/css" href="../bootstrap/css/bootstrap.min.css">
  	<script src="../js/jquery.min.js"></script>
  	<script src="../bootstrap/js/bootstrap.min.js"></script>
  	<link href="../css/ionicons.css" rel="stylesheet" type="text/css">
</head>
<body>
	<div class="table-responsive">
	<?php
		$fechaini = $_GET['fechaini'];
		$fechafin =  $_GET['fechafin'];

		include_once('../php_conexion.php');
		include_once('../Class/funciones.php');
		if (!$conexion) {
		    die('Could not connect: ' . mysqli_error($con));
		}

		$sql="SELECT codpaciente,idpaciente,apepaterno,apematerno,nombres,fecha,muestra,precioexamen,importe FROM caja c JOIN pacientes p ON c.idpaciente=p.id AND c.fecha>='$fechaini' AND c.fecha<='$fechafin' ORDER BY c.id DESC";
		//$sql="SELECT codpaciente,idpaciente,apepaterno,apematerno,nombres,fecha,muestra,precioexamen,importe FROM caja c JOIN pacientes p ON c.idpaciente=p.id ORDER BY c.id DESC";

		$result = mysqli_query($conexion,$sql);

		echo "<table class='table table-hover table-sm btn-table'>
		<tr><td colspan='7'><a href='reportexcel/cajaexcel.php?fechaini=".$fechaini."&fechafin=".$fechafin."' class='btn btn-secondary btn-sm active' aria-pressed='true'><span class='ion-ios-list-outline'></span> Excel</a><button class='btn btn-secondary btn-sm active' type='button' aria-pressed='true'><span class='ion-ios-copy-outline'></span> PDF</button></td></tr>
		<tr class='bg-primary'>
		<th>COD. PAC.</th>
		<th>NOMBRES</th>
		<th>FECHA REGISTRO</th>
		<th>MUESTRA</th>
		<th>PRECIO EXAMEN</th>
		<th>IMPORTE</th>
		</tr>";
		while($row = mysqli_fetch_array($result)) {
		    echo "<tr>";
		    echo "<td  style='font-size: 18px; color: #FF0000; font-weight: bold;'>" . $row['codpaciente'] . "</td>";
		    echo "<td>" . $row['apepaterno'] . " ".$row['apematerno']." ".$row['nombres']."</td>";
		    echo "<td>" . $row['fecha'] . "</td>";
		    echo "<td>" . $row['muestra']. "</td>";
		    echo "<td> S/. " . sprintf("%01.2f",$row['precioexamen']). "</td>";
		    //echo "<td> S/. " . sprintf("%01.2f",($row['precioexamen']-$row['acumulado'])) . "</td>";
		    echo "<td> S/. " . sprintf("%01.2f",$row['importe']) . "</td>";
		    echo "</tr>" ;
		}
		echo "</table>";
	?>
	</div>
	<?php mysqli_close($conexion); ?>
</body>
</html>