Skip to content

Commit

Permalink
Merge pull request #8 from susom/refactor
Browse files Browse the repository at this point in the history
Refactor
  • Loading branch information
Jordan-M-Schultz authored Mar 8, 2024
2 parents a75cb19 + 742537e commit 54943d6
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions WhatsAppAlerts.php
Original file line number Diff line number Diff line change
Expand Up @@ -172,11 +172,15 @@ public function filterProjectsBySender($projects, $from_number)
$data_table = method_exists('\REDCap', 'getDataTable') ? \REDCap::getDataTable($local_pid) : "redcap_data";

$this->emDebug("Checking project $local_pid for records with $pid_phone_field that is similar to $from_number");
$this->emDebug("local PID $local_pid phone field $pid_phone_field");
$data_table = method_exists('\REDCap', 'getDataTable') ? \REDCap::getDataTable($local_pid) : "redcap_data";
$this->emDebug("$data_table");
$result = $this->query(
"SELECT record, event_id, value from ? where project_id = ? and field_name = ?",
[$data_table, $local_pid, $pid_phone_field]
"SELECT record, event_id, value from ". $data_table ." where project_id = ? and field_name = ?",
[$local_pid, $pid_phone_field]
);
while ($row = $result->fetch_assoc()) {
$this->emDebug("ROW val", $row);
$record_phone_digits = $this->formatNumber($row['value'], '');
if (!empty($record_phone_digits) && $from_digits == $record_phone_digits) {
$this->emDebug("Found an inbound match: " . json_encode($row));
Expand Down

0 comments on commit 54943d6

Please sign in to comment.