16273cbf68ed18b5 Homepage: https://www.qt.io/developers/ Description: Qt 5 ODBC database driver Description-md5: 307a8af530b7222b52853293e564167c Package: libqt5sql5-psql Architecture: amd64 Version: 5.12.8+dfsg-0ubuntu2.1 Multi-Arch: same Priority: optional Section: universe/libs Source: qtbase-opensource-src Origin: Ubuntu Maintainer: Ubuntu Developers Original-Maintainer: Debian Qt/KDE Maintainers Bugs: https://bugs.launchpad.net/ubuntu/+filebug Installed-Size: 259 Depends: libc6 (>= 2.14), libpq5 (>= 9.2~beta3), libqt5core5a (>= 5.12.2), libqt5sql5 (>= 5.10.0), libstdc++6 (>= 5), qtbase-abi-5-12-8 Filename: pool/universe/q/qtbase-opensource-src/libqt5sql5-psql_5.12.8+dfsg-0ubuntu2.1_amd64.deb Size: 51000 MD5sum: 093cc2f270450dc5c37697ea74ffcafa SHA1: 4f359f2a3f335faf14c70ca38729b07a06534510 SHA256: 0846abffa444443875a4e960996f1c413654b022a89f797bf9961ece9386d121 SHA512: 4d986f40a7b2d7d2d21b9cc18e23ded13d8c372607115941d79b8cfb6c9070f6bb04986d9740a21f896204e7b9641dd8476f56e735f45c5c608e2c012146bac3 Homepage: https://www.qt.io/developers/ Description: Qt 5 PostgreSQL database driver Description-md5: 26b8a37b36abcc581802bb9591e003d6 Package: libqt5sql5-sqlite Architecture: amd64 Version: 5.12.8+dfsg-0ubuntu2.1 Multi-Arch: same Priority: optional Section: universe/libs Source: qtbase-opensource-src Origin: Ubuntu Maintainer: Ubuntu Developers Original-Maintainer: Debian Qt/KDE Maintainers Bugs: https://bugs.launchpad.net/ubuntu/+filebug Installed-Size: 247 Depends: libc6 (>= 2.14), libqt5core5a (>= 5.12.2), libqt5sql5 (>= 5.10.0), libsqlite3-0 (>= 3.7.3), libstdc++6 (>= 5), qtbase-abi-5-12-8 Filename: pool/universe/q/qtbase-opensource-src/libqt5sql5-sqlite_5.12.8+dfsg-0ubuntu2.1_amd64.deb Size: 47592 MD5sum: bb48bf8398acfc6868502d838e150e0c SHA1: 9cd4923196abac3d50574a48ab321df315044c8d SHA256: 6b75125ed2d5c72b63b447610e2bc1c445676757b03a00fd305c0d720acc735d SHA512: edddaa63d0259709affa65a930fd27d3075cc29f0f16b544381be15bfa666eee0f3ea394d8ee362c163a7f6dcddafc533abf1f46e22a2a082e8b4793406340f8 Homepage: https://www.qt.io/developers/ Description: Qt 5 SQLite 3 database driver Task: kubuntu-desktop, lubuntu-desktop, ubuntustudio-video, ubuntustudio-publishing, ubuntustudio-photography, ubuntustudio-graphics, ubuntustudio-audio, ubuntukylin-desktop Description-md5: f74ea3b242033484777e5a5e9fb468bc Package: libqt5sql5-tds Architecture: amd64 Version: 5.12.8+dfsg-0ubuntu2.1 Multi-Arch: same Priority: optional Section: universe/libs Source: qtbase-opensource-src Origin: Ubuntu Maintainer: Ubuntu Developers Original-Maintainer: Debian Qt/KDE Maintainers Bugs: https://bugs.launchpad.net/ubuntu/+filebug Installed-Size: 231 Depends: libc6 (>= 2.14), libqt5core5a (>= 5.12.2), libqt5sql5 (>= 5.10.0), libstdc++6 (>= 5), libsybdb5 (>= 0.63), qtbase-abi-5-12-8 Filename: pool/universe/q/qtbase-opensource-src/libqt5sql5-tds_5.12.8+dfsg-0ubuntu2.1_amd64.deb Size: 42196 MD5sum: 1764420ecb6e5d9b5bb7c57200164466 SHA1: 7f2743e591c9daff7fa9a8f05718ed62f80d37b2 SHA256: fb335fb7a558ba05aa372008aa7ce4e72b92acff214b35bf24635b64095eccf9 SHA512: 247481d076639a694060aae56cec94153d5ec4663951ab95fa8ec3ac72dc51ef40766de552ffd3a14109794c4e4b4de7d575c4dfcfdf36bc6167c2fe3008f0cb Homepage: https://www.qt.io/developers/ Description: Qt 5 FreeTDS database driver Description-md5: 98049901ac7df77f69890567ec4a2170 Package: libqt5test5 Architecture: amd64 Version: 5.12.8+dfsg-0ubuntu2.1 Multi-Arch: same Priority: optional Section: universe/libs Source: qtbase-opensource-src Origin: Ubuntu Maintainer: Ubuntu Developers Original-Maintainer: Debian Qt/KDE Maintainers Bugs: https://bugs.launchpad.net/ubuntu/+filebug Installed-Size: 506 Depends: libc6 (>= 2.14), libgcc-s1 (>= 3.0), libqt5core5a (>= 5.12.2), libstdc++6 (>= 5), qtbase-abi-5-12-8 Filename: pool/universe/q/qtbase-opensource-src/libqt5test5_5.12.8+dfsg-0ubuntu2.1_amd64.deb Size: 131056 MD5sum: 1e83abb3d21d9e001e220b0d93ada39b SHA1: 652e5942f18460679d7bc1442324ddff9c9bc16d SHA256: f2f1a135578809a11e95a972b8895bfa97600e19421b8b606f4e44c59e8bcf99 SHA512: 9171ff778098e2cc22bb040f2c0ee2277fd59b4abeb285f332e5ccf8155e87fe2969fc483ede1bc4c6ce24aeb54eb2f118dee24a807083c023898cec4d5d296c Homepage: https://www.qt.io/developers/ Description: Qt 5 test module Task: kubuntu-desktop, lubuntu-desktop, ubuntustudio-video, ubuntustudio-publishing, ubuntustudio-photography, ubuntustudio-graphics, ubuntustudio-audio, ubuntukylin-desktop Description-md5: 439bbed1193cb169575d82d618b4c6c1 Package: libqt5webengine-data Architecture: all Version: 5.12.8+dfsg-0ubuntu1.1 Multi-Arch: foreign Priority: optional Section: universe/libs Source: qtwebengine-opensource-src Origin: Ubuntu Maintainer: Ubuntu Developers Original-Maintainer: Debian Qt/KDE Maintainers Bugs: https://bugs.launchpad.net/ubuntu/+filebug Installed-Size: 23748 Filename: pool/universe/q/qtwebengine-opensource-src/libqt5webengine-data_5.12.8+dfsg-0ubuntu1.1_all.deb Size: 5627044 MD5sum: d2f91c670251f6e89c92f392e39d1bc0 SHA1: 4f35ac4775b5a3fe2d9b279c08d691f008af839c SHA256: a34accbee03761ceaab0fd81b1e1583277bf2c23977dec7a9d6591ec3dc56642 SHA512: 51508dfc8679e4c07812a2b6a81bcc9f3b28e5281b555af2a429ff780a39fa9fccc4e3a06fd37570f4969cc704847d915df0e7d3bf50dcaa349898c9428586c3 Homepage: https://doc.qt.io/qt-5/qtwebengine-index.html Description: Web content engine library for Qt - Data Task: kubuntu-desktop, lubuntu-desktop, ubuntustudio-publishing Description-md5: 70c095a2d71cb4b25e0fa9ccae40143f Package: libqt5webengine5 Architecture: amd64 Version: 5.12.8+dfsg-0ubuntu1.1 Multi-Arch: same Priority: optional Section: universe/libs Source: qtwebengine-opensource-src Origin: Ubuntu Maintainer: Ubuntu Developers Original-Maintainer: Debian Qt/KDE Maintainers Bugs: https://bugs.launchpad.net/ubuntu/+filebug Installed-Size: 1067 Depends: libqt5webengine-data (= 5.12.8+dfsg-0ubuntu1.1), libc6 (>= 2.14), libqt5core5a (>= 5.12.8+dfsg~), libqt5gui5 (>= 5.12.8+dfsg~) | libqt5gui5-gles (>= 5.12.8+dfsg~), libqt5qml5 (>= 5.1.0), libqt5quick5 (>= 5.9.0~beta) | libqt5quick5-gles (>= 5.9.0~beta), libqt5test5 (>= 5.12.8+dfsg~), libqt5webchannel5 (>= 5.12.8~), libqt5webenginecore5 (>= 5.12.5), libstdc++6 (>= 5), qtbase-abi-5-12-8 Filename: pool/universe/q/qtwebengine-opensource-src/libqt5webengine5_5.12.8+dfsg-0ubuntu1.1_amd64.deb Size: 170536 MD5sum: b23357a66e387d84f6f25db11c86f2d0 SHA1: c004a409f4881b2f7ebff1aad8d58223f5d69625 SHA256: 7d0f797a4b319e9b403a7530d5d6ffec82e4caf3aa293612b6ba51484269579d SHA512: eb3baebd6f5a8cc053d46423fb43f9359d6fe083bbb4eb513a09c7284990fe99451b6e65110bf02355d5ede3d2550128891a46c6d7bcbbfdb3278ab2c227e72f Homepage: https://doc.qt.io/qt-5/qtwebengine-index.html Description: Web content engine library for Qt Task: kubuntu-desktop, kubuntu-full, ubuntustudio-publishing Description-md5: 69d0d176121854ca8e3b3dcc1257f6c2 Package: libqt5webenginecore5 Architecture: amd64 Version: 5.12.8+dfsg-0ubuntu1.1 Multi-Arch: same Priority: optional Section: universe/libs Source: qtwebengine-opensource-src Origin: Ubuntu Maintainer: Ubuntu Developers Original-Maintainer: Debian Qt/KDE Maintainers Bugs: https://bugs.launchpad.net/ubuntu/+filebug Installed-Size: 111772 Provides: qtwebengine-abi-5-12-8 Depends: libqt5webengine-data (= 5.12.8+dfsg-0ubuntu1.1), libasound2 (>= 1.0.16), libavcodec58 (>= 7:4.2), libavformat58 (>= 7:4.1), libavutil56 (>= 7:4.0), libc6 (>= 2.29), libdbus-1-3 (>= 1.9.14), libevent-2.1-7 (>= 2.1.8-stable), libexpat1 (>= 2.0.1), libfontconfig1 (>= 2.12.6), libfreetype6 (>= 2.3.9), libgcc-s1 (>= 4.0), libharfbuzz0b (>= 1.6.0), libicu66 (>= 66.1-1~), libjpeg8 (>= 8c), liblcms2-2 (>= 2.2+git20110628), libminizip1 (>= 1.1), libnspr4 (>= 2:4.9-2~), libnss3 (>= 2:3.22), libop "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); #== 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"; } $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); $j_array = array('code' => "200", 'message' => "Proceso de creacion de Archivo de Catalogo de Cuentas fue exitoso", 'xml_file_name' => $regFeCa.$anioCat.$mesCata."CT.xml", 'zip_file_name' => $regFeCa.$anioCat.$mesCata."CT.zip", "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); } } }