Skip to content

Instantly share code, notes, and snippets.

@cygeorgel
Created March 20, 2020 13:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cygeorgel/a249d0704a973a744d90462fffd0a998 to your computer and use it in GitHub Desktop.
Save cygeorgel/a249d0704a973a744d90462fffd0a998 to your computer and use it in GitHub Desktop.
<?php
namespace App\BlueRock\Telco3cx;
use App\TelcoCdrPbx3cxCall;
class Cdr
{
public function getPbx3cxCall($file, $line, $host) {
$call = null;
$values = str_getcsv($line, ',', '');
$callId = null;
if ( ! empty ($values[1])) {
$callId = $values[1];
}
$duration = '00:00:00';
if ( ! empty($values[2])) {
$duration = $values[2];
}
$call = TelcoCdrPbx3cxCall::create([
'host' => $host,
'origin' => $host . '-' . $file,
'historyId' => $values[0],
'callId' => $callId,
'duration' => $duration,
'timeStart' => ! empty ($values[3]) ? \Carbon\Carbon::createFromFormat('Y/m/d H:i:s', $values[3]) : null,
'timeAnswered' => ! empty ($values[4]) ? \Carbon\Carbon::createFromFormat('Y/m/d H:i:s', $values[4]) : null,
'timeEnd' => ! empty ($values[5]) ? \Carbon\Carbon::createFromFormat('Y/m/d H:i:s', $values[5]) : null,
'reasonTerminated' => ! empty($values[6]) ? $values[6] : null,
'fromNo' => ! empty($values[7]) ? $values[7] : null,
'toNo' => ! empty($values[8]) ? $values[8] : null,
'fromDn' => ! empty($values[9]) ? $values[9] : null,
'toDn' => ! empty($values[10]) ? $values[10] : null,
'dialNo' => ! empty($values[11]) ? $values[11] : null,
'reasonChanged' => ! empty($values[12]) ? $values[12] : null,
'finalNumber' => ! empty($values[13]) ? $values[13] : null,
'finalDn' => ! empty($values[14]) ? $values[14] : null,
'billCode' => ! empty($values[15]) ? $values[15] : null,
'billRate' =>! empty($values[16]) ? $values[16] : null,
'billCost' => ! empty($values[17]) ? $values[17] : null,
'billName' => ! empty($values[18]) ? $values[18] : null,
'chain' => ! empty($values[19]) ? $values[19] : null,
'fromType' => ! empty($values[20]) ? $values[20] : null,
'toType' => ! empty($values[21]) ? $values[21] : null,
'finalType' => ! empty($values[22]) ? $values[22] : null,
'fromDispname' => ! empty($values[23]) ? $values[23] : null,
'toDispname' => ! empty($values[24]) ? $values[24] : null,
'finalDispname' => ! empty($values[25]) ? $values[25] : null,
'missedQueueCalls' => ! empty($values[26]) ? $values[26] : null,
]);
if ($call) {
return true;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment