<?php

require_once("DF80000.php");
$dbuser = "root";
$dbpass = "castillejos";
$dbhost = "localhost";
$con = mysqli_connect($dbhost,$dbuser,$dbpass);
if (!$con){
	die('Error N:' . mysqli_errno($con$con) . ": " . mysqli_error($con));
}
$ccrosti = mysqli_select_db('azteca_reyes');

$sq_redocl=mysqli_query($con ,"SELECT * FROM dvredocl WHERE tip_mov='C' AND tot_doc>0");
while($dt_redocl=mysqli_fetch_array($sq_redocl)){
	$dt_bascptFac=mysqli_fetch_array(mysqli_query($con ,"SELECT * FROM dxbascpt WHERE codigo='".$dt_redocl['codigo']."'"));
	/*Calcular Fecha de Revision y Fecha de Vencimiento*/
	$arrFecFac=explode("-",$dt_redocl['fec_doc']);
	$auxFecFac=$arrFecFac[0].'-'.$arrFecFac[1].'-01';
	$fecRev=addMonth($auxFecFac,1);
	$fecVen=addDay($fecRev,$dt_bascptFac['dia_cred']);
	/***************************************************/
	mysqli_query($con ,"update dvredocl SET fec_rev='$fecRev',fec_ven='$fecVen',dia_cre='".$dt_bascptFac['dia_cred']."' WHERE n_reg='".$dt_redocl['n_reg']."'");
}
?>