X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;ds=sidebyside;f=bin%2Fmozilla%2Flicenses.pl;h=5876e85887f46e7d5b05f12ccb544d9991e8c463;hb=bb5ee43d0ddff8f8b57ce0f15a5664b26c110d1f;hp=1dfcb4e285ada55ae5ecb6df4af5b2084498a5d6;hpb=4dbb09950c9f5596646537c12d991c99086fe7c1;p=kivitendo-erp.git diff --git a/bin/mozilla/licenses.pl b/bin/mozilla/licenses.pl index 1dfcb4e28..5876e8588 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,14 @@ sub quot { sub form_header { $lxdebug->enter_sub(); + + $auth->assert('license_edit'); + + $form->{jsscript} = 1; $form->header(); - print(qq| + print( + qq|
{script}>|); $lxdebug->leave_sub(); @@ -54,13 +61,18 @@ sub form_header { sub form_footer { $lxdebug->enter_sub(); - my @items = ("path", "login", "password", "old_callback", "previousform"); - push(@items, @{$form->{"hidden"}}); + + $auth->assert('license_edit'); + + my @items = qw(old_callback previousform); + push(@items, @{ $form->{"hidden"} }); map({ - print("{$_}) . "\">\n"); + print("{$_}) . "\">\n" + ); } @items); - print(qq|
+ print( + qq| |); @@ -69,57 +81,58 @@ sub form_footer { sub set_std_hidden { $lxdebug->enter_sub(); - $form->{"hidden"} = - ["comment", - "validuntil", - "quantity", - @_]; + $form->{"hidden"} = ["comment", "validuntil", "quantity", @_]; $lxdebug->leave_sub(); } sub print_part_selection { $lxdebug->enter_sub(); + + $auth->assert('license_edit'); + 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|


@@ -131,43 +144,48 @@ sub print_part_selection { sub print_customer_selection { $lxdebug->enter_sub(); + + $auth->assert('license_edit'); + 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 +194,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 +207,11 @@ sub print_customer_selection { sub print_license_form { $lxdebug->enter_sub(); - print(qq| + + $auth->assert('license_edit'); + + print( + qq| @@ -197,19 +220,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 +276,34 @@ 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(); + + $auth->assert('license_edit'); + 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; @@ -276,6 +314,9 @@ sub add { sub do_add { $lxdebug->enter_sub(); + + $auth->assert('license_edit'); + $form->{"hidden"} = ["parts_id"]; form_header(); @@ -295,11 +336,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 +355,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(); @@ -340,35 +381,45 @@ sub do_add { sub update { $lxdebug->enter_sub(); + + $auth->assert('license_edit'); + do_add(); + $lxdebug->leave_sub(); } 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}; + + $auth->assert('license_edit'); + + ($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 +434,34 @@ 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) { + 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); $callback .= qq|&$key=$value|; } $form->{callback} = $callback; - + # redirect $form->redirect; - + } else { form_header(); - + print("Die Lizenz wurde gespeichert.\n"); form_footer(); } @@ -418,13 +471,20 @@ sub save { sub search { $lxdebug->enter_sub(); + + $auth->assert('license_edit'); + 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 +505,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|
-
+
@@ -467,16 +529,17 @@ sub search { sub do_search { $lxdebug->enter_sub(); + + $auth->assert('license_edit'); + 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 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 +554,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|
@@ -566,12 +640,17 @@ sub do_search { sub details { $lxdebug->enter_sub(); + + $auth->assert('license_edit'); + 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|