request->post('year') ? ORM::factory('Site_Dates',$this->request->post('year')) : ORM::factory('Site_Dates')->where_year($this->request->param('id')); if (! $sdo->loaded()) { Block::factory() ->type('form-horizontal') ->title('Choose year of enrolment') ->title_icon('fa fa-calendar') ->body(View::factory('enrol/selectyear')); return; } $ao = ORM::factory('Account'); $co = ORM::factory('Child'); $this->meta->title = 'Enrol'; if ($this->request->post('account') AND $this->request->post('child') AND $this->request->post('room.id')) { $ao->values($this->request->post('account')); $co->values($this->request->post('child')); $ro = ORM::factory('Rooms',$this->request->post('room.id')); // First we need to make an account try { if ($ao->save() AND $co->save()) { $co->account_id = $ao; $co->status = 'PEND'; $co->save(); $co->add('rooms',$ro); } } catch (ORM_Validation_Exception $e) { SystemMessage::factory() ->title('Record NOT created') ->type('danger') ->body(join('
',array_values($e->errors('register')))); } } Block::factory() ->type('form-horizontal') ->title('Register enrolment for: '.$sdo->year()) ->title_icon('fa fa-university') ->body(View::factory('enrol/child')->set('ao',$ao)->set('co',$co)->set('room_id',$this->request->post('room.id'))->set('year',$sdo->id)); } } ?>