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

(-)a/C4/Acquisition.pm (-10 / +15 lines)
Lines 429-436 sub CloseBasketgroup { Link Here
429
    my $dbh        = C4::Context->dbh;
429
    my $dbh        = C4::Context->dbh;
430
    my $sth = $dbh->prepare("
430
    my $sth = $dbh->prepare("
431
        UPDATE aqbasketgroups
431
        UPDATE aqbasketgroups
432
        SET    closed=1,
432
        SET closeddate=CAST(NOW() AS DATE)
433
               closeddate=CAST(NOW() AS DATE)
434
        WHERE  id=?
433
        WHERE  id=?
435
    ");
434
    ");
436
    $sth->execute($basketgroupno);
435
    $sth->execute($basketgroupno);
Lines 451-457 sub ReOpenBasketgroup { Link Here
451
    my $dbh        = C4::Context->dbh;
450
    my $dbh        = C4::Context->dbh;
452
    my $sth = $dbh->prepare("
451
    my $sth = $dbh->prepare("
453
        UPDATE aqbasketgroups
452
        UPDATE aqbasketgroups
454
        SET    closed=0, closeddate=NULL
453
        SET    closeddate=NULL
455
        WHERE  id=?
454
        WHERE  id=?
456
    ");
455
    ");
457
    $sth->execute($basketgroupno);
456
    $sth->execute($basketgroupno);
Lines 868-874 $hashref->{'freedeliveryplace'} is the 'freedeliveryplace' field of the basketgr Link Here
868
867
869
$hashref->{'deliverycomment'} is the 'deliverycomment' field of the basketgroup in the aqbasketgroups table,
868
$hashref->{'deliverycomment'} is the 'deliverycomment' field of the basketgroup in the aqbasketgroups table,
870
869
871
$hashref->{'closed'} is the 'closed' field of the aqbasketgroups table, it is false if 0, true otherwise.
870
$hashref->{'closed'} set 'closeddate' if true, or reset 'closeddate' if defined but false.
872
871
873
=cut
872
=cut
874
873
Lines 877-883 sub NewBasketgroup { Link Here
877
    die "booksellerid is required to create a basketgroup" unless $basketgroupinfo->{'booksellerid'};
876
    die "booksellerid is required to create a basketgroup" unless $basketgroupinfo->{'booksellerid'};
878
    my $query = "INSERT INTO aqbasketgroups (";
877
    my $query = "INSERT INTO aqbasketgroups (";
879
    my @params;
878
    my @params;
880
    foreach my $field (qw(name billingplace deliveryplace freedeliveryplace deliverycomment closed)) {
879
    foreach my $field (qw(name billingplace deliveryplace freedeliveryplace deliverycomment)) {
881
        if ( defined $basketgroupinfo->{$field} ) {
880
        if ( defined $basketgroupinfo->{$field} ) {
882
            $query .= "$field, ";
881
            $query .= "$field, ";
883
            push(@params, $basketgroupinfo->{$field});
882
            push(@params, $basketgroupinfo->{$field});
Lines 932-938 $hashref->{'freedeliveryplace'} is the 'freedeliveryplace' field of the basketgr Link Here
932
931
933
$hashref->{'deliverycomment'} is the 'deliverycomment' field of the basketgroup in the aqbasketgroups table,
932
$hashref->{'deliverycomment'} is the 'deliverycomment' field of the basketgroup in the aqbasketgroups table,
934
933
935
$hashref->{'closed'} is the 'closed' field of the aqbasketgroups table, it is false if 0, true otherwise.
934
$hashref->{'closed'} set 'closeddate' if true, or reset 'closeddate' if defined but false.
936
935
937
=cut
936
=cut
938
937
Lines 944-955 sub ModBasketgroup { Link Here
944
    my @params;
943
    my @params;
945
944
946
    if ($basketgroupinfo->{closed}) {
945
    if ($basketgroupinfo->{closed}) {
947
        $query .= "closeddate = IF(closed = 0, CAST(NOW() AS DATE), closeddate), ";
946
        $query .= "closeddate = IF(closeddate IS NULL, CAST(NOW() AS DATE), closeddate), ";
948
    } elsif (defined $basketgroupinfo->{closed}) {
947
    } elsif (defined $basketgroupinfo->{closed}) {
949
        $query .= "closeddate = NULL, ";
948
        $query .= "closeddate = NULL, ";
950
    }
949
    }
951
950
952
    foreach my $field (qw(name billingplace deliveryplace freedeliveryplace deliverycomment closed)) {
951
    foreach my $field (qw(name billingplace deliveryplace freedeliveryplace deliverycomment)) {
953
        if ( defined $basketgroupinfo->{$field} ) {
952
        if ( defined $basketgroupinfo->{$field} ) {
954
            $query .= "$field=?, ";
953
            $query .= "$field=?, ";
955
            push(@params, $basketgroupinfo->{$field});
954
            push(@params, $basketgroupinfo->{$field});
Lines 1022-1028 sub GetBasketgroup { Link Here
1022
        { Slice => {} },
1021
        { Slice => {} },
1023
        $basketgroupid
1022
        $basketgroupid
1024
    );
1023
    );
1025
    return $result_set->[0];    # id is unique
1024
    my $basketgroup = $result_set->[0];    # id is unique
1025
    $basketgroup->{closed} = defined($basketgroup->{closeddate}) ? 1 : 0;
1026
    return $basketgroup;
1026
}
1027
}
1027
1028
1028
#------------------------------------------------------------#
1029
#------------------------------------------------------------#
Lines 1042-1048 sub GetBasketgroups { Link Here
1042
    my $dbh = C4::Context->dbh;
1043
    my $dbh = C4::Context->dbh;
1043
    my $sth = $dbh->prepare($query);
1044
    my $sth = $dbh->prepare($query);
1044
    $sth->execute($booksellerid);
1045
    $sth->execute($booksellerid);
1045
    return $sth->fetchall_arrayref({});
1046
    my $basketgroups = $sth->fetchall_arrayref({});
1047
    foreach my $bg (@$basketgroups) {
1048
        $bg->{closed} = defined($bg->{closeddate}) ? 1 : 0;
1049
    }
1050
    return $basketgroups;
1046
}
1051
}
1047
1052
1048
#------------------------------------------------------------#
1053
#------------------------------------------------------------#
(-)a/installer/data/mysql/updatedatabase.pl (-2 / +10 lines)
Lines 9738-9744 if (CheckVersion($DBversion)) { Link Here
9738
        ALTER TABLE aqbasketgroups
9738
        ALTER TABLE aqbasketgroups
9739
        ADD COLUMN closeddate DATE DEFAULT NULL AFTER closed
9739
        ADD COLUMN closeddate DATE DEFAULT NULL AFTER closed
9740
    |);
9740
    |);
9741
    print "Upgrade to $DBversion done (Bug 11708: Add aqbasketgroups.closeddate)\n";
9741
    $dbh->do(q|
9742
        UPDATE aqbasketgroups
9743
        SET closeddate = CAST(NOW() AS DATE)
9744
        WHERE closed = 1
9745
    |);
9746
    $dbh->do(q|
9747
        ALTER TABLE aqbasketgroups
9748
        DROP COLUMN closed
9749
    |);
9750
    print "Upgrade to $DBversion done (Bug 11708: Add aqbasketgroups.closeddate and remove aqbasketgroups.closed)\n";
9742
    SetVersion($DBversion);
9751
    SetVersion($DBversion);
9743
}
9752
}
9744
9753
9745
- 

Return to bug 11708