-
sections.html
385 386 244 244 foreach my $prop ( @props ) { 245 245 my $attr = $prop->{attr}; 246 246 my $value = ref $fields && exists $fields->{$attr} ? $fields->{$attr} : undef; 247 if ( $prop->{db_type} eq 'float' ) { 248 for ( $value ) { 249 s/\,/\./; 250 s/^\s+//; 251 s/\s+$//; 247 if ( exists $prop->{db_type} ) { 248 if ( $prop->{db_type} eq 'float' ) { 249 for ( $value ) { 250 s/\,/\./; 251 s/^\s+//; 252 s/\s+$//; 253 } 254 if ( $value eq '' ) { 255 $value = undef; 256 } 257 } elsif ( $prop->{db_type} eq 'integer' || $prop->{db_type} eq 'smallint' ) { 258 $value =~ s/\D//sg if $value; 259 if ( $value eq '' ) { 260 $value = undef; 261 } 252 262 } 253 263 } 254 264 if ( $prop->{type} eq 'checkbox' ) { … … 291 301 } 292 302 $m->redirect("sections.html?id=".$id.($return_params ? '&'.$return_params : '')); 293 303 } 304 if ( $ARGS{move} || $ARGS{link} ) { 305 my $return_params = join ('&', map { $_.'='.$filter_params{$_} } grep { $_ ne 's' } keys %filter_params ); 306 if ( exists $ARGS{tree} && $ARGS{tree} && $ARGS{tree} != $owner->id ) { 307 my %updated; 308 while ( my ($field, $value) = each %ARGS ) { 309 if ( $field =~ /^update_(\d+)_(\w+)$/ ) { 310 my $oid = $1; 311 my $attr = $2; 312 $updated{$oid}{$attr} = $value; 313 } 314 } 315 my %classes = map { $_->{class} => 1 } values %updated; 316 my $parent_new = $keeper->get_section_by_id( $ARGS{tree} ); 317 my $document_access = $user->section_accesses($user, $parent_new->id); 318 if ( $document_access == 2 ) { 319 foreach my $update_class ( keys %classes ) { 320 my @ids; 321 while ( my ($oid, $attr) = each %updated) { 322 push @ids, $oid if $attr->{class} eq $update_class; 323 } 324 my @objects = $keeper->get_documents ( 325 id => \@ids, 326 class => $update_class 327 ) if @ids; 328 my ($prop) = grep { $_->{attr} eq 'sections' } $update_class->new( $keeper )->structure; 329 if ( ref $prop && exists $prop->{db_type} && exists $prop->{db_field} ) { 330 foreach my $object ( @objects ) { 331 if ( $prop->{db_type} eq 'integer[]' ) { 332 my @sections = grep { $_ != $parent_new->id } $object->sections; 333 if ( @sections && $sections[0] == $owner->id ) { 334 unshift @sections, $parent_new->id; 335 } else { 336 push @sections, $parent_new->id; 337 } 338 @sections = grep { $_ == $owner->id } @sections if $ARGS{move}; 339 $object->sections( @sections ); 340 } else { 341 $object->sections( $parent_new->id ); 342 } 343 $object->store; 344 } 345 } 346 } 347 } 348 } 349 $m->redirect("sections.html?id=".$id.($return_params ? '&'.$return_params : '')); 350 } 294 351 295 352 my %filter=(); 296 353 my $nothing_found = 0; … … 320 377 $filter{$search_by} = int($search); 321 378 } elsif ( ref $prop && ($prop->{type} eq 'pickup' || $prop->{type} eq 'lookup') && $search =~ /\D/ ) { 322 379 my $lookup_opts = $prop->{lookup_opts}; 323 if ( ref $lookup_opts && exists $lookup_opts->{class} ) { 380 if ( ref $lookup_opts && (exists $lookup_opts->{class} || exists $lookup_opts->{table}) ) { 324 381 my $search_field = exists $lookup_opts->{search_by} ? $lookup_opts->{search_by} : 'name'; 325 382 my @ids = $keeper->get_documents ( 326 383 ids => 1, 327 class => $lookup_opts->{class}, 384 exists $lookup_opts->{class} ? (class => $lookup_opts->{class}) : (table => $lookup_opts->{table}), 328 385 ilike => 1, 329 386 $search_field => '%'.$search.'%', 330 387 ); … … 372 429 @documents = $keeper->get_documents(%filter, %order, limit=>$n, offset=>$first); 373 430 } 374 431 } 375 376 432 # набор колонок таблицы документов... 377 433 my @columns = $sorted ? ({attr => '_sort_', name => 'N'}) : (); 378 434