Пример #1
0
 public function __construct($options = array())
 {
     parent::__construct($options);
     if (isset($options['filename_regex'])) {
         $this->filenameRegex = $options['filename_regex'];
     }
     if (isset($options['receiver']['limit']) && $options['receiver']['limit']) {
         $this->setLimit($options['receiver']['limit']);
     }
     if (isset($options['receiver']['preserve_timestamps'])) {
         $this->preserve_timestamps = $options['receiver']['preserve_timestamps'];
     }
     if (isset($options['backup_path'])) {
         $this->backupPaths = $options['backup_path'];
     } else {
         $this->backupPaths = Billrun_Factory::config()->getConfigValue($this->getType() . '.backup_path', array('./backups/' . $this->getType()));
     }
     if (isset($options['receiver']['backup_granularity']) && $options['receiver']['backup_granularity']) {
         $this->setGranularity((int) $options['receiver']['backup_granularity']);
     }
     if (Billrun_Util::getFieldVal($options['receiver']['backup_date_fromat'], false)) {
         $this->setBackupDateDirFromat($options['receiver']['backup_date_fromat']);
     }
     if (isset($options['receiver']['orphan_time']) && (int) $options['receiver']['orphan_time'] > 900) {
         $this->file_fetch_orphan_time = $options['receiver']['orphan_time'];
     }
 }
Пример #2
0
 /**
  * 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'];
 }
Пример #3
0
 /**
  * 
  * @param type $array
  * @param type $fields
  * @param type $defaultVal
  * @return type
  */
 public static function getNestedArrayVal($array, $fields, $defaultVal = null, $retArr = FALSE)
 {
     $fields = is_array($fields) ? $fields : explode('.', $fields);
     $rawField = array_shift($fields);
     preg_match("/\\[([^\\]]*)\\]/", $rawField, $attr);
     if (!empty($attr)) {
         //Allow for  multiple attribute checks
         $attr = explode("=", Billrun_Util::getFieldVal($attr[1], FALSE));
     }
     $field = preg_replace("/\\[[^\\]]*\\]/", "", $rawField);
     $aggregate = $retArr && $field == '*';
     $keys = $field != "*" ? array($field) : array_keys($array);
     $retVal = $aggregate ? array() : $defaultVal;
     foreach ($keys as $key) {
         if (isset($array[$key]) && (empty($attr) || isset($array[$key][$attr[0]])) && (!isset($attr[1]) || $array[$key][$attr[0]] == $attr[1])) {
             if (!$aggregate) {
                 $retVal = empty($fields) ? $array[$key] : static::getNestedArrayVal($array[$key], $fields, $defaultVal, $retArr);
                 break;
             } else {
                 $retVal[] = empty($fields) ? $array[$key] : static::getNestedArrayVal($array[$key], $fields, $defaultVal, $retArr);
             }
         }
     }
     return $retVal;
 }
Пример #4
0
 /**
  * constructor of the class
  * 
  * @param array $options the options of object load
  */
 public function __construct($options = array())
 {
     parent::__construct($options);
     if (isset($options['calculator']['limit'])) {
         $this->limit = $options['calculator']['limit'];
     }
     if (isset($options['months_limit'])) {
         $this->months_limit = $options['months_limit'];
     }
     if (!isset($options['autoload']) || $options['autoload']) {
         $this->load();
     }
     if (isset($options['autosort'])) {
         $this->autosort = $options['autosort'];
     }
     if (Billrun_Util::getFieldVal($options['calculator']['rates_query'], false)) {
         $this->rates_query = Billrun_Util::getFieldVal($options['calculator']['rates_query'], array());
     }
     $this->queue_coll = Billrun_Factory::db()->queueCollection();
 }