204 lines
6.9 KiB
PHP
204 lines
6.9 KiB
PHP
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
|
|
|
|
class Compactsop extends MY_Controller{
|
|
|
|
function __construct(){
|
|
parent::__construct();
|
|
$models = array(
|
|
"Docx_model",
|
|
"monpas/Arrangementen_model",
|
|
"monpas/Arrangementen_piv_aantal_model",
|
|
"monpas/Compactsop_model",
|
|
"monpas/Compactsoponderdelen_model",
|
|
"monpas/Diversiteits_model",
|
|
"monpas/Filledversions_model",
|
|
"monpas/Groepen_model",
|
|
"monpas/Ijkpunten_model",
|
|
"monpas/Indicatoren_model",
|
|
"shared/Kalenderjaren_model",
|
|
"shared/Aantalleerlingen_model",
|
|
"shared/Licenties_model",
|
|
"monpas/Menus_model",
|
|
"monpas/Modules_model",
|
|
"monpas/Ondersteuningtijden_model",
|
|
"monpas/Oordelen_model",
|
|
"monpas/Scorekleuren_model",
|
|
"monpas/Orgversies_model",
|
|
"shared/Schooljaren_model",
|
|
"monfin2/Finbestemmingen_model",
|
|
"monpas/Versies_model",
|
|
"Phantom_model",
|
|
"monpas/Scores_model",
|
|
"monpas/Sop_model",
|
|
"monpas/Sopinhouden_model",
|
|
"monpas/Sopviews_model",
|
|
"monpas/Tlvs_model"
|
|
|
|
|
|
|
|
);
|
|
$this->load->model($models);
|
|
$this->load->helper('string');
|
|
}
|
|
|
|
function getrechten(){
|
|
if (!$this->userid) die;
|
|
$editok = false;
|
|
$autorisatie = $this->Autorisaties_model->check_autorisatie($this->userrole,259 );
|
|
|
|
if ( $autorisatie> 0) $editok = true;
|
|
echo json_encode($editok);
|
|
}
|
|
|
|
function getorgsoort(){
|
|
if (!$this->userid) die;
|
|
$orgid = $this->globorgid;
|
|
$soort = $this->Organisaties_model->get_fieldvalue(['id' => $this->globorgid], 'soort');
|
|
echo json_encode($soort);
|
|
}
|
|
|
|
|
|
function getSchooljaren(){
|
|
if (!$this->userid) die;
|
|
$schooljaren = $this->Schooljaren_model->getschooljaren();
|
|
|
|
echo json_encode($schooljaren);
|
|
}
|
|
|
|
function getSchooljarenEnOrgs(){
|
|
if (!$this->userid) die;
|
|
$schooljaren = $this->Schooljaren_model->getschooljaren();
|
|
$orgs = $this->Organisaties_model->get_alle_onderliggende_orgs($this->globorgid);
|
|
|
|
echo json_encode(['schooljaren'=>$schooljaren,
|
|
'organisaties'=>$orgs ]);
|
|
}
|
|
|
|
function getCompactSop(){
|
|
if (!$this->userid) die;
|
|
$orgid = $this->clean_input("orgID");
|
|
$schooljaar = $this->clean_input("schooljaarID");
|
|
$compactsopID = $this->Compactsop_model->get_fieldvalue(['organisatie_id'=>$orgid, 'schooljaarnummer'=>$schooljaar], 'id');
|
|
echo json_encode($compactsopID);
|
|
}
|
|
|
|
function download_pdf(){
|
|
$fileID = $this->uri->segment( 4 );
|
|
$this->Compactsop_model->downloadCompactSop ( $fileID );
|
|
}
|
|
|
|
function getOnderdelenEnVersies(){
|
|
if (!$this->userid) die;
|
|
$schooljaar = $this->clean_input('schooljaarID');
|
|
$orgsoort = $this->clean_input('orgsoort');
|
|
$orgid = $this->clean_input('orgID');
|
|
$compacteversies = new Compacteversies($schooljaar, $orgid, $orgsoort);
|
|
$onderdelen = $compacteversies->getOnderdelen();
|
|
|
|
echo json_encode($onderdelen);
|
|
}
|
|
|
|
function getOrganisatiegegevens(){
|
|
if (!$this->userid) die;
|
|
$orgid = $this->uri->segment(4);
|
|
$school = $this->Schooldetails_model->getschool($orgid);
|
|
if(!$school){
|
|
$school = $this->Organisaties_model->get_record_by_id($orgid);
|
|
}
|
|
echo json_encode($school);
|
|
}
|
|
|
|
function saveSchool(){
|
|
if (!$this->userid) die;
|
|
$id = $this->clean_input('id');
|
|
$straat = strip_slashes($this->clean_input('straat'));
|
|
$plaats = strip_slashes($this->clean_input('plaats'));
|
|
$foon = strip_slashes($this->clean_input('telefoon'));
|
|
$mail = strip_slashes($this->clean_input('email1'));
|
|
$web = strip_slashes($this->clean_input('web'));
|
|
|
|
$data = [
|
|
'straat' => $straat,
|
|
'plaats' => $plaats,
|
|
'telefoon' => $foon,
|
|
'email1' => $mail,
|
|
'web' => $web,
|
|
'organisatie_id' => $id
|
|
];
|
|
|
|
|
|
$this->Organisaties_model->update_record(['plaats' =>$plaats], $id);
|
|
|
|
$detailid = $this->Schooldetails_model->get_fieldvalue(['organisatie_id'=>$id], 'id');
|
|
if($detailid){
|
|
$this->Schooldetails_model->update_record($data,$detailid);
|
|
}
|
|
else{
|
|
$detailid = $this->Schooldetails_model->insert_record($data);
|
|
}
|
|
echo json_encode($detailid);
|
|
}
|
|
|
|
function maakPDF(){
|
|
if (!$this->userid) die;
|
|
$schooljaarnr = $this->clean_input('schooljaarnr');
|
|
$orgid = $this->clean_input('orgID');
|
|
$onderdelen = $this->input->post('onderdelen');
|
|
$omvangjaren = $this->clean_input('jaren');
|
|
$paginas = $this->clean_input('paginas');
|
|
|
|
$compact = new Compacteonderdelen($schooljaarnr, $onderdelen, $omvangjaren, $orgid);
|
|
$compacteonderdelen = $compact->getCompacteOnderdelen();
|
|
$schoolID = $orgid;
|
|
$html = (new Compactepaginas($compacteonderdelen, $paginas))->getHtml();
|
|
$padnaam = $schoolID . $schooljaarnr;
|
|
|
|
file_put_contents(MYROOTPATH.'public/tmp/temp'.$schoolID.$schooljaarnr.'.html', $html);
|
|
|
|
echo json_encode($padnaam);
|
|
}
|
|
|
|
public function uploadLogo($schoolID)
|
|
{
|
|
$savePath = MYROOTPATH.'public/images/logos/';
|
|
$this->load->helper('string');
|
|
$pathParts = pathinfo($_FILES['image_file']['name']);
|
|
$extension = $pathParts['extension'];
|
|
|
|
$filename = random_string('alnum', 15).'.'.$extension;
|
|
$source = $_FILES['image_file']['tmp_name'];
|
|
$target = $savePath.$filename;
|
|
|
|
rename($source, $target );
|
|
chmod($target, '0777');
|
|
|
|
$details = $this->Schooldetails_model->get_records_where(['organisatie_id' => $schoolID]);
|
|
if ($details) {
|
|
$logo = $details['logo'];
|
|
if ($logo) {
|
|
$padNaam = $savePath . $logo;
|
|
unlink($padNaam);
|
|
}
|
|
$this->Schooldetails_model->update_record_where(['logo' => $filename], ['organisatie_id' => $schoolID]);
|
|
} else {
|
|
|
|
$org = $this->Organisaties_model->get_record_by_id($schoolID);
|
|
$this->Schooldetails_model->insert_record([
|
|
'logo' => $filename,
|
|
'organisatie_id' => $schoolID,
|
|
'plaats' => $org->plaats ? $org->plaats : ''
|
|
]);
|
|
}
|
|
}
|
|
|
|
function getLogo(){
|
|
$schoolID = $this->clean_input('schoolID');
|
|
$savePath = MYROOTPATH.'public/images/logos/';
|
|
$logo =$this->Schooldetails_model->getLogo($schoolID);
|
|
// $padNaam = $savePath.$logo;
|
|
|
|
$this->json($logo);
|
|
}
|
|
|
|
}
|