3 # This file is part of Koha.
5 # Koha is free software; you can redistribute it and/or modify it under the
6 # terms of the GNU General Public License as published by the Free Software
7 # Foundation; either version 2 of the License, or (at your option) any later
10 # Koha is distributed in the hope that it will be useful, but WITHOUT ANY
11 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
12 # A PARTICULAR PURPOSE. See the GNU General Public License for more details.
14 # You should have received a copy of the GNU General Public License along with
15 # Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
16 # Suite 330, Boston, MA 02111-1307 USA
22 use Encode
qw(encode);
26 use MIME
::QuotedPrint
;
36 my ( $template, $borrowernumber, $cookie ) = get_template_and_user
(
38 template_name
=> "basket/sendbasketform.tmpl",
42 flagsrequired
=> { borrow
=> 1 },
46 my $bib_list = $query->param('bib_list');
47 my $email_add = $query->param('email_add');
48 my $email_sender = $query->param('email_sender');
50 my $dbh = C4
::Context
->dbh;
53 my $email_from = C4
::Context
->preference('KohaAdminEmailAddress');
54 my $comment = $query->param('comment');
60 my ( $template2, $borrowernumber, $cookie ) = get_template_and_user
(
62 template_name
=> "basket/sendbasket.tmpl",
66 flagsrequired
=> { borrow
=> 1 },
70 my @bibs = split( /\//, $bib_list );
73 my $marcflavour = C4
::Context
->preference('marcflavour');
74 foreach my $biblionumber (@bibs) {
75 $template2->param( biblionumber
=> $biblionumber );
77 my $dat = GetBiblioData
($biblionumber);
78 my $record = GetMarcBiblio
($biblionumber);
79 my $marcnotesarray = GetMarcNotes
( $record, $marcflavour );
80 my $marcauthorsarray = GetMarcAuthors
( $record, $marcflavour );
81 my $marcsubjctsarray = GetMarcSubjects
( $record, $marcflavour );
83 my @items = GetItemsInfo
( $biblionumber );
86 if($dat->{'author'} || @
$marcauthorsarray) {
91 $dat->{MARCNOTES
} = $marcnotesarray;
92 $dat->{MARCSUBJCTS
} = $marcsubjctsarray;
93 $dat->{MARCAUTHORS
} = $marcauthorsarray;
94 $dat->{HASAUTHORS
} = $hasauthors;
95 $dat->{'biblionumber'} = $biblionumber;
96 $dat->{ITEM_RESULTS
} = \
@items;
98 $iso2709 .= $record->as_usmarc();
100 push( @results, $dat );
103 my $resultsarray = \
@results;
105 BIBLIO_RESULTS
=> $resultsarray,
106 email_sender
=> $email_sender,
110 # Getting template result
111 my $template_res = $template2->output();
114 # Analysing information and getting mail properties
115 if ( $template_res =~ /<SUBJECT>\n(.*)\n<END_SUBJECT>/s ) {
116 $mail{'subject'} = $1;
118 else { $mail{'subject'} = "no subject"; }
120 my $email_header = "";
121 if ( $template_res =~ /<HEADER>\n(.*)\n<END_HEADER>/s ) {
125 my $email_file = "basket.txt";
126 if ( $template_res =~ /<FILENAME>\n(.*)\n<END_FILENAME>/s ) {
130 if ( $template_res =~ /<MESSAGE>\n(.*)\n<END_MESSAGE>/s ) { $body = encode_qp
($1); }
132 my $boundary = "====" . time() . "====";
134 # $mail{'content-type'} = "multipart/mixed; boundary=\"$boundary\"";
136 # $email_header = encode_qp($email_header);
138 # $boundary = "--".$boundary;
142 $mail{'content-type'} = "multipart/mixed; boundary=\"$boundary\"";
143 my $isofile = encode_base64
(encode
("UTF-8", $iso2709));
144 $boundary = '--' . $boundary;
145 $mail{body
} = <<END_OF_BODY;
147 Content-Type: text/plain; charset="utf-8"
148 Content-Transfer-Encoding: quoted-printable
153 Content-Type: application/octet-stream; name="basket.iso2709"
154 Content-Transfer-Encoding: base64
155 Content-Disposition: attachment; filename="basket.iso2709"
162 if ( sendmail %mail ) {
163 # do something if it works....
164 $template->param( SENT => "1" );
167 # do something if it doesnt work....
168 carp "Error sending mail: $Mail::Sendmail::error \n";
169 $template->param( error => 1 );
171 $template->param( email_add => $email_add );
172 output_html_with_http_headers $query, $cookie, $template->output;
175 $template->param( bib_list => $bib_list );
177 url => "/cgi-bin/koha/basket/sendbasket.pl",
178 suggestion => C4::Context->preference("suggestion"),
179 virtualshelves => C4::Context->preference("virtualshelves"),
181 output_html_with_http_headers $query, $cookie, $template->output;