|
Lines 135-169
sub GetHoldsQueueItems {
Link Here
|
| 135 |
my ($branchlimit) = @_; |
135 |
my ($branchlimit) = @_; |
| 136 |
my $dbh = C4::Context->dbh; |
136 |
my $dbh = C4::Context->dbh; |
| 137 |
|
137 |
|
| 138 |
my @bind_params = (); |
138 |
my $search_params; |
| 139 |
my $query = q/SELECT tmp_holdsqueue.*, biblio.author, items.ccode, items.itype, biblioitems.itemtype, items.location, |
|
|
| 140 |
items.enumchron, items.cn_sort, biblioitems.publishercode, |
| 141 |
biblio.copyrightdate, biblio.subtitle, biblio.medium, |
| 142 |
biblio.part_number, biblio.part_name, |
| 143 |
biblioitems.publicationyear, biblioitems.pages, biblioitems.size, |
| 144 |
biblioitems.isbn, biblioitems.editionstatement, items.copynumber |
| 145 |
FROM tmp_holdsqueue |
| 146 |
JOIN biblio USING (biblionumber) |
| 147 |
LEFT JOIN biblioitems USING (biblionumber) |
| 148 |
LEFT JOIN items USING ( itemnumber) |
| 149 |
/; |
| 150 |
if ($branchlimit) { |
139 |
if ($branchlimit) { |
| 151 |
$query .=" WHERE tmp_holdsqueue.holdingbranch = ?"; |
140 |
$search_params->{'me.holdingbranch'} = $branchlimit; |
| 152 |
push @bind_params, $branchlimit; |
|
|
| 153 |
} |
141 |
} |
| 154 |
$query .= " ORDER BY ccode, location, cn_sort, author, title, pickbranch, reservedate"; |
142 |
|
| 155 |
my $sth = $dbh->prepare($query); |
143 |
my $schema = Koha::Database->new->schema; |
| 156 |
$sth->execute(@bind_params); |
144 |
my $queue_rs = $schema->resultset('TmpHoldsqueue')->search( |
|
|
145 |
$search_params, |
| 146 |
{ |
| 147 |
join => [ qw{ biblio biblioitem borrower item } ], |
| 148 |
order_by => [ qw{ ccode location cn_sort author title pickbranch reservedate } ] |
| 149 |
} |
| 150 |
); |
| 151 |
|
| 157 |
my $items = []; |
152 |
my $items = []; |
| 158 |
while ( my $row = $sth->fetchrow_hashref ){ |
153 |
while ( my $r = $queue_rs->next ) { |
| 159 |
# return the bib-level or item-level itype per syspref |
154 |
my $result = { $r->get_columns }; |
| 160 |
if (!C4::Context->preference('item-level_itypes')) { |
155 |
$result->{author} = $r->biblio->author; |
| 161 |
$row->{itype} = $row->{itemtype}; |
156 |
$result->{copyrightdate} = $r->biblio->copyrightdate; |
|
|
157 |
$result->{medium} = $r->biblio->medium; |
| 158 |
$result->{part_name} = $r->biblio->part_name; |
| 159 |
$result->{part_number} = $r->biblio->part_number; |
| 160 |
$result->{subittle} = $r->biblio->subtitle; |
| 161 |
$result->{editionstatement} = $r->biblioitem->editionstatement; |
| 162 |
$result->{isbn} = $r->biblioitem->isbn; |
| 163 |
$result->{pages} = $r->biblioitem->pages; |
| 164 |
$result->{publicationyear} = $r->biblioitem->publicationyear; |
| 165 |
$result->{publishercode} = $r->biblioitem->publishercode; |
| 166 |
$result->{size} = $r->biblioitem->size; |
| 167 |
$result->{ccode} = $r->item->ccode; |
| 168 |
$result->{cn_sort} = $r->item->cn_sort; |
| 169 |
$result->{copynumber} = $r->item->copynumber; |
| 170 |
$result->{enumchron} = $r->item->enumchron; |
| 171 |
$result->{itype} = $r->item->itype; |
| 172 |
$result->{location} = $r->item->location; |
| 173 |
|
| 174 |
if ( !C4::Context->preference('item-level_itypes') ) { |
| 175 |
$result->{itype} = $result->{itemtype}; |
| 162 |
} |
176 |
} |
| 163 |
delete $row->{itemtype}; |
|
|
| 164 |
|
177 |
|
| 165 |
push @$items, $row; |
178 |
$result->{patron} = Koha::Patron->_new_from_dbic( $r->borrower ); |
|
|
179 |
|
| 180 |
push( @$items, $result ); |
| 166 |
} |
181 |
} |
|
|
182 |
|
| 167 |
return $items; |
183 |
return $items; |
| 168 |
} |
184 |
} |
| 169 |
|
185 |
|