Register Child and Waitlist working
This commit is contained in:
parent
df7776931d
commit
48debfbd6c
3
application/classes/Controller/Child.php
Normal file
3
application/classes/Controller/Child.php
Normal file
@ -0,0 +1,3 @@
|
||||
<?php defined('SYSPATH') or die('No direct script access.');
|
||||
|
||||
class Controller_Child extends Controller_TemplateDefault { }
|
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());
|
||||
|
||||
}
|
||||
}
|
||||
?>
|
@ -20,92 +20,34 @@ class Controller_Director_Welcome extends Controller_Welcome {
|
||||
public function action_index() {
|
||||
$output = '';
|
||||
|
||||
$date = Site::DateStartOfWeek(time());
|
||||
$t = strtotime($this->request->query('date'));
|
||||
if (! $t)
|
||||
$t = time();
|
||||
|
||||
$so = Company::instance()->so();
|
||||
$date = Site::DateStartOfWeek($t);
|
||||
$days = 7;
|
||||
|
||||
$open_dates = $so->open_dates($date,$days);
|
||||
$output .= '<table class="table table-striped table-condensed table-hover">';
|
||||
$output .= '<form id="select_date">';
|
||||
$output .= View::factory('room/availability')
|
||||
->set('date',$date)
|
||||
->set('days',$days)
|
||||
->set('open_dates',$so->open_dates($date,$days))
|
||||
->set('total_places',$so->total_places($date,$days))
|
||||
->set('r',$so->rooms->find_all())
|
||||
->set('uri',$this->request->uri());
|
||||
$output .= '</form>';
|
||||
|
||||
$output .= '<tr>';
|
||||
$output .= '<th colspan="2"> </th>';
|
||||
foreach (array_keys($open_dates) as $day)
|
||||
$output .= sprintf('<th class="text-right">%s (%s)</th>',Site::date($day),date('D',$day));
|
||||
$output .= '</tr>';
|
||||
Style::factory()
|
||||
->type('file')
|
||||
->data('media/theme/bootstrap/css/bootstrap.datepicker.css');
|
||||
|
||||
$output .= '<tr>';
|
||||
$output .= '<th colspan="2">Open</th>';
|
||||
foreach (array_keys($open_dates) as $day)
|
||||
$output .= sprintf('<th class="text-right">%s</th>',StaticList_YesNo::factory()->get(isset($open_dates[$day]) ? $open_dates[$day] : FALSE,TRUE));
|
||||
$output .= '</tr>';
|
||||
|
||||
$output .= '<tr>';
|
||||
$output .= '<th colspan="2">Total</th>';
|
||||
foreach (array_keys($open_dates) as $day)
|
||||
$output .= sprintf('<th class="text-right">%s</th>','-');
|
||||
$output .= '</tr>';
|
||||
|
||||
foreach ($so->rooms->find_all() as $ro) {
|
||||
$output .= sprintf('<tr><th colspan="2">%s</th><th colspan="%s"> </th></tr>',$ro->display('name'),$days);
|
||||
|
||||
// Capacity
|
||||
$output .= '<tr>';
|
||||
$output .= '<td> </td>';
|
||||
$output .= '<td>Capacity</td>';
|
||||
$output .= sprintf('<td class="text-right">%s</td>',join('</td><td class="text-right">',array_values($ro->availability_dates($date,$days))));
|
||||
$output .= '</tr>';
|
||||
|
||||
// Permanent
|
||||
$output .= '<tr>';
|
||||
$output .= '<td> </td>';
|
||||
$output .= '<td>Permanent</td>';
|
||||
foreach (array_values($ro->child_list_date($date,$days)) as $x)
|
||||
$output .= sprintf('<td class="text-right">%s</td>',count($x));
|
||||
$output .= '</tr>';
|
||||
|
||||
// Permanent
|
||||
$output .= '<tr>';
|
||||
$output .= '<td> </td>';
|
||||
$output .= '<td>Absent</td>';
|
||||
foreach (array_values($ro->child_list_date($date,$days,'a')) as $x)
|
||||
$output .= sprintf('<td class="text-right">%s</td>',count($x));
|
||||
$output .= '</tr>';
|
||||
|
||||
// Casual
|
||||
$output .= '<tr>';
|
||||
$output .= '<td> </td>';
|
||||
$output .= '<td>Casual</td>';
|
||||
foreach (array_values($ro->child_list_date($date,$days,'C')) as $x)
|
||||
$output .= sprintf('<td class="text-right">%s</td>',count($x));
|
||||
$output .= '</tr>';
|
||||
|
||||
// Spacer
|
||||
$output .= sprintf('<tr><td colspan="%s"> </td></tr>',$days+2);
|
||||
|
||||
// Waitlist
|
||||
$output .= '<tr>';
|
||||
$output .= '<td> </td>';
|
||||
$output .= '<td>Waitlist</td>';
|
||||
foreach (array_values($ro->child_list_date($date,$days,'W')) as $x)
|
||||
$output .= sprintf('<td class="text-right">%s</td>',count($x));
|
||||
$output .= '</tr>';
|
||||
|
||||
// Availablity
|
||||
$output .= '<tr>';
|
||||
$output .= '<td> </td>';
|
||||
$output .= '<td>Availability</td>';
|
||||
foreach (array_values($ro->room_availablity($date,$days)) as $x)
|
||||
$output .= sprintf('<td class="text-right">%s</td>',$x);
|
||||
$output .= '</tr>';
|
||||
|
||||
// Spacer
|
||||
$output .= sprintf('<tr><td colspan="%s"> </td></tr>',$days+2);
|
||||
}
|
||||
|
||||
$output .= '</table>';
|
||||
Script::factory()
|
||||
->type('file')
|
||||
->data('media/theme/bootstrap/js/bootstrap.datepicker.js');
|
||||
|
||||
Block::factory()
|
||||
->title(sprintf('Site Availability for %s',Site::date($date)))
|
||||
->title(sprintf('Availability for %s',Site::date($date)))
|
||||
->title_icon('icon-cog')
|
||||
->body($output);
|
||||
}
|
||||
|
@ -1,3 +0,0 @@
|
||||
<?php defined('SYSPATH') or die('No direct script access.');
|
||||
|
||||
class Controller_Family extends Controller_TemplateDefault { }
|
74
application/classes/Controller/User/Child.php
Normal file
74
application/classes/Controller/User/Child.php
Normal file
@ -0,0 +1,74 @@
|
||||
<?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());
|
||||
}
|
||||
}
|
||||
?>
|
49
application/classes/Controller/User/Welcome.php
Normal file
49
application/classes/Controller/User/Welcome.php
Normal file
@ -0,0 +1,49 @@
|
||||
<?php defined('SYSPATH') or die('No direct access allowed.');
|
||||
|
||||
/**
|
||||
* Membership Database Main home page
|
||||
*
|
||||
* @package Membership Database
|
||||
* @category Controllers/User
|
||||
* @author Deon George
|
||||
* @copyright (c) 2014 Deon George
|
||||
* @license http://dev.leenooks.net/license.html
|
||||
*/
|
||||
class Controller_User_Welcome extends Controller_Welcome {
|
||||
protected $auth_required = TRUE;
|
||||
protected $secure_actions = array(
|
||||
'index'=>TRUE,
|
||||
);
|
||||
|
||||
public function action_index() {
|
||||
$output = '';
|
||||
|
||||
if (! $this->ao->list_children()->count())
|
||||
$output .= 'You have no currently registered children, would you like to '.HTML::anchor(URL::link('user','child/add'),'Register').' a child?';
|
||||
else
|
||||
$output = Table::factory()
|
||||
->data($this->ao->list_children())
|
||||
->columns(array(
|
||||
'id'=>'ID',
|
||||
'first_name'=>'First Name',
|
||||
'family_name'=>'Family Name',
|
||||
'dob'=>'DOB',
|
||||
))
|
||||
->prepend(array(
|
||||
'id'=>array('url'=>URL::link('user','child/edit/')),
|
||||
));
|
||||
|
||||
Block::factory()
|
||||
->title(sprintf('Membership details for : %s',$this->ao->name()))
|
||||
->title_icon('icon-info-sign')
|
||||
->span(9)
|
||||
->body($output);
|
||||
|
||||
Block::factory()
|
||||
->title('Quick Shortcuts')
|
||||
->title_icon('icon-bookmark')
|
||||
->span(3)
|
||||
->body(View::factory('welcome/user/shortcuts'));
|
||||
}
|
||||
}
|
||||
?>
|
@ -3,7 +3,7 @@
|
||||
/**
|
||||
* Main home page for un-authenticated users
|
||||
*
|
||||
* @package lnApp
|
||||
* @package Membership Database
|
||||
* @category Controllers
|
||||
* @author Deon George
|
||||
* @copyright (c) 2009-2013 Deon George
|
||||
|
24
application/classes/Model/Account.php
Normal file
24
application/classes/Model/Account.php
Normal file
@ -0,0 +1,24 @@
|
||||
<?php defined('SYSPATH') or die('No direct access allowed.');
|
||||
|
||||
/**
|
||||
* This Model manages both the accounts that users use to login to the system, as well as the account where services are owned.
|
||||
*
|
||||
* @package Membership Database
|
||||
* @category Models
|
||||
* @author Deon George
|
||||
* @copyright (c) 2014 Deon George
|
||||
* @license http://dev.leenooks.net/license.html
|
||||
*/
|
||||
class Model_Account extends lnAuth_Model_Account {
|
||||
// Relationships
|
||||
protected $_has_many = array(
|
||||
'child'=>array('far_key'=>'id'),
|
||||
'email_log'=>array('far_key'=>'id'),
|
||||
'group'=>array('through'=>'account_group'),
|
||||
);
|
||||
|
||||
public function list_children() {
|
||||
return $this->child->find_all();
|
||||
}
|
||||
}
|
||||
?>
|
@ -1,7 +1,7 @@
|
||||
<?php defined('SYSPATH') or die('No direct access allowed.');
|
||||
|
||||
/**
|
||||
* This class supports Children belonging to a family
|
||||
* This class supports Children
|
||||
*
|
||||
* @package Membership Database
|
||||
* @category Models
|
||||
@ -10,5 +10,90 @@
|
||||
* @license http://dev.leenooks.net/license.html
|
||||
*/
|
||||
class Model_Child extends ORM {
|
||||
protected $_start = '42D'; // Minimum age to be accepted (42D = 6 Weeks)
|
||||
protected $_max = '4Y'; // Maximum age
|
||||
protected $_max_date = '04-30'; // Date Maximum age must be met, eg: 5Y on April 30
|
||||
protected $_max_return = '12-31'; // Date to leave the center when max date reached, eg: Jan 1
|
||||
|
||||
protected $_has_many = array(
|
||||
'room'=>array('model'=>'Room_Children','foreign_key'=>'child_id','far_key'=>'id'),
|
||||
);
|
||||
|
||||
public function filters() {
|
||||
return Arr::merge(parent::filters(),array(
|
||||
'dob'=>array(array('strtotime', array(':value'))),
|
||||
));
|
||||
}
|
||||
|
||||
protected $_display_filters = array(
|
||||
'dob'=>array(
|
||||
array('Site::Date',array(':value')),
|
||||
),
|
||||
);
|
||||
|
||||
protected $_sub_items_load = array(
|
||||
'room'=>'date_start,date_stop',
|
||||
);
|
||||
|
||||
private function _dob() {
|
||||
$x = new DateTime();
|
||||
|
||||
return $x->setTimestamp($this->dob);
|
||||
}
|
||||
|
||||
public function age($asat=NULL,$format='%Yy%Mm') {
|
||||
if (is_null($asat))
|
||||
$asat = time();
|
||||
|
||||
$dob = $this->_dob();
|
||||
|
||||
$today = new DateTime();
|
||||
$today->setTimestamp($asat);
|
||||
|
||||
return $format == '%w' ? sprintf('%02dw',$dob->diff($today)->days/7) : $dob->diff($today)->format($format);
|
||||
}
|
||||
|
||||
public function date_enrol_min() {
|
||||
$dob = $this->_dob();
|
||||
$dob->add(new DateInterval('P'.$this->_start));
|
||||
|
||||
return $format ? $result->format(Kohana::$config->load('config')->date_format) : $result->format('U');
|
||||
}
|
||||
|
||||
public function date_enrol_max($format=FALSE) {
|
||||
$dob = $this->_dob();
|
||||
$dob->add(new DateInterval('P'.$this->_max));
|
||||
|
||||
$last = new DateTime(sprintf('%s-%s',$dob->format('Y'),$this->_max_date));
|
||||
$x = $dob->diff($last);
|
||||
|
||||
$result = new DateTime(sprintf('%s-%s',$dob->format('Y')+($x->invert ? 1 : 0),$this->_max_return));
|
||||
|
||||
return $format ? $result->format(Company::instance()->date_format()) : $result->format('U');
|
||||
}
|
||||
|
||||
public function save(Validation $validation=NULL) {
|
||||
$changed = $this->changed();
|
||||
|
||||
parent::save($validation);
|
||||
|
||||
// Insert into waitlist
|
||||
$rco = ORM::factory('Room_Children',array('child_id'=>$this,'code'=>$_POST['room']['code']));
|
||||
|
||||
$rco->values($_POST['room']);
|
||||
$rco->child_id = (string)$this;
|
||||
|
||||
foreach ($_POST['room']['R'] as $k => $v) {
|
||||
if (! $v OR isset($_POST['room']['d_'.$k]))
|
||||
continue;
|
||||
|
||||
$rco->{'d_'.$k} = NULL;
|
||||
}
|
||||
|
||||
if ($rco->changed() AND (! $rco->save()))
|
||||
$rco->reload()->values($_POST['room']);
|
||||
|
||||
return $this->reload();
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
@ -14,6 +14,30 @@ class Model_Room_Children extends ORM {
|
||||
'child'=>array(),
|
||||
);
|
||||
|
||||
public function filters() {
|
||||
return Arr::merge(parent::filters(),array(
|
||||
'date_start'=>array(array('strtotime', array(':value'))),
|
||||
'date_stop'=>array(array('strtotime', array(':value'))),
|
||||
));
|
||||
}
|
||||
|
||||
public function rules() {
|
||||
$x = parent::rules();
|
||||
|
||||
unset($x['id']);
|
||||
|
||||
return $x;
|
||||
}
|
||||
|
||||
protected $_display_filters = array(
|
||||
'date_start'=>array(
|
||||
array('Site::Date',array(':value')),
|
||||
),
|
||||
'date_stop'=>array(
|
||||
array('Site::Date',array(':value')),
|
||||
),
|
||||
);
|
||||
|
||||
// @todo: Code A (availble) start/end dates cannot overlap with existing records - put in validation that it cannot be saved.
|
||||
public function day($day) {
|
||||
return $this->{'d_'.$day};
|
||||
|
@ -13,7 +13,7 @@ class Model_Room_Dates extends ORM {
|
||||
// @todo: Code A (availble) start/end dates cannot overlap with existing records - put in validation that it cannot be saved.
|
||||
|
||||
public function avail($day) {
|
||||
return $this->{'d_'.$day};
|
||||
return $this->{'d_'.$day} ? $this->{'d_'.$day} : 0;
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
@ -28,24 +28,19 @@ class Model_Rooms extends ORM {
|
||||
$x = $date;
|
||||
|
||||
while ($x<$date_end) {
|
||||
// If we havent made the start date yet, we need to advance
|
||||
if (! $open_dates[$x]
|
||||
OR ($o->date_start > $x AND (is_null($o->date_stop) OR $o->date_stop > $date_end))
|
||||
OR ((is_null($o->date_start) OR $o->date_start > $x) AND $o->date_stop > $date_end)
|
||||
OR (! is_null($o->date_start) AND ! is_null($o->date_stop))) {
|
||||
if (($o->date_start <= $x AND (is_null($o->date_stop) OR $o->date_stop >= $x))
|
||||
OR ($o->date_stop >= $x AND (is_null($o->date_start) OR $o->date_start <= $x))
|
||||
OR (is_null($o->date_start) AND is_null($o->date_start))) {
|
||||
|
||||
if (! isset($result[$x]) OR ! $result[$x])
|
||||
$result[$x] = 0;
|
||||
$result[$x] = $o->avail(date('w',$x));
|
||||
|
||||
$x += 86400;
|
||||
continue;
|
||||
}
|
||||
|
||||
// Check that this record covers our current date
|
||||
if ($o->date_stop < $x AND ! is_null($o->date_stop))
|
||||
break;
|
||||
if (! isset($result[$x]) OR ! $result[$x])
|
||||
$result[$x] = 0;
|
||||
|
||||
$result[$x] = $o->avail(date('w',$x));
|
||||
$x += 86400;
|
||||
}
|
||||
}
|
||||
@ -66,6 +61,10 @@ class Model_Rooms extends ORM {
|
||||
$result = array();
|
||||
$x = $date;
|
||||
|
||||
// We need to set this, so that unassigned room records are found.
|
||||
if (! $this->loaded())
|
||||
$this->site_id = Company::instance()->site();
|
||||
|
||||
$date_end = $date+$days*86400;
|
||||
$open_dates = $this->site->open_dates($date,$days);
|
||||
foreach ($this->children->where('code','=',$code)->where_startstop($date,$date_end)->find_all() as $o) {
|
||||
@ -75,8 +74,7 @@ class Model_Rooms extends ORM {
|
||||
// If we havent made the start date yet, we need to advance
|
||||
if (! $open_dates[$x]
|
||||
OR ($o->date_start > $x AND (is_null($o->date_stop) OR $o->date_stop > $date_end))
|
||||
OR ((is_null($o->date_start) OR $o->date_start > $x) AND $o->date_stop > $date_end)
|
||||
OR (! is_null($o->date_start) AND ! is_null($o->date_stop))) {
|
||||
OR ((is_null($o->date_start) OR $o->date_start > $x) AND $o->date_stop > $date_end)) {
|
||||
|
||||
if (! isset($result[$x]) OR ! $result[$x])
|
||||
$result[$x] = array();
|
||||
|
@ -97,11 +97,23 @@ class Model_Setup extends ORM {
|
||||
return $result;
|
||||
}
|
||||
|
||||
public function open_dates($date,$days=0) {
|
||||
public function open_days() {
|
||||
$result = array();
|
||||
|
||||
//@todo this needs to change to node have any dates, since the current date may be closed, or a public holiday
|
||||
foreach ($this->open_dates(Site::DateStartOfWeek(time()),7) as $date => $open)
|
||||
$result[date('w',$date)] = $open;
|
||||
|
||||
ksort($result);
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
public function open_dates($date,$days=0,$code='O') {
|
||||
$result = array();
|
||||
|
||||
$date_end = $date+$days*86400;
|
||||
foreach ($this->dates->where('code','=','O')->where_startstop($date,$date_end)->find_all() as $o)
|
||||
foreach ($this->dates->where('code','=',$code)->where_startstop($date,$date_end)->find_all() as $o)
|
||||
while ($date<$date_end) {
|
||||
// If we havent made the start date yet, we need to advance
|
||||
if ($o->date_start > $date AND $o->date_stop > $date_end) {
|
||||
@ -146,5 +158,20 @@ class Model_Setup extends ORM {
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function total_places($date_start,$days=0) {
|
||||
$result = array();
|
||||
|
||||
foreach ($this->rooms->find_all() as $ro) {
|
||||
foreach ($ro->availability_dates($date_start,$days) as $date => $total) {
|
||||
if (! isset($result[$date]))
|
||||
$result[$date] = 0;
|
||||
|
||||
$result[$date] += $total;
|
||||
}
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
23
application/classes/StaticList/Room/Children.php
Normal file
23
application/classes/StaticList/Room/Children.php
Normal file
@ -0,0 +1,23 @@
|
||||
<?php defined('SYSPATH') or die('No direct access allowed.');
|
||||
|
||||
/**
|
||||
* This is class renders Room Children Status Codes.
|
||||
*
|
||||
* @package Membership Database
|
||||
* @category Helpers
|
||||
* @author Deon George
|
||||
* @copyright (c) 2014 Deon George
|
||||
* @license http://dev.leenooks.net/license.html
|
||||
*/
|
||||
class StaticList_Room_Children extends StaticList {
|
||||
protected function _table() {
|
||||
return array(
|
||||
'W'=>_('Waitlist'),
|
||||
);
|
||||
}
|
||||
|
||||
public static function get($value) {
|
||||
return self::factory()->_get($value);
|
||||
}
|
||||
}
|
||||
?>
|
80
application/views/child/user/add_edit.php
Normal file
80
application/views/child/user/add_edit.php
Normal file
@ -0,0 +1,80 @@
|
||||
<fieldset>
|
||||
<legend>Register Child</legend>
|
||||
|
||||
<div class="form-group">
|
||||
<label class="col-md-2 control-label" for="Title">Name</label>
|
||||
<div class="row">
|
||||
<div class="col-md-2">
|
||||
<?php echo Form::input('first_name',$o->display('first_name'),array('class'=>'form-control','placeholder'=>'First Name','required','nocg'=>TRUE)); ?>
|
||||
</div>
|
||||
<div class="col-md-3">
|
||||
<?php echo Form::input('family_name',$o->display('family_name'),array('class'=>'form-control','placeholder'=>'Family Name','required','nocg'=>TRUE)); ?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label class="col-md-2 control-label" for="Title">DOB</label>
|
||||
<div class="col-md-2">
|
||||
<div class="input-group date" id="dob" data-date-format="dd-mm-yyyy" data-provide="datepicker" data-date-start-view="year" data-date-calendar-weeks="true" data-date-autoclose="true" data-date-today-highlight="true" data-date-end-date="0d">
|
||||
<?php echo Form::input('dob',$o->display('dob'),array('class'=>'form-control','placeholder'=>'DOB','required','nocg'=>TRUE,'readonly')); ?>
|
||||
<span class="input-group-addon"><i class="fa fa-calendar"></i></span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-3">
|
||||
Age: <strong><?php echo $o->age(); ?></strong><br/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label class="col-md-2 control-label" for="Title">Requested Days</label>
|
||||
<div class="col-md-10">
|
||||
<table class="table-bordered">
|
||||
<thead>
|
||||
<tr>
|
||||
<th> </th>
|
||||
<?php foreach ($so->open_days() as $d => $open) : ?>
|
||||
<th class="text-center" style="width: 3em;"><?php echo substr(StaticList_Day::get($d),0,2); ?></th>
|
||||
<?php endforeach ?>
|
||||
<th class="text-center">Start Date</th>
|
||||
<th class="text-center">End Date</th>
|
||||
</tr>
|
||||
</thead>
|
||||
|
||||
<tbody>
|
||||
<?php foreach ($o->subitems() as $rco) : ?>
|
||||
<tr>
|
||||
<?php echo Form::hidden('room[child_id]',$rco->child_id); ?>
|
||||
<?php echo Form::hidden('room[code]',$rco->code); ?>
|
||||
<td class="col-md-3"><?php echo StaticList_Room_Children::get($rco->code); ?></td>
|
||||
<?php foreach ($so->open_days() as $d => $open) : ?>
|
||||
<td class="text-center <?php echo $open ? 'bg-success' : 'bg-danger'; ?>">
|
||||
<?php echo Form::checkbox('room[d_'.$d.']',TRUE,$rco->day($d) ? TRUE : FALSE,array('nocg'=>TRUE,$open ? '': 'disabled')); ?>
|
||||
<?php echo Form::hidden(sprintf('room[R][%s]',$d),$rco->day($d)); ?>
|
||||
</td>
|
||||
<?php endforeach ?>
|
||||
<td>
|
||||
<div class="input-group date" id="date_start" data-date-format="dd-mm-yyyy" data-provide="datepicker" data-date-start-view="year" data-date-autoclose="true" data-date-today-highlight="true" data-date-start-date="0d">
|
||||
<?php echo Form::input('room[date_start]',$rco->date_start ? $rco->display('date_start') : Site::Date(time()),array('class'=>'form-control','placeholder'=>'Start','required','nocg'=>TRUE,'readonly')); ?>
|
||||
<span class="input-group-addon"><i class="fa fa-calendar"></i></span>
|
||||
</td>
|
||||
<td>
|
||||
<div class="input-group date" id="date_stop" data-date-format="dd-mm-yyyy" data-provide="datepicker" data-date-start-view="year" data-date-autoclose="true" data-date-today-highlight="true" data-date-start-date="0d">
|
||||
<?php echo Form::input('room[date_stop]',$rco->date_stop ? $rco->display('date_stop') : $o->date_enrol_max(TRUE),array('class'=>'form-control','placeholder'=>'End','required','nocg'=>TRUE,'readonly')); ?>
|
||||
<span class="input-group-addon"><i class="fa fa-calendar"></i></span>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
<?php endforeach ?>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</fieldset>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-md-offset-1">
|
||||
<button type="submit" class="btn btn-primary">Save changes</button>
|
||||
<button type="button" class="btn btn-default">Cancel</button>
|
||||
</div>
|
||||
</div>
|
@ -1,16 +0,0 @@
|
||||
<div class="col-md-11">
|
||||
<fieldset>
|
||||
<legend>Add Method</legend>
|
||||
|
||||
<?php echo Form::input('name',$name,array('label'=>'Method','disabled','class'=>'col-sm-5')); ?>
|
||||
<?php echo Form::input('notes','',array('label'=>'Description','placeholder'=>'Method Description','class'=>'col-sm-7')); ?>
|
||||
<?php echo Form::input('menu_display','',array('label'=>'Menu Title','placeholder'=>'Menu Title','class'=>'col-sm-7')); ?>
|
||||
</fieldset>
|
||||
|
||||
<div class="row">
|
||||
<div class="offset2">
|
||||
<button type="submit" class="btn btn-primary">Save changes</button>
|
||||
<button type="button" class="btn">Cancel</button>
|
||||
</div>
|
||||
</div>
|
||||
</div> <!-- /span -->
|
@ -1,42 +0,0 @@
|
||||
<div class="col-md-5">
|
||||
<fieldset>
|
||||
<legend>Method Details</legend>
|
||||
|
||||
<?php echo Form::input('notes',$o->notes,array('label'=>'Description','placeholder'=>'Method Description','xclass'=>'col-md-5')); ?>
|
||||
<?php echo Form::input('menu_display',$o->menu_display,array('label'=>'Menu Title','placeholder'=>'Menu Title','xclass'=>'col-md-5')); ?>
|
||||
|
||||
</fieldset>
|
||||
</div> <!-- /col-md-->
|
||||
|
||||
<div class="col-md-6">
|
||||
<fieldset>
|
||||
<legend>Method Security</legend>
|
||||
|
||||
<table class="table table-striped table-condensed table-hover" id="list-table">
|
||||
<thead><tr>
|
||||
<th>Method</th>
|
||||
<th>Notes</th>
|
||||
<th>Group Active</th>
|
||||
<th>Method Enable</th>
|
||||
</tr></thead>
|
||||
|
||||
<tbody>
|
||||
<?php foreach (ORM::factory('Group')->find_all() as $go) : ?>
|
||||
<tr>
|
||||
<td><?php echo HTML::anchor(URL::link('admin','group/edit/'.$go->id,TRUE),$go->display('name')); ?></td>
|
||||
<td><?php echo $go->display('notes'); ?></td>
|
||||
<td><?php echo $go->display('active'); ?></td>
|
||||
<td><?php echo Form::checkbox('groups[]',$go->id,$o->has('group',$go)); ?></td>
|
||||
</tr>
|
||||
<?php endforeach ?>
|
||||
</tbody>
|
||||
</table>
|
||||
</fieldset>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-md-offset-2">
|
||||
<button type="submit" class="btn btn-primary">Save changes</button>
|
||||
<button type="button" class="btn">Cancel</button>
|
||||
</div>
|
||||
</div>
|
||||
</div> <!-- /col-md -->
|
140
application/views/room/availability.php
Normal file
140
application/views/room/availability.php
Normal file
@ -0,0 +1,140 @@
|
||||
<fieldset>
|
||||
<legend>Room Summary next <?php echo $days; ?> Days</legend>
|
||||
|
||||
<div class="form-group">
|
||||
<label class="col-md-2 control-label" for="Title">Select Date</label>
|
||||
<div class="col-md-2">
|
||||
<div class="input-group date" id="date" data-date="<?php echo $x=Site::date($date); ?>" data-date-format="dd-mm-yyyy" data-date-autoclose="true" data-provide="datepicker">
|
||||
<?php echo Form::input('date',$x,array('id'=>'caldate','class'=>'form-control','required','nocg'=>TRUE,'readonly','onchange'=>'submit()')); ?>
|
||||
<span class="input-group-addon"><i class="fa fa-calendar"></i></span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<br/>
|
||||
|
||||
<table class="table table-striped table-condensed table-hover">
|
||||
<thead>
|
||||
<tr>
|
||||
<th colspan="2"> </th>
|
||||
<th><?php echo HTML::anchor(sprintf('%s?date=%s',$uri,date('d-m-Y',$date-86400*7)),'<<'); ?></th>
|
||||
|
||||
<?php foreach (array_keys($open_dates) as $day) : ?>
|
||||
<th class="text-right"><?php printf('%s (%s)',Site::date($day),date('D',$day)); ?></th>
|
||||
<?php endforeach ?>
|
||||
|
||||
<th><?php echo HTML::anchor(sprintf('%s?date=%s',$uri,date('d-m-Y',$date+86400*7)),'>>'); ?></th>
|
||||
</tr>
|
||||
</thead>
|
||||
|
||||
<tbody>
|
||||
<!-- Site Open -->
|
||||
<tr>
|
||||
<th colspan="2">Open</th>
|
||||
<th> </th>
|
||||
|
||||
<?php foreach (array_keys($open_dates) as $day) : ?>
|
||||
<td class="text-right"><?php echo StaticList_YesNo::factory()->get(isset($open_dates[$day]) ? $open_dates[$day] : FALSE,TRUE); ?></td>
|
||||
<?php endforeach ?>
|
||||
|
||||
<th> </th>
|
||||
</tr>
|
||||
|
||||
<!-- Total Places -->
|
||||
<tr>
|
||||
<th colspan="2">Total</th>
|
||||
<th> </th>
|
||||
|
||||
<?php foreach (array_keys($total_places) as $day) : ?>
|
||||
<td class="text-right"><?php echo $total_places[$day]; ?></td>
|
||||
<?php endforeach ?>
|
||||
|
||||
<th> </th>
|
||||
</tr>
|
||||
|
||||
<!-- Unprocessed Waitlists -->
|
||||
<tr>
|
||||
<th colspan="2">New Applications</th>
|
||||
<th> </th>
|
||||
|
||||
<?php foreach (array_values(ORM::factory('Rooms')->child_list_date($date,$days,'W')) as $x) : ?>
|
||||
<td class="text-right"><?php echo count($x); ?></td>
|
||||
<?php endforeach ?>
|
||||
|
||||
<th> </th>
|
||||
</tr>
|
||||
|
||||
<!-- Breakdown for each Room -->
|
||||
<?php foreach ($r as $ro) : ?>
|
||||
<tr><th colspan="<?php echo $days+4; ?>"> </th></tr>
|
||||
|
||||
<tr><th colspan="2"><?php echo $ro->display('name'); ?></th><th colspan="<?php echo $days+2; ?>"> </th></tr>
|
||||
|
||||
<!-- Capacity -->
|
||||
<tr>
|
||||
<td> </td>
|
||||
<td>Capacity</td>
|
||||
<td> </td>
|
||||
<td class="text-right"><?php echo join('</td><td class="text-right">',array_values($ro->availability_dates($date,$days))); ?></td>
|
||||
<th> </th>
|
||||
</tr>
|
||||
|
||||
<!-- Permanents -->
|
||||
<tr>
|
||||
<td> </td>
|
||||
<td>Permanent</td>
|
||||
<td> </td>
|
||||
<?php foreach (array_values($ro->child_list_date($date,$days)) as $x) : ?>
|
||||
<td class="text-right"><?php echo count($x); ?></td>
|
||||
<?php endforeach ?>
|
||||
<th> </th>
|
||||
</tr>
|
||||
|
||||
<!-- Absent -->
|
||||
<tr>
|
||||
<td> </td>
|
||||
<td>Absent</td>
|
||||
<td> </td>
|
||||
<?php foreach (array_values($ro->child_list_date($date,$days,'a')) as $x) : ?>
|
||||
<td class="text-right"><?php echo count($x); ?></td>
|
||||
<?php endforeach ?>
|
||||
<th> </th>
|
||||
</tr>
|
||||
|
||||
<!-- Casual -->
|
||||
<tr>
|
||||
<td> </td>
|
||||
<td>Casual</td>
|
||||
<td> </td>
|
||||
<?php foreach (array_values($ro->child_list_date($date,$days,'C')) as $x) : ?>
|
||||
<td class="text-right"><?php echo count($x); ?></td>
|
||||
<?php endforeach ?>
|
||||
<th> </th>
|
||||
</tr>
|
||||
|
||||
<tr><th colspan="<?php echo $days+4; ?>"> </th></tr>
|
||||
|
||||
<!-- Waitlist -->
|
||||
<tr>
|
||||
<td> </td>
|
||||
<td>Waitlist</td>
|
||||
<td> </td>
|
||||
<?php foreach (array_values($ro->child_list_date($date,$days,'W')) as $x) : ?>
|
||||
<td class="text-right"><?php echo count($x); ?></td>
|
||||
<?php endforeach ?>
|
||||
<th> </th>
|
||||
</tr>
|
||||
|
||||
<!-- Availability -->
|
||||
<tr>
|
||||
<td> </td>
|
||||
<td>Availability</td>
|
||||
<td> </td>
|
||||
<?php foreach (array_values($ro->room_availablity($date,$days)) as $x) : ?>
|
||||
<td class="text-right"><?php echo $x; ?></td>
|
||||
<?php endforeach ?>
|
||||
<th> </th>
|
||||
</tr>
|
||||
<?php endforeach ?>
|
||||
</tbody>
|
||||
</table>
|
||||
</fieldset>
|
3
application/views/welcome/user/shortcuts.php
Normal file
3
application/views/welcome/user/shortcuts.php
Normal file
@ -0,0 +1,3 @@
|
||||
<div class="shortcuts">
|
||||
<a href="<?php echo URL::link('user','child/add',TRUE); ?>" class="shortcut"><i class="shortcut-icon fa fa-list-alt"></i><span class="shortcut-label">Register Child</span></a>
|
||||
</div>
|
@ -1 +1 @@
|
||||
Subproject commit f679bf9c06e17f7fe69dc34c0227d91ef30b56b0
|
||||
Subproject commit db7f5f8d55fb2d467d7e70df5f7bd15b7a21efbc
|
@ -1 +1 @@
|
||||
Subproject commit d034b846a6212e8ce8b8a6815b61f91988867b26
|
||||
Subproject commit 082e280fb657ad2377b070b2979cfd118766aa67
|
Reference in New Issue
Block a user