3 use SL::GenericTranslations;
4 use SL::Locale::String qw(t8);
9 # preset_text_$formname will generate a input textarea
10 # and will be preset in $form email dialog if the form name matches
13 salutation_male => t8('Salutation male'),
14 salutation_female => t8('Salutation female'),
15 salutation_general => t8('Salutation general'),
16 salutation_punctuation_mark => t8('Salutation punctuation mark'),
17 preset_text_sales_quotation => t8('Preset email text for sales quotations'),
18 preset_text_sales_order => t8('Preset email text for sales orders'),
19 preset_text_sales_delivery_order => t8('Preset email text for sales delivery orders'),
20 preset_text_invoice => t8('Preset email text for sales invoices'),
21 preset_text_invoice_direct_debit => t8('Preset email text for sales invoices with direct debit'),
22 preset_text_request_quotation => t8('Preset email text for requests (rfq)'),
23 preset_text_purchase_order => t8('Preset email text for purchase orders'),
24 preset_text_periodic_invoices_email_body => t8('Preset email body for periodic invoices'),
25 preset_text_periodic_invoices_email_subject => t8('Preset email subject for periodic invoices'),
29 $main::lxdebug->enter_sub();
31 $main::auth->assert('config');
33 my $form = $main::form;
34 my $locale = $main::locale;
36 $form->get_lists('languages' => 'LANGUAGES');
38 my $translation_list = GenericTranslations->list();
39 my %translations = ();
41 my @types = qw(male female);
43 foreach my $translation (@{ $translation_list }) {
44 $translation->{language_id} ||= 'default';
45 $translations{$translation->{language_id} . '::' . $translation->{translation_type}} = $translation;
48 unshift @{ $form->{LANGUAGES} }, { 'id' => 'default', };
50 foreach my $language (@{ $form->{LANGUAGES} }) {
51 foreach my $type (@types) {
52 $language->{$type} = { };
53 my $translation = $translations{"$language->{id}::greetings::${type}"} || { };
54 $language->{$type} = $translation->{translation};
58 setup_generictranslations_edit_greetings_action_bar();
60 $form->{title} = $locale->text('Edit greetings');
62 print $form->parse_html_template('generictranslations/edit_greetings');
64 $main::lxdebug->leave_sub();
68 $main::lxdebug->enter_sub();
70 $main::auth->assert('config');
72 my $form = $main::form;
73 my $locale = $main::locale;
75 $form->get_lists('languages' => 'LANGUAGES');
77 unshift @{ $form->{LANGUAGES} }, { };
79 my @types = qw(male female);
81 foreach my $language (@{ $form->{LANGUAGES} }) {
82 foreach my $type (@types) {
83 GenericTranslations->save('translation_type' => "greetings::${type}",
84 'translation_id' => undef,
85 'language_id' => $language->{id},
86 'translation' => $form->{"translation__" . ($language->{id} || 'default') . "__${type}"},);
90 $form->{message} = $locale->text('The greetings have been saved.');
94 $main::lxdebug->leave_sub();
97 sub edit_sepa_strings {
98 $main::lxdebug->enter_sub();
100 $main::auth->assert('config');
102 my $form = $main::form;
103 my $locale = $main::locale;
105 $form->get_lists('languages' => 'LANGUAGES');
107 my $translation_list = GenericTranslations->list(translation_type => 'sepa_remittance_info_pfx');
108 my %translations = map { ( ($_->{language_id} || 'default') => $_->{translation} ) } @{ $translation_list };
110 my $translation_list_vc = GenericTranslations->list(translation_type => 'sepa_remittance_vc_no_pfx');
111 my %translations_vc = map { ( ($_->{language_id} || 'default') => $_->{translation} ) } @{ $translation_list_vc };
113 unshift @{ $form->{LANGUAGES} }, { 'id' => 'default', };
115 foreach my $language (@{ $form->{LANGUAGES} }) {
116 $language->{translation} = $translations{$language->{id}};
117 $language->{translation_vc} = $translations_vc{$language->{id}};
120 setup_generictranslations_edit_sepa_strings_action_bar();
122 $form->{title} = $locale->text('Edit SEPA strings');
124 print $form->parse_html_template('generictranslations/edit_sepa_strings');
126 $main::lxdebug->leave_sub();
129 sub save_sepa_strings {
130 $main::lxdebug->enter_sub();
132 $main::auth->assert('config');
134 my $form = $main::form;
135 my $locale = $main::locale;
137 $form->get_lists('languages' => 'LANGUAGES');
139 unshift @{ $form->{LANGUAGES} }, { };
141 foreach my $language (@{ $form->{LANGUAGES} }) {
142 GenericTranslations->save('translation_type' => 'sepa_remittance_info_pfx',
143 'translation_id' => undef,
144 'language_id' => $language->{id},
145 'translation' => $form->{"translation__" . ($language->{id} || 'default')},);
146 GenericTranslations->save('translation_type' => 'sepa_remittance_vc_no_pfx',
147 'translation_id' => undef,
148 'language_id' => $language->{id},
149 'translation' => $form->{"translation__" . ($language->{id} || 'default') . "__vc" },);
152 $form->{message} = $locale->text('The SEPA strings have been saved.');
156 $main::lxdebug->leave_sub();
158 sub edit_email_strings {
159 $main::lxdebug->enter_sub();
161 $main::auth->assert('config');
163 my $form = $main::form;
164 my $locale = $main::locale;
166 $form->get_lists('languages' => 'LANGUAGES');
167 unshift @{ $form->{LANGUAGES} }, { 'id' => 'default', };
169 my (%translations, $translation_list);
170 foreach (keys %mail_strings) {
171 $translation_list = GenericTranslations->list(translation_type => $_);
172 %translations = map { ( ($_->{language_id} || 'default') => $_->{translation} ) } @{ $translation_list };
174 foreach my $language (@{ $form->{LANGUAGES} }) {
175 $language->{$_} = $translations{$language->{id}};
178 setup_generictranslations_edit_email_strings_action_bar();
180 $form->{title} = $locale->text('Edit preset email strings');
181 $::request->{layout}->use_javascript(map { "${_}.js" } qw(ckeditor/ckeditor ckeditor/adapters/jquery));
183 print $form->parse_html_template('generictranslations/edit_email_strings',{ 'MAIL_STRINGS' => \%mail_strings });
185 $main::lxdebug->leave_sub();
188 sub save_email_strings {
189 $main::lxdebug->enter_sub();
191 $main::auth->assert('config');
193 my $form = $main::form;
194 my $locale = $main::locale;
196 $form->get_lists('languages' => 'LANGUAGES');
198 unshift @{ $form->{LANGUAGES} }, { };
199 foreach my $language (@{ $form->{LANGUAGES} }) {
200 foreach (keys %mail_strings) {
201 GenericTranslations->save('translation_type' => $_,
202 'translation_id' => undef,
203 'language_id' => $language->{id},
204 'translation' => $form->{"translation__" . ($language->{id} || 'default') . "__" . $_},
208 $form->{message} = $locale->text('The Mail strings have been saved.');
210 edit_email_strings();
212 $main::lxdebug->leave_sub();
215 sub edit_zugferd_notes {
216 $::auth->assert('config');
218 $::form->get_lists('languages' => 'LANGUAGES');
220 my $translation_list = GenericTranslations->list(translation_type => 'ZUGFeRD/notes');
221 my %translations = map { ( ($_->{language_id} || 'default') => $_->{translation} ) } @{ $translation_list };
223 unshift @{ $::form->{LANGUAGES} }, { 'id' => 'default', };
225 foreach my $language (@{ $::form->{LANGUAGES} }) {
226 $language->{translation} = $translations{$language->{id}};
229 setup_generictranslations_edit_zugferd_notes_action_bar();
231 $::form->{title} = $::locale->text('Edit Factur-X/ZUGFeRD notes');
233 print $::form->parse_html_template('generictranslations/edit_zugferd_notes');
236 sub save_zugferd_notes {
237 $::auth->assert('config');
239 $::form->get_lists('languages' => 'LANGUAGES');
241 unshift @{ $::form->{LANGUAGES} }, { };
243 foreach my $language (@{ $::form->{LANGUAGES} }) {
244 GenericTranslations->save(
245 translation_type => 'ZUGFeRD/notes',
246 translation_id => undef,
247 language_id => $language->{id},
248 translation => $::form->{"translation__" . ($language->{id} || 'default')},
252 $::form->{message} = $::locale->text('The Factur-X/ZUGFeRD notes have been saved.');
254 edit_zugferd_notes();
257 sub setup_generictranslations_edit_greetings_action_bar {
260 for my $bar ($::request->layout->get('actionbar')) {
264 submit => [ '#form', { action => "save_greetings" } ],
265 accesskey => 'enter',
271 sub setup_generictranslations_edit_sepa_strings_action_bar {
274 for my $bar ($::request->layout->get('actionbar')) {
278 submit => [ '#form', { action => "save_sepa_strings" } ],
279 accesskey => 'enter',
285 sub setup_generictranslations_edit_email_strings_action_bar {
288 for my $bar ($::request->layout->get('actionbar')) {
292 submit => [ '#form', { action => "save_email_strings" } ],
293 accesskey => 'enter',
299 sub setup_generictranslations_edit_zugferd_notes_action_bar {
302 for my $bar ($::request->layout->get('actionbar')) {
306 submit => [ '#form', { action => "save_zugferd_notes" } ],
307 accesskey => 'enter',