Work on enrolment for Kinder

This commit is contained in:
Deon George
2016-08-31 02:13:05 +10:00
parent 571c6a9e3e
commit c82b8b127d
15 changed files with 324 additions and 15 deletions

View File

@@ -16,7 +16,7 @@ class Model_Child extends ORM {
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'),
'rooms'=>array('through'=>'room_children'),
);
public function filters() {
@@ -38,7 +38,7 @@ class Model_Child extends ORM {
);
protected $_sub_items_load = array(
'room'=>array('date_start','date_stop'),
'rooms'=>array('date_start','date_stop'),
);
private function _dob() {

View File

@@ -132,5 +132,14 @@ class Model_Rooms extends ORM {
return $result;
}
/**
* Rooms marked with the internal flag are the actual rooms that children are assigned in
* but cannot have an enrolment application for (there may be multiple rooms for the program).
* Thus a non "internal" room should be used for enrolments for the program.
*/
public function where_external() {
return $this->where_open()->where('internal','is',NULL)->or_where('internal','=',0)->where_close();
}
}
?>

View File

@@ -8,12 +8,72 @@
* @author Deon George
* @copyright (c) 2014 Deon George
* @license http://dev.leenooks.net/license.html
*
*/
class Model_Site_Dates extends ORM {
// @todo: Code O (open) start/end dates cannot overlap with existing records - put in validation that it cannot be saved.
protected $_created_column = NULL;
protected $_updated_column = NULL;
protected $_display_filters = array(
'date_start'=>array(
array('Site::date',array(':value')),
),
'date_stop'=>array(
array('Site::date',array(':value')),
),
);
/**
* List our codes
* CODE:
* + O (open) - site is open for business (start/end cannot overlap)
* + S (school year) - this is a year for school terms @see mdb_term_dates (only year is used from start)
* @todo: Code O (open) start/end dates cannot overlap with existing records - put in validation that it cannot be saved.
*/
public function codes() {
return [
'O'=>'Open',
'S'=>'School Year',
];
}
/**
* Return if this day is open
*/
public function open($day) {
return $this->{'d_'.$day};
}
public function where_year($year) {
$id = 0;
foreach ($this->list_years() as $k => $v)
if ($v == $year) {
$id = $k;
break;
}
// If we get hear, we didnt find the years
return ORM::factory('Site_Dates',$id ? $id : NULL);
}
/**
* Return the year this record peratins to
* @note: Only valid for School Years (code S)
*/
public function year() {
if ($this->code != 'S')
throw HTTP_Exception::factory(501,'Invalid call to :method, code [:code] is incorrect',[':method'=>__METHOD__,':code'=>$this->code]);
return $this->date_start ? date('Y',$this->date_start) : NULL;
}
public function list_years() {
$result = array();
foreach (ORM::factory('Site_Dates')->where('code','=','S')->where('date_stop','>',time())->find_all()->as_array() as $sdo)
$result[$sdo->id] = $sdo->year();
return $result;
}
}
?>