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