Revision 2737667a
Von Moritz Bunkus vor mehr als 11 Jahren hinzugefügt
SL/CVar.pm | ||
---|---|---|
64 | 64 |
return $::form->{CVAR_CONFIGS}->{$params{module}}; |
65 | 65 |
} |
66 | 66 |
|
67 |
sub get_config { |
|
68 |
$main::lxdebug->enter_sub(); |
|
69 |
|
|
70 |
my $self = shift; |
|
71 |
my %params = @_; |
|
72 |
|
|
73 |
Common::check_params(\%params, qw(id)); |
|
74 |
|
|
75 |
my $myconfig = \%main::myconfig; |
|
76 |
my $form = $main::form; |
|
77 |
|
|
78 |
my $dbh = $params{dbh} || $form->get_standard_dbh($myconfig); |
|
79 |
|
|
80 |
my $query = qq|SELECT * FROM custom_variable_configs WHERE id = ?|; |
|
81 |
|
|
82 |
my $config = selectfirst_hashref_query($form, $dbh, $query, conv_i($params{id})) || { }; |
|
83 |
|
|
84 |
$self->_unpack_flags($config); |
|
85 |
|
|
86 |
$main::lxdebug->leave_sub(); |
|
87 |
|
|
88 |
return $config; |
|
89 |
} |
|
90 |
|
|
91 | 67 |
sub _unpack_flags { |
92 | 68 |
$main::lxdebug->enter_sub(); |
93 | 69 |
|
... | ... | |
105 | 81 |
$main::lxdebug->leave_sub(); |
106 | 82 |
} |
107 | 83 |
|
108 |
sub save_config { |
|
109 |
$main::lxdebug->enter_sub(); |
|
110 |
|
|
111 |
my $self = shift; |
|
112 |
my %params = @_; |
|
113 |
|
|
114 |
Common::check_params(\%params, qw(module config)); |
|
115 |
|
|
116 |
my $myconfig = \%main::myconfig; |
|
117 |
my $form = $main::form; |
|
118 |
|
|
119 |
my $dbh = $params{dbh} || $form->get_standard_dbh($myconfig); |
|
120 |
|
|
121 |
my $q_id = qq|SELECT nextval('custom_variable_configs_id')|; |
|
122 |
my $h_id = prepare_query($form, $dbh, $q_id); |
|
123 |
|
|
124 |
my $q_new = |
|
125 |
qq|INSERT INTO custom_variable_configs (name, description, type, default_value, options, searchable, includeable, included_by_default, module, flags, id, sortkey) |
|
126 |
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, |
|
127 |
(SELECT COALESCE(MAX(sortkey) + 1, 1) FROM custom_variable_configs))|; |
|
128 |
my $h_new = prepare_query($form, $dbh, $q_new); |
|
129 |
|
|
130 |
my $q_update = |
|
131 |
qq|UPDATE custom_variable_configs SET |
|
132 |
name = ?, description = ?, |
|
133 |
type = ?, default_value = ?, |
|
134 |
options = ?, searchable = ?, |
|
135 |
includeable = ?, included_by_default = ?, |
|
136 |
module = ?, flags = ? |
|
137 |
WHERE id = ?|; |
|
138 |
my $h_update = prepare_query($form, $dbh, $q_update); |
|
139 |
|
|
140 |
my @configs; |
|
141 |
if ('ARRAY' eq ref $params{config}) { |
|
142 |
@configs = @{ $params{config} }; |
|
143 |
} else { |
|
144 |
@configs = ($params{config}); |
|
145 |
} |
|
146 |
|
|
147 |
foreach my $config (@configs) { |
|
148 |
my ($h_actual, $q_actual); |
|
149 |
|
|
150 |
if (!$config->{id}) { |
|
151 |
do_statement($form, $h_id, $q_id); |
|
152 |
($config->{id}) = $h_id->fetchrow_array(); |
|
153 |
|
|
154 |
$h_actual = $h_new; |
|
155 |
$q_actual = $q_new; |
|
156 |
|
|
157 |
} else { |
|
158 |
$h_actual = $h_update; |
|
159 |
$q_actual = $q_update; |
|
160 |
} |
|
161 |
|
|
162 |
do_statement($form, $h_actual, $q_actual, @{$config}{qw(name description type default_value options)}, |
|
163 |
$config->{searchable} ? 't' : 'f', $config->{includeable} ? 't' : 'f', $config->{included_by_default} ? 't' : 'f', |
|
164 |
$params{module}, $config->{flags}, conv_i($config->{id})); |
|
165 |
} |
|
166 |
|
|
167 |
$h_id->finish(); |
|
168 |
$h_new->finish(); |
|
169 |
$h_update->finish(); |
|
170 |
|
|
171 |
$dbh->commit(); |
|
172 |
|
|
173 |
$main::lxdebug->leave_sub(); |
|
174 |
} |
|
175 |
|
|
176 |
sub delete_config { |
|
177 |
$main::lxdebug->enter_sub(); |
|
178 |
|
|
179 |
my $self = shift; |
|
180 |
my %params = @_; |
|
181 |
|
|
182 |
Common::check_params(\%params, qw(id)); |
|
183 |
|
|
184 |
my $myconfig = \%main::myconfig; |
|
185 |
my $form = $main::form; |
|
186 |
|
|
187 |
my $dbh = $params{dbh} || $form->get_standard_dbh($myconfig); |
|
188 |
|
|
189 |
do_query($form, $dbh, qq|DELETE FROM custom_variables WHERE config_id = ?|, conv_i($params{id})); |
|
190 |
do_query($form, $dbh, qq|DELETE FROM custom_variables_validity WHERE config_id = ?|, conv_i($params{id})); |
|
191 |
do_query($form, $dbh, qq|DELETE FROM custom_variable_configs WHERE id = ?|, conv_i($params{id})); |
|
192 |
|
|
193 |
$dbh->commit(); |
|
194 |
|
|
195 |
$main::lxdebug->leave_sub(); |
|
196 |
} |
|
197 |
|
|
198 | 84 |
sub get_custom_variables { |
199 | 85 |
$main::lxdebug->enter_sub(); |
200 | 86 |
|
... | ... | |
768 | 654 |
# dealing with configs |
769 | 655 |
|
770 | 656 |
my $all_configs = CVar->get_configs() |
771 |
my $config = CVar->get_config(id => '1234') |
|
772 |
|
|
773 |
CVar->save_config($config); |
|
774 |
CVar->delete->config($config) |
|
775 | 657 |
|
776 | 658 |
# dealing with custom vars |
777 | 659 |
|
SL/Controller/CustomVariableConfig.pm | ||
---|---|---|
4 | 4 |
|
5 | 5 |
use parent qw(SL::Controller::Base); |
6 | 6 |
|
7 |
use List::Util qw(first); |
|
8 |
|
|
7 | 9 |
use SL::DB::CustomVariableConfig; |
10 |
use SL::Helper::Flash; |
|
11 |
use SL::Locale::String; |
|
12 |
|
|
13 |
use Rose::Object::MakeMethods::Generic ( |
|
14 |
scalar => [ qw(config module module_description flags) ], |
|
15 |
'scalar --get_set_init' => [ qw(translated_types modules) ], |
|
16 |
); |
|
8 | 17 |
|
9 | 18 |
__PACKAGE__->run_before('check_auth'); |
19 |
__PACKAGE__->run_before('check_module'); |
|
20 |
__PACKAGE__->run_before('load_config', only => [ qw(edit update destroy) ]); |
|
21 |
|
|
22 |
our %translations = ( |
|
23 |
text => t8('Free-form text'), |
|
24 |
textfield => t8('Text field'), |
|
25 |
number => t8('Number'), |
|
26 |
date => t8('Date'), |
|
27 |
timestamp => t8('Timestamp'), |
|
28 |
bool => t8('Yes/No (Checkbox)'), |
|
29 |
select => t8('Selection'), |
|
30 |
customer => t8('Customer'), |
|
31 |
vendor => t8('Vendor'), |
|
32 |
part => t8('Part'), |
|
33 |
); |
|
34 |
|
|
35 |
our @types = qw(text textfield number date bool select customer vendor part); # timestamp |
|
10 | 36 |
|
11 | 37 |
# |
12 | 38 |
# actions |
13 | 39 |
# |
14 | 40 |
|
41 |
sub action_list { |
|
42 |
my ($self) = @_; |
|
43 |
|
|
44 |
my $configs = SL::DB::Manager::CustomVariableConfig->get_all_sorted(where => [ module => $self->module ]); |
|
45 |
|
|
46 |
$::form->header; |
|
47 |
$self->render('custom_variable_config/list', |
|
48 |
title => t8('List of custom variables'), |
|
49 |
CONFIGS => $configs); |
|
50 |
} |
|
51 |
|
|
52 |
sub action_new { |
|
53 |
my ($self) = @_; |
|
54 |
|
|
55 |
$self->config(SL::DB::CustomVariableConfig->new(module => $self->module)); |
|
56 |
$self->show_form(title => t8('Add custom variable')); |
|
57 |
} |
|
58 |
|
|
59 |
sub show_form { |
|
60 |
my ($self, %params) = @_; |
|
61 |
|
|
62 |
$self->flags([ |
|
63 |
map { split m/=/, 2 } |
|
64 |
split m/;/, ($self->config->flags || '') |
|
65 |
]); |
|
66 |
|
|
67 |
$::request->layout->focus('#config_name'); |
|
68 |
$self->render('custom_variable_config/form', %params); |
|
69 |
} |
|
70 |
|
|
71 |
sub action_edit { |
|
72 |
my ($self) = @_; |
|
73 |
|
|
74 |
$self->show_form(title => t8('Edit custom variable')); |
|
75 |
} |
|
76 |
|
|
77 |
sub action_create { |
|
78 |
my ($self) = @_; |
|
79 |
|
|
80 |
$self->config(SL::DB::CustomVariableConfig->new); |
|
81 |
$self->create_or_update; |
|
82 |
} |
|
83 |
|
|
84 |
sub action_update { |
|
85 |
my ($self) = @_; |
|
86 |
$self->create_or_update; |
|
87 |
} |
|
88 |
|
|
89 |
sub action_destroy { |
|
90 |
my ($self) = @_; |
|
91 |
|
|
92 |
if (eval { $self->config->delete; 1; }) { |
|
93 |
flash_later('info', t8('The custom variable has been deleted.')); |
|
94 |
} else { |
|
95 |
flash_later('error', t8('The custom variable is in use and cannot be deleted.')); |
|
96 |
} |
|
97 |
|
|
98 |
$self->redirect_to(action => 'list'); |
|
99 |
} |
|
100 |
|
|
15 | 101 |
sub action_reorder { |
16 | 102 |
my ($self) = @_; |
17 | 103 |
|
... | ... | |
28 | 114 |
$::auth->assert('config'); |
29 | 115 |
} |
30 | 116 |
|
117 |
sub check_module { |
|
118 |
my ($self) = @_; |
|
119 |
|
|
120 |
$::form->{module} ||= 'CT'; |
|
121 |
my $mod_desc = first { $_->{module} eq $::form->{module} } @{ $self->modules }; |
|
122 |
die "Invalid 'module' parameter '" . $::form->{module} . "'" if !$mod_desc; |
|
123 |
|
|
124 |
$self->module($mod_desc->{module}); |
|
125 |
$self->module_description($mod_desc->{description}); |
|
126 |
} |
|
127 |
|
|
128 |
sub load_config { |
|
129 |
my ($self) = @_; |
|
130 |
|
|
131 |
$self->config(SL::DB::CustomVariableConfig->new(id => $::form->{id})->load); |
|
132 |
} |
|
133 |
|
|
134 |
# |
|
135 |
# helpers |
|
136 |
# |
|
137 |
|
|
138 |
sub get_translation { |
|
139 |
my ($self, $type) = @_; |
|
140 |
|
|
141 |
return $translations{$type}; |
|
142 |
} |
|
143 |
|
|
144 |
sub init_translated_types { |
|
145 |
my ($self) = @_; |
|
146 |
|
|
147 |
return [ map { { type => $_, translation => $translations{$_} } } @types ]; |
|
148 |
} |
|
149 |
|
|
150 |
sub init_modules { |
|
151 |
my ($self, %params) = @_; |
|
152 |
|
|
153 |
return [ |
|
154 |
{ module => 'CT', description => t8('Customers and vendors') }, |
|
155 |
{ module => 'Contacts', description => t8('Contact persons') }, |
|
156 |
{ module => 'IC', description => t8('Parts, services and assemblies') }, |
|
157 |
{ module => 'Projects', description => t8('Projects') }, |
|
158 |
]; |
|
159 |
} |
|
160 |
|
|
161 |
sub create_or_update { |
|
162 |
my ($self) = @_; |
|
163 |
my $is_new = !$self->config->id; |
|
164 |
|
|
165 |
my $params = delete($::form->{config}) || { }; |
|
166 |
delete $params->{id}; |
|
167 |
|
|
168 |
$params->{default_value} = $::form->parse_amount(\%::myconfig, $params->{default_value}) if $params->{type} eq 'number'; |
|
169 |
$params->{included_by_default} = 0 if !$params->{includeable}; |
|
170 |
$params->{flags} = join ':', map { m/^flag_(.*)/; "${1}=" . delete($params->{$_}) } grep { m/^flag_/ } keys %{ $params }; |
|
171 |
|
|
172 |
$self->config->assign_attributes(%{ $params }, module => $self->module); |
|
173 |
|
|
174 |
my @errors = $self->config->validate; |
|
175 |
|
|
176 |
if (@errors) { |
|
177 |
flash('error', @errors); |
|
178 |
$self->show_form(title => $is_new ? t8('Add new custom variable') : t8('Edit custom variable')); |
|
179 |
return; |
|
180 |
} |
|
181 |
|
|
182 |
$self->config->save; |
|
183 |
|
|
184 |
flash_later('info', $is_new ? t8('The custom variable has been created.') : t8('The custom variable has been saved.')); |
|
185 |
$self->redirect_to(action => 'list', module => $self->module); |
|
186 |
} |
|
187 |
|
|
31 | 188 |
1; |
SL/DB/CustomVariableConfig.pm | ||
---|---|---|
6 | 6 |
use strict; |
7 | 7 |
|
8 | 8 |
use SL::DB::MetaSetup::CustomVariableConfig; |
9 |
use SL::DB::Manager::CustomVariableConfig; |
|
9 | 10 |
use SL::DB::Helper::ActsAsList; |
10 | 11 |
|
11 |
# Creates get_all, get_all_count, get_all_iterator, delete_all and update_all. |
|
12 |
__PACKAGE__->meta->make_manager_class; |
|
12 |
__PACKAGE__->configure_acts_as_list(group_by => [qw(module)]); |
|
13 |
|
|
14 |
sub validate { |
|
15 |
my ($self) = @_; |
|
16 |
|
|
17 |
my @errors; |
|
18 |
push @errors, $::locale->text('The name is missing.') if !$self->name; |
|
19 |
push @errors, $::locale->text('The description is missing.') if !$self->description; |
|
20 |
push @errors, $::locale->text('The type is missing.') if !$self->type; |
|
21 |
push @errors, $::locale->text('The option field is empty.') if (($self->type || '') eq 'select') && !$self->options; |
|
22 |
|
|
23 |
return @errors; |
|
24 |
} |
|
13 | 25 |
|
14 | 26 |
1; |
SL/DB/Manager/CustomVariableConfig.pm | ||
---|---|---|
1 |
package SL::DB::Manager::CustomVariableConfig; |
|
2 |
|
|
3 |
use strict; |
|
4 |
|
|
5 |
use SL::DB::Helper::Manager; |
|
6 |
use base qw(SL::DB::Helper::Manager); |
|
7 |
|
|
8 |
use SL::DB::Helper::Paginated; |
|
9 |
use SL::DB::Helper::Sorted; |
|
10 |
|
|
11 |
sub object_class { 'SL::DB::CustomVariableConfig' } |
|
12 |
|
|
13 |
__PACKAGE__->make_manager_methods; |
|
14 |
|
|
15 |
sub _sort_spec { |
|
16 |
return ( default => [ 'sortkey', 1 ], |
|
17 |
columns => { SIMPLE => 'ALL' } ); |
|
18 |
} |
|
19 |
|
|
20 |
1; |
amcvar.pl | ||
---|---|---|
1 |
am.pl |
bin/mozilla/amcvar.pl | ||
---|---|---|
1 |
#===================================================================== |
|
2 |
# LX-Office ERP |
|
3 |
# Copyright (C) 2004 |
|
4 |
# Based on SQL-Ledger Version 2.1.9 |
|
5 |
# Web http://www.lx-office.org |
|
6 |
# |
|
7 |
#===================================================================== |
|
8 |
# SQL-Ledger Accounting |
|
9 |
# Copyright (c) 1998-2002 |
|
10 |
# |
|
11 |
# Author: Dieter Simader |
|
12 |
# Email: dsimader@sql-ledger.org |
|
13 |
# Web: http://www.sql-ledger.org |
|
14 |
# |
|
15 |
# |
|
16 |
# This program is free software; you can redistribute it and/or modify |
|
17 |
# it under the terms of the GNU General Public License as published by |
|
18 |
# the Free Software Foundation; either version 2 of the License, or |
|
19 |
# (at your option) any later version. |
|
20 |
# |
|
21 |
# This program is distributed in the hope that it will be useful, |
|
22 |
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
23 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
24 |
# GNU General Public License for more details. |
|
25 |
# You should have received a copy of the GNU General Public License |
|
26 |
# along with this program; if not, write to the Free Software |
|
27 |
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
|
28 |
#====================================================================== |
|
29 |
# |
|
30 |
# administration |
|
31 |
# |
|
32 |
#====================================================================== |
|
33 |
|
|
34 |
use SL::AM; |
|
35 |
use SL::CVar; |
|
36 |
use SL::Form; |
|
37 |
|
|
38 |
use Data::Dumper; |
|
39 |
use List::MoreUtils qw(any); |
|
40 |
|
|
41 |
require "bin/mozilla/common.pl"; |
|
42 |
|
|
43 |
use strict; |
|
44 |
|
|
45 |
1; |
|
46 |
|
|
47 |
# end of main |
|
48 |
|
|
49 |
my $locale = $main::locale; |
|
50 |
our %translations = ('text' => $locale->text('Free-form text'), |
|
51 |
'textfield' => $locale->text('Text field'), |
|
52 |
'number' => $locale->text('Number'), |
|
53 |
'date' => $locale->text('Date'), |
|
54 |
'timestamp' => $locale->text('Timestamp'), |
|
55 |
'bool' => $locale->text('Yes/No (Checkbox)'), |
|
56 |
'select' => $locale->text('Selection'), |
|
57 |
'customer' => $locale->text('Customer'), |
|
58 |
'vendor' => $locale->text('Vendor'), |
|
59 |
'part' => $locale->text('Part'), |
|
60 |
); |
|
61 |
|
|
62 |
our @types = qw(text textfield number date bool select customer vendor part); # timestamp |
|
63 |
|
|
64 |
our @modules = ({ module => 'CT', description => $locale->text('Customers and vendors') }, |
|
65 |
{ module => 'Contacts', description => $locale->text('Contact persons') }, |
|
66 |
{ module => 'IC', description => $locale->text('Parts, services and assemblies') }, |
|
67 |
{ module => 'Projects', description => $locale->text('Projects') }, |
|
68 |
); |
|
69 |
|
|
70 |
sub add { |
|
71 |
add_cvar_config(); |
|
72 |
} |
|
73 |
|
|
74 |
sub edit { |
|
75 |
edit_cvar_config(); |
|
76 |
} |
|
77 |
|
|
78 |
sub _is_valid_module { |
|
79 |
my $module = shift; |
|
80 |
|
|
81 |
return any { $_->{module} eq $module } @modules; |
|
82 |
} |
|
83 |
|
|
84 |
sub list_cvar_configs { |
|
85 |
$main::lxdebug->enter_sub(); |
|
86 |
|
|
87 |
my $form = $main::form; |
|
88 |
my $locale = $main::locale; |
|
89 |
|
|
90 |
$main::auth->assert('config'); |
|
91 |
|
|
92 |
$form->{module} = $form->{module} || $form->{cvar_module} || 'CT'; |
|
93 |
$form->{module} = 'CT' unless _is_valid_module($form->{module}); |
|
94 |
|
|
95 |
my @configs = @{ CVar->get_configs(module => $form->{module}) }; |
|
96 |
|
|
97 |
foreach my $config (@configs) { |
|
98 |
$config->{type_tr} = $translations{$config->{type}}; |
|
99 |
} |
|
100 |
|
|
101 |
$form->{title} = $locale->text('List of custom variables'); |
|
102 |
$form->header(); |
|
103 |
print $form->parse_html_template('amcvar/list_cvar_configs', { CONFIGS => \@configs, |
|
104 |
MODULES => \@modules }); |
|
105 |
|
|
106 |
# $main::lxdebug->dump(0, "modules", \@modules); |
|
107 |
|
|
108 |
$main::lxdebug->leave_sub(); |
|
109 |
} |
|
110 |
|
|
111 |
sub add_cvar_config { |
|
112 |
$main::lxdebug->enter_sub(); |
|
113 |
|
|
114 |
my $form = $main::form; |
|
115 |
|
|
116 |
$main::auth->assert('config'); |
|
117 |
|
|
118 |
$form->{module} = $form->{module} || $form->{cvar_module} || 'CT'; |
|
119 |
|
|
120 |
$form->{edit} = 0; |
|
121 |
display_cvar_config_form(); |
|
122 |
|
|
123 |
$main::lxdebug->leave_sub(); |
|
124 |
} |
|
125 |
|
|
126 |
sub edit_cvar_config { |
|
127 |
$main::lxdebug->enter_sub(); |
|
128 |
|
|
129 |
my $form = $main::form; |
|
130 |
|
|
131 |
$main::auth->assert('config'); |
|
132 |
|
|
133 |
my $config = CVar->get_config('id' => $form->{id}); |
|
134 |
|
|
135 |
map { $form->{$_} = $config->{$_} } keys %{ $config }; |
|
136 |
|
|
137 |
$form->{edit} = 1; |
|
138 |
display_cvar_config_form(); |
|
139 |
|
|
140 |
$main::lxdebug->leave_sub(); |
|
141 |
} |
|
142 |
|
|
143 |
sub save { |
|
144 |
$main::lxdebug->enter_sub(); |
|
145 |
|
|
146 |
my $form = $main::form; |
|
147 |
my %myconfig = %main::myconfig; |
|
148 |
my $locale = $main::locale; |
|
149 |
|
|
150 |
$main::auth->assert('config'); |
|
151 |
|
|
152 |
$form->isblank('name', $locale->text('The name is missing.')); |
|
153 |
$form->isblank('description', $locale->text('The description is missing.')); |
|
154 |
$form->isblank('options', $locale->text('The option field is empty.')) if ($form->{type} eq 'select'); |
|
155 |
|
|
156 |
if ($form->{name} !~ /^[a-z][a-z0-9_]*$/i) { |
|
157 |
$form->error($locale->text('The name must only consist of letters, numbers and underscores and start with a letter.')); |
|
158 |
} |
|
159 |
|
|
160 |
if (($form->{type} eq 'number') && ($form->{default_value} ne '')) { |
|
161 |
$form->{default_value} = $form->parse_amount(\%myconfig, $form->{default_value}); |
|
162 |
} |
|
163 |
|
|
164 |
$form->{included_by_default} = $form->{inclusion} eq 'yes_default_on'; |
|
165 |
$form->{includeable} = $form->{inclusion} ne 'no'; |
|
166 |
$form->{flags} = join ':', map { m/^flag_(.*)/; "${1}=" . $form->{$_} } grep { m/^flag_/ } keys %{ $form }; |
|
167 |
|
|
168 |
CVar->save_config('module' => $form->{module}, |
|
169 |
'config' => $form); |
|
170 |
|
|
171 |
$form->{MESSAGE} = $locale->text('The custom variable has been saved.'); |
|
172 |
|
|
173 |
list_cvar_configs(); |
|
174 |
|
|
175 |
$main::lxdebug->leave_sub(); |
|
176 |
} |
|
177 |
|
|
178 |
sub delete { |
|
179 |
$main::lxdebug->enter_sub(); |
|
180 |
|
|
181 |
my $form = $main::form; |
|
182 |
my $locale = $main::locale; |
|
183 |
|
|
184 |
CVar->delete_config('id' => $form->{id}); |
|
185 |
|
|
186 |
$form->{MESSAGE} = $locale->text('The custom variable has been deleted.'); |
|
187 |
|
|
188 |
list_cvar_configs(); |
|
189 |
|
|
190 |
$main::lxdebug->leave_sub(); |
|
191 |
} |
|
192 |
|
|
193 |
sub display_cvar_config_form { |
|
194 |
$main::lxdebug->enter_sub(); |
|
195 |
|
|
196 |
my $form = $main::form; |
|
197 |
my %myconfig = %main::myconfig; |
|
198 |
my $locale = $main::locale; |
|
199 |
|
|
200 |
$main::auth->assert('config'); |
|
201 |
|
|
202 |
my @types = map { { 'type' => $_, 'type_tr' => $translations{$_} } } @types; |
|
203 |
|
|
204 |
if (($form->{type} eq 'number') && ($form->{default_value} ne '')) { |
|
205 |
$form->{default_value} = $form->format_amount(\%myconfig, $form->{default_value}); |
|
206 |
} |
|
207 |
|
|
208 |
$form->{title} = $form->{edit} ? $locale->text("Edit custom variable") : $locale->text("Add custom variable"); |
|
209 |
|
|
210 |
$form->header(); |
|
211 |
print $form->parse_html_template("amcvar/display_cvar_config_form", { TYPES => \@types, |
|
212 |
MODULES => \@modules }); |
|
213 |
|
|
214 |
$main::lxdebug->leave_sub(); |
|
215 |
} |
|
216 |
|
|
217 |
sub update { |
|
218 |
$main::lxdebug->enter_sub(); |
|
219 |
|
|
220 |
my $form = $main::form; |
|
221 |
|
|
222 |
$main::auth->assert('config'); |
|
223 |
|
|
224 |
$form->{included_by_default} = $form->{inclusion} eq 'yes_default_on'; |
|
225 |
$form->{includeable} = $form->{inclusion} ne 'no'; |
|
226 |
|
|
227 |
display_cvar_config_form(); |
|
228 |
|
|
229 |
$main::lxdebug->leave_sub(); |
|
230 |
} |
|
231 |
|
|
232 |
|
|
233 |
sub dispatcher { |
|
234 |
my $form = $main::form; |
|
235 |
my $locale = $main::locale; |
|
236 |
|
|
237 |
foreach my $action (qw(list_cvar_configs add_cvar_config update)) { |
|
238 |
if ($form->{"action_${action}"}) { |
|
239 |
call_sub($action); |
|
240 |
return; |
|
241 |
} |
|
242 |
} |
|
243 |
|
|
244 |
$form->error($locale->text('No action defined.')); |
|
245 |
} |
|
246 |
|
|
247 |
1; |
|
248 |
|
css/kivitendo/main.css | ||
---|---|---|
376 | 376 |
margin-left: 6px; |
377 | 377 |
margin-right: 6px; |
378 | 378 |
} |
379 |
|
|
380 |
.small-text { |
|
381 |
font-size: 0.75em; |
|
382 |
} |
css/lx-office-erp/main.css | ||
---|---|---|
428 | 428 |
margin-left: 6px; |
429 | 429 |
margin-right: 6px; |
430 | 430 |
} |
431 |
|
|
432 |
.small-text { |
|
433 |
font-size: 0.75em; |
|
434 |
} |
js/locale/de.js | ||
---|---|---|
1 | 1 |
namespace("kivi").setupLocale({ |
2 |
"The description is missing.":"Die Beschreibung fehlt.", |
|
3 |
"The name is missing.":"Der Name fehlt.", |
|
4 |
"The name must only consist of letters, numbers and underscores and start with a letter.":"Der Name darf nur aus Buchstaben (keine Umlaute), Ziffern und Unterstrichen bestehen und muss mit einem Buchstaben beginnen.", |
|
5 |
"The option field is empty.":"Das Optionsfeld ist leer." |
|
2 | 6 |
}); |
locale/de/all | ||
---|---|---|
164 | 164 |
'Add link: select records to link with' => 'Verknüpfungen hinzufügen: zu verknüpfende Belege auswählen', |
165 | 165 |
'Add links' => 'Verknüpfungen hinzufügen', |
166 | 166 |
'Add new currency' => 'Neue Währung hinzufügen', |
167 |
'Add new custom variable' => 'Neue benutzerdefinierte Variable erfassen', |
|
167 | 168 |
'Add note' => 'Notiz erfassen', |
168 | 169 |
'Add printer' => 'Drucker hinzufügen', |
169 | 170 |
'Add unit' => 'Einheit hinzufügen', |
... | ... | |
1052 | 1053 |
'Include in drop-down menus' => 'In Aufklappmenü aufnehmen', |
1053 | 1054 |
'Include invalid warehouses ' => 'Ungültige Lager berücksichtigen', |
1054 | 1055 |
'Includeable in reports' => 'In Berichten anzeigbar', |
1056 |
'Included in reports by default' => 'In Berichten standardmäßig enthalten', |
|
1055 | 1057 |
'Including' => 'Enthaltene', |
1056 | 1058 |
'Income Statement' => 'GuV', |
1057 | 1059 |
'Incoming Payments' => 'Zahlungseingänge', |
... | ... | |
1996 | 1998 |
'The connection was established successfully.' => 'Die Verbindung zur Datenbank wurde erfolgreich hergestellt.', |
1997 | 1999 |
'The contact person attribute "birthday" is converted from a free-form text field into a date field.' => 'Das Kontaktpersonenfeld "Geburtstag" wird von einem freien Textfeld auf ein Datumsfeld umgestellt.', |
1998 | 2000 |
'The creation of the authentication database failed:' => 'Das Anlegen der Authentifizierungsdatenbank schlug fehl:', |
2001 |
'The custom variable has been created.' => 'Die benutzerdefinierte Varieble wurde erfasst.', |
|
1999 | 2002 |
'The custom variable has been deleted.' => 'Die benutzerdefinierte Variable wurde gelöscht.', |
2000 | 2003 |
'The custom variable has been saved.' => 'Die benutzerdefinierte Variable wurde gespeichert.', |
2004 |
'The custom variable is in use and cannot be deleted.' => 'Die benutzerdefinierte Variable ist in Benutzung und kann nicht gelöscht werden.', |
|
2001 | 2005 |
'The database for user management and authentication does not exist. You can create let kivitendo create it with the following parameters:' => 'Die Datenbank für die Benutzeranmeldung existiert nicht. Sie können Sie von kivitendo automatisch mit den folgenden Parametern anlegen lassen:', |
2002 | 2006 |
'The database host is missing.' => 'Der Datenbankhost fehlt.', |
2003 | 2007 |
'The database name is missing.' => 'Der Datenbankname fehlt.', |
... | ... | |
2107 | 2111 |
'The third way is to download the module from the above mentioned URL and to install the module manually following the installations instructions contained in the source archive.' => 'Die dritte Variante besteht darin, das Paket von der oben genannten URL herunterzuladen und es manuell zu installieren. Beachten Sie dabei die im Paket enthaltenen Installationsanweisungen.', |
2108 | 2112 |
'The three columns "make_X", "model_X" and "lastcost_X" with the same number "X" are used to import vendor part numbers and vendor prices.' => 'Die drei Spalten "make_X", "model_X" und "lastcost_X" mit derselben Nummer "X" werden zum Import von Lieferantenartikelnummern und -preisen genutzt.', |
2109 | 2113 |
'The transaction is shown below in its current state.' => 'Nachfolgend wird angezeigt, wie die Buchung momentan aussieht.', |
2114 |
'The type is missing.' => 'Der Typ fehlt.', |
|
2110 | 2115 |
'The unit has been saved.' => 'Die Einheit wurde gespeichert.', |
2111 | 2116 |
'The unit in row %d has been deleted in the meantime.' => 'Die Einheit in Zeile %d ist in der Zwischentzeit gelöscht worden.', |
2112 | 2117 |
'The unit in row %d has been used in the meantime and cannot be changed anymore.' => 'Die Einheit in Zeile %d wurde in der Zwischenzeit benutzt und kann nicht mehr geändert werden.', |
menu.ini | ||
---|---|---|
598 | 598 |
action=PaymentTerm/list |
599 | 599 |
|
600 | 600 |
[System--Manage Custom Variables] |
601 |
module=amcvar.pl
|
|
602 |
action=list_cvar_configs
|
|
601 |
module=controller.pl
|
|
602 |
action=CustomVariableConfig/list
|
|
603 | 603 |
|
604 | 604 |
[System--Warehouses] |
605 | 605 |
module=am.pl |
scripts/mklinks.sh | ||
---|---|---|
1 |
#!/bin/sh |
|
2 |
|
|
3 |
for i in am dispatcher login; do |
|
4 |
rm $i.pl 2> /dev/null |
|
5 |
ln -s admin.pl $i.pl |
|
6 |
done |
|
7 |
for i in acctranscorrections amcvar amtemplates ap ar bankaccounts bp ca common cp ct datev dn do fu gl ic ir is menujs menunew menu menuv3 menuv4 oe pe projects rc rp sepa todo ustva wh vk; do |
|
8 |
rm $i.pl 2> /dev/null |
|
9 |
ln -s am.pl $i.pl |
|
10 |
done |
|
11 |
rm generictranslations.pl licenses.pl 2> /dev/null |
|
12 |
ln -s common.pl generictranslations.pl |
|
13 |
rm dispatcher.fcgi 2> /dev/null |
|
14 |
ln -s dispatcher.fpl dispatcher.fcgi |
templates/webpages/amcvar/display_cvar_config_form.html | ||
---|---|---|
1 |
[%- USE T8 %] |
|
2 |
[%- USE HTML %] |
|
3 |
<script type='text/javascript'> |
|
4 |
$(function(){document.Form.name.focus();}); |
|
5 |
</script> |
|
6 |
|
|
7 |
<style type="text/css"> |
|
8 |
.small { |
|
9 |
font-size: 0.75em; |
|
10 |
} |
|
11 |
</style> |
|
12 |
|
|
13 |
<div class="listtop">[% title %]</div> |
|
14 |
|
|
15 |
<form action="amcvar.pl" name="Form" method="post"> |
|
16 |
|
|
17 |
<p> |
|
18 |
<table> |
|
19 |
<tr> |
|
20 |
<td align="right">[% 'Module' | $T8 %]</td> |
|
21 |
<td> |
|
22 |
[%- INCLUDE generic/multibox.html |
|
23 |
name = 'module', |
|
24 |
id_key = 'module', |
|
25 |
label_key = 'description', |
|
26 |
DATA = MODULES, |
|
27 |
onChange = "document.getElementById('update_button').click();" %] |
|
28 |
</td> |
|
29 |
</tr> |
|
30 |
|
|
31 |
<tr> |
|
32 |
<td align="right">[% 'Variable Name' | $T8 %]<sup><span class="small">(1)</span></sup></td> |
|
33 |
<td><input name="name" value="[% HTML.escape(name) %]"></td> |
|
34 |
</tr> |
|
35 |
|
|
36 |
<tr> |
|
37 |
<td align="right">[% 'Variable Description' | $T8 %]<sup><span class="small">(2)</span></sup></td> |
|
38 |
<td><input name="description" value="[% HTML.escape(description) %]"></td> |
|
39 |
</tr> |
|
40 |
|
|
41 |
<tr> |
|
42 |
<td align="right">[% 'Type' | $T8 %]<sup><span class="small">(3)</span></sup></td> |
|
43 |
<td> |
|
44 |
<select name="type"> |
|
45 |
[%- FOREACH row = TYPES %] |
|
46 |
<option value="[% HTML.escape(row.type) %]"[% IF row.type == type %] selected[% END %]>[% HTML.escape(row.type_tr) %]</option> |
|
47 |
[%- END %] |
|
48 |
</select> |
|
49 |
</td> |
|
50 |
</tr> |
|
51 |
|
|
52 |
<tr> |
|
53 |
<td align="right">[% 'Default value' | $T8 %]<sup><span class="small">(4)</span></sup></td> |
|
54 |
<td><input name="default_value" value="[% HTML.escape(default_value) %]"></td> |
|
55 |
</tr> |
|
56 |
|
|
57 |
<tr> |
|
58 |
<td align="right">[% 'Options' | $T8 %]<sup><span class="small">(5)</span></sup></td> |
|
59 |
<td><input name="options" value="[% HTML.escape(options) %]"></td> |
|
60 |
</tr> |
|
61 |
|
|
62 |
<tr> |
|
63 |
<td align="right">[% 'Is Searchable' | $T8 %]<sup><span class="small"></span></sup></td> |
|
64 |
<td> |
|
65 |
<input type="radio" name="searchable" id="searchable_1" value="1"[% IF searchable %] checked[% END %]> |
|
66 |
<label for="searchable_1">[% 'Yes' | $T8 %]</label> |
|
67 |
<input type="radio" name="searchable" id="searchable_0" value="0"[% UNLESS searchable %] checked[% END %]> |
|
68 |
<label for="searchable_0">[% 'No' | $T8 %]</label> |
|
69 |
</td> |
|
70 |
</tr> |
|
71 |
|
|
72 |
<tr> |
|
73 |
<td align="right">[% 'Includeable in reports' | $T8 %]<sup><span class="small"></span></sup></td> |
|
74 |
<td> |
|
75 |
<select name="inclusion"> |
|
76 |
<option value="no"[% UNLESS includeable %] selected[% END %]>[% 'No' | $T8 %]</option> |
|
77 |
<option value="yes"[% IF includeable && !included_by_default %] selected[% END %]>[% 'Yes' | $T8 %]</option> |
|
78 |
<option value="yes_default_on"[% IF included_by_default %] selected[% END %]>[% 'Yes, included by default' | $T8 %]</option> |
|
79 |
</select> |
|
80 |
</td> |
|
81 |
</tr> |
|
82 |
|
|
83 |
[%- IF module == 'IC' %] |
|
84 |
<tr> |
|
85 |
<td align="right">[% 'Editable' | $T8 %]<sup><span class="small">(5)</span></sup></td> |
|
86 |
<td> |
|
87 |
<input type="radio" name="flag_editable" id="flag_editable_1" value="1"[% IF flag_editable %] checked[% END %]> |
|
88 |
<label for="flag_editable_1">[% 'Yes' | $T8 %]</label> |
|
89 |
<input type="radio" name="flag_editable" id="flag_editable_0" value="0"[% UNLESS flag_editable %] checked[% END %]> |
|
90 |
<label for="flag_editable_0">[% 'No' | $T8 %]</label> |
|
91 |
</td> |
|
92 |
</tr> |
|
93 |
[%- END %] |
|
94 |
</table> |
|
95 |
</p> |
|
96 |
|
|
97 |
<input type="hidden" name="id" value="[% HTML.escape(id) %]"> |
|
98 |
|
|
99 |
<p> |
|
100 |
<input type="submit" name="action" id="update_button" value="[% 'Update' | $T8 %]"> |
|
101 |
<input type="submit" name="action" value="[% 'Save' | $T8 %]"> |
|
102 |
[%- IF id %] |
|
103 |
<input type="submit" name="action" value="[% 'Delete' | $T8 %]"> |
|
104 |
[%- END %] |
|
105 |
</p> |
|
106 |
|
|
107 |
<hr> |
|
108 |
|
|
109 |
<h3>[% 'Annotations' | $T8 %]</h3> |
|
110 |
|
|
111 |
<p> |
|
112 |
(1) [% 'The variable name must only consist of letters, numbers and underscores. It must begin with a letter. Example: send_christmas_present' | $T8 %] |
|
113 |
</p> |
|
114 |
|
|
115 |
<p> |
|
116 |
(2) [% 'The description is shown on the form. Chose something short and descriptive.' | $T8 %] |
|
117 |
</p> |
|
118 |
<p> |
|
119 |
(3) [% 'For type "customer" the perl module JSON is required. Please check this on system level: $ ./scripts/installation_check.pl' | $T8 %] |
|
120 |
</p> |
|
121 |
|
|
122 |
<p> |
|
123 |
(4) [% 'The default value depends on the variable type:' | $T8 %] |
|
124 |
<br> |
|
125 |
<ul> |
|
126 |
<li>[%- 'Text, text field and number variables: The default value will be used as-is.' | $T8 %]</li> |
|
127 |
<li>[%- 'Boolean variables: If the default value is non-empty then the checkbox will be checked by default and unchecked otherwise.' | $T8 %]</li> |
|
128 |
<li>[%- 'Date and timestamp variables: If the default value equals \'NOW\' then the current date/current timestamp will be used. Otherwise the default value is copied as-is.' | $T8 %]</li> |
|
129 |
</ul> |
|
130 |
</p> |
|
131 |
|
|
132 |
<p> |
|
133 |
(5) [% 'The available options depend on the varibale type:' | $T8 %] |
|
134 |
<br> |
|
135 |
<ul> |
|
136 |
<li>[%- 'Text variables: \'MAXLENGTH=n\' sets the maximum entry length to \'n\'.' | $T8 %]</li> |
|
137 |
<li>[%- 'Text field variables: \'WIDTH=w HEIGHT=h\' sets the width and height of the text field. They default to 30 and 5 respectively.' | $T8 %]</li> |
|
138 |
<li>[%- 'Number variables: \'PRECISION=n\' forces numbers to be shown with exactly n decimal places.' | $T8 %]</li> |
|
139 |
<li>[%- 'Selection fields: The option field must contain the available options for the selection. Options are separated by \'##\', for example \'Early##Normal##Late\'.' | $T8 %]</li> |
|
140 |
</ul> |
|
141 |
<br> |
|
142 |
[% 'Other values are ignored.' | $T8 %] |
|
143 |
</p> |
|
144 |
|
|
145 |
[%- IF module == 'IC' %] |
|
146 |
<p> |
|
147 |
(6) |
|
148 |
|
|
149 |
[%- 'A variable marked as \'editable\' can be changed in each quotation, order, invoice etc.' | $T8 %] |
|
150 |
|
|
151 |
[% 'Otherwise the variable is only available for printing.' | $T8 %] |
|
152 |
</p> |
|
153 |
[%- END %] |
|
154 |
|
|
155 |
</form> |
|
156 |
|
templates/webpages/amcvar/list_cvar_configs.html | ||
---|---|---|
1 |
[%- USE T8 %][% USE LxERP %][% USE L %] |
|
2 |
[% USE HTML %] |
|
3 |
|
|
4 |
[% IF MESSAGE %]<p>[% MESSAGE %]</p>[% END %] |
|
5 |
|
|
6 |
<div class="listtop">[% title %]</div> |
|
7 |
|
|
8 |
<form method="post" action="amcvar.pl"> |
|
9 |
<input type="hidden" name="action" value="dispatcher"> |
|
10 |
<input type="hidden" name="callback" value="[% HTML.escape(callback) %]"> |
|
11 |
|
|
12 |
<p> |
|
13 |
[% 'Custom variables for module' | $T8 %] |
|
14 |
[%- INCLUDE generic/multibox.html |
|
15 |
name = 'module', |
|
16 |
id_key = 'module', |
|
17 |
label_key = 'description', |
|
18 |
DATA = MODULES %] |
|
19 |
<input type="submit" class="submit" name="action_list_cvar_configs" value="[% 'Show' | $T8 %]"> |
|
20 |
</p> |
|
21 |
|
|
22 |
<p> |
|
23 |
<table width="100%" id="cvarcfg_list"> |
|
24 |
<thead> |
|
25 |
<tr class="listheading"> |
|
26 |
<th align="center"><img src="image/updown.png" alt="[ LxERP.t8('reorder item') %]"></th> |
|
27 |
<th width="20%">[% 'Name' | $T8 %]</th> |
|
28 |
<th width="20%">[% 'Description' | $T8 %]</th> |
|
29 |
<th width="20%">[% 'Type' | $T8 %]</th> |
|
30 |
<th width="20%">[% 'Searchable' | $T8 %]</th> |
|
31 |
<th width="20%">[% 'Includeable in reports' | $T8 %]</th> |
|
32 |
[%- IF module == 'IC' %] |
|
33 |
<th width="20%">[% 'Editable' | $T8 %]</th> |
|
34 |
[%- END %] |
|
35 |
</tr> |
|
36 |
</thead> |
|
37 |
|
|
38 |
<tbody> |
|
39 |
[%- FOREACH cfg = CONFIGS %] |
|
40 |
<tr class="listrow[% loop.count % 2 %]" id="cvarcfg_id_[% cfg.id %]"> |
|
41 |
<td align="center" class="dragdrop"><img src="image/updown.png" alt="[ LxERP.t8('reorder item') %]"></td> |
|
42 |
|
|
43 |
<td> |
|
44 |
<a href="amcvar.pl?action=edit_cvar_config&module=[% HTML.url(module) %]&id=[% HTML.url(cfg.id) %]&callback=[% HTML.url(callback) %]"> |
|
45 |
[% HTML.escape(cfg.name) %] |
|
46 |
</a> |
|
47 |
</td> |
|
48 |
|
|
49 |
<td>[% HTML.escape(cfg.description) %]</td> |
|
50 |
<td>[% HTML.escape(cfg.type_tr) %]</td> |
|
51 |
|
|
52 |
<td> |
|
53 |
[%- IF cfg.searchable %] |
|
54 |
[% 'Yes' | $T8 %] |
|
55 |
[%- ELSE %] |
|
56 |
[% 'No' | $T8 %] |
|
57 |
[%- END %] |
|
58 |
</td> |
|
59 |
|
|
60 |
<td> |
|
61 |
[%- IF cfg.included_by_default %] |
|
62 |
[% 'Yes, included by default' | $T8 %] |
|
63 |
[%- ELSIF cfg.includeable %] |
|
64 |
[% 'Yes' | $T8 %] |
|
65 |
[%- ELSE %] |
|
66 |
[% 'No' | $T8 %] |
|
67 |
[%- END %] |
|
68 |
</td> |
|
69 |
|
|
70 |
[%- IF module == 'IC' %] |
|
71 |
<td> |
|
72 |
[%- IF cfg.flag_editable %] |
|
73 |
[% 'Yes' | $T8 %] |
|
74 |
[%- ELSE %] |
|
75 |
[% 'No' | $T8 %] |
|
76 |
[%- END %] |
|
77 |
</td> |
|
78 |
[%- END %] |
|
79 |
</tr> |
|
80 |
[%- END %] |
|
81 |
</tbody> |
|
82 |
</table> |
|
83 |
</p> |
|
84 |
|
|
85 |
<hr height="3"> |
|
86 |
|
|
87 |
<p> |
|
88 |
<a href="amcvar.pl?action=add_cvar_config&callback=[% HTML.url(callback) %]">[%- 'Add' | $T8 %]</a> |
|
89 |
</p> |
|
90 |
</form> |
|
91 |
|
|
92 |
[% L.sortable_element('#cvarcfg_list tbody', url => 'controller.pl?action=CustomVariableConfig/reorder', with => 'cvarcfg_id') %] |
templates/webpages/custom_variable_config/form.html | ||
---|---|---|
1 |
[%- USE HTML -%][%- USE LxERP -%][%- USE L -%][%- USE T8 -%]<h1>[% HTML.escape(title) %]</h1> |
|
2 |
|
|
3 |
<form action="controller.pl" method="post"> |
|
4 |
[%- L.hidden_tag("id", SELF.config.id) %] |
|
5 |
|
|
6 |
<p> |
|
7 |
<table> |
|
8 |
<tr> |
|
9 |
<td align="right">[% 'Module' | $T8 %]</td> |
|
10 |
<td>[%- L.select_tag('module', SELF.modules, value_key='module', title_key='description', default=SELF.module, onchange="update_ic_rows();") %]</td> |
|
11 |
</tr> |
|
12 |
|
|
13 |
<tr> |
|
14 |
<td align="right">[% 'Variable Name' | $T8 %]<sup><span class="small-text">(1)</span></sup></td> |
|
15 |
<td>[%- L.input_tag("config.name", SELF.config.name) %]</td> |
|
16 |
</tr> |
|
17 |
|
|
18 |
<tr> |
|
19 |
<td align="right">[% 'Variable Description' | $T8 %]<sup><span class="small-text">(2)</span></sup></td> |
|
20 |
<td>[%- L.input_tag("config.description", SELF.config.description) %]</td> |
|
21 |
</tr> |
|
22 |
|
|
23 |
<tr> |
|
24 |
<td align="right">[% 'Type' | $T8 %]<sup><span class="small-text">(3)</span></sup></td> |
|
25 |
<td>[% L.select_tag("config.type", SELF.translated_types, value_key='type', title_key='translation', default=SELF.config.type) %]</td> |
|
26 |
</tr> |
|
27 |
|
|
28 |
<tr> |
|
29 |
<td align="right">[% 'Default value' | $T8 %]<sup><span class="small-text">(4)</span></sup></td> |
|
30 |
<td>[%- L.input_tag("config.default_value", SELF.config.type == 'number' ? LxERP.format_amount(SELF.config.default_value, 2) : SELF.config.default_value) %]</td> |
|
31 |
</tr> |
|
32 |
|
|
33 |
<tr> |
|
34 |
<td align="right">[% 'Options' | $T8 %]<sup><span class="small-text">(5)</span></sup></td> |
|
35 |
<td>[%- L.input_tag("config.options", SELF.config.options) %]</td> |
|
36 |
</tr> |
|
37 |
|
|
38 |
<tr> |
|
39 |
<td align="right">[% 'Is Searchable' | $T8 %]</td> |
|
40 |
<td> |
|
41 |
[% L.radio_button_tag('config.searchable', value='1', id='config_searchable_1', label=LxERP.t8('Yes'), checked=(SELF.config.searchable ? 1 : '')) %] |
|
42 |
[% L.radio_button_tag('config.searchable', value='0', id='config_searchable_0', label=LxERP.t8('No'), checked=(SELF.config.searchable ? '' : 1)) %] |
|
43 |
</td> |
|
44 |
</tr> |
|
45 |
|
|
46 |
<tr> |
|
47 |
<td align="right">[% 'Includeable in reports' | $T8 %]</td> |
|
48 |
<td> |
|
49 |
[% L.radio_button_tag('config.includeable', value='1', id='config_includeable_1', label=LxERP.t8('Yes'), checked=(SELF.config.includeable ? 1 : ''), onclick='update_included_by_default()') %] |
|
50 |
[% L.radio_button_tag('config.includeable', value='0', id='config_includeable_0', label=LxERP.t8('No'), checked=(SELF.config.includeable ? '' : 1), onclick='update_included_by_default()') %] |
|
51 |
</td> |
|
52 |
</tr> |
|
53 |
|
|
54 |
<tr> |
|
55 |
<td align="right">[% 'Included in reports by default' | $T8 %]</td> |
|
56 |
<td> |
|
57 |
[% SET disabled = SELF.config.includeable ? '' : 'disabled' %] |
|
58 |
[% L.radio_button_tag('config.included_by_default', value='1', id='config_included_by_default_1', label=LxERP.t8('Yes'), checked=(SELF.config.included_by_default ? 1 : ''), disabled=disabled) %] |
|
59 |
[% L.radio_button_tag('config.included_by_default', value='0', id='config_included_by_default_0', label=LxERP.t8('No'), checked=(SELF.config.included_by_default ? '' : 1), disabled=disabled) %] |
|
60 |
</td> |
|
61 |
</tr> |
|
62 |
|
|
63 |
<tr data-show-for="IC"[% UNLESS SELF.module == 'IC' %] style="display: none;"[% END %]> |
|
64 |
<td align="right">[% 'Editable' | $T8 %]<sup><span class="small-text">(6)</span></sup></td> |
|
65 |
<td> |
|
66 |
[% L.radio_button_tag('config.flag_editable', value='1', id='config.flag_editable_1', label=LxERP.t8('Yes'), checked=(SELF.flags.editable ? 1 : '')) %] |
|
67 |
[% L.radio_button_tag('config.flag_editable', value='0', id='config.flag_editable_0', label=LxERP.t8('No'), checked=(SELF.flags.editable ? '' : 1)) %] |
|
68 |
</td> |
|
69 |
</tr> |
|
70 |
</table> |
|
71 |
</p> |
|
72 |
|
|
73 |
<p> |
|
74 |
[% L.hidden_tag("action", "CustomVariableConfig/dispatch") %] |
|
75 |
[% L.submit_tag("action_" _ (SELF.config.id ? "update" : "create"), LxERP.t8('Save'), onclick="return check_prerequisites();") %] |
|
76 |
[%- IF SELF.config.id %] |
|
77 |
[% L.submit_tag("action_create", LxERP.t8('Save as new'), onclick="return check_prerequisites();") %] |
|
78 |
[% L.submit_tag("action_destroy", LxERP.t8('Delete'), confirm=LxERP.t8('Are you sure?')) %] |
|
79 |
[%- END %] |
|
80 |
<a href="[% SELF.url_for(action='list', module=SELF.module) %]">[%- LxERP.t8("Cancel") %]</a> |
|
81 |
</p> |
|
82 |
|
|
83 |
<hr> |
|
84 |
|
|
85 |
<h3>[% 'Annotations' | $T8 %]</h3> |
|
86 |
|
|
87 |
<p> |
|
88 |
(1) [% 'The variable name must only consist of letters, numbers and underscores. It must begin with a letter. Example: send_christmas_present' | $T8 %] |
|
89 |
</p> |
|
90 |
|
|
91 |
<p> |
|
92 |
(2) [% 'The description is shown on the form. Chose something short and descriptive.' | $T8 %] |
|
93 |
</p> |
|
94 |
<p> |
|
95 |
(3) [% 'For type "customer" the perl module JSON is required. Please check this on system level: $ ./scripts/installation_check.pl' | $T8 %] |
|
96 |
</p> |
|
97 |
|
|
98 |
<p> |
|
99 |
(4) [% 'The default value depends on the variable type:' | $T8 %] |
|
100 |
<br> |
|
101 |
<ul> |
|
102 |
<li>[%- 'Text, text field and number variables: The default value will be used as-is.' | $T8 %]</li> |
|
103 |
<li>[%- 'Boolean variables: If the default value is non-empty then the checkbox will be checked by default and unchecked otherwise.' | $T8 %]</li> |
|
104 |
<li>[%- 'Date and timestamp variables: If the default value equals \'NOW\' then the current date/current timestamp will be used. Otherwise the default value is copied as-is.' | $T8 %]</li> |
|
105 |
</ul> |
|
106 |
</p> |
|
107 |
|
|
108 |
<p> |
|
109 |
(5) [% 'The available options depend on the varibale type:' | $T8 %] |
|
110 |
<br> |
|
111 |
<ul> |
|
112 |
<li>[%- 'Text variables: \'MAXLENGTH=n\' sets the maximum entry length to \'n\'.' | $T8 %]</li> |
|
113 |
<li>[%- 'Text field variables: \'WIDTH=w HEIGHT=h\' sets the width and height of the text field. They default to 30 and 5 respectively.' | $T8 %]</li> |
|
114 |
<li>[%- 'Number variables: \'PRECISION=n\' forces numbers to be shown with exactly n decimal places.' | $T8 %]</li> |
|
115 |
<li>[%- 'Selection fields: The option field must contain the available options for the selection. Options are separated by \'##\', for example \'Early##Normal##Late\'.' | $T8 %]</li> |
|
116 |
</ul> |
|
117 |
<br> |
|
118 |
[% 'Other values are ignored.' | $T8 %] |
|
119 |
</p> |
|
120 |
|
|
121 |
<p data-show-for="IC"[% UNLESS SELF.module == 'IC' %] style="display: none;"[% END %]> |
|
122 |
(6) |
|
123 |
|
|
124 |
[%- 'A variable marked as \'editable\' can be changed in each quotation, order, invoice etc.' | $T8 %] |
|
125 |
|
|
126 |
[% 'Otherwise the variable is only available for printing.' | $T8 %] |
|
127 |
</p> |
|
128 |
|
|
129 |
</form> |
|
130 |
|
|
131 |
<script type="text/javascript"> |
|
132 |
<!-- |
|
133 |
function update_included_by_default() { |
|
134 |
$('INPUT[name="config.included_by_default"]').prop('disabled', !$('#config_includeable_1').prop('checked')); |
|
135 |
} |
|
136 |
|
|
137 |
function update_ic_rows() { |
|
138 |
$('[data-show-for="IC"]').toggle($('#module').val() === "IC"); |
|
139 |
} |
|
140 |
|
|
141 |
function check_prerequisites() { |
|
142 |
if (($('#config_type').val() === "select") && ($('#config_options').val() === "")) { |
|
143 |
alert(kivi.t8('The option field is empty.')); |
|
144 |
return false; |
|
145 |
} |
|
146 |
|
|
147 |
if ($('#config_name').val() === "") { |
|
148 |
alert(kivi.t8('The name is missing.')); |
|
149 |
return false; |
|
150 |
} |
|
151 |
|
|
152 |
if (!$('#config_name').val().match(/^[a-z][a-z0-9_]*$/i)) { |
|
153 |
alert(kivi.t8('The name must only consist of letters, numbers and underscores and start with a letter.')); |
|
154 |
return false; |
|
155 |
} |
|
156 |
|
|
157 |
if ($('#config_description').val() === "") { |
|
158 |
alert(kivi.t8('The description is missing.')); |
|
159 |
return false; |
|
160 |
} |
|
161 |
|
|
162 |
return true; |
|
163 |
} |
|
164 |
--> |
|
165 |
</script> |
templates/webpages/custom_variable_config/list.html | ||
---|---|---|
1 |
[%- USE HTML -%][%- USE LxERP -%][%- USE L -%][%- USE T8 -%][%- INCLUDE 'common/flash.html' %] |
|
2 |
|
|
3 |
<h1>[% title %]</h1> |
|
4 |
|
|
5 |
<p> |
|
6 |
[% 'Custom variables for module' | $T8 %] |
|
7 |
[%- L.select_tag('module', SELF.modules, value_key='module', title_key='description', default=SELF.module, onchange='show_module_list()') %] |
|
8 |
</p> |
|
9 |
|
|
10 |
<p> |
|
11 |
<table width="100%" id="cvarcfg_list"> |
|
12 |
<thead> |
|
13 |
<tr class="listheading"> |
|
14 |
<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 |
[%- IF SELF.module == 'IC' %] |
|
21 |
<th width="20%">[% 'Editable' | $T8 %]</th> |
|
22 |
[%- END %] |
|
23 |
</tr> |
|
24 |
</thead> |
|
25 |
|
|
26 |
<tbody> |
|
27 |
[%- FOREACH cfg = CONFIGS %] |
|
28 |
<tr class="listrow" id="cvarcfg_id_[% cfg.id %]"> |
|
29 |
<td align="center" class="dragdrop"><img src="image/updown.png" alt="[ LxERP.t8('reorder item') %]"></td> |
|
30 |
|
|
31 |
<td><a href="[% SELF.url_for(action='edit', module=SELF.module, id=cfg.id) %]">[% HTML.escape(cfg.name) %]</a></td> |
|
32 |
|
|
33 |
<td>[% HTML.escape(cfg.description) %]</td> |
|
34 |
<td>[% HTML.escape(SELF.get_translation(cfg.type)) %]</td> |
|
35 |
|
|
36 |
<td>[%- IF cfg.searchable %][% 'Yes' | $T8 %][%- ELSE %][% 'No' | $T8 %][%- END %]</td> |
|
37 |
|
|
38 |
<td>[%- IF cfg.included_by_default %][% 'Yes, included by default' | $T8 %][%- ELSIF cfg.includeable %][% 'Yes' | $T8 %][%- ELSE %][% 'No' | $T8 %][%- END %]</td> |
|
39 |
|
|
40 |
[%- IF SELF.module == 'IC' %] |
|
41 |
<td>[%- IF cfg.flags.match('editable=1') %][% 'Yes' | $T8 %][%- ELSE %][% 'No' | $T8 %][%- END %]</td> |
|
42 |
[%- END %] |
|
43 |
</tr> |
|
44 |
[%- END %] |
|
45 |
</tbody> |
|
46 |
</table> |
|
47 |
</p> |
|
48 |
|
|
49 |
<hr height="3"> |
|
50 |
|
|
51 |
<p> |
|
52 |
<a href="[% SELF.url_for(action='new', module=SELF.module) %]">[%- 'Add' | $T8 %]</a> |
|
53 |
</p> |
|
54 |
|
|
55 |
[% L.sortable_element('#cvarcfg_list tbody', url=SELF.url_for(action='reorder'), with='cvarcfg_id', params='"&module=" + encodeURIComponent($("#module").val())') %] |
|
56 |
|
|
57 |
<script type="text/javascript"> |
|
58 |
<!-- |
|
59 |
function show_module_list() { |
|
60 |
window.location.href = '[% SELF.url_for(action='list') %]&module=' + encodeURIComponent($('#module').val()); |
|
61 |
} |
|
62 |
--> |
|
63 |
</script> |
Auch abrufbar als: Unified diff
Verwaltung von benutzerdefinierten Variablen auf Controller umgestellt