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

(-)a/C4/Acquisition.pm (-85 / +57 lines)
Lines 428-434 sub DelBasket { Link Here
428
    my $dbh = C4::Context->dbh;
428
    my $dbh = C4::Context->dbh;
429
    my $sth = $dbh->prepare($query);
429
    my $sth = $dbh->prepare($query);
430
    $sth->execute($basketno);
430
    $sth->execute($basketno);
431
    $sth->finish;
431
    return;
432
}
432
}
433
433
434
#------------------------------------------------------------#
434
#------------------------------------------------------------#
Lines 468-474 sub ModBasket { Link Here
468
    my $dbh = C4::Context->dbh;
468
    my $dbh = C4::Context->dbh;
469
    my $sth = $dbh->prepare($query);
469
    my $sth = $dbh->prepare($query);
470
    $sth->execute(@params);
470
    $sth->execute(@params);
471
    $sth->finish;
471
    return;
472
}
472
}
473
473
474
#------------------------------------------------------------#
474
#------------------------------------------------------------#
Lines 517-525 sub ModBasketHeader { Link Here
517
        my $query2 ="UPDATE aqbasket SET contractnumber=? WHERE basketno=?";
517
        my $query2 ="UPDATE aqbasket SET contractnumber=? WHERE basketno=?";
518
        my $sth2 = $dbh->prepare($query2);
518
        my $sth2 = $dbh->prepare($query2);
519
        $sth2->execute($contractnumber,$basketno);
519
        $sth2->execute($contractnumber,$basketno);
520
        $sth2->finish;
521
    }
520
    }
522
    $sth->finish;
521
    return;
523
}
522
}
524
523
525
#------------------------------------------------------------#
524
#------------------------------------------------------------#
Lines 562-570 sub GetBasketsByBookseller { Link Here
562
    my $dbh = C4::Context->dbh;
561
    my $dbh = C4::Context->dbh;
563
    my $sth = $dbh->prepare($query);
562
    my $sth = $dbh->prepare($query);
564
    $sth->execute($booksellerid);
563
    $sth->execute($booksellerid);
565
    my $results = $sth->fetchall_arrayref({});
564
    return $sth->fetchall_arrayref({});
566
    $sth->finish;
567
    return $results
568
}
565
}
569
566
570
=head3 GetBasketsInfosByBookseller
567
=head3 GetBasketsInfosByBookseller
Lines 632-640 sub GetBasketsByBasketgroup { Link Here
632
    my $dbh = C4::Context->dbh;
629
    my $dbh = C4::Context->dbh;
633
    my $sth = $dbh->prepare($query);
630
    my $sth = $dbh->prepare($query);
634
    $sth->execute($basketgroupid);
631
    $sth->execute($basketgroupid);
635
    my $results = $sth->fetchall_arrayref({});
632
    return $sth->fetchall_arrayref({});
636
    $sth->finish;
637
    return $results
638
}
633
}
639
634
640
#------------------------------------------------------------#
635
#------------------------------------------------------------#
Lines 746-755 sub ModBasketgroup { Link Here
746
        $sth = $dbh->prepare("UPDATE aqbasket SET basketgroupid=? WHERE basketno=?");
741
        $sth = $dbh->prepare("UPDATE aqbasket SET basketgroupid=? WHERE basketno=?");
747
        foreach my $basketno (@{$basketgroupinfo->{'basketlist'}}) {
742
        foreach my $basketno (@{$basketgroupinfo->{'basketlist'}}) {
748
            $sth->execute($basketgroupinfo->{'id'}, $basketno);
743
            $sth->execute($basketgroupinfo->{'id'}, $basketno);
749
            $sth->finish;
750
        }
744
        }
751
    }
745
    }
752
    $sth->finish;
746
    return;
753
}
747
}
754
748
755
#------------------------------------------------------------#
749
#------------------------------------------------------------#
Lines 775-781 sub DelBasketgroup { Link Here
775
    my $dbh = C4::Context->dbh;
769
    my $dbh = C4::Context->dbh;
776
    my $sth = $dbh->prepare($query);
770
    my $sth = $dbh->prepare($query);
777
    $sth->execute($basketgroupid);
771
    $sth->execute($basketgroupid);
778
    $sth->finish;
772
    return;
779
}
773
}
780
774
781
#------------------------------------------------------------#
775
#------------------------------------------------------------#
Lines 794-806 Returns a reference to the hash containing all infermation about the basketgroup Link Here
794
sub GetBasketgroup {
788
sub GetBasketgroup {
795
    my $basketgroupid = shift;
789
    my $basketgroupid = shift;
796
    die "basketgroup id is required to edit a basketgroup" unless $basketgroupid;
790
    die "basketgroup id is required to edit a basketgroup" unless $basketgroupid;
797
    my $query = "SELECT * FROM aqbasketgroups WHERE id=?";
798
    my $dbh = C4::Context->dbh;
791
    my $dbh = C4::Context->dbh;
799
    my $sth = $dbh->prepare($query);
792
    my $result_set = $dbh->selectall_arrayref(
800
    $sth->execute($basketgroupid);
793
        'SELECT * FROM aqbasketgroups WHERE id=?',
801
    my $result = $sth->fetchrow_hashref;
794
        { Slice => {} },
802
    $sth->finish;
795
        $basketgroupid
803
    return $result
796
    );
797
    return $result_set->[0];    # id is unique
804
}
798
}
805
799
806
#------------------------------------------------------------#
800
#------------------------------------------------------------#
Lines 908-918 sub GetPendingOrders { Link Here
908
    }
902
    }
909
    $strsth .= " group by aqbasket.basketno" if $grouped;
903
    $strsth .= " group by aqbasket.basketno" if $grouped;
910
    $strsth .= " order by aqbasket.basketno";
904
    $strsth .= " order by aqbasket.basketno";
911
    my $sth = $dbh->prepare($strsth);
905
    return $dbh->selectall_arrayref( $strsth, { Slice => {} }, @query_params );
912
    $sth->execute( @query_params );
913
    my $results = $sth->fetchall_arrayref({});
914
    $sth->finish;
915
    return $results;
916
}
906
}
917
907
918
#------------------------------------------------------------#
908
#------------------------------------------------------------#
Lines 950-960 sub GetOrders { Link Here
950
940
951
    $orderby = "biblioitems.publishercode,biblio.title" unless $orderby;
941
    $orderby = "biblioitems.publishercode,biblio.title" unless $orderby;
952
    $query .= " ORDER BY $orderby";
942
    $query .= " ORDER BY $orderby";
953
    my $sth = $dbh->prepare($query);
943
    my $result_set =
954
    $sth->execute($basketno);
944
      $dbh->selectall_arrayref( $query, { Slice => {} }, $basketno );
955
    my $results = $sth->fetchall_arrayref({});
945
    return @{$result_set};
956
    $sth->finish;
957
    return @$results;
958
}
946
}
959
947
960
#------------------------------------------------------------#
948
#------------------------------------------------------------#
Lines 985-995 sub GetOrdersByBiblionumber { Link Here
985
            LEFT JOIN biblioitems      ON biblioitems.biblionumber =biblio.biblionumber
973
            LEFT JOIN biblioitems      ON biblioitems.biblionumber =biblio.biblionumber
986
        WHERE   aqorders.biblionumber=?
974
        WHERE   aqorders.biblionumber=?
987
    ";
975
    ";
988
    my $sth = $dbh->prepare($query);
976
    my $result_set =
989
    $sth->execute($biblionumber);
977
      $dbh->selectall_arrayref( $query, { Slice => {} }, $biblionumber );
990
    my $results = $sth->fetchall_arrayref({});
978
    return @{$result_set};
991
    $sth->finish;
992
    return @$results;
993
}
979
}
994
980
995
#------------------------------------------------------------#
981
#------------------------------------------------------------#
Lines 1016-1026 sub GetOrder { Link Here
1016
        WHERE aqorders.ordernumber=?
1002
        WHERE aqorders.ordernumber=?
1017
1003
1018
    ";
1004
    ";
1019
    my $sth= $dbh->prepare($query);
1005
    my $result_set =
1020
    $sth->execute($ordernumber);
1006
      $dbh->selectall_arrayref( $query, { Slice => {} }, $ordernumber );
1021
    my $data = $sth->fetchrow_hashref;
1007
1022
    $sth->finish;
1008
    # result_set assumed to contain 1 match
1023
    return $data;
1009
    return $result_set->[0];
1024
}
1010
}
1025
1011
1026
=head3 GetLastOrderNotReceivedFromSubscriptionid
1012
=head3 GetLastOrderNotReceivedFromSubscriptionid
Lines 1042-1051 sub GetLastOrderNotReceivedFromSubscriptionid { Link Here
1042
            AND aqorders.datereceived IS NULL
1028
            AND aqorders.datereceived IS NULL
1043
        LIMIT 1
1029
        LIMIT 1
1044
    |;
1030
    |;
1045
    my $sth = $dbh->prepare( $query );
1031
    my $result_set =
1046
    $sth->execute( $subscriptionid );
1032
      $dbh->selectall_arrayref( $query, { Slice => {} }, $subscriptionid );
1047
    my $order = $sth->fetchrow_hashref;
1033
1048
    return $order;
1034
    # result_set assumed to contain 1 match
1035
    return $result_set->[0];
1049
}
1036
}
1050
1037
1051
=head3 GetLastOrderReceivedFromSubscriptionid
1038
=head3 GetLastOrderReceivedFromSubscriptionid
Lines 1076-1085 sub GetLastOrderReceivedFromSubscriptionid { Link Here
1076
        ORDER BY ordernumber DESC
1063
        ORDER BY ordernumber DESC
1077
        LIMIT 1
1064
        LIMIT 1
1078
    |;
1065
    |;
1079
    my $sth = $dbh->prepare( $query );
1066
    my $result_set =
1080
    $sth->execute( $subscriptionid, $subscriptionid );
1067
      $dbh->selectall_arrayref( $query, { Slice => {} }, $subscriptionid );
1081
    my $order = $sth->fetchrow_hashref;
1068
1082
    return $order;
1069
    # result_set assumed to contain 1 match
1070
    return $result_set->[0];
1083
1071
1084
}
1072
}
1085
1073
Lines 1216-1226 sub ModOrder { Link Here
1216
    }
1204
    }
1217
1205
1218
    $query .= "timestamp=NOW()  WHERE  ordernumber=?";
1206
    $query .= "timestamp=NOW()  WHERE  ordernumber=?";
1219
#   push(@params, $specorderinfo{'ordernumber'});
1220
    push(@params, $orderinfo->{'ordernumber'} );
1207
    push(@params, $orderinfo->{'ordernumber'} );
1221
    $sth = $dbh->prepare($query);
1208
    $sth = $dbh->prepare($query);
1222
    $sth->execute(@params);
1209
    $sth->execute(@params);
1223
    $sth->finish;
1210
    return;
1224
}
1211
}
1225
1212
1226
#------------------------------------------------------------#
1213
#------------------------------------------------------------#
Lines 1322-1334 sub ModReceiveOrder { Link Here
1322
                        );
1309
                        );
1323
    }
1310
    }
1324
1311
1325
    my $sth=$dbh->prepare("
1312
    my $result_set = $dbh->selectall_arrayref(
1326
        SELECT * FROM   aqorders
1313
q{SELECT * FROM aqorders WHERE biblionumber=? AND aqorders.ordernumber=?},
1327
        WHERE           biblionumber=? AND aqorders.ordernumber=?");
1314
        { Slice => {} }, $biblionumber, $ordernumber
1315
    );
1328
1316
1329
    $sth->execute($biblionumber,$ordernumber);
1317
    # we assume we have a unique order
1330
    my $order = $sth->fetchrow_hashref();
1318
    my $order = $result_set->[0];
1331
    $sth->finish();
1332
1319
1333
    my $new_ordernumber = $ordernumber;
1320
    my $new_ordernumber = $ordernumber;
1334
    if ( $order->{quantity} > $quantrec ) {
1321
    if ( $order->{quantity} > $quantrec ) {
Lines 1336-1342 sub ModReceiveOrder { Link Here
1336
        # without received items (the quantity is decreased),
1323
        # without received items (the quantity is decreased),
1337
        # the second part is a new order line with quantity=quantityrec
1324
        # the second part is a new order line with quantity=quantityrec
1338
        # (entirely received)
1325
        # (entirely received)
1339
        $sth=$dbh->prepare("
1326
        my $sth=$dbh->prepare("
1340
            UPDATE aqorders
1327
            UPDATE aqorders
1341
            SET quantity = ?
1328
            SET quantity = ?
1342
            WHERE ordernumber = ?
1329
            WHERE ordernumber = ?
Lines 1344-1351 sub ModReceiveOrder { Link Here
1344
1331
1345
        $sth->execute($order->{quantity} - $quantrec, $ordernumber);
1332
        $sth->execute($order->{quantity} - $quantrec, $ordernumber);
1346
1333
1347
        $sth->finish;
1348
1349
        delete $order->{'ordernumber'};
1334
        delete $order->{'ordernumber'};
1350
        $order->{'quantity'} = $quantrec;
1335
        $order->{'quantity'} = $quantrec;
1351
        $order->{'quantityreceived'} = $quantrec;
1336
        $order->{'quantityreceived'} = $quantrec;
Lines 1364-1375 sub ModReceiveOrder { Link Here
1364
            }
1349
            }
1365
        }
1350
        }
1366
    } else {
1351
    } else {
1367
        $sth=$dbh->prepare("update aqorders
1352
        my $sth=$dbh->prepare("update aqorders
1368
                            set quantityreceived=?,datereceived=?,invoiceid=?,
1353
                            set quantityreceived=?,datereceived=?,invoiceid=?,
1369
                                unitprice=?,rrp=?,ecost=?
1354
                                unitprice=?,rrp=?,ecost=?
1370
                            where biblionumber=? and ordernumber=?");
1355
                            where biblionumber=? and ordernumber=?");
1371
        $sth->execute($quantrec,$datereceived,$invoiceid,$cost,$rrp,$ecost,$biblionumber,$ordernumber);
1356
        $sth->execute($quantrec,$datereceived,$invoiceid,$cost,$rrp,$ecost,$biblionumber,$ordernumber);
1372
        $sth->finish;
1373
    }
1357
    }
1374
    return ($datereceived, $new_ordernumber);
1358
    return ($datereceived, $new_ordernumber);
1375
}
1359
}
Lines 1561-1569 sub SearchOrder { Link Here
1561
1545
1562
    my $sth = $dbh->prepare($query);
1546
    my $sth = $dbh->prepare($query);
1563
    $sth->execute(@args);
1547
    $sth->execute(@args);
1564
    my $results = $sth->fetchall_arrayref({});
1548
    return $sth->fetchall_arrayref({});
1565
    $sth->finish;
1566
    return $results;
1567
}
1549
}
1568
1550
1569
#------------------------------------------------------------#
1551
#------------------------------------------------------------#
Lines 1588-1599 sub DelOrder { Link Here
1588
    ";
1570
    ";
1589
    my $sth = $dbh->prepare($query);
1571
    my $sth = $dbh->prepare($query);
1590
    $sth->execute( $bibnum, $ordernumber );
1572
    $sth->execute( $bibnum, $ordernumber );
1591
    $sth->finish;
1592
    my @itemnumbers = GetItemnumbersFromOrder( $ordernumber );
1573
    my @itemnumbers = GetItemnumbersFromOrder( $ordernumber );
1593
    foreach my $itemnumber (@itemnumbers){
1574
    foreach my $itemnumber (@itemnumbers){
1594
    	C4::Items::DelItem( $dbh, $bibnum, $itemnumber );
1575
    	C4::Items::DelItem( $dbh, $bibnum, $itemnumber );
1595
    }
1576
    }
1596
    
1577
    return;
1597
}
1578
}
1598
1579
1599
=head2 FUNCTIONS ABOUT PARCELS
1580
=head2 FUNCTIONS ABOUT PARCELS
Lines 1660-1675 sub GetParcel { Link Here
1660
        }
1641
        }
1661
    }
1642
    }
1662
    $strsth .= " ORDER BY aqbasket.basketno";
1643
    $strsth .= " ORDER BY aqbasket.basketno";
1663
    # ## parcelinformation : $strsth
1664
    my $sth = $dbh->prepare($strsth);
1665
    $sth->execute( @query_params );
1666
    while ( my $data = $sth->fetchrow_hashref ) {
1667
        push( @results, $data );
1668
    }
1669
    # ## countparcelbiblio: scalar(@results)
1670
    $sth->finish;
1671
1644
1672
    return @results;
1645
    my $result_set = $dbh->selectall_arrayref(
1646
        $strsth,
1647
        { Slice => {} },
1648
        @query_params);
1649
1650
    return @{$result_set};
1673
}
1651
}
1674
1652
1675
#------------------------------------------------------------#
1653
#------------------------------------------------------------#
Lines 1757-1764 sub GetParcels { Link Here
1757
1735
1758
    $sth->execute( @query_params );
1736
    $sth->execute( @query_params );
1759
    my $results = $sth->fetchall_arrayref({});
1737
    my $results = $sth->fetchall_arrayref({});
1760
    $sth->finish;
1738
    return @{$results};
1761
    return @$results;
1762
}
1739
}
1763
1740
1764
#------------------------------------------------------------#
1741
#------------------------------------------------------------#
Lines 2119-2132 sub GetContracts { Link Here
2119
            WHERE booksellerid=?
2096
            WHERE booksellerid=?
2120
                AND contractenddate >= CURDATE( )";
2097
                AND contractenddate >= CURDATE( )";
2121
    }
2098
    }
2122
    my $sth = $dbh->prepare($query);
2099
2123
    $sth->execute( $booksellerid );
2100
    my $result_set =
2124
    my @results;
2101
      $dbh->selectall_arrayref( $query, { Slice => {} }, $booksellerid );
2125
    while (my $data = $sth->fetchrow_hashref ) {
2102
    return @{$result_set};
2126
        push(@results, $data);
2127
    }
2128
    $sth->finish;
2129
    return @results;
2130
}
2103
}
2131
2104
2132
#------------------------------------------------------------#
2105
#------------------------------------------------------------#
2133
- 

Return to bug 10789