Bug 8435: DBRev 3.13.00.038
[koha.git] / C4 / Koha.pm
index 6f91b8b..937ac5f 100644 (file)
@@ -41,7 +41,6 @@ BEGIN {
                &subfield_is_koha_internal_p
                &GetPrinters &GetPrinter
                &GetItemTypes &getitemtypeinfo
-               &GetCcodes
                &GetSupportName &GetSupportList
                &get_itemtypeinfos_of
                &getframeworks &getframeworkinfo
@@ -286,27 +285,6 @@ END_SQL
     return get_infos_of( $query, 'itemtype', undef, \@itemtypes );
 }
 
-# this is temporary until we separate collection codes and item types
-sub GetCcodes {
-    my $count = 0;
-    my @results;
-    my $dbh = C4::Context->dbh;
-    my $sth =
-      $dbh->prepare(
-        "SELECT * FROM authorised_values ORDER BY authorised_value");
-    $sth->execute;
-    while ( my $data = $sth->fetchrow_hashref ) {
-        if ( $data->{category} eq "CCODE" ) {
-            $count++;
-            $results[$count] = $data;
-
-            #warn "data: $data";
-        }
-    }
-    $sth->finish;
-    return ( $count, @results );
-}
-
 =head2 getauthtypes
 
   $authtypes = &getauthtypes();
@@ -730,6 +708,11 @@ sub getFacets {
                 tags  => [ qw/ 225a / ],
                 sep   => ', ',
             },
+            {
+                idx  => 'location',
+                label => 'Location',
+                tags        => [ qw/ 995c / ],
+            }
             ];
 
             my $library_facet;
@@ -739,12 +722,6 @@ sub getFacets {
                     label => 'Libraries',
                     tags        => [ qw/ 995b / ],
                 };
-            } else {
-                $library_facet = {
-                    idx  => 'location',
-                    label => 'Location',
-                    tags        => [ qw/ 995c / ],
-                };
             }
             push( @$facets, $library_facet );
     }
@@ -792,6 +769,11 @@ sub getFacets {
                 tags  => [ qw/ 952y 942c / ],
                 sep   => ', ',
             },
+            {
+                idx => 'location',
+                label => 'Location',
+                tags => [ qw / 952c / ],
+            },
             ];
 
             my $library_facet;
@@ -801,12 +783,6 @@ sub getFacets {
                     label => 'Libraries',
                     tags        => [ qw / 952b / ],
                 };
-            } else {
-                $library_facet = {
-                    idx => 'location',
-                    label => 'Location',
-                    tags => [ qw / 952c / ],
-                };
             }
             push( @$facets, $library_facet );
     }
@@ -1076,7 +1052,11 @@ sub GetAuthorisedValues {
     if(@where_strings > 0) {
         $query .= " WHERE " . join(" AND ", @where_strings);
     }
-    $query .= " GROUP BY lib ORDER BY category, lib, lib_opac";
+    $query .= " GROUP BY lib";
+    $query .= ' ORDER BY category, ' . (
+                $opac ? 'COALESCE(lib_opac, lib)'
+                      : 'lib, lib_opac'
+              );
 
     my $sth = $dbh->prepare($query);