75 lines
1.9 KiB
PHP
75 lines
1.9 KiB
PHP
<?php defined('SYSPATH') or die('No direct access allowed.');
|
|
|
|
/**
|
|
* Membership Database Add Children
|
|
*
|
|
* @package Membership Database
|
|
* @category Controllers/User
|
|
* @author Deon George
|
|
* @copyright (c) 2014 Deon George
|
|
* @license http://dev.leenooks.net/license.html
|
|
*/
|
|
class Controller_User_Child extends Controller_Child {
|
|
protected $auth_required = TRUE;
|
|
protected $secure_actions = array(
|
|
'add'=>TRUE,
|
|
'edit'=>TRUE,
|
|
);
|
|
|
|
public function action_add() {
|
|
Block::factory()
|
|
->type('form-horizontal')
|
|
->title('Add/Edit Record')
|
|
->title_icon('fa-wrench')
|
|
->body($this->add_edit());
|
|
}
|
|
|
|
public function action_edit() {
|
|
Block::factory()
|
|
->type('form-horizontal')
|
|
->title('Add/Edit Record')
|
|
->title_icon('fa-wrench')
|
|
->body($this->add_edit($this->request->param('id')));
|
|
}
|
|
|
|
private function add_edit($id=NULL) {
|
|
$co = ORM::factory('Child',$id);
|
|
|
|
if ($this->request->post()) {
|
|
$co->values($this->request->post());
|
|
$co->account_id = (string)$this->ao;
|
|
|
|
if ($co->changed() AND (! $this->save($co)))
|
|
$co->reload()->values($this->request->post());
|
|
}
|
|
|
|
// If there are no room records, we'll create a waitlist one that can be completed.
|
|
if (! $co->subitems())
|
|
$co->subitem_add($co->room->values(array('child_id'=>$co->id,'code'=>'W')));
|
|
|
|
Style::factory()
|
|
->type('file')
|
|
->data('media/theme/bootstrap/css/bootstrap.datepicker.css');
|
|
|
|
Script::factory()
|
|
->type('file')
|
|
->data('media/theme/bootstrap/js/bootstrap.datepicker.js');
|
|
|
|
// Set our maximum date, that children can stay
|
|
Script::factory()
|
|
->type('stdin')
|
|
->data('
|
|
$(document).ready(function() {
|
|
$("#date_stop").datepicker({
|
|
endDate: new Date('.($co->date_enrol_max()*1000).')
|
|
});
|
|
})
|
|
');
|
|
|
|
return View::factory('child/user/add_edit')
|
|
->set('o',$co)
|
|
->set('so',Company::instance()->so());
|
|
}
|
|
}
|
|
?>
|