Compare commits
No commits in common. "6f1f59990f75dcb851cb1ae159b2b86ebbcb8c21" and "d29fc1c3399d620d0e71e25f87065cf4f1d9c282" have entirely different histories.
6f1f59990f
...
d29fc1c339
@ -108,10 +108,6 @@ p.small, span.small, td.small {
|
|||||||
font-size: 14px;
|
font-size: 14px;
|
||||||
}
|
}
|
||||||
|
|
||||||
p.big, span.big, td.big {
|
|
||||||
font-size: 18px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.red {
|
.red {
|
||||||
color: #a80908;
|
color: #a80908;
|
||||||
}
|
}
|
||||||
@ -259,11 +255,11 @@ button.red:enabled:hover, button.red:enabled:focus, a.button.red:hover, a.button
|
|||||||
}
|
}
|
||||||
|
|
||||||
button.yellow, a.button.yellow {
|
button.yellow, a.button.yellow {
|
||||||
background-color: #daa520;
|
background-color: #e8a349;
|
||||||
}
|
}
|
||||||
|
|
||||||
button.yellow:enabled:hover, button.yellow:enabled:focus, a.button.yellow:hover, a.button.yellow:focus {
|
button.yellow:enabled:hover, button.yellow:enabled:focus, a.button.yellow:hover, a.button.yellow:focus {
|
||||||
background-color: #b8860b;
|
background-color: #c37713;
|
||||||
}
|
}
|
||||||
|
|
||||||
button.green, a.button.green {
|
button.green, a.button.green {
|
||||||
@ -401,7 +397,7 @@ header>p {
|
|||||||
}
|
}
|
||||||
|
|
||||||
header>p>span {
|
header>p>span {
|
||||||
padding-left: 8px;
|
padding-left: 6px;
|
||||||
}
|
}
|
||||||
|
|
||||||
header>p>span>a:link, header>p>span>a:visited {
|
header>p>span>a:link, header>p>span>a:visited {
|
||||||
@ -414,7 +410,7 @@ header>p>span>a:hover, header>p>span>a:focus {
|
|||||||
|
|
||||||
header>p>span:not(:last-child) {
|
header>p>span:not(:last-child) {
|
||||||
border-right: solid white 1px;
|
border-right: solid white 1px;
|
||||||
padding-right: 8px;
|
padding-right: 6px;
|
||||||
}
|
}
|
||||||
|
|
||||||
main {
|
main {
|
||||||
@ -541,15 +537,6 @@ p.formLabel {
|
|||||||
font-size: 14px;
|
font-size: 14px;
|
||||||
}
|
}
|
||||||
|
|
||||||
span.label {
|
|
||||||
border-radius: 3px;
|
|
||||||
background-color: #555555;
|
|
||||||
color: #ffffff;
|
|
||||||
padding: 2px 4px;
|
|
||||||
font-weight: bold;
|
|
||||||
font-size: 13px;
|
|
||||||
}
|
|
||||||
|
|
||||||
@media screen and (max-width: 424px) {
|
@media screen and (max-width: 424px) {
|
||||||
div.gridContainer {
|
div.gridContainer {
|
||||||
grid-template-columns: auto;
|
grid-template-columns: auto;
|
||||||
|
@ -1,30 +0,0 @@
|
|||||||
(function () {
|
|
||||||
const element = document.getElementById('transactionForm').elements['event_id'];
|
|
||||||
const select = new TomSelect(element, {
|
|
||||||
valueField: 'value',
|
|
||||||
labelField: 'label',
|
|
||||||
searchField: 'label',
|
|
||||||
loadThrottle: 300,
|
|
||||||
load: function (query, callback) {
|
|
||||||
var self = this;
|
|
||||||
RVR.httpRequest('GET', searchEventUrl.replace('QUERY', encodeURIComponent(query)), function () {
|
|
||||||
self.clearOptions();
|
|
||||||
callback(this.response.results);
|
|
||||||
});
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
select.on('change', function (value) {
|
|
||||||
this.clearOptions();
|
|
||||||
});
|
|
||||||
|
|
||||||
select.on('blur', function (value) {
|
|
||||||
this.clearOptions();
|
|
||||||
});
|
|
||||||
|
|
||||||
select.on('type', function (value) {
|
|
||||||
if (value === '') {
|
|
||||||
this.clearOptions();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
})();
|
|
@ -11,7 +11,6 @@ use RVR\Repository\CommunityRepository;
|
|||||||
use RVR\Repository\CommunityMemberRepository;
|
use RVR\Repository\CommunityMemberRepository;
|
||||||
use RVR\Repository\CurrencyExchangeRateRepository;
|
use RVR\Repository\CurrencyExchangeRateRepository;
|
||||||
use RVR\Repository\CurrencyRepository;
|
use RVR\Repository\CurrencyRepository;
|
||||||
use RVR\Repository\EventRepository;
|
|
||||||
use RVR\Repository\TransactionRepository;
|
use RVR\Repository\TransactionRepository;
|
||||||
use RVR\Repository\UserRepository;
|
use RVR\Repository\UserRepository;
|
||||||
use SokoWeb\Interfaces\Authentication\IAuthenticationRequired;
|
use SokoWeb\Interfaces\Authentication\IAuthenticationRequired;
|
||||||
@ -33,8 +32,6 @@ class CommunityController implements IAuthenticationRequired
|
|||||||
|
|
||||||
private TransactionRepository $transactionRepository;
|
private TransactionRepository $transactionRepository;
|
||||||
|
|
||||||
private EventRepository $eventRepository;
|
|
||||||
|
|
||||||
public function __construct()
|
public function __construct()
|
||||||
{
|
{
|
||||||
$this->userRepository = new UserRepository();
|
$this->userRepository = new UserRepository();
|
||||||
@ -43,7 +40,6 @@ class CommunityController implements IAuthenticationRequired
|
|||||||
$this->currencyRepository = new CurrencyRepository();
|
$this->currencyRepository = new CurrencyRepository();
|
||||||
$this->currencyExchangeRatesRepository = new CurrencyExchangeRateRepository();
|
$this->currencyExchangeRatesRepository = new CurrencyExchangeRateRepository();
|
||||||
$this->transactionRepository = new TransactionRepository();
|
$this->transactionRepository = new TransactionRepository();
|
||||||
$this->eventRepository = new EventRepository();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function isAuthenticationRequired(): bool
|
public function isAuthenticationRequired(): bool
|
||||||
@ -79,7 +75,7 @@ class CommunityController implements IAuthenticationRequired
|
|||||||
|
|
||||||
return new HtmlContent('communities/community', [
|
return new HtmlContent('communities/community', [
|
||||||
'community' => $community,
|
'community' => $community,
|
||||||
'upcomingEvents' => iterator_to_array($this->eventRepository->getUpcomingByCommunity($community, new DateTime(), 3)),
|
'upcomingEvents' => [],
|
||||||
'debtItems' => $debtItems,
|
'debtItems' => $debtItems,
|
||||||
'debtBalance' => $debtBalance,
|
'debtBalance' => $debtBalance,
|
||||||
'outstandingItems' => $outstandingItems,
|
'outstandingItems' => $outstandingItems,
|
||||||
|
@ -1,146 +0,0 @@
|
|||||||
<?php namespace RVR\Controller;
|
|
||||||
|
|
||||||
use Container;
|
|
||||||
use DateTime;
|
|
||||||
use RVR\PersistentData\Model\Community;
|
|
||||||
use RVR\PersistentData\Model\CommunityMember;
|
|
||||||
use RVR\PersistentData\Model\Event;
|
|
||||||
use RVR\PersistentData\Model\User;
|
|
||||||
use RVR\Repository\CommunityMemberRepository;
|
|
||||||
use RVR\Repository\CommunityRepository;
|
|
||||||
use RVR\Repository\EventRepository;
|
|
||||||
use SokoWeb\Interfaces\Authentication\IAuthenticationRequired;
|
|
||||||
use SokoWeb\Interfaces\Authorization\ISecured;
|
|
||||||
use SokoWeb\Interfaces\Response\IContent;
|
|
||||||
use SokoWeb\Response\HtmlContent;
|
|
||||||
use SokoWeb\Response\JsonContent;
|
|
||||||
|
|
||||||
class EventController implements IAuthenticationRequired, ISecured
|
|
||||||
{
|
|
||||||
private CommunityRepository $communityRepository;
|
|
||||||
|
|
||||||
private CommunityMemberRepository $communityMemberRepository;
|
|
||||||
|
|
||||||
private EventRepository $eventRepository;
|
|
||||||
|
|
||||||
private ?Community $community;
|
|
||||||
|
|
||||||
private ?CommunityMember $ownCommunityMember;
|
|
||||||
|
|
||||||
public function __construct()
|
|
||||||
{
|
|
||||||
$this->communityRepository = new CommunityRepository();
|
|
||||||
$this->communityMemberRepository = new CommunityMemberRepository();
|
|
||||||
$this->eventRepository = new EventRepository();
|
|
||||||
}
|
|
||||||
|
|
||||||
public function isAuthenticationRequired(): bool
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function authorize(): bool
|
|
||||||
{
|
|
||||||
$communitySlug = \Container::$request->query('communitySlug');
|
|
||||||
$this->community = $this->communityRepository->getBySlug($communitySlug);
|
|
||||||
if ($this->community === null) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @var User $user
|
|
||||||
*/
|
|
||||||
$user = \Container::$request->user();
|
|
||||||
$this->ownCommunityMember = $this->communityMemberRepository->getByCommunityAndUser($this->community, $user);
|
|
||||||
if ($this->ownCommunityMember === null) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getEvents(): IContent
|
|
||||||
{
|
|
||||||
$itemsPerPage = 10;
|
|
||||||
$numberOfEvents = $this->eventRepository->countAllByCommunity($this->community);
|
|
||||||
$pages = ceil($numberOfEvents / $itemsPerPage);
|
|
||||||
$currentPage = Container::$request->query('page') ?: 0;
|
|
||||||
$events = $this->eventRepository->getPagedByCommunity(
|
|
||||||
$this->community,
|
|
||||||
$currentPage * $itemsPerPage,
|
|
||||||
$itemsPerPage
|
|
||||||
);
|
|
||||||
|
|
||||||
return new HtmlContent('events/events', [
|
|
||||||
'community' => $this->community,
|
|
||||||
'pages' => $pages,
|
|
||||||
'currentPage' => $currentPage,
|
|
||||||
'numberOfEvents' => $numberOfEvents,
|
|
||||||
'events' => $events
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function searchEvent(): IContent
|
|
||||||
{
|
|
||||||
$events = iterator_to_array($this->eventRepository->searchByTitle($this->community, Container::$request->query('q')));
|
|
||||||
$results = [];
|
|
||||||
foreach ($events as $event) {
|
|
||||||
$results[] = ['value' => $event->getId(), 'label' => $event->getTitle()];
|
|
||||||
}
|
|
||||||
|
|
||||||
return new JsonContent([
|
|
||||||
'results' => $results
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getEvent(): IContent
|
|
||||||
{
|
|
||||||
$event = $this->eventRepository->getBySlug(Container::$request->query('eventSlug'));
|
|
||||||
if (!$event) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
Container::$persistentDataManager->loadRelationsFromDb($this->community, true, ['main_currency']);
|
|
||||||
|
|
||||||
return new HtmlContent('events/event', [
|
|
||||||
'community' => $this->community,
|
|
||||||
'event' => $event
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getEventEdit(): ?IContent
|
|
||||||
{
|
|
||||||
$eventSlug = Container::$request->query('eventSlug');
|
|
||||||
if ($eventSlug) {
|
|
||||||
$event = $this->eventRepository->getBySlug($eventSlug);
|
|
||||||
if ($event === null) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
$event = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
return new HtmlContent('events/event_edit', [
|
|
||||||
'community' => $this->community,
|
|
||||||
'event' => $event
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function saveEvent(): ?IContent
|
|
||||||
{
|
|
||||||
$eventSlug = Container::$request->query('eventSlug');
|
|
||||||
if ($eventSlug) {
|
|
||||||
$event = $this->eventRepository->getBySlug($eventSlug);
|
|
||||||
} else {
|
|
||||||
$event = new Event();
|
|
||||||
$event->setCommunity($this->community);
|
|
||||||
}
|
|
||||||
|
|
||||||
$event->setTitle(Container::$request->post('title'));
|
|
||||||
$event->setDescription(Container::$request->post('description'));
|
|
||||||
$event->setStartDate(new DateTime(Container::$request->post('start')));
|
|
||||||
$event->setEndDate(new DateTime(Container::$request->post('end')));
|
|
||||||
Container::$persistentDataManager->saveToDb($event);
|
|
||||||
|
|
||||||
return new JsonContent(['success' => true]);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,10 +1,8 @@
|
|||||||
<?php namespace RVR\Controller;
|
<?php namespace RVR\Controller;
|
||||||
|
|
||||||
use DateTime;
|
|
||||||
use RVR\PersistentData\Model\Community;
|
use RVR\PersistentData\Model\Community;
|
||||||
use RVR\PersistentData\Model\User;
|
use RVR\PersistentData\Model\User;
|
||||||
use RVR\Repository\CommunityMemberRepository;
|
use RVR\Repository\CommunityMemberRepository;
|
||||||
use RVR\Repository\EventRepository;
|
|
||||||
use SokoWeb\Interfaces\Authentication\IAuthenticationRequired;
|
use SokoWeb\Interfaces\Authentication\IAuthenticationRequired;
|
||||||
use SokoWeb\Interfaces\Response\IContent;
|
use SokoWeb\Interfaces\Response\IContent;
|
||||||
use SokoWeb\Response\HtmlContent;
|
use SokoWeb\Response\HtmlContent;
|
||||||
@ -13,12 +11,9 @@ class HomeController implements IAuthenticationRequired
|
|||||||
{
|
{
|
||||||
private CommunityMemberRepository $communityMemberRepository;
|
private CommunityMemberRepository $communityMemberRepository;
|
||||||
|
|
||||||
private EventRepository $eventRepository;
|
|
||||||
|
|
||||||
public function __construct()
|
public function __construct()
|
||||||
{
|
{
|
||||||
$this->communityMemberRepository = new CommunityMemberRepository();
|
$this->communityMemberRepository = new CommunityMemberRepository();
|
||||||
$this->eventRepository = new EventRepository();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function isAuthenticationRequired(): bool
|
public function isAuthenticationRequired(): bool
|
||||||
@ -44,7 +39,7 @@ class HomeController implements IAuthenticationRequired
|
|||||||
|
|
||||||
return new HtmlContent('home', [
|
return new HtmlContent('home', [
|
||||||
'communities' => $communities,
|
'communities' => $communities,
|
||||||
'upcomingEvents' => iterator_to_array($this->eventRepository->getUpcomingByUser($user, new DateTime(), 3, true, ['community']))
|
'upcomingEvents' => []
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -11,7 +11,6 @@ use RVR\Repository\CommunityMemberRepository;
|
|||||||
use RVR\Repository\CommunityRepository;
|
use RVR\Repository\CommunityRepository;
|
||||||
use RVR\Repository\CurrencyRepository;
|
use RVR\Repository\CurrencyRepository;
|
||||||
use RVR\Repository\TransactionRepository;
|
use RVR\Repository\TransactionRepository;
|
||||||
use RVR\Repository\EventRepository;
|
|
||||||
use SokoWeb\Interfaces\Authentication\IAuthenticationRequired;
|
use SokoWeb\Interfaces\Authentication\IAuthenticationRequired;
|
||||||
use SokoWeb\Interfaces\Authorization\ISecured;
|
use SokoWeb\Interfaces\Authorization\ISecured;
|
||||||
use SokoWeb\Interfaces\Response\IContent;
|
use SokoWeb\Interfaces\Response\IContent;
|
||||||
@ -28,11 +27,9 @@ class TransactionController implements IAuthenticationRequired, ISecured
|
|||||||
|
|
||||||
private TransactionRepository $transactionRepository;
|
private TransactionRepository $transactionRepository;
|
||||||
|
|
||||||
private EventRepository $eventRepository;
|
private Community $community;
|
||||||
|
|
||||||
private ?Community $community;
|
private CommunityMember $ownCommunityMember;
|
||||||
|
|
||||||
private ?CommunityMember $ownCommunityMember;
|
|
||||||
|
|
||||||
public function __construct()
|
public function __construct()
|
||||||
{
|
{
|
||||||
@ -40,7 +37,6 @@ class TransactionController implements IAuthenticationRequired, ISecured
|
|||||||
$this->communityMemberRepository = new CommunityMemberRepository();
|
$this->communityMemberRepository = new CommunityMemberRepository();
|
||||||
$this->currencyRepository = new CurrencyRepository();
|
$this->currencyRepository = new CurrencyRepository();
|
||||||
$this->transactionRepository = new TransactionRepository();
|
$this->transactionRepository = new TransactionRepository();
|
||||||
$this->eventRepository = new EventRepository();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function isAuthenticationRequired(): bool
|
public function isAuthenticationRequired(): bool
|
||||||
@ -82,7 +78,7 @@ class TransactionController implements IAuthenticationRequired, ISecured
|
|||||||
$currentPage * $itemsPerPage,
|
$currentPage * $itemsPerPage,
|
||||||
$itemsPerPage,
|
$itemsPerPage,
|
||||||
true,
|
true,
|
||||||
['event', 'currency', 'payer_user', 'payee_user']
|
['currency', 'payer_user', 'payee_user']
|
||||||
);
|
);
|
||||||
|
|
||||||
return new HtmlContent('communities/transactions', [
|
return new HtmlContent('communities/transactions', [
|
||||||
@ -103,22 +99,13 @@ class TransactionController implements IAuthenticationRequired, ISecured
|
|||||||
if ($transaction === null) {
|
if ($transaction === null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
Container::$persistentDataManager->loadRelationsFromDb($transaction, false, ['event']);
|
|
||||||
$event = $transaction->getEvent();
|
|
||||||
} else {
|
} else {
|
||||||
$transaction = null;
|
$transaction = null;
|
||||||
$eventSlug = Container::$request->query('event');
|
|
||||||
if ($eventSlug) {
|
|
||||||
$event = $this->eventRepository->getBySlug($eventSlug);
|
|
||||||
} else {
|
|
||||||
$event = null;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return new HtmlContent('communities/transaction_edit', [
|
return new HtmlContent('communities/transaction_edit', [
|
||||||
'community' => $this->community,
|
'community' => $this->community,
|
||||||
'transaction' => $transaction,
|
'transaction' => $transaction,
|
||||||
'event' => $event,
|
|
||||||
'members' => $this->getMembers($this->community),
|
'members' => $this->getMembers($this->community),
|
||||||
'currencies' => $this->getCurrencies($this->community)
|
'currencies' => $this->getCurrencies($this->community)
|
||||||
]);
|
]);
|
||||||
@ -134,7 +121,6 @@ class TransactionController implements IAuthenticationRequired, ISecured
|
|||||||
$transaction->setCommunity($this->community);
|
$transaction->setCommunity($this->community);
|
||||||
}
|
}
|
||||||
|
|
||||||
$transaction->setEventId(Container::$request->post('event_id') ?: null);
|
|
||||||
$transaction->setCurrencyId(Container::$request->post('currency_id'));
|
$transaction->setCurrencyId(Container::$request->post('currency_id'));
|
||||||
$transaction->setPayerUserId(Container::$request->post('payer_user_id'));
|
$transaction->setPayerUserId(Container::$request->post('payer_user_id'));
|
||||||
$transaction->setPayeeUserId(Container::$request->post('payee_user_id') ?: null);
|
$transaction->setPayeeUserId(Container::$request->post('payee_user_id') ?: null);
|
||||||
|
@ -7,11 +7,10 @@ class Transaction extends Model
|
|||||||
{
|
{
|
||||||
protected static string $table = 'transactions';
|
protected static string $table = 'transactions';
|
||||||
|
|
||||||
protected static array $fields = ['community_id', 'event_id', 'currency_id', 'payer_user_id', 'payee_user_id', 'description', 'sum', 'time'];
|
protected static array $fields = ['community_id', 'currency_id', 'payer_user_id', 'payee_user_id', 'description', 'sum', 'time'];
|
||||||
|
|
||||||
protected static array $relations = [
|
protected static array $relations = [
|
||||||
'community' => Community::class,
|
'community' => Community::class,
|
||||||
'event' => Event::class,
|
|
||||||
'currency' => Currency::class,
|
'currency' => Currency::class,
|
||||||
'payer_user' => User::class,
|
'payer_user' => User::class,
|
||||||
'payee_user' => User::class
|
'payee_user' => User::class
|
||||||
@ -21,10 +20,6 @@ class Transaction extends Model
|
|||||||
|
|
||||||
private int $communityId;
|
private int $communityId;
|
||||||
|
|
||||||
private ?Event $event = null;
|
|
||||||
|
|
||||||
private ?int $eventId = null;
|
|
||||||
|
|
||||||
private ?Currency $currency = null;
|
private ?Currency $currency = null;
|
||||||
|
|
||||||
private int $currencyId;
|
private int $currencyId;
|
||||||
@ -53,16 +48,6 @@ class Transaction extends Model
|
|||||||
$this->communityId = $communityId;
|
$this->communityId = $communityId;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function setEvent(?Event $event): void
|
|
||||||
{
|
|
||||||
$this->event = $event;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function setEventId(?int $eventId): void
|
|
||||||
{
|
|
||||||
$this->eventId = $eventId;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function setCurrency(Currency $currency): void
|
public function setCurrency(Currency $currency): void
|
||||||
{
|
{
|
||||||
$this->currency = $currency;
|
$this->currency = $currency;
|
||||||
@ -123,16 +108,6 @@ class Transaction extends Model
|
|||||||
return $this->communityId;
|
return $this->communityId;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getEvent(): ?Event
|
|
||||||
{
|
|
||||||
return $this->event;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getEventId(): ?int
|
|
||||||
{
|
|
||||||
return $this->eventId;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getCurrency(): ?Currency
|
public function getCurrency(): ?Currency
|
||||||
{
|
{
|
||||||
return $this->currency;
|
return $this->currency;
|
||||||
|
@ -5,7 +5,6 @@ use DateTime;
|
|||||||
use Generator;
|
use Generator;
|
||||||
use RVR\PersistentData\Model\Community;
|
use RVR\PersistentData\Model\Community;
|
||||||
use RVR\PersistentData\Model\Event;
|
use RVR\PersistentData\Model\Event;
|
||||||
use RVR\PersistentData\Model\User;
|
|
||||||
use SokoWeb\Database\Query\Select;
|
use SokoWeb\Database\Query\Select;
|
||||||
|
|
||||||
class EventRepository
|
class EventRepository
|
||||||
@ -42,16 +41,6 @@ class EventRepository
|
|||||||
yield from Container::$persistentDataManager->selectMultipleFromDb($select, Event::class, $useRelations, $withRelations);
|
yield from Container::$persistentDataManager->selectMultipleFromDb($select, Event::class, $useRelations, $withRelations);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getUpcomingByUser(User $user, DateTime $from, int $limit, bool $useRelations = false, array $withRelations = []): Generator
|
|
||||||
{
|
|
||||||
$select = $this->selectAllByUser($user);
|
|
||||||
$select->where('end', '>', $from->format('Y-m-d H:i:s'));
|
|
||||||
$select->orderBy('start', 'ASC');
|
|
||||||
$select->limit($limit, 0);
|
|
||||||
|
|
||||||
yield from Container::$persistentDataManager->selectMultipleFromDb($select, Event::class, $useRelations, $withRelations);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getPagedByCommunity(Community $community, int $start, int $limit, bool $useRelations = false, array $withRelations = []): Generator
|
public function getPagedByCommunity(Community $community, int $start, int $limit, bool $useRelations = false, array $withRelations = []): Generator
|
||||||
{
|
{
|
||||||
$select = $this->selectAllByCommunity($community);
|
$select = $this->selectAllByCommunity($community);
|
||||||
@ -65,7 +54,6 @@ class EventRepository
|
|||||||
{
|
{
|
||||||
$select = $this->selectAllByCommunity($community);
|
$select = $this->selectAllByCommunity($community);
|
||||||
$select->where('title', 'LIKE', '%' . $title . '%');
|
$select->where('title', 'LIKE', '%' . $title . '%');
|
||||||
$select->orderBy('start', 'DESC');
|
|
||||||
$select->limit(10);
|
$select->limit(10);
|
||||||
|
|
||||||
yield from Container::$persistentDataManager->selectMultipleFromDb($select, Event::class);
|
yield from Container::$persistentDataManager->selectMultipleFromDb($select, Event::class);
|
||||||
@ -75,15 +63,7 @@ class EventRepository
|
|||||||
{
|
{
|
||||||
$select = new Select(Container::$dbConnection, Event::getTable());
|
$select = new Select(Container::$dbConnection, Event::getTable());
|
||||||
$select->where('community_id', '=', $community->getId());
|
$select->where('community_id', '=', $community->getId());
|
||||||
return $select;
|
$select->orderBy('start', 'DESC');
|
||||||
}
|
|
||||||
|
|
||||||
private function selectAllByUser(User $user)
|
|
||||||
{
|
|
||||||
$select = new Select(Container::$dbConnection, Event::getTable());
|
|
||||||
$select->innerJoin('communities', ['communities', 'id'], '=', ['events', 'community_id']);
|
|
||||||
$select->innerJoin('community_members', ['communities', 'id'], '=', ['community_members', 'community_id']);
|
|
||||||
$select->where(['community_members', 'user_id'], '=', $user->getId());
|
|
||||||
return $select;
|
return $select;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -15,15 +15,11 @@
|
|||||||
<h3 class="marginBottom">Upcoming events</h3>
|
<h3 class="marginBottom">Upcoming events</h3>
|
||||||
<?php if (count($upcomingEvents) > 0): ?>
|
<?php if (count($upcomingEvents) > 0): ?>
|
||||||
<?php foreach ($upcomingEvents as $event): ?>
|
<?php foreach ($upcomingEvents as $event): ?>
|
||||||
<p>
|
<!-- todo -->
|
||||||
<a href="<?= Container::$routeCollection->getRoute('community.event')->generateLink(['communitySlug' => $community->getSlug(), 'eventSlug' => $event->getSlug()]) ?>"><?= $event->getTitle() ?></a>
|
|
||||||
<span class="small"><?= $event->getStartDate()->format('Y-m-d') ?> – <?= $event->getEndDate()->format('Y-m-d') ?></span>
|
|
||||||
</p>
|
|
||||||
<?php endforeach; ?>
|
<?php endforeach; ?>
|
||||||
<?php else: ?>
|
<?php else: ?>
|
||||||
<p>There is no upcoming event.</p>
|
<p>There is no upcoming event.</p>
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
<p class="marginTop"><a href="<?= Container::$routeCollection->getRoute('community.events')->generateLink(['communitySlug' => $community->getSlug()]) ?>">All events</a> | <a href="<?= Container::$routeCollection->getRoute('community.events.new')->generateLink(['communitySlug' => $community->getSlug()]) ?>">New event</a></p>
|
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
<?php
|
<?php
|
||||||
@ -31,7 +27,7 @@
|
|||||||
$mainCurrencyRoundDigits = $community->getMainCurrency()->getRoundDigits();
|
$mainCurrencyRoundDigits = $community->getMainCurrency()->getRoundDigits();
|
||||||
?>
|
?>
|
||||||
<h3 class="marginBottom">Finances</h3>
|
<h3 class="marginBottom">Finances</h3>
|
||||||
<p><a href="<?= Container::$routeCollection->getRoute('community.transactions')->generateLink(['communitySlug' => $community->getSlug()]) ?>">Transactions</a> | <a href="<?= Container::$routeCollection->getRoute('community.transactions.new')->generateLink(['communitySlug' => $community->getSlug()]) ?>">New transaction</a></p>
|
<a href="<?= Container::$routeCollection->getRoute('community.transactions')->generateLink(['communitySlug' => $community->getSlug()]) ?>">Transactions</a>
|
||||||
<table class="fullWidth marginTop">
|
<table class="fullWidth marginTop">
|
||||||
<tr>
|
<tr>
|
||||||
<td class="bold">You owe</td>
|
<td class="bold">You owe</td>
|
||||||
|
@ -41,7 +41,7 @@
|
|||||||
<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(['communitySlug' => $community->getSlug()]) ?>" method="post" data-reload-on-success="true" data-observe-inputs="user_id"></form>
|
||||||
<select form="newMember" name="user_id" required></select>
|
<select type="text" form="newMember" name="user_id">
|
||||||
</td>
|
</td>
|
||||||
<td style="text-align: center;">
|
<td style="text-align: center;">
|
||||||
<input type="checkbox" form="newMember" name="owner" />
|
<input type="checkbox" form="newMember" name="owner" />
|
||||||
|
@ -1,7 +1,3 @@
|
|||||||
@css(/static/node_modules/tom-select/dist/css/tom-select.min.css)
|
|
||||||
@js(/static/node_modules/tom-select/dist/js/tom-select.base.min.js)
|
|
||||||
@js(js/communities/transaction.js)
|
|
||||||
|
|
||||||
@extends(templates/layout_normal)
|
@extends(templates/layout_normal)
|
||||||
|
|
||||||
@section(main)
|
@section(main)
|
||||||
@ -21,14 +17,7 @@
|
|||||||
Container::$routeCollection->getRoute('community.transactions.new-action')->generateLink(['communitySlug' => $community->getSlug()]);
|
Container::$routeCollection->getRoute('community.transactions.new-action')->generateLink(['communitySlug' => $community->getSlug()]);
|
||||||
?>
|
?>
|
||||||
<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(['communitySlug' => $community->getSlug()]) ?>">
|
||||||
<p class="formLabel">Event</p>
|
<p class="formLabel">Payer</p>
|
||||||
<select name="event_id">
|
|
||||||
<option value="">[none]</option>
|
|
||||||
<?php if (isset($event)): ?>
|
|
||||||
<option value="<?= $event->getId() ?>" selected><?= $event->getTitle() ?></option>
|
|
||||||
<?php endif; ?>
|
|
||||||
</select>
|
|
||||||
<p class="formLabel marginTop">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>
|
||||||
<?php foreach ($members as $member): ?>
|
<?php foreach ($members as $member): ?>
|
||||||
@ -68,9 +57,3 @@
|
|||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
</div>
|
</div>
|
||||||
@endsection
|
@endsection
|
||||||
|
|
||||||
@section(pageScript)
|
|
||||||
<script>
|
|
||||||
var searchEventUrl = '<?= Container::$routeCollection->getRoute('community.events.search')->generateLink(['communitySlug' => $community->getSlug(), 'q' => 'QUERY']) ?>';
|
|
||||||
</script>
|
|
||||||
@endsection
|
|
||||||
|
@ -29,9 +29,6 @@
|
|||||||
<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(['communitySlug' => $community->getSlug(), 'transactionId' => $transaction->getId()]) ?>">
|
||||||
<div class="box transaction">
|
<div class="box transaction">
|
||||||
<div>
|
<div>
|
||||||
<?php if ($transaction->getEvent()): ?>
|
|
||||||
<p><span class="label"><?= $transaction->getEvent()->getTitle() ?></span></p>
|
|
||||||
<?php endif; ?>
|
|
||||||
<p style="font-weight: bold;"><?= $transaction->getDescription() ?></p>
|
<p style="font-weight: bold;"><?= $transaction->getDescription() ?></p>
|
||||||
<p class="small"><?= $transaction->getPayerUser()->getDisplayName() ?> <i class="fa-solid fa-caret-right"></i> <?= $transaction->getPayeeUser() ? $transaction->getPayeeUser()->getDisplayName() : '[common]' ?></p>
|
<p class="small"><?= $transaction->getPayerUser()->getDisplayName() ?> <i class="fa-solid fa-caret-right"></i> <?= $transaction->getPayeeUser() ? $transaction->getPayeeUser()->getDisplayName() : '[common]' ?></p>
|
||||||
<p class="small"><?= $transaction->getTimeDate()->format('Y-m-d H:i') ?></p>
|
<p class="small"><?= $transaction->getTimeDate()->format('Y-m-d H:i') ?></p>
|
||||||
|
@ -1,27 +0,0 @@
|
|||||||
@extends(templates/layout_normal)
|
|
||||||
|
|
||||||
@section(main)
|
|
||||||
<h2>
|
|
||||||
<a href="<?= Container::$routeCollection->getRoute('community')->generateLink(['communitySlug' => $community->getSlug()]) ?>"><?= $community->getName() ?></a> »
|
|
||||||
<a href="<?= Container::$routeCollection->getRoute('community.events')->generateLink(['communitySlug' => $community->getSlug()]) ?>">Events</a> »
|
|
||||||
<?= $event->getTitle() ?>
|
|
||||||
<span class="small">[<a href="<?= Container::$routeCollection->getRoute('community.event.edit')->generateLink(['communitySlug' => $community->getSlug(), 'eventSlug' => $event->getSlug()]) ?>">edit</a>]</span>
|
|
||||||
</h2>
|
|
||||||
|
|
||||||
<div class="gridContainer marginTop">
|
|
||||||
<div>
|
|
||||||
<?php
|
|
||||||
$mainCurrencyCode = $community->getMainCurrency()->getCode();
|
|
||||||
$mainCurrencyRoundDigits = $community->getMainCurrency()->getRoundDigits();
|
|
||||||
?>
|
|
||||||
<h3 class="marginBottom">Finances</h3>
|
|
||||||
<p><a href="<?= Container::$routeCollection->getRoute('community.transactions.new')->generateLink(['communitySlug' => $community->getSlug(), 'event' => $event->getSlug()]) ?>">New transaction</a></p>
|
|
||||||
<table class="fullWidth marginTop">
|
|
||||||
<tr>
|
|
||||||
<td class="bold">Total cost</td>
|
|
||||||
<td class="mono" style="text-align: right;"><?= number_format(0, $mainCurrencyRoundDigits) ?> <?= $mainCurrencyCode ?></td>
|
|
||||||
</tr>
|
|
||||||
</table>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
@endsection
|
|
@ -1,40 +0,0 @@
|
|||||||
@extends(templates/layout_normal)
|
|
||||||
|
|
||||||
@section(main)
|
|
||||||
<h2>
|
|
||||||
<a href="<?= Container::$routeCollection->getRoute('community')->generateLink(['communitySlug' => $community->getSlug()]) ?>"><?= $community->getName() ?></a> »
|
|
||||||
<a href="<?= Container::$routeCollection->getRoute('community.events')->generateLink(['communitySlug' => $community->getSlug()]) ?>">Events</a> »
|
|
||||||
<?php if (isset($event)): ?>
|
|
||||||
<a href="<?= Container::$routeCollection->getRoute('community.event')->generateLink(['communitySlug' => $community->getSlug(), 'eventSlug' => $event->getSlug()]) ?>"><?= $event->getTitle() ?></a> » Edit event
|
|
||||||
<?php else: ?>
|
|
||||||
New event
|
|
||||||
<?php endif; ?>
|
|
||||||
</h2>
|
|
||||||
<div class="box compactBox">
|
|
||||||
<?php
|
|
||||||
$formAction = isset($event) ?
|
|
||||||
Container::$routeCollection->getRoute('community.event.edit-action')->generateLink(['communitySlug' => $community->getSlug(), 'eventSlug' => $event->getSlug()]) :
|
|
||||||
Container::$routeCollection->getRoute('community.events.new-action')->generateLink(['communitySlug' => $community->getSlug()]);
|
|
||||||
?>
|
|
||||||
<form id="eventForm" action="<?= $formAction ?>" method="post" data-redirect-on-success="<?= Container::$routeCollection->getRoute('community.events')->generateLink(['communitySlug' => $community->getSlug()]) ?>">
|
|
||||||
<p class="formLabel">Title</p>
|
|
||||||
<input type="text" class="text big fullWidth" name="title" value="<?= isset($event) ? $event->getTitle() : '' ?>" required>
|
|
||||||
<p class="formLabel marginTop">Description</p>
|
|
||||||
<textarea class="text big fullWidth" name="description" rows="3"><?= isset($event) ? $event->getDescription() : '' ?></textarea>
|
|
||||||
<p class="formLabel marginTop">Start</p>
|
|
||||||
<input type="datetime-local" class="text big fullWidth" name="start" value="<?= isset($event) ? $event->getStartDate()->format('Y-m-d\TH:i') : '' ?>" required>
|
|
||||||
<p class="formLabel marginTop">End</p>
|
|
||||||
<input type="datetime-local" class="text big fullWidth" name="end" value="<?= isset($event) ? $event->getEndDate()->format('Y-m-d\TH:i') : '' ?>" required>
|
|
||||||
<p class="formError justify marginTop"></p>
|
|
||||||
<div class="right marginTop" style="font-size: 0;">
|
|
||||||
<button type="submit" name="submit_button"><?= isset($event) ? '<i class="fa-regular fa-floppy-disk"></i> Save' : '<i class="fa-regular fa-plus"></i> Create' ?></button>
|
|
||||||
<?php if (isset($event)): ?>
|
|
||||||
<button type="submit" form="deleteEvent" name="submit_button" data-confirmation="Are you sure you want to delete this event?" class="red marginLeft"><i class="fa-regular fa-trash-can"></i> Delete</button>
|
|
||||||
<?php endif; ?>
|
|
||||||
</div>
|
|
||||||
</form>
|
|
||||||
<?php if (isset($event)): ?>
|
|
||||||
<form id="deleteEvent" action="<?= Container::$routeCollection->getRoute('community.event.delete-action')->generateLink(['communitySlug' => $community->getSlug(), 'eventSlug' => $event->getSlug()]) ?>" method="post" data-redirect-on-success="<?= Container::$routeCollection->getRoute('community.events')->generateLink(['communitySlug' => $community->getSlug()]) ?>"></form>
|
|
||||||
<?php endif; ?>
|
|
||||||
</div>
|
|
||||||
@endsection
|
|
@ -1,60 +0,0 @@
|
|||||||
@extends(templates/layout_normal)
|
|
||||||
|
|
||||||
@section(main)
|
|
||||||
<h2>
|
|
||||||
<a href="<?= Container::$routeCollection->getRoute('community')->generateLink(['communitySlug' => $community->getSlug()]) ?>"><?= $community->getName() ?></a> »
|
|
||||||
Events
|
|
||||||
</h2>
|
|
||||||
|
|
||||||
<p class="marginTop"><a href="<?= Container::$routeCollection->getRoute('community.events.new')->generateLink(['communitySlug' => $community->getSlug()]) ?>">New event</a></p>
|
|
||||||
|
|
||||||
<?php if ($numberOfEvents > 0): ?>
|
|
||||||
<?php if ($pages > 1): ?>
|
|
||||||
<p class="paginateContainer marginTop">
|
|
||||||
<a href="<?= Container::$routeCollection->getRoute('community.events')->generateLink(['communitySlug' => $community->getSlug(), 'page' => 0]) ?>">«</a>
|
|
||||||
<a href="<?= Container::$routeCollection->getRoute('community.events')->generateLink(['communitySlug' => $community->getSlug(), 'page' => max(0, $currentPage - 1)]) ?>">‹</a>
|
|
||||||
<?php for ($i = 0; $i < $pages; $i++): ?>
|
|
||||||
<?php if ($currentPage == $i): ?>
|
|
||||||
<span class="selected"><?= $i + 1 ?></span>
|
|
||||||
<?php else: ?>
|
|
||||||
<a href="<?= Container::$routeCollection->getRoute('community.events')->generateLink(['communitySlug' => $community->getSlug(), 'page' => $i]) ?>"><?= $i + 1 ?></a>
|
|
||||||
<?php endif; ?>
|
|
||||||
<?php endfor; ?>
|
|
||||||
<a href="<?= Container::$routeCollection->getRoute('community.events')->generateLink(['communitySlug' => $community->getSlug(), 'page' => min($pages - 1, $currentPage + 1)]) ?>">›</a>
|
|
||||||
<a href="<?= Container::$routeCollection->getRoute('community.events')->generateLink(['communitySlug' => $community->getSlug(), 'page' => $pages - 1]) ?>">»</a>
|
|
||||||
</p>
|
|
||||||
<?php endif; ?>
|
|
||||||
|
|
||||||
<?php foreach ($events as $event): ?>
|
|
||||||
<a class="block" href="<?= Container::$routeCollection->getRoute('community.event')->generateLink(['communitySlug' => $community->getSlug(), 'eventSlug' => $event->getSlug()]) ?>">
|
|
||||||
<div class="box">
|
|
||||||
<p style="font-weight: bold;"><?= $event->getTitle() ?></p>
|
|
||||||
<p class="small"><?= $event->getStartDate()->format('Y-m-d') ?> – <?= $event->getEndDate()->format('Y-m-d') ?></p>
|
|
||||||
<p class="small"><?= $event->getDescription() ?></p>
|
|
||||||
</div>
|
|
||||||
</a>
|
|
||||||
<?php endforeach; ?>
|
|
||||||
|
|
||||||
<?php if ($pages > 1): ?>
|
|
||||||
<p class="paginateContainer marginTop">
|
|
||||||
<a href="<?= Container::$routeCollection->getRoute('community.events')->generateLink(['communitySlug' => $community->getSlug(), 'page' => 0]) ?>">«</a>
|
|
||||||
<a href="<?= Container::$routeCollection->getRoute('community.events')->generateLink(['communitySlug' => $community->getSlug(), 'page' => max(0, $currentPage - 1)]) ?>">‹</a>
|
|
||||||
<?php for ($i = 0; $i < $pages; $i++): ?>
|
|
||||||
<?php if ($currentPage == $i): ?>
|
|
||||||
<span class="selected"><?= $i + 1 ?></span>
|
|
||||||
<?php else: ?>
|
|
||||||
<a href="<?= Container::$routeCollection->getRoute('community.events')->generateLink(['communitySlug' => $community->getSlug(), 'page' => $i]) ?>"><?= $i + 1 ?></a>
|
|
||||||
<?php endif; ?>
|
|
||||||
<?php endfor; ?>
|
|
||||||
<a href="<?= Container::$routeCollection->getRoute('community.events')->generateLink(['communitySlug' => $community->getSlug(), 'page' => min($pages - 1, $currentPage + 1)]) ?>">›</a>
|
|
||||||
<a href="<?= Container::$routeCollection->getRoute('community.events')->generateLink(['communitySlug' => $community->getSlug(), 'page' => $pages - 1]) ?>">»</a>
|
|
||||||
</p>
|
|
||||||
<?php endif; ?>
|
|
||||||
|
|
||||||
<p class="marginTop"><a href="<?= Container::$routeCollection->getRoute('community.events.new')->generateLink(['communitySlug' => $community->getSlug()]) ?>">New event</a></p>
|
|
||||||
<?php else: ?>
|
|
||||||
<div class="box">
|
|
||||||
<p>There are no transactions yet.</p>
|
|
||||||
</div>
|
|
||||||
<?php endif; ?>
|
|
||||||
@endsection
|
|
@ -19,13 +19,7 @@
|
|||||||
<h3 class="marginBottom">Upcoming events</h3>
|
<h3 class="marginBottom">Upcoming events</h3>
|
||||||
<?php if (count($upcomingEvents) > 0): ?>
|
<?php if (count($upcomingEvents) > 0): ?>
|
||||||
<?php foreach ($upcomingEvents as $event): ?>
|
<?php foreach ($upcomingEvents as $event): ?>
|
||||||
<p>
|
<!-- todo -->
|
||||||
<a href="<?= Container::$routeCollection->getRoute('community.event')->generateLink(['communitySlug' => $event->getCommunity()->getSlug(), 'eventSlug' => $event->getSlug()]) ?>"><?= $event->getTitle() ?></a>
|
|
||||||
<span class="small">
|
|
||||||
(<a href="<?= Container::$routeCollection->getRoute('community')->generateLink(['communitySlug' => $event->getCommunity()->getSlug()]) ?>"><?= $event->getCommunity()->getName() ?></a>)
|
|
||||||
<?= $event->getStartDate()->format('Y-m-d') ?> – <?= $event->getEndDate()->format('Y-m-d') ?>
|
|
||||||
</span>
|
|
||||||
</p>
|
|
||||||
<?php endforeach; ?>
|
<?php endforeach; ?>
|
||||||
<?php else: ?>
|
<?php else: ?>
|
||||||
<p>There is no upcoming event.</p>
|
<p>There is no upcoming event.</p>
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
<meta name="description" content="<?= $_ENV['APP_NAME'] ?>">
|
<meta name="description" content="<?= $_ENV['APP_NAME'] ?>">
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||||
<meta name="theme-color" content="#212f4d">
|
<meta name="theme-color" content="#212f4d">
|
||||||
<title><?= isset($title) ? $title . ' – ' : '' ?><?= $_ENV['APP_NAME'] ?></title>
|
<title><?= $_ENV['APP_NAME'] ?></title>
|
||||||
<?php if (preg_match('/^(http(s)?:)?\/\//', $_ENV['STATIC_ROOT']) === 1): ?>
|
<?php if (preg_match('/^(http(s)?:)?\/\//', $_ENV['STATIC_ROOT']) === 1): ?>
|
||||||
<link href="<?= $_ENV['STATIC_ROOT'] ?>" rel="preconnect">
|
<link href="<?= $_ENV['STATIC_ROOT'] ?>" rel="preconnect">
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
|
Loading…
Reference in New Issue
Block a user