X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;f=bin%2Fmozilla%2Fic.pl;h=3434861c128366af5604344e5d3912f3a54f21c5;hb=8bde65163db8c36ffa5e83bed7ee68ab859c106d;hp=195a72cfb8c593da3c6f0a777e318d6d8b4ffe31;hpb=4bbf708cfb8324cbad57b0a379d0489124aad132;p=kivitendo-erp.git
diff --git a/bin/mozilla/ic.pl b/bin/mozilla/ic.pl
index 195a72cfb..3434861c1 100644
--- a/bin/mozilla/ic.pl
+++ b/bin/mozilla/ic.pl
@@ -32,18 +32,22 @@
#======================================================================
use POSIX qw(strftime);
-use List::Util qw(max);
+use List::Util qw(first max);
+use List::MoreUtils qw(any);
+use SL::AM;
+use SL::CVar;
use SL::IC;
+use SL::Helper::Flash;
use SL::ReportGenerator;
#use SL::PE;
-# use strict;
+use strict;
#use warnings;
# global imports
-our ($form, $locale, %myconfig, $lxdebug);
+our ($form, $locale, %myconfig, $lxdebug, $auth);
require "bin/mozilla/io.pl";
require "bin/mozilla/invoice_io.pl";
@@ -75,7 +79,8 @@ sub add {
$auth->assert('part_service_assembly_edit');
- $form->{title} = $locale->text('Add ' . ucfirst $form->{item});
+ my $title = 'Add ' . ucfirst $form->{item};
+ $form->{title} = $locale->text($title);
$form->{callback} = "$form->{script}?action=add&item=$form->{item}" unless $form->{callback};
$form->{unit_changeable} = 1;
@@ -99,14 +104,20 @@ sub search {
$form->{title} = (ucfirst $form->{searchitems}) . "s";
$form->{title} = $locale->text($form->{title});
- $form->{title} = $locale->text('Assemblies') if ($is_xyz{assembly});
+ $form->{title} = $locale->text('Assemblies') if ($is_xyz{is_assembly});
- $form->{jsscript} = 1;
+ $form->{CUSTOM_VARIABLES} = CVar->get_configs('module' => 'IC');
+ ($form->{CUSTOM_VARIABLES_FILTER_CODE},
+ $form->{CUSTOM_VARIABLES_INCLUSION_CODE}) = CVar->render_search_options('variables' => $form->{CUSTOM_VARIABLES},
+ 'include_prefix' => 'l_',
+ 'include_value' => 'Y');
$form->header;
+ $form->get_lists('partsgroup' => 'ALL_PARTSGROUPS');
print $form->parse_html_template('ic/search', { %is_xyz,
- dateformat => $myconfig{dateformat}, });
+ dateformat => $myconfig{dateformat},
+ limit => $myconfig{vclimit}, });
$lxdebug->leave_sub();
} #end search()
@@ -118,6 +129,8 @@ sub search_update_prices {
my $pricegroups = IC->get_pricegroups(\%myconfig, \%$form);
+ $form->{title} = $locale->text('Update Prices');
+
$form->header;
print $form->parse_html_template('ic/search_update_prices', { PRICE_ROWS => $pricegroups });
@@ -130,12 +143,42 @@ sub confirm_price_update {
$auth->assert('part_service_assembly_edit');
+ my @errors = ();
+ my $value_found = undef;
+
+ foreach my $idx (qw(sellprice listprice), (1..$form->{price_rows})) {
+ my $name = $idx =~ m/\d/ ? $form->{"pricegroup_${idx}"} : $idx eq 'sellprice' ? $locale->text('Sell Price') : $locale->text('List Price');
+ my $type = $idx =~ m/\d/ ? $form->{"pricegroup_type_${idx}"} : $form->{"${idx}_type"};
+ my $value_idx = $idx =~ m/\d/ ? "price_${idx}" : $idx;
+ my $value = $form->parse_amount(\%myconfig, $form->{$value_idx});
+
+ if ((0 > $value) && ($type eq 'percent')) {
+ push @errors, $locale->text('You cannot adjust the price for pricegroup "#1" by a negative percentage.', $name);
+
+ } elsif (!$value && ($form->{$value_idx} ne '')) {
+ push @errors, $locale->text('No valid number entered for pricegroup "#1".', $name);
+
+ } elsif (0 < $value) {
+ $value_found = 1;
+ }
+ }
+
+ push @errors, $locale->text('No prices will be updated because no prices have been entered.') if (!$value_found);
+
+ my $num_matches = IC->get_num_matches_for_priceupdate();
+
+ $form->header();
+
+ if (@errors) {
+ $form->show_generic_error(join('
', @errors), 'back_button' => 1);
+ }
+
$form->{nextsub} = "update_prices";
- $form->header;
map { delete $form->{$_} } qw(action header);
- print $form->parse_html_template('ic/confirm_price_update', { HIDDENS => [ map { name => $_, value => $form->{$_} }, keys %$form ] });
+ print $form->parse_html_template('ic/confirm_price_update', { HIDDENS => [ map { name => $_, value => $form->{$_} }, keys %$form ],
+ num_matches => $num_matches });
$lxdebug->leave_sub();
}
@@ -145,8 +188,10 @@ sub update_prices {
$auth->assert('part_service_assembly_edit');
- if (IC->update_prices(\%myconfig, \%$form)) {
- $form->redirect($form->{update_count} . $locale->text('prices updated!'));
+ my $num_updated = IC->update_prices(\%myconfig, \%$form);
+
+ if (-1 != $num_updated) {
+ $form->redirect($locale->text('#1 prices were updated.', $num_updated));
} else {
$form->error($locale->text('Could not update prices!'));
}
@@ -242,21 +287,20 @@ sub update_prices {
# $form->header;
#
# print qq|
-#