/**
* ASTERISK
*
* @version 0.1 (beta)
* Biete die Moeglichkeit vom Asterisk
* eine Anruf-History in Form einer einfachen
* Statisk anzuzeigen.
*
*/
class ASTERISK {
// Globale Variablen
public $callDataCSV = 'PFAD_ZUR_DATEI/Master.csv'; // aus dieser Datei werden die Anrufdaten gelesen (Symlink vom Asterisk Order)
public $callDataSeperator = ','; // dient als Trennzeichen fuer die CSV-Datei
public $callDataArrayKeys = array( // Spaltenbezeichnungen- und bedeutungen innherhalb der CSV-Datei
'accountcode', // What account number to use: account, (string, 20 characters)
'src', // Caller*ID number (string, 80 characters)
'dst', // Destination extension (string, 80 characters)
'dcontext', // Destination context (string, 80 characters)
'clid', // Caller*ID with text (80 characters)
'channel', // Channel used (80 characters)
'dstchannel', // Destination channel if appropriate (80 characters)
'lastapp', // Last application if appropriate (80 characters)
'lastdata', // Last application data (arguments) (80 characters)
'start', // Start of call (date/time)
'answer', // Anwer of call (date/time)
'end', // End of call (date/time)
'duration', // Total time in system, in seconds (integer)
'billsec', // Total time call is up, in seconds (integer)
'disposition', // What happened to the call: ANSWERED, NO ANSWER, BUSY, FAILED
'amaflags'); // What flags to use: see amaflags::DOCUMENTATION, BILL, IGNORE etc, specified on a per channel basis like accountcode.
public $statisticTpl = 'PFAD_ZUR_DATEI/statistic.tpl'; // Template fuer die Statistiktabelle
// Konstruktor
function ASTERISK() {
}
function parseCallDetailCSV2Array(){
// lokale Zaehlervariablen
$i=0;
$j=0;
// CSV-Datei auslesen
$callData = file($this->callDataCSV);
// CSV-Datei in ein Array schreiben
while (list($key,$val) = each($callData)){
// CSV-String in Array legen
$tmpCsvArray = explode($this->callDataSeperator,$val);
// Assozatives Array erzeugen
for($m=0;$m<count($tmpCsvArray);$m++) {
// $i zaehler nach 16 durchlaeufen zuruecksetzen
if($i == 16) {$i=0; $j++;}
if($this->callDataArrayKeys[$i]){
// Assosatives Array bilden ...
$callDataAssoziationArray[$j][$this->callDataArrayKeys[$i]] = $tmpCsvArray[$i];
$i++;
}
}
}
return $callDataAssoziationArray;
}
function getStatisticTpl() {
// Template laden
$statisticTpl = file_get_contents($this->statisticTpl);
// Template uebergeben
return $statisticTpl;
}
function callStatistic() {
// Array mit (Live!) CSV-Inhalte
$callArray = $this->parseCallDetailCSV2Array();
// Array mit CSV-Inahlte in Template einsetzen
$callStatisticTpl = $this->getStatisticTpl();
// Template fuellen
for($i=0;$i<count($callArray);$i++){
$callStatistic_tmp = $callStatisticTpl;
while (list($key,$val) = each($callArray[$i])){
$val = str_replace('"','',$val);
$callStatistic_tmp = str_replace('#'.$key.'#',$val,$callStatistic_tmp);
// Farbbalken
if((($i)%2)==0) {
$callStatistic_tmp = str_replace('#bgcolor','#E9E9E9',$callStatistic_tmp);
}
else {
$callStatistic_tmp = str_replace('#bgcolor','',$callStatistic_tmp);
}
}
$callStatistic .= $callStatistic_tmp;
}
echo '<table border="0" cellspacing="0" cellpadding="2">
<tr>
<td width="100"><b>Von Apperat</b></td>
<td width="100"><b>Zielrufnummer</b></td>
<td width="150"><b>Anruf Start</b></td>
<td width="150"><b>Anruf Ende</b></td>
<td width="150"><b>Anrufdauer (in Sekunden)</b></td>
<td width="100"><b>Anrufstatus</b></td>
</tr>
<tr>
<td colspan="6"><hr size="1"></td>
</tr>
'.$callStatistic.'</table>';
}
}
$asterisk = new ASTERISK();
$asterisk->callStatistic();
?>