Revision cb253140
Von Moritz Bunkus vor mehr als 13 Jahren hinzugefügt
bin/mozilla/io.pl | ||
---|---|---|
36 | 36 |
# |
37 | 37 |
####################################################################### |
38 | 38 |
|
39 |
use Carp; |
|
39 | 40 |
use CGI; |
40 | 41 |
use CGI::Ajax; |
41 | 42 |
use List::Util qw(min max first); |
... | ... | |
437 | 438 |
sub select_item { |
438 | 439 |
$main::lxdebug->enter_sub(); |
439 | 440 |
|
441 |
my %params = @_; |
|
442 |
|
|
440 | 443 |
my $form = $main::form; |
441 | 444 |
my %myconfig = %main::myconfig; |
442 | 445 |
my $locale = $main::locale; |
443 | 446 |
my $cgi = $main::cgi; |
444 | 447 |
|
445 |
# diese variable kommt schon in der methode display_row vor, kann man die besser wiederverwenden? @mb fragen. ich check das jetzt erstmal so ein |
|
446 |
my $is_purchase = (first { $_ eq $form->{type} } qw(request_quotation purchase_order purchase_delivery_order)) || ($form->{script} eq 'ir.pl'); |
|
448 |
my $mode = $params{mode} || croak "Missing parameter 'mode'"; |
|
449 |
my $is_purchase = $mode eq 'IS'; |
|
450 |
|
|
447 | 451 |
_check_io_auth(); |
448 | 452 |
|
449 | 453 |
my @column_index = qw(ndx partnumber description rop onhand unit sellprice); |
... | ... | |
455 | 459 |
qq|<th class="listheading">| . $locale->text('Part Description') . qq|</th>|; |
456 | 460 |
$column_data{sellprice} = |
457 | 461 |
qq|<th class="listheading">| . $locale->text('Price') . qq|</th>|; |
458 |
if ($is_purchase){
|
|
459 |
$column_data{rop} =
|
|
460 |
qq|<th class="listheading">| . $locale->text('ROP') . qq|</th>|;
|
|
461 |
}# ende if $is_purchase -> Überschrift Mindestlagerbestand - ähnliche Prüfung weiter unten
|
|
462 |
if ($is_purchase){ |
|
463 |
$column_data{rop} = |
|
464 |
qq|<th class="listheading">| . $locale->text('ROP') . qq|</th>|; |
|
465 |
}# ende if $is_purchase -> Überschrift Mindestlagerbestand - ähnliche Prüfung weiter unten |
|
462 | 466 |
$column_data{onhand} = |
463 | 467 |
qq|<th class="listheading">| . $locale->text('Qty') . qq|</th>|; |
464 | 468 |
$column_data{unit} = |
... | ... | |
485 | 489 |
|
486 | 490 |
print qq|</tr>|; |
487 | 491 |
|
488 |
my @new_fields = |
|
489 |
qw(bin listprice inventory_accno income_accno expense_accno unit weight |
|
490 |
assembly taxaccounts partsgroup formel longdescription not_discountable |
|
491 |
part_payment_id partnotes id lastcost price_factor_id price_factor); |
|
492 |
push @new_fields, "lizenzen" if $::lx_office_conf{features}->{lizenzen}; |
|
493 |
push @new_fields, grep { m/^ic_cvar_/ } keys %{ $form->{item_list}->[0] }; |
|
494 |
|
|
495 | 492 |
my $i = 0; |
496 | 493 |
my $j; |
497 | 494 |
foreach my $ref (@{ $form->{item_list} }) { |
... | ... | |
509 | 506 |
} |
510 | 507 |
} |
511 | 508 |
|
512 |
map { $ref->{$_} =~ s/\"/"/g } qw(partnumber description unit); |
|
513 |
|
|
514 | 509 |
my $display_sellprice = $ref->{sellprice} * (1 - $form->{tradediscount}); |
515 | 510 |
$display_sellprice /= $ref->{price_factor} if ($ref->{price_factor}); |
516 | 511 |
$display_sellprice = $form->format_amount(\%myconfig, $display_sellprice, 2); |
512 |
my $new_id = $ref->{id}; |
|
513 |
|
|
514 |
map { $ref->{$_} = H($ref->{$_}) } qw(id partnumber description unit); |
|
515 |
|
|
516 |
$column_data{ndx} = qq|<td><input name="select_item_id" class="radio" type="radio" value="${new_id}" $checked></td>|; |
|
517 |
$column_data{partnumber} = qq|<td>$ref->{partnumber}</td>|; |
|
518 |
$column_data{description} = qq|<td>$ref->{description}</td>|; |
|
519 |
$column_data{sellprice} = qq|<td align="right">${display_sellprice}</td>|; |
|
520 |
$column_data{onhand} = qq|<td align="right">| . $form->format_amount(\%myconfig, $ref->{onhand}, '', " ") . qq|</td>|; |
|
521 |
$column_data{unit} = qq|<td>$ref->{unit}</td>|; |
|
517 | 522 |
|
518 |
$column_data{ndx} = |
|
519 |
qq|<td><input name="ndx" class="radio" type="radio" value="$i" $checked></td>|; |
|
520 |
$column_data{partnumber} = |
|
521 |
qq|<td><input name="new_partnumber_$i" type="hidden" value="$ref->{partnumber}">$ref->{partnumber}</td>|; |
|
522 |
$column_data{description} = |
|
523 |
qq|<td><input name="new_description_$i" type="hidden" value="$ref->{description}">$ref->{description}</td>|; |
|
524 |
$column_data{sellprice} = |
|
525 |
qq|<td align="right"><input name="new_sellprice_$i" type="hidden" value="$ref->{sellprice}">| |
|
526 |
. $display_sellprice |
|
527 |
. qq|</td>|; |
|
528 |
$column_data{onhand} = |
|
529 |
qq|<td align="right"><input name="new_onhand_$i" type="hidden" value="$ref->{onhand}">| |
|
530 |
. $form->format_amount(\%myconfig, $ref->{onhand}, '', " ") |
|
531 |
. qq|</td>|; |
|
532 | 523 |
if ($is_purchase){ |
533 |
$column_data{rop} = |
|
534 |
qq|<td align="right"><input name="new_rop$i" type="hidden" value="$ref->{rop}">| |
|
535 |
. $form->format_amount(\%myconfig, $ref->{rop}, '', " ") |
|
536 |
. qq|</td>|; |
|
524 |
$column_data{rop} = qq|<td align="right">| . $form->format_amount(\%myconfig, $ref->{rop}, '', " ") . qq|</td>|; |
|
537 | 525 |
}# ende if $is_purchase -> Falls der Aufruf über eine Einkaufsmaske kam, handelt es sich um einen Lieferantenauftrag und uns interessiert auch die Mindestbestandsmenge |
538 |
$column_data{unit} = |
|
539 |
qq|<td>$ref->{unit}</td>|; |
|
526 |
|
|
540 | 527 |
$j++; |
541 | 528 |
$j %= 2; |
542 | 529 |
print qq| |
... | ... | |
545 | 532 |
map { print "\n$column_data{$_}" } @column_index; |
546 | 533 |
|
547 | 534 |
print("</tr>\n"); |
548 |
|
|
549 |
print join "\n", map { $cgi->hidden("-name" => "new_${_}_$i", "-value" => $ref->{$_}) } @new_fields; |
|
550 |
print "\n"; |
|
551 | 535 |
} |
552 | 536 |
|
553 | 537 |
print qq| |
554 | 538 |
<tr><td colspan="8"><hr size="3" noshade></td></tr> |
555 | 539 |
</table> |
556 |
|
|
557 |
<input name="lastndx" type="hidden" value="$i"> |
|
558 |
|
|
559 | 540 |
|; |
560 | 541 |
|
561 | 542 |
# delete action variable |
562 | 543 |
map { delete $form->{$_} } qw(action item_list header); |
563 | 544 |
|
564 |
# save all other form variables |
|
565 |
foreach my $key (keys %${form}) { |
|
566 |
next if (($key eq 'login') || ($key eq 'password') || ('' ne ref $form->{$key})); |
|
567 |
$form->{$key} =~ s/\"/"/g; |
|
568 |
print qq|<input name="$key" type="hidden" value="$form->{$key}">\n|; |
|
569 |
} |
|
545 |
my $previous_form = $::auth->save_form_in_session(form => $form); |
|
570 | 546 |
|
571 | 547 |
print qq| |
548 |
<input name="select_item_mode" type="hidden" value="$mode"> |
|
549 |
<input name="select_item_previous_form" type="hidden" value="${previous_form}"> |
|
572 | 550 |
<input type="hidden" name="nextsub" value="item_selected"> |
573 | 551 |
|
574 | 552 |
<br> |
... | ... | |
591 | 569 |
|
592 | 570 |
_check_io_auth(); |
593 | 571 |
|
594 |
# replace the last row with the checked row |
|
595 |
my $i = $form->{rowcount}; |
|
596 |
$i = $form->{assembly_rows} if ($form->{item} eq 'assembly'); |
|
572 |
$::auth->restore_form_from_session($form->{select_item_previous_form} || croak('Missing previous form ID'), form => $form); |
|
597 | 573 |
|
598 |
# index for new item |
|
599 |
my $j = $form->{ndx}; |
|
574 |
my $mode = delete($form->{select_item_mode}) || croak 'Missing item selection mode'; |
|
575 |
my $id = delete($form->{select_item_id}) || croak 'Missing item selection ID'; |
|
576 |
my $i = $form->{ $mode eq 'IC' ? 'assembly_rows' : 'rowcount' }; |
|
600 | 577 |
|
601 |
#sk |
|
602 |
#($form->{"sellprice_$i"},$form->{"$pricegroup_old_$i"}) = split /--/, $form->{"sellprice_$i"}; |
|
603 |
#$form->{"sellprice_$i"} = $form->{"sellprice_$i"}; |
|
578 |
$form->{"id_${i}"} = $id; |
|
579 |
|
|
580 |
if ($mode eq 'IS') { |
|
581 |
IS->retrieve_item(\%myconfig, \%$form); |
|
582 |
} elsif ($mode eq 'IR') { |
|
583 |
IR->retrieve_item(\%myconfig, \%$form); |
|
584 |
} elsif ($mode eq 'IC') { |
|
585 |
IC->assembly_item(\%myconfig, \%$form); |
|
586 |
} else { |
|
587 |
croak "Invalid item selection mode '${mode}'"; |
|
588 |
} |
|
589 |
|
|
590 |
my $new_item = $form->{item_list}->[0] || croak "No item found for mode '${mode}' and ID '${id}'"; |
|
604 | 591 |
|
605 | 592 |
# if there was a price entered, override it |
606 | 593 |
my $sellprice = $form->parse_amount(\%myconfig, $form->{"sellprice_$i"}); |
... | ... | |
611 | 598 |
partsgroup formel longdescription not_discountable partnotes lastcost |
612 | 599 |
price_factor_id price_factor); |
613 | 600 |
|
601 |
push @new_fields, 'lizenzen' if $::lx_office_conf{features}->{lizenzen}; |
|
602 |
|
|
614 | 603 |
my $ic_cvar_configs = CVar->get_configs(module => 'IC'); |
615 | 604 |
push @new_fields, map { "ic_cvar_$_->{name}" } @{ $ic_cvar_configs }; |
616 | 605 |
|
617 |
map { $form->{"${_}_$i"} = $form->{"new_${_}_$j"} } @new_fields;
|
|
606 |
map { $form->{"${_}_$i"} = $new_item->{$_} } @new_fields;
|
|
618 | 607 |
|
619 |
$form->{"marge_price_factor_$i"} = $form->{"new_price_factor_$j"};
|
|
608 |
$form->{"marge_price_factor_$i"} = $new_item->{price_factor};
|
|
620 | 609 |
|
621 | 610 |
if ($form->{"part_payment_id_$i"} ne "") { |
622 | 611 |
$form->{payment_id} = $form->{"part_payment_id_$i"}; |
623 | 612 |
} |
624 | 613 |
|
625 |
if ($::lx_office_conf{features}->{lizenzen}) { |
|
626 |
map { $form->{"${_}_$i"} = $form->{"new_${_}_$j"} } qw(lizenzen); |
|
627 |
} |
|
628 |
|
|
629 | 614 |
my ($dec) = ($form->{"sellprice_$i"} =~ /\.(\d+)/); |
630 | 615 |
$dec = length $dec; |
631 | 616 |
my $decimalplaces = ($dec > 2) ? $dec : 2; |
... | ... | |
665 | 650 |
|
666 | 651 |
$form->{"runningnumber_$i"} = $i; |
667 | 652 |
|
668 |
# delete all the new_ variables |
|
669 |
for $i (1 .. $form->{lastndx}) { |
|
670 |
map { delete $form->{"new_${_}_$i"} } @new_fields; |
|
671 |
} |
|
672 |
|
|
673 |
map { delete $form->{$_} } qw(ndx lastndx nextsub); |
|
653 |
delete $form->{nextsub}; |
|
674 | 654 |
|
675 | 655 |
# format amounts |
676 | 656 |
map { |
Auch abrufbar als: Unified diff
Bei Artikelauswahl nur ID als Hidden mitschleifen, nicht alle Artikeldetails
Fix für Bug 1670.