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');
26 my $email_sender=$query->param('email_sender');
29 my $email_from = C4::Context->preference('KohaAdminEmailAddress');
31 my %mail = ( To => $email_add,
34 my ($template2, $borrowernumber, $cookie)
35 = get_template_and_user({template_name => "opac-sendbasket.tmpl",
39 flagsrequired => {borrow => 1},
42 my @bibs = split(/\//, $bib_list);
45 foreach my $biblionumber (@bibs) {
46 $template2->param(biblionumber => $biblionumber);
48 my $dat = &bibdata($biblionumber);
49 my ($authorcount, $addauthor) = &addauthor($biblionumber);
51 $dat->{'additional'}=$addauthor->[0]->{'author'};
52 for (my $i = 1; $i < $authorcount; $i++) {
53 $dat->{'additional'} .= "|" . $addauthor->[$i]->{'author'};
56 $dat->{'biblionumber'} = $biblionumber;
58 push (@results, $dat);
61 my $resultsarray=\@results;
62 $template2->param(BIBLIO_RESULTS => $resultsarray,
63 email_sender => $email_sender);
65 # Getting template result
66 my $template_res = $template2->output();
68 # Analysing information and getting mail properties
69 if ($template_res =~ /<SUBJECT>\n(.*)\n<END_SUBJECT>/s) { $mail{'subject'} = $1; }
70 else { $mail{'subject'} = "no subject"; }
72 my $email_header = "";
73 if ($template_res =~ /<HEADER>\n(.*)\n<END_HEADER>/s) { $email_header = $1; }
75 my $email_file = "basket.txt";
76 if ($template_res =~ /<FILENAME>\n(.*)\n<END_FILENAME>/s) { $email_file = $1; }
78 if ($template_res =~ /<MESSAGE>\n(.*)\n<END_MESSAGE>/s) { $mail{'body'} = $1; }
80 my $boundary = "====" . time() . "====";
81 $mail{'content-type'} = "multipart/mixed; boundary=\"$boundary\"";
83 $email_header = encode_qp($email_header);
85 $boundary = "--".$boundary;
88 $mail{body} = <<END_OF_BODY;
90 Content-Type: text/plain; charset="iso-8859-1"
91 Content-Transfer-Encoding: quoted-printable
100 # $mail{body} = <<END_OF_BODY;
102 #Content-Type: text/plain; charset="iso-8859-1"
103 #Content-Transfer-Encoding: quoted-printable
108 #Content-Type: text/plain; name="$email_file"
109 #Content-Transfer-Encoding: quoted-printable
110 #Content-Disposition: attachment; filename="$email_file"
118 if (sendmail %mail) {
119 # do something if it works....
120 warn "Mail sent ok\n";
121 $template->param(SENT => "1");
122 $template->param(email_add => $email_add);
124 # do something if it doesnt work....
125 warn "Error sending mail: $Mail::Sendmail::error \n";
128 output_html_with_http_headers $query, $cookie, $template->output;
131 $template->param(bib_list => $bib_list);
132 $template->param(url => "/cgi-bin/koha/opac-sendbasket.pl");
133 output_html_with_http_headers $query, $cookie, $template->output;