#include #include "strops.hpp" #include "ui.hpp" #include "imgui.h" #include "administration.hpp" #include "locales.hpp" static view_state current_view_state = view_state::LIST; static invoice active_invoice; void ui_setup_invoices() { current_view_state = view_state::LIST; active_invoice = administration_create_empty_invoice(); } bool draw_invoice_form(invoice* buffer, bool back_button_enabled = true, bool viewing_only = false) { if (back_button_enabled) { if (ImGui::Button(localize("form.back"))) { current_view_state = view_state::LIST; return false; } } ImGui::Spacing(); float widthAvailable = ImGui::GetContentRegionAvail().x; // 1. Identifier //ImGui::BeginDisabled(); //ImGui::SetNextItemWidth(widthAvailable*0.2f); //ImGui::InputText(localize("contact.form.identifier"), buffer->id, IM_ARRAYSIZE(buffer->id)); // 2. Sequential number ImGui::SetNextItemWidth(widthAvailable*0.5f); ImGui::InputTextWithHint("Invoice number", "Invoice number", buffer->sequential_number, IM_ARRAYSIZE(buffer->sequential_number)); ImGui::SameLine();ui_helper_draw_required_tag(); if (!viewing_only) ImGui::EndDisabled(); return false; } void draw_invoices_list() { // Table header controls: create button and pagination. if (ImGui::Button(localize("form.create"))) { current_view_state = view_state::CREATE; active_invoice = administration_create_empty_invoice(); } } void ui_draw_invoices() { switch(current_view_state) { case view_state::LIST: draw_invoices_list(); break; case view_state::CREATE: if (draw_invoice_form(&active_invoice)) { //administration_create_invoice(active_invoice); current_view_state = view_state::LIST; } break; case view_state::EDIT: break; case view_state::VIEW: break; } }