3 # Converted to new plugin style (Bug 13437)
5 # Copyright 2015 Koha Development Team
7 # This file is part of Koha.
9 # Koha is free software; you can redistribute it and/or modify it under the
10 # terms of the GNU General Public License as published by the Free Software
11 # Foundation; either version 3 of the License, or (at your option) any later
14 # Koha is distributed in the hope that it will be useful, but WITHOUT ANY
15 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
16 # A PARTICULAR PURPOSE. See the GNU General Public License for more details.
18 # You should have received a copy of the GNU General Public License along
19 # with Koha; if not, write to the Free Software Foundation, Inc.,
20 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
31 my $function_name = $params->{id
};
33 <script type=\"text/javascript\">
36 function Click$function_name(i) {
37 q = document.getElementById('$params->{id}');
38 window.open(\"../cataloguing/plugin_launcher.pl?plugin_name=cn_browser.pl&popup&q=\"+q.value,\"cnbrowser\",\"width=500,height=400,toolbar=false,scrollbars=yes\");
49 my $cgi = $params->{cgi
};
50 my $results_per_page = 30;
51 my $current_page = $cgi->param('page') || 1;
53 my ( $template, $loggedinuser, $cookie ) = get_template_and_user
(
54 { template_name
=> "cataloguing/value_builder/cn_browser.tt",
58 flagsrequired
=> { catalogue
=> 1 },
64 my $dbh = C4
::Context
->dbh;
68 my $real_limit = $results_per_page / 2;
77 if ( $q = $cgi->param('q') ) {
80 if ( $cgi->param('lt') ) {
81 $lt = $cgi->param('lt');
84 if ( $cgi->param('gt') ) {
85 $gt = $cgi->param('gt');
89 #Don't show half the results of show lt or gt
90 $real_limit = $results_per_page if $search ne $q;
91 $cn_sort = GetClassSort
( undef, undef, $search );
92 my $cn_sort_q = GetClassSort
( undef, undef, $q );
95 if ( $search ne $gt ) {
98 #Results before the cn_sort
99 $query = "SELECT b.title, itemcallnumber, biblionumber, barcode, cn_sort, branchname, author
101 JOIN biblio AS b USING (biblionumber)
102 LEFT OUTER JOIN branches ON (branches.branchcode = homebranch)
104 AND itemcallnumber != ''
105 ORDER BY cn_sort DESC, itemnumber
107 $sth = $dbh->prepare($query);
108 $sth->execute($cn_sort);
109 while ( my $data = $sth->fetchrow_hashref ) {
110 if ( $data->{itemcallnumber
} eq $q ) {
111 $data->{background
} = 'red';
113 } elsif ( ( GetClassSort
( undef, undef, $data->{itemcallnumber
} ) lt $cn_sort_q ) && !$green && !$red ) {
115 unshift @cn, { 'background' => 'green' };
122 $rows_lt = $sth->rows;
125 if ( $search ne $lt ) {
128 #Results after the cn_sort
129 $query = "SELECT b.title, itemcallnumber, biblionumber, i.cn_sort, branchname, author
131 JOIN biblio AS b USING (biblionumber)
132 LEFT OUTER JOIN branches ON (branches.branchcode = homebranch)
133 WHERE i.cn_sort >= '$cn_sort'
134 AND itemcallnumber != ''
135 ORDER BY cn_sort, itemnumber
137 $sth = $dbh->prepare($query);
140 while ( my $data = $sth->fetchrow_hashref ) {
141 if ( $data->{itemcallnumber
} eq $q ) {
142 $data->{background
} = 'red';
144 } elsif ( ( GetClassSort
( undef, undef, $data->{itemcallnumber
} ) gt $cn_sort_q ) && !$green && !$red && !$globalGreen ) {
145 push @cn, { 'background' => 'green' };
150 $rows_gt = $sth->rows;
152 if ( !$green && !$red && !$globalGreen ) {
153 push @cn, { 'background' => 'green' };
159 $template->param( 'q' => $q );
160 $template->param( 'cn_loop' => \
@cn ) if $#cn != -1;
161 $template->param( 'popup' => defined( $cgi->param('popup') ) );
163 output_html_with_http_headers
$cgi, $cookie, $template->output;
166 return { builder
=> $builder, launcher
=> $launcher };