diff --git a/application/controllers/shared/Organisaties.php b/application/controllers/shared/Organisaties.php index 4c4e4f6..61659ae 100644 --- a/application/controllers/shared/Organisaties.php +++ b/application/controllers/shared/Organisaties.php @@ -15,6 +15,7 @@ class Organisaties extends MY_Controller{ "monpas/Scores_model", "monpas/Schooldetails_model", "monpas/Ambities_model", + "monpas/Wenssituaties_model", "shared/Licenties_model"); $this->load->model($models); $this->load->helper('string'); @@ -132,6 +133,7 @@ class Organisaties extends MY_Controller{ $this->Ambities_model->delete_record_where(array("organisatie_id"=>$orgid)); $this->Orgversies_model->delete_record_where(array("organisatie_id" =>$orgid)); $this->Licenties_model->delete_record_where(array("orgid" =>$orgid)); + $this->Wenssituaties_model->delete_record_where(["organisatie_id" =>$orgid ]); $this->Organisaties_model->delete_record($orgid); } } @@ -150,7 +152,13 @@ class Organisaties extends MY_Controller{ } else { $actief = 1; - if ($this->input->post("actief")=="false") $actief = 0; + if ($this->input->post("actief")=="false"){ + if($this->input->post("soort")== "4") $actief = 0; + else{ $orgs = $this->Organisaties_model->getorgsonderbestuur($orgid); + if($orgs) $errortekst .= "Deactiveer eerst de actieve organisaties onder deze organisatie."; + else $actief = 0; + } + } // $monbas=1; // if ($this->input->post("monbas")=="false") $monbas = 0; // $mondiv = 1; @@ -189,6 +197,29 @@ class Organisaties extends MY_Controller{ else {$errortekst = " U bent niet geautoriseerd voor deze handeling.";}; echo json_encode($errortekst); } + + function dearchiveer(){ + //TODO clean input + if ($this->Autorisaties_model->check_autorisatie($this->userrole, SUPERUSER) > 0) { + $orgid =$this->input->post("id"); + $errortekst = ''; + + if($this->input->post("soort")== "1") $actief = 1; + else{ $valtonderID = $this->input->post("valtonderID"); + $actief = $this->Organisaties_model->get_fieldvalue(["valtonder_id" => $valtonderID], 'actief'); + if($actief == 0) $errortekst .= "Activeer eerst de gearchiveerd organisatie(s) boven deze organisatie."; + else $actief = 1; + } + $data=array( + "actief" =>$actief + ); + $this->Organisaties_model->update_record($data,$orgid); + + } + else {$errortekst = " U bent niet geautoriseerd voor deze handeling.";}; + echo json_encode($errortekst); + } + function zoek(){ //TODO clean input $errortekst=""; diff --git a/application/models/shared/Organisaties_model.php b/application/models/shared/Organisaties_model.php index 51e8ee1..a5509f2 100644 --- a/application/models/shared/Organisaties_model.php +++ b/application/models/shared/Organisaties_model.php @@ -282,11 +282,11 @@ class Organisaties_model extends MY_Model{ O.bijlagefile, SD.email1 FROM tb_organisaties O LEFT JOIN tb_schooldetails SD ON O.id = SD.organisatie_id - WHERE O.soort = {$soort} - AND O.actief = 1"; + WHERE O.soort = {$soort} "; if ($valtonder) { $this->sql .=" AND O.valtonder_id = {$valtonder} "; - }; + } + $this->sql .=" ORDER BY O.actief DESC, O.id ASC "; return $this->get_query_result(); } function getorgdetails($id){ diff --git a/application/views/monpas/pages/organisaties.php b/application/views/monpas/pages/organisaties.php index fa98654..3fac7e2 100644 --- a/application/views/monpas/pages/organisaties.php +++ b/application/views/monpas/pages/organisaties.php @@ -7,11 +7,20 @@ data-bind=" options : swvs, optionsText : 'naam', value : selectedSWV, + style : {'backgroundColor': selectedSWV() && selectedSWV().actief() == true ? 'white' : 'lightgrey'}, event : {change: fChangeSWV}"> - - + + + + +
@@ -20,24 +29,48 @@ data-bind=" options : kamers, optionsText : 'naam', value : selectedKamer, + style : {'backgroundColor': selectedKamer() && selectedKamer().actief() == true ? 'white' : 'lightgrey'}, event : {change: fChangeKamer}"> - - + + + + + +
+ BG - - + + + + + + + + +
@@ -60,6 +93,7 @@ + @@ -67,9 +101,65 @@ + - -
+ + + + + +

+ + + + + Gearchiveerde scholen +

+ + + + + + + + + + + + + + + + + + + + + + + +
brinnaam (kort)plaatsactief
+ + + + + + + + +
+ + diff --git a/public/js/monpas/models/organisatiesmodel.js b/public/js/monpas/models/organisatiesmodel.js index 129f2ee..6d946b6 100644 --- a/public/js/monpas/models/organisatiesmodel.js +++ b/public/js/monpas/models/organisatiesmodel.js @@ -4,15 +4,19 @@ ls.initOrganisatiesModel = function(){ function fAddOrg(p){ this.id = p.id - this.naam = ko.observable(p.naam); + this.actief = ko.observable(false); + + if (p.actief == 1) this.actief(true); + this.naam = ko.observable(p.naam); + this.selectnaam = ko.observable(this.actief() ? p.naam : p.naam + ' (archief)') + this.naamkort = ko.observable(p.naamkort); this.plaats = ko.observable(p.plaats); this.email = ko.observable(p.email1 ? p.email1 : '') this.nummer = ko.observable(p.brin); this.soort = p.soort; this.valtonder_id = p.valtonder_id; - this.actief = ko.observable(false); - if (p.actief == 1) this.actief(true); + this.monbas = ko.observable(false); if (p.monbas==1) this.monbas(true); this.mondiv = ko.observable(false); @@ -62,6 +66,8 @@ ls.initOrganisatiesModel = function(){ selectedBG : ko.observable(), scholen : ko.observableArray([]), targetsoort : ko.observable(1), + erIsArchief : ko.observable(false), + toonArchief : ko.observable(false), oldOrg : ko.observable(), // om de oude waardes vast te houden in geval van annuleren editOrg : ko.observable(), // organisatie die geupdate wordt newOrg : ko.observable({ @@ -139,6 +145,9 @@ ls.initOrganisatiesModel = function(){ var self=ls.OrganisatiesModel; if (self.ignore()) return; self.scholen.removeAll(); + self.erIsArchief(false); + + if (self.selectedBG() == undefined) return; var submitData={toporgid : self.selectedBG().id, @@ -146,6 +155,10 @@ ls.initOrganisatiesModel = function(){ $.post("index.php/shared/organisaties/getorgsperlevel/4", submitData, function(data){ if (data){ $.each(data,function(i,p){ + if(p.actief == 0){ + self.erIsArchief(true); + + } self.scholen.push(new fAddOrg(p)); }); } @@ -360,7 +373,7 @@ ls.initOrganisatiesModel = function(){ } }); var submitData = { id : self.editOrg().id, - nummer : self.editOrg().nummer(), + nummer : self.editOrg().nummer(), naamkort : self.editOrg().naamkort(), naam : self.editOrg().naam(), plaats : self.editOrg().plaats(), @@ -383,10 +396,70 @@ ls.initOrganisatiesModel = function(){ self.oldOrg().actief(self.editOrg().actief()); self.oldOrg().monbas(self.editOrg().monbas()); self.oldOrg().mondiv(self.editOrg().mondiv()); + + self.erIsArchief(false); + $.each(self.scholen(), function (i,s){ + if(s.actief() == false) self.erIsArchief(true); + }) + + $("#modEditOrg").modal('hide'); + + + } },'json') }, + + fDearchiveer :function(data, gek){ + var self = ls.OrganisatiesModel; + var dit = this; + + var dit; + switch (data){ + case 1: if (self.selectedSWV() == undefined) return; + dit = self.selectedSWV(); + break; + case 2: if (self.selectedKamer() == undefined) return; + dit = self.selectedKamer(); + break; + case 3: if (self.selectedBG() == undefined) return; + dit = self.selectedBG(); + break; + case 4: if (this== undefined) return; + dit = this; + break; + } + dit.actief(true); + + + var submitData = { + id : dit.id, + soort : dit.soort, + valtonderID : dit.valtonder_id + }; + + $.post("index.php/shared/organisaties/dearchiveer", submitData, function(error){ + if(error){apprise(error); + + } + else{ + self.erIsArchief(false); + $.each(self.scholen(), function (i,s){ + if(s.actief() == false) self.erIsArchief(true); + }) + + } + },'json') + + + }, + + fToggleArchief: function(){ + var self = ls.OrganisatiesModel; + self.toonArchief(! self.toonArchief()) + }, + fStartZoek :function(){ var self = ls.OrganisatiesModel; if (self.zoekstring().length < 2) return;