initial commit
This commit is contained in:
@@ -0,0 +1,104 @@
|
||||
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
|
||||
|
||||
class Toner extends MY_Controller{
|
||||
|
||||
function __construct(){
|
||||
parent::__construct();
|
||||
$models = array("monpas/Menus_model",
|
||||
"monpas/Labels_model",
|
||||
"shared/Licenties_model",
|
||||
"shared/Schooljaren_model",
|
||||
"shared/Kalenderjaren_model");
|
||||
$this->load->model($models);
|
||||
$this->load->library('partituur/partituur_home');
|
||||
}
|
||||
|
||||
public function index ($page = 'index'){
|
||||
$this->maintenance = false;
|
||||
$allowedIPs = array('95.97.191.15','127.0.0.1', '5.79.76.38');
|
||||
if( $this->maintenance == true && !in_array($this->input->ip_address(), $allowedIPs)){
|
||||
redirect(base_url().'construction');
|
||||
exit;
|
||||
}
|
||||
|
||||
if (!file_exists(APPPATH.'/views/monpas/pages/'.$page.'.php')){
|
||||
show_404();
|
||||
}
|
||||
if( ! $this->session->userdata('userid')){
|
||||
$this->load->view('start.php',base_url());
|
||||
}else{
|
||||
// controleer of er een nieuw schooljaar of kalenderjaar moet worden aangemaakt.
|
||||
$this->setjaren();
|
||||
$module = $this->session->userdata('module');
|
||||
|
||||
if ($module == 20) return $this->partituur_home->index();
|
||||
|
||||
$licenties = null;
|
||||
$licenties = $this->Licenties_model->get_licentie($this->globorgid);
|
||||
$menu = new stdClass;
|
||||
|
||||
if (!$module || 0== $module || -1 >= $module){
|
||||
|
||||
// zet de module altijd op 0 anders kun je niet bij accounts
|
||||
$module = 0;
|
||||
|
||||
//zet de sessie variable
|
||||
$this->Session_model->set_module($module);
|
||||
}
|
||||
if ($module >= 0){
|
||||
// hier wordt het menu opgehaald om de pagina's van de module te laden
|
||||
|
||||
$menu = $this->Menus_model->getmenu($module,$this->userrole);
|
||||
|
||||
};
|
||||
|
||||
if ($menu){
|
||||
foreach($menu as $menuitem){
|
||||
$menuitem->submenus=$this->Menus_model->getsubmenus($menuitem->id, $this->userrole);
|
||||
}
|
||||
}
|
||||
$lbl = array();
|
||||
$lbl=$this->Labels_model->getalllabels();
|
||||
|
||||
$this->load->view('monpas/mainheader.php',array( "pages"=>$menu,
|
||||
"labels" =>$lbl,
|
||||
"versie" =>$this->version,
|
||||
"base_url()"=>base_url() ) );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function setsessionmodule(){
|
||||
$module = $this->uri->segment(3);
|
||||
$this->Session_model->set_module($module);
|
||||
}
|
||||
function setjaren(){
|
||||
$today = date("Y-m-d");
|
||||
$month = date("n",strtotime($today));
|
||||
$year = date("Y", strtotime($today));
|
||||
|
||||
if ($month ==4){
|
||||
$schooljaren = $this->Schooljaren_model->getschooljaren();
|
||||
if (date("Y", strtotime($schooljaren[0]->eind)) <= $year){
|
||||
//creeer nieuw schooljaar
|
||||
$data = array( "schooljaarnr" => $schooljaren[0]->schooljaarnr + 1,
|
||||
"naam" => $year.'-'.($year + 1),
|
||||
"start" => $year.'-08-01',
|
||||
"eind" => ($year + 1).'-07-31');
|
||||
$newid= $this->Schooljaren_model->insert_record($data);
|
||||
}
|
||||
}
|
||||
if ($month >= 11){
|
||||
$kalenderjaren = $this->Kalenderjaren_model->getkalenderjaren();
|
||||
if (date("Y", strtotime($kalenderjaren[0]->tm)) <= $year){
|
||||
//creeer nieuw kalender
|
||||
$data = array( "jaarnr" => $kalenderjaren[0]->jaarnr + 1,
|
||||
"naam" => $year + 1,
|
||||
"van" => ($year + 1).'-01-01',
|
||||
"tm" => ($year + 1).'-12-31');
|
||||
$newid= $this->Kalenderjaren_model->insert_record($data);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user