summaryrefslogtreecommitdiff
path: root/src/ui/ui_invoices.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/ui/ui_invoices.cpp')
-rw-r--r--src/ui/ui_invoices.cpp58
1 files changed, 56 insertions, 2 deletions
diff --git a/src/ui/ui_invoices.cpp b/src/ui/ui_invoices.cpp
index ea45f4e..26f60c4 100644
--- a/src/ui/ui_invoices.cpp
+++ b/src/ui/ui_invoices.cpp
@@ -6,10 +6,64 @@
#include "administration.hpp"
#include "locales.hpp"
-static view_state current_view_state = LIST;
+static view_state current_view_state = view_state::LIST;
static invoice active_invoice;
-void ui_draw_invoices()
+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;
+ }
} \ No newline at end of file