/[koha]/koha/C4/Koha.pm
ViewVC logotype

Diff of /koha/C4/Koha.pm

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.22.2.1 by hdl, Wed Sep 28 14:35:57 2005 UTC revision 1.22.2.2 by hdl, Mon Nov 21 17:10:37 2005 UTC
# Line 60  Koha.pm provides many functions for Koha Line 60  Koha.pm provides many functions for Koha
60                          &getitemtypes &getitemtypeinfo                          &getitemtypes &getitemtypeinfo
61                          &getframeworks &getframeworkinfo                          &getframeworks &getframeworkinfo
62                          &getauthtypes &getauthtype                          &getauthtypes &getauthtype
63                          &getallthemes &getalllanguages                          &getallthemes &getalllanguages
64                            &getallbranches
65                          $DEBUG);                          $DEBUG);
66    
67  use vars qw();  use vars qw();
# Line 173  sub subfield_is_koha_internal_p ($) { Line 174  sub subfield_is_koha_internal_p ($) {
174    $branches = &getbranches();    $branches = &getbranches();
175    returns informations about branches.    returns informations about branches.
176    Create a branch selector with the following code    Create a branch selector with the following code
177      Is branchIndependant sensitive
178       When IndependantBranches is set AND user is not superlibrarian, displays only user's branch
179        
180  =head3 in PERL SCRIPT  =head3 in PERL SCRIPT
181    
# Line 214  sub getbranches { Line 217  sub getbranches {
217          $sth->execute;          $sth->execute;
218          while (my $branch=$sth->fetchrow_hashref) {          while (my $branch=$sth->fetchrow_hashref) {
219                  my $nsth = $dbh->prepare("select categorycode from branchrelations where branchcode = ?");                  my $nsth = $dbh->prepare("select categorycode from branchrelations where branchcode = ?");
220                    $nsth->execute($branch->{'branchcode'});
221                    while (my ($cat) = $nsth->fetchrow_array) {
222                            # FIXME - This seems wrong. It ought to be
223                            # $branch->{categorycodes}{$cat} = 1;
224                            # otherwise, there's a namespace collision if there's a
225                            # category with the same name as a field in the 'branches'
226                            # table (i.e., don't create a category called "issuing").
227                            # In addition, the current structure doesn't really allow
228                            # you to list the categories that a branch belongs to:
229                            # you'd have to list keys %$branch, and remove those keys
230                            # that aren't fields in the "branches" table.
231                            $branch->{$cat} = 1;
232                            }
233                            $branches{$branch->{'branchcode'}}=$branch;
234            }
235            return (\%branches);
236    }
237    
238    =head2 getallbranches
239    
240      $branches = &getallbranches();
241      returns informations about ALL branches.
242      Create a branch selector with the following code
243      IndependantBranches Insensitive...
244      
245    =head3 in PERL SCRIPT
246    
247    my $branches = getallbranches;
248    my @branchloop;
249    foreach my $thisbranch (keys %$branches) {
250            my $selected = 1 if $thisbranch eq $branch;
251            my %row =(value => $thisbranch,
252                                    selected => $selected,
253                                    branchname => $branches->{$thisbranch}->{'branchname'},
254                            );
255            push @branchloop, \%row;
256    }
257    
258    
259    =head3 in TEMPLATE  
260                            <select name="branch">
261                                    <option value="">Default</option>
262                            <!-- TMPL_LOOP name="branchloop" -->
263                                    <option value="<!-- TMPL_VAR name="value" -->" <!-- TMPL_IF name="selected" -->selected<!-- /TMPL_IF -->><!-- TMPL_VAR name="branchname" --></option>
264                            <!-- /TMPL_LOOP -->
265                            </select>
266    
267    =cut
268    
269    sub getallbranches {
270    # returns a reference to a hash of references to ALL branches...
271            my %branches;
272            my $dbh = C4::Context->dbh;
273            my $sth;
274            $sth = $dbh->prepare("Select * from branches order by branchname");
275            $sth->execute;
276            while (my $branch=$sth->fetchrow_hashref) {
277                    my $nsth = $dbh->prepare("select categorycode from branchrelations where branchcode = ?");
278                  $nsth->execute($branch->{'branchcode'});                  $nsth->execute($branch->{'branchcode'});
279                  while (my ($cat) = $nsth->fetchrow_array) {                  while (my ($cat) = $nsth->fetchrow_array) {
280                          # FIXME - This seems wrong. It ought to be                          # FIXME - This seems wrong. It ought to be

Legend:
Removed from v.1.22.2.1  
changed lines
  Added in v.1.22.2.2

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26