From b2f44e3d98cbbd622b1497c23602eb79e71a3c64 Mon Sep 17 00:00:00 2001
From: Moritz Bunkus
Date: Mon, 29 Jun 2009 15:54:52 +0000
Subject: [PATCH] Das Definieren, Erstellen und Bearbeiten von
benutzerdefinierten Variablen bei Waren, Dienstleistungen und Erzeugnissen
implementiert.
---
SL/CVar.pm | 8 ++--
SL/IC.pm | 15 ++++++++
bin/mozilla/amcvar.pl | 19 +++++++---
bin/mozilla/ic.pl | 28 +++++++++++++-
locale/de/all | 11 ++++--
locale/de/menu | 2 +
locale/de/menunew | 2 +
menu.ini | 10 +++++
.../amcvar/display_cvar_config_form_de.html | 35 ++++++++++++++++++
.../display_cvar_config_form_master.html | 37 +++++++++++++++++++
.../webpages/amcvar/list_cvar_configs_de.html | 13 +++++++
.../amcvar/list_cvar_configs_master.html | 13 +++++++
templates/webpages/ic/form_footer_de.html | 19 ++++++++++
templates/webpages/ic/form_footer_master.html | 19 ++++++++++
templates/webpages/ic/form_header_de.html | 3 ++
templates/webpages/ic/form_header_master.html | 3 ++
templates/webpages/ic/search_de.html | 4 ++
templates/webpages/ic/search_master.html | 4 ++
18 files changed, 232 insertions(+), 13 deletions(-)
diff --git a/SL/CVar.pm b/SL/CVar.pm
index f5a84c601..27febc5b6 100644
--- a/SL/CVar.pm
+++ b/SL/CVar.pm
@@ -79,8 +79,8 @@ sub save_config {
my $h_id = prepare_query($form, $dbh, $q_id);
my $q_new =
- qq|INSERT INTO custom_variable_configs (name, description, type, default_value, options, searchable, includeable, included_by_default, module, id, sortkey)
- VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?,
+ qq|INSERT INTO custom_variable_configs (name, description, type, default_value, options, searchable, includeable, included_by_default, module, flags, id, sortkey)
+ VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?,
(SELECT COALESCE(MAX(sortkey) + 1, 1) FROM custom_variable_configs))|;
my $h_new = prepare_query($form, $dbh, $q_new);
@@ -90,7 +90,7 @@ sub save_config {
type = ?, default_value = ?,
options = ?, searchable = ?,
includeable = ?, included_by_default = ?,
- module = ?
+ module = ?, flags = ?
WHERE id = ?|;
my $h_update = prepare_query($form, $dbh, $q_update);
@@ -118,7 +118,7 @@ sub save_config {
do_statement($form, $h_actual, $q_actual, @{$config}{qw(name description type default_value options)},
$config->{searchable} ? 't' : 'f', $config->{includeable} ? 't' : 'f', $config->{included_by_default} ? 't' : 'f',
- $params{module}, conv_i($config->{id}));
+ $params{module}, $config->{flags}, conv_i($config->{id}));
}
$h_id->finish();
diff --git a/SL/IC.pm b/SL/IC.pm
index 5548d19df..880502b9d 100644
--- a/SL/IC.pm
+++ b/SL/IC.pm
@@ -38,6 +38,7 @@ use Data::Dumper;
use List::MoreUtils qw(all);
use YAML;
+use SL::CVar;
use SL::DBUtils;
sub get_part {
@@ -565,6 +566,11 @@ sub save {
}
}
+ CVar->save_custom_variables('dbh' => $dbh,
+ 'module' => 'IC',
+ 'trans_id' => $form->{id},
+ 'variables' => $form);
+
# commit
my $rc = $dbh->commit;
$dbh->disconnect;
@@ -957,6 +963,15 @@ sub all_parts {
my $where_clause = join ' AND ', map { "($_)" } @where_tokens;
my $group_clause = ' GROUP BY ' . join ', ', map { ($table_prefix{$_} || "p.") . $_ } @group_tokens if scalar @group_tokens;
+ my ($cvar_where, @cvar_values) = CVar->build_filter_query('module' => 'IC',
+ 'trans_id_field' => 'p.id',
+ 'filter' => $form);
+
+ if ($cvar_where) {
+ $where_clause .= qq| AND ($cvar_where)|;
+ push @bind_vars, @cvar_values;
+ }
+
my $query = qq|SELECT DISTINCT $select_clause FROM parts p $join_clause WHERE $where_clause $group_clause $order_clause $limit_clause|;
$form->{parts} = selectall_hashref_query($form, $dbh, $query, @bind_vars);
diff --git a/bin/mozilla/amcvar.pl b/bin/mozilla/amcvar.pl
index 57457acc2..47c821c96 100644
--- a/bin/mozilla/amcvar.pl
+++ b/bin/mozilla/amcvar.pl
@@ -73,15 +73,23 @@ sub list_cvar_configs {
my $previous_config;
- foreach (@configs) {
- $_->{type_tr} = $translations{$_->{type}};
+ foreach my $config (@configs) {
+ $config->{type_tr} = $translations{$config->{type}};
+
+ foreach my $flag (split m/:/, $config->{flags}) {
+ if ($flag =~ m/(.*?)=(.*)/) {
+ $config->{"flag_${1}"} = $2;
+ } else {
+ $config->{"flag_${flag}"} = 1;
+ }
+ }
if ($previous_config) {
- $previous_config->{next_id} = $_->{id};
- $_->{previous_id} = $previous_config->{id};
+ $previous_config->{next_id} = $config->{id};
+ $config->{previous_id} = $previous_config->{id};
}
- $previous_config = $_;
+ $previous_config = $config;
}
$form->{title} = $locale->text('List of custom variables');
@@ -138,6 +146,7 @@ sub save {
$form->{included_by_default} = $form->{inclusion} eq 'yes_default_on';
$form->{includeable} = $form->{inclusion} ne 'no';
+ $form->{flags} = join ':', map { m/^flag_(.*)/; "${1}=" . $form->{$_} } grep { m/^flag_/ } keys %{ $form };
CVar->save_config('module' => $form->{module},
'config' => $form);
diff --git a/bin/mozilla/ic.pl b/bin/mozilla/ic.pl
index 063973159..07a008917 100644
--- a/bin/mozilla/ic.pl
+++ b/bin/mozilla/ic.pl
@@ -36,6 +36,7 @@ use List::Util qw(max);
use List::MoreUtils qw(any);
use SL::AM;
+use SL::CVar;
use SL::IC;
use SL::ReportGenerator;
@@ -105,6 +106,12 @@ sub search {
$form->{jsscript} = 1;
+ $form->{CUSTOM_VARIABLES} = CVar->get_configs('module' => 'IC');
+ ($form->{CUSTOM_VARIABLES_FILTER_CODE},
+ $form->{CUSTOM_VARIABLES_INCLUSION_CODE}) = CVar->render_search_options('variables' => $form->{CUSTOM_VARIABLES},
+ 'include_prefix' => 'l_',
+ 'include_value' => 'Y');
+
$form->header;
print $form->parse_html_template('ic/search', { %is_xyz,
@@ -1010,6 +1017,8 @@ sub generate_report {
my ($revers, $lastsort, $description);
+ my $cvar_configs = CVar->get_configs('module' => 'IC');
+
$form->{title} = (ucfirst $form->{searchitems}) . "s";
$form->{title} =~ s/ys$/ies/;
$form->{title} = $locale->text($form->{title});
@@ -1151,6 +1160,12 @@ sub generate_report {
qw(partnumber description partsgroup bin onhand rop unit listprice linetotallistprice sellprice linetotalsellprice lastcost linetotallastcost
priceupdate weight image drawing microfiche invnumber ordnumber quonumber name serialnumber soldtotal deliverydate);
+ my @includeable_custom_variables = grep { $_->{includeable} } @{ $cvar_configs };
+ my @searchable_custom_variables = grep { $_->{searchable} } @{ $cvar_configs };
+ my %column_defs_cvars = map { +"cvar_$_->{name}" => { 'text' => $_->{description} } } @includeable_custom_variables;
+
+ push @columns, map { "cvar_$_->{name}" } @includeable_custom_variables;
+
my %column_defs = (
'bin' => { 'text' => $locale->text('Bin'), },
'deliverydate' => { 'text' => $locale->text('deliverydate'), },
@@ -1177,12 +1192,13 @@ sub generate_report {
'soldtotal' => { 'text' => $locale->text('soldtotal'), },
'unit' => { 'text' => $locale->text('Unit'), },
'weight' => { 'text' => $locale->text('Weight'), },
+ %column_defs_cvars,
);
map { $column_defs{$_}->{visible} = $form->{"l_$_"} ? 1 : 0 } @columns;
map { $column_defs{$_}->{align} = 'right' } qw(onhand sellprice listprice lastcost linetotalsellprice linetotallastcost linetotallistprice rop weight soldtotal);
- my @hidden_variables = (qw(l_subtotal l_linetotal searchitems itemstatus bom), @itemstatus_keys, @callback_keys, map { "l_$_" } @columns);
+ my @hidden_variables = (qw(l_subtotal l_linetotal searchitems itemstatus bom), @itemstatus_keys, @callback_keys, @searchable_custom_variables, map { "l_$_" } @columns);
my $callback = build_std_url('action=generate_report', grep { $form->{$_} } @hidden_variables);
my @sort_full = qw(partnumber description onhand soldtotal deliverydate);
@@ -1219,6 +1235,12 @@ sub generate_report {
$report->set_sort_indicator($form->{sort}, $form->{revers} ? 0 : 1);
+ CVar->add_custom_variables_to_report('module' => 'IC',
+ 'trans_id_field' => 'id',
+ 'configs' => $cvar_configs,
+ 'column_defs' => \%column_defs,
+ 'data' => $form->{parts});
+
my @subtotal_columns = qw(sellprice listprice lastcost);
my %subtotals = map { $_ => 0 } ('onhand', @subtotal_columns);
my %totals = map { $_ => 0 } @subtotal_columns;
@@ -1514,6 +1536,10 @@ sub form_header {
$form->{fokus} = "ic.partnumber";
+ $form->{CUSTOM_VARIABLES} = CVar->get_custom_variables('module' => 'IC', 'trans_id' => $form->{id});
+
+ CVar->render_inputs('variables' => $form->{CUSTOM_VARIABLES}) if (scalar @{ $form->{CUSTOM_VARIABLES} });
+
$form->header;
#print $form->parse_html_template('ic/form_header', { ALL_PRICE_FACTORS => $form->{ALL_PRICE_FACTORS},
# ALL_UNITS => $form->{ALL_UNITS},
diff --git a/locale/de/all b/locale/de/all
index bd45eb859..18d6a5631 100644
--- a/locale/de/all
+++ b/locale/de/all
@@ -40,6 +40,7 @@ $self->{texts} = {
'A temporary file could not be created. Please verify that the directory "#1" is writeable by the webserver.' => 'Eine temporäre Datei konnte nicht angelegt werden. Bitte stellen Sie sicher, dass das Verzeichnis "#1" vom Webserver beschrieben werden darf.',
'A temporary file could not be created:' => 'Eine temporäre Datei konnte nicht erstellt werden:',
'A unit with this name does already exist.' => 'Eine Einheit mit diesem Namen existiert bereits.',
+ 'A variable marked as \'editable\' can be changed in each quotation, order, invoice etc.' => 'Eine als \'editierbar\' markierte Variable kann in jedem Angebot, Auftrag, jeder Rechnung etc für jede Position geändert werden.',
'ADDED' => 'Hinzugefügt',
'AP' => 'Einkauf',
'AP Aging' => 'Offene Verbindlichkeiten',
@@ -102,6 +103,7 @@ $self->{texts} = {
'Add' => 'Erfassen',
'Add ' => 'Hinzufügen',
'Add (Customers and Vendors)' => 'Erfassen (Kunden und Lieferanten)',
+ 'Add (Parts, services, assemblies)' => 'Erfassen (Waren, Dienstleistungen, Erzeugnisse)',
'Add (Projects)' => 'Erfassen (Projekte)',
'Add AP Transaction' => 'Kreditorenbuchung',
'Add AR Transaction' => 'Debitorenbuchung',
@@ -438,6 +440,7 @@ $self->{texts} = {
'Customername' => 'Kundenname',
'Customernumberinit' => 'Kunden-/Lieferantennummernkreis',
'Customers' => 'Kunden',
+ 'Customers and vendors' => 'Kunden und Lieferanten',
'Customized Report' => 'Vorgewählte Zeiträume',
'DATEV - Export Assistent' => 'DATEV-Exportassistent',
'DATEV Angaben' => 'DATEV-Angaben',
@@ -479,7 +482,6 @@ $self->{texts} = {
'December' => 'Dezember',
'Decimalplaces' => 'Dezimalstellen',
'Decrease' => 'Verringern',
- 'Default (no language selected)' => 'Standard (keine Sprache ausgewählt)',
'Default Accounts' => 'Standardkonten',
'Default output medium' => 'Standardausgabekanal',
'Default printer' => 'Standarddrucker',
@@ -625,7 +627,6 @@ $self->{texts} = {
'Edit and delete a group' => 'Gruppen bearbeiten und löschen',
'Edit custom variable' => 'Benutzerdefinierte Variable bearbeiten',
'Edit file' => 'Datei bearbeiten',
- 'Edit greetings' => 'Anreden bearbeiten',
'Edit group ' => 'Gruppe bearbeiten',
'Edit group membership' => 'Gruppenmitgliedschaften bearbeiten',
'Edit groups' => 'Gruppen bearbeiten',
@@ -640,6 +641,7 @@ $self->{texts} = {
'Edit the sales_quotation' => 'Bearbeiten des Angebots',
'Edit the stylesheet' => 'Stilvorlage bearbeiten',
'Edit units' => 'Einheiten bearbeiten',
+ 'Editable' => 'Bearbeitbar',
'Employee' => 'Bearbeiter',
'Empty transaction!' => 'Buchung ist leer!',
'Enter a description for this new draft.' => 'Geben Sie eine Beschreibung für diesen Entwurf ein.',
@@ -887,6 +889,7 @@ $self->{texts} = {
'Line Total' => 'Zeilensumme',
'Line endings' => 'Zeilenumbrüche',
'List (Customers and Vendors)' => 'Auflisten (Kunden und Lieferanten)',
+ 'List (Parts, services, assemblies)' => 'Auflisten (Waren, Dienstleistungen, Erzeugnisse)',
'List (Projects)' => 'Auflisten (Projekte)',
'List Accounting Groups' => 'Buchungsgruppen anzeigen',
'List Accounts' => 'Konten anzeigen',
@@ -958,6 +961,7 @@ $self->{texts} = {
'Mobile1' => 'Mobile 1',
'Mobile2' => 'Mobile 2',
'Model' => 'Lieferanten-Art-Nr.',
+ 'Module' => 'Modul',
'Module home page' => 'Modul-Webseite',
'Module name' => 'Modulname',
'Monat' => 'Monat',
@@ -1068,6 +1072,7 @@ $self->{texts} = {
'Other values are ignored.' => 'Andere Eingaben werden ignoriert.',
'Others' => 'Andere',
'Otherwise all users will only have access to their own settings.' => 'Andernfalls haben alle Benutzer nur Zugriff auf ihre Benutzereinstellungen.',
+ 'Otherwise the variable is only available for printing.' => 'Andernfalls steht die Variable nur beim Ausdruck zur Verfügung.',
'Out of balance transaction!' => 'Buchung ist nicht ausgeglichen!',
'Out of balance!' => 'Summen stimmen nicht berein!',
'Output Number Format' => 'Zahlenformat (Ausgabe)',
@@ -1098,6 +1103,7 @@ $self->{texts} = {
'Parts' => 'Waren',
'Parts Inventory' => 'Warenliste',
'Parts must have an entry type.' => 'Waren müssen eine Buchungsgruppe haben.',
+ 'Parts, services and assemblies' => 'Waren, Dienstleistungen und Erzeugnisse',
'Password' => 'Passwort',
'Payables' => 'Verbindlichkeiten',
'Payment' => 'Zahlungsausgang',
@@ -1510,7 +1516,6 @@ $self->{texts} = {
'The following users have been migrated into the authentication database:' => 'Die folgenden Benutzer wurden in die Authentifizierungsdatenbank migriert:',
'The following warnings occured during an upgrade to the document templates:' => 'Die folgenden Warnungen traten während einer Aktualisierung der Dokumentenvorlagen auf:',
'The formula needs the following syntax:
For regular article:
Variablename= Variable Unit;
Variablename2= Variable2 Unit2;
...
###
Variable + ( Variable2 / Variable )
Please be beware of the spaces in the formula
' => 'Die Formeln müssen in der folgenden Syntax eingegeben werden:
Bei normalen Artikeln:
Variablenname = Variable Einheit;
Variablenname2 = Variable2 Einheit2;
...
###
Variable + Variable2 * ( Variable - Variable2 )
Variablennamen und Einheiten dürfen nur aus alphanumerischen Zeichen bestehen.
Es muss jeweils die Gesamte Zeile eingegeben werden',
- 'The greetings have been saved.' => 'Die Anreden wurden gespeichert',
'The group has been added.' => 'Die Gruppe wurde erfasst.',
'The group has been deleted.' => 'Die Gruppe wurde gelöscht.',
'The group has been saved.' => 'Die Gruppe wurde gespeichert.',
diff --git a/locale/de/menu b/locale/de/menu
index cc0d24b5f..d5beaf60d 100644
--- a/locale/de/menu
+++ b/locale/de/menu
@@ -8,6 +8,7 @@ $self->{texts} = {
'AR Aging' => 'Offene Forderungen',
'Accounting Menu' => 'Kontoverwaltung',
'Add (Customers and Vendors)' => 'Erfassen (Kunden und Lieferanten)',
+ 'Add (Parts, services, assemblies)' => 'Erfassen (Waren, Dienstleistungen, Erzeugnisse)',
'Add (Projects)' => 'Erfassen (Projekte)',
'Add AP Transaction' => 'Kreditorenbuchung',
'Add AR Transaction' => 'Debitorenbuchung',
@@ -119,6 +120,7 @@ $self->{texts} = {
'Lead' => 'Kundenquelle',
'Licenses' => 'Lizenzen',
'List (Customers and Vendors)' => 'Auflisten (Kunden und Lieferanten)',
+ 'List (Parts, services, assemblies)' => 'Auflisten (Waren, Dienstleistungen, Erzeugnisse)',
'List (Projects)' => 'Auflisten (Projekte)',
'List Accounting Groups' => 'Buchungsgruppen anzeigen',
'List Accounts' => 'Konten anzeigen',
diff --git a/locale/de/menunew b/locale/de/menunew
index 6fcf371c5..cb853f166 100644
--- a/locale/de/menunew
+++ b/locale/de/menunew
@@ -7,6 +7,7 @@ $self->{texts} = {
'AR' => 'Verkauf',
'AR Aging' => 'Offene Forderungen',
'Add (Customers and Vendors)' => 'Erfassen (Kunden und Lieferanten)',
+ 'Add (Parts, services, assemblies)' => 'Erfassen (Waren, Dienstleistungen, Erzeugnisse)',
'Add (Projects)' => 'Erfassen (Projekte)',
'Add AP Transaction' => 'Kreditorenbuchung',
'Add AR Transaction' => 'Debitorenbuchung',
@@ -118,6 +119,7 @@ $self->{texts} = {
'Lead' => 'Kundenquelle',
'Licenses' => 'Lizenzen',
'List (Customers and Vendors)' => 'Auflisten (Kunden und Lieferanten)',
+ 'List (Parts, services, assemblies)' => 'Auflisten (Waren, Dienstleistungen, Erzeugnisse)',
'List (Projects)' => 'Auflisten (Projekte)',
'List Accounting Groups' => 'Buchungsgruppen anzeigen',
'List Accounts' => 'Konten anzeigen',
diff --git a/menu.ini b/menu.ini
index 92bbfa855..318759065 100644
--- a/menu.ini
+++ b/menu.ini
@@ -691,6 +691,16 @@ module=amcvar.pl
action=list_cvar_configs
cvar_module=CT
+[System--Custom Variables--Add (Parts, services, assemblies)]
+module=amcvar.pl
+action=add_cvar_config
+cvar_module=IC
+
+[System--Custom Variables--List (Parts, services, assemblies)]
+module=amcvar.pl
+action=list_cvar_configs
+cvar_module=IC
+
[System--Custom Variables--Add (Projects)]
module=amcvar.pl
action=add_cvar_config
diff --git a/templates/webpages/amcvar/display_cvar_config_form_de.html b/templates/webpages/amcvar/display_cvar_config_form_de.html
index 0bee90ba6..3e912112a 100644
--- a/templates/webpages/amcvar/display_cvar_config_form_de.html
+++ b/templates/webpages/amcvar/display_cvar_config_form_de.html
@@ -12,6 +12,19 @@
@@ -111,6 +136,16 @@
Andere Eingaben werden ignoriert.
+ [%- IF module == 'IC' %]
+
+ (5)
+
+ Eine als 'editierbar' markierte Variable kann in jedem Angebot, Auftrag, jeder Rechnung etc für jede Position geändert werden.
+
+ Andernfalls steht die Variable nur beim Ausdruck zur Verfügung.
+
+ [%- END %]
+