|
Lines 251-284
sub get_letter_loop {
Link Here
|
| 251 |
]; |
251 |
]; |
| 252 |
} |
252 |
} |
| 253 |
|
253 |
|
| 254 |
sub _guess_enddate { |
|
|
| 255 |
my ($startdate_iso, $frequencyid, $numberlength, $weeklength, $monthlength) = @_; |
| 256 |
my ($year, $month, $day); |
| 257 |
my $enddate; |
| 258 |
if($numberlength != 0) { |
| 259 |
my $frequency = GetSubscriptionFrequency($frequencyid); |
| 260 |
if($frequency->{'unit'} eq 'day') { |
| 261 |
($year, $month, $day) = Add_Delta_Days(split(/-/, $startdate_iso), $numberlength * $frequency->{'unitsperissue'} / $frequency->{'issuesperunit'}); |
| 262 |
} elsif($frequency->{'unit'} eq 'week') { |
| 263 |
($year, $month, $day) = Add_Delta_Days(split(/-/, $startdate_iso), $numberlength * 7 * $frequency->{'unitsperissue'} / $frequency->{'issuesperunit'}); |
| 264 |
} elsif($frequency->{'unit'} eq 'month') { |
| 265 |
($year, $month, $day) = Add_Delta_YM(split(/-/, $startdate_iso), 0, $numberlength * $frequency->{'unitsperissue'} / $frequency->{'issuesperunit'}); |
| 266 |
} elsif($frequency->{'unit'} eq 'year') { |
| 267 |
($year, $month, $day) = Add_Delta_YM(split(/-/, $startdate_iso), $numberlength * $frequency->{'unitsperissue'} / $frequency->{'issuesperunit'}, 0); |
| 268 |
} |
| 269 |
} elsif($weeklength != 0) { |
| 270 |
($year, $month, $day) = Add_Delta_Days(split(/-/, $startdate_iso), $weeklength * 7); |
| 271 |
} elsif($monthlength != 0) { |
| 272 |
($year, $month, $day) = Add_Delta_YM(split(/-/, $startdate_iso), 0, $monthlength); |
| 273 |
} |
| 274 |
if(defined $year) { |
| 275 |
$enddate = sprintf("%04d-%02d-%02d", $year, $month, $day); |
| 276 |
} else { |
| 277 |
undef $enddate; |
| 278 |
} |
| 279 |
return $enddate; |
| 280 |
} |
| 281 |
|
| 282 |
sub redirect_add_subscription { |
254 |
sub redirect_add_subscription { |
| 283 |
my $periodicity = $query->param('frequency'); |
255 |
my $periodicity = $query->param('frequency'); |
| 284 |
if ($periodicity eq 'mana') { |
256 |
if ($periodicity eq 'mana') { |
|
Lines 300-305
sub redirect_add_subscription {
Link Here
|
| 300 |
my $cost = $query->param('cost'); |
272 |
my $cost = $query->param('cost'); |
| 301 |
my $aqbudgetid = $query->param('aqbudgetid'); |
273 |
my $aqbudgetid = $query->param('aqbudgetid'); |
| 302 |
my @irregularity = $query->multi_param('irregularity'); |
274 |
my @irregularity = $query->multi_param('irregularity'); |
|
|
275 |
my @permanent_irregularity = $query->multi_param('permanent_irregularity'); |
| 303 |
my $locale = $query->param('locale'); |
276 |
my $locale = $query->param('locale'); |
| 304 |
my $graceperiod = $query->param('graceperiod') || 0; |
277 |
my $graceperiod = $query->param('graceperiod') || 0; |
| 305 |
|
278 |
|
|
Lines 340-358
sub redirect_add_subscription {
Link Here
|
| 340 |
my $firstacquidate = output_pref( { str => scalar $query->param('firstacquidate'), dateonly => 1, dateformat => 'iso' } ); |
313 |
my $firstacquidate = output_pref( { str => scalar $query->param('firstacquidate'), dateonly => 1, dateformat => 'iso' } ); |
| 341 |
|
314 |
|
| 342 |
if(!defined $enddate || $enddate eq '') { |
315 |
if(!defined $enddate || $enddate eq '') { |
|
|
316 |
my $subscription = Koha::Subscriptions->new({ |
| 317 |
startdate => $startdate, |
| 318 |
periodicity => $periodicity, |
| 319 |
weeklength => $weeklength, |
| 320 |
monthlength =>$monthlength, |
| 321 |
numberlength => $numberlength |
| 322 |
}); |
| 323 |
|
| 343 |
if($subtype eq "issues") { |
324 |
if($subtype eq "issues") { |
| 344 |
$enddate = _guess_enddate($firstacquidate, $periodicity, $numberlength, $weeklength, $monthlength) |
325 |
$subscription->startdate($firstacquidate); |
| 345 |
} else { |
|
|
| 346 |
$enddate = _guess_enddate($startdate, $periodicity, $numberlength, $weeklength, $monthlength) |
| 347 |
} |
326 |
} |
|
|
327 |
$enddate = $subscription->guess_enddate; |
| 348 |
} |
328 |
} |
| 349 |
my $subscriptionid = NewSubscription( |
329 |
my $subscriptionid = NewSubscription( |
| 350 |
$auser, $branchcode, $aqbooksellerid, $cost, $aqbudgetid, $biblionumber, |
330 |
$auser, $branchcode, $aqbooksellerid, $cost, $aqbudgetid, $biblionumber, |
| 351 |
$startdate, $periodicity, $numberlength, $weeklength, |
331 |
$startdate, $periodicity, $numberlength, $weeklength, |
| 352 |
$monthlength, $lastvalue1, $innerloop1, $lastvalue2, $innerloop2, |
332 |
$monthlength, $lastvalue1, $innerloop1, $lastvalue2, $innerloop2, |
| 353 |
$lastvalue3, $innerloop3, $status, $notes, $letter, $firstacquidate, |
333 |
$lastvalue3, $innerloop3, $status, $notes, $letter, $firstacquidate, |
| 354 |
join(";",@irregularity), $numberpattern, $locale, $callnumber, |
334 |
join(";",@irregularity), join(';', @permanent_irregularity), $numberpattern, $locale, |
| 355 |
$manualhistory, $internalnotes, $serialsadditems, |
335 |
$callnumber, $manualhistory, $internalnotes, $serialsadditems, |
| 356 |
$staffdisplaycount, $opacdisplaycount, $graceperiod, $location, $enddate, |
336 |
$staffdisplaycount, $opacdisplaycount, $graceperiod, $location, $enddate, |
| 357 |
$skip_serialseq, $itemtype, $previousitemtype, $mana_id |
337 |
$skip_serialseq, $itemtype, $previousitemtype, $mana_id |
| 358 |
); |
338 |
); |
|
Lines 386-391
sub redirect_add_subscription {
Link Here
|
| 386 |
sub redirect_mod_subscription { |
366 |
sub redirect_mod_subscription { |
| 387 |
my $subscriptionid = $query->param('subscriptionid'); |
367 |
my $subscriptionid = $query->param('subscriptionid'); |
| 388 |
my @irregularity = $query->multi_param('irregularity'); |
368 |
my @irregularity = $query->multi_param('irregularity'); |
|
|
369 |
my @permanent_irregularity = $query->multi_param('permanent_irregularity'); |
| 389 |
my $auser = $query->param('user'); |
370 |
my $auser = $query->param('user'); |
| 390 |
my $librarian => scalar $query->param('librarian'), |
371 |
my $librarian => scalar $query->param('librarian'), |
| 391 |
my $branchcode = $query->param('branchcode'); |
372 |
my $branchcode = $query->param('branchcode'); |
|
Lines 453-463
sub redirect_mod_subscription {
Link Here
|
| 453 |
|
434 |
|
| 454 |
# Guess end date |
435 |
# Guess end date |
| 455 |
if(!defined $enddate || $enddate eq '') { |
436 |
if(!defined $enddate || $enddate eq '') { |
|
|
437 |
my $subscription = Koha::Subscriptions->new({ |
| 438 |
startdate => $startdate, |
| 439 |
periodicity => $periodicity, |
| 440 |
weeklength => $weeklength, |
| 441 |
monthlength =>$monthlength, |
| 442 |
numberlength => $numberlength |
| 443 |
}); |
| 444 |
|
| 456 |
if($subtype eq "issues") { |
445 |
if($subtype eq "issues") { |
| 457 |
$enddate = _guess_enddate($nextacquidate, $periodicity, $numberlength, $weeklength, $monthlength); |
446 |
$subscription->startdate($nextacquidate); |
| 458 |
} else { |
|
|
| 459 |
$enddate = _guess_enddate($startdate, $periodicity, $numberlength, $weeklength, $monthlength); |
| 460 |
} |
447 |
} |
|
|
448 |
$enddate = $subscription->guess_enddate; |
| 461 |
} |
449 |
} |
| 462 |
|
450 |
|
| 463 |
my $nextexpected = GetNextExpected($subscriptionid); |
451 |
my $nextexpected = GetNextExpected($subscriptionid); |
|
Lines 471-477
sub redirect_mod_subscription {
Link Here
|
| 471 |
ModSubscription( |
459 |
ModSubscription( |
| 472 |
$auser, $branchcode, $aqbooksellerid, $cost, $aqbudgetid, $startdate, |
460 |
$auser, $branchcode, $aqbooksellerid, $cost, $aqbudgetid, $startdate, |
| 473 |
$periodicity, $firstacquidate, join(";",@irregularity), |
461 |
$periodicity, $firstacquidate, join(";",@irregularity), |
| 474 |
$numberpattern, $locale, $numberlength, $weeklength, $monthlength, $lastvalue1, |
462 |
join(';', @permanent_irregularity), $numberpattern, $locale, |
|
|
463 |
$numberlength, $weeklength, $monthlength, $lastvalue1, |
| 475 |
$innerloop1, $lastvalue2, $innerloop2, $lastvalue3, $innerloop3, |
464 |
$innerloop1, $lastvalue2, $innerloop2, $lastvalue3, $innerloop3, |
| 476 |
$status, $biblionumber, $callnumber, $notes, $letter, |
465 |
$status, $biblionumber, $callnumber, $notes, $letter, |
| 477 |
$manualhistory, $internalnotes, $serialsadditems, $staffdisplaycount, |
466 |
$manualhistory, $internalnotes, $serialsadditems, $staffdisplaycount, |