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