diff --git a/plugins/barcode-generator/README.md b/plugins/barcode-generator/README.md index 973c17fb..2d29e5d3 100644 --- a/plugins/barcode-generator/README.md +++ b/plugins/barcode-generator/README.md @@ -4,7 +4,8 @@ This plugin generates SVG image of one or two dimensional barcode which can be i ## Templates implementation You can add barcode image into template code e.g.: ```` -> Server must be secured with valid certificate for https request. +> Make sure you have valid SSL certificate, otherwise the barcode won't load when used in PDF or email templates. +> In PDF templates only, you can use `http://localhost/crm/...` as an alternative. ## Required parameters - `token` - Security token from the plugin configuration in the CRM diff --git a/plugins/barcode-generator/barcode-generator.zip b/plugins/barcode-generator/barcode-generator.zip index 88843a99..be4d0001 100644 Binary files a/plugins/barcode-generator/barcode-generator.zip and b/plugins/barcode-generator/barcode-generator.zip differ diff --git a/plugins/barcode-generator/src/hook_install.php b/plugins/barcode-generator/src/hook_install.php index 691b624c..4e642547 100644 --- a/plugins/barcode-generator/src/hook_install.php +++ b/plugins/barcode-generator/src/hook_install.php @@ -2,20 +2,31 @@ declare(strict_types=1); -use Monolog\Handler\StreamHandler; -use Monolog\Logger; use UBarcode\Service\TokenInstaller; +use Ubnt\UcrmPluginSdk\Service\PluginConfigManager; use Ubnt\UcrmPluginSdk\Service\PluginLogManager; +use Ubnt\UcrmPluginSdk\Service\UcrmOptionsManager; chdir(__DIR__); require __DIR__ . '/vendor/autoload.php'; -$logger = new Logger('UBarcode'); -$logger->pushHandler(new StreamHandler('data/plugin.log')); - -$logManager = PluginLogManager::create(); - (new TokenInstaller())->install(); -$logger->info('Security token has been generated. Use it as a part of request string.'); +$configManager = PluginConfigManager::create(); +$config = $configManager->loadConfig(); +$ucrmOptionsManager = UcrmOptionsManager::create(); +$ucrmOptions = $ucrmOptionsManager->loadOptions(); + +$logManager = PluginLogManager::create(); +$logManager->appendLog('Security token has been automatically generated. You must use it as a part of the URL.'); +$logManager->appendLog(''); +$logManager->appendLog('Example usage:'); +$logManager->appendLog( + sprintf( + '', + $ucrmOptions->ucrmPublicUrl, + $config['token'] ?? '' + ) +); +$logManager->appendLog('');