Register Child and Waitlist working
This commit is contained in:
74
application/classes/Controller/Director/Account.php
Normal file
74
application/classes/Controller/Director/Account.php
Normal file
@@ -0,0 +1,74 @@
|
||||
<?php defined('SYSPATH') or die('No direct access allowed.');
|
||||
|
||||
/**
|
||||
* This class provides the Directors ability to setup families
|
||||
*
|
||||
* @package Membership Database
|
||||
* @category Controllers/Director
|
||||
* @author Deon George
|
||||
* @copyright (c) 2014 Deon George
|
||||
* @license http://dev.leenooks.net/license.html
|
||||
*/
|
||||
class Controller_Director_Account extends Controller_Account {
|
||||
protected $secure_actions = array(
|
||||
'add'=>TRUE,
|
||||
'ajaxlist'=>FALSE,
|
||||
'list'=>TRUE,
|
||||
);
|
||||
|
||||
/**
|
||||
* Edit a Module Configuration
|
||||
*/
|
||||
public function action_add() {
|
||||
Block::factory()
|
||||
->type('form-horizontal')
|
||||
->title('Add/Edit Record')
|
||||
->title_icon('fa-wrench')
|
||||
->body($this->add_edit());
|
||||
}
|
||||
|
||||
public function action_ajaxlist() {
|
||||
$result = array();
|
||||
|
||||
if ($this->request->query('query'))
|
||||
$result = Arr::merge($result,ORM::factory('Account')->list_autocomplete($this->request->query('query'),'id','id',array('%s: %s'=>array('id','name(TRUE)'))));
|
||||
|
||||
$this->response->headers('Content-Type','application/json');
|
||||
$this->response->body(json_encode(array_values($result)));
|
||||
}
|
||||
/**
|
||||
* Edit a Module Configuration
|
||||
*/
|
||||
public function action_list() {
|
||||
$output = __METHOD__;
|
||||
|
||||
Block::factory()
|
||||
->title('List Families')
|
||||
->body($output);
|
||||
}
|
||||
|
||||
private function add_edit($id=NULL) {
|
||||
$co = ORM::factory('Child',$id);
|
||||
|
||||
if ($this->request->post() AND $co->values($this->request->post())->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');
|
||||
|
||||
return View::factory('child/user/add_edit')
|
||||
->set('o',$co)
|
||||
->set('so',Company::instance()->so());
|
||||
|
||||
}
|
||||
}
|
||||
?>
|
Reference in New Issue
Block a user