X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;f=bin%2Fmozilla%2Fam.pl;h=f1b339843c6fa782bca51b573aabc1e3500cb211;hb=53593baa211863fbf66540cf1bcc36c8fb37257f;hp=4e327fd422e432b35785e9465654f30f7044dc22;hpb=8ec0d29a33e23ce962b807e87cc8b577c8c98ec2;p=kivitendo-erp.git diff --git a/bin/mozilla/am.pl b/bin/mozilla/am.pl index 4e327fd42..541ababea 100644 --- a/bin/mozilla/am.pl +++ b/bin/mozilla/am.pl @@ -24,52 +24,87 @@ # GNU General Public License for more details. # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software -# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, +# MA 02110-1335, USA. #====================================================================== # # administration # #====================================================================== +use utf8; + +use List::MoreUtils qw(any); + +use SL::Auth; +use SL::Auth::PasswordPolicy; use SL::AM; use SL::CA; use SL::Form; +use SL::Helper::Flash; +use SL::Helper::UserPreferences; use SL::User; +use SL::USTVA; +use SL::Iconv; +use SL::Locale::String qw(t8); +use SL::TODO; +use SL::DB::Printer; +use SL::DB::Tax; +use SL::DB::Language; +use SL::DB::Default; +use SL::DBUtils qw(selectall_array_query conv_dateq); +use CGI; -use Data::Dumper; +require "bin/mozilla/common.pl"; -1; +use strict; -require "$form->{path}/common.pl"; +1; # end of main -sub add { &{"add_$form->{type}"} } -sub edit { &{"edit_$form->{type}"} } -sub save { &{"save_$form->{type}"} } -sub delete { &{"delete_$form->{type}"} } +sub add { call_sub("add_$main::form->{type}"); } +sub delete { call_sub("delete_$main::form->{type}"); } +sub save { call_sub("save_$main::form->{type}"); } +sub edit { call_sub("edit_$main::form->{type}"); } +sub continue { call_sub($main::form->{"nextsub"}); } +sub save_as_new { call_sub("save_as_new_$main::form->{type}"); } sub add_account { - $lxdebug->enter_sub(); + $main::lxdebug->enter_sub(); + + my $form = $main::form; + my %myconfig = %main::myconfig; + + $main::auth->assert('config'); $form->{title} = "Add"; $form->{charttype} = "A"; AM->get_account(\%myconfig, \%$form); - $form->{callback} = - "$form->{script}?action=list_account&path=$form->{path}&login=$form->{login}&password=$form->{password}" - unless $form->{callback}; + $form->{callback} = "am.pl?action=list_account" unless $form->{callback}; &account_header; - &form_footer; - $lxdebug->leave_sub(); + $main::lxdebug->leave_sub(); } sub edit_account { - $lxdebug->enter_sub(); + $main::lxdebug->enter_sub(); + + my $form = $main::form; + my %myconfig = %main::myconfig; + my $defaults = SL::DB::Default->get; + + $main::auth->assert('config'); $form->{title} = "Edit"; + $form->{feature_balance} = $defaults->feature_balance; + $form->{feature_datev} = $defaults->feature_datev; + $form->{feature_erfolgsrechnung} = $defaults->feature_erfolgsrechnung; + $form->{feature_eurechnung} = $defaults->feature_eurechnung; + $form->{feature_ustva} = $defaults->feature_ustva; + AM->get_account(\%myconfig, \%$form); foreach my $item (split(/:/, $form->{link})) { @@ -77,492 +112,364 @@ sub edit_account { } &account_header; - &form_footer; - $lxdebug->leave_sub(); + $main::lxdebug->leave_sub(); } sub account_header { - $lxdebug->enter_sub(); + $main::lxdebug->enter_sub(); + + my $form = $main::form; + my %myconfig = %main::myconfig; + my $locale = $main::locale; + + $main::auth->assert('config'); + + if ( $form->{action} eq 'edit_account') { + $form->{account_exists} = '1'; + } $form->{title} = $locale->text("$form->{title} Account"); - $checked{ $form->{charttype} } = "checked"; - $checked{"$form->{category}_"} = "checked"; - $checked{CT_tax} = ($form->{CT_tax}) ? "" : "checked"; + $form->{"$form->{charttype}_checked"} = "checked"; + $form->{"$form->{category}_checked"} = "checked"; + + $form->{select_tax} = ""; - $form->{description} =~ s/\"/"/g; + my @tax_report_pos = USTVA->report_variables({ + myconfig => \%myconfig, + form => $form, + type => '', + attribute => 'position', + calc => '', + }); if (@{ $form->{TAXKEY} }) { - foreach $item (@{ $form->{TAXKEY} }) { - if ($item->{tax} == $form->{tax}) { - $form->{selecttaxkey} .= - ""; + $form->{selectnewaccount} = qq||; } - foreach $item (@{ $form->{NEWACCOUNT} }) { + foreach my $item (@{ $form->{NEWACCOUNT} }) { if ($item->{id} == $form->{new_chart_id}) { $form->{selectnewaccount} .= - ""; + qq||; } elsif (!$form->{new_chart_valid}) { $form->{selectnewaccount} .= - ""; + qq||; } } } - $newaccount = qq| - - - - - - - - - -
| . $locale->text('Folgekonto') . qq|| . $locale->text('Gültig ab') . qq|
- - |; - - $form->{selectustva} = "\n|; + my %eur = %{ AM->get_eur_categories(\%myconfig, $form) }; + foreach my $item (sort({ $a <=> $b } keys(%eur))) { + my $text = H($::locale->{iconv_utf8}->convert($eur{$item})); + if ($item == $form->{pos_eur}) { + $select_eur .= qq|\n|; } else { - $form->{selectustva} .= "\n|; } } - $ustva = qq| - - | . $locale->text('Umsatzsteuervoranmeldung') . qq| - - - |; - - $form->{selecteur} = "\n|; + my %er = ( + 1 => "Ertrag", + 6 => "Aufwand"); + foreach my $item (sort({ $a <=> $b } keys(%er))) { + my $text = H($::locale->{iconv_utf8}->convert($er{$item})); + if ($item == $form->{pos_er}) { + $select_er .= qq|\n|; } else { - $form->{selecteur} .= "\n|; } } - $eur = qq| - - | . $locale->text('EUER') . qq| - - - |; - - $form->{selectbwa} = "\n|; + + my %bwapos = %{ AM->get_bwa_categories(\%myconfig, $form) }; + foreach my $item (sort({ $a <=> $b } keys %bwapos)) { + my $text = H($::locale->{iconv_utf8}->convert($bwapos{$item})); if ($item == $form->{pos_bwa}) { - $form->{selectbwa} .= "\n|; + foreach my $item ((1, 2, 3, 4)) { + if ($item == $form->{pos_bilanz}) { + $select_bilanz .= qq|\n|; + + my %category = ( + 'A' => $locale->text('Asset'), + 'L' => $locale->text('Liability'), + 'Q' => $locale->text('Equity'), + 'I' => $locale->text('Revenue'), + 'E' => $locale->text('Expense'), + 'C' => $locale->text('Costs'), + ); + foreach my $item ( sort({ $a <=> $b } keys %category) ) { + if ($item eq $form->{category}) { + $select_category .= qq||; - foreach $item (qw(1,000.00 1000.00 1.000,00 1000,00)) { - $numberformat .= - ($item eq $form->{output_numberformat}) - ? ""; - } + setup_am_edit_warehouse_action_bar(id => $::form->{id}, in_use => any { $_->{in_use} } @{ $::form->{BINS} }); - my $dateformat = - qq||; - foreach $item (qw(mm-dd-yy mm/dd/yy dd-mm-yy dd/mm/yy dd.mm.yy yyyy-mm-dd)) { - $dateformat .= - ($item eq $form->{output_dateformat}) - ? ""; - } + $form->header(); + print $form->parse_html_template('am/edit_warehouse'); - print qq| - - -
{script}> - -{id}> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
$form->{title}
| . $locale->text('Language') . qq|
| . $locale->text('Template Code') . qq|
| . $locale->text('Article Code') . qq|
| . $locale->text('Number Format') . qq|
| . $locale->text('Date Format') . qq|
| . $locale->text('Long Dates') . qq|{output_longdates} ? " checked" : "") . - qq|>| . $locale->text("Yes") . - qq|{output_longdates} ? "" : " checked") . - qq|>| . $locale->text("No") . - qq|

-|; - - $lxdebug->leave_sub(); + $main::lxdebug->leave_sub(); } -sub save_language { - $lxdebug->enter_sub(); - - $form->isblank("description", $locale->text('Language missing!')); - $form->isblank("template_code", $locale->text('Template Code missing!')); - $form->isblank("article_code", $locale->text('Article Code missing!')); - AM->save_language(\%myconfig, \%$form); - $form->redirect($locale->text('Language saved!')); +sub edit_bins { + $::auth->assert('config'); - $lxdebug->leave_sub(); -} + AM->get_warehouse(\%::myconfig, $::form); -sub delete_language { - $lxdebug->enter_sub(); + $::form->{title} = $::locale->text('Edit Bins for Warehouse \'#1\'', $::form->{description}); + $::form->{callback} ||= build_std_url('action=list_warehouses'); - AM->delete_language(\%myconfig, \%$form); - $form->redirect($locale->text('Language deleted!')); + setup_am_edit_bins_action_bar(id => $::form->{id}); - $lxdebug->leave_sub(); + $::form->header; + print $::form->parse_html_template('am/edit_bins'); } +sub list_warehouses { + $main::lxdebug->enter_sub(); -sub add_buchungsgruppe { - $lxdebug->enter_sub(); - - # $locale->text("Add Buchungsgruppe") - # $locale->text("Edit Buchungsgruppe") - $form->{title} = "Add"; - - $form->{callback} = - "$form->{script}?action=add_buchungsgruppe&path=$form->{path}&login=$form->{login}&password=$form->{password}" - unless $form->{callback}; - AM->get_buchungsgruppe(\%myconfig, \%$form); - $form->{"inventory_accno_id"} = $form->{"std_inventory_accno_id"}; - for (my $i = 0; 4 > $i; $i++) { - map({ $form->{"${_}_accno_id_$i"} = $form->{"std_${_}_accno_id"}; } - qw(income expense)); - } - - &buchungsgruppe_header; - &form_footer; - - $lxdebug->leave_sub(); -} + my $form = $main::form; + my %myconfig = %main::myconfig; + my $locale = $main::locale; -sub edit_buchungsgruppe { - $lxdebug->enter_sub(); + $main::auth->assert('config'); - $form->{title} = "Edit"; + AM->get_all_warehouses(\%myconfig, $form); - AM->get_buchungsgruppe(\%myconfig, \%$form); + $form->{callback} = build_std_url('action=list_warehouses'); + $form->{title} = $locale->text('Warehouses'); + $form->{url_base} = build_std_url('callback'); - &buchungsgruppe_header; + setup_am_list_warehouses_action_bar(); - &form_footer; + $form->header(); + print $form->parse_html_template('am/list_warehouses'); - $lxdebug->leave_sub(); + $main::lxdebug->leave_sub(); } -sub list_buchungsgruppe { - $lxdebug->enter_sub(); - - AM->buchungsgruppe(\%myconfig, \%$form); - - $form->{callback} = - "$form->{script}?action=list_buchungsgruppe&path=$form->{path}&login=$form->{login}&password=$form->{password}"; - - $callback = $form->escape($form->{callback}); - - $form->{title} = $locale->text('Buchungsgruppen'); - - @column_index = qw(description inventory_accno income_accno_0 expense_accno_0 income_accno_1 expense_accno_1 income_accno_2 expense_accno_2 income_accno_3 expense_accno_3 ); - - $column_header{description} = - qq|| - . $locale->text('Description') - . qq||; - $column_header{inventory_accno} = - qq|| - . $locale->text('Bestandskonto') - . qq||; - $column_header{income_accno_0} = - qq|| - . $locale->text('Erlöse Inland') - . qq||; - $column_header{expense_accno_0} = - qq|| - . $locale->text('Aufwand Inland') - . qq||; - $column_header{income_accno_1} = - qq|| - . $locale->text('Erlöse EU m. UStId') - . qq||; - $column_header{expense_accno_1} = - qq|| - . $locale->text('Aufwand EU m. UStId') - . qq||; - $column_header{income_accno_2} = - qq|| - . $locale->text('Erlöse EU o. UStId') - . qq||; - $column_header{expense_accno_2} = - qq|| - . $locale->text('Aufwand EU o. UStId') - . qq||; - $column_header{income_accno_3} = - qq|| - . $locale->text('Erlöse Ausland') - . qq||; - $column_header{expense_accno_3} = - qq|| - . $locale->text('Aufwand Ausland') - . qq||; - $form->header; - - print qq| - - - - - - - - - - - - - -
$form->{title}
- - -|; - - map { print "$column_header{$_}\n" } @column_index; - - print qq| - -|; - - foreach $ref (@{ $form->{ALL} }) { - - $i++; - $i %= 2; - - print qq| - -|; - - - $column_data{description} = - qq||; - $column_data{inventory_accno} = qq||; - $column_data{income_accno_0} = - qq||; - $column_data{expense_accno_0} = qq||; - $column_data{income_accno_1} = - qq||; - $column_data{expense_accno_1} = qq||; - $column_data{income_accno_2} = - qq||; - $column_data{expense_accno_2} = qq||; - $column_data{income_accno_3} = - qq||; - $column_data{expense_accno_3} = qq||; - - map { print "$column_data{$_}\n" } @column_index; - - print qq| - -|; - } - - print qq| -
{script}?action=edit_buchungsgruppe&id=$ref->{id}&path=$form->{path}&login=$form->{login}&password=$form->{password}&callback=$callback>$ref->{description}$ref->{inventory_accno}$ref->{income_accno_0}$ref->{expense_accno_0}$ref->{income_accno_1}$ref->{expense_accno_1}$ref->{income_accno_2}$ref->{expense_accno_2}$ref->{income_accno_3}$ref->{expense_accno_3}
-

+sub save_warehouse { + $main::lxdebug->enter_sub(); -
-{script}> + my $form = $main::form; + my %myconfig = %main::myconfig; + my $locale = $main::locale; - + $main::auth->assert('config'); - + $form->isblank("description", $locale->text('Description missing!')); + $form->isblank("number_of_new_bins", $locale->text('Number') . $locale->text(' missing!')); -{path}> -{login}> -{password}> + $form->{number_of_new_bins} = $form->parse_amount(\%myconfig, $form->{number_of_new_bins}); - + AM->save_warehouse(\%myconfig, $form); -
+ $form->{callback} .= '&saved_message=' . E($locale->text('Warehouse saved.')) if ($form->{callback}); - - -|; + $form->redirect($locale->text('Warehouse saved.')); - $lxdebug->leave_sub(); + $main::lxdebug->leave_sub(); } -sub buchungsgruppe_header { - $lxdebug->enter_sub(); - - $form->{title} = $locale->text("$form->{title} Buchungsgruppe"); - - # $locale->text('Buchungsgruppe hinzufügen') - # $locale->text('Buchungsgruppe bearbeiten') - - my ($acc_inventory, $acc_income, $acc_expense) = ({}, {}, {}); - my %acc_type_map = ( - "IC" => $acc_inventory, - "IC_income" => $acc_income, - "IC_sale" => $acc_income, - "IC_expense" => $acc_expense, - "IC_cogs" => $acc_expense, - ); +sub delete_warehouse { + $main::lxdebug->enter_sub(); - foreach $key (keys(%acc_type_map)) { - foreach $ref (@{ $form->{IC_links}{$key} }) { - $acc_type_map{$key}->{$ref->{"id"}} = $ref; - } - } + my $form = $main::form; + my %myconfig = %main::myconfig; + my $locale = $main::locale; - foreach my $type (qw(IC IC_income IC_expense)) { - $form->{"select$type"} = - join("", - map({ "" } - sort({ $a->{"accno"} cmp $b->{"accno"} } - values(%{$acc_type_map{$type}})))); - } + $main::auth->assert('config'); - if ($form->{id}) { - $form->{selectIC} =~ s/selected//g; - $form->{selectIC} =~ s/ value=$form->{inventory_accno_id}/ value=$form->{inventory_accno_id} selected/; - $form->{selectIC_income} =~ s/selected//g; - $form->{selectIC_income} =~ s/ value=$form->{income_accno_id_0}/ value=$form->{income_accno_id_0} selected/; - $form->{selectIC_expense} =~ s/selected//g; - $form->{selectIC_expense} =~ s/ value=$form->{expense_accno_id_0}/ value=$form->{expense_accno_id_0} selected/; - } + if (AM->delete_warehouse(\%myconfig, $form)) { + $form->{callback} .= '&saved_message=' . E($locale->text('Warehouse deleted.')) if ($form->{callback}); + $form->redirect($locale->text('Warehouse deleted.')); - if (!$eur) { - $linkaccounts = qq| - - | . $locale->text('Inventory') . qq| - - - |; } else { - $linkaccounts = qq| - {inventory_accno_id}>|; - } - - - $linkaccounts .= qq| - - | . $locale->text('Erlöse Inland') . qq| - - - - | . $locale->text('Aufwand Inland') . qq| - - |; - if ($form->{id}) { - $form->{selectIC_income} =~ s/selected//g; - $form->{selectIC_income} =~ s/ value=$form->{income_accno_id_1}/ value=$form->{income_accno_id_1} selected/; - $form->{selectIC_expense} =~ s/selected//g; - $form->{selectIC_expense} =~ s/ value=$form->{expense_accno_id_1}/ value=$form->{expense_accno_id_1} selected/; - } - $linkaccounts .= qq| - | . $locale->text('Erlöse EU m. UStId') . qq| - - - - | . $locale->text('Aufwand EU m UStId') . qq| - - |; - - if ($form->{id}) { - $form->{selectIC_income} =~ s/selected//g; - $form->{selectIC_income} =~ s/ value=$form->{income_accno_id_2}/ value=$form->{income_accno_id_2} selected/; - $form->{selectIC_expense} =~ s/selected//g; - $form->{selectIC_expense} =~ s/ value=$form->{expense_accno_id_2}/ value=$form->{expense_accno_id_2} selected/; - } - - $linkaccounts .= qq| - | . $locale->text('Erlöse EU o. UStId') . qq| - - - - | . $locale->text('Aufwand EU o. UStId') . qq| - - |; - - if ($form->{id}) { - $form->{selectIC_income} =~ s/selected//g; - $form->{selectIC_income} =~ s/ value=$form->{income_accno_id_3}/ value=$form->{income_accno_id_3} selected/; - $form->{selectIC_expense} =~ s/selected//g; - $form->{selectIC_expense} =~ s/ value=$form->{expense_accno_id_3}/ value=$form->{expense_accno_id_3} selected/; + $form->error($locale->text('The warehouse could not be deleted because it has already been used.')); } - $linkaccounts .= qq| - | . $locale->text('Erlöse Ausland') . qq| - - - - | . $locale->text('Aufwand Ausland') . qq| - - -|; - - - $form->header; - - print qq| - - -
{script}> - -{id}> - - - - - - - - - - - - $linkaccounts - - -
$form->{title}
| . $locale->text('Buchungsgruppe') . qq|

-|; - - $lxdebug->leave_sub(); -} - -sub save_buchungsgruppe { - $lxdebug->enter_sub(); - - $form->isblank("description", $locale->text('Description missing!')); - - AM->save_buchungsgruppe(\%myconfig, \%$form); - $form->redirect($locale->text('Buchungsgruppe gespeichert!')); - - $lxdebug->leave_sub(); -} - -sub delete_buchungsgruppe { - $lxdebug->enter_sub(); - - AM->delete_buchungsgruppe(\%myconfig, \%$form); - $form->redirect($locale->text('Buchungsgruppe gelöscht!')); - - $lxdebug->leave_sub(); + $main::lxdebug->leave_sub(); } +sub save_bin { + $main::lxdebug->enter_sub(); -sub add_printer { - $lxdebug->enter_sub(); - - $form->{title} = "Add"; - - $form->{callback} = - "$form->{script}?action=add_printer&path=$form->{path}&login=$form->{login}&password=$form->{password}" - unless $form->{callback}; + my $form = $main::form; + my %myconfig = %main::myconfig; + my $locale = $main::locale; - &printer_header; - &form_footer; + $main::auth->assert('config'); - $lxdebug->leave_sub(); -} - -sub edit_printer { - $lxdebug->enter_sub(); - - $form->{title} = "Edit"; + AM->save_bins(\%myconfig, $form); - AM->get_printer(\%myconfig, \%$form); + $form->{callback} .= '&saved_message=' . E($locale->text('Bins saved.')) if ($form->{callback}); - &printer_header; + $form->redirect($locale->text('Bins saved.')); - $form->{orphaned} = 1; - &form_footer; - - $lxdebug->leave_sub(); + $main::lxdebug->leave_sub(); } -sub list_printer { - $lxdebug->enter_sub(); - - AM->printer(\%myconfig, \%$form); - - $form->{callback} = - "$form->{script}?action=list_printer&path=$form->{path}&login=$form->{login}&password=$form->{password}"; - - $callback = $form->escape($form->{callback}); +sub setup_am_config_action_bar { + my %params = @_; - $form->{title} = $locale->text('Printer'); - - @column_index = qw(printer_description printer_command template_code); - - $column_header{printer_description} = - qq|| - . $locale->text('Printer Description') - . qq||; - $column_header{printer_command} = - qq|| - . $locale->text('Printer Command') - . qq||; - $column_header{template_code} = - qq|| - . $locale->text('Template Code') - . qq||; - - $form->header; - - print qq| - - - - - - - - - - - - - -
$form->{title}
- - -|; - - map { print "$column_header{$_}\n" } @column_index; - - print qq| - -|; - - foreach $ref (@{ $form->{ALL} }) { - - $i++; - $i %= 2; - - print qq| - -|; - - - $column_data{printer_description} = - qq||; - $column_data{printer_command} = qq||; - $column_data{template_code} = - qq||; - - map { print "$column_data{$_}\n" } @column_index; - - print qq| - -|; + for my $bar ($::request->layout->get('actionbar')) { + $bar->add( + action => [ + t8('Save'), + submit => [ '#form', { action => "save_preferences" } ], + accesskey => 'enter', + ], + ); } - - print qq| -
{script}?action=edit_printer&id=$ref->{id}&path=$form->{path}&login=$form->{login}&password=$form->{password}&callback=$callback>$ref->{printer_description}$ref->{printer_command}$ref->{template_code}
-

- -
-{script}> - - - - - -{path}> -{login}> -{password}> - - - -
- - - -|; - - $lxdebug->leave_sub(); } -sub printer_header { - $lxdebug->enter_sub(); - - $form->{title} = $locale->text("$form->{title} Printer"); - - # $locale->text('Add Printer') - # $locale->text('Edit Printer') - - $form->{printer_description} =~ s/\"/"/g; - $form->{template_code} =~ s/\"/"/g; - $form->{printer_command} =~ s/\"/"/g; - - - $form->header; - - print qq| - - -
{script}> - -{id}> - - - - - - - - - - - - - - - - - - - - - -
$form->{title}
| . $locale->text('Printer') . qq|
| . $locale->text('Printer Command') . qq|
| . $locale->text('Template Code') . qq|

-|; - - $lxdebug->leave_sub(); +sub setup_am_edit_account_action_bar { + my %params = @_; + + for my $bar ($::request->layout->get('actionbar')) { + $bar->add( + combobox => [ + action => [ + t8('Save'), + submit => [ '#form', { action => "save_account" } ], + accesskey => 'enter', + ], + + action => [ + t8('Save as new'), + submit => [ '#form', { action => "save_as_new_account" } ], + disabled => !$::form->{id} ? t8('The object has not been saved yet.') : undef, + ], + ], + + action => [ + t8('Delete'), + submit => [ '#form', { action => "delete_account" } ], + disabled => !$::form->{id} ? t8('The object has not been saved yet.') + : $::form->{id} && !$::form->{orphaned} ? t8('The object is in use and cannot be deleted.') + : undef, + confirm => t8('Do you really want to delete this object?'), + ], + ); + } } -sub save_printer { - $lxdebug->enter_sub(); - - $form->isblank("printer_description", $locale->text('Description missing!')); - $form->isblank("printer_command", $locale->text('Printer Command missing!')); - AM->save_printer(\%myconfig, \%$form); - $form->redirect($locale->text('Printer saved!')); +sub setup_am_list_tax_action_bar { + my %params = @_; - $lxdebug->leave_sub(); + for my $bar ($::request->layout->get('actionbar')) { + $bar->add( + link => [ + t8('Add'), + link => 'am.pl?action=add_tax', + ], + ); + } } -sub delete_printer { - $lxdebug->enter_sub(); - - AM->delete_printer(\%myconfig, \%$form); - $form->redirect($locale->text('Printer deleted!')); - - $lxdebug->leave_sub(); +sub setup_am_edit_tax_action_bar { + my %params = @_; + + for my $bar ($::request->layout->get('actionbar')) { + $bar->add( + action => [ + t8('Save'), + submit => [ '#form', { action => "save_tax" } ], + accesskey => 'enter', + ], + + action => [ + t8('Delete'), + submit => [ '#form', { action => "delete_tax" } ], + disabled => !$::form->{id} ? t8('The object has not been saved yet.') + : !$::form->{orphaned} || $::form->{tax_already_used} ? t8('The object is in use and cannot be deleted.') + : undef, + confirm => t8('Do you really want to delete this object?'), + ], + ); + } } +sub setup_am_add_unit_action_bar { + my %params = @_; -sub add_payment { - $lxdebug->enter_sub(); - - $form->{title} = "Add"; - - $form->{callback} = - "$form->{script}?action=add_payment&path=$form->{path}&login=$form->{login}&password=$form->{password}" - unless $form->{callback}; + for my $bar ($::request->layout->get('actionbar')) { + $bar->add( + action => [ + t8('Save'), + submit => [ '#form', { action => "create_unit" } ], + accesskey => 'enter', + ], - $form->{terms_netto} = 0; - $form->{terms_skonto} = 0; - $form->{percent_skonto} = 0; - &payment_header; - &form_footer; + 'separator', - $lxdebug->leave_sub(); + link => [ + t8('Back'), + link => 'am.pl?action=edit_units', + ], + ); + } } -sub edit_payment { - $lxdebug->enter_sub(); - - $form->{title} = "Edit"; - - AM->get_payment(\%myconfig, \%$form); +sub setup_am_edit_units_action_bar { + my %params = @_; - &payment_header; + for my $bar ($::request->layout->get('actionbar')) { + $bar->add( + action => [ + t8('Save'), + submit => [ '#form', { action => "save_unit" } ], + accesskey => 'enter', + ], - $form->{orphaned} = 1; - &form_footer; + 'separator', - $lxdebug->leave_sub(); + link => [ + t8('Add'), + link => 'am.pl?action=add_unit', + ], + ); + } } -sub list_payment { - $lxdebug->enter_sub(); - - AM->payment(\%myconfig, \%$form); - - $form->{callback} = - "$form->{script}?action=list_payment&path=$form->{path}&login=$form->{login}&password=$form->{password}"; - - $callback = $form->escape($form->{callback}); - - $form->{title} = $locale->text('Payment Terms'); - - @column_index = qw(description description_long terms_netto terms_skonto percent_skonto); - - $column_header{description} = - qq|| - . $locale->text('Description') - . qq||; - $column_header{description_long} = - qq|| - . $locale->text('Long Description') - . qq||; - $column_header{terms_netto} = - qq|| - . $locale->text('Netto Terms') - . qq||; - $column_header{terms_skonto} = - qq|| - . $locale->text('Skonto Terms') - . qq||; - $column_header{percent_skonto} = - qq|| - . $locale->text('Skonto') - . qq| %|; - - $form->header; - - print qq| - - - - - - - - - - - - - -
$form->{title}
- - -|; - - map { print "$column_header{$_}\n" } @column_index; +sub setup_am_list_warehouses_action_bar { + my %params = @_; - print qq| - -|; - - foreach $ref (@{ $form->{ALL} }) { - - $i++; - $i %= 2; - - print qq| - -|; - - - $column_data{description} = - qq||; - $column_data{description_long} = qq||; - $column_data{terms_netto} = - qq||; - $column_data{terms_skonto} = - qq||; - $column_data{percent_skonto} = - qq||; - map { print "$column_data{$_}\n" } @column_index; - - print qq| - -|; + for my $bar ($::request->layout->get('actionbar')) { + $bar->add( + link => [ + t8('Add'), + link => 'am.pl?action=add&type=warehouse&callback=' . E($::form->{callback}), + accesskey => 'enter', + ], + ); } - - print qq| -
{script}?action=edit_payment&id=$ref->{id}&path=$form->{path}&login=$form->{login}&password=$form->{password}&callback=$callback>$ref->{description}$ref->{description_long}$ref->{terms_netto}$ref->{terms_skonto}$ref->{percent_skonto} %
-

- -
-{script}> - - - - - -{path}> -{login}> -{password}> - - - -
- - - -|; - - $lxdebug->leave_sub(); } -sub payment_header { - $lxdebug->enter_sub(); - - $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| - - -
{script}> - -{id}> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
$form->{title}
| . $locale->text('Description') . qq|
| . $locale->text('Long Description') . qq|
| . $locale->text('Netto Terms') . qq|
| . $locale->text('Skonto Terms') . qq|
| . $locale->text('Skonto') . qq| %

-|; - - $lxdebug->leave_sub(); +sub setup_am_edit_warehouse_action_bar { + my %params = @_; + + for my $bar ($::request->layout->get('actionbar')) { + $bar->add( + action => [ + t8('Save'), + submit => [ '#form', { action => 'save_warehouse' } ], + accesskey => 'enter', + ], + + action => [ + t8('Delete'), + submit => [ '#form', { action => 'delete_warehouse' } ], + disabled => !$params{id} ? t8('The object has not been saved yet.') + : $params{in_use} ? t8('The object is in use and cannot be deleted.') + : undef, + confirm => t8('Do you really want to delete this object?'), + ], + + 'separator', + + link => [ + t8('Bins'), + link => 'am.pl?action=edit_bins&id=' . E($params{id}), + only_if => $params{id}, + ], + + link => [ + t8('Abort'), + link => $::form->{callback} || 'am.pl?action=list_warehouses', + ], + ); + } } -sub save_payment { - $lxdebug->enter_sub(); - - $form->isblank("description", $locale->text('Language missing!')); - AM->save_payment(\%myconfig, \%$form); - $form->redirect($locale->text('Payment Terms saved!')); +sub setup_am_edit_bins_action_bar { + my %params = @_; - $lxdebug->leave_sub(); -} - -sub delete_payment { - $lxdebug->enter_sub(); + for my $bar ($::request->layout->get('actionbar')) { + $bar->add( + action => [ + t8('Save'), + submit => [ '#form', { action => 'save_bin' } ], + accesskey => 'enter', + ], - AM->delete_payment(\%myconfig, \%$form); - $form->redirect($locale->text('Payment terms deleted!')); + 'separator', - $lxdebug->leave_sub(); + link => [ + t8('Abort'), + link => 'am.pl?action=edit_warehouse&id=' . E($params{id}), + ], + ); + } } -sub add_sic { - $lxdebug->enter_sub(); +sub setup_am_audit_control_action_bar { + my %params = @_; - $form->{title} = "Add"; - - $form->{callback} = - "$form->{script}?action=add_sic&path=$form->{path}&login=$form->{login}&password=$form->{password}" - unless $form->{callback}; - - &sic_header; - &form_footer; - - $lxdebug->leave_sub(); + for my $bar ($::request->layout->get('actionbar')) { + $bar->add( + action => [ + t8('Save'), + submit => [ '#form', { action => 'doclose' } ], + accesskey => 'enter', + ], + ); + } } -sub edit_sic { - $lxdebug->enter_sub(); - - $form->{title} = "Edit"; - - AM->get_sic(\%myconfig, \%$form); +sub setup_am_show_history_search_action_bar { + my %params = @_; - &sic_header; - - $form->{orphaned} = 1; - &form_footer; - - $lxdebug->leave_sub(); + for my $bar ($::request->layout->get('actionbar')) { + $bar->add( + action => [ + t8('Show'), + submit => [ '#form' ], + accesskey => 'enter', + ], + ); + } } -sub list_sic { - $lxdebug->enter_sub(); +sub setup_am_show_am_history_action_bar { + my %params = @_; - AM->sic(\%myconfig, \%$form); - - $form->{callback} = - "$form->{script}?action=list_sic&path=$form->{path}&login=$form->{login}&password=$form->{password}"; - - $callback = $form->escape($form->{callback}); - - $form->{title} = $locale->text('Standard Industrial Codes'); - - @column_index = qw(code description); - - $column_header{code} = - qq|| . $locale->text('Code') . qq||; - $column_header{description} = - qq|| . $locale->text('Description') . qq||; - - $form->header; - - print qq| - - - - - - - - - - - - - -
$form->{title}
- - -|; - - map { print "$column_header{$_}\n" } @column_index; - - print qq| - -|; - - foreach $ref (@{ $form->{ALL} }) { - - $i++; - $i %= 2; - - if ($ref->{sictype} eq 'H') { - print qq| - -|; - $column_data{code} = - qq||; - $column_data{description} = qq||; - - } else { - print qq| - -|; - - $column_data{code} = - qq||; - $column_data{description} = qq||; - - } - - map { print "$column_data{$_}\n" } @column_index; - - print qq| - -|; - } - - print qq| -
{script}?action=edit_sic&code=$ref->{code}&path=$form->{path}&login=$form->{login}&password=$form->{password}&callback=$callback>$ref->{code}$ref->{description}
{script}?action=edit_sic&code=$ref->{code}&path=$form->{path}&login=$form->{login}&password=$form->{password}&callback=$callback>$ref->{code}$ref->{description}
-

- -
-{script}> - - - - - -{path}> -{login}> -{password}> - - - -
- - - -|; - - $lxdebug->leave_sub(); -} - -sub sic_header { - $lxdebug->enter_sub(); - - $form->{title} = $locale->text("$form->{title} SIC"); - - # $locale->text('Add SIC') - # $locale->text('Edit SIC') - - $form->{code} =~ s/\"/"/g; - $form->{description} =~ s/\"/"/g; - - $checked = ($form->{sictype} eq 'H') ? "checked" : ""; - - $form->header; - - print qq| - - -
{script}> - - -{code}> - - - - - - - - - - - - - - - - - - - - -
$form->{title}
| . $locale->text('Code') . qq|{code}>
| - . $locale->text('Heading') . qq|
| . $locale->text('Description') . qq|

-|; - - $lxdebug->leave_sub(); -} - -sub save_sic { - $lxdebug->enter_sub(); - - $form->isblank("code", $locale->text('Code missing!')); - $form->isblank("description", $locale->text('Description missing!')); - AM->save_sic(\%myconfig, \%$form); - $form->redirect($locale->text('SIC saved!')); - - $lxdebug->leave_sub(); -} - -sub delete_sic { - $lxdebug->enter_sub(); - - AM->delete_sic(\%myconfig, \%$form); - $form->redirect($locale->text('SIC deleted!')); - - $lxdebug->leave_sub(); -} - -sub display_stylesheet { - $lxdebug->enter_sub(); - - $form->{file} = "css/$myconfig{stylesheet}"; - &display_form; - - $lxdebug->leave_sub(); -} - -sub display_form { - $lxdebug->enter_sub(); - - $form->{file} =~ s/^(.:)*?\/|\.\.\///g; - $form->{file} =~ s/^\/*//g; - $form->{file} =~ s/$userspath//; - - $form->error("$!: $form->{file}") unless -f $form->{file}; - - AM->load_template(\%$form); - - $form->{title} = $form->{file}; - - # if it is anything but html - if ($form->{file} !~ /\.html$/) { - $form->{body} = "
\n$form->{body}\n
"; - } - - $form->header; - - print qq| - - -$form->{body} - -{script}> - -{file}> - - -{path}> -{login}> -{password}> - - - -
- - - -|; - - $lxdebug->leave_sub(); -} - -sub edit_template { - $lxdebug->enter_sub(); - - AM->load_template(\%$form); - - $form->{title} = $locale->text('Edit Template'); - - # convert   to &nbsp; - $form->{body} =~ s/ /&nbsp;/gi; - - $form->header; - - print qq| - - -
{script}> - -{file}> - - -{path}> -{login}> -{password}> - - - - - -
- - -
- - - - -|; - - $lxdebug->leave_sub(); -} - -sub save_template { - $lxdebug->enter_sub(); - - AM->save_template(\%$form); - $form->redirect($locale->text('Template saved!')); - - $lxdebug->leave_sub(); -} - -sub config { - $lxdebug->enter_sub(); - - # get defaults for account numbers and last numbers - AM->defaultaccounts(\%myconfig, \%$form); - - foreach $item (qw(mm-dd-yy mm/dd/yy dd-mm-yy dd/mm/yy dd.mm.yy yyyy-mm-dd)) { - $dateformat .= - ($item eq $myconfig{dateformat}) - ? ""; - } - - %countrycodes = User->country_codes; - $countrycodes = ''; - foreach $key (sort { $countrycodes{$a} cmp $countrycodes{$b} } - keys %countrycodes - ) { - $countrycodes .= - ($myconfig{countrycode} eq $key) - ? "