<?php
include ("conexion.php");
$folio=$_GET['folio'];

$con1="SELECT idPaquete,fechaSalida,expedientePaciente,nombrePaciente,doctor,montoTotal FROM salida WHERE idSalida='$folio'";
$res1=mysql_query($con1,$conex) or die ("No se realizo con1");
$idpaquete=mysql_result($res1,0,'idPaquete');
$fecha=mysql_result($res1,0,'fechaSalida');
$expediente=mysql_result($res1,0,'expedientePaciente');
$nombre=mysql_result($res1,0,'nombrePaciente');
$doctor=mysql_result($res1,0,'doctor');
$monto=mysql_result($res1,0,'montoTotal');

$con2="SELECT nompaquete FROM paquetes WHERE idPaquete='$idpaquete'";
$res2=mysql_query($con2,$conex) or die ("No se realizo con1");
$paquete=mysql_result($res2,0,'nompaquete');
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Ticket de Venta</title>
<link href="ticket_estilo.css" rel="stylesheet" type="text/css" />
<link href="ticket_estiloimpresion.css" rel="stylesheet" type="text/css" media="print">
<style type="text/css">
<!--
.Estilo2 {
	font-size: 18pt;
	color: #999999;
}
.Estilo1 {
	font-size: 9pt;
	color: #333333;
	font-weight:bold;
}
-->
</style>
<SCRIPT language="javascript"> 
function imprimir()
{ if ((navigator.appName == "Netscape")) { window.print() ; 
} 
else
{ var WebBrowser = '<OBJECT ID="WebBrowser1" WIDTH=0 HEIGHT=0 CLASSID="CLSID:8856F961-340A-11D0-A96B-00C04FD705A2"></OBJECT>'; 
document.body.insertAdjacentHTML('beforeEnd', WebBrowser); WebBrowser1.ExecWB(6, -1); WebBrowser1.outerHTML = "";
}
}

function imprSelec(nombre)
{
  var ficha = document.getElementById(nombre);
  var ventimp = window.open(' ', 'popimpr');
  ventimp.document.write( ficha.innerHTML );
  ventimp.document.close();
  ventimp.print( );
  ventimp.close();
}
</SCRIPT> 

</head>

<body >
<table width="800" border="0" align="center" cellpadding="0" cellspacing="0" bgcolor="#FFFFFF">
  <tr>
    <td><div id="banner"><img src="img/top02.jpg" width="800" height="100" /></div></td>
  </tr>
  </table>
  <table width="800" border="0" align="center" cellpadding="0" cellspacing="0" bgcolor="#FFFFFF">
  <tr>
    <td>
      <table width="600" border="0" align="center" cellpadding="0" cellspacing="0">
      <tr>
        <td><div align="center" ><span class="Estilo2">TICKET COPIA</span></div>
                                 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Folio: <span class="Estilo1"><?php echo $folio; ?></span>
          <table width="400" border="0" align="center" cellpadding="0" cellspacing="5">
  <tr>
    <td width="8%"><div id="noimprimible">
      <div align="right"><strong>Nombre:</strong></div>
    </div></td>
    <td colspan="3"><?php echo $nombre; ?></td>
    </tr>
  <tr>
    <td height="5">&nbsp;</td>
    <td width="39%"></td>
    <td width="11%"></td>
    <td width="42%"></td>
  </tr>
  <tr>
    <td><div id="noimprimible">
      <div align="right"><strong>Fecha:</strong></div>
    </div></td>
    <td><?php echo $fecha; ?></td>
    <td><div id="noimprimible">
      <div align="right"><strong>Expediente:</strong></div>
    </div></td>
    <td><?php echo $expediente; ?></td>
  </tr>
  <tr>
    <td><div id="noimprimible">
      <div align="right"><strong>Doctor:</strong></div>
    </div></td>
    <td colspan="3"><?php echo $doctor; ?></td>
    </tr>
  </table>
<table width="400" border="0" align="center" cellpadding="0" cellspacing="5">
  <tr>
    <td width="23" height="35">&nbsp;</td>
    <td colspan="3">&nbsp;</td>
  </tr>
  <tr>
    <td height="109" align="center" valign="top">1</td>
    <td colspan="2" valign="top"><strong>Paquete de tratamiento:</strong><p>&nbsp;&nbsp;&nbsp;<?php echo $paquete; ?></p></td>
    <td width="66" align="center" valign="top"><?php printf ("$%.2f", $monto); ?></td>
  </tr>
  <tr>
    <td colspan="3" valign="top">&nbsp;</td>
    <td align="center" valign="top"><?php printf ("$%.2f", $monto); ?></td>
  </tr>
</table>
<hr width="600" size="1" color="#999999" class="linea" id="noimprimible"></td>
      </tr>
      <tr>
        <td>
        <p id="segundahoja">
          <div align="center" id="seleccion"><span class="Estilo2">TICKET COPIA</span></div>
          <p id="noimprimible"><strong>DETALLE:</strong></p>
          
            <?php

echo "<div id='contenido_venta'>";
echo "<table border=0 align='center' cellpadding='2'>";
echo "<tr>";

echo "<td bgcolor='#FFFFFF'>";
echo "<strong>Entregado</strong>";
echo "</td>";
					
echo "<td>";
echo "<strong>Clave</strong>";
echo "</td>";
						
echo "<td>";
echo "<strong>Producto</strong>";
echo "</td>";
						
echo "<td>";
echo "<strong>Clasificaci&oacute;n</strong>";
echo "</td>";
						
echo "<td>";
echo "<strong>Presentaci&oacute;n</strong>";
echo "</td>";
						
echo "<td>";
echo "<strong>Cantidad</strong>";
echo "</td>";

echo "</tr>";
						
$cons3="SELECT idProducto,cantidad FROM contenido_salida WHERE idSalida='$folio'" ;
$res3=mysql_query($cons3,$conex) or die ("No se realizo con exito la consulta de contenido_salida");
$numero_filas3=mysql_num_rows($res3);
$numero_campos3= mysql_num_fields($res3);
while ($fila3=mysql_fetch_row($res3))
{				  
		echo "<tr>";
		
		//CLAVE
		echo "<td align='center'>";
		echo "<input type='checkbox'> ";
		echo "</td>";
		
		//CLAVE
		echo "<td >";
		echo $fila3[0];
		echo "</td>";
		//NOMBRE, DESCRIPCION, PRECIO
		$cons4="SELECT nombre,clasificacion,idPresentacion,precio FROM productos Where clave = '".$fila3[0]."'" ;
		$res4=mysql_query($cons4,$conex) or die ("No se realizo con exito la consulta CONS4");
		$nombre=mysql_result($res4,0,'nombre');
		$clasificacion=mysql_result($res4,0,'clasificacion');
		$idprese=mysql_result($res4,0,'idPresentacion');
		$precio=mysql_result($res4,0,'precio');
							
		echo "<td >";
		echo $nombre;
		echo "</td>";
							
		echo "<td >";
		echo $clasificacion;
		echo "</td>";
							
		$cons04="SELECT presentacion FROM presentaciones Where idPresentacion = '$idprese'" ;
		$res04=mysql_query($cons04,$conex) or die ("No se realizo con exito la consulta de la presentacion");
		$presen=mysql_result($res04,0,'presentacion');
							
		echo "<td >";
		echo $presen;
		echo "</td>";
							
		//CANTIDAD
		echo "<td align='center'>";
		echo $fila3[1];
		echo "</td>";
													
}//end while
						
echo "</tr>";
echo "</table>";
						
?>
          </p>          </td>
      </tr>
      <tr>
        <td>
        <div id="noimprimible">
        <table width="141" border="0" align="center" cellpadding="0" cellspacing="10">
          <tr>
            <td width="46" height="24"><form id="form1" name="form1" method="post" action="main.php">
              <input type="submit" name="button2" id="button2" value="Inicio" />
            </form>            </td>
            <td width="133"><form id="form2" name="form1" method="post" >
              <input type="button" name="button" id="button" value="Imprimir" onclick="imprSelec('seleccion')" />
            </form>              </td>
          </tr>
        </table>
        </div>
        </td>
      </tr>
    </table>    
    <br /></td>
  </tr>
  <tr>
    <td><div id="pie">
      <table width="99%" border="0" align="center" cellpadding="2" cellspacing="0">
        <tr>
          <td width="50%"><div align="left"><span class="style8">Universidad Cuauht&eacute;moc Plantel Aguascalientes</span></div></td>
          <td width="50%"><div align="right"><span class="style8">Departamento de Sistemas / </span><a href="mailto:des.sistemas@ucuauhtemoc.edu.mx"><span class="style8">Desarrollo</span></a></div></td>
        </tr>
      </table>
    </div></td>
  </tr>
</table>
</body>
</html>
