/** Datei: plugins/contacts/library/ARUNOX/Plugins/Contacts/Model.php **/ $pid, ]); $cids = $query->fetchColumns(); if( !$cids ) return []; if( $ids ) return $cids; return static::getAll([ "id__in" => $cids, ]); } public static function isSubContact( int|string $value, null|int|string $origin = NULL ) : bool { $cid = static::getValue( $value ); $query = QueryBuilder::select( static::getTable( "relations" ), "parent_id", [ "child_id" => $cid, ]); $pids = $query->fetchColumns(); if( !$pids ) return FALSE; if( !$origin ) return !!$pids; $pid = static::getValue( $origin ); return in_array( $pid, $pids ); } public static function getParent( int|string $value, ?string $column = NULL ) : mixed { $cid = static::getValue( $value ); $query = QueryBuilder::select( static::getTable( "relations" ), "parent_id", [ "child_id" => $cid, ]); $pid = $query->fetchColumn(); if( !$pid ) return FALSE; return static::getValue( $pid, $column ); } } /** Datei: plugins/contacts/library/ARUNOX/Plugins/Contacts/Reachability.php **/ [ "color" => REST\Generator\Config\Color::Default, "icon" => "bi-question", "label" => "Other" ], self::Morning => [ "color" => REST\Generator\Config\Color::Warning, "icon" => "bi-sunrise-fill", "label" => "Morning" ], self::Afternoon => [ "color" => REST\Generator\Config\Color::Primary, "icon" => "bi-sun-fill", "label" => "Afternoon" ], self::Evening => [ "color" => REST\Generator\Config\Color::Danger, "icon" => "bi-sunset-fill", "label" => "Evening" ], self::AllDay => [ "color" => REST\Generator\Config\Color::Success, "icon" => "bi-clock-history", "label" => "All day" ], self::WeekendsOnly => [ "color" => REST\Generator\Config\Color::Secondary, "icon" => "bi-calendar-day-fill", "label" => "Weekends only" ], self::EmailOnly => [ "color" => REST\Generator\Config\Color::Secondary, "icon" => "bi-envelope-at", "label" => "By email only" ], ]; /* ### PUBLIC FUNCTIONS ######################################### # */ } /** Datei: plugins/contacts/library/ARUNOX/Plugins/Contacts/API/v1/Routes.php **/ * @copyright 2025 ARUNOX * @version 1.1.0 * * @since 1.0.0 File is created */ namespace ARUNOX\Plugins\Contacts\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" => "/contacts", "label" => "Kontakte", "icon" => "bi bi-journal-bookmark-fill", "menu" => "content", ]; return $routes; }); } } /** Datei: plugins/contacts/library/ARUNOX/Plugins/Contacts/API/v1/Controller.php **/ * @copyright 2025 ARUNOX * @version 1.1.0 * * @since 1.0.0 File is created */ namespace ARUNOX\Plugins\Contacts\API\v1; use ARUNOX\HTTP; use ARUNOX\API\PHP; use ARUNOX\Plugins; use ARUNOX\Core\Hooks; use ARUNOX\Plugins\REST; use ARUNOX\Plugins\Contacts; use ARUNOX\API\BaseController; use ARUNOX\Database\Attribute; use ARUNOX\Database\BaseEntity; #[PHP\Attributes\Controller\Label( "Kontakt", "Kontakte" )] #[PHP\Attributes\Controller\Icon( REST\Generator\Config\Icon::PersonVcard )] #[PHP\Attributes\Controller\Route( "contacts" )] class Controller extends BaseController { /* ### PUBLIC GET FUNCTIONS ##################################### # */ /** * @api * @method GET * * @route.path /contacts * @route.description Listet alle Kontakte */ public static function getAll() : array { return Contacts\Model::getAll(); } /** * @api * @method GET * * @route.path /contacts/{hashid} * @route.description Gibt einen einzelnen Kontakts anhand der ID zurück */ public static function get( int|string $hashid ) : BaseEntity | HTTP\Response { if( $result = Contacts\Model::get( $hashid ) ) return $result; return REST\Response::autoResponse( 404, static::getNotify("notfound") ); } /* ### PUBLIC SAVE FUNCTIONS #################################### # */ /** * @api * @method PUT * * @route.path /contacts/{hashid} * @route.description Speichert Änderungen an einem bestehenden Kontakts */ public static function save( int|string $hashid, array $data ) : HTTP\Response { if( $result = Contacts\Model::get( $hashid ) ) { if( $result->save( $data ) ) { return REST\Response::autoResponse( 200, static::getNotify("saved") ); } return REST\Response::autoResponse( 500, static::getNotify("notsaved") ); } return REST\Response::autoResponse( 404, static::getNotify("notfound") ); } /** * @api * @method POST * * @route.path /contacts * @route.description Erstellt einen neuen Kontakt */ public static function create( array $data ) : HTTP\Response { if( $hashid = Contacts\Model::save( $data ) ) { $result = Contacts\Model::get( $hashid ); return REST\Response::autoResponse( 200, static::getNotify("created" ), [ "data" => $result ] ); } return REST\Response::autoResponse( 500, static::getNotify("notfound") ); } /** * @api * @method DELETE * * @route.path /contacts/{hashid} * @route.description Löscht einen Kontakt anhand der ID */ public static function delete( int|string $hashid ) : HTTP\Response { if( Contacts\Model::delete( $hashid ) ) { return REST\Response::autoResponse( 200, static::getNotify("deleted") ); } return REST\Response::autoResponse( 500, static::getNotify("notfound") ); } /** * @api * @method PATCH * * @route.path /contacts/{hashid}/status * @route.description Wechselt den Status (aktiv/inaktiv) eines Kontakts */ public static function toggleStatus( int|string $hashid ) : HTTP\Response { if( $result = Contacts\Model::get( $hashid ) ) { $result->toggleStatus( TRUE ); return REST\Response::autoResponse( 200, static::getNotify("statuschanged.{$result->status->getValue()}" ), [ "data" => $result ] ); } return REST\Response::autoResponse( 404, static::getNotify("notfound") ); } /** * @api * @method PATCH * * @route.path /contacts/{hashid}/invoice * @route.description Wechselt den Status (aktiv/inaktiv) eines Kontakts */ public static function toggleInvoice( int|string $hashid ) : HTTP\Response { if( $result = Contacts\Model::get( $hashid ) ) { $result->toggleInvoice( TRUE ); return REST\Response::autoResponse( 200, static::getNotify("statuschanged.{$result->status->getValue()}" ), [ "data" => $result ] ); } return REST\Response::autoResponse( 404, static::getNotify("notfound") ); } /* ### PUBLIC VALIDATE FUNCTIONS ################################ # */ /* ### PUBLIC REST FUNCTIONS #################################### # */ /* ### PUBLIC REST RESPONSE FUNCTIONS ########################### # */ /** * @internal rest * @method PUT * * @route.path /contacts/{hashid} * @route.description REST-Antwort nach dem Speichern eines Kontakts */ public static function restResponseSave( int|string $hashid, array $data ) : HTTP\Response { $result = static::save( $hashid, $data ); if( $result->isStatus( 200 ) ) { $data = Contacts\Model::get( $hashid ); REST\Response::closeModals(); REST\Response::addUpdater( [ "data/table/row", $hashid ], $data ); } return static::restResponse( $result ); } /** * @internal rest * @method POST * * @route.path /contacts * @route.description REST-Antwort nach dem Erstellen eines Kontakts (inkl. Notifikation, Redirect etc.) */ public static function restResponseCreate( array $data ) : HTTP\Response { $result = static::create( $data ); if( $result->isStatus( 200 ) ) { REST\Response::closeModals(); REST\Response::redirect( "/contacts/{$result->getBody("data", "hashid")}" ); } return static::restResponse( $result ); } /** * @internal rest * @method DELETE * * @route.path /contacts/{hashid} * @route.description REST-Antwort nach dem Löschen eines Kontakts */ public static function restResponseDelete( int|string $hashid ) : HTTP\Response { REST\Response::closeModals(); $result = static::delete( $hashid ); if( $result->isStatus( 200 ) ) { REST\Response::redirect( "/contacts" ); } return static::restResponse( $result ); } /** * @internal rest * @method PATCH * * @route.path /contacts/{hashid}/status * @route.description REST-Antwort zur Status-Umschaltung eines Kontakts (z. B. für Notifications) */ public static function restResponseToggleStatus( int|string $hashid ) : HTTP\Response { $result = static::toggleStatus( $hashid ); if( $result->isStatus( 200 ) ) { $data = $result->getBody("data"); REST\Response::addUpdater( [ "data/table/row", $hashid ], $data ); } return static::restResponse( $result ); } /** * @internal rest * @method PATCH * * @route.path /contacts/{hashid}/invoice * @route.description REST-Antwort zur Status-Umschaltung eines Kontakts (z. B. für Notifications) */ public static function restResponseToggleInvoice( int|string $hashid ) : HTTP\Response { $result = static::toggleInvoice( $hashid ); if( $result->isStatus( 200 ) ) { $data = $result->getBody("data"); REST\Response::addUpdater( [ "data/table/row", $hashid ], $data ); } return static::restResponse( $result ); } /* ### PUBLIC REST CONFIG FUNCTIONS ############################# # */ /** * @internal rest * @method GET * * @route.path /contacts * @route.description REST-Konfiguration für Kontakt-Tabelle */ public static function restConfigOverview() : REST\Generator\Base\BaseGenerator { return REST\Response::addWrapper( "overview", static::getPlural() ) ->replaceContent( static::restConfigTable() ); } /** * @internal rest * @method GET * * @route.path /contacts/{hashid} * @route.alternative.0 /contacts/{hashid}#kontext * @route.alternative.1 /contacts/{hashid}#chat * @route.alternative.2 /contacts/{hashid}#telefon * @route.description REST-Konfiguration für Detailansicht eines Kontakts */ public static function restConfigDetails( int|string $hashid ) : REST\Generator\Base\BaseGenerator { if( Contacts\Model::isSubContact( $hashid ) ) { $origin = Contacts\Model::getParent( $hashid, "hashid" ); return Contacts\Contacts\API\v1\Controller::restConfigDetails( $origin, $hashid ); } $data = Contacts\Model::get( $hashid ); return REST\Response::addWrapper( "details", static::getSingular( "%t bearbeiten" ) ) ->setBacklink( "/contacts" ) ->get() ->setApi( "/contacts/{$hashid}" ) ->setAction( "/contacts/{$hashid}", "PUT" ) ->addTab( "Kontaktdaten", "contactdata" )->get() ->setIcon( "bi-person-vcard" ) ->addHeadline( "Kontakt", 2 ) ->addField(...Hooks::filter( "rest.generator::control.type->text", [], "company_name", FALSE, "contacts" )) ->addField(...Hooks::filter( "rest.generator::control.type->text", [], "firstname", FALSE, "contacts" )) ->addField(...Hooks::filter( "rest.generator::control.type->text", [], "lastname", FALSE, "contacts" )) ->addField(...Hooks::filter( "rest.generator::control.type->select", [ "options" => Attribute\Status::getAll(), ], "status", TRUE, FALSE, "contacts" )) ->parent() ->addTab( "Ansprechpartner", "contacts" )->get() ->setIcon( "bi-people" ) ->addContent( Contacts\Contacts\API\v1\Controller::restConfigTable( $hashid ) ) ->parent() ->addTab( "Adressen", "addresses" )->get() ->setIcon( "bi-geo-alt" ) ->addContent( Contacts\Addresses\API\v1\Controller::restConfigTable( $hashid ) ) ->parent() ->addCallable( [ Plugins\Logs\API\v1\Controller::class, "restConfigTab" ], $hashid ) ->addCallable( [ Plugins\Calendars\Entries\API\v1\Controller::class, "restConfigTab" ], $hashid ) ->addCallable( [ Plugins\Calendars\Tasks\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 /contacts/create * @route.description REST-Konfiguration für das Erstellen eines Kontakts (Formular) */ public static function restConfigCreate() : REST\Generator\Base\BaseGenerator { return REST\Response::addModal( "details", static::getSingular( "%t erstellen" ) ) ->get() ->setAction( "/contacts", "POST" ) ->addButton(...Hooks::filter( "rest.generator::button.type->submit", [], "Erstellen", "contacts" )) ->addField(...Hooks::filter( "rest.generator::control.type->text", [], "name", TRUE, "contacts" )); } /** * @internal rest * @method GET * * @route.path /contacts/{hashid}/delete * @route.description REST-Konfiguration für die Lösch-Bestätigung eines Kontakts */ 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 { $table = REST\Generator\Data\Table::create() ->setApi( "/contacts" ) ->setAction( "/contacts/{hashid}" ) ->setOrder( "name", "asc" ) ->setSearch( TRUE ) ->addButton(...Hooks::filter( "rest.generator::button.name->create", [], "contacts" )) ->addColumn(...Hooks::filter( "rest.generator::column.type->status", [], "status", [], "contacts", "hashid" )) ->addColumn(...Hooks::filter( "rest.generator::column.type->icon", [ "label" => Contacts\Category::label(), "icon" => Contacts\Category::icon(), "options" => Contacts\Category::getAll(), ], "category", [], "contacts", "hashid" )) ->addColumn(...Hooks::filter( "rest.generator::column.type->status", [ "label" => Contacts\Invoice::label(), "icon" => Contacts\Invoice::icon(), "options" => Contacts\Invoice::getAll(), ], "invoice", [], "contacts", "hashid" )) ->addColumn(...Hooks::filter( "rest.generator::column.type->text", [], "company_name", TRUE, TRUE, TRUE, "contacts" )) ->addColumn(...Hooks::filter( "rest.generator::column.type->text", [], "firstname", TRUE, TRUE, TRUE, "contacts" )) ->addColumn(...Hooks::filter( "rest.generator::column.type->text", [], "lastname", TRUE, TRUE, TRUE, "contacts" )) ->addColumn(...Hooks::filter( "rest.generator::column.type->text", [], "email", TRUE, TRUE, TRUE, "contacts" )) ->addColumn(...Hooks::filter( "rest.generator::column.type->icon", [ "label" => Contacts\Reachability::label(), "icon" => Contacts\Reachability::icon(), "options" => Contacts\Reachability::getAll(), ], "reachability", [], "contacts", "hashid" )) ->addColumn(...Hooks::filter( "rest.generator::column.type->datetime", [], "date_edit", FALSE, FALSE, TRUE, "contacts" )) ->addColumn(...Hooks::filter( "rest.generator::column.type->actions", [], [], FALSE, "contacts" ))->get() ->addButton(...Hooks::filter( "rest.generator::action.name->edit", [], "contacts", "hashid" )) ->addButton(...Hooks::filter( "rest.generator::action.name->delete", [], "contacts", "hashid" )) ; $buttons = $table->top()->getButtons(); foreach( Contacts\Type::getAll() as $type ) { $type["name"] = "type"; $buttons->addDropdown( ...Hooks::filter( "rest.generator::button.name->create", $type, "contacts" ) ); } return $table; } } /** Datei: plugins/contacts/library/ARUNOX/Plugins/Contacts/Category.php **/ [ "color" => REST\Generator\Config\Color::Default, "icon" => "bi-person-vcard-fill", "label" => "Contact" ], self::Customer => [ "color" => REST\Generator\Config\Color::Success, "icon" => "bi-briefcase-fill", "label" => "Customer" ], self::Supplier => [ "color" => REST\Generator\Config\Color::Warning, "icon" => "bi-truck", "label" => "Supplier" ], self::Partner => [ "color" => REST\Generator\Config\Color::Info, "icon" => "bi-person-plus-fill", "label" => "Partner" ], self::Employee => [ "color" => REST\Generator\Config\Color::Danger, "icon" => "bi-person-fill-lock", "label" => "Employee" ], ]; /* ### PUBLIC FUNCTIONS ######################################### # */ } /** Datei: plugins/contacts/library/ARUNOX/Plugins/Contacts/Type.php **/ [ "color" => REST\Generator\Config\Color::Primary, "icon" => "bi-person-fill", "label" => "Person" ], self::Company => [ "color" => REST\Generator\Config\Color::Secondary, "icon" => "bi-buildings-fill", "label" => "Company" ], ]; /* ### PUBLIC FUNCTIONS ######################################### # */ } /** Datei: plugins/contacts/library/ARUNOX/Plugins/Contacts/Addresses/Model.php **/ $pid, ]); } /* ### PUBLIC STATIC LOG FUNCTIONS ############################## # */ public static function getLogRulesUpdated() { return [ "status" => [ "options" => Attribute\Status::getAll(), "message" => "Status wurde auf {\$label} gesetzt.", ], "is_primary" => [ "options" => Primary::getAll(), "message" => "Is Primary wurde auf {\$label} gesetzt.", ], ]; } public static function getLogRulesCreated() { return [ "__self" => [ "message" => "Adresse wurde erstellt", ], "origin_id" => [ "class" => Contacts\Model::class, "message" => "Adresse ({\$hashid}) wurde hinzugefügt", ], ]; } } /** Datei: plugins/contacts/library/ARUNOX/Plugins/Contacts/Addresses/API/v1/Routes.php **/ * @copyright 2025 ARUNOX * @version 1.1.0 * * @since 1.0.0 File is created */ namespace ARUNOX\Plugins\Contacts\Addresses\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 ############################## # */ } } /** Datei: plugins/contacts/library/ARUNOX/Plugins/Contacts/Addresses/API/v1/Controller.php **/ * @copyright 2025 ARUNOX * @version 1.1.0 * * @since 1.0.0 File is created */ namespace ARUNOX\Plugins\Contacts\Addresses\API\v1; use ARUNOX\HTTP; use ARUNOX\Plugins; use ARUNOX\API\PHP; use ARUNOX\Core\Hooks; use ARUNOX\Plugins\REST; use ARUNOX\Plugins\Contacts; use ARUNOX\API\BaseController; use ARUNOX\Database\Attribute; use ARUNOX\Database\BaseEntity; #[PHP\Attributes\Controller\Label( "Adresse", "Adressen" )] #[PHP\Attributes\Controller\Icon( REST\Generator\Config\Icon::GeoAlt )] #[PHP\Attributes\Controller\Route( "addresses" )] class Controller extends BaseController { /* ### VARIABLES ################################################ # */ /* ### PUBLIC GET FUNCTIONS ##################################### # */ /** * @api * @method GET * * @route.path /contacts/{hashid}/addresses * @route.description Listet alle Adresseen */ public static function getAllOwn( int|string $origin ) : array { return Contacts\Addresses\Model::getByContact( $origin ); } /** * @api * @method GET * * @route.path /contacts/{hashid}/addresses/{hashid} * @route.description Gibt einen einzelnen Adresse anhand der ID zurück */ public static function get( int|string $origin, int|string $hashid ) : BaseEntity | HTTP\Response { $origin = Contacts\Model::getValue( $origin ); $current = Contacts\Addresses\Model::getValue( $hashid ); $where = [ "id" => $current, "origin_id" => $origin ]; if( $result = Contacts\Addresses\Model::get( $where ) ) return $result; return REST\Response::autoResponse( 404, static::getNotify("notfound") ); } /* ### PUBLIC SAVE FUNCTIONS #################################### # */ /** * @api * @method PUT * * @route.path /contacts/{hashid}/addresses/{hashid} * @route.description Speichert Änderungen an einem bestehenden Adresse */ public static function save( int|string $origin, int|string $hashid, array $data ) : HTTP\Response { $origin = Contacts\Model::getValue( $origin ); $current = Contacts\Addresses\Model::getValue( $hashid ); $where = [ "id" => $current, "origin_id" => $origin ]; if( $result = Contacts\Addresses\Model::get( $where ) ) { if( $result->save( $data ) ) { return REST\Response::autoResponse( 200, static::getNotify("saved") ); } return REST\Response::autoResponse( 500, static::getNotify("notsaved") ); } return REST\Response::autoResponse( 404, static::getNotify("notfound") ); } /** * @api * @method POST * * @route.path /contacts/{hashid}/addresses * @route.description Erstellt einen neue Adresse */ public static function create( int|string $origin, array $data ) : HTTP\Response { $data["origin_id"] = Contacts\Model::getValue( $origin ); if( $hashid = Contacts\Addresses\Model::save( $data ) ) { $result = Contacts\Addresses\Model::get( $hashid ); return REST\Response::autoResponse( 200, static::getNotify("created"), [ "data" => $result ] ); } return REST\Response::autoResponse( 500, static::getNotify("notfound") ); } /** * @api * @method DELETE * * @route.path /contacts/{hashid}/addresses/{hashid} * @route.description Löscht eine Adresse anhand der ID */ public static function delete( int|string $origin, int|string $hashid ) : HTTP\Response { $origin = Contacts\Model::getValue( $origin ); $current = Contacts\Addresses\Model::getValue( $hashid ); $where = [ "id" => $current, "origin_id" => $origin ]; if( Contacts\Addresses\Model::delete( $where ) ) { return REST\Response::autoResponse( 200, static::getNotify("deleted") ); } return REST\Response::autoResponse( 500, static::getNotify("notfound") ); } /** * @api * @method PATCH * * @route.path /contacts/{hashid}/addresses/{hashid}/status * @route.description Wechselt den Status (aktiv/inaktiv) eines Adresse */ public static function toggleStatus( int|string $origin, int|string $hashid ) : HTTP\Response { $origin = Contacts\Model::getValue( $origin ); $current = Contacts\Addresses\Model::getValue( $hashid ); $where = [ "id" => $current, "origin_id" => $origin ]; if( $result = Contacts\Addresses\Model::get( $where ) ) { $result->toggleStatus( TRUE ); return REST\Response::autoResponse( 200, static::getNotify("statuschanged.{$result->status->getValue()}" ), [ "data" => $result ] ); } return REST\Response::autoResponse( 404, static::getNotify("notfound") ); } /** * @api * @method PATCH * * @route.path /contacts/{hashid}/addresses/{hashid}/primary * @route.description Wechselt den Status (aktiv/inaktiv) eines Adresse */ public static function togglePrimary( int|string $origin, int|string $hashid ) : HTTP\Response { $origin = Contacts\Model::getValue( $origin ); $current = Contacts\Addresses\Model::getValue( $hashid ); $where = [ "id" => $current, "origin_id" => $origin ]; if( $result = Contacts\Addresses\Model::get( $where ) ) { $result->togglePrimary( TRUE ); return REST\Response::autoResponse( 200, static::getNotify("statuschanged.{$result->status->getValue()}" ), [ "data" => $result ] ); } return REST\Response::autoResponse( 404, static::getNotify("notfound") ); } /* ### PUBLIC VALIDATE FUNCTIONS ################################ # */ /* ### PUBLIC REST FUNCTIONS #################################### # */ /* ### PUBLIC REST RESPONSE FUNCTIONS ########################### # */ /** * @internal rest * @method PUT * * @route.path /contacts/{hashid}/addresses/{hashid} * @route.description REST-Antwort nach dem Speichern eines Adresse */ public static function restResponseSave( int|string $origin, int|string $hashid, array $data ) : HTTP\Response { $result = static::save( $origin, $hashid, $data ); if( $result->isStatus( 200 ) ) { $data = Contacts\Addresses\Model::get( $hashid ); REST\Response::closeModals(); REST\Response::addUpdater( [ "data/table/row", "/api/v1/contacts/{hashid}/addresses", $hashid ], $data ); } return static::restResponse( $result ); } /** * @internal rest * @method POST * * @route.path /contacts/{hashid}/addresses * @route.description REST-Antwort nach dem Erstellen einer Adresse (inkl. Notifikation, Redirect etc.) */ public static function restResponseCreate( int|string $origin, array $data ) : HTTP\Response { $result = static::create( $origin, $data ); if( $result->isStatus( 200 ) ) { REST\Response::closeModals(); REST\Response::redirect( "/contacts/{hashid}/addresses/{$result->getBody("data", "hashid")}" ); } return static::restResponse( $result ); } /** * @internal rest * @method DELETE * * @route.path /contacts/{hashid}/addresses/{hashid} * @route.description REST-Antwort nach dem Löschen einer Adresse */ public static function restResponseDelete( int|string $origin, int|string $hashid ) : HTTP\Response { REST\Response::closeModals(); $result = static::delete( $origin, $hashid ); if( $result->isStatus( 200 ) ) { REST\Response::redirect( "/contacts/{hashid}/addresses" ); } return static::restResponse( $result ); } /** * @internal rest * @method PATCH * * @route.path /contacts/{hashid}/addresses/{hashid}/status * @route.description REST-Antwort zur Status-Umschaltung einer Adresse (z. B. für Notifications) */ public static function restResponseToggleStatus( int|string $origin, int|string $hashid ) : HTTP\Response { $result = static::toggleStatus( $origin, $hashid ); if( $result->isStatus( 200 ) ) { $data = $result->getBody("data"); REST\Response::addUpdater( [ "data/table/row", "/api/v1/contacts/{$origin}/addresses", $hashid ], $data ); } return static::restResponse( $result ); } /** * @internal rest * @method PATCH * * @route.path /contacts/{hashid}/addresses/{hashid}/primary * @route.description REST-Antwort zur Status-Umschaltung einer Adresse (z. B. für Notifications) */ public static function restResponseTogglePrimary( int|string $origin, int|string $hashid ) : HTTP\Response { $result = static::togglePrimary( $origin, $hashid ); if( $result->isStatus( 200 ) ) { $data = $result->getBody("data"); REST\Response::addUpdater( [ "data/table/row", "/api/v1/contacts/{$origin}/addresses", $hashid ], $data ); } return static::restResponse( $result ); } /* ### PUBLIC REST CONFIG FUNCTIONS ############################# # */ /** * @internal rest * @method GET * * @route.path /contacts/{hashid}/addresses * @route.description REST-Konfiguration für Adressen-Tabelle */ public static function restConfigOverview() : REST\Generator\Base\BaseGenerator { return REST\Response::addWrapper( "overview", "Adressen" ) ->get() ->setApi( "/contacts/{hashid}/addresses" ) ->setAction( "/contacts/{hashid}/addresses/{hashid}" ) ->setOrder( "name", "asc" ) ->setSearch( TRUE ) ->addButton(...Hooks::filter( "rest.generator::button.name->create", [], "contacts" )) ->addColumn(...Hooks::filter( "rest.generator::column.type->icon", [ "label" => Contacts\Addresses\Type::label(), "icon" => Contacts\Addresses\Type::icon(), "options" => Contacts\Addresses\Type::getAll(), ], "type", [], "contacts", "hashid" )) ->addColumn(...Hooks::filter( "rest.generator::column.type->text", [], "custom_id", TRUE, TRUE, TRUE, "contacts" )) ->addColumn(...Hooks::filter( "rest.generator::column.type->status", [], "status", [], "contacts", "hashid" )) ->addColumn(...Hooks::filter( "rest.generator::column.type->icon", [ "label" => Contacts\Addresses\Category::label(), "icon" => Contacts\Addresses\Category::icon(), "options" => Contacts\Addresses\Category::getAll(), ], "category", [], "contacts", "hashid" )) ->addColumn(...Hooks::filter( "rest.generator::column.type->text", [], "company_name", TRUE, TRUE, TRUE, "contacts" )) ->addColumn(...Hooks::filter( "rest.generator::column.type->text", [], "firstname", TRUE, TRUE, TRUE, "contacts" )) ->addColumn(...Hooks::filter( "rest.generator::column.type->text", [], "lastname", TRUE, TRUE, TRUE, "contacts" )) ->addColumn(...Hooks::filter( "rest.generator::column.type->text", [], "email", TRUE, TRUE, TRUE, "contacts" )) ->addColumn(...Hooks::filter( "rest.generator::column.type->status", [ "label" => Contacts\Addresses\Invoice::label(), "icon" => Contacts\Addresses\Invoice::icon(), "options" => Contacts\Addresses\Invoice::getAll(), ], "invoice", [], "contacts", "hashid" )) ->addColumn(...Hooks::filter( "rest.generator::column.type->icon", [ "label" => Contacts\Addresses\Reachability::label(), "icon" => Contacts\Addresses\Reachability::icon(), "options" => Contacts\Addresses\Reachability::getAll(), ], "reachability", [], "contacts", "hashid" )) ->addColumn(...Hooks::filter( "rest.generator::column.type->datetime", [], "date_edit", FALSE, FALSE, TRUE, "contacts" )) ->addColumn(...Hooks::filter( "rest.generator::column.type->actions", [], [], FALSE, "contacts" ))->get() ->addButton(...Hooks::filter( "rest.generator::action.name->edit", [], "contacts", "hashid" )) ->addButton(...Hooks::filter( "rest.generator::action.name->delete", [], "contacts", "hashid" )); } /** * @internal rest * @method GET * * @route.path /contacts/{hashid}/addresses/{hashid} * @route.alternative.0 /contacts/{hashid}/addresses/{hashid}#kontext * @route.alternative.1 /contacts/{hashid}/addresses/{hashid}#chat * @route.alternative.2 /contacts/{hashid}/addresses/{hashid}#telefon * @route.description REST-Konfiguration für Detailansicht einer Addresses */ public static function restConfigDetails( int|string $origin, int|string $hashid ) : REST\Generator\Base\BaseGenerator { $origin = Contacts\Model::getValue( $origin, "hashid" ); $current = Contacts\Addresses\Model::get( $hashid ); return REST\Response::addModal( "details", "Adresse bearbeiten" ) ->setSize( "max" ) ->setWidth( "lg" ) ->get() ->setApi( "/contacts/{$origin}/addresses/{$hashid}" ) ->setAction( "/contacts/{$origin}/addresses/{$hashid}", "PUT" ) ->addTab( "Kontaktdaten", "contactdata" )->get() ->setIcon( "bi-person-vcard" ) ->addHeadline( "Kontakt", 2 ) ->addField(...Hooks::filter( "rest.generator::control.type->text", [], "name", FALSE, "contacts/{$origin}/addresses" )) ->addField(...Hooks::filter( "rest.generator::control.type->text", [], "street", TRUE, "contacts/{$origin}/addresses" )) ->addField(...Hooks::filter( "rest.generator::control.type->select", [ "label" => Contacts\Addresses\Primary::label(), "options" => Attribute\Status::getAll(), ], "is_primary", TRUE, FALSE, "contacts/{$origin}/addresses" )) ->addField(...Hooks::filter( "rest.generator::control.type->text", [], "line_1", FALSE, "contacts/{$origin}/addresses" )) ->addField(...Hooks::filter( "rest.generator::control.type->text", [], "line_2", FALSE, "contacts/{$origin}/addresses" )) ->addField(...Hooks::filter( "rest.generator::control.type->text", [], "zipcode", TRUE, "contacts/{$origin}/addresses" )) ->addField(...Hooks::filter( "rest.generator::control.type->text", [], "city", TRUE, "contacts/{$origin}/addresses" )) ->addField(...Hooks::filter( "rest.generator::control.type->text", [], "country", TRUE, "contacts/{$origin}/addresses" )) ->addField(...Hooks::filter( "rest.generator::control.type->textarea", [], "notes ", FALSE, "contacts/{$origin}/addresses" )) ->addField(...Hooks::filter( "rest.generator::control.type->textarea", [], "notes ", FALSE, "contacts/{$origin}/addresses" )) ->addField(...Hooks::filter( "rest.generator::control.type->textarea", [], "notes ", FALSE, "contacts/{$origin}/addresses" )) ->addField(...Hooks::filter( "rest.generator::control.type->textarea", [], "notes ", FALSE, "contacts/{$origin}/addresses" )) ->addField(...Hooks::filter( "rest.generator::control.type->textarea", [], "notes ", FALSE, "contacts/{$origin}/addresses" )) ->addField(...Hooks::filter( "rest.generator::control.type->textarea", [], "notes ", FALSE, "contacts/{$origin}/addresses" )) ->addField(...Hooks::filter( "rest.generator::control.type->textarea", [], "notes ", FALSE, "contacts/{$origin}/addresses" )) ->addField(...Hooks::filter( "rest.generator::control.type->textarea", [], "notes ", FALSE, "contacts/{$origin}/addresses" )) ->addField(...Hooks::filter( "rest.generator::control.type->textarea", [], "notes ", FALSE, "contacts/{$origin}/addresses" )) ->addField(...Hooks::filter( "rest.generator::control.type->textarea", [], "notes ", FALSE, "contacts/{$origin}/addresses" )) ->parent() ->addCallable( [ Plugins\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 /contacts/{hashid}/addresses/create * @route.description REST-Konfiguration für das Erstellen einer Adresse (Formular) */ public static function restConfigCreate( int|string $origin ) : REST\Generator\Base\BaseGenerator { $origin = Contacts\Model::getValue( $origin, "hashid" ); return REST\Response::addModal( "details", "Adresse erstellen" ) ->get() ->setAction( "/contacts/{$origin}/addresses", "POST" ) ->addButton(...Hooks::filter( "rest.generator::button.type->submit", [], "Erstellen", "contacts" )) ->addField(...Hooks::filter( "rest.generator::control.type->text", [], "name", FALSE, "contacts/{$origin}/addresses" )) ->addField(...Hooks::filter( "rest.generator::control.type->text", [], "street", TRUE, "contacts/{$origin}/addresses" )) ->addField(...Hooks::filter( "rest.generator::control.type->select", [ "label" => Contacts\Addresses\Primary::label(), "options" => Attribute\Status::getAll(), ], "is_primary", TRUE, FALSE, "contacts/{$origin}/addresses" )) ->addField(...Hooks::filter( "rest.generator::control.type->text", [], "line_1", FALSE, "contacts/{$origin}/addresses" )) ->addField(...Hooks::filter( "rest.generator::control.type->text", [], "line_2", FALSE, "contacts/{$origin}/addresses" )) ->addField(...Hooks::filter( "rest.generator::control.type->text", [], "zipcode", TRUE, "contacts/{$origin}/addresses" )) ->addField(...Hooks::filter( "rest.generator::control.type->text", [], "city", TRUE, "contacts/{$origin}/addresses" )) ->addField(...Hooks::filter( "rest.generator::control.type->text", [], "country", TRUE, "contacts/{$origin}/addresses" )) ->addField(...Hooks::filter( "rest.generator::control.type->textarea", [], "notes ", FALSE, "contacts/{$origin}/addresses" )) ; } /** * @internal rest * @method GET * * @route.path /contacts/{hashid}/addresses/{hashid}/delete * @route.description REST-Konfiguration für die Lösch-Bestätigung einer Adresse */ public static function restConfigDeleteOwn( int|string $origin, int|string $hashid ) : REST\Generator\Base\BaseGenerator { return REST\Response::addModal( "details", "Adresse Löschen" ) ->setSize( REST\Wrapper\Modal\Size::sm ) ->get() ->setAction( "/contacts/{$origin}/addresses/{$hashid}", "DELETE" ) ->addText( "Möchtest du wirklich den Datensatz (#{$hashid}) löschen? " ) ->addButton(...Hooks::filter( "rest.generator::button.type->cancel", [], NULL, "contacts" )) ->addButton(...Hooks::filter( "rest.generator::button.type->delete", [], NULL, "contacts" )); } /* ### PUBLIC REST EXTENSION FUNCTIONS ########################## # */ public static function restConfigTable( int|string $origin ) : REST\Generator\Base\BaseGenerator { $table = REST\Generator\Data\Table::create() ->setApi( "/contacts/{$origin}/addresses" ) ->setAction( "/contacts/{$origin}/addresses/{hashid}" ) ->setOrder( "name", "asc" ) ->setSearch( TRUE ) ->addButton(...Hooks::filter( "rest.generator::button.name->create", [], "contacts/{$origin}/addresses" )) ->addColumn(...Hooks::filter( "rest.generator::column.type->status", [], "status", [], "contacts/{$origin}/addresses", "hashid" )) ->addColumn(...Hooks::filter( "rest.generator::column.type->status", [ "label" => Contacts\Addresses\Primary::getSingular(), "icon" => Contacts\Addresses\Primary::getIcon(), "options" => Contacts\Addresses\Primary::getAll(), "action" => [ "route" => "/contacts/{$origin}/addresses/{hashid}/primary", ], ], "is_primary", [], "contacts/{$origin}/addresses/{hashid}", "hashid" )) ->addColumn(...Hooks::filter( "rest.generator::column.type->text", [], "name", TRUE, TRUE, TRUE, "contacts/{origin_id}/addresses" )) ->addColumn(...Hooks::filter( "rest.generator::column.type->text", [], "street", TRUE, TRUE, TRUE, "contacts/{origin_id}/addresses" )) ->addColumn(...Hooks::filter( "rest.generator::column.type->text", [], "zipcode", TRUE, TRUE, TRUE, "contacts/{origin_id}/addresses" )) ->addColumn(...Hooks::filter( "rest.generator::column.type->text", [], "city", TRUE, TRUE, TRUE, "contacts/{origin_id}/addresses" )) ->addColumn(...Hooks::filter( "rest.generator::column.type->datetime", [], "date_edit", FALSE, FALSE, TRUE, "contacts/{id}/addresses" )) ->addColumn(...Hooks::filter( "rest.generator::column.type->actions", [], [], FALSE, "contacts/{id}/addresses" ))->get() ->addButton(...Hooks::filter( "rest.generator::action.name->edit", [], "contacts/{$origin}/addresses", "hashid" )) ->addButton(...Hooks::filter( "rest.generator::action.name->delete", [], "contacts/{$origin}/addresses", "hashid" )) ; return $table; } } /** Datei: plugins/contacts/library/ARUNOX/Plugins/Contacts/Addresses/Primary.php **/ Primary::class, "status" => Attribute\Status::class, "date_create" => Attribute\DateTime::class, "date_edit" => Attribute\DateTime::class, ]; /* ### PUBLIC FUNCTIONS ######################################### # */ public function toggleStatus( bool $save = FALSE ) { $this->status->toggle(); if( $save ) $this->save(); } public function togglePrimary( bool $save = FALSE ) { $this->is_primary->toggle(); if( $save ) $this->save(); } } /** Datei: plugins/contacts/library/ARUNOX/Plugins/Contacts/Contacts/API/v1/Routes.php **/ * @copyright 2025 ARUNOX * @version 1.1.0 * * @since 1.0.0 File is created */ namespace ARUNOX\Plugins\Contacts\Contacts\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 ############################## # */ } } /** Datei: plugins/contacts/library/ARUNOX/Plugins/Contacts/Contacts/API/v1/Controller.php **/ * @copyright 2025 ARUNOX * @version 1.1.0 * * @since 1.0.0 File is created */ namespace ARUNOX\Plugins\Contacts\Contacts\API\v1; use ARUNOX\HTTP; use ARUNOX\Core\Hooks; use ARUNOX\Plugins\REST; use ARUNOX\Plugins\Logs; use ARUNOX\Plugins\Contacts; use ARUNOX\API\BaseController; use ARUNOX\Database\BaseEntity; class Controller extends BaseController { /* ### VARIABLES ################################################ # */ protected static array $NOTIFY = [ "notfound" => "Kontakt nicht gefunden", "saved" => "Kontakt wurde erfolgreich gespeichert", "deleted" => "Kontakt wurde erfolgreich gelöscht", "created" => "Kontakt wurde erfolgreich erstellt", "statuschanged.0" => "Kontakt wurde erfolgreich deaktiviert", "statuschanged.1" => "Kontakt wurde erfolgreich aktiviert", "notcreated" => "Kontakt konnte nicht erstellt werden", "notsaved" => "Kontakt konnte nicht gespeichert werden", ]; /* ### PUBLIC GET FUNCTIONS ##################################### # */ /** * @api * @method GET * * @route.path /contacts/{hashid}/contacts * @route.description Listet alle Kontakte */ public static function getAllOwn( string $origin ) : array { return Contacts\Model::getByContact( $origin ); } /** * @api * @method GET * * @route.path /contacts/{hashid}/contacts/{hashid} * @route.description Gibt einen einzelnen Kontakts anhand der ID zurück */ public static function get( string $origin, string $hashid ) : BaseEntity | HTTP\Response { if( Contacts\Model::isSubContact( $hashid, $origin ) ) { if( $result = Contacts\Model::get( $hashid ) ) return $result; } return REST\Response::autoResponse( 404, static::getNotify("notfound") ); } /* ### PUBLIC SAVE FUNCTIONS #################################### # */ /** * @api * @method PUT * * @route.path /contacts/{hashid}/contacts/{hashid} * @route.description Speichert Änderungen an einem bestehenden Kontakts */ public static function save( string $origin, string $hashid, array $data ) : HTTP\Response { if( Contacts\Model::isSubContact( $hashid, $origin ) ) { return Contacts\API\v1\Controller::save( $hashid, $data ); } return REST\Response::autoResponse( 404, static::getNotify("notfound") ); } /** * @api * @method POST * * @route.path /contacts/{hashid}/contacts * @route.description Erstellt einen neuen Kontakt */ public static function create( string $origin, array $data ) : HTTP\Response { if( $hashid = Contacts\Model::save( $data ) ) { $result = Contacts\Model::get( $hashid ); return REST\Response::autoResponse( 200, static::getNotify("created"), [ "data" => $result ] ); } return REST\Response::autoResponse( 500, static::getNotify("notfound") ); } /** * @api * @method DELETE * * @route.path /contacts/{hashid}/contacts/{hashid} * @route.description Löscht einen Kontakt anhand der ID */ public static function delete( string $origin, string $hashid ) : HTTP\Response { if( Contacts\Model::isSubContact( $hashid, $origin ) ) { return Contacts\API\v1\Controller::delete( $hashid ); } return REST\Response::autoResponse( 500, static::getNotify("notfound") ); } /** * @api * @method PATCH * * @route.path /contacts/{hashid}/contacts/{hashid}/status * @route.description Wechselt den Status (aktiv/inaktiv) eines Kontakts */ public static function toggleStatus( int|string $origin, int|string $hashid ) : HTTP\Response { if( Contacts\Model::isSubContact( $hashid, $origin ) ) { return Contacts\API\v1\Controller::toggleStatus( $hashid ); } return REST\Response::autoResponse( 404, static::getNotify("notfound") ); } /** * @api * @method PATCH * * @route.path /contacts/{hashid}/contacts/{hashid}/invoice * @route.description Wechselt den Status (aktiv/inaktiv) eines Kontakts */ public static function toggleInvoice( int|string $origin, int|string $hashid ) : HTTP\Response { if( Contacts\Model::isSubContact( $hashid, $origin ) ) { return Contacts\API\v1\Controller::toggleInvoice( $hashid ); } return REST\Response::autoResponse( 404, static::getNotify("notfound") ); } /* ### PUBLIC VALIDATE FUNCTIONS ################################ # */ /* ### PUBLIC REST FUNCTIONS #################################### # */ /* ### PUBLIC REST RESPONSE FUNCTIONS ########################### # */ /** * @internal rest * @method PUT * * @route.path /contacts/{hashid}/contacts/{hashid} * @route.description REST-Antwort nach dem Speichern eines Kontakts */ public static function restResponseSave( int|string $origin, int|string $hashid, array $data ) : HTTP\Response { $result = static::save( $origin, $hashid, $data ); if( $result->isStatus( 200 ) ) { $data = Contacts\Model::get( $hashid ); REST\Response::closeModals(); REST\Response::addUpdater( [ "data/table/row", "/api/v1/contacts/{hashid}/contacts", $hashid ], $data ); } return static::restResponse( $result ); } /** * @internal rest * @method POST * * @route.path /contacts/{hashid}/contacts * @route.description REST-Antwort nach dem Erstellen eines Kontakts (inkl. Notifikation, Redirect etc.) */ public static function restResponseCreate( int|string $origin, array $data ) : HTTP\Response { $result = static::create( $origin, $data ); if( $result->isStatus( 200 ) ) { REST\Response::closeModals(); REST\Response::redirect( "/contacts/{hashid}" ); } return static::restResponse( $result ); } /** * @internal rest * @method DELETE * * @route.path /contacts/{hashid}/contacts/{hashid} * @route.description REST-Antwort nach dem Löschen eines Kontakts */ public static function restResponseDelete( int|string $origin, int|string $hashid ) : HTTP\Response { REST\Response::closeModals(); $result = static::delete( $origin, $hashid ); if( $result->isStatus( 200 ) ) { REST\Response::redirect( "/contacts/{hashid}" ); } return static::restResponse( $result ); } /** * @internal rest * @method PATCH * * @route.path /contacts/{hashid}/contacts/{hashid}/status * @route.description REST-Antwort zur Status-Umschaltung eines Kontakts (z. B. für Notifications) */ public static function restResponseToggleStatus( int|string $origin, int|string $hashid ) : HTTP\Response { $result = static::toggleStatus( $origin, $hashid ); if( $result->isStatus( 200 ) ) { $data = $result->getBody("data"); REST\Response::addUpdater( [ "data/table/row", "/api/v1/contacts/{$origin}/contacts", $hashid ], $data ); } return static::restResponse( $result ); } /** * @internal rest * @method PATCH * * @route.path /contacts/{hashid}/contacts/{hashid}/invoice * @route.description REST-Antwort zur Status-Umschaltung eines Kontakts (z. B. für Notifications) */ public static function restResponseToggleInvoice( int|string $origin, int|string $hashid ) : HTTP\Response { $result = static::toggleInvoice( $origin, $hashid ); if( $result->isStatus( 200 ) ) { $data = $result->getBody("data"); REST\Response::addUpdater( [ "data/table/row", "/api/v1/contacts/{$origin}/contacts", $hashid ], $data ); } return static::restResponse( $result ); } /* ### PUBLIC REST CONFIG FUNCTIONS ############################# # */ /** * @internal rest * @method GET * * @route.path /contacts/{hashid}/contacts * @route.description REST-Konfiguration für Kontakt-Tabelle */ public static function restConfigOverview() : REST\Generator\Base\BaseGenerator { return REST\Response::addWrapper( "overview", "Kontakte" ) ->replaceContent( static::restConfigTable() ); } /** * @internal rest * @method GET * * @route.path /contacts/{hashid}/contacts/{hashid} * @route.description REST-Konfiguration für Detailansicht eines Kontakts */ public static function restConfigDetails( int|string $origin, int|string $hashid ) : REST\Generator\Base\BaseGenerator { return REST\Response::addModal( "details", "Kontakt bearbeiten" ) ->get() ->setApi( "/contacts/{$origin}/contacts/{$hashid}" ) ->setAction( "/contacts/{$origin}/contacts/{$hashid}", "PUT" ) ->addTab( "Kontaktdaten", "contactdata" )->get() ->setIcon( "bi-person-vcard" ) ->addHeadline( "Kontakt", 2 ) ->addField(...Hooks::filter( "rest.generator::control.type->text", [], "company_name", FALSE, "contacts" )) ->addField(...Hooks::filter( "rest.generator::control.type->text", [], "firstname", FALSE, "contacts" )) ->addField(...Hooks::filter( "rest.generator::control.type->text", [], "lastname", FALSE, "contacts" )) ->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 /contacts/{hashid}/contacts/create * @route.description REST-Konfiguration für das Erstellen eines Kontakts (Formular) */ public static function restConfigCreate() : REST\Generator\Base\BaseGenerator { return REST\Response::addModal( "details", "Kontakt erstellen" ) ->get() ->setAction( "/contacts/{hashid}/contacts", "POST" ) ->addButton(...Hooks::filter( "rest.generator::button.type->submit", [], "Erstellen", "contacts" )) ->addField(...Hooks::filter( "rest.generator::control.type->text", [], "name", TRUE, "contacts" )); } /** * @internal rest * @method GET * * @route.path /contacts/{hashid}/contacts/{hashid}/delete * @route.description REST-Konfiguration für die Lösch-Bestätigung eines Kontakts */ public static function restConfigDeleteOwn( int|string $origin, int|string $hashid ) : REST\Generator\Base\BaseGenerator { return REST\Response::addModal( "details", "Kontakt Löschen" ) ->setSize( REST\Wrapper\Modal\Size::sm ) ->get() ->setAction( "/contacts/{hashid}/contacts/{$hashid}", "DELETE" ) ->addText( "Möchtest du wirklich den Datensatz (#{$hashid}) löschen? " ) ->addButton(...Hooks::filter( "rest.generator::button.type->cancel", [], NULL, "contacts" )) ->addButton(...Hooks::filter( "rest.generator::button.type->delete", [], NULL, "contacts" )); } /* ### PUBLIC REST EXTENSION FUNCTIONS ########################## # */ public static function restConfigTable( int|string $origin ) : REST\Generator\Base\BaseGenerator { $table = Contacts\API\v1\Controller::restConfigTable()->top() ->setApi( "/contacts/{$origin}/contacts" ) ->setAction( "/contacts/{$origin}/contacts/{hashid}" ) ->getColumn( "status")->setAction( "/contacts/{$origin}/contacts/{hashid}/status", "PATCH" )->parent() ->getColumn( "invoice")->setAction( "/contacts/{$origin}/contacts/{hashid}/invoice", "PATCH" )->parent() ; $actions = $table->top()->getColumn("actions")->getConfig("buttons"); foreach( $actions as $button ) { $action = $button->getAction(); if( preg_match( "/^\/contacts\/\{hashid\}/", $action["route"] ) ) { $action["route"] = preg_replace( "/^\/contacts\/\{hashid\}/", "/contacts/{$origin}/contacts/{hashid}", $action["route"] ); $button->setAction( ...$action ); } // show( $action, FALSE ); } return $table; } } /** Datei: plugins/contacts/library/ARUNOX/Plugins/Contacts/Entity.php **/ status->toggle(); if( $save ) $this->save(); } public function toggleInvoice( bool $save = FALSE ) { $this->invoice->toggle(); if( $save ) $this->save(); } } /** Datei: plugins/contacts/library/ARUNOX/Plugins/Contacts/Invoice.php **/