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

(-)a/C4/Letters.pm (+66 lines)
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:
(-)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 / +12 lines)
Lines 64-69 $(document).ready(function() { Link Here
64
        location.href = url;
64
        location.href = url;
65
        return false;
65
        return false;
66
    });
66
    });
67
68
    $('#print-claim').on('click', function(e) {
69
        e.preventDefault();
70
        var form = $(this).parents('form')
71
        var op = form.find('input[name="op"]');
72
73
        op.val('print_alert');
74
        form.submit();
75
        op.val('send_alert');
76
    });
77
67
});
78
});
68
//]]>
79
//]]>
69
</script>
80
</script>
Lines 208-213 $(document).ready(function() { Link Here
208
        <input type="button" value="Export as CSV" id="ExportSelected" />
219
        <input type="button" value="Export as CSV" id="ExportSelected" />
209
        [% UNLESS lateorder.budget_lock %]
220
        [% UNLESS lateorder.budget_lock %]
210
            <input type="submit"  value="Claim order" />
221
            <input type="submit"  value="Claim order" />
222
            <input type="button"  value="Print claim" id="print-claim" />
211
        [% END %]
223
        [% END %]
212
    </p>
224
    </p>
213
</form>
225
</form>
214
- 

Return to bug 20119