Skip to content

Commit 24cec49

Browse files
voicebroadcasting
1 parent da8a9f1 commit 24cec49

File tree

10 files changed

+125
-16
lines changed

10 files changed

+125
-16
lines changed

build/MagnusBilling-current.tar.gz

-82 Bytes
Binary file not shown.

classic/src/view/campaignPoll/Form.js

+4
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,10 @@ Ext.define('MBilling.view.campaignPoll.Form', {
125125
name: 'option9',
126126
fieldLabel: t('Option 9'),
127127
allowBlank: true
128+
}, {
129+
name: 'option10',
130+
fieldLabel: t('Option 10'),
131+
allowBlank: true
128132
}]
129133
}]
130134
}];

classic/src/view/restrictedPhonenumber/Form.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,8 @@ Ext.define('MBilling.view.restrictedPhonenumber.Form', {
4545
store: window.dialC ? [
4646
[1, t('Outbound')],
4747
[2, t('Inbound')],
48-
[3, t('Outbound & CallerID')]
48+
[3, t('Outbound & CallerID')],
49+
[4, t('CallerID')]
4950
] : [
5051
[1, t('Outbound')],
5152
[2, t('Inbound')]

protected/commands/UpdateMysqlCommand.php

+16
Original file line numberDiff line numberDiff line change
@@ -2010,6 +2010,22 @@ public function run($args)
20102010
$this->update($version);
20112011
}
20122012

2013+
//2024-05-27
2014+
if ($version == '7.8.4.6') {
2015+
$sql = " ALTER TABLE `pkg_campaign_poll` ADD `option10` VARCHAR(150) NULL DEFAULT NULL AFTER `option9`;";
2016+
$this->executeDB($sql);
2017+
2018+
$sql = " ALTER TABLE `pkg_campaign_poll_info` ADD `resposta_text` VARCHAR(150) NULL DEFAULT NULL AFTER `city`";
2019+
$this->executeDB($sql);
2020+
2021+
$sql = "
2022+
ALTER TABLE `pkg_campaign_poll_info` CHANGE `resposta` `resposta` INT(11) NOT NULL;";
2023+
$this->executeDB($sql);
2024+
2025+
$version = '7.8.4.7';
2026+
$this->update($version);
2027+
}
2028+
20132029
}
20142030

20152031
public function executeDB($sql)

protected/components/ApiAccess.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -265,8 +265,8 @@ private function createUser($baseController)
265265
$values['id_group'] = $values['id_group'];
266266
} else {
267267
$modelGroupUser = GroupUser::model()->findAllByAttributes(["id_user_type" => 3]);
268-
if (isset($modelGroupUser->id)) {
269-
$values['id_group'] = $modelGroupUser[0]['id'];
268+
if (isset($modelGroupUser[0]->id)) {
269+
$values['id_group'] = $modelGroupUser[0]->id;
270270
} else {
271271
echo json_encode([
272272
'success' => false,

protected/components/BaseController.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -418,7 +418,7 @@ public function actionRead($asJson = true, $condition = null)
418418

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

421-
$records = $this->afterRead($records);
421+
$this->afterRead($records);
422422

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

471471
public function afterRead($records)
472472
{
473-
return $records;
473+
return;
474474
}
475475
public function hidenInvisibleField($values)
476476
{
@@ -1753,7 +1753,7 @@ public function getColumnsFromReport($columns, $fieldGroup = null, $type = 'csv'
17531753
($fieldName == 'id' && $fieldReport == 'destination') ||
17541754
($fieldName == 'idPrefixprefix' && $fieldReport == 'destination')) {
17551755
//altera as colunas para poder pegar o destino das tarifas
1756-
$subSelect = "(SELECT $fieldReport FROM $table WHERE $table.$pk = t.id_prefix) AS connectcharge";
1756+
$subSelect = "(SELECT $fieldReport FROM $table WHERE $table.$pk = t.id_prefix) AS destination";
17571757
} else {
17581758
if (isset($fk['where'])) {
17591759
$subSelect = "(SELECT $fieldReport FROM $table WHERE $table.$pk = t." . $fk['where'] . ") AS $fieldName";

protected/controllers/CampaignPollInfoController.php

+22-5
Original file line numberDiff line numberDiff line change
@@ -18,17 +18,17 @@
1818
class CampaignPollInfoController extends Controller
1919
{
2020
public $attributeOrder = 't.id';
21-
public $extraValues = array('idCampaignPoll' => 'name');
21+
public $extraValues = ['idCampaignPoll' => 'name'];
2222

2323
public $nameFileReport = 'exported';
2424

25-
public $fieldsFkReport = array(
26-
'id_campaign_poll' => array(
25+
public $fieldsFkReport = [
26+
'id_campaign_poll' => [
2727
'table' => 'pkg_campaign_poll',
2828
'pk' => 'id',
2929
'fieldReport' => 'name',
30-
),
31-
);
30+
],
31+
];
3232

3333
public function init()
3434
{
@@ -69,4 +69,21 @@ public function extraFilterCustomAgent($filter)
6969

7070
return $filter;
7171
}
72+
73+
public function subscribeColunms($columns = '')
74+
{
75+
76+
for ($i = 0; $i < count($columns); $i++) {
77+
78+
if ($columns[$i]['dataIndex'] == 'resposta') {
79+
$columns[$i]['header'] = 'DTMF';
80+
}
81+
82+
}
83+
84+
$columns[] = ['header' => 'Response', 'dataIndex' => 'resposta_text'];
85+
86+
return $columns;
87+
}
88+
7289
}

protected/controllers/RateProviderController.php

+17
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,10 @@ class RateProviderController extends Controller
3737
'table' => 'pkg_prefix',
3838
'pk' => 'id',
3939
'fieldReport' => 'destination',
40+
], 't.id' => [
41+
'table' => 'pkg_prefix',
42+
'pk' => 'id',
43+
'fieldReport' => 'destination',
4044
],
4145
];
4246

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

78+
$destino = '{"header":"Prefix","dataIndex":"idPrefixprefix"},';
79+
$destinoNew = '{"header":"Prefix","dataIndex":"id_prefix"},';
80+
if (preg_match("/$destino/", $_GET['columns'])) {
81+
$_GET['columns'] = preg_replace("/$destino/", $destinoNew, $_GET['columns']);
82+
}
83+
7484
$destino = '{"header":"Destino","dataIndex":"idPrefixdestination"},';
7585
$destinoNew = '{"header":"Destino","dataIndex":"id"},';
7686
if (preg_match("/$destino/", $_GET['columns'])) {
7787
$_GET['columns'] = preg_replace("/$destino/", $destinoNew, $_GET['columns']);
7888
}
89+
90+
$destino = '{"header":"Destination","dataIndex":"idPrefixdestination"},';
91+
$destinoNew = '{"header":"Destination","dataIndex":"id"},';
92+
if (preg_match("/$destino/", $_GET['columns'])) {
93+
$_GET['columns'] = preg_replace("/$destino/", $destinoNew, $_GET['columns']);
94+
}
95+
7996
}
8097

8198
public function actionImportFromCsv()

protected/models/CampaignPoll.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ public function rules()
5757
['id_user,ordem_exibicao, repeat, id_campaign, digit_authorize, request_authorize',
5858
'numerical', 'integerOnly' => true],
5959
['name, arq_audio', 'length', 'max' => 100],
60-
['option0, option1, option2, option3, option4, option5, option6, option7, option8, option9',
60+
['option0, option1, option2, option3, option4, option5, option6, option7, option8, option9, option10',
6161
'length', 'max' => 300],
6262
['description', 'length', 'max' => 300],
6363

resources/asterisk/MassiveCall.php

+58-4
Original file line numberDiff line numberDiff line change
@@ -410,6 +410,11 @@ public function send($agi, &$MAGNUS, &$CalcAgi)
410410

411411
foreach ($modelCampaignPoll as $poll) {
412412

413+
if (isset($execute_poll_name)) {
414+
$poll = $execute_poll_name;
415+
unset($execute_poll_name);
416+
}
417+
413418
$repeat = $poll->repeat;
414419

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

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

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

445451
} else {
446-
$res_dtmf = $agi->get_data($audio, 5000, 1);
452+
453+
$agi->verbose("poll->option10: $poll->option10", 5);
454+
455+
if (strlen($poll->option10)) {
456+
457+
if (preg_match('/\#/', $poll->option10)) {
458+
$digit_timeout = preg_split('/\#/', $poll->option10);
459+
460+
$agi->verbose(print_r($digit_timeout, true), 5);
461+
$digit_timeout = end($digit_timeout);
462+
463+
} else {
464+
$digit_timeout = strlen($poll->option10);
465+
}
466+
467+
$res_dtmf = $agi->get_data($audio, strlen($poll->option10) * 2000, $digit_timeout);
468+
} else {
469+
$res_dtmf = $agi->get_data($audio, 5000, 1);
470+
}
471+
447472
}
448473

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

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

479+
$sql = "SELECT * FROM pkg_campaign_poll WHERE name = '" . $poll->{'option' . $dtmf_result} . "' AND id_campaign = $idCampaign";
480+
$poll2 = $agi->query($sql)->fetchAll(PDO::FETCH_OBJ);
481+
482+
if (isset($poll2[0]->id)) {
483+
//execute other poll
484+
$fields = "id_campaign_poll,resposta,number,city,resposta_text";
485+
$values = "'$poll->id', '$dtmf_result', '$destination', '$phonenumberCity','" . strtok($poll->{'option' . $dtmf_result}, '#') . "'";
486+
$sql = "INSERT INTO pkg_campaign_poll_info ($fields) VALUES ($values)";
487+
$agi->exec($sql);
488+
489+
$execute_poll_name = $poll2[0];
490+
continue;
491+
492+
}
493+
454494
//Hungaup call if the fisrt poll dtmf is not numeric
455495
if ($i == 0 && ! is_numeric($dtmf_result)) {
456496
$agi->verbose('nao votou nada na 1º enquete', 5);
@@ -505,6 +545,16 @@ public function send($agi, &$MAGNUS, &$CalcAgi)
505545
}
506546

507547
if (is_numeric($dtmf_result) && $dtmf_result >= 0) {
548+
549+
if (preg_match('/play_/', $poll->{'option' . $dtmf_result})) {
550+
551+
preg_match_all('/play_(.*)\#/', $poll->{'option' . $dtmf_result}, $play_audio);
552+
553+
if (isset($play_audio[1][0])) {
554+
$agi->stream_file($play_audio[1][0], ' #');
555+
}
556+
}
557+
508558
if (preg_match('/^http/', $poll->{'option' . $dtmf_result})) {
509559

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

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

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

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

589639
} else {
590640

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

@@ -610,6 +660,10 @@ public function send($agi, &$MAGNUS, &$CalcAgi)
610660
}
611661
}
612662

663+
if (preg_match('/hangup/', $poll->{'option' . $dtmf_result})) {
664+
break;
665+
}
666+
613667
} else {
614668
$agi->verbose('Cliente no marco nada', 8);
615669
break;

0 commit comments

Comments
 (0)