112 lines
3.1 KiB
PHP
112 lines
3.1 KiB
PHP
<?php
|
|
|
|
|
|
// env_loader.php
|
|
|
|
// 1. Leer el archivo .env respetando tu formato exacto
|
|
$env_path = __DIR__ . '/.env';
|
|
if (!file_exists($env_path)) {
|
|
die('Error: Archivo .env no encontrado');
|
|
}
|
|
|
|
$env_vars = [];
|
|
$lines = file($env_path, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES);
|
|
|
|
foreach ($lines as $line) {
|
|
$line = trim($line);
|
|
|
|
// Ignorar líneas vacías o comentarios completos
|
|
if (empty($line) || strpos($line, '#') === 0) {
|
|
continue;
|
|
}
|
|
|
|
// Separar nombre y valor (incluyendo comentarios después del valor)
|
|
list($name, $value) = array_pad(explode('=', $line, 2), 2, '');
|
|
|
|
// Limpiar el valor (eliminar comentarios y espacios)
|
|
$clean_value = trim(preg_replace('/\s*#.*$/', '', $value)); // Elimina comentarios después del valor
|
|
$env_vars[trim($name)] = $clean_value;
|
|
}
|
|
|
|
// 2. Obtener APP_MODE exactamente como está en tu .env (con espacios)
|
|
$app_mode = trim($env_vars['APP_MODE']); // Esto capturará " 0" o " 1" de tu formato actual
|
|
|
|
// 3. Convertir a booleano de manera segura
|
|
$is_production = ($app_mode === '1'); // Comparación estricta con '1'
|
|
|
|
// API
|
|
$api_url = $is_production ? $env_vars['API_URL'] : $env_vars['DEV_API_URL'];
|
|
$api_key_definition = $is_production ? $env_vars['API_KEY_DEFINITION'] : $env_vars['DEV_API_KEY_DEFINITION'];
|
|
$api_key = $is_production ? $env_vars['API_KEY'] : $env_vars['DEV_API_KEY'];
|
|
|
|
// Base de Datos
|
|
$db_host = $is_production ? $env_vars['DB_HOST'] : $env_vars['DEV_DB_HOST'];
|
|
$db_user = $is_production ? $env_vars['DB_USER'] : $env_vars['DEV_DB_USER'];
|
|
$db_pass = $is_production ? $env_vars['DB_PASS'] : $env_vars['DEV_DB_PASS'];
|
|
$db_name = $is_production ? $env_vars['DB_NAME'] : $env_vars['DEV_DB_NAME'];
|
|
|
|
// SAP
|
|
$sap_url = $is_production ? $env_vars['SAP_URL'] : $env_vars['DEV_SAP_URL'];
|
|
$sap_usr = $is_production ? $env_vars['SAP_USR'] : $env_vars['DEV_SAP_USR'];
|
|
$sap_pass = $is_production ? $env_vars['SAP_PASS'] : $env_vars['DEV_SAP_PASS'];
|
|
|
|
// Rutas
|
|
$cfdi_xml_path = $env_vars['CFDI_XML_FILE_URL'] ?? '';
|
|
|
|
// // $rutaPRD = 'https://apis.hmngyportal.com';
|
|
|
|
$ruta = $api_url;
|
|
// $rutaHotel='https://pmsgateway.hmngyportal.com';
|
|
|
|
// // $rutaT = 'http://127.0.0.1:8000';
|
|
|
|
|
|
// $apiKeyBD = 'jNJdG9zBY92NSAALgnEdsoEIRycJiAScB6pBgIADsyg=';
|
|
|
|
/// Obtener clientes
|
|
$clientesUrl = "$ruta/api/SAP/Clientes";
|
|
|
|
// Obtener productos
|
|
$productosUrl = "$ruta/api/SAP/Productos";
|
|
|
|
//VTA_FACTURACION
|
|
$vtaFacturacionUrl = "$ruta/api/Venta/Facturacion";
|
|
|
|
//VTA_CABECERA
|
|
$vtaCabeceraUrl = "$ruta/api/Venta/Cabecera";
|
|
|
|
//VTA_DETALLE
|
|
$vtaDetalleUrl = "$ruta/api/Venta/Detalle";
|
|
|
|
//USO CFDI
|
|
$usoCfdiUrl = "$ruta/api/SAT/Uso_CFDI";
|
|
|
|
//Metodo pago
|
|
|
|
$metodoPagoUrl = "$ruta/api/SAP/Metodo_Pago";
|
|
|
|
//Via pago
|
|
|
|
$viaPagoUrl = "$ruta/api/SAP/Via_Pago";
|
|
|
|
$loginFacturacion = "$ruta/api/facturacion/login";
|
|
$loginUser = "$ruta/ttl/accessUser";
|
|
|
|
$usuariosFacturacion = "$ruta/api/facturacion";
|
|
|
|
|
|
///Registrar facturas, ver
|
|
|
|
$facturasPortal = "$ruta/api/facturacionR/creadas";
|
|
|
|
///Select aeropuertos
|
|
$aero_gaf_aeropuertosUrl = "$ruta/api/aero/gaf_aeropuertos/";
|
|
|
|
$api_factura = "$ruta/api/facturar";
|
|
|
|
$api_facturacion = "$ruta/api/facturacion/f";
|
|
|
|
$api_impuestos = "$ruta/api/f/h";
|
|
|
|
$facturacion_impuesto = "$ruta/api/facturacion/Impuesto_Unidad";
|