Revision bce93dd4
Von Sven Schöling vor mehr als 3 Jahren hinzugefügt
bin/mozilla/io.pl | ||
---|---|---|
38 | 38 |
####################################################################### |
39 | 39 |
|
40 | 40 |
use Carp; |
41 |
use CGI; |
|
42 | 41 |
use List::MoreUtils qw(any uniq apply); |
43 | 42 |
use List::Util qw(sum min max first); |
44 | 43 |
use List::UtilsBy qw(sort_by uniq_by); |
... | ... | |
54 | 53 |
use SL::File; |
55 | 54 |
use SL::PriceSource; |
56 | 55 |
use SL::Presenter::Part; |
56 |
use SL::Presenter::Tag qw(select_tag input_tag hidden_tag button_tag textarea_tag html_tag); |
|
57 | 57 |
|
58 | 58 |
use SL::DB::Contact; |
59 | 59 |
use SL::DB::Currency; |
... | ... | |
62 | 62 |
use SL::DB::Language; |
63 | 63 |
use SL::DB::Printer; |
64 | 64 |
use SL::DB::Vendor; |
65 |
use SL::Helper::Number qw(:ALL); |
|
65 | 66 |
use SL::Helper::CreatePDF; |
66 | 67 |
use SL::Helper::Flash; |
67 | 68 |
use SL::Helper::PrintOptions; |
... | ... | |
130 | 131 |
my $form = $main::form; |
131 | 132 |
my %myconfig = %main::myconfig; |
132 | 133 |
my $locale = $main::locale; |
133 |
my $cgi = $::request->{cgi}; |
|
134 | 134 |
|
135 | 135 |
my $numrows = shift; |
136 | 136 |
|
... | ... | |
224 | 224 |
$form->{sellprice_total} = 0; |
225 | 225 |
$form->{lastcost_total} = 0; |
226 | 226 |
$form->{totalweight} = 0; |
227 |
my %projectnumber_labels = (); |
|
228 |
my @projectnumber_values = (""); |
|
229 |
|
|
230 |
foreach my $item (@{ $form->{"ALL_PROJECTS"} }) { |
|
231 |
push(@projectnumber_values, $item->{"id"}); |
|
232 |
$projectnumber_labels{$item->{"id"}} = $item->{"projectnumber"}; |
|
233 |
} |
|
234 | 227 |
|
235 | 228 |
_update_part_information(); |
236 | 229 |
_update_ship() if ($is_s_p_order); |
... | ... | |
273 | 266 |
$this_unit = $form->{"selected_unit_$i"} if AM->convert_unit($this_unit, $form->{"selected_unit_$i"}, $all_units); |
274 | 267 |
|
275 | 268 |
if (0 < scalar @{ $form->{ALL_PRICE_FACTORS} }) { |
276 |
my @values = ('', map { $_->{id} } @{ $form->{ALL_PRICE_FACTORS} }); |
|
277 |
my %labels = map { $_->{id} => $_->{description} } @{ $form->{ALL_PRICE_FACTORS} }; |
|
278 |
|
|
279 |
$column_data{price_factor} = |
|
280 |
NTI($cgi->popup_menu('-name' => "price_factor_id_$i", |
|
281 |
'-default' => $form->{"price_factor_id_$i"}, |
|
282 |
'-values' => \@values, |
|
283 |
'-labels' => \%labels, |
|
284 |
'-style' => 'width:90px')); |
|
269 |
$column_data{price_factor} = select_tag("price_factor_id_$i", $form->{ALL_PRICE_FACTORS}, |
|
270 |
title_key => 'description', |
|
271 |
default => $form->{"price_factor_id_$i"}, |
|
272 |
style => 'width:90px', |
|
273 |
); |
|
285 | 274 |
} else { |
286 | 275 |
$column_data{price_factor} = ' '; |
287 | 276 |
} |
... | ... | |
303 | 292 |
# quick delete single row |
304 | 293 |
$column_data{runningnumber} = q|<a onclick= "$('#partnumber_| . $i . q|').val(''); $('#update_button').click();">| . |
305 | 294 |
q|<img height="10px" width="10px" src="image/cross.png" alt="| . $locale->text('Remove') . q|"></a> |; |
306 |
$column_data{runningnumber} .= $cgi->textfield(-name => "runningnumber_$i", -id => "runningnumber_$i", -size => 5, -value => $i); # HuT
|
|
295 |
$column_data{runningnumber} .= input_tag("runningnumber_$i", $i, id => "runningnumber_$i", size => 4);
|
|
307 | 296 |
|
308 | 297 |
|
309 |
$column_data{partnumber} = $cgi->textfield(-name => "partnumber_$i", -id => "partnumber_$i", -size => 12, -value => $form->{"partnumber_$i"});
|
|
298 |
$column_data{partnumber} = input_tag("partnumber_$i", $form->{"partnumber_$i"}, id => "partnumber_$i", size => 12);
|
|
310 | 299 |
$column_data{type_and_classific} = SL::Presenter::Part::type_abbreviation($form->{"part_type_$i"}). |
311 | 300 |
SL::Presenter::Part::classification_abbreviation($form->{"classification_id_$i"}) if $form->{"id_$i"}; |
312 | 301 |
$column_data{description} = (($rows > 1) # if description is too large, use a textbox instead |
313 |
? $cgi->textarea( -name => "description_$i", -id => "description_$i", -default => $form->{"description_$i"}, -rows => $rows, -columns => 30)
|
|
314 |
: $cgi->textfield(-name => "description_$i", -id => "description_$i", -value => $form->{"description_$i"}, -size => 30))
|
|
315 |
. $cgi->button(-value => $locale->text('L'), -onClick => "kivi.SalesPurchase.edit_longdescription($i)");
|
|
302 |
? textarea_tag("description_$i", $form->{"description_$i"}, id => "description_$i", rows => $rows, cols => 30)
|
|
303 |
: input_tag("description_$i", $form->{"description_$i"}, id => "description_$i", size => 30))
|
|
304 |
. button_tag("kivi.SalesPurchase.edit_longdescription($i)", t8('L'), type => "button", title => t8("Long Description"));
|
|
316 | 305 |
|
317 | 306 |
my $qty_dec = ($form->{"qty_$i"} =~ /\.(\d+)/) ? length $1 : 2; |
318 | 307 |
|
319 |
$column_data{qty} = $cgi->textfield(-name => "qty_$i", -size => 5, -class => "numeric", -value => $form->format_amount(\%myconfig, $form->{"qty_$i"}, $qty_dec));
|
|
320 |
$column_data{qty} .= $cgi->button(-onclick => "calculate_qty_selection_dialog('qty_$i', '', 'formel_$i', '')", -value => $locale->text('*/'))
|
|
321 |
. $cgi->hidden(-name => "formel_$i", -value => $form->{"formel_$i"})
|
|
308 |
$column_data{qty} = input_tag("qty_$i", _format_number($::form->{"qty_$i"}, $qty_dec), size => 5, class => "numeric");
|
|
309 |
$column_data{qty} .= button_tag("calculate_qty_selection_dialog('qty_$i', '', 'formel_$i', '')", t8('*/'), onclick => )
|
|
310 |
. hidden_tag("formel_$i", $form->{"formel_$i"})
|
|
322 | 311 |
if $form->{"formel_$i"}; |
323 | 312 |
|
324 | 313 |
$column_data{ship} = ''; |
... | ... | |
328 | 317 |
$ship_qty /= ( $all_units->{$form->{"unit_$i"}}->{factor} || 1 ); |
329 | 318 |
|
330 | 319 |
$column_data{ship} = $form->format_amount(\%myconfig, $form->round_amount($ship_qty, 2) * 1) . ' ' . $form->{"unit_$i"} |
331 |
. $cgi->hidden(-name => "ship_$i", -value => $form->{"ship_$i"}, $qty_dec);
|
|
320 |
. hidden_tag("ship_$i", _format_number($form->{"ship_$i"}, $qty_dec));
|
|
332 | 321 |
|
333 | 322 |
my $ship_missing_qty = $form->{"qty_$i"} - $ship_qty; |
334 | 323 |
my $ship_missing_amount = $form->round_amount($ship_missing_qty * $form->{"sellprice_$i"} * (100 - $form->{"discount_$i"}) / 100 / $price_factor, 2); |
... | ... | |
351 | 340 |
my $discount = $price_source->discount_from_source($::form->{"active_discount_source_$i"}); |
352 | 341 |
my $best_price = $price_source->best_price; |
353 | 342 |
my $best_discount = $price_source->best_discount; |
354 |
$column_data{price_source} .= $cgi->button(-value => $price->source_description, -onClick => "kivi.io.price_chooser($i)");
|
|
343 |
$column_data{price_source} .= button_tag("kivi.io.price_chooser($i)", $price->source_description);
|
|
355 | 344 |
if ($price->source) { |
356 |
$column_data{price_source} .= ' ' . $cgi->img({src => 'image/flag-red.png', alt => $price->invalid, title => $price->invalid }) if $price->invalid;
|
|
357 |
$column_data{price_source} .= ' ' . $cgi->img({src => 'image/flag-red.png', alt => $price->missing, title => $price->missing }) if $price->missing;
|
|
345 |
$column_data{price_source} .= ' ' . html_tag("img", undef, src => 'image/flag-red.png', alt => $price->invalid, title => $price->invalid ) if $price->invalid;
|
|
346 |
$column_data{price_source} .= ' ' . html_tag("img", undef, src => 'image/flag-red.png', alt => $price->missing, title => $price->missing ) if $price->missing;
|
|
358 | 347 |
if (!$price->missing && !$price->invalid) { |
359 |
$column_data{price_source} .= ' ' . $cgi->img({src => 'image/up.png', alt => t8('This price has since gone up'), title => t8('This price has since gone up' ) }) if $price->price - $record_item->sellprice > 0.01;
|
|
360 |
$column_data{price_source} .= ' ' . $cgi->img({src => 'image/down.png', alt => t8('This price has since gone down'), title => t8('This price has since gone down') }) if $price->price - $record_item->sellprice < -0.01;
|
|
361 |
$column_data{price_source} .= ' ' . $cgi->img({src => 'image/ok.png', alt => t8('There is a better price available'), title => t8('There is a better price available') }) if $best_price && $price->source ne $price_source->best_price->source;
|
|
348 |
$column_data{price_source} .= ' ' . html_tag("img", undef, src => 'image/up.png', alt => t8('This price has since gone up'), title => t8('This price has since gone up' ) ) if $price->price - $record_item->sellprice > 0.01;
|
|
349 |
$column_data{price_source} .= ' ' . html_tag("img", undef, src => 'image/down.png', alt => t8('This price has since gone down'), title => t8('This price has since gone down') ) if $price->price - $record_item->sellprice < -0.01;
|
|
350 |
$column_data{price_source} .= ' ' . html_tag("img", undef, src => 'image/ok.png', alt => t8('There is a better price available'), title => t8('There is a better price available') ) if $best_price && $price->source ne $price_source->best_price->source;
|
|
362 | 351 |
} |
363 | 352 |
} |
364 | 353 |
if ($discount->source) { |
365 |
$column_data{discount_source} .= ' ' . $cgi->img({src => 'image/flag-red.png', alt => $discount->invalid, title => $discount->invalid }) if $discount->invalid;
|
|
366 |
$column_data{discount_source} .= ' ' . $cgi->img({src => 'image/flag-red.png', alt => $discount->missing, title => $discount->missing }) if $discount->missing;
|
|
354 |
$column_data{discount_source} .= ' ' . html_tag("img", undef, src => 'image/flag-red.png', alt => $discount->invalid, title => $discount->invalid ) if $discount->invalid;
|
|
355 |
$column_data{discount_source} .= ' ' . html_tag("img", undef, src => 'image/flag-red.png', alt => $discount->missing, title => $discount->missing ) if $discount->missing;
|
|
367 | 356 |
if (!$discount->missing && !$discount->invalid) { |
368 |
$column_data{price_source} .= ' ' . $cgi->img({src => 'image/up.png', alt => t8('This discount has since gone up'), title => t8('This discount has since gone up') }) if $discount->discount * 100 - $record_item->discount > 0.01;
|
|
369 |
$column_data{price_source} .= ' ' . $cgi->img({src => 'image/down.png', alt => t8('This discount has since gone down'), title => t8('This discount has since gone down') }) if $discount->discount * 100 - $record_item->discount < -0.01;
|
|
370 |
$column_data{price_source} .= ' ' . $cgi->img({src => 'image/ok.png', alt => t8('There is a better discount available'), title => t8('There is a better discount available') }) if $best_discount && $discount->source ne $price_source->best_discount->source;
|
|
357 |
$column_data{price_source} .= ' ' . html_tag("img", undef, src => 'image/up.png', alt => t8('This discount has since gone up'), title => t8('This discount has since gone up') ) if $discount->discount * 100 - $record_item->discount > 0.01;
|
|
358 |
$column_data{price_source} .= ' ' . html_tag("img", undef, src => 'image/down.png', alt => t8('This discount has since gone down'), title => t8('This discount has since gone down') ) if $discount->discount * 100 - $record_item->discount < -0.01;
|
|
359 |
$column_data{price_source} .= ' ' . html_tag("img", undef, src => 'image/ok.png', alt => t8('There is a better discount available'), title => t8('There is a better discount available') ) if $best_discount && $discount->source ne $price_source->best_discount->source;
|
|
371 | 360 |
} |
372 | 361 |
} |
373 | 362 |
} |
... | ... | |
376 | 365 |
my $edit_prices = $right_to_edit_prices && (!$::form->{"active_price_source_$i"} || !$price || $price->editable); |
377 | 366 |
my $edit_discounts = $right_to_edit_prices && !$::form->{"active_discount_source_$i"}; |
378 | 367 |
$column_data{sellprice} = (!$edit_prices) |
379 |
? $cgi->hidden( -name => "sellprice_$i", -id => "sellprice_$i", -value => $sellprice_value) . $sellprice_value
|
|
380 |
: $cgi->textfield(-name => "sellprice_$i", -id => "sellprice_$i", -size => 10, -class => "numeric", -value => $sellprice_value);
|
|
368 |
? hidden_tag("sellprice_$i", $sellprice_value, id => "sellprice_$i") . $sellprice_value
|
|
369 |
: input_tag("sellprice_$i", $sellprice_value, id => "sellprice_$i", "data-validate" => "number", size => 10, class => "numeric");
|
|
381 | 370 |
$column_data{discount} = (!$edit_discounts) |
382 |
? $cgi->hidden( -name => "discount_$i", -id => "discount_$i", -value => $discount_value) . $discount_value . ' %'
|
|
383 |
: $cgi->textfield(-name => "discount_$i", -id => "discount_$i", -size => 3, -"data-validate" => "number", -class => "numeric", -value => $discount_value);
|
|
371 |
? hidden_tag("discount_$i", $discount_value, id => "discount_$i") . $discount_value . ' %'
|
|
372 |
: input_tag("discount_$i", $discount_value, id => "discount_$i", size => 3, "data-validate" => "number", class => "numeric");
|
|
384 | 373 |
|
385 | 374 |
if ($is_delivery_order) { |
386 | 375 |
$column_data{stock_in_out} = calculate_stock_in_out($i); |
387 | 376 |
} |
388 | 377 |
|
389 | 378 |
$column_data{serialnr} = qq|<input name="serialnumber_$i" size="15" value="$form->{"serialnumber_$i"}">|; |
390 |
$column_data{projectnr} = NTI($cgi->popup_menu( |
|
391 |
'-name' => "project_id_$i", |
|
392 |
'-values' => \@projectnumber_values, |
|
393 |
'-labels' => \%projectnumber_labels, |
|
394 |
'-default' => $form->{"project_id_$i"} |
|
395 |
)); |
|
379 |
$column_data{projectnr} = select_tag("project_id_$i", $form->{"ALL_PROJECTS"}, default => $form->{"project_id_$i"}, title_key => 'projectnumber', with_empty => 1); |
|
396 | 380 |
$column_data{reqdate} = qq|<input name="reqdate_$i" size="11" data-validate="date" value="$form->{"reqdate_$i"}">|; |
397 | 381 |
$column_data{subtotal} = sprintf qq|<input type="checkbox" name="subtotal_$i" value="1" %s>|, $form->{"subtotal_$i"} ? 'checked' : ''; |
398 | 382 |
|
... | ... | |
475 | 459 |
} |
476 | 460 |
|
477 | 461 |
my @HIDDENS = map { value => $_}, ( |
478 |
$cgi->hidden("-name" => "unit_old_$i", "-value" => $form->{"selected_unit_$i"}),
|
|
479 |
$cgi->hidden("-name" => "price_new_$i", "-value" => $form->format_amount(\%myconfig, $form->{"price_new_$i"})),
|
|
480 |
map { ($cgi->hidden("-name" => $_, "-id" => $_, "-value" => $form->{$_})); } map { $_."_$i" }
|
|
462 |
hidden_tag("unit_old_$i", => $form->{"selected_unit_$i"}),
|
|
463 |
hidden_tag("price_new_$i", _format_number($form->{"price_new_$i"})),
|
|
464 |
map { hidden_tag($_, $form->{$_}, id => $_) } map { $_."_$i" }
|
|
481 | 465 |
(qw(bo price_old id inventory_accno bin partsgroup partnotes active_price_source active_discount_source |
482 | 466 |
income_accno expense_accno listprice part_type taxaccounts ordnumber donumber transdate cusordnumber |
483 | 467 |
longdescription basefactor marge_absolut marge_percent marge_price_factor weight), @hidden_vars) |
... | ... | |
746 | 730 |
$::form->{"id_$::form->{rowcount}"} = $part->id; |
747 | 731 |
|
748 | 732 |
my $url = build_std_url("script=$::form->{script}", "RESTORE_FORM_FROM_SESSION_ID=" . $::auth->save_form_in_session); |
749 |
print $::request->{cgi}->redirect($url);
|
|
733 |
print $::request->cgi->redirect($url);
|
|
750 | 734 |
} |
751 | 735 |
|
752 | 736 |
sub check_form { |
Auch abrufbar als: Unified diff
CGI.pm nicht mehr als html Generator verwenden
Die restlichen Vorkommen sind jetzt noch
- header
- redirect
- cookie
und sind alle der Form: $::request->cgi->...