X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;f=bin%2Fmozilla%2Flicenses.pl;h=fd8f01d9f514e8c24f914a8d26882a4978671315;hb=6ebad56e58db857141565f397c555524cba43109;hp=1dfcb4e285ada55ae5ecb6df4af5b2084498a5d6;hpb=4dbb09950c9f5596646537c12d991c99086fe7c1;p=kivitendo-erp.git diff --git a/bin/mozilla/licenses.pl b/bin/mozilla/licenses.pl index 1dfcb4e28..fd8f01d9f 100644 --- a/bin/mozilla/licenses.pl +++ b/bin/mozilla/licenses.pl @@ -35,6 +35,8 @@ use SL::IC; use SL::IS; use SL::LICENSES; +require "bin/mozilla/common.pl"; + sub quot { $lxdebug->enter_sub(); $_[0] =~ s/\"/\"/g; @@ -44,9 +46,11 @@ sub quot { sub form_header { $lxdebug->enter_sub(); + $form->{jsscript} = 1; $form->header(); - print(qq| + print( + qq|
{script}>|); $lxdebug->leave_sub(); @@ -54,13 +58,15 @@ sub form_header { sub form_footer { $lxdebug->enter_sub(); - my @items = ("path", "login", "password", "old_callback", "previousform"); - push(@items, @{$form->{"hidden"}}); + my @items = qw(login password old_callback previousform); + push(@items, @{ $form->{"hidden"} }); map({ - print("{$_}) . "\">\n"); + print("{$_}) . "\">\n" + ); } @items); - print(qq|
+ print( + qq| |); @@ -69,11 +75,7 @@ sub form_footer { sub set_std_hidden { $lxdebug->enter_sub(); - $form->{"hidden"} = - ["comment", - "validuntil", - "quantity", - @_]; + $form->{"hidden"} = ["comment", "validuntil", "quantity", @_]; $lxdebug->leave_sub(); } @@ -82,44 +84,46 @@ sub print_part_selection { form_header(); set_std_hidden("business"); - print(qq| + print( + qq| - + - + |); $j = 1; - for ($i = 1; $i <= scalar(@{$form->{"parts"}}); $i++) { - %p = %{$form->{"parts"}->[$i - 1]}; + for ($i = 1; $i <= scalar(@{ $form->{"parts"} }); $i++) { + %p = %{ $form->{"parts"}->[$i - 1] }; if ($i == 1) { $checked = "checked"; } else { $checked = ""; } - print(qq| + print( + qq| - - - + + + |); $j = ($j + 1) % 2; } - print(qq| + print( + qq|
| . - $locale->text('Select from one of the items below') . qq|| + . $locale->text('Select from one of the items below') . qq|
  | . $locale->text('Part Number') . qq|| . $locale->text('Description'). qq|| . $locale->text('Description') . qq|
| . $p{"partnumber"} . qq|| . $p{"description"} . qq|| . $p{"partnumber"} . qq|| . $p{"description"} . qq|


@@ -134,40 +138,42 @@ sub print_customer_selection { form_header(); set_std_hidden("parts_id", "partnumber", "description"); - print(qq| + print( + qq| - + - - - - + + + + |); print(qq||); $j = 1; - for ($i = 1; $i <= scalar(@{$form->{"all_customers"}}); $i++) { - %c = %{$form->{"all_customers"}->[$i - 1]}; + for ($i = 1; $i <= scalar(@{ $form->{"all_customers"} }); $i++) { + %c = %{ $form->{"all_customers"}->[$i - 1] }; if ($i == 1) { $checked = "checked"; } else { $checked = ""; } - print(qq| + print( + qq| - - + + @@ -176,7 +182,8 @@ sub print_customer_selection { $j = ($j + 1) % 2; } - print(qq| + print( + qq|
| . - $locale->text('Select from one of the names below') . qq|| + . $locale->text('Select from one of the names below') . qq|
  | . $locale->text('Customer Number') . qq|| . $locale->text('Company Name'). qq|| . $locale->text('Street'). qq|| . $locale->text('Zipcode'). qq|| . $locale->text('City'). qq|| . $locale->text('Company Name') . qq|| . $locale->text('Street') . qq|| . $locale->text('Zipcode') . qq|| . $locale->text('City') . qq|

$c{"customernumber"}$c{"name"}$c{"customernumber"}$c{"name"} $c{"street"} $c{"zipcode"} $c{"city"}
@@ -188,7 +195,8 @@ sub print_customer_selection { sub print_license_form { $lxdebug->enter_sub(); - print(qq| + print( + qq| @@ -197,19 +205,19 @@ sub print_license_form {
| . $locale->text("Add License") . qq|
- + - + |); if ($form->{"all_customer"}) { print(qq||); } else { - print(qq||); + print( qq||); } - print(qq| + print( + qq| - + - + - + - + @@ -250,22 +261,31 @@ sub print_license_form { text('Update') . qq|\"> |); + if ($_[0]) { - print(qq|  - text('Save') . - qq|\">\n|); + print( + qq|  + text('Save') . qq|\">\n|); } - print(qq| + print( + qq| -
| . $locale->text('Part Number') . qq|{"partnumber"}) . - qq|\">{"partnumber"}) . qq|\">
| . $locale->text('Description') . qq|{"description"}) . - qq|\">{"description"}) . qq|\">
| . $locale->text('Company Name') . qq|{"customer_name"}) . qq|\">{"customer_name"}) + . qq|\">
| . $locale->text('Comment') . qq|{"comment"}) . qq|\">{"comment"}) . qq|\">
| . $locale->text('Valid until') . qq|{"validuntil"}) . qq|\">{"validuntil"}) . qq|\"> +
| . $locale->text('Quantity') . qq|{"quantity"}) . qq|\">{"quantity"}) . qq|\">
| . $locale->text('License key') . qq|{"licensenumber"}) . qq|\">{"licensenumber"}) . qq|\">
| . $locale->text('Own Product') . qq|
|); +| . + $form->write_trigger(\%myconfig, 1, "validuntil", "BL", + "trigger_validuntil")); + $lxdebug->leave_sub(); } sub add { $lxdebug->enter_sub(); if (!$lizenzen) { - $form->error($locale->text('The licensing module has been deactivated in lx-erp.conf.')); + $form->error( + $locale->text( + 'The licensing module has been deactivated in lx-erp.conf.') + ); } $form->{"initial"} = 1; @@ -295,11 +315,11 @@ sub do_add { if ($form->{"customer_name"}) { LICENSES->get_customers(\%myconfig, $form); - if (scalar(@{$form->{"all_customers"}}) == 1) { - %c = %{$form->{"all_customers"}->[0]}; - $form->{"customer_id"} = $c{"id"}; + if (scalar(@{ $form->{"all_customers"} }) == 1) { + %c = %{ $form->{"all_customers"}->[0] }; + $form->{"customer_id"} = $c{"id"}; $form->{"customer_name"} = $c{"name"}; - } elsif (scalar(@{$form->{"all_customers"}}) == 0) { + } elsif (scalar(@{ $form->{"all_customers"} }) == 0) { $form->{"customer_name"} = ""; delete($form->{"customer_id"}); } else { @@ -314,13 +334,13 @@ sub do_add { $form->{"sort"} = "p.partnumber"; $form->{searchitems} = "part"; IC->all_parts(\%myconfig, $form); - if (scalar(@{$form->{"parts"}}) == 1) { + if (scalar(@{ $form->{"parts"} }) == 1) { map({ $form->{$_} = $form->{"parts"}->[0]->{$_}; } ("partnumber", "description")); $form->{"parts_id"} = $form->{"parts"}->[0]->{"id"}; - } elsif (scalar(@{$form->{"parts"}}) == 0) { - map({ $form->{$_} = ""; } ("partnumber", "description", "parts_id")); + } elsif (scalar(@{ $form->{"parts"} }) == 0) { + map({ $form->{$_} = ""; }("partnumber", "description", "parts_id")); } else { print_part_selection(); @@ -346,29 +366,33 @@ sub update { sub continue { $lxdebug->enter_sub(); - &{ $form->{nextsub} }; + call_sub($form->{"nextsub"}); $lxdebug->leave_sub(); } sub save { $lxdebug->enter_sub(); - - ($form->{customername}, $form->{customer_id}) = split /--/, $form->{customer}; + + ($form->{customername}, $form->{customer_id}) = split /--/, + $form->{customer}; $form->isblank("customer", $locale->text('Customer missing!')); - - if ($form->{quantity} eq "" || $form->{quantity} !~ /^[0-9]*$/ || $form->{quantity} < 1) { + + if ( $form->{quantity} eq "" + || $form->{quantity} !~ /^[0-9]*$/ + || $form->{quantity} < 1) { $form->error($locale->text('Please enter a number of licenses.')); } if (!$form->{licensenumber} || $form->{licensenumber} eq "") { $form->error($locale->text('Please enter a license key.')); } - + $rc = LICENSES->save_license(\%myconfig, \%$form); - # load previous variables + # load previous variables if ($form->{previousform}) { + # save the new form variables before splitting previousform map { $newform{$_} = $form->{$_} } keys %$form; @@ -383,32 +407,33 @@ sub save { $value =~ s/%26/&/g; $form->{$key} = $value; } - - $form->{"lizenzen_$form->{row}"} = ""; + + $form->{"lizenzen_$form->{row}"} = + ""; $form->{rowcount}--; - + delete $form->{action}; # restore original callback $callback = $form->unescape($form->{callback}); $form->{callback} = $form->unescape($form->{old_callback}); delete $form->{old_callback}; - # put callback together foreach $key (keys %$form) { + # do single escape for Apache 2.0 $value = $form->escape($form->{$key}, 1); $callback .= qq|&$key=$value|; } $form->{callback} = $callback; - + # redirect $form->redirect; - + } else { form_header(); - + print("Die Lizenz wurde gespeichert.\n"); form_footer(); } @@ -419,12 +444,16 @@ sub save { sub search { $lxdebug->enter_sub(); if (!$lizenzen) { - $form->error($locale->text('The licensing module has been deactivated in lx-erp.conf.')); + $form->error( + $locale->text( + 'The licensing module has been deactivated in lx-erp.conf.') + ); } form_header(); - print(qq| + print( + qq| @@ -445,15 +474,17 @@ sub search { - +
| . $locale->text("Licenses") . qq|
| . $locale->text('Include in Report') . qq|| . $locale->text('All') . - qq| | . - $locale->text('Expiring in x month(s)') . qq| 
- | . - $locale->text('Expired licenses') . qq|
| + . $locale->text('All') + . qq| | + . $locale->text('Expiring in x month(s)') + . qq| 
+ | + . $locale->text('Expired licenses') . qq|
-
+
@@ -470,13 +501,11 @@ sub do_search { LICENSES->search(\%myconfig, $form); $callback = ""; - foreach (("db", "path", "login", "password", "partnumber", "description", - "customer_name", "all", "expiring_in", "show_expired")) { - $callback .= "\&${_}=" . $form->escape($form->{$_}, 1); - } - $details = $form->{"script"} . "?action=details" . $callback . "\&id="; + map { $callback .= "\&${_}=" . $form->escape($form->{$_}, 1) } + qw(db login password partnumber description customer_name all expiring_in show_expired); + $details = $form->{"script"} . "?action=details" . $callback . "\&id="; $invdetails = "is.pl?action=edit" . $callback . "\&id="; - $callback = $form->{"script"} . "?action=do_search" . $callback; + $callback = $form->{"script"} . "?action=do_search" . $callback; $form->{"sortby"} = "validuntil" unless ($form->{"sortby"}); $form->{"sortasc"} *= 1; @@ -491,63 +520,74 @@ sub do_search { form_header(); - print(qq| + print( + qq| |); - if (scalar(@{$form->{"licenses"}}) == 0) { - print(qq|
| . $locale->text("Licenses") . qq|
| . - $locale->text("No licenses were found that match the search criteria.") . - qq||); + if (scalar(@{ $form->{"licenses"} }) == 0) { + print(qq|| + . $locale->text( + "No licenses were found that match the search criteria.") + . qq||); exit(0); } - print(qq| + print( + qq| - - - - - + + + + + |); $j = 1; - for ($i = 0; $i < scalar(@{$form->{"licenses"}}); $i++) { + for ($i = 0; $i < scalar(@{ $form->{"licenses"} }); $i++) { $ref = $form->{"licenses"}->[$i]; - print(qq| + print( + qq| - + |); $j = ($j + 1) % 2; } - $form->{"num_licenses"} = scalar(@{$form->{"licenses"}}); - push(@{$form->{"hidden"}}, "num_licenses"); + $form->{"num_licenses"} = scalar(@{ $form->{"licenses"} }); + push(@{ $form->{"hidden"} }, "num_licenses"); - print(qq| + print( + qq|
" . - $locale->text('Part Number') . qq|" . - $locale->text('Description') . qq|" . - $locale->text('Company Name') . qq|" . - $locale->text('Valid until') . qq|" . - $locale->text('Invoice Number') . qq|" + . $locale->text('Part Number') + . qq|" + . $locale->text('Description') + . qq|" . $locale->text('Company Name') . qq|" + . $locale->text('Valid until') + . qq|" + . $locale->text('Invoice Number') + . qq|
{"id"} . qq| {"id"}\">$ref->{"partnumber"} {"id"}\">$ref->{"description"} {"id"}\">$ref->{"name"} {"id"}\">$ref->{"validuntil"}| . - ($ref->{"invnumber"} ? - qq|{"invnumber"}\">$ref->{"invnumber"}| : - qq| |) . qq|| + . ( + $ref->{"invnumber"} + ? qq|{"invnumber"}\">$ref->{"invnumber"}| + : qq| | + ) + . qq|
@@ -567,11 +607,13 @@ sub do_search { sub details { $lxdebug->enter_sub(); LICENSES->get_license(\%myconfig, $form); - map({ $form->{$_} = $form->{"license"}->{$_}; } keys(%{$form->{"license"}})); + map( + { $form->{$_} = $form->{"license"}->{$_}; } keys(%{ $form->{"license"} })); form_header(); - print(qq| + print( + qq|
| . $locale->text("View License") . qq|