X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;f=bin%2Fmozilla%2Fam.pl;h=ca1ee4c0d89b75ed1b3fcf9f4a17b198a20ae3a3;hb=4f3393f4faf9b531d48bb97056468eaf5d0676c8;hp=fcf7d018b65b57392380f737a49b3739ea9c3344;hpb=1beff66b3fa058377168668daac8a51092bfea5d;p=kivitendo-erp.git diff --git a/bin/mozilla/am.pl b/bin/mozilla/am.pl index fcf7d018b..ca1ee4c0d 100644 --- a/bin/mozilla/am.pl +++ b/bin/mozilla/am.pl @@ -40,14 +40,15 @@ use Data::Dumper; 1; -require "$form->{path}/common.pl"; +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(); @@ -57,7 +58,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; @@ -94,14 +95,16 @@ sub account_header { $form->{description} =~ s/\"/"/g; if (@{ $form->{TAXKEY} }) { - $form->{selecttaxkey} = ""; + } - - - - - - - - - - - -
$form->{title}
- - + if (!$myconfig{"default_media"}) { + $myconfig{"default_media"} = "screen"; + } + my %selected = ($myconfig{"default_media"} => "selected"); + my $default_media = qq| + + + |; - map { print "$column_header{$_}\n" } @column_index; + %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||; + } - print qq| - -|; + %countrycodes = User->country_codes; + $countrycodes = ''; + foreach $key (sort { $countrycodes{$a} cmp $countrycodes{$b} } + keys %countrycodes + ) { + $countrycodes .= + ($myconfig{countrycode} eq $key) + ? " -|; - $column_data{code} = - qq||; - $column_data{description} = qq||; +# 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}) { + $selectstylesheet .= qq| -|; - - $column_data{code} = - qq||; - $column_data{description} = qq||; - + $selectstylesheet .= qq| -|; } + $selectstylesheet .= "
{script}?action=edit_sic&code=$ref->{code}&path=$form->{path}&login=$form->{login}&password=$form->{password}&callback=$callback>$ref->{code}$ref->{description}
{script}?action=edit_sic&code=$ref->{code}&path=$form->{path}&login=$form->{login}&password=$form->{password}&callback=$callback>$ref->{code}$ref->{description}
-

- -
-
{script}> - - - - - -{path}> -{login}> -{password}> + $form->{title} = $locale->text('Edit Preferences for') . qq| $form->{login}|; -|; + $form->header; - if ($form->{menubar}) { - require "$form->{path}/menu.pl"; - &menubar; + if ($myconfig{menustyle} eq "old") { + $menustyle_old = "checked"; + } elsif ($myconfig{menustyle} eq "neu") { + $menustyle_neu = "checked"; + } elsif ($myconfig{menustyle} eq "v3") { + $menustyle_v3 = "checked"; } - print qq| -
- - - -|; - - $lxdebug->leave_sub(); -} - -sub sic_header { - $lxdebug->enter_sub(); - - $form->{title} = $locale->text("$form->{title} SIC"); - - # $locale->text('Add SIC') - # $locale->text('Edit SIC') - - $form->{code} =~ s/\"/"/g; - $form->{description} =~ s/\"/"/g; - - $checked = ($form->{sictype} eq 'H') ? "checked" : ""; - - $form->header; + 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|
{script}> - -{code}> + + + + - - - - - - - - - - - - - - - - - -
$form->{title}
$form->{title}
| . $locale->text('Code') . qq|{code}>
| - . $locale->text('Heading') . qq|
| . $locale->text('Description') . qq|

-|; - - $lxdebug->leave_sub(); -} - -sub save_sic { - $lxdebug->enter_sub(); - - $form->isblank("code", $locale->text('Code missing!')); - $form->isblank("description", $locale->text('Description missing!')); - AM->save_sic(\%myconfig, \%$form); - $form->redirect($locale->text('SIC saved!')); + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - $lxdebug->leave_sub(); -} - -sub delete_sic { - $lxdebug->enter_sub(); - - AM->delete_sic(\%myconfig, \%$form); - $form->redirect($locale->text('SIC deleted!')); - - $lxdebug->leave_sub(); -} - -sub display_stylesheet { - $lxdebug->enter_sub(); - - $form->{file} = "css/$myconfig{stylesheet}"; - &display_form; - - $lxdebug->leave_sub(); -} - -sub display_form { - $lxdebug->enter_sub(); - - $form->{file} =~ s/^(.:)*?\/|\.\.\///g; - $form->{file} =~ s/^\/*//g; - $form->{file} =~ s/$userspath//; - - $form->error("$!: $form->{file}") unless -f $form->{file}; - - AM->load_template(\%$form); - - $form->{title} = $form->{file}; - - # if it is anything but html - if ($form->{file} !~ /\.html$/) { - $form->{body} = "
\n$form->{body}\n
"; - } - - $form->header; - - print qq| - - -$form->{body} - -{script}> - -{file}> - - -{path}> -{login}> -{password}> - -|; - - if ($form->{menubar}) { - require "$form->{path}/menu.pl"; - &menubar; - } - - print qq| - - - - -|; - - $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| - - -{script}> - -{file}> - - -{path}> -{login}> -{password}> - - - - - -
-|; - - if ($form->{menubar}) { - require "$form->{path}/menu.pl"; - &menubar; - } - - print q| - - - - - -|; - - $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}) - ? "
| . $locale->text('Name') . qq|
| . $locale->text('Password') . qq|
| . $locale->text('E-mail') . qq|
| . $locale->text('Signature') . qq|
| . $locale->text('Phone') . qq|
| . $locale->text('Fax') . qq|
| . $locale->text('Company') . qq|
| . $locale->text('Address') . qq|
| . $locale->text('Date Format') . qq|
| . $locale->text('Output Number Format') . qq|
- - - - - - - - - - -
$form->{title}
- - - - - - - - - - - - - - - - - - - + + - - + + - - - - - - + + - - + + + + + + - - - + + + - - + + - - - + + - - + + - - + + - - - - - + + @@ -2981,16 +2653,8 @@ sub config { -
| . $locale->text('Name') . qq|
| . $locale->text('Password') . qq|
| . $locale->text('E-mail') . qq|
| . $locale->text('Signature') . qq|
| . $locale->text('Phone') . qq|| . $locale->text('Dropdown Limit') . qq|
| . $locale->text('Fax') . qq|| . $locale->text('Language') . qq|
| . $locale->text('Company') . qq|
| . $locale->text('Address') . qq|| . $locale->text('Stylesheet') . qq|
| . $locale->text('Date Format') . qq|| . $locale->text('Setup Menu') . qq| | . + $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('Output Number Format') . qq|
| . $locale->text("Print options") . qq|
| . $locale->text('Input Number Format') . qq|| . $locale->text('Default template format') . qq|
| . $locale->text('Dropdown Limit') . qq|| . $locale->text('Default output medium') . qq|
| . $locale->text('Language') . qq|| . $locale->text('Default printer') . qq|
| . $locale->text('Stylesheet') . qq|| . $locale->text('Number of copies') . qq|
| . $locale->text('Setup Menu') . qq| New -  Old
 
- - - - - -
| . $locale->text('Year End') . qq| (mm/dd) {defaults}{yearend}>| . $locale->text('Weight Unit') . qq|
-
| @@ -3076,40 +2740,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| @@ -3117,20 +2781,13 @@ sub config { -{path}> {login}> {password}>
|; - - if ($form->{menubar}) { - require "$form->{path}/menu.pl"; - &menubar; - } + . $locale->text('Save') . qq|"> - print qq| @@ -3154,26 +2811,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(); @@ -3194,7 +2831,6 @@ sub audit_control {
{script}> -{path}> {login}> {password}> @@ -3260,205 +2896,6 @@ sub doclose { $lxdebug->leave_sub(); } -sub add_warehouse { - $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(); - - $form->{title} = "Edit"; - - AM->get_warehouse(\%myconfig, \%$form); - - &warehouse_header; - &form_footer; - - $lxdebug->leave_sub(); -} - -sub list_warehouse { - $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||; - - map { print "$column_data{$_}\n" } @column_index; - - print qq| - -|; - } - - print qq| -
{script}?action=edit_warehouse&id=$ref->{id}&path=$form->{path}&login=$form->{login}&password=$form->{password}&callback=$callback>$ref->{description}
-

- -
-{script}> - - - - - -{path}> -{login}> -{password}> - -|; - - if ($form->{menubar}) { - require "$form->{path}/menu.pl"; - &menubar; - } - - print qq| -
- - - -|; - - $lxdebug->leave_sub(); -} - -sub warehouse_header { - $lxdebug->enter_sub(); - - $form->{title} = $locale->text("$form->{title} Warehouse"); - - # $locale->text('Add Warehouse') - # $locale->text('Edit Warehouse') - - $form->{description} =~ s/\"/"/g; - - if (($rows = $form->numtextrows($form->{description}, 60)) > 1) { - $description = - qq||; - } else { - $description = - qq||; - } - - $form->header; - - print qq| - - -
{script}> - -{id}> - - - - - - - - - - - - - - -
$form->{title}
| . $locale->text('Description') . qq|$description

-|; - - $lxdebug->leave_sub(); -} - -sub save_warehouse { - $lxdebug->enter_sub(); - - $form->isblank("description", $locale->text('Description missing!')); - AM->save_warehouse(\%myconfig, \%$form); - $form->redirect($locale->text('Warehouse saved!')); - - $lxdebug->leave_sub(); -} - -sub delete_warehouse { - $lxdebug->enter_sub(); - - AM->delete_warehouse(\%myconfig, \%$form); - $form->redirect($locale->text('Warehouse deleted!')); - - $lxdebug->leave_sub(); -} - -sub continue { - $lxdebug->enter_sub(); - - &{ $form->{nextsub} }; - - $lxdebug->leave_sub(); -} - sub edit_units { $lxdebug->enter_sub(); @@ -3466,20 +2903,38 @@ sub edit_units { AM->units_in_use(\%myconfig, $form, $units); map({ $units->{$_}->{"BASE_UNIT_DDBOX"} = AM->unit_select_data($units, $units->{$_}->{"base_unit"}, 1); } keys(%{$units})); - @unit_list = (); - foreach $name (sort({ lc($a) cmp lc($b) } grep({ !$units->{$_}->{"base_unit"} } keys(%{$units})))) { - map({ push(@unit_list, $units->{$_}); } - sort({ ($units->{$a}->{"resolved_factor"} * 1) <=> ($units->{$b}->{"resolved_factor"} * 1) } - grep({ $units->{$_}->{"resolved_base_unit"} eq $name } 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++; } - map({ $_->{"factor"} = $form->format_amount(\%myconfig, $_->{"factor"}, 5) if ($_->{"factor"}); } @unit_list); $units = AM->retrieve_units(\%myconfig, $form, $form->{"unit_type"}); $ddbox = AM->unit_select_data($units, undef, 1); + my $updownlink = build_std_url("action=swap_units", "unit_type"); + $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 })); + print($form->parse_html_template("am/edit_units", + { "UNITS" => \@unit_list, + "NEW_BASE_UNIT_DDBOX" => $ddbox, + "LANGUAGES" => \@languages, + "updownlink" => $updownlink })); $lxdebug->leave_sub(); } @@ -3489,7 +2944,8 @@ sub add_unit { $form->isblank("new_name", $locale->text("The name is missing.")); $units = AM->retrieve_units(\%myconfig, $form, $form->{"unit_type"}); - $form->show_generic_error($locale->text("A unit with this name does already exist.")) if ($units->{$form->{"new_name"}}); + $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"}}); my ($base_unit, $factor); if ($form->{"new_base_unit"}) { @@ -3501,7 +2957,16 @@ sub add_unit { $base_unit = $form->{"new_base_unit"}; } - AM->add_unit(\%myconfig, $form, $form->{"new_name"}, $base_unit, $factor, $form->{"unit_type"}); + 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}"}, + }); + } + + 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."); @@ -3510,12 +2975,32 @@ sub add_unit { $lxdebug->leave_sub(); } +sub set_unit_languages { + $lxdebug->enter_sub(); + + my ($unit, $languages, $idx) = @_; + + $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 save_unit { $lxdebug->enter_sub(); $old_units = AM->retrieve_units(\%myconfig, $form, $form->{"unit_type"}, "resolved_"); AM->units_in_use(\%myconfig, $form, $old_units); + @languages = AM->language(\%myconfig, $form, 1); + $new_units = {}; @delete_units = (); foreach $i (1..($form->{"rowcount"} * 1)) { @@ -3527,6 +3012,7 @@ sub save_unit { 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; } @@ -3545,6 +3031,7 @@ sub save_unit { 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); } foreach $unit (values(%{$new_units})) { @@ -3583,3 +3070,113 @@ sub save_unit { $lxdebug->leave_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(); +} + +sub show_am_history { + $lxdebug->enter_sub(); + my %search = ( "Artikelnummer" => "parts", + "Kundennummer" => "customer", + "Lieferantennummer" => "vendor", + "Projektnummer" => "project", + "Buchungsnummer" => "oe", + "Eingangsrechnungnummer" => "ap", + "Ausgangsrechnungnummer" => "ar" + ); + my %searchNo = ( "Artikelnummer" => "partnumber", + "Kundennummer" => "customernumber", + "Lieferantennummer" => "vendornumber", + "Projektnummer" => "projectnummer", + "Buchungsnummer" => "ordnumber", + "Eingangsrechnungnummer" => "invnumber", + "Ausgangsrechnungnummer" => "invnumber" + ); + + 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(); +} + +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 swap_units { + $lxdebug->enter_sub(); + + 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(); +}