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

(-)a/cataloguing/value_builder/labs_theses.pl (-188 lines)
Lines 1-188 Link Here
1
#!/usr/bin/perl
2
3
# Copyright 2000-2002 Katipo Communications
4
#
5
# This file is part of Koha.
6
#
7
# Koha is free software; you can redistribute it and/or modify it under the
8
# terms of the GNU General Public License as published by the Free Software
9
# Foundation; either version 2 of the License, or (at your option) any later
10
# version.
11
#
12
# Koha is distributed in the hope that it will be useful, but WITHOUT ANY
13
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
14
# A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
15
#
16
# You should have received a copy of the GNU General Public License along
17
# with Koha; if not, write to the Free Software Foundation, Inc.,
18
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19
20
use strict;
21
#use warnings; FIXME - Bug 2505
22
23
use CGI;
24
25
use C4::Output;
26
use C4::Context;
27
use C4::Auth;
28
use C4::Output;
29
30
use C4::Koha;
31
32
sub plugin_parameters {
33
my ($dbh,$record,$tagslib,$i,$tabloop) = @_;
34
return "";
35
}
36
37
sub plugin_javascript {
38
my ($dbh,$record,$tagslib,$field_number,$tabloop) = @_;
39
my $function_name= "328".(int(rand(100000))+1);
40
my $res="
41
<script type=\"text/javascript\">
42
//<![CDATA[
43
44
function Focus$function_name(subfield_managed) {
45
return 1;
46
}
47
48
function Blur$function_name(subfield_managed) {
49
	return 1;
50
}
51
52
function Clic$function_name(i) {
53
	defaultvalue=document.f.field_value[i].value;
54
	newin=window.open(\"../cataloguing/plugin_launcher.pl?plugin_name=labs_theses.pl&cat_auth=LABTHE&index=\"+i+\"&result=\"+defaultvalue,\"tag_editor\",'width=700,height=700,toolbar=false,scrollbars=yes');
55
56
}
57
//]]>
58
</script>
59
";
60
61
return ($function_name,$res);
62
}
63
64
sub plugin {
65
	my ($input) = @_;
66
	my $dbh=C4::Context->dbh;
67
	my $query = new CGI;
68
	my $op = $query->param('op');
69
	my $cat_auth=$query->param('cat_auth');
70
71
	my $startfrom=$query->param('startfrom');
72
	$startfrom=0 if(!defined $startfrom);
73
	my ($template, $loggedinuser, $cookie);
74
	my $resultsperpage;
75
	my $search = $query->param('search');
76
77
	if ($op eq "do_search") {
78
79
		$resultsperpage= $query->param('resultsperpage');
80
		$resultsperpage = 19 if(!defined $resultsperpage);
81
# 		my $upperlimit=$startfrom+$resultsperpage;
82
		# builds tag and subfield arrays
83
		my $strquery = "SELECT authorised_value, lib from authorised_values where category = ? and lib like ?";
84
# 		$strquery .= " LIMIT $startfrom,$upperlimit";
85
86
		$search=~s/\*/%/g;
87
		my $sth = $dbh->prepare($strquery);
88
		$sth->execute($cat_auth,$search);
89
		$search=~s/%/\*/g;
90
91
92
		my @results;
93
		my $total;
94
		while (my $data = $sth->fetchrow_hashref){
95
			my $libjs=$data->{'lib'};
96
			$libjs=~s#\'#\\\'#g;
97
			my $authjs=$data->{'authorised_value'};
98
			$authjs=~s#\'#\\\'#g;
99
			push @results, {'libjs'=>$libjs,
100
							'lib'=>$data->{'lib'},
101
							'authjs'=>$authjs,
102
							'auth_value'=>$data->{'authorised_value'}}
103
							unless (($total<$startfrom) or ($total>$startfrom+$resultsperpage));
104
			$total++;
105
		}
106
107
        ($template, $loggedinuser, $cookie) = get_template_and_user(
108
            {
109
                template_name   => "value_builder/labs_theses.tt",
110
                query           => $query,
111
                type            => 'intranet',
112
                authnotrequired => 0,
113
                debug           => 1,
114
            }
115
        );
116
117
		# multi page display gestion
118
		my $displaynext=0;
119
		my $displayprev=$startfrom;
120
		if(($total - (($startfrom+1)*($resultsperpage))) > 0 ){
121
			$displaynext = 1;
122
		}
123
124
		my @numbers = ();
125
126
		if ($total>$resultsperpage)
127
		{
128
			for (my $i=1; (($i<$total/$resultsperpage+1) && ($i<16)); $i++)
129
			{
130
					my $highlight=0;
131
					($startfrom==($i-1)) && ($highlight=1);
132
					push @numbers, { number => $i,
133
						highlight => $highlight ,
134
						search=> $search,
135
						startfrom => $resultsperpage*($i-1)};
136
			}
137
		}
138
139
		my $from = $startfrom+1;
140
		my $to;
141
142
		if($total < (($startfrom+1)*$resultsperpage))
143
		{
144
			$to = $total;
145
		} else {
146
			$to = (($startfrom+1)*$resultsperpage);
147
		}
148
 		$template->param(catresult => \@results,
149
 						cat_auth=>$cat_auth,
150
 						index => $query->param('index')."",
151
 								startfrom=> $startfrom,
152
								displaynext=> $displaynext,
153
								displayprev=> $displayprev,
154
								resultsperpage => $resultsperpage,
155
								startfromnext => $startfrom+$resultsperpage,
156
								startfromprev => $startfrom-$resultsperpage,
157
								search=>$search,
158
								total=>$total,
159
								from=>$from,
160
								to=>$to,
161
								numbers=>\@numbers,
162
								resultlist=>1
163
								);
164
165
	} else {
166
        ($template, $loggedinuser, $cookie) = get_template_and_user(
167
            {
168
                template_name   => "value_builder/labs_theses.tt",
169
                query           => $query,
170
                type            => "intranet",
171
                authnotrequired => 0,
172
            }
173
        );
174
175
		$template->param(
176
						'search'=>$query->param('search'),
177
		);
178
		$template->param(
179
						'index'=>''.$query->param('index')
180
		) if ($query->param('index'));
181
		$template->param(
182
 						'cat_auth'=>$cat_auth
183
		) if ($cat_auth);
184
	}
185
	output_html_with_http_headers $query, $cookie, $template->output ;
186
}
187
188
1;
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/value_builder/labs_theses.tt (-123 lines)
Lines 1-122 Link Here
1
[% INCLUDE 'doc-head-open.inc' %]
2
<title>Koha &rsaquo; Labs thesis selection plugin</title>
3
[% INCLUDE 'doc-head-close.inc' %]
4
<script type="text/javascript">
5
//<![CDATA[
6
function openWindow(targeturl, windowname) {
7
	newwin =
8
window.open(targeturl,windowname,"height=480,width=640,scrollbars,resizable")
9
}
10
function Help() {
11
	newin=window.open("/cgi-bin/koha/help.pl","KohaHelp",'width=600,height=600,toolbar=false,scrollbars=yes');
12
}
13
//]]>
14
</script>
15
16
<link rel="stylesheet" type="text/css" href="/intranet-tmpl/default/en/includes/common-style.css" />
17
<style type="text/css">
18
.catalogue {
19
	background-color:#ad11ad;
20
	color:#FFFFFF;
21
	background-image:none;
22
	text-decoration: normal;
23
	}
24
a.catalogue:hover {
25
	background-color: #ad11ad;
26
	color: #FFFFFF;
27
	text-decoration: none;
28
	}
29
</style>
30
</head>
31
32
<body id="cat_labs_theses" class="cat" style="padding:1em;">
33
<div id="mainbloc">
34
    <h1>Laboratory search</h1>
35
	
36
	<form name="f" method="post" action="/cgi-bin/koha/cataloguing/plugin_launcher.pl">
37
		<div class="bloc25">
38
			<h2>Search on</h2>
39
			<p>
40
				<input type="hidden" name="plugin_name" value="labs_theses.pl">
41
				<input type="hidden" name="index" value="[% index %]">
42
				<input type="hidden" name="result" value="unimarc field 328 [% index %]">
43
				<input type="hidden" name="op" value="do_search">
44
				<input type="hidden" name="cat_auth" value="[% cat_auth %]" >
45
				<input type="text" name="search" value="[% search %]" size="35">
46
				
47
				<input type="submit" value="Start search" class="button">
48
			</p>
49
		</div>
50
	</form>
51
52
[% IF ( resultlist ) %]
53
	<div class="bloc25">
54
    <h2>Laboratory search results</h2>
55
		<div id="resultnumber">
56
			<p class="resultcount">
57
			[% IF ( total ) %]
58
					Results [% from %] to [% to %] of [% total %][% ELSE %]No results found
59
			[% END %]
60
			</p>
61
		</div>
62
		<div id="resultlist">
63
			<table>
64
				<tr>
65
					<th>Laboratory</th>
66
					<th>Select</th>
67
				</tr>
68
				[% FOREACH catresul IN catresult %]
69
					[% IF ( catresul.even ) %]
70
					<tr class="hilighted">
71
					[% ELSE %]
72
					<tr>
73
					[% END %]
74
						<td>
75
						[% catresul.lib %]
76
						</td>
77
						<td>
78
							<a  href="javascript:SelectEntry('[% catresul.libjs |url %]','[% catresul.authjs |url %]',[% catresul.index |url %],0)" class="button">Select</a>
79
							<a  href="javascript:SelectEntry('[% catresul.libjs |url %]','[% catresul.authjs |url %]',[% catresul.index |url %],1)" class="button">Sel&amp;close</a>
80
						</td>
81
					</tr>
82
				[% END %]
83
			</table>
84
		</div>
85
		<div id="resultnumber">
86
			<p>[% IF ( displayprev ) %] 
87
					<a class="resultnumber" href="/cgi-bin/koha/cataloguing/plugin_launcher.pl?plugin_name=labs_theses.pl&amp;startfrom=[% startfromprev %]&amp;cat_auth=[% cat_auth |url %]&amp;search=[% search |url %]&amp;resultsperpage=[% resultsperpage %]&amp;type=intranet&amp;op=do_search&amp;index=[% anindex %]">&lt;&lt; Previous</a>
88
				[% END %]
89
				[% FOREACH number IN numbers %]
90
					[% IF ( number.highlight ) %]
91
						<span class="highlight">[% number.number %]</span>
92
					[% ELSE %] 
93
						<a class="resultnumber" href="/cgi-bin/koha/cataloguing/plugin_launcher.pl?plugin_name=labs_theses.pl&amp;startfrom=[% number.startfrom %]&amp;cat_auth=[% number.cat_auth |url %]&amp;search=[% number.search |url %]&amp;resultsperpage=[% number.resultsperpage %]&amp;type=intranet&amp;op=do_search&amp;index=[% number.anindex %]">[% number.number %]</a>
94
					[% END %]
95
				[% END %] 
96
				[% IF ( displaynext ) %]
97
					<a class="resultnumber" href="/cgi-bin/koha/cataloguing/plugin_launcher.pl?plugin_name=labs_theses.pl&amp;startfrom=[% startfromnext %]&amp;cat_auth=[% cat_auth |url %]&amp;search=[% search %]&amp;resultsperpage=[% resultsperpage %]&amp;type=intranet&amp;op=do_search&amp;index=[% anindex %]">Next&gt;&gt;</a>
98
				[% END %]
99
			</p>
100
			<p class="resultcount">
101
			[% IF ( total ) %]
102
					Results [% from %] to [% to %] of [% total %][% ELSE %]No results found
103
			[% END %]
104
			</p>
105
		</div>
106
	<script language="JavaScript" type="text/javascript">
107
	function SelectEntry(myentry, mycode, myindex, wclose){
108
		if (opener.document.f.field_value[myindex].value!=""){ 
109
			opener.document.f.field_value[myindex].value=opener.document.f.field_value[myindex].value+"|"+myentry
110
		} else {
111
			opener.document.f.field_value[myindex].value=myentry
112
		}
113
		if (wclose == 1) {
114
	// 	alert("closing")
115
			self.close();
116
		}
117
	}
118
	</script>
119
	</div>
120
[% END %]
121
</div>
122
[% INCLUDE 'popup-bottom.inc' %]
123
- 

Return to bug 13204