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);
50 my @items = &ItemInfo(undef, $biblionumber, 'opac');
52 $dat->{'additional'}=$addauthor->[0]->{'author'};
53 for (my $i = 1; $i < $authorcount; $i++) {
54 $dat->{'additional'} .= "|" . $addauthor->[$i]->{'author'};
57 $dat->{'biblionumber'} = $biblionumber;
58 $dat->{ITEM_RESULTS} = \@items;
59 my $record = MARCgetbiblio($dbh,$bibid);
60 $iso2709 .= $record->as_usmarc();
62 push (@results, $dat);
65 my $resultsarray=\@results;
66 $template2->param(BIBLIO_RESULTS => $resultsarray,
67 email_sender => $email_sender);
69 # Getting template result
70 my $template_res = $template2->output();
72 # Analysing information and getting mail properties
73 if ($template_res =~ /<SUBJECT>\n(.*)\n<END_SUBJECT>/s) { $mail{'subject'} = $1; }
74 else { $mail{'subject'} = "no subject"; }
76 my $email_header = "";
77 if ($template_res =~ /<HEADER>\n(.*)\n<END_HEADER>/s) { $email_header = $1; }
79 my $email_file = "basket.txt";
80 if ($template_res =~ /<FILENAME>\n(.*)\n<END_FILENAME>/s) { $email_file = $1; }
82 if ($template_res =~ /<MESSAGE>\n(.*)\n<END_MESSAGE>/s) { $mail{'body'} = $1; }
84 my $boundary = "====" . time() . "====";
85 $mail{'content-type'} = "multipart/mixed; boundary=\"$boundary\"";
87 $email_header = encode_qp($email_header);
89 $boundary = "--".$boundary;
92 $mail{body} = <<END_OF_BODY;
94 Content-Type: text/plain; charset="iso-8859-1"
95 Content-Transfer-Encoding: quoted-printable
104 $mail{PJ} = $iso2709;
105 # $mail{body} = <<END_OF_BODY;
107 #Content-Type: text/plain; charset="iso-8859-1"
108 #Content-Transfer-Encoding: quoted-printable
113 #Content-Type: text/plain; name="$email_file"
114 #Content-Transfer-Encoding: quoted-printable
115 #Content-Disposition: attachment; filename="$email_file"
123 if (sendmail %mail) {
124 # do something if it works....
125 warn "Mail sent ok\n";
126 $template->param(SENT => "1");
127 $template->param(email_add => $email_add);
129 # do something if it doesnt work....
130 warn "Error sending mail: $Mail::Sendmail::error \n";
133 output_html_with_http_headers $query, $cookie, $template->output;
136 $template->param(bib_list => $bib_list);
137 $template->param(url => "/cgi-bin/koha/opac-sendbasket.pl",
138 suggestion => C4::Context->preference("suggestion"),
139 virtualshelves => C4::Context->preference("virtualshelves"),
141 output_html_with_http_headers $query, $cookie, $template->output;