diff --git a/src/Controller/CommunityController.php b/src/Controller/CommunityController.php index 30b90be..77b1aa3 100644 --- a/src/Controller/CommunityController.php +++ b/src/Controller/CommunityController.php @@ -53,36 +53,48 @@ class CommunityController implements IAuthenticationRequired $balanceCalculator = new BalanceCalculator($community); $debts = $balanceCalculator->calculate(); - $debtUsers = []; + $debtItems = []; $debtBalance = 0.0; - $outstandingUsers = []; + $outstandingItems = []; $outstandingBalance = 0.0; foreach ($debts as $debt) { if ($debt['payer']->getId() === \Container::$request->user()->getUniqueId()) { $debtBalance += $debt['amount']; - $debtUsers[] = $debt; + $debtItems[] = $debt; } if ($debt['payee']->getId() === \Container::$request->user()->getUniqueId()) { $outstandingBalance += $debt['amount']; - $outstandingUsers[] = $debt; + $outstandingItems[] = $debt; } } $balance = $outstandingBalance - $debtBalance; return new HtmlContent('communities/community', [ 'community' => $community, - 'members' => $this->getMembers($community), - 'currencies' => $this->getCurrencies($community), 'upcomingEvents' => [], - 'debtUsers' => $debtUsers, + 'debtItems' => $debtItems, 'debtBalance' => $debtBalance, - 'outstandingUsers' => $outstandingUsers, + 'outstandingItems' => $outstandingItems, 'outstandingBalance' => $outstandingBalance, 'balance' => $balance, 'editPermission' => $ownCommunityMember->getOwner() ]); } + public function getCommunitySettings(): ?IContent + { + if (!$this->checkPermission(\Container::$request->query('communityId'), false, $community, $ownCommunityMember)) { + return null; + } + + return new HtmlContent('communities/community_settings', [ + 'community' => $community, + 'members' => $this->getMembers($community), + 'currencies' => $this->getCurrencies($community), + 'editPermission' => $ownCommunityMember->getOwner() + ]); + } + public function getCommunityNew(): IContent { return new HtmlContent('communities/community_edit'); diff --git a/src/Controller/TransactionController.php b/src/Controller/TransactionController.php index c6b484d..3f075c9 100644 --- a/src/Controller/TransactionController.php +++ b/src/Controller/TransactionController.php @@ -86,6 +86,7 @@ class TransactionController implements IAuthenticationRequired, ISecured 'exchangeRateCalculator' => $exchangeRateCalculator, 'pages' => $pages, 'currentPage' => $currentPage, + 'numberOfTransactions' => $numberOfTransactions, 'transactions' => $transactions ]); } diff --git a/views/communities/community.php b/views/communities/community.php index fe8bc40..13ce2dc 100644 --- a/views/communities/community.php +++ b/views/communities/community.php @@ -1,35 +1,16 @@ @extends(templates/layout_normal) @section(main) -

getName() ?> [edit]

+

+ getName() ?> + + [edit] + +

+ +

Settings

-
-

Members

- -

getUser()->getDisplayName() ?>

- - -
-

Edit members

- -
-
-

Currencies

- -

- getId() === $community->getMainCurrencyId()): ?> - getCode() ?> - - getCode() ?> - -

- - -
-

Edit currencies

- -

Upcoming events

0): ?> @@ -52,20 +33,20 @@ You owe - + - getUser()->getDisplayName() ?> - + getUser()->getDisplayName() ?> + You're owed - + - getUser()->getDisplayName() ?> - + getUser()->getDisplayName() ?> + diff --git a/views/communities/community_currencies.php b/views/communities/community_currencies.php index 36ad30c..ab19f0b 100644 --- a/views/communities/community_currencies.php +++ b/views/communities/community_currencies.php @@ -3,6 +3,7 @@ @section(main)

getName() ?> » + Settings » Edit currencies

diff --git a/views/communities/community_members.php b/views/communities/community_members.php index 4818b1b..0397cbd 100644 --- a/views/communities/community_members.php +++ b/views/communities/community_members.php @@ -7,6 +7,7 @@ @section(main)

getName() ?> » + Settings » Edit members

diff --git a/views/communities/community_settings.php b/views/communities/community_settings.php new file mode 100644 index 0000000..03b979a --- /dev/null +++ b/views/communities/community_settings.php @@ -0,0 +1,39 @@ +@extends(templates/layout_normal) + +@section(main) +

+ getName() ?> » + Settings +

+ +
+
+

+ Members + + [edit] + +

+ +

getUser()->getDisplayName() ?>

+ +
+
+

+ Currencies + + [edit] + +

+ +

+ getId() === $community->getMainCurrencyId()): ?> + getCode() ?> + + getCode() ?> + +

+ +
+
+@endsection diff --git a/views/communities/currency_exchange_rates.php b/views/communities/currency_exchange_rates.php index b3e73b0..e880d99 100644 --- a/views/communities/currency_exchange_rates.php +++ b/views/communities/currency_exchange_rates.php @@ -3,6 +3,7 @@ @section(main)

getName() ?> » + Settings » Exchange rates for getCode() ?>

diff --git a/views/communities/transactions.php b/views/communities/transactions.php index 3a7cf0f..216c52d 100644 --- a/views/communities/transactions.php +++ b/views/communities/transactions.php @@ -8,55 +8,61 @@

New transaction

- 1): ?> -

- « - - - - - - - - - - » -

- + 0): ?> + 1): ?> +

+ « + + + + + + + + + + » +

+ - - -
-
-

getDescription() ?>

-

getPayerUser()->getDisplayName() ?> ► getPayeeUser() ? $transaction->getPayeeUser()->getDisplayName() : '[common]' ?>

-

getTimeDate()->format('Y-m-d H:i') ?>

-
-
-

calculate($transaction->getSum(), $transaction->getCurrency(), $transaction->getTimeDate()), $community->getMainCurrency()->getRoundDigits()) ?> getMainCurrency()->getCode() ?>

- getMainCurrencyId() !== $transaction->getCurrencyId()): ?> -

getSum(), $transaction->getCurrency()->getRoundDigits()) ?> getCurrency()->getCode() ?>

- + +
+
+
+

getDescription() ?>

+

getPayerUser()->getDisplayName() ?> ► getPayeeUser() ? $transaction->getPayeeUser()->getDisplayName() : '[common]' ?>

+

getTimeDate()->format('Y-m-d H:i') ?>

+
+
+

calculate($transaction->getSum(), $transaction->getCurrency(), $transaction->getTimeDate()), $community->getMainCurrency()->getRoundDigits()) ?> getMainCurrency()->getCode() ?>

+ getMainCurrencyId() !== $transaction->getCurrencyId()): ?> +

getSum(), $transaction->getCurrency()->getRoundDigits()) ?> getCurrency()->getCode() ?>

+ +
+
+ + + 1): ?> +

+ « + + + + + + + + + + » +

+ + +

New transaction

+ +
+

There are no transactions yet.

- - - - 1): ?> -

- « - - - - - - - - - - » -

- -

New transaction

@endsection diff --git a/views/home.php b/views/home.php index cc3a6a6..f88aa66 100644 --- a/views/home.php +++ b/views/home.php @@ -3,7 +3,10 @@ @section(main)
-

Communities

+

+ Communities + [new] +

0): ?>

getName() ?>

@@ -11,8 +14,6 @@

You have no community.

-
-

New community

Upcoming events

diff --git a/web.php b/web.php index 4f2f758..e5b3421 100644 --- a/web.php +++ b/web.php @@ -61,6 +61,7 @@ Container::$routeCollection->group('communities', function (RouteCollection $rou $routeCollection->post('community-new-action', 'new', [CommunityController::class, 'saveCommunity']); $routeCollection->group('{communityId}', function (RouteCollection $routeCollection) { $routeCollection->get('community', '', [CommunityController::class, 'getCommunityHome']); + $routeCollection->get('community.settings', 'settings', [CommunityController::class, 'getCommunitySettings']); $routeCollection->get('community-edit', 'edit', [CommunityController::class, 'getCommunityEdit']); $routeCollection->post('community-edit-action', 'edit', [CommunityController::class, 'saveCommunity']); $routeCollection->get('community-members', 'members', [CommunityController::class, 'getMembersEdit']);