| $this->show_template( 'GrantUser', $params ); | $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 ); | $mp = MinecraftMonthPaid::GetByUnique( 0, $m ,$y ); | ||||
| if ( $mp ) { | if ( $mp ) { | ||||
| echo __( [ 'de' => 'Bereits abgerechnet', 'en' => 'Already settled' ] ); | echo __( [ 'de' => 'Bereits abgerechnet', 'en' => 'Already settled' ] ); | ||||
| } | } | ||||
| } | } | ||||
| 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 ) { | public function acredit_view( string $url ) { | ||||
| if ( !Permission::PERMITTED( 'Minecraft-Pay-Settings', 1 ) ) return; | if ( !Permission::PERMITTED( 'Minecraft-Pay-Settings', 1 ) ) return; | ||||
| $params = null; | $params = null; |