Lines 24-29
use C4::Auth qw(haspermission);
Link Here
|
24 |
use C4::Context; |
24 |
use C4::Context; |
25 |
use C4::Dates qw(format_date format_date_in_iso); |
25 |
use C4::Dates qw(format_date format_date_in_iso); |
26 |
use DateTime; |
26 |
use DateTime; |
|
|
27 |
use DateTime::Format::MySQL; |
27 |
use Date::Calc qw(:all); |
28 |
use Date::Calc qw(:all); |
28 |
use POSIX qw(strftime); |
29 |
use POSIX qw(strftime); |
29 |
use C4::Biblio; |
30 |
use C4::Biblio; |
Lines 268-274
sub GetSerialInformation {
Link Here
|
268 |
} |
269 |
} |
269 |
} |
270 |
} |
270 |
$data->{ "status" . $data->{'serstatus'} } = 1; |
271 |
$data->{ "status" . $data->{'serstatus'} } = 1; |
271 |
$data->{'subscriptionexpired'} = HasSubscriptionExpired( $data->{'subscriptionid'} ) && $data->{'status'} == 1; |
272 |
$data->{'subscriptionexpired'} = C4::Serials::HasSerialExpired( $data ) && $data->{'status'} == 1; |
272 |
$data->{'abouttoexpire'} = abouttoexpire( $data->{'subscriptionid'} ); |
273 |
$data->{'abouttoexpire'} = abouttoexpire( $data->{'subscriptionid'} ); |
273 |
$data->{cannotedit} = not can_edit_subscription( $data ); |
274 |
$data->{cannotedit} = not can_edit_subscription( $data ); |
274 |
return $data; |
275 |
return $data; |
Lines 1878-1883
sub HasSubscriptionExpired {
Link Here
|
1878 |
return 0; # Notice that you'll never get here. |
1879 |
return 0; # Notice that you'll never get here. |
1879 |
} |
1880 |
} |
1880 |
|
1881 |
|
|
|
1882 |
=head2 HasSerialExpired |
1883 |
|
1884 |
$has_expired = HasSerialExpired($serial) |
1885 |
|
1886 |
the serial has expired when the serials.publisheddate is beyond the subscription expiration date. |
1887 |
|
1888 |
Used to check if individual serials can still be received even if the subscription |
1889 |
has already expired. |
1890 |
|
1891 |
@param {HASHRef} Serial |
1892 |
|
1893 |
@returns : 0 if the serial has not expired |
1894 |
1 if the serial has expired |
1895 |
2 if has serial does not have a valid expiration date set |
1896 |
|
1897 |
=cut |
1898 |
|
1899 |
sub HasSerialExpired { |
1900 |
my ($serial) = @_; |
1901 |
|
1902 |
return unless ($serial); |
1903 |
|
1904 |
#Normalize dates for comparison |
1905 |
my $expirationdate = DateTime::Format::MySQL->parse_date($serial->{enddate} || GetExpirationDate($serial->{subscriptionid})); |
1906 |
my $publisheddate = Koha::DateUtils::dt_from_string($serial->{publisheddate}); |
1907 |
|
1908 |
if (!defined $expirationdate) { |
1909 |
return 2; |
1910 |
} |
1911 |
if (DateTime->compare($publisheddate, $expirationdate) == -1) { #publisheddate < expirationdate |
1912 |
return 0; |
1913 |
} |
1914 |
return 1; |
1915 |
} |
1916 |
|
1881 |
=head2 SetDistributedto |
1917 |
=head2 SetDistributedto |
1882 |
|
1918 |
|
1883 |
SetDistributedto($distributedto,$subscriptionid); |
1919 |
SetDistributedto($distributedto,$subscriptionid); |