|
Lines 50-55
use Koha::Subscription::Routinglists;
Link Here
|
| 50 |
use Koha::Subscriptions; |
50 |
use Koha::Subscriptions; |
| 51 |
use Koha::Suggestions; |
51 |
use Koha::Suggestions; |
| 52 |
use Koha::TemplateUtils qw( process_tt ); |
52 |
use Koha::TemplateUtils qw( process_tt ); |
|
|
53 |
use List::Util qw( first ); |
| 54 |
use Locale::PO; |
| 53 |
|
55 |
|
| 54 |
# Define statuses |
56 |
# Define statuses |
| 55 |
use constant { |
57 |
use constant { |
|
Lines 108-113
BEGIN {
Link Here
|
| 108 |
|
110 |
|
| 109 |
findSerialsByStatus |
111 |
findSerialsByStatus |
| 110 |
|
112 |
|
|
|
113 |
GetSeasonsTranslations |
| 111 |
); |
114 |
); |
| 112 |
} |
115 |
} |
| 113 |
|
116 |
|
|
Lines 319-340
sub GetFullSubscription {
Link Here
|
| 319 |
my $query = qq| |
322 |
my $query = qq| |
| 320 |
SELECT serial.serialid, |
323 |
SELECT serial.serialid, |
| 321 |
serial.serialseq, |
324 |
serial.serialseq, |
| 322 |
serial.planneddate, |
325 |
serial.planneddate, |
| 323 |
serial.publisheddate, |
326 |
serial.publisheddate, |
| 324 |
serial.publisheddatetext, |
327 |
serial.publisheddatetext, |
| 325 |
serial.status, |
328 |
serial.status, |
| 326 |
serial.notes as notes, |
329 |
serial.notes as notes, |
| 327 |
year(IF(serial.publisheddate IS NULL,serial.planneddate,serial.publisheddate)) as year, |
330 |
year(IF(serial.publisheddate IS NULL,serial.planneddate,serial.publisheddate)) as year, |
| 328 |
aqbooksellers.name as aqbooksellername, |
331 |
aqbooksellers.name as aqbooksellername, |
| 329 |
biblio.title as bibliotitle, |
332 |
biblio.title as bibliotitle, |
| 330 |
subscription.branchcode AS branchcode, |
333 |
subscription.branchcode AS branchcode, |
| 331 |
subscription.subscriptionid AS subscriptionid |
334 |
subscription.subscriptionid AS subscriptionid |
| 332 |
FROM serial |
335 |
FROM serial |
| 333 |
LEFT JOIN subscription ON |
336 |
LEFT JOIN subscription ON |
| 334 |
(serial.subscriptionid=subscription.subscriptionid ) |
337 |
(serial.subscriptionid=subscription.subscriptionid ) |
| 335 |
LEFT JOIN aqbooksellers on subscription.aqbooksellerid=aqbooksellers.id |
338 |
LEFT JOIN aqbooksellers on subscription.aqbooksellerid=aqbooksellers.id |
| 336 |
LEFT JOIN biblio on biblio.biblionumber=subscription.biblionumber |
339 |
LEFT JOIN biblio on biblio.biblionumber=subscription.biblionumber |
| 337 |
WHERE serial.subscriptionid = ? |
340 |
WHERE serial.subscriptionid = ? |
| 338 |
ORDER BY year DESC, |
341 |
ORDER BY year DESC, |
| 339 |
IF(serial.publisheddate IS NULL,serial.planneddate,serial.publisheddate) DESC, |
342 |
IF(serial.publisheddate IS NULL,serial.planneddate,serial.publisheddate) DESC, |
| 340 |
serial.subscriptionid |
343 |
serial.subscriptionid |
|
Lines 460-481
sub GetFullSubscriptionsFromBiblionumber {
Link Here
|
| 460 |
my $query = qq| |
463 |
my $query = qq| |
| 461 |
SELECT serial.serialid, |
464 |
SELECT serial.serialid, |
| 462 |
serial.serialseq, |
465 |
serial.serialseq, |
| 463 |
serial.planneddate, |
466 |
serial.planneddate, |
| 464 |
serial.publisheddate, |
467 |
serial.publisheddate, |
| 465 |
serial.publisheddatetext, |
468 |
serial.publisheddatetext, |
| 466 |
serial.status, |
469 |
serial.status, |
| 467 |
serial.notes as notes, |
470 |
serial.notes as notes, |
| 468 |
year(IF(serial.publisheddate IS NULL,serial.planneddate,serial.publisheddate)) as year, |
471 |
year(IF(serial.publisheddate IS NULL,serial.planneddate,serial.publisheddate)) as year, |
| 469 |
biblio.title as bibliotitle, |
472 |
biblio.title as bibliotitle, |
| 470 |
subscription.branchcode AS branchcode, |
473 |
subscription.branchcode AS branchcode, |
| 471 |
subscription.subscriptionid AS subscriptionid, |
474 |
subscription.subscriptionid AS subscriptionid, |
| 472 |
subscription.location AS location |
475 |
subscription.location AS location |
| 473 |
FROM serial |
476 |
FROM serial |
| 474 |
LEFT JOIN subscription ON |
477 |
LEFT JOIN subscription ON |
| 475 |
(serial.subscriptionid=subscription.subscriptionid) |
478 |
(serial.subscriptionid=subscription.subscriptionid) |
| 476 |
LEFT JOIN aqbooksellers on subscription.aqbooksellerid=aqbooksellers.id |
479 |
LEFT JOIN aqbooksellers on subscription.aqbooksellerid=aqbooksellers.id |
| 477 |
LEFT JOIN biblio on biblio.biblionumber=subscription.biblionumber |
480 |
LEFT JOIN biblio on biblio.biblionumber=subscription.biblionumber |
| 478 |
WHERE subscription.biblionumber = ? |
481 |
WHERE subscription.biblionumber = ? |
| 479 |
ORDER BY year DESC, |
482 |
ORDER BY year DESC, |
| 480 |
IF(serial.publisheddate IS NULL,serial.planneddate,serial.publisheddate) DESC, |
483 |
IF(serial.publisheddate IS NULL,serial.planneddate,serial.publisheddate) DESC, |
| 481 |
serial.subscriptionid |
484 |
serial.subscriptionid |
|
Lines 726-732
sub GetSerials2 {
Link Here
|
| 726 |
my $query = q| |
729 |
my $query = q| |
| 727 |
SELECT serialid,serialseq, status, planneddate, publisheddate, |
730 |
SELECT serialid,serialseq, status, planneddate, publisheddate, |
| 728 |
publisheddatetext, notes, routingnotes |
731 |
publisheddatetext, notes, routingnotes |
| 729 |
FROM serial |
732 |
FROM serial |
| 730 |
WHERE subscriptionid=? |
733 |
WHERE subscriptionid=? |
| 731 |
| |
734 |
| |
| 732 |
. q| AND status IN (| . join( ",", ('?') x @$statuses ) . q|)| . q| |
735 |
. q| AND status IN (| . join( ",", ('?') x @$statuses ) . q|)| . q| |
|
Lines 861-866
sub GetNextSeq {
Link Here
|
| 861 |
$newinnerloop1 = $subscription->{innerloop1} || 0; |
864 |
$newinnerloop1 = $subscription->{innerloop1} || 0; |
| 862 |
$newinnerloop2 = $subscription->{innerloop2} || 0; |
865 |
$newinnerloop2 = $subscription->{innerloop2} || 0; |
| 863 |
$newinnerloop3 = $subscription->{innerloop3} || 0; |
866 |
$newinnerloop3 = $subscription->{innerloop3} || 0; |
|
|
867 |
my $translations = $subscription->{translations}; |
| 864 |
my %calc; |
868 |
my %calc; |
| 865 |
|
869 |
|
| 866 |
foreach (qw/X Y Z/) { |
870 |
foreach (qw/X Y Z/) { |
|
Lines 905-920
sub GetNextSeq {
Link Here
|
| 905 |
$newlastvalue3 = $pattern->{setto3} if ( $newlastvalue3 > $pattern->{whenmorethan3} ); |
909 |
$newlastvalue3 = $pattern->{setto3} if ( $newlastvalue3 > $pattern->{whenmorethan3} ); |
| 906 |
} |
910 |
} |
| 907 |
} |
911 |
} |
| 908 |
if ( $calc{'X'} ) { |
912 |
if($calc{'X'}) { |
| 909 |
my $newlastvalue1string = _numeration( $newlastvalue1, $pattern->{numbering1}, $locale ); |
913 |
my $newlastvalue1string = _numeration( $newlastvalue1, $pattern->{numbering1}, $locale, $translations ); |
| 910 |
$calculated =~ s/\{X\}/$newlastvalue1string/g; |
914 |
$calculated =~ s/\{X\}/$newlastvalue1string/g; |
| 911 |
} |
915 |
} |
| 912 |
if ( $calc{'Y'} ) { |
916 |
if($calc{'Y'}) { |
| 913 |
my $newlastvalue2string = _numeration( $newlastvalue2, $pattern->{numbering2}, $locale ); |
917 |
my $newlastvalue2string = _numeration( $newlastvalue2, $pattern->{numbering2}, $locale, $translations ); |
| 914 |
$calculated =~ s/\{Y\}/$newlastvalue2string/g; |
918 |
$calculated =~ s/\{Y\}/$newlastvalue2string/g; |
| 915 |
} |
919 |
} |
| 916 |
if ( $calc{'Z'} ) { |
920 |
if($calc{'Z'}) { |
| 917 |
my $newlastvalue3string = _numeration( $newlastvalue3, $pattern->{numbering3}, $locale ); |
921 |
my $newlastvalue3string = _numeration( $newlastvalue3, $pattern->{numbering3}, $locale, $translations ); |
| 918 |
$calculated =~ s/\{Z\}/$newlastvalue3string/g; |
922 |
$calculated =~ s/\{Z\}/$newlastvalue3string/g; |
| 919 |
} |
923 |
} |
| 920 |
|
924 |
|
|
Lines 952-972
sub GetSeq {
Link Here
|
| 952 |
|
956 |
|
| 953 |
my $locale = $subscription->{locale}; |
957 |
my $locale = $subscription->{locale}; |
| 954 |
|
958 |
|
|
|
959 |
my $translations = $subscription->{translations}; |
| 960 |
|
| 955 |
my $calculated = $pattern->{numberingmethod}; |
961 |
my $calculated = $pattern->{numberingmethod}; |
| 956 |
|
962 |
|
| 957 |
my $newlastvalue1 = $subscription->{'lastvalue1'} || 0; |
963 |
my $newlastvalue1 = $subscription->{'lastvalue1'} || 0; |
| 958 |
$newlastvalue1 = _numeration( $newlastvalue1, $pattern->{numbering1}, $locale ) |
964 |
$newlastvalue1 = _numeration($newlastvalue1, $pattern->{numbering1}, $locale, $translations) if ($pattern->{numbering1}); # reset counter if needed. |
| 959 |
if ( $pattern->{numbering1} ); # reset counter if needed. |
|
|
| 960 |
$calculated =~ s/\{X\}/$newlastvalue1/g; |
965 |
$calculated =~ s/\{X\}/$newlastvalue1/g; |
| 961 |
|
966 |
|
| 962 |
my $newlastvalue2 = $subscription->{'lastvalue2'} || 0; |
967 |
my $newlastvalue2 = $subscription->{'lastvalue2'} || 0; |
| 963 |
$newlastvalue2 = _numeration( $newlastvalue2, $pattern->{numbering2}, $locale ) |
968 |
$newlastvalue2 = _numeration($newlastvalue2, $pattern->{numbering2}, $locale, $translations) if ($pattern->{numbering2}); # reset counter if needed. |
| 964 |
if ( $pattern->{numbering2} ); # reset counter if needed. |
|
|
| 965 |
$calculated =~ s/\{Y\}/$newlastvalue2/g; |
969 |
$calculated =~ s/\{Y\}/$newlastvalue2/g; |
| 966 |
|
970 |
|
| 967 |
my $newlastvalue3 = $subscription->{'lastvalue3'} || 0; |
971 |
my $newlastvalue3 = $subscription->{'lastvalue3'} || 0; |
| 968 |
$newlastvalue3 = _numeration( $newlastvalue3, $pattern->{numbering3}, $locale ) |
972 |
$newlastvalue3 = _numeration($newlastvalue3, $pattern->{numbering3}, $locale, $translations) if ($pattern->{numbering3}); # reset counter if needed. |
| 969 |
if ( $pattern->{numbering3} ); # reset counter if needed. |
|
|
| 970 |
$calculated =~ s/\{Z\}/$newlastvalue3/g; |
973 |
$calculated =~ s/\{Z\}/$newlastvalue3/g; |
| 971 |
|
974 |
|
| 972 |
my $dt = dt_from_string( $subscription->{firstacquidate} ); |
975 |
my $dt = dt_from_string( $subscription->{firstacquidate} ); |
|
Lines 1072-1078
sub ModSubscriptionHistory {
Link Here
|
| 1072 |
return unless ($subscriptionid); |
1075 |
return unless ($subscriptionid); |
| 1073 |
|
1076 |
|
| 1074 |
my $dbh = C4::Context->dbh; |
1077 |
my $dbh = C4::Context->dbh; |
| 1075 |
my $query = "UPDATE subscriptionhistory |
1078 |
my $query = "UPDATE subscriptionhistory |
| 1076 |
SET histstartdate=?,histenddate=?,recievedlist=?,missinglist=?,opacnote=?,librariannote=? |
1079 |
SET histstartdate=?,histenddate=?,recievedlist=?,missinglist=?,opacnote=?,librariannote=? |
| 1077 |
WHERE subscriptionid=? |
1080 |
WHERE subscriptionid=? |
| 1078 |
"; |
1081 |
"; |
|
Lines 1279-1285
sub GetNextExpected {
Link Here
|
| 1279 |
ModNextExpected($subscriptionid,$date) |
1282 |
ModNextExpected($subscriptionid,$date) |
| 1280 |
|
1283 |
|
| 1281 |
Update the planneddate for the current expected issue of the subscription. |
1284 |
Update the planneddate for the current expected issue of the subscription. |
| 1282 |
This will modify all future prediction results. |
1285 |
This will modify all future prediction results. |
| 1283 |
|
1286 |
|
| 1284 |
C<$date> is an ISO date. |
1287 |
C<$date> is an ISO date. |
| 1285 |
|
1288 |
|
|
Lines 1582-1588
sub ReNewSubscription {
Link Here
|
| 1582 |
my $subscription = GetSubscription($subscriptionid); |
1585 |
my $subscription = GetSubscription($subscriptionid); |
| 1583 |
my $query = qq| |
1586 |
my $query = qq| |
| 1584 |
SELECT * |
1587 |
SELECT * |
| 1585 |
FROM biblio |
1588 |
FROM biblio |
| 1586 |
LEFT JOIN biblioitems ON biblio.biblionumber=biblioitems.biblionumber |
1589 |
LEFT JOIN biblioitems ON biblio.biblionumber=biblioitems.biblionumber |
| 1587 |
WHERE biblio.biblionumber=? |
1590 |
WHERE biblio.biblionumber=? |
| 1588 |
|; |
1591 |
|; |
|
Lines 1719-1725
sub NewIssue {
Link Here
|
| 1719 |
|
1722 |
|
| 1720 |
1 or 0 = HasSubscriptionStrictlyExpired($subscriptionid) |
1723 |
1 or 0 = HasSubscriptionStrictlyExpired($subscriptionid) |
| 1721 |
|
1724 |
|
| 1722 |
the subscription has stricly expired when today > the end subscription date |
1725 |
the subscription has stricly expired when today > the end subscription date |
| 1723 |
|
1726 |
|
| 1724 |
return : |
1727 |
return : |
| 1725 |
1 if true, 0 if false, -1 if the expiration date is not set. |
1728 |
1 if true, 0 if false, -1 if the expiration date is not set. |
|
Lines 1907-1913
sub DelIssue {
Link Here
|
| 1907 |
this function selects missing issues on database - where serial.status = MISSING* or serial.status = LATE or planneddate<now |
1910 |
this function selects missing issues on database - where serial.status = MISSING* or serial.status = LATE or planneddate<now |
| 1908 |
|
1911 |
|
| 1909 |
return : |
1912 |
return : |
| 1910 |
the issuelist as an array of hash refs. Each element of this array contains |
1913 |
the issuelist as an array of hash refs. Each element of this array contains |
| 1911 |
name,title,planneddate,serialseq,serial.subscriptionid from tables : subscription, serial & biblio |
1914 |
name,title,planneddate,serialseq,serial.subscriptionid from tables : subscription, serial & biblio |
| 1912 |
|
1915 |
|
| 1913 |
=cut |
1916 |
=cut |
|
Lines 2040-2046
sub check_routing {
Link Here
|
| 2040 |
|
2043 |
|
| 2041 |
my $dbh = C4::Context->dbh; |
2044 |
my $dbh = C4::Context->dbh; |
| 2042 |
my $sth = $dbh->prepare( |
2045 |
my $sth = $dbh->prepare( |
| 2043 |
"SELECT count(routingid) routingids FROM subscription LEFT JOIN subscriptionroutinglist |
2046 |
"SELECT count(routingid) routingids FROM subscription LEFT JOIN subscriptionroutinglist |
| 2044 |
ON subscription.subscriptionid = subscriptionroutinglist.subscriptionid |
2047 |
ON subscription.subscriptionid = subscriptionroutinglist.subscriptionid |
| 2045 |
WHERE subscription.subscriptionid = ? GROUP BY routingid ORDER BY ranking ASC |
2048 |
WHERE subscription.subscriptionid = ? GROUP BY routingid ORDER BY ranking ASC |
| 2046 |
" |
2049 |
" |
|
Lines 2172-2178
sub getroutinglist {
Link Here
|
| 2172 |
my $dbh = C4::Context->dbh; |
2175 |
my $dbh = C4::Context->dbh; |
| 2173 |
my $sth = $dbh->prepare( |
2176 |
my $sth = $dbh->prepare( |
| 2174 |
'SELECT routingid, borrowernumber, ranking, biblionumber |
2177 |
'SELECT routingid, borrowernumber, ranking, biblionumber |
| 2175 |
FROM subscription |
2178 |
FROM subscription |
| 2176 |
JOIN subscriptionroutinglist ON subscription.subscriptionid = subscriptionroutinglist.subscriptionid |
2179 |
JOIN subscriptionroutinglist ON subscription.subscriptionid = subscriptionroutinglist.subscriptionid |
| 2177 |
WHERE subscription.subscriptionid = ? ORDER BY ranking ASC' |
2180 |
WHERE subscription.subscriptionid = ? ORDER BY ranking ASC' |
| 2178 |
); |
2181 |
); |
|
Lines 2240-2246
sub HasItems {
Link Here
|
| 2240 |
my $dbh = C4::Context->dbh; |
2243 |
my $dbh = C4::Context->dbh; |
| 2241 |
my $query = q| |
2244 |
my $query = q| |
| 2242 |
SELECT COUNT(serialitems.itemnumber) |
2245 |
SELECT COUNT(serialitems.itemnumber) |
| 2243 |
FROM serial |
2246 |
FROM serial |
| 2244 |
LEFT JOIN serialitems USING(serialid) |
2247 |
LEFT JOIN serialitems USING(serialid) |
| 2245 |
WHERE subscriptionid=? AND serialitems.serialid IS NOT NULL |
2248 |
WHERE subscriptionid=? AND serialitems.serialid IS NOT NULL |
| 2246 |
|; |
2249 |
|; |
|
Lines 2606-2612
num_type can take :
Link Here
|
| 2606 |
=cut |
2609 |
=cut |
| 2607 |
|
2610 |
|
| 2608 |
sub _numeration { |
2611 |
sub _numeration { |
| 2609 |
my ( $value, $num_type, $locale ) = @_; |
2612 |
my ($value, $num_type, $locale, $translations) = @_; |
| 2610 |
$value ||= 0; |
2613 |
$value ||= 0; |
| 2611 |
$num_type //= ''; |
2614 |
$num_type //= ''; |
| 2612 |
$locale ||= 'en'; |
2615 |
$locale ||= 'en'; |
|
Lines 2637-2649
sub _numeration {
Link Here
|
| 2637 |
? $dt->format_cldr("LLLL") |
2640 |
? $dt->format_cldr("LLLL") |
| 2638 |
: $dt->strftime("%b"); |
2641 |
: $dt->strftime("%b"); |
| 2639 |
} elsif ( $num_type =~ /^season$/ ) { |
2642 |
} elsif ( $num_type =~ /^season$/ ) { |
| 2640 |
my @seasons = qw( Spring Summer Fall Winter ); |
2643 |
$value = $value % 4; |
| 2641 |
$value = $value % 4; |
2644 |
$string = $translations->{seasons}->[$value]; |
| 2642 |
$string = $seasons[$value]; |
|
|
| 2643 |
} elsif ( $num_type =~ /^seasonabrv$/ ) { |
2645 |
} elsif ( $num_type =~ /^seasonabrv$/ ) { |
| 2644 |
my @seasonsabrv = qw( Spr Sum Fal Win ); |
2646 |
$value = $value % 4; |
| 2645 |
$value = $value % 4; |
2647 |
$string = $translations->{seasonsabrv}->[$value]; |
| 2646 |
$string = $seasonsabrv[$value]; |
|
|
| 2647 |
} else { |
2648 |
} else { |
| 2648 |
$string = $value; |
2649 |
$string = $value; |
| 2649 |
} |
2650 |
} |
|
Lines 2713-2718
sub ReopenSubscription {
Link Here
|
| 2713 |
$sth->execute( EXPECTED, $subscriptionid, STOPPED ); |
2714 |
$sth->execute( EXPECTED, $subscriptionid, STOPPED ); |
| 2714 |
} |
2715 |
} |
| 2715 |
|
2716 |
|
|
|
2717 |
=head2 GetSeasonsTranslations |
| 2718 |
|
| 2719 |
Provide translations for the seasons and their abbreviations for the specified locale |
| 2720 |
|
| 2721 |
=cut |
| 2722 |
|
| 2723 |
sub GetSeasonsTranslations { |
| 2724 |
my ( $need_seasons, $need_seasonsabrv, $subtag ) = @_; |
| 2725 |
my @seasons = qw( Spring Summer Fall Winter ); |
| 2726 |
my @seasonsabrv = qw( Spr Sum Fal Win ); |
| 2727 |
my @error_messages = qw(); |
| 2728 |
|
| 2729 |
my @dirs = ( |
| 2730 |
C4::Context->config('intranetdir') . '/misc/translator/po', |
| 2731 |
C4::Context->config('intranetdir') . '/../../misc/translator/po', |
| 2732 |
); |
| 2733 |
|
| 2734 |
my $dir = first { -d } @dirs; |
| 2735 |
|
| 2736 |
if ($dir) { |
| 2737 |
my @po_paths = glob("$dir/$subtag*staff-prog.po"); |
| 2738 |
if (@po_paths) { |
| 2739 |
my $po_path = $po_paths[0]; |
| 2740 |
my $po_filename = ( $po_path =~ s/$dir\///gr ); |
| 2741 |
my $po_data = Locale::PO->load_file_ashash( $po_path, 'utf8' ); |
| 2742 |
|
| 2743 |
if ($need_seasons) { |
| 2744 |
my $response = _translate( $po_data, @seasons ); |
| 2745 |
@seasons = @{ $response->{translations} }; |
| 2746 |
@error_messages = |
| 2747 |
( @error_messages, map { sprintf( $_, $po_filename ) } @{ $response->{error_messages} } ); |
| 2748 |
} |
| 2749 |
|
| 2750 |
if ($need_seasonsabrv) { |
| 2751 |
my $response = _translate( $po_data, @seasonsabrv ); |
| 2752 |
@seasonsabrv = @{ $response->{translations} }; |
| 2753 |
@error_messages = |
| 2754 |
( @error_messages, map { sprintf( $_, $po_filename ) } @{ $response->{error_messages} } ); |
| 2755 |
} |
| 2756 |
} else { |
| 2757 |
push( |
| 2758 |
@error_messages, |
| 2759 |
"No translation file found for $subtag. Ensure that the translation files for $subtag are installed." |
| 2760 |
); |
| 2761 |
} |
| 2762 |
} else { |
| 2763 |
push( @error_messages, "The PO directory has not been found. There is a problem in your Koha installation." ); |
| 2764 |
} |
| 2765 |
|
| 2766 |
return { seasons => \@seasons, seasonsabrv => \@seasonsabrv, error_messages => \@error_messages }; |
| 2767 |
} |
| 2768 |
|
| 2716 |
=head2 subscriptionCurrentlyOnOrder |
2769 |
=head2 subscriptionCurrentlyOnOrder |
| 2717 |
|
2770 |
|
| 2718 |
$bool = subscriptionCurrentlyOnOrder( $subscriptionid ); |
2771 |
$bool = subscriptionCurrentlyOnOrder( $subscriptionid ); |
|
Lines 2803-2808
sub _can_do_on_subscription {
Link Here
|
| 2803 |
return 0; |
2856 |
return 0; |
| 2804 |
} |
2857 |
} |
| 2805 |
|
2858 |
|
|
|
2859 |
=head2 _translate |
| 2860 |
|
| 2861 |
Provide translations for the given words based on the provided data |
| 2862 |
|
| 2863 |
=cut |
| 2864 |
|
| 2865 |
sub _translate { |
| 2866 |
my ( $data, @words ) = @_; |
| 2867 |
|
| 2868 |
my @translations = qw(); |
| 2869 |
my @error_messages = qw(); |
| 2870 |
|
| 2871 |
for my $word (@words) { |
| 2872 |
my $regex = qr/^"$word"$|\%s$word\%s/; |
| 2873 |
my @msgids = grep /$regex/, keys %{$data}; |
| 2874 |
my $translation = ""; |
| 2875 |
|
| 2876 |
while ( ( $translation eq "" ) && ( my $msgid = shift(@msgids) ) ) { |
| 2877 |
next unless ( $data->{$msgid}->reference =~ /serials/ ); |
| 2878 |
my $msgstr = $data->{$msgid}->msgstr; |
| 2879 |
my @ids = split( /\%s/, $msgid ); |
| 2880 |
my @strs = split( /\%s/, $msgstr ); |
| 2881 |
|
| 2882 |
next unless ( scalar @ids == scalar @strs ); |
| 2883 |
|
| 2884 |
my $idx = first { $ids[$_] eq $word || $ids[$_] eq $msgid } 0 .. $#ids; |
| 2885 |
$translation = Locale::PO->dequote( $strs[$idx] ) if ( defined $idx ); |
| 2886 |
} |
| 2887 |
|
| 2888 |
if ( $translation eq "" ) { |
| 2889 |
push( @translations, $word ); |
| 2890 |
push( @error_messages, "The translation for $word doesn't exist in the file \%s" ); |
| 2891 |
next; |
| 2892 |
} |
| 2893 |
|
| 2894 |
push( @translations, $translation ); |
| 2895 |
} |
| 2896 |
|
| 2897 |
return { translations => \@translations, error_messages => \@error_messages }; |
| 2898 |
} |
| 2899 |
|
| 2806 |
=head2 findSerialsByStatus |
2900 |
=head2 findSerialsByStatus |
| 2807 |
|
2901 |
|
| 2808 |
@serials = findSerialsByStatus($status, $subscriptionid); |
2902 |
@serials = findSerialsByStatus($status, $subscriptionid); |