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

(-)a/C4/Breeding.pm (-1 / +299 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 controlnumber=? 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
            
481
            my $heading;
482
            $heading = C4::AuthoritiesMarc::GetAuthorizedHeading({ record => $marcrecord });
483
            
484
            my $heading_authtype_code;
485
            $heading_authtype_code = GuessAuthTypeCode($marcrecord);
486
            
487
            my $controlnumber;
488
            $controlnumber = $marcrecord->field('001')->data;
489
            
490
            #Check if the authority record already exists in the database...
491
            my ($duplicateauthid,$duplicateauthvalue);
492
            if ($marcrecord && $heading_authtype_code) {
493
                ($duplicateauthid,$duplicateauthvalue) = FindDuplicateAuthority( $marcrecord, $heading_authtype_code);
494
            }
495
            
496
            if ($duplicateauthid && $overwrite_auth ne 2) {
497
                #If the authority record exists and $overwrite_auth doesn't equal 2, then mark it as already in the DB
498
                #FIXME: What does $overwrite_auth = 2 even mean?
499
                
500
                #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...
501
                #^^ 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...
502
                $alreadyindb++;      
503
            } else {
504
                
505
                if ($controlnumber && $heading) {
506
                    $searchbreeding->execute($controlnumber,$heading);
507
                    ($breedingid) = $searchbreeding->fetchrow;
508
                }
509
                if ($breedingid && $overwrite_auth eq '0') {
510
                    #FIXME: What does $overwrite_auth = 0 even mean?
511
                    $alreadyinfarm++;
512
                } else {
513
                    if ($breedingid && $overwrite_auth eq '1') {
514
                        #FIXME: What does $overwrite_auth = 1 even mean?
515
                        ModAuthInBatch($breedingid, $marcrecord);
516
                    } else {
517
                        my $import_id = AddAuthToBatch($batch_id, $imported, $marcrecord, $encoding, $z3950random);
518
                        $breedingid = $import_id;
519
                    }
520
                    $imported++;
521
                }
522
            }
523
        }
524
    }
525
    return ($notmarcrecord,$alreadyindb,$alreadyinfarm,$imported,$breedingid);
526
}
527
528
=head2 Z3950SearchAuth
529
530
Z3950SearchAuth($pars, $template);
531
532
Parameters for Z3950 search are all passed via the $pars hash. It may contain nameany, namepersonal, namecorp, namemeetingcon, 
533
title, uniform title, subject, subjectsubdiv, srchany.
534
Also it should contain an arrayref id that points to a list of IDs of the z3950 targets to be queried (see z3950servers table).
535
This code is used in cataloging/z3950_auth_search.
536
The second parameter $template is a Template object. The routine uses this parameter to store the found values into the template.
537
538
=cut
539
540
sub Z3950SearchAuth {
541
    my ($pars, $template)= @_;
542
543
    my $dbh   = C4::Context->dbh;
544
    my @id= @{$pars->{id}};
545
    my $random= $pars->{random};
546
    my $page= $pars->{page};
547
    
548
    my $nameany= $pars->{nameany};
549
    my $namepersonal= $pars->{namepersonal};
550
    my $namecorp= $pars->{namecorp};
551
    my $namemeetingcon= $pars->{namemeetingcon};
552
    my $title= $pars->{title};
553
    my $uniformtitle= $pars->{uniformtitle};
554
    my $subject= $pars->{subject};
555
    my $subjectsubdiv= $pars->{subjectsubdiv};
556
    my $srchany= $pars->{srchany};
557
558
    my $show_next       = 0;
559
    my $total_pages     = 0;
560
    my $attr = '';
561
    my $host;
562
    my $server; 
563
    my $database;
564
    my $port;
565
    my $marcdata;
566
    my @encoding;
567
    my @results;
568
    my $count;
569
    my $record;
570
    my @serverhost;
571
    my @servername;
572
    my @breeding_loop = ();
573
574
    my @oConnection;
575
    my @oResult;
576
    my @errconn;
577
    my $s = 0;
578
    my $query;
579
    my $nterms=0;
580
581
    
582
    if ($nameany) {
583
        $query .= " \@attr 1=1003 \"$nameany\" "; #Author-name
584
        $nterms++;
585
    }
586
    
587
    if ($namecorp) {
588
        $query .= " \@attr 1=2 \"$namecorp\" "; #1005 is another valid corporate author attribute...
589
        $nterms++;
590
    }
591
    
592
    if ($namepersonal) {
593
        $query .= " \@attr 1=1 \"$namepersonal\" "; #1004 is another valid personal name attribute...
594
        $nterms++;
595
    }
596
    
597
    if ($namemeetingcon) {
598
        $query .= " \@attr 1=1006 \"$namemeetingcon\" "; 
599
        $nterms++;
600
    }
601
    
602
    if ($subject) {
603
        $query .= " \@attr 1=21 \"$subject\" ";
604
        $nterms++;
605
    }
606
    
607
    if ($subjectsubdiv) {
608
        $query .= " \@attr 1=47 \"$subjectsubdiv\" ";
609
        $nterms++;
610
    }
611
    
612
    if ($title) {
613
        $query .= " \@attr 1=4 \"$title\" "; #This is a regular title search. 1=6 will give just uniform titles
614
        $nterms++;
615
    } 
616
    
617
     if ($uniformtitle) {
618
        $query .= " \@attr 1=6 \"$uniformtitle\" "; #This is the uniform title search
619
        $nterms++;
620
    }    
621
622
    if($srchany) {
623
        $query .= " \@attr 1=1016 \"$srchany\" ";
624
        $nterms++;
625
    }
626
627
    for my $i (1..$nterms-1) {
628
        $query = "\@and " . $query;
629
    }
630
631
    foreach my $servid (@id) {
632
        my $sth = $dbh->prepare("select * from z3950servers where id=?");
633
        $sth->execute($servid);
634
        while ( $server = $sth->fetchrow_hashref ) {
635
            my $option1      = new ZOOM::Options();
636
            $option1->option( 'async' => 1 );
637
            $option1->option( 'elementSetName', 'F' );
638
            $option1->option( 'databaseName',   $server->{db} );
639
            $option1->option( 'user', $server->{userid} ) if $server->{userid};
640
            $option1->option( 'password', $server->{password} ) if $server->{password};
641
            $option1->option( 'preferredRecordSyntax', $server->{syntax} );
642
            $option1->option( 'timeout', $server->{timeout} ) if $server->{timeout};
643
            $oConnection[$s] = create ZOOM::Connection($option1);
644
            $oConnection[$s]->connect( $server->{host}, $server->{port} );
645
            $serverhost[$s] = $server->{host};
646
            $servername[$s] = $server->{name};
647
            $encoding[$s]   = ($server->{encoding}?$server->{encoding}:"iso-5426");
648
            $s++;
649
        }    ## while fetch
650
    }    # foreach
651
    my $nremaining  = $s;
652
653
    for ( my $z = 0 ; $z < $s ; $z++ ) {
654
        $oResult[$z] = $oConnection[$z]->search_pqf($query);
655
    }
656
657
    while ( $nremaining-- ) {
658
        my $k;
659
        my $event;
660
        while ( ( $k = ZOOM::event( \@oConnection ) ) != 0 ) {
661
            $event = $oConnection[ $k - 1 ]->last_event();
662
            last if $event == ZOOM::Event::ZEND;
663
        }
664
665
        if ( $k != 0 ) {
666
            $k--;
667
            my ($error, $errmsg, $addinfo, $diagset)= $oConnection[$k]->error_x();
668
            if ($error) {
669
                if ($error =~ m/^(10000|10007)$/ ) {
670
                    push(@errconn, {'server' => $serverhost[$k]});
671
                }
672
            }
673
            else {
674
                my $numresults = $oResult[$k]->size();
675
                my $i;
676
                my $result = '';
677
                if ( $numresults > 0  and $numresults >= (($page-1)*20)) {
678
                    $show_next = 1 if $numresults >= ($page*20);
679
                    $total_pages = int($numresults/20)+1 if $total_pages < ($numresults/20);
680
                    for ($i = ($page-1)*20; $i < (($numresults < ($page*20)) ? $numresults : ($page*20)); $i++) {
681
                        my $rec = $oResult[$k]->record($i);
682
                        if ($rec) {
683
                            my $marcrecord;
684
                            my $marcdata;
685
                            $marcdata   = $rec->raw();
686
                            
687
                            my ($charset_result, $charset_errors);
688
                            ($marcrecord, $charset_result, $charset_errors)= MarcToUTF8Record($marcdata, C4::Context->preference('marcflavour'), $encoding[$k]);
689
690
                            my $heading;
691
                            my $heading_authtype_code;
692
                            $heading_authtype_code = GuessAuthTypeCode($marcrecord);
693
                            $heading = C4::AuthoritiesMarc::GetAuthorizedHeading({ record => $marcrecord });
694
       
695
                            my ($notmarcrecord, $alreadyindb, $alreadyinfarm, $imported, $breedingid)= ImportBreedingAuth( $marcdata, 2, $serverhost[$k], $encoding[$k], $random, 'z3950' );
696
                            my %row_data;
697
                            $row_data{server}       = $servername[$k];
698
                            $row_data{breedingid}   = $breedingid;
699
                            $row_data{heading}      = $heading;
700
                            $row_data{heading_code}      = $heading_authtype_code;
701
                            push( @breeding_loop, \%row_data );
702
                        }
703
                        else {
704
                            push(@breeding_loop,{'server'=>$servername[$k],'title'=>join(': ',$oConnection[$k]->error_x()),'breedingid'=>-1});
705
                        }
706
                    }
707
                }    #if $numresults
708
            }
709
        }    # if $k !=0
710
711
        $template->param(
712
            numberpending => $nremaining,
713
            current_page => $page,
714
            total_pages => $total_pages,
715
            show_nextbutton => $show_next?1:0,
716
            show_prevbutton => $page!=1,
717
        );
718
    } # while nremaining
719
720
    #close result sets and connections
721
    foreach(0..$s-1) {
722
        $oResult[$_]->destroy();
723
        $oConnection[$_]->destroy();
724
    }
725
726
    my @servers = ();
727
    foreach my $id (@id) {
728
        push @servers, {id => $id};
729
    }
730
    $template->param(
731
        breeding_loop => \@breeding_loop,
732
        servers => \@servers,
733
        errconn       => \@errconn
734
    );
735
}
736
439
1;
737
1;
440
__END__
738
__END__
441
739
(-)a/authorities/authorities.pl (-2 / +27 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
    
57
        if ( !defined(ref($record)) ) {
58
                return -1;
59
        } else {
60
            return $record, $encoding;
61
        }
62
    } else {
63
        return -1;
64
    }
65
}
66
50
sub build_authorized_values_list {
67
sub build_authorized_values_list {
51
    my ( $tag, $subfield, $value, $dbh, $authorised_values_sth,$index_tag,$index_subfield ) = @_;
68
    my ( $tag, $subfield, $value, $dbh, $authorised_values_sth,$index_tag,$index_subfield ) = @_;
52
69
Lines 544-549 my $nonav = $input->param('nonav'); Link Here
544
my $myindex = $input->param('index');
561
my $myindex = $input->param('index');
545
my $linkid=$input->param('linkid');
562
my $linkid=$input->param('linkid');
546
my $authtypecode = $input->param('authtypecode');
563
my $authtypecode = $input->param('authtypecode');
564
my $breedingid    = $input->param('breedingid');
547
565
548
my $dbh = C4::Context->dbh;
566
my $dbh = C4::Context->dbh;
549
if(!$authtypecode) {
567
if(!$authtypecode) {
Lines 558-568 my ($template, $loggedinuser, $cookie) Link Here
558
                            flagsrequired => {editauthorities => 1},
576
                            flagsrequired => {editauthorities => 1},
559
                            debug => 1,
577
                            debug => 1,
560
                            });
578
                            });
561
$template->param(nonav   => $nonav,index=>$myindex,authtypecode=>$authtypecode,);
579
$template->param(nonav   => $nonav,index=>$myindex,authtypecode=>$authtypecode,breedingid=>$breedingid,);
580
562
$tagslib = GetTagsLabels(1,$authtypecode);
581
$tagslib = GetTagsLabels(1,$authtypecode);
563
my $record=-1;
582
my $record=-1;
564
my $encoding="";
583
my $encoding="";
565
$record = GetAuthority($authid) if ($authid);
584
if (($authid) && !($breedingid)){
585
    $record = GetAuthority($authid);
586
}
587
if ($breedingid) {
588
    ( $record, $encoding ) = MARCfindbreeding_auth( $breedingid );
589
}
590
566
my ($oldauthnumtagfield,$oldauthnumtagsubfield);
591
my ($oldauthnumtagfield,$oldauthnumtagsubfield);
567
my ($oldauthtypetagfield,$oldauthtypetagsubfield);
592
my ($oldauthtypetagfield,$oldauthtypetagsubfield);
568
$is_a_modif=0;
593
$is_a_modif=0;
(-)a/cataloguing/z3950_auth_search.pl (+105 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 $namecorp     = $input->param('namecorp');
39
my $namepersonal     = $input->param('namepersonal');
40
my $namemeetingcon     = $input->param('namemeetingcon');
41
my $title         = $input->param('title');
42
my $uniformtitle         = $input->param('uniformtitle');
43
my $subject       = $input->param('subject');
44
my $subjectsubdiv       = $input->param('subjectsubdiv');
45
my $srchany       = $input->param('srchany');
46
my $op            = $input->param('op')||'';
47
my $page            = $input->param('current_page') || 1;
48
$page = $input->param('goto_page') if $input->param('changepage_goto');
49
50
my ( $template, $loggedinuser, $cookie ) = get_template_and_user({
51
        template_name   => "cataloguing/z3950_auth_search.tmpl",
52
        query           => $input,
53
        type            => "intranet",
54
        authnotrequired => 1,
55
        flagsrequired   => { catalogue => 1 },
56
});
57
58
$template->param(
59
    nameany    => $nameany,
60
    namecorp    => $namecorp,
61
    namepersonal    => $namepersonal,
62
    namemeetingcon    => $namemeetingcon,
63
    title        => $title,
64
    uniformtitle      => $uniformtitle,
65
    subject      => $subject,
66
    subjectsubdiv   => $subjectsubdiv,
67
    srchany      => $srchany,
68
);
69
70
if ( $op ne "do_search" ) {
71
    my $sth = $dbh->prepare("SELECT id,host,name,checked FROM z3950servers ORDER BY rank, name");
72
    $sth->execute();
73
    my $serverloop = $sth->fetchall_arrayref( {} );
74
    $template->param(
75
        serverloop   => $serverloop,
76
        opsearch     => "search",
77
    );
78
    output_html_with_http_headers $input, $cookie, $template->output;
79
    exit;
80
}
81
82
my @id = $input->param('id');
83
if ( @id==0 ) {
84
        # empty server list -> report and exit
85
        $template->param( emptyserverlist => 1 );
86
        output_html_with_http_headers $input, $cookie, $template->output;
87
        exit;
88
}
89
90
my $pars= {
91
        random => $input->param('random') || rand(1000000000),
92
        page => $page,
93
        id => \@id,
94
        nameany => $nameany,
95
        namecorp => $namecorp,
96
        namepersonal => $namepersonal,
97
        namemeetingcon => $namemeetingcon,
98
        title => $title,
99
        uniformtitle => $uniformtitle,
100
        subject => $subject,
101
        subjectsubdiv => $subjectsubdiv,
102
        srchany => $srchany,
103
};
104
Z3950SearchAuth($pars, $template);
105
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 / +232 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="namepersonal">Name (personal): </label> <input type="text" id="namepersonal" name="namepersonal" value="" /></li>
115
                <li><label for="namecorp">Name (corporate): </label> <input type="text" id="namecorp" name="namecorp" value="" /></li>
116
                <li><label for="namemeetingcon">Name (meeting/conference): </label> <input type="text" id="namemeetingcon" name="namemeetingcon" value="" /></li>
117
                </ol>
118
                
119
                </fieldset>
120
            </div>
121
            <div class="yui-u">
122
                
123
                <fieldset class="rows">
124
                    <ol>
125
                 <li><label for="subject">Subject heading: </label> <input type="text" id="subject" name="subject" value="" /></li>
126
                <li><label for="subjectsubdiv">Subject sub-division: </label> <input type="text" id="subjectsubdiv" name="subjectsubdiv" value="" /></li>
127
                <li><label for="title">Title (any): </label> <input type="text" id="title"  name="title" value="[% title |html %]" /></li>
128
                <li><label for="uniformtitle">Title (uniform): </label> <input type="text" id="uniformtitle"  name="uniformtitle" value="[% uniformtitle |html %]" /></li>   
129
130
                    </ol>
131
                </fieldset>
132
            </div>
133
        </div>
134
        <div class="yui-g">
135
            <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>
136
            [% FOREACH serverloo IN serverloop %]
137
                <p> 
138
                [% IF ( serverloo.checked ) %]
139
                    <input type="checkbox" name="id" id="z3950_[% serverloo.id %]" value="[% serverloo.id %]" checked="checked" />
140
                [% ELSE %]
141
                    <input type="checkbox" name="id" id="z3950_[% serverloo.id %]" value="[% serverloo.id %]" />
142
                [% END %]
143
                <label for="z3950_[% serverloo.id %]">[% serverloo.name %]</label>  
144
                </p>
145
            [% END %]
146
        </div>
147
        <fieldset class="action"><input type="submit"  class="submit" value="Search" onclick="cursor :'wait'"/> <a class="cancel close" href="#">Cancel</a></fieldset>
148
        </form>
149
150
151
[% ELSE %]
152
    <h2>Results for Authority Records</h2>
153
    [% IF ( breeding_loop ) %]
154
    <table id="resultst">
155
<thead>    <tr>
156
        <th>Server</th>
157
        <th>Heading</th>
158
        <th>Authority Type</th>
159
        <th>MARC</th>
160
        <!-- <th>Card</th> -->
161
		<th>&nbsp;</th>
162
    </tr></thead>
163
    <tbody>[% FOREACH breeding_loo IN breeding_loop %]
164
        [% IF ( breeding_loo.breedingid ) %]
165
166
	    <tr id="row[% breeding_loo.breedingid %]">
167
            <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>
168
            <td>[% breeding_loo.heading %]</td>
169
            <td>[% breeding_loo.heading_code %]</td>
170
            <td><a href="/cgi-bin/koha/catalogue/showmarc.pl?importid=[% breeding_loo.breedingid %]" title="MARC" rel="gb_page_center[600,500]">MARC</a></td>
171
            <!-- <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> -->
172
            <td><a href="#" onclick="Import([% breeding_loo.breedingid %],'[% breeding_loo.heading_code %]'); return false">Import</a></td> 
173
        </tr>
174
        [% END %]
175
    [% END %]</tbody>
176
</table>
177
178
    <form method="post" action="z3950_auth_search.pl" id="page_form" name="page_form" class="checkboxed">
179
        <input type="hidden" name="op" id="op" value="do_search" />
180
        <input type="hidden" name="current_page" id="current_page" value="[% current_page %]" />
181
        <input type="hidden" id="nameany"  name="nameany" value="[% nameany %]" />
182
        <input type="hidden" id="namecorp"  name="namecorp" value="[% namecorp %]" />
183
        <input type="hidden" id="namepersonal"  name="namepersonal" value="[% namepersonal %]" />
184
        <input type="hidden" id="namemeetingcon"  name="namemeetingcon" value="[% namemeetingcon %]" />
185
        <input type="hidden" id="title"  name="title" value="[% title %]" />
186
        <input type="hidden" id="uniformtitle"  name="uniformtitle" value="[% uniformtitle %]" />
187
        <input type="hidden" id="subject" name="subject" value="[% subject %]" />
188
        <input type="hidden" id="subjectsubdiv" name="subjectsubdiv" value="[% subjectsubdiv %]" />
189
        <input type="hidden" id="heading"  name="heading" value="[% heading %]" /> 
190
        <input type="hidden" id="srchany" name="srchany" value="[% srchany %]" />
191
        
192
        [% FOREACH server IN servers %]
193
        <input type="hidden" name="id" id="z3950_[% server.id %]" value="[% server.id %]" />
194
        [% END %]
195
196
        [% IF ( show_prevbutton ) %]
197
            <input type="button" name="changepage_prev" value="Previous Page" onclick="$('#current_page').val([% current_page %]-1);$('#page_form').submit();" />
198
        [% END %]
199
        Page [% current_page %] / [% total_pages %]
200
        [% IF ( show_nextbutton ) %]
201
            <input type="button" name="changepage_next" value="Next Page" onclick="$('#current_page').val([% current_page %]+1);$('#page_form').submit();" />
202
        [% END %]
203
        <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" />
204
    </form>
205
206
<p><form method="get" action="/cgi-bin/koha/cataloguing/z3950_auth_search.pl"><input type="submit" value="Try Another Search"/></form></p>
207
    [% ELSE %]
208
        [% IF ( errconn ) %]
209
            <div class="dialog alert">
210
                <ul>
211
                [% FOREACH errcon IN errconn %]
212
                    [% IF ( errcon.error == '10000' ) %]<li>Connection failed to [% errcon.server %]</li>
213
                    [% ELSIF ( errcon.error == '10007' ) %]<li>Connection timeout to [% errcon.server %]</li>[% END %]
214
                [% END %]
215
                </ul>
216
            </div>
217
         [% END %]
218
   <div class="dialog message">Nothing found.</div>
219
	<p><form method="get" action="/cgi-bin/koha/cataloguing/z3950_auth_search.pl"><input type="submit" value="Try Another Search"/></form></p>
220
    [% END %]
221
222
223
[% END %]
224
225
	</div>
226
</div>
227
228
[% IF ( numberpending ) %]<h3 align="center">Still [% numberpending %] servers to search</h3>[% END %]
229
230
</body>
231
</html>
232

Return to bug 10096