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