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

(-)a/C4/Acquisition.pm (-10 / +15 lines)
Lines 476-483 sub CloseBasketgroup { Link Here
476
    my $dbh        = C4::Context->dbh;
476
    my $dbh        = C4::Context->dbh;
477
    my $sth = $dbh->prepare("
477
    my $sth = $dbh->prepare("
478
        UPDATE aqbasketgroups
478
        UPDATE aqbasketgroups
479
        SET    closed=1,
479
        SET closeddate=CAST(NOW() AS DATE)
480
               closeddate=CAST(NOW() AS DATE)
481
        WHERE  id=?
480
        WHERE  id=?
482
    ");
481
    ");
483
    $sth->execute($basketgroupno);
482
    $sth->execute($basketgroupno);
Lines 498-504 sub ReOpenBasketgroup { Link Here
498
    my $dbh        = C4::Context->dbh;
497
    my $dbh        = C4::Context->dbh;
499
    my $sth = $dbh->prepare("
498
    my $sth = $dbh->prepare("
500
        UPDATE aqbasketgroups
499
        UPDATE aqbasketgroups
501
        SET    closed=0, closeddate=NULL
500
        SET    closeddate=NULL
502
        WHERE  id=?
501
        WHERE  id=?
503
    ");
502
    ");
504
    $sth->execute($basketgroupno);
503
    $sth->execute($basketgroupno);
Lines 923-929 $hashref->{'freedeliveryplace'} is the 'freedeliveryplace' field of the basketgr Link Here
923
922
924
$hashref->{'deliverycomment'} is the 'deliverycomment' field of the basketgroup in the aqbasketgroups table,
923
$hashref->{'deliverycomment'} is the 'deliverycomment' field of the basketgroup in the aqbasketgroups table,
925
924
926
$hashref->{'closed'} is the 'closed' field of the aqbasketgroups table, it is false if 0, true otherwise.
925
$hashref->{'closed'} set 'closeddate' if true, or reset 'closeddate' if defined but false.
927
926
928
=cut
927
=cut
929
928
Lines 932-938 sub NewBasketgroup { Link Here
932
    die "booksellerid is required to create a basketgroup" unless $basketgroupinfo->{'booksellerid'};
931
    die "booksellerid is required to create a basketgroup" unless $basketgroupinfo->{'booksellerid'};
933
    my $query = "INSERT INTO aqbasketgroups (";
932
    my $query = "INSERT INTO aqbasketgroups (";
934
    my @params;
933
    my @params;
935
    foreach my $field (qw(name billingplace deliveryplace freedeliveryplace deliverycomment closed)) {
934
    foreach my $field (qw(name billingplace deliveryplace freedeliveryplace deliverycomment)) {
936
        if ( defined $basketgroupinfo->{$field} ) {
935
        if ( defined $basketgroupinfo->{$field} ) {
937
            $query .= "$field, ";
936
            $query .= "$field, ";
938
            push(@params, $basketgroupinfo->{$field});
937
            push(@params, $basketgroupinfo->{$field});
Lines 987-993 $hashref->{'freedeliveryplace'} is the 'freedeliveryplace' field of the basketgr Link Here
987
986
988
$hashref->{'deliverycomment'} is the 'deliverycomment' field of the basketgroup in the aqbasketgroups table,
987
$hashref->{'deliverycomment'} is the 'deliverycomment' field of the basketgroup in the aqbasketgroups table,
989
988
990
$hashref->{'closed'} is the 'closed' field of the aqbasketgroups table, it is false if 0, true otherwise.
989
$hashref->{'closed'} set 'closeddate' if true, or reset 'closeddate' if defined but false.
991
990
992
=cut
991
=cut
993
992
Lines 999-1010 sub ModBasketgroup { Link Here
999
    my @params;
998
    my @params;
1000
999
1001
    if ($basketgroupinfo->{closed}) {
1000
    if ($basketgroupinfo->{closed}) {
1002
        $query .= "closeddate = IF(closed = 0, CAST(NOW() AS DATE), closeddate), ";
1001
        $query .= "closeddate = IF(closeddate IS NULL, CAST(NOW() AS DATE), closeddate), ";
1003
    } elsif (defined $basketgroupinfo->{closed}) {
1002
    } elsif (defined $basketgroupinfo->{closed}) {
1004
        $query .= "closeddate = NULL, ";
1003
        $query .= "closeddate = NULL, ";
1005
    }
1004
    }
1006
1005
1007
    foreach my $field (qw(name billingplace deliveryplace freedeliveryplace deliverycomment closed)) {
1006
    foreach my $field (qw(name billingplace deliveryplace freedeliveryplace deliverycomment)) {
1008
        if ( defined $basketgroupinfo->{$field} ) {
1007
        if ( defined $basketgroupinfo->{$field} ) {
1009
            $query .= "$field=?, ";
1008
            $query .= "$field=?, ";
1010
            push(@params, $basketgroupinfo->{$field});
1009
            push(@params, $basketgroupinfo->{$field});
Lines 1077-1083 sub GetBasketgroup { Link Here
1077
        { Slice => {} },
1076
        { Slice => {} },
1078
        $basketgroupid
1077
        $basketgroupid
1079
    );
1078
    );
1080
    return $result_set->[0];    # id is unique
1079
    my $basketgroup = $result_set->[0];    # id is unique
1080
    $basketgroup->{closed} = defined($basketgroup->{closeddate}) ? 1 : 0;
1081
    return $basketgroup;
1081
}
1082
}
1082
1083
1083
#------------------------------------------------------------#
1084
#------------------------------------------------------------#
Lines 1097-1103 sub GetBasketgroups { Link Here
1097
    my $dbh = C4::Context->dbh;
1098
    my $dbh = C4::Context->dbh;
1098
    my $sth = $dbh->prepare($query);
1099
    my $sth = $dbh->prepare($query);
1099
    $sth->execute($booksellerid);
1100
    $sth->execute($booksellerid);
1100
    return $sth->fetchall_arrayref({});
1101
    my $basketgroups = $sth->fetchall_arrayref({});
1102
    foreach my $bg (@$basketgroups) {
1103
        $bg->{closed} = defined($bg->{closeddate}) ? 1 : 0;
1104
    }
1105
    return $basketgroups;
1101
}
1106
}
1102
1107
1103
#------------------------------------------------------------#
1108
#------------------------------------------------------------#
(-)a/installer/data/mysql/atomicupdate/Bug-11708-remove-column-aqbasketgroups-closed.sql (+3 lines)
Line 0 Link Here
1
UPDATE aqbasketgroups SET closeddate = CAST(NOW() AS DATE) WHERE closed = 1;
2
3
ALTER TABLE aqbasketgroups DROP COLUMN closed;
(-)a/installer/data/mysql/kohastructure.sql (-3 / +1 lines)
Lines 2837-2844 DROP TABLE IF EXISTS `aqbasketgroups`; Link Here
2837
CREATE TABLE `aqbasketgroups` (
2837
CREATE TABLE `aqbasketgroups` (
2838
  `id` int(11) NOT NULL auto_increment,
2838
  `id` int(11) NOT NULL auto_increment,
2839
  `name` varchar(50) default NULL,
2839
  `name` varchar(50) default NULL,
2840
  `closed` tinyint(1) default NULL,
2840
  `closeddate` date default NULL,
2841
  closeddate date default NULL, -- the date the basketgroup was closed
2842
  `booksellerid` int(11) NOT NULL,
2841
  `booksellerid` int(11) NOT NULL,
2843
  `deliveryplace` varchar(10) default NULL,
2842
  `deliveryplace` varchar(10) default NULL,
2844
  `freedeliveryplace` text default NULL,
2843
  `freedeliveryplace` text default NULL,
2845
- 

Return to bug 11708