Lines 81-86
BEGIN {
Link Here
|
81 |
|
81 |
|
82 |
&AddClaim |
82 |
&AddClaim |
83 |
&GetBiblioCountByBasketno |
83 |
&GetBiblioCountByBasketno |
|
|
84 |
|
85 |
&GetOrderUsers |
86 |
&ModOrderUsers |
87 |
&NotifyOrderUsers |
84 |
); |
88 |
); |
85 |
} |
89 |
} |
86 |
|
90 |
|
Lines 1476-1481
q{SELECT * FROM aqorders WHERE biblionumber=? AND aqorders.ordernumber=?},
Link Here
|
1476 |
$biblionumber, |
1480 |
$biblionumber, |
1477 |
$ordernumber |
1481 |
$ordernumber |
1478 |
); |
1482 |
); |
|
|
1483 |
|
1484 |
# All items have been received, sent a notification to users |
1485 |
NotifyOrderUsers( $ordernumber ); |
1486 |
|
1479 |
} |
1487 |
} |
1480 |
return ($datereceived, $new_ordernumber); |
1488 |
return ($datereceived, $new_ordernumber); |
1481 |
} |
1489 |
} |
Lines 2883-2888
sub GetBiblioCountByBasketno {
Link Here
|
2883 |
return $sth->fetchrow; |
2891 |
return $sth->fetchrow; |
2884 |
} |
2892 |
} |
2885 |
|
2893 |
|
|
|
2894 |
|
2895 |
=head3 GetOrderUsers |
2896 |
|
2897 |
$order_users_ids = &GetOrderUsers($ordernumber); |
2898 |
|
2899 |
Returns a list of all borrowernumbers that are in order users list |
2900 |
|
2901 |
=cut |
2902 |
|
2903 |
sub GetOrderUsers { |
2904 |
my ($ordernumber) = @_; |
2905 |
|
2906 |
return unless $ordernumber; |
2907 |
|
2908 |
my $query = q| |
2909 |
SELECT borrowernumber |
2910 |
FROM aqorderusers |
2911 |
WHERE ordernumber = ? |
2912 |
|; |
2913 |
my $dbh = C4::Context->dbh; |
2914 |
my $sth = $dbh->prepare($query); |
2915 |
$sth->execute($ordernumber); |
2916 |
my $results = $sth->fetchall_arrayref( {} ); |
2917 |
|
2918 |
my @borrowernumbers; |
2919 |
foreach (@$results) { |
2920 |
push @borrowernumbers, $_->{'borrowernumber'}; |
2921 |
} |
2922 |
|
2923 |
return @borrowernumbers; |
2924 |
} |
2925 |
|
2926 |
=head3 ModOrderUsers |
2927 |
|
2928 |
my @order_users_ids = (1, 2, 3); |
2929 |
&ModOrderUsers($ordernumber, @basketusers_ids); |
2930 |
|
2931 |
Delete all users from order users list, and add users in C<@order_users_ids> |
2932 |
to this users list. |
2933 |
|
2934 |
=cut |
2935 |
|
2936 |
sub ModOrderUsers { |
2937 |
my ( $ordernumber, @order_users_ids ) = @_; |
2938 |
|
2939 |
return unless $ordernumber; |
2940 |
|
2941 |
my $dbh = C4::Context->dbh; |
2942 |
my $query = q| |
2943 |
DELETE FROM aqorderusers |
2944 |
WHERE ordernumber = ? |
2945 |
|; |
2946 |
my $sth = $dbh->prepare($query); |
2947 |
$sth->execute($ordernumber); |
2948 |
|
2949 |
$query = q| |
2950 |
INSERT INTO aqorderusers (ordernumber, borrowernumber) |
2951 |
VALUES (?, ?) |
2952 |
|; |
2953 |
$sth = $dbh->prepare($query); |
2954 |
foreach my $order_user_id (@order_users_ids) { |
2955 |
$sth->execute( $ordernumber, $order_user_id ); |
2956 |
} |
2957 |
} |
2958 |
|
2959 |
sub NotifyOrderUsers { |
2960 |
my ($ordernumber) = @_; |
2961 |
|
2962 |
my @borrowernumbers = GetOrderUsers($ordernumber); |
2963 |
return unless @borrowernumbers; |
2964 |
|
2965 |
my $order = GetOrder( $ordernumber ); |
2966 |
for my $borrowernumber (@borrowernumbers) { |
2967 |
my $borrower = C4::Members::GetMember( borrowernumber => $borrowernumber ); |
2968 |
my $branch = C4::Branch::GetBranchDetail( $borrower->{branchcode} ); |
2969 |
my $biblio = C4::Biblio::GetBiblio( $order->{biblionumber} ); |
2970 |
my $letter = C4::Letters::GetPreparedLetter( |
2971 |
module => 'acquisition', |
2972 |
letter_code => 'ACQ_NOTIF_ON_RECEIV', |
2973 |
branchcode => $branch->{branchcode}, |
2974 |
tables => { |
2975 |
'branches' => $branch, |
2976 |
'borrowers' => $borrower, |
2977 |
'biblio' => $biblio, |
2978 |
'aqorders' => $order, |
2979 |
}, |
2980 |
); |
2981 |
if ( $letter ) { |
2982 |
C4::Letters::EnqueueLetter( |
2983 |
{ |
2984 |
letter => $letter, |
2985 |
borrowernumber => $borrowernumber, |
2986 |
LibraryName => C4::Context->preference("LibraryName"), |
2987 |
message_transport_type => 'email', |
2988 |
} |
2989 |
) or warn "can't enqueue letter $letter"; |
2990 |
} |
2991 |
} |
2992 |
} |
2993 |
|
2886 |
1; |
2994 |
1; |
2887 |
__END__ |
2995 |
__END__ |
2888 |
|
2996 |
|