<?php
 
session_start();
include("DMMYSQLG.php");
include("DSA1000.php");
include("DMMYSQLG.php");
include('DF30000.inc');

// Graba Detalle Poliza  
function fgrab_dpol($tpol,$fpol,$npol,$nr,$cta,$ddpol,$car,$abo){
		$sql="insert into dcdpoliz (tip_pol, fec_pol, num_pol, num_reg, cta_con, desc_con, cargo, abono) values ('$tpol', '$fpol', '$npol','$nr', '$cta', '$ddpol','$car', '$abo')";
	   	$result = mysqli_query($con ,$sql);
}

// -----Empieza Formulario -----------------
?>
<html>
<link rel="stylesheet" href="css/estilo1.css" type="text/css"/>
<script type="text/javascript" language="JavaScript1.2" src="DSSCRIPT.js"></script>

<body>
<div align="center">
<form name="form1" id="form1" method="post" action="">
  <table width="730"  align="center">
    <tr>
      <th width="720" colspan="4">GENERA POLIZAS DE CUENTAS X PAGAR </th>
    </tr>
    <tr>
      <td>A&ntilde;o Proceso </td>
      <td><select name="axo" id="axo">
          <?php
 
			$sq_a = mysqli_query($con ,"select axo from dccalend group by axo DESC");
			while($re_a = mysqli_fetch_array($sq_a)){
				echo '<option value = "'.$re_a['axo'].'">'.$re_a['axo'].'</option>';
				}
			?>
        </select>      </td>
      <td>Mes Proceso </td>
      <td><select name="mes" id="mes">
          <option value="01" selected>Enero</option>
          <option value="02">Febrero</option>
          <option value="03">Marzo</option>
          <option value="04">Abril</option>
          <option value="05">Mayo</option>
          <option value="06">Junio</option>
          <option value="07">Julio</option>
          <option value="08">Agosto</option>
          <option value="09">Septiembre</option>
          <option value="10">Octubre</option>
          <option value="11">Noviembre</option>
          <option value="12">Diciembre</option>
      </select></td>
    </tr>
          <tr>
          <td colspan="4" align="center" class="inputcodigo"> <input name="calcula" type="submit" id="calcula" value="Genera Polizas" /></td>
        </tr>
      <tr>
        <td colspan="4" class="typeagre">
		<div align="left">
<?php
 
if(isset($_POST['calcula'])){
   	$f1 = $_POST['axo'].'-'.$_POST['mes'].'-01';
	$fr_fec = 'AMD';
    $fr_fecr = 'Ymd';
    $sep_fecr = '-';
	include('DF70000.php');

	$dt_parame=mysqli_fetch_array(mysqli_query($con ,"select * from dvparame where n_reg ='1'")); // parametros generales

	$fec_ini = $fec_imes;
	$fec_fin = $fec_fmes;
	$tmov = "P"; // indica c x p
	$tpol = $dt_parame['tip_pol_gas']; // tipo de poliza
	$ori = "DW"; // indica ORIGEN c x p
	
	$sq_redocl=mysqli_query($con ,"select * from dvredocl");
	while($dt_redocl=mysqli_fetch_array($sq_redocl)){ //lee agrupado x rango de fecha
			$sq_redocd=mysqli_query($con ,"select * from dvredocd where codigo = '".$dt_redocl0['codigo']."' and num_doc = '".$dt_redocl0['num_doc']."' and fec_doc = '".$dt_redocl0['fec_doc']."'");
			while($dt_redocd=mysqli_fetch_array($sq_redocd)){ //lee detalle doctos
				$rs=mysqli_query($con ,"update dvredocd set tip_mov = '".$dt_redocl['tip_mov']."' where n_reg = '".$dt_redocd['n_reg']."'");	
			}//termina while detalle doctos
	}// termina while fechas agrupadas
		echo '<br>';
		echo 'Fin Proceso Polizas Generadas Correctamente '.'<br>';
}// Termina Isset Calculo
?>
</div></td></tr>
</table>
</form>
</body>
</html>