Adding a plugin to select multiple authorised_values.
Beware, It works only for one authorised_value category at the moment but would be easy to change to support any category if add_biblio.pl would be change to take plugin before authorised values into account.
This commit is contained in:
parent
fb1dc97a5d
commit
296c7e5a57
|
|
@ -0,0 +1,126 @@
|
|||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
||||
<html>
|
||||
<head>
|
||||
<title>KOHA: Labs Thesis Selection plugin</title>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
|
||||
|
||||
<script language="JavaScript" type="text/javascript">
|
||||
<!-- Hide from old browsers
|
||||
function openWindow(targeturl, windowname) {
|
||||
newwin =
|
||||
window.open(targeturl,windowname,"height=480,width=640,scrollbars,resizable")
|
||||
}
|
||||
function Help() {
|
||||
newin=window.open("/cgi-bin/koha/help.pl","Koha Help",'width=600,height=600,toolbar=false,scrollbars=yes');
|
||||
}
|
||||
// end hiding -->
|
||||
</script>
|
||||
|
||||
<link rel="stylesheet" type="text/css" href="/intranet-tmpl/default/en/includes/common-style.css">
|
||||
<style type="text/css">
|
||||
.catalogue {
|
||||
background-color:#ad11ad;
|
||||
color:#FFFFFF;
|
||||
background-image:none;
|
||||
text-decoration: normal;
|
||||
}
|
||||
a.catalogue:hover {
|
||||
background-color: #ad11ad;
|
||||
color: #FFFFFF;
|
||||
text-decoration: none;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div id="mainbloc">
|
||||
<h1 class="catalogue">Laboratory Search</h1>
|
||||
|
||||
<form name="f" method="post" action="/cgi-bin/koha/plugin_launcher.pl">
|
||||
<div class="bloc25">
|
||||
<h2 class="catalogue">Search on</h2>
|
||||
<p>
|
||||
<input type="hidden" name="plugin_name" value="labs_theses.pl">
|
||||
<input type="hidden" name="index" value="<!--TMPL_VAR Name="index" -->">
|
||||
<input type="hidden" name="result" value="unimarc field 328 <!--TMPL_VAR Name="index" -->">
|
||||
<input type="hidden" name="op" value="do_search">
|
||||
<input type="hidden" name="cat_auth" value="<!--TMPL_VAR Name="cat_auth" -->" >
|
||||
<input type="text" name="search" value="<!-- TMPL_VAR Name="search" -->" size="35">
|
||||
|
||||
<input type="submit" value="Start search" class="button catalogue">
|
||||
</p>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
<!-- TMPL_IF Name="resultlist" -->
|
||||
<div class="bloc25">
|
||||
<h2 class="catalogue">Laboratory Search results</h2>
|
||||
<div id="resultnumber">
|
||||
<p class="resultcount">
|
||||
<!-- TMPL_IF NAME="total" -->
|
||||
Results <!-- TMPL_VAR NAME="from" --> to <!-- TMPL_VAR NAME="to" --> of <!-- TMPL_VAR NAME="total" --><!-- TMPL_ELSE -->No results found.
|
||||
<!-- /TMPL_IF -->
|
||||
</p>
|
||||
</div>
|
||||
<div id="resultlist">
|
||||
<table>
|
||||
<tr>
|
||||
<th class="catalogue">Laboratory</th>
|
||||
<th class="catalogue">Select</th>
|
||||
</tr>
|
||||
<!-- TMPL_LOOP NAME="catresult" -->
|
||||
<!-- TMPL_IF NAME="even" -->
|
||||
<tr class="hilighted">
|
||||
<!-- TMPL_ELSE -->
|
||||
<tr>
|
||||
<!-- /TMPL_IF -->
|
||||
<td>
|
||||
<!-- TMPL_VAR NAME="lib" -->
|
||||
</td>
|
||||
<td>
|
||||
<a href="javascript:SelectEntry('<!-- TMPL_VAR NAME="libjs" ESCAPE="URL" -->','<!-- TMPL_VAR NAME="auth_value" ESCAPE="URL" -->',<!-- TMPL_VAR NAME="index" ESCAPE="URL" -->,0)" class="button catalogue">Select</a>
|
||||
<a href="javascript:SelectEntry('<!-- TMPL_VAR NAME="libjs" ESCAPE="URL" -->','<!-- TMPL_VAR NAME="auth_value" ESCAPE="URL" -->',<!-- TMPL_VAR NAME="index" ESCAPE="URL" -->,1)" class="button catalogue">Sel&close</a>
|
||||
</td>
|
||||
</tr>
|
||||
<!-- /TMPL_LOOP -->
|
||||
</table>
|
||||
</div>
|
||||
<div id="resultnumber">
|
||||
<p><!-- TMPL_IF NAME="displayprev" -->
|
||||
<a class="resultnumber" href="/cgi-bin/koha/plugin_launcher.pl?plugin_name=labs_theses.pl&startfrom=<!-- TMPL_VAR NAME="startfromprev" -->&cat_auth=<!-- TMPL_VAR NAME="cat_auth" ESCAPE=URL-->&search=<!-- TMPL_VAR NAME="search" ESCAPE=URL-->&resultsperpage=<!-- TMPL_VAR NAME="resultsperpage" -->&type=intranet&op=do_search&index=<!-- TMPL_VAR Name="anindex" -->"><<Previous</a>
|
||||
<!-- /TMPL_IF -->
|
||||
<!-- TMPL_LOOP NAME="numbers" -->
|
||||
<!-- TMPL_IF NAME="highlight" -->
|
||||
<span class="highlight"><!-- TMPL_VAR NAME="number" --></span>
|
||||
<!-- TMPL_ELSE -->
|
||||
<a class="resultnumber" href="/cgi-bin/koha/plugin_launcher.pl?plugin_name=labs_theses.pl&startfrom=<!-- TMPL_VAR NAME="startfrom" -->&cat_auth=<!-- TMPL_VAR NAME="cat_auth" ESCAPE=URL-->&search=<!-- TMPL_VAR NAME="search" ESCAPE=URL -->&resultsperpage=<!-- TMPL_VAR NAME="resultsperpage" -->&type=intranet&op=do_search&index=<!-- TMPL_VAR Name="anindex" -->"><!-- TMPL_VAR NAME="number" --></a>
|
||||
<!-- /TMPL_IF -->
|
||||
<!-- /TMPL_LOOP -->
|
||||
<!-- TMPL_IF NAME="displaynext" -->
|
||||
<a class="resultnumber" href="/cgi-bin/koha/plugin_launcher.pl?plugin_name=labs_theses.pl&startfrom=<!-- TMPL_VAR NAME="startfromnext" -->&cat_auth=<!-- TMPL_VAR NAME="cat_auth" ESCAPE=URL-->&search=<!-- TMPL_VAR NAME="search" -->&resultsperpage=<!-- TMPL_VAR NAME="resultsperpage" -->&type=intranet&op=do_search&index=<!-- TMPL_VAR Name="anindex" -->">Next>></a>
|
||||
<!-- /TMPL_IF -->
|
||||
</p>
|
||||
<p class="resultcount">
|
||||
<!-- TMPL_IF NAME="total" -->
|
||||
Results <!-- TMPL_VAR NAME="from" --> to <!-- TMPL_VAR NAME="to" --> of <!-- TMPL_VAR NAME="total" --><!-- TMPL_ELSE -->No results found.
|
||||
<!-- /TMPL_IF -->
|
||||
</p>
|
||||
</div>
|
||||
<script language="JavaScript" type="text/javascript">
|
||||
function SelectEntry(myentry, mycode, myindex, wclose){
|
||||
if (opener.document.f.field_value[myindex].value!=""){
|
||||
opener.document.f.field_value[myindex].value=opener.document.f.field_value[myindex].value+"|"+myentry
|
||||
} else {
|
||||
opener.document.f.field_value[myindex].value=myentry
|
||||
}
|
||||
if (wclose == 1) {
|
||||
// alert("closing")
|
||||
self.close();
|
||||
}
|
||||
}
|
||||
</script>
|
||||
</div>
|
||||
<!-- /TMPL_IF -->
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
|
|
@ -0,0 +1,184 @@
|
|||
#!/usr/bin/perl
|
||||
|
||||
# Copyright 2000-2002 Katipo Communications
|
||||
#
|
||||
# This file is part of Koha.
|
||||
#
|
||||
# Koha is free software; you can redistribute it and/or modify it under the
|
||||
# terms of the GNU General Public License as published by the Free Software
|
||||
# Foundation; either version 2 of the License, or (at your option) any later
|
||||
# version.
|
||||
#
|
||||
# Koha is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
||||
# A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License along with
|
||||
# Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
|
||||
# Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
use strict;
|
||||
require Exporter;
|
||||
use CGI;
|
||||
use HTML::Template;
|
||||
use C4::Interface::CGI::Output;
|
||||
use C4::Context;
|
||||
use C4::Auth;
|
||||
use C4::Output;
|
||||
use C4::Database;
|
||||
use C4::Koha;
|
||||
|
||||
sub plugin_parameters {
|
||||
my ($dbh,$record,$tagslib,$i,$tabloop) = @_;
|
||||
return "";
|
||||
}
|
||||
|
||||
sub plugin_javascript {
|
||||
my ($dbh,$record,$tagslib,$field_number,$tabloop) = @_;
|
||||
my $function_name= "328".(int(rand(100000))+1);
|
||||
my $res="
|
||||
<script>
|
||||
function Focus$function_name(subfield_managed) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
function Blur$function_name(subfield_managed) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
function Clic$function_name(i) {
|
||||
defaultvalue=document.f.field_value[i].value;
|
||||
newin=window.open(\"../plugin_launcher.pl?plugin_name=labs_theses.pl&cat_auth=LABTHE&index=\"+i+\"&result=\"+defaultvalue,\"unimarc field 328\",'width=700,height=700,toolbar=false,scrollbars=yes');
|
||||
|
||||
}
|
||||
</script>
|
||||
";
|
||||
|
||||
return ($function_name,$res);
|
||||
}
|
||||
|
||||
sub plugin {
|
||||
my ($input) = @_;
|
||||
my %env;
|
||||
|
||||
|
||||
my $dbh=C4::Context->dbh;
|
||||
my $query = new CGI;
|
||||
my $op = $query->param('op');
|
||||
my $cat_auth=$query->param('cat_auth');
|
||||
|
||||
my $startfrom=$query->param('startfrom');
|
||||
$startfrom=0 if(!defined $startfrom);
|
||||
my ($template, $loggedinuser, $cookie);
|
||||
my $resultsperpage;
|
||||
my $search = $query->param('search');
|
||||
|
||||
if ($op eq "do_search") {
|
||||
|
||||
$resultsperpage= $query->param('resultsperpage');
|
||||
$resultsperpage = 19 if(!defined $resultsperpage);
|
||||
# my $upperlimit=$startfrom+$resultsperpage;
|
||||
# builds tag and subfield arrays
|
||||
my $strquery = "SELECT authorised_value, lib from authorised_values where category = ? and lib like ?";
|
||||
# $strquery .= " LIMIT $startfrom,$upperlimit";
|
||||
|
||||
warn 'category : '.$cat_auth.' recherche :'.$search;
|
||||
warn "$strquery";
|
||||
$search=~s/\*/%/g;
|
||||
my $sth = $dbh->prepare($strquery);
|
||||
$sth->execute($cat_auth,$search);
|
||||
$search=~s/%/\*/g;
|
||||
|
||||
|
||||
my @results;
|
||||
my $total;
|
||||
while (my $data = $sth->fetchrow_hashref){
|
||||
my $libjs=$data->{'lib'};
|
||||
$libjs=~s#\'#\\\'#g;
|
||||
warn $libjs;
|
||||
push @results, {'libjs'=>$libjs,
|
||||
'lib'=>$data->{'lib'},
|
||||
'auth_value'=>$data->{'authorised_value'}}
|
||||
unless (($total<$startfrom) or ($total>$startfrom+$resultsperpage));
|
||||
$total++;
|
||||
}
|
||||
|
||||
($template, $loggedinuser, $cookie)
|
||||
= get_template_and_user({template_name => "value_builder/labs_theses.tmpl",
|
||||
query => $query,
|
||||
type => 'intranet',
|
||||
authnotrequired => 1,
|
||||
debug => 1,
|
||||
});
|
||||
|
||||
# multi page display gestion
|
||||
my $displaynext=0;
|
||||
my $displayprev=$startfrom;
|
||||
if(($total - (($startfrom+1)*($resultsperpage))) > 0 ){
|
||||
$displaynext = 1;
|
||||
}
|
||||
|
||||
my @numbers = ();
|
||||
|
||||
if ($total>$resultsperpage)
|
||||
{
|
||||
for (my $i=1; (($i<$total/$resultsperpage+1) && ($i<16)); $i++)
|
||||
{
|
||||
my $highlight=0;
|
||||
($startfrom==($i-1)) && ($highlight=1);
|
||||
push @numbers, { number => $i,
|
||||
highlight => $highlight ,
|
||||
search=> $search,
|
||||
startfrom => $resultsperpage*($i-1)};
|
||||
}
|
||||
}
|
||||
|
||||
my $from = $startfrom+1;
|
||||
my $to;
|
||||
|
||||
if($total < (($startfrom+1)*$resultsperpage))
|
||||
{
|
||||
$to = $total;
|
||||
} else {
|
||||
$to = (($startfrom+1)*$resultsperpage);
|
||||
}
|
||||
$template->param(catresult => \@results,
|
||||
cat_auth=>$cat_auth,
|
||||
index => $query->param('index')."",
|
||||
startfrom=> $startfrom,
|
||||
displaynext=> $displaynext,
|
||||
displayprev=> $displayprev,
|
||||
resultsperpage => $resultsperpage,
|
||||
startfromnext => $startfrom+$resultsperpage,
|
||||
startfromprev => $startfrom-$resultsperpage,
|
||||
search=>$search,
|
||||
total=>$total,
|
||||
from=>$from,
|
||||
to=>$to,
|
||||
numbers=>\@numbers,
|
||||
resultlist=>1
|
||||
);
|
||||
|
||||
} else {
|
||||
($template, $loggedinuser, $cookie)
|
||||
= get_template_and_user({template_name => "value_builder/labs_theses.tmpl",
|
||||
query => $query,
|
||||
type => "intranet",
|
||||
authnotrequired => 1,
|
||||
});
|
||||
|
||||
$template->param(
|
||||
'search'=>$query->param('search'),
|
||||
);
|
||||
$template->param(
|
||||
'index'=>''.$query->param('index')
|
||||
) if ($query->param('index'));
|
||||
warn 'index : '.$query->param('index');
|
||||
$template->param(
|
||||
'cat_auth'=>$cat_auth
|
||||
) if ($cat_auth);
|
||||
}
|
||||
output_html_with_http_headers $query, $cookie, $template->output ;
|
||||
}
|
||||
|
||||
1;
|
||||
Loading…
Reference in New Issue