Skip to content

Commit

Permalink
voicebroadcasting
Browse files Browse the repository at this point in the history
  • Loading branch information
callcenter-magnus committed Jun 5, 2024
1 parent da8a9f1 commit 24cec49
Show file tree
Hide file tree
Showing 10 changed files with 125 additions and 16 deletions.
Binary file modified build/MagnusBilling-current.tar.gz
Binary file not shown.
4 changes: 4 additions & 0 deletions classic/src/view/campaignPoll/Form.js
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,10 @@ Ext.define('MBilling.view.campaignPoll.Form', {
name: 'option9',
fieldLabel: t('Option 9'),
allowBlank: true
}, {
name: 'option10',
fieldLabel: t('Option 10'),
allowBlank: true
}]
}]
}];
Expand Down
3 changes: 2 additions & 1 deletion classic/src/view/restrictedPhonenumber/Form.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@ Ext.define('MBilling.view.restrictedPhonenumber.Form', {
store: window.dialC ? [
[1, t('Outbound')],
[2, t('Inbound')],
[3, t('Outbound & CallerID')]
[3, t('Outbound & CallerID')],
[4, t('CallerID')]
] : [
[1, t('Outbound')],
[2, t('Inbound')]
Expand Down
16 changes: 16 additions & 0 deletions protected/commands/UpdateMysqlCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -2010,6 +2010,22 @@ public function run($args)
$this->update($version);
}

//2024-05-27
if ($version == '7.8.4.6') {
$sql = " ALTER TABLE `pkg_campaign_poll` ADD `option10` VARCHAR(150) NULL DEFAULT NULL AFTER `option9`;";
$this->executeDB($sql);

$sql = " ALTER TABLE `pkg_campaign_poll_info` ADD `resposta_text` VARCHAR(150) NULL DEFAULT NULL AFTER `city`";
$this->executeDB($sql);

$sql = "
ALTER TABLE `pkg_campaign_poll_info` CHANGE `resposta` `resposta` INT(11) NOT NULL;";
$this->executeDB($sql);

$version = '7.8.4.7';
$this->update($version);
}

}

public function executeDB($sql)
Expand Down
4 changes: 2 additions & 2 deletions protected/components/ApiAccess.php
Original file line number Diff line number Diff line change
Expand Up @@ -265,8 +265,8 @@ private function createUser($baseController)
$values['id_group'] = $values['id_group'];
} else {
$modelGroupUser = GroupUser::model()->findAllByAttributes(["id_user_type" => 3]);
if (isset($modelGroupUser->id)) {
$values['id_group'] = $modelGroupUser[0]['id'];
if (isset($modelGroupUser[0]->id)) {
$values['id_group'] = $modelGroupUser[0]->id;
} else {
echo json_encode([
'success' => false,
Expand Down
6 changes: 3 additions & 3 deletions protected/components/BaseController.php
Original file line number Diff line number Diff line change
Expand Up @@ -418,7 +418,7 @@ public function actionRead($asJson = true, $condition = null)

$recordsSum = $this->recordsExtraSum($records);

$records = $this->afterRead($records);
$this->afterRead($records);

$return[$this->nameRoot] = $records;
$return[$this->nameCount] = $countRecords;
Expand Down Expand Up @@ -470,7 +470,7 @@ public function beforeRead($values)

public function afterRead($records)
{
return $records;
return;
}
public function hidenInvisibleField($values)
{
Expand Down Expand Up @@ -1753,7 +1753,7 @@ public function getColumnsFromReport($columns, $fieldGroup = null, $type = 'csv'
($fieldName == 'id' && $fieldReport == 'destination') ||
($fieldName == 'idPrefixprefix' && $fieldReport == 'destination')) {
//altera as colunas para poder pegar o destino das tarifas
$subSelect = "(SELECT $fieldReport FROM $table WHERE $table.$pk = t.id_prefix) AS connectcharge";
$subSelect = "(SELECT $fieldReport FROM $table WHERE $table.$pk = t.id_prefix) AS destination";
} else {
if (isset($fk['where'])) {
$subSelect = "(SELECT $fieldReport FROM $table WHERE $table.$pk = t." . $fk['where'] . ") AS $fieldName";
Expand Down
27 changes: 22 additions & 5 deletions protected/controllers/CampaignPollInfoController.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,17 @@
class CampaignPollInfoController extends Controller
{
public $attributeOrder = 't.id';
public $extraValues = array('idCampaignPoll' => 'name');
public $extraValues = ['idCampaignPoll' => 'name'];

public $nameFileReport = 'exported';

public $fieldsFkReport = array(
'id_campaign_poll' => array(
public $fieldsFkReport = [
'id_campaign_poll' => [
'table' => 'pkg_campaign_poll',
'pk' => 'id',
'fieldReport' => 'name',
),
);
],
];

public function init()
{
Expand Down Expand Up @@ -69,4 +69,21 @@ public function extraFilterCustomAgent($filter)

return $filter;
}

public function subscribeColunms($columns = '')
{

for ($i = 0; $i < count($columns); $i++) {

if ($columns[$i]['dataIndex'] == 'resposta') {
$columns[$i]['header'] = 'DTMF';
}

}

$columns[] = ['header' => 'Response', 'dataIndex' => 'resposta_text'];

return $columns;
}

}
17 changes: 17 additions & 0 deletions protected/controllers/RateProviderController.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,10 @@ class RateProviderController extends Controller
'table' => 'pkg_prefix',
'pk' => 'id',
'fieldReport' => 'destination',
], 't.id' => [
'table' => 'pkg_prefix',
'pk' => 'id',
'fieldReport' => 'destination',
],
];

Expand Down Expand Up @@ -71,11 +75,24 @@ public function replaceToExport()
$_GET['columns'] = preg_replace("/$destino/", $destinoNew, $_GET['columns']);
}

$destino = '{"header":"Prefix","dataIndex":"idPrefixprefix"},';
$destinoNew = '{"header":"Prefix","dataIndex":"id_prefix"},';
if (preg_match("/$destino/", $_GET['columns'])) {
$_GET['columns'] = preg_replace("/$destino/", $destinoNew, $_GET['columns']);
}

$destino = '{"header":"Destino","dataIndex":"idPrefixdestination"},';
$destinoNew = '{"header":"Destino","dataIndex":"id"},';
if (preg_match("/$destino/", $_GET['columns'])) {
$_GET['columns'] = preg_replace("/$destino/", $destinoNew, $_GET['columns']);
}

$destino = '{"header":"Destination","dataIndex":"idPrefixdestination"},';
$destinoNew = '{"header":"Destination","dataIndex":"id"},';
if (preg_match("/$destino/", $_GET['columns'])) {
$_GET['columns'] = preg_replace("/$destino/", $destinoNew, $_GET['columns']);
}

}

public function actionImportFromCsv()
Expand Down
2 changes: 1 addition & 1 deletion protected/models/CampaignPoll.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public function rules()
['id_user,ordem_exibicao, repeat, id_campaign, digit_authorize, request_authorize',
'numerical', 'integerOnly' => true],
['name, arq_audio', 'length', 'max' => 100],
['option0, option1, option2, option3, option4, option5, option6, option7, option8, option9',
['option0, option1, option2, option3, option4, option5, option6, option7, option8, option9, option10',
'length', 'max' => 300],
['description', 'length', 'max' => 300],

Expand Down
62 changes: 58 additions & 4 deletions resources/asterisk/MassiveCall.php
Original file line number Diff line number Diff line change
Expand Up @@ -410,6 +410,11 @@ public function send($agi, &$MAGNUS, &$CalcAgi)

foreach ($modelCampaignPoll as $poll) {

if (isset($execute_poll_name)) {
$poll = $execute_poll_name;
unset($execute_poll_name);
}

$repeat = $poll->repeat;

if ($dtmf_result == -1) {
Expand All @@ -430,6 +435,7 @@ public function send($agi, &$MAGNUS, &$CalcAgi)

$audio = $uploaddir . "idPoll_" . $poll->id;

$agi->verbose("audio: $audio", 5);
if ($poll->request_authorize == 1) {
$agi->verbose('Request authorize', 5);
//IF CUSTOMER MARK 1 EXECUTE POLL
Expand All @@ -443,14 +449,48 @@ public function send($agi, &$MAGNUS, &$CalcAgi)
}

} else {
$res_dtmf = $agi->get_data($audio, 5000, 1);

$agi->verbose("poll->option10: $poll->option10", 5);

if (strlen($poll->option10)) {

if (preg_match('/\#/', $poll->option10)) {
$digit_timeout = preg_split('/\#/', $poll->option10);

$agi->verbose(print_r($digit_timeout, true), 5);
$digit_timeout = end($digit_timeout);

} else {
$digit_timeout = strlen($poll->option10);
}

$res_dtmf = $agi->get_data($audio, strlen($poll->option10) * 2000, $digit_timeout);
} else {
$res_dtmf = $agi->get_data($audio, 5000, 1);
}

}

//GET RESULT OF POLL
$dtmf_result = $res_dtmf['result'];

$agi->verbose("Cliente votou na opcao: $dtmf_result", 5);

$sql = "SELECT * FROM pkg_campaign_poll WHERE name = '" . $poll->{'option' . $dtmf_result} . "' AND id_campaign = $idCampaign";
$poll2 = $agi->query($sql)->fetchAll(PDO::FETCH_OBJ);

if (isset($poll2[0]->id)) {
//execute other poll
$fields = "id_campaign_poll,resposta,number,city,resposta_text";
$values = "'$poll->id', '$dtmf_result', '$destination', '$phonenumberCity','" . strtok($poll->{'option' . $dtmf_result}, '#') . "'";
$sql = "INSERT INTO pkg_campaign_poll_info ($fields) VALUES ($values)";
$agi->exec($sql);

$execute_poll_name = $poll2[0];
continue;

}

//Hungaup call if the fisrt poll dtmf is not numeric
if ($i == 0 && ! is_numeric($dtmf_result)) {
$agi->verbose('nao votou nada na 1º enquete', 5);
Expand Down Expand Up @@ -505,6 +545,16 @@ public function send($agi, &$MAGNUS, &$CalcAgi)
}

if (is_numeric($dtmf_result) && $dtmf_result >= 0) {

if (preg_match('/play_/', $poll->{'option' . $dtmf_result})) {

preg_match_all('/play_(.*)\#/', $poll->{'option' . $dtmf_result}, $play_audio);

if (isset($play_audio[1][0])) {
$agi->stream_file($play_audio[1][0], ' #');
}
}

if (preg_match('/^http/', $poll->{'option' . $dtmf_result})) {

$agi->verbose('chamar API', 25);
Expand Down Expand Up @@ -532,7 +582,7 @@ public function send($agi, &$MAGNUS, &$CalcAgi)

}
//si esta hangup en la opcion, corlgar.
else if (preg_match('/hangup/', $poll->{'option' . $dtmf_result})) {
else if ($poll->{'option' . $dtmf_result} == 'hangup') {

$agi->verbose('desligar chamadas', 25);

Expand Down Expand Up @@ -588,8 +638,8 @@ public function send($agi, &$MAGNUS, &$CalcAgi)

} else {

$fields = "id_campaign_poll,resposta,number,city";
$values = "'$poll->id', '$dtmf_result', '$destination', '$phonenumberCity'";
$fields = "id_campaign_poll,resposta,number,city,resposta_text";
$values = "'$poll->id', '$dtmf_result', '$destination', '$phonenumberCity','" . strtok($poll->{'option' . $dtmf_result}, '#') . "'";
$sql = "INSERT INTO pkg_campaign_poll_info ($fields) VALUES ($values)";
$agi->exec($sql);

Expand All @@ -610,6 +660,10 @@ public function send($agi, &$MAGNUS, &$CalcAgi)
}
}

if (preg_match('/hangup/', $poll->{'option' . $dtmf_result})) {
break;
}

} else {
$agi->verbose('Cliente no marco nada', 8);
break;
Expand Down

0 comments on commit 24cec49

Please sign in to comment.