X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;f=bin%2Fmozilla%2Flicenses.pl;h=6fe4f764eb99d1bb62d2630e8ff5ba6b4dd67141;hb=5ee57de8a130f13418e9013102963e4336e72f6d;hp=1dfcb4e285ada55ae5ecb6df4af5b2084498a5d6;hpb=4dbb09950c9f5596646537c12d991c99086fe7c1;p=kivitendo-erp.git diff --git a/bin/mozilla/licenses.pl b/bin/mozilla/licenses.pl index 1dfcb4e28..6fe4f764e 100644 --- a/bin/mozilla/licenses.pl +++ b/bin/mozilla/licenses.pl @@ -35,139 +35,174 @@ use SL::IC; use SL::IS; use SL::LICENSES; +require "bin/mozilla/common.pl"; + +use strict; + sub quot { - $lxdebug->enter_sub(); + $main::lxdebug->enter_sub(); $_[0] =~ s/\"/\"/g; - $lxdebug->leave_sub(); + $main::lxdebug->leave_sub(); return $_[0]; } sub form_header { - $lxdebug->enter_sub(); + $main::lxdebug->enter_sub(); + + $main::auth->assert('license_edit'); + + my $form = $main::form; + + $form->{jsscript} = 1; $form->header(); - print(qq| + print( + qq|
{script}>|); - $lxdebug->leave_sub(); + $main::lxdebug->leave_sub(); } sub form_footer { - $lxdebug->enter_sub(); - my @items = ("path", "login", "password", "old_callback", "previousform"); - push(@items, @{$form->{"hidden"}}); + $main::lxdebug->enter_sub(); + + $main::auth->assert('license_edit'); + + my $form = $main::form; + + my @items = qw(old_callback previousform); + push @items, @{ $form->{"hidden"} } if ref $form->{hidden} eq 'ARRAY'; map({ - print("{$_}) . "\">\n"); + print("{$_}) . "\">\n" + ); } @items); - print(qq|
+ print( + qq| |); - $lxdebug->leave_sub(); + $main::lxdebug->leave_sub(); } sub set_std_hidden { - $lxdebug->enter_sub(); - $form->{"hidden"} = - ["comment", - "validuntil", - "quantity", - @_]; - $lxdebug->leave_sub(); + $main::lxdebug->enter_sub(); + + my $form = $main::form; + + $form->{"hidden"} = ["comment", "validuntil", "quantity", @_]; + $main::lxdebug->leave_sub(); } sub print_part_selection { - $lxdebug->enter_sub(); + $main::lxdebug->enter_sub(); + + $main::auth->assert('license_edit'); + + my $form = $main::form; + my $locale = $main::locale; + 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]}; + my $j = 1; + for (my $i = 1; $i <= scalar(@{ $form->{"parts"} }); $i++) { + my %p = %{ $form->{"parts"}->[$i - 1] }; + my $checked; 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|


text('Continue') . qq|>|); form_footer(); - $lxdebug->leave_sub(); + $main::lxdebug->leave_sub(); } sub print_customer_selection { - $lxdebug->enter_sub(); + $main::lxdebug->enter_sub(); + + $main::auth->assert('license_edit'); + + my $form = $main::form; + my $locale = $main::locale; + 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]}; + my $j = 1; + for (my $i = 1; $i <= scalar(@{ $form->{"all_customers"} }); $i++) { + my %c = %{ $form->{"all_customers"}->[$i - 1] }; + my $checked; if ($i == 1) { $checked = "checked"; } else { $checked = ""; } - print(qq| + print( + qq| - - + + @@ -176,19 +211,28 @@ 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"}
text('Continue') . qq|>|); form_footer(); - $lxdebug->leave_sub(); + $main::lxdebug->leave_sub(); } sub print_license_form { - $lxdebug->enter_sub(); - print(qq| + $main::lxdebug->enter_sub(); + + $main::auth->assert('license_edit'); + + my $form = $main::form; + my %myconfig = %main::myconfig; + my $locale = $main::locale; + + print( + qq| @@ -197,50 +241,53 @@ 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,37 +297,58 @@ 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|
|); - $lxdebug->leave_sub(); +| . + $form->write_trigger(\%myconfig, 1, "validuntil", "BL", + "trigger_validuntil")); + + $main::lxdebug->leave_sub(); } sub add { - $lxdebug->enter_sub(); - if (!$lizenzen) { - $form->error($locale->text('The licensing module has been deactivated in lx-erp.conf.')); + $main::lxdebug->enter_sub(); + + $main::auth->assert('license_edit'); + + my $form = $main::form; + my $locale = $main::locale; + + if (!$main::lizenzen) { + $form->error( + $locale->text( + 'The licensing module has been deactivated in lx-erp.conf.') + ); } $form->{"initial"} = 1; do_add(); - $lxdebug->leave_sub(); + $main::lxdebug->leave_sub(); } sub do_add { - $lxdebug->enter_sub(); + $main::lxdebug->enter_sub(); + + $main::auth->assert('license_edit'); + + my $form = $main::form; + my %myconfig = %main::myconfig; + $form->{"hidden"} = ["parts_id"]; form_header(); if ($form->{"ndx"}) { - $ndx = $form->{"ndx"}; + my $ndx = $form->{"ndx"}; foreach (keys(%{$form})) { next unless (/^new_.*_${ndx}$/); s/^new_//; @@ -295,11 +363,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) { + my %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 +382,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(); @@ -335,96 +403,128 @@ sub do_add { print_license_form($form->{"parts_id"} && $form->{"customer_id"}); form_footer(); - $lxdebug->leave_sub(); + $main::lxdebug->leave_sub(); } sub update { - $lxdebug->enter_sub(); + $main::lxdebug->enter_sub(); + + $main::auth->assert('license_edit'); + + my $form = $main::form; + do_add(); - $lxdebug->leave_sub(); + + $main::lxdebug->leave_sub(); } sub continue { - $lxdebug->enter_sub(); - &{ $form->{nextsub} }; - $lxdebug->leave_sub(); + $main::lxdebug->enter_sub(); + + my $form = $main::form; + + call_sub($form->{"nextsub"}); + $main::lxdebug->leave_sub(); } sub save { - $lxdebug->enter_sub(); - - ($form->{customername}, $form->{customer_id}) = split /--/, $form->{customer}; + $main::lxdebug->enter_sub(); + + $main::auth->assert('license_edit'); + + my $form = $main::form; + my %myconfig = %main::myconfig; + my $locale = $main::locale; + + ($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 + my $rc = LICENSES->save_license(\%myconfig, \%$form); + + # load previous variables if ($form->{previousform}) { + # save the new form variables before splitting previousform + my %newform; map { $newform{$_} = $form->{$_} } keys %$form; - $previousform = $form->unescape($form->{previousform}); + my $previousform = $form->unescape($form->{previousform}); # don't trample on previous variables map { delete $form->{$_} } keys %newform; # now take it apart and restore original values - foreach $item (split /&/, $previousform) { - ($key, $value) = split /=/, $item, 2; + foreach my $item (split /&/, $previousform) { + my ($key, $value) = split /=/, $item, 2; $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}); + my $callback = $form->unescape($form->{callback}); $form->{callback} = $form->unescape($form->{old_callback}); delete $form->{old_callback}; - # put callback together - foreach $key (keys %$form) { + foreach my $key (keys %$form) { + next if (($key eq 'login') || ($key eq 'password') || ('' ne ref $form->{$key})); + # do single escape for Apache 2.0 - $value = $form->escape($form->{$key}, 1); + my $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(); } - $lxdebug->leave_sub(); + $main::lxdebug->leave_sub(); } sub search { - $lxdebug->enter_sub(); - if (!$lizenzen) { - $form->error($locale->text('The licensing module has been deactivated in lx-erp.conf.')); + $main::lxdebug->enter_sub(); + + $main::auth->assert('license_edit'); + + my $form = $main::form; + my $locale = $main::locale; + + if (!$main::lizenzen) { + $form->error( + $locale->text( + 'The licensing module has been deactivated in lx-erp.conf.') + ); } form_header(); - print(qq| + print( + qq| @@ -445,15 +545,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|
-
+
@@ -462,24 +564,30 @@ sub search { |); form_footer(); - $lxdebug->leave_sub(); + $main::lxdebug->leave_sub(); } sub do_search { - $lxdebug->enter_sub(); + $main::lxdebug->enter_sub(); + + $main::auth->assert('license_edit'); + + my $form = $main::form; + my %myconfig = %main::myconfig; + my $locale = $main::locale; + 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="; - $invdetails = "is.pl?action=edit" . $callback . "\&id="; - $callback = $form->{"script"} . "?action=do_search" . $callback; + my $callback = ""; + map { $callback .= "\&${_}=" . $form->escape($form->{$_}, 1) } + qw(db partnumber description customer_name all expiring_in show_expired); + my $details = $form->{"script"} . "?action=details" . $callback . "\&id="; + my $invdetails = "is.pl?action=edit" . $callback . "\&id="; + $callback = $form->{"script"} . "?action=do_search" . $callback; $form->{"sortby"} = "validuntil" unless ($form->{"sortby"}); $form->{"sortasc"} *= 1; + my %columns; foreach (("partnumber", "description", "name", "validuntil", "invnumber")) { $columns{$_} = $callback . "\&sortby=${_}\&sortasc="; if ($form->{"sortby"} eq $_) { @@ -491,63 +599,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++) { - $ref = $form->{"licenses"}->[$i]; - print(qq| + my $j = 1; + for (my $i = 0; $i < scalar(@{ $form->{"licenses"} }); $i++) { + my $ref = $form->{"licenses"}->[$i]; + 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|
@@ -561,17 +680,26 @@ sub do_search { |); form_footer(); - $lxdebug->leave_sub(); + $main::lxdebug->leave_sub(); } sub details { - $lxdebug->enter_sub(); + $main::lxdebug->enter_sub(); + + $main::auth->assert('license_edit'); + + my $form = $main::form; + my %myconfig = %main::myconfig; + my $locale = $main::locale; + 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| @@ -617,7 +745,7 @@ sub details { |); form_footer(); - $lxdebug->leave_sub(); + $main::lxdebug->leave_sub(); } 1;
| . $locale->text("View License") . qq|