Added a param to catalogsearch to allow selection of order (ASC or DESC)
authordoxulting <doxulting>
Thu, 3 Mar 2005 09:32:04 +0000 (09:32 +0000)
committerdoxulting <doxulting>
Thu, 3 Mar 2005 09:32:04 +0000 (09:32 +0000)
C4/SearchMarc.pm

index a42fb0e..a033c66 100644 (file)
@@ -165,7 +165,7 @@ $marcflavour ("MARC21" or "UNIMARC") determines which tags are used for retrievi
 =cut
 
 sub catalogsearch {
-       my ($dbh, $tags, $and_or, $excluding, $operator, $value, $offset,$length,$orderby) = @_;
+       my ($dbh, $tags, $and_or, $excluding, $operator, $value, $offset,$length,$orderby, $desc_or_asc) = @_;
        # build the sql request. She will look like :
        # select m1.bibid
        #               from marc_subfield_table as m1, marc_subfield_table as m2
@@ -188,7 +188,7 @@ sub catalogsearch {
        my @not_value = ();
        my $any_not = 0;
        $orderby = "biblio.title" unless $orderby;
-       
+       $desc_or_asc = "ASC" unless $desc_or_asc;
        #last minute stripping out of ' and ,
 # paul : quoting, it's done a few lines lated.
 #      foreach $_ (@$value) {
@@ -276,11 +276,11 @@ sub catalogsearch {
        $sql_where1 .= "and TO_DAYS( NOW( ) ) - TO_DAYS( biblio.timestamp ) <30" if $orderby =~ "biblio.timestamp";
        my $sth;
        if ($sql_where2) {
-               $sth = $dbh->prepare("select distinct m1.bibid from biblio,biblioitems,marc_biblio,$sql_tables where biblio.biblionumber=marc_biblio.biblionumber and biblio.biblionumber=biblioitems.biblionumber and m1.bibid=marc_biblio.bibid and $sql_where2 and ($sql_where1) order by $orderby");
-               warn "Q2 : select distinct m1.bibid from biblio,biblioitems,marc_biblio,$sql_tables where biblio.biblionumber=marc_biblio.biblionumber and biblio.biblionumber=biblioitems.biblionumber and m1.bibid=marc_biblio.bibid and $sql_where2 and ($sql_where1) order by $orderby term is  @$value";
+               $sth = $dbh->prepare("select distinct m1.bibid from biblio,biblioitems,marc_biblio,$sql_tables where biblio.biblionumber=marc_biblio.biblionumber and biblio.biblionumber=biblioitems.biblionumber and m1.bibid=marc_biblio.bibid and $sql_where2 and ($sql_where1) order by $orderby $desc_or_asc");
+               warn "Q2 : select distinct m1.bibid from biblio,biblioitems,marc_biblio,$sql_tables where biblio.biblionumber=marc_biblio.biblionumber and biblio.biblionumber=biblioitems.biblionumber and m1.bibid=marc_biblio.bibid and $sql_where2 and ($sql_where1) order by $orderby $desc_or_asc term is  @$value";
        } else {
-               $sth = $dbh->prepare("select distinct m1.bibid from biblio,biblioitems,marc_biblio,$sql_tables where biblio.biblionumber=marc_biblio.biblionumber and biblio.biblionumber=biblioitems.biblionumber and m1.bibid=marc_biblio.bibid and $sql_where1 order by $orderby");
-               warn "Q : select distinct m1.bibid from biblio,biblioitems,marc_biblio,$sql_tables where biblio.biblionumber=marc_biblio.biblionumber and biblio.biblionumber=biblioitems.biblionumber and m1.bibid=marc_biblio.bibid and $sql_where1 order by $orderby";
+               $sth = $dbh->prepare("select distinct m1.bibid from biblio,biblioitems,marc_biblio,$sql_tables where biblio.biblionumber=marc_biblio.biblionumber and biblio.biblionumber=biblioitems.biblionumber and m1.bibid=marc_biblio.bibid and $sql_where1 order by $orderby $desc_or_asc");
+               warn "Q : select distinct m1.bibid from biblio,biblioitems,marc_biblio,$sql_tables where biblio.biblionumber=marc_biblio.biblionumber and biblio.biblionumber=biblioitems.biblionumber and m1.bibid=marc_biblio.bibid and $sql_where1 order by $orderby $desc_or_asc";
        }
        $sth->execute();
        my @result = ();