-
- |
- . $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}> |
@@ -3001,36 +2602,27 @@ 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();
}
-sub continue {
- $lxdebug->enter_sub();
-
- &{ $form->{nextsub} };
-
- $lxdebug->leave_sub();
-}
-
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}));
@@ -3054,18 +2646,18 @@ 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,
+ { "UNITS" => \@unit_list,
"NEW_BASE_UNIT_DDBOX" => $ddbox,
- "LANGUAGES" => \@languages,
- "updownlink" => $updownlink }));
+ "LANGUAGES" => \@languages,
+ "updownlink" => $updownlink }));
$lxdebug->leave_sub();
}
@@ -3073,8 +2665,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"}});
@@ -3097,7 +2691,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.");
@@ -3109,6 +2703,8 @@ sub add_unit {
sub set_unit_languages {
$lxdebug->enter_sub();
+ $auth->assert('config');
+
my ($unit, $languages, $idx) = @_;
$unit->{"LANGUAGES"} = [];
@@ -3127,7 +2723,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);
@@ -3193,7 +2791,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.");
@@ -3205,23 +2803,29 @@ sub save_unit {
sub show_history_search {
$lxdebug->enter_sub();
+ $auth->assert('config');
+
$form->{title} = $locale->text("History Search");
$form->header();
- print $form->parse_html_template("/common/search_history");
+ print $form->parse_html_template("common/search_history");
$lxdebug->leave_sub();
}
sub show_am_history {
$lxdebug->enter_sub();
+
+ $auth->assert('config');
+
my %search = ( "Artikelnummer" => "parts",
"Kundennummer" => "customer",
"Lieferantennummer" => "vendor",
"Projektnummer" => "project",
"Buchungsnummer" => "oe",
"Eingangsrechnungnummer" => "ap",
- "Ausgangsrechnungnummer" => "ar"
+ "Ausgangsrechnungnummer" => "ar",
+ "Mahnungsnummer" => "dunning"
);
my %searchNo = ( "Artikelnummer" => "partnumber",
"Kundennummer" => "customernumber",
@@ -3229,7 +2833,8 @@ sub show_am_history {
"Projektnummer" => "projectnummer",
"Buchungsnummer" => "ordnumber",
"Eingangsrechnungnummer" => "invnumber",
- "Ausgangsrechnungnummer" => "invnumber"
+ "Ausgangsrechnungnummer" => "invnumber",
+ "Mahnungsnummer" => "dunning_id"
);
my $restriction;
@@ -3243,7 +2848,6 @@ sub show_am_history {
$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 "")
@@ -3253,40 +2857,55 @@ sub show_am_history {
: ""
)
);
-
+ $restriction .= ($form->{mitarbeiter} eq "" ? ""
+ : ($form->{mitarbeiter} =~ /^[0-9]*$/
+ ? " AND employee_id = " . $form->{mitarbeiter}
+ : " AND employee_id = " . &get_employee_id($form->{mitarbeiter}, $dbh)));
+
my $dbh = $form->dbconnect(\%myconfig);
-
- $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 id FROM $search{$form->{what2search}}
- WHERE $searchNo{$form->{'what2search'}} ILIKE '$form->{"searchid"}'
- |;
-
- my $sth = $dbh->prepare($query);
+ my $query = qq|SELECT trans_id AS id FROM history_erp | .
+ ($form->{'searchid'} ?
+ qq| WHERE snumbers = '| . $searchNo{$form->{'what2search'}} . qq|_| . $form->{'searchid'} . qq|'| :
+ qq| WHERE snumbers ~ '^| . $searchNo{$form->{'what2search'}} . qq|'|);
+
+ my $sth = $dbh->prepare($query);
$sth->execute() || $form->dberror($query);
-
- $form->{title} = $locale->text("History Search");
+
+ $form->{title} = $locale->text("History Search");
$form->header();
- while(my $hash_ref = $sth->fetchrow_hashref()){
- print $form->parse_html_template("/common/show_history",
- {"DATEN" => $form->get_history($dbh,$hash_ref->{id},$restriction),
- "SUCCESS" => ($form->get_history($dbh,$hash_ref->{id},$restriction) != 0),
- "NONEWWINDOW" => "1"
- }
- );
- }
+ my $i = 1;
+ my $daten = qq||;
+ while(my $hash_ref = $sth->fetchrow_hashref()){
+ if($i) {
+ $daten .= $hash_ref->{id};
+ $i = 0;
+ }
+ else {
+ $daten .= " OR trans_id = " . $hash_ref->{id};
+ }
+ }
+
+ my ($sort, $sortby) = split(/\-\-/, $form->{order});
+ $sort =~ s/.*\.(.*)$/$1/;
+
+ print $form->parse_html_template("common/show_history",
+ {"DATEN" => $form->get_history($dbh, $daten, $restriction, $form->{order}),
+ "SUCCESS" => ($form->get_history($dbh, $daten, $restriction, $form->{order}) ne "0"),
+ "NONEWWINDOW" => 1,
+ uc($sort) => 1,
+ uc($sort)."BY" => $sortby
+ });
$dbh->disconnect();
-
- $lxdebug->leave_sub();
+ $lxdebug->leave_sub();
}
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);
@@ -3299,12 +2918,363 @@ 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();
$lxdebug->leave_sub();
-}
\ No newline at end of file
+}
+
+sub add_tax {
+ $lxdebug->enter_sub();
+
+ $auth->assert('config');
+
+ $form->{title} = $locale->text('Add');
+
+ $form->{callback} ||= "am.pl?action=add_tax";
+
+ _get_taxaccount_selection();
+
+ $form->header();
+
+ my $parameters_ref = {
+# ChartTypeIsAccount => $ChartTypeIsAccount,
+ };
+
+ # Ausgabe des Templates
+ print($form->parse_html_template('am/edit_tax', $parameters_ref));
+
+ $lxdebug->leave_sub();
+}
+
+sub edit_tax {
+ $lxdebug->enter_sub();
+
+ $auth->assert('config');
+
+ $form->{title} = $locale->text('Edit');
+
+ AM->get_tax(\%myconfig, \%$form);
+ _get_taxaccount_selection();
+
+ $form->{rate} = $form->format_amount(\%myconfig, $form->{rate}, 2);
+
+ $form->header();
+
+ my $parameters_ref = {
+ };
+
+ # Ausgabe des Templates
+ print($form->parse_html_template('am/edit_tax', $parameters_ref));
+
+ $lxdebug->leave_sub();
+}
+
+sub list_tax {
+ $lxdebug->enter_sub();
+
+ $auth->assert('config');
+
+ AM->taxes(\%myconfig, \%$form);
+
+ map { $_->{rate} = $form->format_amount(\%myconfig, $_->{rate}, 2) } @{ $form->{TAX} };
+
+ $form->{callback} = build_std_url('action=list_tax');
+
+ $form->{title} = $locale->text('Tax-O-Matic');
+
+ $form->header();
+
+ # Ausgabe des Templates
+ print($form->parse_html_template('am/list_tax', $parameters_ref));
+
+ $lxdebug->leave_sub();
+}
+
+sub _get_taxaccount_selection{
+ $lxdebug->enter_sub();
+
+ $auth->assert('config');
+
+ AM->get_tax_accounts(\%myconfig, \%$form);
+
+ map { $_->{selected} = $form->{chart_id} == $_->{id} } @{ $form->{ACCOUNTS} };
+
+ $lxdebug->leave_sub();
+}
+
+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!'));
+
+ $form->{rate} = $form->parse_amount(\%myconfig, $form->{rate});
+
+ if ( $form->{rate} < 0 || $form->{rate} >= 100 ) {
+ $form->error($locale->text('Tax Percent is a number between 0 and 100'));
+ }
+
+ if ( $form->{rate} <= 0.99 && $form->{rate} > 0 ) {
+ $form->error($locale->text('Tax Percent is a number between 0 and 100'));
+ }
+
+ AM->save_tax(\%myconfig, \%$form);
+ $form->redirect($locale->text('Tax saved!'));
+
+ $lxdebug->leave_sub();
+}
+
+sub delete_tax {
+ $lxdebug->enter_sub();
+
+ $auth->assert('config');
+
+ AM->delete_tax(\%myconfig, \%$form);
+ $form->redirect($locale->text('Tax deleted!'));
+
+ $lxdebug->leave_sub();
+}
+
+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';
+
+ $form->header();
+ print $form->parse_html_template('am/edit_price_factor');
+
+ $lxdebug->leave_sub();
+}
+
+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';
+
+ AM->get_price_factor(\%myconfig, $form);
+
+ $form->{factor} = $form->format_amount(\%myconfig, $form->{factor} * 1);
+
+ $form->header();
+ print $form->parse_html_template('am/edit_price_factor');
+
+ $lxdebug->leave_sub();
+}
+
+sub list_price_factors {
+ $lxdebug->enter_sub();
+
+ $auth->assert('config');
+
+ AM->get_all_price_factors(\%myconfig, \%$form);
+
+ my $previous;
+ foreach my $current (@{ $form->{PRICE_FACTORS} }) {
+ if ($previous) {
+ $previous->{next_id} = $current->{id};
+ $current->{previous_id} = $previous->{id};
+ }
+
+ $current->{factor} = $form->format_amount(\%myconfig, $current->{factor} * 1);
+
+ $previous = $current;
+ }
+
+ $form->{callback} = build_std_url('action=list_price_factors');
+ $form->{title} = $locale->text('Price Factors');
+ $form->{url_base} = build_std_url('callback');
+
+ $form->header();
+ print $form->parse_html_template('am/list_price_factors');
+
+ $lxdebug->leave_sub();
+}
+
+sub save_price_factor {
+ $lxdebug->enter_sub();
+
+ $auth->assert('config');
+
+ $form->isblank("description", $locale->text('Description missing!'));
+ $form->isblank("factor", $locale->text('Factor missing!'));
+
+ $form->{factor} = $form->parse_amount(\%myconfig, $form->{factor});
+
+ AM->save_price_factor(\%myconfig, $form);
+
+ $form->{callback} .= '&MESSAGE=' . $form->escape($locale->text('Price factor saved!')) if ($form->{callback});
+
+ $form->redirect($locale->text('Price factor saved!'));
+
+ $lxdebug->leave_sub();
+}
+
+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});
+
+ $form->redirect($locale->text('Price factor deleted!'));
+
+ $lxdebug->leave_sub();
+}
+
+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();
+}
+
|