Revision a66591cc
Von Bernd Bleßmann vor mehr als 5 Jahren hinzugefügt
SL/Controller/Order.pm | ||
---|---|---|
39 | 39 |
use Rose::Object::MakeMethods::Generic |
40 | 40 |
( |
41 | 41 |
scalar => [ qw(item_ids_to_delete) ], |
42 |
'scalar --get_set_init' => [ qw(order valid_types type cv p multi_items_models all_price_factors) ], |
|
42 |
'scalar --get_set_init' => [ qw(order valid_types type cv p multi_items_models all_price_factors search_cvpartnumber) ],
|
|
43 | 43 |
); |
44 | 44 |
|
45 | 45 |
|
... | ... | |
685 | 685 |
->focus( '#order_' . $self->cv . '_id'); |
686 | 686 |
|
687 | 687 |
$self->js_redisplay_amounts_and_taxes; |
688 |
$self->js_redisplay_cvpartnumbers; |
|
688 | 689 |
$self->js->render(); |
689 | 690 |
} |
690 | 691 |
|
... | ... | |
755 | 756 |
|
756 | 757 |
$self->recalc(); |
757 | 758 |
|
759 |
$self->get_item_cvpartnumber($item); |
|
760 |
|
|
758 | 761 |
my $item_id = join('_', 'new', Time::HiRes::gettimeofday(), int rand 1000000000000); |
759 | 762 |
my $row_as_html = $self->p->render('order/tabs/_row', |
760 |
ITEM => $item, |
|
761 |
ID => $item_id, |
|
762 |
TYPE => $self->type, |
|
763 |
ALL_PRICE_FACTORS => $self->all_price_factors |
|
763 |
ITEM => $item, |
|
764 |
ID => $item_id, |
|
765 |
TYPE => $self->type, |
|
766 |
ALL_PRICE_FACTORS => $self->all_price_factors, |
|
767 |
SEARCH_CVPARTNUMBER => $self->search_cvpartnumber, |
|
764 | 768 |
); |
765 | 769 |
|
766 | 770 |
$self->js |
... | ... | |
781 | 785 |
|
782 | 786 |
$self->order->add_items( $item ); |
783 | 787 |
$self->recalc(); |
788 |
$self->get_item_cvpartnumber($item); |
|
784 | 789 |
my $item_id = join('_', 'new', Time::HiRes::gettimeofday(), int rand 1000000000000); |
785 | 790 |
my $row_as_html = $self->p->render('order/tabs/_row', |
786 |
ITEM => $item, |
|
787 |
ID => $item_id, |
|
788 |
TYPE => $self->type, |
|
789 |
ALL_PRICE_FACTORS => $self->all_price_factors |
|
791 |
ITEM => $item, |
|
792 |
ID => $item_id, |
|
793 |
TYPE => $self->type, |
|
794 |
ALL_PRICE_FACTORS => $self->all_price_factors, |
|
795 |
SEARCH_CVPARTNUMBER => $self->search_cvpartnumber, |
|
790 | 796 |
); |
791 | 797 |
$self->js |
792 | 798 |
->append('#row_table_id', $row_as_html); |
... | ... | |
862 | 868 |
$self->recalc(); |
863 | 869 |
|
864 | 870 |
foreach my $item (@items) { |
871 |
$self->get_item_cvpartnumber($item); |
|
865 | 872 |
my $item_id = join('_', 'new', Time::HiRes::gettimeofday(), int rand 1000000000000); |
866 | 873 |
my $row_as_html = $self->p->render('order/tabs/_row', |
867 |
ITEM => $item, |
|
868 |
ID => $item_id, |
|
869 |
TYPE => $self->type, |
|
870 |
ALL_PRICE_FACTORS => $self->all_price_factors |
|
874 |
ITEM => $item, |
|
875 |
ID => $item_id, |
|
876 |
TYPE => $self->type, |
|
877 |
ALL_PRICE_FACTORS => $self->all_price_factors, |
|
878 |
SEARCH_CVPARTNUMBER => $self->search_cvpartnumber, |
|
871 | 879 |
); |
872 | 880 |
|
873 | 881 |
$self->js->append('#row_table_id', $row_as_html); |
... | ... | |
900 | 908 |
my ($self) = @_; |
901 | 909 |
|
902 | 910 |
my %sort_keys = ( |
903 |
partnumber => sub { $_[0]->part->partnumber }, |
|
904 |
description => sub { $_[0]->description }, |
|
905 |
qty => sub { $_[0]->qty }, |
|
906 |
sellprice => sub { $_[0]->sellprice }, |
|
907 |
discount => sub { $_[0]->discount }, |
|
911 |
partnumber => sub { $_[0]->part->partnumber }, |
|
912 |
description => sub { $_[0]->description }, |
|
913 |
qty => sub { $_[0]->qty }, |
|
914 |
sellprice => sub { $_[0]->sellprice }, |
|
915 |
discount => sub { $_[0]->discount }, |
|
916 |
cvpartnumber => sub { $_[0]->{cvpartnumber} }, |
|
908 | 917 |
); |
909 | 918 |
|
919 |
$self->get_item_cvpartnumber($_) for @{$self->order->items_sorted}; |
|
920 |
|
|
910 | 921 |
my $method = $sort_keys{$::form->{order_by}}; |
911 | 922 |
my @to_sort = map { { old_pos => $_->position, order_by => $method->($_) } } @{ $self->order->items_sorted }; |
912 | 923 |
if ($::form->{sort_dir}) { |
... | ... | |
1054 | 1065 |
->insertBefore($self->build_tax_rows, '#amount_row_id'); |
1055 | 1066 |
} |
1056 | 1067 |
|
1068 |
sub js_redisplay_cvpartnumbers { |
|
1069 |
my ($self) = @_; |
|
1070 |
|
|
1071 |
$self->get_item_cvpartnumber($_) for @{$self->order->items_sorted}; |
|
1072 |
|
|
1073 |
my @data = map {[$_->{cvpartnumber}]} @{ $self->order->items_sorted }; |
|
1074 |
|
|
1075 |
$self->js |
|
1076 |
->run('kivi.Order.redisplay_cvpartnumbers', \@data); |
|
1077 |
} |
|
1078 |
|
|
1057 | 1079 |
sub js_reset_order_and_item_ids_after_save { |
1058 | 1080 |
my ($self) = @_; |
1059 | 1081 |
|
... | ... | |
1104 | 1126 |
return $cv; |
1105 | 1127 |
} |
1106 | 1128 |
|
1129 |
sub init_search_cvpartnumber { |
|
1130 |
my ($self) = @_; |
|
1131 |
|
|
1132 |
my $user_prefs = SL::Helper::UserPreferences::PartPickerSearch->new(); |
|
1133 |
my $search_cvpartnumber; |
|
1134 |
$search_cvpartnumber = !!$user_prefs->get_sales_search_customer_partnumber() if $self->cv eq 'customer'; |
|
1135 |
$search_cvpartnumber = !!$user_prefs->get_purchase_search_makemodel() if $self->cv eq 'vendor'; |
|
1136 |
|
|
1137 |
return $search_cvpartnumber; |
|
1138 |
} |
|
1139 |
|
|
1107 | 1140 |
sub init_p { |
1108 | 1141 |
SL::Presenter->get; |
1109 | 1142 |
} |
... | ... | |
1564 | 1597 |
$self->{order_probabilities} = [ map { { title => ($_ * 10) . '%', id => $_ * 10 } } (0..10) ]; |
1565 | 1598 |
$self->{positions_scrollbar_height} = SL::Helper::UserPreferences::PositionsScrollbar->new()->get_height(); |
1566 | 1599 |
|
1567 |
my $user_prefs = SL::Helper::UserPreferences::PartPickerSearch->new(); |
|
1568 |
$self->{search_cvpartnumber} = !!$user_prefs->get_sales_search_customer_partnumber() if $self->cv eq 'customer'; |
|
1569 |
$self->{search_cvpartnumber} = !!$user_prefs->get_purchase_search_makemodel() if $self->cv eq 'vendor'; |
|
1570 |
|
|
1571 | 1600 |
my $print_form = Form->new(''); |
1572 | 1601 |
$print_form->{type} = $self->type; |
1573 | 1602 |
$print_form->{printers} = SL::DB::Manager::Printer->get_all_sorted; |
... | ... | |
1605 | 1634 |
} } @all_objects; |
1606 | 1635 |
} |
1607 | 1636 |
|
1637 |
$self->get_item_cvpartnumber($_) for @{$self->order->items_sorted}; |
|
1638 |
|
|
1608 | 1639 |
$::request->{layout}->use_javascript("${_}.js") for qw(kivi.SalesPurchase kivi.Order kivi.File ckeditor/ckeditor ckeditor/adapters/jquery edit_periodic_invoices_config calculate_qty); |
1609 | 1640 |
$self->setup_edit_action_bar; |
1610 | 1641 |
} |
... | ... | |
1834 | 1865 |
: ''; |
1835 | 1866 |
} |
1836 | 1867 |
|
1868 |
sub get_item_cvpartnumber { |
|
1869 |
my ($self, $item) = @_; |
|
1870 |
|
|
1871 |
if ($self->cv eq 'vendor') { |
|
1872 |
my @mms = grep { $_->make eq $self->order->customervendor->id } @{$item->part->makemodels}; |
|
1873 |
$item->{cvpartnumber} = $mms[0]->model if scalar @mms; |
|
1874 |
} elsif ($self->cv eq 'customer') { |
|
1875 |
my @cps = grep { $_->customer_id eq $self->order->customervendor->id } @{$item->part->customerprices}; |
|
1876 |
$item->{cvpartnumber} = $cps[0]->customer_partnumber if scalar @cps; |
|
1877 |
} |
|
1878 |
} |
|
1879 |
|
|
1837 | 1880 |
sub sales_order_type { |
1838 | 1881 |
'sales_order'; |
1839 | 1882 |
} |
Auch abrufbar als: Unified diff
Auftrags-Controller: Kunden- bzw. Lieferanten-Art-Nr. in Pos-Zeile anzeigen.
… sofern in den Benutzereinstellungen auch die Suche danach ausgewählt ist.