Lines 659-664
sub SendAlerts {
Link Here
|
659 |
return 1; |
659 |
return 1; |
660 |
} |
660 |
} |
661 |
|
661 |
|
|
|
662 |
=head2 PrintClaimOrderNotice |
663 |
|
664 |
Returns a 'claimorders' notice for given order ids and letter code as PDF |
665 |
|
666 |
my $pdf = PrintClaimOrderNotice(\@orderids, $letter_code); |
667 |
|
668 |
print $cgi->header('application/pdf'); |
669 |
print $pdf; |
670 |
|
671 |
=cut |
672 |
|
673 |
sub PrintClaimOrderNotice { |
674 |
my ($orderids, $letter_code) = @_; |
675 |
|
676 |
return unless ref $orderids eq 'ARRAY'; |
677 |
return unless @$orderids > 0; |
678 |
return unless $letter_code; |
679 |
|
680 |
my $dbh = C4::Context->dbh; |
681 |
|
682 |
my $orderids_str = join(',', ('?') x @$orderids); |
683 |
my $orders = $dbh->selectall_arrayref(qq{ |
684 |
SELECT aqorders.*, aqbasket.*, biblio.* |
685 |
FROM aqorders |
686 |
LEFT JOIN biblio ON aqorders.biblionumber = biblio.biblionumber |
687 |
LEFT JOIN aqbasket ON aqorders.basketno = aqbasket.basketno |
688 |
WHERE aqorders.ordernumber IN ($orderids_str) |
689 |
}, {Slice => {}}, @$orderids); |
690 |
|
691 |
return unless @$orders; |
692 |
|
693 |
my $booksellerid = $orders->[0]->{aqbooksellerid}; |
694 |
|
695 |
my $schema = Koha::Database->new->schema; |
696 |
my $bookseller = |
697 |
$schema->resultset('Aqbookseller')->find( { id => $booksellerid }, |
698 |
{ result_class => 'DBIx::Class::ResultClass::HashRefInflator' } ); |
699 |
|
700 |
my $userenv = C4::Context->userenv; |
701 |
my $letter = GetPreparedLetter( |
702 |
module => 'claimacquisition', |
703 |
letter_code => $letter_code, |
704 |
branchcode => $userenv->{branch}, |
705 |
message_transport_type => 'print', |
706 |
tables => { |
707 |
'branches' => $userenv->{branch}, |
708 |
'aqbooksellers' => $bookseller, |
709 |
}, |
710 |
want_librarian => 1, |
711 |
repeat => $orders, |
712 |
) or return; |
713 |
|
714 |
my $content = $letter->{content}; |
715 |
if ($letter->{is_html}) { |
716 |
$content = _wrap_html($content, $letter->{title}); |
717 |
} |
718 |
|
719 |
my $output = ''; |
720 |
my $pdf = PDF::FromHTML->new(encoding => 'utf-8'); |
721 |
$pdf->load_file(\$content); |
722 |
$pdf->convert(); |
723 |
$pdf->write_file(\$output); |
724 |
|
725 |
return $output; |
726 |
} |
727 |
|
662 |
=head2 GetPreparedLetter( %params ) |
728 |
=head2 GetPreparedLetter( %params ) |
663 |
|
729 |
|
664 |
%params hash: |
730 |
%params hash: |