Revision 30ab7da0
Von Tamino Steinert vor 7 Tagen hinzugefügt
SL/Controller/Reclamation.pm | ||
---|---|---|
91 | 91 |
sub action_add { |
92 | 92 |
my ($self) = @_; |
93 | 93 |
|
94 |
$self->reclamation(SL::Model::Record->update_after_new($self->reclamation)); |
|
95 |
|
|
96 | 94 |
$self->pre_render(); |
97 | 95 |
|
98 | 96 |
if (!$::form->{form_validity_token}) { |
... | ... | |
126 | 124 |
my $record = SL::Model::Record->get_record($from_type, $from_id); |
127 | 125 |
my $reclamation = SL::Model::Record->new_from_workflow($record, $self->type, %flags); |
128 | 126 |
$self->reclamation($reclamation); |
127 |
$self->reinit_after_new_reclamation(); |
|
129 | 128 |
|
130 | 129 |
if ($record->type eq SALES_RECLAMATION_TYPE()) { # check for direct delivery |
131 | 130 |
# copy shipto in custom shipto (custom shipto will be copied by new_from() in case) |
... | ... | |
138 | 137 |
} |
139 | 138 |
} |
140 | 139 |
|
141 |
$self->reinit_after_new_reclamation(); |
|
142 |
|
|
143 |
if (!$::form->{form_validity_token}) { |
|
144 |
$::form->{form_validity_token} = SL::DB::ValidityToken->create(scope => SL::DB::ValidityToken::SCOPE_RECLAMATION_SAVE())->token; |
|
145 |
} |
|
146 |
|
|
147 |
$self->render( |
|
148 |
'reclamation/form', |
|
149 |
title => $self->type_data->text('add'), |
|
150 |
%{$self->{template_args}}, |
|
151 |
); |
|
140 |
$self->action_add; |
|
152 | 141 |
} |
153 | 142 |
|
154 | 143 |
sub action_add_from_email_journal { |
... | ... | |
177 | 166 |
return $self->js->render(); |
178 | 167 |
} |
179 | 168 |
|
180 |
$self->load_reclamation; |
|
181 |
|
|
182 | 169 |
$self->recalc(); |
183 | 170 |
$self->pre_render(); |
184 | 171 |
|
... | ... | |
934 | 921 |
sub action_return_from_create_part { |
935 | 922 |
my ($self) = @_; |
936 | 923 |
|
937 |
$self->{created_part} = SL::DB::Part->new(id => delete $::form->{new_parts_id})->load if $::form->{new_parts_id}; |
|
924 |
$self->{created_part} = SL::DB::Part->new( |
|
925 |
id => delete $::form->{new_parts_id} |
|
926 |
)->load if $::form->{new_parts_id}; |
|
938 | 927 |
|
939 | 928 |
$::auth->restore_form_from_session(delete $::form->{previousform}); |
929 |
$self->reclamation($self->init_reclamation); |
|
930 |
$self->reinit_after_new_reclamation(); |
|
940 | 931 |
|
941 |
# set item ids to new fake id, to identify them as new items |
|
942 |
foreach my $item (@{$self->reclamation->items_sorted}) { |
|
943 |
$item->{new_fake_id} = join('_', 'new', Time::HiRes::gettimeofday(), int rand 1000000000000); |
|
932 |
if ($self->reclamation->id) { |
|
933 |
$self->action_edit; |
|
934 |
} else { |
|
935 |
$self->action_add; |
|
944 | 936 |
} |
945 |
|
|
946 |
$self->recalc(); |
|
947 |
$self->get_unalterable_data(); |
|
948 |
$self->pre_render(); |
|
949 |
|
|
950 |
# trigger rendering values for second row/longdescription as hidden, because |
|
951 |
# they are loaded only on demand. So we need to keep the values from the |
|
952 |
# source. |
|
953 |
$_->{render_second_row} = 1 for @{ $self->reclamation->items_sorted }; |
|
954 |
$_->{render_longdescription} = 1 for @{ $self->reclamation->items_sorted }; |
|
955 |
|
|
956 |
$self->render( |
|
957 |
'reclamation/form', |
|
958 |
title => $self->type_data->text('edit'), |
|
959 |
%{$self->{template_args}} |
|
960 |
); |
|
961 | 937 |
} |
962 | 938 |
|
963 | 939 |
# load the second row for one or more items |
... | ... | |
1349 | 1325 |
$self->js->render; |
1350 | 1326 |
} |
1351 | 1327 |
|
1352 |
sub load_reclamation { |
|
1353 |
my ($self) = @_; |
|
1354 |
|
|
1355 |
return if !$::form->{id}; |
|
1356 |
|
|
1357 |
$self->reclamation(SL::DB::Reclamation->new(id => $::form->{id})->load); |
|
1358 |
|
|
1359 |
# Add an empty custom shipto to the reclamation, so that the dialog can render |
|
1360 |
# the cvar inputs. You need a custom shipto object to call cvars_by_config to |
|
1361 |
# get the cvars. |
|
1362 |
if (!$self->reclamation->custom_shipto) { |
|
1363 |
$self->reclamation->custom_shipto(SL::DB::Shipto->new(module => 'RC', custom_variables => [])); |
|
1364 |
} |
|
1365 |
|
|
1366 |
return $self->reclamation; |
|
1367 |
} |
|
1368 |
|
|
1369 | 1328 |
# load or create a new reclamation object |
1370 | 1329 |
# |
1371 | 1330 |
# And assign changes from the form to this object. |
... | ... | |
1387 | 1346 |
reclamation_items => [], |
1388 | 1347 |
currency_id => $::instance_conf->get_currency_id(), |
1389 | 1348 |
); |
1349 |
$reclamation = SL::Model::Record->update_after_new($reclamation) |
|
1390 | 1350 |
} |
1391 | 1351 |
|
1392 | 1352 |
my $cv_id_method = $reclamation->type_data->properties('customervendor'). '_id'; |
... | ... | |
1602 | 1562 |
my ($self) = @_; |
1603 | 1563 |
|
1604 | 1564 |
# change form type |
1605 |
$::form->{type} = $self->reclamation->type if $self->reclamation->type;
|
|
1565 |
$::form->{type} = $self->reclamation->type; |
|
1606 | 1566 |
$self->type($self->init_type); |
1607 | 1567 |
$self->cv ($self->init_cv); |
1608 | 1568 |
$self->check_auth; |
1609 | 1569 |
|
1610 |
$self->recalc(); |
|
1611 |
$self->get_unalterable_data(); |
|
1612 |
$self->pre_render(); |
|
1570 |
foreach my $item (@{$self->reclamation->items_sorted}) { |
|
1571 |
# set item ids to new fake id, to identify them as new items |
|
1572 |
$item->{new_fake_id} = join('_', 'new', Time::HiRes::gettimeofday(), int rand 1000000000000); |
|
1573 |
|
|
1574 |
# trigger rendering values for second row as hidden, because they |
|
1575 |
# are loaded only on demand. So we need to keep the values from the |
|
1576 |
# source. |
|
1577 |
$item->{render_second_row} = 1; |
|
1578 |
} |
|
1613 | 1579 |
|
1614 |
# trigger rendering values for second row as hidden, because they |
|
1615 |
# are loaded only on demand. So we need to keep the values from the |
|
1616 |
# source. |
|
1617 |
$_->{render_second_row} = 1 for @{ $self->reclamation->items_sorted }; |
|
1580 |
$self->get_unalterable_data(); |
|
1581 |
$self->recalc(); |
|
1618 | 1582 |
} |
1619 | 1583 |
|
1620 | 1584 |
sub pre_render { |
Auch abrufbar als: Unified diff
FIX: S:C:Reclamation: Daten über Workflows vollständig und korrekt laden