You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
199 lines
6.4 KiB
199 lines
6.4 KiB
#!/usr/bin/php
|
|
<?php
|
|
|
|
|
|
require_once "/var/www/html/prgdmug/F_DMUG.php";
|
|
require_once "/var/www/html/prgdmug/inc/AppConfig.php";
|
|
require_once "/var/www/html/prgdmug/inc/PostgreClass.php";
|
|
require_once "/var/www/html/prgdmug/inc/ObtieneDatosPg.php";
|
|
|
|
if ( file_exists("/tmp/InterFactFis.blk") )
|
|
{
|
|
$fec = date('l jS \of F Y h:i:s A');
|
|
echo "$fec:Existe Otro Programa Corriendo \n Verifique PID en archivo /tmp/InterFactFis.blk , si no existe el pid , elimine el archivo \n";
|
|
exit();
|
|
}
|
|
$pid = getmypid();
|
|
|
|
|
|
|
|
|
|
system( "/bin/echo 'Inicia Proceso Ejecutandose PID = $pid \n' > /tmp/InterFactFis.blk " );
|
|
|
|
$fec = date('l jS \of F Y h:i:s A');
|
|
echo "$fec:Inicia Proceso InterFactFis ....\n";
|
|
|
|
$server= "192.168.1.5";
|
|
$port = 1030; //1030
|
|
$hs = "DEMIURGO10-MCANET";
|
|
$user = "general";
|
|
$pass = "123456789";
|
|
|
|
$pid = getmypid();
|
|
$limit = 5;
|
|
$veces_error_server = 0;
|
|
$appConfig =& new AppConfig;
|
|
|
|
/* Crea un objeto para el manejo postgres */
|
|
|
|
$dataBD_PG =& $appConfig->BASE_DATOS_PG;
|
|
|
|
$manejaBD_PG =& new PostgreClass($dataBD_PG["host"], $dataBD_PG["name"],
|
|
$dataBD_PG["user"], $dataBD_PG["pass"]);
|
|
|
|
|
|
$obtieneDatos_pg = & new ObtieneDatos_PG($appConfig, $manejaBD_PG);
|
|
|
|
$pg_sql_factu = "SELECT * FROM forumvta.factu WHERE fac_trans = 0 AND (fac_tip = 'PV' OR fac_tip = 'PN') AND fac_nexti > 0 LIMIT $limit";
|
|
|
|
$v_FACTU = $obtieneDatos_pg->obtenerDatos($pg_sql_factu);
|
|
|
|
$v_i=0;
|
|
|
|
$control = count( $v_FACTU[0] );
|
|
|
|
//echo "control = $control\n";//responde 101 campos si leyo OK
|
|
|
|
if ( $control < 10 )
|
|
{
|
|
echo "NO HAY FACTURAS PARA TRANSFERIR\n";
|
|
Finalizar();
|
|
}
|
|
|
|
for( $v_i=0 ; $v_FACTU[$v_i]['fac_nro'] ; $v_i++ )
|
|
{
|
|
|
|
$FAC_SUC = $v_FACTU[$v_i]['fac_suc'] ;
|
|
$FAC_TIP = $v_FACTU[$v_i]['fac_tip'] ;
|
|
$FAC_STIP= $v_FACTU[$v_i]['fac_stip'] ;
|
|
$FAC_NRO = $v_FACTU[$v_i]['fac_nro'] ;
|
|
$NROEXT = $v_FACTU[$v_i]['fac_nexti'];
|
|
|
|
$fec = date('l jS \of F Y h:i:s A');
|
|
echo "$fec .... FACTURA pos = $v_i sucu = $FAC_SUC tip=$FAC_TIP nro = $FAC_NRO NEXT = $NROEXT \n";
|
|
|
|
$ConDMUG = new ConexDMUG( $server , $port , $hs ,$user , $pass );
|
|
|
|
$ConDMUG->SetProgram( "Interfaz_FacFisPG_Forum" );
|
|
|
|
Carga_CABECERA( $ConDMUG , $v_FACTU , $v_i );
|
|
|
|
$ConDMUG->SetParameter( "CANTIDAD_CABECERAS" , 1 );
|
|
$ConDMUG->SetParameter( "FECHA_TRASMITE" , date() );
|
|
$ConDMUG->SetParameter( "HORA_TRASMITE" , time() );
|
|
|
|
if ( $ConDMUG->Execute_DMUG() < 0)
|
|
{
|
|
$fec = date('l jS \of F Y h:i:s A');
|
|
echo "$fec : ERROR EN CONEXION CON SERVER , esperando 3 segundos para continuar ....\n";
|
|
$veces_error_server++;
|
|
if ( $veces_error_server > 2 )
|
|
{
|
|
$fec = date('l jS \of F Y h:i:s A');
|
|
echo "$fec :FINALIZA POR ERROR DE CONEXION CON SERVER !!!!!!!!!!\n";
|
|
Finalizar();
|
|
}
|
|
sleep(3);
|
|
continue;
|
|
}
|
|
|
|
|
|
$RESULTADO = $ConDMUG->GetChild( "STRERROR" );
|
|
|
|
echo "RESULTADO:".$RESULTADO."\n" ;
|
|
echo "ERROR:".$ConDMUG->GetChild( "ERROR" )."\n" ;
|
|
echo "INFORME :".$ConDMUG->GetChild( "INFO1" )."\n" ;
|
|
echo "INFORME :".$ConDMUG->GetChild( "INFO2" )."\n" ;
|
|
echo "PUTRECORD:".$ConDMUG->GetChild( "PUTRECORD" )."\n" ;
|
|
echo "REGISTROS:".$ConDMUG->GetChild( "REGISTROS" )."\n" ;
|
|
|
|
$ConDMUG->CloseConex();
|
|
|
|
|
|
if ( $RESULTADO== "EXACTO" )
|
|
{
|
|
echo "Se marca FACTU $FAC_NRO en PG TRANS es 1 \n";
|
|
Marca_CABECERA( $obtieneDatos_pg , $v_FACTU , $v_i );
|
|
}
|
|
else
|
|
{
|
|
echo "ERROR en $FAC_NRO \n";
|
|
}
|
|
echo "-------------------------------------------------------\n";
|
|
|
|
sleep(1);
|
|
|
|
}
|
|
|
|
unset($v_FACTU);
|
|
Finalizar();
|
|
|
|
/***********************************************************************/
|
|
function Finalizar()
|
|
{
|
|
system( "/bin/rm /tmp/InterFactFis.blk" );
|
|
exit();
|
|
}
|
|
/***********************************************************************/
|
|
/*----------------------- function Carga_CABECERA ---------------------*/
|
|
/***********************************************************************/
|
|
function Carga_CABECERA( $ConDMUG , $p_FACTU , $v_i )
|
|
{
|
|
|
|
|
|
# define FACTU_FAC_SUC (dbfield) 0x0a01 /* Integer /
|
|
$ConDMUG->SetParameter("FAC_SUC" , $p_FACTU[$v_i]['fac_suc'] );
|
|
|
|
if ( $p_FACTU[$v_i]['fac_tip']== "PV" )
|
|
$FAC_TIP = "pv" ;
|
|
if ( $p_FACTU[$v_i]['fac_tip']== "PN" )
|
|
$FAC_TIP = "pn" ;
|
|
echo "FACTURA pos tip=$FAC_TIP \n";
|
|
# define FACTU_FAC_TIP (dbfield) 0x0a02 /* String
|
|
# $ConDMUG->SetParameter("FAC_TIP" , $p_FACTU[$v_i]['fac_tip'] );
|
|
$ConDMUG->SetParameter("FAC_TIP" , $FAC_TIP );
|
|
|
|
# define FACTU_FAC_STIP (dbfield) 0x0a03 /* Integer
|
|
$ConDMUG->SetParameter("FAC_STIP" , $p_FACTU[$v_i]['fac_stip'] );
|
|
|
|
# define FACTU_FAC_NRO (dbfield) 0x0a04 /* Long
|
|
$ConDMUG->SetParameter("FAC_NRO" , $p_FACTU[$v_i]['fac_nro'] );
|
|
|
|
# define FACTU_FAC_SEXT (dbfield) 0x0a47 /* String /
|
|
$ConDMUG->SetParameter("FAC_SEXT" , $p_FACTU[$v_i]['fac_sext'] );
|
|
|
|
# define FACTU_FAC_NEXTI (dbfield) 0x0a48 /* Long /
|
|
$ConDMUG->SetParameter("FAC_NEXTI", $p_FACTU[$v_i]['fac_nexti'] );
|
|
|
|
# define FACTU_FAC_NEXTF (dbfield) 0x0a49 /* Long /
|
|
$ConDMUG->SetParameter("FAC_NEXTF", $p_FACTU[$v_i]['fac_nextf'] );
|
|
|
|
# define FACTU_FAC_EMP (dbfield) 0x0a60 /* Integer /
|
|
$ConDMUG->SetParameter("FAC_EMP" , $p_FACTU[$v_i]['fac_emp'] );
|
|
|
|
}
|
|
|
|
/***********************************************************************/
|
|
/*----------------------- function Carga_CABECERA ---------------------*/
|
|
/***********************************************************************/
|
|
function Marca_CABECERA( $obtieneDatos_pg , $p_FACTU , $v_i )
|
|
{
|
|
|
|
$SUC = $p_FACTU[$v_i]['fac_suc'];
|
|
$TIP = $p_FACTU[$v_i]['fac_tip'];
|
|
$STIP = $p_FACTU[$v_i]['fac_stip'];
|
|
$NRO = $p_FACTU[$v_i]['fac_nro'];
|
|
|
|
echo "FACTURA sucu = $SUC tip=$TIP nro = $NRO STIP = $STIP \n";
|
|
$pg_sql_factu = "UPDATE forumvta.factu SET fac_trans = 1 WHERE fac_suc = $SUC AND fac_tip = '$TIP' ";
|
|
$pg_sql_factu .="AND fac_stip = $STIP AND fac_nro = $NRO ";
|
|
|
|
$obtieneDatos_pg->obtenerDatos( $pg_sql_factu );
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
?>
|
|
|
|
|