Lines 1-16
Link Here
|
1 |
#!/usr/bin/perl |
1 |
use Modern::Perl; |
2 |
|
|
|
3 |
use strict; |
4 |
use warnings; |
5 |
no warnings 'redefine'; |
2 |
no warnings 'redefine'; |
6 |
|
3 |
|
7 |
use CGI; |
4 |
use CGI; |
8 |
use C4::Auth; |
5 |
use C4::Auth; |
9 |
use C4::Output; |
|
|
10 |
use POSIX; |
11 |
use C4::ClassSource; |
6 |
use C4::ClassSource; |
12 |
use URI::Escape; |
|
|
13 |
use Data::Dumper; |
14 |
|
7 |
|
15 |
sub plugin_parameters { |
8 |
sub plugin_parameters { |
16 |
my ($dbh,$record,$tagslib,$i,$tabloop) = @_; |
9 |
my ($dbh,$record,$tagslib,$i,$tabloop) = @_; |
Lines 45-60
function Clic$function_name(i) {
Link Here
|
45 |
return ($function_name,$res); |
38 |
return ($function_name,$res); |
46 |
} |
39 |
} |
47 |
|
40 |
|
48 |
|
|
|
49 |
sub plugin { |
41 |
sub plugin { |
50 |
my ($input) = @_; |
42 |
my ($input) = @_; |
51 |
my $cgi = new CGI; |
43 |
my $cgi = new CGI; |
52 |
my $params = $cgi->Vars; |
44 |
my $params = $cgi->Vars; |
53 |
my $results_per_page = 30; |
45 |
my $results_per_page = 30; |
54 |
my $current_page = $cgi->param('page') || 1; |
46 |
my $current_page = $cgi->param('page') || 1; |
55 |
|
47 |
|
56 |
my ( $template, $loggedinuser, $cookie ) = get_template_and_user({ |
48 |
my ( $template, $loggedinuser, $cookie ) = get_template_and_user({ |
57 |
template_name => "tools/cn_browser.tt", |
49 |
template_name => "cataloguing/value_builder/cn_browser.tt", |
58 |
query => $cgi, |
50 |
query => $cgi, |
59 |
type => "intranet", |
51 |
type => "intranet", |
60 |
authnotrequired => 0, |
52 |
authnotrequired => 0, |
Lines 63-69
sub plugin {
Link Here
|
63 |
|
55 |
|
64 |
my $cn_sort; |
56 |
my $cn_sort; |
65 |
|
57 |
|
66 |
my $dbh = C4::Context->dbh; |
58 |
my $dbh = C4::Context->dbh; |
67 |
my $sth; |
59 |
my $sth; |
68 |
my @cn; |
60 |
my @cn; |
69 |
my $query; |
61 |
my $query; |
Lines 71-76
sub plugin {
Link Here
|
71 |
my $rows_lt = 999; |
63 |
my $rows_lt = 999; |
72 |
my $rows_gt = 999; |
64 |
my $rows_gt = 999; |
73 |
my $search; |
65 |
my $search; |
|
|
66 |
my $globalGreen=0; |
74 |
my $lt = ''; |
67 |
my $lt = ''; |
75 |
my $gt = ''; |
68 |
my $gt = ''; |
76 |
my $q; |
69 |
my $q; |
Lines 95-100
sub plugin {
Link Here
|
95 |
my $red = 0; |
88 |
my $red = 0; |
96 |
if ($search ne $gt) { |
89 |
if ($search ne $gt) { |
97 |
my $green = 0; |
90 |
my $green = 0; |
|
|
91 |
|
98 |
#Results before the cn_sort |
92 |
#Results before the cn_sort |
99 |
$query = "SELECT b.title, itemcallnumber, biblionumber, barcode, cn_sort, branchname, author |
93 |
$query = "SELECT b.title, itemcallnumber, biblionumber, barcode, cn_sort, branchname, author |
100 |
FROM items AS i |
94 |
FROM items AS i |
Lines 111-119
sub plugin {
Link Here
|
111 |
$data->{background} = 'red'; |
105 |
$data->{background} = 'red'; |
112 |
$red = 1; |
106 |
$red = 1; |
113 |
} |
107 |
} |
114 |
elsif (($data->{cn_sort} lt $cn_sort_q) && !$green && !$red) { |
108 |
elsif ((GetClassSort(undef, undef, $data->{itemcallnumber}) lt $cn_sort_q) && !$green && !$red) { |
115 |
if ($#cn != -1) { |
109 |
if ($#cn != -1) { |
116 |
unshift @cn, {'background' => 'green'}; |
110 |
unshift @cn, {'background' => 'green'}; |
|
|
111 |
$globalGreen = 1; |
117 |
} |
112 |
} |
118 |
$green = 1; |
113 |
$green = 1; |
119 |
} |
114 |
} |
Lines 136-154
sub plugin {
Link Here
|
136 |
LIMIT $real_limit"; |
131 |
LIMIT $real_limit"; |
137 |
$sth = $dbh->prepare($query); |
132 |
$sth = $dbh->prepare($query); |
138 |
$sth->execute(); |
133 |
$sth->execute(); |
|
|
134 |
|
139 |
while ( my $data = $sth->fetchrow_hashref ) { |
135 |
while ( my $data = $sth->fetchrow_hashref ) { |
140 |
if ($data->{itemcallnumber} eq $q) { |
136 |
if ($data->{itemcallnumber} eq $q) { |
141 |
$data->{background} = 'red'; |
137 |
$data->{background} = 'red'; |
142 |
$red = 1; |
138 |
$red = 1; |
143 |
} |
139 |
} |
144 |
elsif (($data->{cn_sort} gt $cn_sort_q) && !$green && !$red) { |
140 |
elsif ((GetClassSort(undef, undef, $data->{itemcallnumber}) gt $cn_sort_q) && !$green && !$red && !$globalGreen) { |
145 |
push @cn, {'background' => 'green'}; |
141 |
push @cn, {'background' => 'green'}; |
146 |
$green = 1; |
142 |
$green = 1; |
147 |
} |
143 |
} |
148 |
push @cn, $data; |
144 |
push @cn, $data; |
149 |
} |
145 |
} |
150 |
$rows_gt = $sth->rows; |
146 |
$rows_gt = $sth->rows; |
151 |
if ($rows_gt == 0 && !$green && !$red){ |
147 |
|
|
|
148 |
if (!$green && !$red && !$globalGreen){ |
152 |
push @cn, {'background' => 'green'}; |
149 |
push @cn, {'background' => 'green'}; |
153 |
} |
150 |
} |
154 |
|
151 |
|