|
Lines 26-36
use C4::Output qw( output_html_with_http_headers );
Link Here
|
| 26 |
use C4::Reserves qw( AddReserve ModReserve ); |
26 |
use C4::Reserves qw( AddReserve ModReserve ); |
| 27 |
use C4::Context; |
27 |
use C4::Context; |
| 28 |
use C4::Serials qw( delroutingmember getroutinglist GetSubscription GetSerials check_routing ); |
28 |
use C4::Serials qw( delroutingmember getroutinglist GetSubscription GetSerials check_routing ); |
|
|
29 |
use C4::Letters qw( GetPreparedLetter ); |
| 29 |
use URI::Escape; |
30 |
use URI::Escape; |
| 30 |
|
31 |
|
| 31 |
use Koha::Biblios; |
32 |
use Koha::Biblios; |
| 32 |
use Koha::Libraries; |
33 |
use Koha::Libraries; |
| 33 |
use Koha::Patrons; |
34 |
use Koha::Patrons; |
|
|
35 |
use Koha::Serials; |
| 34 |
|
36 |
|
| 35 |
my $query = CGI->new; |
37 |
my $query = CGI->new; |
| 36 |
my $subscriptionid = $query->param('subscriptionid'); |
38 |
my $subscriptionid = $query->param('subscriptionid'); |
|
Lines 55-73
my $subs = GetSubscription($subscriptionid);
Link Here
|
| 55 |
my ( $tmp, @serials ) = GetSerials($subscriptionid); |
57 |
my ( $tmp, @serials ) = GetSerials($subscriptionid); |
| 56 |
my ( $template, $loggedinuser, $cookie ); |
58 |
my ( $template, $loggedinuser, $cookie ); |
| 57 |
|
59 |
|
| 58 |
my $library; |
60 |
# get biblio information.... |
| 59 |
if ( $op eq 'cud-save_and_preview' ) { |
61 |
my $biblionumber = $subs->{'bibnum'}; |
| 60 |
|
62 |
|
| 61 |
# get biblio information.... |
63 |
my $library; |
| 62 |
my $biblionumber = $subs->{'bibnum'}; |
64 |
my $biblio = Koha::Biblios->find($biblionumber); |
|
|
65 |
my $items = $biblio->items->search_ordered; |
| 66 |
my $branch = |
| 67 |
$items->count |
| 68 |
? $items->next->holding_branch->branchcode |
| 69 |
: $subs->{branchcode}; |
| 70 |
$library = Koha::Libraries->find($branch); |
| 63 |
|
71 |
|
| 64 |
my $biblio = Koha::Biblios->find($biblionumber); |
72 |
if ( $op eq 'cud-save_and_preview' ) { |
| 65 |
my $items = $biblio->items->search_ordered; |
|
|
| 66 |
my $branch = |
| 67 |
$items->count |
| 68 |
? $items->next->holding_branch->branchcode |
| 69 |
: $subs->{branchcode}; |
| 70 |
$library = Koha::Libraries->find($branch); |
| 71 |
|
73 |
|
| 72 |
if ( C4::Context->preference('RoutingListAddReserves') ) { |
74 |
if ( C4::Context->preference('RoutingListAddReserves') ) { |
| 73 |
|
75 |
|
|
Lines 127-149
if ( $op eq 'cud-save_and_preview' ) {
Link Here
|
| 127 |
|
129 |
|
| 128 |
$template->param( libraryname => $library->branchname ) if $library; |
130 |
$template->param( libraryname => $library->branchname ) if $library; |
| 129 |
|
131 |
|
| 130 |
my $memberloop = []; |
132 |
my @borrowernumbers = map { $_->{borrowernumber} } @routinglist; |
| 131 |
for my $routing (@routinglist) { |
133 |
|
| 132 |
my $member = Koha::Patrons->find( $routing->{borrowernumber} )->unblessed; |
134 |
my $matching_serial; |
| 133 |
$member->{name} = "$member->{firstname} $member->{surname}"; |
135 |
if ($issue) { |
| 134 |
push @{$memberloop}, $member; |
136 |
my $serial_obj = Koha::Serials->find($issue); |
|
|
137 |
$matching_serial = $serial_obj->unblessed if $serial_obj; |
| 135 |
} |
138 |
} |
| 136 |
|
139 |
|
| 137 |
my $routingnotes = $serials[0]->{'routingnotes'}; |
140 |
my $letter = GetPreparedLetter( |
| 138 |
$routingnotes =~ s/\n/\<br \/\>/g; |
141 |
module => 'serial', |
|
|
142 |
letter_code => 'ROUTING_LIST', |
| 143 |
message_transport_type => 'print', |
| 144 |
lang => 'default', |
| 145 |
tables => { |
| 146 |
subscription => $subscriptionid, |
| 147 |
biblio => $subs->{bibnum}, |
| 148 |
biblioitems => $subs->{bibnum}, |
| 149 |
branches => $branch, |
| 150 |
serial => $matching_serial ? $matching_serial->{serialid} : $serials[0]->{serialid}, |
| 151 |
|
| 152 |
}, |
| 153 |
loops => { |
| 154 |
borrowers => \@borrowernumbers, |
| 155 |
}, |
| 156 |
); |
| 139 |
|
157 |
|
| 140 |
$template->param( |
158 |
$template->param( |
|
|
159 |
letter_content => $letter->{content}, |
| 141 |
title => $subs->{'bibliotitle'}, |
160 |
title => $subs->{'bibliotitle'}, |
| 142 |
issue => $issue, |
161 |
issue => $issue, |
| 143 |
issue_escaped => URI::Escape::uri_escape_utf8($issue), |
162 |
issue_escaped => URI::Escape::uri_escape_utf8($issue), |
| 144 |
subscriptionid => $subscriptionid, |
163 |
subscriptionid => $subscriptionid, |
| 145 |
memberloop => $memberloop, |
|
|
| 146 |
routingnotes => $routingnotes, |
| 147 |
hasRouting => check_routing($subscriptionid), |
164 |
hasRouting => check_routing($subscriptionid), |
| 148 |
( uc( C4::Context->preference("marcflavour") ) ) => 1 |
165 |
( uc( C4::Context->preference("marcflavour") ) ) => 1 |
| 149 |
); |
166 |
); |
| 150 |
- |
|
|