View | Details | Raw Unified | Return to bug 23991
Collapse All | Expand All

(-)a/suggestion/suggestion.pl (-9 / +18 lines)
Lines 362-377 if ($op=~/else/) { Link Here
362
        @criteria_dv = ( C4::Context->userenv->{'branch'} );
362
        @criteria_dv = ( C4::Context->userenv->{'branch'} );
363
    }
363
    }
364
364
365
    unless ( exists $suggestion_ref->{branchcode} ) {
366
        $suggestion_ref->{branchcode} = C4::Context->userenv->{'branch'};
367
    }
368
365
    my @allsuggestions;
369
    my @allsuggestions;
366
    foreach my $criteriumvalue ( @criteria_dv ) {
370
    foreach my $criteriumvalue ( @criteria_dv ) {
371
        my $search_params = {%$suggestion_ref};
367
        # By default, display suggestions from current working branch
372
        # By default, display suggestions from current working branch
368
        unless ( exists $$suggestion_ref{'branchcode'} ) {
369
            $$suggestion_ref{'branchcode'} = C4::Context->userenv->{'branch'};
370
        }
371
        my $definedvalue = defined $$suggestion_ref{$displayby} && $$suggestion_ref{$displayby} ne "";
373
        my $definedvalue = defined $$suggestion_ref{$displayby} && $$suggestion_ref{$displayby} ne "";
372
374
373
        next if ( $definedvalue && $$suggestion_ref{$displayby} ne $criteriumvalue ) and ($displayby ne 'branchcode' && $branchfilter ne '__ANY__' );
375
        next if ( $definedvalue && $$suggestion_ref{$displayby} ne $criteriumvalue ) and ($displayby ne 'branchcode' && $branchfilter ne '__ANY__' );
374
        $$suggestion_ref{$displayby} = $criteriumvalue;
376
377
        $search_params->{$displayby} = $criteriumvalue;
375
378
376
        # filter on date fields
379
        # filter on date fields
377
        foreach my $field (qw( suggesteddate manageddate accepteddate )) {
380
        foreach my $field (qw( suggesteddate manageddate accepteddate )) {
Lines 389-405 if ($op=~/else/) { Link Here
389
            if ( $from_dt || $to_dt ) {
392
            if ( $from_dt || $to_dt ) {
390
                my $dtf = Koha::Database->new->schema->storage->datetime_parser;
393
                my $dtf = Koha::Database->new->schema->storage->datetime_parser;
391
                if ( $from_dt && $to_dt ) {
394
                if ( $from_dt && $to_dt ) {
392
                    $suggestion_ref->{$field} = { -between => [ $from_dt, $to_dt ] };
395
                    $search_params->{$field} = { -between => [ $from_dt, $to_dt ] };
393
                } elsif ( $from_dt ) {
396
                } elsif ( $from_dt ) {
394
                    $suggestion_ref->{$field} = { '>=' => $from_dt };
397
                    $search_params->{$field} = { '>=' => $from_dt };
395
                } elsif ( $to_dt ) {
398
                } elsif ( $to_dt ) {
396
                    $suggestion_ref->{$field} = { '<=' => $to_dt };
399
                    $search_params->{$field} = { '<=' => $to_dt };
397
                }
400
                }
398
            }
401
            }
399
        }
402
        }
403
        if ( $search_params->{budgetid} && $search_params->{budgetid} eq '__NONE__' ) {
404
            $search_params->{budgetid} = [undef, '' ];
405
        }
406
        for my $f (qw (branchcode budgetid)) {
407
            delete $search_params->{$f} if $search_params->{$f} eq '__ANY__';
408
        }
409
400
        my @suggestions =
410
        my @suggestions =
401
          Koha::Suggestions->search_limited(
411
          Koha::Suggestions->search_limited(
402
            { %$suggestion_ref, archived => $filter_archived } )->as_list;
412
            { %$search_params, archived => $filter_archived } )->as_list;
403
413
404
        push @allsuggestions,
414
        push @allsuggestions,
405
          {
415
          {
406
- 

Return to bug 23991