Revision 91ab1ef6
Von Sven Schöling vor etwa 17 Jahren hinzugefügt
bin/mozilla/invoice_io.pl | ||
---|---|---|
90 | 90 |
# Eintrag fuer Version 2.2.0 geaendert # |
91 | 91 |
# neue Optik im Rechnungsformular # |
92 | 92 |
######################################## |
93 |
sub display_row { |
|
94 |
$lxdebug->enter_sub(); |
|
95 |
my $numrows = shift; |
|
96 |
|
|
97 |
my $is_sales = |
|
98 |
(substr($form->{type}, 0, 6) eq "sales_") |
|
99 |
|| (($form->{type} eq "invoice") && ($form->{script} eq "is.pl")) |
|
100 |
|| ($form->{type} eq 'credit_note'); |
|
101 |
|
|
102 |
if ($lizenzen && $form->{vc} eq "customer") { |
|
103 |
if ($form->{type} =~ /sales_order/) { |
|
104 |
@column_index = (runningnumber, partnumber, description, ship, qty); |
|
105 |
} elsif ($form->{type} =~ /sales_quotation/) { |
|
106 |
@column_index = (runningnumber, partnumber, description, qty); |
|
107 |
} else { |
|
108 |
@column_index = (runningnumber, partnumber, description, qty); |
|
109 |
} |
|
110 |
} else { |
|
111 |
if ( ($form->{type} =~ /purchase_order/) |
|
112 |
|| ($form->{type} =~ /sales_order/)) { |
|
113 |
@column_index = (runningnumber, partnumber, description, ship, qty); |
|
114 |
} else { |
|
115 |
@column_index = (runningnumber, partnumber, description, qty); |
|
116 |
} |
|
117 |
} |
|
118 |
############## ENDE Neueintrag ################## |
|
119 |
|
|
120 |
my $dimension_units = AM->retrieve_units(\%myconfig, $form, "dimension"); |
|
121 |
my $service_units = AM->retrieve_units(\%myconfig, $form, "service"); |
|
122 |
my $all_units = AM->retrieve_units(\%myconfig, $form); |
|
123 |
|
|
124 |
my %price_factors = map { $_->{id} => $_->{factor} } @{ $form->{ALL_PRICE_FACTORS} }; |
|
125 |
|
|
126 |
push @column_index, qw(unit); |
|
127 |
|
|
128 |
#for pricegroups column |
|
129 |
if ( $form->{type} =~ (/sales_quotation/) |
|
130 |
or (($form->{level} =~ /Sales/) and ($form->{type} =~ /invoice/)) |
|
131 |
or (($form->{level} eq undef) and ($form->{type} =~ /invoice/)) |
|
132 |
or ($form->{type} =~ /sales_order/)) { |
|
133 |
push @column_index, qw(sellprice_pg); |
|
134 |
} |
|
135 |
|
|
136 |
push @column_index, qw(sellprice); |
|
137 |
|
|
138 |
if ($form->{vc} eq 'customer') { |
|
139 |
push @column_index, qw(discount); |
|
140 |
} |
|
141 |
|
|
142 |
push @column_index, "linetotal"; |
|
143 |
|
|
144 |
my $colspan = $#column_index + 1; |
|
145 |
|
|
146 |
$form->{invsubtotal} = 0; |
|
147 |
map { $form->{"${_}_base"} = 0 } (split(/ /, $form->{taxaccounts})); |
|
148 |
|
|
149 |
######################################## |
|
150 |
# Eintrag fuer Version 2.2.0 geaendert # |
|
151 |
# neue Optik im Rechnungsformular # |
|
152 |
######################################## |
|
153 |
$column_data{runningnumber} = qq|<th align="left" nowrap width="5%" class="listheading">| . $locale->text('No.') . qq|</th>|; |
|
154 |
$column_data{partnumber} = qq|<th align="left" nowrap width="12%" class="listheading">| . $locale->text('Number') . qq|</th>|; |
|
155 |
$column_data{description} = qq|<th align="left" nowrap width="30%" class="listheading">| . $locale->text('Part Description') . qq|</th>|; |
|
156 |
if ($form->{"type"} eq "purchase_order") { |
|
157 |
$column_data{ship} = qq|<th align="left" nowrap width="5%" class="listheading">| . $locale->text('Ship rcvd') . qq|</th>|; |
|
158 |
} else { |
|
159 |
$column_data{ship} = qq|<th align="left" nowrap width="5%" class="listheading">| . $locale->text('Ship') . qq|</th>|; |
|
160 |
} |
|
161 |
$column_data{qty} = qq|<th align="left" nowrap width="5%" class="listheading">| . $locale->text('Qty') . qq|</th>|; |
|
162 |
$column_data{unit} = qq|<th align="left" nowrap width="20%" class="listheading">| . $locale->text('Unit') . qq|</th>|; |
|
163 |
$column_data{license} = qq|<th align="left" nowrap width="10%" class="listheading">| . $locale->text('License') . qq|</th>|; |
|
164 |
$column_data{serialnr} = qq|<th align="left" nowrap width="10%" class="listheading">| . $locale->text('Serial No.') . qq|</th>|; |
|
165 |
$column_data{projectnr} = qq|<th align="left" nowrap width="10%" class="listheading">| . $locale->text('Project') . qq|</th>|; |
|
166 |
$column_data{sellprice} = qq|<th align="left" nowrap width="15%" class="listheading">| . $locale->text('Price') . qq|</th>|; |
|
167 |
$column_data{sellprice_pg} = qq|<th align="left" nowrap width="15%" class="listheading">| . $locale->text('Pricegroup') . qq|</th>|; |
|
168 |
$column_data{discount} = qq|<th align="left" nowrap width="5%" class="listheading">| . $locale->text('Discount') . qq|</th>|; |
|
169 |
$column_data{linetotal} = qq|<th align="left" nowrap width="10%" class="listheading">| . $locale->text('Extended') . qq|</th>|; |
|
170 |
$column_data{bin} = qq|<th align="left" nowrap width="10%" class="listheading">| . $locale->text('Bin') . qq|</th>|; |
|
171 |
############## ENDE Neueintrag ################## |
|
172 |
|
|
173 |
$myconfig{"show_form_details"} = 1 |
|
174 |
unless (defined($myconfig{"show_form_details"})); |
|
175 |
$form->{"show_details"} = $myconfig{"show_form_details"} |
|
176 |
unless (defined($form->{"show_details"})); |
|
177 |
$form->{"show_details"} = $form->{"show_details"} ? 1 : 0; |
|
178 |
my $show_details_new = 1 - $form->{"show_details"}; |
|
179 |
my $show_details_checked = $form->{"show_details"} ? "checked" : ""; |
|
180 |
|
|
181 |
print qq| |
|
182 |
<tr> |
|
183 |
<td>| . $cgi->hidden("-name" => "show_details", "-value" => $form->{show_details}) . qq| |
|
184 |
<input type="checkbox" id="cb_show_details" onclick="show_form_details($show_details_new);" $show_details_checked> |
|
185 |
<label for="cb_show_details">| . $locale->text("Show details") . qq|</label><br> |
|
186 |
<table width="100%"> |
|
187 |
<tr class="listheading">|; |
|
188 |
|
|
189 |
map { print "\n$column_data{$_}" } @column_index; |
|
190 |
|
|
191 |
print qq| |
|
192 |
</tr> |
|
193 |
|; |
|
194 |
|
|
195 |
$runningnumber = $locale->text('No.'); |
|
196 |
$deliverydate = $locale->text('Delivery Date'); |
|
197 |
$serialnumber = $locale->text('Serial No.'); |
|
198 |
$projectnumber = $locale->text('Project'); |
|
199 |
$partsgroup = $locale->text('Group'); |
|
200 |
$reqdate = $locale->text('Reqdate'); |
|
201 |
|
|
202 |
$delvar = 'deliverydate'; |
|
203 |
|
|
204 |
if ($form->{type} =~ /_order$/ || $form->{type} =~ /_quotation$/) { |
|
205 |
$deliverydate = $locale->text('Required by'); |
|
206 |
$delvar = 'reqdate'; |
|
207 |
} |
|
208 |
|
|
209 |
$form->{marge_total} = 0; |
|
210 |
$form->{sellprice_total} = 0; |
|
211 |
$form->{lastcost_total} = 0; |
|
212 |
my %projectnumber_labels = (); |
|
213 |
my @projectnumber_values = (""); |
|
214 |
foreach my $item (@{ $form->{"ALL_PROJECTS"} }) { |
|
215 |
push(@projectnumber_values, $item->{"id"}); |
|
216 |
$projectnumber_labels{$item->{"id"}} = $item->{"projectnumber"}; |
|
217 |
} |
|
218 |
|
|
219 |
for $i (1 .. $numrows) { |
|
220 |
|
|
221 |
# undo formatting |
|
222 |
map { |
|
223 |
$form->{"${_}_$i"} = |
|
224 |
$form->parse_amount(\%myconfig, $form->{"${_}_$i"}) |
|
225 |
} qw(qty ship discount sellprice price_new price_old) unless ($form->{simple_save}); |
|
226 |
|
|
227 |
if (!$form->{"unit_old_$i"}) { |
|
228 |
# Neue Ware aus der Datenbank. In diesem Fall ist unit_$i die |
|
229 |
# Einheit, wie sie in den Stammdaten hinterlegt wurde. |
|
230 |
# Es sollte also angenommen werden, dass diese ausgewaehlt war. |
|
231 |
$form->{"unit_old_$i"} = $form->{"unit_$i"}; |
|
232 |
} |
|
233 |
|
|
234 |
# Die zuletzt ausgewaehlte mit der aktuell ausgewaehlten Einheit |
|
235 |
# vergleichen und bei Unterschied den Preis entsprechend umrechnen. |
|
236 |
$form->{"selected_unit_$i"} = $form->{"unit_$i"} unless ($form->{"selected_unit_$i"}); |
|
237 |
|
|
238 |
my $check_units = $form->{"inventory_accno_$i"} ? $dimension_units : $service_units; |
|
239 |
if (!$check_units->{$form->{"selected_unit_$i"}} || |
|
240 |
($check_units->{$form->{"selected_unit_$i"}}->{"base_unit"} ne |
|
241 |
$all_units->{$form->{"unit_old_$i"}}->{"base_unit"})) { |
|
242 |
# Die ausgewaehlte Einheit ist fuer diesen Artikel nicht gueltig |
|
243 |
# (z.B. Dimensionseinheit war ausgewaehlt, es handelt sich aber |
|
244 |
# um eine Dienstleistung). Dann keinerlei Umrechnung vornehmen. |
|
245 |
$form->{"unit_old_$i"} = $form->{"selected_unit_$i"} = $form->{"unit_$i"}; |
|
246 |
} |
|
247 |
if ((!$form->{"prices_$i"}) || ($form->{"new_pricegroup_$i"} == $form->{"old_pricegroup_$i"})) { |
|
248 |
if ($form->{"unit_old_$i"} ne $form->{"selected_unit_$i"}) { |
|
249 |
my $basefactor = 1; |
|
250 |
if (defined($all_units->{$form->{"unit_old_$i"}}->{"factor"}) && |
|
251 |
$all_units->{$form->{"unit_old_$i"}}->{"factor"}) { |
|
252 |
$basefactor = $all_units->{$form->{"selected_unit_$i"}}->{"factor"} / |
|
253 |
$all_units->{$form->{"unit_old_$i"}}->{"factor"}; |
|
254 |
} |
|
255 |
$form->{"sellprice_$i"} *= $basefactor; |
|
256 |
$form->{"unit_old_$i"} = $form->{"selected_unit_$i"}; |
|
257 |
} |
|
258 |
} |
|
259 |
|
|
260 |
($dec) = ($form->{"sellprice_$i"} =~ /\.(\d+)/); |
|
261 |
$decimalplaces = max length($dec), 2; |
|
262 |
|
|
263 |
$price_factor = $price_factors{$form->{"price_factor_id_$i"}} || 1; |
|
264 |
$discount = (100 - $form->{"discount_$i"} * 1) / 100; |
|
265 |
|
|
266 |
$linetotal = $form->round_amount($form->{"sellprice_$i"} * $form->{"qty_$i"} * $discount / $price_factor, $decimalplaces); |
|
267 |
|
|
268 |
my $real_sellprice = $form->{"sellprice_$i"} * $discount / $price_factor; |
|
269 |
|
|
270 |
# marge calculations |
|
271 |
my ($marge_font_start, $marge_font_end); |
|
272 |
|
|
273 |
$form->{"lastcost_$i"} *= 1; |
|
274 |
|
|
275 |
$marge_price_factor = $form->{"marge_price_factor_$i"} * 1 || 1; |
|
276 |
|
|
277 |
if ($real_sellprice && ($form->{"qty_$i"} * 1)) { |
|
278 |
$form->{"marge_percent_$i"} = ($real_sellprice - $form->{"lastcost_$i"} / $marge_price_factor) * 100 / $real_sellprice; |
|
279 |
$myconfig{"marge_percent_warn"} = 15 unless (defined($myconfig{"marge_percent_warn"})); |
|
280 |
|
|
281 |
if ($form->{"id_$i"} && |
|
282 |
($form->{"marge_percent_$i"} < (1 * $myconfig{"marge_percent_warn"}))) { |
|
283 |
$marge_font_start = "<font color=\"#ff0000\">"; |
|
284 |
$marge_font_end = "</font>"; |
|
285 |
} |
|
286 |
|
|
287 |
} else { |
|
288 |
$form->{"marge_percent_$i"} = 0; |
|
289 |
} |
|
290 |
|
|
291 |
my $marge_adjust_credit_note = $form->{type} eq 'credit_note' ? -1 : 1; |
|
292 |
$form->{"marge_total_$i"} = ($real_sellprice - $form->{"lastcost_$i"} / $marge_price_factor) * $form->{"qty_$i"} * $marge_adjust_credit_note; |
|
293 |
$form->{"marge_total"} += $form->{"marge_total_$i"}; |
|
294 |
$form->{"lastcost_total"} += $form->{"lastcost_$i"} * $form->{"qty_$i"} / $marge_price_factor; |
|
295 |
$form->{"sellprice_total"} += $real_sellprice * $form->{"qty_$i"}; |
|
296 |
|
|
297 |
map { $form->{"${_}_$i"} = $form->format_amount(\%myconfig, $form->{"${_}_$i"}, 2) } qw(marge_total marge_percent); |
|
298 |
|
|
299 |
# convert " to " |
|
300 |
map { $form->{"${_}_$i"} =~ s/\"/"/g } |
|
301 |
qw(partnumber description unit unit_old); |
|
302 |
|
|
303 |
######################################## |
|
304 |
# Eintrag fuer Version 2.2.0 geaendert # |
|
305 |
# neue Optik im Rechnungsformular # |
|
306 |
######################################## |
|
307 |
$column_data{runningnumber} = |
|
308 |
qq|<td><input name="runningnumber_$i" size="5" value="$i"></td>|; # HuT |
|
309 |
############## ENDE Neueintrag ################## |
|
310 |
|
|
311 |
$column_data{partnumber} = |
|
312 |
qq|<td><input name="partnumber_$i" size=12 value="$form->{"partnumber_$i"}"></td>|; |
|
313 |
|
|
314 |
if (($rows = $form->numtextrows($form->{"description_$i"}, 30, 6)) > 1) { |
|
315 |
$column_data{description} = |
|
316 |
qq|<td><textarea name="description_$i" rows="$rows" cols="30" wrap="soft">| . H($form->{"description_$i"}) . qq|</textarea><button type="button" onclick="set_longdescription_window('longdescription_$i')">| . $locale->text('L') . qq|</button></td>|; |
|
317 |
} else { |
|
318 |
$column_data{description} = |
|
319 |
qq|<td><input name="description_$i" size="30" value="| . $form->quote($form->{"description_$i"}) . qq|"><button type="button" onclick="set_longdescription_window('longdescription_$i')">| . $locale->text('L') . qq|</button></td>|; |
|
320 |
} |
|
321 |
|
|
322 |
(my $qty_dec) = ($form->{"qty_$i"} =~ /\.(\d+)/); |
|
323 |
$qty_dec = length $qty_dec; |
|
324 |
|
|
325 |
$column_data{qty} = |
|
326 |
qq|<td align="right"><input name="qty_$i" size="5" value="| |
|
327 |
. $form->format_amount(\%myconfig, $form->{"qty_$i"}, $qty_dec) .qq|">|; |
|
328 |
if ($form->{"formel_$i"}) { |
|
329 |
$column_data{qty} .= qq|<button type="button" onclick="calculate_qty_selection_window('qty_$i','alu_$i', 'formel_$i', $i)">| . $locale->text('*/') . qq|</button>| |
|
330 |
. $cgi->hidden("-name" => "formel_$i", "-value" => $form->{"formel_$i"}) . $cgi->hidden("-name" => "alu_$i", "-value" => $form->{"alu_$i"}); |
|
331 |
} |
|
332 |
$column_data{qty} .= qq|</td>|; |
|
333 |
$column_data{ship} = |
|
334 |
qq|<td align="right"><input name="ship_$i" size=5 value="| |
|
335 |
. $form->format_amount(\%myconfig, $form->{"ship_$i"}) |
|
336 |
. qq|"></td>|; |
|
337 |
|
|
338 |
my $is_part = $form->{"inventory_accno_$i"}; |
|
339 |
my $is_assembly = $form->{"assembly_$i"}; |
|
340 |
my $is_assigned = $form->{"id_$i"}; |
|
341 |
my $this_unit = $form->{"unit_$i"}; |
|
342 |
if ($form->{"selected_unit_$i"} && $this_unit && |
|
343 |
$all_units->{$form->{"selected_unit_$i"}} && $all_units->{$this_unit} && |
|
344 |
($all_units->{$form->{"selected_unit_$i"}}->{"base_unit"} eq $all_units->{$this_unit}->{"base_unit"})) { |
|
345 |
$this_unit = $form->{"selected_unit_$i"}; |
|
346 |
} elsif (!$is_assigned || |
|
347 |
($is_part && !$this_unit && ($all_units->{$this_unit} && ($all_units->{$this_unit}->{"base_unit"} eq $all_units->{"kg"}->{"base_unit"})))) { |
|
348 |
$this_unit = "kg"; |
|
349 |
} |
|
350 |
|
|
351 |
my $price_factor_select; |
|
352 |
if (0 < scalar @{ $form->{ALL_PRICE_FACTORS} }) { |
|
353 |
my @values = ('', map { $_->{id} } @{ $form->{ALL_PRICE_FACTORS} }); |
|
354 |
my %labels = map { $_->{id} => $_->{description} } @{ $form->{ALL_PRICE_FACTORS} }; |
|
355 |
|
|
356 |
$price_factor_select = |
|
357 |
NTI($cgi->popup_menu('-name' => "price_factor_id_$i", |
|
358 |
'-default' => $form->{"price_factor_id_$i"}, |
|
359 |
'-values' => \@values, |
|
360 |
'-labels' => \%labels, |
|
361 |
'-style' => 'width:90px')) |
|
362 |
. ' '; |
|
363 |
} |
|
364 |
|
|
365 |
$column_data{"unit"} = "<td>" . |
|
366 |
$price_factor_select . |
|
367 |
AM->unit_select_html($is_part || $is_assembly ? $dimension_units : |
|
368 |
$is_assigned ? $service_units : $all_units, |
|
369 |
"unit_$i", $this_unit, |
|
370 |
$is_assigned ? $form->{"unit_$i"} : undef) |
|
371 |
. "</td>"; |
|
372 |
|
|
373 |
# build in drop down list for pricesgroups |
|
374 |
if ($form->{"prices_$i"}) { |
|
375 |
if ($form->{"new_pricegroup_$i"} != $form->{"old_pricegroup_$i"}) { |
|
376 |
$price_tmp = $form->format_amount(\%myconfig, $form->{"price_new_$i"}, $decimalplaces); |
|
377 |
} else { |
|
378 |
$price_tmp = $form->format_amount(\%myconfig, $form->{"sellprice_$i"}, $decimalplaces); |
|
379 |
} |
|
380 |
|
|
381 |
$column_data{sellprice_pg} = |
|
382 |
qq|<td align="right"><select name="sellprice_pg_$i">$form->{"prices_$i"}</select></td>|; |
|
383 |
$column_data{sellprice} = |
|
384 |
qq|<td><input name="sellprice_$i" size="10" value="$price_tmp" onBlur=\"check_right_number_format(this)\"></td>|; |
|
385 |
} else { |
|
386 |
|
|
387 |
# for last row and report |
|
388 |
# set pricegroup drop down list from report menu |
|
389 |
if ($form->{"sellprice_$i"} != 0) { |
|
390 |
$prices = |
|
391 |
qq|<option value="$form->{"sellprice_$i"}--$form->{"pricegroup_id_$i"}" selected>$form->{"pricegroup_$i"}</option>\n|; |
|
392 |
|
|
393 |
$form->{"pricegroup_old_$i"} = $form->{"pricegroup_id_$i"}; |
|
394 |
|
|
395 |
$column_data{sellprice_pg} = |
|
396 |
qq|<td align="right"><select name="sellprice_pg_$i">$prices</select></td>|; |
|
397 |
|
|
398 |
} else { |
|
399 |
|
|
400 |
# for last row |
|
401 |
$column_data{sellprice_pg} = qq|<td align="right"> </td>|; |
|
402 |
} |
|
403 |
|
|
404 |
$column_data{sellprice} = |
|
405 |
qq|<td><input name="sellprice_$i" size="10" onBlur=\"check_right_number_format(this)\" value="| |
|
406 |
. $form->format_amount(\%myconfig, $form->{"sellprice_$i"}, |
|
407 |
$decimalplaces) |
|
408 |
. qq|"></td>|; |
|
409 |
} |
|
410 |
$column_data{discount} = |
|
411 |
qq|<td align="right"><input name="discount_$i" size=3 value="| |
|
412 |
. $form->format_amount(\%myconfig, $form->{"discount_$i"}) |
|
413 |
. qq|"></td>|; |
|
414 |
$column_data{linetotal} = |
|
415 |
qq|<td align="right">| |
|
416 |
. $form->format_amount(\%myconfig, $linetotal, 2) |
|
417 |
. qq|</td>|; |
|
418 |
$column_data{bin} = qq|<td>$form->{"bin_$i"}</td>|; |
|
419 |
|
|
420 |
######################################## |
|
421 |
# Eintrag fuer Version 2.2.0 geaendert # |
|
422 |
# neue Optik im Rechnungsformular # |
|
423 |
######################################## |
|
424 |
# if ($lizenzen && $form->{type} eq "invoice" && $form->{vc} eq "customer") { |
|
425 |
# $column_data{license} = qq|<td><select name="licensenumber_$i">$form->{"lizenzen_$i"}></select></td>|; |
|
426 |
# } |
|
427 |
# |
|
428 |
# if ($form->{type} !~ /_quotation/) { |
|
429 |
# $column_data{serialnr} = qq|<td><input name="serialnumber_$i" size=10 value="$form->{"serialnumber_$i"}"></td>|; |
|
430 |
# } |
|
431 |
# |
|
432 |
# $column_data{projectnr} = qq|<td><input name="projectnumber_$i" size=10 value="$form->{"projectnumber_$i"}"></td>|; |
|
433 |
############## ENDE Neueintrag ################## |
|
434 |
my $j = $i % 2; |
|
435 |
print qq| |
|
436 |
|
|
437 |
<tr valign="top" class="listrow$j">|; |
|
438 |
|
|
439 |
map { print "\n$column_data{$_}" } @column_index; |
|
440 |
|
|
441 |
print("</tr>\n" . |
|
442 |
$cgi->hidden("-name" => "unit_old_$i", |
|
443 |
"-value" => $form->{"selected_unit_$i"}) |
|
444 |
. "\n" . |
|
445 |
$cgi->hidden("-name" => "price_new_$i", |
|
446 |
"-value" => $form->format_amount(\%myconfig, $form->{"price_new_$i"})) |
|
447 |
. "\n"); |
|
448 |
map({ print($cgi->hidden("-name" => $_, "-value" => $form->{$_}) . "\n"); } |
|
449 |
("orderitems_id_$i", "bo_$i", "pricegroup_old_$i", "price_old_$i", |
|
450 |
"id_$i", "inventory_accno_$i", "bin_$i", "partsgroup_$i", "partnotes_$i", |
|
451 |
"income_accno_$i", "expense_accno_$i", "listprice_$i", "assembly_$i", |
|
452 |
"taxaccounts_$i", "ordnumber_$i", "transdate_$i", "cusordnumber_$i", |
|
453 |
"longdescription_$i", "basefactor_$i", "marge_total_$i", "marge_percent_$i", "lastcost_$i", |
|
454 |
"marge_price_factor_$i")); |
|
455 |
|
|
456 |
######################################## |
|
457 |
# Eintrag fuer Version 2.2.0 geaendert # |
|
458 |
# neue Optik im Rechnungsformular # |
|
459 |
######################################## |
|
460 |
|
|
461 |
my $row_style_attr = |
|
462 |
'style="display:none;"' if (!$form->{"show_details"}); |
|
463 |
|
|
464 |
# print second row |
|
465 |
print qq| |
|
466 |
<tr class="listrow$j" $row_style_attr> |
|
467 |
<td colspan="$colspan"> |
|
468 |
|; |
|
469 |
if ($lizenzen && $form->{type} eq "invoice" && $form->{vc} eq "customer") { |
|
470 |
my $selected = $form->{"licensenumber_$i"}; |
|
471 |
my $lizenzen_quoted; |
|
472 |
$form->{"lizenzen_$i"} =~ s/ selected//g; |
|
473 |
$form->{"lizenzen_$i"} =~ |
|
474 |
s/value="${selected}"\>/value="${selected}" selected\>/; |
|
475 |
$lizenzen_quoted = $form->{"lizenzen_$i"}; |
|
476 |
$lizenzen_quoted =~ s/\"/"/g; |
|
477 |
print qq| |
|
478 |
<b>Lizenz\#</b> <select name="licensenumber_$i" size="1"> |
|
479 |
$form->{"lizenzen_$i"} |
|
480 |
</select> |
|
481 |
<input type="hidden" name="lizenzen_$i" value="${lizenzen_quoted}"> |
|
482 |
|; |
|
483 |
} |
|
484 |
if ($form->{type} !~ /_quotation/) { |
|
485 |
print qq| |
|
486 |
<b>$serialnumber</b> <input name="serialnumber_$i" size="15" value="$form->{"serialnumber_$i"}">|; |
|
487 |
} |
|
488 |
|
|
489 |
print qq|<b>$projectnumber</b> | . |
|
490 |
NTI($cgi->popup_menu('-name' => "project_id_$i", |
|
491 |
'-values' => \@projectnumber_values, |
|
492 |
'-labels' => \%projectnumber_labels, |
|
493 |
'-default' => $form->{"project_id_$i"})); |
|
494 |
|
|
495 |
if ($form->{type} eq 'invoice' or $form->{type} =~ /order/) { |
|
496 |
my $reqdate_term = |
|
497 |
($form->{type} eq 'invoice') |
|
498 |
? 'deliverydate' |
|
499 |
: 'reqdate'; # invoice uses a different term for the same thing. |
|
500 |
print qq| |
|
501 |
<b>${$reqdate_term}</b> <input name="${reqdate_term}_$i" size="11" onBlur="check_right_date_format(this)" value="$form->{"${reqdate_term}_$i"}"> |
|
502 |
|; |
|
503 |
} |
|
504 |
my $subtotalchecked = ($form->{"subtotal_$i"}) ? "checked" : ""; |
|
505 |
print qq| |
|
506 |
<b>|.$locale->text('Subtotal').qq|</b> <input type="checkbox" name="subtotal_$i" value="1" $subtotalchecked> |
|
507 |
|; |
|
508 |
|
|
509 |
if ($form->{"id_$i"} && $is_sales) { |
|
510 |
my $marge_price_factor; |
|
511 |
|
|
512 |
$form->{"marge_price_factor_$i"} *= 1; |
|
513 |
|
|
514 |
if ($form->{"marge_price_factor_$i"} && (1 != $form->{"marge_price_factor_$i"})) { |
|
515 |
$marge_price_factor = '/' . $form->format_amount(\%myconfig, $form->{"marge_price_factor_$i"}); |
|
516 |
} |
|
517 |
|
|
518 |
print qq| |
|
519 |
${marge_font_start}<b>| . $locale->text('Ertrag') . qq|</b> $form->{"marge_total_$i"} $form->{"marge_percent_$i"} % ${marge_font_end}|; |
|
520 |
} |
|
521 |
print qq| |
|
522 |
<b>| . $locale->text('LP') . qq|</b> | . $form->format_amount(\%myconfig, $form->{"listprice_$i"}, 2) . qq| |
|
523 |
<b>| . $locale->text('EK') . qq|</b> | . $form->format_amount(\%myconfig, $form->{"lastcost_$i"}, 2) . $marge_price_factor; |
|
524 |
|
|
525 |
|
|
526 |
print qq| |
|
527 |
</td> |
|
528 |
</tr> |
|
529 |
|; |
|
530 |
|
|
531 |
############## ENDE Neueintrag ################## |
|
532 |
|
|
533 |
map { $form->{"${_}_base"} += $linetotal } |
|
534 |
(split(/ /, $form->{"taxaccounts_$i"})); |
|
535 |
|
|
536 |
$form->{invsubtotal} += $linetotal; |
|
537 |
} |
|
538 |
|
|
539 |
print qq| |
|
540 |
</table> |
|
541 |
</td> |
|
542 |
</tr> |
|
543 |
|; |
|
544 |
|
|
545 |
if (0 != ($form->{sellprice_total} * 1)) { |
|
546 |
$form->{marge_percent} = ($form->{sellprice_total} - $form->{lastcost_total}) / $form->{sellprice_total} * 100; |
|
547 |
} |
|
548 |
|
|
549 |
$lxdebug->leave_sub(); |
|
550 |
} |
|
93 |
#sub display_row {
|
|
94 |
# $lxdebug->enter_sub();
|
|
95 |
# my $numrows = shift;
|
|
96 |
# |
|
97 |
# my $is_sales =
|
|
98 |
# (substr($form->{type}, 0, 6) eq "sales_")
|
|
99 |
# || (($form->{type} eq "invoice") && ($form->{script} eq "is.pl"))
|
|
100 |
# || ($form->{type} eq 'credit_note');
|
|
101 |
# |
|
102 |
# if ($lizenzen && $form->{vc} eq "customer") {
|
|
103 |
# if ($form->{type} =~ /sales_order/) {
|
|
104 |
# @column_index = (runningnumber, partnumber, description, ship, qty);
|
|
105 |
# } elsif ($form->{type} =~ /sales_quotation/) {
|
|
106 |
# @column_index = (runningnumber, partnumber, description, qty);
|
|
107 |
# } else {
|
|
108 |
# @column_index = (runningnumber, partnumber, description, qty);
|
|
109 |
# }
|
|
110 |
# } else {
|
|
111 |
# if ( ($form->{type} =~ /purchase_order/)
|
|
112 |
# || ($form->{type} =~ /sales_order/)) {
|
|
113 |
# @column_index = (runningnumber, partnumber, description, ship, qty);
|
|
114 |
# } else {
|
|
115 |
# @column_index = (runningnumber, partnumber, description, qty);
|
|
116 |
# }
|
|
117 |
# }
|
|
118 |
############### ENDE Neueintrag ##################
|
|
119 |
# |
|
120 |
# my $dimension_units = AM->retrieve_units(\%myconfig, $form, "dimension");
|
|
121 |
# my $service_units = AM->retrieve_units(\%myconfig, $form, "service");
|
|
122 |
# my $all_units = AM->retrieve_units(\%myconfig, $form);
|
|
123 |
# |
|
124 |
# my %price_factors = map { $_->{id} => $_->{factor} } @{ $form->{ALL_PRICE_FACTORS} };
|
|
125 |
# |
|
126 |
# push @column_index, qw(unit);
|
|
127 |
# |
|
128 |
# #for pricegroups column
|
|
129 |
# if ( $form->{type} =~ (/sales_quotation/)
|
|
130 |
# or (($form->{level} =~ /Sales/) and ($form->{type} =~ /invoice/))
|
|
131 |
# or (($form->{level} eq undef) and ($form->{type} =~ /invoice/))
|
|
132 |
# or ($form->{type} =~ /sales_order/)) {
|
|
133 |
# push @column_index, qw(sellprice_pg);
|
|
134 |
# }
|
|
135 |
# |
|
136 |
# push @column_index, qw(sellprice);
|
|
137 |
# |
|
138 |
# if ($form->{vc} eq 'customer') {
|
|
139 |
# push @column_index, qw(discount);
|
|
140 |
# }
|
|
141 |
# |
|
142 |
# push @column_index, "linetotal";
|
|
143 |
# |
|
144 |
# my $colspan = $#column_index + 1;
|
|
145 |
# |
|
146 |
# $form->{invsubtotal} = 0;
|
|
147 |
# map { $form->{"${_}_base"} = 0 } (split(/ /, $form->{taxaccounts}));
|
|
148 |
# |
|
149 |
#########################################
|
|
150 |
# # Eintrag fuer Version 2.2.0 geaendert #
|
|
151 |
# # neue Optik im Rechnungsformular #
|
|
152 |
#########################################
|
|
153 |
# $column_data{runningnumber} = qq|<th align="left" nowrap width="5%" class="listheading">| . $locale->text('No.') . qq|</th>|;
|
|
154 |
# $column_data{partnumber} = qq|<th align="left" nowrap width="12%" class="listheading">| . $locale->text('Number') . qq|</th>|;
|
|
155 |
# $column_data{description} = qq|<th align="left" nowrap width="30%" class="listheading">| . $locale->text('Part Description') . qq|</th>|;
|
|
156 |
# if ($form->{"type"} eq "purchase_order") {
|
|
157 |
# $column_data{ship} = qq|<th align="left" nowrap width="5%" class="listheading">| . $locale->text('Ship rcvd') . qq|</th>|;
|
|
158 |
# } else {
|
|
159 |
# $column_data{ship} = qq|<th align="left" nowrap width="5%" class="listheading">| . $locale->text('Ship') . qq|</th>|;
|
|
160 |
# }
|
|
161 |
# $column_data{qty} = qq|<th align="left" nowrap width="5%" class="listheading">| . $locale->text('Qty') . qq|</th>|;
|
|
162 |
# $column_data{unit} = qq|<th align="left" nowrap width="20%" class="listheading">| . $locale->text('Unit') . qq|</th>|;
|
|
163 |
# $column_data{license} = qq|<th align="left" nowrap width="10%" class="listheading">| . $locale->text('License') . qq|</th>|;
|
|
164 |
# $column_data{serialnr} = qq|<th align="left" nowrap width="10%" class="listheading">| . $locale->text('Serial No.') . qq|</th>|;
|
|
165 |
# $column_data{projectnr} = qq|<th align="left" nowrap width="10%" class="listheading">| . $locale->text('Project') . qq|</th>|;
|
|
166 |
# $column_data{sellprice} = qq|<th align="left" nowrap width="15%" class="listheading">| . $locale->text('Price') . qq|</th>|;
|
|
167 |
# $column_data{sellprice_pg} = qq|<th align="left" nowrap width="15%" class="listheading">| . $locale->text('Pricegroup') . qq|</th>|;
|
|
168 |
# $column_data{discount} = qq|<th align="left" nowrap width="5%" class="listheading">| . $locale->text('Discount') . qq|</th>|;
|
|
169 |
# $column_data{linetotal} = qq|<th align="left" nowrap width="10%" class="listheading">| . $locale->text('Extended') . qq|</th>|;
|
|
170 |
# $column_data{bin} = qq|<th align="left" nowrap width="10%" class="listheading">| . $locale->text('Bin') . qq|</th>|;
|
|
171 |
############### ENDE Neueintrag ##################
|
|
172 |
# |
|
173 |
# $myconfig{"show_form_details"} = 1
|
|
174 |
# unless (defined($myconfig{"show_form_details"}));
|
|
175 |
# $form->{"show_details"} = $myconfig{"show_form_details"}
|
|
176 |
# unless (defined($form->{"show_details"}));
|
|
177 |
# $form->{"show_details"} = $form->{"show_details"} ? 1 : 0;
|
|
178 |
# my $show_details_new = 1 - $form->{"show_details"};
|
|
179 |
# my $show_details_checked = $form->{"show_details"} ? "checked" : "";
|
|
180 |
# |
|
181 |
# print qq|
|
|
182 |
# <tr>
|
|
183 |
# <td>| . $cgi->hidden("-name" => "show_details", "-value" => $form->{show_details}) . qq|
|
|
184 |
# <input type="checkbox" id="cb_show_details" onclick="show_form_details($show_details_new);" $show_details_checked>
|
|
185 |
# <label for="cb_show_details">| . $locale->text("Show details") . qq|</label><br>
|
|
186 |
# <table width="100%">
|
|
187 |
# <tr class="listheading">|;
|
|
188 |
# |
|
189 |
# map { print "\n$column_data{$_}" } @column_index;
|
|
190 |
# |
|
191 |
# print qq|
|
|
192 |
# </tr>
|
|
193 |
#|;
|
|
194 |
# |
|
195 |
# $runningnumber = $locale->text('No.');
|
|
196 |
# $deliverydate = $locale->text('Delivery Date');
|
|
197 |
# $serialnumber = $locale->text('Serial No.');
|
|
198 |
# $projectnumber = $locale->text('Project');
|
|
199 |
# $partsgroup = $locale->text('Group');
|
|
200 |
# $reqdate = $locale->text('Reqdate');
|
|
201 |
# |
|
202 |
# $delvar = 'deliverydate';
|
|
203 |
# |
|
204 |
# if ($form->{type} =~ /_order$/ || $form->{type} =~ /_quotation$/) {
|
|
205 |
# $deliverydate = $locale->text('Required by');
|
|
206 |
# $delvar = 'reqdate';
|
|
207 |
# }
|
|
208 |
# |
|
209 |
# $form->{marge_total} = 0;
|
|
210 |
# $form->{sellprice_total} = 0;
|
|
211 |
# $form->{lastcost_total} = 0;
|
|
212 |
# my %projectnumber_labels = ();
|
|
213 |
# my @projectnumber_values = ("");
|
|
214 |
# foreach my $item (@{ $form->{"ALL_PROJECTS"} }) {
|
|
215 |
# push(@projectnumber_values, $item->{"id"});
|
|
216 |
# $projectnumber_labels{$item->{"id"}} = $item->{"projectnumber"};
|
|
217 |
# }
|
|
218 |
# |
|
219 |
# for $i (1 .. $numrows) {
|
|
220 |
# |
|
221 |
# # undo formatting
|
|
222 |
# map {
|
|
223 |
# $form->{"${_}_$i"} =
|
|
224 |
# $form->parse_amount(\%myconfig, $form->{"${_}_$i"})
|
|
225 |
# } qw(qty ship discount sellprice price_new price_old) unless ($form->{simple_save});
|
|
226 |
# |
|
227 |
# if (!$form->{"unit_old_$i"}) {
|
|
228 |
# # Neue Ware aus der Datenbank. In diesem Fall ist unit_$i die
|
|
229 |
# # Einheit, wie sie in den Stammdaten hinterlegt wurde.
|
|
230 |
# # Es sollte also angenommen werden, dass diese ausgewaehlt war.
|
|
231 |
# $form->{"unit_old_$i"} = $form->{"unit_$i"};
|
|
232 |
# }
|
|
233 |
# |
|
234 |
# # Die zuletzt ausgewaehlte mit der aktuell ausgewaehlten Einheit
|
|
235 |
# # vergleichen und bei Unterschied den Preis entsprechend umrechnen.
|
|
236 |
# $form->{"selected_unit_$i"} = $form->{"unit_$i"} unless ($form->{"selected_unit_$i"});
|
|
237 |
# |
|
238 |
# my $check_units = $form->{"inventory_accno_$i"} ? $dimension_units : $service_units;
|
|
239 |
# if (!$check_units->{$form->{"selected_unit_$i"}} ||
|
|
240 |
# ($check_units->{$form->{"selected_unit_$i"}}->{"base_unit"} ne
|
|
241 |
# $all_units->{$form->{"unit_old_$i"}}->{"base_unit"})) {
|
|
242 |
# # Die ausgewaehlte Einheit ist fuer diesen Artikel nicht gueltig
|
|
243 |
# # (z.B. Dimensionseinheit war ausgewaehlt, es handelt sich aber
|
|
244 |
# # um eine Dienstleistung). Dann keinerlei Umrechnung vornehmen.
|
|
245 |
# $form->{"unit_old_$i"} = $form->{"selected_unit_$i"} = $form->{"unit_$i"};
|
|
246 |
# }
|
|
247 |
# if ((!$form->{"prices_$i"}) || ($form->{"new_pricegroup_$i"} == $form->{"old_pricegroup_$i"})) {
|
|
248 |
# if ($form->{"unit_old_$i"} ne $form->{"selected_unit_$i"}) {
|
|
249 |
# my $basefactor = 1;
|
|
250 |
# if (defined($all_units->{$form->{"unit_old_$i"}}->{"factor"}) &&
|
|
251 |
# $all_units->{$form->{"unit_old_$i"}}->{"factor"}) {
|
|
252 |
# $basefactor = $all_units->{$form->{"selected_unit_$i"}}->{"factor"} /
|
|
253 |
# $all_units->{$form->{"unit_old_$i"}}->{"factor"};
|
|
254 |
# }
|
|
255 |
# $form->{"sellprice_$i"} *= $basefactor;
|
|
256 |
# $form->{"unit_old_$i"} = $form->{"selected_unit_$i"};
|
|
257 |
# }
|
|
258 |
# }
|
|
259 |
# |
|
260 |
# ($dec) = ($form->{"sellprice_$i"} =~ /\.(\d+)/);
|
|
261 |
# $decimalplaces = max length($dec), 2;
|
|
262 |
# |
|
263 |
# $price_factor = $price_factors{$form->{"price_factor_id_$i"}} || 1;
|
|
264 |
# $discount = (100 - $form->{"discount_$i"} * 1) / 100;
|
|
265 |
# |
|
266 |
# $linetotal = $form->round_amount($form->{"sellprice_$i"} * $form->{"qty_$i"} * $discount / $price_factor, $decimalplaces);
|
|
267 |
# |
|
268 |
# my $real_sellprice = $form->{"sellprice_$i"} * $discount / $price_factor;
|
|
269 |
# |
|
270 |
# # marge calculations
|
|
271 |
# my ($marge_font_start, $marge_font_end);
|
|
272 |
# |
|
273 |
# $form->{"lastcost_$i"} *= 1;
|
|
274 |
# |
|
275 |
# $marge_price_factor = $form->{"marge_price_factor_$i"} * 1 || 1;
|
|
276 |
# |
|
277 |
# if ($real_sellprice && ($form->{"qty_$i"} * 1)) {
|
|
278 |
# $form->{"marge_percent_$i"} = ($real_sellprice - $form->{"lastcost_$i"} / $marge_price_factor) * 100 / $real_sellprice;
|
|
279 |
# $myconfig{"marge_percent_warn"} = 15 unless (defined($myconfig{"marge_percent_warn"}));
|
|
280 |
# |
|
281 |
# if ($form->{"id_$i"} &&
|
|
282 |
# ($form->{"marge_percent_$i"} < (1 * $myconfig{"marge_percent_warn"}))) {
|
|
283 |
# $marge_font_start = "<font color=\"#ff0000\">";
|
|
284 |
# $marge_font_end = "</font>";
|
|
285 |
# }
|
|
286 |
# |
|
287 |
# } else {
|
|
288 |
# $form->{"marge_percent_$i"} = 0;
|
|
289 |
# }
|
|
290 |
# |
|
291 |
# my $marge_adjust_credit_note = $form->{type} eq 'credit_note' ? -1 : 1;
|
|
292 |
# $form->{"marge_total_$i"} = ($real_sellprice - $form->{"lastcost_$i"} / $marge_price_factor) * $form->{"qty_$i"} * $marge_adjust_credit_note;
|
|
293 |
# $form->{"marge_total"} += $form->{"marge_total_$i"};
|
|
294 |
# $form->{"lastcost_total"} += $form->{"lastcost_$i"} * $form->{"qty_$i"} / $marge_price_factor;
|
|
295 |
# $form->{"sellprice_total"} += $real_sellprice * $form->{"qty_$i"};
|
|
296 |
# |
|
297 |
# map { $form->{"${_}_$i"} = $form->format_amount(\%myconfig, $form->{"${_}_$i"}, 2) } qw(marge_total marge_percent);
|
|
298 |
# |
|
299 |
# # convert " to "
|
|
300 |
# map { $form->{"${_}_$i"} =~ s/\"/"/g }
|
|
301 |
# qw(partnumber description unit unit_old);
|
|
302 |
# |
|
303 |
#########################################
|
|
304 |
# # Eintrag fuer Version 2.2.0 geaendert #
|
|
305 |
# # neue Optik im Rechnungsformular #
|
|
306 |
#########################################
|
|
307 |
# $column_data{runningnumber} =
|
|
308 |
# qq|<td><input name="runningnumber_$i" size="5" value="$i"></td>|; # HuT
|
|
309 |
############### ENDE Neueintrag ##################
|
|
310 |
# |
|
311 |
# $column_data{partnumber} =
|
|
312 |
# qq|<td><input name="partnumber_$i" size=12 value="$form->{"partnumber_$i"}"></td>|;
|
|
313 |
# |
|
314 |
# if (($rows = $form->numtextrows($form->{"description_$i"}, 30, 6)) > 1) {
|
|
315 |
# $column_data{description} =
|
|
316 |
# qq|<td><textarea name="description_$i" rows="$rows" cols="30" wrap="soft">| . H($form->{"description_$i"}) . qq|</textarea><button type="button" onclick="set_longdescription_window('longdescription_$i')">| . $locale->text('L') . qq|</button></td>|;
|
|
317 |
# } else {
|
|
318 |
# $column_data{description} =
|
|
319 |
# qq|<td><input name="description_$i" size="30" value="| . $form->quote($form->{"description_$i"}) . qq|"><button type="button" onclick="set_longdescription_window('longdescription_$i')">| . $locale->text('L') . qq|</button></td>|;
|
|
320 |
# }
|
|
321 |
# |
|
322 |
# (my $qty_dec) = ($form->{"qty_$i"} =~ /\.(\d+)/);
|
|
323 |
# $qty_dec = length $qty_dec;
|
|
324 |
# |
|
325 |
# $column_data{qty} =
|
|
326 |
# qq|<td align="right"><input name="qty_$i" size="5" value="|
|
|
327 |
# . $form->format_amount(\%myconfig, $form->{"qty_$i"}, $qty_dec) .qq|">|;
|
|
328 |
# if ($form->{"formel_$i"}) {
|
|
329 |
# $column_data{qty} .= qq|<button type="button" onclick="calculate_qty_selection_window('qty_$i','alu_$i', 'formel_$i', $i)">| . $locale->text('*/') . qq|</button>|
|
|
330 |
# . $cgi->hidden("-name" => "formel_$i", "-value" => $form->{"formel_$i"}) . $cgi->hidden("-name" => "alu_$i", "-value" => $form->{"alu_$i"});
|
|
331 |
# }
|
|
332 |
# $column_data{qty} .= qq|</td>|;
|
|
333 |
# $column_data{ship} =
|
|
334 |
# qq|<td align="right"><input name="ship_$i" size=5 value="|
|
|
335 |
# . $form->format_amount(\%myconfig, $form->{"ship_$i"})
|
|
336 |
# . qq|"></td>|;
|
|
337 |
# |
|
338 |
# my $is_part = $form->{"inventory_accno_$i"};
|
|
339 |
# my $is_assembly = $form->{"assembly_$i"};
|
|
340 |
# my $is_assigned = $form->{"id_$i"};
|
|
341 |
# my $this_unit = $form->{"unit_$i"};
|
|
342 |
# if ($form->{"selected_unit_$i"} && $this_unit &&
|
|
343 |
# $all_units->{$form->{"selected_unit_$i"}} && $all_units->{$this_unit} &&
|
|
344 |
# ($all_units->{$form->{"selected_unit_$i"}}->{"base_unit"} eq $all_units->{$this_unit}->{"base_unit"})) {
|
|
345 |
# $this_unit = $form->{"selected_unit_$i"};
|
|
346 |
# } elsif (!$is_assigned ||
|
|
347 |
# ($is_part && !$this_unit && ($all_units->{$this_unit} && ($all_units->{$this_unit}->{"base_unit"} eq $all_units->{"kg"}->{"base_unit"})))) {
|
|
348 |
# $this_unit = "kg";
|
|
349 |
# }
|
|
350 |
# |
|
351 |
# my $price_factor_select;
|
|
352 |
# if (0 < scalar @{ $form->{ALL_PRICE_FACTORS} }) {
|
|
353 |
# my @values = ('', map { $_->{id} } @{ $form->{ALL_PRICE_FACTORS} });
|
|
354 |
# my %labels = map { $_->{id} => $_->{description} } @{ $form->{ALL_PRICE_FACTORS} };
|
|
355 |
# |
|
356 |
# $price_factor_select =
|
|
357 |
# NTI($cgi->popup_menu('-name' => "price_factor_id_$i",
|
|
358 |
# '-default' => $form->{"price_factor_id_$i"},
|
|
359 |
# '-values' => \@values,
|
|
360 |
# '-labels' => \%labels,
|
|
361 |
# '-style' => 'width:90px'))
|
|
362 |
# . ' ';
|
|
363 |
# }
|
|
364 |
# |
|
365 |
# $column_data{"unit"} = "<td>" .
|
|
366 |
# $price_factor_select .
|
|
367 |
# AM->unit_select_html($is_part || $is_assembly ? $dimension_units :
|
|
368 |
# $is_assigned ? $service_units : $all_units,
|
|
369 |
# "unit_$i", $this_unit,
|
|
370 |
# $is_assigned ? $form->{"unit_$i"} : undef)
|
|
371 |
# . "</td>";
|
|
372 |
# |
|
373 |
# # build in drop down list for pricesgroups
|
|
374 |
# if ($form->{"prices_$i"}) {
|
|
375 |
# if ($form->{"new_pricegroup_$i"} != $form->{"old_pricegroup_$i"}) {
|
|
376 |
# $price_tmp = $form->format_amount(\%myconfig, $form->{"price_new_$i"}, $decimalplaces);
|
|
377 |
# } else {
|
|
378 |
# $price_tmp = $form->format_amount(\%myconfig, $form->{"sellprice_$i"}, $decimalplaces);
|
|
379 |
# }
|
|
380 |
# |
|
381 |
# $column_data{sellprice_pg} =
|
|
382 |
# qq|<td align="right"><select name="sellprice_pg_$i">$form->{"prices_$i"}</select></td>|;
|
|
383 |
# $column_data{sellprice} =
|
|
384 |
# qq|<td><input name="sellprice_$i" size="10" value="$price_tmp" onBlur=\"check_right_number_format(this)\"></td>|;
|
|
385 |
# } else {
|
|
386 |
# |
|
387 |
# # for last row and report
|
|
388 |
# # set pricegroup drop down list from report menu
|
|
389 |
# if ($form->{"sellprice_$i"} != 0) {
|
|
390 |
# $prices =
|
|
391 |
# qq|<option value="$form->{"sellprice_$i"}--$form->{"pricegroup_id_$i"}" selected>$form->{"pricegroup_$i"}</option>\n|;
|
|
392 |
# |
|
393 |
# $form->{"pricegroup_old_$i"} = $form->{"pricegroup_id_$i"};
|
|
394 |
# |
|
395 |
# $column_data{sellprice_pg} =
|
|
396 |
# qq|<td align="right"><select name="sellprice_pg_$i">$prices</select></td>|;
|
|
397 |
# |
|
398 |
# } else {
|
|
399 |
# |
|
400 |
# # for last row
|
|
401 |
# $column_data{sellprice_pg} = qq|<td align="right"> </td>|;
|
|
402 |
# }
|
|
403 |
# |
|
404 |
# $column_data{sellprice} =
|
|
405 |
# qq|<td><input name="sellprice_$i" size="10" onBlur=\"check_right_number_format(this)\" value="|
|
|
406 |
# . $form->format_amount(\%myconfig, $form->{"sellprice_$i"},
|
|
407 |
# $decimalplaces)
|
|
408 |
# . qq|"></td>|;
|
|
409 |
# }
|
|
410 |
# $column_data{discount} =
|
|
411 |
# qq|<td align="right"><input name="discount_$i" size=3 value="|
|
|
412 |
# . $form->format_amount(\%myconfig, $form->{"discount_$i"})
|
|
413 |
# . qq|"></td>|;
|
|
414 |
# $column_data{linetotal} =
|
|
415 |
# qq|<td align="right">|
|
|
416 |
# . $form->format_amount(\%myconfig, $linetotal, 2)
|
|
417 |
# . qq|</td>|;
|
|
418 |
# $column_data{bin} = qq|<td>$form->{"bin_$i"}</td>|;
|
|
419 |
# |
|
420 |
#########################################
|
|
421 |
# # Eintrag fuer Version 2.2.0 geaendert #
|
|
422 |
# # neue Optik im Rechnungsformular #
|
|
423 |
#########################################
|
|
424 |
# # if ($lizenzen && $form->{type} eq "invoice" && $form->{vc} eq "customer") {
|
|
425 |
# # $column_data{license} = qq|<td><select name="licensenumber_$i">$form->{"lizenzen_$i"}></select></td>|;
|
|
426 |
# # }
|
|
427 |
# #
|
|
428 |
# # if ($form->{type} !~ /_quotation/) {
|
|
429 |
# # $column_data{serialnr} = qq|<td><input name="serialnumber_$i" size=10 value="$form->{"serialnumber_$i"}"></td>|;
|
|
430 |
# # }
|
|
431 |
# #
|
|
432 |
# # $column_data{projectnr} = qq|<td><input name="projectnumber_$i" size=10 value="$form->{"projectnumber_$i"}"></td>|;
|
|
433 |
############### ENDE Neueintrag ##################
|
|
434 |
# my $j = $i % 2;
|
|
435 |
# print qq|
|
|
436 |
# |
|
437 |
# <tr valign="top" class="listrow$j">|;
|
|
438 |
# |
|
439 |
# map { print "\n$column_data{$_}" } @column_index;
|
|
440 |
# |
|
441 |
# print("</tr>\n" .
|
|
442 |
# $cgi->hidden("-name" => "unit_old_$i",
|
|
443 |
# "-value" => $form->{"selected_unit_$i"})
|
|
444 |
# . "\n" .
|
|
445 |
# $cgi->hidden("-name" => "price_new_$i",
|
|
446 |
# "-value" => $form->format_amount(\%myconfig, $form->{"price_new_$i"}))
|
|
447 |
# . "\n");
|
|
448 |
# map({ print($cgi->hidden("-name" => $_, "-value" => $form->{$_}) . "\n"); }
|
|
449 |
# ("orderitems_id_$i", "bo_$i", "pricegroup_old_$i", "price_old_$i",
|
|
450 |
# "id_$i", "inventory_accno_$i", "bin_$i", "partsgroup_$i", "partnotes_$i",
|
|
451 |
# "income_accno_$i", "expense_accno_$i", "listprice_$i", "assembly_$i",
|
|
452 |
# "taxaccounts_$i", "ordnumber_$i", "transdate_$i", "cusordnumber_$i",
|
|
453 |
# "longdescription_$i", "basefactor_$i", "marge_total_$i", "marge_percent_$i", "lastcost_$i",
|
|
454 |
# "marge_price_factor_$i"));
|
|
455 |
# |
|
456 |
#########################################
|
|
457 |
# # Eintrag fuer Version 2.2.0 geaendert #
|
|
458 |
# # neue Optik im Rechnungsformular #
|
|
459 |
#########################################
|
|
460 |
# |
|
461 |
# my $row_style_attr =
|
|
462 |
# 'style="display:none;"' if (!$form->{"show_details"});
|
|
463 |
# |
|
464 |
# # print second row
|
|
465 |
# print qq|
|
|
466 |
# <tr class="listrow$j" $row_style_attr>
|
|
467 |
# <td colspan="$colspan">
|
|
468 |
#|;
|
|
469 |
# if ($lizenzen && $form->{type} eq "invoice" && $form->{vc} eq "customer") {
|
|
470 |
# my $selected = $form->{"licensenumber_$i"};
|
|
471 |
# my $lizenzen_quoted;
|
|
472 |
# $form->{"lizenzen_$i"} =~ s/ selected//g;
|
|
473 |
# $form->{"lizenzen_$i"} =~
|
|
474 |
# s/value="${selected}"\>/value="${selected}" selected\>/;
|
|
475 |
# $lizenzen_quoted = $form->{"lizenzen_$i"};
|
|
476 |
# $lizenzen_quoted =~ s/\"/"/g;
|
|
477 |
# print qq|
|
|
478 |
# <b>Lizenz\#</b> <select name="licensenumber_$i" size="1">
|
|
479 |
# $form->{"lizenzen_$i"}
|
|
480 |
# </select>
|
|
481 |
# <input type="hidden" name="lizenzen_$i" value="${lizenzen_quoted}">
|
|
482 |
#|;
|
|
483 |
# }
|
|
484 |
# if ($form->{type} !~ /_quotation/) {
|
|
485 |
# print qq|
|
|
486 |
# <b>$serialnumber</b> <input name="serialnumber_$i" size="15" value="$form->{"serialnumber_$i"}">|;
|
|
487 |
# }
|
|
488 |
# |
|
489 |
# print qq|<b>$projectnumber</b> | .
|
|
490 |
# NTI($cgi->popup_menu('-name' => "project_id_$i",
|
|
491 |
# '-values' => \@projectnumber_values,
|
|
492 |
# '-labels' => \%projectnumber_labels,
|
|
493 |
# '-default' => $form->{"project_id_$i"}));
|
|
494 |
# |
|
495 |
# if ($form->{type} eq 'invoice' or $form->{type} =~ /order/) {
|
|
496 |
# my $reqdate_term =
|
|
497 |
# ($form->{type} eq 'invoice')
|
|
498 |
# ? 'deliverydate'
|
|
499 |
# : 'reqdate'; # invoice uses a different term for the same thing.
|
|
500 |
# print qq|
|
|
501 |
# <b>${$reqdate_term}</b> <input name="${reqdate_term}_$i" size="11" onBlur="check_right_date_format(this)" value="$form->{"${reqdate_term}_$i"}">
|
|
502 |
#|;
|
|
503 |
# }
|
|
504 |
# my $subtotalchecked = ($form->{"subtotal_$i"}) ? "checked" : "";
|
|
505 |
# print qq|
|
|
506 |
# <b>|.$locale->text('Subtotal').qq|</b> <input type="checkbox" name="subtotal_$i" value="1" $subtotalchecked>
|
|
507 |
#|;
|
|
508 |
# |
|
509 |
# if ($form->{"id_$i"} && $is_sales) {
|
|
510 |
# my $marge_price_factor;
|
|
511 |
# |
|
512 |
# $form->{"marge_price_factor_$i"} *= 1;
|
|
513 |
# |
|
514 |
# if ($form->{"marge_price_factor_$i"} && (1 != $form->{"marge_price_factor_$i"})) {
|
|
515 |
# $marge_price_factor = '/' . $form->format_amount(\%myconfig, $form->{"marge_price_factor_$i"});
|
|
516 |
# }
|
|
517 |
# |
|
518 |
# print qq|
|
|
519 |
# ${marge_font_start}<b>| . $locale->text('Ertrag') . qq|</b> $form->{"marge_total_$i"} $form->{"marge_percent_$i"} % ${marge_font_end}|;
|
|
520 |
# }
|
|
521 |
# print qq|
|
|
522 |
# <b>| . $locale->text('LP') . qq|</b> | . $form->format_amount(\%myconfig, $form->{"listprice_$i"}, 2) . qq|
|
|
523 |
# <b>| . $locale->text('EK') . qq|</b> | . $form->format_amount(\%myconfig, $form->{"lastcost_$i"}, 2) . $marge_price_factor;
|
|
524 |
# |
|
525 |
# |
|
526 |
# print qq|
|
|
527 |
# </td>
|
|
528 |
# </tr>
|
|
529 |
#|;
|
|
530 |
# |
|
531 |
############### ENDE Neueintrag ##################
|
|
532 |
# |
|
533 |
# map { $form->{"${_}_base"} += $linetotal }
|
|
534 |
# (split(/ /, $form->{"taxaccounts_$i"}));
|
|
535 |
# |
|
536 |
# $form->{invsubtotal} += $linetotal;
|
|
537 |
# }
|
|
538 |
# |
|
539 |
# print qq|
|
|
540 |
# </table>
|
|
541 |
# </td>
|
|
542 |
# </tr>
|
|
543 |
#|;
|
|
544 |
# |
|
545 |
# if (0 != ($form->{sellprice_total} * 1)) {
|
|
546 |
# $form->{marge_percent} = ($form->{sellprice_total} - $form->{lastcost_total}) / $form->{sellprice_total} * 100;
|
|
547 |
# }
|
|
548 |
# |
|
549 |
# $lxdebug->leave_sub();
|
|
550 |
#}
|
|
551 | 551 |
|
552 | 552 |
sub set_pricegroup { |
553 | 553 |
$lxdebug->enter_sub(); |
Auch abrufbar als: Unified diff
Um die Benutzung des Template Systems mal ein wenig zu foerdern.
Die bin/mozilla/oe.pl noch einmal umgeschrieben, so dass jetzt noch mehr Funktionen ins Frontend ausgelagert sind.
Ein neues Highlight ist die template/generic/multibox.html, die es erlaubt aus wenigen Steuerkommandos ein HTML-Eingabefeld zu erstellen, was bei kleinen Datenmengen als Dropdownbox erscheint, udn bei grossen asl Textfeld, mit dazugehörigem Popup-Button, um eine Auswahlliste aufzumachen. Saemtliche Funktionen lassen sich ueber Perlfunktionsreferenzen wieder zurück ins Backend leiten, und dort wieder mit komplexer Logik füllen. Dokumentation ist im Template direkt enthalten.
Die Customer/Vendor Eingabe macht auch gleich Gebrauch davon und erzeugt bei zu grosser Anzahl ein Textfeld, und daneben einen Suchbutton, der die passenden Kunden in einer Liste anzeigt.
Der "Kundendetails"-Button wurde von "?" umbenannt in "D" (immernoch gruselig)
Auf Wunsch von Moritz habe ich die display_row von bin/mozilla/oe.pl wieder verlagert in die bin/mozilla/io.pl, und dafuer die Version in bin/mozilla/invoice_io.pl deaktiviert.