use utf8;
use SL::Auth;
+use SL::Auth::PasswordPolicy;
use SL::AM;
use SL::CA;
use SL::Form;
push(@ { $form->{AJAX} }, $pjx);
- $form->{stylesheets} = "list_accounts.css";
+ $form->use_stylesheet("list_accounts.css");
$form->{title} = $locale->text('Chart of Accounts');
$form->header;
$form->{title} = $locale->text('Type of Business');
my @column_index = qw(description discount customernumberinit);
- push @column_index, 'salesman' if $::vertreter;
+ push @column_index, 'salesman' if $::lx_office_conf{features}->{vertreter};
my %column_header;
$column_header{description} =
qq|<th class=listheading width=60%>|
$form->format_amount(\%myconfig, $form->{discount} * 100);
my $salesman_code;
- if ($::vertreter) {
+ if ($::lx_office_conf{features}->{vertreter}) {
$salesman_code = qq|
<tr>
<th align="right">| . $locale->text('Representative') . qq|</th>
}
my $linkaccounts;
- if (!$main::eur) {
+ if (!$::lx_office_conf{system}->{eur}) {
$linkaccounts = qq|
<tr>
<th align=right>| . $locale->text('Inventory') . qq|</th>
$main::lxdebug->leave_sub();
}
-sub add_payment {
- $main::lxdebug->enter_sub();
-
- my $form = $main::form;
- my %myconfig = %main::myconfig;
-
- $main::auth->assert('config');
-
- $form->{title} = "Add";
-
- $form->{callback} = "am.pl?action=add_payment" unless $form->{callback};
-
- $form->{terms_netto} = 0;
- $form->{terms_skonto} = 0;
- $form->{percent_skonto} = 0;
- my @languages = AM->language(\%myconfig, $form, 1);
- map({ $_->{"language"} = $_->{"description"};
- $_->{"language_id"} = $_->{"id"}; } @languages);
- $form->{"TRANSLATION"} = \@languages;
- &payment_header;
- &form_footer;
-
- $main::lxdebug->leave_sub();
-}
-
-sub edit_payment {
- $main::lxdebug->enter_sub();
-
- my $form = $main::form;
- my %myconfig = %main::myconfig;
-
- $main::auth->assert('config');
-
- $form->{title} = "Edit";
-
- AM->get_payment(\%myconfig, $form);
- $form->{percent_skonto} =
- $form->format_amount(\%myconfig, $form->{percent_skonto} * 100);
-
- &payment_header;
-
- $form->{orphaned} = 1;
- &form_footer;
-
- $main::lxdebug->leave_sub();
-}
-
-sub list_payment {
- $main::lxdebug->enter_sub();
-
- my $form = $main::form;
- my %myconfig = %main::myconfig;
- my $locale = $main::locale;
-
- $main::auth->assert('config');
-
- AM->payment(\%myconfig, \%$form);
-
- $form->{callback} = build_std_url("action=list_payment");
-
- my $callback = $form->escape($form->{callback});
-
- $form->{title} = $locale->text('Payment Terms');
-
- my @column_index = qw(up down description description_long terms_netto
- terms_skonto percent_skonto);
- my %column_header;
- $column_header{up} =
- qq|<th class="listheading" align="center" valign="center" width="16">|
- . qq|<img src="image/up.png" alt="| . $locale->text("up") . qq|">|
- . qq|</th>|;
- $column_header{down} =
- qq|<th class="listheading" align="center" valign="center" width="16">|
- . qq|<img src="image/down.png" alt="| . $locale->text("down") . qq|">|
- . qq|</th>|;
- $column_header{description} =
- qq|<th class=listheading>|
- . $locale->text('Description')
- . qq|</th>|;
- $column_header{description_long} =
- qq|<th class=listheading>|
- . $locale->text('Long Description')
- . qq|</th>|;
- $column_header{terms_netto} =
- qq|<th class=listheading>|
- . $locale->text('Netto Terms')
- . qq|</th>|;
- $column_header{terms_skonto} =
- qq|<th class=listheading>|
- . $locale->text('Skonto Terms')
- . qq|</th>|;
- $column_header{percent_skonto} =
- qq|<th class=listheading>|
- . $locale->text('Skonto')
- . qq| %</th>|;
-
- $form->header;
-
- print qq|
-<body>
-
-<table width=100%>
- <tr>
- <th class=listtop>$form->{title}</th>
- </tr>
- <tr height="5"></tr>
- <tr>
- <td>
- <table width=100%>
- <tr class=listheading>
-|;
-
- map { print "$column_header{$_}\n" } @column_index;
-
- print qq|
- </tr>
-|;
-
- my $swap_link = build_std_url("action=swap_payment_terms");
-
- my $row = 0;
- my ($i, %column_data);
- foreach my $ref (@{ $form->{ALL} }) {
-
- $i++;
- $i %= 2;
-
- print qq|
- <tr valign=top class=listrow$i>
-|;
-
- if ($row) {
- my $pref = $form->{ALL}->[$row - 1];
- $column_data{up} =
- qq|<td align="center" valign="center" width="16">| .
- qq|<a href="${swap_link}&id1=$ref->{id}&id2=$pref->{id}">| .
- qq|<img border="0" src="image/up.png" alt="| . $locale->text("up") . qq|">| .
- qq|</a></td>|;
- } else {
- $column_data{up} = qq|<td width="16"> </td>|;
- }
-
- if ($row == (scalar(@{ $form->{ALL} }) - 1)) {
- $column_data{down} = qq|<td width="16"> </td>|;
- } else {
- my $nref = $form->{ALL}->[$row + 1];
- $column_data{down} =
- qq|<td align="center" valign="center" width="16">| .
- qq|<a href="${swap_link}&id1=$ref->{id}&id2=$nref->{id}">| .
- qq|<img border="0" src="image/down.png" alt="| . $locale->text("down") . qq|">| .
- qq|</a></td>|;
- }
-
- $column_data{description} =
- qq|<td><a href="| .
- build_std_url("action=edit_payment", "id=$ref->{id}", "callback=$callback") .
- qq|">| . H($ref->{description}) . qq|</a></td>|;
- $column_data{description_long} =
- qq|<td>| . H($ref->{description_long}) . qq|</td>|;
- $column_data{terms_netto} =
- qq|<td align=right>$ref->{terms_netto}</td>|;
- $column_data{terms_skonto} =
- qq|<td align=right>$ref->{terms_skonto}</td>|;
- $column_data{percent_skonto} =
- qq|<td align=right>| .
- $form->format_amount(\%myconfig, $ref->{percent_skonto} * 100) .
- qq|%</td>|;
- map { print "$column_data{$_}\n" } @column_index;
-
- print qq|
- </tr>
-|;
- $row++;
- }
-
- print qq|
- </table>
- </td>
- </tr>
- <tr>
- <td><hr size=3 noshade></td>
- </tr>
-</table>
-
-<br>
-<form method=post action=am.pl>
-
-<input name=callback type=hidden value="$form->{callback}">
-
-<input type=hidden name=type value=payment>
-
-<input class=submit type=submit name=action value="|
- . $locale->text('Add') . qq|">
-
- </form>
-
- </body>
- </html>
-|;
-
- $main::lxdebug->leave_sub();
-}
-
-sub payment_header {
- $main::lxdebug->enter_sub();
-
- my $form = $main::form;
- my $locale = $main::locale;
-
- $main::auth->assert('config');
-
- $form->{title} = $locale->text("$form->{title} Payment Terms");
-
- # $locale->text('Add Payment Terms')
- # $locale->text('Edit Payment Terms')
-
- $form->{description} =~ s/\"/"/g;
-
-
-
- $form->header;
-
- print qq|
-<body>
-
-<form method=post action=am.pl>
-
-<input type=hidden name=id value=$form->{id}>
-<input type=hidden name=type value=payment>
-
-<table width=100%>
- <tr>
- <th class=listtop colspan=2>$form->{title}</th>
- </tr>
- <tr height="5"></tr>
- <tr>
- <th align=right>| . $locale->text('Description') . qq|</th>
- <td><input name=description size=30 value="$form->{description}"></td>
- <tr>
- <tr>
- <th align=right>| . $locale->text('Long Description') . qq|</th>
- <td><input name=description_long size=50 value="$form->{description_long}"></td>
- </tr>
-|;
-
- foreach my $language (@{ $form->{"TRANSLATION"} }) {
- print qq|
- <tr>
- <th align="right">| .
- sprintf($locale->text('Translation (%s)'),
- $language->{"language"})
- . qq|</th>
- <td><input name="description_long_$language->{language_id}" size="50"
- value="| . Q($language->{"description_long"}) . qq|"></td>
- </tr>
-|;
- }
-
- print qq|
- <tr>
- <th align=right>| . $locale->text('Netto Terms') . qq|</th>
- <td><input name=terms_netto size=10 value="$form->{terms_netto}"></td>
- </tr>
- <tr>
- <th align=right>| . $locale->text('Skonto Terms') . qq|</th>
- <td><input name=terms_skonto size=10 value="$form->{terms_skonto}"></td>
- </tr>
- <tr>
- <th align=right>| . $locale->text('Skonto') . qq| %</th>
- <td><input name=percent_skonto size=10 value="$form->{percent_skonto}"></td>
- </tr>
- <td colspan=2><hr size=3 noshade></td>
- </tr>
-</table>
-
-<p>| . $locale->text("You can use the following strings in the long " .
- "description and all translations. They will be " .
- "replaced by their actual values by Lx-Office " .
- "before they're output.")
-. qq|</p>
-
-<ul>
- <li>| . $locale->text("<%netto_date%> -- Date the payment is due in " .
- "full")
-. qq|</li>
- <li>| . $locale->text("<%skonto_date%> -- Date the payment is due " .
- "with discount")
-. qq|</li>
- <li>| . $locale->text("<%skonto_amount%> -- The deductible amount")
-. qq|</li>
- <li>| . $locale->text("<%skonto_in_percent%> -- The discount in percent")
-. qq|</li>
- <li>| . $locale->text("<%total%> -- Amount payable")
-. qq|</li>
- <li>| . $locale->text("<%total_wo_skonto%> -- Amount payable less discount")
-. qq|</li>
- <li>| . $locale->text("<%invtotal%> -- Invoice total")
-. qq|</li>
- <li>| . $locale->text("<%invtotal_wo_skonto%> -- Invoice total less discount")
-. qq|</li>
- <li>| . $locale->text("<%currency%> -- The selected currency")
-. qq|</li>
- <li>| . $locale->text("<%terms_netto%> -- The number of days for " .
- "full payment")
-. qq|</li>
- <li>| . $locale->text("<%account_number%> -- Your account number")
-. qq|</li>
- <li>| . $locale->text("<%bank%> -- Your bank")
-. qq|</li>
- <li>| . $locale->text("<%bank_code%> -- Your bank code")
-. qq|</li>
-</ul>|;
-
- $main::lxdebug->leave_sub();
-}
-
-sub save_payment {
- $main::lxdebug->enter_sub();
-
- my $form = $main::form;
- my %myconfig = %main::myconfig;
- my $locale = $main::locale;
-
- $main::auth->assert('config');
-
- $form->isblank("description", $locale->text('Description missing!'));
- $form->{"percent_skonto"} =
- $form->parse_amount(\%myconfig, $form->{percent_skonto}) / 100;
- AM->save_payment(\%myconfig, \%$form);
- $form->redirect($locale->text('Payment Terms saved!'));
-
- $main::lxdebug->leave_sub();
-}
-
-sub delete_payment {
- $main::lxdebug->enter_sub();
-
- my $form = $main::form;
- my %myconfig = %main::myconfig;
- my $locale = $main::locale;
-
- $main::auth->assert('config');
-
- AM->delete_payment(\%myconfig, \%$form);
- $form->redirect($locale->text('Payment terms deleted!'));
-
- $main::lxdebug->leave_sub();
-}
-
-sub swap_payment_terms {
- $main::lxdebug->enter_sub();
-
- my $form = $main::form;
- my %myconfig = %main::myconfig;
-
- $main::auth->assert('config');
-
- AM->swap_sortkeys(\%myconfig, $form, "payment_terms");
- list_payment();
-
- $main::lxdebug->leave_sub();
-}
-
sub edit_defaults {
$main::lxdebug->enter_sub();
_build_cfg_options('numberformat', ('1,000.00', '1000.00', '1.000,00', '1000,00'));
my @formats = ();
- if ($main::opendocument_templates && $main::openofficeorg_writer_bin &&
- $main::xvfb_bin && (-x $main::openofficeorg_writer_bin) && (-x $main::xvfb_bin)) {
+ if ($::lx_office_conf{print_templates}->{opendocument}
+ && $::lx_office_conf{applications}->{openofficeorg_writer} && (-x $::lx_office_conf{applications}->{openofficeorg_writer})
+ && $::lx_office_conf{applications}->{xvfb} && (-x $::lx_office_conf{applications}->{xvfb})) {
push(@formats, { "name" => $locale->text("PDF (OpenDocument/OASIS)"),
"value" => "opendocument_pdf" });
}
- if ($main::latex_templates) {
+ if ($::lx_office_conf{print_templates}->{latex}) {
push(@formats, { "name" => $locale->text("PDF"), "value" => "pdf" });
}
push(@formats, { "name" => "HTML", "value" => "html" });
- if ($main::latex_templates) {
+ if ($::lx_office_conf{print_templates}->{latex}) {
push(@formats, { "name" => $locale->text("Postscript"),
"value" => "postscript" });
}
- if ($main::opendocument_templates) {
+ if ($::lx_office_conf{print_templates}->{opendocument}) {
push(@formats, { "name" => $locale->text("OpenDocument/OASIS"),
"value" => "opendocument" });
}
TODO->save_user_config('login' => $form->{login}, %{ $form->{todo_cfg} || { } });
- $form->redirect($locale->text('Preferences saved!')) if (AM->save_preferences(\%myconfig, \%$form, 0));
+ if (AM->save_preferences(\%myconfig, $form)) {
+ if ($::auth->can_change_password()
+ && defined $form->{new_password}
+ && ($form->{new_password} ne '********')) {
+ my $verifier = SL::Auth::PasswordPolicy->new;
+ my $result = $verifier->verify($form->{new_password});
+
+ if ($result != SL::Auth::PasswordPolicy->OK()) {
+ $form->error($::locale->text('The settings were saved, but the password was not changed.') . ' ' . join(' ', $verifier->errors($result)));
+ }
+
+ $::auth->change_password($form->{login}, $form->{new_password});
+
+ $form->{password} = $form->{new_password};
+ $::auth->set_session_value('password', $form->{password});
+ $::auth->create_or_refresh_session();
+ }
+
+ $form->redirect($locale->text('Preferences saved!'));
+ }
+
$form->error($locale->text('Cannot save preferences!'));
$main::lxdebug->leave_sub();
$units = AM->retrieve_units(\%myconfig, $form);
my $ddbox = AM->unit_select_data($units, undef, 1);
- my $updownlink = build_std_url("action=swap_units");
-
$form->{"title"} = $locale->text("Add and edit units");
$form->header();
print($form->parse_html_template("am/edit_units",
{ "UNITS" => \@unit_list,
"NEW_BASE_UNIT_DDBOX" => $ddbox,
"LANGUAGES" => \@languages,
- "updownlink" => $updownlink }));
+ }));
$main::lxdebug->leave_sub();
}
my %searchNo = ( "Artikelnummer" => "partnumber",
"Kundennummer" => "customernumber",
"Lieferantennummer" => "vendornumber",
- "Projektnummer" => "projectnummer",
+ "Projektnummer" => "projectnumber",
"Buchungsnummer" => "ordnumber",
"Eingangsrechnungnummer" => "invnumber",
"Ausgangsrechnungnummer" => "invnumber",
$main::lxdebug->leave_sub();
}
-sub swap_units {
- $main::lxdebug->enter_sub();
-
- my $form = $main::form;
- my %myconfig = %main::myconfig;
-
- $main::auth->assert('config');
-
- my $dir = $form->{"dir"} eq "down" ? "down" : "up";
- AM->swap_units(\%myconfig, $form, $dir, $form->{"name"});
-
- edit_units();
-
- $main::lxdebug->leave_sub();
-}
-
sub add_tax {
$main::lxdebug->enter_sub();
AM->get_all_price_factors(\%myconfig, \%$form);
- my $previous;
foreach my $current (@{ $form->{PRICE_FACTORS} }) {
- if ($previous) {
- $previous->{next_id} = $current->{id};
- $current->{previous_id} = $previous->{id};
- }
-
$current->{factor} = $form->format_amount(\%myconfig, $current->{factor} * 1);
-
- $previous = $current;
}
$form->{callback} = build_std_url('action=list_price_factors');
$main::lxdebug->leave_sub();
}
-sub swap_price_factors {
- $main::lxdebug->enter_sub();
-
- my $form = $main::form;
- my %myconfig = %main::myconfig;
-
- $main::auth->assert('config');
-
- AM->swap_sortkeys(\%myconfig, $form, 'price_factors');
- list_price_factors();
-
- $main::lxdebug->leave_sub();
-}
-
sub add_warehouse {
$main::lxdebug->enter_sub();
AM->get_all_warehouses(\%myconfig, $form);
- my $previous;
- foreach my $current (@{ $form->{WAREHOUSES} }) {
- if ($previous) {
- $previous->{next_id} = $current->{id};
- $current->{previous_id} = $previous->{id};
- }
-
- $previous = $current;
- }
-
$form->{callback} = build_std_url('action=list_warehouses');
$form->{title} = $locale->text('Warehouses');
$form->{url_base} = build_std_url('callback');
$main::lxdebug->leave_sub();
}
-sub swap_warehouses {
- $main::lxdebug->enter_sub();
-
- my $form = $main::form;
- my %myconfig = %main::myconfig;
-
- $main::auth->assert('config');
-
- AM->swap_sortkeys(\%myconfig, $form, 'warehouse');
- list_warehouses();
-
- $main::lxdebug->leave_sub();
-}
-
sub delete_warehouse {
$main::lxdebug->enter_sub();