|
Lines 312-332
sub delalert {
Link Here
|
| 312 |
sub getalert { |
312 |
sub getalert { |
| 313 |
my ( $borrowernumber, $type, $externalid ) = @_; |
313 |
my ( $borrowernumber, $type, $externalid ) = @_; |
| 314 |
my $dbh = C4::Context->dbh; |
314 |
my $dbh = C4::Context->dbh; |
| 315 |
my $query = "SELECT a.*, b.branchcode FROM alert a JOIN borrowers b USING(borrowernumber) WHERE"; |
315 |
my $query = "SELECT a.*, b.branchcode FROM alert a JOIN borrowers b USING(borrowernumber) WHERE 1"; |
| 316 |
my @bind; |
316 |
my @bind; |
| 317 |
if ($borrowernumber and $borrowernumber =~ /^\d+$/) { |
317 |
if ($borrowernumber and $borrowernumber =~ /^\d+$/) { |
| 318 |
$query .= " borrowernumber=? AND "; |
318 |
$query .= " AND borrowernumber=?"; |
| 319 |
push @bind, $borrowernumber; |
319 |
push @bind, $borrowernumber; |
| 320 |
} |
320 |
} |
| 321 |
if ($type) { |
321 |
if ($type) { |
| 322 |
$query .= " type=? AND "; |
322 |
$query .= " AND type=?"; |
| 323 |
push @bind, $type; |
323 |
push @bind, $type; |
| 324 |
} |
324 |
} |
| 325 |
if ($externalid) { |
325 |
if ($externalid) { |
| 326 |
$query .= " externalid=? AND "; |
326 |
$query .= " AND externalid=?"; |
| 327 |
push @bind, $externalid; |
327 |
push @bind, $externalid; |
| 328 |
} |
328 |
} |
| 329 |
$query =~ s/ AND $//; |
|
|
| 330 |
my $sth = $dbh->prepare($query); |
329 |
my $sth = $dbh->prepare($query); |
| 331 |
$sth->execute(@bind); |
330 |
$sth->execute(@bind); |
| 332 |
return $sth->fetchall_arrayref({}); |
331 |
return $sth->fetchall_arrayref({}); |