Files
monpas/application/controllers/Toner.php
T
2023-02-27 09:44:33 +01:00

104 lines
3.3 KiB
PHP

<?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
$org = $this->Organisaties_model->get_record_by_id($this->globorgid);
$menu = $this->Menus_model->getmenu($module,$this->userrole, $org->soort);
};
if ($menu){
foreach($menu as $menuitem){
$menuitem->submenus=$this->Menus_model->getsubmenus($menuitem->id, $this->userrole, $org->soort);
}
}
$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 ==2){
$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);
}
}
}
}