Lines 34-42
use C4::Branch;
Link Here
|
34 |
use C4::ItemType; |
34 |
use C4::ItemType; |
35 |
|
35 |
|
36 |
sub plugin_javascript { |
36 |
sub plugin_javascript { |
37 |
my ( $dbh, $record, $tagslib, $field_number, $tabloop ) = @_; |
37 |
my ( $dbh, $record, $tagslib, $field_number, $tabloop ) = @_; |
38 |
my $function_name = $field_number; |
38 |
my $function_name = $field_number; |
39 |
my $res = " |
39 |
my $res = " |
40 |
<script type='text/javascript'> |
40 |
<script type='text/javascript'> |
41 |
function Clic$function_name(i) { |
41 |
function Clic$function_name(i) { |
42 |
defaultvalue=document.getElementById(\"$field_number\").value; |
42 |
defaultvalue=document.getElementById(\"$field_number\").value; |
Lines 60-334
sub plugin_javascript {
Link Here
|
60 |
sub plugin { |
60 |
sub plugin { |
61 |
my ($input) = @_; |
61 |
my ($input) = @_; |
62 |
my $dbh = C4::Context->dbh; |
62 |
my $dbh = C4::Context->dbh; |
63 |
my $query = new CGI; |
63 |
my $query = new CGI; |
64 |
my $op = $query->param('op'); |
64 |
my $op = $query->param('op'); |
65 |
my $type = $query->param('type'); |
65 |
my $type = $query->param('type'); |
66 |
my $startfrom = $query->param('startfrom'); |
66 |
my $startfrom = $query->param('startfrom'); |
67 |
$startfrom = 0 if ( !defined $startfrom ); |
67 |
$startfrom = 0 if ( !defined $startfrom ); |
68 |
my ( $template, $loggedinuser, $cookie ); |
68 |
my ( $template, $loggedinuser, $cookie ); |
69 |
my $resultsperpage; |
69 |
my $resultsperpage; |
70 |
my $searchdesc; |
70 |
my $searchdesc; |
71 |
|
71 |
|
72 |
if ( $op eq "fillinput" ) { |
72 |
if ( $op eq "fillinput" ) { |
73 |
my $biblionumber = $query->param('biblionumber'); |
73 |
my $biblionumber = $query->param('biblionumber'); |
74 |
my $index = $query->param('index'); |
74 |
my $index = $query->param('index'); |
75 |
my $marcrecord; |
75 |
my $marcrecord; |
76 |
|
76 |
|
77 |
# open template |
77 |
# open template |
78 |
( $template, $loggedinuser, $cookie ) = get_template_and_user( |
78 |
( $template, $loggedinuser, $cookie ) = get_template_and_user( |
79 |
{ |
79 |
{ template_name => "cataloguing/value_builder/marc21_linking_section.tt", |
80 |
template_name => |
80 |
query => $query, |
81 |
"cataloguing/value_builder/marc21_linking_section.tt", |
81 |
type => "intranet", |
82 |
query => $query, |
82 |
authnotrequired => 0, |
83 |
type => "intranet", |
83 |
flagsrequired => { editcatalogue => '*' }, |
84 |
authnotrequired => 0, |
84 |
debug => 1, |
85 |
flagsrequired => { editcatalogue => '*' }, |
85 |
} |
86 |
debug => 1, |
86 |
); |
87 |
} |
87 |
|
88 |
); |
88 |
#get marc record |
89 |
|
89 |
$marcrecord = GetMarcBiblio($biblionumber); |
90 |
#get marc record |
90 |
|
91 |
$marcrecord = GetMarcBiblio($biblionumber); |
91 |
my $subfield_value_9 = $biblionumber; |
92 |
|
92 |
my $subfield_value_0 = $biblionumber; |
93 |
my $subfield_value_9 = $biblionumber; |
93 |
|
94 |
my $subfield_value_0 = $biblionumber; |
94 |
#my $subfield_value_0; |
95 |
|
95 |
#$subfield_value_0 = $marcrecord->field('001')->data |
96 |
#my $subfield_value_0; |
96 |
# if $marcrecord->field('001'); |
97 |
#$subfield_value_0 = $marcrecord->field('001')->data |
97 |
my $subfield_value_w; |
98 |
# if $marcrecord->field('001'); |
98 |
if ( $marcrecord->field('001') ) { |
99 |
my $subfield_value_w; |
99 |
$subfield_value_w = $marcrecord->field('001')->data; |
100 |
if ( $marcrecord->field('001') ) { |
100 |
} else { |
101 |
$subfield_value_w = $marcrecord->field('001')->data; |
101 |
$subfield_value_w = $biblionumber; |
102 |
} |
102 |
} |
103 |
else { |
103 |
|
104 |
$subfield_value_w = $biblionumber; |
104 |
my $subfield_value_a; |
105 |
} |
105 |
my $subfield_value_c; |
106 |
|
106 |
my $subfield_value_d; |
107 |
my $subfield_value_a; |
107 |
my $subfield_value_e; |
108 |
my $subfield_value_c; |
108 |
|
109 |
my $subfield_value_d; |
109 |
my $subfield_value_h; |
110 |
my $subfield_value_e; |
110 |
|
111 |
|
111 |
my $subfield_value_i; |
112 |
my $subfield_value_h; |
112 |
|
113 |
|
113 |
my $subfield_value_p; |
114 |
my $subfield_value_i; |
114 |
|
115 |
|
115 |
my $subfield_value_t; |
116 |
my $subfield_value_p; |
116 |
if ( $marcrecord->field('245') ) { |
117 |
|
117 |
$subfield_value_t = $marcrecord->title(); |
118 |
my $subfield_value_t; |
118 |
} |
119 |
if ( $marcrecord->field('245') ) { |
119 |
|
120 |
$subfield_value_t = $marcrecord->title(); |
120 |
my $subfield_value_u; |
121 |
} |
121 |
my $subfield_value_v; |
122 |
|
122 |
my $subfield_value_x; |
123 |
my $subfield_value_u; |
123 |
my $subfield_value_y; |
124 |
my $subfield_value_v; |
124 |
my $subfield_value_z; |
125 |
my $subfield_value_x; |
125 |
|
126 |
my $subfield_value_y; |
126 |
$subfield_value_x = $marcrecord->field('022')->subfield("a") |
127 |
my $subfield_value_z; |
127 |
if ( $marcrecord->field('022') ); |
128 |
|
128 |
$subfield_value_z = $marcrecord->field('020')->subfield("a") |
129 |
$subfield_value_x = $marcrecord->field('022')->subfield("a") |
129 |
if ( $marcrecord->field('020') ); |
130 |
if ( $marcrecord->field('022') ); |
130 |
|
131 |
$subfield_value_z = $marcrecord->field('020')->subfield("a") |
131 |
# escape the 's |
132 |
if ( $marcrecord->field('020') ); |
132 |
$subfield_value_9 =~ s/'/\\'/g; |
133 |
|
133 |
$subfield_value_0 =~ s/'/\\'/g; |
134 |
# escape the 's |
134 |
$subfield_value_a =~ s/'/\\'/g; |
135 |
$subfield_value_9 =~ s/'/\\'/g; |
135 |
$subfield_value_c =~ s/'/\\'/g; |
136 |
$subfield_value_0 =~ s/'/\\'/g; |
136 |
$subfield_value_d =~ s/'/\\'/g; |
137 |
$subfield_value_a =~ s/'/\\'/g; |
137 |
$subfield_value_e =~ s/'/\\'/g; |
138 |
$subfield_value_c =~ s/'/\\'/g; |
138 |
$subfield_value_h =~ s/'/\\'/g; |
139 |
$subfield_value_d =~ s/'/\\'/g; |
139 |
$subfield_value_i =~ s/'/\\'/g; |
140 |
$subfield_value_e =~ s/'/\\'/g; |
140 |
$subfield_value_p =~ s/'/\\'/g; |
141 |
$subfield_value_h =~ s/'/\\'/g; |
141 |
$subfield_value_t =~ s/'/\\'/g; |
142 |
$subfield_value_i =~ s/'/\\'/g; |
142 |
$subfield_value_u =~ s/'/\\'/g; |
143 |
$subfield_value_p =~ s/'/\\'/g; |
143 |
$subfield_value_v =~ s/'/\\'/g; |
144 |
$subfield_value_t =~ s/'/\\'/g; |
144 |
$subfield_value_w =~ s/'/\\'/g; |
145 |
$subfield_value_u =~ s/'/\\'/g; |
145 |
$subfield_value_x =~ s/'/\\'/g; |
146 |
$subfield_value_v =~ s/'/\\'/g; |
146 |
$subfield_value_y =~ s/'/\\'/g; |
147 |
$subfield_value_w =~ s/'/\\'/g; |
147 |
$subfield_value_z =~ s/'/\\'/g; |
148 |
$subfield_value_x =~ s/'/\\'/g; |
148 |
$template->param( |
149 |
$subfield_value_y =~ s/'/\\'/g; |
149 |
fillinput => 1, |
150 |
$subfield_value_z =~ s/'/\\'/g; |
150 |
index => $query->param('index') . "", |
151 |
$template->param( |
151 |
biblionumber => $biblionumber ? $biblionumber : "", |
152 |
fillinput => 1, |
152 |
subfield_value_9 => "$subfield_value_9", |
153 |
index => $query->param('index') . "", |
153 |
subfield_value_0 => "$subfield_value_0", |
154 |
biblionumber => $biblionumber ? $biblionumber : "", |
154 |
subfield_value_a => "$subfield_value_a", |
155 |
subfield_value_9 => "$subfield_value_9", |
155 |
subfield_value_c => "$subfield_value_c", |
156 |
subfield_value_0 => "$subfield_value_0", |
156 |
subfield_value_d => "$subfield_value_d", |
157 |
subfield_value_a => "$subfield_value_a", |
157 |
subfield_value_e => "$subfield_value_e", |
158 |
subfield_value_c => "$subfield_value_c", |
158 |
subfield_value_h => "$subfield_value_h", |
159 |
subfield_value_d => "$subfield_value_d", |
159 |
subfield_value_i => "$subfield_value_i", |
160 |
subfield_value_e => "$subfield_value_e", |
160 |
subfield_value_p => "$subfield_value_p", |
161 |
subfield_value_h => "$subfield_value_h", |
161 |
subfield_value_t => "$subfield_value_t", |
162 |
subfield_value_i => "$subfield_value_i", |
162 |
subfield_value_u => "$subfield_value_u", |
163 |
subfield_value_p => "$subfield_value_p", |
163 |
subfield_value_v => "$subfield_value_v", |
164 |
subfield_value_t => "$subfield_value_t", |
164 |
subfield_value_w => "$subfield_value_w", |
165 |
subfield_value_u => "$subfield_value_u", |
165 |
subfield_value_x => "$subfield_value_x", |
166 |
subfield_value_v => "$subfield_value_v", |
166 |
subfield_value_y => "$subfield_value_y", |
167 |
subfield_value_w => "$subfield_value_w", |
167 |
subfield_value_z => "$subfield_value_z", |
168 |
subfield_value_x => "$subfield_value_x", |
168 |
); |
169 |
subfield_value_y => "$subfield_value_y", |
|
|
170 |
subfield_value_z => "$subfield_value_z", |
171 |
); |
172 |
############################################################### |
169 |
############################################################### |
173 |
} |
170 |
} elsif ( $op eq "do_search" ) { |
174 |
elsif ( $op eq "do_search" ) { |
171 |
my $search = $query->param('search'); |
175 |
my $search = $query->param('search'); |
172 |
my $itype = $query->param('itype'); |
176 |
my $itype = $query->param('itype'); |
173 |
my $startfrom = $query->param('startfrom'); |
177 |
my $startfrom = $query->param('startfrom'); |
174 |
my $resultsperpage = $query->param('resultsperpage') || 20; |
178 |
my $resultsperpage = $query->param('resultsperpage') || 20; |
175 |
my $orderby; |
179 |
my $orderby; |
176 |
my $QParser; |
180 |
my $QParser; |
177 |
$QParser = C4::Context->queryparser if ( C4::Context->preference('UseQueryParser') ); |
181 |
$QParser = C4::Context->queryparser if (C4::Context->preference('UseQueryParser')); |
178 |
my $op; |
182 |
my $op; |
179 |
|
183 |
if ($QParser) { |
180 |
if ($QParser) { |
184 |
$op = '&&'; |
181 |
$op = '&&'; |
185 |
} else { |
182 |
} else { |
186 |
$op = 'and'; |
183 |
$op = 'and'; |
|
|
184 |
} |
185 |
$search = 'kw:' . $search . " $op mc-itemtype:" . $itype if $itype; |
186 |
my ( $errors, $results, $total_hits ) = SimpleSearch( $search, $startfrom * $resultsperpage, $resultsperpage ); |
187 |
if ( defined $errors ) { |
188 |
$results = []; |
189 |
} |
190 |
my $total = @{$results}; |
191 |
|
192 |
# warn " biblio count : ".$total; |
193 |
|
194 |
( $template, $loggedinuser, $cookie ) = get_template_and_user( |
195 |
{ template_name => "cataloguing/value_builder/marc21_linking_section.tt", |
196 |
query => $query, |
197 |
type => 'intranet', |
198 |
authnotrequired => 0, |
199 |
debug => 1, |
187 |
} |
200 |
} |
188 |
$search = 'kw:' . $search . " $op mc-itemtype:" . $itype if $itype; |
201 |
); |
189 |
my ( $errors, $results, $total_hits ) = |
202 |
|
190 |
SimpleSearch( $search, $startfrom * $resultsperpage, |
203 |
# multi page display gestion |
191 |
$resultsperpage ); |
204 |
my $displaynext = 0; |
192 |
if ( defined $errors ) { |
205 |
my $displayprev = $startfrom; |
193 |
$results = []; |
206 |
|
194 |
} |
207 |
if ( ( $total_hits - ( ( $startfrom + 1 ) * ($resultsperpage) ) ) > 0 ) { |
195 |
my $total = @{$results}; |
208 |
$displaynext = 1; |
196 |
|
209 |
} |
197 |
# warn " biblio count : ".$total; |
210 |
my @arrayresults; |
198 |
|
211 |
my @field_data = ($search); |
199 |
( $template, $loggedinuser, $cookie ) = get_template_and_user( |
212 |
for ( my $i = 0 ; $i < $resultsperpage ; $i++ ) { |
200 |
{ |
213 |
my $record = C4::Search::new_record_from_zebra( 'biblioserver', $results->[$i] ); |
201 |
template_name => |
214 |
my $rechash = TransformMarcToKoha( $dbh, $record ); |
202 |
"cataloguing/value_builder/marc21_linking_section.tt", |
215 |
my $pos; |
203 |
query => $query, |
216 |
my $countitems = $rechash->{itembumber} ? 1 : 0; |
204 |
type => 'intranet', |
217 |
while ( index( $rechash->{itemnumber}, '|', $pos ) > 0 ) { |
205 |
authnotrequired => 0, |
218 |
$countitems += 1; |
206 |
debug => 1, |
219 |
$pos = index( $rechash->{itemnumber}, '|', $pos ) + 1; |
207 |
} |
220 |
} |
208 |
); |
221 |
$rechash->{totitem} = $countitems; |
209 |
|
222 |
my @holdingbranches = split /\|/, $rechash->{holdingbranch}; |
210 |
# multi page display gestion |
223 |
my @itemcallnumbers = split /\|/, $rechash->{itemcallnumber}; |
211 |
my $displaynext = 0; |
224 |
my $CN; |
212 |
my $displayprev = $startfrom; |
225 |
for ( my $i = 0 ; $i < @holdingbranches ; $i++ ) { |
213 |
|
226 |
$CN .= $holdingbranches[$i] . " ( " . $itemcallnumbers[$i] . " ) |"; |
214 |
if ( ( $total_hits - ( ( $startfrom + 1 ) * ($resultsperpage) ) ) > 0 ) |
227 |
} |
215 |
{ |
228 |
$CN =~ s/ \|$//; |
216 |
$displaynext = 1; |
229 |
$rechash->{CN} = $CN; |
217 |
} |
230 |
push @arrayresults, $rechash; |
218 |
my @arrayresults; |
231 |
} |
219 |
my @field_data = ($search); |
232 |
|
220 |
for ( my $i = 0 ; $i < $resultsperpage ; $i++ ) { |
233 |
# for(my $i = 0 ; $i <= $#marclist ; $i++) |
221 |
my $record = C4::Search::new_record_from_zebra( 'biblioserver', $results->[$i] ); |
234 |
# { |
222 |
my $rechash = TransformMarcToKoha( $dbh, $record ); |
235 |
# push @field_data, { term => "marclist", val=>$marclist[$i] }; |
223 |
my $pos; |
236 |
# push @field_data, { term => "and_or", val=>$and_or[$i] }; |
224 |
my $countitems = $rechash->{itembumber} ? 1 : 0; |
237 |
# push @field_data, { term => "excluding", val=>$excluding[$i] }; |
225 |
while ( index( $rechash->{itemnumber}, '|', $pos ) > 0 ) { |
238 |
# push @field_data, { term => "operator", val=>$operator[$i] }; |
226 |
$countitems += 1; |
239 |
# push @field_data, { term => "value", val=>$value[$i] }; |
227 |
$pos = index( $rechash->{itemnumber}, '|', $pos ) + 1; |
240 |
# } |
228 |
} |
241 |
|
229 |
$rechash->{totitem} = $countitems; |
242 |
my @numbers = (); |
230 |
my @holdingbranches = split /\|/, $rechash->{holdingbranch}; |
243 |
|
231 |
my @itemcallnumbers = split /\|/, $rechash->{itemcallnumber}; |
244 |
if ( $total > $resultsperpage ) { |
232 |
my $CN; |
245 |
for ( my $i = 1 ; $i < $total / $resultsperpage + 1 ; $i++ ) { |
233 |
for ( my $i = 0 ; $i < @holdingbranches ; $i++ ) { |
246 |
if ( $i < 16 ) { |
234 |
$CN .= |
247 |
my $highlight = 0; |
235 |
$holdingbranches[$i] . " ( " . $itemcallnumbers[$i] . " ) |"; |
248 |
( $startfrom == ( $i - 1 ) ) && ( $highlight = 1 ); |
236 |
} |
249 |
push @numbers, |
237 |
$CN =~ s/ \|$//; |
250 |
{ number => $i, |
238 |
$rechash->{CN} = $CN; |
251 |
highlight => $highlight, |
239 |
push @arrayresults, $rechash; |
252 |
searchdata => \@field_data, |
240 |
} |
253 |
startfrom => ( $i - 1 ) |
241 |
|
254 |
}; |
242 |
# for(my $i = 0 ; $i <= $#marclist ; $i++) |
255 |
} |
243 |
# { |
256 |
} |
244 |
# push @field_data, { term => "marclist", val=>$marclist[$i] }; |
257 |
} |
245 |
# push @field_data, { term => "and_or", val=>$and_or[$i] }; |
258 |
|
246 |
# push @field_data, { term => "excluding", val=>$excluding[$i] }; |
259 |
my $from = $startfrom * $resultsperpage + 1; |
247 |
# push @field_data, { term => "operator", val=>$operator[$i] }; |
260 |
my $to; |
248 |
# push @field_data, { term => "value", val=>$value[$i] }; |
261 |
|
249 |
# } |
262 |
if ( $total_hits < $from + $resultsperpage ) { |
250 |
|
263 |
$to = $total_hits; |
251 |
my @numbers = (); |
264 |
} else { |
252 |
|
265 |
$to = $from + $resultsperpage; |
253 |
if ( $total > $resultsperpage ) { |
266 |
} |
254 |
for ( my $i = 1 ; $i < $total / $resultsperpage + 1 ; $i++ ) { |
267 |
my $defaultview = 'BiblioDefaultView' . C4::Context->preference('BiblioDefaultView'); |
255 |
if ( $i < 16 ) { |
268 |
|
256 |
my $highlight = 0; |
269 |
# my $link="/cgi-bin/koha/cataloguing/value_builder/unimarc4XX.pl?op=do_search&q=$search_desc&resultsperpage=$resultsperpage&startfrom=$startfrom&search=$search"; |
257 |
( $startfrom == ( $i - 1 ) ) && ( $highlight = 1 ); |
270 |
# foreach my $sort (@sort_by){ |
258 |
push @numbers, |
271 |
# $link.="&sort_by=".$sort."&"; |
259 |
{ |
272 |
# } |
260 |
number => $i, |
273 |
# $template->param( |
261 |
highlight => $highlight, |
274 |
# pagination_bar => pagination_bar( |
262 |
searchdata => \@field_data, |
275 |
# $link, |
263 |
startfrom => ( $i - 1 ) |
276 |
# getnbpages($hits, $results_per_page), |
264 |
}; |
277 |
# $page, |
265 |
} |
278 |
# 'page' |
266 |
} |
279 |
# ), |
267 |
} |
280 |
# ); |
268 |
|
281 |
$template->param( |
269 |
my $from = $startfrom * $resultsperpage + 1; |
282 |
result => \@arrayresults, |
270 |
my $to; |
283 |
index => $query->param('index') . "", |
271 |
|
284 |
startfrom => $startfrom, |
272 |
if ( $total_hits < $from + $resultsperpage ) { |
285 |
displaynext => $displaynext, |
273 |
$to = $total_hits; |
286 |
displayprev => $displayprev, |
274 |
} |
287 |
resultsperpage => $resultsperpage, |
275 |
else { |
288 |
orderby => $orderby, |
276 |
$to = $from + $resultsperpage; |
289 |
startfromnext => $startfrom + 1, |
277 |
} |
290 |
startfromprev => $startfrom - 1, |
278 |
my $defaultview = |
291 |
searchdata => \@field_data, |
279 |
'BiblioDefaultView' . C4::Context->preference('BiblioDefaultView'); |
292 |
total => $total_hits, |
280 |
|
293 |
from => $from, |
281 |
# my $link="/cgi-bin/koha/cataloguing/value_builder/unimarc4XX.pl?op=do_search&q=$search_desc&resultsperpage=$resultsperpage&startfrom=$startfrom&search=$search"; |
294 |
to => $to, |
282 |
# foreach my $sort (@sort_by){ |
295 |
numbers => \@numbers, |
283 |
# $link.="&sort_by=".$sort."&"; |
296 |
search => $search, |
284 |
# } |
297 |
$defaultview => 1, |
285 |
# $template->param( |
298 |
Search => 0 |
286 |
# pagination_bar => pagination_bar( |
299 |
); |
287 |
# $link, |
300 |
|
288 |
# getnbpages($hits, $results_per_page), |
301 |
} else { |
289 |
# $page, |
302 |
( $template, $loggedinuser, $cookie ) = get_template_and_user( |
290 |
# 'page' |
303 |
{ template_name => "cataloguing/value_builder/marc21_linking_section.tt", |
291 |
# ), |
304 |
query => $query, |
292 |
# ); |
305 |
type => "intranet", |
293 |
$template->param( |
306 |
authnotrequired => 0, |
294 |
result => \@arrayresults, |
307 |
} |
295 |
index => $query->param('index') . "", |
308 |
); |
296 |
startfrom => $startfrom, |
309 |
|
297 |
displaynext => $displaynext, |
310 |
my @itemtypes = C4::ItemType->all; |
298 |
displayprev => $displayprev, |
|
|
299 |
resultsperpage => $resultsperpage, |
300 |
orderby => $orderby, |
301 |
startfromnext => $startfrom + 1, |
302 |
startfromprev => $startfrom - 1, |
303 |
searchdata => \@field_data, |
304 |
total => $total_hits, |
305 |
from => $from, |
306 |
to => $to, |
307 |
numbers => \@numbers, |
308 |
search => $search, |
309 |
$defaultview => 1, |
310 |
Search => 0 |
311 |
); |
312 |
|
311 |
|
|
|
312 |
$template->param( |
313 |
itypeloop => \@itemtypes, |
314 |
index => $query->param('index'), |
315 |
Search => 1, |
316 |
); |
313 |
} |
317 |
} |
314 |
else { |
318 |
output_html_with_http_headers $query, $cookie, $template->output; |
315 |
( $template, $loggedinuser, $cookie ) = get_template_and_user( |
|
|
316 |
{ |
317 |
template_name => |
318 |
"cataloguing/value_builder/marc21_linking_section.tt", |
319 |
query => $query, |
320 |
type => "intranet", |
321 |
authnotrequired => 0, |
322 |
} |
323 |
); |
324 |
|
325 |
my @itemtypes = C4::ItemType->all; |
326 |
|
327 |
$template->param( |
328 |
itypeloop => \@itemtypes, |
329 |
index => $query->param('index'), |
330 |
Search => 1, |
331 |
); |
332 |
} |
333 |
output_html_with_http_headers $query, $cookie, $template->output; |
334 |
} |
319 |
} |
335 |
- |
|
|