This repository has been archived on 2024-04-08. You can view files and clone it, but cannot push or open issues or pull requests.
memberdb/application/classes/Controller/Director/Welcome.php
2014-09-29 15:17:37 +10:00

114 lines
3.5 KiB
PHP

<?php defined('SYSPATH') or die('No direct access allowed.');
/**
* This class provides the Directors Welcome Screen
*
* @package Membership Database
* @category Controllers/Director
* @author Deon George
* @copyright (c) 2014 Deon George
* @license http://dev.leenooks.net/license.html
*/
class Controller_Director_Welcome extends Controller_Welcome {
protected $secure_actions = array(
'index'=>TRUE,
);
/**
* Edit a Module Configuration
*/
public function action_index() {
$output = '';
$date = Site::DateStartOfWeek(time());
$so = Company::instance()->so();
$days = 7;
$open_dates = $so->open_dates($date,$days);
$output .= '<table class="table table-striped table-condensed table-hover">';
$output .= '<tr>';
$output .= '<th colspan="2">&nbsp;</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>';
$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">&nbsp;</th></tr>',$ro->display('name'),$days);
// Capacity
$output .= '<tr>';
$output .= '<td>&nbsp;</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>&nbsp;</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>&nbsp;</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>&nbsp;</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">&nbsp;</td></tr>',$days+2);
// Waitlist
$output .= '<tr>';
$output .= '<td>&nbsp;</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>&nbsp;</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">&nbsp;</td></tr>',$days+2);
}
$output .= '</table>';
Block::factory()
->title(sprintf('Site Availability for %s',Site::date($date)))
->title_icon('icon-cog')
->body($output);
}
}
?>