/** * @param $data * @param $form * @throws ValidationException * @throws null * Handle submit signup */ public function Submit($data, $form) { foreach ($data as $k => &$v) { if ($v === 'false') { $data[$k] = false; } elseif ($v === 'true') { $data[$k] = true; } if ($k === 'Title') { $v = $v + 1; } } Session::set('SignupData', $data); $Signup = new Signup(); $Signup->update($data); $type = Session::get('Signup'); if ($type['type'] === 'PowerPlan') { $plan = PowerPlan::get_by_id('PowerPlan', $type['id']); } elseif ($type['type'] === 'GasPlan') { $plan = GasPlan::get_by_id('GasPlan', $type['id']); } $Signup->Plan = $plan->Name; $Signup->Company = $plan->Company()->Name; $SignupID = $Signup->write(); if ($SignupID) { Session::clear('SignupData'); Session::clear('Signup'); $this->redirect('signup/result?result=success'); } else { $this->redirect('signup/result?result=fail'); } }