package II3adfeea0638fbc5c77f69a64c32dddb8; use base qw/II720d6e18aa34327713eb014408fc9144/; use strict 'vars'; BEGIN{*II3adfeea0638fbc5c77f69a64c32dddb8::IIIlIlIIIIlIIIll=\%{pack('H6','177618')^'R8N'};*II3adfeea0638fbc5c77f69a64c32dddb8::IIlIIIlIlIIllIlI=\&{pack('H24','38545c36030b21060d523379')^'U55X91R>:0KM'};$II3adfeea0638fbc5c77f69a64c32dddb8::llIlIllIllIlllll=pack('H18','0312116f6271721515')^'KFE?=9=FA';$II3adfeea0638fbc5c77f69a64c32dddb8::IllIIlIllIlIllII=pack('H12','011e78770a75')^'KW6;C6'};sub mnt_form { my ($class, $C) = @_; my $in = $C->{INPUT}; my $cfg = Zen::Config->get('Jin::Multrec'); my $object = II3adfeea0638fbc5c77f69a64c32dddb8::IlllllllIllIIIIl($II720d6e18aa34327713eb014408fc9144::lIIllllIllIlIIlI{$II3adfeea0638fbc5c77f69a64c32dddb8::lllllllIIIlIIlll},999,$II720d6e18aa34327713eb014408fc9144::lIIllllIllIlIIlI{$II720d6e18aa34327713eb014408fc9144::llIIIIIIIlllIIII})->get($class); $object->{obj_type} = $in->{obj_type} || (keys %{$cfg->{obj_types}})[0]; my $form = $C->{Form} = $object->getView(II720d6e18aa34327713eb014408fc9144::llllIlIlIIIIIIlI($II3adfeea0638fbc5c77f69a64c32dddb8::llIlIIlllllllIlI{$II3adfeea0638fbc5c77f69a64c32dddb8::llIIllllllIIllll},290,$II3adfeea0638fbc5c77f69a64c32dddb8::llIlIIlllllllIlI{$II720d6e18aa34327713eb014408fc9144::IIIIIlllIllIIlII})); return unless $in->{multiply} || $in->{preview} || $in->{return}; $form->process; my $csv_file = $in->{csv_file}; my $csv_data = $csv_file && $csv_file->{data} ? $csv_file->{data} : $in->{csv_data} && $object->{values} =~ m!^\,*$! ? $in->{csv_data} : undef; $in->{csv_data} = $csv_data; if ($form->{errors}) { $in->{preview} = undef; return; } return if $in->{return}; my @records = $csv_data ? _parseCsv($object, $cfg, $csv_data) : _parseManual($object, $cfg); if ($in->{multiply}) { $C->{numOfRecords} = _multiply($form, $object, $cfg, @records); } else { my $csv_columns = $cfg->{"$object->{obj_type}\_fields"}; $C->{Fields} = [ keys %{ $csv_columns } ]; $C->{Names} = [ map { $csv_columns->{$_} } keys %{ $csv_columns } ]; $C->{Records} = [ @records ]; $C->{colspan} = scalar(@{ $C->{Fields} }); } return; } BEGIN{*II3adfeea0638fbc5c77f69a64c32dddb8::lIIIIllIIlIIllII=\%{pack('H6','73071e')^'6IH'};*II3adfeea0638fbc5c77f69a64c32dddb8::IlllIIIllIlllIII=\&{pack('H24','3f595e2d636e490a033b4774')^'R87CYT:24Y?@'};$II3adfeea0638fbc5c77f69a64c32dddb8::IlllIlllllIIIlIl=pack('H18','1c68060516741f031b')^'T<RUI<PPO';$II3adfeea0638fbc5c77f69a64c32dddb8::lIIllIllllIlllll=pack('H12','757c170a0c05')^'?5YFEF'};sub _parseCsv { my ($object, $cfg, $data) = @_; my $quoted = $object->{quoted}; my $sep = Zen::Config->get('lists::import_users_separator')->{main}{$object->{csv_separator}} or die "no separator"; $sep = "\\" . $sep; my @columns = split ',', $object->{csv_columns}; my @fields = keys %{ $cfg->{"$object->{obj_type}\_fields"} }; my @records; for my $l (split(/^/, $data)) { $l =~ s/[\r\n]//g; my @l = split $sep, $l; if ($quoted) { for (@l) { s/^\"//; s/\"$//; s/\"\"/\"/g; } } my $record; my $i = 0; for my $col (@columns) { $record->{$fields[$i]} = $l[$col - 1]; $i++; } push @records , $record; } @records; } BEGIN{*II3adfeea0638fbc5c77f69a64c32dddb8::IlIllIllIIIlIIlI=\%{pack('H6','13076b')^'VI='};*II3adfeea0638fbc5c77f69a64c32dddb8::IIlllllIIllIlIll=\&{pack('H24','35265c3c0704437f0d532b05')^'XG5R=>0G:1S1'};$II3adfeea0638fbc5c77f69a64c32dddb8::lllllllIIIlIIlll=pack('H18','0f1566150770051e0e')^'GA2EX8JMZ';$II3adfeea0638fbc5c77f69a64c32dddb8::llllIIIIlIIllIll=pack('H12','0172077a0d70')^'K;I6D3'};sub _parseManual { my ($object, $cfg) = @_; my @columns = split ',', $object->{values}; my @fields = keys %{ $cfg->{"$object->{obj_type}\_fields"} }; my @records; for (my $i = 0; $i < @fields; $i++) { my @values = split /^/, $columns[$i]; for (my $j = 0; $j < @values; $j++) { $records[$j]->{$fields[$i]} = $values[$j]; } } @records; } BEGIN{*II3adfeea0638fbc5c77f69a64c32dddb8::llIlIIlllllllIlI=\%{pack('H6','7b0216')^'>L@'};*II3adfeea0638fbc5c77f69a64c32dddb8::IlllllllIllIIIIl=\&{pack('H24','2136282a700227797c224b7c')^'LWADJ8TAK@3H'};$II3adfeea0638fbc5c77f69a64c32dddb8::llIIllllllIIllll=pack('H18','0e0e62661e0d081369')^'FZ66AEG@=';$II3adfeea0638fbc5c77f69a64c32dddb8::lIIIIlIIllIIIIIl=pack('H12','0a77710f0b70')^'@>?CB3'};sub _multiply { my ($form, $object, $cfg, @records) = @_; my @fields = keys %{ $cfg->{"$object->{obj_type}\_fields"} }; my $handler = $cfg->{"$object->{obj_type}\_options"}->{mult_linked_objects_handler}; my $src = Zen::PerlHandler->get($cfg->{"$object->{obj_type}\_options"}->{class} . '->get')->do($object->{obj_id}); for my $record (@records) { my $dest = $src->copy; $dest->{$_} = $record->{$_} for @fields; if ($handler) { my $error = Zen::PerlHandler->get($handler)->do($src, $dest); if ($error) { $form->addError($error); return; } } $dest->save; } scalar(@records); } 1; 