Revision bce08af4
Von Sven Schöling vor fast 8 Jahren hinzugefügt
bin/mozilla/ic.pl | ||
---|---|---|
102 | 102 |
$lxdebug->leave_sub(); |
103 | 103 |
} #end search() |
104 | 104 |
|
105 |
sub search_update_prices { |
|
106 |
$lxdebug->enter_sub(); |
|
107 |
|
|
108 |
$auth->assert('part_service_assembly_edit'); |
|
109 |
|
|
110 |
my $pricegroups = IC->get_pricegroups(\%myconfig, \%$form); |
|
111 |
|
|
112 |
$form->{title} = $locale->text('Update Prices'); |
|
113 |
|
|
114 |
$form->header; |
|
115 |
|
|
116 |
print $form->parse_html_template('ic/search_update_prices', { PRICE_ROWS => $pricegroups }); |
|
117 |
|
|
118 |
$lxdebug->leave_sub(); |
|
119 |
} #end search() |
|
120 |
|
|
121 |
sub confirm_price_update { |
|
122 |
$lxdebug->enter_sub(); |
|
123 |
|
|
124 |
$auth->assert('part_service_assembly_edit'); |
|
125 |
|
|
126 |
my @errors = (); |
|
127 |
my $value_found = undef; |
|
128 |
|
|
129 |
foreach my $idx (qw(sellprice listprice), (1..$form->{price_rows})) { |
|
130 |
my $name = $idx =~ m/\d/ ? $form->{"pricegroup_${idx}"} : $idx eq 'sellprice' ? $locale->text('Sell Price') : $locale->text('List Price'); |
|
131 |
my $type = $idx =~ m/\d/ ? $form->{"pricegroup_type_${idx}"} : $form->{"${idx}_type"}; |
|
132 |
my $value_idx = $idx =~ m/\d/ ? "price_${idx}" : $idx; |
|
133 |
my $value = $form->parse_amount(\%myconfig, $form->{$value_idx}); |
|
134 |
|
|
135 |
if ((0 > $value) && ($type eq 'percent')) { |
|
136 |
push @errors, $locale->text('You cannot adjust the price for pricegroup "#1" by a negative percentage.', $name); |
|
137 |
|
|
138 |
} elsif (!$value && ($form->{$value_idx} ne '')) { |
|
139 |
push @errors, $locale->text('No valid number entered for pricegroup "#1".', $name); |
|
140 |
|
|
141 |
} elsif (0 < $value) { |
|
142 |
$value_found = 1; |
|
143 |
} |
|
144 |
} |
|
145 |
|
|
146 |
push @errors, $locale->text('No prices will be updated because no prices have been entered.') if (!$value_found); |
|
147 |
|
|
148 |
my $num_matches = IC->get_num_matches_for_priceupdate(); |
|
149 |
|
|
150 |
$form->header(); |
|
151 |
|
|
152 |
if (@errors) { |
|
153 |
$form->show_generic_error(join('<br>', @errors)); |
|
154 |
} |
|
155 |
|
|
156 |
$form->{nextsub} = "update_prices"; |
|
157 |
|
|
158 |
map { delete $form->{$_} } qw(action header); |
|
159 |
|
|
160 |
print $form->parse_html_template('ic/confirm_price_update', { HIDDENS => [ map { name => $_, value => $form->{$_} }, keys %$form ], |
|
161 |
num_matches => $num_matches }); |
|
162 |
|
|
163 |
$lxdebug->leave_sub(); |
|
164 |
} |
|
165 |
|
|
166 |
sub update_prices { |
|
167 |
$lxdebug->enter_sub(); |
|
168 |
|
|
169 |
$auth->assert('part_service_assembly_edit'); |
|
170 |
|
|
171 |
my $num_updated = IC->update_prices(\%myconfig, \%$form); |
|
172 |
|
|
173 |
if (-1 != $num_updated) { |
|
174 |
$form->redirect($locale->text('#1 prices were updated.', $num_updated)); |
|
175 |
} else { |
|
176 |
$form->error($locale->text('Could not update prices!')); |
|
177 |
} |
|
178 |
|
|
179 |
$lxdebug->leave_sub(); |
|
180 |
} |
|
181 |
|
|
182 | 105 |
sub top100 { |
183 | 106 |
$::lxdebug->enter_sub(); |
184 | 107 |
|
Auch abrufbar als: Unified diff
Preisupdate in eigenen controller verlagert
...und dabei das völlig kaputte Exceptionhandling gefixt