nieuwe versie
This commit is contained in:
@@ -0,0 +1,168 @@
|
||||
<?php if (!defined('BASEPATH')) exit('No direct script access allowed');
|
||||
|
||||
class Sopkeuze
|
||||
{
|
||||
private $orgid;
|
||||
private $sops;
|
||||
private $soplabels = [];
|
||||
private $label;
|
||||
private $sop;
|
||||
private $sopid;
|
||||
private $labelids = [];
|
||||
private $stringlabelids;
|
||||
private $standaardlabels = [];
|
||||
private $hfstlabels =[];
|
||||
private $stringids;
|
||||
private $hoofdstukids = [];
|
||||
private $keuzelabels = [];
|
||||
private $labels;
|
||||
private $sopkeuze;
|
||||
|
||||
|
||||
private $CI;
|
||||
|
||||
public function __construct($sopid)
|
||||
{
|
||||
$this->CI =& get_instance();
|
||||
$this->sopid = $sopid;
|
||||
$this->handle();
|
||||
}
|
||||
|
||||
public function getSopKeuze(){
|
||||
return $this->sopkeuze;
|
||||
}
|
||||
|
||||
public function getSops(){
|
||||
return $this->sops;
|
||||
}
|
||||
|
||||
public function getLabels(){
|
||||
return $this->labels;
|
||||
}
|
||||
|
||||
public function getHoofdstukLabels(){
|
||||
return $this->hfstlabels;
|
||||
}
|
||||
|
||||
private function handle()
|
||||
{
|
||||
$this->setOrgid();
|
||||
$this->setSops();
|
||||
$this->setSopLabels();
|
||||
$this->setLabelids();
|
||||
$this->setLabelidsInString();
|
||||
$this->setStandaardLabels();
|
||||
$this->setHoofdstukLabels();
|
||||
$this->loopHoofdstukLabels();
|
||||
$this->hoofdstukIdsInString();
|
||||
$this->setKeuzeLabels();
|
||||
$this->plaatsBuitenSop();
|
||||
$this->setLabels();
|
||||
$this->setSopKeuze();
|
||||
}
|
||||
|
||||
private function setOrgid(){
|
||||
$this->orgid = $this->CI->globorgid;
|
||||
}
|
||||
|
||||
private function setSops(){
|
||||
$this->sops = $this->CI->Sop_model->getnieuwesops($this->orgid);
|
||||
}
|
||||
|
||||
private function setSopLabels(){
|
||||
if(!$this->sops) return;
|
||||
if($this->sopid === 0){
|
||||
$this->sopid = $this->sops[0]->profielID;
|
||||
}
|
||||
|
||||
$this->soplabels = $this->CI->Hoofdstukken_model->getHoofdstukLabelsSop($this->sopid);
|
||||
}
|
||||
|
||||
private function setLabelids(){
|
||||
$this->labelsids = [];
|
||||
if(!$this->sops) return;
|
||||
if(!$this->soplabels) return;
|
||||
foreach($this->soplabels as $index =>$this->label){
|
||||
array_push($this->labelids, $this->label->id);
|
||||
}
|
||||
}
|
||||
|
||||
private function setLabelidsInString(){
|
||||
if(!$this->sops) return;
|
||||
if(!$this->soplabels) return;
|
||||
$this->stringlabelids = implode(",", $this->labelids);
|
||||
}
|
||||
|
||||
private function setStandaardLabels(){
|
||||
if(!$this->sops) return;
|
||||
$this->standaardlabels= $this->CI->Hoofdstukken_model->getStandaardLabelsSop($this->stringlabelids);
|
||||
}
|
||||
|
||||
private function setHoofdstukLabels(){
|
||||
if(!$this->sops) return;
|
||||
$this->hfstlabels = [];
|
||||
|
||||
if(!$this->soplabels){
|
||||
$this->hfstlabels = $this->standaardlabels;
|
||||
}
|
||||
if(!$this->standaardlabels){
|
||||
$this->hfstlabels = $this->soplabels;
|
||||
}
|
||||
if($this->soplabels && $this->standaardlabels) {
|
||||
$this->hfstlabels = $this->standaardlabels + $this->soplabels;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private function loopHoofdstukLabels(){
|
||||
if(!$this->sops) return;
|
||||
if(!$this->hfstlabels) return;
|
||||
foreach($this->hfstlabels as $index => $this->label){
|
||||
$this->plaatsInSop();
|
||||
$this->setHoofdstukids();
|
||||
}
|
||||
}
|
||||
|
||||
private function plaatsInSop(){
|
||||
$this->label->sop = 'T';
|
||||
}
|
||||
|
||||
private function setHoofdstukids(){
|
||||
array_push($this->hoofdstukids, $this->label->id);
|
||||
}
|
||||
|
||||
private function hoofdstukIdsInString(){
|
||||
if(!$this->sops) return;
|
||||
if(!$this->hoofdstukids) return;
|
||||
$this->stringids = implode(",", $this->hoofdstukids);
|
||||
}
|
||||
|
||||
private function setKeuzeLabels(){
|
||||
if(!$this->stringids){$this->stringids = 0;}
|
||||
$this->keuzelabels = $this->CI->Hoofdstukken_model->getKeuzelabelsSop($this->orgid, $this->stringids);
|
||||
}
|
||||
|
||||
private function plaatsBuitenSop(){
|
||||
if(!$this->keuzelabels) return;
|
||||
foreach($this->keuzelabels as $index => $this->label){
|
||||
$this->label->sop = 'F';
|
||||
}
|
||||
}
|
||||
|
||||
private function setLabels(){
|
||||
if(!$this->keuzelabels) {
|
||||
$this->labels = $this->hfstlabels;
|
||||
}
|
||||
if($this->keuzelabels){
|
||||
$this->labels = array_merge($this->hfstlabels, $this->keuzelabels);
|
||||
}
|
||||
}
|
||||
|
||||
private function setSopKeuze(){
|
||||
$this->sopkeuze =[
|
||||
"sops" => $this->sops,
|
||||
"labels" => $this->labels
|
||||
];
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user