|
Lines 23-30
use CGI;
Link Here
|
| 23 |
use JSON qw( from_json ); |
23 |
use JSON qw( from_json ); |
| 24 |
|
24 |
|
| 25 |
use C4::Auth qw( get_session get_template_and_user ); |
25 |
use C4::Auth qw( get_session get_template_and_user ); |
| 26 |
use C4::Output qw( output_html_with_http_headers ); |
|
|
| 27 |
use C4::Context; |
26 |
use C4::Context; |
|
|
27 |
use C4::Letters qw( GetPreparedLetter EnqueueLetter SendQueuedMessages ); |
| 28 |
use C4::Output qw( output_html_with_http_headers ); |
| 28 |
|
29 |
|
| 29 |
use Koha::Account::DebitTypes; |
30 |
use Koha::Account::DebitTypes; |
| 30 |
use Koha::AuthorisedValues; |
31 |
use Koha::AuthorisedValues; |
|
Lines 39-54
my $session = get_session($sessionID);
Link Here
|
| 39 |
|
40 |
|
| 40 |
my ( $template, $loggedinuser, $cookie, $user_flags ) = get_template_and_user( |
41 |
my ( $template, $loggedinuser, $cookie, $user_flags ) = get_template_and_user( |
| 41 |
{ |
42 |
{ |
| 42 |
template_name => 'pos/pay.tt', |
43 |
template_name => 'pos/pay.tt', |
| 43 |
query => $input, |
44 |
query => $input, |
| 44 |
type => 'intranet', |
45 |
type => 'intranet', |
| 45 |
flagsrequired => { cash_management => 'takepayment' }, |
46 |
flagsrequired => { cash_management => 'takepayment' }, |
| 46 |
} |
47 |
} |
| 47 |
); |
48 |
); |
| 48 |
my $logged_in_user = Koha::Patrons->find($loggedinuser) or die "Not logged in"; |
49 |
my $logged_in_user = Koha::Patrons->find($loggedinuser) or die "Not logged in"; |
| 49 |
|
50 |
|
| 50 |
my $library_id = C4::Context->userenv->{'branch'}; |
51 |
my $library_id = C4::Context->userenv->{'branch'}; |
| 51 |
my $registerid = $input->param('registerid'); |
52 |
my $registerid = $input->param('registerid'); |
|
|
53 |
my $action = $input->param('action') || ''; |
| 52 |
|
54 |
|
| 53 |
my $invoice_types = |
55 |
my $invoice_types = |
| 54 |
Koha::Account::DebitTypes->search_with_library_limits( |
56 |
Koha::Account::DebitTypes->search_with_library_limits( |
|
Lines 82-87
if ( $total_paid and $total_paid ne '0.00' ) {
Link Here
|
| 82 |
); |
84 |
); |
| 83 |
} |
85 |
} |
| 84 |
|
86 |
|
|
|
87 |
if ( $action eq 'send' ) { |
| 88 |
my $payment_id = $input->param('payment_id'); |
| 89 |
my $change = $input->param('change'); |
| 90 |
my $collected = $input->param('collected'); |
| 91 |
my $toaddr = $input->param('toaddr'); |
| 92 |
|
| 93 |
# Create our letter from the template |
| 94 |
my $letter = GetPreparedLetter( |
| 95 |
module => 'pos', |
| 96 |
letter_code => 'RECEIPT', |
| 97 |
branchcode => C4::Context->userenv->{'branch'}, |
| 98 |
message_transport_type => 'email', |
| 99 |
tables => { |
| 100 |
credits => $payment_id, |
| 101 |
}, |
| 102 |
substitute => { |
| 103 |
collected => $collected, |
| 104 |
change => $change |
| 105 |
} |
| 106 |
); |
| 107 |
|
| 108 |
# Add letter to the queue |
| 109 |
my $message_id = EnqueueLetter( |
| 110 |
{ |
| 111 |
letter => $letter, |
| 112 |
message_transport_type => 'email', |
| 113 |
from_address => C4::Context->preference('KohaAdminEmailAddress'), |
| 114 |
to_address => $toaddr, |
| 115 |
} |
| 116 |
); |
| 117 |
|
| 118 |
# Send immediately |
| 119 |
SendQueuedMessages( { message_id => $message_id } ); |
| 120 |
|
| 121 |
# Set variables for template to allow printing still |
| 122 |
$template->param( |
| 123 |
payment_id => $payment_id, |
| 124 |
collected => $collected, |
| 125 |
change => $change |
| 126 |
); |
| 127 |
} |
| 128 |
|
| 85 |
output_html_with_http_headers( $input, $cookie, $template->output ); |
129 |
output_html_with_http_headers( $input, $cookie, $template->output ); |
| 86 |
|
130 |
|
| 87 |
1; |
131 |
1; |
| 88 |
- |
|
|