Register Child and Waitlist working

This commit is contained in:
Deon George
2014-10-22 22:22:47 +11:00
parent df7776931d
commit 48debfbd6c
21 changed files with 645 additions and 160 deletions

View File

@@ -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();