ture: all Version: 10.5.0-1ubuntu1~20.04cross1 Built-Using: gcc-10 (= 10.5.0-1ubuntu1~20.04) Priority: optional Section: universe/devel Source: gcc-10-cross (6ubuntu6) Origin: Ubuntu Maintainer: Ubuntu Core developers Original-Maintainer: Debian GCC Maintainers Bugs: https://bugs.launchpad.net/ubuntu/+filebug Installed-Size: 301 Depends: gcc-10-cross-base (>= 10.5.0-1ubuntu1~20.04), libc6 (>= 2.23) Filename: pool/universe/g/gcc-10-cross/libquadmath0-amd64-cross_10.5.0-1ubuntu1~20.04cross1_all.deb Size: 146384 MD5sum: c3578f8e4557ad1763dda4058785138c SHA1: af0bf2f4e668894542655093d8003eb9f56871d3 SHA256: 8171cd2232c06a0d6e2ae5f7e8ed88039ddcb37e4dbd87b9be720452ec0bba1b SHA512: 6f78a79efc80acc88349c8b65f8576fd4dd2f7cbc6ecc1304ab3a95fd9d2bdf89901360e463aad9211c8506fd1f7fe8211cf3399a437e2a28ec2bfb4ecdecbd3 Homepage: http://gcc.gnu.org/ Description: GCC Quad-Precision Math Library Description-md5: fb375c278b15a5774cef34cf9570ecc9 Package: libquadmath0-i386-cross Architecture: all Version: 10.5.0-1ubuntu1~20.04cross1 Built-Using: gcc-10 (= 10.5.0-1ubuntu1~20.04) Priority: optional Section: universe/devel Source: gcc-10-cross (6ubuntu6) Origin: Ubuntu Maintainer: Ubuntu Core developers Original-Maintainer: Debian GCC Maintainers Bugs: https://bugs.launchpad.net/ubuntu/+filebug Installed-Size: 696 Depends: gcc-10-cross-base (>= 10.5.0-1ubuntu1~20.04), libc6-i386-cross (>= 2.31) Filename: pool/universe/g/gcc-10-cross/libquadmath0-i386-cross_10.5.0-1ubuntu1~20.04cross1_all.deb Size: 229932 MD5sum: 1152a778a2818ead0ee03130d58b2baf SHA1: d7788863b1940e4b9221010b5da891d0597b86e7 SHA256: 0505412fc74b945d60d5c7b85748a885e2520aa035820fe0fe3a09ed0bb40b55 SHA512: 2e5ac275e405804884af2f83f428f135e35b41399e96e09f7b9bb61413b2b7f5dc378c8b9fbc420f4d2d4b5e0a39f18e2bb60b63aad69fbfd000897ba51b5445 Homepage: http://gcc.gnu.org/ Description: GCC Quad-Precision Math Library Description-md5: fb375c278b15a5774cef34cf9570ecc9 Package: libquadmath0-x32-cross Architecture: all Version: 10.2.0-5ubuntu1~20.04cross1 Built-Using: gcc-10 (= 10.2.0-5ubuntu1~20.04) Priority: optional Section: universe/devel Source: gcc-10-cross-ports (5ubuntu2) Origin: Ubuntu Maintainer: Ubuntu Core developers Original-Maintainer: Debian GCC Maintainers Bugs: https://bugs.launchpad.net/ubuntu/+filebug Installed-Size: 301 Depends: gcc-10-cross-base-ports (= 10.2.0-5ubuntu1~20.04cross1), libc6-x32-cross (>= 2.31) Filename: pool/universe/g/gcc-10-cross-ports/libquadmath0-x32-cross_10.2.0-5ubuntu1~20.04cross1_all.deb Size: 148084 MD5sum: fd4931a8f087f393ca7d4992bae1a395 SHA1: 0fd3b1ce2d9a0bd17931c52dba374a9f3fe40798 SHA256: 629de5f763cc59f20531214db18691fcbd206d4590c614899a752b4cc12d5ee3 SHA512: efe1186a90e6bd6a94212f95e998d0e6961dc5e4a0239cee7702c50c2af8e8b79fdb335fb3f82e44e4496f3c9daf600f382b3d0dab69e6fff97f577db68f988e Homepage: http://gcc.gnu.org/ Description: GCC Quad-Precision Math Library Description-md5: fb375c278b15a5774cef34cf9570ecc9 Package: libquadmath0-x32-cross Architecture: all Version: 10.5.0-1ubuntu1~20.04cross1 Built-Using: gcc-10 (= 10.5.0-1ubuntu1~20.04) Priority: optional Section: universe/devel Source: gcc-10-cross-ports (5ubuntu6) Origin: Ubuntu Maintainer: Ubuntu Core developers Original-Maintainer: Debian GCC Maintainers Bugs: https://bugs.launchpad.net/ubuntu/+filebug Installed-Size: 301 Depends: gcc-10-cross-base-ports (= 10.5.0-1ubuntu1~20.04cross1), libc6-x32-cross (>= 2.31) Filename: pool/universe/g/gcc-10-cross-ports/libquadmath0-x32-cross_10.5.0-1ubuntu1~20.04cross1_all.deb Size: 148444 MD5sum: acf56d9b4563cbff328f88a8165bfa26 SHA1: c6ed4aaf6760fbf84abd656e8580326058aeb925 SHA256: 35fe75b4854061b6217e973ddfe7bb4616477c0ad156e02c420723d19a24a426 SHA512: 83d827a7611f1cc9156fcf46d718cb2c601e704018bb478bdde8f3067848a7212e060b0cbf0d9716e8e0ac31314f784e8710900c6c182e95be1e0986f6a5d44a Homepage: http://gcc.gnu.org/ Description: GCC Quad-Precision Math Library Description-md5: fb375c278b15a5774cef34cf9570ecc9 Package: libraven0 Architecture: amd64 Version: 10.5.1-6ubuntu0.2 Priority: optional Section: universe/libs Source: budgie-desktop Origin: Ubuntu Maintainer: David Mohammed Bugs: https://bugs.launchpad.net/ubuntu/+filebug Installed-Size: 331 Depends: libbudgie-private0 (>= 10.4), libc6 (>= 2.4), libcairo2 (>= 1.2.4), libgdk-pixbuf2.0-0 (>= 2.23.0), libglib2.0-0 (>= 2.57), libgtk-3-0 (>= 3.21.4), libpango-1.0-0 (>= 1.14.0) Filename: pool/universe/b/budgie-desktop/libraven0_10.5.1-6ubuntu0.2_amd64.deb Size: 82296 MD5sum: d9c8f201b236a9093880b10b7cb96289 SHA1: b7260968a8b3e3d0b4e3caa8a4b81e689e98afb8 SHA256: 465693d2066d6223dcc27b400dec6bf5334da41bb19d562526e51604b8a1609d SHA512: 2b9a4d41c81bbf8751fd08e35e35d5a1ebcc7b9bdf6c79b0dc89dcbdaa76e26a4a72701a581c63e09e078c837d2403cd8fc890eccf316ca0e603889ba45b244d Homepage: https://github.com/solus-project/budgie-desktop Description: Raven library for budgie-desktop Task: ubuntu-budgie-desktop Description-md5: 79da31133055c18caac93b1de4c3a3e8 Package: libraw-bin Architecture: amd64 Version: 0.19.5-1ubuntu1.3 Multi-Arch: foreign Priority: optional Section: universe/graphics Source: libraw Origin: Ubuntu Maintainer: Ubuntu Developers Original-Maintainer: Debian PhotoTools Maintainers Bugs: https://bugs.launchpad.net/ubuntu/+filebug Installed-Size: 234 Depends: libc6 (>= 2.29), libgcc-s1 (>= 3.0), libgomp1 (>= 4.2.1), libraw19 (>= 0.19.0), libstdc++6 (>= 4.1.1) Filename: pool/universe/libr/libraw/libraw-bin_0.19.5-1ubuntu1.3_amd64.deb Size: 41780 MD5sum: cae0c463262d14fd73c82ee0789472bf SHA1: 156489dac9c8aa48280ebbfc3040199fd8704f46 SHA256: aab1c61c6ac61007cc039e9cf4b65739c2a69caf138e4a09aaa5f7022b44357a SHA512: eb8e2ba7945d9a85ca90eb0b7ff62ee62b058c1ffd8a4b4c475873d211525021193f6a7634c7d11cd523c9a66aa3cd039d9da118c2e4118ad02b1b775cd658eb Homepage: https://www.libraw.org Description: raw image decoder library (tools) Task: ubuntustudio-photography Description-md5: 4c913ed132454ab0396aa40ae3b9f9f5 Package: librdf-query-perl Architecture: all Version: 2.918-1ubuntu0.1 Priority: optional Section: universe/perl Origin: Ubuntu Maintainer: Ubuntu Developers Original-Maintainer: Debian Perl Group Bugs: https://bugs.launchpad.net/ubuntu/+filebug Installed-Size: 1202 Depends: perl:any, libossp-uuid-perl, libdatetime-format-w3cdtf-perl, liberror-perl, libjson-perl, libparse-recdescent-perl, libset-scalar-perl, perl (>= 5.12) | libfile-spec-perl, librdf-trine-perl (>= 1.004), liburi-perl (>= 1.52), libmodule-pluggable-perl | perl (<< 5.17.0), libcgi-pm-perl | perl (<< 5.19), libterm-readkey-perl Recommends: libwww-perl, libgetopt-simple-perl, libgeo-distance-perl Filename: pool/universe/libr/librdf-query-perl/librdf-query-perl_2.918-1ubuntu0.1_all.deb Size: 325020 MD5sum: 5f031aea8e5a992ccc3d7c9c8c7a6102 SHA1: 3e0b2546863533817b5058fd1247a0129a125db8 SHA256: e7f890e8d889c9ddb753def6dfe0fd277964f02eb8cf3d0f02111a9033e56b26 SHA512: d08f40d3e89d11f96487b13a1c9fc814a90bea30ea2817c84617ab1108ad337293e60f499b3e27108f71dd672e80d671522673b2ed77d6cf66ab391cd369631d Homepage: http://search.cpan.org/dist/RDF-Query/ Description: complete SPARQL 1.1 Query and Update implementation for RDF::Trine Description-md5: 3de7e2e029c96e18a7aa94e848f2782e Package: librecad Architecture: amd64 Version: 2.1.3-1.2+deb10u1build0.20.04.1 Priority: optional Section: universe/graphics Origin: Ubuntu Maintainer: Ubuntu Developers Original-Maintainer: Debian Science Maintainers Bugs: https://bugs.launchpad.net/ubuntu/+filebug Installed-Size: 8451 Depends: libc6 (>= 2.29), libgcc-s1 (>= 4.0), libmuparser2v5 (>= 2.2.6.1+dfsg), libqt5core5a (>= 5.12.2), libqt5gui5 (>= 5.2.0) | libqt5gui5-gles (>= 5.2.0), libqt5 "302", "message" => "ERROR - [wsCatalogoCuentas_v13] Parametros incompletos para el Servicio Web, faltan el Anio de vigencia"); $Resultado = json_encode($j_array); echo $Resultado; return $Resultado; } if($mesCata == "") { $j_array = array('code' => "303", "message" => "ERROR - [wsCatalogoCuentas_v13] Parametros incompletos para el Servicio Web, faltan el Mes de vigencia"); $Resultado = json_encode($j_array); echo $Resultado; return $Resultado; } if($organi_id_ZB == "") { $j_array = array('code' => "304", "message" => "ERROR - [wsCatalogoCuentas_v13] Parametros incompletos para el Servicio Web, faltan el Organization ID de Books"); $Resultado = json_encode($j_array); echo $Resultado; return $Resultado; } $dirBase = realpath("../"); ### DEFINICIÓN DE CONSTANTES ################################################### $SendaPEM = "archs_pem/"; $SendaXML = "archs_xml/"; $SendaZIP = "archs_zip/"; #---------------------------------------------------------------- # Creamos la conexión a la base de datos #---------------------------------------------------------------- $conn = mysqli_connect("127.0.0.1", "aptuslegal", "#Aptus2021#", "vendorbills"); if (!$conn) { echo "Error: No se pudo conectar a MySQL." . PHP_EOL; echo "errno de depuración: " . mysqli_connect_errno() . PHP_EOL; exit; } #---------------------------------------------------------------- # Traemos los valores de conexión utilizando el organizationId #---------------------------------------------------------------- $sql = 'SELECT * FROM conndetails WHERE organization_id = ' . $organi_id_ZB; if($result = $conn->query($sql)) { $row = $result->fetch_assoc(); } else exit('No se ejecuto la consulta'); #---------------------------------------------------------------- # Cerramos la conexión #---------------------------------------------------------------- mysqli_close($conn); #---------------------------------------------------------------- # Variables para Zoho Books #---------------------------------------------------------------- $appOwner = $row['appOwner']; $boa_RefreshToken = $row['zbooks_rtoken']; $boa_ClientId = $row['zbooksclient_id']; $boa_ClientSecret = $row['zbooksclient_secret']; $boa_RedirectUri = $row['RedirectUri']; $boa_AuthUrl = 'https://accounts.zoho.com/oauth/v2/token'; $boa_GrantType = "refresh_token"; #---------------------------------------------------------------- # Variables para Zoho Workdrive #---------------------------------------------------------------- $wdrv_parent_id = $row['zworkdrvcatcue_id']; $woa_RefreshToken = $row['zworkdrv_rtoken']; $woa_ClientId = $row['zworkdrvclient_id']; $woa_ClientSecret = $row['zworkdrvclient_secret']; $woa_RedirectUri = $row['RedirectUri']; $woa_AuthUrl = 'https://accounts.zoho.com/oauth/v2/token'; $woa_GrantType = "refresh_token"; #---------------------------------------------------------------- # RFC de la Organización #---------------------------------------------------------------- $regFeCa = $row['rfc']; // echo "Variables: ".$appOwner.', ZBooks'.", ".$boa_RefreshToken.", ".$boa_ClientId." ".$boa_ClientSecret.", ".$boa_RedirectUri.", ".$boa_GrantType.", boa_AuthUrl: ".$boa_AuthUrl."
"; $boa_access_token = oauth($appOwner, 'ZBooks', $boa_RefreshToken, $boa_ClientId, $boa_ClientSecret, $boa_RedirectUri, $boa_GrantType, $boa_AuthUrl); $request_url = "https://www.zohoapis.com/books/v3/chartofaccounts?sort_column=account_name&organization_id=".$organi_id_ZB; $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $request_url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); curl_setopt($ch, CURLOPT_HTTPHEADER, array('Authorization: Zoho-oauthtoken ' . $boa_access_token)); $r = curl_exec($ch); $array = json_decode($r); $bdCtasCont = $array->chartofaccounts; curl_close ($ch); #== Creación de la variable de tipo DOM, aquí se conforma el XML a timbrar posteriormente. $xml = new DOMdocument('1.0', 'UTF-8'); $root = $xml->createElement("catalogocuentas:Catalogo"); $root = $xml->appendChild($root); #== Se crea e inserta el primer nodo donde se declaran los namespaces ====== cargaAttNodo($root, array("xsi:schemaLocation"=>"http://www.sat.gob.mx/esquemas/ContabilidadE/1_3/CatalogoCuentas http://www.sat.gob.mx/esquemas/ContabilidadE/1_3/CatalogoCuentas/CatalogoCuentas_1_3.xsd", "xmlns:catalogocuentas"=>"http://www.sat.gob.mx/esquemas/ContabilidadE/1_3/CatalogoCuentas", "xmlns:xsi"=>"http://www.w3.org/2001/XMLSchema-instance" ) ); #== Rutina de integración de nodos ========================================= cargaAttNodo($root, array( "Version"=>"1.3", "RFC"=>$regFeCa, "Mes"=>$mesCata, "Anio"=>$anioCat ) ); $cantidadCuentas = count($bdCtasCont); $cantidadDeudoras = 0; $cantidadAcreedoras = 0; #== Ciclo "for", recopilación de datos del catalogo de cuentas e integración de sus respectivos nodos == for ($i=0; $i < $cantidadCuentas; $i++) { if($bdCtasCont[$i]->account_code != "" && $bdCtasCont[$i]->cf_c_digo_del_sat != "") { $naturCta = "A"; if($bdCtasCont[$i]->cf_naturaleza == "Deudora") { $naturCta = "D"; $cantidadDeudoras +=1; } else{ $cantidadAcreedoras +=1; } $nivelCta = "1"; if($bdCtasCont[$i]->depth == "1") { $nivelCta = "2"; } $cuentas = $xml->createElement("catalogocuentas:Ctas"); $cuenta = $root->appendChild($cuentas); if($bdCtasCont[$i]->parent_account_name == "") { cargaAttNodo($cuenta, array( "CodAgrup"=>$bdCtasCont[$i]->cf_c_digo_del_sat, "NumCta"=>$bdCtasCont[$i]->account_code, "Desc"=>utf8_decode(substr($bdCtasCont[$i]->account_name, 11)), "Nivel"=>$nivelCta, "Natur"=>$naturCta ) ); } else { cargaAttNodo($cuenta, array( "CodAgrup"=>$bdCtasCont[$i]->cf_c_digo_del_sat, "NumCta"=>$bdCtasCont[$i]->account_code, "Desc"=>utf8_decode(substr($bdCtasCont[$i]->account_name, 11)), "Nivel"=>$nivelCta, "Natur"=>$naturCta, "SubCtaDe"=>substr($bdCtasCont[$i]->parent_account_name, 0, 10) ) ); } } } #---------------------------------------------------------------- # Cerramos la conexión #---------------------------------------------------------------- mysqli_close($conn); #=== Se guarda el archivo .XML del Catalogo de Cuentas ======================= $file_name_with_full_path = '/var/www/html/aptusContaElec/archs_xml/'.$regFeCa.$anioCat.$mesCata."CT.xml"; #=== Si existe el archivo XML se elimina para crear el nuevo ======================= if(!file_exists($file_name_with_full_path)){ unlink($file_name_with_full_path); } #=== Se guarda el archivo XML creado ======================= $cfdi = $xml->saveXML(); $xml->formatOutput = true; $xml->save($file_name_with_full_path); unset($xml); #=== Se dan permisos de escritura al archivo .xml. ========================= chmod($SendaXML.$regFeCa.$anioCat.$mesCata."CT.xml", 0777); #=== Se procede a crear el archivo ZIP del Catalogo de Cuentas ========================= $zip = new ZipArchive(); $nombreArchivoZip = '/var/www/html/aptusContaElec/archs_zip/'.$regFeCa.$anioCat.$mesCata."CT.zip"; $nameArchZip = $regFeCa.$anioCat.$mesCata."CT.zip"; #=== Si existe el archivo ZIP se elimina para crear el nuevo ======================= if(!file_exists($nombreArchivoZip)){ unlink($nombreArchivoZip); } if (!$zip->open($nombreArchivoZip, ZipArchive::CREATE | ZipArchive::OVERWRITE)) { exit("Error abriendo ZIP en $nombreArchivoZip"); } $nombre = basename($file_name_with_full_path); $zip->addFile($file_name_with_full_path, $nombre); $resultado = $zip->close(); if (!$resultado) { echo "Error creando archivo"; exit("Error creando archivo ZIP"); } #---------------------------------------------------------------- # Se sube archivo ZIP a Workdrive #---------------------------------------------------------------- $woa_access_token = oauth($appOwner, 'ZWorkrdv', $woa_RefreshToken, $woa_ClientId, $woa_ClientSecret, $woa_RedirectUri, $woa_GrantType, $woa_AuthUrl); $urlWorkdrv = 'https://workdrive.zoho.com/api/v1/upload?parent_id='.$wdrv_parent_id.'&filename='.$nameArchZip.'&override-name-exist=true'; $curl = curl_init(); curl_setopt_array($curl, array( CURLOPT_URL => $urlWorkdrv, CURLOPT_RETURNTRANSFER => true, CURLOPT_ENCODING => '', CURLOPT_MAXREDIRS => 10, CURLOPT_TIMEOUT => 0, CURLOPT_FOLLOWLOCATION => true, CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, CURLOPT_CUSTOMREQUEST => 'POST', CURLOPT_POSTFIELDS => array('content'=> new CURLFILE($nombreArchivoZip)), CURLOPT_HTTPHEADER => array('Authorization: Zoho-oauthtoken '.$woa_access_token ), ) ); $response = curl_exec($curl); curl_close($curl); #=== FIN DEL PROCESO ======================= $xmlFilesPath = 'https://aptuslegal.app/aptusContaElec/archs_xml/'; $zipFilesPath = 'https://aptuslegal.app/aptusContaElec/archs_zip/'; $resultData = array('xmlFilesPath'=>$xmlFilesPath, 'xmlFileName'=>$regFeCa.$anioCat.$mesCata."CT.xml", 'zipFilesPath'=>$zipFilesPath, 'zipFileName' => $regFeCa.$anioCat.$mesCata."CT.zip", 'cantidadCuentas' => $cantidadCuentas, 'cantidadAcreedoras' => $cantidadAcreedoras, 'cantidadDeudoras' => $cantidadDeudoras); $j_array = array('code' => "200", 'message' => "Proceso de creacion de Archivo de Catalogo de Cuentas fue exitoso", "data"=>$resultData); $Resultado = json_encode($j_array); echo $Resultado; return $Resultado; ### FUNCIONES DEL MÓDULO ######################################################### # Función que integra los nodos al archivo .XML function cargaAttNodo(&$nodo, $attr){ global $xmldoc; foreach ($attr as $key => $val){ $val = preg_replace('/\s\s+/', ' ', $val); $val = trim($val); if (strlen($val)>0){ $val = utf8_encode(str_replace("|","/",$val)); $nodo->setAttribute($key,$val); } } }