116 lines
3.9 KiB
PHP
116 lines
3.9 KiB
PHP
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
|
|
class Ondersteuning extends MY_Controller{
|
|
|
|
function __construct(){
|
|
parent::__construct();
|
|
$models = array( "shared/Users_model",
|
|
"monpas/Ondersteuningtijden_model",
|
|
"monpas/Groepen_model");
|
|
$this->load->model($models);
|
|
$this->load->helper('string');
|
|
if ( ! $this->check_online_status() ) {
|
|
echo json_encode( array('offline' => TRUE) );
|
|
die;
|
|
};// if
|
|
}
|
|
|
|
function getgroepen(){
|
|
if (!$this->userid) die;
|
|
$orgid = $this->clean_input('orgID');
|
|
$schooljaarnr = $this->clean_input('schooljaar');
|
|
$module = $this->clean_input('module');
|
|
$groepen = $this->Groepen_model->getgroepenlist($orgid, $schooljaarnr, $module);
|
|
echo json_encode($groepen);
|
|
}
|
|
|
|
function getgroepenso(){
|
|
if (!$this->userid) die;
|
|
$orgid = $this->uri->segment(4);
|
|
$schooljaarnr = $this->uri->segment(5);
|
|
$groepen = $this->Groepen_model->getgroepenSboSo($orgid, $schooljaarnr);
|
|
|
|
echo json_encode($groepen);
|
|
}
|
|
|
|
function meldondersteuning(){
|
|
if (!$this->userid) die;
|
|
$schoolid = $this->clean_input('schoolid');
|
|
$schooljaarnr = $this->clean_input('schooljaar');
|
|
$module = $this->clean_input('module');
|
|
$ondersteuning = $this->clean_input('ondersteuning');
|
|
if($schoolid && $schooljaarnr && $module){
|
|
$groepsIDs = $this->Groepen_model->getgroepsids($schoolid, $schooljaarnr, $module);
|
|
if($groepsIDs){
|
|
foreach($groepsIDs AS $groepsID){
|
|
$this->Groepen_model->update_record(array("ondersteuning" => $ondersteuning), $groepsID->id);
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
echo json_encode('gelukt');
|
|
}
|
|
|
|
function gettijden(){
|
|
if (!$this->userid) die;
|
|
$groepid = $this->uri->segment(4);
|
|
|
|
$dagen=array( ['dagnr'=> 1,'dag' => 'maandag', 'minutenG'=>0, 'minutenS'=> 0,'minutenI'=> 0],
|
|
['dagnr'=> 2,'dag' => 'dinsdag', 'minutenG'=>0, 'minutenS'=> 0,'minutenI'=> 0],
|
|
['dagnr'=> 3,'dag' => 'woensdag', 'minutenG'=>0, 'minutenS'=> 0,'minutenI'=> 0],
|
|
['dagnr'=> 4,'dag' => 'donderdag', 'minutenG'=>0, 'minutenS'=> 0,'minutenI'=> 0],
|
|
['dagnr'=> 5,'dag' => 'vrijdag', 'minutenG'=>0, 'minutenS'=> 0,'minutenI'=> 0]);
|
|
for($i=0;$i<count($dagen);$i++){
|
|
$minuten = $this->Ondersteuningtijden_model->getminuten($groepid, $dagen[$i]['dagnr'],'G');
|
|
|
|
if ($minuten){
|
|
$dagen[$i]['minutenG']= $minuten;
|
|
};
|
|
|
|
$minuten = $this->Ondersteuningtijden_model->getminuten($groepid, $dagen[$i]['dagnr'],'S');
|
|
if ($minuten){
|
|
$dagen[$i]['minutenS']= $minuten;};
|
|
|
|
$minuten = $this->Ondersteuningtijden_model->getminuten($groepid, $dagen[$i]['dagnr'],'I');
|
|
if ($minuten){$dagen[$i]['minutenI']= $minuten;};
|
|
}
|
|
echo json_encode($dagen);
|
|
}
|
|
|
|
function saveondersteuning(){
|
|
$ondersteuning = $this->clean_input('ondersteuning');
|
|
$orgid = $this->clean_input('orgid');
|
|
$schooljaar = $this->clean_input('schooljaar');
|
|
|
|
$groepen = $this->Groepen_model->getgroepenSboSo($orgid, $schooljaar);
|
|
if ($groepen) {
|
|
foreach ($groepen as $groep) {
|
|
$this->Groepen_model->update_record_where(['ondersteuning' => $ondersteuning], ['id' => $groep->id]);
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
function insertorupdatetijd(){
|
|
if (!$this->userid) die;
|
|
$where= array( "groep_id" =>$this->clean_input('groepid'),
|
|
"dagnr" =>$this->clean_input('dagnr'),
|
|
"soort" =>$this->clean_input('soort') );
|
|
|
|
$tijd = $this->Ondersteuningtijden_model->get_records_where($where, true);
|
|
if ($tijd){
|
|
$this->Ondersteuningtijden_model->update_record(array("minuten" =>$this->clean_input('minuten')), $tijd->id);
|
|
}
|
|
else{
|
|
$where['organisatie_id'] = $this->clean_input('orgid');
|
|
$where['minuten'] = $this->clean_input('minuten');
|
|
|
|
$this->Ondersteuningtijden_model->insert_record($where);
|
|
}
|
|
}
|
|
}
|