Lines 583-588
sub SendAlerts {
Link Here
|
583 |
return 1; |
583 |
return 1; |
584 |
} |
584 |
} |
585 |
|
585 |
|
|
|
586 |
=head2 PrintClaimOrderNotice |
587 |
|
588 |
Returns a 'claimorders' notice for given order ids and letter code as PDF |
589 |
|
590 |
my $pdf = PrintClaimOrderNotice(\@orderids, $letter_code); |
591 |
|
592 |
print $cgi->header('application/pdf'); |
593 |
print $pdf; |
594 |
|
595 |
=cut |
596 |
|
597 |
sub PrintClaimOrderNotice { |
598 |
my ($orderids, $letter_code) = @_; |
599 |
|
600 |
return unless ref $orderids eq 'ARRAY'; |
601 |
return unless @$orderids > 0; |
602 |
return unless $letter_code; |
603 |
|
604 |
my $dbh = C4::Context->dbh; |
605 |
|
606 |
my $orderids_str = join(',', ('?') x @$orderids); |
607 |
my $orders = $dbh->selectall_arrayref(qq{ |
608 |
SELECT aqorders.*, aqbasket.*, biblio.* |
609 |
FROM aqorders |
610 |
LEFT JOIN biblio ON aqorders.biblionumber = biblio.biblionumber |
611 |
LEFT JOIN aqbasket ON aqorders.basketno = aqbasket.basketno |
612 |
WHERE aqorders.ordernumber IN ($orderids_str) |
613 |
}, {Slice => {}}, @$orderids); |
614 |
|
615 |
return unless @$orders; |
616 |
|
617 |
my $booksellerid = $orders->[0]->{aqbooksellerid}; |
618 |
|
619 |
my $schema = Koha::Database->new->schema; |
620 |
my $bookseller = |
621 |
$schema->resultset('Aqbookseller')->find( { id => $booksellerid }, |
622 |
{ result_class => 'DBIx::Class::ResultClass::HashRefInflator' } ); |
623 |
|
624 |
my $userenv = C4::Context->userenv; |
625 |
my $letter = GetPreparedLetter( |
626 |
module => 'claimacquisition', |
627 |
letter_code => $letter_code, |
628 |
branchcode => $userenv->{branch}, |
629 |
message_transport_type => 'print', |
630 |
tables => { |
631 |
'branches' => $userenv->{branch}, |
632 |
'aqbooksellers' => $bookseller, |
633 |
}, |
634 |
want_librarian => 1, |
635 |
repeat => $orders, |
636 |
) or return; |
637 |
|
638 |
my $content = $letter->{content}; |
639 |
if ($letter->{is_html}) { |
640 |
$content = _wrap_html($content, $letter->{title}); |
641 |
} |
642 |
|
643 |
my $output = ''; |
644 |
my $pdf = PDF::FromHTML->new(encoding => 'utf-8'); |
645 |
$pdf->load_file(\$content); |
646 |
$pdf->convert(); |
647 |
$pdf->write_file(\$output); |
648 |
|
649 |
return $output; |
650 |
} |
651 |
|
586 |
=head2 GetPreparedLetter( %params ) |
652 |
=head2 GetPreparedLetter( %params ) |
587 |
|
653 |
|
588 |
%params hash: |
654 |
%params hash: |