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

(-)a/C4/Breeding.pm (-1 / +304 lines)
Lines 1-6 Link Here
1
package C4::Breeding;
1
package C4::Breeding;
2
2
3
# Copyright 2000-2002 Katipo Communications
3
# Copyright 2000-2002 Katipo Communications
4
# Parts Copyright 2013 Prosentient Systems
4
#
5
#
5
# This file is part of Koha.
6
# This file is part of Koha.
6
#
7
#
Lines 25-30 use C4::Koha; Link Here
25
use C4::Charset;
26
use C4::Charset;
26
use MARC::File::USMARC;
27
use MARC::File::USMARC;
27
use C4::ImportBatch;
28
use C4::ImportBatch;
29
use C4::AuthoritiesMarc; #GuessAuthTypeCode, FindDuplicateAuthority
28
30
29
use vars qw($VERSION @ISA @EXPORT @EXPORT_OK %EXPORT_TAGS);
31
use vars qw($VERSION @ISA @EXPORT @EXPORT_OK %EXPORT_TAGS);
30
32
Lines 33-39 BEGIN { Link Here
33
    $VERSION = 3.07.00.049;
35
    $VERSION = 3.07.00.049;
34
	require Exporter;
36
	require Exporter;
35
	@ISA = qw(Exporter);
37
	@ISA = qw(Exporter);
36
    @EXPORT = qw(&ImportBreeding &BreedingSearch &Z3950Search);
38
    @EXPORT = qw(&ImportBreeding &BreedingSearch &Z3950Search &Z3950SearchAuth);
37
}
39
}
38
40
39
=head1 NAME
41
=head1 NAME
Lines 436-441 sub Z3950Search { Link Here
436
    );
438
    );
437
}
439
}
438
440
441
=head2 ImportBreedingAuth
442
443
	ImportBreedingAuth($marcrecords,$overwrite_auth,$filename,$encoding,$z3950random,$batch_type);
444
445
	TODO description
446
447
=cut
448
449
sub ImportBreedingAuth {
450
    my ($marcrecords,$overwrite_auth,$filename,$encoding,$z3950random,$batch_type) = @_;
451
    my @marcarray = split /\x1D/, $marcrecords;
452
453
    my $dbh = C4::Context->dbh;
454
455
    my $batch_id = GetZ3950BatchId($filename);
456
    my $searchbreeding = $dbh->prepare("select import_record_id from import_auths where control_number=? and authorized_heading=?");
457
458
#     $encoding = C4::Context->preference("marcflavour") unless $encoding;
459
    # fields used for import results
460
    my $imported=0;
461
    my $alreadyindb = 0;
462
    my $alreadyinfarm = 0;
463
    my $notmarcrecord = 0;
464
    my $breedingid;
465
    for (my $i=0;$i<=$#marcarray;$i++) {
466
        my ($marcrecord, $charset_result, $charset_errors);
467
        ($marcrecord, $charset_result, $charset_errors) = 
468
            MarcToUTF8Record($marcarray[$i]."\x1D", C4::Context->preference("marcflavour"), $encoding);
469
470
        # Normalize the record so it doesn't have separated diacritics
471
        SetUTF8Flag($marcrecord);
472
473
#         warn "$i : $marcarray[$i]";
474
        # FIXME - currently this does nothing
475
        my @warnings = $marcrecord->warnings();
476
477
        if (scalar($marcrecord->fields()) == 0) {
478
            $notmarcrecord++;
479
        } else {
480
            my $heading;
481
            $heading = C4::AuthoritiesMarc::GetAuthorizedHeading({ record => $marcrecord });
482
483
            my $heading_authtype_code;
484
            $heading_authtype_code = GuessAuthTypeCode($marcrecord);
485
486
            my $controlnumber;
487
            $controlnumber = $marcrecord->field('001')->data;
488
489
            #Check if the authority record already exists in the database...
490
            my ($duplicateauthid,$duplicateauthvalue);
491
            if ($marcrecord && $heading_authtype_code) {
492
                ($duplicateauthid,$duplicateauthvalue) = FindDuplicateAuthority( $marcrecord, $heading_authtype_code);
493
            }
494
495
            if ($duplicateauthid && $overwrite_auth ne 2) {
496
                #If the authority record exists and $overwrite_auth doesn't equal 2, then mark it as already in the DB
497
                #FIXME: What does $overwrite_auth = 2 even mean?
498
499
                #FIXME: Should we bother with $overwrite_auth values? Currently, the hard-coded $overwrite_auth value is 2, which means the database gets filled with import_records...
500
                #^^ of course, we might not want to reject records if their control number/heading exist in the db or breeding/import pool...as we might be wanting to update existing authority records...
501
                $alreadyindb++;
502
            } else {
503
                if ($controlnumber && $heading) {
504
                    $searchbreeding->execute($controlnumber,$heading);
505
                    ($breedingid) = $searchbreeding->fetchrow;
506
                }
507
                if ($breedingid && $overwrite_auth eq '0') {
508
                    #FIXME: What does $overwrite_auth = 0 even mean?
509
                    $alreadyinfarm++;
510
                } else {
511
                    if ($breedingid && $overwrite_auth eq '1') {
512
                        #FIXME: What does $overwrite_auth = 1 even mean?
513
                        ModAuthorityInBatch($breedingid, $marcrecord);
514
                    } else {
515
                        my $import_id = AddAuthToBatch($batch_id, $imported, $marcrecord, $encoding, $z3950random);
516
                        $breedingid = $import_id;
517
                    }
518
                    $imported++;
519
                }
520
            }
521
        }
522
    }
523
    return ($notmarcrecord,$alreadyindb,$alreadyinfarm,$imported,$breedingid);
524
}
525
526
=head2 Z3950SearchAuth
527
528
Z3950SearchAuth($pars, $template);
529
530
Parameters for Z3950 search are all passed via the $pars hash. It may contain nameany, namepersonal, namecorp, namemeetingcon,
531
title, uniform title, subject, subjectsubdiv, srchany.
532
Also it should contain an arrayref id that points to a list of IDs of the z3950 targets to be queried (see z3950servers table).
533
This code is used in cataloging/z3950_auth_search.
534
The second parameter $template is a Template object. The routine uses this parameter to store the found values into the template.
535
536
=cut
537
538
sub Z3950SearchAuth {
539
    my ($pars, $template)= @_;
540
541
    my $dbh   = C4::Context->dbh;
542
    my @id= @{$pars->{id}};
543
    my $random= $pars->{random};
544
    my $page= $pars->{page};
545
546
    my $nameany= $pars->{nameany};
547
    my $authorany= $pars->{authorany};
548
    my $authorpersonal= $pars->{authorpersonal};
549
    my $authorcorp= $pars->{authorcorp};
550
    my $authormeetingcon= $pars->{authormeetingcon};
551
    my $title= $pars->{title};
552
    my $uniformtitle= $pars->{uniformtitle};
553
    my $subject= $pars->{subject};
554
    my $subjectsubdiv= $pars->{subjectsubdiv};
555
    my $srchany= $pars->{srchany};
556
557
    my $show_next       = 0;
558
    my $total_pages     = 0;
559
    my $attr = '';
560
    my $host;
561
    my $server;
562
    my $database;
563
    my $port;
564
    my $marcdata;
565
    my @encoding;
566
    my @results;
567
    my $count;
568
    my $record;
569
    my @serverhost;
570
    my @servername;
571
    my @breeding_loop = ();
572
573
    my @oConnection;
574
    my @oResult;
575
    my @errconn;
576
    my $s = 0;
577
    my $query;
578
    my $nterms=0;
579
580
    if ($nameany) {
581
        $query .= " \@attr 1=1002 \"$nameany\" "; #Any name (this includes personal, corporate, meeting/conference authors, and author names in subject headings)
582
        #This attribute is supported by both the Library of Congress and Libraries Australia 08/05/2013
583
        $nterms++;
584
    }
585
586
    if ($authorany) {
587
        $query .= " \@attr 1=1003 \"$authorany\" "; #Author-name (this includes personal, corporate, meeting/conference authors, but not author names in subject headings)
588
        #This attribute is not supported by the Library of Congress, but is supported by Libraries Australia 08/05/2013
589
        $nterms++;
590
    }
591
592
    if ($authorcorp) {
593
        $query .= " \@attr 1=2 \"$authorcorp\" "; #1005 is another valid corporate author attribute...
594
        $nterms++;
595
    }
596
597
    if ($authorpersonal) {
598
        $query .= " \@attr 1=1 \"$authorpersonal\" "; #1004 is another valid personal name attribute...
599
        $nterms++;
600
    }
601
602
    if ($authormeetingcon) {
603
        $query .= " \@attr 1=3 \"$authormeetingcon\" "; #1006 is another valid meeting/conference name attribute...
604
        $nterms++;
605
    }
606
607
    if ($subject) {
608
        $query .= " \@attr 1=21 \"$subject\" ";
609
        $nterms++;
610
    }
611
612
    if ($subjectsubdiv) {
613
        $query .= " \@attr 1=47 \"$subjectsubdiv\" ";
614
        $nterms++;
615
    }
616
617
    if ($title) {
618
        $query .= " \@attr 1=4 \"$title\" "; #This is a regular title search. 1=6 will give just uniform titles
619
        $nterms++;
620
    }
621
622
     if ($uniformtitle) {
623
        $query .= " \@attr 1=6 \"$uniformtitle\" "; #This is the uniform title search
624
        $nterms++;
625
    }
626
627
    if($srchany) {
628
        $query .= " \@attr 1=1016 \"$srchany\" ";
629
        $nterms++;
630
    }
631
632
    for my $i (1..$nterms-1) {
633
        $query = "\@and " . $query;
634
    }
635
636
    foreach my $servid (@id) {
637
        my $sth = $dbh->prepare("select * from z3950servers where id=?");
638
        $sth->execute($servid);
639
        while ( $server = $sth->fetchrow_hashref ) {
640
            my $option1      = new ZOOM::Options();
641
            $option1->option( 'async' => 1 );
642
            $option1->option( 'elementSetName', 'F' );
643
            $option1->option( 'databaseName',   $server->{db} );
644
            $option1->option( 'user', $server->{userid} ) if $server->{userid};
645
            $option1->option( 'password', $server->{password} ) if $server->{password};
646
            $option1->option( 'preferredRecordSyntax', $server->{syntax} );
647
            $option1->option( 'timeout', $server->{timeout} ) if $server->{timeout};
648
            $oConnection[$s] = create ZOOM::Connection($option1);
649
            $oConnection[$s]->connect( $server->{host}, $server->{port} );
650
            $serverhost[$s] = $server->{host};
651
            $servername[$s] = $server->{name};
652
            $encoding[$s]   = ($server->{encoding}?$server->{encoding}:"iso-5426");
653
            $s++;
654
        }    ## while fetch
655
    }    # foreach
656
    my $nremaining  = $s;
657
658
    for ( my $z = 0 ; $z < $s ; $z++ ) {
659
        $oResult[$z] = $oConnection[$z]->search_pqf($query);
660
    }
661
662
    while ( $nremaining-- ) {
663
        my $k;
664
        my $event;
665
        while ( ( $k = ZOOM::event( \@oConnection ) ) != 0 ) {
666
            $event = $oConnection[ $k - 1 ]->last_event();
667
            last if $event == ZOOM::Event::ZEND;
668
        }
669
670
        if ( $k != 0 ) {
671
            $k--;
672
            my ($error, $errmsg, $addinfo, $diagset)= $oConnection[$k]->error_x();
673
            if ($error) {
674
                if ($error =~ m/^(10000|10007)$/ ) {
675
                    push(@errconn, {'server' => $serverhost[$k]});
676
                }
677
            }
678
            else {
679
                my $numresults = $oResult[$k]->size();
680
                my $i;
681
                my $result = '';
682
                if ( $numresults > 0  and $numresults >= (($page-1)*20)) {
683
                    $show_next = 1 if $numresults >= ($page*20);
684
                    $total_pages = int($numresults/20)+1 if $total_pages < ($numresults/20);
685
                    for ($i = ($page-1)*20; $i < (($numresults < ($page*20)) ? $numresults : ($page*20)); $i++) {
686
                        my $rec = $oResult[$k]->record($i);
687
                        if ($rec) {
688
                            my $marcrecord;
689
                            my $marcdata;
690
                            $marcdata   = $rec->raw();
691
692
                            my ($charset_result, $charset_errors);
693
                            ($marcrecord, $charset_result, $charset_errors)= MarcToUTF8Record($marcdata, C4::Context->preference('marcflavour'), $encoding[$k]);
694
695
                            my $heading;
696
                            my $heading_authtype_code;
697
                            $heading_authtype_code = GuessAuthTypeCode($marcrecord);
698
                            $heading = C4::AuthoritiesMarc::GetAuthorizedHeading({ record => $marcrecord });
699
700
                            my ($notmarcrecord, $alreadyindb, $alreadyinfarm, $imported, $breedingid)= ImportBreedingAuth( $marcdata, 2, $serverhost[$k], $encoding[$k], $random, 'z3950' );
701
                            my %row_data;
702
                            $row_data{server}       = $servername[$k];
703
                            $row_data{breedingid}   = $breedingid;
704
                            $row_data{heading}      = $heading;
705
                            $row_data{heading_code}      = $heading_authtype_code;
706
                            push( @breeding_loop, \%row_data );
707
                        }
708
                        else {
709
                            push(@breeding_loop,{'server'=>$servername[$k],'title'=>join(': ',$oConnection[$k]->error_x()),'breedingid'=>-1});
710
                        }
711
                    }
712
                }    #if $numresults
713
            }
714
        }    # if $k !=0
715
716
        $template->param(
717
            numberpending => $nremaining,
718
            current_page => $page,
719
            total_pages => $total_pages,
720
            show_nextbutton => $show_next?1:0,
721
            show_prevbutton => $page!=1,
722
        );
723
    } # while nremaining
724
725
    #close result sets and connections
726
    foreach(0..$s-1) {
727
        $oResult[$_]->destroy();
728
        $oConnection[$_]->destroy();
729
    }
730
731
    my @servers = ();
732
    foreach my $id (@id) {
733
        push @servers, {id => $id};
734
    }
735
    $template->param(
736
        breeding_loop => \@breeding_loop,
737
        servers => \@servers,
738
        errconn       => \@errconn
739
    );
740
}
741
439
1;
742
1;
440
__END__
743
__END__
441
744
(-)a/authorities/authorities.pl (-2 / +26 lines)
Lines 24-29 use CGI; Link Here
24
use C4::Auth;
24
use C4::Auth;
25
use C4::Output;
25
use C4::Output;
26
use C4::AuthoritiesMarc;
26
use C4::AuthoritiesMarc;
27
use C4::ImportBatch; #GetImportRecordMarc
27
use C4::Context;
28
use C4::Context;
28
use C4::Koha; # XXX subfield_is_koha_internal_p
29
use C4::Koha; # XXX subfield_is_koha_internal_p
29
use Date::Calc qw(Today);
30
use Date::Calc qw(Today);
Lines 47-52 builds list, depending on authorised value... Link Here
47
48
48
=cut
49
=cut
49
50
51
sub MARCfindbreeding_auth {
52
    my ( $id ) = @_;
53
    my ($marc, $encoding) = GetImportRecordMarc($id);
54
    if ($marc) {
55
        my $record = MARC::Record->new_from_usmarc($marc);
56
        if ( !defined(ref($record)) ) {
57
                return -1;
58
        } else {
59
            return $record, $encoding;
60
        }
61
    } else {
62
        return -1;
63
    }
64
}
65
50
sub build_authorized_values_list {
66
sub build_authorized_values_list {
51
    my ( $tag, $subfield, $value, $dbh, $authorised_values_sth,$index_tag,$index_subfield ) = @_;
67
    my ( $tag, $subfield, $value, $dbh, $authorised_values_sth,$index_tag,$index_subfield ) = @_;
52
68
Lines 544-549 my $nonav = $input->param('nonav'); Link Here
544
my $myindex = $input->param('index');
560
my $myindex = $input->param('index');
545
my $linkid=$input->param('linkid');
561
my $linkid=$input->param('linkid');
546
my $authtypecode = $input->param('authtypecode');
562
my $authtypecode = $input->param('authtypecode');
563
my $breedingid    = $input->param('breedingid');
547
564
548
my $dbh = C4::Context->dbh;
565
my $dbh = C4::Context->dbh;
549
if(!$authtypecode) {
566
if(!$authtypecode) {
Lines 558-568 my ($template, $loggedinuser, $cookie) Link Here
558
                            flagsrequired => {editauthorities => 1},
575
                            flagsrequired => {editauthorities => 1},
559
                            debug => 1,
576
                            debug => 1,
560
                            });
577
                            });
561
$template->param(nonav   => $nonav,index=>$myindex,authtypecode=>$authtypecode,);
578
$template->param(nonav   => $nonav,index=>$myindex,authtypecode=>$authtypecode,breedingid=>$breedingid,);
579
562
$tagslib = GetTagsLabels(1,$authtypecode);
580
$tagslib = GetTagsLabels(1,$authtypecode);
563
my $record=-1;
581
my $record=-1;
564
my $encoding="";
582
my $encoding="";
565
$record = GetAuthority($authid) if ($authid);
583
if (($authid) && !($breedingid)){
584
    $record = GetAuthority($authid);
585
}
586
if ($breedingid) {
587
    ( $record, $encoding ) = MARCfindbreeding_auth( $breedingid );
588
}
589
566
my ($oldauthnumtagfield,$oldauthnumtagsubfield);
590
my ($oldauthnumtagfield,$oldauthnumtagsubfield);
567
my ($oldauthtypetagfield,$oldauthtypetagsubfield);
591
my ($oldauthtypetagfield,$oldauthtypetagsubfield);
568
$is_a_modif=0;
592
$is_a_modif=0;
(-)a/cataloguing/z3950_auth_search.pl (+108 lines)
Line 0 Link Here
1
#!/usr/bin/perl
2
3
# This is a completely new Z3950 clients search using async ZOOM -TG 02/11/06
4
# Copyright 2000-2002 Katipo Communications
5
#
6
# This is a new Z3950 authority search using the current Z3950 bibliographic search as a model 07/05/2013
7
# Parts Copyright 2013 Prosentient Systems
8
#
9
# This file is part of Koha.
10
#
11
# Koha is free software; you can redistribute it and/or modify it under the
12
# terms of the GNU General Public License as published by the Free Software
13
# Foundation; either version 2 of the License, or (at your option) any later
14
# version.
15
#
16
# Koha is distributed in the hope that it will be useful, but WITHOUT ANY
17
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
18
# A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
19
#
20
# You should have received a copy of the GNU General Public License along
21
# with Koha; if not, write to the Free Software Foundation, Inc.,
22
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
23
24
use strict;
25
use warnings;
26
use CGI qw( -utf8 );
27
28
use C4::Auth;
29
use C4::Output;
30
use C4::Context;
31
use C4::Breeding;
32
use C4::Koha;
33
34
my $input        = new CGI;
35
my $dbh          = C4::Context->dbh;
36
my $error         = $input->param('error');
37
my $nameany     = $input->param('nameany');
38
my $authorany     = $input->param('authorany');
39
my $authorcorp     = $input->param('authorcorp');
40
my $authorpersonal     = $input->param('authorpersonal');
41
my $authormeetingcon     = $input->param('authormeetingcon');
42
my $title         = $input->param('title');
43
my $uniformtitle         = $input->param('uniformtitle');
44
my $subject       = $input->param('subject');
45
my $subjectsubdiv       = $input->param('subjectsubdiv');
46
my $srchany       = $input->param('srchany');
47
my $op            = $input->param('op')||'';
48
my $page            = $input->param('current_page') || 1;
49
$page = $input->param('goto_page') if $input->param('changepage_goto');
50
51
my ( $template, $loggedinuser, $cookie ) = get_template_and_user({
52
        template_name   => "cataloguing/z3950_auth_search.tmpl",
53
        query           => $input,
54
        type            => "intranet",
55
        authnotrequired => 1,
56
        flagsrequired   => { catalogue => 1 },
57
});
58
59
$template->param(
60
    nameany    => $nameany,
61
    authorany    => $authorany,
62
    authorcorp    => $authorcorp,
63
    authorpersonal    => $authorpersonal,
64
    authormeetingcon    => $authormeetingcon,
65
    title        => $title,
66
    uniformtitle      => $uniformtitle,
67
    subject      => $subject,
68
    subjectsubdiv   => $subjectsubdiv,
69
    srchany      => $srchany,
70
);
71
72
if ( $op ne "do_search" ) {
73
    my $sth = $dbh->prepare("SELECT id,host,name,checked FROM z3950servers ORDER BY rank, name");
74
    $sth->execute();
75
    my $serverloop = $sth->fetchall_arrayref( {} );
76
    $template->param(
77
        serverloop   => $serverloop,
78
        opsearch     => "search",
79
    );
80
    output_html_with_http_headers $input, $cookie, $template->output;
81
    exit;
82
}
83
84
my @id = $input->param('id');
85
if ( @id==0 ) {
86
        # empty server list -> report and exit
87
        $template->param( emptyserverlist => 1 );
88
        output_html_with_http_headers $input, $cookie, $template->output;
89
        exit;
90
}
91
92
my $pars= {
93
        random => $input->param('random') || rand(1000000000),
94
        page => $page,
95
        id => \@id,
96
        nameany => $nameany,
97
        authorany => $authorany,
98
        authorcorp => $authorcorp,
99
        authorpersonal => $authorpersonal,
100
        authormeetingcon => $authormeetingcon,
101
        title => $title,
102
        uniformtitle => $uniformtitle,
103
        subject => $subject,
104
        subjectsubdiv => $subjectsubdiv,
105
        srchany => $srchany,
106
};
107
Z3950SearchAuth($pars, $template);
108
output_html_with_http_headers $input, $cookie, $template->output;
(-)a/koha-tmpl/intranet-tmpl/prog/en/includes/authorities-toolbar.inc (+9 lines)
Lines 5-10 Link Here
5
            confirm_deletion();
5
            confirm_deletion();
6
            return false;
6
            return false;
7
        });
7
        });
8
9
        $("#z3950submit").click(function(){
10
            window.open("/cgi-bin/koha/cataloguing/z3950_auth_search.pl","z3950search",'width=740,height=450,location=yes,toolbar=no,scrollbars=yes,resize=yes');
11
            return false;
12
        });
13
8
    });
14
    });
9
15
10
//]]>
16
//]]>
Lines 40-43 Link Here
40
            [% END %]
46
            [% END %]
41
        </ul>
47
        </ul>
42
    </div>
48
    </div>
49
    <div class="btn-group">
50
        <a class="btn btn-small" id="z3950submit" href="#"><i class="icon-search"></i> Z39.50 search</a>
51
    </div>
43
</div>
52
</div>
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/z3950_auth_search.tt (-1 / +228 lines)
Line 0 Link Here
0
- 
1
[% INCLUDE 'doc-head-open.inc' %]
2
<title>Koha &rsaquo; Z39.50 search results</title>
3
[% INCLUDE 'greybox.inc' %]
4
[% INCLUDE 'doc-head-close.inc' %]
5
<script type="text/javascript" src="[% themelang %]/lib/jquery/plugins/jquery.checkboxes.min.js"></script>
6
<link rel="stylesheet" type="text/css" href="[% themelang %]/css/datatables.css" />
7
<script type="text/javascript" src="[% themelang %]/lib/jquery/plugins/jquery.dataTables.min.js"></script>
8
[% INCLUDE 'datatables-strings.inc' %]
9
<script type="text/javascript" src="[% themelang %]/js/datatables.js"></script>
10
<script type="text/javascript">
11
//<![CDATA[
12
function Import(Breeding,AuthType) {
13
    opener.document.location="../authorities/authorities.pl?breedingid="+Breeding+"&authtypecode="+AuthType;
14
    window.close();
15
    return false;
16
}
17
18
function closemenu(){
19
    $(".linktools").hide();
20
    $("tr").removeClass("selected");
21
}
22
23
$(document).ready(function(){
24
    $("#CheckAll").click(function(){
25
        $(".checkboxed").checkCheckboxes();
26
        return false;
27
    });
28
    $("#CheckNone").click(function(){
29
        $(".checkboxed").unCheckCheckboxes();
30
        return false;
31
    });
32
    $("#resultst").dataTable($.extend(true, {}, dataTablesDefaults, {
33
        "sDom": 't',
34
        "aoColumnDefs": [
35
            { "aTargets": [ -1,-2,-3 ], "bSortable": false, "bSearchable": false },
36
        ],
37
        "aaSorting": [[ 1, "asc" ]],
38
        "bPaginate": false
39
    }));
40
        /* Inline edit/delete links */
41
        $("td").click(function(event){
42
            var $tgt = $(event.target);
43
            var row = $(this).parent();
44
            $(".linktools").hide();
45
            $("tr").removeClass("selected");
46
            row.addClass("selected");
47
            if($tgt.is("a")||$tgt.is(":nth-child(7)")||$tgt.is(":nth-child(8)")||$tgt.is(":nth-child(9)")||$tgt.is(":nth-child(10)")){
48
                return true;
49
            } else {
50
                var position = $(this).offset();
51
                var top = position.top+5;
52
                var left = position.left+5;
53
                $(".linktools",row).show().css("position","absolute").css("top",top).css("left",left);
54
            }
55
        });
56
    $("form[name='f']").submit(function(){
57
        if ($('input[type=checkbox]').filter(':checked').length == 0) {
58
            alert(_("Please choose at least one Z39.50 target"));
59
            return false;
60
        } else
61
            return true;
62
    });
63
});
64
65
[% IF ( total_pages ) %]
66
function validate_goto_page(){
67
    var page = $('#goto_page').val();
68
    if(isNaN(page)) {
69
        alert(_("The page entered is not a number."));
70
        return false;
71
    }
72
    else if(page < 1 || page > [% total_pages %] ) {
73
        alert(_("The page should be a number between 1 and ") + [% total_pages %] + ".");
74
        return false;
75
    }
76
    else {
77
        return true;
78
    }
79
}
80
[% END %]
81
82
//]]>
83
</script>
84
<style type="text/css">
85
.linktools { background-color:#FFF;border-top:1px solid #DDD; border-left: 1px solid #DDD; border-right: 1px solid #666; border-bottom:1px solid #666;display: none; white-space: nowrap;}
86
.linktools a { font-size : 85%; text-decoration:none; padding:.3em;;background-color:#FFF; display:block;float:left;border-right:1px solid #DDD;}
87
.linktools a:hover { background-color:#EEE;color:#CC3300;border-right:1px solid #CCC;}
88
tr.selected { background-color : #FFFFCC; } tr.selected td { background-color : transparent; }
89
</style>
90
91
    [% IF ( opsearch ) %]
92
        <style type="text/css">
93
        #custom-doc { width:53em;*width:51.72em;min-width:689px; margin:auto; text-align:left; }
94
        </style>
95
        </head>
96
        <body id="cat_z3950_auth_search" class="cat">
97
        <div id="custom-doc" class="yui-t7">
98
    [% ELSE %]
99
        </head>
100
        <body style="padding:.5em;">
101
        <div>
102
    [% END %]
103
    <div id="bd">
104
	[% IF ( opsearch ) %]
105
        <h2>Z39.50 Authority search points</h2>
106
        <form method="post" action="z3950_auth_search.pl" name="f" class="checkboxed">
107
        <input type="hidden" name="op" id="op" value="do_search" />
108
        <div class="yui-g">
109
            <div class="yui-u first">
110
                <fieldset class="rows">
111
                <ol>
112
                    <li><label for="srchany">Raw (any): </label> <input type="text" id="srchany" name="srchany" value="" /></li>
113
                    <li><label for="nameany">Name (any): </label> <input type="text" id="nameany" name="nameany" value="" /></li>
114
                    <li><label for="authorany">Author (any): </label> <input type="text" id="authorany" name="authorany" value="" /></li>
115
                    <li><label for="authorpersonal">Author (personal): </label> <input type="text" id="authorpersonal" name="authorpersonal" value="" /></li>
116
                    <li><label for="authorcorp">Author (corporate): </label> <input type="text" id="authorcorp" name="authorcorp" value="" /></li>
117
                    <li><label for="authormeetingcon">Author (meeting/conference): </label> <input type="text" id="authormeetingcon" name="authormeetingcon" value="" /></li>
118
                </ol>
119
                </fieldset>
120
            </div>
121
            <div class="yui-u">
122
                <fieldset class="rows">
123
                <ol>
124
                    <li><label for="subject">Subject heading: </label> <input type="text" id="subject" name="subject" value="" /></li>
125
                    <li><label for="subjectsubdiv">Subject sub-division: </label> <input type="text" id="subjectsubdiv" name="subjectsubdiv" value="" /></li>
126
                    <li><label for="title">Title (any): </label> <input type="text" id="title"  name="title" value="[% title |html %]" /></li>
127
                    <li><label for="uniformtitle">Title (uniform): </label> <input type="text" id="uniformtitle"  name="uniformtitle" value="[% uniformtitle |html %]" /></li>
128
                </ol>
129
                </fieldset>
130
            </div>
131
        </div>
132
        <div class="yui-g">
133
            <h2>Search targets <span style="display: inline; font-size: 70%; padding-left: 1em;"><span class="checkall"><a id="CheckAll" href="#">Select all</a></span><span class="clearall"><a id="CheckNone" href="#">Clear all</a></span></span></h2>
134
            [% FOREACH serverloo IN serverloop %]
135
                <p>
136
                [% IF ( serverloo.checked ) %]
137
                    <input type="checkbox" name="id" id="z3950_[% serverloo.id %]" value="[% serverloo.id %]" checked="checked" />
138
                [% ELSE %]
139
                    <input type="checkbox" name="id" id="z3950_[% serverloo.id %]" value="[% serverloo.id %]" />
140
                [% END %]
141
                <label for="z3950_[% serverloo.id %]">[% serverloo.name %]</label>
142
                </p>
143
            [% END %]
144
        </div>
145
        <fieldset class="action"><input type="submit"  class="submit" value="Search" onclick="cursor :'wait'"/> <a class="cancel close" href="#">Cancel</a></fieldset>
146
        </form>
147
148
149
[% ELSE %]
150
    <h2>Results for Authority Records</h2>
151
    [% IF ( breeding_loop ) %]
152
    <table id="resultst">
153
<thead>    <tr>
154
        <th>Server</th>
155
        <th>Heading</th>
156
        <th>Authority Type</th>
157
        <th>MARC</th>
158
        <!-- <th>Card</th> -->
159
        <th>&nbsp;</th>
160
    </tr></thead>
161
    <tbody>[% FOREACH breeding_loo IN breeding_loop %]
162
        [% IF ( breeding_loo.breedingid ) %]
163
	    <tr id="row[% breeding_loo.breedingid %]">
164
            <td>[% breeding_loo.server %] <div class="linktools"><a href="/cgi-bin/koha/catalogue/showmarc.pl?importid=[% breeding_loo.breedingid %]" rel="gb_page_center[600,500]">Preview MARC</a> <a href="#" onclick="Import([% breeding_loo.breedingid %],'[% breeding_loo.heading_code %]'); return false">Import</a><a href="#" onclick="closemenu();return false;" title="Close this menu"> X </a></div> </td>
165
            <td>[% breeding_loo.heading %]</td>
166
            <td>[% breeding_loo.heading_code %]</td>
167
            <td><a href="/cgi-bin/koha/catalogue/showmarc.pl?importid=[% breeding_loo.breedingid %]" title="MARC" rel="gb_page_center[600,500]">MARC</a></td>
168
            <!-- <td><a href="/cgi-bin/koha/catalogue/showmarc.pl?viewas=card&amp;importid=[% breeding_loo.breedingid %]" title="MARC" rel="gb_page_center[600,500]">Card</a></td> -->
169
            <td><a href="#" onclick="Import([% breeding_loo.breedingid %],'[% breeding_loo.heading_code %]'); return false">Import</a></td>
170
        </tr>
171
        [% END %]
172
    [% END %]</tbody>
173
</table>
174
175
    <form method="post" action="z3950_auth_search.pl" id="page_form" name="page_form" class="checkboxed">
176
        <input type="hidden" name="op" id="op" value="do_search" />
177
        <input type="hidden" name="current_page" id="current_page" value="[% current_page %]" />
178
        <input type="hidden" id="nameany"  name="nameany" value="[% nameany %]" />
179
        <input type="hidden" id="authorany"  name="authorany" value="[% authorany %]" />
180
        <input type="hidden" id="authorcorp"  name="authorcorp" value="[% authorcorp %]" />
181
        <input type="hidden" id="authorpersonal"  name="authorpersonal" value="[% authorpersonal %]" />
182
        <input type="hidden" id="authormeetingcon"  name="authormeetingcon" value="[% authormeetingcon %]" />
183
        <input type="hidden" id="title"  name="title" value="[% title %]" />
184
        <input type="hidden" id="uniformtitle"  name="uniformtitle" value="[% uniformtitle %]" />
185
        <input type="hidden" id="subject" name="subject" value="[% subject %]" />
186
        <input type="hidden" id="subjectsubdiv" name="subjectsubdiv" value="[% subjectsubdiv %]" />
187
        <input type="hidden" id="heading"  name="heading" value="[% heading %]" />
188
        <input type="hidden" id="srchany" name="srchany" value="[% srchany %]" />
189
190
        [% FOREACH server IN servers %]
191
        <input type="hidden" name="id" id="z3950_[% server.id %]" value="[% server.id %]" />
192
        [% END %]
193
194
        [% IF ( show_prevbutton ) %]
195
            <input type="button" name="changepage_prev" value="Previous Page" onclick="$('#current_page').val([% current_page %]-1);$('#page_form').submit();" />
196
        [% END %]
197
        Page [% current_page %] / [% total_pages %]
198
        [% IF ( show_nextbutton ) %]
199
            <input type="button" name="changepage_next" value="Next Page" onclick="$('#current_page').val([% current_page %]+1);$('#page_form').submit();" />
200
        [% END %]
201
        <br />Go to page : <input id="goto_page" name="goto_page" value="[% current_page %]" size="4" /><input type="submit" name="changepage_goto" onclick="return validate_goto_page();" value="Go" />
202
    </form>
203
204
<p><form method="get" action="/cgi-bin/koha/cataloguing/z3950_auth_search.pl"><input type="submit" value="Try Another Search"/></form></p>
205
    [% ELSE %]
206
        [% IF ( errconn ) %]
207
            <div class="dialog alert">
208
                <ul>
209
                [% FOREACH errcon IN errconn %]
210
                    [% IF ( errcon.error == '10000' ) %]<li>Connection failed to [% errcon.server %]</li>
211
                    [% ELSIF ( errcon.error == '10007' ) %]<li>Connection timeout to [% errcon.server %]</li>[% END %]
212
                [% END %]
213
                </ul>
214
            </div>
215
         [% END %]
216
   <div class="dialog message">Nothing found.</div>
217
	<p><form method="get" action="/cgi-bin/koha/cataloguing/z3950_auth_search.pl"><input type="submit" value="Try Another Search"/></form></p>
218
    [% END %]
219
220
[% END %]
221
	</div>
222
</div>
223
224
[% IF ( numberpending ) %]<h3 align="center">Still [% numberpending %] servers to search</h3>[% END %]
225
226
</body>
227
</html>
228

Return to bug 10096