View | Details | Raw Unified | Return to bug 7593
Collapse All | Expand All

(-)a/C4/Acquisition.pm (-2 / +36 lines)
Lines 53-60 BEGIN { Link Here
53
        &ModBasketgroup &NewBasketgroup &DelBasketgroup &GetBasketgroup &CloseBasketgroup
53
        &ModBasketgroup &NewBasketgroup &DelBasketgroup &GetBasketgroup &CloseBasketgroup
54
        &GetBasketgroups &ReOpenBasketgroup
54
        &GetBasketgroups &ReOpenBasketgroup
55
55
56
        &NewOrder &DelOrder &ModOrder &GetPendingOrders &GetOrder &GetOrders
56
        &NewOrder &DelOrder &ModOrder &GetPendingOrders &GetOrder &GetOrders &GetOrdersByBiblionumber
57
        &GetOrderNumber &GetLateOrders &GetOrderFromItemnumber
58
        &SearchOrder &GetHistory &GetRecentAcqui
57
        &SearchOrder &GetHistory &GetRecentAcqui
59
        &ModReceiveOrder &CancelReceipt &ModOrderBiblioitemNumber
58
        &ModReceiveOrder &CancelReceipt &ModOrderBiblioitemNumber
60
        &GetCancelledOrders
59
        &GetCancelledOrders
Lines 950-955 sub GetOrders { Link Here
950
}
949
}
951
950
952
#------------------------------------------------------------#
951
#------------------------------------------------------------#
952
=head3 GetOrdersByBiblionumber
953
954
  @orders = &GetOrdersByBiblionumber($biblionumber);
955
956
Looks up the orders with linked to a specific $biblionumber, including
957
cancelled orders and received orders.
958
959
return :
960
C<@orders> is an array of references-to-hash, whose keys are the
961
fields from the aqorders, biblio, and biblioitems tables in the Koha database.
962
963
=cut
964
965
sub GetOrdersByBiblionumber {
966
    my $biblionumber = shift;
967
    return unless $biblionumber;
968
    my $dbh   = C4::Context->dbh;
969
    my $query  ="
970
        SELECT biblio.*,biblioitems.*,
971
                aqorders.*,
972
                aqbudgets.*
973
        FROM    aqorders
974
            LEFT JOIN aqbudgets        ON aqbudgets.budget_id = aqorders.budget_id
975
            LEFT JOIN biblio           ON biblio.biblionumber = aqorders.biblionumber
976
            LEFT JOIN biblioitems      ON biblioitems.biblionumber =biblio.biblionumber
977
        WHERE   aqorders.biblionumber=?
978
    ";
979
    my $sth = $dbh->prepare($query);
980
    $sth->execute($biblionumber);
981
    my $results = $sth->fetchall_arrayref({});
982
    $sth->finish;
983
    return @$results;
984
}
985
986
#------------------------------------------------------------#
953
987
954
=head3 GetOrderNumber
988
=head3 GetOrderNumber
955
989
(-)a/cataloguing/merge.pl (+12 lines)
Lines 29-34 use C4::Biblio; Link Here
29
use C4::Serials;
29
use C4::Serials;
30
use C4::Koha;
30
use C4::Koha;
31
use C4::Reserves qw/MergeHolds/;
31
use C4::Reserves qw/MergeHolds/;
32
use C4::Acquisition qw/ModOrder GetOrdersByBiblionumber/;
32
33
33
my $input = new CGI;
34
my $input = new CGI;
34
my @biblionumber = $input->param('biblionumber');
35
my @biblionumber = $input->param('biblionumber');
Lines 69-74 if ($merge) { Link Here
69
    ModBiblio($record, $tobiblio, $frameworkcode);
70
    ModBiblio($record, $tobiblio, $frameworkcode);
70
71
71
    # Moving items from the other record to the reference record
72
    # Moving items from the other record to the reference record
73
    # Also moving orders from the other record to the reference record, only if the order is linked to an item of the other record
72
    my $itemnumbers = get_itemnumbers_of($frombiblio);
74
    my $itemnumbers = get_itemnumbers_of($frombiblio);
73
    foreach my $itloop ($itemnumbers->{$frombiblio}) {
75
    foreach my $itloop ($itemnumbers->{$frombiblio}) {
74
    foreach my $itemnumber (@$itloop) {
76
    foreach my $itemnumber (@$itloop) {
Lines 101-106 if ($merge) { Link Here
101
103
102
    # TODO : Moving reserves
104
    # TODO : Moving reserves
103
105
106
    # Moving orders (orders linked to items of frombiblio have already been moved by MoveItemFromBiblio)
107
    my @allorders = GetOrdersByBiblionumber($frombiblio);
108
    my @tobiblioitem = GetBiblioItemByBiblioNumber ($tobiblio);
109
    my $tobiblioitem_biblioitemnumber = $tobiblioitem [0]-> {biblioitemnumber };
110
    foreach my $myorder (@allorders) {
111
        $myorder->{'biblionumber'} = $tobiblio;
112
        ModOrder ($myorder);
113
    # TODO : add error control (in ModOrder?)
114
    }
115
104
    # Deleting the other record
116
    # Deleting the other record
105
    if (scalar(@errors) == 0) {
117
    if (scalar(@errors) == 0) {
106
    # Move holds
118
    # Move holds
(-)a/t/db_dependent/Acquisition.t (-2 / +18 lines)
Lines 10-16 use POSIX qw(strftime); Link Here
10
10
11
use C4::Bookseller qw( GetBookSellerFromId );
11
use C4::Bookseller qw( GetBookSellerFromId );
12
12
13
use Test::More tests => 37;
13
use Test::More tests => 42;
14
14
15
BEGIN {
15
BEGIN {
16
    use_ok('C4::Acquisition');
16
    use_ok('C4::Acquisition');
Lines 32-37 my $grouped = 0; Link Here
32
my $orders = GetPendingOrders( $supplierid, $grouped );
32
my $orders = GetPendingOrders( $supplierid, $grouped );
33
isa_ok( $orders, 'ARRAY' );
33
isa_ok( $orders, 'ARRAY' );
34
34
35
# testing GetOrdersByBiblionumber
36
# result should be undef if no params
37
my @ordersbybiblionumber = GetOrdersByBiblionumber();
38
is(@ordersbybiblionumber,0,'GetOrdersByBiblionumber : no argument, return undef');
39
# TODO : create 2 orders using the same biblionumber, and check the result of GetOrdersByBiblionumber
40
# if a record is used in at least one order, result should be an array with at least one element
41
SKIP: {
42
   skip 'No Orders, cannot test GetOrdersByBiblionumber', 3 unless( scalar @$orders );
43
   my $testorder = @$orders[0];
44
   my $testbiblio = $testorder->{'biblionumber'};
45
   my @listorders = GetOrdersByBiblionumber($testbiblio);
46
   isa_ok( ref @listorders, 'ARRAY','GetOrdersByBiblionumber : result is an array' );
47
   ok( scalar (@listorders) >0,'GetOrdersByBiblionumber : result contains at least one element' );
48
   my @matched_biblios = grep {$_->{biblionumber} == $testbiblio} @listorders;
49
   ok ( @matched_biblios == @listorders, "all orders match");
50
}
51
35
my @lateorders = GetLateOrders(0);
52
my @lateorders = GetLateOrders(0);
36
SKIP: {
53
SKIP: {
37
   skip 'No Late Orders, cannot test AddClaim', 1 unless @lateorders;
54
   skip 'No Late Orders, cannot test AddClaim', 1 unless @lateorders;
38
- 

Return to bug 7593