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);
25 use MIME
::QuotedPrint
;
35 my ( $template, $borrowernumber, $cookie ) = get_template_and_user
(
37 template_name
=> "opac-sendbasketform.tmpl",
41 flagsrequired
=> { borrow
=> 1 },
45 my $bib_list = $query->param('bib_list');
46 my $email_add = $query->param('email_add');
47 my $email_sender = $query->param('email_sender');
49 my $dbh = C4
::Context
->dbh;
52 my $email_from = C4
::Context
->preference('KohaAdminEmailAddress');
53 my $comment = $query->param('comment');
59 my ( $template2, $borrowernumber, $cookie ) = get_template_and_user
(
61 template_name
=> "opac-sendbasket.tmpl",
65 flagsrequired
=> { borrow
=> 1 },
69 my @bibs = split( /\//, $bib_list );
72 my $marcflavour = C4
::Context
->preference('marcflavour');
73 foreach my $biblionumber (@bibs) {
74 $template2->param( biblionumber
=> $biblionumber );
76 my $dat = GetBiblioData
($biblionumber);
77 my $record = GetMarcBiblio
($biblionumber);
78 my $marcnotesarray = GetMarcNotes
( $record, $marcflavour );
79 my $marcauthorsarray = GetMarcAuthors
( $record, $marcflavour );
80 my $marcsubjctsarray = GetMarcSubjects
( $record, $marcflavour );
82 my @items = &GetItemsInfo
( $biblionumber, 'opac' );
85 if($dat->{'author'} || @
$marcauthorsarray) {
90 $dat->{MARCNOTES
} = $marcnotesarray;
91 $dat->{MARCSUBJCTS
} = $marcsubjctsarray;
92 $dat->{MARCAUTHORS
} = $marcauthorsarray;
93 $dat->{HASAUTHORS
} = $hasauthors;
94 $dat->{'biblionumber'} = $biblionumber;
95 $dat->{ITEM_RESULTS
} = \
@items;
97 $iso2709 .= $record->as_usmarc();
99 push( @results, $dat );
102 my $resultsarray = \
@results;
104 BIBLIO_RESULTS
=> $resultsarray,
105 email_sender
=> $email_sender,
109 # Getting template result
110 my $template_res = $template2->output();
113 # Analysing information and getting mail properties
114 if ( $template_res =~ /<SUBJECT>\n(.*)\n<END_SUBJECT>/s ) {
115 $mail{'subject'} = $1;
117 else { $mail{'subject'} = "no subject"; }
119 my $email_header = "";
120 if ( $template_res =~ /<HEADER>\n(.*)\n<END_HEADER>/s ) {
124 my $email_file = "basket.txt";
125 if ( $template_res =~ /<FILENAME>\n(.*)\n<END_FILENAME>/s ) {
129 if ( $template_res =~ /<MESSAGE>\n(.*)\n<END_MESSAGE>/s ) { $body = encode_qp
($1); }
131 my $boundary = "====" . time() . "====";
133 # $mail{'content-type'} = "multipart/mixed; boundary=\"$boundary\"";
135 # $email_header = encode_qp($email_header);
137 # $boundary = "--".$boundary;
141 $mail{'content-type'} = "multipart/mixed; boundary=\"$boundary\"";
142 my $isofile = encode_base64
(encode
("UTF-8", $iso2709));
143 $boundary = '--' . $boundary;
144 $mail{body
} = <<END_OF_BODY;
146 Content-Type: text/plain; charset="utf-8"
147 Content-Transfer-Encoding: quoted-printable
152 Content-Type: application/octet-stream; name="basket.iso2709"
153 Content-Transfer-Encoding: base64
154 Content-Disposition: attachment; filename="basket.iso2709"
161 if ( sendmail %mail ) {
162 # do something if it works....
163 $template->param( SENT => "1" );
166 # do something if it doesnt work....
167 warn "Error sending mail: $Mail::Sendmail::error \n";
168 $template->param( error => 1 );
170 $template->param( email_add => $email_add );
171 output_html_with_http_headers $query, $cookie, $template->output;
174 $template->param( bib_list => $bib_list );
176 url => "/cgi-bin/koha/opac-sendbasket.pl",
177 suggestion => C4::Context->preference("suggestion"),
178 virtualshelves => C4::Context->preference("virtualshelves"),
180 output_html_with_http_headers $query, $cookie, $template->output;