General Progress

This commit is contained in:
Deon George 2014-12-01 14:01:02 +11:00
parent 6eb0b2f8dd
commit fba5988d8d
18 changed files with 806 additions and 136 deletions

View File

@ -166,7 +166,7 @@ Route::set('default/media', 'media(/<file>)', array('file' => '.+'))
* Set the routes. Each route must have a minimum of a name, a URI and a set of
* defaults for the URI.
*/
Route::set('default', '(<controller>(/<action>(/<id>)))', array('id'=>'[a-zA-Z0-9_.-]+'))
Route::set('default', '(<controller>(/<action>(/<id>)))', array('id'=>'[a-zA-Z0-9_.:-]+'))
->defaults(array(
'controller' => 'welcome',
'action' => 'index',

View File

@ -17,7 +17,7 @@ class Controller_Director_Account extends Controller_Account {
);
/**
* Edit a Module Configuration
* Add an Account
*/
public function action_add() {
Block::factory()
@ -36,8 +36,9 @@ class Controller_Director_Account extends Controller_Account {
$this->response->headers('Content-Type','application/json');
$this->response->body(json_encode(array_values($result)));
}
/**
* Edit a Module Configuration
* List Accounts
*/
public function action_list() {
$output = __METHOD__;
@ -65,10 +66,9 @@ class Controller_Director_Account extends Controller_Account {
->type('file')
->data('media/theme/bootstrap/js/bootstrap.datepicker.js');
return View::factory('child/user/add_edit')
return View::factory('account/user/add_edit')
->set('o',$co)
->set('so',Company::instance()->so());
}
}
?>

View File

@ -0,0 +1,176 @@
<?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_Child extends Controller_Child {
protected $secure_actions = array(
'add'=>TRUE,
'ajaxroomrow'=>FALSE,
'edit'=>TRUE,
'list'=>TRUE,
);
/**
* Add a Child
*/
public function action_add() {
Block::factory()
->type('form-horizontal')
->title('Add/Edit Record')
->title_icon('fa-wrench')
->body($this->add_edit());
}
public function action_ajaxroomrow() {
$this->response->body(
View::factory('child/director/add_roomrow')
->set('o',ORM::factory('Child',$this->request->query('cid')))
->set('so',Company::instance()->so())
->set('rco',ORM::factory('Room_Children'))
->set('row',$this->request->query('id'))
->set('type',$this->request->query('type')));
}
/**
* Edit a Child
*/
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')));
}
public function action_list() {
Block::factory()
->title('Children List')
->title_icon('fa-list-ol')
->body(Table::factory()
->data(ORM::factory('Child')->find_all())
->columns(array(
'id'=>'ID',
'name()'=>'Name',
'age()'=>'Age',
"days(NULL,".Site::DateStartOfWeek(time()).",7,'P',TRUE)"=>'Perm Days',
"days(NULL,".Site::DateStartOfWeek(time()).",7,'w',TRUE)"=>'Wait Days',
'date_orig'=>'Date Registered'
))
->prepend(array(
'id'=>array('url'=>URL::link('director','child/edit/')),
))
);
}
private function add_edit($id=NULL) {
$co = ORM::factory('Child',$id);
if ($this->request->post()) {
foreach ($this->request->post('room') as $index=>$room) {
$new = FALSE;
if (! $room['id'] OR ! $rco=$co->subitem_get('id',$room['id'])) {
$new = TRUE;
$rco = $co->room;
$rco->child_id = $co->id;
}
$rco->values($room);
if ($new)
$co->subitem_add($rco);
}
$co->values($this->request->post());
if (! $this->save($co))
$co->reload()->values($this->request->post());
}
Style::factory()
->type('file')
->data('media/theme/bootstrap/css/bootstrap.datepicker.css');
Script::factory()
->type('file')
->data('media/theme/bootstrap/js/bootstrap.datepicker.js');
Script::factory()
->type('stdin')
->data('
$(document).ready(function() {
var x = '.count($co->subitems()).';
$("button[name=add]").click(function() {
// Send the request and get a new room row
$.ajax({
type: "GET",
data: "cid='.$co->id.'&type="+$(this).val()+"&id="+x++,
dataType: "html",
cache: false,
url: "'.URL::link('director','child/ajaxroomrow',TRUE).'",
timeout: 2000,
error: function(x) {
alert("Failed to submit");
},
success: function(data) {
$("table[name=room] tr:last").after(data);
}
});
});
$("#dob").datepicker().on("hide",function(e) {
var x = $("#dob").datepicker("getDate").getTime()/1000;
// Send the request and update sub category dropdown
$.ajax({
type: "GET",
data: "date="+x,
dataType: "html",
cache: false,
url: "'.URL::link('user','child/ajaxage',TRUE).'",
timeout: 2000,
error: function(x) {
alert("Failed to submit");
},
success: function(data) {
$("div[id=age]").empty().append(data);
}
});
// This code has been disabled as it pollutes datepicker.
/*
$.ajax({
type: "GET",
data: "date="+x,
dataType: "html",
cache: false,
url: "'.URL::link('user','child/ajaxagemax',TRUE).'",
timeout: 2000,
error: function(x) {
alert("Failed to submit");
},
success: function(data) {
// $(".date input:not(#dob)").each(function(){$(this).datepicker("setEndDate",new Date(data*1000))});
// $(".input-daterange input").each(function(){alert(new Date(data*1000));$(this).datepicker("setEndDate",new Date(data*1000))});
$(".input-daterange").each(function(){alert(data);$(this).datepicker("setEndDate",data)});
}
});
*/
});
});
');
return View::factory('child/director/add_edit')
->set('o',$co)
->set('so',Company::instance()->so());
}
}
?>

View File

@ -0,0 +1,96 @@
<?php defined('SYSPATH') or die('No direct access allowed.');
/**
* This class provides the Directors ability to manage details about rooms
*
* @package Membership Database
* @category Controllers/Director
* @author Deon George
* @copyright (c) 2014 Deon George
* @license http://dev.leenooks.net/license.html
*/
class Controller_Director_Room extends Controller_Room {
protected $secure_actions = array(
'availability'=>TRUE,
'list'=>TRUE,
);
/**
* Show Directory Main Page
*/
public function action_availability() {
$output = '';
$t = strtotime($this->request->query('date'));
if (! $t)
$t = time();
$so = Company::instance()->so();
$date = Site::DateStartOfWeek($t);
$days = 7;
$output .= '<form id="select_date">';
$output .= View::factory('room/availability')
->set('date',$date)
->set('days',$days)
->set('available_places',$so->available_places($date,$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>';
Style::factory()
->type('file')
->data('media/theme/bootstrap/css/bootstrap.datepicker.css');
Script::factory()
->type('file')
->data('media/theme/bootstrap/js/bootstrap.datepicker.js');
Block::factory()
->title(sprintf('Availability for %s',Site::date($date)))
->title_icon('icon-cog')
->body($output);
}
/**
* List Children in a Room
*/
public function action_list() {
$days = 1;
if (substr_count($this->request->param('id'),':') == 2)
list($id,$date_start,$code) = explode(':',$this->request->param('id'));
elseif (substr_count($this->request->param('id'),':') == 3)
list($id,$date_start,$code,$days) = explode(':',$this->request->param('id'));
else
HTTP::redirect(URL::link('director','welcome'));
$ro = ORM::factory('Rooms',$id);
$result = array();
foreach ($ro->child_list_date($date_start,$days,$code) as $date => $children)
foreach ($children as $co)
if (! Object::in_array('id',$co->id,$result))
array_push($result,$co);
Block::factory()
->title(sprintf('%s Room List for %s',$ro->display('name'),Site::date($date_start).($days > 1 ? ' to '.Site::date($date_start+$days*86400) : '')))
->title_icon('fa-list-ol')
->body(Table::factory()
->data($result)
->columns(array(
'id'=>'ID',
'name()'=>'Name',
'age()'=>'Age',
"days($ro->id,$date_start,$days,'$code',TRUE)"=>'Days',
'date_orig'=>'Register Date',
))
->prepend(array(
'id'=>array('url'=>URL::link('director','child/edit/')),
))
);
}
}
?>

View File

@ -15,7 +15,7 @@ class Controller_Director_Welcome extends Controller_Welcome {
);
/**
* Edit a Module Configuration
* Show Directory Main Page
*/
public function action_index() {
$output = '';
@ -32,6 +32,7 @@ class Controller_Director_Welcome extends Controller_Welcome {
$output .= View::factory('room/availability')
->set('date',$date)
->set('days',$days)
->set('available_places',$so->available_places($date,$days))
->set('open_dates',$so->open_dates($date,$days))
->set('total_places',$so->total_places($date,$days))
->set('r',$so->rooms->find_all())

View File

@ -0,0 +1,3 @@
<?php defined('SYSPATH') or die('No direct script access.');
class Controller_Room extends Controller_TemplateDefault { }

View File

@ -35,7 +35,7 @@ class Controller_User_Child extends Controller_Child {
public function action_ajaxagemax() {
$x = ORM::factory('Child');
$x->dob = $this->request->query('date');
$this->template->content = $x->date_enrol_max();
$this->template->content = $x->date_enrol_max(TRUE);
}
public function action_edit() {
@ -50,17 +50,27 @@ class Controller_User_Child extends Controller_Child {
$co = ORM::factory('Child',$id);
if ($this->request->post()) {
$co->values($this->request->post());
$co->account_id = (string)$this->ao;
foreach ($this->request->post('room') as $index=>$room) {
$new = FALSE;
if ($co->changed() AND (! $this->save($co)))
if (! $room['id'] OR ! $rco=$co->subitem_get('id',$room['id'])) {
$new = TRUE;
$rco = $co->room;
$rco->child_id = $co->id;
}
$rco->values($room);
if ($new)
$co->subitem_add($rco);
}
$co->values($this->request->post());
if (! $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');
@ -73,48 +83,62 @@ class Controller_User_Child extends Controller_Child {
Script::factory()
->type('stdin')
->data('
$(document).ready(function() {
'.($co->loaded() ? '
$("#date_stop").datepicker({
endDate: new Date('.($co->date_enrol_max()*1000).')
});
' : '').'
$(document).ready(function() {
var x = '.count($co->subitems()).';
$("#dob").datepicker().on("hide",function(e) {
var x = $("#dob").datepicker("getDate").getTime()/1000;
// Send the request and update sub category dropdown
$.ajax({
type: "GET",
data: "date="+x,
dataType: "html",
cache: false,
url: "'.URL::link('user','child/ajaxage',TRUE).'",
timeout: 2000,
error: function(x) {
alert("Failed to submit");
},
success: function(data) {
$("div[id=age]").empty().append(data);
}
});
$.ajax({
type: "GET",
data: "date="+x,
dataType: "html",
cache: false,
url: "'.URL::link('user','child/ajaxagemax',TRUE).'",
timeout: 2000,
error: function(x) {
alert("Failed to submit");
},
success: function(data) {
$("#date_stop").datepicker("setEndDate",new Date(data*1000));
}
});
$("button[name=add]").click(function() {
// Send the request and get a new room row
$.ajax({
type: "GET",
data: "cid='.$co->id.'&type="+$(this).val()+"&id="+x++,
dataType: "html",
cache: false,
url: "'.URL::link('director','child/ajaxroomrow',TRUE).'",
timeout: 2000,
error: function(x) {
alert("Failed to submit");
},
success: function(data) {
$("table[name=room] tr:last").after(data);
}
});
});
$("#dob").datepicker().on("hide",function(e) {
var x = $("#dob").datepicker("getDate").getTime()/1000;
// Send the request and update sub category dropdown
$.ajax({
type: "GET",
data: "date="+x,
dataType: "html",
cache: false,
url: "'.URL::link('user','child/ajaxage',TRUE).'",
timeout: 2000,
error: function(x) {
alert("Failed to submit");
},
success: function(data) {
$("div[id=age]").empty().append(data);
}
});
$.ajax({
type: "GET",
data: "date="+x,
dataType: "html",
cache: false,
url: "'.URL::link('user','child/ajaxagemax',TRUE).'",
timeout: 2000,
error: function(x) {
alert("Failed to submit");
},
success: function(data) {
$(".date input:not(#dob)").each(function(){$(this).datepicker("setEndDate",data)});
}
});
});
});
');
return View::factory('child/user/add_edit')

View File

@ -1,7 +1,7 @@
<?php defined('SYSPATH') or die('No direct access allowed.');
/**
* This class supports Children
* This class supports Children
*
* @package Membership Database
* @category Models
@ -26,13 +26,19 @@ class Model_Child extends ORM {
}
protected $_display_filters = array(
'date_orig'=>array(
array('Site::Date',array(':value')),
),
'date_last'=>array(
array('Site::Date',array(':value')),
),
'dob'=>array(
array('Site::Date',array(':value')),
),
);
protected $_sub_items_load = array(
'room'=>'date_start,date_stop',
'room'=>array('date_start','date_stop'),
);
private function _dob() {
@ -54,7 +60,7 @@ class Model_Child extends ORM {
}
public function date($value) {
return is_numeric($value) ? $value : strtotime($value);
return is_numeric($value) ? $value : strtotime($value);
}
public function date_enrol_min() {
@ -76,27 +82,83 @@ class Model_Child extends ORM {
return $format ? $result->format(Company::instance()->date_format()) : $result->format('U');
}
public function days($room_id,$date_start,$days,$code,$markup=FALSE) {
$result = '';
$date_end = $date_start+$days*86400;
$open_dates = Company::instance()->so()->open_dates($date_start,$days);
$o = $this->room->where('code','=',$code);
$o->where_startstop($date_start,$date_end);
if (! is_null($room_id))
$o->where('room_id','=',$room_id);
// Set all open dayes to 0
foreach ($open_dates as $k=>$v)
if ($v === TRUE)
$open_dates[$k] = 0;
foreach ($o->find_all() as $date => $rco) {
foreach ($open_dates as $day=>$open) {
if ($open === FALSE or $rco->date_start > $day OR $rco->date_stop < $day)
continue;
$open_dates[$day] = $rco->day(date('w',$day));
}
}
foreach ($open_dates as $day=>$open) {
$dayname = substr(date('D',$day),0,1);
if ($open === FALSE)
$result .= $markup ? sprintf('<span class="fa-stack text-danger"><i class="fa fa-square fa-stack-2x"></i><span class="fa-stack-1x" style="color: white;">%s</span></span>',$dayname) : '-';
elseif ($open)
$result .= $markup ? sprintf('<span class="fa-stack text-success"><i class="fa %s fa-stack-2x"></i><strong class="fa-stack-1x" style="color: %s;">%s</strong></span>',($code=='P' ? 'fa-circle' : 'fa-circle-o'),($code=='P' ? 'white' : 'black'),$dayname) : $dayname;
else
$result .= $markup ? sprintf('<span class="fa-stack"><i class="fa fa-square-o fa-stack-2x"></i><strong class="fa-stack-1x">%s</strong></span>',$dayname) : strtolower($dayname);
}
return $result;
}
public function name() {
return sprintf('%s, %s',strtoupper($this->family_name),$this->first_name);
}
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']));
// Process our Sub-Items and Validate them.
Sort::MASort($this->_sub_items,array('code','room_id','date_start','date_stop'));
$last = NULL;
foreach ($this->_sub_items as $rco) {
// If no dates are selected, clear this record.
if (! $rco->have_days()) {
if ($rco->loaded())
$rco->delete();
$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 there is no last item, we'll accept this as is.
if (is_null($last) OR ($last->date_stop <= $rco->date_start)) {
$rco->save($validation);
$last = $rco;
continue;
}
// @todo: If our dates overlap, fix that
// @todo: Check that casual days dont overlap with permanent days
// @todo: Check that absent days are attending days
// @todo: Check that waitlist days dont overlap with permanent days
if ($rco->changed() AND (! $rco->save()))
$rco->reload();
}
if ($rco->changed() AND (! $rco->save()))
$rco->reload()->values($_POST['room']);
return $this->reload();
}
}

View File

@ -12,12 +12,19 @@
class Model_Room_Children extends ORM {
protected $_belongs_to = array(
'child'=>array(),
'room'=>array('model'=>'Rooms'),
);
public function filters() {
return Arr::merge(parent::filters(),array(
'date_start'=>array(array('strtotime', array(':value'))),
'date_stop'=>array(array('strtotime', array(':value'))),
'date_start'=>array(
array('strtotime', array(':value')),
array('ORM::tostring', array(':value')),
),
'date_stop'=>array(
array('strtotime', array(':value')),
array('ORM::tostring', array(':value')),
),
));
}
@ -26,7 +33,20 @@ class Model_Room_Children extends ORM {
unset($x['id']);
return $x;
return Arr::merge($x,array(
'date_start'=>array(
array('not_empty'),
),
'date_stop'=>array(
array('not_empty'),
array(array($this,'validate_datestop'),array(':validation')),
),
'code' => array(
array(array($this,'validate_absentnoshow'),array(':validation',':value')),
array(array($this,'validate_absentnotice'),array(':validation',':value')),
array(array($this,'validate_casualrequest'),array(':validation',':value')),
),
));
}
protected $_display_filters = array(
@ -38,9 +58,58 @@ class Model_Room_Children extends ORM {
),
);
// @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};
}
/**
* Has a day been selected
*/
public function have_days() {
for ($i=0;$i<7;$i++)
if ($this->day($i))
return TRUE;
return FALSE;
}
/**
* No show date cannot be in the future
*/
public function validate_absentnoshow($array,$code) {
return ($code != 'A') OR ($array['date_start'] < time());
}
/**
* Notice date cannot be in the past
*/
public function validate_absentnotice($array,$code) {
return ($code != 'a') OR ($array['date_start'] > time());
}
/**
* Casual Request cannot be in the past
*/
public function validate_casualrequest($array,$code) {
return ($code != 'c') OR ($array['date_start'] > time());
}
/**
* End date cannot be earlier than start date
*/
public function validate_datestop($array) {
return $array['date_start'] <= $array['date_stop'];
}
/**
* Since we use checkboxes for dates, we need to unselect dates not selected
*/
public function values(array $values, array $expected = NULL) {
for ($i=0;$i<7;$i++)
if ($this->day($i) AND empty($values['d_'.$i]))
$this->{'d_'.$i} = NULL;
return parent::values($values,$expected);
}
}
?>

View File

@ -18,6 +18,8 @@ class Model_Rooms extends ORM {
'children'=>array('model'=>'Room_Children','far_key'=>'id','foreign_key'=>'room_id'),
);
protected $_form = array('id'=>'id','value'=>'name');
public function availability_dates($date,$days=0,$code='A') {
$result = array();
$x = $date;

View File

@ -78,6 +78,21 @@ class Model_Setup extends ORM {
return $this;
}
public function available_places($date_start,$days=0) {
$result = array();
foreach ($this->rooms->find_all() as $ro) {
foreach ($ro->room_availablity($date_start,$days) as $date => $total) {
if (! isset($result[$date]))
$result[$date] = 0;
$result[$date] += $total;
}
}
return $result;
}
public function module_config_id($key=NULL) {
$result = array();

View File

@ -11,8 +11,16 @@
*/
class StaticList_Room_Children extends StaticList {
protected function _table() {
// Lowercase items can be seleted by users
// Upper case items can only be selected by Staff
return array(
'W'=>_('Waitlist'),
'A'=>_('Absent NoShow'),
'a'=>_('Absent Notice'),
'C'=>_('Casual Placement'),
'c'=>_('Casual Request'),
'r'=>_('Reduce Days'),
'P'=>_('Permanent'),
'w'=>_('Waitlist'),
);
}

View File

@ -0,0 +1,27 @@
<?php defined('SYSPATH') or die('No direct access allowed.');
/**
* Room Children Code validation messages.
*
* @package Membership Database
* @category Validation
* @author Deon George
* @copyright (c) 2010 Deon George
* @license http://dev.leenooks.net/license.html
*/
return array(
'date_start'=>array(
'not_empty'=>'End Date cannot be empty',
),
'date_stop'=>array(
'not_empty'=>'End Date cannot be empty',
'validate_datestop'=>'End Date cannot be earlier than Start Date',
),
'code'=>array(
'validate_absentnoshow'=>'Absent No Show date cant be in the future',
'validate_absentnotice'=>'Absent Notice date cant be in the past',
'validate_casualrequest'=>'Casual Request date cant be in the past',
),
);
?>

View File

@ -0,0 +1,65 @@
<fieldset>
<?php echo Form::hidden('child_id',$o->id); ?>
<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><div id="age" style="display: inline;"><?php echo $o->dob ? $o->age() : ''; ?></div></strong><br/>
</div>
</div>
<div class="form-group">
<label class="col-md-2 control-label" for="Title">Member Days</label>
<div class="col-md-10">
<table class="table-bordered" name="room">
<thead>
<tr>
<th class="col-md-2">Room</th>
<th class="col-md-2">P/C/W</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="col-md-4 text-center">Start and End Dates</th>
</tr>
</thead>
<tbody>
<?php $x=0;foreach ($o->subitems() as $rco) echo View::factory('child/director/add_roomrow')->set('o',$o)->set('so',$so)->set('rco',$rco)->set('row',$x++)->set('type',$rco->code); ?>
</tbody>
</table>
<br/>
<button type="button" name="add" class="btn btn-sm btn-default" value="a">Absent Notice</button>
<button type="button" name="add" class="btn btn-sm btn-default" value="A" disabled="disabled">Absent No Show</button>
<button type="button" name="add" class="btn btn-sm btn-default" value="c">Casual Request</button>
<button type="button" name="add" class="btn btn-sm btn-default" value="C" disabled="disabled">Casual Days</button>
<button type="button" name="add" class="btn btn-sm btn-default" value="r" disabled="disabled">Reduce Days</button>
<button type="button" name="add" class="btn btn-sm btn-default" value="P">Permanent Placement</button>
<button type="button" name="add" class="btn btn-sm btn-default" value="w">Waitlist</button>
</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>

View File

@ -0,0 +1,65 @@
<tr>
<?php echo Form::hidden(sprintf('room[%s][id]',$row),$rco->id); ?>
<td><?php
switch ($type) {
case 'c':
case 'r':
echo '&nbsp;';
break;
default:
echo ($rco->id) ? $rco->room->display('name') : Form::select(sprintf('room[%s][room_id]',$row),ORM::factory('Rooms')->list_select(TRUE),$rco->room_id,array('class'=>'form-control','nocg'=>TRUE));
}
?></td>
<td><?php
switch ($type) {
case 'a':
case 'c':
case 'P':
case 'r':
case 'w':
case 'W':
echo StaticList_Room_Children::get($type);
echo Form::hidden(sprintf('room[%s][code]',$row),$type);
break;
default:
echo ($rco->id) ? StaticList_Room_Children::get($rco->code) : StaticList_Room_Children::form(sprintf('room[%s][code]',$row),$rco->code ? $rco->code : $type,FALSE,array('class'=>'form-control','nocg'=>TRUE));
}
?></td>
<?php foreach ($so->open_days() as $d => $open) : ?>
<td class="text-center <?php echo $open ? 'bg-success' : 'bg-danger'; ?>">
<?php if ($rco->loaded()) : ?>
<?php if (! $open) : ?>
<i class="fa fa-times text-danger"></i>
<?php elseif ($rco->day($d)): ?>
<?php if (in_array($rco->code,array('a','P','w','c'))) : ?>
<?php echo Form::checkbox(sprintf('room[%s][d_%s]',$row,$d),TRUE,$rco->day($d) ? TRUE : FALSE,array('nocg'=>TRUE,($open ? '': 'disabled'))); ?>
<?php else : ?>
<i class="fa fa-check text-success"></i>
<?php endif ?>
<?php else : ?>
<?php if (in_array($rco->code,array('C'))) : ?>
<?php echo Form::checkbox(sprintf('room[%s][d_%s]',$row,$d),TRUE,$rco->day($d) ? TRUE : FALSE,array('nocg'=>TRUE,($open ? '': 'disabled'))); ?>
<?php else : ?>
&nbsp;
<?php endif ?>
<?php endif ?>
<?php else : ?>
<?php echo Form::checkbox(sprintf('room[%s][d_%s]',$row,$d),TRUE,$rco->day($d) ? TRUE : FALSE,array('nocg'=>TRUE,($open ? '': 'disabled'))); ?>
<?php endif ?>
</td>
<?php endforeach ?>
<td>
<div class="input-group input-daterange date" data-date-format="dd-mm-yyyy" data-provide="datepicker" data-date-start-view="year" data-date-autoclose="true" data-date-today-highlight="true" <?php if ($o->loaded()) : ?>data-date-start-date="<?php echo $o->display('dob'); ?>" data-date-end-date="<?php echo $o->date_enrol_max(TRUE); ?>" <?php endif ?>data-date-today-btn="true">
<div class="input-group-addon"><i class="fa fa-calendar"></i></div>
<?php echo Form::input(sprintf('room[%s][date_start]',$row),$rco->date_start ? $rco->display('date_start') : Site::Date(time()),array('class'=>'form-control','placeholder'=>'Start','nocg'=>TRUE,'readonly')); ?>
<span class="input-group-addon"> to </span>
<?php echo Form::input(sprintf('room[%s][date_stop]',$row),$rco->date_stop ? $rco->display('date_stop') : '',array('class'=>'form-control','placeholder'=>'End','nocg'=>TRUE,'readonly')); ?>
</div>
</td>
</tr>

View File

@ -1,6 +1,8 @@
<fieldset>
<legend>Register Child</legend>
<?php echo Form::hidden('child_id',$o->id); ?>
<div class="form-group">
<label class="col-md-2 control-label" for="Title">Name</label>
<div class="row">
@ -27,12 +29,13 @@
</div>
<div class="form-group">
<label class="col-md-2 control-label" for="Title">Requested Days</label>
<label class="col-md-2 control-label" for="Title">Member Days</label>
<div class="col-md-10">
<table class="table-bordered">
<table class="table-bordered" name="room">
<thead>
<tr>
<th>&nbsp;</th>
<th class="col-md-2">Room</th>
<th class="col-md-2">P/C/W</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 ?>
@ -42,32 +45,14 @@
</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') : '',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 ?>
<?php $x=0;foreach ($o->subitems() as $rco) echo View::factory('child/user/add_roomrow')->set('o',$o)->set('so',$so)->set('rco',$rco)->set('row',$x++)->set('type',$rco->code); ?>
</tbody>
</table>
<br/>
<button type="button" name="add" class="btn btn-sm btn-default" value="a">Advise Absent Notice</button>
<button type="button" name="add" class="btn btn-sm btn-default" value="c">Request Casual Days</button>
<button type="button" name="add" class="btn btn-sm btn-default" value="r">Reduce Days</button>
<button type="button" name="add" class="btn btn-sm btn-default" value="w">Waitlist Additional Days</button>
</div>
</div>
</fieldset>

View File

@ -0,0 +1,66 @@
<tr>
<?php $allowed_updates = array('w','c'); ?>
<?php echo Form::hidden(sprintf('room[%s][id]',$row),in_array($rco->code,$allowed_updates) ? $rco->id : NULL); ?>
<td><?php
switch ($type) {
case 'a':
case 'c':
case 'r':
case 'w':
echo '&nbsp;';
break;
default:
echo ($rco->id) ? $rco->room->display('name') : Form::select(sprintf('room[%s][room_id]',$row),ORM::factory('Rooms')->list_select(TRUE),$rco->room_id,array('class'=>'form-control','nocg'=>TRUE));
}
?></td>
<td><?php
switch ($type) {
case 'a':
case 'c':
case 'r':
case 'w':
echo StaticList_Room_Children::get($type);
echo Form::hidden(sprintf('room[%s][code]',$row),$type);
break;
default:
echo ($rco->id) ? StaticList_Room_Children::get($rco->code) : StaticList_Room_Children::form(sprintf('room[%s][code]',$row),$rco->code,FALSE,array('class'=>'form-control','nocg'=>TRUE));
}
?></td>
<?php foreach ($so->open_days() as $d => $open) : ?>
<td class="text-center <?php echo $open ? 'bg-success' : 'bg-danger'; ?>">
<?php if ($rco->loaded()) : ?>
<?php if (! $open) : ?>
<i class="fa fa-times text-danger"></i>
<?php elseif ($rco->day($d)): ?>
<?php if (in_array($rco->code,$allowed_updates)) : ?>
<?php echo Form::checkbox(sprintf('room[%s][d_%s]',$row,$d),TRUE,$rco->day($d) ? TRUE : FALSE,array('nocg'=>TRUE,($open ? '': 'disabled'))); ?>
<?php else : ?>
<i class="fa fa-check text-success"></i>
<?php endif ?>
<?php else : ?>
&nbsp;
<?php endif ?>
<?php else : ?>
<?php echo Form::checkbox(sprintf('room[%s][d_%s]',$row,$d),TRUE,$rco->day($d) ? TRUE : FALSE,array('nocg'=>TRUE,($open ? '': 'disabled'))); ?>
<?php endif ?>
</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="<?php echo $o->display('dob'); ?>" data-date-end-date="<?php echo $o->date_enrol_max(TRUE); ?>" data-date-today-btn="true">
<?php echo Form::input(sprintf('room[%s][date_start]',$row),$rco->date_start ? $rco->display('date_start') : Site::Date(time()),array('class'=>'form-control','placeholder'=>'Start','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="<?php echo $o->display('dob'); ?>" data-date-end-date="<?php echo $o->date_enrol_max(TRUE); ?>" data-date-today-btn="true">
<?php echo Form::input(sprintf('room[%s][date_stop]',$row),$rco->date_stop ? $rco->display('date_stop') : '',array('class'=>'form-control','placeholder'=>'End','nocg'=>TRUE,'readonly')); ?>
<span class="input-group-addon"><i class="fa fa-calendar"></i></span>
</div>
</td>
</tr>

View File

@ -51,12 +51,24 @@
<th>&nbsp;</th>
</tr>
<!-- Available Places -->
<tr class="info">
<th colspan="2">Availability</th>
<th>&nbsp;</th>
<?php foreach (array_keys($available_places) as $day) : ?>
<td class="text-right"><?php echo $available_places[$day]; ?></td>
<?php endforeach ?>
<th>&nbsp;</th>
</tr>
<!-- Unprocessed Waitlists -->
<tr>
<tr class="danger">
<th colspan="2">New Applications</th>
<th>&nbsp;</th>
<?php foreach (array_values(ORM::factory('Rooms')->child_list_date($date,$days,'W')) as $x) : ?>
<?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 ?>
@ -78,54 +90,48 @@
<th>&nbsp;</th>
</tr>
<!-- Permanents -->
<tr>
<td>&nbsp;</td>
<td>Permanent</td>
<td>&nbsp;</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>&nbsp;</th>
</tr>
<?php foreach (array(
'P'=>'Permanent',
'a'=>'Absent',
'C'=>'Casual',
) as $code => $title) : ?>
<!-- Absent -->
<tr>
<td>&nbsp;</td>
<td>Absent</td>
<td>&nbsp;</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>&nbsp;</th>
</tr>
<!-- Casual -->
<tr>
<td>&nbsp;</td>
<td>Casual</td>
<td>&nbsp;</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>&nbsp;</th>
</tr>
<tr>
<td>&nbsp;</td>
<td><?php echo HTML::anchor(URL::link('director',sprintf('room/list/%s:%s:%s:7',$ro->id,$date,$code)),$title); ?></td>
<td>&nbsp;</td>
<?php foreach ($ro->child_list_date($date,$days,$code) as $day=>$x) : ?>
<td class="text-right"><?php echo HTML::anchor(URL::link('director',sprintf('room/list/%s:%s:%s:1',$ro->id,$day,$code)),count($x)); ?></td>
<?php endforeach ?>
<th>&nbsp;</th>
</tr>
<?php endforeach ?>
<tr><th colspan="<?php echo $days+4; ?>">&nbsp;</th></tr>
<!-- Waitlist -->
<tr class="danger">
<td>&nbsp;</td>
<td><?php echo HTML::anchor(URL::link('director','room/list/'.$ro->id.':'.$date.':w:7'),'Waitlist'); ?></td>
<td>&nbsp;</td>
<?php foreach ($ro->child_list_date($date,$days,'w') as $day=>$x) : ?>
<td class="text-right"><?php echo HTML::anchor(URL::link('director','room/list/'.$ro->id.':'.$day.':w:1'),count($x)); ?></td>
<?php endforeach ?>
<th>&nbsp;</th>
</tr>
<tr>
<td>&nbsp;</td>
<td>Waitlist</td>
<td><?php echo HTML::anchor(URL::link('director','room/list/'.$ro->id.':'.$date.':w:7'),'Casual Request'); ?></td>
<td>&nbsp;</td>
<?php foreach (array_values($ro->child_list_date($date,$days,'W')) as $x) : ?>
<td class="text-right"><?php echo count($x); ?></td>
<?php foreach ($ro->child_list_date($date,$days,'c') as $day=>$x) : ?>
<td class="text-right"><?php echo HTML::anchor(URL::link('director','room/list/'.$ro->id.':'.$day.':c:1'),count($x)); ?></td>
<?php endforeach ?>
<th>&nbsp;</th>
</tr>
<!-- Availability -->
<tr>
<tr class="info">
<td>&nbsp;</td>
<td>Availability</td>
<td>&nbsp;</td>