<?php
 session_start();
 //Recibe Datos
 $STOCK_MIN=$_GET['STOCK_MIN'];
 $COD_INTERNO=$_GET['COD_INTERNO'];
 $COD_BARRA=$_GET['COD_BARRA'];
 $GLOSA=$_GET['GLOSA'];
 $PRECIO=$_GET['PRECIO'];
?>
<!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>

<TITLE>Agregar</TITLE>

<link rel="stylesheet" href="styles.css">
<script language="javascript">
function validar(form1){
 
 num = parseInt(document.form1.hdcan.value);
 can = parseInt(document.form1.CANTIDAD.value);
 if (document.form1.CANTIDAD.value.length < 1){
  document.form1.CANTIDAD.style.backgroundColor="#FFFFCC";
  document.form1.CANTIDAD.focus();  
  return (false);
 }
 if(isNaN(document.form1.CANTIDAD.value)==false){
  }else{
  window.alert("Ingrese un valor");
  document.form1.CANTIDAD.style.backgroundColor="#FFFFCC";
  document.form1.CANTIDAD.focus();  
  return (false);
 }
 if(can > num){
  //window.alert("No tenemos en Stock la cantidad Solicitada");
  document.form1.CANTIDAD.style.backgroundColor="#FFFFCC";
  document.form1.CANTIDAD.focus();  
  return (false);
 }else{  
  //window.alert("Tenemos en Stock la cantidad Solicitada");
  document.form1.STOCK_MIN.disabled=false;
  document.form1.COD_INTERNO.disabled=false;
  document.form1.COD_BARRA.disabled=false;
  document.form1.GLOSA.disabled=false;
  document.form1.PRECIO.disabled=false;
  stot=(document.form1.PRECIO.value * document.form1.CANTIDAD.value);
  document.form1.hdtot.value=stot;
  document.form1.action="agregacarro.php";
  document.form1.method="post";
  document.form1.submit(); 
 }
 
 
 return (true);
}
function cerrar(){
javascript:window.close();
}//cerrar
function validar2(){
 if (event.keyCode==13){
  validar();
 }
}
</script>

</HEAD>
<BODY onload="javascript:document.form1.CANTIDAD.focus();">
<TABLE height="100%" cellSpacing=0 cellPadding=0 width="100%" align=center 
border=0>
  <TBODY>
  <TR>
    <TD vAlign=center align=middle height="100%">
      <TABLE height=371 cellSpacing=0 cellPadding=0 width=648 border=0>
        <TBODY>
        <TR>
          <TD width="718" height=22>
            <TABLE height=22 cellSpacing=0 cellPadding=0 width="100%" 
              border=0><TBODY>
              <TR>
                <TD vAlign=top align=left width=24><A 
                  href="index.php"><IMG 
                  height=22 src="images/xc_left.gif" width=24 
                  border=0></A></TD>
                <TD vAlign=top align=left width="100%"><IMG height=22 
                  src="images/xc_center.gif" width="100%" 
                border=0></TD>
              <TD vAlign=top align=right width=24><IMG height=22 
                  src="images/xc_right.gif" width=24 
              border=0></TD></TR></TBODY></TABLE></TD></TR>
        <TR>
          <TD class=BottomTable vAlign=top 
          background=images/xc_stripes.gif height="100%">
            <TABLE class=IconsTable height=33 cellSpacing=0 cellPadding=0 
            width="100%" border=0>
              <TBODY>
              <TR>
                <TD height="32">&nbsp;</TD>
              </TR></TBODY></TABLE>
            <TABLE width="576" 
              border=0 align="center" cellPadding=0 cellSpacing=0>
              <TBODY>
              <TR>
                <TD width=52 height=8>&nbsp;</TD>
                <TD width="500" height=8 class="contentcell">
				<form id="form1" name="form1" method="post" onsubmit="return validar(this)" action="">
                  <table width="73%" cellpadding="0" cellspacing="0">
                      <tr>
                        <td colspan="2" scope="col"><div align="center"><strong><span class="MainMenuHead">Proceso de Venta </span></strong><br />
                          <br />
                        </div></td>
                        </tr>

                      <tr>
                        <td scope="row"><div align="right" class="Emphasize">Stock:</div></td>
                        <td scope="row"><label>
                          <div align="left">
                            <input name="STOCK_MIN" type="text" id="STOCK_MIN" value="<?php echo $STOCK_MIN ?>" disabled size="21" maxlength="20" />
                            <input name="hdcan" type="hidden" id="hdcan" value="<?php echo $STOCK_MIN ?>" />
                          </div>
                        </label></td>
                      </tr>
					  <tr>
                        <td width="11%" class="Emphasize" scope="row"><div align="right">Cod_interno:</div></td>
                        <td width="16%" scope="row"><div align="left">
                          <input name="COD_INTERNO" type="text" id="COD_INTERNO" disabled value="<?php echo $COD_INTERNO ?>" size="21" maxlength="20" />
                        </div></td>
                      </tr>
                      
                      <tr>
                        <td class="Emphasize" scope="row"><div align="right">Cod_barra:</div></td>
                        <td scope="row"><div align="left">
                          <input name="COD_BARRA" type="text" id="COD_BARRA" disabled value="<?php echo $COD_BARRA ?>" size="21" maxlength="20" />
                        </div></td>
                      </tr>
                      <tr>
                        <td class="Emphasize" scope="row"><div align="right"><strong>Glosa:</strong></div></td>
                        <td scope="row"><textarea name="GLOSA" cols="50" rows="5" disabled id="GLOSA"><?php echo $GLOSA ?>
</textarea></td>
                      </tr>
                      <tr>
                        <td class="Emphasize" scope="row"><div align="right"><strong>Precio:</strong></div></td>
                        <td scope="row"><div align="left">
                          <input name="PRECIO" type="text" id="PRECIO" disabled value="<?php echo $PRECIO ?>" size="11" maxlength="10" />
                        </div></td>
                      </tr>
                      <tr>
                        <td class="Emphasize" scope="row"><div align="right"><strong>Cantidad:</strong></div></td>
                        <td scope="row"><div align="left">
                          <input name="CANTIDAD" type="text" id="CANTIDAD" size="11" maxlength="10" onkeydown="validar2()" />
                          <span class="style5">(* Ingrese la cantidad a vender)</span> 
                          <input name="hdtot" type="hidden" id="hdtot" />
                        </div></td>
                      </tr>
                      <tr>
                        <td colspan="2" scope="row"><label>
                          <div align="center">
                            <input type="button" name="Submit" value="Agregar..." />
                            <input type="button" name="Submit2" value="Cancelar" onclick="cerrar()" />
                          </div>                          
                          </label></td>
                      </tr>
                      
                      <tr>
                        <th colspan="2" scope="row"><label></label></th>
                        </tr>
                    </table>
                </form>                </TD>
                <TD width=24 
      height=8>&nbsp;</TD></TR>
              <TR>
                <TD height=8 colspan="3">&nbsp;</TD>
                </TR>
              </TBODY></TABLE></TD></TR></TBODY></TABLE></TD></TR></TBODY>
</TABLE>
</BODY>
</HTML>