|
Lines 247-280
sub get_letter_loop {
Link Here
|
| 247 |
]; |
247 |
]; |
| 248 |
} |
248 |
} |
| 249 |
|
249 |
|
| 250 |
sub _guess_enddate { |
|
|
| 251 |
my ($startdate_iso, $frequencyid, $numberlength, $weeklength, $monthlength) = @_; |
| 252 |
my ($year, $month, $day); |
| 253 |
my $enddate; |
| 254 |
if($numberlength != 0) { |
| 255 |
my $frequency = GetSubscriptionFrequency($frequencyid); |
| 256 |
if($frequency->{'unit'} eq 'day') { |
| 257 |
($year, $month, $day) = Add_Delta_Days(split(/-/, $startdate_iso), $numberlength * $frequency->{'unitsperissue'} / $frequency->{'issuesperunit'}); |
| 258 |
} elsif($frequency->{'unit'} eq 'week') { |
| 259 |
($year, $month, $day) = Add_Delta_Days(split(/-/, $startdate_iso), $numberlength * 7 * $frequency->{'unitsperissue'} / $frequency->{'issuesperunit'}); |
| 260 |
} elsif($frequency->{'unit'} eq 'month') { |
| 261 |
($year, $month, $day) = Add_Delta_YM(split(/-/, $startdate_iso), 0, $numberlength * $frequency->{'unitsperissue'} / $frequency->{'issuesperunit'}); |
| 262 |
} elsif($frequency->{'unit'} eq 'year') { |
| 263 |
($year, $month, $day) = Add_Delta_YM(split(/-/, $startdate_iso), $numberlength * $frequency->{'unitsperissue'} / $frequency->{'issuesperunit'}, 0); |
| 264 |
} |
| 265 |
} elsif($weeklength != 0) { |
| 266 |
($year, $month, $day) = Add_Delta_Days(split(/-/, $startdate_iso), $weeklength * 7); |
| 267 |
} elsif($monthlength != 0) { |
| 268 |
($year, $month, $day) = Add_Delta_YM(split(/-/, $startdate_iso), 0, $monthlength); |
| 269 |
} |
| 270 |
if(defined $year) { |
| 271 |
$enddate = sprintf("%04d-%02d-%02d", $year, $month, $day); |
| 272 |
} else { |
| 273 |
undef $enddate; |
| 274 |
} |
| 275 |
return $enddate; |
| 276 |
} |
| 277 |
|
| 278 |
sub redirect_add_subscription { |
250 |
sub redirect_add_subscription { |
| 279 |
my $periodicity = $query->param('frequency'); |
251 |
my $periodicity = $query->param('frequency'); |
| 280 |
if ($periodicity eq 'mana') { |
252 |
if ($periodicity eq 'mana') { |
|
Lines 296-301
sub redirect_add_subscription {
Link Here
|
| 296 |
my $cost = $query->param('cost'); |
268 |
my $cost = $query->param('cost'); |
| 297 |
my $aqbudgetid = $query->param('aqbudgetid'); |
269 |
my $aqbudgetid = $query->param('aqbudgetid'); |
| 298 |
my @irregularity = $query->multi_param('irregularity'); |
270 |
my @irregularity = $query->multi_param('irregularity'); |
|
|
271 |
my @permanent_irregularity = $query->multi_param('permanent_irregularity'); |
| 299 |
my $locale = $query->param('locale'); |
272 |
my $locale = $query->param('locale'); |
| 300 |
my $graceperiod = $query->param('graceperiod') || 0; |
273 |
my $graceperiod = $query->param('graceperiod') || 0; |
| 301 |
|
274 |
|
|
Lines 338-356
sub redirect_add_subscription {
Link Here
|
| 338 |
my $firstacquidate = output_pref( { str => scalar $query->param('firstacquidate'), dateonly => 1, dateformat => 'iso' } ); |
311 |
my $firstacquidate = output_pref( { str => scalar $query->param('firstacquidate'), dateonly => 1, dateformat => 'iso' } ); |
| 339 |
|
312 |
|
| 340 |
if(!defined $enddate || $enddate eq '') { |
313 |
if(!defined $enddate || $enddate eq '') { |
|
|
314 |
my $subscription = Koha::Subscriptions->new({ |
| 315 |
startdate => $startdate, |
| 316 |
periodicity => $periodicity, |
| 317 |
weeklength => $weeklength, |
| 318 |
monthlength =>$monthlength, |
| 319 |
numberlength => $numberlength |
| 320 |
}); |
| 321 |
|
| 341 |
if($subtype eq "issues") { |
322 |
if($subtype eq "issues") { |
| 342 |
$enddate = _guess_enddate($firstacquidate, $periodicity, $numberlength, $weeklength, $monthlength) |
323 |
$subscription->startdate($firstacquidate); |
| 343 |
} else { |
|
|
| 344 |
$enddate = _guess_enddate($startdate, $periodicity, $numberlength, $weeklength, $monthlength) |
| 345 |
} |
324 |
} |
|
|
325 |
$enddate = $subscription->guess_enddate; |
| 346 |
} |
326 |
} |
| 347 |
my $subscriptionid = NewSubscription( |
327 |
my $subscriptionid = NewSubscription( |
| 348 |
$auser, $branchcode, $aqbooksellerid, $cost, $aqbudgetid, $biblionumber, |
328 |
$auser, $branchcode, $aqbooksellerid, $cost, $aqbudgetid, $biblionumber, |
| 349 |
$startdate, $periodicity, $numberlength, $weeklength, |
329 |
$startdate, $periodicity, $numberlength, $weeklength, |
| 350 |
$monthlength, $lastvalue1, $innerloop1, $lastvalue2, $innerloop2, |
330 |
$monthlength, $lastvalue1, $innerloop1, $lastvalue2, $innerloop2, |
| 351 |
$lastvalue3, $innerloop3, $status, $notes, $letter, $firstacquidate, |
331 |
$lastvalue3, $innerloop3, $status, $notes, $letter, $firstacquidate, |
| 352 |
join(";",@irregularity), $numberpattern, $locale, $callnumber, |
332 |
join(";",@irregularity), join(';', @permanent_irregularity), $numberpattern, $locale, |
| 353 |
$manualhistory, $internalnotes, $serialsadditems, |
333 |
$callnumber, $manualhistory, $internalnotes, $serialsadditems, |
| 354 |
$staffdisplaycount, $opacdisplaycount, $graceperiod, $location, $enddate, |
334 |
$staffdisplaycount, $opacdisplaycount, $graceperiod, $location, $enddate, |
| 355 |
$skip_serialseq, $itemtype, $previousitemtype, $mana_id, $ccode, $published_on_template |
335 |
$skip_serialseq, $itemtype, $previousitemtype, $mana_id, $ccode, $published_on_template |
| 356 |
); |
336 |
); |
|
Lines 370-375
sub redirect_add_subscription {
Link Here
|
| 370 |
sub redirect_mod_subscription { |
350 |
sub redirect_mod_subscription { |
| 371 |
my $subscriptionid = $query->param('subscriptionid'); |
351 |
my $subscriptionid = $query->param('subscriptionid'); |
| 372 |
my @irregularity = $query->multi_param('irregularity'); |
352 |
my @irregularity = $query->multi_param('irregularity'); |
|
|
353 |
my @permanent_irregularity = $query->multi_param('permanent_irregularity'); |
| 373 |
my $auser = $query->param('user'); |
354 |
my $auser = $query->param('user'); |
| 374 |
my $librarian => scalar $query->param('librarian'), |
355 |
my $librarian => scalar $query->param('librarian'), |
| 375 |
my $branchcode = $query->param('branchcode'); |
356 |
my $branchcode = $query->param('branchcode'); |
|
Lines 439-449
sub redirect_mod_subscription {
Link Here
|
| 439 |
|
420 |
|
| 440 |
# Guess end date |
421 |
# Guess end date |
| 441 |
if(!defined $enddate || $enddate eq '') { |
422 |
if(!defined $enddate || $enddate eq '') { |
|
|
423 |
my $subscription = Koha::Subscriptions->new({ |
| 424 |
startdate => $startdate, |
| 425 |
periodicity => $periodicity, |
| 426 |
weeklength => $weeklength, |
| 427 |
monthlength =>$monthlength, |
| 428 |
numberlength => $numberlength |
| 429 |
}); |
| 430 |
|
| 442 |
if($subtype eq "issues") { |
431 |
if($subtype eq "issues") { |
| 443 |
$enddate = _guess_enddate($nextacquidate, $periodicity, $numberlength, $weeklength, $monthlength); |
432 |
$subscription->startdate($nextacquidate); |
| 444 |
} else { |
|
|
| 445 |
$enddate = _guess_enddate($startdate, $periodicity, $numberlength, $weeklength, $monthlength); |
| 446 |
} |
433 |
} |
|
|
434 |
$enddate = $subscription->guess_enddate; |
| 447 |
} |
435 |
} |
| 448 |
|
436 |
|
| 449 |
my $nextexpected = GetNextExpected($subscriptionid); |
437 |
my $nextexpected = GetNextExpected($subscriptionid); |
|
Lines 457-463
sub redirect_mod_subscription {
Link Here
|
| 457 |
ModSubscription( |
445 |
ModSubscription( |
| 458 |
$auser, $branchcode, $aqbooksellerid, $cost, $aqbudgetid, $startdate, |
446 |
$auser, $branchcode, $aqbooksellerid, $cost, $aqbudgetid, $startdate, |
| 459 |
$periodicity, $firstacquidate, join(";",@irregularity), |
447 |
$periodicity, $firstacquidate, join(";",@irregularity), |
| 460 |
$numberpattern, $locale, $numberlength, $weeklength, $monthlength, $lastvalue1, |
448 |
join(';', @permanent_irregularity), $numberpattern, $locale, |
|
|
449 |
$numberlength, $weeklength, $monthlength, $lastvalue1, |
| 461 |
$innerloop1, $lastvalue2, $innerloop2, $lastvalue3, $innerloop3, |
450 |
$innerloop1, $lastvalue2, $innerloop2, $lastvalue3, $innerloop3, |
| 462 |
$status, $biblionumber, $callnumber, $notes, $letter, |
451 |
$status, $biblionumber, $callnumber, $notes, $letter, |
| 463 |
$manualhistory, $internalnotes, $serialsadditems, $staffdisplaycount, |
452 |
$manualhistory, $internalnotes, $serialsadditems, $staffdisplaycount, |