Lines 51-57
BEGIN {
Link Here
|
51 |
&getroutinglist &delroutingmember &addroutingmember |
51 |
&getroutinglist &delroutingmember &addroutingmember |
52 |
&reorder_members |
52 |
&reorder_members |
53 |
&check_routing &updateClaim &removeMissingIssue |
53 |
&check_routing &updateClaim &removeMissingIssue |
54 |
&CountIssues |
54 |
&CountIssues &SearchSubscriptions |
|
|
55 |
&subscriptionCurrentlyOnOrder |
55 |
HasItems |
56 |
HasItems |
56 |
|
57 |
|
57 |
); |
58 |
); |
Lines 150-155
sub GetLateIssues {
Link Here
|
150 |
return @issuelist; |
151 |
return @issuelist; |
151 |
} |
152 |
} |
152 |
|
153 |
|
|
|
154 |
=head2 SearchSubscriptions |
155 |
|
156 |
@results = SearchSubscriptions($biblionumber, $title, $issn, $ean, $publisher, $supplier, $branch, $minold, $maxold); |
157 |
|
158 |
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. |
159 |
$minold and $maxold are values in days. It allows to get active and inactive subscription apart. |
160 |
|
161 |
return: |
162 |
a table of hashref. Each hash containt the subscription. |
163 |
|
164 |
=cut |
165 |
|
166 |
sub SearchSubscriptions { |
167 |
my ($biblionumber, $title, $issn, $ean, $publisher, $supplier, $branch, $minold, $maxold) = @_; |
168 |
|
169 |
my $query = qq{ |
170 |
SELECT subscription.*, subscriptionhistory.*, biblio.*, biblioitems.issn, |
171 |
subscription.notes AS notes |
172 |
FROM subscription |
173 |
LEFT JOIN subscriptionhistory USING(subscriptionid) |
174 |
LEFT JOIN biblio ON biblio.biblionumber = subscription.biblionumber |
175 |
LEFT JOIN biblioitems ON biblioitems.biblionumber = subscription.biblionumber |
176 |
LEFT JOIN aqbooksellers ON subscription.aqbooksellerid = aqbooksellers.id |
177 |
}; |
178 |
my @where_strs; |
179 |
my @where_args; |
180 |
if($biblionumber){ |
181 |
push @where_strs, "subscription.biblionumber = ?"; |
182 |
push @where_args, "$biblionumber"; |
183 |
} |
184 |
if($title){ |
185 |
push @where_strs, "biblio.title LIKE ?"; |
186 |
push @where_args, "%$title%"; |
187 |
} |
188 |
if($issn){ |
189 |
push @where_strs, "biblioitems.issn LIKE ?"; |
190 |
push @where_args, "%$issn%"; |
191 |
} |
192 |
if($ean){ |
193 |
push @where_strs, "biblioitems.ean LIKE ?"; |
194 |
push @where_args, "%$ean%"; |
195 |
} |
196 |
if($publisher){ |
197 |
push @where_strs, "biblioitems.publishercode LIKE ?"; |
198 |
push @where_args, "%$publisher%"; |
199 |
} |
200 |
if($supplier){ |
201 |
push @where_strs, "aqbooksellers.name LIKE ?"; |
202 |
push @where_args, "%$supplier%"; |
203 |
} |
204 |
if($branch){ |
205 |
push @where_strs, "subscription.branchcode = ?"; |
206 |
push @where_args, "$branch"; |
207 |
} |
208 |
if ($minold) { |
209 |
push @where_strs, "TO_DAYS(NOW()) - TO_DAYS(subscription.enddate) > ?" if ($minold); |
210 |
push @where_args, "$minold" if ($minold); |
211 |
} |
212 |
if ($maxold) { |
213 |
push @where_strs, "(TO_DAYS(NOW()) - TO_DAYS(subscription.enddate) <= ? OR subscription.enddate IS NULL OR subscription.enddate = '0000-00-00')"; |
214 |
push @where_args, "$maxold"; |
215 |
} |
216 |
|
217 |
if(@where_strs){ |
218 |
$query .= " WHERE " . join(" AND ", @where_strs); |
219 |
} |
220 |
warn $query; |
221 |
warn join(",", @where_args) if @where_args; |
222 |
my $dbh = C4::Context->dbh; |
223 |
my $sth = $dbh->prepare($query); |
224 |
$sth->execute(@where_args); |
225 |
my $results = $sth->fetchall_arrayref( {} ); |
226 |
$sth->finish; |
227 |
|
228 |
return @$results; |
229 |
} |
230 |
|
231 |
=head2 |
232 |
$bool = subscriptionCurrentlyOnOrder( $subscriptionid ); |
233 |
Return 1 if subscription is already on order |
234 |
else 0 |
235 |
=cut |
236 |
|
237 |
sub subscriptionCurrentlyOnOrder { |
238 |
my ( $subscriptionid ) = @_; |
239 |
my $dbh = C4::Context->dbh; |
240 |
my $query = qq| |
241 |
SELECT COUNT(*) FROM aqorders |
242 |
WHERE subscriptionid = ? |
243 |
AND datereceived IS NULL |
244 |
|; |
245 |
my $sth = $dbh->prepare( $query ); |
246 |
$sth->execute($subscriptionid); |
247 |
return $sth->fetchrow_array; |
248 |
} |
249 |
|
250 |
|
153 |
=head2 GetSubscriptionHistoryFromSubscriptionId |
251 |
=head2 GetSubscriptionHistoryFromSubscriptionId |
154 |
|
252 |
|
155 |
$sth = GetSubscriptionHistoryFromSubscriptionId() |
253 |
$sth = GetSubscriptionHistoryFromSubscriptionId() |