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

4 years ago
  1. #!/usr/bin/php
  2. <?php
  3. require_once "/var/www/html/prgdmug/F_DMUG.php";
  4. require_once "/var/www/html/prgdmug/inc/AppConfig.php";
  5. require_once "/var/www/html/prgdmug/inc/PostgreClass.php";
  6. require_once "/var/www/html/prgdmug/inc/ObtieneDatosPg.php";
  7. if ( file_exists("/tmp/ImpZeta.blk") )
  8. {
  9. $fec = date('l jS \of F Y h:i:s A');
  10. echo "$fec:Existe Otro Programa Corriendo \n Verifique PID en archivo /tmp/ImpZeta.blk , si no existe el pid , elimine el archivo \n";
  11. exit();
  12. }
  13. $pid = getmypid();
  14. system( "/bin/echo 'Inicia Proceso Ejecutandose PID = $pid \n' > /tmp/ImpZeta.blk " );
  15. $fec = date('l jS \of F Y h:i:s A');
  16. echo "$fec:Inicia Proceso ImpZeta ....\n";
  17. $server= "192.168.1.5";
  18. $port = 1030; //1030
  19. $hs = "DEMIURGO10-MCANET";
  20. $user = "general";
  21. $pass = "123456789";
  22. $pid = getmypid();
  23. $limit = 5;
  24. $veces_error_server = 0;
  25. $appConfig =& new AppConfig;
  26. /* Crea un objeto para el manejo postgres */
  27. $dataBD_PG =& $appConfig->BASE_DATOS_PG;
  28. $manejaBD_PG =& new PostgreClass($dataBD_PG["host"], $dataBD_PG["name"],
  29. $dataBD_PG["user"], $dataBD_PG["pass"]);
  30. $obtieneDatos_pg = & new ObtieneDatos_PG($appConfig, $manejaBD_PG);
  31. $pg_sql_zeta = "SELECT * FROM minor.zeta WHERE z_trans = 0 LIMIT $limit";
  32. $v_ZETA = $obtieneDatos_pg->obtenerDatos($pg_sql_zeta);
  33. $v_i=0;
  34. $control = count( $v_ZETA[0] );
  35. //echo "control = $control\n";//responde 101 campos si leyo OK
  36. if ( $control < 10 )
  37. {
  38. echo "NO HAY ZETAS PARA TRANSFERIR\n";
  39. Finalizar();
  40. }
  41. $ConDMUG = new ConexDMUG( $server , $port , $hs ,$user , $pass );
  42. $ConDMUG->SetProgram( "Interfaz_Zeta" );
  43. Carga_CABECERA( $ConDMUG , $v_ZETA , $v_i );
  44. if ( $ConDMUG->Execute_DMUG() < 0)
  45. {
  46. $fec = date('l jS \of F Y h:i:s A');
  47. echo "$fec : ERROR EN CONEXION CON SERVER , esperando 3 segundos para continuar ....\n";
  48. $veces_error_server++;
  49. if ( $veces_error_server > 2 )
  50. {
  51. $fec = date('l jS \of F Y h:i:s A');
  52. echo "$fec :FINALIZA POR ERROR DE CONEXION CON SERVER !!!!!!!!!!\n";
  53. Finalizar();
  54. }
  55. sleep(3);
  56. continue;
  57. }
  58. $RESULTADO = $ConDMUG->GetChild( "STRERROR" );
  59. echo "RESULTADO:".$RESULTADO."\n" ;
  60. echo "ERROR:".$ConDMUG->GetChild( "ERROR" )."\n" ;
  61. echo "INFORME :".$ConDMUG->GetChild( "INFO1" )."\n" ;
  62. echo "INFORME :".$ConDMUG->GetChild( "INFO2" )."\n" ;
  63. echo "PUTRECORD:".$ConDMUG->GetChild( "PUTRECORD" )."\n" ;
  64. echo "REGISTROS:".$ConDMUG->GetChild( "REGISTROS" )."\n" ;
  65. $ConDMUG->CloseConex();
  66. if ( $RESULTADO== "EXACTO" )
  67. {
  68. echo "Se marca ZETA $Z_ZETA en PG TRANS es 1 \n";
  69. Marca_CABECERA( $obtieneDatos_pg , $v_ZETA , $v_i );
  70. }
  71. else
  72. {
  73. echo "ERROR en $Z_ZETA \n";
  74. }
  75. unset($v_ZETA);
  76. Finalizar();
  77. /***********************************************************************/
  78. function Finalizar()
  79. {
  80. system( "/bin/rm /tmp/ImpZeta.blk" );
  81. exit();
  82. }
  83. /***********************************************************************/
  84. /*----------------------- function Carga_CABECERA ---------------------*/
  85. /***********************************************************************/
  86. function Carga_CABECERA( $ConDMUG , $p_ZETA , $v_i )
  87. {
  88. # define FACTU_FAC_SUC (dbfield) 0x0a01 /* Integer /
  89. $ConDMUG->SetParameter("Z_SUC" , $p_ZETA[$v_i]['z_suc'] );
  90. # define FACTU_FAC_TIP (dbfield) 0x0a02 /* String
  91. $ConDMUG->SetParameter("Z_PTOVTA" , $p_ZETA[$v_i]['z_ptovta'] );
  92. # define FACTU_FAC_STIP (dbfield) 0x0a03 /* Integer
  93. $ConDMUG->SetParameter("Z_ESTADI" , $p_ZETA[$v_i]['z_estadi'] );
  94. # define FACTU_FAC_NRO (dbfield) 0x0a04 /* Long
  95. $ConDMUG->SetParameter("Z_ESTADF" , $p_ZETA[$v_i]['z_estadf'] );
  96. # define FACTU_FAC_FEC (dbfield) 0x0a05 /* Date /
  97. $ConDMUG->SetParameter("Z_ZETA" , $p_ZETA[$v_i]['z_zeta'] );
  98. # define FACTU_FAC_CLIE (dbfield) 0x0a06 /* Long /
  99. $ConDMUG->SetParameter("Z_CCANCEL" , $p_ZETA[$v_i]['z_ccancel'] );
  100. # define FACTU_FAC_FPED (dbfield) 0x0a07 /* Date /
  101. $ConDMUG->SetParameter("Z_CNFH" , $p_ZETA[$v_i]['z_cnfh'] );
  102. # define FACTU_FAC_NREP (dbfield) 0x0a08 /* Long /
  103. $ConDMUG->SetParameter("Z_CNFISCAL" , $p_ZETA[$v_i]['z_cnfiscal'] );
  104. # define FACTU_FAC_CPAG (dbfield) 0x0a09 /* Integer /
  105. $ConDMUG->SetParameter("Z_CFISCAL" , $p_ZETA[$v_i]['z_cfiscal'] );
  106. # define FACTU_FAC_IVA (dbfield) 0x0a0a /* Integer /
  107. $ConDMUG->SetParameter("Z_ULT_B" , $p_ZETA[$v_i]['z_ult_b'] );
  108. # define FACTU_FAC_CAJA (dbfield) 0x0a0b /* Integer /
  109. $ConDMUG->SetParameter("Z_ULT_A" , $p_ZETA[$v_i]['z_ult_a'] );
  110. # define FACTU_FAC_CAJ (dbfield) 0x0a0c /* Integer /
  111. $ConDMUG->SetParameter("Z_VFISCAL" , $p_ZETA[$v_i]['z_vfiscal'] * 100 );
  112. # define FACTU_FAC_FAC (dbfield) 0x0a0d /* Integer
  113. $ConDMUG->SetParameter("Z_IVAFISCAL" , $p_ZETA[$v_i]['z_ivafiscal'] * 100 );
  114. # define FACTU_FAC_SEC (dbfield) 0x0a0e /* String /
  115. $ConDMUG->SetParameter("Z_IIFISCAL" , $p_ZETA[$v_i]['z_iifiscal'] * 100 );
  116. # define FACTU_FAC_TVEN (dbfield) 0x0a0f /* String
  117. $ConDMUG->SetParameter("Z_PERFISCAL" , $p_ZETA[$v_i]['z_perfiscal'] * 100 );
  118. # define FACTU_FAC_COM (dbfield) 0x0a10 /* Long /
  119. $ConDMUG->SetParameter("Z_IVANIFI" , $p_ZETA[$v_i]['z_ivanifi'] * 100 );
  120. # define FACTU_FAC_COM (dbfield) 0x0a10 /* Long /
  121. $ConDMUG->SetParameter("Z_ULT_NCB" , $p_ZETA[$v_i]['z_ult_ncb'] );
  122. # define FACTU_FAC_TDEV (dbfield) 0x0a11 /* String
  123. $ConDMUG->SetParameter("Z_ULT_NCA" , $p_ZETA[$v_i]['z_ult_nva'] );
  124. # define FACTU_FAC_NDEV (dbfield) 0x0a13 /* Long /
  125. $ConDMUG->SetParameter("Z_CRED_NC" , $p_ZETA[$v_i]['z_cred_nc'] * 100 );
  126. # define FACTU_FAC_FDEV (dbfield) 0x0a14 /* Date
  127. $ConDMUG->SetParameter("Z_IVA_NC" , $p_ZETA[$v_i]['z_iva_nc'] * 100 );
  128. # define FACTU_FAC_DES (dbfield) 0x0a15 /* Long /
  129. $ConDMUG->SetParameter("Z_II_NC" , $p_ZETA[$v_i]['z_ii_nc'] * 100 );
  130. # define FACTU_FAC_RECCP (dbfield) 0x0a16 /* Long /
  131. $ConDMUG->SetParameter("Z_PER_NC", $p_ZETA[$v_i]['v_per_nc'] * 100 );
  132. # define FACTU_FAC_RECVT (dbfield) 0x0a17 /* Long /
  133. $ConDMUG->SetParameter("Z_IVANINC", $p_ZETA[$v_i]['z_ivaninc'] * 100 );
  134. # define FACTU_FAC_RECOF (dbfield) 0x0a18 /* Long /
  135. $ConDMUG->SetParameter("Z_ULT_REM", $p_ZETA[$v_i]['z_ult_rem'] );
  136. # define FACTU_FAC_RECUN (dbfield) 0x0a19 /* Long /
  137. $ConDMUG->SetParameter("Z_FGEN", $p_ZETA[$v_i]['z_fgen']) ;
  138. }
  139. /***********************************************************************/
  140. /*----------------------- function Carga_CABECERA ---------------------*/
  141. /***********************************************************************/
  142. function Marca_CABECERA( $obtieneDatos_pg , $p_ZETA , $v_i )
  143. {
  144. $SUC = $p_ZETA[$v_i]['z_suc'];
  145. $VTOVTA = $p_ZETA[$v_i]['z_ptovta'];
  146. $ZETA = $p_ZETA[$v_i]['z_zeta'];
  147. $FGEN = $p_ZETA[$v_i]['z_fgen'];
  148. $pg_sql_factu = "UPDATE minor.zeta SET z_trans = 1 WHERE z_suc = $SUC AND z_ptovta = '$VTOVTA' ";
  149. $pg_sql_factu .="AND z_zeta = $ZETA AND z_fgen = $FGEN ";
  150. $obtieneDatos_pg->obtenerDatos( $pg_sql_factu );
  151. ////$errorUPDATE = pg_last_error ( $obtieneDatos_pg );
  152. ///echo "Error=".$errorUPDATE."\n";
  153. return 1;
  154. }
  155. ?>