<?php
session_start();
if (isset($_SESSION['usuario'])){
$user=$_SESSION['usuario'];
}
else{
?>
<script>
location.href="index.php?errorusuario=3";
</script>
<?php
}

//sacar el tipo de usuario
include("conexion.php");

$cons="Select nombre,tipo,idClinica FROM usuarios Where idUsuario='$user'";
$res=mysql_query($cons,$conex) or die ("No se realizó la consulta en usuarios");
$nombreuser=mysql_result($res,0,'nombre');
$tipo=mysql_result($res,0,'tipo');
$clini=mysql_result($res,0,'idClinica');

//OPERACION SOBRE EL FOLIO DE LA VENTA
	if(isset($_GET['folio']))
	{
		$folio=$_GET['folio'];
		echo $folio;		
	}
	else
	{
		$cons2="SELECT max(idSalida) as folio FROM salida";
		$resul2=mysql_query($cons2,$conex) or die ("No se realizó la obtencion del maximo en salida");
		$fol=mysql_result($resul2,0,'folio');
		$folio=$fol + 1;
	}
	echo "<input name='folio' type='hidden' id='folio' value='".$folio."' size='5'>";
?>
<head>
<script src="prototype.js" language="javascript"></script>
<script src="ajax_orios.js" language="javascript"></script>
<title>Clinisys :.</title>
<link href="ucaestilos.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" language="JavaScript1.2" src="stm31.js"></script>
<script language="javascript" src="InnerDiv.js"></script>
<script language="javascript">
function listar(){
	I= 'miId';                          //---- id de la ventana
	N= 20;                              //---- posicion x
	n= 20;                              //---- posicion y
	e= 380;                            //---- ancho
	r= 600;                             //---- alto
	d= 'listaproductos.php';            //---- pagina de carga
	i= 'Listado de Productos';  		//---- texto de la barra
	v=null;                              //---- indica si utiliza CSS
	INNERDIV.newInnerDiv(I,N,n,e,r,d,i,v);
}
</script>
<style type="text/css">
<!--
body {
	background-color: #CCCCCC;
}
-->
</style>
<script type="text/javascript" src="ajax.js"></script>
<script type="text/javascript" src="ajax-dynamic-list.js"></script>
<script type="text/javascript" src="acc_calendar/acc_calendar.js"></script>

<script>
function cancelarventa()
{
	alert("La venta se ha cancelado");
}
function ejecutarventa()
{
	var foliodatos=document.getElementById('folio').value;
	alert("La venta se ha ejecutado, se generará recibo de compra, FOLIO: " + foliodatos);
}
</script>
<link href="ajaxestilosautocomplete.css" rel="stylesheet" type="text/css">
</head>

<body onLoad="abrirdatos()">
<table width="1000" border="0" align="center" cellpadding="0" cellspacing="0" bgcolor="#FFFFFF">
  <tr>
    <td bgcolor="#4E5977"><div align="left"><img src="img/top03.jpg" width="1000" height="90"></div></td>
  </tr>
  <tr>
    <td>
	<table width="1000" border="0" align="center">
      <tr>
	  <td width="3%"><img src="img/icon_security.jpg" width="22" height="22"></td>
        <td width="28%"><span class="style4">Operador: </span><span class="style5"><?php echo $nombreuser;?></span></td>
        <td width="69%">
		<?php 
		//if ($tipo =='user')
		//{
		$cons2="Select clinica FROM clinicas Where idClinica='$clini'";
		$res2=mysql_query($cons2,$conex) or die ("No se realizó la consulta de la clinica");
		$clinica=mysql_result($res2,0,'clinica');
		echo "<span class='style4'>Cl&iacute;nica: </span><span class='style5'>".$clinica."</span>";
		//}
		?>		</td>
        </tr>
    </table>
	<table width="1000" border="0" align="center">
      <tr>
        <td width="87%" height="20" bgcolor="#666666">
		<?php
				if ($tipo=='admin')
				{
			  		?>
          <script type="text/javascript" language="JavaScript1.2" src="menuadm.js"></script>
          <?php
			  	}
				else
				{
					
				}
			  ?>
		</td>
        <td width="13%" bgcolor="#666666" class="style8"><div align="center"><a href="cerrar.php"><span class="style6">Cerrar Sesión</span></a></div></td>
      </tr>
    </table>
      <table width="100%" border="0" cellspacing="0" cellpadding="0">
      <tr>
        <td width="12%" valign="top"><br />
		
		  <table width="900" border="0" align="center" cellpadding="0" cellspacing="0">
            <tr>
              <td class="style7">PUNTO DE VENTA</td>
            </tr>
          </table>
		  <form id="formventa" method="post" action="svventa.php">
		  <table width="890" border="1" align="center" cellpadding="0" cellspacing="2">
            <tr>
              <td>
			  
			  <table width="100%" border="0" cellpadding="0" cellspacing="5" bgcolor="#CCCCCC">
                  <tr>
                    <td width="72%"><table width="100%" border="0" cellspacing="5" cellpadding="0">
                      <tr>
                        <td width="105" height="25"><div align="right"><span class="style4">Fecha: </span></div></td>
                        <td width="285"><span class="style4">
                        <label for="fecha"><span class="fecha rang10"></span>
                <input name="fecha" type="text" class="fecha rang10" id="fecha" value="<?php echo date("Y-m-d"); ?>" size="10" maxlength="10" />
              </label>
                        </span></td>
                        <td width="90" ><div align="right"><span class="style4">Folio: </span></div></td>
                        <td width="367"><span class="style3"><?php echo $folio;?>
                          
                        </span>
						<script>
						//total();
						</script>						<span class="style3">
						<input name="clinica" type="hidden" id="clinica" value="<?php echo $clini;?>" size="5">
						</span></td>
                      </tr>
                      <tr>
                        <td><div align="right"><span class="style4">Expediente: </span></div></td>
                        <td><input name="expediente" type="text" class="cuadrotexto" id="expediente" onKeyUp="javascript:paciente()" size="10" maxlength="15"></td>
                        <td><div align="right"><span class="style4">Paciente: </span></div></td>
                        <td>
                          <div id="nombrepaciente">
                        </div>
						</td>
                      </tr>
                      <tr>
                        <td><div align="right"><span class="style4">Clave Doctor: </span></div></td>
                        <td ><input name="clavedoctor" type="text" class="cuadrotexto" id="clavedoctor" onKeyUp="javascript:doctor()" size="10" maxlength="15"></td>
                        <td><div align="right"><span class="style4">Doctor: </span></div></td>
						<td><div id="nombredoctor"> </div></td>
                      </tr>
                    </table></td>
                    </tr>
              </table>
			  
			  </td>
            </tr>
            <tr>
              <td>
                <table width="100%" border="0" cellpadding="0" cellspacing="0" bgcolor="#F2F3F4">
                  <tr>
                    <td width="43%" bgcolor="#CCE6FF"><table width="100%" border="0" cellpadding="0" cellspacing="5">
                      <tr>
                        <td width="75" class="style4">Producto: </td>
                        <td width="289">
                        <!--<input name="clave" type="text" class="cuadrotexto" id="clave" value="" size="10">-->
                        <input type="text" class="cuadrotexto" id="nombre" name="nombre" onKeyUp="ajax_showOptions(this,'getCountriesByLetters',event)" value="" size="40" autocomplete="off">	
					<input name="clave" id="clave" type="hidden" class="cuadrotexto">
                    
                          <img src="img/button_view.jpg" alt="Ver listado" width="15" height="16" onClick="listar()" style="CURSOR: hand" align="absmiddle"></td>
						</tr>
                    </table></td>
                    <td width="57%"><table width="268" border="0" align="right" cellpadding="0" cellspacing="5" bgcolor="#CCE6FF">
                      <tr>
                        <td width="63" class="style4"><div align="right">Paquete: </div></td>
                        <td width="190"><?php
					
					include ("conexion.php");
					$cons="SELECT * FROM paquetes";
					$res=mysql_query($cons,$conex) or die ("No se pudo consultar las clinicas");
					  echo "<select name='paquete' class='cuadrotexto'>";
                      While ($campo=mysql_fetch_assoc($res)) 
	    				{
						  echo "<option value=".$campo['idPaquete']." >".$campo['nompaquete']."</option>"; 
 						}
                      echo "</select>";
					  
                    ?>
          <input name="addpaquete2" type="button" class="boton2" id="addpaquete2" onClick="javascript:addpaquete()" value="Agregar">						</td>
                      </tr>
                    </table></td>
                  </tr>
                  <tr>
                    <td bgcolor="#CCE6FF"><table width="100%" border="0" cellpadding="0" cellspacing="5">
                      <tr>
                        <td width="74" class="style4">Cantidad: </td>
                        <td width="290">
                        	<input name="cantidad" type="text" class="cuadrotexto" id="cantidad" size="5" maxlength="10" onKeyPress="if (event.keyCode &lt; 45 || event.keyCode &gt; 57) event.returnValue = false;">
                            <input name="agregar2" type="button" class="boton2" value="Agregar" onClick="javascript:agregar()" />                        </td>
                      </tr>
                    </table></td>
                    <td>&nbsp;</td>
                  </tr>
                </table>
                <p align="center">
                <div id="tablacontenido"></div>
                </p></td>
            </tr>
          </table>
		  <table width="790" border="0" align="center" cellpadding="0" cellspacing="0">
            <tr>
              <td width="382"><input name="Submit3" type="button" class="boton1" value="Cancelar venta" onClick="javascript:cancelarventa()"></td>
              <td width="408"><div align="right">
                <input name="Submit" type="button" class="boton1" value="Ejecutar Venta" onClick="javascript:ejecutarventa()">
              </div></td>
            </tr>
          </table>
		  </form>
		  
		  <br /></td>
        </tr>
      <tr>
        <td height="17" valign="middle" bgcolor="#4E5B7B"><div align="center"><span class="style8">Universidad Cuauht&eacute;moc Plantel Aguascalientes </span></div></td>
        </tr>
    </table></td>
  </tr>
</table>
</body>
</html>
