Work on enrolment for Kinder
This commit is contained in:
77
application/classes/Controller/Admin/Site/Date.php
Normal file
77
application/classes/Controller/Admin/Site/Date.php
Normal file
@@ -0,0 +1,77 @@
|
||||
<?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()));
|
||||
}
|
||||
}
|
||||
?>
|
Reference in New Issue
Block a user