|
Lines 255-286
sub get_letter_loop {
Link Here
|
| 255 |
]; |
255 |
]; |
| 256 |
} |
256 |
} |
| 257 |
|
257 |
|
| 258 |
sub _guess_enddate { |
258 |
sub _get_sub_length { |
| 259 |
my ($startdate_iso, $frequencyid, $numberlength, $weeklength, $monthlength) = @_; |
259 |
my ($type, $length) = @_; |
| 260 |
my ($year, $month, $day); |
260 |
return |
| 261 |
my $enddate; |
261 |
( |
| 262 |
if($numberlength != 0) { |
262 |
$type eq 'issues' ? $length : 0, |
| 263 |
my $frequency = GetSubscriptionFrequency($frequencyid); |
263 |
$type eq 'weeks' ? $length : 0, |
| 264 |
if($frequency->{'unit'} eq 'day') { |
264 |
$type eq 'months' ? $length : 0, |
| 265 |
($year, $month, $day) = Add_Delta_Days(split(/-/, $startdate_iso), $numberlength * $frequency->{'unitsperissue'} / $frequency->{'issuesperunit'}); |
265 |
); |
| 266 |
} elsif($frequency->{'unit'} eq 'week') { |
|
|
| 267 |
($year, $month, $day) = Add_Delta_Days(split(/-/, $startdate_iso), $numberlength * 7 * $frequency->{'unitsperissue'} / $frequency->{'issuesperunit'}); |
| 268 |
} elsif($frequency->{'unit'} eq 'month') { |
| 269 |
($year, $month, $day) = Add_Delta_YM(split(/-/, $startdate_iso), 0, $numberlength * $frequency->{'unitsperissue'} / $frequency->{'issuesperunit'}); |
| 270 |
} elsif($frequency->{'unit'} eq 'year') { |
| 271 |
($year, $month, $day) = Add_Delta_YM(split(/-/, $startdate_iso), $numberlength * $frequency->{'unitsperissue'} / $frequency->{'issuesperunit'}, 0); |
| 272 |
} |
| 273 |
} elsif($weeklength != 0) { |
| 274 |
($year, $month, $day) = Add_Delta_Days(split(/-/, $startdate_iso), $weeklength * 7); |
| 275 |
} elsif($monthlength != 0) { |
| 276 |
($year, $month, $day) = Add_Delta_YM(split(/-/, $startdate_iso), 0, $monthlength); |
| 277 |
} |
| 278 |
if(defined $year) { |
| 279 |
$enddate = sprintf("%04d-%02d-%02d", $year, $month, $day); |
| 280 |
} else { |
| 281 |
undef $enddate; |
| 282 |
} |
| 283 |
return $enddate; |
| 284 |
} |
266 |
} |
| 285 |
|
267 |
|
| 286 |
sub redirect_add_subscription { |
268 |
sub redirect_add_subscription { |
|
Lines 304-309
sub redirect_add_subscription {
Link Here
|
| 304 |
my $cost = $query->param('cost'); |
286 |
my $cost = $query->param('cost'); |
| 305 |
my $aqbudgetid = $query->param('aqbudgetid'); |
287 |
my $aqbudgetid = $query->param('aqbudgetid'); |
| 306 |
my @irregularity = $query->multi_param('irregularity'); |
288 |
my @irregularity = $query->multi_param('irregularity'); |
|
|
289 |
my @permanent_irregularity = $query->multi_param('permanent_irregularity'); |
| 307 |
my $locale = $query->param('locale'); |
290 |
my $locale = $query->param('locale'); |
| 308 |
my $graceperiod = $query->param('graceperiod') || 0; |
291 |
my $graceperiod = $query->param('graceperiod') || 0; |
| 309 |
|
292 |
|
|
Lines 344-362
sub redirect_add_subscription {
Link Here
|
| 344 |
my $firstacquidate = output_pref( { str => scalar $query->param('firstacquidate'), dateonly => 1, dateformat => 'iso' } ); |
327 |
my $firstacquidate = output_pref( { str => scalar $query->param('firstacquidate'), dateonly => 1, dateformat => 'iso' } ); |
| 345 |
|
328 |
|
| 346 |
if(!defined $enddate || $enddate eq '') { |
329 |
if(!defined $enddate || $enddate eq '') { |
|
|
330 |
my $subscription = Koha::Subscriptions->new({ |
| 331 |
startdate => $startdate, |
| 332 |
periodicity => $periodicity, |
| 333 |
weeklength => $weeklength, |
| 334 |
monthlength =>$monthlength, |
| 335 |
numberlength => $numberlength |
| 336 |
}); |
| 337 |
|
| 347 |
if($subtype eq "issues") { |
338 |
if($subtype eq "issues") { |
| 348 |
$enddate = _guess_enddate($firstacquidate, $periodicity, $numberlength, $weeklength, $monthlength) |
339 |
$subscription->startdate($firstacquidate); |
| 349 |
} else { |
|
|
| 350 |
$enddate = _guess_enddate($startdate, $periodicity, $numberlength, $weeklength, $monthlength) |
| 351 |
} |
340 |
} |
|
|
341 |
$enddate = $subscription->guess_enddate; |
| 352 |
} |
342 |
} |
| 353 |
my $subscriptionid = NewSubscription( |
343 |
my $subscriptionid = NewSubscription( |
| 354 |
$auser, $branchcode, $aqbooksellerid, $cost, $aqbudgetid, $biblionumber, |
344 |
$auser, $branchcode, $aqbooksellerid, $cost, $aqbudgetid, $biblionumber, |
| 355 |
$startdate, $periodicity, $numberlength, $weeklength, |
345 |
$startdate, $periodicity, $numberlength, $weeklength, |
| 356 |
$monthlength, $lastvalue1, $innerloop1, $lastvalue2, $innerloop2, |
346 |
$monthlength, $lastvalue1, $innerloop1, $lastvalue2, $innerloop2, |
| 357 |
$lastvalue3, $innerloop3, $status, $notes, $letter, $firstacquidate, |
347 |
$lastvalue3, $innerloop3, $status, $notes, $letter, $firstacquidate, |
| 358 |
join(";",@irregularity), $numberpattern, $locale, $callnumber, |
348 |
join(";",@irregularity), join(';', @permanent_irregularity), $numberpattern, $locale, |
| 359 |
$manualhistory, $internalnotes, $serialsadditems, |
349 |
$callnumber, $manualhistory, $internalnotes, $serialsadditems, |
| 360 |
$staffdisplaycount, $opacdisplaycount, $graceperiod, $location, $enddate, |
350 |
$staffdisplaycount, $opacdisplaycount, $graceperiod, $location, $enddate, |
| 361 |
$skip_serialseq, $itemtype, $previousitemtype, $mana_id |
351 |
$skip_serialseq, $itemtype, $previousitemtype, $mana_id |
| 362 |
); |
352 |
); |
|
Lines 390-395
sub redirect_add_subscription {
Link Here
|
| 390 |
sub redirect_mod_subscription { |
380 |
sub redirect_mod_subscription { |
| 391 |
my $subscriptionid = $query->param('subscriptionid'); |
381 |
my $subscriptionid = $query->param('subscriptionid'); |
| 392 |
my @irregularity = $query->multi_param('irregularity'); |
382 |
my @irregularity = $query->multi_param('irregularity'); |
|
|
383 |
my @permanent_irregularity = $query->multi_param('permanent_irregularity'); |
| 393 |
my $auser = $query->param('user'); |
384 |
my $auser = $query->param('user'); |
| 394 |
my $librarian => scalar $query->param('librarian'), |
385 |
my $librarian => scalar $query->param('librarian'), |
| 395 |
my $branchcode = $query->param('branchcode'); |
386 |
my $branchcode = $query->param('branchcode'); |
|
Lines 457-467
sub redirect_mod_subscription {
Link Here
|
| 457 |
|
448 |
|
| 458 |
# Guess end date |
449 |
# Guess end date |
| 459 |
if(!defined $enddate || $enddate eq '') { |
450 |
if(!defined $enddate || $enddate eq '') { |
|
|
451 |
my $subscription = Koha::Subscriptions->new({ |
| 452 |
startdate => $startdate, |
| 453 |
periodicity => $periodicity, |
| 454 |
weeklength => $weeklength, |
| 455 |
monthlength =>$monthlength, |
| 456 |
numberlength => $numberlength |
| 457 |
}); |
| 458 |
|
| 460 |
if($subtype eq "issues") { |
459 |
if($subtype eq "issues") { |
| 461 |
$enddate = _guess_enddate($nextacquidate, $periodicity, $numberlength, $weeklength, $monthlength); |
460 |
$subscription->startdate($nextacquidate); |
| 462 |
} else { |
|
|
| 463 |
$enddate = _guess_enddate($startdate, $periodicity, $numberlength, $weeklength, $monthlength); |
| 464 |
} |
461 |
} |
|
|
462 |
$enddate = $subscription->guess_enddate; |
| 465 |
} |
463 |
} |
| 466 |
|
464 |
|
| 467 |
my $nextexpected = GetNextExpected($subscriptionid); |
465 |
my $nextexpected = GetNextExpected($subscriptionid); |
|
Lines 475-481
sub redirect_mod_subscription {
Link Here
|
| 475 |
ModSubscription( |
473 |
ModSubscription( |
| 476 |
$auser, $branchcode, $aqbooksellerid, $cost, $aqbudgetid, $startdate, |
474 |
$auser, $branchcode, $aqbooksellerid, $cost, $aqbudgetid, $startdate, |
| 477 |
$periodicity, $firstacquidate, join(";",@irregularity), |
475 |
$periodicity, $firstacquidate, join(";",@irregularity), |
| 478 |
$numberpattern, $locale, $numberlength, $weeklength, $monthlength, $lastvalue1, |
476 |
join(';', @permanent_irregularity), $numberpattern, $locale, |
|
|
477 |
$numberlength, $weeklength, $monthlength, $lastvalue1, |
| 479 |
$innerloop1, $lastvalue2, $innerloop2, $lastvalue3, $innerloop3, |
478 |
$innerloop1, $lastvalue2, $innerloop2, $lastvalue3, $innerloop3, |
| 480 |
$status, $biblionumber, $callnumber, $notes, $letter, |
479 |
$status, $biblionumber, $callnumber, $notes, $letter, |
| 481 |
$manualhistory, $internalnotes, $serialsadditems, $staffdisplaycount, |
480 |
$manualhistory, $internalnotes, $serialsadditems, $staffdisplaycount, |