X-Git-Url: http://wagnertech.de/gitweb/gitweb.cgi/kivitendo-erp.git/blobdiff_plain/4dbb09950c9f5596646537c12d991c99086fe7c1..b12e8d1411cb7af3a1a9b6f7637692f0758b4741:/bin/mozilla/am.pl diff --git a/bin/mozilla/am.pl b/bin/mozilla/am.pl index b41b0ec99..e34957f94 100644 --- a/bin/mozilla/am.pl +++ b/bin/mozilla/am.pl @@ -31,50 +31,71 @@ # #====================================================================== - 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 delete { &{"delete_$form->{type}"} } +sub display { + if ($form->{display_nextsub}) { + &{ $form->{display_nextsub} }(); + } else { + &{ $form->{nextsub} }(); + } +} +sub save { + if ($form->{save_nextsub}) { + &{ $form->{save_nextsub} }(); + } else { + &{ $form->{nextsub} }(); + } +} +sub edit { + if ($form->{edit_nextsub}) { + &{ $form->{edit_nextsub} }(); + } else { + &{ "edit_$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 +106,246 @@ 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_language { + $lxdebug->enter_sub(); -sub edit_department { + $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!')); + + $lxdebug->leave_sub(); +} + +sub delete_language { $lxdebug->enter_sub(); + AM->delete_language(\%myconfig, \%$form); + $form->redirect($locale->text('Language deleted!')); - $form->{title} = "Edit"; + $lxdebug->leave_sub(); +} - AM->get_department(\%myconfig, \%$form); - &department_header; +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(); } - -sub list_department { +sub edit_buchungsgruppe { $lxdebug->enter_sub(); + $form->{title} = "Edit"; - AM->departments(\%myconfig, \%$form); + AM->get_buchungsgruppe(\%myconfig, \%$form); - $form->{callback} = "$form->{script}?action=list_department&path=$form->{path}&login=$form->{login}&password=$form->{password}"; + &buchungsgruppe_header; - $callback = $form->escape($form->{callback}); - - $form->{title} = $locale->text('Departments'); + &form_footer; - @column_index = qw(description cost profit); + $lxdebug->leave_sub(); +} + +sub list_buchungsgruppe { + $lxdebug->enter_sub(); - $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||; + 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(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 +1645,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||; + } + + $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; + map { print "$column_data{$_}\n" } @column_index; - print qq| + print qq| |; + + $row++; } print qq| @@ -848,50 +1720,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 +1858,7 @@ sub department_header {
{script}> {id}> - + @@ -908,16 +1866,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 +1878,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 +1938,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_index = qw(printer_description printer_command template_code); - $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_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 +1988,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 +2024,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 +2063,7 @@ sub business_header {
{script}> {id}> - + @@ -1109,21 +2071,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 +2090,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 +2149,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 +2214,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| |; + } + + 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|{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| + print qq| |; + $row++; } print qq| @@ -1270,43 +2284,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 Payment Terms') + # $locale->text('Edit Payment Terms') -# $locale->text('Add SIC') -# $locale->text('Edit SIC') - - $form->{code} =~ s/\"/"/g; $form->{description} =~ s/\"/"/g; - $checked = ($form->{sictype} eq 'H') ? "checked" : ""; + $form->header; @@ -1315,8 +2321,8 @@ sub sic_header {
{script}> - -{code}> +{id}> + @@ -1324,190 +2330,348 @@ 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 { +sub display_template { $lxdebug->enter_sub(); - - $form->{file} = "css/$myconfig{stylesheet}"; - &display_form; - + $form->{edit} = 0; + display_template_form(); + $lxdebug->leave_sub(); } +sub edit_template { + $lxdebug->enter_sub(); + + $form->{edit} = 1; + display_template_form(); + + $lxdebug->leave_sub(); +} -sub display_form { +sub save_template { $lxdebug->enter_sub(); + $form->isblank("formname", $locale->text("You're not editing a file.")) unless ($form->{type} eq "stylesheet"); - $form->{file} =~ s/^(.:)*?\/|\.\.\///g; - $form->{file} =~ s/^\/*//g; - $form->{file} =~ s/$userspath//; + my ($filename) = AM->prepare_template_filename(\%myconfig, $form); + if (my $error = AM->save_template($filename, $form->{content})) { + $form->error(sprintf($locale->text("Saving the file '%s' failed. OS error message: %s"), $filename, $error)); + } - $form->error("$!: $form->{file}") unless -f $form->{file}; + $form->{edit} = 0; + display_template_form(); - AM->load_template(\%$form); + $lxdebug->leave_sub(); +} - $form->{title} = $form->{file}; +sub display_template_form { + $lxdebug->enter_sub(); - # if it is anything but html - if ($form->{file} !~ /\.html$/) { - $form->{body} = "
\n$form->{body}\n
"; - } - - $form->header; + $form->{formname} =~ s|.*/||; + my $format = $form->{format} eq "html" ? "html" : "tex"; + + my $title = $form->{type} eq "stylesheet" ? $locale->text("Edit the stylesheet") : $locale->text("Edit templates"); + $form->{title} = $title; + + my $edit_options; + + my @hidden = qw(login path password type format); + + if (($form->{type} ne "stylesheet") && !$form->{edit}) { + $edit_options = "

"; + + my %formname_setup = + ( + "balance_sheet" => { "translation" => $locale->text('Balance Sheet'), "html" => 1 }, + "bin_list" => $locale->text('Bin List'), + "bwa" => { "translation" => $locale->text('BWA'), "html" => 1 }, + "check" => { "translation" => $locale->text('Check'), "html" => 1 }, + "credit_note" => $locale->text('Credit Note'), + "income_statement" => { "translation" => $locale->text('Income Statement'), "html" => 1 }, + "invoice" => $locale->text('Invoice'), + "packing_list" => $locale->text('Packing List'), + "pick_list" => $locale->text('Pick List'), + "proforma" => $locale->text('Proforma Invoice'), + "purchase_order" => $locale->text('Purchase Order'), + "receipt" => { "translation" => $locale->text('Receipt'), "tex" => 1 }, + "request_quotation" => $locale->text('RFQ'), + "sales_order" => $locale->text('Confirmation'), + "sales_quotation" => $locale->text('Quotation'), + "statement" => $locale->text('Statement'), + "storno_invoice" => $locale->text('Storno Invoice'), + "storno_packing_list" => $locale->text('Storno Packing List'), + "ustva-2004" => { "translation" => $locale->text("USTVA 2004"), "tex" => 1 }, + "ustva-2005" => { "translation" => $locale->text("USTVA 2005"), "tex" => 1 }, + "ustva-2006" => { "translation" => $locale->text("USTVA 2006"), "tex" => 1 }, + "ustva-2007" => { "translation" => $locale->text("USTVA 2007"), "tex" => 1 }, + "ustva" => $locale->text("USTVA"), + "zahlungserinnerung" => $locale->text('Payment Reminder'), + ); + + my (@values, %labels, $file, $setup); + + while (($file, $setup) = each(%formname_setup)) { + next unless (!ref($setup) || $setup->{$format}); + + push(@values, $file); + $labels{$file} = ref($setup) ? $setup->{translation} : $setup; + } + @values = sort({ $labels{$a} cmp $labels{$b} } @values); - print qq| - + $edit_options .= + $locale->text("Template") . " " . + NTI($cgi->popup_menu("-name" => "formname", "-default" => $form->{formname}, + "-values" => \@values, "-labels" => \%labels)); -$form->{body} + $form->get_lists("printers" => "ALL_PRINTERS", + "languages" => "ALL_LANGUAGES"); -{script}> + @values = (""); + %labels = (); -{file}> - + foreach my $item (@{ $form->{ALL_LANGUAGES} }) { + next unless ($item->{template_code}); + my $key = "$item->{id}--$item->{template_code}"; + push(@values, $key); + $labels{$key} = $item->{description}; + } -{path}> -{login}> -{password}> + if (1 != scalar(@values)) { + $edit_options .= + " " . $locale->text("Language") . " " . + NTI($cgi->popup_menu("-name" => "language", "-default" => $form->{language}, + "-values" => \@values, "-labels" => \%labels)); + } -|; + @values = (""); + %labels = (); - if ($form->{menubar}) { - require "$form->{path}/menu.pl"; - &menubar; - } + foreach my $item (@{ $form->{ALL_PRINTERS} }) { + next unless ($item->{template_code}); + my $key = "$item->{id}--$item->{template_code}"; + push(@values, $key); + $labels{$key} = $item->{printer_description}; + } - print qq| -

+ if (1 != scalar(@values)) { + $edit_options .= + " " . $locale->text("Printer") . " " . + NTI($cgi->popup_menu("-name" => "printer", "-default" => $form->{printer}, + "-values" => \@values, "-labels" => \%labels)); + } - - -|; + $edit_options .= qq| - $lxdebug->leave_sub(); -} + + -sub edit_template { - $lxdebug->enter_sub(); +

+
+|; - AM->load_template(\%$form); + } else { + push(@hidden, qw(formname language printer)); + } - $form->{title} = $locale->text('Edit Template'); - # convert   to   - $form->{body} =~ s/ / /gi; - + if ($form->{formname} || ($form->{type} eq "stylesheet")) { + my ($filename, $display_filename) = AM->prepare_template_filename(\%myconfig, $form); + my ($content, $lines) = AM->load_template($filename); - $form->header; - - print qq| - + $body = qq| +|; -
{script}> + if ($form->{edit}) { + $form->{fokus} = "Form.content"; + $body = qq|\n

| . $locale->text('Edit file') . " '" . H($display_filename) . qq|'

\n

| + . NTI($cgi->textarea("-name" => "content", + "-id" => "content", + "-default" => $content, + "-columns" => 100, + "-rows" => 25)) + . qq|

+ +

+ + + +

+|; -{file}> - + } else { + $content = "\n\n" unless ($content); -{path}> -{login}> -{password}> + $body = qq| +

| . $locale->text('Display file') . " '" . H($display_filename) . qq|'

- + - +

-
-|; +

+

| . H($content) . qq|
+

+|; - if ($form->{menubar}) { - require "$form->{path}/menu.pl"; - &menubar; + if ($lines > 25) { + $body .= qq| + +|; + } + } } - print q| -
+ $form->header; + + print qq| + + +
$title
+
- - |; + $form->hide_form(@hidden); - $lxdebug->leave_sub(); -} + print qq| +$edit_options +$body -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) ? "