|
Lines 2484-2489
sub GetFictiveIssueNumber {
Link Here
|
| 2484 |
return $issueno; |
2484 |
return $issueno; |
| 2485 |
} |
2485 |
} |
| 2486 |
|
2486 |
|
|
|
2487 |
sub _get_next_date_day { |
| 2488 |
my ($subscription, $freqdata, $year, $month, $day) = @_; |
| 2489 |
|
| 2490 |
if ($subscription->{'countissuesperunit'} + 1 > $freqdata->{'issuesperunit'}){ |
| 2491 |
($year,$month,$day) = Add_Delta_Days($year,$month, $day , $freqdata->{'unitsperissue'} ); |
| 2492 |
$subscription->{'countissuesperunit'} = 1; |
| 2493 |
} else { |
| 2494 |
$subscription->{'countissuesperunit'}++; |
| 2495 |
} |
| 2496 |
|
| 2497 |
return ($year, $month, $day); |
| 2498 |
} |
| 2499 |
|
| 2500 |
sub _get_next_date_week { |
| 2501 |
my ($subscription, $freqdata, $year, $month, $day) = @_; |
| 2502 |
|
| 2503 |
my ($wkno, $yr) = Week_of_Year($year, $month, $day); |
| 2504 |
|
| 2505 |
if ($subscription->{'countissuesperunit'} + 1 > $freqdata->{'issuesperunit'}){ |
| 2506 |
$subscription->{'countissuesperunit'} = 1; |
| 2507 |
$wkno += $freqdata->{"unitsperissue"}; |
| 2508 |
if($wkno > 52){ |
| 2509 |
$wkno = $wkno % 52; |
| 2510 |
$yr++; |
| 2511 |
} |
| 2512 |
my $dow = Day_of_Week($year, $month, $day); |
| 2513 |
($year,$month,$day) = Monday_of_Week($wkno, $yr); |
| 2514 |
if($freqdata->{'issuesperunit'} == 1) { |
| 2515 |
($year, $month, $day) = Add_Delta_Days($year, $month, $day, $dow - 1); |
| 2516 |
} |
| 2517 |
} else { |
| 2518 |
$subscription->{'countissuesperunit'}++; |
| 2519 |
} |
| 2520 |
|
| 2521 |
return ($year, $month, $day); |
| 2522 |
} |
| 2523 |
|
| 2524 |
sub _get_next_date_month { |
| 2525 |
my ($subscription, $freqdata, $year, $month, $day) = @_; |
| 2526 |
|
| 2527 |
if ($subscription->{'countissuesperunit'} + 1 > $freqdata->{'issuesperunit'}){ |
| 2528 |
$subscription->{'countissuesperunit'} = 1; |
| 2529 |
($year,$month,$day) = Add_Delta_YM($year,$month,$day, 0,$freqdata->{"unitsperissue"}); |
| 2530 |
unless($freqdata->{'issuesperunit'} == 1) { |
| 2531 |
$day = 1; # Jumping to the first day of month, because we don't know what day is expected |
| 2532 |
} |
| 2533 |
} else { |
| 2534 |
$subscription->{'countissuesperunit'}++; |
| 2535 |
} |
| 2536 |
|
| 2537 |
return ($year, $month, $day); |
| 2538 |
} |
| 2539 |
|
| 2540 |
sub _get_next_date_year { |
| 2541 |
my ($subscription, $freqdata, $year, $month, $day) = @_; |
| 2542 |
|
| 2543 |
if ($subscription->{'countissuesperunit'} + 1 > $freqdata->{'issuesperunit'}){ |
| 2544 |
$subscription->{'countissuesperunit'} = 1; |
| 2545 |
($year,$month,$day) = Add_Delta_YM($year,$month,$day, $freqdata->{"unitsperissue"},0); |
| 2546 |
unless($freqdata->{'issuesperunit'} == 1) { |
| 2547 |
# Jumping to the first day of year, because we don't know what day is expected |
| 2548 |
$month = 1; |
| 2549 |
$day = 1; |
| 2550 |
} |
| 2551 |
} else { |
| 2552 |
$subscription->{'countissuesperunit'}++; |
| 2553 |
} |
| 2554 |
|
| 2555 |
return ($year, $month, $day); |
| 2556 |
} |
| 2557 |
|
| 2487 |
=head2 GetNextDate |
2558 |
=head2 GetNextDate |
| 2488 |
|
2559 |
|
| 2489 |
$resultdate = GetNextDate($publisheddate,$subscription) |
2560 |
$resultdate = GetNextDate($publisheddate,$subscription) |
|
Lines 2534-2640
sub GetNextDate {
Link Here
|
| 2534 |
my $unit = lc $freqdata->{'unit'}; |
2605 |
my $unit = lc $freqdata->{'unit'}; |
| 2535 |
if ($unit eq 'day') { |
2606 |
if ($unit eq 'day') { |
| 2536 |
while ($irregularities{$issueno}) { |
2607 |
while ($irregularities{$issueno}) { |
| 2537 |
if ($subscription->{'countissuesperunit'} + 1 > $freqdata->{'issuesperunit'}){ |
2608 |
($year, $month, $day) = _get_next_date_day($subscription, |
| 2538 |
($year,$month,$day) = Add_Delta_Days($year,$month, $day , $freqdata->{'unitsperissue'} ); |
2609 |
$freqdata, $year, $month, $day); |
| 2539 |
$subscription->{'countissuesperunit'} = 1; |
|
|
| 2540 |
} else { |
| 2541 |
$subscription->{'countissuesperunit'}++; |
| 2542 |
} |
| 2543 |
$issueno++; |
2610 |
$issueno++; |
| 2544 |
} |
2611 |
} |
| 2545 |
if ($subscription->{'countissuesperunit'} + 1 > $freqdata->{'issuesperunit'}){ |
2612 |
($year, $month, $day) = _get_next_date_day($subscription, $freqdata, |
| 2546 |
($year,$month,$day) = Add_Delta_Days($year,$month, $day , $freqdata->{"unitsperissue"} ); |
2613 |
$year, $month, $day); |
| 2547 |
$subscription->{'countissuesperunit'} = 1; |
|
|
| 2548 |
} else { |
| 2549 |
$subscription->{'countissuesperunit'}++; |
| 2550 |
} |
| 2551 |
} |
2614 |
} |
| 2552 |
elsif ($unit eq 'week') { |
2615 |
elsif ($unit eq 'week') { |
| 2553 |
my ($wkno, $yr) = Week_of_Year($year, $month, $day); |
|
|
| 2554 |
while ($irregularities{$issueno}) { |
2616 |
while ($irregularities{$issueno}) { |
| 2555 |
if ($subscription->{'countissuesperunit'} + 1 > $freqdata->{'issuesperunit'}){ |
2617 |
($year, $month, $day) = _get_next_date_week($subscription, |
| 2556 |
$subscription->{'countissuesperunit'} = 1; |
2618 |
$freqdata, $year, $month, $day); |
| 2557 |
$wkno += $freqdata->{"unitsperissue"}; |
|
|
| 2558 |
if($wkno > 52){ |
| 2559 |
$wkno = $wkno % 52; |
| 2560 |
$yr++; |
| 2561 |
} |
| 2562 |
my $dow = Day_of_Week($year, $month, $day); |
| 2563 |
($year,$month,$day) = Monday_of_Week($wkno, $yr); |
| 2564 |
if($freqdata->{'issuesperunit'} == 1) { |
| 2565 |
($year, $month, $day) = Add_Delta_Days($year, $month, $day, $dow - 1); |
| 2566 |
} |
| 2567 |
} else { |
| 2568 |
$subscription->{'countissuesperunit'}++; |
| 2569 |
} |
| 2570 |
$issueno++; |
2619 |
$issueno++; |
| 2571 |
} |
2620 |
} |
| 2572 |
if ($subscription->{'countissuesperunit'} + 1 > $freqdata->{'issuesperunit'}){ |
2621 |
($year, $month, $day) = _get_next_date_week($subscription, |
| 2573 |
$subscription->{'countissuesperunit'} = 1; |
2622 |
$freqdata, $year, $month, $day); |
| 2574 |
$wkno += $freqdata->{"unitsperissue"}; |
|
|
| 2575 |
if($wkno > 52){ |
| 2576 |
$wkno = $wkno % 52 ; |
| 2577 |
$yr++; |
| 2578 |
} |
| 2579 |
my $dow = Day_of_Week($year, $month, $day); |
| 2580 |
($year,$month,$day) = Monday_of_Week($wkno, $yr); |
| 2581 |
if($freqdata->{'issuesperunit'} == 1) { |
| 2582 |
($year, $month, $day) = Add_Delta_Days($year, $month, $day, $dow - 1); |
| 2583 |
} |
| 2584 |
} else { |
| 2585 |
$subscription->{'countissuesperunit'}++; |
| 2586 |
} |
| 2587 |
} |
2623 |
} |
| 2588 |
elsif ($unit eq 'month') { |
2624 |
elsif ($unit eq 'month') { |
| 2589 |
while ($irregularities{$issueno}) { |
2625 |
while ($irregularities{$issueno}) { |
| 2590 |
if ($subscription->{'countissuesperunit'} + 1 > $freqdata->{'issuesperunit'}){ |
2626 |
($year, $month, $day) = _get_next_date_month($subscription, |
| 2591 |
$subscription->{'countissuesperunit'} = 1; |
2627 |
$freqdata, $year, $month, $day); |
| 2592 |
($year,$month,$day) = Add_Delta_YM($year,$month,$day, 0,$freqdata->{"unitsperissue"}); |
|
|
| 2593 |
unless($freqdata->{'issuesperunit'} == 1) { |
| 2594 |
$day = 1; # Jumping to the first day of month, because we don't know what day is expected |
| 2595 |
} |
| 2596 |
} else { |
| 2597 |
$subscription->{'countissuesperunit'}++; |
| 2598 |
} |
| 2599 |
$issueno++; |
2628 |
$issueno++; |
| 2600 |
} |
2629 |
} |
| 2601 |
if ($subscription->{'countissuesperunit'} + 1 > $freqdata->{'issuesperunit'}){ |
2630 |
($year, $month, $day) = _get_next_date_month($subscription, |
| 2602 |
$subscription->{'countissuesperunit'} = 1; |
2631 |
$freqdata, $year, $month, $day); |
| 2603 |
($year,$month,$day) = Add_Delta_YM($year,$month,$day, 0,$freqdata->{"unitsperissue"}); |
|
|
| 2604 |
unless($freqdata->{'issuesperunit'} == 1) { |
| 2605 |
$day = 1; # Jumping to the first day of month, because we don't know what day is expected |
| 2606 |
} |
| 2607 |
} else { |
| 2608 |
$subscription->{'countissuesperunit'}++; |
| 2609 |
} |
| 2610 |
} |
2632 |
} |
| 2611 |
elsif ($unit eq 'year') { |
2633 |
elsif ($unit eq 'year') { |
| 2612 |
while ($irregularities{$issueno}) { |
2634 |
while ($irregularities{$issueno}) { |
| 2613 |
if ($subscription->{'countissuesperunit'} + 1 > $freqdata->{'issuesperunit'}){ |
2635 |
($year, $month, $day) = _get_next_date_year($subscription, |
| 2614 |
$subscription->{'countissuesperunit'} = 1; |
2636 |
$freqdata, $year, $month, $day); |
| 2615 |
($year,$month,$day) = Add_Delta_YM($year,$month,$day, $freqdata->{"unitsperissue"},0); |
|
|
| 2616 |
unless($freqdata->{'issuesperunit'} == 1) { |
| 2617 |
# Jumping to the first day of year, because we don't know what day is expected |
| 2618 |
$month = 1; |
| 2619 |
$day = 1; |
| 2620 |
} |
| 2621 |
} else { |
| 2622 |
$subscription->{'countissuesperunit'}++; |
| 2623 |
} |
| 2624 |
$issueno++; |
2637 |
$issueno++; |
| 2625 |
} |
2638 |
} |
| 2626 |
if ($subscription->{'countissuesperunit'} + 1 > $freqdata->{'issuesperunit'}){ |
2639 |
($year, $month, $day) = _get_next_date_year($subscription, |
| 2627 |
$subscription->{'countissuesperunit'} = 1; |
2640 |
$freqdata, $year, $month, $day); |
| 2628 |
($year,$month,$day) = Add_Delta_YM($year,$month,$day, $freqdata->{"unitsperissue"},0); |
|
|
| 2629 |
unless($freqdata->{'issuesperunit'} == 1) { |
| 2630 |
# Jumping to the first day of year, because we don't know what day is expected |
| 2631 |
$month = 1; |
| 2632 |
$day = 1; |
| 2633 |
} |
| 2634 |
} else { |
| 2635 |
$subscription->{'countissuesperunit'}++; |
| 2636 |
} |
| 2637 |
} |
2641 |
} |
|
|
2642 |
|
| 2638 |
if ($updatecount){ |
2643 |
if ($updatecount){ |
| 2639 |
my $dbh = C4::Context->dbh; |
2644 |
my $dbh = C4::Context->dbh; |
| 2640 |
my $query = qq{ |
2645 |
my $query = qq{ |
|
Lines 2645-2650
sub GetNextDate {
Link Here
|
| 2645 |
my $sth = $dbh->prepare($query); |
2650 |
my $sth = $dbh->prepare($query); |
| 2646 |
$sth->execute($subscription->{'countissuesperunit'}, $subscription->{'subscriptionid'}); |
2651 |
$sth->execute($subscription->{'countissuesperunit'}, $subscription->{'subscriptionid'}); |
| 2647 |
} |
2652 |
} |
|
|
2653 |
|
| 2648 |
return sprintf("%04d-%02d-%02d", $year, $month, $day); |
2654 |
return sprintf("%04d-%02d-%02d", $year, $month, $day); |
| 2649 |
} |
2655 |
} |
| 2650 |
} |
2656 |
} |
| 2651 |
- |
|
|