Example #1
0
 /**
  * create and save service lines
  * @param type $subscriber
  * @param type $billrun_key
  * @return array of inserted lines
  */
 protected function saveServiceLines($subscriber, $billrun_key)
 {
     $services = $subscriber->getServices($billrun_key, true);
     $ret = array();
     foreach ($services as $service) {
         $rawData = $service->getRawData();
         try {
             $this->lines->insert($rawData, array("w" => 1));
         } catch (Exception $e) {
             if ($e->getCode() == 11000) {
                 Billrun_Factory::log("Service already exists for subscriber " . $subscriber->sid . " for billrun " . $billrun_key . " service details: " . print_R($rawData, 1), Zend_log::ALERT);
             } else {
                 Billrun_Factory::log("Problem inserting service for subscriber " . $subscriber->sid . " for billrun " . $billrun_key . ". error message: " . $e->getMessage() . ". error code: " . $e->getCode() . ". service details:" . print_R($rawData, 1), Zend_log::ALERT);
                 Billrun_Util::logFailedServiceRow($rawData);
             }
         }
         $ret[$service['stamp']] = $service;
     }
     return $ret;
 }