function valuesToForm(&$ret, Product $record) { if ($record->isLoaded()) { $ret['_categories'] = $record->getCategories(); $ret['_plan'] = array(); foreach ($record->getBillingPlans() as $plan) { $arr = $plan->toArray(); $arr['paysys_id'] = $arr['paysys_id'] ? explode(',', $arr['paysys_id']) : array(); if (!empty($arr['rebill_times'])) { $arr['_rebill_times'] = $arr['rebill_times']; if (!in_array($arr['rebill_times'], array(0, 1, IProduct::RECURRING_REBILLS))) { $arr['_rebill_times'] = 'x'; } } foreach (array('first_period', 'second_period') as $f) { if (array_key_exists($f, $arr)) { $arr[$f] = new Am_Period($arr[$f]); } } $ret['_plan'][$plan->pk()] = $arr; } } }