X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;f=bin%2Fmozilla%2Fam.pl;h=c4f2a291d7f321f908f3a82d8634382ca0b71c30;hb=63024c9f98f172ec904324fd0b6f9cc819ce7600;hp=ab334edcf6969772e8302ce08c2ddf64b8bde916;hpb=c116ffc27cb9ff1c4913f409e67241192be1aff8;p=kivitendo-erp.git diff --git a/bin/mozilla/am.pl b/bin/mozilla/am.pl index ab334edcf..c4f2a291d 100644 --- a/bin/mozilla/am.pl +++ b/bin/mozilla/am.pl @@ -35,15 +35,23 @@ use SL::AM; use SL::CA; use SL::Form; use SL::User; +use SL::USTVA; +use CGI::Ajax; +use CGI; + +use Data::Dumper; 1; +require "bin/mozilla/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 { call_sub("add_$form->{type}"); } +sub delete { call_sub("delete_$form->{type}"); } +sub save { call_sub("save_$form->{type}"); } +sub edit { call_sub("edit_$form->{type}"); } +sub continue { call_sub($form->{"nextsub"}); } sub add_account { $lxdebug->enter_sub(); @@ -53,7 +61,7 @@ sub add_account { AM->get_account(\%myconfig, \%$form); $form->{callback} = - "$form->{script}?action=list_account&path=$form->{path}&login=$form->{login}&password=$form->{password}" + "$form->{script}?action=list_account&login=$form->{login}&password=$form->{password}" unless $form->{callback}; &account_header; @@ -81,61 +89,108 @@ sub edit_account { sub account_header { $lxdebug->enter_sub(); + 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->{description} =~ s/\"/"/g; + $form->{select_tax} = ""; + + my @tax_report_pos = USTVA->report_variables({ + myconfig => \%myconfig, + form => $form, + type => '', + attribute => 'position', + calc => '', + }); if (@{ $form->{TAXKEY} }) { - $form->{selecttaxkey} = "|; } + foreach $item (@{ $form->{NEWACCOUNT} }) { + if ($item->{id} == $form->{new_chart_id}) { + $form->{selectnewaccount} .= + qq||; + } elsif (!$form->{new_chart_valid}) { + $form->{selectnewaccount} .= + qq||; + } + } } - $ustva = qq| - - | . $locale->text('Umsatzsteuervoranmeldung') . qq| - - - |; - - $form->{selecteur} = "\n|; %eur = (1 => "Umsatzerlöse", 2 => "sonstige Erlöse", 3 => "Privatanteile", @@ -169,21 +224,14 @@ sub account_header { 31 => "Betriebliche Steuern"); foreach $item (sort({ $a <=> $b } keys(%eur))) { if ($item == $form->{pos_eur}) { - $form->{selecteur} .= "\n|; } else { - $form->{selecteur} .= "\n|; } } - $eur = qq| - - | . $locale->text('EÜR') . qq| - - - |; - - $form->{selectbwa} = "\n|; %bwapos = (1 => 'Umsatzerlöse', 2 => 'Best.Verdg.FE/UE', @@ -209,184 +257,87 @@ sub account_header { 35 => 'Steuern Eink.u.Ertr.'); foreach $item (sort({ $a <=> $b } keys %bwapos)) { if ($item == $form->{pos_bwa}) { - $form->{selectbwa} .= "\n|; foreach $item ((1, 2, 3, 4)) { if ($item == $form->{pos_bilanz}) { - $form->{selectbilanz} .= "\n|; + + %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 $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}) + ? ""; + } + + 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(); + + $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!')); + + $lxdebug->leave_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&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_buchungsgruppe { + $lxdebug->enter_sub(); + + $form->{title} = "Edit"; + + AM->get_buchungsgruppe(\%myconfig, \%$form); + + &buchungsgruppe_header; + + &form_footer; + + $lxdebug->leave_sub(); +} + +sub list_buchungsgruppe { + $lxdebug->enter_sub(); + + AM->buchungsgruppe(\%myconfig, \%$form); $form->{callback} = - "$form->{script}?action=list_department&path=$form->{path}&login=$form->{login}&password=$form->{password}"; + "$form->{script}?action=list_buchungsgruppe&login=$form->{login}&password=$form->{password}"; $callback = $form->escape($form->{callback}); - $form->{title} = $locale->text('Departments'); + $form->{title} = $locale->text('Buchungsgruppen'); - @column_index = qw(description cost profit); + @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|| + qq|| . $locale->text('Description') . qq||; - $column_header{cost} = - qq|| - . $locale->text('Cost Center') + $column_header{inventory_accno} = + qq|| + . $locale->text('Bestandskonto') . qq||; - $column_header{profit} = - qq|| - . $locale->text('Profit Center') + $column_header{income_accno_0} = + qq|| + . $locale->text('National Revenues') + . qq||; + $column_header{expense_accno_0} = + qq|| + . $locale->text('National Expenses') + . qq||; + $column_header{income_accno_1} = + qq|| + . $locale->text('Revenues EU with UStId') + . qq||; + $column_header{expense_accno_1} = + qq|| + . $locale->text('Expenses EU with UStId') + . qq||; + $column_header{income_accno_2} = + qq|| + . $locale->text('Revenues EU without UStId') + . qq||; + $column_header{expense_accno_2} = + qq|| + . $locale->text('Expenses EU without UStId') + . qq||; + $column_header{income_accno_3} = + qq|| + . $locale->text('Foreign Revenues') + . qq||; + $column_header{expense_accno_3} = + qq|| + . $locale->text('Foreign Expenses') . qq||; - $form->header; print qq| @@ -873,6 +1561,11 @@ sub list_department { |; + my $swap_link = qq|$form->{script}?action=swap_buchungsgruppen&|; + map({ $swap_link .= $_ . "=" . $form->escape($form->{$_}) . "&" } + qw(login password)); + + my $row = 0; foreach $ref (@{ $form->{ALL} }) { $i++; @@ -882,19 +1575,51 @@ sub list_department { |; - $costcenter = ($ref->{role} eq "C") ? "X" : ""; - $profitcenter = ($ref->{role} eq "P") ? "X" : ""; + 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_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|; + qq|{script}?action=edit_buchungsgruppe&id=$ref->{id}&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| |; + + $row++; } print qq| @@ -911,21 +1636,14 @@ sub list_department { - + -{path}> {login}> {password}> |; + . $locale->text('Add') . qq|"> - if ($form->{menubar}) { - require "$form->{path}/menu.pl"; - &menubar; - } - - print qq| @@ -935,26 +1653,117 @@ sub list_department { $lxdebug->leave_sub(); } -sub department_header { +sub buchungsgruppe_header { $lxdebug->enter_sub(); - $form->{title} = $locale->text("$form->{title} Department"); + $form->{title} = $locale->text("$form->{title} Buchungsgruppe"); - # $locale->text('Add Department') - # $locale->text('Edit Department') + # $locale->text('Add Accounting Group') + # $locale->text('Edit Accounting Group') - $form->{description} =~ s/\"/"/g; + 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, + ); - if (($rows = $form->numtextrows($form->{description}, 60)) > 1) { - $description = - qq||; + foreach $key (keys(%acc_type_map)) { + foreach $ref (@{ $form->{IC_links}{$key} }) { + $acc_type_map{$key}->{$ref->{"id"}} = $ref; + } + } + + 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('National Revenues') . qq| + + + + | . $locale->text('National Expenses') . 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('Revenues EU with UStId') . qq| + + + + | . $locale->text('Expenses EU with 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('Revenues EU without UStId') . qq| + + + + | . $locale->text('Expenses EU without 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('Foreign Revenues') . qq| + + + + | . $locale->text('Foreign Expenses') . qq| + + +|; + $form->header; @@ -964,7 +1773,7 @@ sub department_header {
{script}> {id}> - + @@ -972,18 +1781,11 @@ sub department_header { - - - - - - + + - + $linkaccounts +
| . $locale->text('Description') . qq|$description
| - . $locale->text('Cost Center') . qq| - | - . $locale->text('Profit Center') . qq| - | . $locale->text('Buchungsgruppe') . qq|


|; @@ -991,48 +1793,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('Accounting Group saved!')); $lxdebug->leave_sub(); } -sub delete_department { +sub delete_buchungsgruppe { $lxdebug->enter_sub(); - AM->delete_department(\%myconfig, \%$form); - $form->redirect($locale->text('Department deleted!')); + AM->delete_buchungsgruppe(\%myconfig, \%$form); + $form->redirect($locale->text('Accounting Group deleted!')); $lxdebug->leave_sub(); } -sub add_business { +sub swap_buchungsgruppen { + $lxdebug->enter_sub(); + + AM->swap_sortkeys(\%myconfig, $form, "buchungsgruppen"); + list_buchungsgruppe(); + + $lxdebug->leave_sub(); +} + + +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}" + "$form->{script}?action=add_printer&login=$form->{login}&password=$form->{password}" unless $form->{callback}; - &business_header; + &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; @@ -1040,31 +1853,31 @@ sub edit_business { $lxdebug->leave_sub(); } -sub list_business { +sub list_printer { $lxdebug->enter_sub(); - AM->business(\%myconfig, \%$form); + AM->printer(\%myconfig, \%$form); $form->{callback} = - "$form->{script}?action=list_business&path=$form->{path}&login=$form->{login}&password=$form->{password}"; + "$form->{script}?action=list_printer&login=$form->{login}&password=$form->{password}"; $callback = $form->escape($form->{callback}); - $form->{title} = $locale->text('Type of Business'); + $form->{title} = $locale->text('Printer'); - @column_index = qw(description discount customernumberinit); + @column_index = qw(printer_description printer_command template_code); - $column_header{description} = + $column_header{printer_description} = qq|| - . $locale->text('Description') + . $locale->text('Printer Description') . qq||; - $column_header{discount} = + $column_header{printer_command} = qq|| - . $locale->text('Discount') - . qq| %|; - $column_header{customernumberinit} = + . $locale->text('Printer Command') + . qq||; + $column_header{template_code} = qq|| - . $locale->text('Customernumberinit') + . $locale->text('Template Code') . qq||; $form->header; @@ -1098,17 +1911,12 @@ sub list_business { |; - $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}|; + + $column_data{printer_description} = + qq|{script}?action=edit_printer&id=$ref->{id}&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; @@ -1131,21 +1939,13 @@ sub list_business { - + -{path}> {login}> {password}> |; - - if ($form->{menubar}) { - require "$form->{path}/menu.pl"; - &menubar; - } - - print qq| + . $locale->text('Add') . qq|"> @@ -1156,18 +1956,18 @@ sub list_business { $lxdebug->leave_sub(); } -sub business_header { +sub printer_header { $lxdebug->enter_sub(); - $form->{title} = $locale->text("$form->{title} Business"); - $form->{salesman} = "checked" if $form->{salesman}; + $form->{title} = $locale->text("$form->{title} Printer"); - # $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; @@ -1177,7 +1977,7 @@ sub business_header {
{script}> {id}> - + @@ -1185,20 +1985,16 @@ sub business_header { - - - + + - - - - - + + - - + + @@ -1208,48 +2004,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}" + "$form->{script}?action=add_payment&login=$form->{login}&password=$form->{password}" unless $form->{callback}; - &sic_header; + $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; @@ -1257,24 +2063,48 @@ sub edit_sic { $lxdebug->leave_sub(); } -sub list_sic { +sub list_payment { $lxdebug->enter_sub(); - AM->sic(\%myconfig, \%$form); + AM->payment(\%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'); + $form->{title} = $locale->text('Payment Terms'); - @column_index = qw(code description); + @column_index = qw(up down description description_long terms_netto + terms_skonto percent_skonto); - $column_header{code} = - qq||; + $column_header{up} = + qq||; + $column_header{down} = + qq||; $column_header{description} = - qq||; + qq||; + $column_header{description_long} = + qq||; + $column_header{terms_netto} = + qq||; + $column_header{terms_skonto} = + qq||; + $column_header{percent_skonto} = + qq||; $form->header; @@ -1298,35 +2128,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||; - $column_data{description} = qq||; - - } else { - print qq| + print qq| |; - $column_data{code} = - qq||; - $column_data{description} = qq||; + if ($row) { + my $pref = $form->{ALL}->[$row - 1]; + $column_data{up} = + 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||; } + $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| |; + $row++; } print qq| @@ -1343,21 +2198,14 @@ sub list_sic { - + -{path}> {login}> {password}> |; - - if ($form->{menubar}) { - require "$form->{path}/menu.pl"; - &menubar; - } + . $locale->text('Add') . qq|"> - print qq| @@ -1367,18 +2215,17 @@ sub list_sic { $lxdebug->leave_sub(); } -sub sic_header { +sub payment_header { $lxdebug->enter_sub(); - $form->{title} = $locale->text("$form->{title} SIC"); + $form->{title} = $locale->text("$form->{title} Payment Terms"); - # $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; @@ -1387,8 +2234,8 @@ sub sic_header { {script}> - -{code}> +{id}> +
| . $locale->text('Type of Business') . qq|
| . $locale->text('Printer') . qq|
| . $locale->text('Discount') . qq| %{discount}>
| . $locale->text('Customernumberinit') . qq|{customernumberinit}>| . $locale->text('Printer Command') . qq|
| . $locale->text('Salesman') . qq|{salesman}>| . $locale->text('Template Code') . qq|

| . $locale->text('Code') . qq|| + . qq|| . $locale->text(| + . qq|| + . qq|| . $locale->text(| + . qq|| . $locale->text('Description') . qq|| + . $locale->text('Description') + . qq|| + . $locale->text('Long Description') + . qq|| + . $locale->text('Netto Terms') + . qq|| + . $locale->text('Skonto Terms') + . qq|| + . $locale->text('Skonto') + . 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}| . + qq|| . + qq|| . $locale->text(| . + qq|  | . + qq|| . + qq|| . $locale->text(| . + qq|{id}", "callback=$callback") . + qq|">| . H($ref->{description}) . qq|| . H($ref->{description_long}) . qq|$ref->{terms_netto}$ref->{terms_skonto}| . + $form->format_amount(\%myconfig, $ref->{percent_skonto} * 100) . + qq|%
@@ -1396,162 +2243,106 @@ sub sic_header { - - - - - - + + - - + + - - -
| . $locale->text('Code') . qq|{code}>
| - . $locale->text('Heading') . qq|| . $locale->text('Description') . qq|
| . $locale->text('Description') . qq|| . $locale->text('Long 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}> - -|; - - if ($form->{menubar}) { - require "$form->{path}/menu.pl"; - &menubar; + foreach my $language (@{ $form->{"TRANSLATION"} }) { + print qq| + + | . + sprintf($locale->text('Translation (%s)'), + $language->{"language"}) + . qq| + + +|; } print 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|

+ +
    +
  • | . $locale->text("<%netto_date%> -- Date the payment is due in " . + "full") +. qq|
  • +
  • | . $locale->text("<%skonto_date%> -- Date the payment is due " . + "with discount") +. qq|
  • +
  • | . $locale->text("<%skonto_amount%> -- The deductible amount") +. qq|
  • +
  • | . $locale->text("<%total%> -- Amount payable") +. qq|
  • +
  • | . $locale->text("<%invtotal%> -- Invoice total") +. qq|
  • +
  • | . $locale->text("<%currency%> -- The selected currency") +. qq|
  • +
  • | . $locale->text("<%terms_netto%> -- The number of days for " . + "full payment") +. qq|
  • +
  • | . $locale->text("<%account_number%> -- Your account number") +. qq|
  • +
  • | . $locale->text("<%bank%> -- Your bank") +. qq|
  • +
  • | . $locale->text("<%bank_code%> -- Your bank code") +. qq|
  • +
|; $lxdebug->leave_sub(); } -sub edit_template { +sub save_payment { $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}> - - - - - -
-|; - - if ($form->{menubar}) { - require "$form->{path}/menu.pl"; - &menubar; - } + $form->isblank("description", $locale->text('Description missing!')); + $form->{"percent_skonto"} = + $form->parse_amount(\%myconfig, $form->{percent_skonto}) / 100; + AM->save_payment(\%myconfig, \%$form); + $form->redirect($locale->text('Payment Terms saved!')); - print q| -
+ $lxdebug->leave_sub(); +} +sub delete_payment { + $lxdebug->enter_sub(); - - -|; + AM->delete_payment(\%myconfig, \%$form); + $form->redirect($locale->text('Payment terms deleted!')); $lxdebug->leave_sub(); } -sub save_template { +sub swap_payment_terms { $lxdebug->enter_sub(); - AM->save_template(\%$form); - $form->redirect($locale->text('Template saved!')); + AM->swap_sortkeys(\%myconfig, $form, "payment_terms"); + list_payment(); $lxdebug->leave_sub(); } @@ -1584,6 +2375,58 @@ sub config { $myconfig{$item} =~ s/\\n/\r\n/g; } + @formats = (); + if ($opendocument_templates && $openofficeorg_writer_bin && + $xvfb_bin && (-x $openofficeorg_writer_bin) && (-x $xvfb_bin)) { + push(@formats, { "name" => $locale->text("PDF (OpenDocument/OASIS)"), + "value" => "opendocument_pdf" }); + } + if ($latex_templates) { + push(@formats, { "name" => $locale->text("PDF"), "value" => "pdf" }); + } + push(@formats, { "name" => "HTML", "value" => "html" }); + if ($latex_templates) { + push(@formats, { "name" => $locale->text("Postscript"), + "value" => "postscript" }); + } + if ($opendocument_templates) { + push(@formats, { "name" => $locale->text("OpenDocument/OASIS"), + "value" => "opendocument" }); + } + + if (!$myconfig{"template_format"}) { + $myconfig{"template_format"} = "pdf"; + } + my $template_format = ""; + foreach $item (@formats) { + $template_format .= + ""; + } + + 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} } @@ -1605,9 +2448,13 @@ sub config { } } - opendir CSS, "css/."; - @all = grep /.*\.css$/, readdir CSS; - closedir CSS; +# opendir CSS, "css/."; +# @all = grep /.*\.css$/, readdir CSS; +# closedir CSS; + +# css dir has styles that are not intended as general layouts. +# reverting to hardcoded list + @all = qw(lx-office-erp.css Win2000.css); foreach $item (@all) { if ($item eq $myconfig{stylesheet}) { @@ -1622,8 +2469,19 @@ sub config { $form->header; - if ($myconfig{menustyle} eq "old") { $oldS = "checked"; } - else { $newS = "checked"; } + if ($myconfig{menustyle} eq "old") { + $menustyle_old = "checked"; + } elsif ($myconfig{menustyle} eq "neu") { + $menustyle_neu = "checked"; + } elsif ($myconfig{menustyle} eq "v3") { + $menustyle_v3 = "checked"; + } + + my ($show_form_details, $hide_form_details); + $myconfig{"show_form_details"} = 1 + unless (defined($myconfig{"show_form_details"})); + $show_form_details = "checked" if ($myconfig{"show_form_details"}); + $hide_form_details = "checked" unless ($myconfig{"show_form_details"}); print qq| @@ -1676,9 +2534,10 @@ sub config { - | . $locale->text('Number Format') . qq| + | . $locale->text('Output Number Format') . qq| + | . $locale->text('Dropdown Limit') . qq| @@ -1687,20 +2546,49 @@ sub config { | . $locale->text('Language') . qq| - - | . $locale->text('Character Set') . qq| - - | . $locale->text('Stylesheet') . qq| | . $locale->text('Setup Menu') . qq| -  New -  Old - +  | . + $locale->text("Top (CSS)") . qq| +  | . + $locale->text("Top (Javascript)") . qq| +  | . + $locale->text("Old (on the side)") . qq| + + + | . $locale->text('Form details (second row)') . qq| +   + +   + + + + | . $locale->text("Print options") . qq| + + + | . $locale->text('Default template format') . qq| + + + + | . $locale->text('Default output medium') . qq| + + + + | . $locale->text('Default printer') . qq| + + + + | . $locale->text('Number of copies') . qq| + + + +   @@ -1709,16 +2597,8 @@ sub config { - - - - - - -
| . $locale->text('Year End') . qq| (mm/dd) {defaults}{yearend}>| . $locale->text('Weight Unit') . qq|
- | @@ -1769,14 +2649,19 @@ sub config { | - . $locale->text('Last Sales Order Number') . qq| - {defaults}{sonumber}> + . $locale->text('Last Credit Note Number') . qq| + {defaults}{cnnumber}> | . $locale->text('Last Vendor Number') . qq| {defaults}{vendornumber}> | + . $locale->text('Last Sales Order Number') . qq| + {defaults}{sonumber}> + + + | . $locale->text('Last Purchase Order Number') . qq| {defaults}{ponumber}> | @@ -1799,40 +2684,40 @@ sub config { - - - | . $locale->text('Tax Accounts') . qq| - - - - - - - - - -|; - - foreach $accno (sort keys %{ $form->{taxrates} }) { - print qq| - - - - - -|; - $form->{taxaccounts} .= "$form->{taxrates}{$accno}{id} "; - } - - chop $form->{taxaccounts}; - - print qq| - - -
 | . $locale->text('Rate') . qq| (%)| . $locale->text('Number') . qq|
$form->{taxrates}{$accno}{description}{taxrates}{$accno}{id} size=6 value=$form->{taxrates}{$accno}{rate}>
- - - + |; +# +# | . $locale->text('Tax Accounts') . qq| +# +# +# +# +# +# +# +# +# +# |; +# +# foreach $accno (sort keys %{ $form->{taxrates} }) { +# print qq| +# +# +# +# +# +# |; +# $form->{taxaccounts} .= "$form->{taxrates}{$accno}{id} "; +# } +# +# chop $form->{taxaccounts}; +# +# print qq| +# +# +#
 | . $locale->text('Rate') . qq| (%)| . $locale->text('Number') . qq|
$form->{taxrates}{$accno}{description}{taxrates}{$accno}{id} size=6 value=$form->{taxrates}{$accno}{rate}>
+# +# +print qq| @@ -1840,20 +2725,13 @@ sub config { -{path}> {login}> {password}>
|; - - if ($form->{menubar}) { - require "$form->{path}/menu.pl"; - &menubar; - } + . $locale->text('Save') . qq|"> - print qq| @@ -1877,26 +2755,6 @@ sub save_preferences { $lxdebug->leave_sub(); } -sub backup { - $lxdebug->enter_sub(); - - if ($form->{media} eq 'email') { - $form->error($locale->text('No email address for') . " $myconfig{name}") - unless ($myconfig{email}); - - $form->{OUT} = "$sendmail"; - - } - - AM->backup(\%myconfig, \%$form, $userspath); - - if ($form->{media} eq 'email') { - $form->redirect($locale->text('Backup sent to') . qq| $myconfig{email}|); - } - - $lxdebug->leave_sub(); -} - sub audit_control { $lxdebug->enter_sub(); @@ -1917,7 +2775,6 @@ sub audit_control {
{script}> -{path}> {login}> {password}> @@ -1983,201 +2840,289 @@ sub doclose { $lxdebug->leave_sub(); } -sub add_warehouse { +sub edit_units { $lxdebug->enter_sub(); - $form->{title} = "Add"; - - $form->{callback} = - "$form->{script}?action=add_warehouse&path=$form->{path}&login=$form->{login}&password=$form->{password}" - unless $form->{callback}; - - &warehouse_header; - &form_footer; - - $lxdebug->leave_sub(); -} - -sub edit_warehouse { - $lxdebug->enter_sub(); + $units = AM->retrieve_units(\%myconfig, $form, $form->{"unit_type"}, "resolved_"); + AM->units_in_use(\%myconfig, $form, $units); + map({ $units->{$_}->{"BASE_UNIT_DDBOX"} = AM->unit_select_data($units, $units->{$_}->{"base_unit"}, 1); } keys(%{$units})); + + @languages = AM->language(\%myconfig, $form, 1); + + @unit_list = sort({ $a->{"sortkey"} <=> $b->{"sortkey"} } values(%{$units})); + + my $i = 1; + foreach (@unit_list) { + $_->{"factor"} = $form->format_amount(\%myconfig, $_->{"factor"} * 1) if ($_->{"factor"}); + $_->{"UNITLANGUAGES"} = []; + foreach my $lang (@languages) { + push(@{ $_->{"UNITLANGUAGES"} }, + { "idx" => $i, + "unit" => $_->{"name"}, + "language_id" => $lang->{"id"}, + "localized" => $_->{"LANGUAGES"}->{$lang->{"template_code"}}->{"localized"}, + "localized_plural" => $_->{"LANGUAGES"}->{$lang->{"template_code"}}->{"localized_plural"}, + }); + } + $i++; + } - $form->{title} = "Edit"; + $units = AM->retrieve_units(\%myconfig, $form, $form->{"unit_type"}); + $ddbox = AM->unit_select_data($units, undef, 1); - AM->get_warehouse(\%myconfig, \%$form); + my $updownlink = build_std_url("action=swap_units", "unit_type"); - &warehouse_header; - &form_footer; + $form->{"title"} = sprintf($locale->text("Add and edit %s"), $form->{"unit_type"} eq "dimension" ? $locale->text("dimension units") : $locale->text("service units")); + $form->header(); + print($form->parse_html_template("am/edit_units", + { "UNITS" => \@unit_list, + "NEW_BASE_UNIT_DDBOX" => $ddbox, + "LANGUAGES" => \@languages, + "updownlink" => $updownlink })); $lxdebug->leave_sub(); } -sub list_warehouse { +sub add_unit { $lxdebug->enter_sub(); - AM->warehouses(\%myconfig, \%$form); - - $form->{callback} = - "$form->{script}?action=list_warehouse&path=$form->{path}&login=$form->{login}&password=$form->{password}"; - - $callback = $form->escape($form->{callback}); - - $form->{title} = $locale->text('Warehouses'); - - @column_index = qw(description); - - $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; - - print qq| - -|; - - $column_data{description} = - qq||; + $form->isblank("new_name", $locale->text("The name is missing.")); + $units = AM->retrieve_units(\%myconfig, $form, $form->{"unit_type"}); + $all_units = AM->retrieve_units(\%myconfig, $form); + $form->show_generic_error($locale->text("A unit with this name does already exist.")) if ($all_units->{$form->{"new_name"}}); - map { print "$column_data{$_}\n" } @column_index; + my ($base_unit, $factor); + if ($form->{"new_base_unit"}) { + $form->show_generic_error($locale->text("The base unit does not exist.")) unless (defined($units->{$form->{"new_base_unit"}})); - print qq| - -|; + $form->isblank("new_factor", $locale->text("The factor is missing.")); + $factor = $form->parse_amount(\%myconfig, $form->{"new_factor"}); + $form->show_generic_error($locale->text("The factor is missing.")) unless ($factor); + $base_unit = $form->{"new_base_unit"}; } - print qq| -
{script}?action=edit_warehouse&id=$ref->{id}&path=$form->{path}&login=$form->{login}&password=$form->{password}&callback=$callback>$ref->{description}
-

+ my @languages; + foreach my $lang (AM->language(\%myconfig, $form, 1)) { + next unless ($form->{"new_localized_$lang->{id}"} || $form->{"new_localized_plural_$lang->{id}"}); + push(@languages, { "id" => $lang->{"id"}, + "localized" => $form->{"new_localized_$lang->{id}"}, + "localized_plural" => $form->{"new_localized_plural_$lang->{id}"}, + }); + } -
-{script}> + AM->add_unit(\%myconfig, $form, $form->{"new_name"}, $base_unit, $factor, $form->{"unit_type"}, \@languages); - + $form->{"saved_message"} = $locale->text("The unit has been saved."); - + edit_units(); -{path}> -{login}> -{password}> + $lxdebug->leave_sub(); +} -|; +sub set_unit_languages { + $lxdebug->enter_sub(); - if ($form->{menubar}) { - require "$form->{path}/menu.pl"; - &menubar; - } + my ($unit, $languages, $idx) = @_; - print qq| -
+ $unit->{"LANGUAGES"} = []; - - -|; + foreach my $lang (@{$languages}) { + push(@{ $unit->{"LANGUAGES"} }, + { "id" => $lang->{"id"}, + "localized" => $form->{"localized_${idx}_$lang->{id}"}, + "localized_plural" => $form->{"localized_plural_${idx}_$lang->{id}"}, + }); + } $lxdebug->leave_sub(); } -sub warehouse_header { +sub save_unit { $lxdebug->enter_sub(); - $form->{title} = $locale->text("$form->{title} Warehouse"); + $old_units = AM->retrieve_units(\%myconfig, $form, $form->{"unit_type"}, "resolved_"); + AM->units_in_use(\%myconfig, $form, $old_units); - # $locale->text('Add Warehouse') - # $locale->text('Edit Warehouse') + @languages = AM->language(\%myconfig, $form, 1); - $form->{description} =~ s/\"/"/g; + $new_units = {}; + @delete_units = (); + foreach $i (1..($form->{"rowcount"} * 1)) { + $old_unit = $old_units->{$form->{"old_name_$i"}}; + if (!$old_unit) { + $form->show_generic_error(sprintf($locale->text("The unit in row %d has been deleted in the meantime."), $i)); + } - if (($rows = $form->numtextrows($form->{description}, 60)) > 1) { - $description = - qq||; - } else { - $description = - qq||; - } + if ($form->{"unchangeable_$i"}) { + $new_units->{$form->{"old_name_$i"}} = $old_units->{$form->{"old_name_$i"}}; + $new_units->{$form->{"old_name_$i"}}->{"unchanged_unit"} = 1; + set_unit_languages($new_units->{$form->{"old_name_$i"}}, \@languages, $i); + next; + } - $form->header; + if ($old_unit->{"in_use"}) { + $form->show_generic_error(sprintf($locale->text("The unit in row %d has been used in the meantime and cannot be changed anymore."), $i)); + } - print qq| - + if ($form->{"delete_$i"}) { + push(@delete_units, $old_unit->{"name"}); + next; + } -
{script}> + $form->isblank("name_$i", sprintf($locale->text("The name is missing in row %d."), $i)); -{id}> - + $form->show_generic_error(sprintf($locale->text("The name in row %d has already been used before."), $i)) if ($new_units->{$form->{"name_$i"}}); + my %h = map({ $_ => $form->{"${_}_$i"} } qw(name base_unit factor old_name)); + $new_units->{$form->{"name_$i"}} = \%h; + $new_units->{$form->{"name_$i"}}->{"row"} = $i; + set_unit_languages($new_units->{$form->{"old_name_$i"}}, \@languages, $i); + } - - - - - - - - - - - - -
$form->{title}
| . $locale->text('Description') . qq|$description

-|; + foreach $unit (values(%{$new_units})) { + next unless ($unit->{"old_name"}); + if ($unit->{"base_unit"}) { + $form->show_generic_error(sprintf($locale->text("The base unit does not exist or it is about to be deleted in row %d."), $unit->{"row"})) + unless (defined($new_units->{$unit->{"base_unit"}})); + $unit->{"factor"} = $form->parse_amount(\%myconfig, $unit->{"factor"}); + $form->show_generic_error(sprintf($locale->text("The factor is missing in row %d."), $unit->{"row"})) unless ($unit->{"factor"} >= 1.0); + } else { + $unit->{"base_unit"} = undef; + $unit->{"factor"} = undef; + } + } - $lxdebug->leave_sub(); -} + foreach $unit (values(%{$new_units})) { + next if ($unit->{"unchanged_unit"}); + + map({ $_->{"seen"} = 0; } values(%{$new_units})); + $new_unit = $unit; + while ($new_unit->{"base_unit"}) { + $new_unit->{"seen"} = 1; + $new_unit = $new_units->{$new_unit->{"base_unit"}}; + if ($new_unit->{"seen"}) { + $form->show_generic_error(sprintf($locale->text("The base unit relations must not contain loops (e.g. by saying that unit A's base unit is B, " . + "B's base unit is C and C's base unit is A) in row %d."), $unit->{"row"})); + } + } + } -sub save_warehouse { - $lxdebug->enter_sub(); + AM->save_units(\%myconfig, $form, $form->{"unit_type"}, $new_units, \@delete_units); - $form->isblank("description", $locale->text('Description missing!')); - AM->save_warehouse(\%myconfig, \%$form); - $form->redirect($locale->text('Warehouse saved!')); + $form->{"saved_message"} = $locale->text("The units have been saved."); + + edit_units(); $lxdebug->leave_sub(); } -sub delete_warehouse { - $lxdebug->enter_sub(); +sub show_history_search { + $lxdebug->enter_sub(); + + $form->{title} = $locale->text("History Search"); + $form->header(); + + print $form->parse_html_template("/common/search_history"); + + $lxdebug->leave_sub(); +} - AM->delete_warehouse(\%myconfig, \%$form); - $form->redirect($locale->text('Warehouse deleted!')); +sub show_am_history { + $lxdebug->enter_sub(); + my %search = ( "Artikelnummer" => "parts", + "Kundennummer" => "customer", + "Lieferantennummer" => "vendor", + "Projektnummer" => "project", + "Buchungsnummer" => "oe", + "Eingangsrechnungnummer" => "ap", + "Ausgangsrechnungnummer" => "ar", + "Mahnungsnummer" => "dunning" + ); + my %searchNo = ( "Artikelnummer" => "partnumber", + "Kundennummer" => "customernumber", + "Lieferantennummer" => "vendornumber", + "Projektnummer" => "projectnummer", + "Buchungsnummer" => "ordnumber", + "Eingangsrechnungnummer" => "invnumber", + "Ausgangsrechnungnummer" => "invnumber", + "Mahnungsnummer" => "dunning_id" + ); + + my $restriction; + my $tempNo = 0; + foreach(split(/\,/, $form->{einschraenkungen})) { + if($tempNo == 0) { + $restriction .= " AND addition = '" . $_ . "'"; + $tempNo = 1; + } + else { + $restriction .= " OR addition = '" . $_ . "'"; + } + } + + $restriction .= (($form->{transdate} ne "" && $form->{reqdate} ne "") + ? qq| AND st.itime::date >= '| . $form->{transdate} . qq|' AND st.itime::date <= '| . $form->{reqdate} . qq|'| + : (($form->{transdate} ne "" && $form->{reqdate} eq "") + ? qq| AND st.itime::date >= '| . $form->{transdate} . qq|'| + : ($form->{transdate} eq "" && $form->{reqdate} ne "") + ? qq| AND st.itime::date <= '| . $form->{reqdate} . qq|'| + : "" + ) + ); + + my $dbh = $form->dbconnect(\%myconfig); + my $searchSNumber = $searchNo{$form->{'what2search'}} . qq|_| . $form->{'searchid'}; + $restriction .= ($form->{mitarbeiter} eq "" ? "" + : ($form->{mitarbeiter} =~ /^[0-9]*$/ + ? " AND employee_id = " . $form->{mitarbeiter} + : " AND employee_id = " . &get_employee_id($form->{mitarbeiter}, $dbh))); + my $query = qq|SELECT trans_id AS id FROM history_erp WHERE sNumbers = '$searchSNumber' |; + + my $sth = $dbh->prepare($query); + + $sth->execute() || $form->dberror($query); + + if($sth->fetch() <= 0) { + $sth->finish(); + my $query = qq|SELECT id FROM $search{$form->{what2search}} + WHERE $searchNo{$form->{'what2search'}} ILIKE '$form->{"searchid"}' + |; + } + $sth->execute() || $form->dberror($query); + $form->{title} = $locale->text("History Search"); + $form->header(); + my $daten = ""; + while(my $hash_ref = $sth->fetchrow_hashref()){ + $daten = $form->get_history($dbh,$hash_ref->{id},$restriction); + } + $dbh->disconnect(); + print $form->parse_html_template("/common/show_history", + {"DATEN" => $daten, + "SUCCESS" => ($daten != 0 ? 1 : 0), + "NONEWWINDOW" => 1 + }); + $lxdebug->leave_sub(); +} - $lxdebug->leave_sub(); +sub get_employee_id { + $lxdebug->enter_sub(); + my $query = qq|SELECT id FROM employee WHERE name = '| . $_[0] . qq|'|; + my $sth = $_[1]->prepare($query); + $sth->execute() || $form->dberror($query); + my $return = $sth->fetch(); + $sth->finish(); + return ${$return}[0]; + $lxdebug->leave_sub(); } -sub continue { +sub swap_units { $lxdebug->enter_sub(); - &{ $form->{nextsub} }; + my $dir = $form->{"dir"} eq "down" ? "down" : "up"; + my $unit_type = $form->{"unit_type"} eq "dimension" ? + "dimension" : "service"; + AM->swap_units(\%myconfig, $form, $dir, $form->{"name"}, $unit_type); + + edit_units(); $lxdebug->leave_sub(); }