<?php
 
session_start();
$com = "A";
include("DMMYSQLG.php");
include("DSA3000.php");
include("DMMYSQLG.php");
include("DF30000.inc");

require_once("DF80000.php");
require_once("DFMOVCAP.inc");
require_once("DFJQUERY.inc");
require_once("DFSELMAN.inc");
?>
<html>
<head>
<title>Orden de compra</title>
<link rel="stylesheet" href="css/estilo1.css" type="text/css"/>
<link rel="stylesheet" href="DSSTYLESCOM.css" type="text/css"/>
<script type="text/javascript" language="JavaScript1.2" src="DSSCRIPT.js"></script>

<script language="javascript">
function cambiaImagen(idExa,idImg){
	var objImg=document.getElementById(idImg);
	var objExa=document.getElementById(idExa);
	objImg.src=objExa.value;	
}

$(document).ready(function(){
	$('#cla_rec').click(function(){
		loadOnLayer({				
			action:'DYCLAREC.php',
			idLayer:'divClaRec',			
			width:'auto',
			height:'200px'
		},{
			idRetObjCve:'cla_rec',
			idRetObjIds:'id_cla_rec',			
			iniSel:document.getElementById('id_cla_rec').value		
		});
		
	});
	function formatItem(row) {
		return " (<strong>" + row[1] + "</strong>)"+row[0];
	}
	var pagRes='DYAUTRESE.php';
	var idObjDes='des_rec';
	var idObjCve='id_ope';
	var nomObjRad='tip_bus_ope';
	$("#"+idObjDes).autocomplete(pagRes,{
		minChars: 1,                 //Caracteres Minimos antes de autocompletar
		max:20,                      //maximo de resultados mostrados, se manda como limit en autosugestion
		cacheLength: 0,
		delay: 200,                  //Retardo de autocompletar 
		width: 500,                  //ancho del cuadro de despliegue
		highlight: false,            //Resalta letras coincidentes
		autoFill: false,             //autocompleta en texto la posible palabra
		scroll: true,				 //si cuadro tiene barra scroll
		scrollHeight: 100,           //alto del cuadro para el scroll
		formatItem:formatItem,	     //formato de presentacion de las posibles busquedas
		extraParams:{typeRequest:'ac',tipBus:'d',cr:'ALLREC'}  //Parametros Extra a Mandar en autosugestion
	});
	$("#"+idObjDes).result(function(event, data, formatted){
	});	
	
});

</script>

</head>
<body >

<?php

if(!isset($_POST['fec_fac'])){
	$dt_receta=mysqli_fetch_array(mysqli_query($con ,"SELECT * FROM rcreceta order by id_receta desc limit 1"));
	$_REQUEST['fec_fac']=date("d/m/Y");
	$_REQUEST['iva_des']='1';
	$_REQUEST['tip_pro']='N';
	$_REQUEST['id_receta']=$dt_receta['id_receta']+1;	
}

?>
<div id="divClaRec"></div>
<form name="frm1" id="frm1" method="post" action="" enctype="multipart/form-data">


<table border="0" align="center">
  <tr>
    <th colspan="6">Alta de Receta </th>
  </tr>
  <tr>
    <td nowrap class="priDat">Clave:      </td>
    <td nowrap class="priDat"><input name="id_receta" type="text" id="id_receta" size="15" tabindex="1" value="<? echo $_REQUEST['id_receta'];?>" readonly class="textNoCap"></td>
    <td nowrap class="priDat">Descripci&oacute;n:
      <label></label>      <label></label></td>
    <td colspan="3" nowrap class="priDat"><input name="des_rec" type="text" id="des_rec" size="50" tabindex="2" value="<? echo $_REQUEST['des_rec'];?>"></td>
    </tr>
  <tr>
    <td nowrap class="priSec">Tipo: </td>
    <td colspan="3" nowrap class="priSec"><select name="cve_uni" id="cve_uni" tabindex="5">
      <option></option>
      <?php
 
		if(!isset($_REQUEST['cve_uni'])) $selTip='1';
		else $selTip=$_REQUEST['cve_uni'];

		 $result = mysqli_query($con ,"SELECT * FROM rctieali ORDER BY des_tieali");
		while($dato = mysqli_fetch_array ($result) ){ 
			if($selTip==$dato['id_tieali']){
				echo '<option value= "' . $dato['id_tieali'] . '" selected>' .$dato['cve_tieali'].' '.$dato['des_tieali'] .' </option>'; 
			}else{
				echo '<option value= "' . $dato['id_tieali'] . '">' .$dato['cve_tieali'].' '.$dato['des_tieali'] .' </option>'; 
			}
		}
		?>
    </select></td>
    <td nowrap class="priSec">Uni. Medida:</td>
    <td nowrap class="priSec"><select name="unidad" id="unidad" tabindex="4">
      <option></option>
      <?php
 
		if(!isset($_REQUEST['unidad'])) $selUniMed='1';
		else $selUniMed=$_REQUEST['unidad'];
		$result = mysqli_query($con ,"SELECT * FROM dggrupos ORDER BY des_uni");
		while($dato = mysqli_fetch_array($result) ){ 
			if($dato['cve_uni']==$selUniMed){
				echo '<option value= "' . $dato['cve_uni'] . '" selected>' . $dato['des_uni'] .' </option>'; 
			}else{
				echo '<option value= "' . $dato['cve_uni'] . '">' . $dato['des_uni'] .' </option>'; 
			}
		}
		?>
    </select></td>
    </tr>
  <tr>
    <td nowrap class="priSec">Porcion:</td>
    <td nowrap class="priSec"><input name="porc_rec" type="text" id="porc_rec" size="15" tabindex="3" value="<? echo $_REQUEST['porc_rec'];?>"></td>
    <td nowrap class="priSec">Tiempo Prep.:</td>
    <td nowrap class="priSec"><input name="tie_pre" type="text" id="tie_pre" value="<? echo $_REQUEST['tie_pre'];?>" size="7"></td>
    <td colspan="2" nowrap class="fotPro">Fotografia</td>
    </tr>
  <tr>
    <td nowrap class="priSec">Preparaci&oacute;n:</td>
    <td colspan="3" nowrap class="priSec"><div align="left">
      <textarea name="prep_rec" cols="45" rows="10" id="prep_rec" tabindex="6"><? echo $_REQUEST['prep_rec'];?></textarea>
    </div></td>
    <td colspan="2" nowrap class="fotPro"><div align="center" id="capa"><?php

			$fotografia = 'foto/dginvent/NO_'. $reg["nparte1"] .'.JPG';
			if (file_exists($fotografia)) {
				echo '<img src="foto/dginvent/NO_'.$reg["nparte1"].'.JPG" width="150" height="150" id="impPro">';
			}else{
				echo '<img src="foto/sin_producto.jpg" width="150" height="150" id="impPro">';
			}
		  ?>
	    </div>
	    <input type="checkbox" name="ac" value="1" onClick="act_fichero(ac.checked)">
        <input name="fichero" type="file" disabled="disabled" size="10" id="ficImg" onChange="cambiaImagen(this.id,'impPro');"></td>
    </tr>
  <tr>
<td colspan="6" nowrap class="backFec">
Clasificaci&oacute;n:
<label>
<input name="id_cla_rec" type="hidden" id="id_cla_rec" value="<? echo $_REQUEST['id_cla_rec']?>" size="10">
</label>
<label>
  <input name="cla_rec" type="text" id="cla_rec" value="<? echo $_REQUEST['cla_rec']; ?>" size="50" readonly>
      </label></td>
    </tr>
  <tr>
    <td nowrap class="backFec">Fecha Alta:
<div align="center"></div></td>
    <td nowrap class="backFec"><input name="fec_alt" type="text" class="fieldFec" id="fec_alt" size="10"
		  <?php
 
			  if(isset($_REQUEST['fec_alt'])){
			  	echo 'value="'.$_REQUEST['fec_alt'].'"'; 
			  }else{
			  	echo 'value="'.date('d/m/Y').'"'; 
			  }
			  ?>
		  >
      <input name="bot" id="bot1" type="image" value="Cal" src="logos/cal4.jpg" />  </td>
	  <script type="text/javascript">
      Calendar.setup(
	{
		inputField  : "fec_alt",       // ID del cuadro de texto
		ifFormat    : "%d/%m/%Y",   // formato de la fecha
		button      : "bot1"      	// ID del boton
	}
);
      </script>
    <td nowrap class="backFec">Fecha Baja:</td>
    <td nowrap class="backFec"><input name="fec_baj" type="text" class="fieldFec" id="fec_baj" size="10"
		   <?php
 
			  if(isset($_REQUEST['fec_baj'])){
			  	echo 'value="'.$_REQUEST['fec_baj'].'"'; 
			  }else{
			  	echo 'value="'.date('d/m/Y').'"'; 
			  }
			  ?>
		  >
      <input name="bot2" id="bot2" type="image" value="Cal" src="logos/cal4.jpg" /></td>
	   <script type="text/javascript">
      Calendar.setup(
	{
		inputField  : "fec_baj",       // ID del cuadro de texto
		ifFormat    : "%d/%m/%Y",   // formato de la fecha
		button      : "bot2"      	// ID del boton
	}
);
      </script>
    <td nowrap class="backFec">Fecha Cambio: </td>
    <td nowrap class="backFec"><input name="fec_cam" type="text" class="fieldFec" id="fec_cam" size="10"
		 <?php
 
			  if(isset($_REQUEST['fec_cam'])){
			  	echo 'value="'.$_REQUEST['fec_cam'].'"'; 
			  }else{
			  	echo 'value="'.date('d/m/Y').'"'; 
			  }
			  ?>>
      <input name="bot3" id="bot3" type="image" value="Cal" src="logos/cal4.jpg" /></td>
	   <script type="text/javascript">
      Calendar.setup(
	{
		inputField  : "fec_cam",       // ID del cuadro de texto
		ifFormat    : "%d/%m/%Y",   // formato de la fecha
		button      : "bot3"      	// ID del boton
	}
);
      </script>
    </tr>
  <tr>
	<td colspan="6" nowrap class="footerTab">
	<div align="center">
		<input name="agregar" type="button" id="agregar" onClick="openpage('RC31100_AC.php','_self')" value="Agregar">
  		&nbsp;
		<input name="regresar" type="button" id="regresar" onClick="openpage('RC31100_PR.php','_self')" value="Regresar">
	</div>	</td>
  </tr>
</table>

</form>
</body>
</html>
