foreach my $key ( sort { $b cmp $a } keys %tmpresults ) {
push @res, $tmpresults{$key};
}
- $res[0]->{'first'} = 1;
return \@res;
}
my @sqlstrings;
my @strings_to_search;
@strings_to_search = map { "%$_%" } split( / /, $string );
- foreach my $index qw(biblio.title subscription.callnumber subscription.location subscription.notes subscription.internalnotes) {
+ foreach my $index (qw(biblio.title subscription.callnumber subscription.location subscription.notes subscription.internalnotes)) {
push @bind_params, @strings_to_search;
my $tmpstring = "AND $index LIKE ? " x scalar(@strings_to_search);
$debug && warn "$tmpstring";
$tmpstring =~ s/^AND //;
push @sqlstrings, $tmpstring;
}
- $sqlwhere .= ( $sqlwhere ? " AND " : " WHERE " ) . "(" . join( ") OR (", @sqlstrings ) . ")";
+ $sqlwhere .= ( $sqlwhere ? " AND " : " WHERE " ) . "((" . join( ") OR (", @sqlstrings ) . "))";
}
if ($issn) {
my @sqlstrings;
my @strings_to_search;
@strings_to_search = map { "%$_%" } split( / /, $issn );
- foreach my $index qw(biblioitems.issn subscription.callnumber) {
+ foreach my $index ( qw(biblioitems.issn subscription.callnumber)) {
push @bind_params, @strings_to_search;
my $tmpstring = "OR $index LIKE ? " x scalar(@strings_to_search);
$debug && warn "$tmpstring";
$tmpstring =~ s/^OR //;
push @sqlstrings, $tmpstring;
}
- $sqlwhere .= ( $sqlwhere ? " AND " : " WHERE " ) . "(" . join( ") OR (", @sqlstrings ) . ")";
+ $sqlwhere .= ( $sqlwhere ? " AND " : " WHERE " ) . "((" . join( ") OR (", @sqlstrings ) . "))";
}
$sql .= "$sqlwhere ORDER BY title";
$debug and warn "GetSubscriptions query: $sql params : ", join( " ", @bind_params );
my $odd = 1;
while ( my $line = $sth->fetchrow_hashref ) {
- if ( $previousbiblio eq $line->{biblionumber} ) {
- $line->{title} = "";
- $line->{issn} = "";
- } else {
- $previousbiblio = $line->{biblionumber};
- $odd = -$odd;
- }
- $line->{toggle} = 1 if $odd == 1;
$line->{'cannotedit'} =
( C4::Context->preference('IndependantBranches')
&& C4::Context->userenv
my $sth = $dbh->prepare($query);
$sth->execute($subscriptionid);
my ($res) = $sth->fetchrow;
- return 0 unless $res;
+ if (!$res || $res=~m/^0000/) {
+ return 0;
+ }
my @res = split( /-/, $res );
my @endofsubscriptiondate = split( /-/, $expirationdate );
return 2 if ( scalar(@res) != 3 || scalar(@endofsubscriptiondate) != 3 || not check_date(@res) || not check_date(@endofsubscriptiondate) );
=head2 getroutinglist
-($count,@routinglist) = getroutinglist($subscriptionid)
+@routinglist = getroutinglist($subscriptionid)
this gets the info from the subscriptionroutinglist for $subscriptionid
return :
-a count of the number of members on routinglist
the routinglist as an array. Each element of the array contains a hash_ref containing
routingid - a unique id, borrowernumber, ranking, and biblionumber of subscription
my ($subscriptionid) = @_;
my $dbh = C4::Context->dbh;
my $sth = $dbh->prepare(
- "SELECT routingid, borrowernumber, ranking, biblionumber
+ 'SELECT routingid, borrowernumber, ranking, biblionumber
FROM subscription
JOIN subscriptionroutinglist ON subscription.subscriptionid = subscriptionroutinglist.subscriptionid
- WHERE subscription.subscriptionid = ? ORDER BY ranking ASC
- "
+ WHERE subscription.subscriptionid = ? ORDER BY ranking ASC'
);
$sth->execute($subscriptionid);
- my @routinglist;
- my $count = 0;
- while ( my $line = $sth->fetchrow_hashref ) {
- $count++;
- push( @routinglist, $line );
- }
- return ( $count, @routinglist );
+ my $routinglist = $sth->fetchall_arrayref({});
+ return @{$routinglist};
}
=head2 countissuesfrom
@res=Date::Calc::Today;
}
my @endofsubscriptiondate=split(/-/,$expirationdate);
- my @per_list = (0, 7, 7, 14, 21, 31, 62, 93, 93, 190, 365, 730, 0, 0, 0, 0);
+ my @per_list = (0, 7, 7, 14, 21, 31, 62, 93, 93, 190, 365, 730, 0, 124, 0, 0);
my @datebeforeend;
@datebeforeend = Add_Delta_Days( $endofsubscriptiondate[0],$endofsubscriptiondate[1],$endofsubscriptiondate[2],
- (3 * $per_list[$per])) if (@endofsubscriptiondate && $endofsubscriptiondate[0]*$endofsubscriptiondate[1]*$endofsubscriptiondate[2]);
}
@resultdate = Add_Delta_YMD( $year, $month, $day, 0, 3, 0 );
}
+ if ( $subscription->{periodicity} == 13 ) {
+ for ( my $i = 0 ; $i < @irreg ; $i++ ) {
+ if ( $irreg[$i] == ( ( $tmpmonth != 8 ) ? ( $tmpmonth + 4 ) % 12 : 12 ) ) {
+ ( $year, $month, $day ) = Add_Delta_YMD( $year, $month, $day, 0, 4, 0 );
+ $tmpmonth = ( ( $tmpmonth != 8 ) ? ( $tmpmonth + 4 ) % 12 : 12 );
+ }
+ }
+ @resultdate = Add_Delta_YMD( $year, $month, $day, 0, 4, 0 );
+ }
if ( $subscription->{periodicity} == 9 ) {
for ( my $i = 0 ; $i < @irreg ; $i++ ) {
if ( $irreg[$i] == ( ( $tmpmonth != 9 ) ? ( $tmpmonth + 3 ) % 12 : 12 ) ) {