diff options
| author | Aldrik Ramaekers <aldrikboy@gmail.com> | 2025-09-27 18:38:35 +0200 |
|---|---|---|
| committer | Aldrik Ramaekers <aldrikboy@gmail.com> | 2025-09-27 18:38:35 +0200 |
| commit | d8c4d84dc75300c6d4d8b0adceafa33741960b92 (patch) | |
| tree | 00e2dfcc5c836d62fccff76c862e6ec3b0a74db8 /src/ui | |
| parent | fa088bb60692ba02d30d39affa9a31d9e2b688e2 (diff) | |
added http lib, working on AI invoice importing
Diffstat (limited to 'src/ui')
| -rw-r--r-- | src/ui/imgui_extensions.cpp | 9 | ||||
| -rw-r--r-- | src/ui/ui_expenses.cpp | 17 | ||||
| -rw-r--r-- | src/ui/ui_invoices.cpp | 2 | ||||
| -rw-r--r-- | src/ui/ui_log.cpp | 2 |
4 files changed, 21 insertions, 9 deletions
diff --git a/src/ui/imgui_extensions.cpp b/src/ui/imgui_extensions.cpp index 4dc1fb9..4a0117b 100644 --- a/src/ui/imgui_extensions.cpp +++ b/src/ui/imgui_extensions.cpp @@ -43,20 +43,19 @@ namespace ImGui } } - bool FormFileSelector(char* buffer) + bool FormInvoiceFileSelector(char* text, char* buffer) { bool result = false; float widthAvailable = ImGui::GetContentRegionAvail().x; ImGui::SetNextItemWidth(widthAvailable*0.5f); - if (ImGui::Button("Select file...")) // @localize + if (ImGui::Button(text)) { - // You can adjust filters, title, default path - const char *filterPatterns[] = { "*.png", "*.jpg", "*.pdf", "*" }; + const char *filterPatterns[] = { "*.pdf" }; const char *file = tinyfd_openFileDialog( "Choose a file", // dialog title // @localize NULL, // default path - 4, // number of filter patterns + 1, // number of filter patterns filterPatterns, // filter patterns array NULL, // single filter description (can be NULL) 0); // allowMultiple (0 = single) diff --git a/src/ui/ui_expenses.cpp b/src/ui/ui_expenses.cpp index 92f9c7c..790394a 100644 --- a/src/ui/ui_expenses.cpp +++ b/src/ui/ui_expenses.cpp @@ -27,6 +27,7 @@ #include "administration.hpp" #include "administration_writer.hpp" #include "locales.hpp" +#include "ai_service.hpp" static view_state current_view_state = view_state::LIST; static invoice active_invoice = {0}; @@ -85,7 +86,7 @@ static void draw_expense_form(invoice* buffer, bool viewing_only = false) ImGui::Separator(); - if (ImGui::FormFileSelector(buffer->document.original_path)) { + if (ImGui::FormInvoiceFileSelector("Select file...", buffer->document.original_path)) { // @localize buffer->document.copy_path[0] = 0; } @@ -162,7 +163,7 @@ static void ui_draw_expenses_list() s32 max_page = (total_invoice_count + items_per_page - 1) / items_per_page; if (max_page == 0) max_page = 1; - // Table header controls: create button and pagination. + // Table header controls: create, import, and pagination. if (ImGui::Button(localize("form.create"))) { current_view_state = view_state::CREATE; @@ -172,6 +173,18 @@ static void ui_draw_expenses_list() active_invoice.status = invoice_status::INVOICE_RECEIVED; } + char import_file_path[MAX_LEN_PATH] = {0}; + ImGui::SameLine(); + if (ImGui::FormInvoiceFileSelector("+ Import", import_file_path)) { // @localize + current_view_state = view_state::CREATE; + active_invoice = administration_invoice_create_empty(); // @leak + active_invoice.customer = administration_company_info_get(); + active_invoice.is_outgoing = 0; + active_invoice.status = invoice_status::INVOICE_RECEIVED; + + ai_document_to_invoice(import_file_path); + } + if (current_page >= max_page-1) current_page = max_page-1; if (current_page < 0) current_page = 0; diff --git a/src/ui/ui_invoices.cpp b/src/ui/ui_invoices.cpp index fdeafc6..1be0c82 100644 --- a/src/ui/ui_invoices.cpp +++ b/src/ui/ui_invoices.cpp @@ -206,7 +206,7 @@ static void draw_invoice_form(invoice* buffer, bool viewing_only = false) ImGui::Separator(); - if (ImGui::FormFileSelector(buffer->document.original_path)) { + if (ImGui::FormInvoiceFileSelector("Select file...", buffer->document.original_path)) { // @localize buffer->document.copy_path[0] = 0; } diff --git a/src/ui/ui_log.cpp b/src/ui/ui_log.cpp index 5b380a3..fa56f4a 100644 --- a/src/ui/ui_log.cpp +++ b/src/ui/ui_log.cpp @@ -23,7 +23,7 @@ void ui_draw_log() { - log* l = get_log(); + program_log* l = get_log(); for (int i = (int)l->history_length-1; i >= 0; i--) { |
