View | Details | Raw Unified | Return to bug 20119
Collapse All | Expand All

(-)a/C4/Letters.pm (+66 lines)
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:
(-)a/acqui/lateorders.pl (+12 lines)
Lines 119-124 if ($op and $op eq "send_alert"){ Link Here
119
    }
119
    }
120
}
120
}
121
121
122
if ($op and $op eq "print_alert") {
123
    my @orderids = $input->multi_param('ordernumber');
124
125
    my $pdf = C4::Letters::PrintClaimOrderNotice(\@orderids, 'ACQCLAIM');
126
    print $input->header(
127
        -type => 'application/pdf',
128
        -attachment => 'claims.pdf',
129
    );
130
    print $pdf;
131
    exit;
132
}
133
122
my @lateorders = Koha::Acquisition::Orders->filter_by_lates(
134
my @lateorders = Koha::Acquisition::Orders->filter_by_lates(
123
    {
135
    {
124
        delay        => $delay,
136
        delay        => $delay,
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/lateorders.tt (-1 / +11 lines)
Lines 213-218 Link Here
213
        </div>
213
        </div>
214
214
215
        <input type="submit"  class="btn btn-default" value="Claim order" />
215
        <input type="submit"  class="btn btn-default" value="Claim order" />
216
        <input type="button"  value="Print claim" id="print-claim" />
216
    </fieldset>
217
    </fieldset>
217
</form>
218
</form>
218
[% ELSE %]<p>There are no late orders.</p>
219
[% ELSE %]<p>There are no late orders.</p>
Lines 369-374 Link Here
369
                $("#ordernumber").val("");
370
                $("#ordernumber").val("");
370
                $("#type").val("");
371
                $("#type").val("");
371
            });
372
            });
373
374
            $('#print-claim').on('click', function(e) {
375
                e.preventDefault();
376
                var form = $(this).parents('form')
377
                var op = form.find('input[name="op"]');
378
379
                op.val('print_alert');
380
                form.submit();
381
                op.val('send_alert');
382
            });
372
        });
383
        });
373
    </script>
384
    </script>
374
[% END %]
385
[% END %]
375
- 

Return to bug 20119