&SearchOrder &GetHistory &GetRecentAcqui
&ModReceiveOrder &CancelReceipt &ModOrderBiblioitemNumber
&GetCancelledOrders
-
+ &GetLastOrderNotReceivedFromSubscriptionid &GetLastOrderReceivedFromSubscriptionid
&NewOrderItem &ModOrderItem &ModItemOrder
&GetParcels &GetParcel
=cut
sub NewBasket {
- my ( $booksellerid, $authorisedby, $basketname, $basketnote, $basketbooksellernote, $basketcontractnumber, $deliveryplace, $billingplace ) = @_;
+ my ( $booksellerid, $authorisedby, $basketname, $basketnote,
+ $basketbooksellernote, $basketcontractnumber, $deliveryplace,
+ $billingplace ) = @_;
my $dbh = C4::Context->dbh;
- my $query = "
- INSERT INTO aqbasket
- (creationdate,booksellerid,authorisedby)
- VALUES (now(),'$booksellerid','$authorisedby')
- ";
- my $sth =
- $dbh->do($query);
-#find & return basketno MYSQL dependant, but $dbh->last_insert_id always returns null :-(
- my $basket = $dbh->{'mysql_insertid'};
- ModBasketHeader($basket, $basketname || '', $basketnote || '', $basketbooksellernote || '', $basketcontractnumber || undef, $booksellerid, $deliveryplace || undef, $billingplace || undef );
+ my $query =
+ 'INSERT INTO aqbasket (creationdate,booksellerid,authorisedby) '
+ . 'VALUES (now(),?,?)';
+ $dbh->do( $query, {}, $booksellerid, $authorisedby );
+
+ my $basket = $dbh->{mysql_insertid};
+ $basketname ||= q{}; # default to empty strings
+ $basketnote ||= q{};
+ $basketbooksellernote ||= q{};
+ ModBasketHeader( $basket, $basketname, $basketnote, $basketbooksellernote,
+ $basketcontractnumber, $booksellerid, $deliveryplace, $billingplace );
return $basket;
}
$hashref->{'basketlist'} is a list reference of the 'id's of the baskets that belong to this group,
+$hashref->{'billingplace'} is the 'billingplace' field of the basketgroup in the aqbasketgroups table,
+
$hashref->{'deliveryplace'} is the 'deliveryplace' field of the basketgroup in the aqbasketgroups table,
+$hashref->{'freedeliveryplace'} is the 'freedeliveryplace' field of the basketgroup in the aqbasketgroups table,
+
$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.
die "booksellerid is required to create a basketgroup" unless $basketgroupinfo->{'booksellerid'};
my $query = "INSERT INTO aqbasketgroups (";
my @params;
- foreach my $field ('name', 'deliveryplace', 'deliverycomment', 'closed') {
- if ( $basketgroupinfo->{$field} ) {
+ foreach my $field (qw(name billingplace deliveryplace freedeliveryplace deliverycomment closed)) {
+ if ( defined $basketgroupinfo->{$field} ) {
$query .= "$field, ";
push(@params, $basketgroupinfo->{$field});
}
$hashref->{'deliveryplace'} is the 'deliveryplace' field of the basketgroup in the aqbasketgroups table,
+$hashref->{'freedeliveryplace'} is the 'freedeliveryplace' field of the basketgroup in the aqbasketgroups table,
+
$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.
sub GetBasketgroups {
my $booksellerid = shift;
- die "bookseller id is required to edit a basketgroup" unless $booksellerid;
- my $query = "SELECT * FROM aqbasketgroups WHERE booksellerid=? ORDER BY `id` DESC";
+ die 'bookseller id is required to edit a basketgroup' unless $booksellerid;
+ my $query = 'SELECT * FROM aqbasketgroups WHERE booksellerid=? ORDER BY id DESC';
my $dbh = C4::Context->dbh;
my $sth = $dbh->prepare($query);
$sth->execute($booksellerid);
- my $results = $sth->fetchall_arrayref({});
- $sth->finish;
- return $results
+ return $sth->fetchall_arrayref({});
}
#------------------------------------------------------------#
return $data;
}
+=head3 GetLastOrderNotReceivedFromSubscriptionid
+
+ $order = &GetLastOrderNotReceivedFromSubscriptionid($subscriptionid);
+
+Returns a reference-to-hash describing the last order not received for a subscription.
+
+=cut
+
+sub GetLastOrderNotReceivedFromSubscriptionid {
+ my ( $subscriptionid ) = @_;
+ my $dbh = C4::Context->dbh;
+ my $query = qq|
+ SELECT * FROM aqorders
+ LEFT JOIN subscription
+ ON ( aqorders.subscriptionid = subscription.subscriptionid )
+ WHERE aqorders.subscriptionid = ?
+ AND aqorders.datereceived IS NULL
+ LIMIT 1
+ |;
+ my $sth = $dbh->prepare( $query );
+ $sth->execute( $subscriptionid );
+ my $order = $sth->fetchrow_hashref;
+ return $order;
+}
+
+=head3 GetLastOrderReceivedFromSubscriptionid
+
+ $order = &GetLastOrderReceivedFromSubscriptionid($subscriptionid);
+
+Returns a reference-to-hash describing the last order received for a subscription.
+
+=cut
+
+sub GetLastOrderReceivedFromSubscriptionid {
+ my ( $subscriptionid ) = @_;
+ my $dbh = C4::Context->dbh;
+ my $query = qq|
+ SELECT * FROM aqorders
+ LEFT JOIN subscription
+ ON ( aqorders.subscriptionid = subscription.subscriptionid )
+ WHERE aqorders.subscriptionid = ?
+ AND aqorders.datereceived =
+ (
+ SELECT MAX( aqorders.datereceived )
+ FROM aqorders
+ LEFT JOIN subscription
+ ON ( aqorders.subscriptionid = subscription.subscriptionid )
+ WHERE aqorders.subscriptionid = ?
+ AND aqorders.datereceived IS NOT NULL
+ )
+ ORDER BY ordernumber DESC
+ LIMIT 1
+ |;
+ my $sth = $dbh->prepare( $query );
+ $sth->execute( $subscriptionid, $subscriptionid );
+ my $order = $sth->fetchrow_hashref;
+ return $order;
+
+}
+
+
#------------------------------------------------------------#
=head3 NewOrder