Compare commits

..

No commits in common. "75f0ae7668c257fe157f885ab54f588b10c9cb72" and "5e1692efdb86a05b979ab1120ea42af7bc0db3eb" have entirely different histories.

18 changed files with 74 additions and 171 deletions

View File

@ -10,7 +10,7 @@
} }
], ],
"require": { "require": {
"esoko/soko-web": "0.11", "esoko/soko-web": "0.10",
"firebase/php-jwt": "^6.4" "firebase/php-jwt": "^6.4"
}, },
"require-dev": { "require-dev": {

83
composer.lock generated
View File

@ -4,92 +4,17 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically" "This file is @generated automatically"
], ],
"content-hash": "c17dd5eb82ff8f509a17404bd4c471b8", "content-hash": "607b383c44826c6307dd79b0362ca320",
"packages": [ "packages": [
{
"name": "cocur/slugify",
"version": "v4.3.0",
"source": {
"type": "git",
"url": "https://github.com/cocur/slugify.git",
"reference": "652234ef5f1be844a2ae1c36ad1b4c88b05160f9"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/cocur/slugify/zipball/652234ef5f1be844a2ae1c36ad1b4c88b05160f9",
"reference": "652234ef5f1be844a2ae1c36ad1b4c88b05160f9",
"shasum": ""
},
"require": {
"ext-mbstring": "*",
"php": "^7.1 || ~8.0.0 || ~8.1.0 || ~8.2.0"
},
"conflict": {
"symfony/config": "<3.4 || >=4,<4.3",
"symfony/dependency-injection": "<3.4 || >=4,<4.3",
"symfony/http-kernel": "<3.4 || >=4,<4.3",
"twig/twig": "<2.12.1"
},
"require-dev": {
"laravel/framework": "^5.0|^6.0|^7.0|^8.0",
"latte/latte": "~2.2",
"league/container": "^2.2.0",
"mikey179/vfsstream": "~1.6.8",
"mockery/mockery": "^1.3",
"nette/di": "~2.4",
"pimple/pimple": "~1.1",
"plumphp/plum": "~0.1",
"symfony/config": "^3.4 || ^4.3 || ^5.0 || ^6.0",
"symfony/dependency-injection": "^3.4 || ^4.3 || ^5.0 || ^6.0",
"symfony/http-kernel": "^3.4 || ^4.3 || ^5.0 || ^6.0",
"symfony/phpunit-bridge": "^5.4 || ^6.0",
"twig/twig": "^2.12.1 || ~3.0",
"zendframework/zend-modulemanager": "~2.2",
"zendframework/zend-servicemanager": "~2.2",
"zendframework/zend-view": "~2.2"
},
"type": "library",
"autoload": {
"psr-4": {
"Cocur\\Slugify\\": "src"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Florian Eckerstorfer",
"email": "florian@eckerstorfer.co",
"homepage": "https://florian.ec"
},
{
"name": "Ivo Bathke",
"email": "ivo.bathke@gmail.com"
}
],
"description": "Converts a string into a slug.",
"keywords": [
"slug",
"slugify"
],
"support": {
"issues": "https://github.com/cocur/slugify/issues",
"source": "https://github.com/cocur/slugify/tree/v4.3.0"
},
"time": "2022-12-07T19:48:48+00:00"
},
{ {
"name": "esoko/soko-web", "name": "esoko/soko-web",
"version": "v0.11", "version": "0.10",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://git.esoko.eu/esoko/soko-web.git", "url": "https://git.esoko.eu/esoko/soko-web.git",
"reference": "78f891fbff0dc8e5de5607529f4c8282f1dff40f" "reference": "fd286c9cffadc4a26609bfa00944f8014a2f3f59"
}, },
"require": { "require": {
"cocur/slugify": "^4.3",
"phpmailer/phpmailer": "^6.8", "phpmailer/phpmailer": "^6.8",
"symfony/console": "^5.4", "symfony/console": "^5.4",
"vlucas/phpdotenv": "^5.5" "vlucas/phpdotenv": "^5.5"
@ -108,7 +33,7 @@
"GNU GPL 3.0" "GNU GPL 3.0"
], ],
"description": "Lightweight web framework", "description": "Lightweight web framework",
"time": "2023-05-06T23:52:34+00:00" "time": "2023-05-02T10:55:47+00:00"
}, },
{ {
"name": "firebase/php-jwt", "name": "firebase/php-jwt",

View File

@ -1,12 +0,0 @@
<?php
use RVR\PersistentData\Model\Community;
use SokoWeb\Database\Query\Select;
$select = new Select(Container::$dbConnection);
$communities = Container::$persistentDataManager->selectMultipleFromDb($select, Community::class);
foreach ($communities as $community) {
$community->generateSlug();
Container::$persistentDataManager->saveToDb($community);
}

View File

@ -1,3 +0,0 @@
ALTER TABLE `communities`
ADD `slug` varchar(255) CHARACTER SET ascii COLLATE ascii_bin DEFAULT NULL AFTER `id`,
ADD UNIQUE `slug` (`slug`);

View File

@ -49,7 +49,7 @@ class CommunityController implements IAuthenticationRequired
public function getCommunityHome(): ?IContent public function getCommunityHome(): ?IContent
{ {
if (!$this->checkPermission(\Container::$request->query('communitySlug'), false, $community, $ownCommunityMember)) { if (!$this->checkPermission(\Container::$request->query('communityId'), false, $community, $ownCommunityMember)) {
return null; return null;
} }
@ -87,7 +87,7 @@ class CommunityController implements IAuthenticationRequired
public function getCommunitySettings(): ?IContent public function getCommunitySettings(): ?IContent
{ {
if (!$this->checkPermission(\Container::$request->query('communitySlug'), false, $community, $ownCommunityMember)) { if (!$this->checkPermission(\Container::$request->query('communityId'), false, $community, $ownCommunityMember)) {
return null; return null;
} }
@ -106,7 +106,7 @@ class CommunityController implements IAuthenticationRequired
public function getCommunityEdit(): ?IContent public function getCommunityEdit(): ?IContent
{ {
if (!$this->checkPermission(\Container::$request->query('communitySlug'), true, $community, $ownCommunityMember)) { if (!$this->checkPermission(\Container::$request->query('communityId'), true, $community, $ownCommunityMember)) {
return null; return null;
} }
@ -124,9 +124,9 @@ class CommunityController implements IAuthenticationRequired
]); ]);
} }
$communitySlug = \Container::$request->query('communitySlug'); $communityId = \Container::$request->query('communityId');
if ($communitySlug){ if ($communityId){
if (!$this->checkPermission($communitySlug, true, $community, $ownCommunityMember)) { if (!$this->checkPermission($communityId, true, $community, $ownCommunityMember)) {
return null; return null;
} }
} else { } else {
@ -145,7 +145,7 @@ class CommunityController implements IAuthenticationRequired
$community->setName($name); $community->setName($name);
\Container::$persistentDataManager->saveToDb($community); \Container::$persistentDataManager->saveToDb($community);
if (!$communitySlug) { if (!$communityId) {
/** /**
* @var User $user * @var User $user
*/ */
@ -168,13 +168,13 @@ class CommunityController implements IAuthenticationRequired
} }
return new JsonContent([ return new JsonContent([
'redirect' => ['target' => \Container::$routeCollection->getRoute('community')->generateLink(['communitySlug' => $community->getSlug()])] 'redirect' => ['target' => \Container::$routeCollection->getRoute('community')->generateLink(['communityId' => $community->getId()])]
]); ]);
} }
public function getMembersEdit(): ?IContent public function getMembersEdit(): ?IContent
{ {
if (!$this->checkPermission(\Container::$request->query('communitySlug'), true, $community, $ownCommunityMember)) { if (!$this->checkPermission(\Container::$request->query('communityId'), true, $community, $ownCommunityMember)) {
return null; return null;
} }
@ -186,7 +186,7 @@ class CommunityController implements IAuthenticationRequired
public function saveMember(): ?IContent public function saveMember(): ?IContent
{ {
if (!$this->checkPermission(\Container::$request->query('communitySlug'), true, $community, $ownCommunityMember)) { if (!$this->checkPermission(\Container::$request->query('communityId'), true, $community, $ownCommunityMember)) {
return null; return null;
} }
@ -225,7 +225,7 @@ class CommunityController implements IAuthenticationRequired
public function deleteMember(): ?IContent public function deleteMember(): ?IContent
{ {
if (!$this->checkPermission(\Container::$request->query('communitySlug'), true, $community, $ownCommunityMember)) { if (!$this->checkPermission(\Container::$request->query('communityId'), true, $community, $ownCommunityMember)) {
return null; return null;
} }
@ -250,7 +250,7 @@ class CommunityController implements IAuthenticationRequired
public function getCurrenciesEdit(): ?IContent public function getCurrenciesEdit(): ?IContent
{ {
if (!$this->checkPermission(\Container::$request->query('communitySlug'), true, $community, $ownCommunityMember)) { if (!$this->checkPermission(\Container::$request->query('communityId'), true, $community, $ownCommunityMember)) {
return null; return null;
} }
@ -262,7 +262,7 @@ class CommunityController implements IAuthenticationRequired
public function saveCurrency(): ?IContent public function saveCurrency(): ?IContent
{ {
if (!$this->checkPermission(\Container::$request->query('communitySlug'), true, $community, $ownCommunityMember)) { if (!$this->checkPermission(\Container::$request->query('communityId'), true, $community, $ownCommunityMember)) {
return null; return null;
} }
@ -298,7 +298,7 @@ class CommunityController implements IAuthenticationRequired
public function deleteCurrency(): ?IContent public function deleteCurrency(): ?IContent
{ {
if (!$this->checkPermission(\Container::$request->query('communitySlug'), true, $community, $ownCommunityMember)) { if (!$this->checkPermission(\Container::$request->query('communityId'), true, $community, $ownCommunityMember)) {
return null; return null;
} }
@ -324,7 +324,7 @@ class CommunityController implements IAuthenticationRequired
public function getCurrencyExchangeRates(): ?IContent public function getCurrencyExchangeRates(): ?IContent
{ {
if (!$this->checkPermission(\Container::$request->query('communitySlug'), true, $community, $ownCommunityMember)) { if (!$this->checkPermission(\Container::$request->query('communityId'), true, $community, $ownCommunityMember)) {
return null; return null;
} }
@ -345,7 +345,7 @@ class CommunityController implements IAuthenticationRequired
public function saveCurrencyExchangeRate(): ?IContent public function saveCurrencyExchangeRate(): ?IContent
{ {
if (!$this->checkPermission(\Container::$request->query('communitySlug'), true, $community, $ownCommunityMember)) { if (!$this->checkPermission(\Container::$request->query('communityId'), true, $community, $ownCommunityMember)) {
return null; return null;
} }
@ -378,7 +378,7 @@ class CommunityController implements IAuthenticationRequired
public function deleteCurrencyExchangeRate(): ?IContent public function deleteCurrencyExchangeRate(): ?IContent
{ {
if (!$this->checkPermission(\Container::$request->query('communitySlug'), true, $community, $ownCommunityMember)) { if (!$this->checkPermission(\Container::$request->query('communityId'), true, $community, $ownCommunityMember)) {
return null; return null;
} }
@ -415,12 +415,12 @@ class CommunityController implements IAuthenticationRequired
} }
private function checkPermission( private function checkPermission(
string $communitySlug, int $communityId,
bool $needToBeOwner, bool $needToBeOwner,
?Community &$community, ?Community &$community,
?CommunityMember &$ownCommunityMember): bool ?CommunityMember &$ownCommunityMember): bool
{ {
$community = $this->communityRepository->getBySlug($communitySlug); $community = $this->communityRepository->getById($communityId);
if ($community === null) { if ($community === null) {
return false; return false;
} }

View File

@ -46,8 +46,8 @@ class TransactionController implements IAuthenticationRequired, ISecured
public function authorize(): bool public function authorize(): bool
{ {
$communitySlug = \Container::$request->query('communitySlug'); $communityId = \Container::$request->query('communityId');
$this->community = $this->communityRepository->getBySlug($communitySlug); $this->community = $this->communityRepository->getById($communityId);
if ($this->community === null) { if ($this->community === null) {
return false; return false;
} }

View File

@ -1,9 +1,9 @@
<?php namespace RVR\PersistentData\Model; <?php namespace RVR\PersistentData\Model;
use DateTime; use DateTime;
use SokoWeb\PersistentData\Model\ModelWithSlug; use SokoWeb\PersistentData\Model\Model;
class Community extends ModelWithSlug class Community extends Model
{ {
protected static string $table = 'communities'; protected static string $table = 'communities';
@ -11,8 +11,6 @@ class Community extends ModelWithSlug
protected static array $relations = ['main_currency' => Currency::class]; protected static array $relations = ['main_currency' => Currency::class];
protected static string $slugSource = 'name';
private string $name = ''; private string $name = '';
private string $currency = ''; private string $currency = '';

View File

@ -8,9 +8,4 @@ class CommunityRepository
{ {
return \Container::$persistentDataManager->selectFromDbById($id, Community::class); return \Container::$persistentDataManager->selectFromDbById($id, Community::class);
} }
public function getBySlug(string $slug): ?Community
{
return \Container::$persistentDataManager->selectFromDbBySlug($slug, Community::class);
}
} }

View File

@ -4,11 +4,11 @@
<h2> <h2>
<?= $community->getName() ?> <?= $community->getName() ?>
<?php if ($editPermission): ?> <?php if ($editPermission): ?>
<span class="small">[<a href="<?= Container::$routeCollection->getRoute('community.edit')->generateLink(['communitySlug' => $community->getSlug()]) ?>">edit</a>]</span> <span class="small">[<a href="<?= Container::$routeCollection->getRoute('community.edit')->generateLink(['communityId' => $community->getId()]) ?>">edit</a>]</span>
<?php endif; ?> <?php endif; ?>
</h2> </h2>
<p class="marginTop"><a href="<?= Container::$routeCollection->getRoute('community.settings')->generateLink(['communitySlug' => $community->getSlug()]) ?>">Settings</a></p> <p class="marginTop"><a href="<?= Container::$routeCollection->getRoute('community.settings')->generateLink(['communityId' => $community->getId()]) ?>">Settings</a></p>
<div class="gridContainer marginTop"> <div class="gridContainer marginTop">
<div> <div>
@ -27,7 +27,7 @@
$mainCurrencyRoundDigits = $community->getMainCurrency()->getRoundDigits(); $mainCurrencyRoundDigits = $community->getMainCurrency()->getRoundDigits();
?> ?>
<h3 class="marginBottom">Finances</h3> <h3 class="marginBottom">Finances</h3>
<a href="<?= Container::$routeCollection->getRoute('community.transactions')->generateLink(['communitySlug' => $community->getSlug()]) ?>">Transactions</a> <a href="<?= Container::$routeCollection->getRoute('community.transactions')->generateLink(['communityId' => $community->getId()]) ?>">Transactions</a>
<table class="fullWidth marginTop"> <table class="fullWidth marginTop">
<tr> <tr>
<td class="bold">You owe</td> <td class="bold">You owe</td>

View File

@ -2,8 +2,8 @@
@section(main) @section(main)
<h2> <h2>
<a href="<?= Container::$routeCollection->getRoute('community')->generateLink(['communitySlug' => $community->getSlug()]) ?>"><?= $community->getName() ?></a> » <a href="<?= Container::$routeCollection->getRoute('community')->generateLink(['communityId' => $community->getId()]) ?>"><?= $community->getName() ?></a> »
<a href="<?= Container::$routeCollection->getRoute('community.settings')->generateLink(['communitySlug' => $community->getSlug()]) ?>">Settings</a> » <a href="<?= Container::$routeCollection->getRoute('community.settings')->generateLink(['communityId' => $community->getId()]) ?>">Settings</a> »
Edit currencies Edit currencies
</h2> </h2>
<div class="box compactBox"> <div class="box compactBox">
@ -18,8 +18,8 @@
<?php foreach ($currencies as $currency): ?> <?php foreach ($currencies as $currency): ?>
<tr> <tr>
<td> <td>
<form id="editCurrency_<?= $currency->getId() ?>" action="<?= Container::$routeCollection->getRoute('community.currencies.edit-action')->generateLink(['communitySlug' => $community->getSlug(), 'currency_id' => $currency->getId()]) ?>" method="post" data-reload-on-success="true" data-observe-inputs="code,round_digits"></form> <form id="editCurrency_<?= $currency->getId() ?>" action="<?= Container::$routeCollection->getRoute('community.currencies.edit-action')->generateLink(['communityId' => $community->getId(), 'currency_id' => $currency->getId()]) ?>" method="post" data-reload-on-success="true" data-observe-inputs="code,round_digits"></form>
<form id="deleteCurrency_<?= $currency->getId() ?>" action="<?= Container::$routeCollection->getRoute('community.currencies.delete-action')->generateLink(['communitySlug' => $community->getSlug(), 'currency_id' => $currency->getId()]) ?>" method="post" data-reload-on-success="true"></form> <form id="deleteCurrency_<?= $currency->getId() ?>" action="<?= Container::$routeCollection->getRoute('community.currencies.delete-action')->generateLink(['communityId' => $community->getId(), 'currency_id' => $currency->getId()]) ?>" method="post" data-reload-on-success="true"></form>
<input type="text" form="editCurrency_<?= $currency->getId() ?>" class="text fullWidth" name="code" value="<?= $currency->getCode() ?>" maxlength="3" required> <input type="text" form="editCurrency_<?= $currency->getId() ?>" class="text fullWidth" name="code" value="<?= $currency->getCode() ?>" maxlength="3" required>
</td> </td>
<td> <td>
@ -35,7 +35,7 @@
<?php endforeach; ?> <?php endforeach; ?>
<tr> <tr>
<td> <td>
<form id="newCurrency" action="<?= Container::$routeCollection->getRoute('community.currencies.new-action')->generateLink(['communitySlug' => $community->getSlug()]) ?>" method="post" data-reload-on-success="true" data-observe-inputs="code,round_digits"></form> <form id="newCurrency" action="<?= Container::$routeCollection->getRoute('community.currencies.new-action')->generateLink(['communityId' => $community->getId()]) ?>" method="post" data-reload-on-success="true" data-observe-inputs="code,round_digits"></form>
<input type="text" form="newCurrency" class="text fullWidth" name="code" maxlength="3" required> <input type="text" form="newCurrency" class="text fullWidth" name="code" maxlength="3" required>
</td> </td>
<td> <td>

View File

@ -3,7 +3,7 @@
@section(main) @section(main)
<h2> <h2>
<?php if (isset($community)): ?> <?php if (isset($community)): ?>
<a href="<?= Container::$routeCollection->getRoute('community')->generateLink(['communitySlug' => $community->getSlug()]) ?>"><?= $community->getName() ?></a> » <a href="<?= Container::$routeCollection->getRoute('community')->generateLink(['communityId' => $community->getId()]) ?>"><?= $community->getName() ?></a> »
Edit Edit
<?php else: ?> <?php else: ?>
New community New community
@ -12,7 +12,7 @@
<div class="box compactBox"> <div class="box compactBox">
<?php <?php
$formAction = isset($community) ? $formAction = isset($community) ?
Container::$routeCollection->getRoute('community.edit-action')->generateLink(['communitySlug' => $community->getSlug()]) : Container::$routeCollection->getRoute('community.edit-action')->generateLink(['communityId' => $community->getId()]) :
Container::$routeCollection->getRoute('community.new-action')->generateLink(); Container::$routeCollection->getRoute('community.new-action')->generateLink();
?> ?>
<form id="communityForm" action="<?= $formAction ?>" method="post" data-redirect-on-success="true"> <form id="communityForm" action="<?= $formAction ?>" method="post" data-redirect-on-success="true">

View File

@ -6,8 +6,8 @@
@section(main) @section(main)
<h2> <h2>
<a href="<?= Container::$routeCollection->getRoute('community')->generateLink(['communitySlug' => $community->getSlug()]) ?>"><?= $community->getName() ?></a> » <a href="<?= Container::$routeCollection->getRoute('community')->generateLink(['communityId' => $community->getId()]) ?>"><?= $community->getName() ?></a> »
<a href="<?= Container::$routeCollection->getRoute('community.settings')->generateLink(['communitySlug' => $community->getSlug()]) ?>">Settings</a> » <a href="<?= Container::$routeCollection->getRoute('community.settings')->generateLink(['communityId' => $community->getId()]) ?>">Settings</a> »
Edit members Edit members
</h2> </h2>
<div class="box compactBox"> <div class="box compactBox">
@ -23,8 +23,8 @@
<?php $editable = $member->getUserId() !== Container::$request->user()->getUniqueId(); ?> <?php $editable = $member->getUserId() !== Container::$request->user()->getUniqueId(); ?>
<tr> <tr>
<td> <td>
<form id="editMember_<?= $member->getId() ?>" action="<?= Container::$routeCollection->getRoute('community.members.edit-action')->generateLink(['communitySlug' => $community->getSlug(), 'community_member_id' => $member->getId()]) ?>" method="post" data-reload-on-success="true" data-observe-inputs="owner"></form> <form id="editMember_<?= $member->getId() ?>" action="<?= Container::$routeCollection->getRoute('community.members.edit-action')->generateLink(['communityId' => $community->getId(), 'community_member_id' => $member->getId()]) ?>" method="post" data-reload-on-success="true" data-observe-inputs="owner"></form>
<form id="deleteMember_<?= $member->getId() ?>" action="<?= Container::$routeCollection->getRoute('community.members.delete-action')->generateLink(['communitySlug' => $community->getSlug(), 'community_member_id' => $member->getId()]) ?>" method="post" data-reload-on-success="true"></form> <form id="deleteMember_<?= $member->getId() ?>" action="<?= Container::$routeCollection->getRoute('community.members.delete-action')->generateLink(['communityId' => $community->getId(), 'community_member_id' => $member->getId()]) ?>" method="post" data-reload-on-success="true"></form>
<?= $member->getUser()->getDisplayName() ?> <?= $member->getUser()->getDisplayName() ?>
</td> </td>
<td style="text-align: center;"> <td style="text-align: center;">
@ -40,7 +40,7 @@
<?php endforeach; ?> <?php endforeach; ?>
<tr> <tr>
<td> <td>
<form id="newMember" action="<?= Container::$routeCollection->getRoute('community.members.new-action')->generateLink(['communitySlug' => $community->getSlug()]) ?>" method="post" data-reload-on-success="true" data-observe-inputs="user_id"></form> <form id="newMember" action="<?= Container::$routeCollection->getRoute('community.members.new-action')->generateLink(['communityId' => $community->getId()]) ?>" method="post" data-reload-on-success="true" data-observe-inputs="user_id"></form>
<select type="text" form="newMember" name="user_id"> <select type="text" form="newMember" name="user_id">
</td> </td>
<td style="text-align: center;"> <td style="text-align: center;">

View File

@ -2,7 +2,7 @@
@section(main) @section(main)
<h2> <h2>
<a href="<?= Container::$routeCollection->getRoute('community')->generateLink(['communitySlug' => $community->getSlug()]) ?>"><?= $community->getName() ?></a> » <a href="<?= Container::$routeCollection->getRoute('community')->generateLink(['communityId' => $community->getId()]) ?>"><?= $community->getName() ?></a> »
Settings Settings
</h2> </h2>
@ -11,7 +11,7 @@
<h3 class="marginBottom"> <h3 class="marginBottom">
Members Members
<?php if ($editPermission): ?> <?php if ($editPermission): ?>
<span class="small">[<a href="<?= Container::$routeCollection->getRoute('community.members')->generateLink(['communitySlug' => $community->getSlug()]) ?>">edit</a>]</span> <span class="small">[<a href="<?= Container::$routeCollection->getRoute('community.members')->generateLink(['communityId' => $community->getId()]) ?>">edit</a>]</span>
<?php endif; ?> <?php endif; ?>
</h3> </h3>
<?php foreach ($members as $member): ?> <?php foreach ($members as $member): ?>
@ -22,7 +22,7 @@
<h3 class="marginBottom"> <h3 class="marginBottom">
Currencies Currencies
<?php if ($editPermission): ?> <?php if ($editPermission): ?>
<span class="small">[<a href="<?= Container::$routeCollection->getRoute('community.currencies')->generateLink(['communitySlug' => $community->getSlug()]) ?>">edit</a>]</span> <span class="small">[<a href="<?= Container::$routeCollection->getRoute('community.currencies')->generateLink(['communityId' => $community->getId()]) ?>">edit</a>]</span>
<?php endif; ?> <?php endif; ?>
</h3> </h3>
<?php foreach ($currencies as $currency): ?> <?php foreach ($currencies as $currency): ?>
@ -30,7 +30,7 @@
<?php if ($currency->getId() === $community->getMainCurrencyId()): ?> <?php if ($currency->getId() === $community->getMainCurrencyId()): ?>
<b><?= $currency->getCode() ?></b> <b><?= $currency->getCode() ?></b>
<?php else: ?> <?php else: ?>
<a href="<?= Container::$routeCollection->getRoute('community.currencyExchangeRates')->generateLink(['communitySlug' => $community->getSlug(), 'code' => $currency->getCode()]) ?>"><?= $currency->getCode() ?></a> <a href="<?= Container::$routeCollection->getRoute('community.currencyExchangeRates')->generateLink(['communityId' => $community->getId(), 'code' => $currency->getCode()]) ?>"><?= $currency->getCode() ?></a>
<?php endif; ?> <?php endif; ?>
</p> </p>
<?php endforeach; ?> <?php endforeach; ?>

View File

@ -2,8 +2,8 @@
@section(main) @section(main)
<h2> <h2>
<a href="<?= Container::$routeCollection->getRoute('community')->generateLink(['communitySlug' => $community->getSlug()]) ?>"><?= $community->getName() ?></a> » <a href="<?= Container::$routeCollection->getRoute('community')->generateLink(['communityId' => $community->getId()]) ?>"><?= $community->getName() ?></a> »
<a href="<?= Container::$routeCollection->getRoute('community.settings')->generateLink(['communitySlug' => $community->getSlug()]) ?>">Settings</a> » <a href="<?= Container::$routeCollection->getRoute('community.settings')->generateLink(['communityId' => $community->getId()]) ?>">Settings</a> »
Exchange rates for <?= $currency->getCode() ?> Exchange rates for <?= $currency->getCode() ?>
</h2> </h2>
<div class="box compactBox"> <div class="box compactBox">
@ -24,8 +24,8 @@
<tr> <tr>
<?php if ($editPermission): ?> <?php if ($editPermission): ?>
<td> <td>
<form id="editExchangeRate_<?= $currencyExchangeRate->getId() ?>" action="<?= Container::$routeCollection->getRoute('community.currencyExchangeRates.edit-action')->generateLink(['communitySlug' => $community->getSlug(), 'code' => $currency->getCode(), 'currency_exchange_rate_id' => $currencyExchangeRate->getId()]) ?>" method="post" data-reload-on-success="true" data-observe-inputs="exchange_rate,valid_from"></form> <form id="editExchangeRate_<?= $currencyExchangeRate->getId() ?>" action="<?= Container::$routeCollection->getRoute('community.currencyExchangeRates.edit-action')->generateLink(['communityId' => $community->getId(), 'code' => $currency->getCode(), 'currency_exchange_rate_id' => $currencyExchangeRate->getId()]) ?>" method="post" data-reload-on-success="true" data-observe-inputs="exchange_rate,valid_from"></form>
<form id="deleteCurrency_<?= $currencyExchangeRate->getId() ?>" action="<?= Container::$routeCollection->getRoute('community.currencyExchangeRates.delete-action')->generateLink(['communitySlug' => $community->getSlug(), 'code' => $currency->getCode(), 'currency_exchange_rate_id' => $currencyExchangeRate->getId()]) ?>" method="post" data-reload-on-success="true"></form> <form id="deleteCurrency_<?= $currencyExchangeRate->getId() ?>" action="<?= Container::$routeCollection->getRoute('community.currencyExchangeRates.delete-action')->generateLink(['communityId' => $community->getId(), 'code' => $currency->getCode(), 'currency_exchange_rate_id' => $currencyExchangeRate->getId()]) ?>" method="post" data-reload-on-success="true"></form>
<input type="number" form="editExchangeRate_<?= $currencyExchangeRate->getId() ?>" class="text fullWidth" name="exchange_rate" value="<?= $currencyExchangeRate->getExchangeRate() ?>" min="0" step="0.000000001" required> <input type="number" form="editExchangeRate_<?= $currencyExchangeRate->getId() ?>" class="text fullWidth" name="exchange_rate" value="<?= $currencyExchangeRate->getExchangeRate() ?>" min="0" step="0.000000001" required>
</td> </td>
<td> <td>
@ -44,7 +44,7 @@
<?php if ($editPermission): ?> <?php if ($editPermission): ?>
<tr> <tr>
<td> <td>
<form id="newExchangeRate" action="<?= Container::$routeCollection->getRoute('community.currencyExchangeRates.new-action')->generateLink(['communitySlug' => $community->getSlug(), 'code' => $currency->getCode()]) ?>" method="post" data-reload-on-success="true" data-observe-inputs="exchange_rate,valid_from"></form> <form id="newExchangeRate" action="<?= Container::$routeCollection->getRoute('community.currencyExchangeRates.new-action')->generateLink(['communityId' => $community->getId(), 'code' => $currency->getCode()]) ?>" method="post" data-reload-on-success="true" data-observe-inputs="exchange_rate,valid_from"></form>
<input type="number" form="newExchangeRate" class="text fullWidth" name="exchange_rate" min="0" step="0.000000001" required> <input type="number" form="newExchangeRate" class="text fullWidth" name="exchange_rate" min="0" step="0.000000001" required>
</td> </td>
<td> <td>

View File

@ -2,8 +2,8 @@
@section(main) @section(main)
<h2> <h2>
<a href="<?= Container::$routeCollection->getRoute('community')->generateLink(['communitySlug' => $community->getSlug()]) ?>"><?= $community->getName() ?></a> » <a href="<?= Container::$routeCollection->getRoute('community')->generateLink(['communityId' => $community->getId()]) ?>"><?= $community->getName() ?></a> »
<a href="<?= Container::$routeCollection->getRoute('community.transactions')->generateLink(['communitySlug' => $community->getSlug()]) ?>">Transactions</a> » <a href="<?= Container::$routeCollection->getRoute('community.transactions')->generateLink(['communityId' => $community->getId()]) ?>">Transactions</a> »
<?php if (isset($transaction)): ?> <?php if (isset($transaction)): ?>
Edit transaction Edit transaction
<?php else: ?> <?php else: ?>
@ -13,10 +13,10 @@
<div class="box compactBox"> <div class="box compactBox">
<?php <?php
$formAction = isset($transaction) ? $formAction = isset($transaction) ?
Container::$routeCollection->getRoute('community.transactions.edit-action')->generateLink(['communitySlug' => $community->getSlug(), 'transactionId' => $transaction->getId()]) : Container::$routeCollection->getRoute('community.transactions.edit-action')->generateLink(['communityId' => $community->getId(), 'transactionId' => $transaction->getId()]) :
Container::$routeCollection->getRoute('community.transactions.new-action')->generateLink(['communitySlug' => $community->getSlug()]); Container::$routeCollection->getRoute('community.transactions.new-action')->generateLink(['communityId' => $community->getId()]);
?> ?>
<form id="transactionForm" action="<?= $formAction ?>" method="post" data-redirect-on-success="<?= Container::$routeCollection->getRoute('community.transactions')->generateLink(['communitySlug' => $community->getSlug()]) ?>"> <form id="transactionForm" action="<?= $formAction ?>" method="post" data-redirect-on-success="<?= Container::$routeCollection->getRoute('community.transactions')->generateLink(['communityId' => $community->getId()]) ?>">
<p class="formLabel">Payer</p> <p class="formLabel">Payer</p>
<select class="big fullWidth" name="payer_user_id" required> <select class="big fullWidth" name="payer_user_id" required>
<option value="" hidden></option> <option value="" hidden></option>
@ -53,7 +53,7 @@
</div> </div>
</form> </form>
<?php if (isset($transaction)): ?> <?php if (isset($transaction)): ?>
<form id="deleteTransaction" action="<?= Container::$routeCollection->getRoute('community.transactions.delete-action')->generateLink(['communitySlug' => $community->getSlug(), 'transactionId' => $transaction->getId()]) ?>" method="post" data-redirect-on-success="<?= Container::$routeCollection->getRoute('community.transactions')->generateLink(['communitySlug' => $community->getSlug()]) ?>"></form> <form id="deleteTransaction" action="<?= Container::$routeCollection->getRoute('community.transactions.delete-action')->generateLink(['communityId' => $community->getId(), 'transactionId' => $transaction->getId()]) ?>" method="post" data-redirect-on-success="<?= Container::$routeCollection->getRoute('community.transactions')->generateLink(['communityId' => $community->getId()]) ?>"></form>
<?php endif; ?> <?php endif; ?>
</div> </div>
@endsection @endsection

View File

@ -2,31 +2,31 @@
@section(main) @section(main)
<h2> <h2>
<a href="<?= Container::$routeCollection->getRoute('community')->generateLink(['communitySlug' => $community->getSlug()]) ?>"><?= $community->getName() ?></a> » <a href="<?= Container::$routeCollection->getRoute('community')->generateLink(['communityId' => $community->getId()]) ?>"><?= $community->getName() ?></a> »
Transactions Transactions
</h2> </h2>
<p class="marginTop"><a href="<?= Container::$routeCollection->getRoute('community.transactions.new')->generateLink(['communitySlug' => $community->getSlug()]) ?>">New transaction</a></p> <p class="marginTop"><a href="<?= Container::$routeCollection->getRoute('community.transactions.new')->generateLink(['communityId' => $community->getId()]) ?>">New transaction</a></p>
<?php if ($numberOfTransactions > 0): ?> <?php if ($numberOfTransactions > 0): ?>
<?php if ($pages > 1): ?> <?php if ($pages > 1): ?>
<p class="paginateContainer marginTop"> <p class="paginateContainer marginTop">
<a href="<?= Container::$routeCollection->getRoute('community.transactions')->generateLink(['communitySlug' => $community->getSlug(), 'page' => 0]) ?>">«</a> <a href="<?= Container::$routeCollection->getRoute('community.transactions')->generateLink(['communityId' => $community->getId(), 'page' => 0]) ?>">«</a>
<a href="<?= Container::$routeCollection->getRoute('community.transactions')->generateLink(['communitySlug' => $community->getSlug(), 'page' => max(0, $currentPage - 1)]) ?>"></a> <a href="<?= Container::$routeCollection->getRoute('community.transactions')->generateLink(['communityId' => $community->getId(), 'page' => max(0, $currentPage - 1)]) ?>"></a>
<?php for ($i = 0; $i < $pages; $i++): ?> <?php for ($i = 0; $i < $pages; $i++): ?>
<?php if ($currentPage == $i): ?> <?php if ($currentPage == $i): ?>
<span class="selected"><?= $i + 1 ?></span> <span class="selected"><?= $i + 1 ?></span>
<?php else: ?> <?php else: ?>
<a href="<?= Container::$routeCollection->getRoute('community.transactions')->generateLink(['communitySlug' => $community->getSlug(), 'page' => $i]) ?>"><?= $i + 1 ?></a> <a href="<?= Container::$routeCollection->getRoute('community.transactions')->generateLink(['communityId' => $community->getId(), 'page' => $i]) ?>"><?= $i + 1 ?></a>
<?php endif; ?> <?php endif; ?>
<?php endfor; ?> <?php endfor; ?>
<a href="<?= Container::$routeCollection->getRoute('community.transactions')->generateLink(['communitySlug' => $community->getSlug(), 'page' => min($pages - 1, $currentPage + 1)]) ?>"></a> <a href="<?= Container::$routeCollection->getRoute('community.transactions')->generateLink(['communityId' => $community->getId(), 'page' => min($pages - 1, $currentPage + 1)]) ?>"></a>
<a href="<?= Container::$routeCollection->getRoute('community.transactions')->generateLink(['communitySlug' => $community->getSlug(), 'page' => $pages - 1]) ?>">»</a> <a href="<?= Container::$routeCollection->getRoute('community.transactions')->generateLink(['communityId' => $community->getId(), 'page' => $pages - 1]) ?>">»</a>
</p> </p>
<?php endif; ?> <?php endif; ?>
<?php foreach ($transactions as $transaction): ?> <?php foreach ($transactions as $transaction): ?>
<a class="block" href="<?= Container::$routeCollection->getRoute('community.transactions.edit')->generateLink(['communitySlug' => $community->getSlug(), 'transactionId' => $transaction->getId()]) ?>"> <a class="block" href="<?= Container::$routeCollection->getRoute('community.transactions.edit')->generateLink(['communityId' => $community->getId(), 'transactionId' => $transaction->getId()]) ?>">
<div class="box transaction"> <div class="box transaction">
<div> <div>
<p style="font-weight: bold;"><?= $transaction->getDescription() ?></p> <p style="font-weight: bold;"><?= $transaction->getDescription() ?></p>
@ -45,21 +45,21 @@
<?php if ($pages > 1): ?> <?php if ($pages > 1): ?>
<p class="paginateContainer marginTop"> <p class="paginateContainer marginTop">
<a href="<?= Container::$routeCollection->getRoute('community.transactions')->generateLink(['communitySlug' => $community->getSlug(), 'page' => 0]) ?>">«</a> <a href="<?= Container::$routeCollection->getRoute('community.transactions')->generateLink(['communityId' => $community->getId(), 'page' => 0]) ?>">«</a>
<a href="<?= Container::$routeCollection->getRoute('community.transactions')->generateLink(['communitySlug' => $community->getSlug(), 'page' => max(0, $currentPage - 1)]) ?>"></a> <a href="<?= Container::$routeCollection->getRoute('community.transactions')->generateLink(['communityId' => $community->getId(), 'page' => max(0, $currentPage - 1)]) ?>"></a>
<?php for ($i = 0; $i < $pages; $i++): ?> <?php for ($i = 0; $i < $pages; $i++): ?>
<?php if ($currentPage == $i): ?> <?php if ($currentPage == $i): ?>
<span class="selected"><?= $i + 1 ?></span> <span class="selected"><?= $i + 1 ?></span>
<?php else: ?> <?php else: ?>
<a href="<?= Container::$routeCollection->getRoute('community.transactions')->generateLink(['communitySlug' => $community->getSlug(), 'page' => $i]) ?>"><?= $i + 1 ?></a> <a href="<?= Container::$routeCollection->getRoute('community.transactions')->generateLink(['communityId' => $community->getId(), 'page' => $i]) ?>"><?= $i + 1 ?></a>
<?php endif; ?> <?php endif; ?>
<?php endfor; ?> <?php endfor; ?>
<a href="<?= Container::$routeCollection->getRoute('community.transactions')->generateLink(['communitySlug' => $community->getSlug(), 'page' => min($pages - 1, $currentPage + 1)]) ?>"></a> <a href="<?= Container::$routeCollection->getRoute('community.transactions')->generateLink(['communityId' => $community->getId(), 'page' => min($pages - 1, $currentPage + 1)]) ?>"></a>
<a href="<?= Container::$routeCollection->getRoute('community.transactions')->generateLink(['communitySlug' => $community->getSlug(), 'page' => $pages - 1]) ?>">»</a> <a href="<?= Container::$routeCollection->getRoute('community.transactions')->generateLink(['communityId' => $community->getId(), 'page' => $pages - 1]) ?>">»</a>
</p> </p>
<?php endif; ?> <?php endif; ?>
<p class="marginTop"><a href="<?= Container::$routeCollection->getRoute('community.transactions.new')->generateLink(['communitySlug' => $community->getSlug()]) ?>">New transaction</a></p> <p class="marginTop"><a href="<?= Container::$routeCollection->getRoute('community.transactions.new')->generateLink(['communityId' => $community->getId()]) ?>">New transaction</a></p>
<?php else: ?> <?php else: ?>
<div class="box"> <div class="box">
<p>There are no transactions yet.</p> <p>There are no transactions yet.</p>

View File

@ -9,7 +9,7 @@
</h3> </h3>
<?php if (count($communities) > 0): ?> <?php if (count($communities) > 0): ?>
<?php foreach ($communities as $community): ?> <?php foreach ($communities as $community): ?>
<p><a href="<?= Container::$routeCollection->getRoute('community')->generateLink(['communitySlug' => $community->getSlug()]) ?>"><?= $community->getName() ?></a></p> <p><a href="<?= Container::$routeCollection->getRoute('community')->generateLink(['communityId' => $community->getId()]) ?>"><?= $community->getName() ?></a></p>
<?php endforeach; ?> <?php endforeach; ?>
<?php else: ?> <?php else: ?>
<p>You have no community.</p> <p>You have no community.</p>

View File

@ -64,7 +64,7 @@ Container::$routeCollection->get('searchUser', 'searchUser', [UserSearchControll
Container::$routeCollection->group('communities', function (RouteCollection $routeCollection) { Container::$routeCollection->group('communities', function (RouteCollection $routeCollection) {
$routeCollection->get('community.new', 'new', [CommunityController::class, 'getCommunityNew']); $routeCollection->get('community.new', 'new', [CommunityController::class, 'getCommunityNew']);
$routeCollection->post('community.new-action', 'new', [CommunityController::class, 'saveCommunity']); $routeCollection->post('community.new-action', 'new', [CommunityController::class, 'saveCommunity']);
$routeCollection->group('{communitySlug}', function (RouteCollection $routeCollection) { $routeCollection->group('{communityId}', function (RouteCollection $routeCollection) {
$routeCollection->get('community', '', [CommunityController::class, 'getCommunityHome']); $routeCollection->get('community', '', [CommunityController::class, 'getCommunityHome']);
$routeCollection->get('community.settings', 'settings', [CommunityController::class, 'getCommunitySettings']); $routeCollection->get('community.settings', 'settings', [CommunityController::class, 'getCommunitySettings']);
$routeCollection->get('community.edit', 'edit', [CommunityController::class, 'getCommunityEdit']); $routeCollection->get('community.edit', 'edit', [CommunityController::class, 'getCommunityEdit']);