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

(-)a/C4/Letters.pm (+66 lines)
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:
(-)a/acqui/lateorders.pl (+12 lines)
Lines 122-127 if ($op and $op eq "send_alert"){ Link Here
122
    }
122
    }
123
}
123
}
124
124
125
if ($op and $op eq "print_alert") {
126
    my @orderids = $input->multi_param('ordernumber');
127
128
    my $pdf = C4::Letters::PrintClaimOrderNotice(\@orderids, 'ACQCLAIM');
129
    print $input->header(
130
        -type => 'application/pdf',
131
        -attachment => 'claims.pdf',
132
    );
133
    print $pdf;
134
    exit;
135
}
136
125
my @parameters = ( $delay );
137
my @parameters = ( $delay );
126
push @parameters, $estimateddeliverydatefrom_dt
138
push @parameters, $estimateddeliverydatefrom_dt
127
    ? $estimateddeliverydatefrom_dt->ymd()
139
    ? $estimateddeliverydatefrom_dt->ymd()
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/lateorders.tt (-1 / +11 lines)
Lines 148-153 Link Here
148
        <input type="button" value="Export as CSV" id="ExportSelected" />
148
        <input type="button" value="Export as CSV" id="ExportSelected" />
149
        [% UNLESS lateorder.budget_lock %]
149
        [% UNLESS lateorder.budget_lock %]
150
            <input type="submit"  value="Claim order" />
150
            <input type="submit"  value="Claim order" />
151
            <input type="button"  value="Print claim" id="print-claim" />
151
        [% END %]
152
        [% END %]
152
    </p>
153
    </p>
153
</form>
154
</form>
Lines 249-254 Link Here
249
                location.href = url;
250
                location.href = url;
250
                return false;
251
                return false;
251
            });
252
            });
253
254
            $('#print-claim').on('click', function(e) {
255
                e.preventDefault();
256
                var form = $(this).parents('form')
257
                var op = form.find('input[name="op"]');
258
259
                op.val('print_alert');
260
                form.submit();
261
                op.val('send_alert');
262
            });
252
        });
263
        });
253
    </script>
264
    </script>
254
[% END %]
265
[% END %]
255
- 

Return to bug 20119