Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision 81f99fbd

Von Moritz Bunkus vor mehr als 2 Jahren hinzugefügt

  • ID 81f99fbda636506147299bedcfa26abf98e1c85b
  • Vorgänger 2590383a
  • Nachfolger be3e7212

Drucken: Variablen in Positionen interpolieren

Alle Variablen, die in Schleifen ausgegeben
werden (z.B. Artikelbeschreibung, Langtext, aber auch die Steuern)
werden nun ebenfalls der Interpolation unterzogen, sodass
z.B. in wiederkehrenden Rechnungen <%current_quarter%> in
Artikelbeschreibungen genutzt werden kann — aber auch Belegfelder.

Unterschiede anzeigen:

SL/BackgroundJob/CreatePeriodicInvoices.pm
143 143
  my $sub_fmt  = lc($params{attribute_format} // 'text');
144 144

  
145 145
  my ($start_tag, $end_tag) = $sub_fmt eq 'html' ? ('&lt;%', '%&gt;') : ('<%', '%>');
146
  my @invoice_keys          = $params{invoice} ? (map { $_->name } $params{invoice}->meta->columns) : ();
147
  my $key_name_re           = join '|', map { quotemeta } (@invoice_keys, keys %{ $params{vars} });
146 148

  
147
  $str =~ s{ ${start_tag} ([a-z0-9_]+) ( \s+ format \s*=\s* (.*?) \s* )? ${end_tag} }{
149
  $str =~ s{ ${start_tag} ($key_name_re) ( \s+ format \s*=\s* (.*?) \s* )? ${end_tag} }{
148 150
    my ($key, $format) = ($1, $3);
149 151
    $key               = $::locale->unquote_special_chars('html', $key) if $sub_fmt eq 'html';
150 152
    my $new_value;
SL/DB/MetaSetup/Default.pm
131 131
  pdonumber                                 => { type => 'text' },
132 132
  ponumber                                  => { type => 'text' },
133 133
  precision                                 => { type => 'numeric', default => '0.01', not_null => 1, precision => 15, scale => 5 },
134
  print_interpolate_variables_in_positions  => { type => 'boolean', default => 'true', not_null => 1 },
134 135
  produce_assembly_same_warehouse           => { type => 'boolean', default => 'true' },
135 136
  produce_assembly_transfer_service         => { type => 'boolean', default => 'false' },
136 137
  profit_carried_forward_chart_id           => { type => 'integer' },
SL/Form.pm
3214 3214
    today     => DateTime->today,
3215 3215
  };
3216 3216

  
3217
  if ($defaults->print_interpolate_variables_in_positions) {
3218
    $self->substitute_placeholders_in_template_arrays({ field => 'description', type => 'text' }, { field => 'longdescription', type => 'html' });
3219
  }
3220

  
3221
  return $self;
3222
}
3223

  
3224
sub substitute_placeholders_in_template_arrays {
3225
  my ($self, @fields) = @_;
3226

  
3227
  foreach my $spec (@fields) {
3228
    $spec     = { field => $spec, type => 'text' } if !ref($spec);
3229
    my $field = $spec->{field};
3230

  
3231
    next unless exists $self->{TEMPLATE_ARRAYS} && exists $self->{TEMPLATE_ARRAYS}->{$field};
3232

  
3233
    my $tag_start = $spec->{type} eq 'html' ? '&lt;%' : '<%';
3234
    my $tag_end   = $spec->{type} eq 'html' ? '%&gt;' : '%>';
3235
    my $formatter = $spec->{type} eq 'html' ? sub { $::locale->quote_special_chars('html', $_[0] // '') } : sub { $_[0] };
3236

  
3237
    $self->{TEMPLATE_ARRAYS}->{$field} = [
3238
      apply { s{${tag_start}(.+?)${tag_end}}{ $formatter->($self->{$1}) }eg }
3239
        @{ $self->{TEMPLATE_ARRAYS}->{$field} }
3240
    ];
3241
  }
3242

  
3217 3243
  return $self;
3218 3244
}
3219 3245

  
bin/mozilla/io.pl
1570 1570
    today     => DateTime->today,
1571 1571
  };
1572 1572

  
1573
  if ($defaults->print_interpolate_variables_in_positions) {
1574
    $form->substitute_placeholders_in_template_arrays({ field => 'description', type => 'text' }, { field => 'longdescription', type => 'html' });
1575
  }
1576

  
1573 1577
  $form->parse_template(\%myconfig);
1574 1578

  
1575 1579
  $form->{callback} = "";
doc/changelog
33 33
- Pflichtenhefte: wenn in einem Auftrag, das mit einem Pflichtenheft
34 34
  verknüpft ist, ein Projekt ausgewählt, so wird dieses Projekt auch
35 35
  automatisch beim verknüpften Pflichtenheft eingetragen.
36
- Druckvorlagen: die in Positionen verwendeten Variablen können nun
37
  Platzhalter enthalten, die vom Beleg selber stammen. So könnte
38
  z.B. in der Artikelbeschreibung automatisch die Rechnungsnummer
39
  ersetzt werden. Beispiel: »Abrechnungszeitraum bis <%invnumber%>«
36 40

  
37 41
Bugfixes (Tracker: https://www.kivitendo.de/redmine):
38 42

  
locale/de/all
1798 1798
  'Internal Phone List'         => 'Interne Telefonliste',
1799 1799
  'Internal comment'            => 'Interne Bemerkungen',
1800 1800
  'Internet'                    => 'Internet',
1801
  'Interpolate variables in texts of positions' => 'Variablen in Positionstexten interpolieren',
1801 1802
  'Into bin'                    => 'Eingelagert',
1802 1803
  'Intra-Community supply'      => 'Gelangensbestätigung',
1803 1804
  'Introduction of clients'     => 'Einführung von Mandanten',
......
4150 4151
  'What this template contains' => 'Was diese Vorlage enthält',
4151 4152
  'What type of item is this?'  => 'Was ist dieser Artikel?',
4152 4153
  'When converting a requirement spec into a quotation or an oder each section gets converted into a line position in the new record. This is the article used by default for this conversion.' => 'Wenn ein Pflichtenheft in ein Angebot oder Auftrag umgewandelt wird, wird für jeden Abschnitt eine Position im neuen Beleg angelegt. Dies ist der Artikel, der standardmäßig bei dieser Umwandlung genutzt wird.',
4154
  'Whether or not to replace variable placeholders such as "<%invdate%>" in texts in positions such as the part description by the record\'s actual value' => 'Ob Variablenplatzhalter wie z.B. <%invdate%> in Positionstexten wie der Artikelbeschreibung durch den tatsächlichen Wert aus dem Beleg ersetzt werden sollen',
4153 4155
  'Which is located at doc/kivitendo-Dokumentation.pdf. Click here: ' => 'Diese befindet sich unter doc/kivitendo-Dokumentation.pdf. Klicken Sie hier:',
4154 4156
  'With Attachments'            => 'Journal mit Anhängen',
4155 4157
  'With Extension Of Time'      => 'mit Dauerfristverlängerung',
sql/Pg-upgrade2/defaults_print_interpolate_variables_in_positions.sql
1
-- @tag: defaults_print_interpolate_variables_in_positions
2
-- @description: Drucken: Variablen in Belegpositionen interpolieren (abschaltbar via Mandantenkonfiguration)
3
-- @depends: release_3_5_8
4
ALTER TABLE defaults
5
ADD COLUMN print_interpolate_variables_in_positions BOOLEAN
6
DEFAULT TRUE NOT NULL;
templates/webpages/client_config/_miscellaneous.html
99 99
   </td>
100 100
  </tr>
101 101

  
102
  <tr>
103
   <td align="right">[% LxERP.t8('Interpolate variables in texts of positions') %]</td>
104
   <td>[% L.yes_no_tag('defaults.print_interpolate_variables_in_positions', SELF.defaults.print_interpolate_variables_in_positions) %]</td>
105
   <td>[% LxERP.t8('Whether or not to replace variable placeholders such as "<%invdate%>" in texts in positions such as the part description by the record\'s actual value') %]</td>
106
  </tr>
107

  
102 108
  <tr><td class="listheading" colspan="4">[% LxERP.t8("Currencies") %]</td></tr>
103 109

  
104 110
  <tr>

Auch abrufbar als: Unified diff