[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Koha-cvs] Changes to koha/C4/Koha.pm [rel_2_2]
From: |
Henri-Damien LAURENT |
Subject: |
[Koha-cvs] Changes to koha/C4/Koha.pm [rel_2_2] |
Date: |
Mon, 21 Nov 2005 12:10:39 -0500 |
Index: koha/C4/Koha.pm
diff -u koha/C4/Koha.pm:1.22.2.1 koha/C4/Koha.pm:1.22.2.2
--- koha/C4/Koha.pm:1.22.2.1 Wed Sep 28 14:35:57 2005
+++ koha/C4/Koha.pm Mon Nov 21 17:10:37 2005
@@ -60,7 +60,8 @@
&getitemtypes &getitemtypeinfo
&getframeworks &getframeworkinfo
&getauthtypes &getauthtype
- &getallthemes &getalllanguages
+ &getallthemes &getalllanguages
+ &getallbranches
$DEBUG);
use vars qw();
@@ -173,6 +174,8 @@
$branches = &getbranches();
returns informations about branches.
Create a branch selector with the following code
+ Is branchIndependant sensitive
+ When IndependantBranches is set AND user is not superlibrarian, displays
only user's branch
=head3 in PERL SCRIPT
@@ -211,6 +214,64 @@
} else {
$sth = $dbh->prepare("Select * from branches order by branchname");
}
+ $sth->execute;
+ while (my $branch=$sth->fetchrow_hashref) {
+ my $nsth = $dbh->prepare("select categorycode from
branchrelations where branchcode = ?");
+ $nsth->execute($branch->{'branchcode'});
+ while (my ($cat) = $nsth->fetchrow_array) {
+ # FIXME - This seems wrong. It ought to be
+ # $branch->{categorycodes}{$cat} = 1;
+ # otherwise, there's a namespace collision if there's a
+ # category with the same name as a field in the
'branches'
+ # table (i.e., don't create a category called
"issuing").
+ # In addition, the current structure doesn't really
allow
+ # you to list the categories that a branch belongs to:
+ # you'd have to list keys %$branch, and remove those
keys
+ # that aren't fields in the "branches" table.
+ $branch->{$cat} = 1;
+ }
+ $branches{$branch->{'branchcode'}}=$branch;
+ }
+ return (\%branches);
+}
+
+=head2 getallbranches
+
+ $branches = &getallbranches();
+ returns informations about ALL branches.
+ Create a branch selector with the following code
+ IndependantBranches Insensitive...
+
+=head3 in PERL SCRIPT
+
+my $branches = getallbranches;
+my @branchloop;
+foreach my $thisbranch (keys %$branches) {
+ my $selected = 1 if $thisbranch eq $branch;
+ my %row =(value => $thisbranch,
+ selected => $selected,
+ branchname =>
$branches->{$thisbranch}->{'branchname'},
+ );
+ push @branchloop, \%row;
+}
+
+
+=head3 in TEMPLATE
+ <select name="branch">
+ <option value="">Default</option>
+ <!-- TMPL_LOOP name="branchloop" -->
+ <option value="<!-- TMPL_VAR name="value" -->"
<!-- TMPL_IF name="selected" -->selected<!-- /TMPL_IF -->><!-- TMPL_VAR
name="branchname" --></option>
+ <!-- /TMPL_LOOP -->
+ </select>
+
+=cut
+
+sub getallbranches {
+# returns a reference to a hash of references to ALL branches...
+ my %branches;
+ my $dbh = C4::Context->dbh;
+ my $sth;
+ $sth = $dbh->prepare("Select * from branches order by branchname");
$sth->execute;
while (my $branch=$sth->fetchrow_hashref) {
my $nsth = $dbh->prepare("select categorycode from
branchrelations where branchcode = ?");
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Koha-cvs] Changes to koha/C4/Koha.pm [rel_2_2],
Henri-Damien LAURENT <=