Lines 52-58
number or ISBN is valid.
Link Here
|
52 |
@ISA = qw(Exporter); |
52 |
@ISA = qw(Exporter); |
53 |
@EXPORT = qw( |
53 |
@EXPORT = qw( |
54 |
&checkdigit |
54 |
&checkdigit |
55 |
&buildCGIsort |
|
|
56 |
); |
55 |
); |
57 |
|
56 |
|
58 |
=item checkdigit |
57 |
=item checkdigit |
Lines 109-166
sub checkdigit ($;$) {
Link Here
|
109 |
return 0; |
108 |
return 0; |
110 |
} # sub checkdigit |
109 |
} # sub checkdigit |
111 |
|
110 |
|
112 |
=item buildCGISort |
|
|
113 |
|
114 |
$CGIScrollingList = &buildCGISort($name string, $input_name string); |
115 |
|
116 |
Returns the scrolling list with name $input_name, built on authorised Values named $name. |
117 |
Returns NULL if no authorised values found |
118 |
|
119 |
=cut |
120 |
|
121 |
sub buildCGIsort { |
122 |
my ( $name, $input_name, $data ) = @_; |
123 |
my $branch_limit = C4::Context->userenv ? C4::Context->userenv->{"branch"} : ""; |
124 |
|
125 |
my $dbh=C4::Context->dbh; |
126 |
my $query = qq{ |
127 |
SELECT * |
128 |
FROM authorised_values |
129 |
}; |
130 |
$query .= qq{ |
131 |
LEFT JOIN authorised_values_branches ON ( id = av_id ) |
132 |
} if $branch_limit; |
133 |
$query .= qq{ |
134 |
WHERE category = ? |
135 |
}; |
136 |
$query .= qq{ AND ( branchcode = ? OR branchcode IS NULL )} if $branch_limit; |
137 |
$query .= qq{ GROUP BY lib ORDER BY lib}; |
138 |
|
139 |
my $sth=$dbh->prepare($query); |
140 |
$sth->execute( $name, $branch_limit ? $branch_limit : () ); |
141 |
my $CGISort; |
142 |
if ($sth->rows>0){ |
143 |
my @values; |
144 |
my %labels; |
145 |
|
146 |
for (my $i =0;$i<$sth->rows;$i++){ |
147 |
my $results = $sth->fetchrow_hashref; |
148 |
push @values, $results->{authorised_value}; |
149 |
$labels{$results->{authorised_value}}=$results->{lib}; |
150 |
} |
151 |
$CGISort= CGI::scrolling_list( |
152 |
-name => $input_name, |
153 |
-id => $input_name, |
154 |
-values => \@values, |
155 |
-labels => \%labels, |
156 |
-default=> $data, |
157 |
-size => 1, |
158 |
-multiple => 0); |
159 |
} |
160 |
$sth->finish; |
161 |
return $CGISort; |
162 |
} |
163 |
|
164 |
END { } # module clean-up code here (global destructor) |
111 |
END { } # module clean-up code here (global destructor) |
165 |
|
112 |
|
166 |
1; |
113 |
1; |