Skip to content

Commit

Permalink
voicebroadcasting
Browse files Browse the repository at this point in the history
  • Loading branch information
callcenter-magnus committed Jun 1, 2024
1 parent da8a9f1 commit 1e9e1fc
Show file tree
Hide file tree
Showing 7 changed files with 103 additions and 11 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
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;
}

}
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 1e9e1fc

Please sign in to comment.