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

(-)a/C4/Acquisition.pm (-10 / +15 lines)
Lines 413-420 sub CloseBasketgroup { Link Here
413
    my $dbh        = C4::Context->dbh;
413
    my $dbh        = C4::Context->dbh;
414
    my $sth = $dbh->prepare("
414
    my $sth = $dbh->prepare("
415
        UPDATE aqbasketgroups
415
        UPDATE aqbasketgroups
416
        SET    closed=1,
416
        SET closeddate=CAST(NOW() AS DATE)
417
               closeddate=CAST(NOW() AS DATE)
418
        WHERE  id=?
417
        WHERE  id=?
419
    ");
418
    ");
420
    $sth->execute($basketgroupno);
419
    $sth->execute($basketgroupno);
Lines 435-441 sub ReOpenBasketgroup { Link Here
435
    my $dbh        = C4::Context->dbh;
434
    my $dbh        = C4::Context->dbh;
436
    my $sth = $dbh->prepare("
435
    my $sth = $dbh->prepare("
437
        UPDATE aqbasketgroups
436
        UPDATE aqbasketgroups
438
        SET    closed=0, closeddate=NULL
437
        SET    closeddate=NULL
439
        WHERE  id=?
438
        WHERE  id=?
440
    ");
439
    ");
441
    $sth->execute($basketgroupno);
440
    $sth->execute($basketgroupno);
Lines 852-858 $hashref->{'freedeliveryplace'} is the 'freedeliveryplace' field of the basketgr Link Here
852
851
853
$hashref->{'deliverycomment'} is the 'deliverycomment' field of the basketgroup in the aqbasketgroups table,
852
$hashref->{'deliverycomment'} is the 'deliverycomment' field of the basketgroup in the aqbasketgroups table,
854
853
855
$hashref->{'closed'} is the 'closed' field of the aqbasketgroups table, it is false if 0, true otherwise.
854
$hashref->{'closed'} set 'closeddate' if true, or reset 'closeddate' if defined but false.
856
855
857
=cut
856
=cut
858
857
Lines 861-867 sub NewBasketgroup { Link Here
861
    die "booksellerid is required to create a basketgroup" unless $basketgroupinfo->{'booksellerid'};
860
    die "booksellerid is required to create a basketgroup" unless $basketgroupinfo->{'booksellerid'};
862
    my $query = "INSERT INTO aqbasketgroups (";
861
    my $query = "INSERT INTO aqbasketgroups (";
863
    my @params;
862
    my @params;
864
    foreach my $field (qw(name billingplace deliveryplace freedeliveryplace deliverycomment closed)) {
863
    foreach my $field (qw(name billingplace deliveryplace freedeliveryplace deliverycomment)) {
865
        if ( defined $basketgroupinfo->{$field} ) {
864
        if ( defined $basketgroupinfo->{$field} ) {
866
            $query .= "$field, ";
865
            $query .= "$field, ";
867
            push(@params, $basketgroupinfo->{$field});
866
            push(@params, $basketgroupinfo->{$field});
Lines 916-922 $hashref->{'freedeliveryplace'} is the 'freedeliveryplace' field of the basketgr Link Here
916
915
917
$hashref->{'deliverycomment'} is the 'deliverycomment' field of the basketgroup in the aqbasketgroups table,
916
$hashref->{'deliverycomment'} is the 'deliverycomment' field of the basketgroup in the aqbasketgroups table,
918
917
919
$hashref->{'closed'} is the 'closed' field of the aqbasketgroups table, it is false if 0, true otherwise.
918
$hashref->{'closed'} set 'closeddate' if true, or reset 'closeddate' if defined but false.
920
919
921
=cut
920
=cut
922
921
Lines 928-939 sub ModBasketgroup { Link Here
928
    my @params;
927
    my @params;
929
928
930
    if ($basketgroupinfo->{closed}) {
929
    if ($basketgroupinfo->{closed}) {
931
        $query .= "closeddate = IF(closed = 0, CAST(NOW() AS DATE), closeddate), ";
930
        $query .= "closeddate = IF(closeddate IS NULL, CAST(NOW() AS DATE), closeddate), ";
932
    } elsif (defined $basketgroupinfo->{closed}) {
931
    } elsif (defined $basketgroupinfo->{closed}) {
933
        $query .= "closeddate = NULL, ";
932
        $query .= "closeddate = NULL, ";
934
    }
933
    }
935
934
936
    foreach my $field (qw(name billingplace deliveryplace freedeliveryplace deliverycomment closed)) {
935
    foreach my $field (qw(name billingplace deliveryplace freedeliveryplace deliverycomment)) {
937
        if ( defined $basketgroupinfo->{$field} ) {
936
        if ( defined $basketgroupinfo->{$field} ) {
938
            $query .= "$field=?, ";
937
            $query .= "$field=?, ";
939
            push(@params, $basketgroupinfo->{$field});
938
            push(@params, $basketgroupinfo->{$field});
Lines 1006-1012 sub GetBasketgroup { Link Here
1006
        { Slice => {} },
1005
        { Slice => {} },
1007
        $basketgroupid
1006
        $basketgroupid
1008
    );
1007
    );
1009
    return $result_set->[0];    # id is unique
1008
    my $basketgroup = $result_set->[0];    # id is unique
1009
    $basketgroup->{closed} = defined($basketgroup->{closeddate}) ? 1 : 0;
1010
    return $basketgroup;
1010
}
1011
}
1011
1012
1012
#------------------------------------------------------------#
1013
#------------------------------------------------------------#
Lines 1026-1032 sub GetBasketgroups { Link Here
1026
    my $dbh = C4::Context->dbh;
1027
    my $dbh = C4::Context->dbh;
1027
    my $sth = $dbh->prepare($query);
1028
    my $sth = $dbh->prepare($query);
1028
    $sth->execute($booksellerid);
1029
    $sth->execute($booksellerid);
1029
    return $sth->fetchall_arrayref({});
1030
    my $basketgroups = $sth->fetchall_arrayref({});
1031
    foreach my $bg (@$basketgroups) {
1032
        $bg->{closed} = defined($bg->{closeddate}) ? 1 : 0;
1033
    }
1034
    return $basketgroups;
1030
}
1035
}
1031
1036
1032
#------------------------------------------------------------#
1037
#------------------------------------------------------------#
(-)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 2851-2858 DROP TABLE IF EXISTS `aqbasketgroups`; Link Here
2851
CREATE TABLE `aqbasketgroups` (
2851
CREATE TABLE `aqbasketgroups` (
2852
  `id` int(11) NOT NULL auto_increment,
2852
  `id` int(11) NOT NULL auto_increment,
2853
  `name` varchar(50) default NULL,
2853
  `name` varchar(50) default NULL,
2854
  `closed` tinyint(1) default NULL,
2854
  `closeddate` date default NULL,
2855
  closeddate date default NULL, -- the date the basketgroup was closed
2856
  `booksellerid` int(11) NOT NULL,
2855
  `booksellerid` int(11) NOT NULL,
2857
  `deliveryplace` varchar(10) default NULL,
2856
  `deliveryplace` varchar(10) default NULL,
2858
  `freedeliveryplace` text default NULL,
2857
  `freedeliveryplace` text default NULL,
2859
- 

Return to bug 11708