Skip to content

Commit

Permalink
added alarm to Same number and CallerID
Browse files Browse the repository at this point in the history
  • Loading branch information
magnussolution committed Apr 23, 2022
1 parent fccf2e6 commit 259216f
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 12 deletions.
Binary file modified build/MagnusBilling-current.tar.gz
Binary file not shown.
3 changes: 2 additions & 1 deletion classic/src/view/alarm/Form.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@ Ext.define('MBilling.view.alarm.Form', {
['2', t('ASR')],
['3', t('Calls per minute')],
['4', t('Consecutive number')],
['5', t('Online calls on same number')]
['5', t('Online calls on same number')],
['6', t('Same number and CallerID')]
]
}, {
xtype: 'combobox',
Expand Down
3 changes: 3 additions & 0 deletions classic/src/view/alarm/List.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,9 @@ Ext.define('MBilling.view.alarm.List', {
case 5:
value = t('Online calls on same number');
break;
case 6:
value = t('Same number and CallerID');
break;
}
return value
},
Expand Down
43 changes: 32 additions & 11 deletions protected/commands/AlarmCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,10 @@ public function run($args)
# ONLINE CALLS ON THE SAME NUMBER
$this->onlineCallsSameNumber($alarm);
break;
case 6:
# ONLINE CALLS ON THE SAME NUMBER
$this->numberEqualCaller($alarm);
break;
}
}
}
Expand All @@ -71,12 +75,12 @@ public function asr($alarm)
echo 'ASR ' . $asr . "\n";
if ($alarm->condition == 1) {
if ($asr > $alarm->amount) {
$message = "MagnusBilling ALERT. The ASR is bigger than your alarm configuration";
$message = "MagnusBilling ALARM. The ASR is bigger than your alarm configuration";
$this->notification($message, $alarm);
}
} else if ($alarm->condition == 2) {
if ($asr < $alarm->amount) {
$message = "MagnusBilling ALERT. The ASR is less than your alarm configuration";
$message = "MagnusBilling ALARM. The ASR is less than your alarm configuration";
$this->notification($message, $alarm);
}
}
Expand All @@ -98,12 +102,12 @@ public function aloc($alarm)
echo 'ALOC ' . $aloc . "\n";
if ($alarm->condition == 1) {
if ($aloc > $alarm->amount) {
$message = "MagnusBilling ALERT. The ALOC is bigger than your alarm configuration";
$message = "MagnusBilling ALARM. The ALOC is bigger than your alarm configuration";
$this->notification($message, $alarm);
}
} else if ($alarm->condition == 2) {
if ($aloc < $alarm->amount) {
$message = "MagnusBilling ALERT. The ALOC is less than your alarm configuration";
$message = "MagnusBilling ALARM. The ALOC is less than your alarm configuration";
$this->notification($message, $alarm);
}
}
Expand All @@ -128,12 +132,12 @@ public function callPerMin($alarm)
echo 'CALLS PER MINUTE ' . $callPerMin . "\n";
if ($alarm->condition == 1) {
if ($callPerMin > $alarm->amount) {
$message = "MagnusBilling ALERT. You had more calls per minute than your alarm configuration";
$message = "MagnusBilling ALARM. You had more calls per minute than your alarm configuration";
$this->notification($message, $alarm);
}
} else if ($alarm->condition == 2) {
if ($callPerMin < $alarm->amount) {
$message = "MagnusBilling ALERT. You had less calls per minute than your alarm configuration";
$message = "MagnusBilling ALARM. You had less calls per minute than your alarm configuration";
$this->notification($message, $alarm);
}
}
Expand All @@ -156,12 +160,12 @@ public function consecutiveCalls($alarm)

if ($alarm->condition == 1) {
if ($totalConsecutiveCalls > $alarm->amount) {
$message = "MagnusBilling ALERT. User " . $cdr->idUser->username . " dial more than $totalConsecutiveCalls to numeber $cdr->calledstation";
$message = "MagnusBilling ALARM. User " . $cdr->idUser->username . " dial more than $totalConsecutiveCalls to numeber $cdr->calledstation";
$this->notification($message, $alarm);
}
} else if ($alarm->condition == 2) {
if ($totalConsecutiveCalls < $alarm->amount) {
$message = "MagnusBilling ALERT. User $cdr->id_user dial less than $totalConsecutiveCalls to numeber $cdr->calledstation";
$message = "MagnusBilling ALARM. User $cdr->id_user dial less than $totalConsecutiveCalls to numeber $cdr->calledstation";
$this->notification($message, $alarm);

}
Expand All @@ -182,11 +186,28 @@ public function onlineCallsSameNumber($alarm)
foreach ($modelCallOnLine as $key => $call) {

if (($call->canal) >= ($alarm->amount)) {
$message = "MagnusBilling ALERT. Multiple online calls to the same number(" . $call->ndiscado . ") detected! ";
$message = "MagnusBilling ALARM. Multiple online calls to the same number(" . $call->ndiscado . ") detected! ";
$this->notification($message, $alarm);
}
}

}
public function numberEqualCaller($alarm)
{
$period = time() - $alarm->period;

$period = date("Y-m-d H:i:s", $period);

$filter = "starttime > '$period'";

$sql = "SELECT COUNT(*) id, calledstation FROM pkg_cdr WHERE " . $filter . " AND (calledstation = callerid OR SUBSTRING(calledstation,2) = callerid)";
$modeCdr = Call::model()->findBySql($sql);

if (($modeCdr->id) >= ($alarm->amount)) {
$message = "MagnusBilling ALARM. Multiple calls to the Dialled Number (" . $modeCdr->calledstation . ") with the salve CallerID detected! ";
$this->notification($message, $alarm);
}

}

public function notification($message, $alarm)
Expand Down Expand Up @@ -222,10 +243,10 @@ public function notification($message, $alarm)
$mail->Username = $smtp_username;
$mail->Password = $smtp_password;
$mail->Port = $smtp_port;
$mail->SetFrom($alarm->email, $alarm->email);
$mail->SetFrom($modelSmtps->username, "MagnusBilling ALARM");
$mail->SetLanguage($this->config['global']['base_language'] == 'pt_BR' ? 'br' : $this->config['global']['base_language']);

$mail->Subject = mb_encode_mimeheader('MagnusBilling ALERT');
$mail->Subject = mb_encode_mimeheader('MagnusBilling ALARM');
$mail->AltBody = 'To view the message, please use an HTML compatible email viewer!';
$mail->MsgHTML($message);
$mail->AddAddress($alarm->email);
Expand Down

0 comments on commit 259216f

Please sign in to comment.