|
Lines 53-58
use C4::Context;
Link Here
|
| 53 |
use C4::Auth; |
53 |
use C4::Auth; |
| 54 |
use C4::Output; |
54 |
use C4::Output; |
| 55 |
use C4::Serials; |
55 |
use C4::Serials; |
|
|
56 |
use C4::Serials::Frequency; |
| 57 |
use C4::Serials::Numberpattern; |
| 58 |
use Date::Calc qw(Today Day_of_Year Week_of_Year Add_Delta_Days Add_Delta_YM); |
| 56 |
use Koha::DateUtils; |
59 |
use Koha::DateUtils; |
| 57 |
|
60 |
|
| 58 |
my $query = new CGI; |
61 |
my $query = new CGI; |
|
Lines 83-88
if ( $op eq "renew" ) {
Link Here
|
| 83 |
# Make sure the subscription exists |
86 |
# Make sure the subscription exists |
| 84 |
my $subscription = GetSubscription( $subscriptionid ); |
87 |
my $subscription = GetSubscription( $subscriptionid ); |
| 85 |
output_and_exit( $query, $cookie, $template, 'unknown_subscription') unless $subscription; |
88 |
output_and_exit( $query, $cookie, $template, 'unknown_subscription') unless $subscription; |
|
|
89 |
|
| 90 |
my @permanent_irregularities = $query->param('permanent_irregularity'); |
| 91 |
my @irregularities = $query->param('irregularity'); |
| 86 |
my $startdate = output_pref( { str => scalar $query->param('startdate'), dateonly => 1, dateformat => 'iso' } ); |
92 |
my $startdate = output_pref( { str => scalar $query->param('startdate'), dateonly => 1, dateformat => 'iso' } ); |
| 87 |
($numberlength, $weeklength, $monthlength) = GetSubscriptionLength( $subtype, $sublength ); |
93 |
($numberlength, $weeklength, $monthlength) = GetSubscriptionLength( $subtype, $sublength ); |
| 88 |
ReNewSubscription( |
94 |
ReNewSubscription( |
|
Lines 97-102
if ( $op eq "renew" ) {
Link Here
|
| 97 |
branchcode => $branchcode |
103 |
branchcode => $branchcode |
| 98 |
} |
104 |
} |
| 99 |
); |
105 |
); |
|
|
106 |
|
| 107 |
my $subscription = Koha::Subscriptions->find($subscriptionid); |
| 108 |
$subscription->permanent_irregularity(join(';', @permanent_irregularities)); |
| 109 |
$subscription->irregularity(join(';', @irregularities)); |
| 110 |
$subscription->store; |
| 100 |
} elsif ( $op eq 'multi_renew' ) { |
111 |
} elsif ( $op eq 'multi_renew' ) { |
| 101 |
for my $subscriptionid ( @subscriptionids ) { |
112 |
for my $subscriptionid ( @subscriptionids ) { |
| 102 |
my $subscription = GetSubscription( $subscriptionid ); |
113 |
my $subscription = GetSubscription( $subscriptionid ); |
|
Lines 124-140
if ( $op eq "renew" ) {
Link Here
|
| 124 |
my $newstartdate = output_pref( { str => $subscription->{enddate}, dateonly => 1 } ) |
135 |
my $newstartdate = output_pref( { str => $subscription->{enddate}, dateonly => 1 } ) |
| 125 |
or output_pref( { dt => dt_from_string, dateonly => 1 } ); |
136 |
or output_pref( { dt => dt_from_string, dateonly => 1 } ); |
| 126 |
|
137 |
|
|
|
138 |
my ($serials_number) = GetSerials($subscriptionid); |
| 139 |
if ($serials_number > 1) { |
| 140 |
$template->param(more_than_one_serial => 1); |
| 141 |
} |
| 142 |
|
| 143 |
my $subscription_o = Koha::Subscriptions->find($subscription->{subscriptionid}); |
| 144 |
my $subtype = $subscription_o->subtype; |
| 145 |
my $nextexpected = GetNextExpected($subscriptionid); |
| 146 |
my $enddate = GuessEnddate($subscription->{enddate} || dt_from_string, |
| 147 |
$subscription->{periodicity}, |
| 148 |
$subscription->{numberlength}, |
| 149 |
$subscription->{weeklength}, |
| 150 |
$subscription->{monthlength}); |
| 151 |
|
| 152 |
my $sub_length; |
| 153 |
foreach my $length_unit (qw(numberlength weeklength monthlength)) { |
| 154 |
if ($subscription->{$length_unit}) { |
| 155 |
$sub_length=$subscription->{$length_unit}; |
| 156 |
last; |
| 157 |
} |
| 158 |
} |
| 159 |
|
| 160 |
my $numberpattern = GetSubscriptionNumberpattern($subscription->{numberpattern}); |
| 161 |
|
| 127 |
$template->param( |
162 |
$template->param( |
| 128 |
startdate => $newstartdate, |
163 |
startdate => $newstartdate, |
| 129 |
subscription => $subscription, |
164 |
subscription => $subscription, |
|
|
165 |
numberpattern => $numberpattern, |
| 166 |
startdate => $newstartdate, |
| 167 |
nextacquidate => $nextexpected->{planneddate}, |
| 168 |
enddate => $enddate, |
| 169 |
subtype => $subtype, |
| 170 |
sublength => $sub_length, |
| 130 |
); |
171 |
); |
| 131 |
} |
172 |
} |
| 132 |
|
173 |
|
| 133 |
my $libraries = Koha::Libraries->search( {}, { order_by => ['branchcode'] }, ); |
174 |
my $libraries = Koha::Libraries->search( {}, { order_by => ['branchcode'] }, ); |
| 134 |
|
175 |
|
| 135 |
$template->param( |
176 |
$template->param( |
| 136 |
op => $op, |
177 |
op => $op, |
| 137 |
libraries => $libraries, |
178 |
libraries => $libraries, |
|
|
179 |
popup => ($mode eq 'popup'), |
| 138 |
); |
180 |
); |
| 139 |
|
181 |
|
| 140 |
output_html_with_http_headers $query, $cookie, $template->output; |
182 |
output_html_with_http_headers $query, $cookie, $template->output; |