<!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'];
		$idempresa =  $_GET['idempresa'];
		$idexamen =  $_GET['idexamen'];


		if ($idempresa!="all") {
			$conempresa=" AND idempresa='$idempresa'";
		}else{
			$conempresa="";
		}
		if ($idexamen!="all") {
			$conexamen=" AND idexamen='$idexamen'";
		}else{
			$conexamen="";
		}

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

		$sql="SELECT * FROM reportepacientes WHERE fechareg>='$fechaini' AND fechareg<='$fechafin' ".$conempresa." ".$conexamen." ORDER BY id DESC";
		$result = mysqli_query($conexion,$sql);

		echo "<table class='table table-hover table-sm btn-table'>
		<tr class='bg-primary'>
		<th>Cod. Pac.</th>
		<th>Num. Doc.</th>
		<th>Nombre</th>
		<th>Edad</th>
		<th>Muestra</th>
		<th>Telefono</th>
		<th>Fecha recepcion</th>
		<th>Fecha entrega</th>
		<th>Precio</th>
		<th>A cuenta</th>
		<th>Saldo</th>
		<th>Cancelado?</th>
		<th>estado</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['numdoc']."</td>";
		    echo "<td>" . $row['apepaterno'] . " ".$row['apematerno']." ".$row['nombres']."</td>";
		    echo "<td>" . $row['edad'] . "</td>";
		    echo "<td>" . $row['muestra']. "</td>";
		    echo "<td>" . $row['telefono']."</td>";
		    echo "<td>" . $row['fechareg']."</td>";
		    echo "<td>" . $row['fechaentrega']."</td>";
		    echo "<td> S/. " . sprintf("%01.2f",$row['precioexamen']). "</td>";
		    echo "<td> S/. " . sprintf("%01.2f",$row['acuenta']) . "</td>";
		    echo "<td> S/. " . sprintf("%01.2f",($row['precioexamen']-$row['acuenta'])) . "</td>";
		    if ($row['estadocuenta']=="x") {
		    	$estadocuenta="Cancelado";
		    }else{
		    	$estadocuenta="";
		    }
		    echo "<td>" . $estadocuenta ."</td>";
		    echo "<td>" . $row['estado']."</td>";
		    echo "</tr>" ;
		}
		echo "</table>";
	?>
	</div>
	<?php mysqli_close($conexion); ?>
</body>
</html>