|
Lines 457-463
sub CloseBasketgroup {
Link Here
|
| 457 |
my $dbh = C4::Context->dbh; |
457 |
my $dbh = C4::Context->dbh; |
| 458 |
my $sth = $dbh->prepare(" |
458 |
my $sth = $dbh->prepare(" |
| 459 |
UPDATE aqbasketgroups |
459 |
UPDATE aqbasketgroups |
| 460 |
SET closed=1 |
460 |
SET closeddate=CAST(NOW() AS DATE) |
| 461 |
WHERE id=? |
461 |
WHERE id=? |
| 462 |
"); |
462 |
"); |
| 463 |
$sth->execute($basketgroupno); |
463 |
$sth->execute($basketgroupno); |
|
Lines 478-484
sub ReOpenBasketgroup {
Link Here
|
| 478 |
my $dbh = C4::Context->dbh; |
478 |
my $dbh = C4::Context->dbh; |
| 479 |
my $sth = $dbh->prepare(" |
479 |
my $sth = $dbh->prepare(" |
| 480 |
UPDATE aqbasketgroups |
480 |
UPDATE aqbasketgroups |
| 481 |
SET closed=0 |
481 |
SET closeddate=NULL |
| 482 |
WHERE id=? |
482 |
WHERE id=? |
| 483 |
"); |
483 |
"); |
| 484 |
$sth->execute($basketgroupno); |
484 |
$sth->execute($basketgroupno); |
|
Lines 914-920
$hashref->{'freedeliveryplace'} is the 'freedeliveryplace' field of the basketgr
Link Here
|
| 914 |
|
914 |
|
| 915 |
$hashref->{'deliverycomment'} is the 'deliverycomment' field of the basketgroup in the aqbasketgroups table, |
915 |
$hashref->{'deliverycomment'} is the 'deliverycomment' field of the basketgroup in the aqbasketgroups table, |
| 916 |
|
916 |
|
| 917 |
$hashref->{'closed'} is the 'closed' field of the aqbasketgroups table, it is false if 0, true otherwise. |
917 |
$hashref->{'closed'} set 'closeddate' if true, or reset 'closeddate' if defined but false. |
| 918 |
|
918 |
|
| 919 |
=cut |
919 |
=cut |
| 920 |
|
920 |
|
|
Lines 923-938
sub NewBasketgroup {
Link Here
|
| 923 |
die "booksellerid is required to create a basketgroup" unless $basketgroupinfo->{'booksellerid'}; |
923 |
die "booksellerid is required to create a basketgroup" unless $basketgroupinfo->{'booksellerid'}; |
| 924 |
my $query = "INSERT INTO aqbasketgroups ("; |
924 |
my $query = "INSERT INTO aqbasketgroups ("; |
| 925 |
my @params; |
925 |
my @params; |
| 926 |
foreach my $field (qw(name billingplace deliveryplace freedeliveryplace deliverycomment closed)) { |
926 |
foreach my $field (qw(name billingplace deliveryplace freedeliveryplace deliverycomment)) { |
| 927 |
if ( defined $basketgroupinfo->{$field} ) { |
927 |
if ( defined $basketgroupinfo->{$field} ) { |
| 928 |
$query .= "$field, "; |
928 |
$query .= "$field, "; |
| 929 |
push(@params, $basketgroupinfo->{$field}); |
929 |
push(@params, $basketgroupinfo->{$field}); |
| 930 |
} |
930 |
} |
| 931 |
} |
931 |
} |
|
|
932 |
|
| 933 |
if ($basketgroupinfo->{closed}) { |
| 934 |
$query .= "closeddate, "; |
| 935 |
} |
| 932 |
$query .= "booksellerid) VALUES ("; |
936 |
$query .= "booksellerid) VALUES ("; |
| 933 |
foreach (@params) { |
937 |
foreach (@params) { |
| 934 |
$query .= "?, "; |
938 |
$query .= "?, "; |
| 935 |
} |
939 |
} |
|
|
940 |
if ($basketgroupinfo->{closed}) { |
| 941 |
$query .= "CAST(NOW() AS DATE), "; |
| 942 |
} |
| 936 |
$query .= "?)"; |
943 |
$query .= "?)"; |
| 937 |
push(@params, $basketgroupinfo->{'booksellerid'}); |
944 |
push(@params, $basketgroupinfo->{'booksellerid'}); |
| 938 |
my $dbh = C4::Context->dbh; |
945 |
my $dbh = C4::Context->dbh; |
|
Lines 971-977
$hashref->{'freedeliveryplace'} is the 'freedeliveryplace' field of the basketgr
Link Here
|
| 971 |
|
978 |
|
| 972 |
$hashref->{'deliverycomment'} is the 'deliverycomment' field of the basketgroup in the aqbasketgroups table, |
979 |
$hashref->{'deliverycomment'} is the 'deliverycomment' field of the basketgroup in the aqbasketgroups table, |
| 973 |
|
980 |
|
| 974 |
$hashref->{'closed'} is the 'closed' field of the aqbasketgroups table, it is false if 0, true otherwise. |
981 |
$hashref->{'closed'} set 'closeddate' if true, or reset 'closeddate' if defined but false. |
| 975 |
|
982 |
|
| 976 |
=cut |
983 |
=cut |
| 977 |
|
984 |
|
|
Lines 981-987
sub ModBasketgroup {
Link Here
|
| 981 |
my $dbh = C4::Context->dbh; |
988 |
my $dbh = C4::Context->dbh; |
| 982 |
my $query = "UPDATE aqbasketgroups SET "; |
989 |
my $query = "UPDATE aqbasketgroups SET "; |
| 983 |
my @params; |
990 |
my @params; |
| 984 |
foreach my $field (qw(name billingplace deliveryplace freedeliveryplace deliverycomment closed)) { |
991 |
|
|
|
992 |
if ($basketgroupinfo->{closed}) { |
| 993 |
$query .= "closeddate = IF(closeddate IS NULL, CAST(NOW() AS DATE), closeddate), "; |
| 994 |
} elsif (defined $basketgroupinfo->{closed}) { |
| 995 |
$query .= "closeddate = NULL, "; |
| 996 |
} |
| 997 |
|
| 998 |
foreach my $field (qw(name billingplace deliveryplace freedeliveryplace deliverycomment)) { |
| 985 |
if ( defined $basketgroupinfo->{$field} ) { |
999 |
if ( defined $basketgroupinfo->{$field} ) { |
| 986 |
$query .= "$field=?, "; |
1000 |
$query .= "$field=?, "; |
| 987 |
push(@params, $basketgroupinfo->{$field}); |
1001 |
push(@params, $basketgroupinfo->{$field}); |
|
Lines 1054-1060
sub GetBasketgroup {
Link Here
|
| 1054 |
{ Slice => {} }, |
1068 |
{ Slice => {} }, |
| 1055 |
$basketgroupid |
1069 |
$basketgroupid |
| 1056 |
); |
1070 |
); |
| 1057 |
return $result_set->[0]; # id is unique |
1071 |
my $basketgroup = $result_set->[0]; # id is unique |
|
|
1072 |
$basketgroup->{closed} = defined($basketgroup->{closeddate}) ? 1 : 0; |
| 1073 |
return $basketgroup; |
| 1058 |
} |
1074 |
} |
| 1059 |
|
1075 |
|
| 1060 |
#------------------------------------------------------------# |
1076 |
#------------------------------------------------------------# |
|
Lines 1074-1080
sub GetBasketgroups {
Link Here
|
| 1074 |
my $dbh = C4::Context->dbh; |
1090 |
my $dbh = C4::Context->dbh; |
| 1075 |
my $sth = $dbh->prepare($query); |
1091 |
my $sth = $dbh->prepare($query); |
| 1076 |
$sth->execute($booksellerid); |
1092 |
$sth->execute($booksellerid); |
| 1077 |
return $sth->fetchall_arrayref({}); |
1093 |
my $basketgroups = $sth->fetchall_arrayref({}); |
|
|
1094 |
foreach my $bg (@$basketgroups) { |
| 1095 |
$bg->{closed} = defined($bg->{closeddate}) ? 1 : 0; |
| 1096 |
} |
| 1097 |
return $basketgroups; |
| 1078 |
} |
1098 |
} |
| 1079 |
|
1099 |
|
| 1080 |
#------------------------------------------------------------# |
1100 |
#------------------------------------------------------------# |