-
- |
- . $locale->text('Enforce transaction reversal for all dates') . qq|
- | |
- . $locale->text('Yes')
- . qq| |
- . $locale->text('No')
- . qq| |
-
| . $locale->text('Close Books up to') . qq| |
{closedto}> |
@@ -2528,19 +2566,16 @@ sub audit_control {
sub doclose {
$lxdebug->enter_sub();
+ $auth->assert('config');
+
AM->closebooks(\%myconfig, \%$form);
- if ($form->{revtrans}) {
+ if ($form->{closedto}) {
$form->redirect(
- $locale->text('Transaction reversal enforced for all dates'));
+ $locale->text('Books closed up to') . " "
+ . $locale->date(\%myconfig, $form->{closedto}, 1));
} else {
- if ($form->{closedto}) {
- $form->redirect(
- $locale->text('Transaction reversal enforced up to') . " "
- . $locale->date(\%myconfig, $form->{closedto}, 1));
- } else {
- $form->redirect($locale->text('Books are open'));
- }
+ $form->redirect($locale->text('Books are open'));
}
$lxdebug->leave_sub();
@@ -2549,7 +2584,9 @@ sub doclose {
sub edit_units {
$lxdebug->enter_sub();
- $units = AM->retrieve_units(\%myconfig, $form, $form->{"unit_type"}, "resolved_");
+ $auth->assert('config');
+
+ $units = AM->retrieve_units(\%myconfig, $form, "resolved_");
AM->units_in_use(\%myconfig, $form, $units);
map({ $units->{$_}->{"BASE_UNIT_DDBOX"} = AM->unit_select_data($units, $units->{$_}->{"base_unit"}, 1); } keys(%{$units}));
@@ -2573,12 +2610,12 @@ sub edit_units {
$i++;
}
- $units = AM->retrieve_units(\%myconfig, $form, $form->{"unit_type"});
+ $units = AM->retrieve_units(\%myconfig, $form);
$ddbox = AM->unit_select_data($units, undef, 1);
- my $updownlink = build_std_url("action=swap_units", "unit_type");
+ my $updownlink = build_std_url("action=swap_units");
- $form->{"title"} = sprintf($locale->text("Add and edit %s"), $form->{"unit_type"} eq "dimension" ? $locale->text("dimension units") : $locale->text("service units"));
+ $form->{"title"} = $locale->text("Add and edit units");
$form->header();
print($form->parse_html_template("am/edit_units",
{ "UNITS" => \@unit_list,
@@ -2592,8 +2629,10 @@ sub edit_units {
sub add_unit {
$lxdebug->enter_sub();
+ $auth->assert('config');
+
$form->isblank("new_name", $locale->text("The name is missing."));
- $units = AM->retrieve_units(\%myconfig, $form, $form->{"unit_type"});
+ $units = AM->retrieve_units(\%myconfig, $form);
$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"}});
@@ -2616,7 +2655,7 @@ sub add_unit {
});
}
- AM->add_unit(\%myconfig, $form, $form->{"new_name"}, $base_unit, $factor, $form->{"unit_type"}, \@languages);
+ AM->add_unit(\%myconfig, $form, $form->{"new_name"}, $base_unit, $factor, \@languages);
$form->{"saved_message"} = $locale->text("The unit has been saved.");
@@ -2628,6 +2667,8 @@ sub add_unit {
sub set_unit_languages {
$lxdebug->enter_sub();
+ $auth->assert('config');
+
my ($unit, $languages, $idx) = @_;
$unit->{"LANGUAGES"} = [];
@@ -2646,7 +2687,9 @@ sub set_unit_languages {
sub save_unit {
$lxdebug->enter_sub();
- $old_units = AM->retrieve_units(\%myconfig, $form, $form->{"unit_type"}, "resolved_");
+ $auth->assert('config');
+
+ $old_units = AM->retrieve_units(\%myconfig, $form, "resolved_");
AM->units_in_use(\%myconfig, $form, $old_units);
@languages = AM->language(\%myconfig, $form, 1);
@@ -2712,7 +2755,7 @@ sub save_unit {
}
}
- AM->save_units(\%myconfig, $form, $form->{"unit_type"}, $new_units, \@delete_units);
+ AM->save_units(\%myconfig, $form, $new_units, \@delete_units);
$form->{"saved_message"} = $locale->text("The units have been saved.");
@@ -2724,6 +2767,8 @@ sub save_unit {
sub show_history_search {
$lxdebug->enter_sub();
+ $auth->assert('config');
+
$form->{title} = $locale->text("History Search");
$form->header();
@@ -2734,6 +2779,9 @@ sub show_history_search {
sub show_am_history {
$lxdebug->enter_sub();
+
+ $auth->assert('config');
+
my %search = ( "Artikelnummer" => "parts",
"Kundennummer" => "customer",
"Lieferantennummer" => "vendor",
@@ -2819,6 +2867,9 @@ sub show_am_history {
sub get_employee_id {
$lxdebug->enter_sub();
+
+ $auth->assert('config');
+
my $query = qq|SELECT id FROM employee WHERE name = '| . $_[0] . qq|'|;
my $sth = $_[1]->prepare($query);
$sth->execute() || $form->dberror($query);
@@ -2831,10 +2882,10 @@ sub get_employee_id {
sub swap_units {
$lxdebug->enter_sub();
+ $auth->assert('config');
+
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);
+ AM->swap_units(\%myconfig, $form, $dir, $form->{"name"});
edit_units();
@@ -2844,11 +2895,11 @@ sub swap_units {
sub add_tax {
$lxdebug->enter_sub();
+ $auth->assert('config');
+
$form->{title} = $locale->text('Add');
- $form->{callback} =
- "$form->{script}?action=add_tax&login=$form->{login}&password=$form->{password}"
- unless $form->{callback};
+ $form->{callback} ||= "am.pl?action=add_tax";
_get_taxaccount_selection();
@@ -2867,6 +2918,8 @@ sub add_tax {
sub edit_tax {
$lxdebug->enter_sub();
+ $auth->assert('config');
+
$form->{title} = $locale->text('Edit');
AM->get_tax(\%myconfig, \%$form);
@@ -2888,6 +2941,8 @@ sub edit_tax {
sub list_tax {
$lxdebug->enter_sub();
+ $auth->assert('config');
+
AM->taxes(\%myconfig, \%$form);
map { $_->{rate} = $form->format_amount(\%myconfig, $_->{rate}, 2) } @{ $form->{TAX} };
@@ -2907,6 +2962,8 @@ sub list_tax {
sub _get_taxaccount_selection{
$lxdebug->enter_sub();
+ $auth->assert('config');
+
AM->get_tax_accounts(\%myconfig, \%$form);
map { $_->{selected} = $form->{chart_id} == $_->{id} } @{ $form->{ACCOUNTS} };
@@ -2917,6 +2974,8 @@ sub _get_taxaccount_selection{
sub save_tax {
$lxdebug->enter_sub();
+ $auth->assert('config');
+
$form->isblank("rate", $locale->text('Taxrate missing!'));
$form->isblank("taxdescription", $locale->text('Taxdescription missing!'));
$form->isblank("taxkey", $locale->text('Taxkey missing!'));
@@ -2940,6 +2999,8 @@ sub save_tax {
sub delete_tax {
$lxdebug->enter_sub();
+ $auth->assert('config');
+
AM->delete_tax(\%myconfig, \%$form);
$form->redirect($locale->text('Tax deleted!'));
@@ -2949,6 +3010,8 @@ sub delete_tax {
sub add_price_factor {
$lxdebug->enter_sub();
+ $auth->assert('config');
+
$form->{title} = $locale->text('Add Price Factor');
$form->{callback} ||= build_std_url('action=add_price_factor');
$form->{fokus} = 'description';
@@ -2962,6 +3025,8 @@ sub add_price_factor {
sub edit_price_factor {
$lxdebug->enter_sub();
+ $auth->assert('config');
+
$form->{title} = $locale->text('Edit Price Factor');
$form->{callback} ||= build_std_url('action=add_price_factor');
$form->{fokus} = 'description';
@@ -2979,6 +3044,8 @@ sub edit_price_factor {
sub list_price_factors {
$lxdebug->enter_sub();
+ $auth->assert('config');
+
AM->get_all_price_factors(\%myconfig, \%$form);
my $previous;
@@ -3006,6 +3073,8 @@ sub list_price_factors {
sub save_price_factor {
$lxdebug->enter_sub();
+ $auth->assert('config');
+
$form->isblank("description", $locale->text('Description missing!'));
$form->isblank("factor", $locale->text('Factor missing!'));
@@ -3023,6 +3092,8 @@ sub save_price_factor {
sub delete_price_factor {
$lxdebug->enter_sub();
+ $auth->assert('config');
+
AM->delete_price_factor(\%myconfig, \%$form);
$form->{callback} .= '&MESSAGE=' . $form->escape($locale->text('Price factor deleted!')) if ($form->{callback});
@@ -3035,9 +3106,139 @@ sub delete_price_factor {
sub swap_price_factors {
$lxdebug->enter_sub();
+ $auth->assert('config');
+
AM->swap_sortkeys(\%myconfig, $form, 'price_factors');
list_price_factors();
$lxdebug->leave_sub();
}
+sub add_warehouse {
+ $lxdebug->enter_sub();
+
+ $auth->assert('config');
+
+ $form->{title} = $locale->text('Add Warehouse');
+ $form->{callback} ||= build_std_url('action=add_warehouse');
+ $form->{fokus} = 'description';
+
+ $form->header();
+ print $form->parse_html_template('am/edit_warehouse');
+
+ $lxdebug->leave_sub();
+}
+
+sub edit_warehouse {
+ $lxdebug->enter_sub();
+
+ $auth->assert('config');
+
+ AM->get_warehouse(\%myconfig, $form);
+
+ $form->get_lists('employees' => 'EMPLOYEES');
+
+ $form->{title} = $locale->text('Edit Warehouse');
+ $form->{callback} ||= build_std_url('action=list_warehouses');
+ $form->{fokus} = 'description';
+
+ $form->header();
+ print $form->parse_html_template('am/edit_warehouse');
+
+ $lxdebug->leave_sub();
+}
+
+sub list_warehouses {
+ $lxdebug->enter_sub();
+
+ $auth->assert('config');
+
+ AM->get_all_warehouses(\%myconfig, $form);
+
+ my $previous;
+ foreach my $current (@{ $form->{WAREHOUSES} }) {
+ if ($previous) {
+ $previous->{next_id} = $current->{id};
+ $current->{previous_id} = $previous->{id};
+ }
+
+ $previous = $current;
+ }
+
+ $form->{callback} = build_std_url('action=list_warehouses');
+ $form->{title} = $locale->text('Warehouses');
+ $form->{url_base} = build_std_url('callback');
+
+ $form->header();
+ print $form->parse_html_template('am/list_warehouses');
+
+ $lxdebug->leave_sub();
+}
+
+sub save_warehouse {
+ $lxdebug->enter_sub();
+
+ $auth->assert('config');
+
+ $form->isblank("description", $locale->text('Description missing!'));
+
+ $form->{number_of_new_bins} = $form->parse_amount(\%myconfig, $form->{number_of_new_bins});
+
+ AM->save_warehouse(\%myconfig, $form);
+
+ $form->{callback} .= '&saved_message=' . E($locale->text('Warehouse saved.')) if ($form->{callback});
+
+ $form->redirect($locale->text('Warehouse saved.'));
+
+ $lxdebug->leave_sub();
+}
+
+sub swap_warehouses {
+ $lxdebug->enter_sub();
+
+ $auth->assert('config');
+
+ AM->swap_sortkeys(\%myconfig, $form, 'warehouse');
+ list_warehouses();
+
+ $lxdebug->leave_sub();
+}
+
+sub delete_warehouse {
+ $lxdebug->enter_sub();
+
+ $auth->assert('config');
+
+ if (!$form->{confirmed}) {
+ $form->{title} = $locale->text('Confirmation');
+
+ $form->header();
+ print $form->parse_html_template('am/confirm_delete_warehouse');
+ exit 0;
+ }
+
+ if (AM->delete_warehouse(\%myconfig, $form)) {
+ $form->{callback} .= '&saved_message=' . E($locale->text('Warehouse deleted.')) if ($form->{callback});
+ $form->redirect($locale->text('Warehouse deleted.'));
+
+ } else {
+ $form->error($locale->text('The warehouse could not be deleted because it has already been used.'));
+ }
+
+ $lxdebug->leave_sub();
+}
+
+sub save_bin {
+ $lxdebug->enter_sub();
+
+ $auth->assert('config');
+
+ AM->save_bins(\%myconfig, $form);
+
+ $form->{callback} .= '&saved_message=' . E($locale->text('Bins saved.')) if ($form->{callback});
+
+ $form->redirect($locale->text('Bins saved.'));
+
+ $lxdebug->leave_sub();
+}
+
|