<?php 
declare(strict_types=0);
foreach($_GET  as $key => $value){${$key}=trim($value);$_PARAMS[$key]=${$key};}  
foreach($_POST as $key => $value){${$key}=trim($value);$_PARAMS[$key]=${$key};}
include_once('lib_main.php');

$empr0=data_maes('empr',$cfg_empr);
if(empty($empr0['empr_cont'])){return;}     
$modulos=['vtas','comp','inve','caja','bcos','tsor','retc','retp','dxco','dxpa','nomi'];

if(empty($fecha1) and date('Y-m-d')<='2025-05-18'){$fecha1=date('Y-01-01');}
if(empty($fecha1)){$fecha1=date('Y-m-01',strtotime('-1 month'));}
if(empty($fecha2)){$fecha2=date('Y-m-d');}

$selcol='idnum1,docu,ptoe,numero,fecha,status,idate ';



$domd = new DOMDocument();
     $domd->encoding = 'utf-8';
     $domd->xmlVersion = '1.0';
     $domd->formatOutput = true;
$elem=$domd;

$img=$elem->appendChild($domd->createElement("img",""));
     $img->setAttribute("src","//vcrxol.com/_logo/logo".$cfg_empr."1.png");
     $img->setAttribute("style","width:auto; max-height:45px;color:#00ced1;");

$div=$elem->appendChild($domd->createElement("div",str_repeat("=",50)));
$div=$elem->appendChild($domd->createElement("div","*** CONTABILIDAD ***"));
$div=$elem->appendChild($domd->createElement("div",str_repeat("=",50)));
$div=$elem->appendChild($domd->createElement("div",$empr0['empr_codigo']." - ".$empr0['empr_descri']));
$div=$elem->appendChild($domd->createElement("div",str_repeat("=",50)));
$div=$elem->appendChild($domd->createElement("div","Start : ".date('Y-m-d H:i:s .v')));
$div=$elem->appendChild($domd->createElement("div",str_repeat("=",50)));
$div=$elem->appendChild($domd->createElement("div","Fecha 1 : ".$fecha1));
$div=$elem->appendChild($domd->createElement("div","Fecha 2 : ".$fecha2));
$div=$elem->appendChild($domd->createElement("div",str_repeat("=",50)));

echo $domd->saveHTML();
foreach($modulos as $modulo)     
{
	$sql_cele=' ';
     if(${$modulo}==1)
     {
          $modu0=data_maes('modu',$modulo);
          if(strtolower($modu0['modu_codigo'])!=$modulo){continue;}
          
          $sql_cele.='select '.$selcol.' from '.$modulo.'1 ';
          $sql_cele.='where 1=1 ';
          $sql_cele.='and fecha>="'.$fecha1.'" ';
          $sql_cele.='and fecha<="'.$fecha2.'" ';
          $sql_cele.='order by docu,fecha,numero,idnum1 ';

          $res_cele=msql_query($sql_cele,$link_data);
          echo '<br> REGS. '.$modu0['modu_descri'].' : '.msql_num_rows($res_cele);
          msql_data_seek($res_cele);
          while($aso_cele=msql_fetch_assoc($res_cele))
          {
               $idcont=gen_contab($aso_cele['docu'],$aso_cele['idnum1']);
               echo '<br> '.$aso_cele['docu'].' - '.$aso_cele['numero'].' | '.$aso_cele['fecha']. ' ==> '.$idcont;
          }
     }
     
     
     
}
echo '<br>=============================================';
echo '<br>End : '.date('Y-m-d H:i:s.v');
echo '<br>=============================================';



?>