diff --git a/client/scripts/regatten.js.php b/client/scripts/regatten.js.php
index 2ee1134..83bb367 100644
--- a/client/scripts/regatten.js.php
+++ b/client/scripts/regatten.js.php
@@ -62,7 +62,11 @@ var badges = {
news: {
id: 'badge-more-news',
cnt: 0
- }
+ },
+ expenditures: {
+ id: 'badge-more-expenditures',
+ cnt: 0
+ }
}
}
};
@@ -512,6 +516,24 @@ async function updateNewsBadge() {
updateBadge('more/news', sum);
}
+async function updateExpendituresBadge() {
+ let allExps = await dbGetData('expenditures');
+ let sum = 0;
+ for (let i in allExps) {
+ let exp = allExps[i];
+ if (exp.approved == 0) {
+ if (exp.direction < 0 && exp.canceled == 0) sum++;
+ if (exp.direction > 0 && exp.canceled == 1) sum++;
+ }
+ }
+ updateBadge('more/expenditures', sum);
+}
+
+function updateBadges() {
+ updateNewsBadge();
+ updateExpendituresBadge();
+}
+
var initRegatten = function() {
showLoader();
@@ -568,11 +590,11 @@ var onDatabaseLoaded = function() {
onServiceWorkerLoaded();
initPushSettings();
- updateNewsBadge();
+ updateBadges();
}
var onAfterSync = function() {
- updateNewsBadge();
+ updateBadges();
}
function sendErrorReport() {
diff --git a/server/page/menus.php b/server/page/menus.php
index 8d6a884..a654a43 100644
--- a/server/page/menus.php
+++ b/server/page/menus.php
@@ -71,7 +71,7 @@
Ausgaben-Verwaltung
-
+
diff --git a/server/scripts/expenditures-add.js b/server/scripts/expenditures-add.js
index fb57ba1..2c18fd7 100644
--- a/server/scripts/expenditures-add.js
+++ b/server/scripts/expenditures-add.js
@@ -100,6 +100,7 @@ async function expendituresInitModals() {
},
success: async function (data, status, xhr) {
await sync();
+ updateExpendituresBadge();
$('#menu-add').hideMenu();
hideLoader();
toastOk('Ausgabe gespeichert. Betrag wurde durch ' + data.count + ' Personen geteilt.');
@@ -199,6 +200,7 @@ async function expendituresInitModals() {
},
success: async function (data, status, xhr) {
await sync();
+ updateExpendituresBadge();
$('#menu-add-transfer').hideMenu();
hideLoader();
toastOk(direction ? 'Geldtransfer gespeichert. ' + (await dbGetData('users', selectedUser)).username + ' muss dies noch bestätigen' : 'Geldtransfer wurde gespeichert');
diff --git a/server/scripts/expenditures-user.js b/server/scripts/expenditures-user.js
index 24cacde..41d6e30 100644
--- a/server/scripts/expenditures-user.js
+++ b/server/scripts/expenditures-user.js
@@ -78,8 +78,9 @@ function expenditureAction(action, expId, successStr) {
}
hideLoader();
},
- success: function (data, status, xhr) {
- sync();
+ success: async function (data, status, xhr) {
+ await sync();
+ updateExpendituresBadge();
hideLoader();
toastOk(successStr);
}