Lines 453-459
sub CloseBasketgroup {
Link Here
|
453 |
my $dbh = C4::Context->dbh; |
453 |
my $dbh = C4::Context->dbh; |
454 |
my $sth = $dbh->prepare(" |
454 |
my $sth = $dbh->prepare(" |
455 |
UPDATE aqbasketgroups |
455 |
UPDATE aqbasketgroups |
456 |
SET closed=1 |
456 |
SET closeddate=CAST(NOW() AS DATE) |
457 |
WHERE id=? |
457 |
WHERE id=? |
458 |
"); |
458 |
"); |
459 |
$sth->execute($basketgroupno); |
459 |
$sth->execute($basketgroupno); |
Lines 474-480
sub ReOpenBasketgroup {
Link Here
|
474 |
my $dbh = C4::Context->dbh; |
474 |
my $dbh = C4::Context->dbh; |
475 |
my $sth = $dbh->prepare(" |
475 |
my $sth = $dbh->prepare(" |
476 |
UPDATE aqbasketgroups |
476 |
UPDATE aqbasketgroups |
477 |
SET closed=0 |
477 |
SET closeddate=NULL |
478 |
WHERE id=? |
478 |
WHERE id=? |
479 |
"); |
479 |
"); |
480 |
$sth->execute($basketgroupno); |
480 |
$sth->execute($basketgroupno); |
Lines 909-915
$hashref->{'freedeliveryplace'} is the 'freedeliveryplace' field of the basketgr
Link Here
|
909 |
|
909 |
|
910 |
$hashref->{'deliverycomment'} is the 'deliverycomment' field of the basketgroup in the aqbasketgroups table, |
910 |
$hashref->{'deliverycomment'} is the 'deliverycomment' field of the basketgroup in the aqbasketgroups table, |
911 |
|
911 |
|
912 |
$hashref->{'closed'} is the 'closed' field of the aqbasketgroups table, it is false if 0, true otherwise. |
912 |
$hashref->{'closed'} set 'closeddate' if true, or reset 'closeddate' if defined but false. |
913 |
|
913 |
|
914 |
=cut |
914 |
=cut |
915 |
|
915 |
|
Lines 918-933
sub NewBasketgroup {
Link Here
|
918 |
die "booksellerid is required to create a basketgroup" unless $basketgroupinfo->{'booksellerid'}; |
918 |
die "booksellerid is required to create a basketgroup" unless $basketgroupinfo->{'booksellerid'}; |
919 |
my $query = "INSERT INTO aqbasketgroups ("; |
919 |
my $query = "INSERT INTO aqbasketgroups ("; |
920 |
my @params; |
920 |
my @params; |
921 |
foreach my $field (qw(name billingplace deliveryplace freedeliveryplace deliverycomment closed)) { |
921 |
foreach my $field (qw(name billingplace deliveryplace freedeliveryplace deliverycomment)) { |
922 |
if ( defined $basketgroupinfo->{$field} ) { |
922 |
if ( defined $basketgroupinfo->{$field} ) { |
923 |
$query .= "$field, "; |
923 |
$query .= "$field, "; |
924 |
push(@params, $basketgroupinfo->{$field}); |
924 |
push(@params, $basketgroupinfo->{$field}); |
925 |
} |
925 |
} |
926 |
} |
926 |
} |
|
|
927 |
|
928 |
if ($basketgroupinfo->{closed}) { |
929 |
$query .= "closeddate, "; |
930 |
} |
927 |
$query .= "booksellerid) VALUES ("; |
931 |
$query .= "booksellerid) VALUES ("; |
928 |
foreach (@params) { |
932 |
foreach (@params) { |
929 |
$query .= "?, "; |
933 |
$query .= "?, "; |
930 |
} |
934 |
} |
|
|
935 |
if ($basketgroupinfo->{closed}) { |
936 |
$query .= "CAST(NOW() AS DATE), "; |
937 |
} |
931 |
$query .= "?)"; |
938 |
$query .= "?)"; |
932 |
push(@params, $basketgroupinfo->{'booksellerid'}); |
939 |
push(@params, $basketgroupinfo->{'booksellerid'}); |
933 |
my $dbh = C4::Context->dbh; |
940 |
my $dbh = C4::Context->dbh; |
Lines 966-972
$hashref->{'freedeliveryplace'} is the 'freedeliveryplace' field of the basketgr
Link Here
|
966 |
|
973 |
|
967 |
$hashref->{'deliverycomment'} is the 'deliverycomment' field of the basketgroup in the aqbasketgroups table, |
974 |
$hashref->{'deliverycomment'} is the 'deliverycomment' field of the basketgroup in the aqbasketgroups table, |
968 |
|
975 |
|
969 |
$hashref->{'closed'} is the 'closed' field of the aqbasketgroups table, it is false if 0, true otherwise. |
976 |
$hashref->{'closed'} set 'closeddate' if true, or reset 'closeddate' if defined but false. |
970 |
|
977 |
|
971 |
=cut |
978 |
=cut |
972 |
|
979 |
|
Lines 976-982
sub ModBasketgroup {
Link Here
|
976 |
my $dbh = C4::Context->dbh; |
983 |
my $dbh = C4::Context->dbh; |
977 |
my $query = "UPDATE aqbasketgroups SET "; |
984 |
my $query = "UPDATE aqbasketgroups SET "; |
978 |
my @params; |
985 |
my @params; |
979 |
foreach my $field (qw(name billingplace deliveryplace freedeliveryplace deliverycomment closed)) { |
986 |
|
|
|
987 |
if ($basketgroupinfo->{closed}) { |
988 |
$query .= "closeddate = IF(closeddate IS NULL, CAST(NOW() AS DATE), closeddate), "; |
989 |
} elsif (defined $basketgroupinfo->{closed}) { |
990 |
$query .= "closeddate = NULL, "; |
991 |
} |
992 |
|
993 |
foreach my $field (qw(name billingplace deliveryplace freedeliveryplace deliverycomment)) { |
980 |
if ( defined $basketgroupinfo->{$field} ) { |
994 |
if ( defined $basketgroupinfo->{$field} ) { |
981 |
$query .= "$field=?, "; |
995 |
$query .= "$field=?, "; |
982 |
push(@params, $basketgroupinfo->{$field}); |
996 |
push(@params, $basketgroupinfo->{$field}); |
Lines 1049-1055
sub GetBasketgroup {
Link Here
|
1049 |
{ Slice => {} }, |
1063 |
{ Slice => {} }, |
1050 |
$basketgroupid |
1064 |
$basketgroupid |
1051 |
); |
1065 |
); |
1052 |
return $result_set->[0]; # id is unique |
1066 |
my $basketgroup = $result_set->[0]; # id is unique |
|
|
1067 |
$basketgroup->{closed} = defined($basketgroup->{closeddate}) ? 1 : 0; |
1068 |
return $basketgroup; |
1053 |
} |
1069 |
} |
1054 |
|
1070 |
|
1055 |
#------------------------------------------------------------# |
1071 |
#------------------------------------------------------------# |
Lines 1069-1075
sub GetBasketgroups {
Link Here
|
1069 |
my $dbh = C4::Context->dbh; |
1085 |
my $dbh = C4::Context->dbh; |
1070 |
my $sth = $dbh->prepare($query); |
1086 |
my $sth = $dbh->prepare($query); |
1071 |
$sth->execute($booksellerid); |
1087 |
$sth->execute($booksellerid); |
1072 |
return $sth->fetchall_arrayref({}); |
1088 |
my $basketgroups = $sth->fetchall_arrayref({}); |
|
|
1089 |
foreach my $bg (@$basketgroups) { |
1090 |
$bg->{closed} = defined($bg->{closeddate}) ? 1 : 0; |
1091 |
} |
1092 |
return $basketgroups; |
1073 |
} |
1093 |
} |
1074 |
|
1094 |
|
1075 |
#------------------------------------------------------------# |
1095 |
#------------------------------------------------------------# |