Revision cf6f95c5
Von Moritz Bunkus vor mehr als 10 Jahren hinzugefügt
SL/Controller/RequirementSpecOrder.pm | ||
---|---|---|
111 | 111 |
my %orderitems_by_id = map { ($_->id => $_) } @{ $order->orderitems }; |
112 | 112 |
my %sections_by_id = map { ($_->id => $_) } @{ $sections }; |
113 | 113 |
$self->{parts} = { map { ($_->id => $_) } @{ SL::DB::Manager::Part->get_all(where => [ id => [ uniq map { $_->order_part_id } @{ $sections } ] ]) } }; |
114 |
my $language_id = $self->requirement_spec->customer->language_id; |
|
114 | 115 |
|
115 | 116 |
my %sections_seen; |
116 | 117 |
|
... | ... | |
119 | 120 |
my $section = $sections_by_id{ $attributes->{section_id} }; |
120 | 121 |
next unless $orderitem && $section; |
121 | 122 |
|
122 |
$self->create_order_item(section => $section, item => $orderitem)->save; |
|
123 |
$self->create_order_item(section => $section, item => $orderitem, language_id => $language_id)->save;
|
|
123 | 124 |
$sections_seen{ $section->id } = 1; |
124 | 125 |
} |
125 | 126 |
|
126 |
my @new_orderitems = map { $self->create_order_item(section => $_) } |
|
127 |
my @new_orderitems = map { $self->create_order_item(section => $_, language_id => $language_id) }
|
|
127 | 128 |
grep { !$sections_seen{ $_->id } } |
128 | 129 |
@{ $sections }; |
129 | 130 |
|
... | ... | |
237 | 238 |
my $section = $params{section}; |
238 | 239 |
my $item = $params{item} || SL::DB::OrderItem->new; |
239 | 240 |
my $part = $self->parts->{ $section->order_part_id }; |
240 |
my $description = $section->{keep_description} ? $item->description : $part->description; |
|
241 |
my $translation = $params{language_id} ? first { $params{language_id} == $_->language_id } @{ $part->translations } : {}; |
|
242 |
my $description = $section->{keep_description} ? $item->description : ($translation->{translation} || $part->description); |
|
243 |
my $longdescription = $translation->{longdescription} || $part->notes; |
|
241 | 244 |
|
242 | 245 |
if (!$section->{keep_description}) { |
243 |
$description = '<%fb_number%> <%title%>' unless $description =~ m{<%}; |
|
244 |
$description =~ s{<% (.+?) %>}{ $section->can($1) ? $section->$1 : '<' . t8('Invalid variable #1', $1) . '>' }egx; |
|
246 |
foreach my $field (\$description, \$longdescription) { |
|
247 |
$$field = '<%fb_number%> <%title%>' unless $$field =~ m{<%}; |
|
248 |
$$field =~ s{<% (.+?) %>}{ $section->can($1) ? $section->$1 : '<' . t8('Invalid variable #1', $1) . '>' }egx; |
|
249 |
} |
|
245 | 250 |
} |
246 | 251 |
|
247 | 252 |
$item->assign_attributes( |
248 |
parts_id => $part->id, |
|
249 |
description => $description, |
|
250 |
qty => $section->time_estimation * 1, |
|
251 |
unit => $self->h_unit_name, |
|
252 |
sellprice => $::form->round_amount($self->requirement_spec->hourly_rate, 2), |
|
253 |
lastcost => $part->lastcost, |
|
254 |
discount => 0, |
|
255 |
project_id => $self->requirement_spec->project_id, |
|
253 |
parts_id => $part->id, |
|
254 |
description => $description, |
|
255 |
longdescription => $longdescription, |
|
256 |
qty => $section->time_estimation * 1, |
|
257 |
unit => $self->h_unit_name, |
|
258 |
sellprice => $::form->round_amount($self->requirement_spec->hourly_rate, 2), |
|
259 |
lastcost => $part->lastcost, |
|
260 |
discount => 0, |
|
261 |
project_id => $self->requirement_spec->project_id, |
|
256 | 262 |
); |
257 | 263 |
|
258 | 264 |
return $item; |
... | ... | |
263 | 269 |
|
264 | 270 |
$self->{parts} = { map { ($_->{id} => $_) } @{ SL::DB::Manager::Part->get_all(where => [ id => [ uniq map { $_->{order_part_id} } @{ $params{sections} } ] ]) } }; |
265 | 271 |
|
266 |
my @orderitems = map { $self->create_order_item(section => $_) } @{ $params{sections} }; |
|
267 |
my $employee = SL::DB::Manager::Employee->current; |
|
268 | 272 |
my $customer = SL::DB::Customer->new(id => $::form->{customer_id})->load; |
273 |
my @orderitems = map { $self->create_order_item(section => $_, language_id => $customer->language_id) } @{ $params{sections} }; |
|
274 |
my $employee = SL::DB::Manager::Employee->current; |
|
269 | 275 |
my $order = SL::DB::Order->new( |
270 | 276 |
globalproject_id => $self->requirement_spec->project_id, |
271 | 277 |
transdate => DateTime->today_local, |
Auch abrufbar als: Unified diff
Pflichtenheft -> Angebot: Langtext setzen