<?php
 
session_start();
$com = "A";
include("DMMYSQLG.php");
include("DSA3000.php");
include("DMMYSQLG.php");
include("DF30000.inc");
?>
<html>
<head>
<title>Orden de compra</title>
<link rel="stylesheet" href="css/estilo1.css" type="text/css"/>
<script type="text/javascript" language="JavaScript1.2" src="DSSCRIPT.js"></script>
</head>
<body>
<?php
 
$ayuda = 'DV3300A_AG.php';
include("DYAYUDA.php");
?>
<form name="frm1" id="frm1" method="post" action="">
<div id="capa1"></div>
<table  align="center">
  <tr>
    <th colspan="6" class=\"titulo\"> AGREGAR EMISION DE NOTA DE CREDITO </th>
  </tr>
  <tr>
    <td>Nota de Credito </td>
    <td><select name="t1" tabindex="1" onChange="cons_nott(this.value)">
      <option></option>
      <?php

	@$resultado=mysqli_query($con ,"select * from dvtinotc");
	while(@$registro=mysqli_fetch_array($resultado)){
		if($_POST['t1']==$registro['tip_not'] .'|'.$registro['con_not']){
			echo '<option value="' . $registro['tip_not'] .'|'.$registro['con_not']. '" selected>' . $registro['des_not'] . '</option>';
		}else{
			echo '<option value="' . $registro['tip_not'] .'|'.$registro['con_not']. '">' . $registro['des_not'] . '</option>';
		}
	}			
?>
    </select>     </td>
    <td>Fecha</td>
    <td><input name="fec" type="text" class="emplea" id="fec" size="8" maxlength="20" readonly
			<?php

				if(isset($_POST['fec'])){ //este es el truco
					echo 'value="' . $_POST['fec'] .  '"';
				}else{
					echo 'value="' .date("d/m/Y").  '"';
				}
			?>onkeypress="return soloNumeros(event)"//solo fechas
		/>
    <input name="bot2" id="bot2" type="image" value="Cal" src="logos/cal4.jpg" />
      <script type="text/javascript">
Calendar.setup(
	{
		inputField  : "fec",       // ID del cuadro de texto
		ifFormat    : "%d/%m/%Y",   // formato de la fecha
		button      : "bot2"      	// ID del boton
	}
);
      </script></td>
    <td>Numero:</td>
    <td><input name="t3" type="text" id="t3" size="12" 
	<?php

	if(isset($_POST['t3'])){
		echo 'value="'.$_POST['t3'].'"';	
	}
	?>
	></td>
  </tr>
  <tr>
    <td>Proveedores:</td>
    <td><span class="inputcodigo">
      <input name="tncli" type="text" id="tncli" size="3" readonly onFocus="javascript: document.getElementById('frm1').submit()"
	<?php

	if(isset($_POST['tncli'])){
		echo 'value="'.$_POST['tncli'].'"';	
	}
	?>
    >
      <input name="tnom_alt" type="text" id="tnom_alt"  readonly
		<?php
 
/*if((isset($_POST['select3']) and $_POST['select3']==0) or (isset($_POST['tip_ven']) or isset($_GET['rr'])) or ($_POST['Submit6']=="Agregar")){
	//buscar el cliente por default
	echo 'value="'.$registro['nom_cli']. ' ' .$registro['ap_pat_cli'] . ' ' .$registro['ap_mat_cli'].'"';
}*/
	if(isset($_POST['tnom_alt'])){
		echo 'value="'.$_POST['tnom_alt'].'"';	
	}

?>
		>
      <input type="button" name="Submit2" value="Buscar" onClick="window.open('DW22000_AG3.php','popuppage','width=750,height=300,top=100,left=50,scrollbars=yes,menubar=yes,status=yes')">
    </span></td>
    <td>Movimiento:</td>
    <td><select name="t4" id="t4" tabindex="20">
      <?php

if ($_REQUEST['t4'] == "D"){
	echo '<option value="D" selected>DESCUENTO</option>';
 }else{
	echo '<option value="D">DESCUENTO</option>';
 }
 if ($_REQUEST['t4'] == "C"){
	echo '<option value="C" selected>CANCELACION</option>';
 }else{
	echo '<option value="C">CANCELACION</option>';
 }
?>
    </select></td>
    <td>Factura:</td>
    <td><select name="t5" id="t5">
      <option></option>
      <?php

  	  	$sql_dcb = mysqli_query($con ,"SELECT * FROM dvredocl WHERE codigo='".$_POST['tncli']."' and tot_sal <>0 ORDER BY num_doc");
		while($row_dcb = mysqli_fetch_array($sql_dcb)){
			if($row_dcb['n_reg'].'|'.$row_dcb['num_doc']==$_POST['t5']){
				echo '<option value="'.$row_dcb['n_reg'].'|'.$row_dcb['num_doc'].'"selected>'.'NO DOC: '.$row_dcb['num_doc'].' | '.'IMP:  '.number_format($row_dcb['tot_doc'], 2, '.', ',').'</option>';
			}else{
				echo '<option value="'.$row_dcb['n_reg'].'|'.$row_dcb['num_doc'].'">'.'NO DOC: '.$row_dcb['num_doc'].' | '.'IMP:  '.number_format($row_dcb['tot_doc'], 2, '.', ',').'</option>';
			}	
		}
	  ?>
    </select></td>
  </tr>
  <tr>
    <td>Cve iva:</td>
    <td><select name="t6" id="t6" tabindex="6">
      <?php

			@$resultado=mysqli_query($con ,"select * from dxtasiva");
			while($registro=mysqli_fetch_array($resultado))
			{
	  			if($_REQUEST['t6'] == $registro['cve_iva']){
					echo '<option value="' . $registro['cve_iva']. '" selected>' . $registro['conc_iva'] . '</option>';
				}else{
					echo '<option value="' . $registro['cve_iva']. '">' . $registro['conc_iva'] . '</option>';
				}
			}	
		?>
    </select></td>
    <td>Desglosa Iva:</td>
    <td><select name="t7" id="t7" tabindex="7">
      <?php

if ($_REQUEST['t7'] == "S"){
	echo '<option value="S" selected>SI</option>';
 }else{
	echo '<option value="S">SI</option>';
 }
 if ($_REQUEST['t7'] == "N"){
	echo '<option value="N" selected>NO</option>';
 }else{
	echo '<option value="N">NO</option>';
 }
?>
    </select></td>
    <td>Generar Poliza: </td>
    <td><select name="t8" id="t8" tabindex="8">
      <?php

if ($_REQUEST['t8'] == "S"){
	echo '<option value="S" selected>SI</option>';
 }else{
	echo '<option value="S">SI</option>';
 }
 if ($_REQUEST['t8'] == "N"){
	echo '<option value="N" selected>NO</option>';
 }else{
	echo '<option value="N">NO</option>';
 }
?>
    </select></td>
  </tr>
  <tr>
    <td>Referencia:</td>
    <td colspan="5"><input name="T10" type="text" id="T10" size="150" maxlength="255"
	<?php

	if(isset($_POST['T10'])){
		echo 'value="'.$_POST['T10'].'"';	
	}
	?>
	></td>
    </tr>
  <tr>
		<td colspan="6">
		  <div align="center">
	  		  <input type="Submit" name="Submit4" value="Guardar" onClick="openpage('DW22000_AG1.php','_self')">
		  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
		  <input type="button" name="Submit" value="Regresar" onClick="openpage('DW22000_PR.php','_self')">
		  </div>		</td>
	</tr>
  </table>
</form>
</body>
</html>