/** * Pull required fields from the CDR nested tree to the surface. * @param type $cdrLine the line to monipulate. */ protected function surfaceCDRFields(&$cdrLine, $mapping) { foreach ($mapping as $key => $fieldToMap) { $val = Billrun_Util::getNestedArrayVal($cdrLine, $fieldToMap, null); if ($val !== null && Billrun_Util::getFieldVal($this->tap3Config['fields_to_save'][$key], false)) { $cdrLine[$key] = $val; } } if (Billrun_Util::getNestedArrayVal($cdrLine, $mapping['localTimeStamp']) !== null) { $offset = $this->currentFileHeader['networkInfo']['UtcTimeOffsetInfoList'][Billrun_Util::getNestedArrayVal($cdrLine, $mapping['TimeOffsetCode'])]; $cdrLine['urt'] = new MongoDate(Billrun_Util::dateTimeConvertShortToIso(Billrun_Util::getNestedArrayVal($cdrLine, $mapping['localTimeStamp']), $offset)); $cdrLine['tzoffset'] = $offset; } if (Billrun_Util::getNestedArrayVal($cdrLine, $mapping['tele_srv_code']) !== null && isset($cdrLine['record_type'])) { $tele_service_code = Billrun_Util::getNestedArrayVal($cdrLine, $mapping['tele_srv_code']); $record_type = $cdrLine['record_type']; if ($record_type == '9') { if ($tele_service_code == '11') { if (Billrun_Util::getNestedArrayVal($cdrLine, $mapping['dialed_digits'])) { $cdrLine['called_number'] = Billrun_Util::getNestedArrayVal($cdrLine, $mapping['dialed_digits']); } else { $cdrLine['called_number'] = Billrun_Util::getNestedArrayVal($cdrLine, $mapping['called_number']); //$cdrLine['basicCallInformation']['Desination']['CalledNumber']; } } else { if ($tele_service_code == '22') { if (Billrun_Util::getNestedArrayVal($cdrLine, $mapping['dialed_digits'])) { $cdrLine['called_number'] = Billrun_Util::getNestedArrayVal($cdrLine, $mapping['dialed_digits']); } else { if (isset($cdrLine['basicCallInformation']['Desination']['CalledNumber'])) { // @todo check with sefi. reference: db.lines.count({'BasicServiceUsedList.BasicServiceUsed.BasicService.BasicServiceCode.TeleServiceCode':"22",record_type:'9','basicCallInformation.Desination.DialedDigits':{$exists:false}});) $cdrLine['called_number'] = Billrun_Util::getNestedArrayVal($cdrLine, $mapping['called_number']); } } } } } else { if ($record_type == 'a') { if ($tele_service_code == '11') { if (Billrun_Util::getNestedArrayVal($cdrLine, $mapping['called_number'])) { $cdrLine['called_number'] = Billrun_Util::getNestedArrayVal($cdrLine, $mapping['called_number']); //$cdrLine['basicCallInformation']['Desination']['CalledNumber']; } } } } } if (isset($cdrLine['called_number'])) { $cdrLine['called_number'] = Billrun_Util::msisdn($cdrLine['called_number']); } // if (!Billrun_Util::getNestedArrayVal($cdrLine, $mapping['calling_number']) && isset($tele_service_code) && isset($record_type) ) { // if ($record_type == 'a' && ($tele_service_code == '11' || $tele_service_code == '21')) { // if (Billrun_Util::getNestedArrayVal($cdrLine, $mapping['call_org_number'])) { // for some calls (incoming?) there's no calling number // $cdrLine['calling_number'] = Billrun_Util::getNestedArrayVal($cdrLine, $mapping['call_org_number']); // } // } // } if (Billrun_Util::getNestedArrayVal($cdrLine, $mapping['serving_network']) !== null) { $cdrLine['serving_network'] = Billrun_Util::getNestedArrayVal($cdrLine, $mapping['serving_network']); } else { $cdrLine['serving_network'] = $this->currentFileHeader['header']['sending_source']; } if (Billrun_Util::getNestedArrayVal($cdrLine, $mapping['sdr']) !== null) { $sdrs = Billrun_Util::getNestedArrayVal($cdrLine, $mapping['sdr'], null, TRUE); $sum = $this->sumup_arrays($sdrs, 20); $cdrLine['sdr'] = $sum; $cdrLine['exchange_rate'] = $this->exchangeRates[Billrun_Util::getNestedArrayVal($cdrLine, $mapping['exchange_rate_code'], 0)]; } if (Billrun_Util::getNestedArrayVal($cdrLine, $mapping['sdr_tax']) !== null) { $cdrLine['sdr_tax'] = Billrun_Util::getNestedArrayVal($cdrLine, $mapping['sdr_tax']) / $this->sdr_division_value; } //save the sending source in each of the lines $cdrLine['sending_source'] = $this->currentFileHeader['header']['sending_source']; }