Revision ec4aa5bb
Von Bernd Bleßmann vor etwa 11 Jahren hinzugefügt
SL/BackgroundJob/CsvImport.pm | ||
---|---|---|
61 | 61 |
|
62 | 62 |
$c->profile($self->profile); |
63 | 63 |
$c->type($job->data_as_hash->{type}); |
64 |
$c->{employee_id} = $job->data_as_hash->{employee_id}; |
|
64 | 65 |
|
65 | 66 |
my $test = $job->data_as_hash->{test}; |
66 | 67 |
|
SL/Controller/CsvImport.pm | ||
---|---|---|
272 | 272 |
} |
273 | 273 |
|
274 | 274 |
$self->{background_job} = SL::BackgroundJob::CsvImport->create_job( |
275 |
file => $self->csv_file_name, |
|
276 |
profile => $self->profile, |
|
277 |
type => $self->profile->type, |
|
278 |
test => $params{test}, |
|
275 |
file => $self->csv_file_name, |
|
276 |
profile => $self->profile, |
|
277 |
type => $self->profile->type, |
|
278 |
test => $params{test}, |
|
279 |
employee_id => SL::DB::Manager::Employee->current->id, |
|
279 | 280 |
)->save; |
280 | 281 |
|
281 | 282 |
if ($self->task_server->is_running) { |
SL/Controller/CsvImport/Base.pm | ||
---|---|---|
2 | 2 |
|
3 | 3 |
use strict; |
4 | 4 |
|
5 |
use List::MoreUtils qw(pairwise); |
|
5 |
use List::MoreUtils qw(pairwise any);
|
|
6 | 6 |
|
7 | 7 |
use SL::Helper::Csv; |
8 | 8 |
use SL::DB::Currency; |
... | ... | |
11 | 11 |
use SL::DB::PaymentTerm; |
12 | 12 |
use SL::DB::Vendor; |
13 | 13 |
use SL::DB::Contact; |
14 |
use SL::DB::History; |
|
14 | 15 |
|
15 | 16 |
use parent qw(Rose::Object); |
16 | 17 |
|
... | ... | |
415 | 416 |
if ( !$object->save(cascade => !!$self->save_with_cascade()) ) { |
416 | 417 |
push @{ $entry->{errors} }, $::locale->text('Error when saving: #1', $entry->{object}->db->error); |
417 | 418 |
} else { |
419 |
$self->_save_history($object); |
|
418 | 420 |
$self->controller->num_imported($self->controller->num_imported + 1); |
419 | 421 |
} |
420 | 422 |
} continue { |
... | ... | |
457 | 459 |
return @cleaned_fields; |
458 | 460 |
} |
459 | 461 |
|
462 |
sub _save_history { |
|
463 |
my ($self, $object) = @_; |
|
464 |
|
|
465 |
if (any { $_ eq $self->controller->{type} } qw(parts customers_vendors)) { |
|
466 |
my $snumbers = $self->controller->{type} eq 'parts' ? 'partnumber_' . $object->partnumber |
|
467 |
: $self->controller->{type} eq 'customers_vendors' ? |
|
468 |
($self->table eq 'customer' ? 'customernumber_' . $object->customernumber : 'vendornumber_' . $object->vendornumber) |
|
469 |
: ''; |
|
470 |
|
|
471 |
SL::DB::History->new( |
|
472 |
trans_id => $object->id, |
|
473 |
snumbers => $snumbers, |
|
474 |
employee_id => $self->controller->{employee_id}, |
|
475 |
addition => 'SAVED', |
|
476 |
)->save(); |
|
477 |
} |
|
478 |
} |
|
479 |
|
|
460 | 480 |
1; |
Auch abrufbar als: Unified diff
Beim CSV-Import Einträge in die Historie machen.
Fixt #1998.