Lines 2430-2435
sub GetFictiveIssueNumber {
Link Here
|
2430 |
return $issueno; |
2430 |
return $issueno; |
2431 |
} |
2431 |
} |
2432 |
|
2432 |
|
|
|
2433 |
sub _get_next_date_day { |
2434 |
my ($subscription, $freqdata, $year, $month, $day) = @_; |
2435 |
|
2436 |
if ($subscription->{'countissuesperunit'} + 1 > $freqdata->{'issuesperunit'}){ |
2437 |
($year,$month,$day) = Add_Delta_Days($year,$month, $day , $freqdata->{'unitsperissue'} ); |
2438 |
$subscription->{'countissuesperunit'} = 1; |
2439 |
} else { |
2440 |
$subscription->{'countissuesperunit'}++; |
2441 |
} |
2442 |
|
2443 |
return ($year, $month, $day); |
2444 |
} |
2445 |
|
2446 |
sub _get_next_date_week { |
2447 |
my ($subscription, $freqdata, $year, $month, $day) = @_; |
2448 |
|
2449 |
my ($wkno, $yr) = Week_of_Year($year, $month, $day); |
2450 |
|
2451 |
if ($subscription->{'countissuesperunit'} + 1 > $freqdata->{'issuesperunit'}){ |
2452 |
$subscription->{'countissuesperunit'} = 1; |
2453 |
$wkno += $freqdata->{"unitsperissue"}; |
2454 |
if($wkno > 52){ |
2455 |
$wkno = $wkno % 52; |
2456 |
$yr++; |
2457 |
} |
2458 |
my $dow = Day_of_Week($year, $month, $day); |
2459 |
($year,$month,$day) = Monday_of_Week($wkno, $yr); |
2460 |
if($freqdata->{'issuesperunit'} == 1) { |
2461 |
($year, $month, $day) = Add_Delta_Days($year, $month, $day, $dow - 1); |
2462 |
} |
2463 |
} else { |
2464 |
$subscription->{'countissuesperunit'}++; |
2465 |
} |
2466 |
|
2467 |
return ($year, $month, $day); |
2468 |
} |
2469 |
|
2470 |
sub _get_next_date_month { |
2471 |
my ($subscription, $freqdata, $year, $month, $day) = @_; |
2472 |
|
2473 |
if ($subscription->{'countissuesperunit'} + 1 > $freqdata->{'issuesperunit'}){ |
2474 |
$subscription->{'countissuesperunit'} = 1; |
2475 |
($year,$month,$day) = Add_Delta_YM($year,$month,$day, 0,$freqdata->{"unitsperissue"}); |
2476 |
unless($freqdata->{'issuesperunit'} == 1) { |
2477 |
$day = 1; # Jumping to the first day of month, because we don't know what day is expected |
2478 |
} |
2479 |
} else { |
2480 |
$subscription->{'countissuesperunit'}++; |
2481 |
} |
2482 |
|
2483 |
return ($year, $month, $day); |
2484 |
} |
2485 |
|
2486 |
sub _get_next_date_year { |
2487 |
my ($subscription, $freqdata, $year, $month, $day) = @_; |
2488 |
|
2489 |
if ($subscription->{'countissuesperunit'} + 1 > $freqdata->{'issuesperunit'}){ |
2490 |
$subscription->{'countissuesperunit'} = 1; |
2491 |
($year,$month,$day) = Add_Delta_YM($year,$month,$day, $freqdata->{"unitsperissue"},0); |
2492 |
unless($freqdata->{'issuesperunit'} == 1) { |
2493 |
# Jumping to the first day of year, because we don't know what day is expected |
2494 |
$month = 1; |
2495 |
$day = 1; |
2496 |
} |
2497 |
} else { |
2498 |
$subscription->{'countissuesperunit'}++; |
2499 |
} |
2500 |
|
2501 |
return ($year, $month, $day); |
2502 |
} |
2503 |
|
2433 |
=head2 GetNextDate |
2504 |
=head2 GetNextDate |
2434 |
|
2505 |
|
2435 |
$resultdate = GetNextDate($publisheddate,$subscription) |
2506 |
$resultdate = GetNextDate($publisheddate,$subscription) |
Lines 2480-2586
sub GetNextDate {
Link Here
|
2480 |
my $unit = lc $freqdata->{'unit'}; |
2551 |
my $unit = lc $freqdata->{'unit'}; |
2481 |
if ($unit eq 'day') { |
2552 |
if ($unit eq 'day') { |
2482 |
while ($irregularities{$issueno}) { |
2553 |
while ($irregularities{$issueno}) { |
2483 |
if ($subscription->{'countissuesperunit'} + 1 > $freqdata->{'issuesperunit'}){ |
2554 |
($year, $month, $day) = _get_next_date_day($subscription, |
2484 |
($year,$month,$day) = Add_Delta_Days($year,$month, $day , $freqdata->{'unitsperissue'} ); |
2555 |
$freqdata, $year, $month, $day); |
2485 |
$subscription->{'countissuesperunit'} = 1; |
|
|
2486 |
} else { |
2487 |
$subscription->{'countissuesperunit'}++; |
2488 |
} |
2489 |
$issueno++; |
2556 |
$issueno++; |
2490 |
} |
2557 |
} |
2491 |
if ($subscription->{'countissuesperunit'} + 1 > $freqdata->{'issuesperunit'}){ |
2558 |
($year, $month, $day) = _get_next_date_day($subscription, $freqdata, |
2492 |
($year,$month,$day) = Add_Delta_Days($year,$month, $day , $freqdata->{"unitsperissue"} ); |
2559 |
$year, $month, $day); |
2493 |
$subscription->{'countissuesperunit'} = 1; |
|
|
2494 |
} else { |
2495 |
$subscription->{'countissuesperunit'}++; |
2496 |
} |
2497 |
} |
2560 |
} |
2498 |
elsif ($unit eq 'week') { |
2561 |
elsif ($unit eq 'week') { |
2499 |
my ($wkno, $yr) = Week_of_Year($year, $month, $day); |
|
|
2500 |
while ($irregularities{$issueno}) { |
2562 |
while ($irregularities{$issueno}) { |
2501 |
if ($subscription->{'countissuesperunit'} + 1 > $freqdata->{'issuesperunit'}){ |
2563 |
($year, $month, $day) = _get_next_date_week($subscription, |
2502 |
$subscription->{'countissuesperunit'} = 1; |
2564 |
$freqdata, $year, $month, $day); |
2503 |
$wkno += $freqdata->{"unitsperissue"}; |
|
|
2504 |
if($wkno > 52){ |
2505 |
$wkno = $wkno % 52; |
2506 |
$yr++; |
2507 |
} |
2508 |
my $dow = Day_of_Week($year, $month, $day); |
2509 |
($year,$month,$day) = Monday_of_Week($wkno, $yr); |
2510 |
if($freqdata->{'issuesperunit'} == 1) { |
2511 |
($year, $month, $day) = Add_Delta_Days($year, $month, $day, $dow - 1); |
2512 |
} |
2513 |
} else { |
2514 |
$subscription->{'countissuesperunit'}++; |
2515 |
} |
2516 |
$issueno++; |
2565 |
$issueno++; |
2517 |
} |
2566 |
} |
2518 |
if ($subscription->{'countissuesperunit'} + 1 > $freqdata->{'issuesperunit'}){ |
2567 |
($year, $month, $day) = _get_next_date_week($subscription, |
2519 |
$subscription->{'countissuesperunit'} = 1; |
2568 |
$freqdata, $year, $month, $day); |
2520 |
$wkno += $freqdata->{"unitsperissue"}; |
|
|
2521 |
if($wkno > 52){ |
2522 |
$wkno = $wkno % 52 ; |
2523 |
$yr++; |
2524 |
} |
2525 |
my $dow = Day_of_Week($year, $month, $day); |
2526 |
($year,$month,$day) = Monday_of_Week($wkno, $yr); |
2527 |
if($freqdata->{'issuesperunit'} == 1) { |
2528 |
($year, $month, $day) = Add_Delta_Days($year, $month, $day, $dow - 1); |
2529 |
} |
2530 |
} else { |
2531 |
$subscription->{'countissuesperunit'}++; |
2532 |
} |
2533 |
} |
2569 |
} |
2534 |
elsif ($unit eq 'month') { |
2570 |
elsif ($unit eq 'month') { |
2535 |
while ($irregularities{$issueno}) { |
2571 |
while ($irregularities{$issueno}) { |
2536 |
if ($subscription->{'countissuesperunit'} + 1 > $freqdata->{'issuesperunit'}){ |
2572 |
($year, $month, $day) = _get_next_date_month($subscription, |
2537 |
$subscription->{'countissuesperunit'} = 1; |
2573 |
$freqdata, $year, $month, $day); |
2538 |
($year,$month,$day) = Add_Delta_YM($year,$month,$day, 0,$freqdata->{"unitsperissue"}); |
|
|
2539 |
unless($freqdata->{'issuesperunit'} == 1) { |
2540 |
$day = 1; # Jumping to the first day of month, because we don't know what day is expected |
2541 |
} |
2542 |
} else { |
2543 |
$subscription->{'countissuesperunit'}++; |
2544 |
} |
2545 |
$issueno++; |
2574 |
$issueno++; |
2546 |
} |
2575 |
} |
2547 |
if ($subscription->{'countissuesperunit'} + 1 > $freqdata->{'issuesperunit'}){ |
2576 |
($year, $month, $day) = _get_next_date_month($subscription, |
2548 |
$subscription->{'countissuesperunit'} = 1; |
2577 |
$freqdata, $year, $month, $day); |
2549 |
($year,$month,$day) = Add_Delta_YM($year,$month,$day, 0,$freqdata->{"unitsperissue"}); |
|
|
2550 |
unless($freqdata->{'issuesperunit'} == 1) { |
2551 |
$day = 1; # Jumping to the first day of month, because we don't know what day is expected |
2552 |
} |
2553 |
} else { |
2554 |
$subscription->{'countissuesperunit'}++; |
2555 |
} |
2556 |
} |
2578 |
} |
2557 |
elsif ($unit eq 'year') { |
2579 |
elsif ($unit eq 'year') { |
2558 |
while ($irregularities{$issueno}) { |
2580 |
while ($irregularities{$issueno}) { |
2559 |
if ($subscription->{'countissuesperunit'} + 1 > $freqdata->{'issuesperunit'}){ |
2581 |
($year, $month, $day) = _get_next_date_year($subscription, |
2560 |
$subscription->{'countissuesperunit'} = 1; |
2582 |
$freqdata, $year, $month, $day); |
2561 |
($year,$month,$day) = Add_Delta_YM($year,$month,$day, $freqdata->{"unitsperissue"},0); |
|
|
2562 |
unless($freqdata->{'issuesperunit'} == 1) { |
2563 |
# Jumping to the first day of year, because we don't know what day is expected |
2564 |
$month = 1; |
2565 |
$day = 1; |
2566 |
} |
2567 |
} else { |
2568 |
$subscription->{'countissuesperunit'}++; |
2569 |
} |
2570 |
$issueno++; |
2583 |
$issueno++; |
2571 |
} |
2584 |
} |
2572 |
if ($subscription->{'countissuesperunit'} + 1 > $freqdata->{'issuesperunit'}){ |
2585 |
($year, $month, $day) = _get_next_date_year($subscription, |
2573 |
$subscription->{'countissuesperunit'} = 1; |
2586 |
$freqdata, $year, $month, $day); |
2574 |
($year,$month,$day) = Add_Delta_YM($year,$month,$day, $freqdata->{"unitsperissue"},0); |
|
|
2575 |
unless($freqdata->{'issuesperunit'} == 1) { |
2576 |
# Jumping to the first day of year, because we don't know what day is expected |
2577 |
$month = 1; |
2578 |
$day = 1; |
2579 |
} |
2580 |
} else { |
2581 |
$subscription->{'countissuesperunit'}++; |
2582 |
} |
2583 |
} |
2587 |
} |
|
|
2588 |
|
2584 |
if ($updatecount){ |
2589 |
if ($updatecount){ |
2585 |
my $dbh = C4::Context->dbh; |
2590 |
my $dbh = C4::Context->dbh; |
2586 |
my $query = qq{ |
2591 |
my $query = qq{ |
Lines 2591-2596
sub GetNextDate {
Link Here
|
2591 |
my $sth = $dbh->prepare($query); |
2596 |
my $sth = $dbh->prepare($query); |
2592 |
$sth->execute($subscription->{'countissuesperunit'}, $subscription->{'subscriptionid'}); |
2597 |
$sth->execute($subscription->{'countissuesperunit'}, $subscription->{'subscriptionid'}); |
2593 |
} |
2598 |
} |
|
|
2599 |
|
2594 |
return sprintf("%04d-%02d-%02d", $year, $month, $day); |
2600 |
return sprintf("%04d-%02d-%02d", $year, $month, $day); |
2595 |
} |
2601 |
} |
2596 |
} |
2602 |
} |
2597 |
- |
|
|