<?php
 
session_start();
$com = "A";
include("DMMYSQLG.php");
include("DSA3000.php");
include("DMMYSQLG.php");
include("DF30000.inc");
include("DF80000.php");
?>
<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>
<form name="frm1" id="frm1" method="post" action="">
<div id="capa1"></div>
<table  align="center">
  <tr>
    <th colspan="6" class=\"titulo\">AGREGAR EMISION DE PAGO </th>
  </tr>
  <tr>
    <td>Movimiento:</td>
    <td><input type="text" name="tipoMovimiento" id="tipoMovimiento" tabindex="6" value="PROVEEDOR" readonly></td>
    <td>Fecha Cob/Pago: </td>
    <td><input name="fec" type="text" class="emplea" id="fec" size="15" maxlength="20" readonly
			<?php

			if(isset($_POST['fec'])){
				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>Folio del Cob/Pago:</td>
    <td><input name="t3" type="text" id="t3" tabindex="3" 
	<?php

	if(isset($_POST['t3'])){
		echo 'value="'.$_POST['t3'].'"';	
	}
	?>
	></td>
  </tr>
  <tr>
    <td>Cliente:</td>
    <td colspan="3"><span class="inputcodigo">
      <input name="tncli" type="text" id="tncli" size="3" readonly tabindex="4" 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 tabindex="5"
		<?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('DV33000_AG3.php','popuppage','width=750,height=300,top=100,left=50,scrollbars=yes,menubar=yes,status=yes')">
    </span></td>
    <td>Tipo de Cobro/Pago:</td>
    <td><select name="tipoCobro" id="tipoCobro">
      <option value="1" <?php
if($_POST["tipoCobro"]=="1") echo 'selected';?>>COBRO/PAGO</option>
      <option value="2" <?php
if($_POST["tipoCobro"]=="2") echo 'selected';?>>CARGO</option>
      <option value="3" <?php
if($_POST["tipoCobro"]=="3") echo 'selected';?>>ABONO</option>
    </select></td>
  </tr>
  <tr>
    <td>Documento:</td>
    <td><select name="t5" id="t5" onChange="javascript: document.getElementById('frm1').submit()">
      <option></option>
      <?php

  	  	$sql_dcb = mysqli_query($con ,"SELECT * FROM dvredocl WHERE tip_mov='P' and 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_sal'], 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_sal'], 2, '.', ',').'</option>';
			}	
		}
	  ?>
    </select>
      <?php


	  $dat=explode("|",$_POST['t5']);
	  //echo $_POST['t5'];
	  $sql_d=mysqli_query($con ,"SELECT * FROM dvredocl WHERE n_reg='$dat[0]'");
	  $row_d=mysqli_fetch_array($sql_d);
	  
	  $sql_tiva=mysqli_query($con ,"SELECT * FROM dxtasiva WHERE cve_iva='".$row_d['cve_iva']."'");
	  $row_tiva=mysqli_fetch_array($sql_tiva);
	  
	  if($row_tiva["porc_iva"]<>0){
	  	  $xcen=$row_tiva["porc_iva"]/100+1;
	  }
	  
	  if($row_d["tot_sal"]<>0){
		  $sub=$row_d["tot_sal"]/$xcen;
		  $iva=$row_d["tot_sal"]-$sub;
		  $tot=$sub+$iva;
	  }
	  ?></td>
    <td>Fecha del Documento:</td>
    <td><input name="fec2" type="text" class="emplea" id="fec2" size="15" maxlength="20" readonly
				<?php

			$dt_redoclA=mysqli_fetch_array(mysqli_query($con ,"select * from dvredocl where n_reg='$dat[0]'"));
			//echo "select * from dvredocl where num_doc='".$_POST['t5']."' and tip_mov='P' and codigo='".$_POST['tncli']."' and tot_doc<>'0' ";
			if(isset($_POST['fec2'])){
				echo 'value="'.chfecha($dt_redoclA["fec_doc"],'Y-m-d','d/m/Y').'"';
			}else{
				echo 'value="' .date("d/m/Y").  '"';
			}
			?>onkeypress="return soloNumeros(event)"//solo fechas
		/>
    <input name="bot22" id="bot22" type="image" value="Cal" src="logos/cal4.jpg" />
      <script type="text/javascript">
Calendar.setup(
	{
		inputField  : "fec2",       // ID del cuadro de texto
		ifFormat    : "%d/%m/%Y",   // formato de la fecha
		button      : "bot22"      	// ID del boton
	}
);
      </script></td>
    <td>Cta Contable: </td>
    <td><select name="select" id="select" tabindex="8">
      <?php
 
	  	@$sql=mysqli_query($con ,"select * from dycatcta");
	  	while($reg = mysqli_fetch_array($sql)){
	  		if($reg['cta_con']==$_POST['select']){	
				echo '<option value = "'.$reg['cta_con'].'"selected>'.$reg['cta_con']. ' ' . $reg['descripcion'].'</option>';
	  		}else{
				echo '<option value = "'.$reg['cta_con'].'">'.$reg['cta_con']. ' ' . $reg['descripcion'].'</option>';
			}
		}
	  ?>
    </select></td>
  </tr>
  <tr>
    <td>Sub-Total:</td>
    <td><input name="t6" type="text" id="t6" tabindex="9" 
	<?php

		echo 'value="'.number_format($sub, 2, '.', '').'"';
	?>
	></td>
    <td>Iva:</td>
    <td><input name="t7" type="text" id="t7" tabindex="10"
	<?php

		echo 'value="'.number_format($iva, 2, '.', '').'"';
	?>
	></td>
    <td>Total:</td>
    <td><input name="t8" type="text" id="t8" tabindex="11"
	<?php

		echo 'value="'.number_format($tot, 2, '.', '').'"';
	?>
	></td>
  </tr>
  <tr>
    <td>Generar Poliza: </td>
    <td><select name="t9" id="t9" tabindex="12">
      <?php
 
		if($_REQUEST['t9']=="S"){
			echo '<option value="S" selected>SI</option>';
		}else{
			echo '<option value="S">SI</option>';
		}
		if($_REQUEST['t9']=="N"){
			echo '<option value="N" selected>NO</option>';
		}else{
			echo '<option value="N">NO</option>';
		}
		?>
    </select></td>
    <td>Afectar Contablemente: </td>
    <td><select name="t10" id="t10" tabindex="13">
      <?php
 
		if($_REQUEST['t10']=="S"){
			echo '<option value="S" selected>SI</option>';
		}else{
			echo '<option value="S">SI</option>';
		}
		if($_REQUEST['t10']=="N"){
			echo '<option value="N" selected>NO</option>';
		}else{
			echo '<option value="N">NO</option>';
		}
		?>
    </select></td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
  </tr>
  <tr>
		<td colspan="6">
		  <div align="center">
	  		  <input type="button" name="Submit4" value="Guardar" onClick="openpage('DW23000_AC.php','_self')">
		  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
		  <input type="button" name="Submit" value="Regresar" onClick="openpage('DW23000_PR.php','_self')">
		  </div>		</td>
	</tr>
  </table>
</form>
</body>
</html>
