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.
 
 
 
 
 
 

221 lines
7.3 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/ImpZeta.blk") )
{
$fec = date('l jS \of F Y h:i:s A');
echo "$fec:Existe Otro Programa Corriendo \n Verifique PID en archivo /tmp/ImpZeta.blk , si no existe el pid , elimine el archivo \n";
exit();
}
$pid = getmypid();
system( "/bin/echo 'Inicia Proceso Ejecutandose PID = $pid \n' > /tmp/ImpZeta.blk " );
$fec = date('l jS \of F Y h:i:s A');
echo "$fec:Inicia Proceso ImpZeta ....\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_zeta = "SELECT * FROM minor.zeta WHERE z_trans = 0 LIMIT $limit";
$v_ZETA = $obtieneDatos_pg->obtenerDatos($pg_sql_zeta);
$v_i=0;
$control = count( $v_ZETA[0] );
//echo "control = $control\n";//responde 101 campos si leyo OK
if ( $control < 10 )
{
echo "NO HAY ZETAS PARA TRANSFERIR\n";
Finalizar();
}
$ConDMUG = new ConexDMUG( $server , $port , $hs ,$user , $pass );
$ConDMUG->SetProgram( "Interfaz_Zeta" );
Carga_CABECERA( $ConDMUG , $v_ZETA , $v_i );
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 ZETA $Z_ZETA en PG TRANS es 1 \n";
Marca_CABECERA( $obtieneDatos_pg , $v_ZETA , $v_i );
}
else
{
echo "ERROR en $Z_ZETA \n";
}
unset($v_ZETA);
Finalizar();
/***********************************************************************/
function Finalizar()
{
system( "/bin/rm /tmp/ImpZeta.blk" );
exit();
}
/***********************************************************************/
/*----------------------- function Carga_CABECERA ---------------------*/
/***********************************************************************/
function Carga_CABECERA( $ConDMUG , $p_ZETA , $v_i )
{
# define FACTU_FAC_SUC (dbfield) 0x0a01 /* Integer /
$ConDMUG->SetParameter("Z_SUC" , $p_ZETA[$v_i]['z_suc'] );
# define FACTU_FAC_TIP (dbfield) 0x0a02 /* String
$ConDMUG->SetParameter("Z_PTOVTA" , $p_ZETA[$v_i]['z_ptovta'] );
# define FACTU_FAC_STIP (dbfield) 0x0a03 /* Integer
$ConDMUG->SetParameter("Z_ESTADI" , $p_ZETA[$v_i]['z_estadi'] );
# define FACTU_FAC_NRO (dbfield) 0x0a04 /* Long
$ConDMUG->SetParameter("Z_ESTADF" , $p_ZETA[$v_i]['z_estadf'] );
# define FACTU_FAC_FEC (dbfield) 0x0a05 /* Date /
$ConDMUG->SetParameter("Z_ZETA" , $p_ZETA[$v_i]['z_zeta'] );
# define FACTU_FAC_CLIE (dbfield) 0x0a06 /* Long /
$ConDMUG->SetParameter("Z_CCANCEL" , $p_ZETA[$v_i]['z_ccancel'] );
# define FACTU_FAC_FPED (dbfield) 0x0a07 /* Date /
$ConDMUG->SetParameter("Z_CNFH" , $p_ZETA[$v_i]['z_cnfh'] );
# define FACTU_FAC_NREP (dbfield) 0x0a08 /* Long /
$ConDMUG->SetParameter("Z_CNFISCAL" , $p_ZETA[$v_i]['z_cnfiscal'] );
# define FACTU_FAC_CPAG (dbfield) 0x0a09 /* Integer /
$ConDMUG->SetParameter("Z_CFISCAL" , $p_ZETA[$v_i]['z_cfiscal'] );
# define FACTU_FAC_IVA (dbfield) 0x0a0a /* Integer /
$ConDMUG->SetParameter("Z_ULT_B" , $p_ZETA[$v_i]['z_ult_b'] );
# define FACTU_FAC_CAJA (dbfield) 0x0a0b /* Integer /
$ConDMUG->SetParameter("Z_ULT_A" , $p_ZETA[$v_i]['z_ult_a'] );
# define FACTU_FAC_CAJ (dbfield) 0x0a0c /* Integer /
$ConDMUG->SetParameter("Z_VFISCAL" , $p_ZETA[$v_i]['z_vfiscal'] * 100 );
# define FACTU_FAC_FAC (dbfield) 0x0a0d /* Integer
$ConDMUG->SetParameter("Z_IVAFISCAL" , $p_ZETA[$v_i]['z_ivafiscal'] * 100 );
# define FACTU_FAC_SEC (dbfield) 0x0a0e /* String /
$ConDMUG->SetParameter("Z_IIFISCAL" , $p_ZETA[$v_i]['z_iifiscal'] * 100 );
# define FACTU_FAC_TVEN (dbfield) 0x0a0f /* String
$ConDMUG->SetParameter("Z_PERFISCAL" , $p_ZETA[$v_i]['z_perfiscal'] * 100 );
# define FACTU_FAC_COM (dbfield) 0x0a10 /* Long /
$ConDMUG->SetParameter("Z_IVANIFI" , $p_ZETA[$v_i]['z_ivanifi'] * 100 );
# define FACTU_FAC_COM (dbfield) 0x0a10 /* Long /
$ConDMUG->SetParameter("Z_ULT_NCB" , $p_ZETA[$v_i]['z_ult_ncb'] );
# define FACTU_FAC_TDEV (dbfield) 0x0a11 /* String
$ConDMUG->SetParameter("Z_ULT_NCA" , $p_ZETA[$v_i]['z_ult_nva'] );
# define FACTU_FAC_NDEV (dbfield) 0x0a13 /* Long /
$ConDMUG->SetParameter("Z_CRED_NC" , $p_ZETA[$v_i]['z_cred_nc'] * 100 );
# define FACTU_FAC_FDEV (dbfield) 0x0a14 /* Date
$ConDMUG->SetParameter("Z_IVA_NC" , $p_ZETA[$v_i]['z_iva_nc'] * 100 );
# define FACTU_FAC_DES (dbfield) 0x0a15 /* Long /
$ConDMUG->SetParameter("Z_II_NC" , $p_ZETA[$v_i]['z_ii_nc'] * 100 );
# define FACTU_FAC_RECCP (dbfield) 0x0a16 /* Long /
$ConDMUG->SetParameter("Z_PER_NC", $p_ZETA[$v_i]['v_per_nc'] * 100 );
# define FACTU_FAC_RECVT (dbfield) 0x0a17 /* Long /
$ConDMUG->SetParameter("Z_IVANINC", $p_ZETA[$v_i]['z_ivaninc'] * 100 );
# define FACTU_FAC_RECOF (dbfield) 0x0a18 /* Long /
$ConDMUG->SetParameter("Z_ULT_REM", $p_ZETA[$v_i]['z_ult_rem'] );
# define FACTU_FAC_RECUN (dbfield) 0x0a19 /* Long /
$ConDMUG->SetParameter("Z_FGEN", $p_ZETA[$v_i]['z_fgen']) ;
}
/***********************************************************************/
/*----------------------- function Carga_CABECERA ---------------------*/
/***********************************************************************/
function Marca_CABECERA( $obtieneDatos_pg , $p_ZETA , $v_i )
{
$SUC = $p_ZETA[$v_i]['z_suc'];
$VTOVTA = $p_ZETA[$v_i]['z_ptovta'];
$ZETA = $p_ZETA[$v_i]['z_zeta'];
$FGEN = $p_ZETA[$v_i]['z_fgen'];
$pg_sql_factu = "UPDATE minor.zeta SET z_trans = 1 WHERE z_suc = $SUC AND z_ptovta = '$VTOVTA' ";
$pg_sql_factu .="AND z_zeta = $ZETA AND z_fgen = $FGEN ";
$obtieneDatos_pg->obtenerDatos( $pg_sql_factu );
////$errorUPDATE = pg_last_error ( $obtieneDatos_pg );
///echo "Error=".$errorUPDATE."\n";
return 1;
}
?>