Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision 36703a86

Von Bernd Blessmann vor etwa 10 Jahren hinzugefügt

  • ID 36703a86a998c7c395f110f94b3b3feebc2a3a80
  • Vorgänger 28f6dabe
  • Nachfolger cd443e24

Warengruppen-Filter f. CVars bei Waren

cherry-pick aus Kundenprojekt und Anpassungen an unstable (hauptsächlich
Umstellung auf Controller)

Conflicts:

SL/CVar.pm
SL/DB/CustomVariableConfig.pm
bin/mozilla/amcvar.pl
bin/mozilla/io.pl
templates/webpages/amcvar/display_cvar_config_form.html
templates/webpages/amcvar/render_inputs_block.html

Unterschiede anzeigen:

SL/CVar.pm
55 55
      }
56 56

  
57 57
      $self->_unpack_flags($config);
58

  
59
      my $cvar_config = SL::DB::CustomVariableConfig->new(id => $config->{id})->load;
60
      @{$config->{'partsgroups'}} = map {$_->id} @{$cvar_config->partsgroups};
61

  
58 62
    }
59 63
    $::form->{CVAR_CONFIGS}->{$params{module}} = $configs;
60 64
  }
......
279 283
  my $myconfig = \%main::myconfig;
280 284
  my $form     = $main::form;
281 285

  
282
  my %options  = ( name_prefix       => "$params{name_prefix}",
283
                   name_postfix      => "$params{name_postfix}",
284
                   hide_non_editable => $params{hide_non_editable},
286
  my %options  = ( name_prefix           => "$params{name_prefix}",
287
                   name_postfix          => "$params{name_postfix}",
288
                   hide_non_editable     => $params{hide_non_editable},
285 289
                   show_disabled_message => $params{show_disabled_message},
286 290
                 );
287 291

  
292
  # should this cvar be filtered by partsgroups?
288 293
  foreach my $var (@{ $params{variables} }) {
294
    if ($var->{flag_partsgroup_filter}) {
295
      if (!$params{partsgroup_id} || (!grep {$params{partsgroup_id} == $_} @{ $var->{partsgroups} })) {
296
        $var->{partsgroup_filtered} = 1;
297
      }
298
    }
299

  
289 300
    $var->{HTML_CODE} = $form->parse_html_template('amcvar/render_inputs',     { var => $var, %options });
290 301
    $var->{VALID_BOX} = $form->parse_html_template('amcvar/render_checkboxes', { var => $var, %options });
291 302
  }
SL/Controller/CustomVariableConfig.pm
8 8

  
9 9
use SL::DB::CustomVariableConfig;
10 10
use SL::DB::CustomVariableValidity;
11
use SL::DB::PartsGroup;
11 12
use SL::Helper::Flash;
12 13
use SL::Locale::String;
13 14
use Data::Dumper;
......
66 67
    split m/:/, ($self->config->flags || '')
67 68
  });
68 69

  
70
  $params{all_partsgroups} = SL::DB::Manager::PartsGroup->get_all();
71

  
72
  $::request->layout->use_javascript("${_}.js") for qw(jquery.selectboxes jquery.multiselect2side);
69 73
  $self->render('custom_variable_config/form', %params);
70 74
}
71 75

  
......
90 94
sub action_destroy {
91 95
  my ($self) = @_;
92 96

  
97
  # delete relationship to partsgroups (for filter) before cvar can be deleted
98
  $self->config->update_attributes(partsgroups => []);
99

  
93 100
  if (eval { $self->config->delete; 1; }) {
94 101
    flash_later('info',  t8('The custom variable has been deleted.'));
95 102
  } else {
......
166 173
  my $params = delete($::form->{config}) || { };
167 174
  delete $params->{id};
168 175

  
176
  if ($self->module eq 'IC') {
177
    $params->{partsgroups} = [] if !$params->{flag_partsgroup_filter};
178
  } else {
179
    delete $params->{flag_partsgroup_filter};
180
    $params->{partsgroups} = [];
181
  }
182

  
183
  $params->{partsgroups}       ||= []; # The list is empty, if control is not send by the browser.
169 184
  $params->{default_value}       = $::form->parse_amount(\%::myconfig, $params->{default_value}) if $params->{type} eq 'number';
170 185
  $params->{included_by_default} = 0                                                             if !$params->{includeable};
171 186
  $params->{flags}               = join ':', map { m/^flag_(.*)/; "${1}=" . delete($params->{$_}) } grep { m/^flag_/ } keys %{ $params };
SL/DB/CustomVariableConfig.pm
11 11
use SL::DB::Manager::CustomVariableConfig;
12 12
use SL::DB::Helper::ActsAsList;
13 13

  
14
__PACKAGE__->meta->add_relationship(
15
  partsgroups  => {
16
    type       => 'many to many',
17
    map_class  => 'SL::DB::CustomVariableConfigPartsgroup',
18
  },
19
);
20

  
14 21
__PACKAGE__->meta->initialize;
15 22

  
16 23
__PACKAGE__->configure_acts_as_list(group_by => [qw(module)]);
SL/DB/CustomVariableConfigPartsgroup.pm
1
# This file has been auto-generated only because it didn't exist.
2
# Feel free to modify it at will; it will not be overwritten automatically.
3

  
4
package SL::DB::CustomVariableConfigPartsgroup;
5

  
6
use strict;
7

  
8
use SL::DB::MetaSetup::CustomVariableConfigPartsgroup;
9
use SL::DB::Manager::CustomVariableConfigPartsgroup;
10

  
11
__PACKAGE__->meta->initialize;
12

  
13
1;
SL/DB/Helper/ALL.pm
28 28
use SL::DB::Currency;
29 29
use SL::DB::CustomVariable;
30 30
use SL::DB::CustomVariableConfig;
31
use SL::DB::CustomVariableConfigPartsgroup;
31 32
use SL::DB::CustomVariableValidity;
32 33
use SL::DB::Customer;
33 34
use SL::DB::Datev;
SL/DB/Helper/Mappings.pm
111 111
  csv_import_report_rows         => 'csv_import_report_row',
112 112
  csv_import_report_status       => 'csv_import_report_status',
113 113
  currencies                     => 'currency',
114
  custom_variable_config_partsgroups => 'custom_variable_config_partsgroup',
114 115
  custom_variable_configs        => 'custom_variable_config',
115 116
  custom_variables               => 'custom_variable',
116 117
  custom_variables_validity      => 'custom_variable_validity',
SL/DB/Manager/CustomVariableConfigPartsgroup.pm
1
# This file has been auto-generated only because it didn't exist.
2
# Feel free to modify it at will; it will not be overwritten automatically.
3

  
4
package SL::DB::Manager::CustomVariableConfigPartsgroup;
5

  
6
use strict;
7

  
8
use SL::DB::Helper::Manager;
9
use base qw(SL::DB::Helper::Manager);
10

  
11
sub object_class { 'SL::DB::CustomVariableConfigPartsgroup' }
12

  
13
__PACKAGE__->make_manager_methods;
14

  
15
1;
SL/DB/MetaSetup/CustomVariableConfigPartsgroup.pm
1
# This file has been auto-generated. Do not modify it; it will be overwritten
2
# by rose_auto_create_model.pl automatically.
3
package SL::DB::CustomVariableConfigPartsgroup;
4

  
5
use strict;
6

  
7
use base qw(SL::DB::Object);
8

  
9
__PACKAGE__->meta->table('custom_variable_config_partsgroups');
10

  
11
__PACKAGE__->meta->columns(
12
  custom_variable_config_id => { type => 'integer', not_null => 1 },
13
  itime                     => { type => 'timestamp', default => 'now()' },
14
  mtime                     => { type => 'timestamp' },
15
  partsgroup_id             => { type => 'integer', not_null => 1 },
16
);
17

  
18
__PACKAGE__->meta->primary_key_columns([ 'custom_variable_config_id', 'partsgroup_id' ]);
19

  
20
__PACKAGE__->meta->allow_inline_column_values(1);
21

  
22
__PACKAGE__->meta->foreign_keys(
23
  custom_variable_config => {
24
    class       => 'SL::DB::CustomVariableConfig',
25
    key_columns => { custom_variable_config_id => 'id' },
26
  },
27

  
28
  partsgroup => {
29
    class       => 'SL::DB::PartsGroup',
30
    key_columns => { partsgroup_id => 'id' },
31
  },
32
);
33

  
34
1;
35
;
SL/DB/PartsGroup.pm
7 7

  
8 8
use SL::DB::MetaSetup::PartsGroup;
9 9

  
10
__PACKAGE__->meta->add_relationship(
11
  custom_variable_configs => {
12
    type                  => 'many to many',
13
    map_class             => 'SL::DB::CustomVariableConfigPartsgroup',
14
  },
15
);
16

  
10 17
__PACKAGE__->meta->initialize;
11 18

  
12 19
# Creates get_all, get_all_count, get_all_iterator, delete_all and update_all.
SL/PE.pm
59 59
    $where .=
60 60
      qq| AND id NOT IN | .
61 61
      qq|  (SELECT DISTINCT partsgroup_id FROM parts | .
62
      qq|   WHERE NOT partsgroup_id ISNULL | .
63
      qq| UNION | .
64
      qq|   SELECT DISTINCT partsgroup_id FROM custom_variable_config_partsgroups | .
62 65
      qq|   WHERE NOT partsgroup_id ISNULL) |;
63 66
  }
64 67

  
......
129 132

  
130 133
  $dbh->disconnect;
131 134

  
135
  # also not orphaned if partsgroup is selected for a cvar filter
136
  if ($form->{orphaned}) {
137
    my $cvar_count = scalar( @{ SL::DB::PartsGroup->new(id => $form->{id})->custom_variable_configs } );
138
    $form->{orphaned} = !$cvar_count;
139
  }
140

  
132 141
  $main::lxdebug->leave_sub();
133 142
}
134 143

  
bin/mozilla/ic.pl
1628 1628

  
1629 1629
  $form->{CUSTOM_VARIABLES} = CVar->get_custom_variables('module' => 'IC', 'trans_id' => $form->{id});
1630 1630

  
1631
  CVar->render_inputs('variables' => $form->{CUSTOM_VARIABLES}, show_disabled_message => 1)
1631
  my ($null, $partsgroup_id) = split /--/, $form->{partsgroup};
1632

  
1633
  CVar->render_inputs('variables' => $form->{CUSTOM_VARIABLES}, show_disabled_message => 1, partsgroup_id => $partsgroup_id)
1632 1634
    if (scalar @{ $form->{CUSTOM_VARIABLES} });
1633 1635

  
1634 1636
  $::request->layout->use_javascript("${_}.js") for qw(ckeditor/ckeditor ckeditor/adapters/jquery);
bin/mozilla/io.pl
1861 1861

  
1862 1862
  my $valid = CVar->custom_variables_validity_by_trans_id(trans_id => $params{part_id});
1863 1863

  
1864
  # get partsgroup_id from part
1865
  my $partsgroup_id;
1866
  if ($params{part_id}) {
1867
    $partsgroup_id = SL::DB::Part->new(id => $params{part_id})->load->partsgroup_id;
1868
  }
1869

  
1864 1870
  my $num_visible_cvars = 0;
1865 1871
  foreach my $cvar (@{ $form->{CVAR_CONFIGS}->{IC} }) {
1866 1872
    $cvar->{valid} = $params{part_id} && $valid->($cvar->{id});
1867 1873

  
1874
    # set partsgroup filter
1875
    my $partsgroup_filtered = 0;
1876
    if ($cvar->{flag_partsgroup_filter}) {
1877
      if (!$partsgroup_id || (!grep {$partsgroup_id == $_} @{ $cvar->{partsgroups} })) {
1878
        $partsgroup_filtered = 1;
1879
      }
1880
    }
1881

  
1868 1882
    my $show = 0;
1869 1883
    my $description = '';
1870
    if ($cvar->{flag_editable} && $cvar->{valid}) {
1884
    if (($cvar->{flag_editable} && $cvar->{valid}) && !$partsgroup_filtered) {
1871 1885
      $num_visible_cvars++;
1872 1886
      $description = $cvar->{description} . ' ';
1873 1887
      $show = 1;
......
1886 1900
         name_postfix      => "_$params{row}",
1887 1901
         valid             => $cvar->{valid},
1888 1902
         value             => CVar->parse($::form->{$form_key}, $cvar),
1903
         partsgroup_filtered => $partsgroup_filtered,
1889 1904
      }
1890 1905
    };
1891 1906
  }
locale/de/all
200 200
  'All general ledger entries'  => 'Alle Hauptbucheinträge',
201 201
  'All groups'                  => 'Alle Gruppen',
202 202
  'All of the exports you have selected were already closed.' => 'Alle von Ihnen ausgewählten Exporte sind bereits abgeschlossen.',
203
  'All partsgroups'             => 'Alle Warengruppen',
203 204
  'All reports'                 => 'Alle Berichte (Kontenübersicht, Summen- u. Saldenliste, GuV, BWA, Bilanz, Projektbuchungen)',
204 205
  'All the other clients will start with an empty set of WebDAV folders.' => 'Alle anderen Mandanten werden mit einem leeren Satz von WebDAV-Ordnern ausgestattet.',
205 206
  'All the selected exports have already been closed, or all of their items have already been executed.' => 'Alle ausgewählten Exporte sind als abgeschlossen markiert, oder für alle Einträge wurden bereits Zahlungen verbucht.',
......
1084 1085
  'File'                        => 'Datei',
1085 1086
  'File name'                   => 'Dateiname',
1086 1087
  'Filter'                      => 'Filter',
1088
  'Filter by Partsgroups'       => 'Nach Warengruppen filtern',
1087 1089
  'Filter date by'              => 'Datum filtern nach',
1088 1090
  'Filter for customer variables' => 'Filter für benutzerdefinierte Kundenvariablen',
1089 1091
  'Filter for item variables'   => 'Filter für benutzerdefinierte Artikelvariablen',
......
1702 1704
  'Partsedit'                   => 'Wareneditor',
1703 1705
  'Partsgroup (database ID)'    => 'Warengruppe (Datenbank-ID)',
1704 1706
  'Partsgroup (name)'           => 'Warengruppe (Name)',
1707
  'Partsgroups where variables are shown' => 'Warengruppen, bei denen Variablen angezeigt werden',
1705 1708
  'Password'                    => 'Passwort',
1706 1709
  'Paste'                       => 'Einfügen',
1707 1710
  'Paste template'              => 'Vorlage einfügen',
locale/en/all
184 184
  'All general ledger entries'  => '',
185 185
  'All groups'                  => '',
186 186
  'All of the exports you have selected were already closed.' => '',
187
  'All partsgroups'             => '',
187 188
  'All reports'                 => '',
188 189
  'All the other clients will start with an empty set of WebDAV folders.' => '',
189 190
  'All the selected exports have already been closed, or all of their items have already been executed.' => '',
......
961 962
  'File'                        => '',
962 963
  'File name'                   => '',
963 964
  'Filter'                      => '',
965
  'Filter by Partsgroups'       => '',
964 966
  'Filter date by'              => '',
965 967
  'Filter for customer variables' => '',
966 968
  'Filter for item variables'   => '',
......
1508 1510
  'Parts, services and assemblies' => '',
1509 1511
  'Partsgroup (database ID)'    => '',
1510 1512
  'Partsgroup (name)'           => '',
1513
  'Partsgroups where variables are shown' => '',
1511 1514
  'Password'                    => '',
1512 1515
  'Payables'                    => '',
1513 1516
  'Payment'                     => '',
sql/Pg-upgrade2/custom_variable_partsgroups.sql
1
-- @tag: custom_variable_partsgroups
2
-- @description: Beziehung zwischen cvar configs und partsgroups für Filter nach Warengruppen
3
-- @depends: release_3_1_0
4
-- @charset: utf-8
5

  
6
CREATE TABLE custom_variable_config_partsgroups (
7
  custom_variable_config_id integer NOT NULL,
8
  partsgroup_id             integer NOT NULL,
9

  
10
  itime                     timestamp              DEFAULT now(),
11
  mtime                     timestamp,
12

  
13
  FOREIGN KEY (custom_variable_config_id) REFERENCES custom_variable_configs(id),
14
  FOREIGN KEY (partsgroup_id)             REFERENCES partsgroup(id),
15

  
16
  PRIMARY KEY(custom_variable_config_id, partsgroup_id)
17
);
18

  
19
CREATE TRIGGER mtime_custom_variable_config_partsgroups BEFORE UPDATE ON custom_variable_config_partsgroups
20
    FOR EACH ROW EXECUTE PROCEDURE set_mtime();
templates/webpages/amcvar/render_checkboxes.html
1 1
[%- USE HTML %]
2 2
[%- SET var_valid = HTML.escape(name_prefix) _ "cvar_" _ HTML.escape(var.name) _ HTML.escape(name_postfix) _ '_valid' -%]
3
[%- IF var.partsgroup_filtered %]
4
<input type="hidden" name="[% var_valid %]" value="[% HTML.escape(var.valid) %]">
5
[%- ELSE %]
3 6
<input type=checkbox name='[% var_valid %]'[% IF var.valid %] checked[% END %]>
7
[%- END %]
templates/webpages/amcvar/render_inputs.html
4 4

  
5 5
[%- SET var_name = HTML.escape(name_prefix) _ "cvar_" _ HTML.escape(var.name) _ HTML.escape(name_postfix) -%]
6 6

  
7
[%- IF hide_non_editable && !var.flag_editable %]
7
[%- IF (hide_non_editable && !var.flag_editable) || var.partsgroup_filtered %]
8 8
<input type="hidden" name="[% var_name %]" value="[% HTML.escape(var.value) %]">
9 9

  
10 10
[%- ELSIF !var.valid %]
templates/webpages/amcvar/render_inputs_block.html
10 10
      SET render_cvar_tag_options.no_id = 1;
11 11
    END;
12 12
%]
13
[%- IF cvar.hide_non_editable && !cvar.var.flag_editable %]
13
[%- IF (cvar.hide_non_editable && !cvar.var.flag_editable) || cvar.partsgroup_filtered %]
14 14
[%- L.hidden_tag(cvar_tag_name, cvar.var.value, render_cvar_tag_options) %]
15 15
[%- ELSIF !cvar.valid %]
16 16
  [%- IF show_disabled_message %]
templates/webpages/custom_variable_config/form.html
74 74
     [% 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)) %]
75 75
    </td>
76 76
   </tr>
77
   <tr data-show-for="IC"[% UNLESS SELF.module == 'IC' %] style="display: none;"[% END %]>
78
    <td align="right">[% 'Filter by Partsgroups' | $T8 %]</td>
79
    <td>
80
     [% L.radio_button_tag('config.flag_partsgroup_filter', value='1', id='config_flag_partsgroup_filter_1', label=LxERP.t8('Yes'), checked=(SELF.flags.partsgroup_filter ?  1 : ''), onclick='update_pg_filter_row()') %]
81
     [% L.radio_button_tag('config.flag_partsgroup_filter', value='0', id='config_flag_partsgroup_filter_0', label=LxERP.t8('No'),  checked=(SELF.flags.partsgroup_filter ? '' :  1), onclick='update_pg_filter_row()') %]
82
    </td>
83
   </tr>
84
   <tr data-show-for="IC+PGFILTER"[% UNLESS (SELF.module == 'IC' && SELF.flags.partsgroup_filter) %] style="display: none;"[% END %]>
85
    <td></td>
86
    <td>
87
  [% L.select_tag('config.partsgroups[]',
88
                      all_partsgroups,
89
                      id                => "partsgroups",
90
                      value_key         => "id",
91
                      title_key         => "partsgroup",
92
                      default           => SELF.config.partsgroups,
93
                      default_value_key => "id",
94
                      multiple          => 1) %]
95
      [% L.multiselect2side("partsgroups",
96
                            labelsx => LxERP.t8("All partsgroups"),
97
                            labeldx => LxERP.t8("Partsgroups where variables are shown")) %]
98
    </td>
99
   </tr>
77 100
  </table>
78 101
 </p>
79 102

  
......
149 172

  
150 173
function update_ic_rows() {
151 174
  $('[data-show-for="IC"]').toggle($('#module').val() === "IC");
175
  $('[data-show-for="IC+PGFILTER"]').toggle($('#module').val() === "IC" && $('#config_flag_partsgroup_filter_1').prop('checked'));
176
}
177

  
178
function update_pg_filter_row() {
179
  $('[data-show-for="IC+PGFILTER"]').toggle($('#module').val() === "IC" && $('#config_flag_partsgroup_filter_1').prop('checked'));
152 180
}
153 181

  
154 182
function check_prerequisites() {
templates/webpages/custom_variable_config/list.html
7 7
 [%- L.select_tag('module', SELF.modules, value_key='module', title_key='description', default=SELF.module, onchange='show_module_list()') %]
8 8
</p>
9 9

  
10
[%- IF SELF.module == 'IC' %]
11
  [%- SET W="12.5%" %]
12
[%- ELSE %]
13
  [%- SET W="20%" %]
14
[%- END %]
10 15
<p>
11 16
 <table width="100%" id="cvarcfg_list">
12 17
  <thead>
13 18
   <tr class="listheading">
14 19
    <th align="center"><img src="image/updown.png" alt="[%- LxERP.t8('reorder item') %]"></th>
15
    <th width="20%">[% 'Name' | $T8 %]</th>
16
    <th width="20%">[% 'Description' | $T8 %]</th>
17
    <th width="20%">[% 'Type' | $T8 %]</th>
18
    <th width="20%">[% 'Searchable' | $T8 %]</th>
19
    <th width="20%">[% 'Includeable in reports' | $T8 %]</th>
20
    <th width="[%- W -%]">[% 'Name' | $T8 %]</th>
21
    <th width="[%- W -%]">[% 'Description' | $T8 %]</th>
22
    <th width="[%- W -%]">[% 'Type' | $T8 %]</th>
23
    <th width="[%- W -%]">[% 'Searchable' | $T8 %]</th>
24
    <th width="[%- W -%]">[% 'Includeable in reports' | $T8 %]</th>
20 25
    [%- IF SELF.module == 'IC' %]
21
     <th width="20%">[% 'Editable' | $T8 %]</th>
22
     <th width="20%">[% 'Deactivate by default' | $T8 %]</th>
26
     <th width="[%- W -%]">[% 'Editable' | $T8 %]</th>
27
     <th width="[%- W -%]">[% 'Deactivate by default' | $T8 %]</th>
28
     <th width="[%- W -%]">[% 'Filter by Partsgroups' | $T8 %]</th>
23 29
    [%- END %]
24 30
   </tr>
25 31
  </thead>
......
41 47
     [%- IF SELF.module == 'IC' %]
42 48
      <td>[%- IF cfg.flags.match('editable=1') %][% 'Yes' | $T8 %][%- ELSE %][% 'No' | $T8 %][%- END %]</td>
43 49
      <td>[%- IF cfg.flags.match('defaults_to_invalid=1') %][% 'Yes' | $T8 %][%- ELSE %][% 'No' | $T8 %][%- END %]</td>
50
      <td>[%- IF cfg.flags.match('partsgroup_filter=1') %][% 'Yes' | $T8 %][%- ELSE %][% 'No' | $T8 %][%- END %]</td>
44 51
     [%- END %]
45 52
    </tr>
46 53
    [%- END %]
templates/webpages/ic/form_footer.html
46 46
   [%- FOREACH var = CUSTOM_VARIABLES %]
47 47
   <tr>
48 48
    <td align="right" valign="top">[% var.VALID_BOX %]</td>
49
    <td align="right" valign="top">[% HTML.escape(var.description) %]</td>
49
    [%- IF !var.partsgroup_filtered %]
50
      <td align="right" valign="top">[% HTML.escape(var.description) %]</td>
51
    [%- END %]
50 52
    <td valign="top">[% var.HTML_CODE %]</td>
51 53
   </tr>
52 54
   [%- END %]
templates/webpages/oe/sales_order.html
45 45
 <table class='row2-cvars-table'>
46 46
   <tr>
47 47
   [%- FOREACH row2 = row.ROW2 %]
48
     [%- IF row2.cvar && row2.render_options.valid %]
48
     [%- IF row2.cvar && row2.render_options.valid && !row2.render_options.partsgroup_filtered %]
49 49
       [%- IF row2.line_break %]
50 50
         </tr><tr>
51 51
       [%- END %]

Auch abrufbar als: Unified diff