11 use C4::Interface::CGI::Output;
16 my ($template, $borrowernumber, $cookie)
17 = get_template_and_user({template_name => "opac-sendbasketform.tmpl",
21 flagsrequired => {borrow => 1},
24 my $bib_list=$query->param('bib_list');
25 my $email_add=$query->param('email_add');
28 my $email_from = C4::Context->preference('KohaAdminEmailAddress');
30 my %mail = ( To => $email_add,
33 my ($template2, $borrowernumber, $cookie)
34 = get_template_and_user({template_name => "opac-sendbasket.tmpl",
38 flagsrequired => {borrow => 1},
41 my @bibs = split(/\//, $bib_list);
44 foreach my $biblionumber (@bibs) {
45 $template2->param(biblionumber => $biblionumber);
47 my $dat = &bibdata($biblionumber);
48 my ($authorcount, $addauthor) = &addauthor($biblionumber);
50 $dat->{'additional'}=$addauthor->[0]->{'author'};
51 for (my $i = 1; $i < $authorcount; $i++) {
52 $dat->{'additional'} .= "|" . $addauthor->[$i]->{'author'};
55 $dat->{'biblionumber'} = $biblionumber;
57 push (@results, $dat);
60 my $resultsarray=\@results;
61 $template2->param(BIBLIO_RESULTS => $resultsarray);
63 # Getting template result
64 my $template_res = $template2->output();
66 # Analysing information and getting mail properties
67 if ($template_res =~ /§SUBJECT§\n(.*)\n§END_SUBJECT§/s) { $mail{'subject'} = $1; }
68 else { $mail{'subject'} = "no subject"; }
70 my $email_header = "";
71 if ($template_res =~ /§HEADER§\n(.*)\n§END_HEADER§/s) { $email_header = $1; }
73 my $email_file = "basket.txt";
74 if ($template_res =~ /§FILENAME§\n(.*)\n§END_FILENAME§/s) { $email_file = $1; }
76 if ($template_res =~ /§MESSAGE§\n(.*)\n§END_MESSAGE§/s) { $mail{'body'} = $1; }
78 my $boundary = "====" . time() . "====";
79 $mail{'content-type'} = "multipart/mixed; boundary=\"$boundary\"";
81 $email_header = encode_qp($email_header);
83 $boundary = "--".$boundary;
86 $mail{body} = <<END_OF_BODY;
88 Content-Type: text/plain; charset="iso-8859-1"
89 Content-Transfer-Encoding: quoted-printable
98 # $mail{body} = <<END_OF_BODY;
100 #Content-Type: text/plain; charset="iso-8859-1"
101 #Content-Transfer-Encoding: quoted-printable
106 #Content-Type: text/plain; name="$email_file"
107 #Content-Transfer-Encoding: quoted-printable
108 #Content-Disposition: attachment; filename="$email_file"
116 if (sendmail %mail) {
117 # do something if it works....
118 warn "Mail sent ok\n";
119 $template->param(SENT => "1");
120 $template->param(email_add => $email_add);
122 # do something if it doesnt work....
123 warn "Error sending mail: $Mail::Sendmail::error \n";
126 output_html_with_http_headers $query, $cookie, $template->output;
129 $template->param(bib_list => $bib_list);
130 $template->param(url => "/cgi-bin/koha/opac-sendbasket.pl");
131 output_html_with_http_headers $query, $cookie, $template->output;