]> wagnertech.de Git - mfinanz.git/commitdiff
Benutzerdef. Variablen f. Waren per Voreinstellung für Belege aktivieren/deaktivieren.
authorBernd Bleßmann <bernd@kivitendo-premium.de>
Mon, 4 Aug 2014 10:58:59 +0000 (12:58 +0200)
committerBernd Bleßmann <bernd@kivitendo-premium.de>
Wed, 6 Aug 2014 13:15:32 +0000 (15:15 +0200)
SL/CVar.pm
SL/Controller/CustomVariableConfig.pm
locale/de/all
locale/en/all
templates/webpages/custom_variable_config/form.html
templates/webpages/custom_variable_config/list.html

index b15f82be2e6e4ebcb0f08fd82278df45a7bbc687..99e46726b5b15e60a0931688950bcf52b14a964a 100644 (file)
@@ -132,6 +132,8 @@ sub get_custom_variables {
       $act_var = $h_var->fetchrow_hashref();
 
       $valid = $self->get_custom_variables_validity(config_id => $cvar->{id}, trans_id => $params{trans_id});
+    } else {
+      $valid = !$cvar->{flag_defaults_to_invalid};
     }
 
     if ($act_var) {
@@ -145,7 +147,7 @@ sub get_custom_variables {
                      :                                $act_var->{text_value};
       $cvar->{valid} = $valid;
     } else {
-      $cvar->{valid}  =  1;
+      $cvar->{valid} = $valid // 1;
 
       if ($cvar->{type} eq 'date') {
         if ($cvar->{default_value} eq 'NOW') {
index 28ed17929df27c705737d5c6db0f8961926dd4b4..a56740b8f7d4528537bf2f91ff6f88dfbbcb3236 100644 (file)
@@ -7,6 +7,7 @@ use parent qw(SL::Controller::Base);
 use List::Util qw(first);
 
 use SL::DB::CustomVariableConfig;
+use SL::DB::CustomVariableValidity;
 use SL::Helper::Flash;
 use SL::Locale::String;
 use Data::Dumper;
@@ -103,7 +104,7 @@ sub action_reorder {
 
   SL::DB::CustomVariableConfig->reorder_list(@{ $::form->{cvarcfg_id} || [] });
 
-  $self->render(\'', { type => 'json' });
+  $self->render(\'', { type => 'json' }); # ' make emacs happy
 }
 
 #
@@ -179,10 +180,33 @@ sub create_or_update {
     return;
   }
 
+  my $dbh = $self->config->db;
+  $dbh->begin_work;
+
   $self->config->save;
+  $self->_set_cvar_validity() if $is_new;
+
+  $dbh->commit;
 
   flash_later('info', $is_new ? t8('The custom variable has been created.') : t8('The custom variable has been saved.'));
   $self->redirect_to(action => 'list', module => $self->module);
 }
 
+sub _set_cvar_validity {
+  my ($self) = @_;
+
+  my $flags = {
+    map { split m/=/, $_, 2 }
+    split m/:/, ($self->config->flags || '')
+  };
+
+  # nothing to do to set valid
+  return if !$flags->{defaults_to_invalid};
+
+  my $all_parts  = SL::DB::Manager::Part->get_all(where => [ or => [ obsolete => 0, obsolete => undef ] ]);
+  foreach my $part (@{ $all_parts }) {
+    SL::DB::CustomVariableValidity->new(config_id => $self->config->id, trans_id => $part->id)->save;
+  }
+}
+
 1;
index f7f3ec3f09def919a776ca57e0d1f0591616695e..6d5b183b4148de9cf36d3f5d23349123dcc511b1 100755 (executable)
@@ -52,6 +52,7 @@ $self->{texts} = {
   'A transaction description is required.' => 'Die Vorgangsbezeichnung muss eingegeben werden.',
   'A unit with this name does already exist.' => 'Eine Einheit mit diesem Namen existiert bereits.',
   'A valid taxkey is missing!'  => 'Einen gültiger Steuerschlüssel fehlt!',
+  'A variable marked as \'Deactivate by default\' isn\'t automatically added to all articles, and has to be explicitly added for each desired article in its master data tab. Only then can the variable be used for that article in the records.' => 'Eine als \'Deaktiviert als Voreinstellung\' markierte Variable wird nicht automatisch bei allen Artikeln hinzugefügt, sondern muß explizit für jeden gewünschten Artikel in den Stammdaten aktiviert werden. Erst danach ist die Variable für den Artikel in Belegen bearbeitbar.',
   'A variable marked as \'editable\' can be changed in each quotation, order, invoice etc.' => 'Eine als \'Bearbeitbar\' markierte Variable kann in jedem Angebot, Auftrag, jeder Rechnung etc für jede Position geändert werden.',
   'ADDED'                       => 'Hinzugefügt',
   'AP'                          => 'Einkauf',
@@ -720,6 +721,7 @@ $self->{texts} = {
   'Date the payment is due with discount' => 'Das Datum, bis die Rechnung unter Abzug von Skonto bezahlt werden kann',
   'Datevautomatik'              => 'Datev-Automatik',
   'Datum von'                   => 'Datum von',
+  'Deactivate by default'       => 'Deaktiviert als Voreinstellung',
   'Debit'                       => 'Soll',
   'Debit (one letter abbreviation)' => 'S',
   'Debit Account'               => 'Sollkonto',
index 30a729adc6214f290b151b95ae6ec3d3f1109d27..ee05e7fbe678ece0654f0a44e767322117efb4a3 100644 (file)
@@ -45,6 +45,7 @@ $self->{texts} = {
   'A special character is required (valid characters: #1).' => '',
   'A unit with this name does already exist.' => '',
   'A valid taxkey is missing!'  => '',
+  'A variable marked as \'Deactivate by default\' isn\'t automatically added to all articles, and has to be explicitly added for each desired article in its master data tab. Only then can the variable be used for that article in the records.' => '',
   'A variable marked as \'editable\' can be changed in each quotation, order, invoice etc.' => '',
   'ADDED'                       => '',
   'AP'                          => 'Purchases',
@@ -633,6 +634,7 @@ $self->{texts} = {
   'Date the payment is due with discount' => '',
   'Datevautomatik'              => '',
   'Datum von'                   => '',
+  'Deactivate by default'       => '',
   'Debit'                       => '',
   'Debit (one letter abbreviation)' => '',
   'Debit Account'               => '',
index 2703cdc1d13999d06dcd501cdcdab85f50833557..a34dd5da151a459931c705a1539f2c9357f37e7e 100644 (file)
      [% L.radio_button_tag('config.flag_editable', value='0', id='config.flag_editable_0', label=LxERP.t8('No'),  checked=(SELF.flags.editable ? '' :  1)) %]
     </td>
    </tr>
+   <tr data-show-for="IC"[% UNLESS SELF.module == 'IC' %] style="display: none;"[% END %]>
+    <td align="right">[% 'Deactivate by default' | $T8 %]<sup><span class="small-text">(7)</span></sup></td>
+    <td>
+     [% L.radio_button_tag('config.flag_defaults_to_invalid', value='1', id='config.flag_defaults_to_invalid_1', label=LxERP.t8('Yes'), checked=(SELF.flags.defaults_to_invalid ?  1 : '')) %]
+     [% L.radio_button_tag('config.flag_defaults_to_invalid', value='0', id='config.flag_defaults_to_invalid_0', label=LxERP.t8('No'),  checked=(SELF.flags.defaults_to_invalid ? '' :  1)) %]
+    </td>
+   </tr>
   </table>
  </p>
 
   [% 'Otherwise the variable is only available for printing.' | $T8 %]
  </p>
 
+ <p data-show-for="IC"[% UNLESS SELF.module == 'IC' %] style="display: none;"[% END %]>
+  (7)
+
+  [%- 'A variable marked as \'Deactivate by default\' isn\'t automatically added to all articles, and has to be explicitly added for each desired article in its master data tab. Only then can the variable be used for that article in the records.' | $T8 %]
+ </p>
+
 </form>
 
 <script type="text/javascript">
index 1f264295f7585a94bbbfd3796bbad63145554839..349674b17b0cccf5bcfef32efe5c19ed94888e32 100644 (file)
@@ -19,6 +19,7 @@
     <th width="20%">[% 'Includeable in reports' | $T8 %]</th>
     [%- IF SELF.module == 'IC' %]
      <th width="20%">[% 'Editable' | $T8 %]</th>
+     <th width="20%">[% 'Deactivate by default' | $T8 %]</th>
     [%- END %]
    </tr>
   </thead>
@@ -39,6 +40,7 @@
 
      [%- IF SELF.module == 'IC' %]
       <td>[%- IF cfg.flags.match('editable=1') %][% 'Yes' | $T8 %][%- ELSE %][% 'No' | $T8 %][%- END %]</td>
+      <td>[%- IF cfg.flags.match('defaults_to_invalid=1') %][% 'Yes' | $T8 %][%- ELSE %][% 'No' | $T8 %][%- END %]</td>
      [%- END %]
     </tr>
     [%- END %]