From b731522bcde6fa96371ab661b7f68097a325d296 Mon Sep 17 00:00:00 2001 From: Dennis Eichhorn Date: Fri, 12 Feb 2021 18:00:25 +0100 Subject: [PATCH] start drafting template handling --- Admin/Install/Media.php | 9 ++++++++- Controller/ApiController.php | 3 +++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/Admin/Install/Media.php b/Admin/Install/Media.php index c4f4b30..df96a81 100644 --- a/Admin/Install/Media.php +++ b/Admin/Install/Media.php @@ -14,6 +14,8 @@ declare(strict_types=1); namespace Modules\Billing\Admin\Install; +use Model\CoreSettings; +use Model\Setting; use phpOMS\DataStorage\Database\DatabasePool; /** @@ -38,6 +40,11 @@ class Media */ public static function install(string $path, DatabasePool $dbPool) : void { - \Modules\Media\Admin\Installer::installExternal($dbPool, ['path' => __DIR__ . '/Media.install.json']); + $media = \Modules\Media\Admin\Installer::installExternal($dbPool, ['path' => __DIR__ . '/Media.install.json']); + + $defaultTemplate = \reset($result['upload']); + + $setting = new Setting(); + SettingMapper::create($setting->with(0, 'default_template', (string) $defaulTemplate->getId(), 'Billing')); } } diff --git a/Controller/ApiController.php b/Controller/ApiController.php index 655bb63..0590f00 100644 --- a/Controller/ApiController.php +++ b/Controller/ApiController.php @@ -273,6 +273,9 @@ final class ApiController extends Controller { $bill = BillMapper::get($request->getData('id')); + $defaultTemplate = CoreSettings::get(null, 'default_template', self::MODULE_NAME); + $template = CollectionMapper::get((int) $defaultTemplate); + // get default template from database OR get template based on provided request template id // create pdf based on template }