# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
# A PARTICULAR PURPOSE. See the GNU General Public License for more details.
#
-# You should have received a copy of the GNU General Public License along with
-# Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
-# Suite 330, Boston, MA 02111-1307 USA
+# You should have received a copy of the GNU General Public License along
+# with Koha; if not, write to the Free Software Foundation, Inc.,
+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
use strict;
+use warnings;
use C4::Context;
use C4::Debug;
use C4::Dates qw(format_date format_date_in_iso);
use MARC::Record;
use C4::Suggestions;
+use C4::Biblio;
use C4::Debug;
use C4::SQLHelper qw(InsertInTable);
@ISA = qw(Exporter);
@EXPORT = qw(
&GetBasket &NewBasket &CloseBasket &DelBasket &ModBasket
+ &GetBasketAsCSV
&GetBasketsByBookseller &GetBasketsByBasketgroup
-
- &ModBasketHeader
+
+ &ModBasketHeader
&ModBasketgroup &NewBasketgroup &DelBasketgroup &GetBasketgroup &CloseBasketgroup
&GetBasketgroups &ReOpenBasketgroup
&NewOrder &DelOrder &ModOrder &GetPendingOrders &GetOrder &GetOrders
&GetOrderNumber &GetLateOrders &GetOrderFromItemnumber
&SearchOrder &GetHistory &GetRecentAcqui
- &ModReceiveOrder &ModOrderBiblioitemNumber
+ &ModReceiveOrder &ModOrderBiblioitemNumber
&NewOrderItem &ModOrderItem
my $sth = $dbh->prepare($query);
- $sth->trace(3);
+# $sth->trace(3);
$sth->execute($itemnumber);
}
-# Returns the itemnumber(s) associated with the ordernumber given in parameter
+# Returns the itemnumber(s) associated with the ordernumber given in parameter
sub GetItemnumbersFromOrder {
my ($ordernumber) = @_;
my $dbh = C4::Context->dbh;
my @tab;
while (my $order = $sth->fetchrow_hashref) {
- push @tab, $order->{'itemnumber'};
+ push @tab, $order->{'itemnumber'};
}
return @tab;
=head3 GetBasket
-=over 4
-
-$aqbasket = &GetBasket($basketnumber);
+ $aqbasket = &GetBasket($basketnumber);
get all basket informations in aqbasket for a given basket
-return :
-informations for a given basket returned as a hashref.
-
-=back
+B<returns:> informations for a given basket returned as a hashref.
=cut
=head3 NewBasket
-=over 4
-
-$basket = &NewBasket( $booksellerid, $authorizedby, $basketname, $basketnote, $basketbooksellernote, $basketcontractnumber );
+ $basket = &NewBasket( $booksellerid, $authorizedby, $basketname,
+ $basketnote, $basketbooksellernote, $basketcontractnumber );
Create a new basket in aqbasket table
+=over
+
=item C<$booksellerid> is a foreign key in the aqbasket table
=item C<$authorizedby> is the username of who created the basket
-The other parameters are optional, see ModBasketHeader for more info on them.
-
=back
+The other parameters are optional, see ModBasketHeader for more info on them.
+
=cut
# FIXME : this function seems to be unused.
=head3 CloseBasket
-=over 4
-
-&CloseBasket($basketno);
+ &CloseBasket($basketno);
close a basket (becomes unmodifiable,except for recieves)
-=back
-
=cut
sub CloseBasket {
#------------------------------------------------------------#
-=head3 CloseBasketgroup
+=head3 GetBasketAsCSV
-=over 4
+ &GetBasketAsCSV($basketno);
-&CloseBasketgroup($basketgroupno);
+Export a basket as CSV
-close a basketgroup
+=cut
-=back
+sub GetBasketAsCSV {
+ my ($basketno) = @_;
+ my $basket = GetBasket($basketno);
+ my @orders = GetOrders($basketno);
+ my $contract = GetContract($basket->{'contractnumber'});
+ my $csv = Text::CSV->new();
+ my $output;
+
+ # TODO: Translate headers
+ my @headers = qw(contractname ordernumber line entrydate isbn author title publishercode collectiontitle notes quantity rrp);
+
+ $csv->combine(@headers);
+ $output = $csv->string() . "\n";
+
+ my @rows;
+ foreach my $order (@orders) {
+ my @cols;
+ my $bd = GetBiblioData($order->{'biblionumber'});
+ push(@cols,
+ $contract->{'contractname'},
+ $order->{'ordernumber'},
+ $order->{'entrydate'},
+ $order->{'isbn'},
+ $bd->{'author'},
+ $bd->{'title'},
+ $bd->{'publishercode'},
+ $bd->{'collectiontitle'},
+ $order->{'notes'},
+ $order->{'quantity'},
+ $order->{'rrp'},
+ );
+ push (@rows, \@cols);
+ }
+
+ # Sort by publishercode
+ # TODO: Sort by publishercode then by title
+ @rows = sort { @$a[7] cmp @$b[7] } @rows;
+
+ foreach my $row (@rows) {
+ $csv->combine(@$row);
+ $output .= $csv->string() . "\n";
+
+ }
+
+ return $output;
+
+}
+
+
+=head3 CloseBasketgroup
+
+ &CloseBasketgroup($basketgroupno);
+
+close a basketgroup
=cut
=head3 ReOpenBaskergroup($basketgroupno)
-=over 4
-
-&ReOpenBaskergroup($basketgroupno);
+ &ReOpenBaskergroup($basketgroupno);
reopen a basketgroup
-=back
-
=cut
sub ReOpenBasketgroup {
=head3 DelBasket
-=over 4
-
-&DelBasket($basketno);
+ &DelBasket($basketno);
Deletes the basket that has basketno field $basketno in the aqbasket table.
-=over 2
+=over
=item C<$basketno> is the primary key of the basket in the aqbasket table.
=back
-=back
-
=cut
+
sub DelBasket {
my ( $basketno ) = @_;
my $query = "DELETE FROM aqbasket WHERE basketno=?";
=head3 ModBasket
-=over 4
-
-&ModBasket($basketinfo);
+ &ModBasket($basketinfo);
Modifies a basket, using a hashref $basketinfo for the relevant information, only $basketinfo->{'basketno'} is required.
-=over 2
+=over
=item C<$basketno> is the primary key of the basket in the aqbasket table.
=back
-=back
-
=cut
+
sub ModBasket {
my $basketinfo = shift;
my $query = "UPDATE aqbasket SET ";
=head3 ModBasketHeader
-=over 4
-
-&ModBasketHeader($basketno, $basketname, $note, $booksellernote, $contractnumber);
+ &ModBasketHeader($basketno, $basketname, $note, $booksellernote, $contractnumber);
Modifies a basket's header.
-=over 2
+=over
=item C<$basketno> is the "basketno" field in the "aqbasket" table;
=back
-=back
-
=cut
+
sub ModBasketHeader {
my ($basketno, $basketname, $note, $booksellernote, $contractnumber) = @_;
my $query = "UPDATE aqbasket SET basketname=?, note=?, booksellernote=? WHERE basketno=?";
=head3 GetBasketsByBookseller
-=over 4
-
-@results = &GetBasketsByBookseller($booksellerid, $extra);
+ @results = &GetBasketsByBookseller($booksellerid, $extra);
Returns a list of hashes of all the baskets that belong to bookseller 'booksellerid'.
-=over 2
+=over
=item C<$booksellerid> is the 'id' field of the bookseller in the aqbooksellers table
=item C<$extra> is the extra sql parameters, can be
-- $extra->{groupby}: group baskets by column
+ $extra->{groupby}: group baskets by column
ex. $extra->{groupby} = aqbasket.basketgroupid
-- $extra->{orderby}: order baskets by column
-- $extra->{limit}: limit number of results (can be helpful for pagination)
-
-=back
+ $extra->{orderby}: order baskets by column
+ $extra->{limit}: limit number of results (can be helpful for pagination)
=back
=head3 GetBasketsByBasketgroup
-=over 4
-
-$baskets = &GetBasketsByBasketgroup($basketgroupid);
-
-=over 2
+ $baskets = &GetBasketsByBasketgroup($basketgroupid);
Returns a reference to all baskets that belong to basketgroup $basketgroupid.
-=back
-
-=back
-
=cut
sub GetBasketsByBasketgroup {
=head3 NewBasketgroup
-=over 4
-
-$basketgroupid = NewBasketgroup(\%hashref);
-
-=over 2
+ $basketgroupid = NewBasketgroup(\%hashref);
Adds a basketgroup to the aqbasketgroups table, and add the initial baskets to it.
$hashref->{'basketlist'} is a list reference of the 'id's of the baskets that belong to this group,
-$hashref->{'closed'} is the 'closed' field of the aqbasketgroups table, it is false if 0, true otherwise.
+$hashref->{'deliveryplace'} is the 'deliveryplace' field of the basketgroup in the aqbasketgroups table,
-=back
+$hashref->{'deliverycomment'} is the 'deliverycomment' field of the basketgroup in the aqbasketgroups table,
-=back
+$hashref->{'closed'} is the 'closed' field of the aqbasketgroups table, it is false if 0, true otherwise.
=cut
die "booksellerid is required to create a basketgroup" unless $basketgroupinfo->{'booksellerid'};
my $query = "INSERT INTO aqbasketgroups (";
my @params;
- foreach my $field ('name', 'closed') {
+ foreach my $field ('name', 'deliveryplace', 'deliverycomment', 'closed') {
if ( $basketgroupinfo->{$field} ) {
$query .= "$field, ";
push(@params, $basketgroupinfo->{$field});
=head3 ModBasketgroup
-=over 4
-
-ModBasketgroup(\%hashref);
-
-=over 2
+ ModBasketgroup(\%hashref);
Modifies a basketgroup in the aqbasketgroups table, and add the baskets to it.
$hashref->{'basketlist'} is a list reference of the 'id's of the baskets that belong to this group,
-$hashref->{'closed'} is the 'closed' field of the aqbasketgroups table, it is false if 0, true otherwise.
+$hashref->{'billingplace'} is the 'billingplace' field of the basketgroup in the aqbasketgroups table,
-=back
+$hashref->{'deliveryplace'} is the 'deliveryplace' field of the basketgroup in the aqbasketgroups table,
-=back
+$hashref->{'deliverycomment'} is the 'deliverycomment' field of the basketgroup in the aqbasketgroups table,
+
+$hashref->{'closed'} is the 'closed' field of the aqbasketgroups table, it is false if 0, true otherwise.
=cut
my $dbh = C4::Context->dbh;
my $query = "UPDATE aqbasketgroups SET ";
my @params;
- foreach my $field (qw(name closed)) {
- if ( $basketgroupinfo->{$field} ne undef) {
+ foreach my $field (qw(name billingplace deliveryplace deliverycomment closed)) {
+ if ( defined $basketgroupinfo->{$field} ) {
$query .= "$field=?, ";
push(@params, $basketgroupinfo->{$field});
}
push(@params, $basketgroupinfo->{'id'});
my $sth = $dbh->prepare($query);
$sth->execute(@params);
-
+
$sth = $dbh->prepare('UPDATE aqbasket SET basketgroupid = NULL WHERE basketgroupid = ?');
$sth->execute($basketgroupinfo->{'id'});
-
+
if($basketgroupinfo->{'basketlist'} && @{$basketgroupinfo->{'basketlist'}}){
$sth = $dbh->prepare("UPDATE aqbasket SET basketgroupid=? WHERE basketno=?");
foreach my $basketno (@{$basketgroupinfo->{'basketlist'}}) {
=head3 DelBasketgroup
-=over 4
-
-DelBasketgroup($basketgroupid);
-
-=over 2
+ DelBasketgroup($basketgroupid);
Deletes a basketgroup in the aqbasketgroups table, and removes the reference to it from the baskets,
-=item C<$basketgroupid> is the 'id' field of the basket in the aqbasketgroup table
+=over
-=back
+=item C<$basketgroupid> is the 'id' field of the basket in the aqbasketgroup table
=back
#------------------------------------------------------------#
-=back
=head2 FUNCTIONS ABOUT ORDERS
-=over 2
-
-=cut
-
=head3 GetBasketgroup
-=over 4
-
-$basketgroup = &GetBasketgroup($basketgroupid);
-
-=over 2
+ $basketgroup = &GetBasketgroup($basketgroupid);
Returns a reference to the hash containing all infermation about the basketgroup.
-=back
-
-=back
-
=cut
sub GetBasketgroup {
=head3 GetBasketgroups
-=over 4
-
-$basketgroups = &GetBasketgroups($booksellerid);
-
-=over 2
+ $basketgroups = &GetBasketgroups($booksellerid);
Returns a reference to the array of all the basketgroups of bookseller $booksellerid.
-=back
-
-=back
-
=cut
sub GetBasketgroups {
#------------------------------------------------------------#
-=back
-
=head2 FUNCTIONS ABOUT ORDERS
-=over 2
-
=cut
#------------------------------------------------------------#
=head3 GetPendingOrders
-=over 4
-
-$orders = &GetPendingOrders($booksellerid, $grouped, $owner);
+ $orders = &GetPendingOrders($booksellerid, $grouped, $owner);
Finds pending orders from the bookseller with the given ID. Ignores
completed and cancelled orders.
C<$grouped> is a boolean that, if set to 1 will group all order lines of the same basket
in a single result line
-=over 2
+=over
=item C<authorizedby>
=item C<basketno>
-These give the value of the corresponding field in the aqorders table
-of the Koha database.
-
=back
-=back
+These give the value of the corresponding field in the aqorders table
+of the Koha database.
Results are ordered from most to least recent.
=head3 GetOrders
-=over 4
-
-@orders = &GetOrders($basketnumber, $orderby);
+ @orders = &GetOrders($basketnumber, $orderby);
Looks up the pending (non-cancelled) orders with the given basket
number. If C<$booksellerID> is non-empty, only orders from that seller
references-to-hash, whose keys are the fields from the aqorders,
biblio, and biblioitems tables in the Koha database.
-=back
-
=cut
sub GetOrders {
=head3 GetOrderNumber
-=over 4
-
-$ordernumber = &GetOrderNumber($biblioitemnumber, $biblionumber);
-
-=back
+ $ordernumber = &GetOrderNumber($biblioitemnumber, $biblionumber);
Looks up the ordernumber with the given biblionumber and biblioitemnumber.
Returns the number of this order.
-=over 4
+=over
=item C<$ordernumber> is the order number.
=back
=cut
+
sub GetOrderNumber {
my ( $biblionumber,$biblioitemnumber ) = @_;
my $dbh = C4::Context->dbh;
=head3 GetOrder
-=over 4
-
-$order = &GetOrder($ordernumber);
+ $order = &GetOrder($ordernumber);
Looks up an order by order number.
Returns a reference-to-hash describing the order. The keys of
C<$order> are fields from the biblio, biblioitems, aqorders tables of the Koha database.
-=back
-
=cut
sub GetOrder {
=head3 NewOrder
-=over 4
-
-&NewOrder(\%hashref);
+ &NewOrder(\%hashref);
Adds a new order to the database. Any argument that isn't described
below is the new value of the field with the same name in the aqorders
table of the Koha database.
-=over 4
+=over
=item $hashref->{'basketno'} is the basketno foreign key in aqorders, it is mandatory
-
-=item $hashref->{'ordernumber'} is a "minimum order number."
+=item $hashref->{'ordernumber'} is a "minimum order number."
=item $hashref->{'budgetdate'} is effectively ignored.
If it's undef (anything false) or the string 'now', the current day is used.
=back
-=back
-
=cut
sub NewOrder {
die "Mandatory parameter $key missing" unless $orderinfo->{$key};
}
- if ( $orderinfo->{'subscription'} eq 'yes' ) {
+ if ( defined $orderinfo->{subscription} && $orderinfo->{'subscription'} eq 'yes' ) {
$orderinfo->{'subscription'} = 1;
} else {
$orderinfo->{'subscription'} = 0;
}
$orderinfo->{'entrydate'} ||= C4::Dates->new()->output("iso");
+ if (!$orderinfo->{quantityreceived}) {
+ $orderinfo->{quantityreceived} = 0;
+ }
my $ordernumber=InsertInTable("aqorders",$orderinfo);
return ( $orderinfo->{'basketno'}, $ordernumber );
=head3 NewOrderItem
-=over 4
-
-&NewOrderItem();
-
-
-=back
+ &NewOrderItem();
=cut
=head3 ModOrder
-=over 4
-
-&ModOrder(\%hashref);
-
-=over 2
+ &ModOrder(\%hashref);
Modifies an existing order. Updates the order with order number
-$hashref->{'ordernumber'} and biblionumber $hashref->{'biblionumber'}. All other keys of the hash
-update the fields with the same name in the aqorders table of the Koha database.
-
-=back
-
-=back
+$hashref->{'ordernumber'} and biblionumber $hashref->{'biblionumber'}. All
+other keys of the hash update the fields with the same name in the aqorders
+table of the Koha database.
=cut
=head3 ModOrderItem
-=over 4
-
-&ModOrderItem(\%hashref);
-
-=over 2
+ &ModOrderItem(\%hashref);
Modifies the itemnumber in the aqorders_items table. The input hash needs three entities:
-- itemnumber: the old itemnumber
-- ordernumber: the order this item is attached to
-- newitemnumber: the new itemnumber we want to attach the line to
-=back
+=over
+
+=item - itemnumber: the old itemnumber
+=item - ordernumber: the order this item is attached to
+=item - newitemnumber: the new itemnumber we want to attach the line to
=back
my $query = "UPDATE aqorders_items set itemnumber=? where itemnumber=? and ordernumber=?";
my @params = ($orderiteminfo->{'newitemnumber'}, $orderiteminfo->{'itemnumber'}, $orderiteminfo->{'ordernumber'});
- warn $query;
- warn Data::Dumper::Dumper(@params);
my $sth = $dbh->prepare($query);
$sth->execute(@params);
return 0;
=head3 ModOrderBibliotemNumber
-=over 4
-
-&ModOrderBiblioitemNumber($biblioitemnumber,$ordernumber, $biblionumber);
+ &ModOrderBiblioitemNumber($biblioitemnumber,$ordernumber, $biblionumber);
Modifies the biblioitemnumber for an existing order.
Updates the order with order number C<$ordernum> and biblionumber C<$biblionumber>.
-=back
-
=cut
#FIXME: is this used at all?
=head3 ModReceiveOrder
-=over 4
-
-&ModReceiveOrder($biblionumber, $ordernumber, $quantityreceived, $user,
+ &ModReceiveOrder($biblionumber, $ordernumber, $quantityreceived, $user,
$unitprice, $booksellerinvoicenumber, $biblioitemnumber,
$freight, $bookfund, $rrp);
Updates the order with bibilionumber C<$biblionumber> and ordernumber
C<$ordernumber>.
-=back
-
=cut
$datereceived = C4::Dates->output('iso') unless $datereceived;
my $suggestionid = GetSuggestionFromBiblionumber( $dbh, $biblionumber );
if ($suggestionid) {
- ModStatus( $suggestionid, 'AVAILABLE', '', $biblionumber );
+ ModSuggestion( {suggestionid=>$suggestionid,
+ STATUS=>'AVAILABLE',
+ biblionumber=> $biblionumber}
+ );
}
my $sth=$dbh->prepare("
- SELECT * FROM aqorders
+ SELECT * FROM aqorders
WHERE biblionumber=? AND aqorders.ordernumber=?");
$sth->execute($biblionumber,$ordernumber);
, unitprice=?
, freight=?
, rrp=?
- , quantityreceived=?
+ , quantity=?
WHERE biblionumber=? AND ordernumber=?");
$sth->execute($quantrec,$datereceived,$invoiceno,$cost,$freight,$rrp,$quantrec,$biblionumber,$ordernumber);
foreach my $orderkey ( "linenumber", "allocation" ) {
delete($order->{'$orderkey'});
}
+ $order->{'quantity'} -= $quantrec;
+ $order->{'quantityreceived'} = 0;
my $newOrder = NewOrder($order);
} else {
$sth=$dbh->prepare("update aqorders
LEFT JOIN biblioitems ON biblioitems.biblionumber=biblio.biblionumber
LEFT JOIN aqbasket ON aqorders.basketno = aqbasket.basketno
WHERE (datecancellationprinted is NULL)";
-
+
if($ordernumber){
$query .= " AND (aqorders.ordernumber=?)";
push @args, $ordernumber;
=head3 DelOrder
-=over 4
-
-&DelOrder($biblionumber, $ordernumber);
+ &DelOrder($biblionumber, $ordernumber);
Cancel the order with the given order and biblio numbers. It does not
delete any entries in the aqorders table, it merely marks them as
cancelled.
-=back
-
=cut
sub DelOrder {
=head3 GetParcel
-=over 4
-
-@results = &GetParcel($booksellerid, $code, $date);
+ @results = &GetParcel($booksellerid, $code, $date);
Looks up all of the received items from the supplier with the given
bookseller ID at the given date, for the given code (bookseller Invoice number). Ignores cancelled and completed orders.
C<@results> is sorted alphabetically by book title.
-=back
-
=cut
sub GetParcel {
=head3 GetParcels
-=over 4
+ $results = &GetParcels($bookseller, $order, $code, $datefrom, $dateto);
-$results = &GetParcels($bookseller, $order, $code, $datefrom, $dateto);
get a lists of parcels.
-=back
-
* Input arg :
-=over 4
+=over
=item $bookseller
is the bookseller this function has to get parcels.
=item $datefrom & $dateto
to know on what date this function has to filter its search.
+=back
+
* return:
a pointer on a hash list containing parcel informations as such :
+=over
+
=item Creation date
=item Last operation
=head3 GetLateOrders
-=over 4
-
-@results = &GetLateOrders;
+ @results = &GetLateOrders;
Searches for bookseller with late orders.
return:
the table of supplier with late issues. This table is full of hashref.
-=back
-
=cut
sub GetLateOrders {
biblioitems.publicationyear,
";
my $from = "
- FROM (((
- (aqorders LEFT JOIN biblio ON biblio.biblionumber = aqorders.biblionumber)
- LEFT JOIN biblioitems ON biblioitems.biblionumber = biblio.biblionumber)
- LEFT JOIN aqbudgets ON aqorders.budget_id = aqbudgets.budget_id),
- (aqbasket LEFT JOIN borrowers ON aqbasket.authorisedby = borrowers.borrowernumber)
- LEFT JOIN aqbooksellers ON aqbasket.booksellerid = aqbooksellers.id
+ FROM
+ aqorders LEFT JOIN biblio ON biblio.biblionumber = aqorders.biblionumber
+ LEFT JOIN biblioitems ON biblioitems.biblionumber = biblio.biblionumber
+ LEFT JOIN aqbudgets ON aqorders.budget_id = aqbudgets.budget_id,
+ aqbasket LEFT JOIN borrowers ON aqbasket.authorisedby = borrowers.borrowernumber
+ LEFT JOIN aqbooksellers ON aqbasket.booksellerid = aqbooksellers.id
WHERE aqorders.basketno = aqbasket.basketno
- AND ( (datereceived = '' OR datereceived IS NULL)
- OR (aqorders.quantityreceived < aqorders.quantity)
+ AND ( datereceived = ''
+ OR datereceived IS NULL
+ OR aqorders.quantityreceived < aqorders.quantity
)
";
my $having = "";
=head3 GetHistory
-=over 4
-
-(\@order_loop, $total_qty, $total_price, $total_qtyreceived) = GetHistory( $title, $author, $name, $from_placed_on, $to_placed_on );
+ (\@order_loop, $total_qty, $total_price, $total_qtyreceived) = GetHistory( $title, $author, $name, $from_placed_on, $to_placed_on );
Retreives some acquisition history information
$total_price is the cost of each in $order_loop times the quantity
$total_qtyreceived is the sum of all of the quantityreceived entries in $order_loop
-=back
-
=cut
sub GetHistory {
biblio.title,
biblio.author,
aqorders.basketno,
- name,aqbasket.creationdate,
+ aqbasket.basketname,
+ aqbasket.basketgroupid,
+ aqbasketgroups.name as groupname,
+ aqbooksellers.name,
+ aqbasket.creationdate,
aqorders.datereceived,
aqorders.quantity,
aqorders.quantityreceived,
aqorders.biblionumber
FROM aqorders
LEFT JOIN aqbasket ON aqorders.basketno=aqbasket.basketno
+ LEFT JOIN aqbasketgroups ON aqbasket.basketgroupid=aqbasketgroups.id
LEFT JOIN aqbooksellers ON aqbasket.booksellerid=aqbooksellers.id
LEFT JOIN biblio ON biblio.biblionumber=aqorders.biblionumber";
$query .= " LEFT JOIN borrowers ON aqbasket.authorisedby=borrowers.borrowernumber"
if ( C4::Context->preference("IndependantBranches") );
-
+
$query .= " WHERE (datecancellationprinted is NULL or datecancellationprinted='0000-00-00') ";
my @query_params = ();
if ( defined $title ) {
$query .= " AND biblio.title LIKE ? ";
+ $title =~ s/\s+/%/g;
push @query_params, "%$title%";
}
}
if ( defined $name ) {
- $query .= " AND name LIKE ? ";
+ $query .= " AND aqbooksellers.name LIKE ? ";
push @query_params, "%$name%";
}
push @query_params, $userenv->{branch};
}
}
- $query .= " ORDER BY booksellerid";
+ $query .= " ORDER BY id";
my $sth = $dbh->prepare($query);
$sth->execute( @query_params );
my $cnt = 1;
=head2 GetRecentAcqui
-$results = GetRecentAcqui($days);
+ $results = GetRecentAcqui($days);
C<$results> is a ref to a table which containts hashref
=head3 GetContracts
-=over 4
-
-$contractlist = &GetContracts($booksellerid, $activeonly);
+ $contractlist = &GetContracts($booksellerid, $activeonly);
Looks up the contracts that belong to a bookseller
Returns a list of contracts
+=over
+
=item C<$booksellerid> is the "id" field in the "aqbooksellers" table.
=item C<$activeonly> if exists get only contracts that are still active.
=back
=cut
+
sub GetContracts {
my ( $booksellerid, $activeonly ) = @_;
my $dbh = C4::Context->dbh;
=head3 GetContract
-=over 4
-
-$contract = &GetContract($contractID);
+ $contract = &GetContract($contractID);
Looks up the contract that has PRIMKEY (contractnumber) value $contractID
Returns a contract
-=back
-
=cut
+
sub GetContract {
my ( $contractno ) = @_;
my $dbh = C4::Context->dbh;
=head1 AUTHOR
-Koha Developement team <info@koha.org>
+Koha Development Team <http://koha-community.org/>
=cut