status wat betreft invullen lijsten

This commit is contained in:
Monique
2022-06-24 14:35:50 +02:00
parent f7fe1ced6b
commit 9545473157
13 changed files with 518 additions and 57 deletions
@@ -156,4 +156,59 @@ class Swvversies extends MY_Controller{
$modules = $this->Modules_model->getmodulesmetlijst();
echo json_encode($modules);
}
function getInvulstatus(){
if (!$this->userid) die;
$orgversie = $this->clean_input('orgversie');
$orgID = $this->clean_input('orgID');
$vorm = $this->clean_input('vorm');
$module = $this->clean_input('module');
$percentage = 0;
$ingevuld = 0;
$aantal = 0;
$mail = [];
$actiemail = [];
$orgsoort = $this->Organisaties_model->get_fieldvalue(['id'=>$orgID], 'soort');
$lijstorg = $this->Orgversies_model->get_fieldvalue(['id' =>$orgversie], 'organisatie_id');
$lijstsoort = $this->Organisaties_model->get_fieldvalue(['id'=>$lijstorg], 'soort');
if($lijstsoort == 1) $join = 'K.valtonder_id';
else $join = "K.id";
$status = FALSE;
if($vorm == 1){
$orgs = $this->Orgversies_model->getOrgsBijOrgversie($orgID, $orgversie, $orgsoort, $module, $join);
if($orgs){
foreach($orgs AS $org){
$status = $this->Filledversions_model->getMeetellen($orgversie, $org->schoolID, FALSE);
if($status) $org->status = $status;
if($status == 'meetellen') $ingevuld++;
}
}
}
if($vorm == 2) {
$orgs = $this->Orgversies_model->getUsersBijOrgversie($orgID, $orgversie, $orgsoort, $module, $join);
if($orgs){
foreach($orgs AS $org){
$status = $this->Filledversions_model->getMeetellen($orgversie, $org->schoolID, $org->gebruikerID);
if($status) $org->status = $status;
if($status == 'meetellen') $ingevuld++;
}
}
}
if($orgs){
$aantal = count($orgs);
$percentage = round($ingevuld/$aantal * 100);
}
echo json_encode(['status' => $orgs,
'lijsten' => $aantal,
'ingevuld' => $ingevuld,
'percentage' => $percentage
]);
}
}
@@ -13,6 +13,7 @@ class Organisaties extends MY_Controller{
"monpas/Orgversies_model",
"monpas/Filledversions_model",
"monpas/Scores_model",
"monpas/Schooldetails_model",
"monpas/Ambities_model",
"shared/Licenties_model");
$this->load->model($models);
@@ -82,7 +83,15 @@ class Organisaties extends MY_Controller{
"actief" =>1,
);
$newid = $this->Organisaties_model->insert_record($data);
$licenties = $this->input->post('licenties');
$data = [ 'organisatie_id' =>$newid,
'plaats' =>$this->clean_input("plaats"),
'email1' =>$this->clean_input("email"),
];
$this->Schooldetails_model->insert_record($data);
$licenties = $this->input->post('licenties');
if ($licenties){
foreach($licenties as $licentie){
$this->Licenties_model->insert_record(array("orgid"=>$newid, "modulenr"=>$licentie));
@@ -156,6 +165,17 @@ class Organisaties extends MY_Controller{
// "mondiv" =>$mondiv
);
$this->Organisaties_model->update_record($data,$orgid);
$detailsid = $this->Schooldetails_model->get_fieldvalue(["organisatie_id" =>$orgid], 'id');
if($detailsid){
$this->Schooldetails_model->update_record(["email1" =>$this->clean_input("email")], $detailsid);
}
else {
$data = [ 'organisatie_id' =>$orgid,
'plaats' =>$this->clean_input("plaats"),
'email1' =>$this->clean_input("email"),
];
$this->Schooldetails_model->insert_record($data);
}
$this->Licenties_model->delete_record_where(array("orgid"=>$orgid));
$licenties = $this->input->post("licenties");
if ($licenties){