| @@ -54,11 +54,7 @@ class MinecraftPaymentPlugin extends Plugin { | |||
| $this->show_template( 'GrantUser', $params ); | |||
| } | |||
| public function settle_view( string $url ) { | |||
| $m = array_key_exists( 'month', $_GET ) ? $_GET[ 'month' ] : date( 'm' ) - 1; | |||
| $y = array_key_exists( 'month', $_GET ) ? $_GET[ 'month' ] : date( 'Y' ); | |||
| if ( $m == '0' ) { $m = '12'; $y--; } | |||
| private function settle( $m, $y ) { | |||
| $mp = MinecraftMonthPaid::GetByUnique( 0, $m ,$y ); | |||
| if ( $mp ) { | |||
| echo __( [ 'de' => 'Bereits abgerechnet', 'en' => 'Already settled' ] ); | |||
| @@ -123,6 +119,38 @@ class MinecraftPaymentPlugin extends Plugin { | |||
| } | |||
| } | |||
| public function settle_view( string $url ) { | |||
| // ORDER BY Year DESC, Month DESC LIMIT 1 | |||
| $nwst = MinecraftMonthPaid::GetAll( "1 ORDER BY Year DESC, Month DESC LIMIT 1" )[ 0 ]; | |||
| if ( !$nwst ) { | |||
| $nwst = new MinecraftMonthPaid(); | |||
| $nwst->SetMonth( date( 'm' ) ); | |||
| $nwst->SetYear( date( 'Y' ) ); | |||
| } | |||
| $m = array_key_exists( 'month', $_GET ) ? $_GET[ 'month' ] + 1 : date( 'm' ); | |||
| $y = array_key_exists( 'year', $_GET ) ? $_GET[ 'year' ] : date( 'Y' ); | |||
| if ( $m == '0' ) { $m = '12'; $y--; } | |||
| $start = ( new DateTime( $nwst->GetYear() . '-' . $nwst->GetMonth() . '-' . '01' ) )->modify( 'first day of next month' ); | |||
| $end = ( new DateTime( date( "$y-$m-01" ) ) )->modify( 'first day of this month' ); | |||
| $interval = DateInterval::createFromDateString( '1 month' ); | |||
| $period = new DatePeriod( $start, $interval, $end ); | |||
| $settled = false; | |||
| foreach ($period as $dt) { | |||
| $settled = true; | |||
| echo 'Settling ' . $dt->format("Y-m") . ': '; | |||
| $this->settle( $dt->format( 'm' ), $dt->format( 'Y' ) ); | |||
| echo "<br>\n"; | |||
| } | |||
| if( !$settled ) { | |||
| echo 'Nothing to settle'; | |||
| } | |||
| } | |||
| public function acredit_view( string $url ) { | |||
| if ( !Permission::PERMITTED( 'Minecraft-Pay-Settings', 1 ) ) return; | |||
| $params = null; | |||
| @@ -0,0 +1,2 @@ | |||
| declare class Account { | |||
| } | |||
| @@ -0,0 +1,2 @@ | |||
| class Account { | |||
| } | |||
| @@ -0,0 +1,3 @@ | |||
| class Account { | |||
| } | |||
| @@ -0,0 +1,4 @@ | |||
| <meta log-in /> | |||
| <div style="width: 100%; text-align: right; border: 1px solid white; border-radius: 1rem; padding: 1rem; margin: 1rem 0; box-sizing: border-box;"> | |||
| <span>Account: <a dval-innerText="MinecraftUserAccount::ACCOUNT() + ' €'"></a></span> | |||
| </div> | |||
| @@ -0,0 +1,2 @@ | |||
| declare class AccountList { | |||
| } | |||
| @@ -0,0 +1,2 @@ | |||
| class AccountList { | |||
| } | |||
| @@ -0,0 +1,3 @@ | |||
| class AccountList { | |||
| } | |||
| @@ -0,0 +1,17 @@ | |||
| <meta log-in permission="Minecraft-Possess-User" /> | |||
| <table class="table"> | |||
| <thead> | |||
| <tr> | |||
| <th dval-innerText="__( [ 'Date' )"></th> | |||
| <th style="width: 100%;" dval-innerText="__( 'Comment' )"></th> | |||
| <th dval-innerText="__( 'Amount' )"></th> | |||
| </tr> | |||
| </thead> | |||
| <tbody> | |||
| <tr dyn-for="[ 'credit', 'MinecraftUserAccount::GetAll( [ \'DebtorID\' => User::CURRENT()->ID ] )' ]"> | |||
| <td dval-innerText="credit.GetOccurence()"></td> | |||
| <td dval-innerText="credit.GetComment()"></td> | |||
| <td style="text-align: right;" dval-innerText="credit.GetMod() + ' €'"></td> | |||
| </tr> | |||
| </tbody> | |||
| </table> | |||
| @@ -0,0 +1,40 @@ | |||
| <meta log-in permission="Minecraft-Pay-Settings" /> | |||
| <div dyn-if="isset( $save_message )"> | |||
| <div dyn-type="alert" eval-value="$save_message" eval-type="$save_success ? ALERT_SUCCESS : ALERT_DANGER"></div> | |||
| </div> | |||
| <form method="POST"> | |||
| <table> | |||
| <thead> | |||
| <tr> | |||
| <th innerText="Minecraft Payment" colspan="2"></th> | |||
| </tr> | |||
| </thead> | |||
| <tbody> | |||
| <tr> | |||
| <th eval-innerText="__([ 'de' => 'Benutzer', 'en' => 'User' ])"></th> | |||
| <td> | |||
| <select name="DebtorID"> | |||
| <div dyn-for="[ 'user', 'User::GetAll()' ]"><option eval-value="$user->GetID()" eval-innerText="$user->GetUsername()"></option></div> | |||
| </select> | |||
| </td> | |||
| </tr> | |||
| <tr> | |||
| <th eval-innerText="__([ 'de' => 'Menge', 'en' => 'Amount' ])"></th> | |||
| <td> | |||
| <input type="number" step="0.01" name="Mod" value="0.00" /> | |||
| </td> | |||
| </tr> | |||
| <tr> | |||
| <th eval-innerText="__([ 'de' => 'Kommentar', 'en' => 'Comment' ])"></th> | |||
| <td> | |||
| <input type="string" name="Comment" /> | |||
| </td> | |||
| </tr> | |||
| <tr> | |||
| <td colspan="2"> | |||
| <input type="submit" name="AddAccountChange" eval-value="__([ 'de' => 'Gutschreiben', 'en' => 'Credit' ])" /> | |||
| </td> | |||
| </tr> | |||
| </tbody> | |||
| </table> | |||
| </form> | |||