From 854db568bf95df079314db5eddc9b4de3fe46fa6 Mon Sep 17 00:00:00 2001 From: Sylvain Date: Thu, 10 Jun 2021 12:04:00 +0200 Subject: [PATCH] Ability to configure the prefix of the payment-schedules' files --- CHANGELOG.md | 1 + .../javascript/controllers/admin/invoices.js | 40 +++++++++++++++++++ app/frontend/src/javascript/router.js | 2 +- .../src/stylesheets/modules/invoice.scss | 32 +++++++++++++++ .../templates/admin/invoices/settings.html | 8 ++++ .../invoices/settings/editSchedulePrefix.html | 20 ++++++++++ config/locales/app.admin.en.yml | 2 + config/locales/app.admin.fr.yml | 2 + 8 files changed, 106 insertions(+), 1 deletion(-) create mode 100644 app/frontend/templates/admin/invoices/settings/editSchedulePrefix.html diff --git a/CHANGELOG.md b/CHANGELOG.md index 4a301cc4e..3a031a58d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -16,6 +16,7 @@ - Validate on server side the reservation of slots restricted to subscribers − Unified and documented upgrade exit codes - During setup, ask for the name of the external network and create it, if it does not already exists +- Ability to configure the prefix of the payment-schedules' files - Fix a bug: cannot select the recurrence end date on Safari or Internet Explorer - Fix a bug: build status badge is not working - Fix a bug: unable to set date formats during installation diff --git a/app/frontend/src/javascript/controllers/admin/invoices.js b/app/frontend/src/javascript/controllers/admin/invoices.js index 87871ea49..4cff1dc62 100644 --- a/app/frontend/src/javascript/controllers/admin/invoices.js +++ b/app/frontend/src/javascript/controllers/admin/invoices.js @@ -61,6 +61,14 @@ Application.Controllers.controller('InvoicesController', ['$scope', '$state', 'I templateUrl: '/admin/invoices/settings/editPrefix.html' }; + // Payment Schedule PDF filename settings (and example) + $scope.scheduleFile = { + prefix: settings.payment_schedule_prefix, + nextId: 11, + date: moment().format('DDMMYYYY'), + templateUrl: '/admin/invoices/settings/editSchedulePrefix.html' + }; + // Invoices parameters $scope.invoice = { logo: null, @@ -529,6 +537,38 @@ Application.Controllers.controller('InvoicesController', ['$scope', '$state', 'I }); }; + /** + * Open a modal dialog allowing the user to edit the prefix of the payment schedules file names + */ + $scope.openEditSchedulePrefix = function () { + const modalInstance = $uibModal.open({ + animation: true, + templateUrl: $scope.scheduleFile.templateUrl, + size: 'lg', + resolve: { + model () { return $scope.scheduleFile.prefix; } + }, + controller: ['$scope', '$uibModalInstance', 'model', function ($scope, $uibModalInstance, model) { + $scope.model = model; + $scope.ok = function () { $uibModalInstance.close($scope.model); }; + $scope.cancel = function () { $uibModalInstance.dismiss('cancel'); }; + }] + }); + + modalInstance.result.then(function (model) { + Setting.update({ name: 'payment_schedule_prefix' }, { value: model }, function (data) { + $scope.scheduleFile.prefix = model; + return growl.success(_t('app.admin.invoices.prefix_successfully_saved')); + } + , function (error) { + if (error.status === 304) return; + + growl.error(_t('app.admin.invoices.an_error_occurred_while_saving_the_prefix')); + console.error(error); + }); + }); + }; + /** * Callback to save the value of the text zone when editing is done */ diff --git a/app/frontend/src/javascript/router.js b/app/frontend/src/javascript/router.js index 0a0f3ef36..6625b81c1 100644 --- a/app/frontend/src/javascript/router.js +++ b/app/frontend/src/javascript/router.js @@ -874,7 +874,7 @@ angular.module('application.router', ['ui.router']) "'accounting_VAT_code', 'accounting_VAT_label', 'accounting_subscription_code', 'accounting_subscription_label', " + "'accounting_Machine_code', 'accounting_Machine_label', 'accounting_Training_code', 'accounting_Training_label', " + "'accounting_Event_code', 'accounting_Event_label', 'accounting_Space_code', 'accounting_Space_label', " + - "'payment_gateway', 'accounting_Error_code', 'accounting_Error_label', " + + "'payment_gateway', 'accounting_Error_code', 'accounting_Error_label', 'payment_schedule_prefix', " + "'feature_tour_display', 'online_payment_module', 'stripe_public_key', 'stripe_currency', 'invoice_prefix']" }).$promise; }], diff --git a/app/frontend/src/stylesheets/modules/invoice.scss b/app/frontend/src/stylesheets/modules/invoice.scss index 6fb608abc..dafdb538c 100644 --- a/app/frontend/src/stylesheets/modules/invoice.scss +++ b/app/frontend/src/stylesheets/modules/invoice.scss @@ -30,6 +30,38 @@ } } +.schedule-file { + text-align: center; + line-height: 4em; + margin-top: 2em; + + .fa-stack { + position: relative; + width: 60px; + height: 75px; + + .fa-file-pdf { + font-size: 4em; + vertical-align: middle; + position: absolute; + background-color: white; + text-shadow: 0 0 2px white; + } + } + + + .filename { + font-size: 1.1em; + vertical-align: middle; + margin-left: 1em; + + .prefix:hover { + background-color: $yellow; + overflow-x: hidden; + } + } +} + .invoice-placeholder { width: 80%; max-width: 800px; diff --git a/app/frontend/templates/admin/invoices/settings.html b/app/frontend/templates/admin/invoices/settings.html index 53c8b5d47..83260986a 100644 --- a/app/frontend/templates/admin/invoices/settings.html +++ b/app/frontend/templates/admin/invoices/settings.html @@ -92,6 +92,14 @@ {{file.prefix}}-{{file.nextId}}_{{file.date}}.pdf +
+

{{ 'app.admin.invoices.schedule_filename' }}

+ + + + + {{scheduleFile.prefix}}-{{scheduleFile.nextId}}_{{scheduleFile.date}}.pdf +