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

(-)Reserves.pm (+62 lines)
Lines 25-30 Link Here
25
25
26
use strict;
26
use strict;
27
use C4::Context;
27
use C4::Context;
28
use C4::Output;
29
use Mail::Sendmail;
28
use C4::Biblio;
30
use C4::Biblio;
29
use C4::Items;
31
use C4::Items;
30
use C4::Search;
32
use C4::Search;
Lines 191-196 Link Here
191
            $i++;
193
            $i++;
192
        }
194
        }
193
    }
195
    }
196
    
197
    # Send E-mail to admin 
198
    if (
199
        C4::Context->preference("emailLibrarianWhenHoldIsPlaced") &&
200
        C4::Context->preference("KohaAdminEmailAddress")   
201
    ) {
202
        
203
        # Get informations
204
        my $query = "
205
        SELECT 
206
        	borrowers.surname,
207
        	borrowers.firstname,
208
        	borrowers.email,
209
        	reserves.reservedate,
210
        	biblio.title,
211
        	biblio.author
212
        	
213
        FROM   reserves
214
        	INNER JOIN biblio
215
        	ON biblio.biblionumber = reserves.biblionumber 
216
        	INNER JOIN borrowers
217
        	ON borrowers.borrowernumber  = reserves.borrowernumber 
218
        
219
        WHERE  
220
        	reserves.borrowernumber=?
221
        AND
222
            reserves.biblionumber=?
223
        ORDER BY reservedate        
224
        ";
225
226
        my $sth = $dbh->prepare($query);
227
        $sth->execute($borrowernumber, $biblionumber);
228
        my $emailinfo = $sth->fetchrow_hashref;
229
230
        # if user email exists
231
        if ( $emailinfo->{email}  ){
232
        
233
            my $template = gettemplate("reserve/mail_reserve.tmpl", "opac", CGI->new());
234
235
            $template->param(
236
                surname => $emailinfo->{surname},
237
                firstname => $emailinfo->{firstname},            
238
                title => $emailinfo->{title},
239
                author =>$emailinfo->{author},
240
                reservedate =>$emailinfo->{reservedate}
241
            );    
242
                                                
243
            my %mail = (
244
                To => $emailinfo->{email},
245
                From => C4::Context->preference("KohaAdminEmailAddress"),
246
                Subject => 'Réservation - '.$emailinfo->{title},
247
                Message => "".$template->output,
248
                'Content-Type' => 'text/plain; charset="utf-8"',
249
            );  
250
            sendmail(%mail);
251
            
252
        }        
253
            
254
    }
255
    
194
    return;
256
    return;
195
}
257
}
196
258

Return to bug 3242