|
|
|
อยากทราบการใส่ loop for 2 process หน่อยครับผมทำได้แค่ process เดียวเอง รบกวนช่วยดู code ให้หน่อยนะครับ |
|
|
|
|
|
|
|
ผมพยายามจะเขียนให้มัน รัน 2 process อะครับ แต่แก้เท่าไหร่ก็ไม่ได้สักที
รบกวนพี่ๆ ช่วยแนะนำหน่อยนะครับ
Code (PHP)
#!/usr/bin/php -q
<?php
include ("phpagi.php");
include ("connect_db.php");
$agi = new AGI();
$agi->answer();
$number = 1234;
$digits = 1234;
//$agi->say_digits($number);
//$agi->say_digits($digits);
$agent = $agi->request['agi_dnid'];
$channel = $agi->request['agi_channel'];
$uniqueid = $agi->request['agi_uniqueid'];
$extension = $agi->request['agi_extension'];
$customer = $agi->request['agi_callerid'];
$context = $agi->request['agi_context'];
$agi->exec('NoOp "POLL CALLCENTER"');
$agi->exec('NoOp "AGENT= '.$agent.'"');
$agi->exec('NoOp "CHANNEL= '.$channel.'"');
$agi->exec('NoOp "UNIQUEID= '.$uniqueid.'"');
$agi->exec('NoOp "EXTENSION = '.$extension.'"');
$agi->exec('NoOp "CUSTOMER= '.$customer.'"');
$agi->exec('NoOp "CONTEXT = '.$context.'"');
for ($i=1; $i<4; $i++) {
$score = 0;
$dtmf=$agi->get_data('custom/Survey-Choice1', 5000, 1);
$score = $dtmf["result"];
$agi->exec('NoOp "SCORE1 = '.$score.'"');
if ($score == 1) {
$agentscore = insert_agent_score($agi, $score);
//if ($agentscore == 2) $agi->stream_file('hello-world');
$agi->stream_file('custom/Survey-Thank-Goodbye');
exit;
} elseif ($score == 2) {
$agentscore = insert_agent_score($agi, $score);
//if ($agentscore == 2) $agi->stream_file($prompt_system_fail);
$agi->stream_file('custom/Survey-Thank-Goodbye');
exit;
} elseif ($score == 3) {
$agentscore = insert_agent_score($agi, $score);
//if ($agentscore == 2) $agi->stream_file($prompt_system_fail);
$agi->stream_file('custom/Survey-Thank-Goodbye');
exit;
} elseif ($score == 4) {
$agentscore = insert_agent_score($agi, $score);
//if ($agentscore == 2) $agi->stream_file($prompt_system_fail);
$agi->stream_file('custom/Survey-Thank-Goodbye');
exit;
} elseif ($score == 5) {
$agentscore = insert_agent_score($agi, $score);
// if ($agentscore == 2) $agi->stream_file($prompt_system_fail);
$agi->stream_file('custom/Survey-Thank-Goodbye');
exit;
} elseif ($score == '') {
if ($i != '3') {
$agi->exec('NoOp "RETUEN SCORE NOINPUT"');
$agi->exec('NoOp "NOINPUT = '.$i.'"');
$agi->stream_file('custom/Survey-do-nothing-listen-again');
}else{
$agi->stream_file('custom/Survey-do-nothing-thx-bye');
}
}
else {
if ($i != '3') {
$agi->exec('NoOp "RETUEN SCORE INVALID"');
$agi->exec('NoOp "INVALID = '.$i.'"');
$agi->stream_file('custom/Survey-incorrect-listen-again');
}else{
$agi->stream_file('custom/Survey-incorrect-thx-bye');
}
}
for ($i=1; $i<4; $i++) {
$score1 = 0;
$dtmf=$agi->get_data('custom/Survey-Choice2', 5000, 1);
$score1 = $dtmf["result"];
$agi->exec('NoOp "SCORE1 = '.$score1.'"');
if ($score1 == 1) {
$agentscore1 = insert_agent_score($agi, $score1);
//if ($agentscore == 2) $agi->stream_file('hello-world');
$agi->stream_file('custom/Survey-Thank-Goodbye');
exit;
} elseif ($score1 == 2) {
$agentscore1 = insert_agent_score($agi, $score1);
//if ($agentscore == 2) $agi->stream_file($prompt_system_fail);
$agi->stream_file('custom/Survey-Thank-Goodbye');
exit;
} elseif ($score1 == 3) {
$agentscore1 = insert_agent_score($agi, $score1);
//if ($agentscore == 2) $agi->stream_file($prompt_system_fail);
$agi->stream_file('custom/Survey-Thank-Goodbye');
exit;
} elseif ($score1 == 4) {
$agentscore1 = insert_agent_score($agi, $score1);
//if ($agentscore == 2) $agi->stream_file($prompt_system_fail);
$agi->stream_file('custom/Survey-Thank-Goodbye');
exit;
} elseif ($score1 == 5) {
$agentscore1 = insert_agent_score($agi, $score1);
// if ($agentscore == 2) $agi->stream_file($prompt_system_fail);
$agi->stream_file('custom/Survey-Thank-Goodbye');
exit;
} elseif ($score1 == '') {
if ($i != '3') {
$agi->exec('NoOp "RETUEN SCORE NOINPUT"');
$agi->exec('NoOp "NOINPUT = '.$i.'"');
$agi->stream_file('custom/Survey-do-nothing-listen-again');
}else{
$agi->stream_file('custom/Survey-do-nothing-thx-bye');
}
}
else {
if ($i != '3') {
$agi->exec('NoOp "RETUEN SCORE INVALID"');
$agi->exec('NoOp "INVALID = '.$i.'"');
$agi->stream_file('custom/Survey-incorrect-listen-again');
}else{
$agi->stream_file('custom/Survey-incorrect-thx-bye');
}
}
function insert_agent_score($agi, $score,$score1) {
include ('connect_db.php');
//informations about call
$agent = $agi->request['agi_dnid'];
$channel = $agi->request['agi_channel'];
$uniqueid = $agi->request['agi_uniqueid'];
$extension = $agi->request['agi_extension'];
$customer = $agi->request['agi_callerid'];
$context = $agi->request['agi_context'];
$agi->exec('NoOp "AGI = '.$agi.'"');
$agi->exec('NoOp "SCORE INDB = '.$score.'"');
$agi->exec('NoOp "SCORE1 INDB = '.$score1.'"');
$sql_check = mysql_query("INSERT INTO survey2 (poll_callerid,poll_agent,poll_date,poll_score_agent,poll_score_service) VALUES ('$customer',$extension,CURRENT_TIMESTAMP,'$score')");
//$sql_check = mysql_query("INSERT INTO score (uniqueid,date,channel,extension,context,agent,customer,score) VALUES ('$uniqueid',CURRENT_TIMESTAMP,'$channel','$extension','$context','$agent','$customer','$score')");
mysql_query($sql_check,$con);
}
}
?>
Tag : PHP, MySQL
|
|
|
|
|
|
Date :
2014-09-26 13:06:59 |
By :
atiruj182 |
View :
898 |
Reply :
6 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
เพิ่ม } หน้า for ตัวที่ 2
|
ประวัติการแก้ไข 2014-09-26 14:44:22 2014-09-26 14:47:50
|
|
|
|
Date :
2014-09-26 14:43:25 |
By :
gaowteen |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
มัน error เหรอครับ ไม่ได้ นี่ คือยังไง ครับ แล้ว มัน ฟ้อง error อะไร อะ งง
|
|
|
|
|
Date :
2014-09-26 15:15:14 |
By :
gaowteen |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ตอบความคิดเห็นที่ : 3 เขียนโดย : gaowteen เมื่อวันที่ 2014-09-26 15:15:14
รายละเอียดของการตอบ ::
เขียน phpagi เชื่อกับ ตู้ asterisk อะครับ คือว่าผมไม่รู้ว่า code ของผมมันผิดตรองไหนหรือปล่าว ถ้าผมใช้แค่ for เดียว
ระบบมันจะโยนไปในระบบได้เลย แต่พอ ลองเอา for มาเพิ่ม มันก็ไม่ได้
* คือผมจะทำ call survey 1 คือให้ลูกค้าประเมิณความพอใจ ต่อพนักงานคนนั้น และ เมื่อประเมิณเส็จแล้วให้โยน มาประเมิณความพึงพอใจกับระบบการให้บริการต่อ
ไฟล์ข้างล่างนี้รันได้ไปติครับ
Code (PHP)
#!/usr/bin/php -q
<?php
include ("phpagi.php");
include ("connect_db.php");
$agi = new AGI();
$agi->answer();
$number = 1234;
$digits = 1234;
//$agi->say_digits($number);
//$agi->say_digits($digits);
$agent = $agi->request['agi_dnid'];
$channel = $agi->request['agi_channel'];
$uniqueid = $agi->request['agi_uniqueid'];
$extension = $agi->request['agi_extension'];
$customer = $agi->request['agi_callerid'];
$context = $agi->request['agi_context'];
$agi->exec('NoOp "POLL CALLCENTER"');
$agi->exec('NoOp "AGENT= '.$agent.'"');
$agi->exec('NoOp "CHANNEL= '.$channel.'"');
$agi->exec('NoOp "UNIQUEID= '.$uniqueid.'"');
$agi->exec('NoOp "EXTENSION = '.$extension.'"');
$agi->exec('NoOp "CUSTOMER= '.$customer.'"');
$agi->exec('NoOp "CONTEXT = '.$context.'"');
for ($i=1; $i<4; $i++) {
$score = 0;
$dtmf=$agi->get_data('custom/Survey-Choice2', 5000, 1);
$score = $dtmf["result"];
$agi->exec('NoOp "SCORE = '.$score.'"');
if ($score == 1) {
$agentscore = insert_agent_score($agi, $score);
//if ($agentscore == 2) $agi->stream_file('hello-world');
$agi->stream_file('custom/Survey-Thank-Goodbye');
exit;
} elseif ($score == 2) {
$agentscore = insert_agent_score($agi, $score);
//if ($agentscore == 2) $agi->stream_file($prompt_system_fail);
$agi->stream_file('custom/Survey-Thank-Goodbye');
exit;
} elseif ($score == 3) {
$agentscore = insert_agent_score($agi, $score);
//if ($agentscore == 2) $agi->stream_file($prompt_system_fail);
$agi->stream_file('custom/Survey-Thank-Goodbye');
exit;
} elseif ($score == 4) {
$agentscore = insert_agent_score($agi, $score);
//if ($agentscore == 2) $agi->stream_file($prompt_system_fail);
$agi->stream_file('custom/Survey-Thank-Goodbye');
exit;
} elseif ($score == 5) {
$agentscore = insert_agent_score($agi, $score);
// if ($agentscore == 2) $agi->stream_file($prompt_system_fail);
$agi->stream_file('custom/Survey-Thank-Goodbye');
exit;
} elseif ($score == '') {
if ($i != '3') {
$agi->exec('NoOp "RETUEN SCORE NOINPUT"');
$agi->exec('NoOp "NOINPUT = '.$i.'"');
$agi->stream_file('custom/Survey-do-nothing-listen-again');
}else{
$agi->stream_file('custom/Survey-do-nothing-thx-bye');
}
}
else {
if ($i != '3') {
$agi->exec('NoOp "RETUEN SCORE INVALID"');
$agi->exec('NoOp "INVALID = '.$i.'"');
$agi->stream_file('custom/Survey-incorrect-listen-again');
}else{
$agi->stream_file('custom/Survey-incorrect-thx-bye');
}
}
}
function insert_agent_score($agi, $score) {
include ('connect_db.php');
//informations about call
$agent = $agi->request['agi_dnid'];
$channel = $agi->request['agi_channel'];
$uniqueid = $agi->request['agi_uniqueid'];
$extension = $agi->request['agi_extension'];
$customer = $agi->request['agi_callerid'];
$context = $agi->request['agi_context'];
$agi->exec('NoOp "AGI = '.$agi.'"');
$agi->exec('NoOp "SCORE INDB = '.$score.'"');
$sql_check = mysql_query("INSERT INTO survey (poll_callerid,poll_agent,poll_date,poll_score) VALUES ('$customer',$extension,CURRENT_TIMESTAMP,'$score')");
//$sql_check = mysql_query("INSERT INTO score (uniqueid,date,channel,extension,context,agent,customer,score) VALUES ('$uniqueid',CURRENT_TIMESTAMP,'$channel','$extension','$context','$agent','$customer','$score')");
mysql_query($sql_check,$con);
}
?>
|
|
|
|
|
Date :
2014-09-26 15:32:02 |
By :
atiruj182 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Code (PHP)
#!/usr/bin/php -q
<?php
include ("phpagi.php");
include ("connect_db.php");
$agi = new AGI();
$agi->answer();
$number = 1234;
$digits = 1234;
//$agi->say_digits($number);
//$agi->say_digits($digits);
$agent = $agi->request['agi_dnid'];
$channel = $agi->request['agi_channel'];
$uniqueid = $agi->request['agi_uniqueid'];
$extension = $agi->request['agi_extension'];
$customer = $agi->request['agi_callerid'];
$context = $agi->request['agi_context'];
$agi->exec('NoOp "POLL CALLCENTER"');
$agi->exec('NoOp "AGENT= '.$agent.'"');
$agi->exec('NoOp "CHANNEL= '.$channel.'"');
$agi->exec('NoOp "UNIQUEID= '.$uniqueid.'"');
$agi->exec('NoOp "EXTENSION = '.$extension.'"');
$agi->exec('NoOp "CUSTOMER= '.$customer.'"');
$agi->exec('NoOp "CONTEXT = '.$context.'"');
for ($i=1; $i<4; $i++) {
$score = 0;
$dtmf=$agi->get_data('custom/Survey-Choice2', 5000, 1);
$score = $dtmf["result"];
$agi->exec('NoOp "SCORE = '.$score.'"');
if ($score == 1) {
$agentscore = insert_agent_score($agi, $score);
//if ($agentscore == 2) $agi->stream_file('hello-world');
$agi->stream_file('custom/Survey-Thank-Goodbye');
exit;
} elseif ($score == 2) {
$agentscore = insert_agent_score($agi, $score);
//if ($agentscore == 2) $agi->stream_file($prompt_system_fail);
$agi->stream_file('custom/Survey-Thank-Goodbye');
exit;
} elseif ($score == 3) {
$agentscore = insert_agent_score($agi, $score);
//if ($agentscore == 2) $agi->stream_file($prompt_system_fail);
$agi->stream_file('custom/Survey-Thank-Goodbye');
exit;
} elseif ($score == 4) {
$agentscore = insert_agent_score($agi, $score);
//if ($agentscore == 2) $agi->stream_file($prompt_system_fail);
$agi->stream_file('custom/Survey-Thank-Goodbye');
exit;
} elseif ($score == 5) {
$agentscore = insert_agent_score($agi, $score);
// if ($agentscore == 2) $agi->stream_file($prompt_system_fail);
$agi->stream_file('custom/Survey-Thank-Goodbye');
exit;
} elseif ($score == '') {
if ($i != '3') {
$agi->exec('NoOp "RETUEN SCORE NOINPUT"');
$agi->exec('NoOp "NOINPUT = '.$i.'"');
$agi->stream_file('custom/Survey-do-nothing-listen-again');
}else{
$agi->stream_file('custom/Survey-do-nothing-thx-bye');
}
}
else {
if ($i != '3') {
$agi->exec('NoOp "RETUEN SCORE INVALID"');
$agi->exec('NoOp "INVALID = '.$i.'"');
$agi->stream_file('custom/Survey-incorrect-listen-again');
}else{
$agi->stream_file('custom/Survey-incorrect-thx-bye');
}
}
}
for ($i=1; $i<4; $i++) {
$score1 = 0;
$dtmf=$agi->get_data('custom/Survey-Choice2', 5000, 1);
$score1 = $dtmf["result"];
$agi->exec('NoOp "SCORE1 = '.$score1.'"');
if ($score1 == 1) {
$agentscore1 = insert_agent_score($agi, $score1);
//if ($agentscore == 2) $agi->stream_file('hello-world');
$agi->stream_file('custom/Survey-Thank-Goodbye');
exit;
} elseif ($score1 == 2) {
$agentscore1 = insert_agent_score($agi, $score1);
//if ($agentscore == 2) $agi->stream_file($prompt_system_fail);
$agi->stream_file('custom/Survey-Thank-Goodbye');
exit;
} elseif ($score1 == 3) {
$agentscore1 = insert_agent_score($agi, $score1);
//if ($agentscore == 2) $agi->stream_file($prompt_system_fail);
$agi->stream_file('custom/Survey-Thank-Goodbye');
exit;
} elseif ($score1 == 4) {
$agentscore1 = insert_agent_score($agi, $score1);
//if ($agentscore == 2) $agi->stream_file($prompt_system_fail);
$agi->stream_file('custom/Survey-Thank-Goodbye');
exit;
} elseif ($score1 == 5) {
$agentscore1 = insert_agent_score($agi, $score1);
// if ($agentscore == 2) $agi->stream_file($prompt_system_fail);
$agi->stream_file('custom/Survey-Thank-Goodbye');
exit;
} elseif ($score1 == '') {
if ($i != '3') {
$agi->exec('NoOp "RETUEN SCORE NOINPUT"');
$agi->exec('NoOp "NOINPUT = '.$i.'"');
$agi->stream_file('custom/Survey-do-nothing-listen-again');
}else{
$agi->stream_file('custom/Survey-do-nothing-thx-bye');
}
}
else {
if ($i != '3') {
$agi->exec('NoOp "RETUEN SCORE INVALID"');
$agi->exec('NoOp "INVALID = '.$i.'"');
$agi->stream_file('custom/Survey-incorrect-listen-again');
}else{
$agi->stream_file('custom/Survey-incorrect-thx-bye');
}
}
}
function insert_agent_score($agi, $score) {
include ('connect_db.php');
//informations about call
$agent = $agi->request['agi_dnid'];
$channel = $agi->request['agi_channel'];
$uniqueid = $agi->request['agi_uniqueid'];
$extension = $agi->request['agi_extension'];
$customer = $agi->request['agi_callerid'];
$context = $agi->request['agi_context'];
$agi->exec('NoOp "AGI = '.$agi.'"');
$agi->exec('NoOp "SCORE INDB = '.$score.'"');
$sql_check = mysql_query("INSERT INTO survey (poll_callerid,poll_agent,poll_date,poll_score) VALUES ('$customer',$extension,CURRENT_TIMESTAMP,'$score')");
//$sql_check = mysql_query("INSERT INTO score (uniqueid,date,channel,extension,context,agent,customer,score) VALUES ('$uniqueid',CURRENT_TIMESTAMP,'$channel','$extension','$context','$agent','$customer','$score')");
mysql_query($sql_check,$con);
}
?>
|
|
|
|
|
Date :
2014-09-26 15:41:29 |
By :
gaowteen |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ได้แล้วครับ เปลื่ยนตรงข้อแรก จาก exit เป็น break
Code (PHP)
$score = 0;
$dtmf=$agi->get_data('custom/Survey-Choice1', 5000, 1);
$score = $dtmf["result"];
$agi->exec('NoOp "SCORE = '.$score.'"');
if ($score == 1) {
$agentscore = insert_agent_score($agi, $score);
//if ($agentscore == 2) $agi->stream_file('hello-world');
$agi->stream_file('custom/Survey-Thank-Goodbye');
break;
} elseif ($score == 2) {
$agentscore = insert_agent_score($agi, $score);
//if ($agentscore == 2) $agi->stream_file($prompt_system_fail);
$agi->stream_file('custom/Survey-Thank-Goodbye');
break;
} elseif ($score == 3) {
$agentscore = insert_agent_score($agi, $score);
//if ($agentscore == 2) $agi->stream_file($prompt_system_fail);
$agi->stream_file('custom/Survey-Thank-Goodbye');
break;
} elseif ($score == 4) {
$agentscore = insert_agent_score($agi, $score);
//if ($agentscore == 2) $agi->stream_file($prompt_system_fail);
$agi->stream_file('custom/Survey-Thank-Goodbye');
break;
} elseif ($score == 5) {
$agentscore = insert_agent_score($agi, $score);
// if ($agentscore == 2) $agi->stream_file($prompt_system_fail);
$agi->stream_file('custom/Survey-Thank-Goodbye');
break;
} elseif ($score == '') {
if ($i != '3') {
|
|
|
|
|
Date :
2014-09-26 16:10:59 |
By :
atiruj182 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 04
|