Removed old Kohana code
This commit is contained in:
parent
289992706b
commit
d7f6bde3a5
9
.gitmodules
vendored
9
.gitmodules
vendored
@ -1,9 +0,0 @@
|
||||
[submodule "includes/kohana"]
|
||||
path = includes/kohana
|
||||
url = git@dev.leenooks.net:deon/lnkohana.git
|
||||
[submodule "modules/lnapp"]
|
||||
path = modules/lnapp
|
||||
url = git@dev.leenooks.net:deon/lnapp.git
|
||||
[submodule "modules/lnauth"]
|
||||
path = modules/lnauth
|
||||
url = git@dev.leenooks.net:deon/lnauth.git
|
21
.htaccess
21
.htaccess
@ -1,21 +0,0 @@
|
||||
# Turn on URL rewriting
|
||||
RewriteEngine On
|
||||
|
||||
# Installation directory
|
||||
RewriteBase /
|
||||
|
||||
# Protect hidden files from being viewed
|
||||
<Files .*>
|
||||
Order Deny,Allow
|
||||
Deny From All
|
||||
</Files>
|
||||
|
||||
# Protect application and system files from being viewed
|
||||
RewriteRule ^(?:application|modules|includes/kohana)\b.* index.php/$0 [L]
|
||||
|
||||
# Allow any files or directories that exist to be displayed directly
|
||||
RewriteCond %{REQUEST_FILENAME} !-f
|
||||
RewriteCond %{REQUEST_FILENAME} !-d
|
||||
|
||||
# Rewrite all other URLs to index.php/URL
|
||||
RewriteRule .* index.php/$0 [PT]
|
@ -1,205 +0,0 @@
|
||||
<?php defined('SYSPATH') or die('No direct script access.');
|
||||
|
||||
// -- Environment setup --------------------------------------------------------
|
||||
|
||||
// Load the core Kohana class
|
||||
require SYSPATH.'classes/Kohana/Core'.EXT;
|
||||
|
||||
if (is_file(APPPATH.'classes/Kohana'.EXT))
|
||||
{
|
||||
// Application extends the core
|
||||
require APPPATH.'classes/Kohana'.EXT;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Load empty core extension
|
||||
require SYSPATH.'classes/Kohana'.EXT;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the default time zone.
|
||||
*
|
||||
* @link http://kohanaframework.org/guide/using.configuration
|
||||
* @link http://www.php.net/manual/timezones
|
||||
*/
|
||||
date_default_timezone_set('Australia/Melbourne');
|
||||
|
||||
/**
|
||||
* Set the default locale.
|
||||
*
|
||||
* @link http://kohanaframework.org/guide/using.configuration
|
||||
* @link http://www.php.net/manual/function.setlocale
|
||||
*/
|
||||
setlocale(LC_ALL, 'en_US.utf-8');
|
||||
|
||||
/**
|
||||
* Enable the Kohana auto-loader.
|
||||
*
|
||||
* @link http://kohanaframework.org/guide/using.autoloading
|
||||
* @link http://www.php.net/manual/function.spl-autoload-register
|
||||
*/
|
||||
spl_autoload_register(array('Kohana', 'auto_load'));
|
||||
|
||||
/**
|
||||
* Optionally, you can enable a compatibility auto-loader for use with
|
||||
* older modules that have not been updated for PSR-0.
|
||||
*
|
||||
* It is recommended to not enable this unless absolutely necessary.
|
||||
*/
|
||||
//spl_autoload_register(array('Kohana', 'auto_load_lowercase'));
|
||||
|
||||
/**
|
||||
* Enable the Kohana auto-loader for unserialization.
|
||||
*
|
||||
* @link http://www.php.net/manual/function.spl-autoload-call
|
||||
* @link http://www.php.net/manual/var.configuration#unserialize-callback-func
|
||||
*/
|
||||
ini_set('unserialize_callback_func', 'spl_autoload_call');
|
||||
|
||||
/**
|
||||
* Set the mb_substitute_character to "none"
|
||||
*
|
||||
* @link http://www.php.net/manual/function.mb-substitute-character.php
|
||||
*/
|
||||
mb_substitute_character('none');
|
||||
|
||||
// -- Configuration and initialization -----------------------------------------
|
||||
|
||||
/**
|
||||
* Set the default language
|
||||
*/
|
||||
I18n::lang('en-us');
|
||||
|
||||
if (isset($_SERVER['SERVER_PROTOCOL']))
|
||||
{
|
||||
// Replace the default protocol.
|
||||
HTTP::$protocol = $_SERVER['SERVER_PROTOCOL'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Kohana::$environment if a 'KOHANA_ENV' environment variable has been supplied.
|
||||
*
|
||||
* Note: If you supply an invalid environment name, a PHP warning will be thrown
|
||||
* saying "Couldn't find constant Kohana::<INVALID_ENV_NAME>"
|
||||
*/
|
||||
|
||||
/**
|
||||
* Set the environment status by the domain.
|
||||
*/
|
||||
Kohana::$environment = Kohana::PRODUCTION;
|
||||
|
||||
if (isset($_SERVER['KOHANA_ENV']))
|
||||
{
|
||||
Kohana::$environment = constant('Kohana::'.strtoupper($_SERVER['KOHANA_ENV']));
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize Kohana, setting the default options.
|
||||
*
|
||||
* The following options are available:
|
||||
*
|
||||
* - string base_url path, and optionally domain, of your application NULL
|
||||
* - string index_file name of your index file, usually "index.php" index.php
|
||||
* - string charset internal character set used for input and output utf-8
|
||||
* - string cache_dir set the internal cache directory APPPATH/cache
|
||||
* - integer cache_life lifetime, in seconds, of items cached 60
|
||||
* - boolean errors enable or disable error handling TRUE
|
||||
* - boolean profile enable or disable internal profiling TRUE
|
||||
* - boolean caching enable or disable internal caching FALSE
|
||||
* - boolean expose set the X-Powered-By header FALSE
|
||||
*/
|
||||
Kohana::init(array(
|
||||
'base_url' => '/',
|
||||
'caching' => Kohana::$environment === Kohana::PRODUCTION,
|
||||
'profile' => Kohana::$environment !== Kohana::PRODUCTION,
|
||||
'index_file' => FALSE,
|
||||
));
|
||||
|
||||
/**
|
||||
* Attach the file write to logging. Multiple writers are supported.
|
||||
*/
|
||||
Kohana::$log->attach(new Log_File(APPPATH.'logs'));
|
||||
|
||||
/**
|
||||
* Attach a file reader to config. Multiple readers are supported.
|
||||
*/
|
||||
Kohana::$config->attach(new Config_File);
|
||||
|
||||
/**
|
||||
* Enable modules. Modules are referenced by a relative or absolute path.
|
||||
*/
|
||||
Kohana::modules(array(
|
||||
'lnauth' => MODPATH.'lnauth', // lnAuth Base Authentication Tools
|
||||
'lnapp' => MODPATH.'lnapp', // lnApp Base Application Tools
|
||||
// 'oauth' => MODPATH.'oauth', // OAuth Module for External Authentication
|
||||
'auth' => SMDPATH.'auth', // Basic authentication
|
||||
// 'cache' => SMDPATH.'cache', // Caching with multiple backends
|
||||
// 'cron' => SMDPATH.'cron', // Kohana Cron Module
|
||||
// 'codebench' => SMDPATH.'codebench', // Benchmarking tool
|
||||
'database' => SMDPATH.'database', // Database access
|
||||
// 'gchart' => MODPATH.'gchart', // Google Chart Module
|
||||
// 'highchart' => MODPATH.'highchart', // Highcharts Chart Module
|
||||
// 'image' => SMDPATH.'image', // Image manipulation
|
||||
'khemail' => SMDPATH.'khemail', // Email module for Kohana 3 PHP Framework
|
||||
// 'minion' => SMDPATH.'minion', // CLI Tasks
|
||||
'orm' => SMDPATH.'orm', // Object Relationship Mapping
|
||||
'pagination' => SMDPATH.'pagination', // Kohana Pagination module for Kohana 3 PHP Framework
|
||||
// 'unittest' => SMDPATH.'unittest', // Unit testing
|
||||
// 'userguide' => SMDPATH.'userguide', // User guide and API documentation
|
||||
// 'xml' => SMDPATH.'xml', // XML module for Kohana 3 PHP Framework
|
||||
));
|
||||
|
||||
/**
|
||||
* Cookie Salt
|
||||
* @see http://kohanaframework.org/3.3/guide/kohana/cookies
|
||||
*
|
||||
* If you have not defined a cookie salt in your Cookie class then
|
||||
* uncomment the line below and define a preferrably long salt.
|
||||
*/
|
||||
// Cookie::$salt = NULL;
|
||||
|
||||
/**
|
||||
* Load our modules defined in the DB
|
||||
*/
|
||||
Kohana::modules(array_merge(Kohana::modules(),Config::modules()));
|
||||
|
||||
/**
|
||||
* Enable specalised interfaces
|
||||
*/
|
||||
Route::set('sections', '<directory>/<controller>(/<action>(/<id>(/<sid>)))',
|
||||
array(
|
||||
'directory' => '('.implode('|',array_values(URL::$method_directory)).')'
|
||||
))
|
||||
->defaults(array(
|
||||
'action' => 'index',
|
||||
));
|
||||
|
||||
// Static file serving (CSS, JS, images)
|
||||
Route::set('default/media', 'media(/<file>)', array('file' => '.+'))
|
||||
->defaults(array(
|
||||
'controller' => 'media',
|
||||
'action' => 'get',
|
||||
));
|
||||
|
||||
/**
|
||||
* 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_.:-]+'))
|
||||
->defaults(array(
|
||||
'controller' => 'login',
|
||||
'action' => 'index',
|
||||
));
|
||||
|
||||
/**
|
||||
* If APC is enabled, and we need to clear the cache
|
||||
*/
|
||||
if (file_exists(APPPATH.'cache/CLEAR_APC_CACHE') AND function_exists('apc_clear_cache') AND (PHP_SAPI !== 'cli')) {
|
||||
if (! apc_clear_cache() OR ! unlink(APPPATH.'cache/CLEAR_APC_CACHE'))
|
||||
throw new Kohana_Exception('Unable to clear the APC cache.');
|
||||
}
|
||||
|
||||
// If we are a CLI, set our session dir
|
||||
if (PHP_SAPI === 'cli')
|
||||
session_save_path('tmp/');
|
||||
?>
|
@ -1,122 +0,0 @@
|
||||
<?php defined('SYSPATH') or die('No direct access allowed.');
|
||||
|
||||
/**
|
||||
* This class is for access company information.
|
||||
*
|
||||
* @package Membership Database
|
||||
* @category Helpers
|
||||
* @author Deon George
|
||||
* @copyright (c) 2014 Deon George
|
||||
* @license http://dev.leenooks.net/license.html
|
||||
*/
|
||||
class Company {
|
||||
public static $instance = array();
|
||||
|
||||
// Our Company Setup object
|
||||
private $so;
|
||||
|
||||
protected function __construct(Model_Setup $so) {
|
||||
$this->so = $so;
|
||||
|
||||
if (! $this->so->loaded())
|
||||
throw new Kohana_Exception(_('Site [:site] not defined in DB?'),array(':site'=>URL::base('http')));
|
||||
|
||||
Kohana::$environment = (int)$this->so->status;
|
||||
}
|
||||
|
||||
public static function instance() {
|
||||
$x = URL::base('http');
|
||||
|
||||
if (! isset(Company::$instance[$x]))
|
||||
Company::$instance[$x] = new Company(ORM::factory('Setup',array('url'=>$x)));
|
||||
|
||||
return Company::$instance[$x];
|
||||
}
|
||||
|
||||
public function admin() {
|
||||
return $this->so->account;
|
||||
}
|
||||
|
||||
public function address($ln='<br/>') {
|
||||
return implode($ln,array($this->street($ln),sprintf('%s, %s %s',$this->city(),$this->state(),$this->pcode())));
|
||||
}
|
||||
|
||||
public function city() {
|
||||
return $this->so->site_details('city');
|
||||
}
|
||||
|
||||
public function contacts() {
|
||||
return 'Tel: '.$this->phone();
|
||||
}
|
||||
|
||||
public function country() {
|
||||
return $this->so->country;
|
||||
}
|
||||
|
||||
public function date_format() {
|
||||
return $this->so->date_format;
|
||||
}
|
||||
|
||||
public function decimals() {
|
||||
return $this->so->decimal_place;
|
||||
}
|
||||
|
||||
public function email() {
|
||||
return $this->so->site_details('email');
|
||||
}
|
||||
|
||||
public function fax() {
|
||||
return $this->so->site_details('fax');
|
||||
}
|
||||
|
||||
public function faq() {
|
||||
return $this->so->site_details('faqurl');
|
||||
}
|
||||
|
||||
public function language() {
|
||||
return $this->so->language;
|
||||
}
|
||||
|
||||
public function logo_file() {
|
||||
list ($path,$suffix) = explode('.',Config::$logo);
|
||||
|
||||
return ($x=Kohana::find_file(sprintf('media/site/%s',$this->site()),$path,$suffix)) ? $x : Kohana::find_file('media',$path,$suffix);
|
||||
}
|
||||
|
||||
public function name() {
|
||||
return $this->so->site_details('name');
|
||||
}
|
||||
|
||||
public function module_config($item,array $value=NULL) {
|
||||
return $this->so->module_config($item,$value);
|
||||
}
|
||||
|
||||
public function pcode() {
|
||||
return $this->so->site_details('pcode');
|
||||
}
|
||||
|
||||
public function phone() {
|
||||
return $this->so->site_details('phone');
|
||||
}
|
||||
|
||||
public function site($format=FALSE) {
|
||||
return $format ? sprintf('%02s',$this->so->id) : $this->so->id;
|
||||
}
|
||||
|
||||
public function so() {
|
||||
return $this->so;
|
||||
}
|
||||
|
||||
public function state() {
|
||||
return $this->so->site_details('state');
|
||||
}
|
||||
|
||||
public function street($ln='<br/>') {
|
||||
return $this->so->site_details('address2') ? implode($ln,array($this->so->site_details('address1'),$this->so->site_details('address2'))) : $this->so->site_details('address1');
|
||||
}
|
||||
|
||||
public function time_format() {
|
||||
return $this->so->time_format;
|
||||
}
|
||||
}
|
||||
?>
|
@ -1,101 +0,0 @@
|
||||
<?php defined('SYSPATH') or die('No direct access allowed.');
|
||||
|
||||
/**
|
||||
* This class extends the core Kohana class by adding some core application
|
||||
* specific functions, and configuration.
|
||||
*
|
||||
* @package Membership Database
|
||||
* @category Helpers
|
||||
* @author Deon George
|
||||
* @copyright (c) 2014 Deon George
|
||||
* @license http://dev.leenooks.net/license.html
|
||||
*/
|
||||
class Config extends Kohana_Config {
|
||||
/**
|
||||
* Some early initialisation
|
||||
*
|
||||
* At this point, KH hasnt been fully initialised either, so we cant rely on
|
||||
* too many KH functions yet.
|
||||
*
|
||||
* NOTE: Kohana doesnt provide a parent construct for the Kohana_Config class.
|
||||
*/
|
||||
public function __construct() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the singleton instance of Config.
|
||||
*
|
||||
* $config = Config::instance();
|
||||
*
|
||||
* @return Config
|
||||
* @compat Restore KH 3.1 functionality
|
||||
*/
|
||||
public static function instance() {
|
||||
if (Config::$_instance === NULL)
|
||||
// Create a new instance
|
||||
Config::$_instance = new Config;
|
||||
|
||||
return Config::$_instance;
|
||||
}
|
||||
|
||||
public static function Copywrite($html=FALSE) {
|
||||
return ($html ? '©' : '(c)').' 2014 Deon George';
|
||||
}
|
||||
|
||||
public static function version() {
|
||||
// @todo Work out our versioning
|
||||
return 'TBA';
|
||||
}
|
||||
|
||||
/**
|
||||
* Find a list of all database enabled modules
|
||||
*
|
||||
* Our available modules are defined in the DB (along with method
|
||||
* security).
|
||||
*/
|
||||
public static function modules() {
|
||||
static $result = array();
|
||||
|
||||
if (! count($result)) {
|
||||
// We need to know our site here, so that we can subsequently load our enabled modules.
|
||||
if (PHP_SAPI === 'cli') {
|
||||
if (! ($site = Minion_CLI::options('site'))) {
|
||||
echo _('Cant figure out the site, use --site= for CLI')."\n";
|
||||
die();
|
||||
|
||||
} else
|
||||
$_SERVER['SERVER_NAME'] = $site;
|
||||
|
||||
}
|
||||
|
||||
foreach (ORM::factory('Module')->list_external() as $mo)
|
||||
$result[$mo->name] = MODPATH.$mo->name;
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
public static function module_config($item,array $value=NULL) {
|
||||
return Company::instance()->module_config($item,$value);
|
||||
}
|
||||
|
||||
public static function module_exist($module) {
|
||||
return array_key_exists(strtolower($module),self::modules()) ? TRUE : FALSE;
|
||||
}
|
||||
|
||||
/**
|
||||
* See if our emails for the template should be sent to configured admin(s)
|
||||
*
|
||||
* @param string template - Template to test for
|
||||
* @return mixed|array - Email to send test emails to
|
||||
*/
|
||||
public static function testmail($template) {
|
||||
$config = Kohana::$config->load('debug')->email_admin_only;
|
||||
|
||||
if (is_null($config) OR ! is_array($config) OR empty($config[$template]))
|
||||
return FALSE;
|
||||
else
|
||||
return $config[$template];
|
||||
}
|
||||
}
|
||||
?>
|
@ -1,77 +0,0 @@
|
||||
<?php defined('SYSPATH') or die('No direct access allowed.');
|
||||
|
||||
/**
|
||||
* This class provides MODULE management
|
||||
*
|
||||
* @package lnAuth
|
||||
* @category Controllers/Admin
|
||||
* @author Deon George
|
||||
* @copyright (c) 2014 Deon George
|
||||
* @license http://dev.leenooks.net/license.html
|
||||
*/
|
||||
class Controller_Admin_Site_Date extends Controller_TemplateDefault {
|
||||
protected $auth_required = TRUE;
|
||||
protected $secure_actions = array(
|
||||
'add'=>TRUE,
|
||||
'edit'=>TRUE,
|
||||
'list'=>TRUE,
|
||||
);
|
||||
|
||||
protected $icon = 'fa fa-calendar';
|
||||
|
||||
/**
|
||||
* Add a new site dates
|
||||
*/
|
||||
public function action_add() {
|
||||
Block::factory()
|
||||
->type('form-horizontal')
|
||||
->title('New Site Date')
|
||||
->title_icon($this->icon)
|
||||
->body($this->add_edit());
|
||||
}
|
||||
|
||||
private function add_edit($id=NULL,$output='') {
|
||||
$o = ORM::factory('Site_Dates',$id);
|
||||
|
||||
if ($this->request->post() AND $o->values($this->request->post())->changed()) {
|
||||
// Some validation
|
||||
if ($o->code == 'S') {
|
||||
$o->date_stop = NULL;
|
||||
$o->date_start = strtotime(date('Y',$o->date_start).'-01-01');
|
||||
$o->date_stop = strtotime(date('Y',$o->date_start).'-12-31');
|
||||
}
|
||||
|
||||
if (! $this->save($o))
|
||||
$o->reload();
|
||||
}
|
||||
|
||||
$this->meta->title = $o->loaded() ? sprintf('Site Date: %s',$o->id) : 'New Site Date';
|
||||
|
||||
return View::factory('site/date/admin/add_edit')
|
||||
->set('o',$o);
|
||||
}
|
||||
|
||||
/**
|
||||
* Edit a Module Configuration
|
||||
*/
|
||||
public function action_edit() {
|
||||
Block::factory()
|
||||
->type('form-horizontal')
|
||||
->title('Update Site Date')
|
||||
->title_icon($this->icon)
|
||||
->body($this->add_edit($this->request->param('id')));
|
||||
}
|
||||
|
||||
/**
|
||||
* List site dates
|
||||
*/
|
||||
public function action_list() {
|
||||
$this->meta->title = 'A|List Site Dates';
|
||||
|
||||
Block::factory()
|
||||
->title('Site Dates')
|
||||
->title_icon($this->icon)
|
||||
->body(View::factory('site/date/list')->set('o',ORM::factory('Site_Dates')->find_all()));
|
||||
}
|
||||
}
|
||||
?>
|
@ -1,3 +0,0 @@
|
||||
<?php defined('SYSPATH') or die('No direct script access.');
|
||||
|
||||
class Controller_Child extends Controller_TemplateDefault { }
|
@ -1,74 +0,0 @@
|
||||
<?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_Account extends Controller_Account {
|
||||
protected $secure_actions = array(
|
||||
'add'=>TRUE,
|
||||
'ajaxlist'=>FALSE,
|
||||
'list'=>TRUE,
|
||||
);
|
||||
|
||||
/**
|
||||
* Add an Account
|
||||
*/
|
||||
public function action_add() {
|
||||
Block::factory()
|
||||
->type('form-horizontal')
|
||||
->title('Add/Edit Record')
|
||||
->title_icon('fa-wrench')
|
||||
->body($this->add_edit());
|
||||
}
|
||||
|
||||
public function action_ajaxlist() {
|
||||
$result = array();
|
||||
|
||||
if ($this->request->query('query'))
|
||||
$result = Arr::merge($result,ORM::factory('Account')->list_autocomplete($this->request->query('query'),'id','id',array('%s: %s'=>array('id','name(TRUE)'))));
|
||||
|
||||
$this->response->headers('Content-Type','application/json');
|
||||
$this->response->body(json_encode(array_values($result)));
|
||||
}
|
||||
|
||||
/**
|
||||
* List Accounts
|
||||
*/
|
||||
public function action_list() {
|
||||
$output = __METHOD__;
|
||||
|
||||
Block::factory()
|
||||
->title('List Families')
|
||||
->body($output);
|
||||
}
|
||||
|
||||
private function add_edit($id=NULL) {
|
||||
$co = ORM::factory('Child',$id);
|
||||
|
||||
if ($this->request->post() AND $co->values($this->request->post())->changed() AND (! $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');
|
||||
|
||||
Script::factory()
|
||||
->type('file')
|
||||
->data('media/theme/bootstrap/js/bootstrap.datepicker.js');
|
||||
|
||||
return View::factory('account/user/add_edit')
|
||||
->set('o',$co)
|
||||
->set('so',Company::instance()->so());
|
||||
}
|
||||
}
|
||||
?>
|
@ -1,176 +0,0 @@
|
||||
<?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());
|
||||
}
|
||||
}
|
||||
?>
|
@ -1,96 +0,0 @@
|
||||
<?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/')),
|
||||
))
|
||||
);
|
||||
}
|
||||
}
|
||||
?>
|
@ -1,23 +0,0 @@
|
||||
<?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,
|
||||
);
|
||||
|
||||
/**
|
||||
* Show Directory Main Page
|
||||
*/
|
||||
public function action_index() {
|
||||
}
|
||||
}
|
||||
?>
|
@ -1,63 +0,0 @@
|
||||
<?php defined('SYSPATH') or die('No direct access allowed.');
|
||||
|
||||
/**
|
||||
* Membership Database Register
|
||||
*
|
||||
* @package Membership Database
|
||||
* @category Controllers/User
|
||||
* @author Deon George
|
||||
* @copyright (c) 2014 Deon George
|
||||
* @license http://dev.leenooks.net/license.html
|
||||
*/
|
||||
class Controller_Enrol extends Controller_TemplateDefault{
|
||||
protected $auth_required = FALSE;
|
||||
|
||||
public function action_index() {
|
||||
$sdo = $this->request->post('year') ? ORM::factory('Site_Dates',$this->request->post('year')) : ORM::factory('Site_Dates')->where_year($this->request->param('id'));
|
||||
if (! $sdo->loaded()) {
|
||||
Block::factory()
|
||||
->type('form-horizontal')
|
||||
->title('Choose year of enrolment')
|
||||
->title_icon('fa fa-calendar')
|
||||
->body(View::factory('enrol/selectyear'));
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$ao = ORM::factory('Account');
|
||||
$co = ORM::factory('Child');
|
||||
|
||||
$this->meta->title = 'Enrol';
|
||||
|
||||
if ($this->request->post('account') AND $this->request->post('child') AND $this->request->post('room.id')) {
|
||||
$ao->values($this->request->post('account'));
|
||||
$co->values($this->request->post('child'));
|
||||
$ro = ORM::factory('Rooms',$this->request->post('room.id'));
|
||||
|
||||
// First we need to make an account
|
||||
try {
|
||||
if ($ao->save() AND $co->save()) {
|
||||
$co->account_id = $ao;
|
||||
$co->status = 'PEND';
|
||||
$co->save();
|
||||
|
||||
$co->add('rooms',$ro);
|
||||
}
|
||||
|
||||
} catch (ORM_Validation_Exception $e) {
|
||||
SystemMessage::factory()
|
||||
->title('Record NOT created')
|
||||
->type('danger')
|
||||
->body(join('<br/>',array_values($e->errors('register'))));
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Block::factory()
|
||||
->type('form-horizontal')
|
||||
->title('Register enrolment for: '.$sdo->year())
|
||||
->title_icon('fa fa-university')
|
||||
->body(View::factory('enrol/child')->set('ao',$ao)->set('co',$co)->set('room_id',$this->request->post('room.id'))->set('year',$sdo->id));
|
||||
}
|
||||
}
|
||||
?>
|
@ -1,3 +0,0 @@
|
||||
<?php defined('SYSPATH') or die('No direct script access.');
|
||||
|
||||
class Controller_Room extends Controller_TemplateDefault { }
|
@ -1,149 +0,0 @@
|
||||
<?php defined('SYSPATH') or die('No direct access allowed.');
|
||||
|
||||
/**
|
||||
* Membership Database Add Children
|
||||
*
|
||||
* @package Membership Database
|
||||
* @category Controllers/User
|
||||
* @author Deon George
|
||||
* @copyright (c) 2014 Deon George
|
||||
* @license http://dev.leenooks.net/license.html
|
||||
*/
|
||||
class Controller_User_Child extends Controller_Child {
|
||||
protected $auth_required = TRUE;
|
||||
protected $secure_actions = array(
|
||||
'add'=>TRUE,
|
||||
'ajaxage'=>FALSE,
|
||||
'ajaxagemax'=>FALSE,
|
||||
'edit'=>TRUE,
|
||||
);
|
||||
|
||||
public function action_add() {
|
||||
Block::factory()
|
||||
->type('form-horizontal')
|
||||
->title('Add/Edit Record')
|
||||
->title_icon('fa-wrench')
|
||||
->body($this->add_edit());
|
||||
}
|
||||
|
||||
public function action_ajaxage() {
|
||||
$x = ORM::factory('Child');
|
||||
$x->dob = $this->request->query('date');
|
||||
$this->template->content = $x->age();
|
||||
}
|
||||
|
||||
public function action_ajaxagemax() {
|
||||
$x = ORM::factory('Child');
|
||||
$x->dob = $this->request->query('date');
|
||||
$this->template->content = $x->date_enrol_max(TRUE);
|
||||
}
|
||||
|
||||
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')));
|
||||
}
|
||||
|
||||
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');
|
||||
|
||||
// Set our maximum date, that children can stay
|
||||
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);
|
||||
}
|
||||
});
|
||||
|
||||
$.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')
|
||||
->set('o',$co)
|
||||
->set('so',Company::instance()->so());
|
||||
}
|
||||
}
|
||||
?>
|
@ -1,49 +0,0 @@
|
||||
<?php defined('SYSPATH') or die('No direct access allowed.');
|
||||
|
||||
/**
|
||||
* Membership Database Main home page
|
||||
*
|
||||
* @package Membership Database
|
||||
* @category Controllers/User
|
||||
* @author Deon George
|
||||
* @copyright (c) 2014 Deon George
|
||||
* @license http://dev.leenooks.net/license.html
|
||||
*/
|
||||
class Controller_User_Welcome extends Controller_Welcome {
|
||||
protected $auth_required = TRUE;
|
||||
protected $secure_actions = array(
|
||||
'index'=>TRUE,
|
||||
);
|
||||
|
||||
public function action_index() {
|
||||
$output = '';
|
||||
|
||||
if (! $this->ao->list_children()->count())
|
||||
$output .= 'You have no currently registered children, would you like to '.HTML::anchor(URL::link('user','child/add'),'Register').' a child?';
|
||||
else
|
||||
$output = Table::factory()
|
||||
->data($this->ao->list_children())
|
||||
->columns(array(
|
||||
'id'=>'ID',
|
||||
'first_name'=>'First Name',
|
||||
'family_name'=>'Family Name',
|
||||
'dob'=>'DOB',
|
||||
))
|
||||
->prepend(array(
|
||||
'id'=>array('url'=>URL::link('user','child/edit/')),
|
||||
));
|
||||
|
||||
Block::factory()
|
||||
->title(sprintf('Membership details for : %s',$this->ao->name()))
|
||||
->title_icon('icon-info-sign')
|
||||
->span(9)
|
||||
->body($output);
|
||||
|
||||
Block::factory()
|
||||
->title('Quick Shortcuts')
|
||||
->title_icon('icon-bookmark')
|
||||
->span(3)
|
||||
->body(View::factory('welcome/user/shortcuts'));
|
||||
}
|
||||
}
|
||||
?>
|
@ -1,23 +0,0 @@
|
||||
<?php defined('SYSPATH') or die('No direct script access.');
|
||||
|
||||
/**
|
||||
* Main home page for un-authenticated users
|
||||
*
|
||||
* @package Membership Database
|
||||
* @category Controllers
|
||||
* @author Deon George
|
||||
* @copyright (c) 2009-2013 Deon George
|
||||
* @license http://dev.leenooks.net/license.html
|
||||
*/
|
||||
class Controller_Welcome extends lnApp_Controller_Welcome {
|
||||
protected $auth_required = FALSE;
|
||||
|
||||
public function action_index() {
|
||||
Style::factory()
|
||||
->type('file')
|
||||
->data('media/css/pages/welcome.css');
|
||||
|
||||
$this->template->content = View::factory('pages/welcome');
|
||||
}
|
||||
}
|
||||
?>
|
@ -1,15 +0,0 @@
|
||||
<?php defined('SYSPATH') or die('No direct access allowed.');
|
||||
|
||||
/**
|
||||
* This class overrides Kohana's Cookie
|
||||
*
|
||||
* @package Membership Database
|
||||
* @category Modifications
|
||||
* @author Deon George
|
||||
* @copyright (c) 2014 Deon George
|
||||
* @license http://dev.leenooks.net/license.html
|
||||
*/
|
||||
class Cookie extends Kohana_Cookie {
|
||||
public static $salt = 'Photo';
|
||||
}
|
||||
?>
|
@ -1,18 +0,0 @@
|
||||
<?php defined('SYSPATH') or die('No direct access allowed.');
|
||||
|
||||
/**
|
||||
* This class extends the core Kohana class by adding some core application
|
||||
* specific functions, and configuration.
|
||||
*
|
||||
* @package Membership Database
|
||||
* @category Modifications
|
||||
* @author Deon George
|
||||
* @copyright (c) 2014 Deon George
|
||||
* @license http://dev.leenooks.net/license.html
|
||||
*/
|
||||
abstract class Database extends Kohana_Database {
|
||||
public function caching() {
|
||||
return isset($this->_config['caching']) ? $this->_config['caching'] : FALSE;
|
||||
}
|
||||
}
|
||||
?>
|
@ -1,72 +0,0 @@
|
||||
<?php defined('SYSPATH') or die('No direct access allowed.');
|
||||
|
||||
/**
|
||||
* This class overrides Kohana's Core
|
||||
*
|
||||
* @package Membership Database
|
||||
* @category Modifications
|
||||
* @author Deon George
|
||||
* @copyright (c) 2014 Deon George
|
||||
* @license http://dev.leenooks.net/license.html
|
||||
*/
|
||||
abstract class Kohana extends Kohana_Core {
|
||||
/**
|
||||
* Work out our Class Name as per Kohana's standards
|
||||
*/
|
||||
public static function classname($name) {
|
||||
return str_replace(' ','_',ucwords(strtolower(str_replace('_',' ',$name))));
|
||||
}
|
||||
|
||||
/**
|
||||
* Find files using a multi-site enabled application
|
||||
*
|
||||
* In order of precedence, we'll return:
|
||||
* 1) site-theme file, ie: site/X/THEME/${file}
|
||||
* 2) site file, ie: site/X/${file}
|
||||
* 3) theme file, ie: THEME/${file}
|
||||
* 4) normal search, ie: ${file}
|
||||
*/
|
||||
public static function find_file($dir,$file,$ext=NULL,$array=FALSE) {
|
||||
// Limit our scope to the following dirs
|
||||
// @note, we cannot have classes checked, since Config() doesnt exist yet
|
||||
$dirs = array('views','media');
|
||||
|
||||
if (! in_array($dir,$dirs) OR PHP_SAPI === 'cli')
|
||||
return parent::find_file($dir,$file,$ext,$array);
|
||||
|
||||
$prefixes = array('');
|
||||
|
||||
// Our search order.
|
||||
array_unshift($prefixes,Site::Theme().'/');
|
||||
array_unshift($prefixes,sprintf('site/%s/',Site::ID()));
|
||||
array_unshift($prefixes,sprintf('site/%s/%s/',Site::ID(),Site::Theme()));
|
||||
|
||||
foreach ($prefixes as $p)
|
||||
if ($x = parent::find_file($dir,$p.$file,$ext,$array))
|
||||
break;
|
||||
|
||||
// We found a path.
|
||||
return $x;
|
||||
}
|
||||
|
||||
/**
|
||||
* Override Kohana's shutdown_handler()
|
||||
*
|
||||
* When set up for multi-site, we need to disable Kohana's caching
|
||||
* unless each site has exactly the same modules enabled.
|
||||
* This is because Kohana::$file is cached with the enabled modules
|
||||
* and is not OSB multi-site aware.
|
||||
*/
|
||||
public static function shutdown_handler() {
|
||||
// If caching isnt enabled, we can skip this anyway
|
||||
if (! Kohana::$caching)
|
||||
return parent::shutdown_handler();
|
||||
|
||||
Kohana::$caching = FALSE;
|
||||
$result = parent::shutdown_handler();
|
||||
Kohana::$caching = TRUE;
|
||||
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
?>
|
@ -1,24 +0,0 @@
|
||||
<?php defined('SYSPATH') or die('No direct access allowed.');
|
||||
|
||||
/**
|
||||
* This Model manages both the accounts that users use to login to the system, as well as the account where services are owned.
|
||||
*
|
||||
* @package Membership Database
|
||||
* @category Models
|
||||
* @author Deon George
|
||||
* @copyright (c) 2014 Deon George
|
||||
* @license http://dev.leenooks.net/license.html
|
||||
*/
|
||||
class Model_Account extends lnAuth_Model_Account {
|
||||
// Relationships
|
||||
protected $_has_many = array(
|
||||
'child'=>array('far_key'=>'id'),
|
||||
'email_log'=>array('far_key'=>'id'),
|
||||
'group'=>array('through'=>'account_group'),
|
||||
);
|
||||
|
||||
public function list_children() {
|
||||
return $this->child->find_all();
|
||||
}
|
||||
}
|
||||
?>
|
@ -1,165 +0,0 @@
|
||||
<?php defined('SYSPATH') or die('No direct access allowed.');
|
||||
|
||||
/**
|
||||
* This class supports Children
|
||||
*
|
||||
* @package Membership Database
|
||||
* @category Models
|
||||
* @author Deon George
|
||||
* @copyright (c) 2014 Deon George
|
||||
* @license http://dev.leenooks.net/license.html
|
||||
*/
|
||||
class Model_Child extends ORM {
|
||||
protected $_start = '42D'; // Minimum age to be accepted (42D = 6 Weeks)
|
||||
protected $_max = '4Y'; // Maximum age
|
||||
protected $_max_date = '04-30'; // Date Maximum age must be met, eg: 5Y on April 30
|
||||
protected $_max_return = '12-31'; // Date to leave the center when max date reached, eg: Jan 1
|
||||
|
||||
protected $_has_many = array(
|
||||
'rooms'=>array('through'=>'room_children'),
|
||||
);
|
||||
|
||||
public function filters() {
|
||||
return Arr::merge(parent::filters(),array(
|
||||
'dob'=>array(array(array($this,'date'), array(':value'))),
|
||||
));
|
||||
}
|
||||
|
||||
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(
|
||||
'rooms'=>array('date_start','date_stop'),
|
||||
);
|
||||
|
||||
private function _dob() {
|
||||
$x = new DateTime();
|
||||
|
||||
return $x->setTimestamp($this->dob);
|
||||
}
|
||||
|
||||
public function age($asat=NULL,$format='%Yy%Mm') {
|
||||
if (is_null($asat))
|
||||
$asat = time();
|
||||
|
||||
$dob = $this->_dob();
|
||||
|
||||
$today = new DateTime();
|
||||
$today->setTimestamp($asat);
|
||||
|
||||
return $format == '%w' ? sprintf('%02dw',$dob->diff($today)->days/7) : $dob->diff($today)->format($format);
|
||||
}
|
||||
|
||||
public function date($value) {
|
||||
return is_numeric($value) ? $value : strtotime($value);
|
||||
}
|
||||
|
||||
public function date_enrol_min() {
|
||||
$dob = $this->_dob();
|
||||
$dob->add(new DateInterval('P'.$this->_start));
|
||||
|
||||
return $format ? $result->format(Kohana::$config->load('config')->date_format) : $result->format('U');
|
||||
}
|
||||
|
||||
public function date_enrol_max($format=FALSE) {
|
||||
$dob = $this->_dob();
|
||||
$dob->add(new DateInterval('P'.$this->_max));
|
||||
|
||||
$last = new DateTime(sprintf('%s-%s',$dob->format('Y'),$this->_max_date));
|
||||
$x = $dob->diff($last);
|
||||
|
||||
$result = new DateTime(sprintf('%s-%s',$dob->format('Y')+($x->invert ? 1 : 0),$this->_max_return));
|
||||
|
||||
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);
|
||||
|
||||
// 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();
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
// 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();
|
||||
}
|
||||
|
||||
return $this->reload();
|
||||
}
|
||||
}
|
||||
?>
|
@ -1,115 +0,0 @@
|
||||
<?php defined('SYSPATH') or die('No direct access allowed.');
|
||||
|
||||
/**
|
||||
* This class supports Children in a Room Configuration
|
||||
*
|
||||
* @package Membership Database
|
||||
* @category Models
|
||||
* @author Deon George
|
||||
* @copyright (c) 2014 Deon George
|
||||
* @license http://dev.leenooks.net/license.html
|
||||
*/
|
||||
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')),
|
||||
array('ORM::tostring', array(':value')),
|
||||
),
|
||||
'date_stop'=>array(
|
||||
array('strtotime', array(':value')),
|
||||
array('ORM::tostring', array(':value')),
|
||||
),
|
||||
));
|
||||
}
|
||||
|
||||
public function rules() {
|
||||
$x = parent::rules();
|
||||
|
||||
unset($x['id']);
|
||||
|
||||
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(
|
||||
'date_start'=>array(
|
||||
array('Site::Date',array(':value')),
|
||||
),
|
||||
'date_stop'=>array(
|
||||
array('Site::Date',array(':value')),
|
||||
),
|
||||
);
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
?>
|
@ -1,19 +0,0 @@
|
||||
<?php defined('SYSPATH') or die('No direct access allowed.');
|
||||
|
||||
/**
|
||||
* This class supports Room Configuration by date
|
||||
*
|
||||
* @package Membership Database
|
||||
* @category Models
|
||||
* @author Deon George
|
||||
* @copyright (c) 2014 Deon George
|
||||
* @license http://dev.leenooks.net/license.html
|
||||
*/
|
||||
class Model_Room_Dates extends ORM {
|
||||
// @todo: Code A (availble) start/end dates cannot overlap with existing records - put in validation that it cannot be saved.
|
||||
|
||||
public function avail($day) {
|
||||
return $this->{'d_'.$day} ? $this->{'d_'.$day} : 0;
|
||||
}
|
||||
}
|
||||
?>
|
@ -1,145 +0,0 @@
|
||||
<?php defined('SYSPATH') or die('No direct access allowed.');
|
||||
|
||||
/**
|
||||
* This class supports Company Rooms
|
||||
*
|
||||
* @package Membership Database
|
||||
* @category Models
|
||||
* @author Deon George
|
||||
* @copyright (c) 2014 Deon George
|
||||
* @license http://dev.leenooks.net/license.html
|
||||
*/
|
||||
class Model_Rooms extends ORM {
|
||||
protected $_belongs_to = array(
|
||||
'site'=>array('model'=>'Setup'),
|
||||
);
|
||||
protected $_has_many = array(
|
||||
'dates'=>array('model'=>'Room_Dates','far_key'=>'id','foreign_key'=>'room_id'),
|
||||
'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;
|
||||
|
||||
$date_end = $date+$days*86400;
|
||||
$open_dates = $this->site->open_dates($date,$days);
|
||||
foreach ($this->dates->where('code','=',$code)->where_startstop($date,$date_end)->find_all() as $o) {
|
||||
$x = $date;
|
||||
|
||||
while ($x<$date_end) {
|
||||
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))) {
|
||||
|
||||
$result[$x] = $o->avail(date('w',$x));
|
||||
|
||||
$x += 86400;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (! isset($result[$x]) OR ! $result[$x])
|
||||
$result[$x] = 0;
|
||||
|
||||
$x += 86400;
|
||||
}
|
||||
}
|
||||
|
||||
// If we broke out and our date $days hasnt ben evaluated, we are closed
|
||||
while ($x<$date_end) {
|
||||
if (! isset($result[$x]) OR ! $result[$x])
|
||||
$result[$x] = 0;
|
||||
|
||||
$x += 86400;
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
// 'P' - Permanent
|
||||
public function child_list_date($date,$days,$code='P') {
|
||||
$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) {
|
||||
$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)) {
|
||||
|
||||
if (! isset($result[$x]) OR ! $result[$x])
|
||||
$result[$x] = array();
|
||||
|
||||
$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]))
|
||||
$result[$x] = array();
|
||||
|
||||
if ($o->day(date('w',$x)))
|
||||
array_push($result[$x],$o->child);
|
||||
|
||||
$x += 86400;
|
||||
}
|
||||
}
|
||||
|
||||
// If we broke out and our date $days hasnt ben evaluated, we are closed
|
||||
while ($x<$date_end) {
|
||||
if (! isset($result[$x]) OR ! $result[$x])
|
||||
$result[$x] = array();
|
||||
|
||||
$x += 86400;
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
public function room_availablity($date,$days) {
|
||||
// We start with our availablity
|
||||
$result = $this->availability_dates($date,$days);
|
||||
|
||||
// Less Permanents
|
||||
foreach ($this->child_list_date($date,$days) as $k => $v)
|
||||
$result[$k] -= count($v);
|
||||
|
||||
// Add Absent
|
||||
foreach ($this->child_list_date($date,$days,'a') as $k => $v)
|
||||
$result[$k] += count($v);
|
||||
|
||||
// Less Casuals
|
||||
foreach ($this->child_list_date($date,$days,'C') as $k => $v)
|
||||
$result[$k] -= count($v);
|
||||
|
||||
// Less Waitlist
|
||||
foreach ($this->child_list_date($date,$days,'W') as $k => $v)
|
||||
$result[$k] -= count($v);
|
||||
|
||||
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();
|
||||
}
|
||||
}
|
||||
?>
|
@ -1,192 +0,0 @@
|
||||
<?php defined('SYSPATH') or die('No direct access allowed.');
|
||||
|
||||
/**
|
||||
* Membership Database Setup Model
|
||||
*
|
||||
* This module must remain in applications/ as it is used very early in the
|
||||
* Membership Database initialisation.
|
||||
*
|
||||
* @package Membership Database
|
||||
* @category Models
|
||||
* @author Deon George
|
||||
* @copyright (c) 2014 Deon George
|
||||
* @license http://dev.leenooks.net/license.html
|
||||
*/
|
||||
class Model_Setup extends ORM {
|
||||
// Setup doesnt use the update column
|
||||
protected $_updated_column = FALSE;
|
||||
|
||||
protected $_has_one = array(
|
||||
'account'=>array('foreign_key'=>'id','far_key'=>'admin_id'),
|
||||
'country'=>array('foreign_key'=>'id','far_key'=>'country_id'),
|
||||
'language'=>array('foreign_key'=>'id','far_key'=>'language_id'),
|
||||
);
|
||||
|
||||
protected $_has_many = array(
|
||||
'dates'=>array('model'=>'Site_Dates','far_key'=>'id','foreign_key'=>'site_id'),
|
||||
'rooms'=>array('far_key'=>'id','foreign_key'=>'site_id'),
|
||||
);
|
||||
|
||||
protected $_compress_column = array(
|
||||
'module_config',
|
||||
'site_details',
|
||||
);
|
||||
|
||||
// Validation rules
|
||||
public function rules() {
|
||||
$x = Arr::merge(parent::rules(), array(
|
||||
'url' => array(
|
||||
array('not_empty'),
|
||||
array('min_length', array(':value', 8)),
|
||||
array('max_length', array(':value', 127)),
|
||||
array('url'),
|
||||
),
|
||||
));
|
||||
|
||||
// This module doesnt use site_id.
|
||||
unset($x['site_id']);
|
||||
|
||||
return $x;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get/Set Module Configuration
|
||||
*
|
||||
* @param $key Module name.
|
||||
* @param $value Values to store. If NULL, retrieves the value stored, otherwise stores value.
|
||||
*/
|
||||
public function module_config($key,array $value=NULL) {
|
||||
// If we are not loaded, we dont have any config.
|
||||
if (! $this->loaded() OR (is_null($value) AND ! $this->module_config))
|
||||
return array();
|
||||
|
||||
$mo = ORM::factory('Module',array('name'=>$key));
|
||||
|
||||
if (! $mo->loaded())
|
||||
throw new Kohana_Exception('Unknown module :name',array(':name'=>$key));
|
||||
|
||||
$mc = $this->module_config ? $this->module_config : array();
|
||||
|
||||
// If $value is NULL, we are a getter
|
||||
if ($value === NULL)
|
||||
return empty($mc[$mo->id]) ? array() : $mc[$mo->id];
|
||||
|
||||
// Store new value
|
||||
$mc[$mo->id] = $value;
|
||||
$this->module_config = $mc;
|
||||
|
||||
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();
|
||||
|
||||
foreach (array_keys($this->module_config) as $mid) {
|
||||
if (is_null($key) OR $key == $mid) {
|
||||
$result[$mid] = array(
|
||||
'object'=>ORM::factory('Module',$mid),
|
||||
'data'=>$this->module_config[$mid],
|
||||
);
|
||||
|
||||
// If we are just after our key, we can continue here
|
||||
if ($key AND $key==$mid)
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
public function open_days() {
|
||||
$result = array();
|
||||
|
||||
//@todo this needs to change to node have any dates, since the current date may be closed, or a public holiday
|
||||
foreach ($this->open_dates(Site::DateStartOfWeek(time()),7) as $date => $open)
|
||||
$result[date('w',$date)] = $open;
|
||||
|
||||
ksort($result);
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
public function open_dates($date,$days=0,$code='O') {
|
||||
$result = array();
|
||||
|
||||
$date_end = $date+$days*86400;
|
||||
foreach ($this->dates->where('code','=',$code)->where_startstop($date,$date_end)->find_all() as $o)
|
||||
while ($date<$date_end) {
|
||||
// If we havent made the start date yet, we need to advance
|
||||
if ($o->date_start > $date AND $o->date_stop > $date_end) {
|
||||
$result[$date] = FALSE;
|
||||
$date += 86400;
|
||||
continue;
|
||||
}
|
||||
|
||||
// Check that this record covers our current date
|
||||
if ($o->date_stop < $date)
|
||||
break;
|
||||
|
||||
$result[$date] = $o->open(date('w',$date)) ? TRUE : FALSE;
|
||||
$date += 86400;
|
||||
}
|
||||
|
||||
// If we broke out and our date $days hasnt ben evaluated, we are closed
|
||||
while ($date<$date_end) {
|
||||
$result[$date] = FALSE;
|
||||
$date += 86400;
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get/Set our Site Configuration from the DB
|
||||
*
|
||||
* @param $key Key
|
||||
* @param $value Values to store. If NULL, retrieves the value stored, otherwise stores value.
|
||||
*/
|
||||
public function site_details($key,array $value=NULL) {
|
||||
if (! in_array($key,array('name','address1','address2','city','state','pcode','phone','fax','email','faqurl')))
|
||||
throw new Kohana_Exception('Unknown Site Configuration Key :key',array(':key'=>$key));
|
||||
|
||||
// If $value is NULL, we are a getter
|
||||
if ($value === NULL)
|
||||
return empty($this->site_details[$key]) ? '' : $this->site_details[$key];
|
||||
|
||||
// Store new value
|
||||
$sc[$key] = $value;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function total_places($date_start,$days=0) {
|
||||
$result = array();
|
||||
|
||||
foreach ($this->rooms->find_all() as $ro) {
|
||||
foreach ($ro->availability_dates($date_start,$days) as $date => $total) {
|
||||
if (! isset($result[$date]))
|
||||
$result[$date] = 0;
|
||||
|
||||
$result[$date] += $total;
|
||||
}
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
?>
|
@ -1,79 +0,0 @@
|
||||
<?php defined('SYSPATH') or die('No direct access allowed.');
|
||||
|
||||
/**
|
||||
* This class supports Site Operating Dates
|
||||
*
|
||||
* @package Membership Database
|
||||
* @category Models
|
||||
* @author Deon George
|
||||
* @copyright (c) 2014 Deon George
|
||||
* @license http://dev.leenooks.net/license.html
|
||||
*
|
||||
*/
|
||||
class Model_Site_Dates extends ORM {
|
||||
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;
|
||||
}
|
||||
}
|
||||
?>
|
@ -1,58 +0,0 @@
|
||||
<?php defined('SYSPATH') or die('No direct access allowed.');
|
||||
|
||||
/**
|
||||
* This class extends Kohana's [ORM] class to create defaults for Membership Database.
|
||||
*
|
||||
* @package Membership Database
|
||||
* @category Helpers
|
||||
* @author Deon George
|
||||
* @copyright (c) 2014 Deon George
|
||||
* @license http://dev.leenooks.net/license.html
|
||||
*/
|
||||
abstract class ORM extends lnAuth_ORM {
|
||||
/**
|
||||
* @var string Database to connect to
|
||||
*/
|
||||
protected $_db = 'default';
|
||||
|
||||
public function config($key) {
|
||||
$mc = Config::instance()->module_config($this->_object_name);
|
||||
|
||||
return empty($mc[$key]) ? '' : $mc[$key];
|
||||
}
|
||||
|
||||
/**
|
||||
* Function help to find records that are active
|
||||
*/
|
||||
public function list_active($active=TRUE) {
|
||||
$x=($active ? $this->where_active() : $this);
|
||||
|
||||
return $x->find_all();
|
||||
}
|
||||
|
||||
public function list_count($active=TRUE) {
|
||||
$x=($active ? $this->where_active() : $this);
|
||||
|
||||
return $x->find_all()->count();
|
||||
}
|
||||
|
||||
public function where_active() {
|
||||
return $this->where($this->_table_name.'.active','=',TRUE);
|
||||
}
|
||||
|
||||
public function where_startstop($date,$date_end,$start='date_start',$stop='date_stop') {
|
||||
if (array_key_exists('priority',$this->table_columns()))
|
||||
$this->order_by('priority','ASC');
|
||||
|
||||
return $this
|
||||
->where_open()
|
||||
->where_open()->where($start,'<=',$date)->and_where($stop,'>=',$date)->where_close()
|
||||
->or_where_open()->where($start,'<=',$date_end)->and_where($stop,'>=',$date_end)->where_close()
|
||||
->or_where_open()->where($start,'is',NULL)->where_open()->where($stop,'is',NULL)->or_where($stop,'>=',$date)->where_close()->where_close()
|
||||
->or_where_open()->where($stop,'is',NULL)->where_open()->where($start,'is',NULL)->or_where($start,'<=',$date_end)->where_close()->where_close()
|
||||
->where_close()
|
||||
->order_by($start,'ASC')
|
||||
->order_by($stop,'ASC');
|
||||
}
|
||||
}
|
||||
?>
|
@ -1,28 +0,0 @@
|
||||
<?php defined('SYSPATH') or die('No direct access allowed.');
|
||||
|
||||
/**
|
||||
* Request. Uses the [Route] class to determine what
|
||||
* [Controller] to send the request to.
|
||||
*
|
||||
* @package Membership Database
|
||||
* @category Modifications
|
||||
* @author Deon George
|
||||
* @copyright (c) 2014 Deon George
|
||||
* @license http://dev.leenooks.net/license.html
|
||||
*/
|
||||
class Request extends lnApp_Request {
|
||||
/**
|
||||
* Get our Module_Method object for this request
|
||||
*/
|
||||
public function mmo() {
|
||||
static $result = FALSE;
|
||||
|
||||
if (is_null($result) OR $result)
|
||||
return $result;
|
||||
|
||||
$result = NULL;
|
||||
|
||||
return ($result = ORM::factory('Module_Method')->request_mmo($this));
|
||||
}
|
||||
}
|
||||
?>
|
@ -1,50 +0,0 @@
|
||||
<?php defined('SYSPATH') or die('No direct access allowed.');
|
||||
|
||||
/**
|
||||
* This class is for Site Information
|
||||
*
|
||||
* @package Membership Database
|
||||
* @category Helpers
|
||||
* @author Deon George
|
||||
* @copyright (c) 2014 Deon George
|
||||
* @license http://dev.leenooks.net/license.html
|
||||
*/
|
||||
class Site extends lnApp_Site {
|
||||
private static $_weekstart = 'monday'; // @todo Move into setup table
|
||||
private static $_weekend = 'sunday'; // @todo Move into setup table
|
||||
|
||||
/**
|
||||
* Show a date using a site configured format
|
||||
*/
|
||||
public static function Date($date) {
|
||||
return (is_null($date) OR ! $date) ? '' : date(Company::instance()->date_format(),$date);
|
||||
}
|
||||
|
||||
public static function DateEndOfWeek($date) {
|
||||
return strtotime(self::$_weekend.' this week',$date);
|
||||
}
|
||||
|
||||
public static function DateStartOfWeek($date) {
|
||||
return strtotime(self::$_weekstart.' this week',$date);
|
||||
}
|
||||
|
||||
/**
|
||||
* Work out our site ID for multihosting
|
||||
*/
|
||||
public static function ID($format=FALSE) {
|
||||
return Company::instance()->site($format);
|
||||
}
|
||||
|
||||
public static function Theme() {
|
||||
// If we are using user admin pages (and login), we'll choose the admin theme.
|
||||
return 'theme/'.(URL::admin_url() ? Kohana::$config->load('config')->theme_admin : Kohana::$config->load('config')->theme);
|
||||
}
|
||||
|
||||
/**
|
||||
* Show a date using a site configured format
|
||||
*/
|
||||
public static function Time($date) {
|
||||
return date(Company::instance()->time_format(),($date ? $date : time()));
|
||||
}
|
||||
}
|
||||
?>
|
@ -1,31 +0,0 @@
|
||||
<?php defined('SYSPATH') or die('No direct access allowed.');
|
||||
|
||||
/**
|
||||
* This is class renders Room Children Status Codes.
|
||||
*
|
||||
* @package Membership Database
|
||||
* @category Helpers
|
||||
* @author Deon George
|
||||
* @copyright (c) 2014 Deon George
|
||||
* @license http://dev.leenooks.net/license.html
|
||||
*/
|
||||
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(
|
||||
'A'=>_('Absent NoShow'),
|
||||
'a'=>_('Absent Notice'),
|
||||
'C'=>_('Casual Placement'),
|
||||
'c'=>_('Casual Request'),
|
||||
'r'=>_('Reduce Days'),
|
||||
'P'=>_('Permanent'),
|
||||
'w'=>_('Waitlist'),
|
||||
);
|
||||
}
|
||||
|
||||
public static function get($value) {
|
||||
return self::factory()->_get($value);
|
||||
}
|
||||
}
|
||||
?>
|
@ -1,44 +0,0 @@
|
||||
<?php defined('SYSPATH') or die('No direct access allowed.');
|
||||
|
||||
/**
|
||||
* This class adds committee support
|
||||
*
|
||||
* @package Membership Database
|
||||
* @category Modifications
|
||||
* @author Deon George
|
||||
* @copyright (c) 2014 Deon George
|
||||
* @license http://dev.leenooks.net/license.html
|
||||
*/
|
||||
class URL extends lnApp_URL {
|
||||
// Our method paths for different functions
|
||||
public static $method_directory = array(
|
||||
'admin'=>'a',
|
||||
'director'=>'d',
|
||||
'committee'=>'c',
|
||||
'user'=>'u',
|
||||
);
|
||||
|
||||
public static function navbar() {
|
||||
$result = array();
|
||||
|
||||
foreach (array_reverse(self::$method_directory) as $k=>$v)
|
||||
switch ($k) {
|
||||
case 'admin': $result[$k] = array('name'=>'Administrator','icon'=>'fa-globe');
|
||||
break;
|
||||
|
||||
case 'director': $result[$k] = array('name'=>'Director','icon'=>'fa-th-list');
|
||||
break;
|
||||
|
||||
case 'committee': $result[$k] = array('name'=>'Committee','icon'=>'fa-th-list');
|
||||
break;
|
||||
|
||||
case 'user': $result[$k] = array('name'=>Auth::instance()->get_user()->name(),'icon'=>'fa-user');
|
||||
break;
|
||||
|
||||
default: $result[$k] = array('name'=>$k,'icon'=>'fa-question');
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
?>
|
@ -1,9 +0,0 @@
|
||||
<?php defined('SYSPATH') OR die('No direct access allowed.');
|
||||
|
||||
return array
|
||||
(
|
||||
'appname' => 'Membership Database',
|
||||
'language' => 'en_AU',
|
||||
'theme' => 'focusbusiness',
|
||||
'theme_admin' => 'baseadmin',
|
||||
);
|
@ -1,31 +0,0 @@
|
||||
<?php defined('SYSPATH') OR die('No direct access allowed.');
|
||||
|
||||
return array
|
||||
(
|
||||
'default' => array
|
||||
(
|
||||
'type' => 'MySQL',
|
||||
'connection' => array(
|
||||
/**
|
||||
* The following options are available for MySQL:
|
||||
*
|
||||
* string hostname server hostname, or socket
|
||||
* string database database name
|
||||
* string username database username
|
||||
* string password database password
|
||||
* boolean persistent use persistent connections?
|
||||
* array variables system variables as "key => value" pairs
|
||||
*
|
||||
* Ports and sockets may be appended to the hostname.
|
||||
*/
|
||||
'hostname' => 'mysql.leenooks.vpn',
|
||||
'database' => 'weblnebcccmdb',
|
||||
'username' => 'ln-ebccc',
|
||||
'password' => 'ebccc',
|
||||
'persistent' => TRUE,
|
||||
),
|
||||
'table_prefix' => 'mdb_',
|
||||
'charset' => 'utf8',
|
||||
'caching' => TRUE,
|
||||
),
|
||||
);
|
@ -1,27 +0,0 @@
|
||||
<?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',
|
||||
),
|
||||
);
|
||||
?>
|
@ -1,65 +0,0 @@
|
||||
<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 Confirm</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>
|
@ -1,64 +0,0 @@
|
||||
<tr>
|
||||
<?php echo Form::hidden(sprintf('room[%s][id]',$row),$rco->id); ?>
|
||||
|
||||
<td><?php
|
||||
switch ($type) {
|
||||
case 'r':
|
||||
echo ' ';
|
||||
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 : ?>
|
||||
|
||||
<?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>
|
@ -1,65 +0,0 @@
|
||||
<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">
|
||||
<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="text-center">Start Date</th>
|
||||
<th class="text-center">End Date</th>
|
||||
</tr>
|
||||
</thead>
|
||||
|
||||
<tbody>
|
||||
<?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>
|
||||
|
||||
<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>
|
@ -1,66 +0,0 @@
|
||||
<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 ' ';
|
||||
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 : ?>
|
||||
|
||||
<?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>
|
@ -1,44 +0,0 @@
|
||||
<div class="col-md-12">
|
||||
|
||||
<?php
|
||||
echo View::factory('field/select')->set('data',['field'=>'room[id]','value'=>ORM::factory('Rooms')->where_external()->list_select(),'default'=>$room_id,'text'=>'Program','class'=>'col-md-4']);
|
||||
?>
|
||||
<fieldset>
|
||||
<legend>Child Details</legend>
|
||||
|
||||
<?php
|
||||
echo View::factory('field/text')->set('data',['field'=>'child[first_name]','value'=>$co->first_name,'text'=>'First Name','class'=>'col-md-5']);
|
||||
echo View::factory('field/text')->set('data',['field'=>'child[family_name]','value'=>$co->family_name,'text'=>'Last Name','class'=>'col-md-5']);
|
||||
echo View::factory('field/date')->set('data',['field'=>'child[dob]','value'=>$co->dob ? $co->dob : time(),'text'=>'Date of Birth','enddate'=>'new Date()']);
|
||||
?>
|
||||
|
||||
</fieldset>
|
||||
|
||||
<fieldset>
|
||||
<legend>Parent Details</legend>
|
||||
|
||||
<?php
|
||||
echo View::factory('field/text')->set('data',['field'=>'account[first_name]','value'=>$ao->first_name,'text'=>'First Name','class'=>'col-md-5']);
|
||||
echo View::factory('field/text')->set('data',['field'=>'account[last_name]','value'=>$ao->last_name,'text'=>'Last Name','class'=>'col-md-5']);
|
||||
echo View::factory('field/text')->set('data',['field'=>'account[email]','value'=>$ao->email,'text'=>'Email','class'=>'col-md-5']);
|
||||
echo View::factory('field/text')->set('data',['field'=>'account[address1]','value'=>$ao->address1,'text'=>'Address','class'=>'col-md-5']);
|
||||
echo View::factory('field/text')->set('data',['field'=>'account[address2]','value'=>$ao->address2,'text'=>'Address','class'=>'col-md-5']);
|
||||
echo View::factory('field/text')->set('data',['field'=>'account[city]','value'=>$ao->city,'text'=>'City','class'=>'col-md-5']);
|
||||
echo View::factory('field/text')->set('data',['field'=>'account[state]','value'=>$ao->state ? $ao->state : 'Vic','text'=>'State','class'=>'col-md-1']);
|
||||
echo View::factory('field/text')->set('data',['field'=>'account[zip]','value'=>$ao->zip,'text'=>'Post Code','class'=>'col-md-1']);
|
||||
?>
|
||||
<input type="hidden" name="account[language_id]" value="1">
|
||||
<input type="hidden" name="account[country_id]" value="61">
|
||||
<input type="hidden" name="year" value="<?php echo $year; ?>">
|
||||
<input type="hidden" name="child[date_reg]" value="<?php echo time(); ?>">
|
||||
</fieldset>
|
||||
|
||||
<?php #@todo This should be in a database ?>
|
||||
<hr>
|
||||
<p>Thank you for your enrolment. An enrolment application of $10 will be invoiced to the email address you have included above.<p>
|
||||
<p>This fee must be paid within 2 days for your application to be accepted. Paying this fee via the method in the email will also confirm that your email address is correct.<p>
|
||||
<p>We send all correspondence via email, so if you change your email, or dont recieve the enrolment application invoice via email, please contact us.<p>
|
||||
<p>This application will be automatically deleted in 2 days if your payment has not been received.
|
||||
|
||||
<?php echo View::factory('field/submit'); ?>
|
||||
</div>
|
@ -1,8 +0,0 @@
|
||||
<div class="col-md-12">
|
||||
|
||||
<?php
|
||||
echo View::factory('field/select')->set('data',['field'=>'year','value'=>ORM::factory('Site_Dates')->list_years(),'default'=>date('Y',time()),'text'=>'Year','class'=>'col-md-4']);
|
||||
?>
|
||||
|
||||
<?php echo View::factory('field/submit'); ?>
|
||||
</div>
|
@ -1,146 +0,0 @@
|
||||
<fieldset>
|
||||
<legend>Room Summary next <?php echo $days; ?> Days</legend>
|
||||
|
||||
<div class="form-group">
|
||||
<label class="col-md-2 control-label" for="Title">Select Date</label>
|
||||
<div class="col-md-2">
|
||||
<div class="input-group date" id="date" data-date="<?php echo $x=Site::date($date); ?>" data-date-format="dd-mm-yyyy" data-date-autoclose="true" data-provide="datepicker">
|
||||
<?php echo Form::input('date',$x,array('id'=>'caldate','class'=>'form-control','required','nocg'=>TRUE,'readonly','onchange'=>'submit()')); ?>
|
||||
<span class="input-group-addon"><i class="fa fa-calendar"></i></span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<br/>
|
||||
|
||||
<table class="table table-striped table-condensed table-hover">
|
||||
<thead>
|
||||
<tr>
|
||||
<th colspan="2"> </th>
|
||||
<th><?php echo HTML::anchor(sprintf('%s?date=%s',$uri,date('d-m-Y',$date-86400*7)),'<<'); ?></th>
|
||||
|
||||
<?php foreach (array_keys($open_dates) as $day) : ?>
|
||||
<th class="text-right"><?php printf('%s (%s)',Site::date($day),date('D',$day)); ?></th>
|
||||
<?php endforeach ?>
|
||||
|
||||
<th><?php echo HTML::anchor(sprintf('%s?date=%s',$uri,date('d-m-Y',$date+86400*7)),'>>'); ?></th>
|
||||
</tr>
|
||||
</thead>
|
||||
|
||||
<tbody>
|
||||
<!-- Site Open -->
|
||||
<tr>
|
||||
<th colspan="2">Open</th>
|
||||
<th> </th>
|
||||
|
||||
<?php foreach (array_keys($open_dates) as $day) : ?>
|
||||
<td class="text-right"><?php echo StaticList_YesNo::factory()->get(isset($open_dates[$day]) ? $open_dates[$day] : FALSE,TRUE); ?></td>
|
||||
<?php endforeach ?>
|
||||
|
||||
<th> </th>
|
||||
</tr>
|
||||
|
||||
<!-- Total Places -->
|
||||
<tr>
|
||||
<th colspan="2">Total</th>
|
||||
<th> </th>
|
||||
|
||||
<?php foreach (array_keys($total_places) as $day) : ?>
|
||||
<td class="text-right"><?php echo $total_places[$day]; ?></td>
|
||||
<?php endforeach ?>
|
||||
|
||||
<th> </th>
|
||||
</tr>
|
||||
|
||||
<!-- Available Places -->
|
||||
<tr class="info">
|
||||
<th colspan="2">Availability</th>
|
||||
<th> </th>
|
||||
|
||||
<?php foreach (array_keys($available_places) as $day) : ?>
|
||||
<td class="text-right"><?php echo $available_places[$day]; ?></td>
|
||||
<?php endforeach ?>
|
||||
|
||||
<th> </th>
|
||||
</tr>
|
||||
|
||||
<!-- Unprocessed Waitlists -->
|
||||
<tr class="danger">
|
||||
<th colspan="2">New Applications</th>
|
||||
<th> </th>
|
||||
|
||||
<?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 ?>
|
||||
|
||||
<th> </th>
|
||||
</tr>
|
||||
|
||||
<!-- Breakdown for each Room -->
|
||||
<?php foreach ($r as $ro) : ?>
|
||||
<tr><th colspan="<?php echo $days+4; ?>"> </th></tr>
|
||||
|
||||
<tr><th colspan="2"><?php echo $ro->display('name'); ?></th><th colspan="<?php echo $days+2; ?>"> </th></tr>
|
||||
|
||||
<!-- Capacity -->
|
||||
<tr>
|
||||
<td> </td>
|
||||
<td>Capacity</td>
|
||||
<td> </td>
|
||||
<td class="text-right"><?php echo join('</td><td class="text-right">',array_values($ro->availability_dates($date,$days))); ?></td>
|
||||
<th> </th>
|
||||
</tr>
|
||||
|
||||
<?php foreach (array(
|
||||
'P'=>'Permanent',
|
||||
'a'=>'Absent',
|
||||
'C'=>'Casual',
|
||||
) as $code => $title) : ?>
|
||||
|
||||
<tr>
|
||||
<td> </td>
|
||||
<td><?php echo HTML::anchor(URL::link('director',sprintf('room/list/%s:%s:%s:7',$ro->id,$date,$code)),$title); ?></td>
|
||||
<td> </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> </th>
|
||||
</tr>
|
||||
<?php endforeach ?>
|
||||
|
||||
<tr><th colspan="<?php echo $days+4; ?>"> </th></tr>
|
||||
|
||||
<!-- Waitlist -->
|
||||
<tr class="danger">
|
||||
<td> </td>
|
||||
<td><?php echo HTML::anchor(URL::link('director','room/list/'.$ro->id.':'.$date.':w:7'),'Waitlist'); ?></td>
|
||||
<td> </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> </th>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td> </td>
|
||||
<td><?php echo HTML::anchor(URL::link('director','room/list/'.$ro->id.':'.$date.':w:7'),'Casual Request'); ?></td>
|
||||
<td> </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> </th>
|
||||
</tr>
|
||||
|
||||
<!-- Availability -->
|
||||
<tr class="info">
|
||||
<td> </td>
|
||||
<td>Availability</td>
|
||||
<td> </td>
|
||||
<?php foreach (array_values($ro->room_availablity($date,$days)) as $x) : ?>
|
||||
<td class="text-right"><?php echo $x; ?></td>
|
||||
<?php endforeach ?>
|
||||
<th> </th>
|
||||
</tr>
|
||||
<?php endforeach ?>
|
||||
</tbody>
|
||||
</table>
|
||||
</fieldset>
|
@ -1,15 +0,0 @@
|
||||
<div class="col-md-12">
|
||||
|
||||
<fieldset>
|
||||
<legend>Configure New Date Parameters</legend>
|
||||
|
||||
<?php
|
||||
echo View::factory('field/select')->set('data',['field'=>'code','value'=>Arr::Merge([''=>''],$o->codes()),'text'=>'Code','default'=>$o->code,'class'=>'col-md-4']);
|
||||
echo View::factory('field/date')->set('data',['field'=>'date_start','value'=>$o->date_start ? $o->date_start : time(),'text'=>'Date Start']);
|
||||
echo View::factory('field/date')->set('data',['field'=>'date_stop','value'=>$o->date_stop ? $o->date_stop : time(),'text'=>'Date Stop']);
|
||||
?>
|
||||
|
||||
</fieldset>
|
||||
|
||||
<?php echo View::factory('field/submit'); ?>
|
||||
</div>
|
@ -1,14 +0,0 @@
|
||||
<!-- o = Array of Model_Site_Date -->
|
||||
<?php echo Table::factory()
|
||||
->page_items(50)
|
||||
->data($o)
|
||||
->columns(array(
|
||||
'id'=>'ID',
|
||||
'code'=>'Code',
|
||||
'date_start'=>'Date Start',
|
||||
'date_stop'=>'Date End',
|
||||
))
|
||||
->prepend(array(
|
||||
'id'=>array('url'=>URL::link('admin','site_date/edit/')),
|
||||
));
|
||||
?>
|
@ -1,3 +0,0 @@
|
||||
<div class="shortcuts">
|
||||
<a href="<?php echo URL::link('user','child/add',TRUE); ?>" class="shortcut"><i class="shortcut-icon fa fa-list-alt"></i><span class="shortcut-label">Register Child</span></a>
|
||||
</div>
|
@ -1 +0,0 @@
|
||||
Subproject commit 898371c849356932afe44d00f29f881430792c46
|
131
index.php
131
index.php
@ -1,131 +0,0 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* The directory in which your application specific resources are located.
|
||||
* The application directory must contain the bootstrap.php file.
|
||||
*
|
||||
* @link http://kohanaframework.org/guide/about.install#application
|
||||
*/
|
||||
$application = 'application';
|
||||
|
||||
/**
|
||||
* The directory in which your modules are located.
|
||||
*
|
||||
* @link http://kohanaframework.org/guide/about.install#modules
|
||||
*/
|
||||
$modules = 'modules';
|
||||
|
||||
/**
|
||||
* The directory in which upstream Kohana resources (modules) are located.
|
||||
*/
|
||||
$sysmodules = 'includes/kohana/modules';
|
||||
|
||||
/**
|
||||
* The directory in which the Kohana resources are located. The system
|
||||
* directory must contain the classes/kohana.php file.
|
||||
*
|
||||
* @link http://kohanaframework.org/guide/about.install#system
|
||||
*/
|
||||
$system = 'includes/kohana/system';
|
||||
|
||||
/**
|
||||
* The default extension of resource files. If you change this, all resources
|
||||
* must be renamed to use the new extension.
|
||||
*
|
||||
* @link http://kohanaframework.org/guide/about.install#ext
|
||||
*/
|
||||
define('EXT', '.php');
|
||||
|
||||
/**
|
||||
* Set the PHP error reporting level. If you set this in php.ini, you remove this.
|
||||
* @link http://www.php.net/manual/errorfunc.configuration#ini.error-reporting
|
||||
*
|
||||
* When developing your application, it is highly recommended to enable notices
|
||||
* and strict warnings. Enable them by using: E_ALL | E_STRICT
|
||||
*
|
||||
* In a production environment, it is safe to ignore notices and strict warnings.
|
||||
* Disable them by using: E_ALL ^ E_NOTICE
|
||||
*
|
||||
* When using a legacy application with PHP >= 5.3, it is recommended to disable
|
||||
* deprecated notices. Disable with: E_ALL & ~E_DEPRECATED
|
||||
*/
|
||||
error_reporting(E_ALL | E_STRICT);
|
||||
|
||||
/**
|
||||
* End of standard configuration! Changing any of the code below should only be
|
||||
* attempted by those with a working knowledge of Kohana internals.
|
||||
*
|
||||
* @link http://kohanaframework.org/guide/using.configuration
|
||||
*/
|
||||
|
||||
// Set the full path to the docroot
|
||||
define('DOCROOT', realpath(dirname(__FILE__)).DIRECTORY_SEPARATOR);
|
||||
|
||||
// Make the application relative to the docroot, for symlink'd index.php
|
||||
if ( ! is_dir($application) AND is_dir(DOCROOT.$application))
|
||||
$application = DOCROOT.$application;
|
||||
|
||||
// Make the modules relative to the docroot, for symlink'd index.php
|
||||
if ( ! is_dir($modules) AND is_dir(DOCROOT.$modules))
|
||||
$modules = DOCROOT.$modules;
|
||||
|
||||
// Make the system relative to the docroot, for symlink'd index.php
|
||||
if ( ! is_dir($sysmodules) AND is_dir(DOCROOT.$sysmodules))
|
||||
$sysmodules = DOCROOT.$sysmodules;
|
||||
|
||||
// Make the system relative to the docroot, for symlink'd index.php
|
||||
if ( ! is_dir($system) AND is_dir(DOCROOT.$system))
|
||||
$system = DOCROOT.$system;
|
||||
|
||||
// Define the absolute paths for configured directories
|
||||
define('APPPATH', realpath($application).DIRECTORY_SEPARATOR);
|
||||
define('MODPATH', realpath($modules).DIRECTORY_SEPARATOR);
|
||||
define('SMDPATH', realpath($sysmodules).DIRECTORY_SEPARATOR);
|
||||
define('SYSPATH', realpath($system).DIRECTORY_SEPARATOR);
|
||||
|
||||
// Clean up the configuration vars
|
||||
unset($application, $modules, $sysmodules, $system);
|
||||
|
||||
if (file_exists('install'.EXT))
|
||||
{
|
||||
// Load the installation check
|
||||
return include 'install'.EXT;
|
||||
}
|
||||
|
||||
/**
|
||||
* Define the start time of the application, used for profiling.
|
||||
*/
|
||||
if ( ! defined('KOHANA_START_TIME'))
|
||||
{
|
||||
define('KOHANA_START_TIME', microtime(TRUE));
|
||||
}
|
||||
|
||||
/**
|
||||
* Define the memory usage at the start of the application, used for profiling.
|
||||
*/
|
||||
if ( ! defined('KOHANA_START_MEMORY'))
|
||||
{
|
||||
define('KOHANA_START_MEMORY', memory_get_usage());
|
||||
}
|
||||
|
||||
// Bootstrap the application
|
||||
require APPPATH.'bootstrap'.EXT;
|
||||
|
||||
if (PHP_SAPI == 'cli') // Try and load minion
|
||||
{
|
||||
class_exists('Minion_Task') OR die('Please enable the Minion module for CLI support.');
|
||||
set_exception_handler(array('Minion_Exception', 'handler'));
|
||||
|
||||
Minion_Task::factory(Minion_CLI::options())->execute();
|
||||
}
|
||||
else
|
||||
{
|
||||
/**
|
||||
* Execute the main request. A source of the URI can be passed, eg: $_SERVER['PATH_INFO'].
|
||||
* If no source is specified, the URI will be automatically detected.
|
||||
*/
|
||||
echo Request::factory(TRUE, array(), FALSE)
|
||||
->execute()
|
||||
->send_headers(TRUE)
|
||||
->body();
|
||||
}
|
@ -1 +0,0 @@
|
||||
Subproject commit f5bc5dfa296a1517ebdb29b2dd0f81b09f136b6a
|
@ -1 +0,0 @@
|
||||
Subproject commit ceb8159826a20dc11e4df61e036dfa9a2d2e3d73
|
Reference in New Issue
Block a user