Revision 5e1de2f8
Von Moritz Bunkus vor fast 8 Jahren hinzugefügt
SL/AM.pm | ||
---|---|---|
1292 | 1292 |
$main::lxdebug->leave_sub(); |
1293 | 1293 |
} |
1294 | 1294 |
|
1295 |
sub save_price_factor { |
|
1296 |
$main::lxdebug->enter_sub(); |
|
1297 |
|
|
1298 |
my ($self, $myconfig, $form) = @_; |
|
1299 |
|
|
1300 |
SL::DB->client->with_transaction(sub { |
|
1301 |
my $dbh = SL::DB->client->dbh; |
|
1302 |
|
|
1303 |
my $query; |
|
1304 |
my @values = ($form->{description}, conv_i($form->{factor})); |
|
1305 |
|
|
1306 |
if ($form->{id}) { |
|
1307 |
$query = qq|UPDATE price_factors SET description = ?, factor = ? WHERE id = ?|; |
|
1308 |
push @values, conv_i($form->{id}); |
|
1309 |
|
|
1310 |
} else { |
|
1311 |
$query = qq|INSERT INTO price_factors (description, factor, sortkey) VALUES (?, ?, (SELECT COALESCE(MAX(sortkey), 0) + 1 FROM price_factors))|; |
|
1312 |
} |
|
1313 |
|
|
1314 |
do_query($form, $dbh, $query, @values); |
|
1315 |
1; |
|
1316 |
}) or do { die SL::DB->client->error }; |
|
1317 |
|
|
1318 |
$main::lxdebug->leave_sub(); |
|
1319 |
} |
|
1320 |
|
|
1321 |
sub get_all_price_factors { |
|
1322 |
$main::lxdebug->enter_sub(); |
|
1323 |
|
|
1324 |
my ($self, $myconfig, $form) = @_; |
|
1325 |
|
|
1326 |
my $dbh = SL::DB->client->dbh; |
|
1327 |
|
|
1328 |
$form->{PRICE_FACTORS} = selectall_hashref_query($form, $dbh, qq|SELECT * FROM price_factors ORDER BY sortkey|); |
|
1329 |
|
|
1330 |
$main::lxdebug->leave_sub(); |
|
1331 |
} |
|
1332 |
|
|
1333 |
sub get_price_factor { |
|
1334 |
$main::lxdebug->enter_sub(); |
|
1335 |
|
|
1336 |
my ($self, $myconfig, $form) = @_; |
|
1337 |
|
|
1338 |
# connect to database |
|
1339 |
my $dbh = SL::DB->client->dbh; |
|
1340 |
|
|
1341 |
my $query = qq|SELECT description, factor, |
|
1342 |
((SELECT COUNT(*) FROM parts WHERE price_factor_id = ?) + |
|
1343 |
(SELECT COUNT(*) FROM invoice WHERE price_factor_id = ?) + |
|
1344 |
(SELECT COUNT(*) FROM orderitems WHERE price_factor_id = ?)) = 0 AS orphaned |
|
1345 |
FROM price_factors WHERE id = ?|; |
|
1346 |
|
|
1347 |
($form->{description}, $form->{factor}, $form->{orphaned}) = selectrow_query($form, $dbh, $query, (conv_i($form->{id})) x 4); |
|
1348 |
|
|
1349 |
$main::lxdebug->leave_sub(); |
|
1350 |
} |
|
1351 |
|
|
1352 |
sub delete_price_factor { |
|
1353 |
$main::lxdebug->enter_sub(); |
|
1354 |
|
|
1355 |
my ($self, $myconfig, $form) = @_; |
|
1356 |
|
|
1357 |
SL::DB->client->with_transaction(sub { |
|
1358 |
do_query($form, SL::DB->client->dbh, qq|DELETE FROM price_factors WHERE id = ?|, conv_i($form->{id})); |
|
1359 |
1; |
|
1360 |
}) or do { die SL::DB->client->error }; |
|
1361 |
|
|
1362 |
$main::lxdebug->leave_sub(); |
|
1363 |
} |
|
1364 |
|
|
1365 | 1295 |
sub save_warehouse { |
1366 | 1296 |
$main::lxdebug->enter_sub(); |
1367 | 1297 |
|
SL/Controller/SimpleSystemSetting.pm | ||
---|---|---|
71 | 71 |
], |
72 | 72 |
}, |
73 | 73 |
|
74 |
price_factor => { |
|
75 |
# Make locales.pl happy: $self->render("simple_system_setting/_price_factor_form") |
|
76 |
class => 'PriceFactor', |
|
77 |
titles => { |
|
78 |
list => t8('Price Factors'), |
|
79 |
add => t8('Add Price Factor'), |
|
80 |
edit => t8('Edit Price Factor'), |
|
81 |
}, |
|
82 |
list_attributes => [ |
|
83 |
{ method => 'description', title => t8('Description') }, |
|
84 |
{ method => 'factor_as_number', title => t8('Factor'), align => 'right' }, |
|
85 |
], |
|
86 |
}, |
|
87 |
|
|
74 | 88 |
pricegroup => { |
75 | 89 |
# Make locales.pl happy: $self->render("simple_system_setting/_pricegroup_form") |
76 | 90 |
class => 'Pricegroup', |
SL/DB/PriceFactor.pm | ||
---|---|---|
8 | 8 |
|
9 | 9 |
__PACKAGE__->meta->initialize; |
10 | 10 |
|
11 |
sub orphaned { |
|
12 |
my ($self) = @_; |
|
13 |
|
|
14 |
die 'not an accessor' if @_ > 1; |
|
15 |
|
|
16 |
require SL::DB::DeliveryOrderItem; |
|
17 |
require SL::DB::InvoiceItem; |
|
18 |
require SL::DB::OrderItem; |
|
19 |
require SL::DB::Part; |
|
20 |
|
|
21 |
return 1 if !$self->id; |
|
22 |
|
|
23 |
return 0 if SL::DB::Manager::DeliveryOrderItem->get_first(query => [ price_factor_id => $self->id ]); |
|
24 |
return 0 if SL::DB::Manager::InvoiceItem ->get_first(query => [ price_factor_id => $self->id ]); |
|
25 |
return 0 if SL::DB::Manager::OrderItem ->get_first(query => [ price_factor_id => $self->id ]); |
|
26 |
return 0 if SL::DB::Manager::Part ->get_first(query => [ price_factor_id => $self->id ]); |
|
27 |
|
|
28 |
return 1; |
|
29 |
} |
|
30 |
|
|
11 | 31 |
1; |
12 | 32 |
|
13 | 33 |
__END__ |
bin/mozilla/am.pl | ||
---|---|---|
1354 | 1354 |
$main::lxdebug->leave_sub(); |
1355 | 1355 |
} |
1356 | 1356 |
|
1357 |
sub add_price_factor { |
|
1358 |
$main::lxdebug->enter_sub(); |
|
1359 |
|
|
1360 |
my $form = $main::form; |
|
1361 |
my $locale = $main::locale; |
|
1362 |
|
|
1363 |
$main::auth->assert('config'); |
|
1364 |
|
|
1365 |
$form->{title} = $locale->text('Add Price Factor'); |
|
1366 |
$form->{callback} ||= build_std_url('action=add_price_factor'); |
|
1367 |
|
|
1368 |
$form->header(); |
|
1369 |
print $form->parse_html_template('am/edit_price_factor'); |
|
1370 |
|
|
1371 |
$main::lxdebug->leave_sub(); |
|
1372 |
} |
|
1373 |
|
|
1374 |
sub edit_price_factor { |
|
1375 |
$main::lxdebug->enter_sub(); |
|
1376 |
|
|
1377 |
my $form = $main::form; |
|
1378 |
my %myconfig = %main::myconfig; |
|
1379 |
my $locale = $main::locale; |
|
1380 |
|
|
1381 |
$main::auth->assert('config'); |
|
1382 |
|
|
1383 |
$form->{title} = $locale->text('Edit Price Factor'); |
|
1384 |
$form->{callback} ||= build_std_url('action=add_price_factor'); |
|
1385 |
|
|
1386 |
AM->get_price_factor(\%myconfig, $form); |
|
1387 |
|
|
1388 |
$form->{factor} = $form->format_amount(\%myconfig, $form->{factor} * 1); |
|
1389 |
|
|
1390 |
$form->header(); |
|
1391 |
print $form->parse_html_template('am/edit_price_factor'); |
|
1392 |
|
|
1393 |
$main::lxdebug->leave_sub(); |
|
1394 |
} |
|
1395 |
|
|
1396 |
sub list_price_factors { |
|
1397 |
$main::lxdebug->enter_sub(); |
|
1398 |
|
|
1399 |
my $form = $main::form; |
|
1400 |
my %myconfig = %main::myconfig; |
|
1401 |
my $locale = $main::locale; |
|
1402 |
|
|
1403 |
$main::auth->assert('config'); |
|
1404 |
|
|
1405 |
AM->get_all_price_factors(\%myconfig, \%$form); |
|
1406 |
|
|
1407 |
foreach my $current (@{ $form->{PRICE_FACTORS} }) { |
|
1408 |
$current->{factor} = $form->format_amount(\%myconfig, $current->{factor} * 1); |
|
1409 |
} |
|
1410 |
|
|
1411 |
$form->{callback} = build_std_url('action=list_price_factors'); |
|
1412 |
$form->{title} = $locale->text('Price Factors'); |
|
1413 |
$form->{url_base} = build_std_url('callback'); |
|
1414 |
|
|
1415 |
$form->header(); |
|
1416 |
print $form->parse_html_template('am/list_price_factors'); |
|
1417 |
|
|
1418 |
$main::lxdebug->leave_sub(); |
|
1419 |
} |
|
1420 |
|
|
1421 |
sub save_price_factor { |
|
1422 |
$main::lxdebug->enter_sub(); |
|
1423 |
|
|
1424 |
my $form = $main::form; |
|
1425 |
my %myconfig = %main::myconfig; |
|
1426 |
my $locale = $main::locale; |
|
1427 |
|
|
1428 |
$main::auth->assert('config'); |
|
1429 |
|
|
1430 |
$form->isblank("description", $locale->text('Description missing!')); |
|
1431 |
$form->isblank("factor", $locale->text('Factor missing!')); |
|
1432 |
|
|
1433 |
$form->{factor} = $form->parse_amount(\%myconfig, $form->{factor}); |
|
1434 |
|
|
1435 |
AM->save_price_factor(\%myconfig, $form); |
|
1436 |
|
|
1437 |
$form->{callback} .= '&MESSAGE=' . $form->escape($locale->text('Price factor saved!')) if ($form->{callback}); |
|
1438 |
|
|
1439 |
$form->redirect($locale->text('Price factor saved!')); |
|
1440 |
|
|
1441 |
$main::lxdebug->leave_sub(); |
|
1442 |
} |
|
1443 |
|
|
1444 |
sub delete_price_factor { |
|
1445 |
$main::lxdebug->enter_sub(); |
|
1446 |
|
|
1447 |
my $form = $main::form; |
|
1448 |
my %myconfig = %main::myconfig; |
|
1449 |
my $locale = $main::locale; |
|
1450 |
|
|
1451 |
$main::auth->assert('config'); |
|
1452 |
|
|
1453 |
AM->delete_price_factor(\%myconfig, \%$form); |
|
1454 |
|
|
1455 |
$form->{callback} .= '&MESSAGE=' . $form->escape($locale->text('Price factor deleted!')) if ($form->{callback}); |
|
1456 |
|
|
1457 |
$form->redirect($locale->text('Price factor deleted!')); |
|
1458 |
|
|
1459 |
$main::lxdebug->leave_sub(); |
|
1460 |
} |
|
1461 |
|
|
1462 | 1357 |
sub add_warehouse { |
1463 | 1358 |
$main::lxdebug->enter_sub(); |
1464 | 1359 |
|
locale/de/all | ||
---|---|---|
10 | 10 |
# run locales.pl from this directory to rebuild the translation files |
11 | 11 |
|
12 | 12 |
$self->{texts} = { |
13 |
' (in use so no change allowed)' => ' (Faktor wird verwendet, keine Änderung erlaubt)', |
|
14 | 13 |
' Date missing!' => ' Datum fehlt!', |
15 | 14 |
' bytes, max=' => ' Bytes, Maximum=', |
16 | 15 |
' missing!' => ' fehlt!', |
... | ... | |
1314 | 1313 |
'Extended status' => 'Erweiterter Status', |
1315 | 1314 |
'Extension Of Time' => 'Dauerfristverlängerung', |
1316 | 1315 |
'Factor' => 'Faktor', |
1317 |
'Factor missing!' => 'Der Faktor fehlt.', |
|
1318 | 1316 |
'Falsches Datumsformat!' => 'Falsches Datumsformat!', |
1319 | 1317 |
'Fax' => 'Fax', |
1320 | 1318 |
'Features' => 'Features', |
... | ... | |
1940 | 1938 |
'Not obsolete' => 'Gültig', |
1941 | 1939 |
'Note' => 'Hinweis', |
1942 | 1940 |
'Note: Taxkeys must have a "valid from" date, and will not behave correctly without.' => 'Hinweis: Steuerschlüssel sind fehlerhaft ohne "Gültig ab" Datum', |
1941 |
'Note: the object is already in use. Therefore some values cannot be changed.' => 'Anmerkung: das Objekt ist bereits in Benutzung. Einige Werte können daher nicht geändert werden.', |
|
1943 | 1942 |
'Notes' => 'Bemerkungen', |
1944 | 1943 |
'Notes (translation for #1)' => 'Bemerkungen (Übersetzung für #1)', |
1945 | 1944 |
'Notes (will appear on hard copy)' => 'Bemerkungen', |
... | ... | |
2209 | 2208 |
'Price Types' => 'Preistypen', |
2210 | 2209 |
'Price factor (database ID)' => 'Preisfaktor (Datenbank-ID)', |
2211 | 2210 |
'Price factor (name)' => 'Preisfaktor (Name)', |
2212 |
'Price factor deleted!' => 'Preisfaktor gelöscht.', |
|
2213 |
'Price factor saved!' => 'Preisfaktor gespeichert.', |
|
2214 | 2211 |
'Price group' => 'Preisgruppe', |
2215 | 2212 |
'Price group (database ID)' => 'Preisgruppe (Datenbank-ID)', |
2216 | 2213 |
'Price group (name)' => 'Preisgruppe (Name) ', |
menus/user/00-erp.yaml | ||
---|---|---|
1100 | 1100 |
id: system_price_factors |
1101 | 1101 |
name: Price Factors |
1102 | 1102 |
order: 1200 |
1103 |
module: am.pl |
|
1104 | 1103 |
params: |
1105 |
action: list_price_factors |
|
1104 |
action: SimpleSystemSetting/list |
|
1105 |
type: price_factor |
|
1106 | 1106 |
- parent: system |
1107 | 1107 |
id: system_departments |
1108 | 1108 |
name: Departments |
templates/webpages/am/edit_price_factor.html | ||
---|---|---|
1 |
[%- USE T8 %] |
|
2 |
[%- USE HTML %] |
|
3 |
<h1>[% title %]</h1> |
|
4 |
|
|
5 |
|
|
6 |
[% IF MESSAGE %]<p>[% MESSAGE %]</p>[% END %] |
|
7 |
|
|
8 |
<form method="post" action="am.pl"> |
|
9 |
|
|
10 |
<p> |
|
11 |
<table border="0"> |
|
12 |
<tr> |
|
13 |
<td align="right">[% 'Description' | $T8 %]</td> |
|
14 |
<td><input id="description" name="description" value="[% HTML.escape(description) %]" class="initial_focus"></td> |
|
15 |
</tr> |
|
16 |
|
|
17 |
<tr> |
|
18 |
<td align="right">[% 'Factor' | $T8 %]</td> |
|
19 |
[% IF !id || orphaned %] |
|
20 |
<td><input name="factor" value="[% HTML.escape(factor) %]"></td> |
|
21 |
[% ELSE %] |
|
22 |
<td><input type="hidden" name="factor" value="[% HTML.escape(factor) %]"> |
|
23 |
[% HTML.escape(factor) %] [% ' (in use so no change allowed)' | $T8 %]</td> |
|
24 |
[% END %] |
|
25 |
</tr> |
|
26 |
</table> |
|
27 |
</p> |
|
28 |
|
|
29 |
<p> |
|
30 |
<input type="hidden" name="callback" value="[% HTML.escape(callback) %]"> |
|
31 |
|
|
32 |
<input type="hidden" name="type" value="price_factor"> |
|
33 |
|
|
34 |
<input type="hidden" name="id" value="[% HTML.escape(id) %]"> |
|
35 |
<input type="submit" name="action" value="[% 'Save' | $T8 %]"> |
|
36 |
[% IF id %][% IF orphaned %]<input type="submit" name="action" value="[% 'Delete' | $T8 %]">[% END %][% END %] |
|
37 |
</p> |
|
38 |
</form> |
templates/webpages/am/list_price_factors.html | ||
---|---|---|
1 |
[%- USE T8 %][% USE L %][% USE LxERP %] |
|
2 |
[% USE HTML %] |
|
3 |
<h1>[% title %]</h1> |
|
4 |
|
|
5 |
[% IF MESSAGE %]<p>[% MESSAGE %]</p>[% END %] |
|
6 |
|
|
7 |
|
|
8 |
<p> |
|
9 |
<table width="100%" id="price_factor_list"> |
|
10 |
<thead> |
|
11 |
<tr class="listheading"> |
|
12 |
<th align="center"><img src="image/updown.png" alt="[%- LxERP.t8('reorder item') %]"></th> |
|
13 |
<th width="80%">[% 'Description' | $T8 %]</th> |
|
14 |
<th width="20%">[% 'Factor' | $T8 %]</th> |
|
15 |
</tr> |
|
16 |
</thead> |
|
17 |
|
|
18 |
<tbody> |
|
19 |
[% FOREACH factor = PRICE_FACTORS %] |
|
20 |
<tr class="listrow[% loop.count % 2 %]" id="price_factor_id_[% factor.id %]"> |
|
21 |
<td align="center" class="dragdrop"><img src="image/updown.png" alt="[%- LxERP.t8('reorder item') %]"></td> |
|
22 |
<td><a href="[% url_base %]&action=edit_price_factor&id=[% HTML.url(factor.id) %]">[% HTML.escape(factor.description) %]</a></td> |
|
23 |
<td>[% HTML.escape(factor.factor) %]</td> |
|
24 |
</tr> |
|
25 |
[% END %] |
|
26 |
</tbody> |
|
27 |
</table> |
|
28 |
</p> |
|
29 |
|
|
30 |
<hr height="3"> |
|
31 |
|
|
32 |
<p> |
|
33 |
<a href="am.pl?action=add&type=price_factor&callback=[% HTML.url(callback) %]">[%- 'Add' | $T8 %]</a> |
|
34 |
</p> |
|
35 |
|
|
36 |
[% L.sortable_element('#price_factor_list tbody', url => 'controller.pl?action=PriceFactor/reorder', with => 'price_factor_id') %] |
templates/webpages/simple_system_setting/_price_factor_form.html | ||
---|---|---|
1 |
[%- USE LxERP -%][%- USE L -%][%- USE HTML -%] |
|
2 |
[%- SET orphaned = SELF.object.orphaned %] |
|
3 |
<table> |
|
4 |
<tr> |
|
5 |
<th align="right">[% LxERP.t8("Description") %]</th> |
|
6 |
<td>[% L.input_tag("object.description", LxERP.t8(SELF.object.description), "data-validate"="required", "data-title"=LxERP.t8("Description")) %]</td> |
|
7 |
</tr> |
|
8 |
<tr> |
|
9 |
<th align="right">[% LxERP.t8("Factor") %]</th> |
|
10 |
<td> |
|
11 |
[% IF orphaned %] |
|
12 |
[% L.input_tag("object.factor_as_number", LxERP.t8(SELF.object.factor_as_number), "data-validate"="required", "data-title"=LxERP.t8("Factor")) %] |
|
13 |
[% ELSE %] |
|
14 |
[% HTML.escape(SELF.object.factor_as_number) %] |
|
15 |
[% END %] |
|
16 |
</td> |
|
17 |
</tr> |
|
18 |
</table> |
|
19 |
|
|
20 |
[% UNLESS orphaned %] |
|
21 |
<p> |
|
22 |
[% LxERP.t8("Note: the object is already in use. Therefore some values cannot be changed.") %] |
|
23 |
</p> |
|
24 |
[% END %] |
Auch abrufbar als: Unified diff
SimpleSystemSetting: Umstellung von »Preisfaktoren«