Merge branch 'feature/archiefoptie-ondersteuningsvorm' into develop

This commit is contained in:
2026-02-03 14:33:50 +01:00
7 changed files with 413 additions and 52 deletions
+135 -25
View File
@@ -63,10 +63,19 @@ class Groepen extends MY_Controller{
$groep->ondersteuningsvormen = $this->Ondersteuningsvormen_model->getvormen($orgid, $minnivo, $maxnivo);
if ($groep->ondersteuningsvormen){
foreach($groep->ondersteuningsvormen as $ondersteuningsvorm){
// hier get aantal
$ax = $this->Aantalxondersteuningsvorm_model->getaantal($groepid, $ondersteuningsvorm->id);
if ($ax){ $ondersteuningsvorm->aantal = $ax->aantal; }
else{ $ondersteuningsvorm->aantal =0; };
$aantal = 0;
$archief = 'F';
$details = $this->Aantalxondersteuningsvorm_model->getdetails($groepid, $ondersteuningsvorm->id);
if($details) {
if ($details->aantal) $aantal = $details->aantal;
if ($details->archief) $archief = $details->archief;
}
$ondersteuningsvorm->aantal = $aantal;
$ondersteuningsvorm->archief = $archief;
$gebruikt = $this->Aantalxondersteuningsvorm_model->aantalGebruikt($orgid, $groepid, $ondersteuningsvorm->id);
$ondersteuningsvorm->gebruikt = $gebruikt > 0 ? 'T' : 'F';
}
}
echo json_encode($groep);
@@ -126,53 +135,120 @@ class Groepen extends MY_Controller{
echo json_encode($groep);
}
function insertorupdateOS(){
//TODO clean input
if(!$this->userid) die;
$osid = $this->clean_input('id');
$orgid = $this->clean_input("orgid");
$aantal = $this->clean_input('aantal');
if (($osid == 0 || $osid == null) &&($aantal > 0)) {
$data=array("organisatie_id" => $orgid,
"naam" => $this->clean_input("naam"),
"nivo" => $this->clean_input('nivo')
$osid = $this->clean_input('id');
$orgid = $this->clean_input("orgid");
$aantal = $this->clean_input('aantal');
$archief = $this->clean_input('archief');
if ($archief !== 'T') $archief = 'F';
if (($osid == 0 || $osid == null) && ($aantal > 0)) {
$data = array(
"organisatie_id" => $orgid,
"naam" => $this->clean_input("naam"),
"nivo" => $this->clean_input('nivo')
);
$osid = $this->Ondersteuningsvormen_model->insert_record($data);
}
else {
if ($orgid > 0){
$data=array("naam" => $this->clean_input('naam'));
$data = array("naam" => $this->clean_input('naam'));
$this->Ondersteuningsvormen_model->update_record($data, $osid);
}
// update name
}
$data2= array("organisatie_id" => $orgid,
"groep_id" => $this->clean_input('groepid'),
"ondersteuningsvorm_id" => $osid);
$aos =$this->Aantalxondersteuningsvorm_model->get_records_where($data2, TRUE);
$data2 = array(
"organisatie_id" => $orgid,
"groep_id" => $this->clean_input('groepid'),
"ondersteuningsvorm_id" => $osid
);
$aos = $this->Aantalxondersteuningsvorm_model->get_records_where($data2, TRUE);
if($aos){
if ($this->clean_input('aantal') == 0) {
//delete de regel
if ($aantal == 0 && $archief !== 'T') {
// delete alleen als het niet gearchiveerd is
$this->Aantalxondersteuningsvorm_model->delete_record($aos->id);
}
else {
// update de regel
$data=array( "aantal" => $this->clean_input('aantal') );
// update de regel (ook archief opslaan)
$data = array(
"aantal" => $aantal,
"archief" => $archief
);
$this->Aantalxondersteuningsvorm_model->update_record($data, $aos->id);
}
}
else{
if ($this->clean_input('aantal') > 0){
$data = array( "organisatie_id" => $orgid,
"groep_id" => $this->clean_input('groepid'),
"ondersteuningsvorm_id" => $osid,
"aantal" => $this->clean_input('aantal'));
// record bestaat nog niet: maak hem aan als er aantal > 0 is OF als het archief is
if ($aantal > 0 || $archief === 'T'){
$data = array(
"organisatie_id" => $orgid,
"groep_id" => $this->clean_input('groepid'),
"ondersteuningsvorm_id" => $osid,
"aantal" => $aantal,
"archief" => $archief
);
$aantalid = $this->Aantalxondersteuningsvorm_model->insert_record($data);
}
}
echo json_encode($osid);
}
// function insertorupdateOS(){
// //TODO clean input
// if(!$this->userid) die;
// $osid = $this->clean_input('id');
// $orgid = $this->clean_input("orgid");
// $aantal = $this->clean_input('aantal');
// if (($osid == 0 || $osid == null) &&($aantal > 0)) {
// $data=array("organisatie_id" => $orgid,
// "naam" => $this->clean_input("naam"),
// "nivo" => $this->clean_input('nivo')
// );
// $osid = $this->Ondersteuningsvormen_model->insert_record($data);
// }
// else {
// if ($orgid > 0){
// $data=array("naam" => $this->clean_input('naam'));
// $this->Ondersteuningsvormen_model->update_record($data, $osid);
// }
// // update name
// }
// $data2= array("organisatie_id" => $orgid,
// "groep_id" => $this->clean_input('groepid'),
// "ondersteuningsvorm_id" => $osid);
// $aos =$this->Aantalxondersteuningsvorm_model->get_records_where($data2, TRUE);
// if($aos){
// if ($this->clean_input('aantal') == 0) {
// //delete de regel
// $this->Aantalxondersteuningsvorm_model->delete_record($aos->id);
// }
// else {
// // update de regel
// $data=array( "aantal" => $this->clean_input('aantal') );
// $this->Aantalxondersteuningsvorm_model->update_record($data, $aos->id);
// }
// }
// else{
// if ($this->clean_input('aantal') > 0){
// $data = array( "organisatie_id" => $orgid,
// "groep_id" => $this->clean_input('groepid'),
// "ondersteuningsvorm_id" => $osid,
// "aantal" => $this->clean_input('aantal'));
// $aantalid = $this->Aantalxondersteuningsvorm_model->insert_record($data);
// }
// }
// echo json_encode($osid);
// }
function getgroepen(){
if (!$this->userid) die;
$orgid = $this->clean_input('schoolID');
@@ -240,6 +316,40 @@ class Groepen extends MY_Controller{
$this->Aantalxondersteuningsvorm_model->delete_record_where(array("ondersteuningsvorm_id" => $osid));
$this->Ondersteuningsvormen_model->delete_record($osid);
}
function archiveerOS(){
if (!$this->userid) die;
if (!$this->writer) return;
$vormID = $this->clean_input('vormID');
$groepID = $this->clean_input('groepID');
$orgID = $this->clean_input('orgID');
$axovID =$this->Aantalxondersteuningsvorm_model->get_fieldvalue(["ondersteuningsvorm_id"=> $vormID, "groep_id" => $groepID], "id");
if ($axovID) $this->Aantalxondersteuningsvorm_model->update_record(["archief"=> 'T', "aantal"=> 0], $axovID);
else $data = [ 'organisatie_id' => $orgID,
'groep_id' => $groepID,
'ondersteuningsvorm_id' => $vormID,
'archief' => 'T',
'aantal' => 0];
$newid = $this->Aantalxondersteuningsvorm_model->insert_record($data);
}
function activeerOS(){
if (!$this->userid) die;
if (!$this->writer) return;
$vormID = $this->clean_input('vormID');
$groepID = $this->clean_input('groepID');
$orgID = $this->clean_input('orgID');
$axovID =$this->Aantalxondersteuningsvorm_model->get_fieldvalue(["ondersteuningsvorm_id"=> $vormID, "groep_id" => $groepID], "id");
if ($axovID) $this->Aantalxondersteuningsvorm_model->update_record(["archief"=> 'F'], $axovID);
else $data = [ 'organisatie_id' => $orgID,
'groep_id' => $groepID,
'ondersteuningsvorm_id' => $vormID,
'archief' => 'T',
'aantal' => 0];
$newid = $this->Aantalxondersteuningsvorm_model->insert_record($data);
}
function getwriter(){
$writer = false;
if ($this->Autorisaties_model->check_autorisatie($this->userrole, 259) > 0){$writer = true;};