Lines 153-235
sub GetLateIssues {
Link Here
|
153 |
return @issuelist; |
153 |
return @issuelist; |
154 |
} |
154 |
} |
155 |
|
155 |
|
156 |
=head2 SearchSubscriptions |
|
|
157 |
|
158 |
@results = SearchSubscriptions($biblionumber, $title, $issn, $ean, $publisher, $supplier, $branch, $minold, $maxold); |
159 |
|
160 |
this function gets all subscriptions which have biblionumber eq $biblionumber, title like $title, ISSN like $issn, EAN like $ean, publisher like $publisher, supplier like $supplier AND branchcode eq $branch. |
161 |
$minold and $maxold are values in days. It allows to get active and inactive subscription apart. |
162 |
|
163 |
return: |
164 |
a table of hashref. Each hash containt the subscription. |
165 |
|
166 |
=cut |
167 |
|
168 |
sub SearchSubscriptions { |
169 |
my ($biblionumber, $title, $issn, $ean, $publisher, $supplier, $branch, $minold, $maxold) = @_; |
170 |
|
171 |
my $query = qq{ |
172 |
SELECT subscription.*, subscriptionhistory.*, biblio.*, biblioitems.issn, |
173 |
subscription.notes AS notes |
174 |
FROM subscription |
175 |
LEFT JOIN subscriptionhistory USING(subscriptionid) |
176 |
LEFT JOIN biblio ON biblio.biblionumber = subscription.biblionumber |
177 |
LEFT JOIN biblioitems ON biblioitems.biblionumber = subscription.biblionumber |
178 |
LEFT JOIN aqbooksellers ON subscription.aqbooksellerid = aqbooksellers.id |
179 |
}; |
180 |
my @where_strs; |
181 |
my @where_args; |
182 |
if($biblionumber){ |
183 |
push @where_strs, "subscription.biblionumber = ?"; |
184 |
push @where_args, "$biblionumber"; |
185 |
} |
186 |
if($title){ |
187 |
push @where_strs, "biblio.title LIKE ?"; |
188 |
push @where_args, "%$title%"; |
189 |
} |
190 |
if($issn){ |
191 |
push @where_strs, "biblioitems.issn LIKE ?"; |
192 |
push @where_args, "%$issn%"; |
193 |
} |
194 |
if($ean){ |
195 |
push @where_strs, "biblioitems.ean LIKE ?"; |
196 |
push @where_args, "%$ean%"; |
197 |
} |
198 |
if($publisher){ |
199 |
push @where_strs, "biblioitems.publishercode LIKE ?"; |
200 |
push @where_args, "%$publisher%"; |
201 |
} |
202 |
if($supplier){ |
203 |
push @where_strs, "aqbooksellers.name LIKE ?"; |
204 |
push @where_args, "%$supplier%"; |
205 |
} |
206 |
if($branch){ |
207 |
push @where_strs, "subscription.branchcode = ?"; |
208 |
push @where_args, "$branch"; |
209 |
} |
210 |
if ($minold) { |
211 |
push @where_strs, "TO_DAYS(NOW()) - TO_DAYS(subscription.enddate) > ?" if ($minold); |
212 |
push @where_args, "$minold" if ($minold); |
213 |
} |
214 |
if ($maxold) { |
215 |
push @where_strs, "(TO_DAYS(NOW()) - TO_DAYS(subscription.enddate) <= ? OR subscription.enddate IS NULL OR subscription.enddate = '0000-00-00')"; |
216 |
push @where_args, "$maxold"; |
217 |
} |
218 |
|
219 |
if(@where_strs){ |
220 |
$query .= " WHERE " . join(" AND ", @where_strs); |
221 |
} |
222 |
warn $query; |
223 |
warn join(",", @where_args) if @where_args; |
224 |
my $dbh = C4::Context->dbh; |
225 |
my $sth = $dbh->prepare($query); |
226 |
$sth->execute(@where_args); |
227 |
my $results = $sth->fetchall_arrayref( {} ); |
228 |
$sth->finish; |
229 |
|
230 |
return @$results; |
231 |
} |
232 |
|
233 |
=head2 |
156 |
=head2 |
234 |
$bool = subscriptionCurrentlyOnOrder( $subscriptionid ); |
157 |
$bool = subscriptionCurrentlyOnOrder( $subscriptionid ); |
235 |
Return 1 if subscription is already on order |
158 |
Return 1 if subscription is already on order |