Commit cf58dfb8 authored by joubu's avatar joubu

Bug 15184: Add users ?

We certainly do not want this patch. What about users that are notified
on receiving?

Sponsored-by: BULAC - http://www.bulac.fr/Signed-off-by: Josef Moravec's avatarJosef Moravec <josef.moravec@gmail.com>
parent 842e7835
......@@ -25,6 +25,7 @@ use Koha::Acquisition::Invoices;
use Koha::Database;
use Koha::DateUtils qw( dt_from_string output_pref );
use Koha::Items;
use Koha::Patrons;
use Koha::Subscriptions;
use base qw(Koha::Object);
......@@ -110,6 +111,14 @@ sub add_item {
$rs->create({ ordernumber => $self->ordernumber, itemnumber => $itemnumber });
}
sub add_user {
my ( $self, $borrowernumber ) = @_;
my $schema = Koha::Database->new->schema;
my $rs = $schema->resultset('AqorderUser');
$rs->create({ ordernumber => $self->ordernumber, borrowernumber => $borrowernumber });
}
=head3 basket
my $basket = Koha::Acquisition::Orders->find( $id )->basket;
......@@ -177,6 +186,13 @@ sub items {
return Koha::Items->search({ itemnumber => \@itemnumbers });
}
sub users {
my ( $self ) = @_;
my $users_rs = $self->_result->aqorder_users;
my @borrowernumbers = $users_rs->get_column( 'borrowernumber' )->all;
return Koha::Patrons->search({ borrowernumber=> \@borrowernumbers });
}
sub duplicate_to {
my ( $self, $basket, $default_values ) = @_;
my $new_order;
......@@ -221,6 +237,10 @@ sub duplicate_to {
my $new_item = Koha::Item->new($item_info)->store;
$new_order->add_item( $new_item->itemnumber );
}
my $users = $self->users; # Do we want ça?
while ( my ($user) = $users->next ) {
$new_order->add_user( $user->borrowernumber );
}
}
);
return $new_order;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment