diff --git a/ai/LocalAIApi.php b/ai/LocalAIApi.php index d428248..8c970bd 100644 --- a/ai/LocalAIApi.php +++ b/ai/LocalAIApi.php @@ -106,6 +106,10 @@ class LocalAIApi $cfg = self::config(); $projectUuid = $cfg['project_uuid']; + + // DEBUG LOGGING + file_put_contents(__DIR__ . '/../debug.log', date('Y-m-d H:i:s') . " - Requesting AI. UUID: [" . ($projectUuid ?? 'NULL') . "] CFG: " . json_encode($cfg) . "\n", FILE_APPEND); + if (empty($projectUuid)) { return [ 'success' => false, diff --git a/ai/config.php b/ai/config.php index b77c60c..d28308b 100644 --- a/ai/config.php +++ b/ai/config.php @@ -64,7 +64,7 @@ return [ 'responses_path' => $responsesPath, 'project_id' => $projectId, 'project_uuid' => $projectUuid, - 'project_header' => 'project-uuid', + 'project_header' => 'Project-UUID', 'default_model' => 'gpt-4o-mini', 'timeout' => 30, 'verify_tls' => true, diff --git a/ai_debug.log b/ai_debug.log new file mode 100644 index 0000000..e43feaf --- /dev/null +++ b/ai_debug.log @@ -0,0 +1 @@ +2026-02-21 18:35:57 - Requesting AI. UUID: [e1f9b5b3-fcef-4c8d-87d2-8630b1f72491] CFG: {"base_url":"https:\/\/flatlogic.com","responses_path":"\/projects\/38471\/ai-request","project_id":"38471","project_uuid":"e1f9b5b3-fcef-4c8d-87d2-8630b1f72491","project_header":"project-uuid","default_model":"gpt-4o-mini","timeout":30,"verify_tls":true} diff --git a/debug.log b/debug.log index ed20a90..d628037 100644 --- a/debug.log +++ b/debug.log @@ -2,3 +2,10 @@ 2026-02-21 17:52:37 - Items case hit 2026-02-21 17:53:18 - Items case hit 2026-02-21 18:10:28 - Items case hit +2026-02-21 18:21:01 - Items case hit +2026-02-21 18:23:51 - Items case hit +2026-02-21 18:36:35 - Requesting AI. UUID: [e1f9b5b3-fcef-4c8d-87d2-8630b1f72491] CFG: {"base_url":"https:\/\/flatlogic.com","responses_path":"\/projects\/38471\/ai-request","project_id":"38471","project_uuid":"e1f9b5b3-fcef-4c8d-87d2-8630b1f72491","project_header":"project-uuid","default_model":"gpt-4o-mini","timeout":30,"verify_tls":true} +2026-02-21 18:37:30 - Requesting AI. UUID: [e1f9b5b3-fcef-4c8d-87d2-8630b1f72491] CFG: {"base_url":"https:\/\/flatlogic.com","responses_path":"\/projects\/38471\/ai-request","project_id":"38471","project_uuid":"e1f9b5b3-fcef-4c8d-87d2-8630b1f72491","project_header":"project-uuid","default_model":"gpt-4o-mini","timeout":30,"verify_tls":true} +2026-02-21 18:42:10 - Requesting AI. UUID: [e1f9b5b3-fcef-4c8d-87d2-8630b1f72491] CFG: {"base_url":"https:\/\/flatlogic.com","responses_path":"\/projects\/38471\/ai-request","project_id":"38471","project_uuid":"e1f9b5b3-fcef-4c8d-87d2-8630b1f72491","project_header":"project-uuid","default_model":"gpt-4o-mini","timeout":30,"verify_tls":true} +2026-02-21 18:43:51 - Requesting AI. UUID: [e1f9b5b3-fcef-4c8d-87d2-8630b1f72491] CFG: {"base_url":"https:\/\/flatlogic.com","responses_path":"\/projects\/38471\/ai-request","project_id":"38471","project_uuid":"e1f9b5b3-fcef-4c8d-87d2-8630b1f72491","project_header":"Project-UUID","default_model":"gpt-4o-mini","timeout":30,"verify_tls":true} +2026-02-21 18:44:10 - Requesting AI. UUID: [e1f9b5b3-fcef-4c8d-87d2-8630b1f72491] CFG: {"base_url":"https:\/\/flatlogic.com","responses_path":"\/projects\/38471\/ai-request","project_id":"38471","project_uuid":"e1f9b5b3-fcef-4c8d-87d2-8630b1f72491","project_header":"Project-UUID","default_model":"gpt-4o-mini","timeout":30,"verify_tls":true} diff --git a/index.php b/index.php index 27e37e9..e7ebbc7 100644 --- a/index.php +++ b/index.php @@ -35,6 +35,16 @@ if ((isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] === 'on') || (isset($_SERVER[ } session_start(); +if (isset($_GET['action']) && $_GET['action'] === 'download_items_template') { + header('Content-Type: text/csv; charset=utf-8'); + header('Content-Disposition: attachment; filename=items_import_template.csv'); + $output = fopen('php://output', 'w'); + // Add BOM for Excel UTF-8 compatibility + fprintf($output, chr(0xEF).chr(0xBB).chr(0xBF)); + fputcsv($output, ['SKU', 'English Name', 'Arabic Name', 'Sale Price', 'Cost Price']); + fclose($output); + exit; +} if ($_SERVER['REQUEST_METHOD'] === 'POST') { file_put_contents('post_debug.log', date('Y-m-d H:i:s') . " - POST: " . json_encode($_POST) . "\n", FILE_APPEND); } @@ -9901,9 +9911,14 @@ $projectDescription = $_SERVER['PROJECT_DESCRIPTION'] ?? 'Accounting System';