Created
July 16, 2018 08:40
-
-
Save cygeorgel/3304ee4edc5c392797885ec17c956080 to your computer and use it in GitHub Desktop.
Import calls from Gentel
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if($service == 'gentel') { | |
// locally: | |
$dir = storage_path('app/cdr/gentel'); | |
$files = scandir($dir); | |
foreach($files as $file) { | |
if($file != '.' && $file != '..') { | |
$control = \DB::table('telco_cdr_gentel_calls')->select('id')->where('origin', $file)->count(); | |
if($control == 0) { | |
$data = file_get_contents(storage_path('app/cdr/gentel/' . $file)); | |
$lines = explode("\n", $data); | |
foreach($lines as $line) { | |
$values = explode(';', $line); | |
if(isset($values[3]) && is_numeric($values[3])) { | |
TelcoCdrGentelCall::create([ | |
'origin' => $file, | |
'NoFacture' => $values[0], | |
'IdCdr' => $values[1], | |
'NoClient' => $values[2], | |
'DateHeureAppel' => $values[3], | |
'DureeEnS' => $values[4], | |
'NumeroAppele' => $values[5], | |
'NoLigneAppelante' => $values[6], | |
'TypeCom' => utf8_encode($values[7]), | |
'VolumeDonneesEnKo' => $values[8], | |
'Destination' => utf8_encode($values[9]), | |
'TypeAppel' => utf8_encode($values[10]), | |
'UnitesAppel' => $values[11], | |
'UnitesDecomptees' => $values[12], | |
'coutEtablissementHt' => $values[13], | |
'coutValoriseHt' => $values[14], | |
'PrefixeForce' => $values[15], | |
]); | |
print 'insert call: ok' . PHP_EOL; | |
} | |
} | |
} | |
else { | |
print 'This file has already been imported' . PHP_EOL; | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment