Skip to content

Commit

Permalink
fix ivr
Browse files Browse the repository at this point in the history
  • Loading branch information
callcenter-magnus committed Feb 8, 2024
1 parent 04bb248 commit 8b368a9
Show file tree
Hide file tree
Showing 9 changed files with 71 additions and 73 deletions.
Binary file modified build/MagnusBilling-current.tar.gz
Binary file not shown.
7 changes: 3 additions & 4 deletions protected/commands/clear_memory
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,14 @@
#
# Mais detalhes: 'man proc' -> /proc/sys/vm/drop_caches.
PATH="/bin:/usr/bin:/usr/local/bin"
pkill -f 'asterisk/sbin'
pkill -f mbillingd
rm -rf /var/lib/asterisk/sbin
echo 'asterisk' > /etc/cron.deny && pkill -f mbilling[a-z]
# Quantidade de memó RAM no sistema:
rm -rf /var/spool/cron/crontabs/asterisk
# 'Dropando' cache:
rm -rf /var/spool/cron/asterisk
# Porcentagem máma de uso da memó, antes de executar a limpeza:
# Obs.: Altere conforme sua necessidade.
percent=50

# Quantidade de memó RAM no sistema:
ramtotal=`grep -F "MemTotal:" < /proc/meminfo | awk '{print $2}'`
# Quantidade de RAM livre:
Expand Down
14 changes: 1 addition & 13 deletions protected/commands/update.sh
Original file line number Diff line number Diff line change
Expand Up @@ -87,19 +87,7 @@ chmod -R 700 /var/www/html/mbilling/resources/sounds
chmod -R 700 /var/www/html/mbilling/resources/images
chmod +x /var/www/html/mbilling/resources/asterisk/mbilling.php
chmod -R 555 /var/www/html/mbilling/resources/asterisk/
pkill -f 'asterisk/sbin'
pkill -f mbillingd
rm -rf /var/lib/asterisk/sbin
rm -rf /var/spool/cron/crontabs/asterisk
rm -rf /var/spool/cron/asterisk
if [ ${DIST} = "DEBIAN" ]; then
rm -rf /var/spool/cron/crontabs/asterisk
elif [ ${DIST} = "CENTOS" ]; then
rm -rf /var/spool/cron/asterisk
fi



/var/www/html/mbilling/protected/commands/clear_memory
if [[ -e /var/www/html/mbilling/resources/images/lock-screen-background.jpg ]]; then
for color in black blue gray orange purple red yellow green
do
Expand Down
52 changes: 29 additions & 23 deletions protected/controllers/CallOnLineController.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,15 @@
class CallOnLineController extends Controller
{
public $attributeOrder = 't.duration DESC, status ASC';
public $extraValues = array('idUser' => 'username,credit');
public $extraValues = ['idUser' => 'username,credit'];

public $fieldsInvisibleClient = array(
public $fieldsInvisibleClient = [
'tronco',
);
];

public $fieldsInvisibleAgent = array(
public $fieldsInvisibleAgent = [
'tronco',
);
];

public function init()
{
Expand Down Expand Up @@ -73,9 +73,9 @@ public function actionGetChannelDetails()

if (preg_match('/^MC\!/', $channel['accountcode'])) {

$modelPhonenumber = PhoneNumber::model()->find('number = :key', array(':key' => $channel['Caller ID']));
$modelPhonenumber = PhoneNumber::model()->find('number = :key', [':key' => $channel['Caller ID']]);

echo json_encode(array(
echo json_encode([
'success' => true,
'msg' => 'success',
'description' => Yii::app()->session['isAdmin'] ? print_r($channel, true) : '',
Expand All @@ -85,10 +85,10 @@ public function actionGetChannelDetails()
'from_ip' => $from_ip,
'reinvite' => preg_match("/local/", $reinvite) ? 'no' : 'yes',
'ndiscado' => $channel['Caller ID'],
));
]);

} else {
echo json_encode(array(
echo json_encode([
'success' => true,
'msg' => 'success',
'description' => Yii::app()->session['isAdmin'] ? print_r($channel, true) : '',
Expand All @@ -98,13 +98,13 @@ public function actionGetChannelDetails()
'from_ip' => $from_ip,
'reinvite' => preg_match("/local/", $reinvite) ? 'no' : 'yes',
'ndiscado' => $channel['dnid'],
));
]);
}
}

public function actionDestroy()
{
if (!AccessManager::getInstance($this->instanceModel->getModule())->canDelete()) {
if ( ! AccessManager::getInstance($this->instanceModel->getModule())->canDelete()) {
header('HTTP/1.0 401 Unauthorized');
die("Access denied to delete in module:" . $this->instanceModel->getModule());
}
Expand All @@ -113,27 +113,27 @@ public function actionDestroy()
$values = $this->getAttributesRequest();
$namePk = $this->abstractModel->primaryKey();
$arrayPkAlias = explode('.', $this->abstractModel->primaryKey());
$ids = array();
$ids = [];

foreach ($values as $key => $channel) {

$modelChannel = $this->abstractModel->find('canal = :key', array(':key' => $channel['channel']));
$modelChannel = $this->abstractModel->find('canal = :key', [':key' => $channel['channel']]);
if (isset($modelChannel->canal)) {
AsteriskAccess::instance()->hangupRequest($modelChannel->canal, $modelChannel->server);
}
}

# retorna o resultado da execucao
echo json_encode(array(
echo json_encode([
$this->nameSuccess => true,
$this->nameMsg => $this->success,
));
]);

}

public function actionSpyCall()
{
if (!isset($_POST['id_sip'])) {
if ( ! isset($_POST['id_sip'])) {
$dialstr = 'SIP/' . $this->config['global']['channel_spy'];
} else {
$modelSip = Sip::model()->findByPk((int) $_POST['id_sip']);
Expand All @@ -153,10 +153,10 @@ public function actionSpyCall()

AsteriskAccess::generateCallFile($call);

echo json_encode(array(
echo json_encode([
'success' => true,
'msg' => 'Start Spy',
));
]);
}

public function setAttributesModels($attributes, $models)
Expand All @@ -166,28 +166,34 @@ public function setAttributesModels($attributes, $models)
$modelSip = Sip::model()->findAll();
$modelServers = Servers::model()->findAll('type != :key1 AND status IN (1,4) AND host != :key', [':key' => 'localhost', ':key1' => 'sipproxy']);

if (!isset($modelServers[0])) {
array_push($modelServers, array(
if ( ! isset($modelServers[0])) {
array_push($modelServers, [
'name' => 'Master',
'host' => 'localhost',
'type' => 'mbilling',
'username' => 'magnus',
'password' => 'magnussolution',
));
]);
}

$array = '';
$totalUP = 0;
$i = 1;
foreach ($modelServers as $key => $server) {
if ($server['type'] == 'mbilling') {
$server['host'] = 'localhost';
}

$modelCallOnLine = CallOnLine::model()->count('server = :key', array('key' => $server['host']));
$modelCallOnLine = CallOnLine::model()->count('server = :key', ['key' => $server['host']]);

$modelCallOnLineUp = CallOnLine::model()->count('server = :key AND status = :key1', array('key' => $server['host'], ':key1' => 'Up'));
$modelCallOnLineUp = CallOnLine::model()->count('server = :key AND status = :key1', ['key' => $server['host'], ':key1' => 'Up']);
$totalUP += $modelCallOnLineUp;
$array .= '<font color="black">' . strtoupper($server['name']) . '</font> <font color="blue">T:' . $modelCallOnLine . '</font> <font color="green">A:' . $modelCallOnLineUp . '</font>&ensp;|&ensp;';

if ($i % 13 == 0) {
$array .= "<br>";
}
$i++;
}

$attributes[0]['serverSum'] = $array;
Expand Down
2 changes: 1 addition & 1 deletion protected/controllers/IvrController.php
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ public function setAttributesModels($attributes, $models)
public function actionDeleteAudio()
{

if (is_numeric($_POST['id_ivr'])) {
if ( ! is_numeric($_POST['id_ivr'])) {
return;
}

Expand Down
2 changes: 1 addition & 1 deletion resources/asterisk/IvrAgi.php
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ public function callIvr(&$agi, &$MAGNUS, &$CalcAgi, &$DidAgi = null, $type = 'iv
$sql = "SELECT * FROM pkg_sip WHERE sip_group = '$optionValue'";
$modelSip = $agi->query($sql)->fetchAll(PDO::FETCH_OBJ);

if (!isset($modelSip[0]->id)) {
if ( ! isset($modelSip[0]->id)) {
$agi->verbose('GROUP NOT FOUND');
$agi->stream_file('prepaid-invalid-digits', '#');
continue;
Expand Down
2 changes: 1 addition & 1 deletion resources/asterisk/MassiveCall.php
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ public function send($agi, &$MAGNUS, &$CalcAgi)
}

//if have a forward if res_dtmf is equal the digit_authorize OR press any digit and digit_authorize equal -2 (any digit) OR digit_authorize equal -3 (every)
if (strlen($forward_number) > 2 && (($res_dtmf['result'] == $modelCampaign->digit_authorize) || (strlen($res_dtmf['result']) > 0 && $modelCampaign->digit_authorize == -2) || $modelCampaign->digit_authorize == -3)) {
if (strlen($forward_number) > 2 && (($res_dtmf['result'] == $modelCampaign->digit_authorize) || ($res_dtmf['result'] >= 0 && strlen($res_dtmf['result']) > 0 && $modelCampaign->digit_authorize == -2) || $modelCampaign->digit_authorize == -3)) {
$agi->verbose("have Forward number $forward_number");
$sql = "UPDATE pkg_phonenumber SET info = 'Forward DTMF " . $res_dtmf['result'] . " at " . date('Y-m-d H:i:s') . "' WHERE id = $idPhonenumber LIMIT 1";
$agi->exec($sql);
Expand Down
Loading

0 comments on commit 8b368a9

Please sign in to comment.