Adding XSLTreultsFilename and XSLTDetailFilename
[koha.git] / C4 / Acquisition.pm
index ee7b384..88f0c6d 100644 (file)
@@ -196,7 +196,7 @@ Results are ordered from most to least recent.
 =cut
 
 sub GetPendingOrders {
-    my ($supplierid,$grouped) = @_;
+    my ($supplierid,$grouped, $closed) = @_;
     my $dbh = C4::Context->dbh;
     my $strsth = "
         SELECT    ".($grouped?"count(*),":"")."aqbasket.basketno,
@@ -206,10 +206,15 @@ sub GetPendingOrders {
         LEFT JOIN aqbasket ON aqbasket.basketno=aqorders.basketno
         LEFT JOIN borrowers ON aqbasket.authorisedby=borrowers.borrowernumber
         WHERE booksellerid=?
-            AND (quantity > quantityreceived OR quantityreceived is NULL)
             AND datecancellationprinted IS NULL
-            AND (to_days(now())-to_days(closedate) < 180 OR closedate IS NULL)
     ";
+    if($closed){
+        $strsth .= "
+        AND (quantity > quantityreceived OR quantityreceived is NULL) 
+        AND closedate IS NOT NULL ";
+    }else{
+        $strsth .= "AND (to_days(now())-to_days(closedate) < 180 OR closedate IS NULL)";
+    }
     ## FIXME  Why 180 days ???
     my @query_params = ( $supplierid );
     if ( C4::Context->preference("IndependantBranches") ) {
@@ -674,7 +679,7 @@ C<@results> is an array of references-to-hash with the following keys:
 =cut
 
 sub SearchOrder {
-    my ( $search, $id, $biblionumber, $catview ) = @_;
+    my ( $search, $id, $biblionumber ) = @_;
     my $dbh = C4::Context->dbh;
     my @data = split( ' ', $search );
     my @searchterms;
@@ -685,7 +690,20 @@ sub SearchOrder {
     push( @searchterms, $search, $search, $biblionumber );
     my $query;
   ### FIXME  THIS CAN raise a problem if more THAN ONE biblioitem is linked to one biblio  
-    if ($id) {  
+    if(not $id and $biblionumber and $search){
+        $query = "SELECT *,biblio.title 
+           FROM aqorders 
+           LEFT JOIN biblio ON aqorders.biblionumber=biblio.biblionumber 
+           LEFT JOIN biblioitems ON biblioitems.biblionumber=biblio.biblionumber 
+           LEFT JOIN aqbasket ON aqorders.basketno = aqbasket.basketno
+            WHERE ((datecancellationprinted is NULL)
+            OR (datecancellationprinted = '0000-00-00'))
+            AND aqorders.biblionumber = ?
+            AND aqorders.ordernumber = ? 
+            ";
+            @searchterms = ($biblionumber, $search);
+    }
+    elsif($id) {  
         $query =
           "SELECT *,biblio.title 
            FROM aqorders 
@@ -701,7 +719,6 @@ sub SearchOrder {
                 map { "(biblio.title like ? or biblio.title like ?)" } @data )
           )
           . ") OR biblioitems.isbn=? OR (aqorders.ordernumber=? AND aqorders.biblionumber=?)) ";
-
     }
     else {
         $query =
@@ -720,6 +737,7 @@ sub SearchOrder {
           )
           . ") or biblioitems.isbn=? OR (aqorders.ordernumber=? AND aqorders.biblionumber=?)) ";
     }
+    
     $query .= " GROUP BY aqorders.ordernumber";
     ### $query
     my $sth = $dbh->prepare($query);
@@ -1124,6 +1142,7 @@ sub GetHistory {
         
         if ( defined $title ) {
             $query .= " AND biblio.title LIKE ? ";
+            $title =~ s/\s+/%/g;
             push @query_params, "%$title%";
         }