2023-05-01 19:23:48 +02:00
@ extends ( templates / layout_normal )
@ section ( main )
< h2 >
< a href = " <?= Container:: $routeCollection->getRoute ('community')->generateLink(['communityId' => $community->getId ()]) ?> " >< ? = $community -> getName () ?> </a> »
< a href = " <?= Container:: $routeCollection->getRoute ('community.transactions')->generateLink(['communityId' => $community->getId ()]) ?> " > Transactions </ a > »
< ? php if ( isset ( $transaction )) : ?>
Edit transaction
< ? php else : ?>
New transaction
< ? php endif ; ?>
</ h2 >
< div class = " box compactBox " >
< ? php
$formAction = isset ( $transaction ) ?
Container :: $routeCollection -> getRoute ( 'community.transactions.edit-action' ) -> generateLink ([ 'communityId' => $community -> getId (), 'transactionId' => $transaction -> getId ()]) :
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(['communityId' => $community->getId ()]) ?> " >
2023-05-02 19:51:15 +02:00
< p class = " formLabel " > Payer </ p >
2023-05-01 19:23:48 +02:00
< select class = " big fullWidth " name = " payer_user_id " required >
2023-05-02 19:51:15 +02:00
< option value = " " hidden ></ option >
2023-05-01 19:23:48 +02:00
< ? php foreach ( $members as $member ) : ?>
< option value = " <?= $member->getUser ()->getId() ?> " < ? = isset ( $transaction ) && $transaction -> getPayerUserId () === $member -> getUser () -> getId () ? 'selected' : '' ?> ><?= $member->getUser()->getDisplayName() ?></option>
< ? php endforeach ; ?>
</ select >
2023-05-02 19:51:15 +02:00
< p class = " formLabel marginTop " > Payee </ p >
< select class = " big fullWidth " name = " payee_user_id " >
< option value = " " > [ common ] </ option >
2023-05-01 19:23:48 +02:00
< ? php foreach ( $members as $member ) : ?>
< option value = " <?= $member->getUser ()->getId() ?> " < ? = isset ( $transaction ) && $transaction -> getPayeeUserId () === $member -> getUser () -> getId () ? 'selected' : '' ?> ><?= $member->getUser()->getDisplayName() ?></option>
< ? php endforeach ; ?>
</ select >
2023-05-02 19:51:15 +02:00
< p class = " formLabel marginTop " > Description </ p >
< input type = " text " class = " text big fullWidth " name = " description " value = " <?= isset( $transaction ) ? $transaction->getDescription () : '' ?> " required >
< p class = " formLabel marginTop " > Sum </ p >
< input type = " number " class = " text big fullWidth " name = " sum " value = " <?= isset( $transaction ) ? $transaction->getSum () : '' ?> " min = " 0 " step = " 0.000000001 " required >
< p class = " formLabel marginTop " > Currency </ p >
< select class = " big fullWidth " name = " currency_id " required >
< option value = " " hidden ></ option >
2023-05-01 19:23:48 +02:00
< ? php foreach ( $currencies as $currency ) : ?>
< option value = " <?= $currency->getId () ?> " < ? = isset ( $transaction ) && $transaction -> getCurrencyId () === $currency -> getId () ? 'selected' : '' ?> ><?= $currency->getCode() ?></option>
< ? php endforeach ; ?>
</ select >
2023-05-02 19:51:15 +02:00
< p class = " formLabel marginTop " > Time </ p >
< input type = " datetime-local " class = " text big fullWidth " name = " time " value = " <?= isset( $transaction ) ? $transaction->getTimeDate ()->format('Y-m-d \T H:i') : (new DateTime())->format('Y-m-d \T H:i') ?> " required >
2023-05-01 19:23:48 +02:00
< p class = " formError justify marginTop " ></ p >
< div class = " right marginTop " style = " font-size: 0; " >
2023-05-02 19:53:06 +02:00
< button type = " submit " name = " submit_button " >< ? = isset ( $transaction ) ? 'Save' : 'Create' ?> </button>
2023-05-01 19:23:48 +02:00
< ? php if ( isset ( $transaction )) : ?>
2023-05-06 13:13:15 +02:00
< button type = " submit " form = " deleteTransaction " name = " submit_button " data - confirmation = " Are you sure you want to delete this transaction? " class = " red marginLeft " > Delete </ button >
2023-05-01 19:23:48 +02:00
< ? php endif ; ?>
</ div >
</ form >
< ? php if ( isset ( $transaction )) : ?>
2023-05-02 00:02:38 +02:00
< 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 >
2023-05-01 19:23:48 +02:00
< ? php endif ; ?>
</ div >
@ endsection