Acquisition & Suggestion :
authortipaul <tipaul>
Thu, 15 Jul 2004 09:41:03 +0000 (09:41 +0000)
committertipaul <tipaul>
Thu, 15 Jul 2004 09:41:03 +0000 (09:41 +0000)
* acquisition rewritte : create a aqbasket table to deal with "bookseller order header".
* add "close basket" feature : a closed basket can't be modified
* suggestion feature : manage suggestions in acquisition (after suggestion filled in OPAC)

17 files changed:
C4/Acquisition.pm
C4/Suggestions.pm
acqui/addorder.pl
acqui/basket.pl
acqui/newbiblio.pl
acqui/order.pl
acqui/suggestion-select.pl [new file with mode: 0755]
koha-tmpl/intranet-tmpl/default/en/suggestion/acceptorreject.tmpl [new file with mode: 0644]
koha-tmpl/intranet-tmpl/default/en/suggestion/mail_suggestion_ACCEPTED.tmpl [new file with mode: 0644]
koha-tmpl/intranet-tmpl/default/en/suggestion/mail_suggestion_AVAILABLE.tmpl [new file with mode: 0644]
koha-tmpl/intranet-tmpl/default/en/suggestion/mail_suggestion_ORDERED.tmpl [new file with mode: 0644]
koha-tmpl/intranet-tmpl/default/en/suggestion/mail_suggestion_REJECTED.tmpl [new file with mode: 0644]
opac/opac-ISBDdetail.pl
opac/opac-MARCdetail.pl
opac/opac-search.pl
opac/opac-suggestions.pl
suggestion/acceptorreject.pl [new file with mode: 0755]

index d5f06ed..950411a 100644 (file)
@@ -1,12 +1,4 @@
-package C4::Catalogue;
-
-# Continue working on updateItem!!!!!!
-#
-# updateItem is looking not bad.  Need to add addSubfield and deleteSubfield
-# functions
-#
-# Trying to track down $dbh's that aren't disconnected....
-
+package C4::Acquisition;
 
 # Copyright 2000-2002 Katipo Communications
 #
@@ -29,7 +21,7 @@ use strict;
 require Exporter;
 use C4::Context;
 use MARC::Record;
-use C4::Biblio;
+use C4::Biblio;
 
 use vars qw($VERSION @ISA @EXPORT);
 
@@ -38,11 +30,11 @@ $VERSION = 0.01;
 
 =head1 NAME
 
-C4::Catalogue - Koha functions for dealing with orders and acquisitions
+C4::Acquisition - Koha functions for dealing with orders and acquisitions
 
 =head1 SYNOPSIS
 
-  use C4::Catalogue;
+  use C4::Acquisition;
 
 =head1 DESCRIPTION
 
@@ -57,19 +49,19 @@ orders, converting money to different currencies, and so forth.
 
 @ISA = qw(Exporter);
 @EXPORT = qw(
-            &basket &newbasket
+               &getbasket &getbasketcontent &newbasket &closebasket
 
-            &getorders &getallorders &getrecorders
-            &getorder &neworder &delorder
-            &ordersearch
-            &modorder &getsingleorder &invoice &receiveorder
-            &updaterecorder &newordernum
+               &getorders &getallorders &getrecorders
+               &getorder &neworder &delorder
+               &ordersearch
+               &modorder &getsingleorder &invoice &receiveorder
+               &updaterecorder &newordernum
 
-            &bookfunds &bookfundbreakdown &updatecost
-            &curconvert &getcurrencies &updatecurrencies &getcurrency
+               &bookfunds &curconvert &getcurrencies &bookfundbreakdown
+               &updatecurrencies &getcurrency
 
-            &findall &needsmod &branches &updatesup &insertsup
-            &bookseller &breakdown &checkitems
+               &branches &updatesup &insertsup
+               &bookseller &breakdown
 );
 
 #
@@ -79,9 +71,24 @@ orders, converting money to different currencies, and so forth.
 #
 #
 #
-=item basket
+=item getbasket
+
+  $aqbasket = &getbasket($basketnumber);
 
-  ($count, @orders) = &basket($basketnumber, $booksellerID);
+get all basket informations in aqbasket for a given basket
+=cut
+
+sub getbasket {
+       my ($basketno)=@_;
+       my $dbh=C4::Context->dbh;
+       my $sth=$dbh->prepare("select aqbasket.*,borrowers.firstname+' '+borrowers.surname as authorisedbyname from aqbasket left join borrowers on aqbasket.authorisedby=borrowers.borrowernumber where basketno=?");
+       $sth->execute($basketno);
+       return($sth->fetchrow_hashref);
+}
+
+=item getbasketcontent
+
+  ($count, @orders) = &getbasketcontent($basketnumber, $booksellerID);
 
 Looks up the pending (non-cancelled) orders with the given basket
 number. If C<$booksellerID> is non-empty, only orders from that seller
@@ -94,64 +101,65 @@ number of elements in C<@orders>.
 
 =cut
 #'
-sub basket {
-  my ($basketno,$supplier)=@_;
-  my $dbh = C4::Context->dbh;
-  my $query="Select *,biblio.title from aqorders,biblio,biblioitems
-  where basketno='$basketno'
-  and biblio.biblionumber=aqorders.biblionumber and biblioitems.biblioitemnumber
-  =aqorders.biblioitemnumber
-  and (datecancellationprinted is NULL or datecancellationprinted =
-  '0000-00-00')";
-  if ($supplier ne ''){
-    $query.=" and aqorders.booksellerid='$supplier'";
-  }
-  $query.=" order by biblioitems.publishercode";
-  my $sth=$dbh->prepare($query);
-  $sth->execute;
-  my @results;
-#  print $query;
-  my $i=0;
-  while (my $data=$sth->fetchrow_hashref){
-    $results[$i]=$data;
-    $i++;
-  }
-  $sth->finish;
-  return($i,@results);
+sub getbasketcontent {
+       my ($basketno,$supplier)=@_;
+       my $dbh = C4::Context->dbh;
+       my $query="Select *,biblio.title from aqorders,biblio,biblioitems
+       where basketno='$basketno'
+       and biblio.biblionumber=aqorders.biblionumber and biblioitems.biblioitemnumber
+       =aqorders.biblioitemnumber
+       and (datecancellationprinted is NULL or datecancellationprinted =
+       '0000-00-00')";
+       if ($supplier ne ''){
+               $query.=" and aqorders.booksellerid='$supplier'";
+       }
+       $query.=" order by biblioitems.publishercode";
+       my $sth=$dbh->prepare($query);
+       $sth->execute;
+       my @results;
+       #  print $query;
+       my $i=0;
+       while (my $data=$sth->fetchrow_hashref){
+               $results[$i]=$data;
+               $i++;
+       }
+       $sth->finish;
+       return($i,@results);
 }
 
 =item newbasket
 
   $basket = &newbasket();
 
-Finds the next unused basket number in the aqorders table of the Koha
-database, and returns it.
-
+Create a new basket in aqbasket table
 =cut
-#'
-# FIXME - There's a race condition here:
-#      A calls &newbasket
-#      B calls &newbasket (gets the same number as A)
-#      A updates the basket
-#      B updates the basket, and clobbers A's result.
-# A better approach might be to create a dummy order (with, say,
-# requisitionedby == "Dummy-$$" or notes == "dummy <time> <pid>"), and
-# see which basket number it gets. Then have a cron job periodically
-# remove out-of-date dummy orders.
+
 sub newbasket {
-  my $dbh = C4::Context->dbh;
-  my $sth=$dbh->prepare("Select max(basketno) from aqorders");
-  $sth->execute;
-  my $data=$sth->fetchrow_arrayref;
-  my $basket=$$data[0];
-  $basket++;
-  $sth->finish;
-  return($basket);
+       my ($booksellerid,$authorisedby) = @_;
+       my $dbh = C4::Context->dbh;
+       my $sth=$dbh->do("insert into aqbasket (creationdate,booksellerid,authorisedby) values(now(),'$booksellerid','$authorisedby')");
+       #find & return basketno MYSQL dependant, but $dbh->last_insert_id always returns null :-(
+       my $basket = $dbh->{'mysql_insertid'};
+       return($basket);
+}
+
+=item closebasket
+
+  &newbasket($basketno);
+
+close a basket (becomes unmodifiable,except for recieves
+=cut
+
+sub closebasket {
+       my ($basketno) = @_;
+       my $dbh = C4::Context->dbh;
+       my $sth=$dbh->prepare("update aqbasket set closedate=now() where basketno=?");
+       $sth->execute($basketno);
 }
 
 =item neworder
 
-  &neworder($biblionumber, $title, $ordnum, $basket, $quantity, $listprice,
+  &neworder($basket, $biblionumber, $title, $quantity, $listprice,
        $booksellerid, $who, $notes, $bookfund, $biblioitemnumber, $rrp,
        $ecost, $gst, $budget, $unitprice, $subscription,
        $booksellerinvoicenumber);
@@ -173,37 +181,36 @@ C<$subscription> may be either "yes", or anything else for "no".
 =cut
 #'
 sub neworder {
-  my ($bibnum,$title,$ordnum,$basket,$quantity,$listprice,$supplier,$who,$notes,$bookfund,$bibitemnum,$rrp,$ecost,$gst,$budget,$cost,$sub,$invoice,$sort1,$sort2)=@_;
-  if ($budget eq 'now'){
-    $budget="now()";
-  } else {
-    $budget="'2001-07-01'";
-  }
-  if ($sub eq 'yes'){
-    $sub=1;
-  } else {
-    $sub=0;
-  }
-  my $dbh = C4::Context->dbh;
-  my $sth=$dbh->prepare("insert into aqorders (biblionumber,title,basketno,
-  quantity,listprice,booksellerid,entrydate,requisitionedby,authorisedby,notes,
-  biblioitemnumber,rrp,ecost,gst,unitprice,subscription,booksellerinvoicenumber,sort1,sort2)
-  values (?,?,?,?,?,?,now(),?,?,?,?,?,?,?,?,?,?,?,?)");
-  $sth->execute($bibnum,$title,$basket,$quantity,$listprice,$supplier,
-  $who,$who,$notes,$bibitemnum,$rrp,$ecost,$gst,$cost,
-  $sub,$invoice,$sort1,$sort2);
-  $sth->finish;
-  $sth=$dbh->prepare("select * from aqorders where
-  biblionumber=? and basketno=? and ordernumber >=?");
-  $sth->execute($bibnum,$basket,$ordnum);
-  my $data=$sth->fetchrow_hashref;
-  $sth->finish;
-  $ordnum=$data->{'ordernumber'};
-  $sth=$dbh->prepare("insert into aqorderbreakdown (ordernumber,bookfundid) values
-  (?,?)");
-#  print $query;
-  $sth->execute($ordnum,$bookfund);
-  $sth->finish;
+       my ($basketno,$bibnum,$title,$quantity,$listprice,$booksellerid,$authorisedby,$notes,$bookfund,$bibitemnum,$rrp,$ecost,$gst,$budget,$cost,$sub,$invoice,$sort1,$sort2)=@_;
+       if ($budget eq 'now'){
+               $budget="now()";
+       } else {
+               $budget="'2001-07-01'";
+       }
+       if ($sub eq 'yes'){
+               $sub=1;
+       } else {
+               $sub=0;
+       }
+       # if $basket empty, it's also a new basket, create it
+       unless ($basketno) {
+               $basketno=newbasket($booksellerid,$authorisedby);
+       }
+       my $dbh = C4::Context->dbh;
+       my $sth=$dbh->prepare("insert into aqorders 
+                                                               (biblionumber,title,basketno,quantity,listprice,notes,
+                                                               biblioitemnumber,rrp,ecost,gst,unitprice,subscription,sort1,sort2)
+                                                               values (?,?,?,?,?,?,?,?,?,?,?,?,?,?)");
+       $sth->execute($bibnum,$title,$basketno,$quantity,$listprice,$notes,
+                                       $bibitemnum,$rrp,$ecost,$gst,$cost,$sub,$sort1,$sort2);
+       $sth->finish;
+       #get ordnum MYSQL dependant, but $dbh->last_insert_id returns null
+       my $ordnum = $dbh->{'mysql_insertid'};
+       $sth=$dbh->prepare("insert into aqorderbreakdown (ordernumber,bookfundid) values
+       (?,?)");
+       $sth->execute($ordnum,$bookfund);
+       $sth->finish;
+       return $basketno;
 }
 
 =item delorder
@@ -256,11 +263,10 @@ sub modorder {
   my $sth=$dbh->prepare("update aqorders set title=?,
   quantity=?,listprice=?,basketno=?,
   rrp=?,ecost=?,unitprice=?,
-  booksellerinvoicenumber=?,
   sort1=?, sort2=?
   where
   ordernumber=? and biblionumber=?");
-  $sth->execute($title,$quantity,$listprice,$basketno,$rrp,$ecost,$cost,$invoice,$sort1,$sort2,$ordnum,$bibnum);
+  $sth->execute($title,$quantity,$listprice,$basketno,$rrp,$ecost,$cost,$sort1,$sort2,$ordnum,$bibnum);
   $sth->finish;
   $sth=$dbh->prepare("update aqorderbreakdown set bookfundid=? where
   ordernumber=?");
@@ -392,20 +398,19 @@ Results are ordered from most to least recent.
 =cut
 #'
 sub getorders {
-  my ($supplierid)=@_;
-  my $dbh = C4::Context->dbh;
-  my $sth=$dbh->prepare("Select count(*),authorisedby,entrydate,basketno from aqorders where
-  booksellerid=? and (quantity > quantityreceived or
-  quantityreceived is NULL)
-  and (datecancellationprinted is NULL or datecancellationprinted = '0000-00-00')
-   group by basketno order by entrydate desc");
-  $sth->execute($supplierid);
-  my @results = ();
-  while (my $data=$sth->fetchrow_hashref){
-    push(@results,$data);
-  }
-  $sth->finish;
-  return (scalar(@results),\@results);
+       my ($supplierid)=@_;
+       my $dbh = C4::Context->dbh;
+       my $sth=$dbh->prepare("Select count(*),authorisedby,creationdate,aqbasket.basketno,closedate from aqorders left join aqbasket on
+       aqbasket.basketno=aqorders.basketno where booksellerid=? and (quantity > quantityreceived or
+       quantityreceived is NULL)
+       group by basketno order by aqbasket.basketno");
+       $sth->execute($supplierid);
+       my @results = ();
+       while (my $data=$sth->fetchrow_hashref){
+               push(@results,$data);
+       }
+       $sth->finish;
+       return (scalar(@results),\@results);
 }
 
 =item getorder
@@ -420,9 +425,7 @@ fields from the biblio, biblioitems, aqorders, and aqorderbreakdown
 tables of the Koha database.
 
 =cut
-#'
-# FIXME - This is effectively identical to &C4::Biblio::getorder.
-# Pick one and stick with it.
+
 sub getorder{
   my ($bi,$bib)=@_;
   my $dbh = C4::Context->dbh;
@@ -447,10 +450,7 @@ C<$order> are fields from the biblio, biblioitems, aqorders, and
 aqorderbreakdown tables of the Koha database.
 
 =cut
-#'
-# FIXME - This is effectively identical to
-# &C4::Biblio::getsingleorder.
-# Pick one and stick with it.
+
 sub getsingleorder {
   my ($ordnum)=@_;
   my $dbh = C4::Context->dbh;
@@ -659,8 +659,13 @@ sub bookfunds {
   return(scalar(@results),@results);
 }
 
-# FIXME - POD. I can't figure out what this function is doing. Then
-# again, I don't think it's being used (anymore).
+=item bookfundbreakdown
+
+       returns the total comtd & spent for a given bookfund
+       used in acqui-home.pl
+=cut
+#'
+
 sub bookfundbreakdown {
   my ($id)=@_;
   my $dbh = C4::Context->dbh;
@@ -685,6 +690,8 @@ sub bookfundbreakdown {
   return($spent,$comtd);
 }
 
+
+
 =item curconvert
 
   $foreignprice = &curconvert($currency, $localprice);
@@ -750,15 +757,6 @@ sub updatecurrencies {
   $sth->finish;
 }
 
-# FIXME - This is never used
-sub updatecost{
-  my($price,$rrp,$itemnum)=@_;
-  my $dbh = C4::Context->dbh;
-  my $sth=$dbh->prepare("update items set price=?,replacementprice=? where itemnumber=?");
-  $sth->execute($price,$rrp,$itemnum);
-  $sth->finish;
-}
-
 #
 #
 # OTHERS
@@ -842,39 +840,6 @@ sub branches {
     return(scalar(@results), @results);
 } # sub branches
 
-# FIXME - Never used
-sub findall {
-  my ($biblionumber)=@_;
-  my $dbh = C4::Context->dbh;
-  my $sth=$dbh->prepare("Select * from biblioitems,items,itemtypes where
-  biblioitems.biblionumber=?
-  and biblioitems.biblioitemnumber=items.biblioitemnumber and
-  itemtypes.itemtype=biblioitems.itemtype
-  order by items.biblioitemnumber");
-  $sth->execute($biblionumber);
-  my @results;
-  while (my $data=$sth->fetchrow_hashref){
-    push(@results,$data);
-  }
-  $sth->finish;
-  return(@results);
-}
-
-# FIXME - Never used
-sub needsmod{
-  my ($bibitemnum,$itemtype)=@_;
-  my $dbh = C4::Context->dbh;
-  my $sth=$dbh->prepare("Select * from biblioitems where biblioitemnumber=?
-  and itemtype=?");
-  $sth->execute($bibitemnum,$itemtype);
-  my $result=0;
-  if (my $data=$sth->fetchrow_hashref){
-    $result=1;
-  }
-  $sth->finish;
-  return($result);
-}
-
 =item updatesup
 
   &updatesup($bookseller);
@@ -911,7 +876,6 @@ sub updatesup {
    $data->{'invoiceincgst'},$data->{'specialty'},$data->{'discount'},
    $data->{'invoicedisc'},$data->{'nocalc'},$data->{'id'});
    $sth->finish;
-#   print $query;
 }
 
 =item insertsup
index ada7f62..9b24811 100644 (file)
@@ -23,6 +23,8 @@ use strict;
 require Exporter;
 use DBI;
 use C4::Context;
+use C4::Output;
+# use C4::Interface::CGI::Output;
 use vars qw($VERSION @ISA @EXPORT);
 
 # set the version for version checking
@@ -57,7 +59,10 @@ Suggestions done by other can be seen when not "AVAILABLE"
 @ISA = qw(Exporter);
 @EXPORT = qw(  &newsuggestion
                                &searchsuggestion
+                               &getsuggestion
                                &delsuggestion
+                               &countsuggestion
+                               &changestatus
                        );
 
 =item SearchSuggestion
@@ -81,9 +86,10 @@ sub searchsuggestion  {
        my $query="Select suggestions.*,
                                                U1.surname as surnamesuggestedby,U1.firstname as firstnamesuggestedby,
                                                U2.surname as surnamemanagedby,U2.firstname as firstnamemanagedby 
-                                               from suggestions,borrowers as U1 
+                                               from suggestions
+                                               left join borrowers as U1 on suggestedby=U1.borrowernumber
                                                left join borrowers as U2  on managedby=U2.borrowernumber
-                                               where suggestedby=U1.borrowernumber";
+                                               where 1=1";
        my @sql_params;
        if ($author) {
                push @sql_params,"%".$author."%";
@@ -125,23 +131,77 @@ sub searchsuggestion  {
 }
 
 sub newsuggestion {
-       my ($borrowernumber,$title,$author,$publishercode,$note) = @_;
+       my ($borrowernumber,$title,$author,$publishercode,$note,$copyrightdate,$volumedesc,$publicationyear,$place,$isbn) = @_;
        my $dbh = C4::Context->dbh;
-       my $sth = $dbh->prepare("insert into suggestions (suggestedby,title,author,publishercode,note) values (?,?,?,?,?)");
-       $sth->execute($borrowernumber,$title,$author,$publishercode,$note);
+       my $sth = $dbh->prepare("insert into suggestions (status,suggestedby,title,author,publishercode,note,copyrightdate,volumedesc,publicationyear,place,isbn) values ('ASKED',?,?,?,?,?,?,?,?,?,?)");
+       $sth->execute($borrowernumber,$title,$author,$publishercode,$note,$copyrightdate,$volumedesc,$publicationyear,$place,$isbn);
+}
+
+sub getsuggestion {
+       my ($suggestionid) = @_;
+       my $dbh = C4::Context->dbh;
+       my $sth = $dbh->prepare("select * from suggestions where suggestionid=?");
+       $sth->execute($suggestionid);
+       return($sth->fetchrow_hashref);
 }
 
 sub delsuggestion {
-       my ($borrowernumber,$suggestionnumber) = @_;
+       my ($borrowernumber,$suggestionid) = @_;
        my $dbh = C4::Context->dbh;
        # check that the suggestion comes from the suggestor
-       my $sth = $dbh->prepare("select suggestedby from suggestions where suggestionnumber=?");
-       $sth->execute($suggestionnumber);
+       my $sth = $dbh->prepare("select suggestedby from suggestions where suggestionid=?");
+       $sth->execute($suggestionid);
        my ($suggestedby) = $sth->fetchrow;
        if ($suggestedby eq $borrowernumber) {
-               $sth = $dbh->prepare("delete from suggestions where suggestionnumber=?");
-               $sth->execute($suggestionnumber);
+               $sth = $dbh->prepare("delete from suggestions where suggestionid=?");
+               $sth->execute($suggestionid);
+       }
+}
+
+sub countsuggestion {
+       my ($status) = @_;
+       my $dbh = C4::Context->dbh;
+       my $sth = $dbh->prepare("select count(*) from suggestions where status=?");
+       $sth->execute($status);
+       my ($result) = $sth->fetchrow;
+       return $result;
+}
+
+sub changestatus {
+       my ($suggestionid,$status,$managedby) = @_;
+       my $dbh = C4::Context->dbh;
+       my $sth;
+       if ($managedby>0) {
+               $sth = $dbh->prepare("update suggestions set status=?,managedby=? where suggestionid=?");
+               $sth->execute($status,$managedby,$suggestionid);
+       } else {
+               $sth = $dbh->prepare("update suggestions set status=? where suggestionid=?");
+               $sth->execute($status,$suggestionid);
+
        }
+       # check mail sending.
+       $sth = $dbh->prepare("select suggestions.*,
+                                                       boby.surname as bysurname, boby.firstname as byfirstname, boby.emailaddress as byemail,
+                                                       lib.surname as libsurname,lib.firstname as libfirstname,lib.emailaddress as libemail
+                                               from suggestions left join borrowers as boby on boby.borrowernumber=suggestedby left join borrowers as lib on lib.borrowernumber=managedby where suggestionid=?");
+       $sth->execute($suggestionid);
+       my $emailinfo = $sth->fetchrow_hashref;
+       my $template = gettemplate("suggestion/mail_suggestion_$status.tmpl","intranet");
+#                               query =>'',
+#                           authnotrequired => 1,
+#                       });
+       $template->param(byemail => $emailinfo->{byemail},
+                                       libemail => $emailinfo->{libemail},
+                                       status => $emailinfo->{status},
+                                       title => $emailinfo->{title},
+                                       author =>$emailinfo->{author},
+                                       libsurname => $emailinfo->{libsurname},
+                                       libfirstname => $emailinfo->{libfirstname},
+                                       byfirstname => $emailinfo->{byfirstname},
+                                       bysurname => $emailinfo->{bysurname},
+                                       );
+       warn "mailing => ".$template->output;
+#      warn "sending email to $emailinfo->{byemail} from $emailinfo->{libemail} to notice new status $emailinfo->{status} for $emailinfo->{title} / $emailinfo->{author}";
 }
 
 =back
index cbc16b5..e7a9401 100755 (executable)
@@ -26,6 +26,7 @@ use CGI;
 use C4::Auth;
 use C4::Output;
 use C4::Acquisition;
+use C4::Suggestions;
 use C4::Biblio;
 use C4::Output;
 use C4::Interface::CGI::Output;
@@ -45,37 +46,43 @@ my ($template, $loggedinuser, $cookie)
                             debug => 1,
                             });
 
-my $existing=$input->param('existing');
+# get CGI parameters
+my $ordnum=$input->param('ordnum');
+my $basketno=$input->param('basketno');
+my $booksellerid = $input->param('booksellerid');
+my $existing=$input->param('existing'); # existing biblio, (not basket or order)
 my $title=$input->param('title');
 my $author=$input->param('author');
 my $copyrightdate=$input->param('copyrightdate');
 my $isbn=$input->param('ISBN');
 my $itemtype=$input->param('format');
-my $ordnum=$input->param('ordnum');
-my $basketno=$input->param('basket');
 my $quantity=$input->param('quantity');
 my $listprice=$input->param('list_price');
-my $series=$input->param('Series');
 if ($listprice eq ''){
-  $listprice=0;
+       $listprice=0;
 }
-my $supplier=$input->param('supplier');
+my $series=$input->param('Series');
+# my $supplier=$input->param('supplier');
 my $notes=$input->param('notes');
 my $bookfund=$input->param('bookfund');
 my $sort1=$input->param('sort1');
 my $sort2=$input->param('sort2');
-my $who=$loggedinuser;
-my $bibnum;
-my $bibitemnum;
 my $rrp=$input->param('rrp');
 my $ecost=$input->param('ecost');
 my $gst=$input->param('GST');
-my $orderexists=$input->param('orderexists');
 my $budget=$input->param('budget');
 my $cost=$input->param('cost');
 my $sub=$input->param('sub');
 my $invoice=$input->param('invoice');
 my $publishercode = $input->param('publishercode');
+my $suggestionid= $input->param('suggestionid');
+
+# create, modify or delete biblio
+# create if $quantity>=0 and $existing='no'
+# modify if $quantity>=0 and $existing='yes'
+# delete if $quantity has been se to 0 by the librarian
+my $bibnum;
+my $bibitemnum;
 if ($quantity ne '0'){
        #check to see if biblio exists
        if ($existing eq 'no'){
@@ -93,22 +100,18 @@ if ($quantity ne '0'){
                        if ($title) {
                                newsubtitle($bibnum,$title);
                        }
+               # change suggestion status if applicable
+               if ($suggestionid) {
+                       changestatus($suggestionid,'ORDERED');
+               }
        } else {
                $bibnum=$input->param('biblio');
                $bibitemnum=$input->param('bibitemnum');
                my $oldtype=$input->param('oldtype');
-               if ($bibitemnum eq '' || $itemtype ne $oldtype){
-                       $bibitemnum= &newbiblioitem({ biblionumber => $bibnum,
-                                                                       itemtype => $itemtype?$itemtype:"",
-                                                                       isbn => $isbn?$isbn:"" ,
-                                                                       publishercode => $publishercode?$publishercode:"",
-                                                                       });
-               } else {
-                       &modbibitem({biblioitemnumber => $bibitemnum,
-                                                       isbn            => $isbn,
-                                                       publishercode   => $publishercode,
-                       });
-               }
+               &modbibitem({biblioitemnumber => $bibitemnum,
+                                               isbn            => $isbn,
+                                               publishercode   => $publishercode,
+               });
                &modbiblio({
                        biblionumber  => $bibnum,
                        title         => $title?$title:"",
@@ -117,14 +120,13 @@ if ($quantity ne '0'){
                        series        => $series?$series:"" },
                        );
        }
-       if ($orderexists ne '') {
-               modorder($title,$ordnum,$quantity,$listprice,$bibnum,$basketno,$supplier,$who,$notes,$bookfund,$bibitemnum,$rrp,$ecost,$gst,$budget,$cost,$sub,$invoice,$sort1,$sort2);
+       if ($ordnum) {
+               modorder($title,$ordnum,$quantity,$listprice,$bibnum,$basketno,$booksellerid,$loggedinuser,$notes,$bookfund,$bibitemnum,$rrp,$ecost,$gst,$budget,$cost,$sub,$invoice,$sort1,$sort2);
        }else {
-               neworder($bibnum,$title,$ordnum,$basketno,$quantity,$listprice,$supplier,$who,$notes,$bookfund,$bibitemnum,$rrp,$ecost,$gst,$budget,$cost,$sub,$invoice,$sort1,$sort2);
+               $basketno=neworder($basketno,$bibnum,$title,$quantity,$listprice,$booksellerid,$loggedinuser,$notes,$bookfund,$bibitemnum,$rrp,$ecost,$gst,$budget,$cost,$sub,$invoice,$sort1,$sort2);
        }
 } else {
        $bibnum=$input->param('biblio');
        delorder($bibnum,$ordnum);
 }
-
 print $input->redirect("basket.pl?basket=$basketno");
index 0e896d5..9d41fa8 100755 (executable)
 # Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
 # Suite 330, Boston, MA  02111-1307 USA
 
+use strict;
 use C4::Auth;
-use C4::Catalogue;
-use C4::Biblio;
+use C4::Koha;
+use C4::Biblio;
 use C4::Output;
 use CGI;
 use C4::Interface::CGI::Output;
 use C4::Database;
 use HTML::Template;
+use C4::Acquisition;
 use C4::Date;
-use strict;
 
 my $query =new CGI;
-my $basket=$query ->param('basket');
+my $basketno = $query ->param('basket');
+my $supplierid = $query->param('id');
 my ($template, $loggedinuser, $cookie)
     = get_template_and_user({template_name => "acqui/basket.tmpl",
                             query => $query,
@@ -45,15 +47,14 @@ my ($template, $loggedinuser, $cookie)
                             debug => 1,
                             });
 my ($count,@results);
-if ($basket eq ''){
-       $basket=newbasket();
-       $results[0]->{'booksellerid'}=$query->param('id');
-       $results[0]->{'authorisedby'} = $loggedinuser;
-} else {
-       ($count,@results)=basket($basket);
-}
 
-my ($count2,@booksellers)=bookseller($results[0]->{'booksellerid'});
+my ($count2,@booksellers)=bookseller($supplierid);
+
+my $basket = getbasket($basketno);
+# if new basket, pre-fill infos
+$basket->{creationdate} = "" unless ($basket->{creationdate});
+$basket->{authorisedby} = $loggedinuser unless ($basket->{authorisedby});
+($count,@results)=getbasketcontent($basketno);
 
 my $line_total; # total of each line
 my $sub_total; # total of line totals
@@ -80,7 +81,7 @@ for (my $i=0;$i<$count;$i++){
        $line{publishercode} = $results[$i]->{'publishercode'};
        $line{isbn} = $results[$i]->{'isbn'};
        $line{booksellerid} = $results[$i]->{'booksellerid'};
-       $line{basket}=$basket;
+       $line{basketno}=$basketno;
        $line{title} = $results[$i]->{'title'};
        $line{author} = $results[$i]->{'author'};
        $line{i} = $i;
@@ -96,11 +97,13 @@ my $prefgist =C4::Context->preference("gist");
 $gist=sprintf("%.2f",$sub_total*$prefgist);
 $grand_total=$sub_total+$gist;
 
-$template->param(basket => $basket,
-                               authorisedby => $results[0]->{'authorisedby'},
-                               entrydate => format_date($results[0]->{'entrydate'}),
-                               id=> $results[0]->{'booksellerid'},
+$template->param(basketno => $basketno,
+                               creationdate => $basket->{creationdate},
+                               authorisedby => $basket->{authorisedby},
+                               authorisedbyname => $basket->{authorisedbyname},
+                               booksellerid=> $booksellers[0]->{'id'},
                                name => $booksellers[0]->{'name'},
+                               entrydate => format_date($results[0]->{'entrydate'}),
                                books_loop => \@books_loop,
                                count =>$count,
                                sub_total => $sub_total,
index 3f85931..757c451 100755 (executable)
 use strict;
 use CGI;
 use C4::Context;
+use C4::Database;
+use C4::Auth;
 use C4::Acquisition;
+use C4::Suggestions;
 use C4::Search;
-use C4::Auth;
 use C4::Output;
 use C4::Interface::CGI::Output;
-use C4::Database;
 use HTML::Template;
 
 my $input=new CGI;
-my $id=$input->param('id');
+my $booksellerid=$input->param('booksellerid');
 my $title=$input->param('title');
 my $author=$input->param('author');
 my $copyright=$input->param('copyright');
-my ($count,@booksellers)=bookseller($id);
+my ($count,@booksellers)=bookseller($booksellerid);
 my $ordnum=$input->param('ordnum');
 my $biblio=$input->param('biblio');
-my $basket=$input->param('basket');
+my $basketno=$input->param('basketno');
+my $suggestionid = $input->param('suggestionid');
 my $data;
 my $new;
 my $dbh = C4::Context->dbh;
-if ($ordnum eq ''){
+if ($ordnum eq ''){ # create order
        $new='yes';
-       $ordnum=newordernum;
+#      $ordnum=newordernum;
        if ($biblio) {
                        $data=bibdata($biblio);
        }
+       if ($suggestionid) { # get suggestion fields if applicable.
+               $data = getsuggestion($suggestionid);
+       }
        if ($data->{'title'} eq ''){
                $data->{'title'}=$title;
                $data->{'author'}=$author;
                $data->{'copyrightdate'}=$copyright;
        }
-}else {
+}else { #modify order
        $data=getsingleorder($ordnum);
        $biblio=$data->{'biblionumber'};
 }
@@ -68,7 +73,8 @@ my ($template, $loggedinuser, $cookie)
                             debug => 1,
                             });
 
-#my ($count2,$currencies)=getcurrencies;
+
+# get currencies (for change rates calcs if needed
 my ($count,$rates)=getcurrencies();
 my @loop_currency = ();
 for (my $i=0;$i<$count;$i++){
@@ -78,17 +84,15 @@ for (my $i=0;$i<$count;$i++){
        push @loop_currency, \%line;
 }
 
+# build itemtype list
 my $sth=$dbh->prepare("Select itemtype,description from itemtypes order by description");
 $sth->execute;
 my  @itemtype;
 my %itemtypes;
-push @itemtype, "";
-$itemtypes{''} = "Please choose";
 while (my ($value,$lib) = $sth->fetchrow_array) {
        push @itemtype, $value;
        $itemtypes{$value}=$lib;
 }
-
 my $CGIitemtype=CGI::scrolling_list( -name     => 'format',
                        -values   => \@itemtype,
                        -default  => $data->{'itemtype'},
@@ -97,6 +101,7 @@ my $CGIitemtype=CGI::scrolling_list( -name     => 'format',
                        -multiple => 0 );
 $sth->finish;
 
+# build branches list
 my @branches;
 my @select_branch;
 my %select_branches;
@@ -112,18 +117,7 @@ my $CGIbranch=CGI::scrolling_list( -name     => 'branch',
                        -size     => 1,
                        -multiple => 0 );
 
-my $auto_barcode = C4::Context->boolean_preference("autoBarcode") || 0;
-       # See whether barcodes should be automatically allocated.
-       # Defaults to 0, meaning "no".
-my $barcode;
-if ($auto_barcode eq '1') {
-       $sth=$dbh->prepare("Select max(barcode) from items");
-       $sth->execute;
-       my $data=$sth->fetchrow_hashref;
-       $barcode = $data->{'barcode'}+1;
-       $sth->finish;
-}
-
+# build bookfund list
 my @bookfund;
 my @select_bookfund;
 my %select_bookfunds;
@@ -139,11 +133,13 @@ my $CGIbookfund=CGI::scrolling_list( -name     => 'bookfund',
                        -size     => 1,
                        -multiple => 0 );
 
+# fill template
 $template->param( existing => $biblio,
                                                title => $title,
                                                ordnum => $ordnum,
-                                               basket => $basket,
-                                               id => $id,
+                                               basketno => $basketno,
+                                               booksellerid => $booksellerid,
+                                               suggestionid => $suggestionid,
                                                biblio => $biblio,
                                                biblioitemnumber => $data->{'biblioitemnumber'},
                                                itemtype => $data->{'itemtype'},
@@ -171,7 +167,6 @@ $template->param( existing => $biblio,
                                                notes => $data->{'notes'},
                                                sort1 => $data->{'sort1'},
                                                sort2 => $data->{'sort2'},
-                                               barcode => $data->{'barcode'},
                                                publishercode => $data->{'publishercode'});
 
 output_html_with_http_headers $input, $cookie, $template->output;
index 3da75ee..7d8acf8 100755 (executable)
@@ -47,32 +47,37 @@ my ($template, $loggedinuser, $cookie)
 my $supplier=$query->param('supplier');
 my ($count,@suppliers)=bookseller($supplier);
 
-my $colour='#EEEEEE';
+# check if we have to "close" a basket before building page
+my $op = $query->param('op');
+my $basket = $query->param('basket');
+if ($op eq 'close') {
+       closebasket($basket);
+}
+
+#build reult page
 my $toggle=0;
 my @loop_suppliers;
 for (my $i=0; $i<$count; $i++) {
        my ($ordcount,$orders)=getorders($suppliers[$i]->{'id'});
        my %line;
        if ($toggle==0){
-               $line{color}='#EEEEEE';
+               $line{even}=1;
                $toggle=1;
        } else {
-               $line{color}='white';
+               $line{even}=0;
                $toggle=0;
        }
-       $line{id} =$suppliers[$i]->{'id'};
+       $line{supplierid} =$suppliers[$i]->{'id'};
        $line{name} = $suppliers[$i]->{'name'};
        $line{active} = $suppliers[$i]->{'active'};
-       $line{total} = $orders->[0]->{'count(*)'};
-       $line{authorisedby} = $orders->[0]->{'authorisedby'};
-       $line{entrydate} = $orders->[0]->{'entrydate'};
        my @loop_basket;
        for (my $i2=0;$i2<$ordcount;$i2++){
                my %inner_line;
                $inner_line{basketno} =$orders->[$i2]->{'basketno'};
                $inner_line{total} =$orders->[$i2]->{'count(*)'};
                $inner_line{authorisedby} = $orders->[$i2]->{'authorisedby'};
-               $inner_line{entrydate} = format_date($orders->[$i2]->{'entrydate'});
+               $inner_line{creationdate} = format_date($orders->[$i2]->{'creationdate'});
+               $inner_line{closedate} = format_date($orders->[$i2]->{'closedate'});
                push @loop_basket, \%inner_line;
        }
        $line{loop_basket} = \@loop_basket;
diff --git a/acqui/suggestion-select.pl b/acqui/suggestion-select.pl
new file mode 100755 (executable)
index 0000000..d2ec8a7
--- /dev/null
@@ -0,0 +1,50 @@
+#!/usr/bin/perl
+use strict;
+require Exporter;
+use CGI;
+use HTML::Template;
+
+use C4::Auth;       # get_template_and_user
+use C4::Interface::CGI::Output;
+use C4::Suggestions;
+
+my $input = new CGI;
+
+my $basketid = $input->param('basket');
+my $supplierid = $input->param('id');
+
+my $title = $input->param('title');
+my $author = $input->param('author');
+my $note = $input->param('note');
+my $copyrightdate =$input->param('copyrightdate');
+my $publishercode = $input->param('publishercode');
+my $volumedesc = $input->param('volumedesc');
+my $publicationyear = $input->param('publicationyear');
+my $place = $input->param('place');
+my $isbn = $input->param('isbn');
+my $status = $input->param('status');
+my $suggestedbyme = $input->param('suggestedbyme');
+my $op = $input->param('op');
+$op = 'else' unless $op;
+
+my $dbh = C4::Context->dbh;
+my ($template, $borrowernumber, $cookie)
+    = get_template_and_user({template_name => "acqui/suggestion-select.tmpl",
+                            type => "intranet",
+                            query => $input,
+                            authnotrequired => 1,
+                            flagsrequired => {borrow => 1},
+                        });
+
+my $suggestions_loop= &searchsuggestion($borrowernumber,$author,$title,$publishercode,$status,$suggestedbyme);
+$template->param(suggestions_loop => $suggestions_loop,
+                               title => $title,
+                               author => $author,
+                               publishercode => $publishercode,
+                               status => $status,
+                               suggestedbyme => $suggestedbyme,
+                               basket => $basketid,
+                               supplierid => $supplierid,
+                               "op_$op" => 1,
+);
+output_html_with_http_headers $input, $cookie, $template->output;
diff --git a/koha-tmpl/intranet-tmpl/default/en/suggestion/acceptorreject.tmpl b/koha-tmpl/intranet-tmpl/default/en/suggestion/acceptorreject.tmpl
new file mode 100644 (file)
index 0000000..e026f44
--- /dev/null
@@ -0,0 +1,51 @@
+<!-- TMPL_INCLUDE NAME="acquisitions-top.inc" -->
+<div id="mainbloc">
+
+<!-- TMPL_IF name="op_else" -->
+       <h1 class="acquisition">Suggestions</h1>
+       <table>
+               <tr>
+                       <th class="acquisition">Status</th>
+                       <th class="acquisition">Suggestion</th>
+                       <th class="acquisition">Suggested by</th>
+               </tr>
+               <form method="post" action="/cgi-bin/koha/suggestion/acceptorreject.pl">
+                       <input type="hidden" name="op" value="aorr_confirm">
+               <!-- TMPL_LOOP NAME="suggestions_loop" -->
+                       <tr>
+                               <td>
+                                       <select name="aorr">
+                                               <option value=""></option>
+                                               <option value="R<!--TMPL_VAR name="suggestionid" -->">Reject</option>
+                                               <option value="A<!--TMPL_VAR name="suggestionid" -->">Accept</option>
+                                       </select>
+                               </td>
+                               <td <!-- TMPL_IF name="even" -->class="hilighted"<!-- /TMPL_IF -->>
+                                       <p><!-- TMPL_VAR NAME="title" --> - <!-- TMPL_VAR NAME="author" --></p>
+                                       <p>
+                                               <!-- TMPL_IF name="copyrightdate" -->copy. year:<!-- TMPL_VAR name="copyrightdate" --> <!-- /TMPL_IF -->
+                                               <!-- TMPL_IF name="volumedesc" -->volume:<i><!-- TMPL_VAR name="volumedesc" --></i> <!-- /TMPL_IF -->
+                                               <!-- TMPL_IF name="isbn" -->ISBN :<i><!-- TMPL_VAR name="isbn" --></i> <!-- /TMPL_IF -->
+                                               <!-- TMPL_IF name="publishercode" --><br/>published by:<!-- TMPL_VAR name="publishercode" --> <!-- /TMPL_IF -->
+                                               <!-- TMPL_IF name="publicationyear" --> in <i><!-- TMPL_VAR name="publicationyear" --></i> <!-- /TMPL_IF -->
+                                               <!-- TMPL_IF name="place" --> at <i><!-- TMPL_VAR name="place" --></i> <!-- /TMPL_IF -->
+                                               <!-- TMPL_IF name="note" --><p><i>(<!-- TMPL_VAR name="copyrightdate" -->)</i></p> <!-- /TMPL_IF -->
+
+                               </td>
+                               <td <!-- TMPL_IF name="even" -->class="hilighted"<!-- /TMPL_IF -->>
+                                       <!-- TMPL_VAR name="surnamesuggestedby" --><!-- TMPL_IF name="firstnamesuggestedby" -->,<!-- /TMPL_IF --> <!-- TMPL_VAR name="firstnamesuggestedby" -->
+                               </td>
+                       </tr>
+               <!-- /TMPL_LOOP -->
+               <tr>
+                       <td>
+                               <input type="submit" class="button acquisition" value="change status">
+                       </td>
+                       <td> &nbsp; </td>
+                       <td> &nbsp; </td>
+               </tr>
+               </form>
+       </table>
+<!-- /TMPL_IF -->
+</div>
+<!-- TMPL_INCLUDE NAME="acquisitions-bottom.inc" -->
diff --git a/koha-tmpl/intranet-tmpl/default/en/suggestion/mail_suggestion_ACCEPTED.tmpl b/koha-tmpl/intranet-tmpl/default/en/suggestion/mail_suggestion_ACCEPTED.tmpl
new file mode 100644 (file)
index 0000000..ded4724
--- /dev/null
@@ -0,0 +1,10 @@
+Dear library user,
+
+You have suggested to the library to buy <!-- TMPL_VAR name="title" --> <!-- TMPL_IF name="author" -->from <!-- TMPL_VAR name="author" --><!-- /TMPL_IF -->
+
+<!-- TMPL_VAR name="lib.surname" --> <!-- TMPL_VAR lib.firstname --> managed your suggestions today, and found it interesting.
+The document will be bought as soon as possible. You will be warned by mail when the acquisition will be done, then mailed again when the book arrives at the library.
+
+Ask any question to <!-- TMPL_VAR name="libemail" -->
+-- 
+You library
\ No newline at end of file
diff --git a/koha-tmpl/intranet-tmpl/default/en/suggestion/mail_suggestion_AVAILABLE.tmpl b/koha-tmpl/intranet-tmpl/default/en/suggestion/mail_suggestion_AVAILABLE.tmpl
new file mode 100644 (file)
index 0000000..0c8506d
--- /dev/null
@@ -0,0 +1,8 @@
+Dear library user,
+
+You have suggested to the library to buy <!-- TMPL_VAR name="title" --> <!-- TMPL_IF name="author" -->from <!-- TMPL_VAR name="author" --><!-- /TMPL_IF -->
+
+We are glad to inform you that the book is now available at the library.
+
+-- 
+You library
\ No newline at end of file
diff --git a/koha-tmpl/intranet-tmpl/default/en/suggestion/mail_suggestion_ORDERED.tmpl b/koha-tmpl/intranet-tmpl/default/en/suggestion/mail_suggestion_ORDERED.tmpl
new file mode 100644 (file)
index 0000000..55ff2fb
--- /dev/null
@@ -0,0 +1,9 @@
+Dear library user,
+
+You have suggested to the library to buy <!-- TMPL_VAR name="title" --> <!-- TMPL_IF name="author" -->from <!-- TMPL_VAR name="author" --><!-- /TMPL_IF -->
+
+We are glad to inform you that the book has been ordered. It should arrive soon at the library.
+
+You will be mailed again when the book is available.
+-- 
+You library
\ No newline at end of file
diff --git a/koha-tmpl/intranet-tmpl/default/en/suggestion/mail_suggestion_REJECTED.tmpl b/koha-tmpl/intranet-tmpl/default/en/suggestion/mail_suggestion_REJECTED.tmpl
new file mode 100644 (file)
index 0000000..1961ca7
--- /dev/null
@@ -0,0 +1,9 @@
+Dear library user,
+
+You have suggested to the library to buy <!-- TMPL_VAR name="title" --> <!-- TMPL_IF name="author" -->from <!-- TMPL_VAR name="author" --><!-- /TMPL_IF -->
+
+<!-- TMPL_VAR name="lib.surname" --> <!-- TMPL_VAR lib.firstname --> managed your suggestions today, and decided to reject it.
+
+Don't hesitate to ask for more explanations by mailing <!-- TMPL_VAR name="libemail" -->
+-- 
+You library
\ No newline at end of file
index 6d71be4..a417ea8 100755 (executable)
@@ -55,7 +55,7 @@ use CGI;
 use C4::Search;
 use MARC::Record;
 use C4::Biblio;
-use C4::Catalogue;
+use C4::Acquisition;
 use HTML::Template;
 
 my $query=new CGI;
index 8154ce3..d90b723 100755 (executable)
@@ -55,7 +55,7 @@ use CGI;
 use C4::Search;
 use MARC::Record;
 use C4::Biblio;
-use C4::Catalogue;
+use C4::Acquisition;
 use HTML::Template;
 
 my $query=new CGI;
index c8abb36..e7c3729 100755 (executable)
@@ -9,7 +9,7 @@ use CGI;
 use C4::Database;
 use HTML::Template;
 use C4::SearchMarc;
-use C4::Catalogue;
+use C4::Acquisition;
 use C4::Biblio;
 
 my $classlist='';
index ba533ed..5e60c39 100755 (executable)
@@ -11,10 +11,15 @@ use C4::Suggestions;
 my $input = new CGI;
 my $title = $input->param('title');
 my $author = $input->param('author');
+my $note = $input->param('note');
+my $copyrightdate =$input->param('copyrightdate');
 my $publishercode = $input->param('publishercode');
+my $volumedesc = $input->param('volumedesc');
+my $publicationyear = $input->param('publicationyear');
+my $place = $input->param('place');
+my $isbn = $input->param('isbn');
 my $status = $input->param('status');
 my $suggestedbyme = $input->param('suggestedbyme');
-my $note = $input->param('note');
 my $op = $input->param('op');
 $op = 'else' unless $op;
 
@@ -27,11 +32,16 @@ my ($template, $borrowernumber, $cookie)
                             flagsrequired => {borrow => 1},
                         });
 if ($op eq "add_confirm") {
-       &newsuggestion($borrowernumber,$title,$author,$publishercode,$note);
+       &newsuggestion($borrowernumber,$title,$author,$publishercode,$note,$copyrightdate,$volumedesc,$publicationyear,$place,$isbn);
        # empty fields, to avoid filter in "searchsuggestion"
        $title='';
        $author='';
        $publishercode='';
+       $copyrightdate ='';
+       $volumedesc = '';
+       $publicationyear = '';
+       $place = '';
+       $isbn = '';
        $op='else';
 }
 
diff --git a/suggestion/acceptorreject.pl b/suggestion/acceptorreject.pl
new file mode 100755 (executable)
index 0000000..af15cf6
--- /dev/null
@@ -0,0 +1,59 @@
+#!/usr/bin/perl
+use strict;
+require Exporter;
+use CGI;
+use HTML::Template;
+
+use C4::Auth;       # get_template_and_user
+use C4::Interface::CGI::Output;
+use C4::Suggestions;
+
+my $input = new CGI;
+my $title = $input->param('title');
+my $author = $input->param('author');
+my $note = $input->param('note');
+my $copyrightdate =$input->param('copyrightdate');
+my $publishercode = $input->param('publishercode');
+my $volumedesc = $input->param('volumedesc');
+my $publicationyear = $input->param('publicationyear');
+my $place = $input->param('place');
+my $isbn = $input->param('isbn');
+my $status = $input->param('status');
+my $suggestedbyme = $input->param('suggestedbyme');
+my $op = $input->param('op');
+$op = 'else' unless $op;
+
+my $dbh = C4::Context->dbh;
+my ($template, $loggedinuser, $cookie)
+    = get_template_and_user({template_name => "suggestion/acceptorreject.tmpl",
+                            type => "intranet",
+                            query => $input,
+                            authnotrequired => 1,
+                            flagsrequired => {borrow => 1},
+                        });
+if ($op eq "aorr_confirm") {
+       my @suggestionlist = $input->param("aorr");
+       foreach my $suggestion (@suggestionlist) {
+               if ($suggestion =~ /(A|R)(.*)/) {
+                       my ($newstatus,$suggestionid) = ($1,$2);
+                       $newstatus="REJECTED" if $newstatus eq "R";
+                       $newstatus="ACCEPTED" if $newstatus eq "A";
+                       changestatus($suggestionid,$newstatus,$loggedinuser);
+               }
+       }
+       $op="else";
+}
+
+if ($op eq "delete_confirm") {
+       my @delete_field = $input->param("delete_field");
+       foreach my $delete_field (@delete_field) {
+               &delsuggestion($loggedinuser,$delete_field);
+       }
+       $op='else';
+}
+
+my $suggestions_loop= &searchsuggestion("","","","",'ASKED',"");
+$template->param(suggestions_loop => $suggestions_loop,
+                               "op_$op" => 1,
+);
+output_html_with_http_headers $input, $cookie, $template->output;