Lines 33-39
BEGIN {
Link Here
|
33 |
&GetBranch |
33 |
&GetBranch |
34 |
&GetBranches |
34 |
&GetBranches |
35 |
&GetBranchesLoop |
35 |
&GetBranchesLoop |
36 |
&GetBranchInfo |
|
|
37 |
&mybranch |
36 |
&mybranch |
38 |
); |
37 |
); |
39 |
@EXPORT_OK = qw( &onlymine &mybranch ); |
38 |
@EXPORT_OK = qw( &onlymine &mybranch ); |
Lines 58-64
The functions in this module deal with branches.
Link Here
|
58 |
$branches = &GetBranches(); |
57 |
$branches = &GetBranches(); |
59 |
|
58 |
|
60 |
Returns informations about ALL branches, IndependentBranches Insensitive. |
59 |
Returns informations about ALL branches, IndependentBranches Insensitive. |
61 |
GetBranchInfo() returns the same information. |
|
|
62 |
|
60 |
|
63 |
Create a branch selector with the following code. |
61 |
Create a branch selector with the following code. |
64 |
|
62 |
|
Lines 185-238
sub GetBranch {
Link Here
|
185 |
return $branch; |
183 |
return $branch; |
186 |
} |
184 |
} |
187 |
|
185 |
|
188 |
=head2 GetBranchInfo |
|
|
189 |
|
190 |
$results = GetBranchInfo($branchcode); |
191 |
|
192 |
returns C<$results>, a reference to an array of hashes containing branches. |
193 |
if $branchcode, just this branch, with associated categories. |
194 |
if ! $branchcode && $categorytype, all branches in the category. |
195 |
|
196 |
=cut |
197 |
|
198 |
sub GetBranchInfo { |
199 |
my ($branchcode,$categorytype) = @_; |
200 |
my $dbh = C4::Context->dbh; |
201 |
my $sth; |
202 |
|
203 |
|
204 |
if ($branchcode) { |
205 |
$sth = |
206 |
$dbh->prepare( |
207 |
"Select * from branches where branchcode = ? order by branchcode"); |
208 |
$sth->execute($branchcode); |
209 |
} |
210 |
else { |
211 |
$sth = $dbh->prepare("Select * from branches order by branchcode"); |
212 |
$sth->execute(); |
213 |
} |
214 |
my @results; |
215 |
while ( my $data = $sth->fetchrow_hashref ) { |
216 |
my @bind = ($data->{'branchcode'}); |
217 |
my $query= "select r.categorycode from branchrelations r"; |
218 |
$query .= ", branchcategories c " if($categorytype); |
219 |
$query .= " where branchcode=? "; |
220 |
if($categorytype) { |
221 |
$query .= " and c.categorytype=? and r.categorycode=c.categorycode"; |
222 |
push @bind, $categorytype; |
223 |
} |
224 |
my $nsth=$dbh->prepare($query); |
225 |
$nsth->execute( @bind ); |
226 |
my @cats = (); |
227 |
while ( my ($cat) = $nsth->fetchrow_array ) { |
228 |
push( @cats, $cat ); |
229 |
} |
230 |
$data->{'categories'} = \@cats; |
231 |
push( @results, $data ); |
232 |
} |
233 |
return \@results; |
234 |
} |
235 |
|
236 |
1; |
186 |
1; |
237 |
__END__ |
187 |
__END__ |
238 |
|
188 |
|