/** * Add a subscriber to the current billrun entry. * @param Billrun_Subscriber $subscriber * @param string $status * @return Billrun_Billrun the current instance of the billrun entry. */ public function addSubscriber($subscriber, $status) { $current_plan_name = $subscriber->plan; if (is_null($current_plan_name) || $current_plan_name == "NULL") { Billrun_Factory::log()->log("Null current plan for subscriber {$subscriber->sid}", Zend_Log::INFO); $current_plan_ref = null; } else { $current_plan_ref = $subscriber->getPlan()->createRef(); } $next_plan = $subscriber->getNextPlan(); if (is_null($next_plan)) { $next_plan_ref = null; } else { $next_plan_ref = $next_plan->createRef(); } $subscribers = $this->data['subs']; $subscriber_entry = $this->getEmptySubscriberBillrunEntry($subscriber->sid); $subscriber_entry['subscriber_status'] = $status; $subscriber_entry['current_plan'] = $current_plan_ref; $subscriber_entry['next_plan'] = $next_plan_ref; foreach ($subscriber->getExtraFieldsForBillrun() as $field => $save) { if ($field == !$save) { continue; } $subscriber_entry[$field] = $subscriber->{$field}; } $subscribers[] = $subscriber_entry; $this->data['subs'] = $subscribers; return $this; }