use SL::Form;
use Data::Dumper;
+use List::MoreUtils qw(any);
1;
our @types = qw(text textfield number date bool select); # timestamp
+our @modules = ({ module => 'CT', description => $locale->text('Customers and vendors') },
+ { module => 'IC', description => $locale->text('Parts, services and assemblies') },
+ { module => 'Projects', description => $locale->text('Projects') },
+ );
+
sub add {
add_cvar_config();
}
edit_cvar_config();
}
+sub _is_valid_module {
+ my $module = shift;
+
+ return any { $_->{module} eq $module } @modules;
+}
+
sub list_cvar_configs {
$lxdebug->enter_sub();
$auth->assert('config');
- $form->{module} ||= $form->{cvar_module};
+ $form->{module} = $form->{module} || $form->{cvar_module} || 'CT';
+ $form->{module} = 'CT' unless _is_valid_module($form->{module});
- my @configs = grep { $_->{module} eq $form->{module} } @{ CVar->get_configs() };
+ my @configs = @{ CVar->get_configs(module => $form->{module}) };
my $previous_config;
$form->{title} = $locale->text('List of custom variables');
$form->header();
- print $form->parse_html_template('amcvar/list_cvar_configs', { 'CONFIGS' => \@configs });
+ print $form->parse_html_template('amcvar/list_cvar_configs', { CONFIGS => \@configs,
+ MODULES => \@modules });
+
+ $main::lxdebug->dump(0, "modules", \@modules);
$lxdebug->leave_sub();
}
$auth->assert('config');
- $form->{module} ||= $form->{cvar_module};
+ $form->{module} = $form->{module} || $form->{cvar_module} || 'CT';
$form->{edit} = 0;
display_cvar_config_form();
$form->{title} = $form->{edit} ? $locale->text("Edit custom variable") : $locale->text("Add custom variable");
$form->header();
- print $form->parse_html_template("amcvar/display_cvar_config_form", { 'TYPES' => \@types });
+ print $form->parse_html_template("amcvar/display_cvar_config_form", { TYPES => \@types,
+ MODULES => \@modules });
$lxdebug->leave_sub();
}
$lxdebug->leave_sub();
}
+sub dispatcher {
+ foreach my $action (qw(list_cvar_configs add_cvar_config)) {
+ if ($form->{"action_${action}"}) {
+ call_sub($action);
+ return;
+ }
+ }
+
+ $form->error($locale->text('No action defined.'));
+}
+
1;
'Active?' => 'Aktiviert?',
'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',
'Add Account' => 'Konto erfassen',
'Current unit' => 'Aktuelle Einheit',
'Current value:' => 'Aktueller Wert:',
'Custom Variables' => 'Benutzerdefinierte Variablen',
+ 'Custom variables for module' => 'Benutzerdefinierte Variablen für Modul',
'Customer' => 'Kunde',
'Customer Number' => 'Kundennummer',
'Customer Order Number' => 'Bestellnummer des Kunden',
'Limit part selection' => 'Artikelauswahl eingrenzen',
'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' => 'Anzeigen',
'List Accounting Groups' => 'Buchungsgruppen anzeigen',
'List Accounts' => 'Konten anzeigen',
'List Businesses' => 'Kunden-/Lieferantentypen anzeigen',
'Credit Note' => 'Gutschrift',
'Customer Number' => 'Kundennummer',
'Customer details' => 'Kundendetails',
+ 'Customers and vendors' => 'Kunden und Lieferanten',
'DATEV Export' => 'DATEV-Export',
'DELETED' => 'Gelöscht',
'DR' => 'S',
'No %s was found matching the search parameters.' => 'Es wurde kein %s gefunden, auf den die Suchparameter zutreffen.',
'No Customer was found matching the search parameters.' => 'Zu dem Suchbegriff wurde kein Endkunde gefunden',
'No Vendor was found matching the search parameters.' => 'Zu dem Suchbegriff wurde kein Händler gefunden',
+ 'No action defined.' => 'Keine Aktion definiert.',
'No customer has been selected yet.' => 'Es wurde noch kein Kunde ausgewählt.',
'No or an unknown authenticantion module specified in "config/authentication.pl".' => 'Es wurde kein oder ein unbekanntes Authentifizierungsmodul in "config/authentication.pl" angegeben.',
'No part was found matching the search parameters.' => 'Es wurde kein Artikel gefunden, auf den die Suchparameter zutreffen.',
'Packing List' => 'Lieferschein',
'Part Number' => 'Artikelnummer',
'Part description' => 'Artikelbeschreibung',
+ 'Parts, services and assemblies' => 'Waren, Dienstleistungen und Erzeugnisse',
'Pick List' => 'Sammelliste',
'Please enter values' => 'Bitte Werte eingeben',
'Preview' => 'Druckvorschau',
'Proforma Invoice' => 'Proformarechnung',
+ 'Projects' => 'Projekte',
'Purchase Order' => 'Lieferantenauftrag',
'Quotation' => 'Angebot',
'RFQ' => 'Anfrage',
'H' => 'H',
'NTI' => 'NTI',
'Q' => 'Q',
+ '_is_valid_module' => '_is_valid_module',
'add' => 'add',
'add_cvar_config' => 'add_cvar_config',
'ap_transaction' => 'ap_transaction',
'cov_selection_internal' => 'cov_selection_internal',
'delete' => 'delete',
'delivery_customer_selection' => 'delivery_customer_selection',
+ 'dispatcher' => 'dispatcher',
'display_cvar_config_form' => 'display_cvar_config_form',
'edit' => 'edit',
'edit_cvar_config' => 'edit_cvar_config',
'löschen' => 'delete',
'neue_ware' => 'new_part',
'speichern' => 'save',
+ 'zeigen' => 'show',
};
1;
'AR' => 'Verkauf',
'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' => 'Erfassen',
'Add AP Transaction' => 'Kreditorenbuchung',
'Add AR Transaction' => 'Debitorenbuchung',
'Add Account' => 'Konto erfassen',
'Languages' => 'Sprachen',
'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' => 'Anzeigen',
'List Accounting Groups' => 'Buchungsgruppen anzeigen',
'List Accounts' => 'Konten anzeigen',
'List Businesses' => 'Kunden-/Lieferantentypen anzeigen',
'AP Aging' => 'Offene Verbindlichkeiten',
'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' => 'Erfassen',
'Add AP Transaction' => 'Kreditorenbuchung',
'Add AR Transaction' => 'Debitorenbuchung',
'Add Account' => 'Konto erfassen',
'Languages' => 'Sprachen',
'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' => 'Anzeigen',
'List Accounting Groups' => 'Buchungsgruppen anzeigen',
'List Accounts' => 'Konten anzeigen',
'List Businesses' => 'Kunden-/Lieferantentypen anzeigen',
target=acc_menu
submenu=1
-[System--Custom Variables--Add (Customers and Vendors)]
+[System--Custom Variables--Add]
module=amcvar.pl
action=add_cvar_config
-cvar_module=CT
-[System--Custom Variables--List (Customers and Vendors)]
+[System--Custom Variables--List]
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
-cvar_module=Projects
-
-[System--Custom Variables--List (Projects)]
-module=amcvar.pl
-action=list_cvar_configs
-cvar_module=Projects
[System--Warehouses]
module=menu.pl
<tr>
<td align="right">Modul</td>
<td>
- [%- IF module == 'CT' %]
- Kunden und Lieferanten
- [%- ELSIF module == 'Projects' %]
- Projekte
- [%- ELSIF module == 'IC' %]
- Waren, Dienstleistungen und Erzeugnisse
- [%- END %]
+ [%- INCLUDE generic/multibox.html
+ name = 'module',
+ id_key = 'module',
+ label_key = 'description',
+ DATA = MODULES %]
</td>
</tr>
</table>
</p>
- <input type="hidden" name="module" value="[% HTML.escape(module) %]">
- <input type="hidden" name="id" value="[% HTML.escape(id) %]">
+ <input type="hidden" name="id" value="[% HTML.escape(id) %]">
<p>
<input type="submit" name="action" value="Speichern">
<tr>
<td align="right"><translate>Module</translate></td>
<td>
- [%- IF module == 'CT' %]
- <translate>Customers and vendors</translate>
- [%- ELSIF module == 'Projects' %]
- <translate>Projects</translate>
- [%- ELSIF module == 'IC' %]
- <translate>Parts, services and assemblies</translate>
- [%- END %]
+ [%- INCLUDE generic/multibox.html
+ name = 'module',
+ id_key = 'module',
+ label_key = 'description',
+ DATA = MODULES %]
</td>
</tr>
</table>
</p>
- <input type="hidden" name="module" value="[% HTML.escape(module) %]">
- <input type="hidden" name="id" value="[% HTML.escape(id) %]">
+ <input type="hidden" name="id" value="[% HTML.escape(id) %]">
<p>
<input type="submit" name="action" value="<translate>Save</translate>">
<div class="listtop">[% title %]</div>
- <p>
- <table width="100%">
- <tr>
- <td class="listheading" width="0%"></td>
- <td class="listheading" width="0%"></td>
- <td class="listheading" width="20%">Name</td>
- <td class="listheading" width="20%">Beschreibung</td>
- <td class="listheading" width="20%">Typ</td>
- <td class="listheading" width="20%">Durchsuchbar</td>
- <td class="listheading" width="20%">In Berichten anzeigbar</td>
- [%- IF module == 'IC' %]
- <td class="listheading" width="20%">Bearbeitbar</td>
- [%- END %]
- </tr>
+ <form method="post" action="amcvar.pl">
+ <input type="hidden" name="action" value="dispatcher">
+ <input type="hidden" name="callback" value="[% HTML.escape(callback) %]">
- [%- FOREACH cfg = CONFIGS %]
- <tr class="listrow[% loop.count % 2 %]">
- <td>
- [%- IF cfg.previous_id %]
- <a href="amcvar.pl?action=swap_cvar_configs&module=[% HTML.url(module) %]&id1=[% HTML.url(cfg.previous_id) %]&id2=[% HTML.url(cfg.id) %]">
- <img border="0" src="image/up.png"></a>
- [%- END %]
- </td>
+ <p>
+ Benutzerdefinierte Variablen für Modul
+ [%- INCLUDE generic/multibox.html
+ name = 'module',
+ id_key = 'module',
+ label_key = 'description',
+ DATA = MODULES %]
+ <input type="submit" class="submit" name="action_list_cvar_configs" value="Zeigen">
+ </p>
- <td>
- [%- IF cfg.next_id %]
- <a href="amcvar.pl?action=swap_cvar_configs&module=[% HTML.url(module) %]&id1=[% HTML.url(cfg.next_id) %]&id2=[% HTML.url(cfg.id) %]">
- <img border="0" src="image/down.png"></a>
+ <p>
+ <table width="100%">
+ <tr>
+ <td class="listheading" width="0%"></td>
+ <td class="listheading" width="0%"></td>
+ <td class="listheading" width="20%">Name</td>
+ <td class="listheading" width="20%">Beschreibung</td>
+ <td class="listheading" width="20%">Typ</td>
+ <td class="listheading" width="20%">Durchsuchbar</td>
+ <td class="listheading" width="20%">In Berichten anzeigbar</td>
+ [%- IF module == 'IC' %]
+ <td class="listheading" width="20%">Bearbeitbar</td>
[%- END %]
- </td>
+ </tr>
- <td>
- <a href="amcvar.pl?action=edit_cvar_config&module=[% HTML.url(module) %]&id=[% HTML.url(cfg.id) %]&callback=[% HTML.url(callback) %]">
- [% HTML.escape(cfg.name) %]
- </a>
- </td>
+ [%- FOREACH cfg = CONFIGS %]
+ <tr class="listrow[% loop.count % 2 %]">
+ <td>
+ [%- IF cfg.previous_id %]
+ <a href="amcvar.pl?action=swap_cvar_configs&module=[% HTML.url(module) %]&id1=[% HTML.url(cfg.previous_id) %]&id2=[% HTML.url(cfg.id) %]">
+ <img border="0" src="image/up.png"></a>
+ [%- END %]
+ </td>
- <td>[% HTML.escape(cfg.description) %]</td>
- <td>[% HTML.escape(cfg.type_tr) %]</td>
+ <td>
+ [%- IF cfg.next_id %]
+ <a href="amcvar.pl?action=swap_cvar_configs&module=[% HTML.url(module) %]&id1=[% HTML.url(cfg.next_id) %]&id2=[% HTML.url(cfg.id) %]">
+ <img border="0" src="image/down.png"></a>
+ [%- END %]
+ </td>
- <td>
- [%- IF cfg.searchable %]
- Ja
- [%- ELSE %]
- Nein
- [%- END %]
- </td>
+ <td>
+ <a href="amcvar.pl?action=edit_cvar_config&module=[% HTML.url(module) %]&id=[% HTML.url(cfg.id) %]&callback=[% HTML.url(callback) %]">
+ [% HTML.escape(cfg.name) %]
+ </a>
+ </td>
- <td>
- [%- IF cfg.included_by_default %]
- Ja, standardmäßig an
- [%- ELSIF cfg.includeable %]
- Ja
- [%- ELSE %]
- Nein
- [%- END %]
- </td>
+ <td>[% HTML.escape(cfg.description) %]</td>
+ <td>[% HTML.escape(cfg.type_tr) %]</td>
- [%- IF module == 'IC' %]
- <td>
- [%- IF cfg.flag_editable %]
- Ja
- [%- ELSE %]
- Nein
+ <td>
+ [%- IF cfg.searchable %]
+ Ja
+ [%- ELSE %]
+ Nein
+ [%- END %]
+ </td>
+
+ <td>
+ [%- IF cfg.included_by_default %]
+ Ja, standardmäßig an
+ [%- ELSIF cfg.includeable %]
+ Ja
+ [%- ELSE %]
+ Nein
+ [%- END %]
+ </td>
+
+ [%- IF module == 'IC' %]
+ <td>
+ [%- IF cfg.flag_editable %]
+ Ja
+ [%- ELSE %]
+ Nein
+ [%- END %]
+ </td>
[%- END %]
- </td>
+ </tr>
[%- END %]
- </tr>
- [%- END %]
- </table>
- </p>
-
- <hr height="3">
+ </table>
+ </p>
- <p>
- <form method="post" action="amcvar.pl">
- <input type="hidden" name="add_nextsub" value="add_cvar_config">
- <input type="hidden" name="module" value="[% HTML.escape(module) %]">
- <input type="hidden" name="callback" value="[% HTML.escape(callback) %]">
+ <hr height="3">
- <input type="submit" class="submit" name="action" value="Erfassen">
- </form>
- </p>
+ <p>
+ <input type="submit" class="submit" name="action_add_cvar_config" value="Erfassen">
+ </p>
+ </form>
</body>
</html>
<div class="listtop">[% title %]</div>
- <p>
- <table width="100%">
- <tr>
- <td class="listheading" width="0%"></td>
- <td class="listheading" width="0%"></td>
- <td class="listheading" width="20%"><translate>Name</translate></td>
- <td class="listheading" width="20%"><translate>Description</translate></td>
- <td class="listheading" width="20%"><translate>Type</translate></td>
- <td class="listheading" width="20%"><translate>Searchable</translate></td>
- <td class="listheading" width="20%"><translate>Includeable in reports</translate></td>
- [%- IF module == 'IC' %]
- <td class="listheading" width="20%"><translate>Editable</translate></td>
- [%- END %]
- </tr>
+ <form method="post" action="amcvar.pl">
+ <input type="hidden" name="action" value="dispatcher">
+ <input type="hidden" name="callback" value="[% HTML.escape(callback) %]">
- [%- FOREACH cfg = CONFIGS %]
- <tr class="listrow[% loop.count % 2 %]">
- <td>
- [%- IF cfg.previous_id %]
- <a href="amcvar.pl?action=swap_cvar_configs&module=[% HTML.url(module) %]&id1=[% HTML.url(cfg.previous_id) %]&id2=[% HTML.url(cfg.id) %]">
- <img border="0" src="image/up.png"></a>
- [%- END %]
- </td>
+ <p>
+ <translate>Custom variables for module</translate>
+ [%- INCLUDE generic/multibox.html
+ name = 'module',
+ id_key = 'module',
+ label_key = 'description',
+ DATA = MODULES %]
+ <input type="submit" class="submit" name="action_list_cvar_configs" value="<translate>Show</translate>">
+ </p>
- <td>
- [%- IF cfg.next_id %]
- <a href="amcvar.pl?action=swap_cvar_configs&module=[% HTML.url(module) %]&id1=[% HTML.url(cfg.next_id) %]&id2=[% HTML.url(cfg.id) %]">
- <img border="0" src="image/down.png"></a>
+ <p>
+ <table width="100%">
+ <tr>
+ <td class="listheading" width="0%"></td>
+ <td class="listheading" width="0%"></td>
+ <td class="listheading" width="20%"><translate>Name</translate></td>
+ <td class="listheading" width="20%"><translate>Description</translate></td>
+ <td class="listheading" width="20%"><translate>Type</translate></td>
+ <td class="listheading" width="20%"><translate>Searchable</translate></td>
+ <td class="listheading" width="20%"><translate>Includeable in reports</translate></td>
+ [%- IF module == 'IC' %]
+ <td class="listheading" width="20%"><translate>Editable</translate></td>
[%- END %]
- </td>
+ </tr>
- <td>
- <a href="amcvar.pl?action=edit_cvar_config&module=[% HTML.url(module) %]&id=[% HTML.url(cfg.id) %]&callback=[% HTML.url(callback) %]">
- [% HTML.escape(cfg.name) %]
- </a>
- </td>
+ [%- FOREACH cfg = CONFIGS %]
+ <tr class="listrow[% loop.count % 2 %]">
+ <td>
+ [%- IF cfg.previous_id %]
+ <a href="amcvar.pl?action=swap_cvar_configs&module=[% HTML.url(module) %]&id1=[% HTML.url(cfg.previous_id) %]&id2=[% HTML.url(cfg.id) %]">
+ <img border="0" src="image/up.png"></a>
+ [%- END %]
+ </td>
- <td>[% HTML.escape(cfg.description) %]</td>
- <td>[% HTML.escape(cfg.type_tr) %]</td>
+ <td>
+ [%- IF cfg.next_id %]
+ <a href="amcvar.pl?action=swap_cvar_configs&module=[% HTML.url(module) %]&id1=[% HTML.url(cfg.next_id) %]&id2=[% HTML.url(cfg.id) %]">
+ <img border="0" src="image/down.png"></a>
+ [%- END %]
+ </td>
- <td>
- [%- IF cfg.searchable %]
- <translate>Yes</translate>
- [%- ELSE %]
- <translate>No</translate>
- [%- END %]
- </td>
+ <td>
+ <a href="amcvar.pl?action=edit_cvar_config&module=[% HTML.url(module) %]&id=[% HTML.url(cfg.id) %]&callback=[% HTML.url(callback) %]">
+ [% HTML.escape(cfg.name) %]
+ </a>
+ </td>
- <td>
- [%- IF cfg.included_by_default %]
- <translate>Yes, included by default</translate>
- [%- ELSIF cfg.includeable %]
- <translate>Yes</translate>
- [%- ELSE %]
- <translate>No</translate>
- [%- END %]
- </td>
+ <td>[% HTML.escape(cfg.description) %]</td>
+ <td>[% HTML.escape(cfg.type_tr) %]</td>
- [%- IF module == 'IC' %]
- <td>
- [%- IF cfg.flag_editable %]
- <translate>Yes</translate>
- [%- ELSE %]
- <translate>No</translate>
+ <td>
+ [%- IF cfg.searchable %]
+ <translate>Yes</translate>
+ [%- ELSE %]
+ <translate>No</translate>
+ [%- END %]
+ </td>
+
+ <td>
+ [%- IF cfg.included_by_default %]
+ <translate>Yes, included by default</translate>
+ [%- ELSIF cfg.includeable %]
+ <translate>Yes</translate>
+ [%- ELSE %]
+ <translate>No</translate>
+ [%- END %]
+ </td>
+
+ [%- IF module == 'IC' %]
+ <td>
+ [%- IF cfg.flag_editable %]
+ <translate>Yes</translate>
+ [%- ELSE %]
+ <translate>No</translate>
+ [%- END %]
+ </td>
[%- END %]
- </td>
+ </tr>
[%- END %]
- </tr>
- [%- END %]
- </table>
- </p>
-
- <hr height="3">
+ </table>
+ </p>
- <p>
- <form method="post" action="amcvar.pl">
- <input type="hidden" name="add_nextsub" value="add_cvar_config">
- <input type="hidden" name="module" value="[% HTML.escape(module) %]">
- <input type="hidden" name="callback" value="[% HTML.escape(callback) %]">
+ <hr height="3">
- <input type="submit" class="submit" name="action" value="<translate>Add</translate>">
- </form>
- </p>
+ <p>
+ <input type="submit" class="submit" name="action_add_cvar_config" value="<translate>Add</translate>">
+ </p>
+ </form>
</body>
</html>