diff --git a/build/MagnusBilling-current.tar.gz b/build/MagnusBilling-current.tar.gz index abf5f4f62..629a79ef5 100644 Binary files a/build/MagnusBilling-current.tar.gz and b/build/MagnusBilling-current.tar.gz differ diff --git a/classic/src/view/alarm/Form.js b/classic/src/view/alarm/Form.js index e238cc41c..a241671ae 100755 --- a/classic/src/view/alarm/Form.js +++ b/classic/src/view/alarm/Form.js @@ -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', diff --git a/classic/src/view/alarm/List.js b/classic/src/view/alarm/List.js index 13e804626..a174c4b3b 100755 --- a/classic/src/view/alarm/List.js +++ b/classic/src/view/alarm/List.js @@ -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 }, diff --git a/protected/commands/AlarmCommand.php b/protected/commands/AlarmCommand.php index 374791e23..de3ae4e3d 100755 --- a/protected/commands/AlarmCommand.php +++ b/protected/commands/AlarmCommand.php @@ -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; } } } @@ -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); } } @@ -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); } } @@ -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); } } @@ -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); } @@ -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) @@ -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);