View | Details | Raw Unified | Return to bug 21650
Collapse All | Expand All

(-)a/C4/Items.pm (-53 lines)
Lines 47-53 BEGIN { Link Here
47
        ItemSafeToDelete
47
        ItemSafeToDelete
48
        DelItemCheck
48
        DelItemCheck
49
        MoveItemFromBiblio
49
        MoveItemFromBiblio
50
        GetLastAcquisitions
51
        CartToShelf
50
        CartToShelf
52
        ShelfToCart
51
        ShelfToCart
53
        GetAnalyticsCount
52
        GetAnalyticsCount
Lines 1177-1233 sub GetHostItemsInfo { Link Here
1177
    return @returnitemsInfo;
1176
    return @returnitemsInfo;
1178
}
1177
}
1179
1178
1180
=head2 GetLastAcquisitions
1181
1182
  my $lastacq = GetLastAcquisitions({'branches' => ('branch1','branch2'), 
1183
                                    'itemtypes' => ('BK','BD')}, 10);
1184
1185
=cut
1186
1187
sub  GetLastAcquisitions {
1188
	my ($data,$max) = @_;
1189
1190
	my $itemtype = C4::Context->preference('item-level_itypes') ? 'itype' : 'itemtype';
1191
	
1192
	my $number_of_branches = @{$data->{branches}};
1193
	my $number_of_itemtypes   = @{$data->{itemtypes}};
1194
	
1195
	
1196
	my @where = ('WHERE 1 '); 
1197
	$number_of_branches and push @where
1198
	   , 'AND holdingbranch IN (' 
1199
	   , join(',', ('?') x $number_of_branches )
1200
	   , ')'
1201
	 ;
1202
	
1203
	$number_of_itemtypes and push @where
1204
	   , "AND $itemtype IN (" 
1205
	   , join(',', ('?') x $number_of_itemtypes )
1206
	   , ')'
1207
	 ;
1208
1209
	my $query = "SELECT biblio.biblionumber as biblionumber, title, dateaccessioned
1210
				 FROM items RIGHT JOIN biblio ON (items.biblionumber=biblio.biblionumber) 
1211
			            RIGHT JOIN biblioitems ON (items.biblioitemnumber=biblioitems.biblioitemnumber)
1212
			            @where
1213
			            GROUP BY biblio.biblionumber 
1214
			            ORDER BY dateaccessioned DESC LIMIT $max";
1215
1216
	my $dbh = C4::Context->dbh;
1217
	my $sth = $dbh->prepare($query);
1218
    
1219
    $sth->execute((@{$data->{branches}}, @{$data->{itemtypes}}));
1220
	
1221
	my @results;
1222
	while( my $row = $sth->fetchrow_hashref){
1223
		push @results, {date => $row->{dateaccessioned} 
1224
						, biblionumber => $row->{biblionumber}
1225
						, title => $row->{title}};
1226
	}
1227
	
1228
	return @results;
1229
}
1230
1231
=head2 get_hostitemnumbers_of
1179
=head2 get_hostitemnumbers_of
1232
1180
1233
  my @itemnumbers_of = get_hostitemnumbers_of($biblionumber);
1181
  my @itemnumbers_of = get_hostitemnumbers_of($biblionumber);
1234
- 

Return to bug 21650