|
Lines 259-304
sub get_letter_loop {
Link Here
|
| 259 |
]; |
259 |
]; |
| 260 |
} |
260 |
} |
| 261 |
|
261 |
|
| 262 |
sub _guess_enddate { |
|
|
| 263 |
my ( $startdate_iso, $frequencyid, $numberlength, $weeklength, $monthlength ) = @_; |
| 264 |
my ( $year, $month, $day ); |
| 265 |
my $enddate; |
| 266 |
if ( $numberlength != 0 ) { |
| 267 |
my $frequency = GetSubscriptionFrequency($frequencyid); |
| 268 |
if ( $frequency->{'unit'} eq 'day' ) { |
| 269 |
( $year, $month, $day ) = Add_Delta_Days( |
| 270 |
split( /-/, $startdate_iso ), |
| 271 |
$numberlength * $frequency->{'unitsperissue'} / $frequency->{'issuesperunit'} |
| 272 |
); |
| 273 |
} elsif ( $frequency->{'unit'} eq 'week' ) { |
| 274 |
( $year, $month, $day ) = Add_Delta_Days( |
| 275 |
split( /-/, $startdate_iso ), |
| 276 |
$numberlength * 7 * $frequency->{'unitsperissue'} / $frequency->{'issuesperunit'} |
| 277 |
); |
| 278 |
} elsif ( $frequency->{'unit'} eq 'month' ) { |
| 279 |
( $year, $month, $day ) = Add_Delta_YM( |
| 280 |
split( /-/, $startdate_iso ), 0, |
| 281 |
$numberlength * $frequency->{'unitsperissue'} / $frequency->{'issuesperunit'} |
| 282 |
); |
| 283 |
} elsif ( $frequency->{'unit'} eq 'year' ) { |
| 284 |
( $year, $month, $day ) = Add_Delta_YM( |
| 285 |
split( /-/, $startdate_iso ), |
| 286 |
$numberlength * $frequency->{'unitsperissue'} / $frequency->{'issuesperunit'}, 0 |
| 287 |
); |
| 288 |
} |
| 289 |
} elsif ( $weeklength != 0 ) { |
| 290 |
( $year, $month, $day ) = Add_Delta_Days( split( /-/, $startdate_iso ), $weeklength * 7 ); |
| 291 |
} elsif ( $monthlength != 0 ) { |
| 292 |
( $year, $month, $day ) = Add_Delta_YM( split( /-/, $startdate_iso ), 0, $monthlength ); |
| 293 |
} |
| 294 |
if ( defined $year ) { |
| 295 |
$enddate = sprintf( "%04d-%02d-%02d", $year, $month, $day ); |
| 296 |
} else { |
| 297 |
undef $enddate; |
| 298 |
} |
| 299 |
return $enddate; |
| 300 |
} |
| 301 |
|
| 302 |
sub redirect_add_subscription { |
262 |
sub redirect_add_subscription { |
| 303 |
my $periodicity = $query->param('frequency'); |
263 |
my $periodicity = $query->param('frequency'); |
| 304 |
if ( $periodicity eq 'mana' ) { |
264 |
if ( $periodicity eq 'mana' ) { |
|
Lines 314-327
sub redirect_add_subscription {
Link Here
|
| 314 |
} |
274 |
} |
| 315 |
my $numberpattern = Koha::Subscription::Numberpatterns->new_or_existing( { $query->Vars } ); |
275 |
my $numberpattern = Koha::Subscription::Numberpatterns->new_or_existing( { $query->Vars } ); |
| 316 |
|
276 |
|
| 317 |
my $auser = $query->param('user'); |
277 |
my $auser = $query->param('user'); |
| 318 |
my $branchcode = $query->param('branchcode'); |
278 |
my $branchcode = $query->param('branchcode'); |
| 319 |
my $aqbooksellerid = $query->param('aqbooksellerid'); |
279 |
my $aqbooksellerid = $query->param('aqbooksellerid'); |
| 320 |
my $cost = $query->param('cost'); |
280 |
my $cost = $query->param('cost'); |
| 321 |
my $aqbudgetid = $query->param('aqbudgetid'); |
281 |
my $aqbudgetid = $query->param('aqbudgetid'); |
| 322 |
my @irregularity = $query->multi_param('irregularity'); |
282 |
my @irregularity = $query->multi_param('irregularity'); |
| 323 |
my $locale = $query->param('locale'); |
283 |
my @permanent_irregularity = $query->multi_param('permanent_irregularity'); |
| 324 |
my $graceperiod = $query->param('graceperiod') || 0; |
284 |
my $locale = $query->param('locale'); |
|
|
285 |
my $graceperiod = $query->param('graceperiod') || 0; |
| 325 |
|
286 |
|
| 326 |
my $subtype = $query->param('subtype'); |
287 |
my $subtype = $query->param('subtype'); |
| 327 |
my $sublength = $query->param('sublength'); |
288 |
my $sublength = $query->param('sublength'); |
|
Lines 363-383
sub redirect_add_subscription {
Link Here
|
| 363 |
output_pref( { str => scalar $query->param('firstacquidate'), dateonly => 1, dateformat => 'iso' } ); |
324 |
output_pref( { str => scalar $query->param('firstacquidate'), dateonly => 1, dateformat => 'iso' } ); |
| 364 |
|
325 |
|
| 365 |
if ( !defined $enddate || $enddate eq '' ) { |
326 |
if ( !defined $enddate || $enddate eq '' ) { |
|
|
327 |
my $subscription = Koha::Subscription->new( |
| 328 |
{ |
| 329 |
startdate => $startdate, |
| 330 |
periodicity => $periodicity, |
| 331 |
weeklength => $weeklength, |
| 332 |
monthlength => $monthlength, |
| 333 |
numberlength => $numberlength |
| 334 |
} |
| 335 |
); |
| 336 |
|
| 366 |
if ( $subtype eq "issues" ) { |
337 |
if ( $subtype eq "issues" ) { |
| 367 |
$enddate = _guess_enddate( $firstacquidate, $periodicity, $numberlength, $weeklength, $monthlength ); |
338 |
$subscription->startdate($firstacquidate); |
| 368 |
} else { |
|
|
| 369 |
$enddate = _guess_enddate( $startdate, $periodicity, $numberlength, $weeklength, $monthlength ); |
| 370 |
} |
339 |
} |
|
|
340 |
$enddate = $subscription->guess_enddate; |
| 371 |
} |
341 |
} |
| 372 |
my $subscriptionid = NewSubscription( |
342 |
my $subscriptionid = NewSubscription( |
| 373 |
$auser, $branchcode, $aqbooksellerid, $cost, $aqbudgetid, $biblionumber, |
343 |
$auser, $branchcode, $aqbooksellerid, $cost, $aqbudgetid, $biblionumber, |
| 374 |
$startdate, $periodicity, $numberlength, $weeklength, |
344 |
$startdate, $periodicity, $numberlength, $weeklength, |
| 375 |
$monthlength, $lastvalue1, $innerloop1, $lastvalue2, $innerloop2, |
345 |
$monthlength, $lastvalue1, $innerloop1, $lastvalue2, $innerloop2, |
| 376 |
$lastvalue3, $innerloop3, $status, $notes, $letter, $firstacquidate, |
346 |
$lastvalue3, $innerloop3, $status, $notes, $letter, $firstacquidate, |
| 377 |
join( ";", @irregularity ), $numberpattern, $locale, $callnumber, |
347 |
join( ";", @irregularity ), join( ';', @permanent_irregularity ), $numberpattern, $locale, $callnumber, |
| 378 |
$manualhistory, $internalnotes, $serialsadditems, |
348 |
$manualhistory, $internalnotes, $serialsadditems, |
| 379 |
$staffdisplaycount, $opacdisplaycount, $graceperiod, $location, $enddate, |
349 |
$staffdisplaycount, $opacdisplaycount, $graceperiod, $location, $enddate, |
| 380 |
$skip_serialseq, $itemtype, $previousitemtype, $mana_id, $ccode, $published_on_template, |
350 |
$skip_serialseq, $itemtype, $previousitemtype, $mana_id, $ccode, $published_on_template, |
| 381 |
$preselect_issues_in_collections_table |
351 |
$preselect_issues_in_collections_table |
| 382 |
); |
352 |
); |
| 383 |
if ( ( C4::Context->preference('Mana') == 1 ) |
353 |
if ( ( C4::Context->preference('Mana') == 1 ) |
|
Lines 399-407
sub redirect_add_subscription {
Link Here
|
| 399 |
} |
369 |
} |
| 400 |
|
370 |
|
| 401 |
sub redirect_mod_subscription { |
371 |
sub redirect_mod_subscription { |
| 402 |
my $subscriptionid = $query->param('subscriptionid'); |
372 |
my $subscriptionid = $query->param('subscriptionid'); |
| 403 |
my @irregularity = $query->multi_param('irregularity'); |
373 |
my @irregularity = $query->multi_param('irregularity'); |
| 404 |
my $auser = $query->param('user'); |
374 |
my @permanent_irregularity = $query->multi_param('permanent_irregularity'); |
|
|
375 |
my $auser = $query->param('user'); |
| 405 |
my $librarian => scalar $query->param('librarian'), |
376 |
my $librarian => scalar $query->param('librarian'), |
| 406 |
my $branchcode = $query->param('branchcode'); |
377 |
my $branchcode = $query->param('branchcode'); |
| 407 |
my $cost = $query->param('cost'); |
378 |
my $cost = $query->param('cost'); |
|
Lines 472-482
sub redirect_mod_subscription {
Link Here
|
| 472 |
|
443 |
|
| 473 |
# Guess end date |
444 |
# Guess end date |
| 474 |
if ( !defined $enddate || $enddate eq '' ) { |
445 |
if ( !defined $enddate || $enddate eq '' ) { |
|
|
446 |
my $subscription = Koha::Subscription->new( |
| 447 |
{ |
| 448 |
startdate => $startdate, |
| 449 |
periodicity => $periodicity, |
| 450 |
weeklength => $weeklength, |
| 451 |
monthlength => $monthlength, |
| 452 |
numberlength => $numberlength |
| 453 |
} |
| 454 |
); |
| 455 |
|
| 475 |
if ( $subtype eq "issues" ) { |
456 |
if ( $subtype eq "issues" ) { |
| 476 |
$enddate = _guess_enddate( $nextacquidate, $periodicity, $numberlength, $weeklength, $monthlength ); |
457 |
$subscription->startdate($nextacquidate); |
| 477 |
} else { |
|
|
| 478 |
$enddate = _guess_enddate( $startdate, $periodicity, $numberlength, $weeklength, $monthlength ); |
| 479 |
} |
458 |
} |
|
|
459 |
$enddate = $subscription->guess_enddate; |
| 480 |
} |
460 |
} |
| 481 |
|
461 |
|
| 482 |
my $nextexpected = GetNextExpected($subscriptionid); |
462 |
my $nextexpected = GetNextExpected($subscriptionid); |
|
Lines 490-497
sub redirect_mod_subscription {
Link Here
|
| 490 |
} |
470 |
} |
| 491 |
|
471 |
|
| 492 |
ModSubscription( |
472 |
ModSubscription( |
| 493 |
$auser, $branchcode, $aqbooksellerid, $cost, $aqbudgetid, $startdate, |
473 |
$auser, $branchcode, $aqbooksellerid, $cost, $aqbudgetid, $startdate, |
| 494 |
$periodicity, $firstacquidate, join( ";", @irregularity ), |
474 |
$periodicity, $firstacquidate, join( ";", @irregularity ), join( ';', @permanent_irregularity ), |
| 495 |
$numberpattern, $locale, $numberlength, $weeklength, $monthlength, $lastvalue1, |
475 |
$numberpattern, $locale, $numberlength, $weeklength, $monthlength, $lastvalue1, |
| 496 |
$innerloop1, $lastvalue2, $innerloop2, $lastvalue3, $innerloop3, |
476 |
$innerloop1, $lastvalue2, $innerloop2, $lastvalue3, $innerloop3, |
| 497 |
$status, $biblionumber, $callnumber, $notes, $letter, |
477 |
$status, $biblionumber, $callnumber, $notes, $letter, |