Some checks failed
CI / PHP 8.4 / mariadb:10.6 (pull_request) Successful in 3m49s
CI / PHP 8.3 / mariadb:10.6 (pull_request) Successful in 3m54s
CI / PHP 8.4 / mariadb:11.4 (pull_request) Successful in 5m27s
CI / PHP 8.3 / mariadb:11.4 (pull_request) Successful in 5m29s
CI / PHP 8.4 / mysql:8.0 (pull_request) Failing after 6m38s
CI / PHP 8.3 / mysql:8.0 (pull_request) Failing after 6m40s
CI / PHP 8.4 / mysql:8.4 (pull_request) Failing after 6m7s
CI / PHP 8.3 / mysql:8.4 (pull_request) Failing after 6m13s
CI / Build-Artefakte aktuell (pull_request) Successful in 1m24s
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
54 lines
2.5 KiB
PHP
54 lines
2.5 KiB
PHP
<?php
|
|
|
|
namespace Inhaus\Plugins\Qm;
|
|
|
|
use App\Dashboard\Widgets;
|
|
use App\Models\User;
|
|
use App\Plugins\Plugin;
|
|
use App\Search\GlobalSearch;
|
|
use App\Support\Abilities;
|
|
use App\Support\Navigation;
|
|
use Illuminate\Support\Facades\Schedule;
|
|
use Inhaus\Plugins\Qm\Models\QmCategory;
|
|
use Inhaus\Plugins\Qm\Text\Ocr;
|
|
use Inhaus\Plugins\Qm\Text\TextExtractor;
|
|
|
|
class QmPlugin extends Plugin
|
|
{
|
|
public function register(): void
|
|
{
|
|
$this->app->make(GlobalSearch::class)->add('qm', 'Qualitätsmanagement', 'shield-check', fn (...$args) => app(QmSearch::class)(...$args), sort: 50);
|
|
|
|
foreach ([QmTree::class, QmAccess::class, Presenter::class, Search::class, Library::class, Reviews::class, Acknowledgements::class, Indexer::class, TextExtractor::class, Ocr::class] as $class) {
|
|
$this->app->singleton($class);
|
|
}
|
|
|
|
$this->app->make(Navigation::class)->add('qm', 'Qualitätsmanagement', '/qm', active: 'qm.*', sort: 55,
|
|
visible: fn (User $user) => $this->app->make(QmAccess::class)->allows($user));
|
|
|
|
// Startseite: noch zu bestätigende QM-Dokumente (nur wenn es welche gibt)
|
|
$this->app->make(Widgets::class)->add('qm.acknowledgements', 'qm::Acknowledgements', 'aside', sort: 15, label: 'QM: Lesebestätigungen',
|
|
props: function (User $user) {
|
|
$open = $this->app->make(Acknowledgements::class)->outstanding($user);
|
|
|
|
return $open->isEmpty() ? null : ['entries' => $open->take(5)->map(fn ($entry) => [
|
|
'id' => $entry->id, 'title' => $entry->title, 'url' => route('qm.view', $entry),
|
|
])->values(), 'total' => $open->count(), 'url' => route('qm.index').'#bestaetigen'];
|
|
});
|
|
|
|
$abilities = $this->app->make(Abilities::class);
|
|
$abilities->define('qm.manage', 'Qualitätsmanagement pflegen (Ordner, Dokumente, Einstellungen)', 'Qualitätsmanagement');
|
|
$abilities->resourceType('qm_category', 'QM-Kategorie', fn () => QmCategory::query()->orderBy('sort')->pluck('name', 'id')->all());
|
|
}
|
|
|
|
public function boot(): void
|
|
{
|
|
// Eingescannte PDFs per Texterkennung durchsuchbar machen (nur wenn eingerichtet).
|
|
Schedule::call(fn () => $this->app->make(Indexer::class)->processOcr())
|
|
->everyTenMinutes()->name('qm-ocr')->withoutOverlapping(30);
|
|
|
|
// Wiedervorlage: fällige Prüfungen melden
|
|
Schedule::call(fn () => $this->app->make(Reviews::class)->notifyDue())
|
|
->dailyAt('07:00')->name('qm-reviews')->withoutOverlapping(30);
|
|
}
|
|
}
|