Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision 36703a86

Von Bernd Blessmann vor mehr als 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
}
$self->_unpack_flags($config);
my $cvar_config = SL::DB::CustomVariableConfig->new(id => $config->{id})->load;
@{$config->{'partsgroups'}} = map {$_->id} @{$cvar_config->partsgroups};
}
$::form->{CVAR_CONFIGS}->{$params{module}} = $configs;
}
......
my $myconfig = \%main::myconfig;
my $form = $main::form;
my %options = ( name_prefix => "$params{name_prefix}",
name_postfix => "$params{name_postfix}",
hide_non_editable => $params{hide_non_editable},
my %options = ( name_prefix => "$params{name_prefix}",
name_postfix => "$params{name_postfix}",
hide_non_editable => $params{hide_non_editable},
show_disabled_message => $params{show_disabled_message},
);
# should this cvar be filtered by partsgroups?
foreach my $var (@{ $params{variables} }) {
if ($var->{flag_partsgroup_filter}) {
if (!$params{partsgroup_id} || (!grep {$params{partsgroup_id} == $_} @{ $var->{partsgroups} })) {
$var->{partsgroup_filtered} = 1;
}
}
$var->{HTML_CODE} = $form->parse_html_template('amcvar/render_inputs', { var => $var, %options });
$var->{VALID_BOX} = $form->parse_html_template('amcvar/render_checkboxes', { var => $var, %options });
}
SL/Controller/CustomVariableConfig.pm
use SL::DB::CustomVariableConfig;
use SL::DB::CustomVariableValidity;
use SL::DB::PartsGroup;
use SL::Helper::Flash;
use SL::Locale::String;
use Data::Dumper;
......
split m/:/, ($self->config->flags || '')
});
$params{all_partsgroups} = SL::DB::Manager::PartsGroup->get_all();
$::request->layout->use_javascript("${_}.js") for qw(jquery.selectboxes jquery.multiselect2side);
$self->render('custom_variable_config/form', %params);
}
......
sub action_destroy {
my ($self) = @_;
# delete relationship to partsgroups (for filter) before cvar can be deleted
$self->config->update_attributes(partsgroups => []);
if (eval { $self->config->delete; 1; }) {
flash_later('info', t8('The custom variable has been deleted.'));
} else {
......
my $params = delete($::form->{config}) || { };
delete $params->{id};
if ($self->module eq 'IC') {
$params->{partsgroups} = [] if !$params->{flag_partsgroup_filter};
} else {
delete $params->{flag_partsgroup_filter};
$params->{partsgroups} = [];
}
$params->{partsgroups} ||= []; # The list is empty, if control is not send by the browser.
$params->{default_value} = $::form->parse_amount(\%::myconfig, $params->{default_value}) if $params->{type} eq 'number';
$params->{included_by_default} = 0 if !$params->{includeable};
$params->{flags} = join ':', map { m/^flag_(.*)/; "${1}=" . delete($params->{$_}) } grep { m/^flag_/ } keys %{ $params };
SL/DB/CustomVariableConfig.pm
use SL::DB::Manager::CustomVariableConfig;
use SL::DB::Helper::ActsAsList;
__PACKAGE__->meta->add_relationship(
partsgroups => {
type => 'many to many',
map_class => 'SL::DB::CustomVariableConfigPartsgroup',
},
);
__PACKAGE__->meta->initialize;
__PACKAGE__->configure_acts_as_list(group_by => [qw(module)]);
SL/DB/CustomVariableConfigPartsgroup.pm
# This file has been auto-generated only because it didn't exist.
# Feel free to modify it at will; it will not be overwritten automatically.
package SL::DB::CustomVariableConfigPartsgroup;
use strict;
use SL::DB::MetaSetup::CustomVariableConfigPartsgroup;
use SL::DB::Manager::CustomVariableConfigPartsgroup;
__PACKAGE__->meta->initialize;
1;
SL/DB/Helper/ALL.pm
use SL::DB::Currency;
use SL::DB::CustomVariable;
use SL::DB::CustomVariableConfig;
use SL::DB::CustomVariableConfigPartsgroup;
use SL::DB::CustomVariableValidity;
use SL::DB::Customer;
use SL::DB::Datev;
SL/DB/Helper/Mappings.pm
csv_import_report_rows => 'csv_import_report_row',
csv_import_report_status => 'csv_import_report_status',
currencies => 'currency',
custom_variable_config_partsgroups => 'custom_variable_config_partsgroup',
custom_variable_configs => 'custom_variable_config',
custom_variables => 'custom_variable',
custom_variables_validity => 'custom_variable_validity',
SL/DB/Manager/CustomVariableConfigPartsgroup.pm
# This file has been auto-generated only because it didn't exist.
# Feel free to modify it at will; it will not be overwritten automatically.
package SL::DB::Manager::CustomVariableConfigPartsgroup;
use strict;
use SL::DB::Helper::Manager;
use base qw(SL::DB::Helper::Manager);
sub object_class { 'SL::DB::CustomVariableConfigPartsgroup' }
__PACKAGE__->make_manager_methods;
1;
SL/DB/MetaSetup/CustomVariableConfigPartsgroup.pm
# This file has been auto-generated. Do not modify it; it will be overwritten
# by rose_auto_create_model.pl automatically.
package SL::DB::CustomVariableConfigPartsgroup;
use strict;
use base qw(SL::DB::Object);
__PACKAGE__->meta->table('custom_variable_config_partsgroups');
__PACKAGE__->meta->columns(
custom_variable_config_id => { type => 'integer', not_null => 1 },
itime => { type => 'timestamp', default => 'now()' },
mtime => { type => 'timestamp' },
partsgroup_id => { type => 'integer', not_null => 1 },
);
__PACKAGE__->meta->primary_key_columns([ 'custom_variable_config_id', 'partsgroup_id' ]);
__PACKAGE__->meta->allow_inline_column_values(1);
__PACKAGE__->meta->foreign_keys(
custom_variable_config => {
class => 'SL::DB::CustomVariableConfig',
key_columns => { custom_variable_config_id => 'id' },
},
partsgroup => {
class => 'SL::DB::PartsGroup',
key_columns => { partsgroup_id => 'id' },
},
);
1;
;
SL/DB/PartsGroup.pm
use SL::DB::MetaSetup::PartsGroup;
__PACKAGE__->meta->add_relationship(
custom_variable_configs => {
type => 'many to many',
map_class => 'SL::DB::CustomVariableConfigPartsgroup',
},
);
__PACKAGE__->meta->initialize;
# Creates get_all, get_all_count, get_all_iterator, delete_all and update_all.
SL/PE.pm
$where .=
qq| AND id NOT IN | .
qq| (SELECT DISTINCT partsgroup_id FROM parts | .
qq| WHERE NOT partsgroup_id ISNULL | .
qq| UNION | .
qq| SELECT DISTINCT partsgroup_id FROM custom_variable_config_partsgroups | .
qq| WHERE NOT partsgroup_id ISNULL) |;
}
......
$dbh->disconnect;
# also not orphaned if partsgroup is selected for a cvar filter
if ($form->{orphaned}) {
my $cvar_count = scalar( @{ SL::DB::PartsGroup->new(id => $form->{id})->custom_variable_configs } );
$form->{orphaned} = !$cvar_count;
}
$main::lxdebug->leave_sub();
}
bin/mozilla/ic.pl
$form->{CUSTOM_VARIABLES} = CVar->get_custom_variables('module' => 'IC', 'trans_id' => $form->{id});
CVar->render_inputs('variables' => $form->{CUSTOM_VARIABLES}, show_disabled_message => 1)
my ($null, $partsgroup_id) = split /--/, $form->{partsgroup};
CVar->render_inputs('variables' => $form->{CUSTOM_VARIABLES}, show_disabled_message => 1, partsgroup_id => $partsgroup_id)
if (scalar @{ $form->{CUSTOM_VARIABLES} });
$::request->layout->use_javascript("${_}.js") for qw(ckeditor/ckeditor ckeditor/adapters/jquery);
bin/mozilla/io.pl
my $valid = CVar->custom_variables_validity_by_trans_id(trans_id => $params{part_id});
# get partsgroup_id from part
my $partsgroup_id;
if ($params{part_id}) {
$partsgroup_id = SL::DB::Part->new(id => $params{part_id})->load->partsgroup_id;
}
my $num_visible_cvars = 0;
foreach my $cvar (@{ $form->{CVAR_CONFIGS}->{IC} }) {
$cvar->{valid} = $params{part_id} && $valid->($cvar->{id});
# set partsgroup filter
my $partsgroup_filtered = 0;
if ($cvar->{flag_partsgroup_filter}) {
if (!$partsgroup_id || (!grep {$partsgroup_id == $_} @{ $cvar->{partsgroups} })) {
$partsgroup_filtered = 1;
}
}
my $show = 0;
my $description = '';
if ($cvar->{flag_editable} && $cvar->{valid}) {
if (($cvar->{flag_editable} && $cvar->{valid}) && !$partsgroup_filtered) {
$num_visible_cvars++;
$description = $cvar->{description} . ' ';
$show = 1;
......
name_postfix => "_$params{row}",
valid => $cvar->{valid},
value => CVar->parse($::form->{$form_key}, $cvar),
partsgroup_filtered => $partsgroup_filtered,
}
};
}
locale/de/all
'All general ledger entries' => 'Alle Hauptbucheinträge',
'All groups' => 'Alle Gruppen',
'All of the exports you have selected were already closed.' => 'Alle von Ihnen ausgewählten Exporte sind bereits abgeschlossen.',
'All partsgroups' => 'Alle Warengruppen',
'All reports' => 'Alle Berichte (Kontenübersicht, Summen- u. Saldenliste, GuV, BWA, Bilanz, Projektbuchungen)',
'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.',
'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.',
......
'File' => 'Datei',
'File name' => 'Dateiname',
'Filter' => 'Filter',
'Filter by Partsgroups' => 'Nach Warengruppen filtern',
'Filter date by' => 'Datum filtern nach',
'Filter for customer variables' => 'Filter für benutzerdefinierte Kundenvariablen',
'Filter for item variables' => 'Filter für benutzerdefinierte Artikelvariablen',
......
'Partsedit' => 'Wareneditor',
'Partsgroup (database ID)' => 'Warengruppe (Datenbank-ID)',
'Partsgroup (name)' => 'Warengruppe (Name)',
'Partsgroups where variables are shown' => 'Warengruppen, bei denen Variablen angezeigt werden',
'Password' => 'Passwort',
'Paste' => 'Einfügen',
'Paste template' => 'Vorlage einfügen',
locale/en/all
'All general ledger entries' => '',
'All groups' => '',
'All of the exports you have selected were already closed.' => '',
'All partsgroups' => '',
'All reports' => '',
'All the other clients will start with an empty set of WebDAV folders.' => '',
'All the selected exports have already been closed, or all of their items have already been executed.' => '',
......
'File' => '',
'File name' => '',
'Filter' => '',
'Filter by Partsgroups' => '',
'Filter date by' => '',
'Filter for customer variables' => '',
'Filter for item variables' => '',
......
'Parts, services and assemblies' => '',
'Partsgroup (database ID)' => '',
'Partsgroup (name)' => '',
'Partsgroups where variables are shown' => '',
'Password' => '',
'Payables' => '',
'Payment' => '',
sql/Pg-upgrade2/custom_variable_partsgroups.sql
-- @tag: custom_variable_partsgroups
-- @description: Beziehung zwischen cvar configs und partsgroups für Filter nach Warengruppen
-- @depends: release_3_1_0
-- @charset: utf-8
CREATE TABLE custom_variable_config_partsgroups (
custom_variable_config_id integer NOT NULL,
partsgroup_id integer NOT NULL,
itime timestamp DEFAULT now(),
mtime timestamp,
FOREIGN KEY (custom_variable_config_id) REFERENCES custom_variable_configs(id),
FOREIGN KEY (partsgroup_id) REFERENCES partsgroup(id),
PRIMARY KEY(custom_variable_config_id, partsgroup_id)
);
CREATE TRIGGER mtime_custom_variable_config_partsgroups BEFORE UPDATE ON custom_variable_config_partsgroups
FOR EACH ROW EXECUTE PROCEDURE set_mtime();
templates/webpages/amcvar/render_checkboxes.html
[%- USE HTML %]
[%- SET var_valid = HTML.escape(name_prefix) _ "cvar_" _ HTML.escape(var.name) _ HTML.escape(name_postfix) _ '_valid' -%]
[%- IF var.partsgroup_filtered %]
<input type="hidden" name="[% var_valid %]" value="[% HTML.escape(var.valid) %]">
[%- ELSE %]
<input type=checkbox name='[% var_valid %]'[% IF var.valid %] checked[% END %]>
[%- END %]
templates/webpages/amcvar/render_inputs.html
[%- SET var_name = HTML.escape(name_prefix) _ "cvar_" _ HTML.escape(var.name) _ HTML.escape(name_postfix) -%]
[%- IF hide_non_editable && !var.flag_editable %]
[%- IF (hide_non_editable && !var.flag_editable) || var.partsgroup_filtered %]
<input type="hidden" name="[% var_name %]" value="[% HTML.escape(var.value) %]">
[%- ELSIF !var.valid %]
templates/webpages/amcvar/render_inputs_block.html
SET render_cvar_tag_options.no_id = 1;
END;
%]
[%- IF cvar.hide_non_editable && !cvar.var.flag_editable %]
[%- IF (cvar.hide_non_editable && !cvar.var.flag_editable) || cvar.partsgroup_filtered %]
[%- L.hidden_tag(cvar_tag_name, cvar.var.value, render_cvar_tag_options) %]
[%- ELSIF !cvar.valid %]
[%- IF show_disabled_message %]
templates/webpages/custom_variable_config/form.html
[% 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>
<tr data-show-for="IC"[% UNLESS SELF.module == 'IC' %] style="display: none;"[% END %]>
<td align="right">[% 'Filter by Partsgroups' | $T8 %]</td>
<td>
[% 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()') %]
[% 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()') %]
</td>
</tr>
<tr data-show-for="IC+PGFILTER"[% UNLESS (SELF.module == 'IC' && SELF.flags.partsgroup_filter) %] style="display: none;"[% END %]>
<td></td>
<td>
[% L.select_tag('config.partsgroups[]',
all_partsgroups,
id => "partsgroups",
value_key => "id",
title_key => "partsgroup",
default => SELF.config.partsgroups,
default_value_key => "id",
multiple => 1) %]
[% L.multiselect2side("partsgroups",
labelsx => LxERP.t8("All partsgroups"),
labeldx => LxERP.t8("Partsgroups where variables are shown")) %]
</td>
</tr>
</table>
</p>
......
function update_ic_rows() {
$('[data-show-for="IC"]').toggle($('#module').val() === "IC");
$('[data-show-for="IC+PGFILTER"]').toggle($('#module').val() === "IC" && $('#config_flag_partsgroup_filter_1').prop('checked'));
}
function update_pg_filter_row() {
$('[data-show-for="IC+PGFILTER"]').toggle($('#module').val() === "IC" && $('#config_flag_partsgroup_filter_1').prop('checked'));
}
function check_prerequisites() {
templates/webpages/custom_variable_config/list.html
[%- L.select_tag('module', SELF.modules, value_key='module', title_key='description', default=SELF.module, onchange='show_module_list()') %]
</p>
[%- IF SELF.module == 'IC' %]
[%- SET W="12.5%" %]
[%- ELSE %]
[%- SET W="20%" %]
[%- END %]
<p>
<table width="100%" id="cvarcfg_list">
<thead>
<tr class="listheading">
<th align="center"><img src="image/updown.png" alt="[%- LxERP.t8('reorder item') %]"></th>
<th width="20%">[% 'Name' | $T8 %]</th>
<th width="20%">[% 'Description' | $T8 %]</th>
<th width="20%">[% 'Type' | $T8 %]</th>
<th width="20%">[% 'Searchable' | $T8 %]</th>
<th width="20%">[% 'Includeable in reports' | $T8 %]</th>
<th width="[%- W -%]">[% 'Name' | $T8 %]</th>
<th width="[%- W -%]">[% 'Description' | $T8 %]</th>
<th width="[%- W -%]">[% 'Type' | $T8 %]</th>
<th width="[%- W -%]">[% 'Searchable' | $T8 %]</th>
<th width="[%- W -%]">[% 'Includeable in reports' | $T8 %]</th>
[%- IF SELF.module == 'IC' %]
<th width="20%">[% 'Editable' | $T8 %]</th>
<th width="20%">[% 'Deactivate by default' | $T8 %]</th>
<th width="[%- W -%]">[% 'Editable' | $T8 %]</th>
<th width="[%- W -%]">[% 'Deactivate by default' | $T8 %]</th>
<th width="[%- W -%]">[% 'Filter by Partsgroups' | $T8 %]</th>
[%- END %]
</tr>
</thead>
......
[%- 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>
<td>[%- IF cfg.flags.match('partsgroup_filter=1') %][% 'Yes' | $T8 %][%- ELSE %][% 'No' | $T8 %][%- END %]</td>
[%- END %]
</tr>
[%- END %]
templates/webpages/ic/form_footer.html
[%- FOREACH var = CUSTOM_VARIABLES %]
<tr>
<td align="right" valign="top">[% var.VALID_BOX %]</td>
<td align="right" valign="top">[% HTML.escape(var.description) %]</td>
[%- IF !var.partsgroup_filtered %]
<td align="right" valign="top">[% HTML.escape(var.description) %]</td>
[%- END %]
<td valign="top">[% var.HTML_CODE %]</td>
</tr>
[%- END %]
templates/webpages/oe/sales_order.html
<table class='row2-cvars-table'>
<tr>
[%- FOREACH row2 = row.ROW2 %]
[%- IF row2.cvar && row2.render_options.valid %]
[%- IF row2.cvar && row2.render_options.valid && !row2.render_options.partsgroup_filtered %]
[%- IF row2.line_break %]
</tr><tr>
[%- END %]

Auch abrufbar als: Unified diff