X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;f=bin%2Fmozilla%2Fam.pl;h=6ff99978453acc03e40ff4ae863face873e03087;hb=95155b0d6ddca4b62319edce20397a3ceebac346;hp=b41b0ec9927034a13f40834c928a2aa1bbf8b69b;hpb=4dbb09950c9f5596646537c12d991c99086fe7c1;p=kivitendo-erp.git diff --git a/bin/mozilla/am.pl b/bin/mozilla/am.pl index b41b0ec99..6ff999784 100644 --- a/bin/mozilla/am.pl +++ b/bin/mozilla/am.pl @@ -31,50 +31,49 @@ # #====================================================================== - use SL::AM; use SL::CA; use SL::Form; use SL::User; +use Data::Dumper; 1; -# end of main -sub add { &{ "add_$form->{type}" } }; -sub edit { &{ "edit_$form->{type}" } }; -sub save { &{ "save_$form->{type}" } }; -sub delete { &{ "delete_$form->{type}" } }; - +require "$form->{path}/common.pl"; +# 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_account { $lxdebug->enter_sub(); - - $form->{title} = "Add"; + $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} = + "$form->{script}?action=list_account&path=$form->{path}&login=$form->{login}&password=$form->{password}" + unless $form->{callback}; &account_header; &form_footer; - + $lxdebug->leave_sub(); } - sub edit_account { $lxdebug->enter_sub(); - $form->{title} = "Edit"; AM->get_account(\%myconfig, \%$form); - + foreach my $item (split(/:/, $form->{link})) { $form->{$item} = "checked"; } @@ -85,122 +84,243 @@ sub edit_account { $lxdebug->leave_sub(); } - sub account_header { $lxdebug->enter_sub(); - $form->{title} = $locale->text("$form->{title} Account"); - - $checked{$form->{charttype}} = "checked"; + + $checked{ $form->{charttype} } = "checked"; $checked{"$form->{category}_"} = "checked"; $checked{CT_tax} = ($form->{CT_tax}) ? "" : "checked"; - + $form->{description} =~ s/\"/"/g; - - if (@{ $form->{TAXKEY} }) { - $form->{selecttaxkey} = ""; + } + foreach $item (@{ $form->{NEWACCOUNT} }) { + if ($item->{id} == $form->{new_chart_id}) { + $form->{selectnewaccount} .= + ""; + } elsif (!$form->{new_chart_valid}) { + $form->{selectnewaccount} .= + ""; + } + + } + } + + $newaccount = qq| + + + + + + + + + +
| . $locale->text('Folgekonto') . qq|| . $locale->text('Gültig ab') . qq|
+ + |; $form->{selectustva} = "|; + foreach $item (qw(1,000.00 1000.00 1.000,00 1000,00)) { + $numberformat .= + ($item eq $form->{output_numberformat}) + ? ""; + } + + 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}) + ? ""; + } + + 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(); } - -sub save_gifi { - $lxdebug->enter_sub(); - - - $form->isblank("accno", $locale->text('GIFI missing!')); - AM->save_gifi(\%myconfig, \%$form); - $form->redirect($locale->text('GIFI saved!')); - - $lxdebug->leave_sub(); -} - - -sub copy_to_coa { +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!')); - $form->isblank("accno", $locale->text('GIFI missing!')); - - AM->save_gifi(\%myconfig, \%$form); - - delete $form->{id}; - $form->{gifi_accno} = $form->{accno}; - $form->{title} = "Add"; - $form->{charttype} = "A"; - - &account_header; - &form_footer; - $lxdebug->leave_sub(); } - -sub delete_gifi { +sub delete_language { $lxdebug->enter_sub(); - - AM->delete_gifi(\%myconfig, \%$form); - $form->redirect($locale->text('GIFI deleted!')); + AM->delete_language(\%myconfig, \%$form); + $form->redirect($locale->text('Language deleted!')); $lxdebug->leave_sub(); } -sub add_department { +sub add_buchungsgruppe { $lxdebug->enter_sub(); - + # $locale->text("Add Buchungsgruppe") + # $locale->text("Edit Buchungsgruppe") $form->{title} = "Add"; - $form->{role} = "P"; - - $form->{callback} = "$form->{script}?action=add_department&path=$form->{path}&login=$form->{login}&password=$form->{password}" unless $form->{callback}; - &department_header; + $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(); } - -sub edit_department { +sub edit_buchungsgruppe { $lxdebug->enter_sub(); - $form->{title} = "Edit"; - AM->get_department(\%myconfig, \%$form); + AM->get_buchungsgruppe(\%myconfig, \%$form); + + &buchungsgruppe_header; - &department_header; &form_footer; $lxdebug->leave_sub(); } - -sub list_department { +sub list_buchungsgruppe { $lxdebug->enter_sub(); + AM->buchungsgruppe(\%myconfig, \%$form); - AM->departments(\%myconfig, \%$form); - - $form->{callback} = "$form->{script}?action=list_department&path=$form->{path}&login=$form->{login}&password=$form->{password}"; + $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('Departments'); - - @column_index = qw(description cost profit); - - $column_header{description} = qq||.$locale->text('Description').qq||; - $column_header{cost} = qq||.$locale->text('Cost Center').qq||; - $column_header{profit} = qq||.$locale->text('Profit Center').qq||; + $form->{title} = $locale->text('Buchungsgruppen'); + + @column_index = qw(up down 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{up} = + qq|| + . qq|| . $locale->text(| + . qq||; + $column_header{down} = + qq|| + . qq|| . $locale->text(| + . qq||; + $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| @@ -812,26 +1627,65 @@ sub list_department { |; + my $swap_link = qq|$form->{script}?action=swap_buchungsgruppen&|; + map({ $swap_link .= $_ . "=" . $form->escape($form->{$_}) . "&" } + qw(login password path)); + + my $row = 0; foreach $ref (@{ $form->{ALL} }) { - - $i++; $i %= 2; - + + $i++; + $i %= 2; + print qq| |; - $costcenter = ($ref->{role} eq "C") ? "X" : ""; - $profitcenter = ($ref->{role} eq "P") ? "X" : ""; - - $column_data{description} = qq|{script}?action=edit_department&id=$ref->{id}&path=$form->{path}&login=$form->{login}&password=$form->{password}&callback=$callback>$ref->{description}|; - $column_data{cost} = qq|$costcenter|; - $column_data{profit} = qq|$profitcenter|; + if ($row) { + my $pref = $form->{ALL}->[$row - 1]; + $column_data{up} = + qq|| . + qq|| . + qq|| . $locale->text(| . + qq||; + } else { + $column_data{up} = qq| |; + } + + if ($row == (scalar(@{ $form->{ALL} }) - 1)) { + $column_data{down} = qq| |; + } else { + my $nref = $form->{ALL}->[$row + 1]; + $column_data{down} = + qq|| . + qq|| . + qq|| . $locale->text(| . + qq||; + } - map { print "$column_data{$_}\n" } @column_index; + $column_data{description} = + qq|{script}?action=edit_buchungsgruppe&id=$ref->{id}&path=$form->{path}&login=$form->{login}&password=$form->{password}&callback=$callback>$ref->{description}|; + $column_data{inventory_accno} = qq|$ref->{inventory_accno}|; + $column_data{income_accno_0} = + qq|$ref->{income_accno_0}|; + $column_data{expense_accno_0} = qq|$ref->{expense_accno_0}|; + $column_data{income_accno_1} = + qq|$ref->{income_accno_1}|; + $column_data{expense_accno_1} = qq|$ref->{expense_accno_1}|; + $column_data{income_accno_2} = + qq|$ref->{income_accno_2}|; + $column_data{expense_accno_2} = qq|$ref->{expense_accno_2}|; + $column_data{income_accno_3} = + qq|$ref->{income_accno_3}|; + $column_data{expense_accno_3} = qq|$ref->{expense_accno_3}|; + + map { print "$column_data{$_}\n" } @column_index; - print qq| + print qq| |; + + $row++; } print qq| @@ -848,50 +1702,136 @@ sub list_department { - + {path}> {login}> {password}> -|; - - if ($form->{menubar}) { - require "$form->{path}/menu.pl"; - &menubar; - } + - print qq| - + - + |; - + $lxdebug->leave_sub(); } - -sub department_header { +sub buchungsgruppe_header { $lxdebug->enter_sub(); + $form->{title} = $locale->text("$form->{title} Buchungsgruppe"); - $form->{title} = $locale->text("$form->{title} Department"); + # $locale->text('Buchungsgruppe hinzufügen') + # $locale->text('Buchungsgruppe bearbeiten') -# $locale->text('Add Department') -# $locale->text('Edit Department') + 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, + ); - $form->{description} =~ s/\"/"/g; + foreach $key (keys(%acc_type_map)) { + foreach $ref (@{ $form->{IC_links}{$key} }) { + $acc_type_map{$key}->{$ref->{"id"}} = $ref; + } + } - if (($rows = $form->numtextrows($form->{description}, 60)) > 1) { - $description = qq||; + 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}})))); + } + + 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 (!$eur) { + $linkaccounts = qq| + + | . $locale->text('Inventory') . qq| + + + |; } else { - $description = qq||; + $linkaccounts = qq| + {inventory_accno_id}>|; } - $costcenter = "checked" if $form->{role} eq "C"; - $profitcenter = "checked" if $form->{role} eq "P"; - + + $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/; + } + + $linkaccounts .= qq| + | . $locale->text('Erlöse Ausland') . qq| + + + + | . $locale->text('Aufwand Ausland') . qq| + + +|; + + $form->header; print qq| @@ -900,7 +1840,7 @@ sub department_header {
{script}> {id}> - + @@ -908,16 +1848,11 @@ sub department_header { - - - - - - + + - + $linkaccounts +
|.$locale->text('Description').qq|$description
|.$locale->text('Cost Center').qq| - |.$locale->text('Profit Center').qq| - | . $locale->text('Buchungsgruppe') . qq|


|; @@ -925,54 +1860,59 @@ sub department_header { $lxdebug->leave_sub(); } - -sub save_department { +sub save_buchungsgruppe { $lxdebug->enter_sub(); - $form->isblank("description", $locale->text('Description missing!')); - AM->save_department(\%myconfig, \%$form); - $form->redirect($locale->text('Department saved!')); + + AM->save_buchungsgruppe(\%myconfig, \%$form); + $form->redirect($locale->text('Buchungsgruppe gespeichert!')); $lxdebug->leave_sub(); } - -sub delete_department { +sub delete_buchungsgruppe { $lxdebug->enter_sub(); + AM->delete_buchungsgruppe(\%myconfig, \%$form); + $form->redirect($locale->text('Buchungsgruppe gelöscht!')); - AM->delete_department(\%myconfig, \%$form); - $form->redirect($locale->text('Department deleted!')); + $lxdebug->leave_sub(); +} + +sub swap_buchungsgruppen { + $lxdebug->enter_sub(); + + AM->swap_sortkeys(\%myconfig, $form, "buchungsgruppen"); + list_buchungsgruppe(); $lxdebug->leave_sub(); } -sub add_business { +sub add_printer { $lxdebug->enter_sub(); - $form->{title} = "Add"; - - $form->{callback} = "$form->{script}?action=add_business&path=$form->{path}&login=$form->{login}&password=$form->{password}" unless $form->{callback}; - &business_header; + $form->{callback} = + "$form->{script}?action=add_printer&path=$form->{path}&login=$form->{login}&password=$form->{password}" + unless $form->{callback}; + + &printer_header; &form_footer; $lxdebug->leave_sub(); } - -sub edit_business { +sub edit_printer { $lxdebug->enter_sub(); - $form->{title} = "Edit"; - AM->get_business(\%myconfig, \%$form); + AM->get_printer(\%myconfig, \%$form); - &business_header; + &printer_header; $form->{orphaned} = 1; &form_footer; @@ -980,24 +1920,32 @@ sub edit_business { $lxdebug->leave_sub(); } - -sub list_business { +sub list_printer { $lxdebug->enter_sub(); + AM->printer(\%myconfig, \%$form); - AM->business(\%myconfig, \%$form); - - $form->{callback} = "$form->{script}?action=list_business&path=$form->{path}&login=$form->{login}&password=$form->{password}"; + $form->{callback} = + "$form->{script}?action=list_printer&path=$form->{path}&login=$form->{login}&password=$form->{password}"; $callback = $form->escape($form->{callback}); - - $form->{title} = $locale->text('Type of Business'); - @column_index = qw(description discount customernumberinit); + $form->{title} = $locale->text('Printer'); - $column_header{description} = qq||.$locale->text('Description').qq||; - $column_header{discount} = qq||.$locale->text('Discount').qq| %|; - $column_header{customernumberinit} = qq||.$locale->text('Customernumberinit').qq||; + @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; @@ -1022,22 +1970,24 @@ sub list_business { |; foreach $ref (@{ $form->{ALL} }) { - - $i++; $i %= 2; - + + $i++; + $i %= 2; + print qq| |; - $discount = $form->format_amount(\%myconfig, $ref->{discount} * 100, 1, " "); - $description = ($ref->{salesman}) ? "$ref->{description}" : "$ref->{description}"; - $column_data{description} = qq|
{script}?action=edit_business&id=$ref->{id}&path=$form->{path}&login=$form->{login}&password=$form->{password}&callback=$callback>$description|; - $column_data{discount} = qq|$discount|; - $column_data{customernumberinit} = qq|$ref->{customernumberinit}|; - - map { print "$column_data{$_}\n" } @column_index; - print qq| + $column_data{printer_description} = + qq|{script}?action=edit_printer&id=$ref->{id}&path=$form->{path}&login=$form->{login}&password=$form->{password}&callback=$callback>$ref->{printer_description}|; + $column_data{printer_command} = qq|$ref->{printer_command}|; + $column_data{template_code} = + qq|$ref->{template_code}|; + + map { print "$column_data{$_}\n" } @column_index; + + print qq| |; } @@ -1056,42 +2006,36 @@ sub list_business { - + {path}> {login}> {password}> -|; - - if ($form->{menubar}) { - require "$form->{path}/menu.pl"; - &menubar; - } + - print qq| - - + - + |; - + $lxdebug->leave_sub(); } - -sub business_header { +sub printer_header { $lxdebug->enter_sub(); + $form->{title} = $locale->text("$form->{title} Printer"); - $form->{title} = $locale->text("$form->{title} Business"); - $form->{salesman} = "checked" if $form->{salesman}; -# $locale->text('Add Business') -# $locale->text('Edit Business') + # $locale->text('Add Printer') + # $locale->text('Edit Printer') + + $form->{printer_description} =~ s/\"/"/g; + $form->{template_code} =~ s/\"/"/g; + $form->{printer_command} =~ s/\"/"/g; - $form->{description} =~ s/\"/"/g; - $form->{discount} = $form->format_amount(\%myconfig, $form->{discount} * 100); $form->header; @@ -1101,7 +2045,7 @@ sub business_header {
{script}> {id}> - + @@ -1109,21 +2053,17 @@ sub business_header { - - + + - - + + - - + + - - - -
|.$locale->text('Type of Business').qq|| . $locale->text('Printer') . qq|
|.$locale->text('Discount').qq| %{discount}>| . $locale->text('Printer Command') . qq|
|.$locale->text('Customernumberinit').qq|{customernumberinit}>| . $locale->text('Template Code') . qq|
|.$locale->text('Salesman').qq|{salesman}>

@@ -1132,55 +2072,58 @@ sub business_header { $lxdebug->leave_sub(); } - -sub save_business { +sub save_printer { $lxdebug->enter_sub(); - - $form->isblank("description", $locale->text('Description missing!')); - AM->save_business(\%myconfig, \%$form); - $form->redirect($locale->text('Business saved!')); + $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!')); $lxdebug->leave_sub(); } - -sub delete_business { +sub delete_printer { $lxdebug->enter_sub(); - - AM->delete_business(\%myconfig, \%$form); - $form->redirect($locale->text('Business deleted!')); + AM->delete_printer(\%myconfig, \%$form); + $form->redirect($locale->text('Printer deleted!')); $lxdebug->leave_sub(); } - - -sub add_sic { +sub add_payment { $lxdebug->enter_sub(); - $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->{callback} = + "$form->{script}?action=add_payment&path=$form->{path}&login=$form->{login}&password=$form->{password}" + 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; $lxdebug->leave_sub(); } - -sub edit_sic { +sub edit_payment { $lxdebug->enter_sub(); - $form->{title} = "Edit"; - AM->get_sic(\%myconfig, \%$form); + AM->get_payment(\%myconfig, $form); + $form->{percent_skonto} = + $form->format_amount(\%myconfig, $form->{percent_skonto} * 100); - &sic_header; + &payment_header; $form->{orphaned} = 1; &form_footer; @@ -1188,23 +2131,48 @@ sub edit_sic { $lxdebug->leave_sub(); } - -sub list_sic { +sub list_payment { $lxdebug->enter_sub(); + AM->payment(\%myconfig, \%$form); - AM->sic(\%myconfig, \%$form); - - $form->{callback} = "$form->{script}?action=list_sic&path=$form->{path}&login=$form->{login}&password=$form->{password}"; + $form->{callback} = build_std_url("action=list_payment"); $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->{title} = $locale->text('Payment Terms'); + + @column_index = qw(up down description description_long terms_netto + terms_skonto percent_skonto); + + $column_header{up} = + qq|| + . qq|| . $locale->text(| + . qq||; + $column_header{down} = + qq|| + . qq|| . $locale->text(| + . qq||; + $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; @@ -1228,32 +2196,60 @@ sub list_sic { |; + my $swap_link = build_std_url("action=swap_payment_terms"); + + my $row = 0; foreach $ref (@{ $form->{ALL} }) { - - $i++; $i %= 2; - - if ($ref->{sictype} eq 'H') { - print qq| - -|; - $column_data{code} = qq|
{script}?action=edit_sic&code=$ref->{code}&path=$form->{path}&login=$form->{login}&password=$form->{password}&callback=$callback>$ref->{code}|; - $column_data{description} = qq|$ref->{description}|; - - } else { - print qq| + + $i++; + $i %= 2; + + print qq| |; - $column_data{code} = qq|{script}?action=edit_sic&code=$ref->{code}&path=$form->{path}&login=$form->{login}&password=$form->{password}&callback=$callback>$ref->{code}|; - $column_data{description} = qq|$ref->{description}|; + if ($row) { + my $pref = $form->{ALL}->[$row - 1]; + $column_data{up} = + qq|| . + qq|| . + qq|| . $locale->text(| . + qq||; + } else { + $column_data{up} = qq| |; + } - } - - map { print "$column_data{$_}\n" } @column_index; + if ($row == (scalar(@{ $form->{ALL} }) - 1)) { + $column_data{down} = qq| |; + } else { + my $nref = $form->{ALL}->[$row + 1]; + $column_data{down} = + qq|| . + qq|| . + qq|| . $locale->text(| . + qq||; + } - print qq| + $column_data{description} = + qq|{id}", "callback=$callback") . + qq|">| . H($ref->{description}) . qq||; + $column_data{description_long} = + qq|| . H($ref->{description_long}) . qq||; + $column_data{terms_netto} = + qq|$ref->{terms_netto}|; + $column_data{terms_skonto} = + qq|$ref->{terms_skonto}|; + $column_data{percent_skonto} = + qq|| . + $form->format_amount(\%myconfig, $ref->{percent_skonto} * 100) . + qq|%|; + map { print "$column_data{$_}\n" } @column_index; + + print qq| |; + $row++; } print qq| @@ -1270,43 +2266,35 @@ sub list_sic { - + {path}> {login}> {password}> -|; - - if ($form->{menubar}) { - require "$form->{path}/menu.pl"; - &menubar; - } + - print qq|
- + - + |; - + $lxdebug->leave_sub(); } - -sub sic_header { +sub payment_header { $lxdebug->enter_sub(); + $form->{title} = $locale->text("$form->{title} Payment Terms"); - $form->{title} = $locale->text("$form->{title} SIC"); - -# $locale->text('Add SIC') -# $locale->text('Edit SIC') + # $locale->text('Add Payment Terms') + # $locale->text('Edit Payment Terms') - $form->{code} =~ s/\"/"/g; $form->{description} =~ s/\"/"/g; - $checked = ($form->{sictype} eq 'H') ? "checked" : ""; + $form->header; @@ -1315,8 +2303,8 @@ sub sic_header {
{script}> - -{code}> +{id}> + @@ -1324,67 +2312,123 @@ sub sic_header { - - + + - - + + + +|; + + foreach my $language (@{ $form->{"TRANSLATION"} }) { + print qq| + + + +|; + } + + print qq| - - + + - + + + + + + + + +
|.$locale->text('Code').qq|{code}>| . $locale->text('Description') . qq|
|.$locale->text('Heading').qq|| . $locale->text('Long Description') . qq|
| . + sprintf($locale->text('Translation (%s)'), + $language->{"language"}) + . qq|
|.$locale->text('Description').qq|| . $locale->text('Netto Terms') . qq|

| . $locale->text('Skonto Terms') . qq|
| . $locale->text('Skonto') . qq| %

-|; + +

| . $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|

+ +|; $lxdebug->leave_sub(); } - -sub save_sic { +sub save_payment { $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!')); + $form->{"percent_skonto"} = + $form->parse_amount(\%myconfig, $form->{percent_skonto}) / 100; + AM->save_payment(\%myconfig, \%$form); + $form->redirect($locale->text('Payment Terms saved!')); $lxdebug->leave_sub(); } - -sub delete_sic { +sub delete_payment { $lxdebug->enter_sub(); - - AM->delete_sic(\%myconfig, \%$form); - $form->redirect($locale->text('SIC deleted!')); + AM->delete_payment(\%myconfig, \%$form); + $form->redirect($locale->text('Payment terms deleted!')); $lxdebug->leave_sub(); } +sub swap_payment_terms { + $lxdebug->enter_sub(); + + AM->swap_sortkeys(\%myconfig, $form, "payment_terms"); + list_payment(); + $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/^\/*//g; $form->{file} =~ s/$userspath//; @@ -1398,7 +2442,7 @@ sub display_form { if ($form->{file} !~ /\.html$/) { $form->{body} = "
\n$form->{body}\n
"; } - + $form->header; print qq| @@ -1415,14 +2459,9 @@ $form->{body} {login}> {password}> -|; - - if ($form->{menubar}) { - require "$form->{path}/menu.pl"; - &menubar; - } + - print qq|
@@ -1432,20 +2471,18 @@ $form->{body} $lxdebug->leave_sub(); } - sub edit_template { $lxdebug->enter_sub(); - AM->load_template(\%$form); $form->{title} = $locale->text('Edit Template'); + # convert   to   $form->{body} =~ s/ / /gi; - $form->header; - + print qq| @@ -1465,14 +2502,9 @@ $form->{body}
-|; + - if ($form->{menubar}) { - require "$form->{path}/menu.pl"; - &menubar; - } - - print q| @@ -1483,31 +2515,33 @@ $form->{body} $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}) ? ""; + } + + if (!$myconfig{"default_media"}) { + $myconfig{"default_media"} = "screen"; + } + my %selected = ($myconfig{"default_media"} => "selected"); + my $default_media = qq| + + + +|; + + %selected = (); + $selected{$myconfig{"default_printer_id"}} = "selected" + if ($myconfig{"default_printer_id"}); + my $default_printer = qq||; + AM->printer(\%myconfig, $form); + foreach my $printer (@{$form->{"ALL"}}) { + $default_printer .= qq||; + } + %countrycodes = User->country_codes; $countrycodes = ''; - foreach $key (sort { $countrycodes{$a} cmp $countrycodes{$b} } keys %countrycodes) { - $countrycodes .= ($myconfig{countrycode} eq $key) ? "