<?php
//==================================================
include ("conexion.php");

//===========ELIMINAR PRODUCTO DE PAQUETE=======================================
if (isset($_GET['nompac']))
{
	$tipousuario=$_GET['tipousuario'];
	$nombre=$_GET['nompac'];
	
	echo "<table align='center' cellpadding='2' class='tablaBordes' width='100%'>";
	echo "<tr class='tablaCabecera' align='center'>";
	
	echo "<td>";
	echo "Expediente";
	echo "</td>";
	
	echo "<td>";
	echo "Fecha Alta";
	echo "</td>";
	
	echo "<td>";
	echo "Nombre";
	echo "</td>";
	
	
	echo "<td>";
	echo "Tipo de paciente";
	echo "</td>";
	
	echo "<td>";
	echo "Estado";
	echo "</td>";
	
	echo "<td>";
	echo "Modificar";
	echo "</td>";
	
	if($tipousuario != "caja")
	{
	echo "<td>";
	echo "Eliminar";
	echo "</td>";
	}
	
	
	echo "</tr>";
	
	$cons="SELECT CvePaciente,NomPaciente,idTipo,estado,fechaAlta FROM pacientes_odontopediatria WHERE NomPaciente like '%$nombre%' ORDER BY NomPaciente" ;
	$res=mysql_query($cons,$conex) or die ("No se realizo con exito la consulta de pacientes");
	while ($fila=mysql_fetch_row($res))
	{				  
			 
		echo "<tr>";
		
		echo "<td class='style1' align='center'>";
		echo $fila[0];
		echo "</td>";
		
		echo "<td class='style1'>";
		echo $fila[4];
		echo "</td>";
		
		echo "<td class='style1'>";
		echo $fila[1];
		echo "</td>";
		
		//tipo 
		$cons2="SELECT * FROM tipo_pacientes WHERE idTipo='$fila[2]'";
		$res2=mysql_query($cons2,$conex) or die ("No se pudo consultar");
		$tipopac=mysql_result($res2,0,'tipo');
		echo "<td class='style1'>";
		echo $tipopac;
		echo "</td>";
		
		echo "<td class='style1'>";
		echo $fila[3];
		echo "</td>";
		
		//Editar
		echo "<td class='style4'align='center'>";
		if($tipousuario != "caja")
		{
			echo "<a href='main.php?a=4752&expediente=".$fila[0]."'> <img src='img/icon_edit.jpg' border='0' ALT='Editar paciente'> </a>";
			
			echo "</td>";
			
			
			//Eliminar
			echo "<td align='center'>";
			echo "<a href='deletepacienteodontopediatria.php?expediente="; echo $fila[0]; echo "'> <img src='img/icon_delete.jpg' border='0' ALT='Eliminar paciente'> </a>";
		}
		else
		{echo "N/A";}
		
		echo "</td>";
		echo "</tr>";
	}
	echo "</table>";
}//END

//=======================>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>><

if (isset($_GET['expedi']))
{
	$tipousuario=$_GET['tipousuario'];
	$expedi=$_GET['expedi'];
	
	echo "<table align='center' cellpadding='2' class='tablaBordes' width='100%'>";
	echo "<tr class='tablaCabecera' align='center'>";
	
	echo "<td>";
	echo "Expediente";
	echo "</td>";
	
	echo "<td>";
	echo "Fecha Alta";
	echo "</td>";
	
	echo "<td>";
	echo "Nombre";
	echo "</td>";
	
	
	echo "<td>";
	echo "Tipo de paciente";
	echo "</td>";
	
	echo "<td>";
	echo "Estado";
	echo "</td>";
	
	echo "<td>";
	echo "Modificar";
	echo "</td>";

	if($tipousuario != "caja")
	{
	echo "<td>";
	echo "Eliminar";
	echo "</td>";
	}	
	
	echo "</tr>";
	
	$cons="SELECT CvePaciente,NomPaciente,idTipo,estado,fechaAlta FROM pacientes_odontopediatria WHERE CvePaciente='$expedi' ORDER BY NomPaciente" ;
	$res=mysql_query($cons,$conex) or die ("No se realizo con exito la consulta de pacientes");
	while ($fila=mysql_fetch_row($res))
	{				  
			 
		echo "<tr>";
		
		echo "<td class='style1' align='center'>";
		echo $fila[0];
		echo "</td>";
		
		echo "<td class='style1'>";
		echo $fila[4];
		echo "</td>";
		
		echo "<td class='style1'>";
		echo $fila[1];
		echo "</td>";
		
		//tipo 
		$cons2="SELECT * FROM tipo_pacientes WHERE idTipo='$fila[2]'";
		$res2=mysql_query($cons2,$conex) or die ("No se pudo consultar");
		$tipopac=mysql_result($res2,0,'tipo');
		echo "<td class='style1'>";
		echo $tipopac;
		echo "</td>";
		
		echo "<td class='style1'>";
		echo $fila[3];
		echo "</td>";
		
		//Editar
		echo "<td class='style4'align='center'>";
		if($tipousuario != "caja")
		{
			echo "<a href='main.php?a=4752&expediente=".$fila[0]."'> <img src='img/icon_edit.jpg' border='0' ALT='Editar paciente'> </a>";
			echo "</td>";
			
			
			//Eliminar
			echo "<td align='center'>";
			
			echo "<a href='deletepacienteodontopediatria.php?expediente="; echo $fila[0]; echo "'> <img src='img/icon_delete.jpg' border='0' ALT='Eliminar paciente'> </a>";
		}
		else
		{echo "N/A";}

		echo "</td>";
		echo "</tr>";
	}
	echo "</table>";
}//END

//===CERRAR CONEXION
mysql_close($conex);
		

?>
