/** Datei: plugins/calendars/library/ARUNOX/Plugins/Calendars/Model.php **/ * @copyright 2025 ARUNOX * @version 1.0.0 * * @since 1.0.0 File is created */ namespace ARUNOX\Plugins\Calendars; use ARUNOX\API\PHP; use ARUNOX\Database\Attribute; use ARUNOX\Database\BaseModel; #[PHP\Attributes\Database\Definitions\Table( "calendars" )] #[PHP\Attributes\Database\Definitions\HashID( "cal" )] #[PHP\Attributes\Database\Definitions\Entity( Entity::class )] class Model extends BaseModel { /* ### VARIABLES ################################################ # */ /* ### PUBLIC STATIC FUNCTIONS ################################## # */ /* ### PUBLIC STATIC LOG FUNCTIONS ############################## # */ public static function getLogRulesUpdated( int $id ) { $current = static::get( $id ); return [ "status" => [ "options" => Attribute\Status::getAll(), "message" => "Status wurde auf '%4\$t' gesetzt", "target_hids" => $current->target_hid, ], ]; } public static function getLogRulesCreated( int $id ) { $current = static::get( $id ); return [ "__self" => [ "target_hids" => $current->target_hid , ], ]; } } /** Datei: plugins/calendars/library/ARUNOX/Plugins/Calendars/Entries/Model.php **/ * @copyright 2025 ARUNOX * @version 1.0.0 * * @since 1.0.0 File is created */ namespace ARUNOX\Plugins\Calendars\Entries; use ARUNOX\API\PHP; use ARUNOX\Plugins\Calendars; use ARUNOX\Database\BaseModel; #[PHP\Attributes\Database\Definitions\Table( "calendars_entries" )] #[PHP\Attributes\Database\Definitions\HashID( "cent" )] #[PHP\Attributes\Database\Definitions\Entity( Entity::class )] #[PHP\Attributes\Database\Definitions\Origin( Calendars\Model::class )] class Model extends BaseModel { /* ### VARIABLES ################################################ # */ /* ### PUBLIC STATIC FUNCTIONS ################################## # */ public static function getByOrigin( int|string|array $origin, null|string $column = NULL ) { $origin = Calendars\Model::getValue( $origin ); if( $column ) return Model::getAllValue([ "origin_id" => $origin ], $column ); return Model::getAll([ "origin_id" => $origin ] ); } public static function save( array $data ) : mixed { if( isset( $data["origin_id"] ) ) { if( !is_numeric( $data["origin_id"] ) ) { if( !$origin_id = Calendars\Model::resolveHashID( $data["origin_id"] ) ) { $origin = static::resolveHashIDPrefix( $data["origin_id"] ); $origin_id = Calendars\Model::save([ "titlt" => $origin->name, "target_hid" => $data["origin_id"], ]); } $data["origin_id"] = $origin_id; } } return parent::save( $data ); } /* ### PUBLIC STATIC LOG FUNCTIONS ############################## # */ public static function getLogRulesUpdated( int $id ) { $current = static::get( $id ); $calendar = $current->origin; $hashids = [ $calendar->hashid, $calendar->target_hid, ]; return [ "status" => [ "options" => Status::getAll(), "message" => "Status wurde auf '%4\$t' gesetzt", "target_hids" => $hashids, ], "category_id" => [ "options" => Calendars\Categories\Model::getAsOptions("title"), "message" => "Kategorie wurde auf '%4\$T' gesetzt", "target_hids" => $hashids, ], "date_end" => [ "message" => "Endzeitpunkt wurde auf '%4\$FORMAT_DATETIME\$D' gesetzt", "target_hids" => $hashids, ], "date_start" => [ "message" => "Startzeitpunkt wurde auf '%4\$FORMAT_DATETIME\$D' gesetzt", "target_hids" => $hashids, ] ]; } public static function getLogRulesCreated( int $id ) { $current = static::get( $id ); $calendar = $current->origin; return [ "__self" => [ "target_hids" => [ $calendar->hashid, $calendar->target_hid, ], ], ]; } } /** Datei: plugins/calendars/library/ARUNOX/Plugins/Calendars/Entries/API/v1/Routes.php **/ * @copyright 2025 ARUNOX * @version 1.1.0 * * @since 1.0.0 File is created */ namespace ARUNOX\Plugins\Calendars\Entries\API\v1; use ARUNOX\Core\Hooks; use ARUNOX\Core\Router; use ARUNOX\Plugins\REST; class Routes { public static function register() : void { /* ### MAIN ROUTES ############################## # */ Router::addAll( Controller::class ); } } /** Datei: plugins/calendars/library/ARUNOX/Plugins/Calendars/Entries/API/v1/Controller.php **/ * @copyright 2025 ARUNOX * @version 1.1.0 * * @since 1.0.0 File is created */ namespace ARUNOX\Plugins\Calendars\Entries\API\v1; use ARUNOX\HTTP; use ARUNOX\API\PHP; use ARUNOX\Core\Hooks; use ARUNOX\Plugins\Logs; use ARUNOX\Plugins\REST; use ARUNOX\Plugins\Calendars; use ARUNOX\API\BaseController; use ARUNOX\Database\BaseEntity; #[PHP\Attributes\Controller\Label( "Termin", "Termine" )] #[PHP\Attributes\Controller\Icon( REST\Generator\Config\Icon::CalendarEvent )] #[PHP\Attributes\Controller\Route( "entries", Calendars\API\v1\Controller::class )] #[PHP\Attributes\Database\Definitions\Model( Calendars\Entries\Model::class )] class Controller extends BaseController { /* ### PUBLIC GET FUNCTIONS ##################################### # */ /** * @api * @method GET * * @route.path /calendars/entries * @route.description Listet alle Logeinträge */ public static function getAllPrepared() : array { return parent::getAllPrepared(); } /** * @api * @method GET * * @route.path /calendars/{origin}/entries * @route.description Listet alle Logeinträge */ public static function getByOriginPrepared( string $origin ) : array { return parent::getByOriginPrepared( $origin ); } /** * @api * @method GET * * @route.path /calendars/entries/{hashid} * @route.description Gibt einen einzelnen Logeintrag anhand der ID zurück */ public static function getPrepared( string $hashid ) : BaseEntity | HTTP\Response { return parent::getPrepared( $hashid ); } /* ### PUBLIC SAVE FUNCTIONS #################################### # */ /** * @api * @method PUT * * @route.path /calendars/entries/{hashid} * @route.description Speichert Änderungen an einem bestehenden Termin */ public static function savePrepared( string $hashid, array $data ) : HTTP\Response { return parent::savePrepared( $hashid, $data ); } /** * @api * @method POST * * @route.description Erstellt einen neuen Termin */ public static function createPrepared( array $data ) : HTTP\Response { return parent::createPrepared( $data ); } /** * @api * @method DELETE * * @route.path /calendars/entries/{hashid} * @route.description Löscht ein Logeintrag anhand der ID */ public static function deletePrepared( string $hashid ) : HTTP\Response { return parent::deletePrepared( $hashid ); } /** * @api * @method PATCH * * @route.path /calendars/entries/{hashid}/status * @route.description Wechselt den Status (aktiv/inaktiv) eines Kalenders */ public static function toggleStatusPrepared( string $hashid ) : HTTP\Response { return parent::toggleStatusPrepared( $hashid ); } /* ### PUBLIC VALIDATE FUNCTIONS ################################ # */ /* ### PUBLIC REST RESPONSE FUNCTIONS ########################### # */ /** * @internal rest * @method PUT * * @route.path /calendars/entries/{hashid} * @route.description REST-Antwort nach dem Speichern eines Termins */ public static function restResponseSave( string $hashid, array $data ) : HTTP\Response { $result = static::savePrepared( $hashid, $data ); if( $result->isStatus( 200 ) ) { $data = Calendars\Entries\Model::get( $hashid ); REST\Response::closeModals(); REST\Response::addUpdater( [ "data/table/row", $hashid ], $data ); } return static::restResponse( $result ); } /** * @internal rest * @method POST * * @route.path /calendars/entries * @route.description REST-Antwort nach dem Erstellen eines Termins (inkl. Notifikation, Redirect etc.) */ public static function restResponseCreate( array $data ) : HTTP\Response { $result = static::createPrepared( $data ); if( $result->isStatus( 200 ) ) { $data = $result->getBody("data"); REST\Response::closeModals(); REST\Response::refresh( "#appointments" ); REST\Response::addClick( [ "data/table/row", $data->hashid ] ); } return static::restResponse( $result ); } /** * @internal rest * @method DELETE * * @route.path /calendars/entries/{hashid} * @route.description REST-Antwort nach dem Löschen eines Logeintrag */ public static function restResponseDelete( string $hashid ) : HTTP\Response { REST\Response::closeModals(); $result = static::deletePrepared( $hashid ); if( $result->isStatus( 200 ) ) { REST\Response::refresh( "#appointments" ); } return static::restResponse( $result ); } /** * @internal rest * @method PATCH * * @route.path /calendars/entries/{hashid}/status * @route.description REST-Antwort zur Status-Umschaltung eines Kalenders */ public static function restResponseToggleStatusPrepared( string $hashid ) : HTTP\Response { return parent::restResponseToggleStatusPrepared( $hashid ); } /* ### PUBLIC REST CONFIG FUNCTIONS ############################# # */ /** * @internal rest * @method GET * * @route.path /calendars/entries/{hashid} * @route.description REST-Konfiguration für Detailansicht eines Logeintrags */ public static function restConfigDetails( string $hashid ) : REST\Generator\Base\BaseGenerator { return REST\Response::addModal( "details", static::getSingular( "%t bearbeiten" ) ) ->setSize( "equal" ) ->setWidth("lg") ->get() ->setApi( "/calendars/entries/{$hashid}" ) ->setAction( "/calendars/entries/{$hashid}", "PUT" ) ->addTab( static::getSingular() )->get() ->addChildren( Calendars\Entries\API\v1\Controller::restConfigInputs() ) ->parent() ->addTab( Calendars\Entries\Participants\API\v1\Controller::getPlural(), "participants" )->get() ->addChildren( Calendars\Entries\Participants\API\v1\Controller::restConfigTable( $hashid ) ) ->parent() ->addCallable( [ Logs\API\v1\Controller::class, "restConfigTab" ], $hashid ) ->addTab( "Speichern" )->get() ->setColor( REST\Generator\Config\Color::Primary ) ->setIcon( "bi bi-save" ) ->setType( "submit" ) ; } /** * @internal rest * @method GET * * @route.path /calendars/entries/create * @route.description REST-Konfiguration für das Erstellen eines Kalenders (Formular) */ public static function restConfigCreatePrepared() : REST\Generator\Base\BaseGenerator { return parent::restConfigCreatePrepared(); } /** * @internal rest * @method GET * * @route.path /calendars/{origin}/entries/create * @route.description REST-Konfiguration für das Erstellen eines Kalenders (Formular) */ public static function restConfigCreateByOriginPrepared( bool | string $origin = FALSE ) : REST\Generator\Base\BaseGenerator { return parent::restConfigCreateByOriginPrepared( $origin ); } /** * @internal rest * @method GET * * @route.path /calendars/entries/{hashid}/delete * @route.description REST-Konfiguration für die Lösch-Bestätigung eines Logeintrags */ public static function restConfigDeletePrepared( string $hashid ) : REST\Generator\Base\BaseGenerator { return REST\Response::addModal( "details", static::getSingular( "%t löschen" ) ) ->setSize( REST\Wrapper\Modal\Size::sm ) ->get() ->setAction( "/calendars/entries/{$hashid}", "DELETE" ) ->addText( "Möchtest du wirklich den Datensatz (#{$hashid}) löschen? " ) ->addButton(...Hooks::filter( "rest.generator::button.type->cancel", [], NULL, "calendars/entries" )) ->addButton(...Hooks::filter( "rest.generator::button.type->delete", [], NULL, "calendars/entries" )); } /* ### PUBLIC REST EXTENSION FUNCTIONS ########################## # */ public static function restConfigTab( REST\Generator\Base\BaseGenerator $rest, null|string $origin = NULL ) : void { $calendar = Calendars\Model::getByColumn( "target_hid", $origin ); $rest->addTab( static::getPlural(), "appointments" )->get() ->setIcon( static::getIcon() ) ->addContent( static::restConfigTable( $calendar ? $calendar->hashid : $origin ) ) ; } public static function restConfigTable( null|string $origin = NULL ) : REST\Generator\Base\BaseGenerator { $rest = REST\Generator\Data\Table::create() ->setApi( "/calendars/{$origin}/entries" ) ->setAction( "/calendars/entries/{hashid}" ) ->setOrder( "date_start", "desc" ) ->setSearch( TRUE ) ->addButton(...Hooks::filter( "rest.generator::button.name->create", [], "calendars/{$origin}/entries" )) ->addColumn(...Hooks::filter( "rest.generator::column.type->status", [ "options" => Calendars\Entries\Status::getAll(), ], "status", [], "calendars/entries", "hashid" )) ->addColumn(...Hooks::filter( "rest.generator::column.type->icon", [ "label" => "Kategorie", "icon" => "bi-tags", "options" => Calendars\Categories\Model::getAsOptions("title") ], "category_id", [], "calendars/entries", "hashid" )) ; foreach( Calendars\Entries\Participants\Status::getAll() as $status ) { $rest->addColumn(...Hooks::filter( "rest.generator::column.type->amount", [ "action" => "/calendars/entries/{hashid}#participants", "label" => FALSE, "title" => $status["label"], "icon" => $status["icon"], ], "participants.status.{$status["value"]}", TRUE, FALSE, TRUE, "calendars/entries", "hashid" )); } $rest ->addColumn(...Hooks::filter( "rest.generator::column.type->datetime", [], "date_start", TRUE, FALSE, TRUE, "calendars/entries" )) ->addColumn(...Hooks::filter( "rest.generator::column.type->datetime", [], "date_end", TRUE, FALSE, TRUE, "calendars/entries" )) ->addColumn(...Hooks::filter( "rest.generator::column.type->text", [], "title", TRUE, TRUE, TRUE, "calendars/entries" )) ->addColumn(...Hooks::filter( "rest.generator::column.type->text", [], "description", TRUE, TRUE, TRUE, "calendars/entries" )) ->addColumn(...Hooks::filter( "rest.generator::column.type->actions", [], [], FALSE, "calendars/entries" ))->get() ->addButton(...Hooks::filter( "rest.generator::action.name->edit", [], "calendars/entries", "hashid" )) ->addButton(...Hooks::filter( "rest.generator::action.name->delete", [], "calendars/entries", "hashid" )) ; return $rest; } public static function restConfigInputs() : array { $rest = REST\Generator\Data\Form::create() ->addGroup() ->addField(...Hooks::filter( "rest.generator::control.type->text", [], "title", TRUE, "calendars/entries" )) ->addField(...Hooks::filter( "rest.generator::control.type->select", [ "options" => Calendars\Categories\Model::getAsOptions( "title" ), ], "category_id", TRUE, FALSE, "calendars/entries" )) ->addField(...Hooks::filter( "rest.generator::control.type->datetime", [], "date_start", TRUE, "calendars/entries" )) ->addField(...Hooks::filter( "rest.generator::control.type->datetime", [], "date_end", TRUE, "calendars/entries" )) ->parent() ->addGroup() ->addField(...Hooks::filter( "rest.generator::control.type->textarea", [ "lines" => 3, ], "description", FALSE, "calendars/entries" )) ; return $rest->top()->getChildren(); } public static function restConfigOrigin( bool|string $origin ) : REST\Generator\Base\BaseGenerator { $rest = REST\Generator\Data\Form::create(); if( $origin === FALSE ) { return $rest->addField(...Hooks::filter( "rest.generator::control.type->select", [ "options" => Calendars\Model::getAsOptions( "title" ), ], "origin_id", TRUE, FALSE, "calendars/entries" )); } $calendar = Calendars\Model::getValue( $origin, "id" ); return $rest->addField(...Hooks::filter( "rest.generator::control.type->hidden", [], "origin_id", $calendar ?? $origin, "calendars/entries" )); } } /** Datei: plugins/calendars/library/ARUNOX/Plugins/Calendars/Entries/Entity.php **/ * @copyright 2025 ARUNOX * @version 1.0.0 * * @since 1.0.0 File is created */ namespace ARUNOX\Plugins\Calendars\Entries; use ARUNOX\API\PHP; use ARUNOX\Plugins\Calendars; use ARUNOX\Database\BaseEntity; #[PHP\Attributes\Database\Attributes( "status" )] #[PHP\Attributes\Database\Attributes( "date_edit" )] #[PHP\Attributes\Database\Attributes( "date_create" )] #[PHP\Attributes\Database\Attributes( "date_start" )] #[PHP\Attributes\Database\Attributes( "date_end" )] #[PHP\Attributes\Database\Definitions\Model( Model::class )] class Entity extends BaseEntity { /* ### VARIABLES ################################################ # */ /* ### PUBLIC FUNCTIONS ######################################### # */ public function getParticipants() : array { $list = Participants\Model::getByOrigin( $this->id ); $status = Participants\Status::getAll(); $count = array_map( fn( $item ) => count( array_filter( $list, fn( $entry ) => $entry->status->getValue() == $item["value"] ) ), $status ); $status = array_map( fn( $count, $status ) => "{$count}x {$status["emoji"]}", $count, $status ); $return = [ "count" => count( $list ), "output" => implode( " | ", $status ), "status" => $count, "list" => $list, ]; return $return; } public function getOrigin() : bool|BaseEntity { return Calendars\Model::get( $this->origin_id ); } } /** Datei: plugins/calendars/library/ARUNOX/Plugins/Calendars/Entries/Status.php **/ [ "color" => REST\Generator\Config\Color::Danger, "icon" => "bi-hourglass", "label" => "offen" ], self::Done => [ "color" => REST\Generator\Config\Color::Success, "icon" => "bi-check-lg", "label" => "erledigt" ], ]; /* ### PUBLIC FUNCTIONS ######################################### # */ } /** Datei: plugins/calendars/library/ARUNOX/Plugins/Calendars/Entries/Participants/Model.php **/ * @copyright 2025 ARUNOX * @version 1.0.0 * * @since 1.0.0 File is created */ namespace ARUNOX\Plugins\Calendars\Entries\Participants; use ARUNOX\API\PHP; use ARUNOX\Plugins\Calendars; use ARUNOX\Database\BaseModel; #[PHP\Attributes\Database\Definitions\Table( "calendars_entries_participants" )] #[PHP\Attributes\Database\Definitions\HashID( "cepar" )] #[PHP\Attributes\Database\Definitions\Entity( Entity::class )] #[PHP\Attributes\Database\Definitions\Origin( Calendars\Entries\Model::class )] class Model extends BaseModel { /* ### VARIABLES ################################################ # */ /* ### PUBLIC STATIC FUNCTIONS ################################## # */ public static function getByOrigin( int|string|array $origin, null|string $column = NULL ) { $origin = Calendars\Entries\Model::getValue( $origin ); if( $column ) return Model::getAllValue([ "origin_id" => $origin ], $column ); return Model::getAll([ "origin_id" => $origin ] ); } /* ### PUBLIC STATIC LOG FUNCTIONS ############################## # */ public static function getLogRulesUpdated( int $id ) { $current = static::get( $id ); $entry = $current->origin; $calendar = $entry->origin; return [ "status" => [ "options" => Status::getAll(), "message" => "Status wurde auf '%4\$t' gesetzt", "target_hids" => [ $current->target_hid, $entry->hashid, $calendar->hashid, $calendar->target_hid, ], ], ]; } public static function getLogRulesCreated( int $id ) { $current = static::get( $id ); $entry = $current->origin; $calendar = $entry->origin; return [ "__self" => [ "message" => "Teilnehmer wurde eingeladen", "target_hids" => [ $current->target_hid, $entry->hashid, $calendar->hashid, $calendar->target_hid, ], ], ]; } } /** Datei: plugins/calendars/library/ARUNOX/Plugins/Calendars/Entries/Participants/API/v1/Routes.php **/ * @copyright 2025 ARUNOX * @version 1.1.0 * * @since 1.0.0 File is created */ namespace ARUNOX\Plugins\Calendars\Entries\Participants\API\v1; use ARUNOX\Core\Hooks; use ARUNOX\Core\Router; use ARUNOX\Plugins\REST; class Routes { public static function register() : void { /* ### MAIN ROUTES ############################## # */ Router::addAll( Controller::class ); } } /** Datei: plugins/calendars/library/ARUNOX/Plugins/Calendars/Entries/Participants/API/v1/Controller.php **/ * @copyright 2025 ARUNOX * @version 1.1.0 * * @since 1.0.0 File is created */ namespace ARUNOX\Plugins\Calendars\Entries\Participants\API\v1; use ARUNOX\HTTP; use ARUNOX\API\PHP; use ARUNOX\Core\Hooks; use ARUNOX\Plugins\REST; use ARUNOX\Plugins\Users; use ARUNOX\Plugins\Calendars; use ARUNOX\API\BaseController; use ARUNOX\Database\BaseEntity; #[PHP\Attributes\Controller\Label( "Teilnehmer" )] #[PHP\Attributes\Controller\Route( "participants", Calendars\Entries\API\v1\Controller::class )] #[PHP\Attributes\Database\Definitions\Model( Calendars\Entries\Participants\Model::class )] class Controller extends BaseController { /* ### PUBLIC GET FUNCTIONS ##################################### # */ /** * @api * @method GET * * @route.path /calendars/entries/{origin}/participants * @route.description Listet alle Logeinträge */ public static function getByOriginPrepared( string $origin ) : array { return parent::getByOriginPrepared( $origin ); } /** * @api * @method GET * * @route.path /calendars/entries/participants/{hashid} * @route.description Gibt einen einzelnen Logeintrag anhand der ID zurück */ public static function getPrepared( string $hashid ) : BaseEntity | HTTP\Response { return parent::getPrepared( $hashid ); } /* ### PUBLIC SAVE FUNCTIONS #################################### # */ /** * @api * @method POST * * @route.path /calendars/entries/{origin}/participants * @route.description Erstellt einen neuen Teilnehmer */ public static function createByOriginPrepared( string $origin, array $data ) : HTTP\Response { return parent::createByOriginPrepared( $origin, $data ); } /** * @api * @method DELETE * * @route.path /calendars/entries/participants/{hashid} * @route.description Löscht ein Logeintrag anhand der ID */ public static function deletePrepared( string $hashid ) : HTTP\Response { return parent::deletePrepared( $hashid ); } /** * @api * @method PATCH * * @route.path /calendars/entries/participants/{hashid}/status * @route.description Wechselt den Status (aktiv/inaktiv) eines Kalenders */ public static function toggleStatusPrepared( string $hashid ) : HTTP\Response { return parent::toggleStatusPrepared( $hashid ); } /* ### PUBLIC VALIDATE FUNCTIONS ################################ # */ /* ### PUBLIC REST RESPONSE FUNCTIONS ########################### # */ /** * @internal rest * @method GET * * @route.path /calendars/entries/participants/{hashid} * @route.description REST-Konfiguration für Detailansicht eines Logeintrags */ public static function restResponseLog( string $hashid ) : HTTP\Response { $entry = Calendars\Entries\Participants\Model::get( $hashid )->origin; $route = Calendars\Entries\API\v1\Controller::getRoute( $entry->hashid, "#participants" ); REST\Response::redirect( $route ); return REST\Response::jsonResponse(); } /** * @internal rest * @method POST * * @route.path /calendars/entries/{origin}/participants * @route.description REST-Antwort nach dem Erstellen eines Kalenders */ public static function restResponseCreate( string $origin, array $data ) : HTTP\Response { $result = static::createByOriginPrepared( $origin, $data ); if( $result->isStatus( 200 ) ) { REST\Response::closeModals(); REST\Response::addClick( [ "data/table/row", $origin ], "participants" ); } return static::restResponse( $result ); } /** * @internal rest * @method DELETE * * @route.path /calendars/entries/participants/{hashid} * @route.description REST-Antwort nach dem Löschen eines Logeintrag */ public static function restResponseDelete( string $hashid ) : HTTP\Response { REST\Response::closeModals(); $current = Calendars\Entries\Participants\Model::get( $hashid ); $origin = Calendars\Entries\Model::get( $current->origin_id ); $result = static::deletePrepared( $hashid ); if( $result->isStatus( 200 ) ) { REST\Response::addClick( [ "data/table/row", $origin->hashid ], "participants" ); } return static::restResponse( $result ); } /** * @internal rest * @method PATCH * * @route.path /calendars/entries/participants/{hashid}/status * @route.description REST-Antwort zur Status-Umschaltung eines Kalenders */ public static function restResponseToggleStatusPrepared( string $hashid ) : HTTP\Response { return parent::restResponseToggleStatusPrepared( $hashid ); } /* ### PUBLIC REST CONFIG FUNCTIONS ############################# # */ /** * @internal rest * @method GET * * @route.path /calendars/entries/{origin}/participants/create * @route.description REST-Konfiguration für das Erstellen eines Teilnehmers (Formular) */ public static function restConfigAddByOriginPrepared( bool | string $origin = FALSE ) : REST\Generator\Base\BaseGenerator { return parent::restConfigAddByOriginPrepared( $origin ); } /** * @internal rest * @method GET * * @route.path /calendars/entries/participants/{hashid}/delete * @route.description REST-Konfiguration für die Lösch-Bestätigung eines Logeintrags */ public static function restConfigDeletePrepared( string $hashid ) : REST\Generator\Base\BaseGenerator { return REST\Response::addModal( "details", static::getSingular( "%t löschen" ) ) ->setSize( REST\Wrapper\Modal\Size::sm ) ->get() ->setAction( "/calendars/entries/participants/{$hashid}", "DELETE" ) ->addText( "Möchtest du wirklich den Datensatz (#{$hashid}) löschen? " ) ->addButton(...Hooks::filter( "rest.generator::button.type->cancel", [], NULL, "calendars/entries/participants" )) ->addButton(...Hooks::filter( "rest.generator::button.type->delete", [], NULL, "calendars/entries/participants" )); } /* ### PUBLIC REST EXTENSION FUNCTIONS ########################## # */ public static function restConfigTable( string $origin ) : REST\Generator\Base\BaseGenerator { $exclude = Calendars\Entries\Participants\Model::getByOrigin( $origin , "target_hid" ); $options = Users\Model::getAsOptions( "username", "hashid", $exclude ); $rest = REST\Generator\Data\Table::create() ->setApi( "/calendars/entries/{$origin}/participants" ) ->setOrder( "date_create", "desc" ) ->setSearch( TRUE ) ; if( !empty( $options ) ) { $rest->addButton(...Hooks::filter( "rest.generator::button.name->create", [], "calendars/entries/{$origin}/participants" )); } $rest->addColumn(...Hooks::filter( "rest.generator::column.type->status", [ "options" => Calendars\Entries\Participants\Status::getAll(), ], "status", [], "calendars/entries/participants", "hashid" )) ->addColumn(...Hooks::filter( "rest.generator::column.type->text", [ "label" => "Name", ], "target.username", TRUE, TRUE, TRUE, "calendars/entries/participants" )) ->addColumn(...Hooks::filter( "rest.generator::column.type->datetime", [ "label" => "Eingeladen am", ], "date_create", TRUE, FALSE, TRUE, "calendars/entries/participants" )) ->addColumn(...Hooks::filter( "rest.generator::column.type->text", [], "feedback", TRUE, FALSE, TRUE, "calendars/entries/participants" )) ->addColumn(...Hooks::filter( "rest.generator::column.type->actions", [], [], FALSE, "calendars/entries/participants" ))->get() ->addButton(...Hooks::filter( "rest.generator::action.name->delete", [], "calendars/entries/participants", "hashid" )) ; return $rest; } public static function restConfigInputs( string $origin ) : array { $exclude = Calendars\Entries\Participants\Model::getByOrigin( $origin , "target_hid" ); $rest = REST\Generator\Data\Form::create() ->addField(...Hooks::filter( "rest.generator::control.type->select", [ "options" => Users\Model::getAsOptions( "username", "hashid", $exclude ), ], "target_hid", TRUE, TRUE, "calendars/entries/participants" )) ; return $rest->top()->getChildren(); } } /** Datei: plugins/calendars/library/ARUNOX/Plugins/Calendars/Entries/Participants/Entity.php **/ * @copyright 2025 ARUNOX * @version 1.0.0 * * @since 1.0.0 File is created */ namespace ARUNOX\Plugins\Calendars\Entries\Participants; use ARUNOX\API\PHP; use ARUNOX\Plugins\Calendars; use ARUNOX\Database\BaseEntity; #[PHP\Attributes\Database\Attributes( "status", Status::class )] #[PHP\Attributes\Database\Attributes( "date_edit" )] #[PHP\Attributes\Database\Attributes( "date_create" )] #[PHP\Attributes\Database\Definitions\Model( Model::class )] class Entity extends BaseEntity { /* ### VARIABLES ################################################ # */ /* ### PUBLIC FUNCTIONS ######################################### # */ public function getTarget() { return \ARUNOX\Plugins\Users\Model::getByColumn( "hashid", $this->target_hid ); } public function getOrigin() : bool|BaseEntity { return Calendars\Entries\Model::get( $this->origin_id ); } } /** Datei: plugins/calendars/library/ARUNOX/Plugins/Calendars/Entries/Participants/Status.php **/ * @copyright 2025 ARUNOX * @version 1.1.0 * * @since 1.0.0 File is created */ namespace ARUNOX\Plugins\Calendars\API\v1; use ARUNOX\Core\Hooks; use ARUNOX\Core\Router; use ARUNOX\Plugins\REST; class Routes { public static function register() : void { /* ### MAIN ROUTES ############################## # */ Router::addAll( Controller::class ); /* ### MENU ROUTES ############################## # */ Hooks::add('router::get->api.v1.rest.routes', function( $routes ) { $routes[] = [ "path" => "/calendars", "label" => "Kalender", "icon" => "bi bi-calendar-week", "menu" => "administration", ]; return $routes; }, 50 ); } } /** Datei: plugins/calendars/library/ARUNOX/Plugins/Calendars/API/v1/Controller.php **/ * @copyright 2025 ARUNOX * @version 1.1.0 * * @since 1.0.0 File is created */ namespace ARUNOX\Plugins\Calendars\API\v1; use ARUNOX\HTTP; use ARUNOX\API\PHP; use ARUNOX\Core\Hooks; use ARUNOX\Plugins\Logs; use ARUNOX\Plugins\REST; use ARUNOX\Plugins\Calendars; use ARUNOX\API\BaseController; use ARUNOX\Database\BaseEntity; #[PHP\Attributes\Controller\Label( "Kalender" )] #[PHP\Attributes\Controller\Icon( REST\Generator\Config\Icon::CalendarWeek )] #[PHP\Attributes\Controller\Route( "calendars" )] #[PHP\Attributes\Database\Definitions\Model( Calendars\Model::class )] class Controller extends BaseController { /* ### PUBLIC GET FUNCTIONS ##################################### # */ /** * @api * @method GET * * @route.path /calendars * @route.description Listet alle Logeinträge */ public static function getAllPrepared() : array { return parent::getAllPrepared(); } /** * @api * @method GET * * @route.path /calendars/{hashid} * @route.description Gibt einen einzelnen Logeintrag anhand der ID zurück */ public static function getPrepared( string $hashid ) : BaseEntity | HTTP\Response { return parent::getPrepared( $hashid ); } /* ### PUBLIC SAVE FUNCTIONS #################################### # */ /** * @api * @method PUT * * @route.path /calendars/{hashid} * @route.description Speichert Änderungen an einem bestehenden Termin */ public static function savePrepared( string $hashid, array $data ) : HTTP\Response { return parent::savePrepared( $hashid, $data ); } /** * @api * @method POST * * @route.path /calendars * @route.description Erstellt einen neuen Kalender */ public static function createPrepared( array $data ) : HTTP\Response { return parent::createPrepared( $data ); } /** * @api * @method DELETE * * @route.path /calendars/{hashid} * @route.description Löscht ein Logeintrag anhand der ID */ public static function deletePrepared( string $hashid ) : HTTP\Response { return parent::deletePrepared( $hashid ); } /** * @api * @method PATCH * * @route.path /calendars/{hashid}/status * @route.description Wechselt den Status (aktiv/inaktiv) eines Kalenders */ public static function toggleStatusPrepared( string $hashid ) : HTTP\Response { return parent::toggleStatusPrepared( $hashid ); } /* ### PUBLIC VALIDATE FUNCTIONS ################################ # */ /* ### PUBLIC REST RESPONSE FUNCTIONS ########################### # */ /** * @internal rest * @method POST * * @route.path /calendars * @route.description REST-Antwort nach dem Erstellen eines Kalenders */ public static function restResponseCreate( array $data ) : HTTP\Response { $result = static::createPrepared( $data ); if( $result->isStatus( 200 ) ) { REST\Response::closeModals(); REST\Response::redirect( "/calendars/{$result->getBody("data", "hashid")}" ); } return static::restResponse( $result ); } /** * @internal rest * @method DELETE * * @route.path /calendars/{hashid} * @route.description REST-Antwort nach dem Löschen eines Logeintrag */ public static function restResponseDelete( string $hashid ) : HTTP\Response { REST\Response::closeModals(); $result = static::deletePrepared( $hashid ); if( $result->isStatus( 200 ) ) { REST\Response::redirect( "/calendars" ); } return static::restResponse( $result ); } /** * @internal rest * @method PATCH * * @route.path /calendars/{hashid}/status * @route.description REST-Antwort zur Status-Umschaltung eines Kalenders */ public static function restResponseToggleStatusPrepared( string $hashid ) : HTTP\Response { return parent::restResponseToggleStatusPrepared( $hashid ); } /* ### PUBLIC REST CONFIG FUNCTIONS ############################# # */ /** * @internal rest * @method GET * * @route.path /calendars * @route.description REST-Konfiguration für Logbuch-Tabelle */ public static function restConfigOverview() : REST\Generator\Base\BaseGenerator { $tabs = REST\Response::addWrapper( "details", static::getPlural() )->get(); $tabs = $tabs->addTab( "Übersicht", FALSE )->get() ->setIcon( static::getIcon() ) ->addHeadline( static::getPlural(), 2 ) ->addContent( static::restConfigTable() ->addButton(...Hooks::filter( "rest.generator::button.name->create", [], "calendars" )) ) ->parent(); $tabs = $tabs->addTab( Calendars\Categories\API\v1\Controller::getPlural(), "categories" )->get() ->setIcon( Calendars\Categories\API\v1\Controller::getIcon() ) ->addHeadline( Calendars\Categories\API\v1\Controller::getPlural(), 2 ) ->addContent( Calendars\Categories\API\v1\Controller::restConfigTable() ) ->parent(); // $tabs = $tabs->addTab( Calendars\Tasks\Templates\API\v1\Controller::getPlural(), "templates" )->get() // ->setIcon( Calendars\Tasks\Templates\API\v1\Controller::getIcon() ) // ->addHeadline( Calendars\Tasks\Templates\API\v1\Controller::getPlural(), 2 ) // ->addContent( // Calendars\Tasks\Templates\API\v1\Controller::restConfigTable() // ->addButton(...Hooks::filter( "rest.generator::button.name->create", [], "calendars/tasks/templates" )) // ) // ->parent(); $tabs = $tabs->addTab( Calendars\Entries\API\v1\Controller::getPlural(), "appointments" )->get() ->setIcon( Calendars\Entries\API\v1\Controller::getIcon() ) ->addHeadline( Calendars\Entries\API\v1\Controller::getPlural(), 2 ) ->addContent( Calendars\Entries\API\v1\Controller::restConfigTable() ) ->parent(); $tabs = $tabs->addTab( Calendars\Tasks\API\v1\Controller::getPlural(), "tasks" )->get() ->setIcon( Calendars\Tasks\API\v1\Controller::getIcon() ) ->addHeadline( Calendars\Tasks\API\v1\Controller::getPlural(), 2 ) ->addContent( Calendars\Tasks\API\v1\Controller::restConfigTable() ) ->parent(); return $tabs; } /** * @internal rest * @method GET * * @route.path /calendars/{hashid} * @route.description REST-Konfiguration für Detailansicht eines Logeintrags */ public static function restConfigDetails( string $hashid ) : REST\Generator\Base\BaseGenerator { return REST\Response::addWrapper( "details", static::getSingular( "%t bearbeiten" ) ) ->setBacklink( "/calendars" ) ->get() ->setApi( "/calendars/{$hashid}" ) ->setAction( "/calendars/{$hashid}", "PUT" ) ->addTab( "Kalender" )->get() ->addHeadline( "Kalender", 2 ) ->addField(...Hooks::filter( "rest.generator::control.type->text", [], "title", FALSE, "calendars" )) ->addField(...Hooks::filter( "rest.generator::control.type->textarea", [], "description", FALSE, "calendars" )) ->parent() ->addCallable( [ Calendars\Entries\API\v1\Controller::class, "restConfigTab" ], $hashid ) ->addCallable( [ Calendars\Tasks\API\v1\Controller::class, "restConfigTab" ], $hashid ) ->addCallable( [ Logs\API\v1\Controller::class, "restConfigTab" ], $hashid ) ->addTab( "Speichern" )->get() ->setColor( REST\Generator\Config\Color::Primary ) ->setIcon( "bi bi-save" ) ->setType( "submit" ); } /** * @internal rest * @method GET * * @route.path /calendars/create * @route.description REST-Konfiguration für das Erstellen eines Kalenders (Formular) */ public static function restConfigCreatePrepared() : REST\Generator\Base\BaseGenerator { return parent::restConfigCreatePrepared(); } /** * @internal rest * @method GET * * @route.path /calendars/{hashid}/delete * @route.description REST-Konfiguration für die Lösch-Bestätigung eines Logeintrags */ public static function restConfigDeletePrepared( string $hashid ) : REST\Generator\Base\BaseGenerator { return parent::restConfigDeletePrepared( $hashid ); } /* ### PUBLIC REST EXTENSION FUNCTIONS ########################## # */ public static function restConfigTable() : REST\Generator\Base\BaseGenerator { $rest = REST\Generator\Data\Table::create() ->setApi( "/calendars" ) ->setAction( "/calendars/{hashid}" ) ->setOrder( "title", "asc" ) ->setSearch( TRUE ) ->addColumn(...Hooks::filter( "rest.generator::column.type->status", [], "status", [], "calendars", "hashid" )) ->addColumn(...Hooks::filter( "rest.generator::column.type->amount", [ "label" => FALSE, "title" => Calendars\Entries\API\v1\Controller::getPlural(), "icon" => Calendars\Entries\API\v1\Controller::getIcon(), ], "entries.status.0", TRUE, FALSE, TRUE, "calendars" )) ->addColumn(...Hooks::filter( "rest.generator::column.type->amount", [ "label" => FALSE, "title" => Calendars\Tasks\API\v1\Controller::getPlural(), "icon" => "bi-clipboard-check", ], "tasks.status.0", TRUE, FALSE, TRUE, "calendars" )) ->addColumn(...Hooks::filter( "rest.generator::column.type->text", [], "title", TRUE, TRUE, TRUE, "calendars" )) ->addColumn(...Hooks::filter( "rest.generator::column.type->text", [], "target.name", TRUE, TRUE, TRUE, "calendars" )) ->addColumn(...Hooks::filter( "rest.generator::column.type->text", [], "description", TRUE, TRUE, TRUE, "calendars" )) ->addColumn(...Hooks::filter( "rest.generator::column.type->datetime", [], "date_create", TRUE, FALSE, TRUE, "calendars" )) ; return $rest; } public static function restConfigInputs() : array { $rest = REST\Generator\Data\Form::create() ->addField(...Hooks::filter( "rest.generator::control.type->text", [], "target_hid", TRUE, "calendars" )) ->addField(...Hooks::filter( "rest.generator::control.type->text", [], "title", TRUE, "calendars" )) ->addField(...Hooks::filter( "rest.generator::control.type->textarea", [], "description", FALSE, "calendars" )) ; return $rest->top()->getChildren(); } } /** Datei: plugins/calendars/library/ARUNOX/Plugins/Calendars/Entity.php **/ * @copyright 2025 ARUNOX * @version 1.0.0 * * @since 1.0.0 File is created */ namespace ARUNOX\Plugins\Calendars; use ARUNOX\API\PHP; use ARUNOX\Database\BaseEntity; #[PHP\Attributes\Database\Attributes( "status" )] #[PHP\Attributes\Database\Attributes( "date_edit" )] #[PHP\Attributes\Database\Attributes( "date_create" )] #[PHP\Attributes\Database\Definitions\Model( Model::class )] class Entity extends BaseEntity { /* ### VARIABLES ################################################ # */ /* ### PUBLIC FUNCTIONS ######################################### # */ public function getEntries() : array { $list = Entries\Model::getByOrigin( $this->id ); $status = Entries\Status::getAll(); $count = array_map( fn( $item ) => count( array_filter( $list, fn( $entry ) => $entry->status->getValue() == $item["value"] ) ), $status ); $status = array_map( fn( $count, $status ) => "{$count}x {$status["emoji"]}", $count, $status ); $return = [ "count" => count( $list ), "output" => implode( " | ", $status ), "status" => $count, "list" => $list, ]; return $return; } public function getTasks() : array { $list = Tasks\Model::getByOrigin( $this->id ); $status = Tasks\Status::getAll(); $count = array_map( fn( $item ) => count( array_filter( $list, fn( $entry ) => $entry->status->getValue() == $item["value"] ) ), $status ); $status = array_map( fn( $count, $status ) => "{$count}x {$status["emoji"]}", $count, $status ); $return = [ "count" => count( $list ), "output" => implode( " | ", $status ), "status" => $count, "list" => $list, ]; return $return; } } /** Datei: plugins/calendars/library/ARUNOX/Plugins/Calendars/Categories/Model.php **/ * @copyright 2025 ARUNOX * @version 1.0.0 * * @since 1.0.0 File is created */ namespace ARUNOX\Plugins\Calendars\Categories; use ARUNOX\API\PHP; use ARUNOX\Plugins\REST; use ARUNOX\Database\BaseModel; #[PHP\Attributes\Database\Definitions\Table( "calendars_categories" )] #[PHP\Attributes\Database\Definitions\HashID( "ccat" )] #[PHP\Attributes\Database\Definitions\Entity( Entity::class )] #[PHP\Attributes\Logs\Rules\Create()] #[PHP\Attributes\Logs\Rules\Update( "icon_name", "Icon wurde auf '%4\$t' gesetzt", REST\Generator\Config\Icon::class )] #[PHP\Attributes\Logs\Rules\Update( "icon_color", "Farbe wurde auf '%4\$t' gesetzt", REST\Generator\Config\Color::class )] class Model extends BaseModel { /* ### VARIABLES ################################################ # */ /* ### PUBLIC STATIC FUNCTIONS ################################## # */ } /** Datei: plugins/calendars/library/ARUNOX/Plugins/Calendars/Categories/API/v1/Routes.php **/ * @copyright 2025 ARUNOX * @version 1.1.0 * * @since 1.0.0 File is created */ namespace ARUNOX\Plugins\Calendars\Categories\API\v1; use ARUNOX\Core\Hooks; use ARUNOX\Core\Router; use ARUNOX\Plugins\REST; class Routes { public static function register() : void { /* ### MAIN ROUTES ############################## # */ Router::addAll( Controller::class ); } } /** Datei: plugins/calendars/library/ARUNOX/Plugins/Calendars/Categories/API/v1/Controller.php **/ * @copyright 2025 ARUNOX * @version 1.1.0 * * @since 1.0.0 File is created */ namespace ARUNOX\Plugins\Calendars\Categories\API\v1; use ARUNOX\HTTP; use ARUNOX\API\PHP; use ARUNOX\Core\Hooks; use ARUNOX\Plugins\Logs; use ARUNOX\Plugins\REST; use ARUNOX\Plugins\Calendars; use ARUNOX\API\BaseController; use ARUNOX\Database\BaseEntity; #[PHP\Attributes\Controller\Label( "Kategorie", "Kategorien" )] #[PHP\Attributes\Controller\Icon( REST\Generator\Config\Icon::Tags )] #[PHP\Attributes\Controller\Route( "categories", Calendars\API\v1\Controller::class )] #[PHP\Attributes\Database\Definitions\Model( Calendars\Categories\Model::class )] class Controller extends BaseController { /* ### PUBLIC GET FUNCTIONS ##################################### # */ /** * @api * @method GET * * @route.path /calendars/categories * @route.description Listet alle Logeinträge */ public static function getAllPrepared() : array { return parent::getAllPrepared(); } /** * @api * @method GET * * @route.path /calendars/categories/{hashid} * @route.description Gibt einen einzelnen Logeintrag anhand der ID zurück */ public static function getPrepared( string $hashid ) : BaseEntity | HTTP\Response { return parent::getPrepared( $hashid ); } /* ### PUBLIC SAVE FUNCTIONS #################################### # */ /** * @api * @method PUT * * @route.path /calendars/categories/{hashid} * @route.description Speichert Änderungen an einem bestehenden Termin */ public static function savePrepared( string $hashid, array $data ) : HTTP\Response { return parent::savePrepared( $hashid, $data ); } /** * @api * @method POST * * @route.path /calendars/categories * @route.description Erstellt einen neuen Kalender */ public static function createPrepared( array $data ) : HTTP\Response { return parent::createPrepared( $data ); } /** * @api * @method DELETE * * @route.path /calendars/categories/{hashid} * @route.description Löscht ein Logeintrag anhand der ID */ public static function deletePrepared( string $hashid ) : HTTP\Response { return parent::deletePrepared( $hashid ); } /** * @api * @method PATCH * * @route.path /calendars/categories/{hashid}/status * @route.description Wechselt den Status (aktiv/inaktiv) eines Kalenders */ public static function toggleStatusPrepared( string $hashid ) : HTTP\Response { return parent::toggleStatusPrepared( $hashid ); } /* ### PUBLIC VALIDATE FUNCTIONS ################################ # */ /* ### PUBLIC REST RESPONSE FUNCTIONS ########################### # */ /** * @internal rest * @method PUT * * @route.path /calendars/categories/{hashid} * @route.description REST-Antwort nach dem Speichern eines Termins */ public static function restResponseSave( string $hashid, array $data ) : HTTP\Response { $result = static::savePrepared( $hashid, $data ); if( $result->isStatus( 200 ) ) { $data = Calendars\Categories\Model::get( $hashid ); REST\Response::closeModals(); REST\Response::addUpdater( [ "data/table/row", $hashid ], $data ); } return static::restResponse( $result ); } /** * @internal rest * @method POST * * @route.path /calendars/categories * @route.description REST-Antwort nach dem Erstellen eines Kalenders */ public static function restResponseCreate( array $data ) : HTTP\Response { $result = static::createPrepared( $data ); if( $result->isStatus( 200 ) ) { REST\Response::closeModals(); REST\Response::redirect( "/calendars#categories" ); } return static::restResponse( $result ); } /** * @internal rest * @method DELETE * * @route.path /calendars/categories/{hashid} * @route.description REST-Antwort nach dem Löschen eines Logeintrag */ public static function restResponseDelete( string $hashid ) : HTTP\Response { REST\Response::closeModals(); $result = static::deletePrepared( $hashid ); if( $result->isStatus( 200 ) ) { REST\Response::redirect( "/calendars#categories" ); } return static::restResponse( $result ); } /** * @internal rest * @method PATCH * * @route.path /calendars/categories/{hashid}/status * @route.description REST-Antwort zur Status-Umschaltung eines Kalenders */ public static function restResponseToggleStatusPrepared( string $hashid ) : HTTP\Response { return parent::restResponseToggleStatusPrepared( $hashid ); } /* ### PUBLIC REST CONFIG FUNCTIONS ############################# # */ /** * @internal rest * @method GET * * @route.path /calendars/categories/{hashid} * @route.description REST-Konfiguration für Detailansicht eines Logeintrags */ public static function restConfigDetails( string $hashid ) : REST\Generator\Base\BaseGenerator { return REST\Response::addModal( "details", static::getSingular( "%t bearbeiten" ) ) ->setSize( "equal" ) ->setWidth("lg") ->get() ->setApi( "/calendars/categories/{$hashid}" ) ->setAction( "/calendars/categories/{$hashid}", "PUT" ) ->addTab( static::getSingular() )->get() ->addChildren( Calendars\Categories\API\v1\Controller::restConfigInputs() ) ->parent() ->addCallable( [ Logs\API\v1\Controller::class, "restConfigTab" ], $hashid ) ->addTab( "Speichern" )->get() ->setColor( REST\Generator\Config\Color::Primary ) ->setIcon( "bi bi-save" ) ->setType( "submit" ) ; } /** * @internal rest * @method GET * * @route.path /calendars/categories/create * @route.description REST-Konfiguration für das Erstellen eines Kalenders (Formular) */ public static function restConfigCreatePrepared() : REST\Generator\Base\BaseGenerator { return parent::restConfigCreatePrepared(); } /** * @internal rest * @method GET * * @route.path /calendars/categories/{hashid}/delete * @route.description REST-Konfiguration für die Lösch-Bestätigung eines Logeintrags */ public static function restConfigDeletePrepared( string $hashid ) : REST\Generator\Base\BaseGenerator { return REST\Response::addModal( "details", static::getSingular( "%t löschen" ) ) ->setSize( REST\Wrapper\Modal\Size::sm ) ->get() ->setAction( "/calendars/categories/{$hashid}", "DELETE" ) ->addText( "Möchtest du wirklich den Datensatz (#{$hashid}) löschen? " ) ->addButton(...Hooks::filter( "rest.generator::button.type->cancel", [], NULL, "calendars/categories" )) ->addButton(...Hooks::filter( "rest.generator::button.type->delete", [], NULL, "calendars/categories" )); } /* ### PUBLIC REST EXTENSION FUNCTIONS ########################## # */ public static function restConfigTable( null|string $hashid = NULL ) : REST\Generator\Base\BaseGenerator { $rest = REST\Generator\Data\Table::create() ->setApi( "/calendars/categories?origin={$hashid}" ) ->setAction( "/calendars/categories/{hashid}" ) ->setOrder( "title", "asc" ) ->setSearch( TRUE ) ->addButton(...Hooks::filter( "rest.generator::button.name->create", [], "calendars/categories" )) ->addColumn(...Hooks::filter( "rest.generator::column.type->status", [], "status", [], "calendars/categories", "hashid" )) ->addColumn(...Hooks::filter( "rest.generator::column.type->icon", [ "label" => "Icon", "icon" => "bi-tag", "options" => REST\Generator\Config\Icon::getAsOptions(), ], "icon", [], "calendars/categories", "hashid" )) ->addColumn(...Hooks::filter( "rest.generator::column.type->text", [], "title", TRUE, TRUE, TRUE, "calendars/categories" )) ->addColumn(...Hooks::filter( "rest.generator::column.type->text", [], "description", TRUE, TRUE, TRUE, "calendars/categories" )) ->addColumn(...Hooks::filter( "rest.generator::column.type->datetime", [], "date_edit", TRUE, FALSE, TRUE, "calendars/categories" )) ->addColumn(...Hooks::filter( "rest.generator::column.type->actions", [], [], FALSE, "calendars/categories" ))->get() ->addButton(...Hooks::filter( "rest.generator::action.name->edit", [], "calendars/categories", "hashid" )) ->addButton(...Hooks::filter( "rest.generator::action.name->delete", [], "calendars/categories", "hashid" )); ; return $rest; } public static function restConfigInputs() : array { $rest = REST\Generator\Data\Form::create() ->addGroup() ->addField(...Hooks::filter( "rest.generator::control.type->text", [], "title", TRUE, "calendars/categories" )) ->addField(...Hooks::filter( "rest.generator::control.type->select", [ "options" => REST\Generator\Config\Icon::getAsOptions(), ], "icon_name", TRUE, TRUE, "calendars/categories" )) ->addField(...Hooks::filter( "rest.generator::control.type->select", [ "options" => REST\Generator\Config\Color::getAsOptions(), ], "icon_color", TRUE, TRUE, "calendars/categories" )) ->parent() ->addGroup() ->addField(...Hooks::filter( "rest.generator::control.type->textarea", [ "lines" => 3, ], "description", FALSE, "calendars/categories" )) ; return $rest->top()->getChildren(); } } /** Datei: plugins/calendars/library/ARUNOX/Plugins/Calendars/Categories/Entity.php **/ * @copyright 2025 ARUNOX * @version 1.0.0 * * @since 1.0.0 File is created */ namespace ARUNOX\Plugins\Calendars\Categories; use ARUNOX\API\PHP; use ARUNOX\Database\BaseEntity; #[PHP\Attributes\Database\Attributes( "status" )] #[PHP\Attributes\Database\Attributes( "date_edit" )] #[PHP\Attributes\Database\Attributes( "date_create" )] #[PHP\Attributes\Database\Definitions\Model( Model::class )] class Entity extends BaseEntity { /* ### VARIABLES ################################################ # */ /* ### PUBLIC FUNCTIONS ######################################### # */ public function getIcon() : array { return [ "icon" => $this->icon_name, "color" => $this->icon_color, ]; } } /** Datei: plugins/calendars/library/ARUNOX/Plugins/Calendars/Tasks/Model.php **/ * @copyright 2025 ARUNOX * @version 1.0.0 * * @since 1.0.0 File is created */ namespace ARUNOX\Plugins\Calendars\Tasks; use ARUNOX\API\PHP; use ARUNOX\Plugins\Calendars; use ARUNOX\Database\BaseModel; #[PHP\Attributes\Database\Definitions\Table( "calendars_tasks" )] #[PHP\Attributes\Database\Definitions\HashID( "ctsk" )] #[PHP\Attributes\Database\Definitions\Entity( Entity::class )] #[PHP\Attributes\Database\Definitions\Origin( Calendars\Model::class )] class Model extends BaseModel { /* ### VARIABLES ################################################ # */ /* ### PUBLIC STATIC FUNCTIONS ################################## # */ public static function getByOrigin( int|string|array $origin, null|string $column = NULL ) { $origin = Calendars\Model::getValue( $origin ); if( $column ) return Model::getAllValue([ "origin_id" => $origin ], $column ); return Model::getAll([ "origin_id" => $origin ] ); } public static function save( array $data ) : mixed { if( isset( $data["origin_id"] ) ) { if( !is_numeric( $data["origin_id"] ) ) { if( !$origin_id = Calendars\Model::resolveHashID( $data["origin_id"] ) ) { $origin = static::resolveHashIDPrefix( $data["origin_id"] ); $origin_id = Calendars\Model::save([ "titlt" => $origin->name, "target_hid" => $data["origin_id"], ]); } $data["origin_id"] = $origin_id; } } return parent::save( $data ); } /* ### PUBLIC STATIC LOG FUNCTIONS ############################## # */ public static function getLogRulesUpdated( int $id ) { $current = static::get( $id ); $calendar = $current->origin; $hashids = [ $calendar->hashid, $calendar->target_hid, ]; return [ "status" => [ "options" => Status::getAll(), "message" => "Status wurde auf '%4\$t' gesetzt", "target_hids" => $hashids, ], "date_due" => [ "message" => "Fälligkeit wurde auf '%4\$FORMAT_DATETIME\$D' gesetzt", "target_hids" => $hashids, ], ]; } public static function getLogRulesCreated( int $id ) { $current = static::get( $id ); $calendar = $current->origin; return [ "__self" => [ "target_hids" => [ $calendar->hashid, $calendar->target_hid, ], ], ]; } } /** Datei: plugins/calendars/library/ARUNOX/Plugins/Calendars/Tasks/Templates/Model.php **/ * @copyright 2025 ARUNOX * @version 1.0.0 * * @since 1.0.0 File is created */ namespace ARUNOX\Plugins\Calendars\Tasks\Templates; use ARUNOX\API\PHP; use ARUNOX\Plugins\Calendars; use ARUNOX\Database\BaseModel; #[PHP\Attributes\Database\Definitions\Table( "calendars_tasks_templates" )] #[PHP\Attributes\Database\Definitions\HashID( "cttpl" )] #[PHP\Attributes\Database\Definitions\Entity( Entity::class )] #[PHP\Attributes\Database\Definitions\Origin( Calendars\Tasks\Model::class )] class Model extends BaseModel { /* ### VARIABLES ################################################ # */ /* ### PUBLIC STATIC FUNCTIONS ################################## # */ } /** Datei: plugins/calendars/library/ARUNOX/Plugins/Calendars/Tasks/Templates/API/v1/Routes.php **/ * @copyright 2025 ARUNOX * @version 1.1.0 * * @since 1.0.0 File is created */ namespace ARUNOX\Plugins\Calendars\Tasks\Templates\API\v1; use ARUNOX\Core\Hooks; use ARUNOX\Core\Router; use ARUNOX\Plugins\REST; class Routes { public static function register() : void { /* ### MAIN ROUTES ############################## # */ Router::addAll( Controller::class ); /* ### MENU ROUTES ############################## # */ // Hooks::add('router::get->api.v1.rest.routes', function( $routes ) { // $routes[] = [ // "path" => "/calendars/tasks/templates", // "label" => "Logbuch", // "icon" => "bi bi-journal-text", // "menu" => "administration", // ]; // // return $routes; // }, 99 ); } } /** Datei: plugins/calendars/library/ARUNOX/Plugins/Calendars/Tasks/Templates/API/v1/Controller.php **/ * @copyright 2025 ARUNOX * @version 1.1.0 * * @since 1.0.0 File is created */ namespace ARUNOX\Plugins\Calendars\Tasks\Templates\API\v1; use ARUNOX\HTTP; use ARUNOX\API\PHP; use ARUNOX\Core\Hooks; use ARUNOX\Plugins\REST; use ARUNOX\Plugins\Calendars; use ARUNOX\API\BaseController; use ARUNOX\Database\BaseEntity; #[PHP\Attributes\Controller\Label( "Vorlage", "Vorlagen" )] #[PHP\Attributes\Controller\Icon( REST\Generator\Config\Icon::FileEarmarkText )] #[PHP\Attributes\Controller\Route( "templates", Calendars\Tasks\API\v1\Controller::class )] #[PHP\Attributes\Database\Definitions\Model( Calendars\Tasks\Templates\Model::class )] class Controller extends BaseController { /* ### PUBLIC GET FUNCTIONS ##################################### # */ /** * @api * @method GET * * @route.path /calendars/tasks/templates * @route.description Listet alle Vorlagen */ public static function getAllPrepared() : array { return parent::getAllPrepared(); } /** * @api * @method GET * * @route.path /calendars/tasks/templates/{hashid} * @route.description Gibt einen einzelnen Vorlage anhand der ID zurück */ public static function getPrepared( string $hashid ) : BaseEntity | HTTP\Response { return parent::getPrepared( $hashid ); } /* ### PUBLIC SAVE FUNCTIONS #################################### # */ /** * @api * @method PUT * * @route.path /calendars/tasks/templates/{hashid} * @route.description Erstellt eine neue Vorlage */ public static function savePrepared( string $hashid, array $data ) : HTTP\Response { return parent::savePrepared( $hashid, $data ); } /** * @api * @method POST * * @route.path /calendars/tasks/templates * @route.description Erstellt eine neue Vorlage */ public static function createPrepared( array $data ) : HTTP\Response { return parent::createPrepared( $data ); } /** * @api * @method DELETE * * @route.path /calendars/tasks/templates/{hashid} * @route.description Löscht ein Vorlage anhand der ID */ public static function deletePrepared( string $hashid ) : HTTP\Response { return parent::deletePrepared( $hashid ); } /** * @api * @method PATCH * * @route.path /calendars/tasks/templates/{hashid}/status * @route.description Wechselt den Status (aktiv/inaktiv) eines Kalenders */ public static function toggleStatusPrepared( string $hashid ) : HTTP\Response { return parent::toggleStatusPrepared( $hashid ); } /* ### PUBLIC VALIDATE FUNCTIONS ################################ # */ /* ### PUBLIC REST RESPONSE FUNCTIONS ########################### # */ /** * @internal rest * @method POST * * @route.path /calendars/tasks/templates * @route.description REST-Antwort nach dem Erstellen einer Vorlage */ public static function restResponseCreate( array $data ) : HTTP\Response { $result = static::createPrepared( $data ); if( $result->isStatus( 200 ) ) { REST\Response::closeModals(); REST\Response::redirect( "/calendars#templates" ); } return static::restResponse( $result ); } /** * @internal rest * @method DELETE * * @route.path /calendars/tasks/templates/{hashid} * @route.description REST-Antwort nach dem Löschen eines Vorlage */ public static function restResponseDelete( string $hashid ) : HTTP\Response { REST\Response::closeModals(); $result = static::deletePrepared( $hashid ); if( $result->isStatus( 200 ) ) { REST\Response::redirect( "/calendars/tasks/templates" ); } return static::restResponse( $result ); } /** * @internal rest * @method PATCH * * @route.path /calendars/tasks/templates/{hashid}/status * @route.description REST-Antwort zur Status-Umschaltung eines Kalenders */ public static function restResponseToggleStatusPrepared( string $hashid ) : HTTP\Response { return parent::restResponseToggleStatusPrepared( $hashid ); } /* ### PUBLIC REST CONFIG FUNCTIONS ############################# # */ /** * @internal rest * @method GET * * @route.path /calendars/tasks/templates/{hashid} * @route.description REST-Konfiguration für Detailansicht eines Vorlages */ public static function restConfigDetails( string $hashid ) : REST\Generator\Base\BaseGenerator { return REST\Response::addWrapper( "details", static::getSingular( "%t bearbeiten" ) ) ->setBacklink( "/calendars/tasks/templates" ) ->get() ->setApi( "/calendars/tasks/templates/{$hashid}" ) ->setAction( "/calendars/tasks/templates/{$hashid}", "PUT" ) ->addTab( "Produkt" )->get() ->addHeadline( "Produkt", 2 ) ->addField(...Hooks::filter( "rest.generator::control.type->text", [], "company_name", FALSE, "calendars/tasks/templates" )) ->addField(...Hooks::filter( "rest.generator::control.type->text", [], "firstname", FALSE, "calendars/tasks/templates" )) ->addField(...Hooks::filter( "rest.generator::control.type->text", [], "lastname", FALSE, "calendars/tasks/templates" )) ->parent() ->addTab( "Ansprechpartner" )->get() ->addContent( // Contacts\Contacts\API\v1\Controller::restConfigTable( $hashid ) ) ->parent() ->addTab( "Adressen" )->get() ->addContent( // Contacts\Addresses\API\v1\Controller::restConfigTable( $hashid ) ) ->parent() ->addTab( "Speichern" )->get() ->setColor( REST\Generator\Config\Color::Primary ) ->setIcon( "bi bi-save" ) ->setType( "submit" ); } /** * @internal rest * @method GET * * @route.path /calendars/tasks/templates/create * @route.description REST-Konfiguration für das Erstellen einer Vorlage (Formular) */ public static function restConfigCreatePrepared() : REST\Generator\Base\BaseGenerator { return parent::restConfigCreatePrepared(); } /** * @internal rest * @method GET * * @route.path /calendars/tasks/templates/{hashid}/delete * @route.description REST-Konfiguration für die Lösch-Bestätigung eines Vorlages */ public static function restConfigDeletePrepared( string $hashid ) : REST\Generator\Base\BaseGenerator { $type = Calendars\Tasks\Templates\Model::getValue( $hashid, "type" ); return REST\Response::addModal( "details", "{$type->getLabel()} Löschen" ) ->setSize( REST\Wrapper\Modal\Size::sm ) ->get() ->setAction( "/calendars/tasks/templates/{$hashid}", "DELETE" ) ->addText( "Möchtest du wirklich den Datensatz (#{$hashid}) löschen? " ) ->addButton(...Hooks::filter( "rest.generator::button.type->cancel", [], NULL, "calendars/tasks/templates" )) ->addButton(...Hooks::filter( "rest.generator::button.type->delete", [], NULL, "calendars/tasks/templates" )); } /* ### PUBLIC REST EXTENSION FUNCTIONS ########################## # */ public static function restConfigTab( REST\Generator\Base\BaseGenerator $rest, null|string $hashid = NULL ) : void { $rest->addTab( "Logbuch", "calendars/tasks/templates" )->get() ->setIcon( "bi-journal-text" ) ->addContent( Calendars\Tasks\Templates\API\v1\Controller::restConfigTable( $hashid ) ) ; } public static function restConfigTable( null|string $hashid = NULL ) : REST\Generator\Base\BaseGenerator { $rest = REST\Generator\Data\Table::create() ->setApi( "/calendars/tasks/templates" ) ->setAction( "/calendars/tasks/templates/{hashid}" ) ->setOrder( "title", "asc" ) ->setSearch( TRUE ) ->addColumn(...Hooks::filter( "rest.generator::column.type->status", [], "status", [], "calendars/tasks/templates", "hashid" )) ->addColumn(...Hooks::filter( "rest.generator::column.type->text", [], "title", TRUE, TRUE, TRUE, "calendars/tasks/templates" )) ->addColumn(...Hooks::filter( "rest.generator::column.type->text", [], "description", TRUE, TRUE, TRUE, "calendars/tasks/templates" )) ->addColumn(...Hooks::filter( "rest.generator::column.type->datetime", [], "date_create", TRUE, FALSE, TRUE, "calendars/tasks/templates" )) ; return $rest; } public static function restConfigInputs() : array { $rest = REST\Generator\Data\Form::create() ->addButton(...Hooks::filter( "rest.generator::button.type->submit", [], "Erstellen", "calendars/tasks/templates" )) ->addField(...Hooks::filter( "rest.generator::control.type->text", [], "title", TRUE, "calendars/tasks/templates" )) ->addField(...Hooks::filter( "rest.generator::control.type->textarea", [], "description", FALSE, "calendars/tasks/templates" )); ; return $rest->top()->getChildren(); } } /** Datei: plugins/calendars/library/ARUNOX/Plugins/Calendars/Tasks/Templates/Entity.php **/ * @copyright 2025 ARUNOX * @version 1.0.0 * * @since 1.0.0 File is created */ namespace ARUNOX\Plugins\Calendars\Tasks\Templates; use ARUNOX\Plugins; use ARUNOX\API\PHP; use ARUNOX\Database\BaseEntity; #[PHP\Attributes\Database\Attributes( "status" )] #[PHP\Attributes\Database\Attributes( "date_edit" )] #[PHP\Attributes\Database\Attributes( "date_create" )] #[PHP\Attributes\Database\Definitions\Model( Model::class )] class Entity extends BaseEntity { /* ### VARIABLES ################################################ # */ /* ### PUBLIC FUNCTIONS ######################################### # */ public function getCreator() { if( $class = $this->getCreatorClass() ) { return $class::get( $this->created_by ); } } public function getCreatorClass() { if( !$this->created_by ) return NULL; $prefix = explode( "_", $this->created_by ); $prefix = current( $prefix ); if( $prefix == Plugins\Users\Model::getHashIDPrefix() ) { return Plugins\Users\Model::class; } return FALSE; } public function getCreatorName() { if( $class = $this->getCreatorClass() ) { return $class::getValue( $this->created_by, "username" ); } } } /** Datei: plugins/calendars/library/ARUNOX/Plugins/Calendars/Tasks/API/v1/Routes.php **/ * @copyright 2025 ARUNOX * @version 1.1.0 * * @since 1.0.0 File is created */ namespace ARUNOX\Plugins\Calendars\Tasks\API\v1; use ARUNOX\Core\Hooks; use ARUNOX\Core\Router; use ARUNOX\Plugins\REST; class Routes { public static function register() : void { /* ### MAIN ROUTES ############################## # */ Router::addAll( Controller::class ); /* ### MENU ROUTES ############################## # */ // Hooks::add('router::get->api.v1.rest.routes', function( $routes ) { // $routes[] = [ // "path" => "/calendars/tasks", // "label" => "Logbuch", // "icon" => "bi bi-journal-text", // "menu" => "administration", // ]; // // return $routes; // }, 99 ); } } /** Datei: plugins/calendars/library/ARUNOX/Plugins/Calendars/Tasks/API/v1/Controller.php **/ * @copyright 2025 ARUNOX * @version 1.1.0 * * @since 1.0.0 File is created */ namespace ARUNOX\Plugins\Calendars\Tasks\API\v1; use ARUNOX\HTTP; use ARUNOX\API\PHP; use ARUNOX\Core\Hooks; use ARUNOX\Plugins\REST; use ARUNOX\Plugins\Users; use ARUNOX\Plugins\Calendars; use ARUNOX\API\BaseController; use ARUNOX\Database\BaseEntity; #[PHP\Attributes\Controller\Label( "Aufgabe", "Aufgaben" )] #[PHP\Attributes\Controller\Icon( REST\Generator\Config\Icon::ClipboardCheck )] #[PHP\Attributes\Controller\Route( "tasks", Calendars\API\v1\Controller::class )] #[PHP\Attributes\Database\Definitions\Model( Calendars\Tasks\Model::class )] class Controller extends BaseController { /* ### PUBLIC GET FUNCTIONS ##################################### # */ /** * @api * @method GET * * @route.path /calendars/tasks * @route.description Listet alle Aufgaben */ public static function getAllPrepared() : array { return parent::getAllPrepared(); } /** * @api * @method GET * * @route.path /calendars/{origin}/tasks * @route.description Listet alle Logeinträge */ public static function getByOriginPrepared( string $origin ) : array { return parent::getByOriginPrepared( $origin ); } /** * @api * @method GET * * @route.path /calendars/tasks/{hashid} * @route.description Gibt einen einzelnen Aufgabe anhand der ID zurück */ public static function getPrepared( string $hashid ) : BaseEntity | HTTP\Response { return parent::getPrepared( $hashid ); } /* ### PUBLIC SAVE FUNCTIONS #################################### # */ /** * @api * @method PUT * * @route.path /calendars/tasks/{hashid} * @route.description Speichert Änderungen an einem bestehenden Termin */ public static function savePrepared( string $hashid, array $data ) : HTTP\Response { return parent::savePrepared( $hashid, $data ); } /** * @api * @method POST * * @route.path /calendars/tasks * @route.description Erstellt einen neuen Termin */ public static function createPrepared( array $data ) : HTTP\Response { return parent::createPrepared( $data ); } /** * @api * @method DELETE * * @route.path /calendars/tasks/{hashid} * @route.description Löscht ein Aufgabe anhand der ID */ public static function deletePrepared( string $hashid ) : HTTP\Response { return parent::deletePrepared( $hashid ); } /** * @api * @method PATCH * * @route.path /calendars/tasks/{hashid}/status * @route.description Wechselt den Status (aktiv/inaktiv) eines Kalenders */ public static function toggleStatusPrepared( string $hashid ) : HTTP\Response { return parent::toggleStatusPrepared( $hashid ); } /* ### PUBLIC VALIDATE FUNCTIONS ################################ # */ /* ### PUBLIC REST RESPONSE FUNCTIONS ########################### # */ /** * @internal rest * @method PUT * * @route.path /calendars/tasks/{hashid} * @route.description REST-Antwort nach dem Speichern eines Termins */ public static function restResponseSave( string $hashid, array $data ) : HTTP\Response { $result = static::savePrepared( $hashid, $data ); if( $result->isStatus( 200 ) ) { $data = Calendars\Tasks\Model::get( $hashid ); REST\Response::closeModals(); REST\Response::addUpdater( [ "data/table/row", $hashid ], $data ); } return static::restResponse( $result ); } /** * @internal rest * @method POST * * @route.path /calendars/tasks * @route.description REST-Antwort nach dem Erstellen eines Termins (inkl. Notifikation, Redirect etc.) */ public static function restResponseCreate( array $data ) : HTTP\Response { $result = static::createPrepared( $data ); if( $result->isStatus( 200 ) ) { $data = $result->getBody("data"); REST\Response::closeModals(); REST\Response::refresh( "#tasks" ); REST\Response::addClick( [ "data/table/row", $data->hashid ] ); } return static::restResponse( $result ); } /** * @internal rest * @method DELETE * * @route.path /calendars/tasks/{hashid} * @route.description REST-Antwort nach dem Löschen eines Aufgabe */ public static function restResponseDelete( string $hashid ) : HTTP\Response { REST\Response::closeModals(); $result = static::deletePrepared( $hashid ); if( $result->isStatus( 200 ) ) { REST\Response::refresh( "#tasks" ); } return static::restResponse( $result ); } /** * @internal rest * @method PATCH * * @route.path /calendars/tasks/{hashid}/status * @route.description REST-Antwort zur Status-Umschaltung eines Kalenders */ public static function restResponseToggleStatusPrepared( string $hashid ) : HTTP\Response { return parent::restResponseToggleStatusPrepared( $hashid ); } /* ### PUBLIC REST CONFIG FUNCTIONS ############################# # */ /** * @internal rest * @method GET * * @route.path /calendars/tasks/{hashid} * @route.description REST-Konfiguration für Detailansicht eines Logeintrags */ public static function restConfigDetails( string $hashid ) : REST\Generator\Base\BaseGenerator { return REST\Response::addModal( "details", static::getSingular( "%t bearbeiten" ) ) ->setSize( "equal" ) ->setWidth("lg") ->get() ->setApi( "/calendars/tasks/{$hashid}" ) ->setAction( "/calendars/tasks/{$hashid}", "PUT" ) ->addTab( "Aufgabe" )->get() ->addChildren( Calendars\Tasks\API\v1\Controller::restConfigInputs() ) ->parent() ->addTab( "Zuweisungen", "assignments" )->get() ->addChildren( Calendars\Tasks\Assignments\API\v1\Controller::restConfigTable( $hashid ) ) ->parent() ->addTab( "Speichern" )->get() ->setColor( REST\Generator\Config\Color::Primary ) ->setIcon( "bi bi-save" ) ->setType( "submit" ) ; } /** * @internal rest * @method GET * * @route.path /calendars/tasks/create * @route.description REST-Konfiguration für das Erstellen eines Kalenders (Formular) */ public static function restConfigCreatePrepared() : REST\Generator\Base\BaseGenerator { return parent::restConfigCreatePrepared(); } /** * @internal rest * @method GET * * @route.path /calendars/{origin}/tasks/create * @route.description REST-Konfiguration für das Erstellen eines Kalenders (Formular) */ public static function restConfigCreateByOriginPrepared( bool | string $origin = FALSE ) : REST\Generator\Base\BaseGenerator { return parent::restConfigCreateByOriginPrepared( $origin ); } /** * @internal rest * @method GET * * @route.path /calendars/tasks/{hashid}/delete * @route.description REST-Konfiguration für die Lösch-Bestätigung eines Logeintrags */ public static function restConfigDeletePrepared( string $hashid ) : REST\Generator\Base\BaseGenerator { $type = Calendars\Tasks\Model::getValue( $hashid, "type" ); return REST\Response::addModal( "details", "{$type->getLabel()} Löschen" ) ->setSize( REST\Wrapper\Modal\Size::sm ) ->get() ->setAction( "/calendars/tasks/{$hashid}", "DELETE" ) ->addText( "Möchtest du wirklich den Datensatz (#{$hashid}) löschen? " ) ->addButton(...Hooks::filter( "rest.generator::button.type->cancel", [], NULL, "calendars/tasks" )) ->addButton(...Hooks::filter( "rest.generator::button.type->delete", [], NULL, "calendars/tasks" )); } /* ### PUBLIC REST EXTENSION FUNCTIONS ########################## # */ public static function restConfigTable( null|string $origin = NULL ) : REST\Generator\Base\BaseGenerator { $rest = REST\Generator\Data\Table::create() ->setApi( "/calendars/{$origin}/tasks" ) ->setAction( "/calendars/tasks/{hashid}" ) ->setOrder( "date_create", "desc" ) ->setSearch( TRUE ) ->addButton(...Hooks::filter( "rest.generator::button.name->create", [], "calendars/{$origin}/tasks" )) ->addColumn(...Hooks::filter( "rest.generator::column.type->status", [ "options" => Calendars\Tasks\Status::getAll(), ], "status", [], "calendars/tasks", "hashid" )) ; foreach( Calendars\Tasks\Assignments\Status::getAll() as $status ) { $rest->addColumn(...Hooks::filter( "rest.generator::column.type->amount", [ "action" => "/calendars/tasks/{hashid}#assignments", "label" => FALSE, "title" => $status["label"], "icon" => $status["icon"], ], "assignments.status.{$status["value"]}", TRUE, FALSE, TRUE, "calendars/tasks", "hashid" )); } $rest ->addColumn(...Hooks::filter( "rest.generator::column.type->datetime", [ "label" => "Fällig am", ], "date_due", TRUE, FALSE, TRUE, "calendars/tasks" )) ->addColumn(...Hooks::filter( "rest.generator::column.type->datetime", [ "label" => "Erledigt am", ], "date_done", TRUE, FALSE, TRUE, "calendars/tasks" )) ->addColumn(...Hooks::filter( "rest.generator::column.type->text", [ "label" => "Zugewiesen an", ], "target.username", TRUE, TRUE, TRUE, "calendars/tasks" )) ->addColumn(...Hooks::filter( "rest.generator::column.type->text", [], "title", TRUE, TRUE, TRUE, "calendars/tasks" )) ->addColumn(...Hooks::filter( "rest.generator::column.type->text", [], "description", TRUE, TRUE, TRUE, "calendars/tasks" )) ->addColumn(...Hooks::filter( "rest.generator::column.type->actions", [], [], FALSE, "calendars/tasks" ))->get() ->addButton(...Hooks::filter( "rest.generator::action.name->edit", [], "calendars/tasks", "hashid" )) ->addButton(...Hooks::filter( "rest.generator::action.name->delete", [], "calendars/tasks", "hashid" )) ; return $rest; } public static function restConfigInputs() : array { $rest = REST\Generator\Data\Form::create() ->addGroup() ->addField(...Hooks::filter( "rest.generator::control.type->text", [], "title", TRUE, "calendars/tasks" )) ->addField(...Hooks::filter( "rest.generator::control.type->select", [ "options" => Users\Model::getAsOptions( "username", "hashid" ), ], "target_hid", TRUE, FALSE, "calendars/tasks" )) ->addField(...Hooks::filter( "rest.generator::control.type->datetime", [], "date_due", TRUE, "calendars/tasks" )) ->parent() ->addGroup() ->addField(...Hooks::filter( "rest.generator::control.type->textarea", [ "lines" => 2, ], "description", FALSE, "calendars/tasks" )) ; return $rest->top()->getChildren(); } public static function restConfigOrigin( bool|string $origin ) : REST\Generator\Base\BaseGenerator { $rest = REST\Generator\Data\Form::create(); if( $origin === FALSE ) { return $rest->addField(...Hooks::filter( "rest.generator::control.type->select", [ "options" => Calendars\Model::getAsOptions( "title" ), ], "origin_id", TRUE, FALSE, "calendars/tasks" )); } $origin = Calendars\Model::getValue( $origin, "id" ); return $rest->addField(...Hooks::filter( "rest.generator::control.type->hidden", [], "origin_id", $origin, "calendars/tasks" )); } public static function restConfigTab( REST\Generator\Base\BaseGenerator $rest, null|string $origin = NULL ) : void { $calendar = Calendars\Model::getByColumn( "target_hid", $origin ); $rest->addTab( static::getPlural(), "tasks" )->get() ->setIcon( static::getIcon() ) ->addContent( static::restConfigTable( $calendar ? $calendar->hashid : $origin ) ) ; } } /** Datei: plugins/calendars/library/ARUNOX/Plugins/Calendars/Tasks/Assignments/Model.php **/ * @copyright 2025 ARUNOX * @version 1.0.0 * * @since 1.0.0 File is created */ namespace ARUNOX\Plugins\Calendars\Tasks\Assignments; use ARUNOX\API\PHP; use ARUNOX\Plugins\Calendars; use ARUNOX\Database\BaseModel; #[PHP\Attributes\Database\Definitions\Table( "calendars_tasks_assignments" )] #[PHP\Attributes\Database\Definitions\HashID( "ctasg" )] #[PHP\Attributes\Database\Definitions\Entity( Entity::class )] #[PHP\Attributes\Database\Definitions\Origin( Calendars\Tasks\Model::class )] class Model extends BaseModel { /* ### VARIABLES ################################################ # */ /* ### PUBLIC STATIC FUNCTIONS ################################## # */ public static function getByOrigin( int|string|array $origin, null|string $column = NULL ) { $origin = Calendars\Tasks\Model::getValue( $origin ); if( $column ) return Model::getAllValue([ "origin_id" => $origin ], $column ); return Model::getAll([ "origin_id" => $origin ] ); } /* ### PUBLIC STATIC LOG FUNCTIONS ############################## # */ public static function getLogRulesUpdated( int $id ) { $current = static::get( $id ); $task = $current->origin; $calendar = $task->origin; return [ "status" => [ "options" => Status::getAll(), "message" => "Status wurde auf '%4\$t' gesetzt", "target_hids" => [ $current->target_hid, $task->hashid, $calendar->hashid, $calendar->target_hid, ], ], ]; } public static function getLogRulesCreated( int $id ) { $current = static::get( $id ); $task = $current->origin; $calendar = $task->origin; return [ "__self" => [ "message" => "Aufgabe wurde zugewiesen", "target_hids" => [ $current->target_hid, $task->hashid, $calendar->hashid, $calendar->target_hid, ], ], ]; } } /** Datei: plugins/calendars/library/ARUNOX/Plugins/Calendars/Tasks/Assignments/API/v1/Routes.php **/ * @copyright 2025 ARUNOX * @version 1.1.0 * * @since 1.0.0 File is created */ namespace ARUNOX\Plugins\Calendars\Tasks\Assignments\API\v1; use ARUNOX\Core\Hooks; use ARUNOX\Core\Router; use ARUNOX\Plugins\REST; class Routes { public static function register() : void { /* ### MAIN ROUTES ############################## # */ Router::addAll( Controller::class ); } } /** Datei: plugins/calendars/library/ARUNOX/Plugins/Calendars/Tasks/Assignments/API/v1/Controller.php **/ * @copyright 2025 ARUNOX * @version 1.1.0 * * @since 1.0.0 File is created */ namespace ARUNOX\Plugins\Calendars\Tasks\Assignments\API\v1; use ARUNOX\HTTP; use ARUNOX\API\PHP; use ARUNOX\Core\Hooks; use ARUNOX\Plugins\REST; use ARUNOX\Plugins\Users; use ARUNOX\Plugins\Calendars; use ARUNOX\API\BaseController; use ARUNOX\Database\BaseEntity; #[PHP\Attributes\Controller\Label( "Zuweisung", "Zuweisungen" )] #[PHP\Attributes\Controller\Route( "assignments", Calendars\Tasks\API\v1\Controller::class )] #[PHP\Attributes\Database\Definitions\Model( Calendars\Tasks\Assignments\Model::class )] class Controller extends BaseController { /* ### PUBLIC GET FUNCTIONS ##################################### # */ /** * @api * @method GET * * @route.path /calendars/tasks/{origin}/assignments * @route.description Listet alle Logeinträge */ public static function getByOriginPrepared( string $origin ) : array { return parent::getByOriginPrepared( $origin ); } /** * @api * @method GET * * @route.path /calendars/tasks/assignments/{hashid} * @route.description Gibt einen einzelnen Logeintrag anhand der ID zurück */ public static function getPrepared( string $hashid ) : BaseEntity | HTTP\Response { return parent::getPrepared( $hashid ); } /* ### PUBLIC SAVE FUNCTIONS #################################### # */ /** * @api * @method POST * * @route.path /calendars/tasks/{origin}/assignments * @route.description Erstellt einen neuen Teilnehmer */ public static function createByOriginPrepared( string $origin, array $data ) : HTTP\Response { return parent::createByOriginPrepared( $origin, $data ); } /** * @api * @method DELETE * * @route.path /calendars/tasks/assignments/{hashid} * @route.description Löscht ein Logeintrag anhand der ID */ public static function deletePrepared( string $hashid ) : HTTP\Response { return parent::deletePrepared( $hashid ); } /** * @api * @method PATCH * * @route.path /calendars/tasks/assignments/{hashid}/status * @route.description Wechselt den Status (aktiv/inaktiv) eines Kalenders */ public static function toggleStatusPrepared( string $hashid ) : HTTP\Response { return parent::toggleStatusPrepared( $hashid ); } /* ### PUBLIC VALIDATE FUNCTIONS ################################ # */ /* ### PUBLIC REST RESPONSE FUNCTIONS ########################### # */ /** * @internal rest * @method GET * * @route.path /calendars/tasks/assignments/{hashid} * @route.description REST-Konfiguration für Detailansicht eines Logeintrags */ public static function restResponseLog( string $hashid ) : HTTP\Response { $entry = Calendars\Tasks\Assignments\Model::get( $hashid )->origin; $route = Calendars\Tasks\API\v1\Controller::getRoute( $entry->hashid, "#assignments" ); REST\Response::redirect( $route ); return REST\Response::jsonResponse(); } /** * @internal rest * @method POST * * @route.path /calendars/tasks/{origin}/assignments * @route.description REST-Antwort nach dem Erstellen eines Kalenders */ public static function restResponseCreate( string $origin, array $data ) : HTTP\Response { $result = static::createByOriginPrepared( $origin, $data ); if( $result->isStatus( 200 ) ) { REST\Response::closeModals(); REST\Response::redirect( "/calendars/tasks/{$origin}#assignments" ); } return static::restResponse( $result ); } /** * @internal rest * @method DELETE * * @route.path /calendars/tasks/assignments/{hashid} * @route.description REST-Antwort nach dem Löschen eines Logeintrag */ public static function restResponseDelete( string $hashid ) : HTTP\Response { REST\Response::closeModals(); $current = Calendars\Tasks\Assignments\Model::get( $hashid ); $origin = Calendars\Tasks\Model::get( $current->origin_id ); $result = static::deletePrepared( $hashid ); if( $result->isStatus( 200 ) ) { REST\Response::addClick( [ "data/table/row", $origin->hashid ], "assignments" ); } return static::restResponse( $result ); } /** * @internal rest * @method PATCH * * @route.path /calendars/tasks/assignments/{hashid}/status * @route.description REST-Antwort zur Status-Umschaltung eines Kalenders */ public static function restResponseToggleStatusPrepared( string $hashid ) : HTTP\Response { return parent::restResponseToggleStatusPrepared( $hashid ); } /* ### PUBLIC REST CONFIG FUNCTIONS ############################# # */ /** * @internal rest * @method GET * * @route.path /calendars/tasks/{origin}/assignments/create * @route.description REST-Konfiguration für das Erstellen eines Teilnehmers (Formular) */ public static function restConfigCreate( string $origin ) : REST\Generator\Base\BaseGenerator { $exclude = Calendars\Tasks\Assignments\Model::getByOrigin( $origin , "target_hid" ); return REST\Response::addModal( "details", static::getSingular( "%t hinzufügen" ) ) ->get() ->setAction( "/calendars/tasks/{$origin}/assignments", "POST" ) ->addButton(...Hooks::filter( "rest.generator::button.type->submit", [], "Hinzufügen", "calendars/tasks/assignments" )) ->addField(...Hooks::filter( "rest.generator::control.type->select", [ "options" => Users\Model::getAsOptions( "username", "hashid", $exclude ), ], "target_hid", TRUE, TRUE, "calendars/tasks/assignments" )) ; } /** * @internal rest * @method GET * * @route.path /calendars/tasks/assignments/{hashid}/delete * @route.description REST-Konfiguration für die Lösch-Bestätigung eines Logeintrags */ public static function restConfigDeletePrepared( string $hashid ) : REST\Generator\Base\BaseGenerator { return REST\Response::addModal( "details", static::getSingular( "%t löschen" ) ) ->setSize( REST\Wrapper\Modal\Size::sm ) ->get() ->setAction( "/calendars/tasks/assignments/{$hashid}", "DELETE" ) ->addText( "Möchtest du wirklich den Datensatz (#{$hashid}) löschen? " ) ->addButton(...Hooks::filter( "rest.generator::button.type->cancel", [], NULL, "calendars/tasks/assignments" )) ->addButton(...Hooks::filter( "rest.generator::button.type->delete", [], NULL, "calendars/tasks/assignments" )); } /* ### PUBLIC REST EXTENSION FUNCTIONS ########################## # */ public static function restConfigTable( string $origin ) : REST\Generator\Base\BaseGenerator { $exclude = Calendars\Tasks\Assignments\Model::getByOrigin( $origin , "target_hid" ); $options = Users\Model::getAsOptions( "username", "hashid", $exclude ); $rest = REST\Generator\Data\Table::create() ->setApi( "/calendars/tasks/{$origin}/assignments" ) ->setOrder( "date_create", "desc" ) ->setSearch( TRUE ) ; if( !empty( $options ) ) { $rest->addButton(...Hooks::filter( "rest.generator::button.name->create", [], "calendars/tasks/{$origin}/assignments" )); } $rest->addColumn(...Hooks::filter( "rest.generator::column.type->status", [ "options" => Calendars\Tasks\Assignments\Status::getAll(), ], "status", [], "calendars/tasks/assignments", "hashid" )) ->addColumn(...Hooks::filter( "rest.generator::column.type->text", [ "label" => "Name", ], "target.username", TRUE, TRUE, TRUE, "calendars/tasks/assignments" )) ->addColumn(...Hooks::filter( "rest.generator::column.type->datetime", [ "label" => "Zugewiesen am", ], "date_create", TRUE, FALSE, TRUE, "calendars/tasks/assignments" )) ->addColumn(...Hooks::filter( "rest.generator::column.type->datetime", [ "label" => "Erledigt am", ], "date_done", TRUE, FALSE, TRUE, "calendars/tasks/assignments" )) ->addColumn(...Hooks::filter( "rest.generator::column.type->text", [ "label" => "Aufgabe", ], "task", TRUE, FALSE, TRUE, "calendars/tasks/assignments" )) ->addColumn(...Hooks::filter( "rest.generator::column.type->actions", [], [], FALSE, "calendars/tasks/assignments" ))->get() ->addButton(...Hooks::filter( "rest.generator::action.name->delete", [], "calendars/tasks/assignments", "hashid" )) ; return $rest; } } /** Datei: plugins/calendars/library/ARUNOX/Plugins/Calendars/Tasks/Assignments/Entity.php **/ * @copyright 2025 ARUNOX * @version 1.0.0 * * @since 1.0.0 File is created */ namespace ARUNOX\Plugins\Calendars\Tasks\Assignments; use ARUNOX\API\PHP; use ARUNOX\Plugins\Calendars; use ARUNOX\Database\BaseEntity; #[PHP\Attributes\Database\Attributes( "status", Status::class )] #[PHP\Attributes\Database\Attributes( "date_edit" )] #[PHP\Attributes\Database\Attributes( "date_create" )] #[PHP\Attributes\Database\Definitions\Model( Model::class )] class Entity extends BaseEntity { /* ### VARIABLES ################################################ # */ /* ### PUBLIC FUNCTIONS ######################################### # */ public function getTarget() { return \ARUNOX\Plugins\Users\Model::getByColumn( "hashid", $this->target_hid ); } public function getOrigin() : bool|BaseEntity { return Calendars\Tasks\Model::get( $this->origin_id ); } } /** Datei: plugins/calendars/library/ARUNOX/Plugins/Calendars/Tasks/Assignments/Status.php **/ [ "color" => REST\Generator\Config\Color::Warning, "icon" => "bi-hourglass", "label" => "Eingeladen" ], self::Accepted => [ "color" => REST\Generator\Config\Color::Success, "icon" => "bi-check-lg", "label" => "Angenommen" ], self::Rejected => [ "color" => REST\Generator\Config\Color::Danger, "icon" => "bi-x-lg", "label" => "Abgelehnt" ], ]; /* ### PUBLIC FUNCTIONS ######################################### # */ } /** Datei: plugins/calendars/library/ARUNOX/Plugins/Calendars/Tasks/Entity.php **/ * @copyright 2025 ARUNOX * @version 1.0.0 * * @since 1.0.0 File is created */ namespace ARUNOX\Plugins\Calendars\Tasks; use ARUNOX\API\PHP; use ARUNOX\Plugins\Calendars; use ARUNOX\Database\BaseEntity; #[PHP\Attributes\Database\Attributes( "status", Status::class )] #[PHP\Attributes\Database\Attributes( "date_edit" )] #[PHP\Attributes\Database\Attributes( "date_create" )] #[PHP\Attributes\Database\Definitions\Model( Model::class )] class Entity extends BaseEntity { /* ### VARIABLES ################################################ # */ /* ### PUBLIC FUNCTIONS ######################################### # */ public function toggleStatus() { if( $this->status->toggle() === Status::Done ) { $this->date_done = date( "Y-m-d H:i:s" ); } } public function getAssignments() : array { $list = Assignments\Model::getByOrigin( $this->id ); $status = Assignments\Status::getAll(); $count = array_map( fn( $item ) => count( array_filter( $list, fn( $entry ) => $entry->status->getValue() == $item["value"] ) ), $status ); $status = array_map( fn( $count, $status ) => "{$count}x {$status["emoji"]}", $count, $status ); $return = [ "count" => count( $list ), "output" => implode( " | ", $status ), "status" => $count, "list" => $list, ]; return $return; } public function getOrigin() : bool|BaseEntity { return Calendars\Model::get( $this->origin_id ); } } /** Datei: plugins/calendars/library/ARUNOX/Plugins/Calendars/Tasks/Status.php **/ [ "color" => REST\Generator\Config\Color::Danger, "icon" => "bi-hourglass", "label" => "Offen" ], self::Done => [ "color" => REST\Generator\Config\Color::Success, "icon" => "bi-check-lg", "label" => "Erledigt" ], ]; /* ### PUBLIC FUNCTIONS ######################################### # */ } /** Datei: plugins/calendars/hooks/init.php **/ * @copyright 2025 ARUNOX * @version 1.0.0 * @since 1.0.0 File is created */ use ARUNOX\Core\Hooks; use ARUNOX\Plugins\Calendars; Hooks::add('public::api->init', [ Calendars\API\v1\Routes::class, "register" ] ); Hooks::add('public::api->init', [ Calendars\Categories\API\v1\Routes::class, "register" ] ); Hooks::add('public::api->init', [ Calendars\Entries\API\v1\Routes::class, "register" ] ); Hooks::add('public::api->init', [ Calendars\Tasks\API\v1\Routes::class, "register" ] ); /** Datei: plugins/calendars/config.php **/ * @copyright 2025 ARUNOX * @version 0.1.0 * * @dependencies users * * @since 0.1.0 initial version */ /** Datei: plugins/calendars/config/schmea/v0.1.0.php **/ [ 'columns' => [ 'id' => 'INT NOT NULL AUTO_INCREMENT', 'hashid' => 'VARCHAR(32) NOT NULL', 'title' => 'VARCHAR(255) NOT NULL', 'description' => 'TEXT NULL', 'date_create' => 'DATETIME NOT NULL', 'date_edit' => 'DATETIME NOT NULL', 'assigned_to' => 'VARCHAR(32) NULL', // optional Eigentümer 'status' => 'TINYINT(1) DEFAULT 1', ], 'primary' => ['id'], 'indexes' => ['hashid', 'assigned_to'], ], 'calendars_entries' => [ 'columns' => [ // 1. Systemfelder 'id' => 'INT NOT NULL AUTO_INCREMENT', 'hashid' => 'VARCHAR(32) NOT NULL', // 2. Metafelder 'date_create' => 'DATETIME NOT NULL', 'date_edit' => 'DATETIME NOT NULL', // 3. Referenzen 'origin_id' => 'INT NOT NULL', // FK auf calendars 'category_id' => 'VARCHAR(32) NULL', // 4. Typisierung 'status' => 'TINYINT(1) DEFAULT 1', // 5. Zeitpunkte 'date_start' => 'DATETIME NULL', 'date_end' => 'DATETIME NULL', 'date_completed' => 'DATETIME NULL', // 6. Inhalte 'title' => 'VARCHAR(255) NULL', 'description' => 'TEXT NULL', ], 'primary' => ['id'], 'indexes' => ['hashid', 'date_start', 'category_id'], ], 'calendars_entries_participants' => [ 'columns' => [ 'id' => 'INT NOT NULL AUTO_INCREMENT', 'origin_id' => 'INT NOT NULL', // FK auf calendars_entries 'target_hid' => 'VARCHAR(32) NOT NULL', // HashID: user, gruppe etc. 'feedback' => 'VARCHAR(16) NULL', // accepted / declined / maybe 'status' => 'TINYINT(1) DEFAULT 1', 'date_create' => 'DATETIME NOT NULL', ], 'primary' => ['id'], 'indexes' => ['origin_id', 'target_hid'], ], 'calendars_tasks' => [ 'columns' => [ // 1. Systemfelder 'id' => 'INT NOT NULL AUTO_INCREMENT', 'hashid' => 'VARCHAR(32) NOT NULL', // 2. Metafelder 'date_create' => 'DATETIME NOT NULL', 'date_edit' => 'DATETIME NOT NULL', // 3. Referenzen 'origin_id' => 'INT NOT NULL', // FK auf calendars 'template_id' => 'VARCHAR(32) NULL', // 4. Typisierung 'status' => 'TINYINT(1) DEFAULT 1', 'task_key' => 'VARCHAR(64) NOT NULL', 'is_template' => 'TINYINT(1) DEFAULT 0', // 5. Zeitpunkte 'date_due' => 'DATE NULL', 'date_completed' => 'DATETIME NULL', // 6. Inhalte 'title' => 'VARCHAR(255) NULL', 'description' => 'TEXT NULL', ], 'primary' => ['id'], 'indexes' => ['hashid', 'task_key', 'assigned_to', 'date_due'], ], 'calendars_tasks_assignments' => [ 'columns' => [ 'id' => 'INT NOT NULL AUTO_INCREMENT', 'origin_id' => 'INT NOT NULL', // FK auf calendars_tasks 'target_hid' => 'VARCHAR(32) NOT NULL', // zuständige Entität 'status' => 'TINYINT(1) DEFAULT 1', 'date_assigned' => 'DATETIME NOT NULL', 'date_completed' => 'DATETIME NULL', 'date_create' => 'DATETIME NOT NULL', ], 'primary' => ['id'], 'indexes' => ['origin_id', 'target_hid', 'date_completed'], ], ];