Revision d13114c0
Von Tamino Steinert vor 8 Tagen hinzugefügt
- ID d13114c01420dfdd4e0f53909647cf495e111c04
- Vorgänger e84b30f1
SL/Controller/Part.pm | ||
---|---|---|
22 | 22 |
use SL::DB::Part; |
23 | 23 |
use SL::DB::PartsGroup; |
24 | 24 |
use SL::DB::PriceRuleItem; |
25 |
use SL::DB::PartLabelPrint; |
|
25 | 26 |
use SL::DB::PurchaseBasketItem; |
26 | 27 |
use SL::DB::Shop; |
27 | 28 |
use SL::Helper::Flash; |
... | ... | |
34 | 35 |
use SL::MoreCommon qw(save_form); |
35 | 36 |
use SL::Presenter::EscapedText qw(escape is_escaped); |
36 | 37 |
use SL::Presenter::Part; |
37 |
use SL::Presenter::Tag qw(select_tag); |
|
38 |
use SL::Presenter::Tag qw(select_tag checkbox_tag); |
|
39 |
use SL::ReportGenerator; |
|
40 |
use SL::Controller::Helper::ReportGenerator; |
|
38 | 41 |
|
39 | 42 |
use Rose::Object::MakeMethods::Generic ( |
40 | 43 |
'scalar --get_set_init' => [ qw(parts models part p warehouses multi_items_models |
... | ... | |
138 | 141 |
$self->js_reset_part_after_save(); |
139 | 142 |
$self->js->flash('info', t8('The item has been saved.')); |
140 | 143 |
|
144 |
$self->print_part($self->part); |
|
145 |
|
|
146 |
$self->js->render(); |
|
147 |
} |
|
148 |
|
|
149 |
sub action_print_multi { |
|
150 |
my ($self) = @_; |
|
151 |
|
|
152 |
my $parts = SL::DB::Manager::Part->get_all(where => [id => $::form->{ids}]); |
|
153 |
foreach my $part(@{$parts}) { |
|
154 |
$self->print_part($part); |
|
155 |
} |
|
156 |
|
|
157 |
$self->js->render(); |
|
158 |
} |
|
159 |
|
|
160 |
sub print_part { |
|
161 |
my ($self, $part) = @_; |
|
162 |
|
|
141 | 163 |
my $formname = $::form->{print_options}->{formname}; |
142 | 164 |
my $format = $::form->{print_options}->{format}; |
143 | 165 |
my $media = $::form->{print_options}->{media}; |
... | ... | |
147 | 169 |
$language = SL::DB::Manager::Language->find_by( |
148 | 170 |
id => $::form->{print_options}->{language_id} |
149 | 171 |
); |
172 |
} |
|
150 | 173 |
my $copies; |
151 | 174 |
if ($::form->{print_options}->{part_labels_for_stock}) { |
152 |
$copies = $self->part->stockqty;
|
|
175 |
$copies = $part->stockqty; |
|
153 | 176 |
} else { |
154 | 177 |
$copies = $::form->{print_options}->{copies}; |
155 | 178 |
} |
... | ... | |
178 | 201 |
} |
179 | 202 |
|
180 | 203 |
my $print_form = Form->new(''); |
181 |
$print_form->{part} = $self->part;
|
|
204 |
$print_form->{part} = $part; |
|
182 | 205 |
|
183 | 206 |
# for doc_filename |
184 | 207 |
$print_form->{type} = 'part'; |
185 | 208 |
$print_form->{formname} = $formname; |
186 | 209 |
$print_form->{format} = $format; |
187 |
$print_form->{partnumber} = $self->part->partnumber;
|
|
210 |
$print_form->{partnumber} = $part->partnumber; |
|
188 | 211 |
$print_form->{language} = $language && ("_" . |
189 | 212 |
($language->template_code || $language->description) |
190 | 213 |
); |
... | ... | |
244 | 267 |
->flash('error', t8("Creating the PDF failed!")) |
245 | 268 |
->flash('error', $@); |
246 | 269 |
}; |
247 |
|
|
248 |
$self->js->render(); |
|
249 | 270 |
} |
250 | 271 |
|
251 | 272 |
sub action_save_and_purchase_order { |
... | ... | |
915 | 936 |
$self->render(\$output, { layout => 0, process => 0 }); |
916 | 937 |
} |
917 | 938 |
|
939 |
sub action_search_print_part_labels_of_changed_prices { |
|
940 |
my ($self) = @_; |
|
941 |
$self->_setup_search_print_part_labels_of_changed_prices_action_bar(); |
|
942 |
|
|
943 |
$::form->{filter} ||= {}; |
|
944 |
|
|
945 |
$::form->{filter}->{price_change_printed} ||= { |
|
946 |
template => 'part_label', |
|
947 |
print_type => 'stock', |
|
948 |
printed => 0 |
|
949 |
}; |
|
950 |
|
|
951 |
my $price_change_printed =$::form->{filter}->{price_change_printed}; |
|
952 |
$::form->{filter}->{price_change_printed} = \$price_change_printed; |
|
953 |
|
|
954 |
my $report = SL::ReportGenerator->new(\%::myconfig, $::form); |
|
955 |
|
|
956 |
$self->models->finalize; # for filter laundering |
|
957 |
|
|
958 |
$::form->{filter}->{price_change_printed} = ${$::form->{filter}->{price_change_printed}}; |
|
959 |
|
|
960 |
my $callback = $self->models->get_callback; |
|
961 |
|
|
962 |
$self->{report} = $report; |
|
963 |
|
|
964 |
my @columns_order = qw( |
|
965 |
id_check_box |
|
966 |
partnumber |
|
967 |
ean |
|
968 |
description |
|
969 |
notes |
|
970 |
partsgroup |
|
971 |
); |
|
972 |
|
|
973 |
my @default_columns = qw( |
|
974 |
id_check_box |
|
975 |
partnumber |
|
976 |
ean |
|
977 |
description |
|
978 |
partsgroup |
|
979 |
); |
|
980 |
|
|
981 |
my %column_defs = ( |
|
982 |
id_check_box => { |
|
983 |
raw_data => sub { |
|
984 |
checkbox_tag("ids[]", value => $_[0]->id, "data-checkall" => 1, checked => 1); |
|
985 |
}, |
|
986 |
raw_header_data => checkbox_tag("", id => "check_all", checkall => "[data-checkall=2]", checked => 1), |
|
987 |
text => ' ', |
|
988 |
}, |
|
989 |
partnumber => { |
|
990 |
obj_link => sub {$self->url_for(action => 'edit', 'part.id' => $_[0]->id, callback => $callback)}, |
|
991 |
sub => sub { $_[0]->partnumber }, |
|
992 |
}, |
|
993 |
ean => { |
|
994 |
obj_link => sub {$self->url_for(action => 'edit', 'part.id' => $_[0]->id, callback => $callback)}, |
|
995 |
sub => sub { $_[0]->ean }, |
|
996 |
}, |
|
997 |
description => { |
|
998 |
sub => sub {$_[0]->description }, |
|
999 |
}, |
|
1000 |
notes => { |
|
1001 |
sub => sub {$_[0]->notes }, |
|
1002 |
}, |
|
1003 |
partsgroup => { |
|
1004 |
sub => sub {t8($_[0]->partsgroup ? $_[0]->partsgroup->partsgroup : '') }, |
|
1005 |
}, |
|
1006 |
); |
|
1007 |
|
|
1008 |
$column_defs{$_}->{text} ||= t8( $self->models->get_sort_spec->{$_}->{title} || $_ ) |
|
1009 |
for keys %column_defs; |
|
1010 |
|
|
1011 |
unless ($::form->{active_in_report}) { |
|
1012 |
$::form->{active_in_report}->{$_} = 1 foreach @default_columns; |
|
1013 |
} |
|
1014 |
|
|
1015 |
$self->models->add_additional_url_params( |
|
1016 |
active_in_report => $::form->{active_in_report}); |
|
1017 |
map { $column_defs{$_}->{visible} = $::form->{active_in_report}->{"$_"} || 0 } |
|
1018 |
grep {$_ ne 'id_check_box'} |
|
1019 |
keys %column_defs; |
|
1020 |
|
|
1021 |
# make all sortable |
|
1022 |
my @sortable = |
|
1023 |
grep {$_ ne 'id_check_box'} |
|
1024 |
keys %column_defs; |
|
1025 |
|
|
1026 |
use SL::Presenter::Filter::Part; |
|
1027 |
my $filter_html = SL::Presenter::Filter::Part::filter( |
|
1028 |
$::form->{filter}, |
|
1029 |
show_price_change_printed_filter => 1, |
|
1030 |
active_in_report => $::form->{active_in_report} |
|
1031 |
); |
|
1032 |
|
|
1033 |
$report->set_options( |
|
1034 |
std_column_visibility => 1, |
|
1035 |
controller_class => 'Part', |
|
1036 |
output_format => 'HTML', |
|
1037 |
raw_top_info_text => $self->render( |
|
1038 |
'part/_print_part_labels_of_changed_prices_report_top', |
|
1039 |
{ output => 0 }, |
|
1040 |
FILTER_HTML => $filter_html, |
|
1041 |
), |
|
1042 |
raw_bottom_info_text => $self->render( |
|
1043 |
'part/_print_part_labels_of_changed_prices_report_bottom', |
|
1044 |
{ output => 0 }, |
|
1045 |
models => $self->models |
|
1046 |
), |
|
1047 |
title => t8('Parts with Changed Prices'), |
|
1048 |
allow_pdf_export => 1, |
|
1049 |
allow_csv_export => 1, |
|
1050 |
); |
|
1051 |
|
|
1052 |
$report->set_columns(%column_defs); |
|
1053 |
$report->set_column_order(@columns_order); |
|
1054 |
$report->set_export_options( |
|
1055 |
'search_print_part_labels_of_changed_prices', |
|
1056 |
qw(filter active_in_report) |
|
1057 |
); |
|
1058 |
$report->set_options_from_form; |
|
1059 |
$self->models->set_report_generator_sort_options( |
|
1060 |
report => $report, |
|
1061 |
sortable_columns => \@sortable |
|
1062 |
); |
|
1063 |
|
|
1064 |
$self->report_generator_list_objects( |
|
1065 |
report => $report, |
|
1066 |
objects => $self->models->get, |
|
1067 |
); |
|
1068 |
} |
|
1069 |
|
|
918 | 1070 |
sub action_print_label { |
919 | 1071 |
my ($self) = @_; |
920 | 1072 |
# TODO: implement |
... | ... | |
1437 | 1589 |
dir => 1, |
1438 | 1590 |
}, |
1439 | 1591 |
partnumber => t8('Partnumber'), |
1440 |
description => t8('Description'), |
|
1592 |
description => t8('Description'), |
|
1593 |
ean => t8('EAN'), |
|
1594 |
notes => t8('Notes'), |
|
1595 |
partsgroup => t8('Partsgroup'), |
|
1441 | 1596 |
}, |
1442 | 1597 |
with_objects => [ qw(unit_obj classification) ], |
1443 | 1598 |
); |
... | ... | |
2025 | 2180 |
} |
2026 | 2181 |
} |
2027 | 2182 |
|
2183 |
sub _setup_search_print_part_labels_of_changed_prices_action_bar { |
|
2184 |
my ($self, %params) = @_; |
|
2185 |
|
|
2186 |
for my $bar ($::request->layout->get('actionbar')) { |
|
2187 |
$bar->add( |
|
2188 |
action => [ |
|
2189 |
t8('Update'), |
|
2190 |
submit => [ |
|
2191 |
'#filter_form', { |
|
2192 |
action => 'Part/search_print_part_labels_of_changed_prices', |
|
2193 |
} |
|
2194 |
], |
|
2195 |
accesskey => 'enter', |
|
2196 |
], |
|
2197 |
combobox => [ |
|
2198 |
action => [ |
|
2199 |
t8('Print'), |
|
2200 |
], |
|
2201 |
action => [ |
|
2202 |
t8('Print one Label'), |
|
2203 |
call => [ 'kivi.Part.show_print_options' ], |
|
2204 |
], |
|
2205 |
action => [ |
|
2206 |
t8('Print Labels for Stock'), |
|
2207 |
call => [ 'kivi.Part.show_part_labels_for_stock_print_options' ], |
|
2208 |
], |
|
2209 |
], |
|
2210 |
); |
|
2211 |
} |
|
2212 |
} |
|
2213 |
|
|
2028 | 2214 |
1; |
2029 | 2215 |
|
2030 | 2216 |
__END__ |
Auch abrufbar als: Unified diff
S:C:Part: Massendruck für Artikeletiketten