@@ -410,6 +410,11 @@ public function send($agi, &$MAGNUS, &$CalcAgi)
410
410
411
411
foreach ($ modelCampaignPoll as $ poll ) {
412
412
413
+ if (isset ($ execute_poll_name )) {
414
+ $ poll = $ execute_poll_name ;
415
+ unset($ execute_poll_name );
416
+ }
417
+
413
418
$ repeat = $ poll ->repeat ;
414
419
415
420
if ($ dtmf_result == -1 ) {
@@ -430,6 +435,7 @@ public function send($agi, &$MAGNUS, &$CalcAgi)
430
435
431
436
$ audio = $ uploaddir . "idPoll_ " . $ poll ->id ;
432
437
438
+ $ agi ->verbose ("audio: $ audio " , 5 );
433
439
if ($ poll ->request_authorize == 1 ) {
434
440
$ agi ->verbose ('Request authorize ' , 5 );
435
441
//IF CUSTOMER MARK 1 EXECUTE POLL
@@ -443,14 +449,48 @@ public function send($agi, &$MAGNUS, &$CalcAgi)
443
449
}
444
450
445
451
} 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
+
447
472
}
448
473
449
474
//GET RESULT OF POLL
450
475
$ dtmf_result = $ res_dtmf ['result ' ];
451
476
452
477
$ agi ->verbose ("Cliente votou na opcao: $ dtmf_result " , 5 );
453
478
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
+
454
494
//Hungaup call if the fisrt poll dtmf is not numeric
455
495
if ($ i == 0 && ! is_numeric ($ dtmf_result )) {
456
496
$ agi ->verbose ('nao votou nada na 1º enquete ' , 5 );
@@ -505,6 +545,16 @@ public function send($agi, &$MAGNUS, &$CalcAgi)
505
545
}
506
546
507
547
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
+
508
558
if (preg_match ('/^http/ ' , $ poll ->{'option ' . $ dtmf_result })) {
509
559
510
560
$ agi ->verbose ('chamar API ' , 25 );
@@ -532,7 +582,7 @@ public function send($agi, &$MAGNUS, &$CalcAgi)
532
582
533
583
}
534
584
//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 ' ) {
536
586
537
587
$ agi ->verbose ('desligar chamadas ' , 25 );
538
588
@@ -588,8 +638,8 @@ public function send($agi, &$MAGNUS, &$CalcAgi)
588
638
589
639
} else {
590
640
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 }, ' # ' ) . " ' " ;
593
643
$ sql = "INSERT INTO pkg_campaign_poll_info ( $ fields) VALUES ( $ values) " ;
594
644
$ agi ->exec ($ sql );
595
645
@@ -610,6 +660,10 @@ public function send($agi, &$MAGNUS, &$CalcAgi)
610
660
}
611
661
}
612
662
663
+ if (preg_match ('/hangup/ ' , $ poll ->{'option ' . $ dtmf_result })) {
664
+ break ;
665
+ }
666
+
613
667
} else {
614
668
$ agi ->verbose ('Cliente no marco nada ' , 8 );
615
669
break ;
0 commit comments