X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;ds=inline;f=bin%2Fmozilla%2Fic.pl;h=faaa702dc0e196ca450db2d18267017e4c26cd2b;hb=1043d7f814fccf5864e677b1e38577d0a150026c;hp=e9b13a3271555b922cd99d808e8644106eb7cc68;hpb=83e061c063b3f6b9f34ee0c9b7ff5575362be9a4;p=kivitendo-erp.git
diff --git a/bin/mozilla/ic.pl b/bin/mozilla/ic.pl
index e9b13a327..faaa702dc 100644
--- a/bin/mozilla/ic.pl
+++ b/bin/mozilla/ic.pl
@@ -30,10 +30,13 @@
# Inventory Control module
#
#======================================================================
-#$locale->text('ea');
use POSIX qw(strftime);
+use List::Util qw(max);
+use List::MoreUtils qw(any);
+use SL::AM;
+use SL::CVar;
use SL::IC;
use SL::ReportGenerator;
@@ -43,7 +46,7 @@ use SL::ReportGenerator;
#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";
@@ -52,18 +55,32 @@ require "bin/mozilla/reportgenerator.pl";
1;
+# Parserhappy(R):
+# type=submit $locale->text('Add Part')
+# type=submit $locale->text('Add Service')
+# type=submit $locale->text('Add Assembly')
+# type=submit $locale->text('Edit Part')
+# type=submit $locale->text('Edit Service')
+# type=submit $locale->text('Edit Assembly')
+# $locale->text('Parts')
+# $locale->text('Services')
+# $locale->text('Inventory quantity must be zero before you can set this part obsolete!')
+# $locale->text('Inventory quantity must be zero before you can set this assembly obsolete!')
+# $locale->text('Part Number missing!')
+# $locale->text('Service Number missing!')
+# $locale->text('Assembly Number missing!')
+# $locale->text('ea');
+
# end of main
sub add {
$lxdebug->enter_sub();
- $form->{title} = $locale->text('Add ' . ucfirst $form->{item});
-
- $form->{callback} =
- "$form->{script}?action=add&item=$form->{item}&login=$form->{login}&password=$form->{password}"
- unless $form->{callback};
+ $auth->assert('part_service_assembly_edit');
- $form->{"unit_changeable"} = 1;
+ $form->{title} = $locale->text('Add ' . ucfirst $form->{item});
+ $form->{callback} = "$form->{script}?action=add&item=$form->{item}" unless $form->{callback};
+ $form->{unit_changeable} = 1;
IC->get_pricegroups(\%myconfig, \%$form);
&link_part;
@@ -75,32 +92,30 @@ sub add {
sub search {
$lxdebug->enter_sub();
- # switch for backward sorting
- $form->{revers} = 0;
-
- # memory for which table was sort at last time
- $form->{lastsort} = "";
-
- # counter for added entries to top100
- $form->{ndxs_counter} = 0;
+ $auth->assert('part_service_assembly_edit');
- # $locale->text('Parts')
- # $locale->text('Services')
+ $form->{revers} = 0; # switch for backward sorting
+ $form->{lastsort} = ""; # memory for which table was sort at last time
+ $form->{ndxs_counter} = 0; # counter for added entries to top100
- my $is_service = $form->{searchitems} eq 'service';
- my $is_assembly = $form->{searchitems} eq 'assembly';
+ my %is_xyz = map { +"is_$_" => ($form->{searchitems} eq $_) } qw(part service assembly);
$form->{title} = (ucfirst $form->{searchitems}) . "s";
$form->{title} = $locale->text($form->{title});
- $form->{title} = $locale->text('Assemblies') if $is_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;
- print $form->parse_html_template('ic/search', { is_assembly => $is_assembly,
- is_service => $is_service,
- dateformat => $myconfig{dateformat}, });
+ print $form->parse_html_template('ic/search', { %is_xyz,
+ dateformat => $myconfig{dateformat}, });
$lxdebug->leave_sub();
} #end search()
@@ -108,6 +123,8 @@ sub search {
sub search_update_prices {
$lxdebug->enter_sub();
+ $auth->assert('part_service_assembly_edit');
+
my $pricegroups = IC->get_pricegroups(\%myconfig, \%$form);
$form->header;
@@ -120,224 +137,263 @@ sub search_update_prices {
sub confirm_price_update {
$lxdebug->enter_sub();
- $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 ] });
-
- $lxdebug->leave_sub();
-}
-
-sub update_prices {
- $lxdebug->enter_sub();
-
- if (IC->update_prices(\%myconfig, \%$form)) {
- $form->redirect($form->{update_count} . $locale->text('prices updated!'));
- } else {
- $form->error($locale->text('Could not update prices!'));
- }
+ $auth->assert('part_service_assembly_edit');
- $lxdebug->leave_sub();
-}
-
-sub choice {
- $lxdebug->enter_sub();
+ my @errors = ();
+ my $value_found = undef;
- our ($j, $lastndx);
- my ($totop100);
+ 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});
- $form->{title} = $locale->text('Top 100 hinzufuegen');
+ if ((0 > $value) && ($type eq 'percent')) {
+ push @errors, $locale->text('You cannot adjust the price for pricegroup "#1" by a negative percentage.', $name);
- $form->header;
+ } elsif (!$value && ($form->{$value_idx} ne '')) {
+ push @errors, $locale->text('No valid number entered for pricegroup "#1".', $name);
- push @custom_hiddens, qw(login password searchitems title bom titel revers lastsort sort ndxs_counter extras);
- push @custom_hiddens, qw(itemstatus l_linetotal l_partnumber l_description l_onhand l_unit l_sellprice l_linetotalsellprice);
- my @HIDDENS = (
- +{ name => 'row', value => $j },
- +{ name => 'nextsub', value => 'item_selected' },
- +{ name => 'test', value => 'item_selected' },
- +{ name => 'lastndx', value => $lastndx },
- map(+{ name => $_, value => $form->{$_} }, @custom_hiddens),
- );
+ } elsif (0 < $value) {
+ $value_found = 1;
+ }
+ }
- my ($partnumber, $description, $unit, $sellprice, $soldtotal);
- # if choice set data
- if ($form->{ndx}) {
- for (my $i = 0; $i < $form->{ndxs_counter}; $i++) {
+ push @errors, $locale->text('No prices will be updated because no prices have been entered.') if (!$value_found);
- # prepeare data
- $partnumber = $form->{"totop100_partnumber_$j"};
- $description = $form->{"totop100_description_$j"};
- $unit = $form->{"totop100_unit_$j"};
- $sellprice = $form->{"totop100_sellprice_$j"};
- $soldtotal = $form->{"totop100_soldtotal_$j"};
+ my $num_matches = IC->get_num_matches_for_priceupdate();
- # insert data into top100
- push @{ $form->{parts} },
- { number => "",
- partnumber => "$partnumber",
- description => "$description",
- unit => "$unit",
- sellprice => "$sellprice",
- soldtotal => "$soldtotal" };
- } #rof
- } #fi
+ $form->header();
- $totop100 = "";
+ if (@errors) {
+ $form->show_generic_error(join('
', @errors), 'back_button' => 1);
+ }
- # set data for next page
- if (($form->{ndxs_counter}) > 0) {
- for (my $i = 1; ($i < $form->{ndxs_counter} + 1); $i++) {
- $partnumber = $form->{"totop100_partnumber_$i"};
- $description = $form->{"totop100_description_$i"};
- $unit = $form->{"totop100_unit_$i"};
- $sellprice = $form->{"totop100_sellprice_$i"};
- $soldtotal = $form->{"totop100_soldtotal_$i"};
+ $form->{nextsub} = "update_prices";
- $totop100 .= qq|
-{"totop100_partnumber_$i"}>
-{"totop100_description_$i"}>
-{"totop100_unit_$i"}>
-{"totop100_sellprice_$i"}>
-{"totop100_soldtotal_$i"}>
- |;
- } #rof
- } #fi
+ map { delete $form->{$_} } qw(action header);
- print $form->parse_html_template('ic/choice', +{ HIDDENS => \@HIDDENS, totop100 => $totop100 });
+ print $form->parse_html_template('ic/confirm_price_update', { HIDDENS => [ map { name => $_, value => $form->{$_} }, keys %$form ],
+ num_matches => $num_matches });
$lxdebug->leave_sub();
-} #end choice
+}
-sub list {
+sub update_prices {
$lxdebug->enter_sub();
- our ($lastndx);
- our ($partnumber, $description, $unit, $sellprice, $soldtotal);
-
- my @sortorders = ("", "partnumber", "description", "all");
- my $sortorder = $sortorders[($form->{description} ? 2 : 0) + ($form->{partnumber} ? 1 : 0)];
- IC->get_parts(\%myconfig, \%$form, $sortorder);
-
- $form->{title} = $locale->text('Top 100 hinzufuegen');
-
- $form->header;
-
- print qq|
-