Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision 4cdc96b6

Von Tamino Steinert vor 8 Monaten hinzugefügt

  • ID 4cdc96b66e78b4eb18f58c70b4b9869fac4ef6a1
  • Vorgänger 10c6ffbe
  • Nachfolger c78851e0

Model::Record: update_for_save_as_new implementiert

Unterschiede anzeigen:

SL/Controller/Reclamation.pm
14 14
use SL::Webdav;
15 15
use SL::File;
16 16
use SL::MIME;
17
use SL::Util qw(trim);
18 17
use SL::YAML;
19 18
use SL::DB::History;
20 19
use SL::DB::Reclamation;
......
311 310
    return $self->js->render();
312 311
  }
313 312

  
314
  # load reclamation from db to check if values changed
315 313
  my $saved_reclamation = SL::DB::Reclamation->new(id => $reclamation->id)->load;
316 314

  
317
  my %new_attrs;
318
  # If it has been changed manually then use it as-is, otherwise change.
319
  $new_attrs{record_number} = (trim($reclamation->record_number) eq $saved_reclamation->record_number)
320
                            ? ''
321
                            : trim($reclamation->record_number);
322
  $new_attrs{transdate} = ($reclamation->transdate == $saved_reclamation->transdate)
323
                        ? DateTime->today_local
324
                        : $reclamation->transdate;
325
  if ($reclamation->reqdate == $saved_reclamation->reqdate) {
326
    $new_attrs{reqdate} = '';
327
  } else {
328
    $new_attrs{reqdate} = $reclamation->reqdate;
329
  }
330

  
331
  # Update employee
332
  $new_attrs{employee}  = SL::DB::Manager::Employee->current;
333

  
334 315
  # Create new record from current one
335
  $self->reclamation(
336
           SL::DB::Reclamation->new_from(
337
             $reclamation,
338
             destination_type   => $reclamation->type,
339
             attributes         => \%new_attrs,
340
             no_linked_records => 1,
341
           )
342
         );
316
  my $new_reclamation = SL::Model::Record->update_for_save_as_new($saved_reclamation, $reclamation);
317
  $self->reclamation($new_reclamation);
343 318

  
344 319
  if (!$::form->{form_validity_token}) {
345 320
    $::form->{form_validity_token} = SL::DB::ValidityToken->create(scope => SL::DB::ValidityToken::SCOPE_RECLAMATION_SAVE())->token;

Auch abrufbar als: Unified diff