よし、今日も髪を抜く。この配列をループして、ここで「エスカレーション」、「プレミアム」、「標準」などとして表示される要素のキーを取得する必要があるため、それらをテーブルに表示できます。
私はこれを試してみましたが、すべてが「放棄」され、階層を上に移動する方法がわかりません。
foreach($calls as $call){
$results[ $call['queue_name'] ][ $call['type'] ] = $call['calls'];
$totalCalls += $call['calls'];
$typeTotals[ $call['type'] ] = isset( $typeTotals[ $call['type'] ]) ? $typeTotals[ $call['type'] ] + $call['calls'] : $call['calls'];
}
ここにvar_dumpがあります:
array(5) {
["Escalations"]=> array(3) {
["abandoned"]=> string(1) "2"
["completed"]=> string(1) "3"
["redirected"]=> string(1) "1" }
["Premium"]=> array(3) {
["abandoned"]=> string(1) "7"
["completed"]=> string(2) "29"
["redirected"]=> string(1) "6" }
["Standard"]=> array(3) {
["abandoned"]=> string(2) "14"
["completed"]=> string(2) "41"
["redirected"]=> string(2) "53" }
["Wingate Queue"]=> array(2) {
["abandoned"]=> string(1) "2"
["completed"]=> string(1) "3" }
["WorldMark"]=> array(3) {
["abandoned"]=> string(2) "32"
["completed"]=> string(3) "100"
["redirected"]=> string(2) "82" } }
array(5) {
["Escalations"]=> array(3) {
["abandoned"]=> string(1) "2"
["completed"]=> string(1) "3"
["redirected"]=> string(1) "1" }
["Premium"]=> array(3) {
["abandoned"]=> string(1) "7"
["completed"]=> string(2) "29"
["redirected"]=> string(1) "6" }
["Standard"]=> array(3) {
["abandoned"]=> string(2) "14"
["completed"]=> string(2) "41"
["redirected"]=> string(2) "53" }
["Wingate Queue"]=> array(2) {
["abandoned"]=> string(1) "2"
["completed"]=> string(1) "3" }
["WorldMark"]=> array(3) {
["abandoned"]=> string(2) "32"
["completed"]=> string(3) "100"
["redirected"]=> string(2) "82" } }
array(5) {
["Escalations"]=> array(3) {
["abandoned"]=> string(1) "2"
["completed"]=> string(1) "3"
["redirected"]=> string(1) "1" }
["Premium"]=> array(3) {
["abandoned"]=> string(1) "7"
["completed"]=> string(2) "29"
["redirected"]=> string(1) "6" }
["Standard"]=> array(3) {
["abandoned"]=> string(2) "14"
["completed"]=> string(2) "41"
["redirected"]=> string(2) "53" }
["Wingate Queue"]=> array(2) {
["abandoned"]=> string(1) "2"
["completed"]=> string(1) "3" }
["WorldMark"]=> array(3) {
["abandoned"]=> string(2) "32"
["completed"]=> string(3) "100"
["redirected"]=> string(2) "82" } }
array(5) {
["Escalations"]=> array(3) {
["abandoned"]=> string(1) "2"
["completed"]=> string(1) "3"
["redirected"]=> string(1) "1" }
["Premium"]=> array(3) {
["abandoned"]=> string(1) "7"
["completed"]=> string(2) "29"
["redirected"]=> string(1) "6" }
["Standard"]=> array(3) {
["abandoned"]=> string(2) "14"
["completed"]=> string(2) "41"
["redirected"]=> string(2) "53" }
["Wingate Queue"]=> array(2) {
["abandoned"]=> string(1) "2"
["completed"]=> string(1) "3" }
["WorldMark"]=> array(3) {
["abandoned"]=> string(2) "32"
["completed"]=> string(3) "100"
["redirected"]=> string(2) "82" } }
array(5) {
["Escalations"]=> array(3) {
["abandoned"]=> string(1) "2"
["completed"]=> string(1) "3"
["redirected"]=> string(1) "1" }
["Premium"]=> array(3) {
["abandoned"]=> string(1) "7"
["completed"]=> string(2) "29"
["redirected"]=> string(1) "6" }
["Standard"]=> array(3) {
["abandoned"]=> string(2) "14"
["completed"]=> string(2) "41"
["redirected"]=> string(2) "53" }
["Wingate Queue"]=> array(2) {
["abandoned"]=> string(1) "2"
["completed"]=> string(1) "3" }
["WorldMark"]=> array(3) {
["abandoned"]=> string(2) "32"
["completed"]=> string(3) "100"
["redirected"]=> string(2) "82" } }
foreach($results as $result){
$perAbandoned = $totalCalls != 0 ? round( ($result['abandoned'] / $totalCalls) * 100 ) : 0;
$perRedirected = $totalCalls != 0 ? round( ($result['redirected'] / $totalCalls) * 100) : 0;
$perAnswered = $totalCalls != 0 ? round( ($result['completed'] / $totalCalls) * 100 ) : 0;
echo "<tr>";
echo "<td>" . key($result) . "</td>";//key
echo "<td>" . $totalCalls . "</td>";
echo "<td>" . $result['completed'] . "</td>";
echo "<td>" . $perAnswered . "%</td>";
echo "<td>" . $result['abandoned'] . "</td>";
echo "<td>" . $perAbandoned . "%</td>";
echo "<td>" . $result['redirected'] . "</td>";
echo "<td>" . $perRedirected . "%</td>";
echo "<td>techs logged in</td>";
echo "</tr>";
}
アレイ:
array(5) {
["Escalations"]=> array(3) {
["abandoned"]=> string(1) "2"
["completed"]=> string(1) "3"
["redirected"]=> string(1) "1" }
["Premium"]=> array(3) {
["abandoned"]=> string(1) "7"
["completed"]=> string(2) "29"
["redirected"]=> string(1) "6" }
["Standard"]=> array(3) {
["abandoned"]=> string(2) "14"
["completed"]=> string(2) "41"
["redirected"]=> string(2) "53" }
["Wingate Queue"]=> array(2) {
["abandoned"]=> string(1) "2"
["completed"]=> string(1) "3" }
["WorldMark"]=> array(3) {
["abandoned"]=> string(2) "32"
["completed"]=> string(3) "100"
["redirected"]=> string(2) "82" } }