282 lines
9.9 KiB
JavaScript
282 lines
9.9 KiB
JavaScript
$(function(){
|
|
|
|
mh.initSopOverzichtModel = function(){
|
|
|
|
function fAddSWV(p){
|
|
console.log(p, "p")
|
|
|
|
var dit = this;
|
|
this.id = p.id;
|
|
this.soort = p.soort;
|
|
this.brin = p.brin;
|
|
this.naam = p.naamkort;
|
|
this.soort = 'SWOP'
|
|
this.plaats = p.plaats;
|
|
this.geopend = ko.observable(false);
|
|
this.erIsEenSop = ko.observable(false);
|
|
if(p.sop === 'T') dit.erIsEenSop(true);
|
|
|
|
this.kamers = ko.observableArray([]);
|
|
if (p.kamers){
|
|
$.each(p.kamers, function(j,k){
|
|
dit.kamers.push(new fAddKamer(k));
|
|
})
|
|
}
|
|
this.bgs = ko.observableArray([])
|
|
this.scholen = ko.observableArray([]);
|
|
}
|
|
|
|
function fAddKamer(p){
|
|
var dit = this;
|
|
this.id = p.id;
|
|
this.soort = p.soort;
|
|
this.brin = p.brin;
|
|
this.naam = p.naamkort;
|
|
this.soort = 'ROP'
|
|
this.plaats = p.plaats;
|
|
this.geopend = ko.observable(false);
|
|
this.erIsEenSop = ko.observable(false);
|
|
if(p.sop === 'T') dit.erIsEenSop(true)
|
|
|
|
this.kamers = ko.observableArray()
|
|
this.bgs = ko.observableArray([]);
|
|
if (p.bgs){
|
|
$.each(p.bgs, function(x,z){
|
|
dit.bgs.push(new fAddBG(z));
|
|
})
|
|
}
|
|
}
|
|
|
|
function fAddBG(p){
|
|
var dit = this;
|
|
this.id = p.id;
|
|
this.soort = 'BOP';
|
|
this.brin = p.brin;
|
|
this.naam = p.naamkort;
|
|
this.plaats = p.plaats;
|
|
this.geopend = ko.observable(false);
|
|
this.kamers = ko.observableArray();
|
|
this.bgs = ko.observableArray();
|
|
this.scholen = ko.observableArray([]);
|
|
|
|
|
|
this.erIsEenSop = ko.observable(false);
|
|
if(p.sop === 'T') dit.erIsEenSop(true)
|
|
|
|
|
|
if (p.scholen){
|
|
$.each(p.scholen, function(a,b){
|
|
dit.scholen.push(new fAddSchool(b));
|
|
})
|
|
}
|
|
}
|
|
|
|
function fAddSchool(b){
|
|
var dit = this;
|
|
this.id = b.id;
|
|
this.soort = 'SOP';
|
|
this.brin = b.brin;
|
|
this.naam = b.naamkort;
|
|
this.plaats = b.plaats;
|
|
this.erIsEenSop = ko.observable(false);
|
|
if(b.sop === 'T') dit.erIsEenSop(true)
|
|
}
|
|
|
|
function fAddLabelOrg(p) {
|
|
var dit = this;
|
|
this.id = p.id;
|
|
this.soort = p.soort;
|
|
this.naam = p.brin ? p.brin = ' ' + p.naamkort : p.naamkort;
|
|
this.soort = ' ';
|
|
this.kleur = ko.observable('');
|
|
this.achtergrond = ko.observable('');
|
|
switch (p.soort) {
|
|
case "1":
|
|
dit.soort = 'SWOP'
|
|
dit.kleur('#A28A29');
|
|
dit.achtergrond('#a07b8e');
|
|
break;
|
|
case "2":
|
|
dit.soort = 'ROP';
|
|
dit.kleur('#ff8c1a');
|
|
dit.achtergrond('#ded0d7');
|
|
break;
|
|
case "3":
|
|
dit.soort = 'BOP';
|
|
dit.kleur('#8cff1a');
|
|
dit.achtergrond('#f5f0f2');
|
|
break;
|
|
case "4":
|
|
dit.soort = 'SOP';
|
|
dit.kleur('#1aa3ff');
|
|
dit.achtergrond('#ffffff');
|
|
break;
|
|
|
|
}
|
|
this.plaats = p.plaats;
|
|
this.geopend = ko.observable(false);
|
|
this.erIsEenSop = ko.observable(false);
|
|
if (p.sop === 'T') dit.erIsEenSop(true);
|
|
this.label = p.label;
|
|
this.orgs = ko.observableArray([]);
|
|
|
|
if (p.scholen) {
|
|
$.each(p.scholen, function (a, b) {
|
|
dit.orgs.push(new fAddLabelOrg(b));
|
|
})
|
|
}
|
|
}
|
|
|
|
function fAddSchooljaar(s){
|
|
this.id = s.schooljaarnr;
|
|
this.naam = s.naam;
|
|
}
|
|
|
|
function fAddCriterium(c) {
|
|
this.id = c.id;
|
|
this.naam = c.naam;
|
|
}
|
|
|
|
|
|
if (mh.SopOverzichtModel !== undefined){
|
|
mh.SopOverzichtModel.initModel();
|
|
}
|
|
else {
|
|
mh.SopOverzichtModel = {
|
|
|
|
orgsoort : ko.observable(4),
|
|
geopend : ko.observable(false),
|
|
schooljaren : ko.observableArray([]),
|
|
criteria : ko.observableArray([]),
|
|
selectedSchooljaar : ko.observable(''),
|
|
selectedCriterium : ko.observable(''),
|
|
selectedOrg : ko.observable(),
|
|
topOrg : ko.observable(),
|
|
gegevens : ko.observable(true),
|
|
bezig : ko.observable(false),
|
|
titel : ko.pureComputed( function(){
|
|
if(mh.SopOverzichtModel && mh.SopOverzichtModel.orgsoort()){
|
|
switch(mh.SopOverzichtModel.orgsoort()){
|
|
case 4 : return 'Compact schoolondersteuningsprofiel (SOP)';
|
|
case 3 : return 'Compacte schoolondersteuningsprofielen (SOPs)';
|
|
case 2 : return 'Compacte school- en bestuursondersteuningsprofielen (SOPs en BOPs)';
|
|
case 1 : return 'Compacte school-, bestuurs- en regionale ondersteuningsprofielen (SOPs, BOPs en ROPs)';
|
|
default: return 'Compact schoolondersteuningsprofiel (SOP)';
|
|
}
|
|
}
|
|
}),
|
|
subtitel : ko.pureComputed( function(){
|
|
if(mh.SopOverzichtModel && mh.SopOverzichtModel.orgsoort()){
|
|
switch(mh.SopOverzichtModel.orgsoort()){
|
|
case 4 : return '';
|
|
case 3 : return 'en het bestuurondersteuningsprofiel (BOP)';
|
|
case 2 : return 'en het regionaal ondersteuningsprofiel (ROP)';
|
|
case 1 : return 'en het SWV-ondersteuningsprofiel (SWOP)';
|
|
default : return '';
|
|
}
|
|
}
|
|
}),
|
|
|
|
initBindings :function(){
|
|
var self = mh.SopOverzichtModel;
|
|
if (!ko.dataFor(document.getElementById('pagsopoverzicht')) ) {
|
|
ko.applyBindings(mh.SopOverzichtModel, document.getElementById("pagsopoverzicht"));
|
|
}
|
|
$.post("index.php/monpas/overzichtsop/getSchooljarenEnCriteria", function(data){
|
|
self.selectedSchooljaar(null);
|
|
self.selectedCriterium(null);
|
|
self.schooljaren.removeAll();
|
|
self.criteria.removeAll();
|
|
self.bezig(true);
|
|
if(data){
|
|
|
|
$.each(data.schooljaren, function (i, s) {
|
|
self.schooljaren.push(new fAddSchooljaar(s));
|
|
});
|
|
|
|
if (self.schooljaren()) self.selectedSchooljaar(self.schooljaren()[0]);
|
|
$.each(data.criteria, function (i, c) {
|
|
self.criteria.push(new fAddCriterium(c));
|
|
}); // each
|
|
self.selectedCriterium(self.criteria()[0]);
|
|
self.orgsoort(data.orgsoort);
|
|
|
|
} // if
|
|
self.initModel();
|
|
},'json')
|
|
},
|
|
|
|
initModel: function(){
|
|
var self = mh.SopOverzichtModel;
|
|
self.fGetOverzicht();
|
|
},
|
|
|
|
fChangeSchooljaar: function() {
|
|
var self = mh.SopOverzichtModel;
|
|
if (!self.selectedSchooljaar()) return;
|
|
if(self.bezig()) return;
|
|
self.fGetOverzicht();
|
|
},
|
|
|
|
fChangeCriterium: function() {
|
|
var self = mh.SopOverzichtModel;
|
|
if (!self.selectedCriterium()) return;
|
|
if(self.bezig()) return;
|
|
self.fGetOverzicht();
|
|
},
|
|
|
|
fGetOverzicht: function(){
|
|
var self = mh.SopOverzichtModel;
|
|
|
|
var submitData = {
|
|
'schooljaarnr' : self.selectedSchooljaar().id,
|
|
'criteriumID' : self.selectedCriterium().id,
|
|
};
|
|
|
|
$.post("index.php/monpas/overzichtsop/getoverzicht", submitData , function(data){
|
|
if (data){
|
|
self.selectedOrg('');
|
|
self.topOrg('');
|
|
|
|
|
|
if(data.criteriumscholen){
|
|
self.topOrg(new fAddLabelOrg(data.criteriumscholen));
|
|
}
|
|
|
|
if(data.organisatie) {
|
|
switch (Number(self.orgsoort())) {
|
|
case 1:
|
|
self.selectedOrg(new fAddSWV(data.organisatie));
|
|
break;
|
|
case 2:
|
|
self.selectedOrg(new fAddKamer(data.organisatie));
|
|
break;
|
|
case 3:
|
|
self.selectedOrg(new fAddBG(data.organisatie));
|
|
break;
|
|
case 4:
|
|
self.selectedOrg(new fAddSchool(data.organisatie));
|
|
break;
|
|
} // switch
|
|
}
|
|
|
|
}
|
|
self.bezig(false);
|
|
},'json');
|
|
},
|
|
|
|
fOpenPDF: function(){
|
|
var self =mh.SopOverzichtModel;
|
|
var dit = this;
|
|
var submitData = {
|
|
'orgid' : dit.id,
|
|
'schooljaarnr': self.selectedSchooljaar().id
|
|
};
|
|
window.open("index.php/monpas/overzichtsop/download_pdf/" + dit.id + '/'+ self.selectedSchooljaar().id );
|
|
}
|
|
|
|
} ; // definition van model
|
|
mh.SopOverzichtModel.initBindings();
|
|
} // else
|
|
}// function init mh.SopOverzichtModel
|
|
}); |