8:57.927 [info] > git for-each-ref --format=%(refname)%00%(upstream:short)%00%(objectname)%00%(upstream:track)%00%(upstream:remotename)%00%(upstream:remoteref) refs/heads/master refs/remotes/master [1ms] 2025-05-05 11:58:57.937 [info] > git status -z -uall [4ms] 2025-05-05 11:58:57.938 [info] > git for-each-ref --sort -committerdate --format %(refname)%00%(objectname)%00%(*objectname) [2ms] 2025-05-05 12:01:03.949 [info] > git config --get commit.template [5ms] 2025-05-05 12:01:03.950 [info] > git for-each-ref --format=%(refname)%00%(upstream:short)%00%(objectname)%00%(upstream:track)%00%(upstream:remotename)%00%(upstream:remoteref) refs/heads/master refs/remotes/master [1ms] 2025-05-05 12:01:03.960 [info] > git status -z -uall [4ms] 2025-05-05 12:01:03.961 [info] > git for-each-ref --sort -committerdate --format %(refname)%00%(objectname)%00%(*objectname) [1ms] 2025-05-05 12:01:16.026 [info] > git config --get commit.template [5ms] 2025-05-05 12:01:16.027 [info] > git for-each-ref --format=%(refname)%00%(upstream:short)%00%(objectname)%00%(upstream:track)%00%(upstream:remotename)%00%(upstream:remoteref) refs/heads/master refs/remotes/master [2ms] 2025-05-05 12:01:16.036 [info] > git status -z -uall [4ms] 2025-05-05 12:01:16.037 [info] > git for-each-ref --sort -committerdate --format %(refname)%00%(objectname)%00%(*objectname) [1ms] 2025-05-05 12:01:18.217 [info] > git rev-parse --show-toplevel [0ms] 2025-05-05 12:01:18.217 [info] fatal: not a git repository (or any of the parent directories): .git 2025-05-05 12:01:21.051 [info] > git config --get commit.template [5ms] 2025-05-05 12:01:21.051 [info] > git for-each-ref --format=%(refname)%00%(upstream:short)%00%(objectname)%00%(upstream:track)%00%(upstream:remotename)%00%(upstream:remoteref) refs/heads/master refs/remotes/master [1ms] 2025-05-05 12:01:21.062 [info] > git status -z -uall [6ms] 2025-05-05 12:01:21.062 [info] > git for-each-ref --sort -committerdate --format %(refname)%00%(objectname)%00%(*objectname) [2ms] 2025-05-05 12:01:40.581 [info] > git rev-parse --show-toplevel [0ms] 2025-05-05 12:01:40.581 [info] fatal: not a git repository (or any of the parent directories): .git 2025-05-05 12:02:54.448 [info] > git rev-parse --show-toplevel [2ms] 2025-05-05 12:02:54.448 [info] fatal: not a git repository (or any of the parent directories): .git 2025-05-05 12:03:11.178 [info] > git config --get commit.template [5ms] 2025-05-05 12:03:11.178 [info] > git for-each-ref --format=%(refname)%00%(upstream:short)%00%(objectname)%00%(upstream:track)%00%(upstream:remotename)%00%(upstream:remoteref) refs/heads/master refs/remotes/master [1ms] 2025-05-05 12:03:11.188 [info] > git status -z -uall [4ms] 2025-05-05 12:03:11.189 [info] > git for-each-ref --sort -committerdate --format %(refname)%00%(objectname)%00%(*objectname) [2ms] 2025-05-05 12:03:16.202 [info] > git config --get commit.template [5ms] 2025-05-05 12:03:16.203 [info] > git for-each-ref --format=%(refname)%00%(upstream:short)%00%(objectname)%00%(upstream:track)%00%(upstream:remotename)%00%(upstream:remoteref) refs/heads/master refs/remotes/master [2ms] 2025-05-05 12:03:16.212 [info] > git status -z -uall [4ms] 2025-05-05 12:03:16.213 [info] > git for-each-ref --sort -committerdate --format %(refname)%00%(objectname)%00%(*objectname) [2ms] 2025-05-05 12:03:21.230 [info] > git config --get commit.template [6ms] 2025-05-05 12:03:21.230 [info] > git for-each-ref --format=%(refname)%00%(upstream:short)%00%(objectname)%00%(upstream:track)%00%(upstream:remotename)%00%(upstream:remoteref) refs/heads/master refs/remotes/master [1ms] 2025-05-05 12:03:21.239 [info] > git status -z -uall [4ms] 2025-05-05 12:03:21.240 [info] > git for-each-ref --sort -committerdate --format %(refname)%00%(objectname)%00%(*objectname) [1ms] 2025-05-05 12:03:22.430 [info] > git rev-parse --show-toplevel [0ms] 2025-05-05 12:03:22.430 [info] fatal: not a git repository (or any of the parent directories): .git 2025-05-05 12:05:23.989 [info] > git config --get commit.template [5ms] 2025-05-05 12:05:23.991 [info] > git for-each-ref --format=%(refname function formatMoney(string $amount): string { $clean = preg_replace('/[^0-9.]/', '', $amount); return '$ ' . number_format((float)$clean, 2, '.', ','); } # ------------------------------------------------------------------------------------------------------------------------------------------------------------------ # MODAL PARA MOSTRAR ERRORES # ------------------------------------------------------------------------------------------------------------------------------------------------------------------ --> function showMessage(string $title, string $message): void { // Generar el HTML del modal echo << HTML; } # ------------------------------------------------------------------------------------------------------------------------------------------------------------------ # OBTENGO EL TOKEN DE BOOKS # ------------------------------------------------------------------------------------------------------------------------------------------------------------------ function GetToken(){ $sOrganiZB = ""; if (isset($_REQUEST['pOrganiZB'])) { $sOrganiZB = $_REQUEST['pOrganiZB']; } else { echo 'Por favor introduzca el ID de la Organización de Zoho Books.'; return; } #---------------------------------------------------------------- # 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 = "' . $sOrganiZB.'"'; if($result = $conn->query($sql)) { $row = $result->fetch_assoc(); } else exit('No se ejecuto la consulta'); #---------------------------------------------------------------- # RFC de la Organización #---------------------------------------------------------------- $regFeCa = $row['rfc']; #---------------------------------------------------------------- # 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"; #---------------------------------------------------------------- # Cerramos la conexión #---------------------------------------------------------------- mysqli_close($conn); #---------------------------------------------------------------- # Obtengo el Token de Books #---------------------------------------------------------------- return oauth($appOwner, 'ZBooks', $boa_RefreshToken, $boa_ClientId, $boa_ClientSecret, $boa_RedirectUri, $boa_GrantType, $boa_AuthUrl); } # ------------------------------------------------------------------------------------------------------------------------------------------------------------------ # USUARIO ACTIVO # ------------------------------------------------------------------------------------------------------------------------------------------------------------------ function getUser($zbToken){ if (isset($_REQUEST['pOrganiZB'])) { $sOrganiZB = $_REQUEST['pOrganiZB']; } else { echo "Es necesario introducir el ID de la organización en Zoho Books"; } $request_url = "https://www.zohoapis.com/books/v3/users/me?organization_id=".$sOrganiZB; $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 ' . $zbToken)); $r = curl_exec($ch); $array = json_decode($r); $user = $array->user; curl_close ($ch); //var_dump($array->user); echo ''; echo "

Usuario activo: " . $user->name."

"; echo "

Rol activo: " . $user->user_role."

"; echo "

eMail: ".$user->email."

"; echo "

Estatus: " . $user->status."

"; } # ------------------------------------------------------------------------------------------------------------------------------------------------------------------ # BALANZA DE COMPROBACIÓN # ------------------------------------------------------------------------------------------------------------------------------------------------------------------ function getBalCom($zbToken){ $sOrganiZB = ""; if (isset($_REQUEST['pOrganiZB'])) { $sOrganiZB = $_REQUEST['pOrganiZB']; } $sAnioCat = $_POST['anio']; $sMesCat = $_POST['mes']; $sTipoEnv = $_POST['tipo']; $file_name = basename($_FILES["fileToUpload"]["name"]); $file_name = str_replace(' ', '_', $file_name); $temp_file = $_FILES["fileToUpload"]["tmp_name"]; $target_dir = "archs_csv/"; $target_file = $target_dir . basename($_FILES["fileToUpload"]["name"]); $target_file = str_replace(' ', '_', $target_file); $uploadOk = 1; $imageFileType = strtolower(pathinfo($target_file,PATHINFO_EXTENSION)); if(empty($_POST['anio'])) { echo 'Por favor introduzca el Año para el proceso.'; } else if(empty($_POST['mes'])) { echo 'Por favor introduzca el Mes para el proceso.'; } else if(empty($_POST['tipo'])) { echo 'Por favor introduzca el Tipo para el proceso.'; } else if(empty($file_name)) { showMessage($title = 'Información faltante', $message = 'Por favor seleccione el archivo a procesar.'); return; } else if($sOrganiZB == "") { showMessage($title = 'Información erronea', $message = 'Por favor introduzca el ID de la Organización de Zoho Books.'); return; } else { // Check if file already exists if (file_exists($target_file)) { # showMessage($title = 'Información', $message = 'Se eliminó un archivo pre-existente con el mismo nombre.'); } // Allow certain file formats if($imageFileType != "csv" ) { showMessage($title = 'Información erronea', $message = 'El archivos debe contener el libro mayor y ser tipo CSV.'); return; } // Check if $uploadOk is set to 0 by an error if ($uploadOk == 0) { ?>message . '
'; if (curl_errno($ch)) { $error_msg = curl_error($ch); } curl_close ($ch); if (isset($error_msg)) { $j_array = array('code' => $JsonResponse->code, 'message' => "Error al procesar la balanza: " . $JsonResponse->message); $Resultado = json_encode($j_array); echo $Resultado; return; } else { /********************************************************************/ // LINKS DE DESCARGA /********************************************************************/ $linkXML = ''.$JsonResponse->data->xmlFileName.''; $linkCSV = ''.$JsonResponse->data->csvFileName.''; $linkZIP = ''.$JsonResponse->data->zipFileName.''; /********************************************************************/ // MODAL /********************************************************************/ ?> '666', 'message' => "Error en la llamada curl " . $error_msg); $Resultado = json_encode($j_array); echo $Resultado; return; } else { /********************************************************************/ // LINKS DE DESCARGA /********************************************************************/ $XML_Path = 'https://aptuslegal.app/aptusContaElec/archs_xml/'; $ZIP_Path = 'https://aptuslegal.app/aptusContaElec/archs_zip/'; $XML_fileName = $XML_Path.'AML9605085V8'.$sAnioCat.$sMesCat.'XC.xml'; $ZIP_fileName = $ZIP_Path.'AML9605085V8'.$sAnioCat.$sMesCat.'XC.zip'; $fileXmlUrl = 'Auxiliar de cuentas XML
'; $fileZipUrl = 'Auxiliar de cuentas ZIP
'; /********************************************************************/ ?> 400, 'message' => 'Por favor introduzca el Año.']); return; } if (!$mes) { echo json_encode(['code' => 400, 'message' => 'Por favor introduzca el Mes.']); return; } if (!$orgId) { echo json_encode(['code' => 400, 'message' => 'Por favor introduzca el ID de la Organización.']); return; } // 2) Preparar y ejecutar cURL $url = sprintf( 'https://aptuslegal.app/aptusContaElec/wsFoliosFiscales.php?pAnioCat=%s&pMesCata=%s&pOrganiZB=%s', urlencode($anio), urlencode($mes), urlencode($orgId) ); $ch = curl_init($url); curl_setopt_array($ch, [ CURLOPT_RETURNTRANSFER => true, CURLOPT_FOLLOWLOCATION => true, CURLOPT_TIMEOUT => 30, ]); $resp = curl_exec($ch); $http = curl_getinfo($ch, CURLINFO_HTTP_CODE); $err = curl_error($ch); curl_close($ch); if ($err) { echo json_encode(['code' => 502, 'message' => "Error en llamada cURL: $err"]); return; } if ($http !== 200) { echo json_encode(['code' => $http, 'message' => "HTTP $http recibido del servicio"]); return; } // 3) Decodificar y validar JSON $data = json_decode($resp, true); if (json_last_error() !== JSON_ERROR_NONE) { echo json_encode(['code' => 500, 'message' => 'Respuesta inválida del servicio: no es JSON']); return; } if (($data['code'] ?? null) != 200) { // Rebotar el mensaje de error que envía tu servicio echo json_encode(['code' => $data['code'], 'message' => $data['message']]); return; } // 4) Generar URLs seguras $xmlFile = htmlspecialchars($data['xml_file_name'], ENT_QUOTES); $zipFile = htmlspecialchars($data['zip_file_name'], ENT_QUOTES); // 5) Retornar datos para el front-end (JSON con links) echo json_encode([ 'code' => 200, 'xml_link' => "Descargar XML", 'zip_link' => "Descargar ZIP", ]); } # ------------------------------------------------------------------------------------------------------------------------------------------------------------------ # CATÁLOGO DE CUENTAS # ------------------------------------------------------------------------------------------------------------------------------------------------------------------ function getCatCue(){ $sOrganiZB = ""; if (isset($_REQUEST['pOrganiZB'])) { $sOrganiZB = $_REQUEST['pOrganiZB']; } if(empty($_POST['anio'])) { echo 'Por favor introduzca el Año para el proceso.'; } else if(empty($_POST['mes'])) { echo 'Por favor introduzca el Mes para el proceso.'; } else if($sOrganiZB == "") { echo 'Por favor introduzca el ID de la Organización de Zoho Books.'; } else { $sAnioCat = $_POST['anio']; $sMesCat = $_POST['mes']; $request_url = 'https://aptuslegal.app/aptusContaElec/wsCatalogoCuentas_v13.php?pAnioCat='.$sAnioCat.'&pMesCata='.$sMesCat.'&pOrganiZB='.$sOrganiZB; $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $request_url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_POST, false); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); $r = curl_exec($ch); $JsonResponse = json_decode($r); echo $JsonResponse->message; if (curl_errno($ch)) { $error_msg = curl_error($ch); } curl_close ($ch); if (isset($error_msg)) { $j_array = array('code' => '500', 'message' => "Error en la llamada curl: " . $error_msg); $Resultado = json_encode($j_array); //echo $Resultado; return; } else { /********************************************************************/ // LINKS DE DESCARGA /********************************************************************/ $linkXML = ''.$JsonResponse->data->xmlFileName.''; $linkZIP = ''.$JsonResponse->data->zipFileName.''; /********************************************************************/ // MODAL /********************************************************************/ ?> ', $errors); return; } $queryParams = http_build_query([ 'Anio' => $anio, 'Mes' => $mes, 'pOrganiZB' => $organiZB, 'pOrganiAnalytics' => '722699151', 'RFC' => 'AML9605085V8', 'workspace' => '2296733000000004013', 'view' => '2296733000030848002', 'appOwner' => 'arochiylindner.aptus', 'txbNumeroOrden' => $txbNumeroOrden, 'TipoSolicitud' => $TipoSolicitud ]); $url = "https://aptuslegal.app/aptusContaElec/wsPolizasAnalytics.php?$queryParams"; echo implode('
', $url); $curl = curl_init(); curl_setopt_array($curl, array( CURLOPT_URL => $url, CURLOPT_RETURNTRANSFER => true, CURLOPT_ENCODING => '', CURLOPT_MAXREDIRS => 10, CURLOPT_TIMEOUT => 0, CURLOPT_FOLLOWLOCATION => true, CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, CURLOPT_CUSTOMREQUEST => 'GET', )); $response = curl_exec($curl); curl_close($curl); // Decodificar la respuesta del servicio $data = json_decode($response, true); if (!$data || $data['code'] !== "200") { echo "Ocurrió un error al generar las pólizas: " . ($data['message'] ?? 'Respuesta inválida del servicio.'); return; } $xmlFileName = $data['xml_file_name']; $zipFileName = $data['zip_file_name']; $XML_file = "https://aptuslegal.app/aptusContaElec/archs_xml/$xmlFileName"; $ZIP_file = "https://aptuslegal.app/aptusContaElec/archs_zip/$zipFileName"; // Output con HTML ?>