11 use C4::Interface::CGI::Output;
17 my ( $template, $borrowernumber, $cookie ) = get_template_and_user(
19 template_name => "opac-sendbasketform.tmpl",
23 flagsrequired => { borrow => 1 },
27 my $bib_list = $query->param('bib_list');
28 my $email_add = $query->param('email_add');
29 my $email_sender = $query->param('email_sender');
31 my $dbh = C4::Context->dbh();
34 my $email_from = C4::Context->preference('KohaAdminEmailAddress');
41 my ( $template2, $borrowernumber, $cookie ) = get_template_and_user(
43 template_name => "opac-sendbasket.tmpl",
47 flagsrequired => { borrow => 1 },
51 my @bibs = split ( /\//, $bib_list );
54 foreach my $biblionumber (@bibs) {
55 $template2->param( biblionumber => $biblionumber );
57 my $dat = &bibdata($biblionumber);
58 my ( $authorcount, $addauthor ) = &addauthor($biblionumber);
59 my @items = &ItemInfo( undef, $biblionumber, 'opac' );
61 $dat->{'additional'} = $addauthor->[0]->{'author'};
62 for ( my $i = 1 ; $i < $authorcount ; $i++ ) {
63 $dat->{'additional'} .= "|" . $addauthor->[$i]->{'author'};
66 $dat->{'biblionumber'} = $biblionumber;
67 $dat->{ITEM_RESULTS} = \@items;
68 my $record = MARCgetbiblio( $dbh, $biblionumber );
69 $iso2709 .= $record->as_usmarc();
71 push ( @results, $dat );
74 my $resultsarray = \@results;
76 BIBLIO_RESULTS => $resultsarray,
77 email_sender => $email_sender
80 # Getting template result
81 my $template_res = $template2->output();
83 # Analysing information and getting mail properties
84 if ( $template_res =~ /<SUBJECT>\n(.*)\n<END_SUBJECT>/s ) {
85 $mail{'subject'} = $1;
87 else { $mail{'subject'} = "no subject"; }
89 my $email_header = "";
90 if ( $template_res =~ /<HEADER>\n(.*)\n<END_HEADER>/s ) {
94 my $email_file = "basket.txt";
95 if ( $template_res =~ /<FILENAME>\n(.*)\n<END_FILENAME>/s ) {
99 if ( $template_res =~ /<MESSAGE>\n(.*)\n<END_MESSAGE>/s ) {
103 my $boundary = "====" . time() . "====";
104 $mail{'content-type'} = "multipart/mixed; boundary=\"$boundary\"";
106 $email_header = encode_qp($email_header);
108 $boundary = "--" . $boundary;
111 $mail{body} = <<END_OF_BODY;
113 Content-Type: text/plain; charset="iso-8859-1"
114 Content-Transfer-Encoding: quoted-printable
124 if ( sendmail %mail ) {
126 # do something if it works....
127 warn "Mail sent ok\n";
128 $template->param( SENT => "1" );
129 $template->param( email_add => $email_add );
133 # do something if it doesnt work....
134 warn "Error sending mail: $Mail::Sendmail::error \n";
135 warn "$mail{'body'}";
138 output_html_with_http_headers $query, $cookie, $template->output;
141 $template->param( bib_list => $bib_list );
143 url => "/cgi-bin/koha/opac-sendbasket.pl",
144 suggestion => C4::Context->preference("suggestion"),
145 virtualshelves => C4::Context->preference("virtualshelves"),
147 output_html_with_http_headers $query, $cookie, $template->output;