Files
Dreierpack-Manager/src/modern/ui/finance_screens.inc
T

48 lines
3.6 KiB
C++

// SPDX-License-Identifier: GPL-3.0-only
std::string App::render_balance() {
const auto rows = balance_rows();
if (!rows.value("ok", false)) throw editor::Error("Die Bilanzdaten sind ungültig.");
std::string out = "<div class=\"balance-native\">";
if (balance_future_) {
out += "<section class=\"balance-plan\"><h2>Ausgabenplanung</h2><div class=\"balance-plan-rows\">";
int i = 0;
for (const auto &row : rows.at("plan")) {
const auto name = row.at("name").get<std::string>();
out += "<div class=\"balance-plan-row\"><span>" + esc(name) + "</span>" +
btn("balance-plan", esc(number(row.at("amount").get<int64_t>() / (engine_mode_?100:finance_currency_factor(*world_)))),
"balance-plan-value amount-trigger", "id=\"balance-plan-" + std::to_string(i) +
"\" data-id=\"" + std::to_string(i) + "\" aria-label=\"" + esc(name + " in " + (engine_mode_?"Euro":money_unit() == "€" ? "Euro" : money_unit())) + "\" " + std::string(engine_mode_&&row.at("editable")!=true?"disabled":"")) + "</div>";
++i;
}
out += "</div></section><p class=\"balance-plan-total\"><span>Geplante Ausgaben</span><span>" +
esc(balance_cash(rows.at("plan_total").get<int64_t>())) + "</span></p>";
} else {
int index = 0;
for (const auto &kind : {std::string("income"), std::string("costs")}) {
out += "<section class=\"balance-panel\" style=\"left:" + std::to_string(index++ * 1322) +
"dp;\"><h2>" + (kind == "income" ? "Einnahmen" : "Ausgaben") + "</h2><div class=\"balance-table\">"
"<div class=\"balance-row balance-head\"><span>Position</span><span>Betrag</span></div>";
int n = 0;
for (const auto &row : rows.at(kind)) {
out += "<div class=\"balance-row" + std::string(n++ % 2 == 0 ? " striped" : "") + "\"><span>" +
esc(row.at("name").get<std::string>()) + "</span><span>" + esc(balance_cash(row.at("amount").get<int64_t>())) + "</span></div>";
}
out += "</div></section>";
}
const std::array<std::string, 6> values = {
number(rows.at("league_home_games").get<int64_t>()) + " Liga-Heimspiele",
number(rows.at("other_home_games").get<int64_t>()) + " sonstige Heimspiele",
"Zuschauerschnitt: " + number(rows.at("attendance_average").get<int64_t>()),
"Eintrittspreis: " + balance_cash(rows.at("ticket").get<int64_t>()),
"Kontostand: " + balance_cash(rows.at("cash").get<int64_t>()),
"Saldo: " + balance_cash(rows.at("balance").get<int64_t>())};
for (int i = 0; i < 6; ++i)
out += "<p class=\"balance-summary-item" + std::string(i == 5 ? " balance-net" : "") + (engine_mode_&&(i==4||i==5)?" "+money_classes(rows.at(i==4?"cash":"balance").get<int64_t>()):std::string()) + "\" style=\"" +
rect(26 + (i % 2) * 1310, 1526 + (i / 2) * 68, 1250, 38) + "\">" + esc(values[size_t(i)]) + "</p>";
}
out += btn("balance-toggle", "<span>" + std::string(balance_future_ ? "Zukunft" : "Aktuell") +
"</span><span class=\"balance-cycle\" aria-hidden=\"true\"><span class=\"cycle-line cycle-top\"></span><span class=\"cycle-line cycle-bottom\"></span><span class=\"cycle-head cycle-right\"></span><span class=\"cycle-head cycle-left\"></span></span>", "balance-toggle report-reset",
"id=\"balance-toggle\" aria-label=\"Zwischen aktueller Bilanz und Zukunftsplanung wechseln\"");
return out + (engine_mode_?"<p id=\"balance-engine-feedback\" style=\"position:absolute;left:0;right:0;bottom:106dp;font-size:24dp;line-height:28dp;\">"+esc(engine_busy_?engine_operation_:engine_balance_feedback_)+"</p>":"") + "</div>";
}