97 lines
2.6 KiB
PHP
97 lines
2.6 KiB
PHP
<?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/')),
|
|
))
|
|
);
|
|
}
|
|
}
|
|
?>
|