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

(-)a/C4/Reports/Guided.pm (-59 / +52 lines)
Lines 29-35 use C4::Output; Link Here
29
use C4::Dates;
29
use C4::Dates;
30
use XML::Simple;
30
use XML::Simple;
31
use XML::Dumper;
31
use XML::Dumper;
32
use Switch;
33
use C4::Debug;
32
use C4::Debug;
34
# use Smart::Comments;
33
# use Smart::Comments;
35
# use Data::Dumper;
34
# use Data::Dumper;
Lines 311-380 sub get_criteria { Link Here
311
    my ($area,$cgi) = @_;
310
    my ($area,$cgi) = @_;
312
    my $dbh    = C4::Context->dbh();
311
    my $dbh    = C4::Context->dbh();
313
    my $crit   = $criteria{$area};
312
    my $crit   = $criteria{$area};
314
	my $column_defs = _get_column_defs($cgi);
313
    my $column_defs = _get_column_defs($cgi);
315
    my @criteria_array;
314
    my @criteria_array;
316
    foreach my $localcrit (@$crit) {
315
    foreach my $localcrit (@$crit) {
317
        my ( $value, $type )   = split( /\|/, $localcrit );
316
        my ( $value, $type )   = split( /\|/, $localcrit );
318
        my ( $table, $column ) = split( /\./, $value );
317
        my ( $table, $column ) = split( /\./, $value );
319
	switch ($type) {
318
        if ($type eq 'textrange') {
320
	    case 'textrange' {
319
            my %temp;
321
		my %temp;
320
            $temp{'name'}        = $value;
322
		$temp{'name'}        = $value;
321
            $temp{'from'}        = "from_" . $value;
323
		$temp{'from'}        = "from_" . $value;
322
            $temp{'to'}          = "to_" . $value;
324
		$temp{'to'}          = "to_" . $value;
323
            $temp{'textrange'}   = 1;
325
		$temp{'textrange'}   = 1;
324
            $temp{'description'} = $column_defs->{$value};
326
		$temp{'description'} = $column_defs->{$value};
325
            push @criteria_array, \%temp;
327
		push @criteria_array, \%temp;
326
        }
328
	    }
327
        elsif ($type eq 'date') {
329
328
            my %temp;
330
	    case 'date' {
329
            $temp{'name'}        = $value;
331
		my %temp;
330
            $temp{'date'}        = 1;
332
		$temp{'name'}        = $value;
331
            $temp{'description'} = $column_defs->{$value};
333
		$temp{'date'}        = 1;
332
            push @criteria_array, \%temp;
334
		$temp{'description'} = $column_defs->{$value};
333
        }
335
		push @criteria_array, \%temp;
334
        elsif ($type eq 'daterange') {
336
	    }
335
            my %temp;
337
336
            $temp{'name'}        = $value;
338
	    case 'daterange' {
337
            $temp{'from'}        = "from_" . $value;
339
		my %temp;
338
            $temp{'to'}          = "to_" . $value;
340
		$temp{'name'}        = $value;
339
            $temp{'daterange'}   = 1;
341
		$temp{'from'}        = "from_" . $value;
340
            $temp{'description'} = $column_defs->{$value};
342
		$temp{'to'}          = "to_" . $value;
341
            push @criteria_array, \%temp;
343
		$temp{'daterange'}   = 1;
342
        }
344
		$temp{'description'} = $column_defs->{$value};
343
        else {
345
		push @criteria_array, \%temp;
344
            my $query =
346
	    }
345
            "SELECT distinct($column) as availablevalues FROM $table";
347
346
            my $sth = $dbh->prepare($query);
348
	    else {
347
            $sth->execute();
349
		my $query =
348
            my @values;
350
		  "SELECT distinct($column) as availablevalues FROM $table";
349
            # push the runtime choosing option
351
		my $sth = $dbh->prepare($query);
350
            my $list;
352
		$sth->execute();
351
            $list='branches' if $column eq 'branchcode' or $column eq 'holdingbranch' or $column eq 'homebranch';
353
		my @values;
352
            $list='categorycode' if $column eq 'categorycode';
354
        # push the runtime choosing option
353
            $list='itemtype' if $column eq 'itype';
355
        my $list;
354
            $list='ccode' if $column eq 'ccode';
356
        $list='branches' if $column eq 'branchcode' or $column eq 'holdingbranch' or $column eq 'homebranch';
355
            # TODO : improve to let the librarian choose the description at runtime
357
        $list='categorycode' if $column eq 'categorycode';
356
            push @values, { availablevalues => "<<$column".($list?"|$list":'').">>" };
358
        $list='itemtype' if $column eq 'itype';
357
            while ( my $row = $sth->fetchrow_hashref() ) {
359
        $list='ccode' if $column eq 'ccode';
358
                push @values, $row;
360
        # TODO : improve to let the librarian choose the description at runtime
359
                if ($row->{'availablevalues'} eq '') { $row->{'default'} = 1 };
361
        push @values, { availablevalues => "<<$column".($list?"|$list":'').">>" };
360
            }
362
		while ( my $row = $sth->fetchrow_hashref() ) {
361
            $sth->finish();
363
		    push @values, $row;
364
		    if ($row->{'availablevalues'} eq '') { $row->{'default'} = 1 };
365
		}
366
		$sth->finish();
367
362
368
		my %temp;
363
            my %temp;
369
		$temp{'name'}        = $value;
364
            $temp{'name'}        = $value;
370
	    	$temp{'description'} = $column_defs->{$value};
365
            $temp{'description'} = $column_defs->{$value};
371
		$temp{'values'}      = \@values;
366
            $temp{'values'}      = \@values;
372
		
367
373
		push @criteria_array, \%temp;
368
            push @criteria_array, \%temp;
374
     
369
        }
375
	    }
376
370
377
	}
378
    }
371
    }
379
    return ( \@criteria_array );
372
    return ( \@criteria_array );
380
}
373
}
(-)a/basket/downloadcart.pl (-9 / +12 lines)
Lines 22-28 use warnings; Link Here
22
22
23
use CGI;
23
use CGI;
24
use Encode qw(encode);
24
use Encode qw(encode);
25
use Switch;
26
25
27
use C4::Auth;
26
use C4::Auth;
28
use C4::Biblio;
27
use C4::Biblio;
Lines 64-79 if ($bib_list && $format) { Link Here
64
    # Other formats
63
    # Other formats
65
    } else {
64
    } else {
66
65
67
	foreach my $biblio (@bibs) {
66
        foreach my $biblio (@bibs) {
68
67
69
	    my $record = GetMarcBiblio($biblio);
68
            my $record = GetMarcBiblio($biblio);
70
69
71
	    switch ($format) {
70
            if ($format eq 'iso2709') {
72
		case "iso2709" { $output .= $record->as_usmarc(); }
71
                $output .= $record->as_usmarc();
73
		case "ris"     { $output .= marc2ris($record); }
72
            }
74
		case "bibtex"  { $output .= marc2bibtex($record, $biblio); }
73
            elsif ($format eq 'ris') {
75
	    }
74
                $output .= marc2ris($record);
76
	}
75
            }
76
            elsif ($format eq 'bibtex') {
77
                $output .= marc2bibtex($record, $biblio);
78
            }
79
        }
77
    }
80
    }
78
81
79
    # If it was a CSV export we change the format after the export so the file extension is fine
82
    # If it was a CSV export we change the format after the export so the file extension is fine
(-)a/opac/opac-detail.pl (-31 / +27 lines)
Lines 40-46 use C4::Serials; Link Here
40
use C4::Members;
40
use C4::Members;
41
use C4::VirtualShelves;
41
use C4::VirtualShelves;
42
use C4::XSLT;
42
use C4::XSLT;
43
use Switch;
44
43
45
BEGIN {
44
BEGIN {
46
	if (C4::Context->preference('BakerTaylorEnabled')) {
45
	if (C4::Context->preference('BakerTaylorEnabled')) {
Lines 597-638 if (my $search_for_title = C4::Context->preference('OPACSearchForTitleIn')){ Link Here
597
# We try to select the best default tab to show, according to what
596
# We try to select the best default tab to show, according to what
598
# the user wants, and what's available for display
597
# the user wants, and what's available for display
599
my $defaulttab = '';
598
my $defaulttab = '';
600
switch (C4::Context->preference('opacSerialDefaultTab')) {
599
my $deftab = C4::Context->preference('opacSerialDefaultTab');
601
600
# If the user wants subscriptions by default
602
    # If the user wants subscriptions by default
601
if ($deftab eq 'subscriptions') { 
603
    case "subscriptions" { 
602
    # And there are subscriptions, we display them
604
	# And there are subscriptions, we display them
603
    if ($subscriptionsnumber) {
605
	if ($subscriptionsnumber) {
604
        $defaulttab = 'subscriptions';
606
	    $defaulttab = 'subscriptions';
605
    } else {
607
	} else {
606
        # Else, we try next option
608
	   # Else, we try next option
607
        $deftab = 'serialcollection'; 
609
	   next; 
610
	}
611
    }
608
    }
612
609
}
613
    case "serialcollection" {
610
if ($deftab eq 'serialcollection') {
614
	if (scalar(@serialcollections) > 0) {
611
    if (scalar(@serialcollections) > 0) {
615
	    $defaulttab = 'serialcollection' ;
612
        $defaulttab = 'serialcollection' ;
616
	} else {
613
    } else {
617
	    next;
614
        $deftab = 'holdings';
618
	}
619
    }
615
    }
616
}
620
617
621
    case "holdings" {
618
if ($deftab eq 'holdings') {
622
	if ($dat->{'count'} > 0) {
619
    if ($dat->{'count'} > 0) {
623
	   $defaulttab = 'holdings'; 
620
        $defaulttab = 'holdings'; 
624
	} else {
621
    } else {
625
	     # As this is the last option, we try other options if there are no items
622
        # As this is the last option, we try other options if there are no items
626
	     if ($subscriptionsnumber) {
623
        if ($subscriptionsnumber) {
627
		$defaulttab = 'subscriptions';
624
            $defaulttab = 'subscriptions';
628
	     } elsif (scalar(@serialcollections) > 0) {
625
        } elsif (scalar(@serialcollections) > 0) {
629
		$defaulttab = 'serialcollection' ;
626
            $defaulttab = 'serialcollection' ;
630
	     }
627
        }
631
	}
632
633
    }
628
    }
634
629
635
}
630
}
631
636
$template->param('defaulttab' => $defaulttab);
632
$template->param('defaulttab' => $defaulttab);
637
633
638
634
(-)a/opac/opac-downloadcart.pl (-13 / +16 lines)
Lines 22-28 use warnings; Link Here
22
22
23
use CGI;
23
use CGI;
24
use Encode qw(encode);
24
use Encode qw(encode);
25
use Switch;
26
25
27
use C4::Auth;
26
use C4::Auth;
28
use C4::Biblio;
27
use C4::Biblio;
Lines 61-79 if ($bib_list && $format) { Link Here
61
60
62
        $output = marc2csv(\@bibs, $format);
61
        $output = marc2csv(\@bibs, $format);
63
62
64
    # Other formats
63
        # Other formats
65
    } else {
64
    } else {
66
	foreach my $biblio (@bibs) {
65
        foreach my $biblio (@bibs) {
67
66
68
	    my $record = GetMarcBiblio($biblio);
67
            my $record = GetMarcBiblio($biblio);
69
        next unless $record;
68
            next unless $record;
70
69
71
	    switch ($format) {
70
            if ($format eq 'iso2709') {
72
		case "iso2709" { $output .= $record->as_usmarc(); }
71
                $output .= $record->as_usmarc();
73
		case "ris"     { $output .= marc2ris($record); }
72
            }
74
		case "bibtex"  { $output .= marc2bibtex($record, $biblio); }
73
            elsif ($format eq 'ris') {
75
	    }
74
                $output .= marc2ris($record);
76
	}
75
            }
76
            elsif ($format eq 'bibtex') {
77
                $output .= marc2bibtex($record, $biblio);
78
            }
79
        }
77
    }
80
    }
78
81
79
    # If it was a CSV export we change the format after the export so the file extension is fine
82
    # If it was a CSV export we change the format after the export so the file extension is fine
(-)a/opac/opac-downloadshelf.pl (-11 / +14 lines)
Lines 22-28 use warnings; Link Here
22
22
23
use CGI;
23
use CGI;
24
use Encode qw(encode);
24
use Encode qw(encode);
25
use Switch;
26
25
27
use C4::Auth;
26
use C4::Auth;
28
use C4::Biblio;
27
use C4::Biblio;
Lines 66-83 if ($shelfid && $format) { Link Here
66
            
65
            
67
    # Other formats
66
    # Other formats
68
    } else {
67
    } else {
69
	foreach my $biblio (@$items) {
68
        foreach my $biblio (@$items) {
70
	    my $biblionumber = $biblio->{biblionumber};
69
            my $biblionumber = $biblio->{biblionumber};
71
70
72
	    my $record = GetMarcBiblio($biblionumber);
71
            my $record = GetMarcBiblio($biblionumber);
73
        next unless $record;
72
            next unless $record;
74
73
75
	    switch ($format) {
74
            if ($format eq 'iso2709') {
76
		case "iso2709" { $output .= $record->as_usmarc(); }
75
                $output .= $record->as_usmarc();
77
		case "ris"     { $output .= marc2ris($record); }
76
            }
78
		case "bibtex"  { $output .= marc2bibtex($record, $biblionumber); }
77
            elsif ($format eq 'ris' ) {
79
	    }
78
                $output .= marc2ris($record);
80
	}
79
            }
80
            elsif ($format eq 'bibtex') {
81
                $output .= marc2bibtex($record, $biblionumber);
82
            }
83
        }
81
    }
84
    }
82
85
83
    # If it was a CSV export we change the format after the export so the file extension is fine
86
    # If it was a CSV export we change the format after the export so the file extension is fine
(-)a/tools/batchMod.pl (-37 / +32 lines)
Lines 32-38 use C4::BackgroundJob; Link Here
32
use C4::ClassSource;
32
use C4::ClassSource;
33
use C4::Dates;
33
use C4::Dates;
34
use C4::Debug;
34
use C4::Debug;
35
use Switch;
36
use MARC::File::XML;
35
use MARC::File::XML;
37
36
38
my $input = new CGI;
37
my $input = new CGI;
Lines 164-172 if ($op eq "action") { Link Here
164
#-------------------------------------------------------------------------------
163
#-------------------------------------------------------------------------------
165
164
166
if ($op eq "show"){
165
if ($op eq "show"){
167
	my $filefh = $input->upload('uploadfile');
166
    my $filefh = $input->upload('uploadfile');
168
	my $filecontent = $input->param('filecontent');
167
    my $filecontent = $input->param('filecontent');
169
	my @notfoundbarcodes;
168
    my @notfoundbarcodes;
170
169
171
    my @contentlist;
170
    my @contentlist;
172
    if ($filefh){
171
    if ($filefh){
Lines 175-222 if ($op eq "show"){ Link Here
175
            push @contentlist, $content if $content;
174
            push @contentlist, $content if $content;
176
        }
175
        }
177
176
178
	switch ($filecontent) {
177
        if ($filecontent eq 'barcode_file') {
179
	    case "barcode_file" {
178
            foreach my $barcode (@contentlist) {
180
		foreach my $barcode (@contentlist) {
181
179
182
		    my $itemnumber = GetItemnumberFromBarcode($barcode);
180
                my $itemnumber = GetItemnumberFromBarcode($barcode);
183
		    if ($itemnumber) {
181
                if ($itemnumber) {
184
			push @itemnumbers,$itemnumber;
182
                    push @itemnumbers,$itemnumber;
185
		    } else {
183
                } else {
186
			push @notfoundbarcodes, $barcode;
184
                    push @notfoundbarcodes, $barcode;
187
		    }
185
                }
188
		}
186
            }
189
187
        }
190
	    }
188
        elsif ( $filecontent eq 'itemid_file') {
191
189
            @itemnumbers = @contentlist;
192
	    case "itemid_file" {
190
        }
193
		@itemnumbers = @contentlist;
194
	    }
195
	}
196
    } else {
191
    } else {
197
       if ( my $list=$input->param('barcodelist')){
192
        if ( my $list=$input->param('barcodelist')){
198
        push my @barcodelist, split(/\s\n/, $list);
193
            push my @barcodelist, split(/\s\n/, $list);
199
194
200
	foreach my $barcode (@barcodelist) {
195
            foreach my $barcode (@barcodelist) {
201
196
202
	    my $itemnumber = GetItemnumberFromBarcode($barcode);
197
                my $itemnumber = GetItemnumberFromBarcode($barcode);
203
	    if ($itemnumber) {
198
                if ($itemnumber) {
204
		push @itemnumbers,$itemnumber;
199
                    push @itemnumbers,$itemnumber;
205
	    } else {
200
                } else {
206
		push @notfoundbarcodes, $barcode;
201
                    push @notfoundbarcodes, $barcode;
207
	    }
202
                }
208
	}
203
            }
209
204
205
        }
210
    }
206
    }
211
}
212
    # Only display the items if there are no more than 1000
207
    # Only display the items if there are no more than 1000
213
    if (scalar(@itemnumbers) <= 1000) {
208
    if (scalar(@itemnumbers) <= 1000) {
214
	$items_display_hashref=BuildItemsData(@itemnumbers);
209
        $items_display_hashref=BuildItemsData(@itemnumbers);
215
    } else {
210
    } else {
216
	$template->param("too_many_items" => scalar(@itemnumbers));
211
        $template->param("too_many_items" => scalar(@itemnumbers));
217
	# Even if we do not display the items, we need the itemnumbers
212
        # Even if we do not display the items, we need the itemnumbers
218
	my @itemnumbers_hashref = map {{itemnumber => $_}} @itemnumbers;
213
        my @itemnumbers_hashref = map {{itemnumber => $_}} @itemnumbers;
219
	$template->param("itemnumbers_hashref" => \@itemnumbers_hashref);
214
        $template->param("itemnumbers_hashref" => \@itemnumbers_hashref);
220
    }
215
    }
221
# now, build the item form for entering a new item
216
# now, build the item form for entering a new item
222
my @loop_data =();
217
my @loop_data =();
(-)a/virtualshelves/downloadshelf.pl (-12 / +14 lines)
Lines 22-28 use warnings; Link Here
22
22
23
use CGI;
23
use CGI;
24
use Encode qw(encode);
24
use Encode qw(encode);
25
use Switch;
26
25
27
use C4::Auth;
26
use C4::Auth;
28
use C4::Biblio;
27
use C4::Biblio;
Lines 65-83 if ($shelfid && $format) { Link Here
65
	$output = marc2csv(\@biblios, $format);
64
	$output = marc2csv(\@biblios, $format);
66
65
67
    # Other formats
66
    # Other formats
68
    } else {
67
} else {
69
	foreach my $biblio (@$items) {
68
    foreach my $biblio (@$items) {
70
	    my $biblionumber = $biblio->{biblionumber};
69
        my $biblionumber = $biblio->{biblionumber};
71
70
72
	    my $record = GetMarcBiblio($biblionumber);
71
        my $record = GetMarcBiblio($biblionumber);
73
72
74
	    switch ($format) {
73
        if ($format eq 'iso2709') {
75
		case "iso2709" { $output .= $record->as_usmarc(); }
74
            $output .= $record->as_usmarc();
76
		case "ris"     { $output .= marc2ris($record); }
75
        }
77
		case "bibtex"  { $output .= marc2bibtex($record, $biblionumber); }
76
        elsif ($format eq 'ris') {
78
	    }
77
            $output .= marc2ris($record);
79
	}
78
        }
79
        elsif ($format eq 'bibtex') {
80
            $output .= marc2bibtex($record, $biblionumber);
81
        }
80
    }
82
    }
83
}
81
84
82
    # If it was a CSV export we change the format after the export so the file extension is fine
85
    # If it was a CSV export we change the format after the export so the file extension is fine
83
    $format = "csv" if ($format =~ m/^\d+$/);
86
    $format = "csv" if ($format =~ m/^\d+$/);
84
- 

Return to bug 5105