822 lines
31 KiB
PHP
822 lines
31 KiB
PHP
<?php
|
|
|
|
define("TEMP_FOLDER", "admin/survey/modules/mod_MJU/temp");
|
|
define("RESULTS_FOLDER", "admin/survey/modules/mod_MJU/results");
|
|
|
|
class SurveyMJU{
|
|
|
|
private $anketa; // id ankete
|
|
private $db_table = '';
|
|
|
|
private $vprasanja = array(); // array z vsemi vprasanji v anketi, ki jih obravnavamo
|
|
private $predavatelji = array(); // array z vsemi predavatelji, ki jih obravnavamo
|
|
private $data = array(); // array z vsemi odgovori
|
|
|
|
private $calculations = array(); // array s custom analizami odgovorov
|
|
|
|
private $calculationsSimple = array(); // array z analizami za enostaven izvoz (anketa udelezenci)
|
|
|
|
|
|
function __construct($anketa){
|
|
global $site_url;
|
|
|
|
if ((int)$anketa > 0){
|
|
$this->anketa = $anketa;
|
|
|
|
# polovimo vrsto tabel (aktivne / neaktivne)
|
|
SurveyInfo :: getInstance()->SurveyInit($this->anketa);
|
|
$this->db_table = SurveyInfo::getInstance()->getSurveyArchiveDBString();
|
|
}
|
|
}
|
|
|
|
|
|
// Pobrisemo zacasne datoteke
|
|
private function deleteTemp(){
|
|
global $site_path;
|
|
|
|
$temp_folder = $site_path . TEMP_FOLDER.'/';
|
|
|
|
if (file_exists($temp_folder.'/data_'.$this->anketa.'.csv')) {
|
|
unlink($temp_folder.'/data_'.$this->anketa.'.csv');
|
|
}
|
|
|
|
// Pobrisemo zacasno CSV datoteko s podatki
|
|
if (file_exists($temp_folder.'/mju.csv')) {
|
|
unlink($temp_folder.'/mju.csv');
|
|
}
|
|
|
|
// Pobrisemo še vse rezultatih
|
|
$files = glob($site_path . RESULTS_FOLDER . '/*');
|
|
foreach($files as $file){
|
|
if(is_file($file))
|
|
unlink($file);
|
|
}
|
|
}
|
|
|
|
|
|
// Zgeneriramo poseben xls mju export
|
|
public function executeExport(){
|
|
global $site_path;
|
|
global $lang;
|
|
global $admin_type;
|
|
|
|
$sql = sisplet_query("SELECT s.id, s.variable
|
|
FROM srv_spremenljivka s, srv_grupa g
|
|
WHERE s.gru_id=g.id AND g.ank_id='".$this->anketa."' AND s.variable='mjuU'");
|
|
|
|
// Kompleksen izvoz po predavateljih za anketo za udelezence usposabljanja
|
|
if(mysqli_num_rows($sql) > 0){
|
|
// Pripravimo podatke
|
|
$this->cacheData();
|
|
|
|
// Pripravimo analizo
|
|
$this->analyseData();
|
|
|
|
/*echo '<br><br><br>';
|
|
var_dump($this->vprasanja);
|
|
var_dump($this->predavatelji);
|
|
var_dump($this->data);
|
|
var_dump($this->calculations);
|
|
die();*/
|
|
|
|
// Izvedemo izvoz
|
|
$this->executeExportLarge();
|
|
}
|
|
// Enostaven izvoz za anketo za udelezence
|
|
else{
|
|
// Pripravimo analizo
|
|
$this->analyseDataSimple();
|
|
|
|
/*echo '<br><br>';
|
|
var_dump($this->calculationsSimple);
|
|
die();*/
|
|
|
|
// Izvedemo izvoz
|
|
$this->executeExportSimple();
|
|
}
|
|
}
|
|
|
|
|
|
// Kompleksen izvoz po predavateljih za anketo za udelezence usposabljanja
|
|
private function executeExportLarge(){
|
|
global $site_path;
|
|
global $lang;
|
|
global $admin_type;
|
|
|
|
$temp_folder = $site_path . TEMP_FOLDER.'/';
|
|
|
|
$file_handler = fopen($temp_folder.'mju_'.$this->anketa.'.xls',"w");
|
|
|
|
$convertType = 1; // kateri tip konvertiranja uporabimo
|
|
$convertTypes[1] = array('charSet' => "windows-1250",
|
|
'delimit' => ";",
|
|
'newLine' => "\n",
|
|
'BOMchar' => "\xEF\xBB\xBF");
|
|
|
|
# dodami boomchar za utf-8
|
|
fwrite($file_handler, $convertTypes[$convertType]['BOMchar']);
|
|
|
|
fwrite($file_handler,'<table border="1">');
|
|
|
|
|
|
// Prestejemo koliko datumov in koliko izvajalcev imamo (zaradi rowspana)
|
|
$date_cnt = count($this->calculations);
|
|
$pred_cnt = count($this->predavatelji);
|
|
|
|
|
|
// Prva vrstica tabele
|
|
$row1 = '<tr>';
|
|
$row1 .= '<td>Seminar</td>';
|
|
$row1 .= '<td>Datum izvedbe</td>';
|
|
$row1 .= '<td>Ocena seminarja</td>';
|
|
|
|
$row1 .= '<td>Izvajalec</td>';
|
|
$row1 .= '<td>Ocena izvajalca</td>';
|
|
$row1 .= '<td>Povprečna ocena izvajalca</td>';
|
|
|
|
$row1 .= '<td colspan="4">Oblike dela</td>';
|
|
|
|
$row1 .= '<td colspan="3">Trajanje seminarja</td>';
|
|
|
|
$row1 .= '<td>Zadovoljstvo z organizacijo</td>';
|
|
|
|
$row1 .= '<td colspan="2">Razlog za udeležbo</td>';
|
|
|
|
$row1 .= '<td colspan="3">Kako ste izvedeli za usposabljanje</td>';
|
|
$row1 .= '</tr>';
|
|
|
|
fwrite($file_handler, $row1);
|
|
|
|
// Druga vrstica tabele
|
|
$row2 = '<tr>';
|
|
$row2 .= '<td></td>';
|
|
$row2 .= '<td></td>';
|
|
$row2 .= '<td></td>';
|
|
$row2 .= '<td></td>';
|
|
$row2 .= '<td></td>';
|
|
$row2 .= '<td></td>';
|
|
|
|
$row2 .= '<td>Predavanje</td>';
|
|
$row2 .= '<td>Diskusija</td>';
|
|
$row2 .= '<td>Praktično delo</td>';
|
|
$row2 .= '<td>Sodelovalno delo</td>';
|
|
|
|
$row2 .= '<td>Prekratko</td>';
|
|
$row2 .= '<td>Primerno</td>';
|
|
$row2 .= '<td>Predolgo</td>';
|
|
|
|
$row2 .= '<td></td>';
|
|
|
|
$row2 .= '<td>Na lastno željo</td>';
|
|
$row2 .= '<td>Po nalogu nadrejenega oz. kadrovske službe</td>';
|
|
|
|
$row2 .= '<td>Na podlagi informacije na spletni strani Upravne akademije</td>';
|
|
$row2 .= '<td>Na podlagi obvestila Upravne akademije </td>';
|
|
$row2 .= '<td>Na podlagi priporočila sodelavcev </td>';
|
|
|
|
$row2 .= '</tr>';
|
|
|
|
fwrite($file_handler, $row2);
|
|
|
|
|
|
// Loop po datumih
|
|
$cnt1 = 0;
|
|
foreach($this->calculations as $datum_id => $datum_data){
|
|
|
|
// Loop po izvajalcih
|
|
$cnt2 = 0;
|
|
foreach($this->predavatelji as $predavatelj_num => $predavatelj){
|
|
|
|
$rowData = '';
|
|
|
|
// Izpis vrstice
|
|
$rowData = '<tr>';
|
|
|
|
|
|
// Ime seminarja
|
|
if($cnt1 == 0 && $cnt2 == 0)
|
|
$rowData .= '<td rowspan="'.($pred_cnt*$date_cnt).'">'.$this->vprasanja['seminar']['naslov'].'</td>';
|
|
|
|
// Datum seminarja
|
|
if($cnt2 == 0)
|
|
$rowData .= '<td rowspan="'.($pred_cnt).'">'.$this->vprasanja['seminar']['datum']['vrednost'][$datum_id].'</td>';
|
|
|
|
// Ocena seminarja (mjuU1)
|
|
if($cnt2 == 0){
|
|
$abs = 0;
|
|
$freq = 0;
|
|
foreach($datum_data['mjuU1'] as $val){
|
|
$abs += $val['abs'];
|
|
$freq += $val['freq'];
|
|
}
|
|
if($freq > 0)
|
|
$rowData .= '<td rowspan="'.($pred_cnt).'">"'.number_format($abs / $freq, 1).'"</td>';
|
|
else
|
|
$rowData .= '<td rowspan="'.($pred_cnt).'">/</td>';
|
|
}
|
|
|
|
// Ime predavatelja
|
|
$rowData .= '<td>'.$predavatelj['ime'].'</td>';
|
|
|
|
// Ocena predavatelja (mjuU1)
|
|
$abs = 0;
|
|
$freq = 0;
|
|
foreach($datum_data['mjuPA'.$predavatelj_num] as $val){
|
|
$abs += $val['abs'];
|
|
$freq += $val['freq'];
|
|
}
|
|
if($freq > 0)
|
|
$rowData .= '<td>"'.number_format($abs / $freq, 1).'"</td>';
|
|
else
|
|
$rowData .= '<td>/</td>';
|
|
|
|
// Povprecna ocena predavatelja (mjuPA)
|
|
$abs = 0;
|
|
$freq = 0;
|
|
foreach($this->calculations as $avg_seminar){
|
|
foreach($avg_seminar['mjuPA'.$predavatelj_num] as $avg_pred){
|
|
$abs += $avg_pred['abs'];
|
|
$freq += $avg_pred['freq'];
|
|
}
|
|
}
|
|
if($freq > 0)
|
|
$rowData .= '<td>"'.number_format($abs / $freq, 1).'"</td>';
|
|
else
|
|
$rowData .= '<td>/';
|
|
|
|
// mjuPB
|
|
$rowData .= '<td>'.(isset($datum_data['mjuPB'.$predavatelj_num]['1']['freq']) ? $datum_data['mjuPB'.$predavatelj_num]['1']['freq'] : '0').'</td>';
|
|
$rowData .= '<td>'.(isset($datum_data['mjuPB'.$predavatelj_num]['2']['freq']) ? $datum_data['mjuPB'.$predavatelj_num]['2']['freq'] : '0').'</td>';
|
|
$rowData .= '<td>'.(isset($datum_data['mjuPB'.$predavatelj_num]['3']['freq']) ? $datum_data['mjuPB'.$predavatelj_num]['3']['freq'] : '0').'</td>';
|
|
$rowData .= '<td>'.(isset($datum_data['mjuPB'.$predavatelj_num]['4']['freq']) ? $datum_data['mjuPB'.$predavatelj_num]['4']['freq'] : '0').'</td>';
|
|
|
|
|
|
// Trajanje seminarja - PO NOVEM V PROCENTIH
|
|
if($cnt2 == 0){
|
|
/*$rowData .= '<td rowspan="'.($pred_cnt).'">'.(isset($datum_data['mjuU2']['1']['freq']) ? $datum_data['mjuU2']['1']['freq'] : '0').'</td>';
|
|
$rowData .= '<td rowspan="'.($pred_cnt).'">'.(isset($datum_data['mjuU2']['2']['freq']) ? $datum_data['mjuU2']['2']['freq'] : '0').'</td>';
|
|
$rowData .= '<td rowspan="'.($pred_cnt).'">'.(isset($datum_data['mjuU2']['3']['freq']) ? $datum_data['mjuU2']['3']['freq'] : '0').'</td>';*/
|
|
$abs = 0;
|
|
$abs += (isset($datum_data['mjuU2']['1']['freq'])) ? $datum_data['mjuU2']['1']['freq'] : 0;
|
|
$abs += (isset($datum_data['mjuU2']['2']['freq'])) ? $datum_data['mjuU2']['2']['freq'] : 0;
|
|
$abs += (isset($datum_data['mjuU2']['3']['freq'])) ? $datum_data['mjuU2']['3']['freq'] : 0;
|
|
$rowData .= '<td rowspan="'.($pred_cnt).'">'.(isset($datum_data['mjuU2']['1']['freq']) ? round($datum_data['mjuU2']['1']['freq'] / $abs * 100, 1) : '0').' %</td>';
|
|
$rowData .= '<td rowspan="'.($pred_cnt).'">'.(isset($datum_data['mjuU2']['2']['freq']) ? round($datum_data['mjuU2']['2']['freq'] / $abs * 100, 1) : '0').' %</td>';
|
|
$rowData .= '<td rowspan="'.($pred_cnt).'">'.(isset($datum_data['mjuU2']['3']['freq']) ? round($datum_data['mjuU2']['3']['freq'] / $abs * 100, 1) : '0').' %</td>';
|
|
|
|
// Zadovoljstvo z organizacijo (mjuU3)
|
|
$abs = 0;
|
|
$freq = 0;
|
|
foreach($datum_data['mjuU3'] as $val){
|
|
$abs += $val['abs'];
|
|
$freq += $val['freq'];
|
|
}
|
|
if($freq > 0)
|
|
$rowData .= '<td rowspan="'.($pred_cnt).'">"'.number_format($abs / $freq, 1).'"</td>';
|
|
else
|
|
$rowData .= '<td rowspan="'.($pred_cnt).'">/</td>';
|
|
|
|
// Razlog za udelezbo (mjuU4)
|
|
/*$rowData .= '<td rowspan="'.($pred_cnt).'">'.(isset($datum_data['mjuU4']['1']['freq']) ? $datum_data['mjuU4']['1']['freq'] : '0').'</td>';
|
|
$rowData .= '<td rowspan="'.($pred_cnt).'">'.(isset($datum_data['mjuU4']['2']['freq']) ? $datum_data['mjuU4']['2']['freq'] : '0').'</td>';*/
|
|
$abs = 0;
|
|
$abs += (isset($datum_data['mjuU4']['1']['freq'])) ? $datum_data['mjuU4']['1']['freq'] : 0;
|
|
$abs += (isset($datum_data['mjuU4']['2']['freq'])) ? $datum_data['mjuU4']['2']['freq'] : 0;
|
|
$rowData .= '<td rowspan="'.($pred_cnt).'">'.(isset($datum_data['mjuU4']['1']['freq']) ? round($datum_data['mjuU4']['1']['freq'] / $abs * 100, 1) : '0').' %</td>';
|
|
$rowData .= '<td rowspan="'.($pred_cnt).'">'.(isset($datum_data['mjuU4']['2']['freq']) ? round($datum_data['mjuU4']['2']['freq'] / $abs * 100, 1) : '0').' %</td>';
|
|
|
|
// Kako ste izvedeli za usposabljanje (mjuU5)
|
|
/*$rowData .= '<td rowspan="'.($pred_cnt).'">'.(isset($datum_data['mjuU5']['1']['freq']) ? $datum_data['mjuU5']['1']['freq'] : '0').'</td>';
|
|
$rowData .= '<td rowspan="'.($pred_cnt).'">'.(isset($datum_data['mjuU5']['2']['freq']) ? $datum_data['mjuU5']['2']['freq'] : '0').'</td>';
|
|
$rowData .= '<td rowspan="'.($pred_cnt).'">'.(isset($datum_data['mjuU5']['3']['freq']) ? $datum_data['mjuU5']['3']['freq'] : '0').'</td>';*/
|
|
$abs = 0;
|
|
$abs += (isset($datum_data['mjuU5']['1']['freq'])) ? $datum_data['mjuU5']['1']['freq'] : 0;
|
|
$abs += (isset($datum_data['mjuU5']['2']['freq'])) ? $datum_data['mjuU5']['2']['freq'] : 0;
|
|
$abs += (isset($datum_data['mjuU5']['3']['freq'])) ? $datum_data['mjuU5']['3']['freq'] : 0;
|
|
$rowData .= '<td rowspan="'.($pred_cnt).'">'.(isset($datum_data['mjuU5']['1']['freq']) ? round($datum_data['mjuU5']['1']['freq'] / $abs * 100, 1) : '0').' %</td>';
|
|
$rowData .= '<td rowspan="'.($pred_cnt).'">'.(isset($datum_data['mjuU5']['2']['freq']) ? round($datum_data['mjuU5']['2']['freq'] / $abs * 100, 1) : '0').' %</td>';
|
|
$rowData .= '<td rowspan="'.($pred_cnt).'">'.(isset($datum_data['mjuU5']['3']['freq']) ? round($datum_data['mjuU5']['3']['freq'] / $abs * 100, 1) : '0').' %</td>';
|
|
}
|
|
|
|
$rowData .= '</tr>';
|
|
|
|
fwrite($file_handler, $rowData);
|
|
|
|
$cnt1++;
|
|
$cnt2++;
|
|
}
|
|
}
|
|
|
|
|
|
fwrite($file_handler, '</table>');
|
|
fclose($file_handler);
|
|
|
|
|
|
ob_clean();
|
|
|
|
$file_url = $temp_folder.'mju_'.$this->anketa.'.xls';
|
|
header('Content-Type: application/vnd.ms-excel; charset="'.$convertTypes[$convertType]['charSet'].'"');
|
|
header("Content-Transfer-Encoding: Binary");
|
|
header("Content-disposition: attachment; filename=\"" . basename($file_url) . "\"");
|
|
readfile($file_url);
|
|
|
|
unlink ($temp_folder.'mju_'.$this->anketa.'.xls');
|
|
|
|
exit;
|
|
}
|
|
|
|
// Nastavimo imena vprasanj za vse predmete
|
|
private function cacheData(){
|
|
|
|
// Napolnimo vprasanja
|
|
$sql = sisplet_query("SELECT s.id, s.naslov, s.variable
|
|
FROM srv_spremenljivka s, srv_grupa g
|
|
WHERE s.gru_id=g.id AND g.ank_id='".$this->anketa."'
|
|
AND s.variable LIKE 'mju%'");
|
|
while($row = mysqli_fetch_array($sql)){
|
|
|
|
// seminar
|
|
if($row['variable'] == 'mjuU'){
|
|
$this->vprasanja['seminar']['naslov'] = strip_tags($row['naslov']);
|
|
}
|
|
// datum
|
|
elseif($row['variable'] == 'mjuUD'){
|
|
|
|
$this->vprasanja['seminar']['datum']['id'] = $row['id'];
|
|
|
|
$sqlD = sisplet_query("SELECT v.id, v.naslov, v.variable
|
|
FROM srv_spremenljivka s, srv_grupa g, srv_vrednost v
|
|
WHERE s.gru_id=g.id AND g.ank_id='".$this->anketa."' AND v.spr_id=s.id
|
|
AND s.variable='mjuUD'");
|
|
while($rowD = mysqli_fetch_array($sqlD)){
|
|
$this->vprasanja['seminar']['datum']['vrednost'][$rowD['id']] = $rowD['naslov'];
|
|
}
|
|
}
|
|
// predavatelji
|
|
elseif($row['variable'] == 'mjuP'){
|
|
|
|
$this->vprasanja['predavatelj']['id'] = $row['id'];
|
|
|
|
$sqlP = sisplet_query("SELECT v.id, v.naslov, v.variable
|
|
FROM srv_spremenljivka s, srv_grupa g, srv_vrednost v
|
|
WHERE s.gru_id=g.id AND g.ank_id='".$this->anketa."' AND v.spr_id=s.id
|
|
AND s.variable='mjuP'");
|
|
while($rowP = mysqli_fetch_array($sqlP)){
|
|
$this->vprasanja['predavatelj']['vrednost'][$rowP['id']] = $rowP['naslov'];
|
|
}
|
|
}
|
|
// vprasanja o predavateljih
|
|
elseif(substr($row['variable'], 0, 4) == 'mjuP'){
|
|
$number = substr($row['variable'], 4);
|
|
|
|
$this->vprasanja['predavatelj'][$number]['naslov'] = strip_tags($row['naslov']);
|
|
$this->vprasanja['predavatelj'][$number]['id'] = $row['id'];
|
|
$this->vprasanja['predavatelj'][$number]['variable'] = $row['variable'];
|
|
}
|
|
// splosna vprasanja
|
|
elseif(substr($row['variable'], 0, 4) == 'mjuU'){
|
|
$number = substr($row['variable'], 4);
|
|
|
|
$this->vprasanja['seminar'][$number]['naslov'] = strip_tags($row['naslov']);
|
|
$this->vprasanja['seminar'][$number]['id'] = $row['id'];
|
|
$this->vprasanja['seminar'][$number]['variable'] = $row['variable'];
|
|
}
|
|
}
|
|
|
|
|
|
// Napolnimo predavatelje
|
|
$sql2 = sisplet_query("SELECT v.id, v.naslov, v.vrstni_red
|
|
FROM srv_spremenljivka s, srv_vrednost v, srv_grupa g
|
|
WHERE s.gru_id=g.id AND g.ank_id='".$this->anketa."' AND v.spr_id=s.id
|
|
AND s.variable='mjuP' AND s.id='".$this->vprasanja['predavatelj']['id']."'");
|
|
while($row2 = mysqli_fetch_array($sql2)){
|
|
$this->predavatelji[$row2['vrstni_red']]['ime'] = strip_tags($row2['naslov']);
|
|
$this->predavatelji[$row2['vrstni_red']]['id'] = $row2['id'];
|
|
}
|
|
|
|
|
|
// Napolnimo splosne odgovore - najprej navadne vrednosti (radio in checkbox)
|
|
$variable = array('mjuUD','mjuP','mjuU2','mjuU4','mjuU5');
|
|
foreach($variable as $var){
|
|
|
|
$sql3 = sisplet_query("SELECT v.naslov, v.variable, v.id, d.usr_id
|
|
FROM srv_grupa g, srv_spremenljivka s, srv_vrednost v, srv_data_vrednost".$this->db_table." d
|
|
WHERE s.variable='".$var."' AND g.ank_id='".$this->anketa."'
|
|
AND s.id=v.spr_id AND s.gru_id=g.id AND d.vre_id=v.id AND d.spr_id=s.id");
|
|
while($row3 = mysqli_fetch_array($sql3)){
|
|
|
|
if($var == 'mjuP' || substr($var, 0, 4) == 'mjuPB')
|
|
$this->data[$row3['usr_id']][$var][] = $row3['id'];
|
|
elseif($var == 'mjuUD')
|
|
$this->data[$row3['usr_id']][$var] = $row3['id'];
|
|
else
|
|
$this->data[$row3['usr_id']][$var] = $row3['variable'];
|
|
}
|
|
}
|
|
|
|
// Napolnimo splosne odgovore - tabela vrednosti
|
|
$variable = array('mjuU1','mjuU3');
|
|
foreach($variable as $var){
|
|
|
|
$sql4 = sisplet_query("SELECT d.grd_id, d.usr_id, d.vre_id
|
|
FROM srv_grupa g, srv_spremenljivka s, srv_data_grid".$this->db_table." d
|
|
WHERE s.variable='".$var."' AND g.ank_id='".$this->anketa."'
|
|
AND s.gru_id=g.id AND d.spr_id=s.id");
|
|
while($row4 = mysqli_fetch_array($sql4)){
|
|
$this->data[$row4['usr_id']][$var][$row4['vre_id']] = $row4['grd_id'];
|
|
}
|
|
}
|
|
|
|
// Napolnimo odgovore za predavatelje - tabele
|
|
$sql5 = sisplet_query("SELECT d.grd_id, d.usr_id, d.vre_id, s.variable
|
|
FROM srv_grupa g, srv_spremenljivka s, srv_data_grid".$this->db_table." d
|
|
WHERE s.variable LIKE 'mjuPA%' AND g.ank_id='".$this->anketa."'
|
|
AND s.gru_id=g.id AND d.spr_id=s.id");
|
|
while($row5 = mysqli_fetch_array($sql5)){
|
|
$this->data[$row5['usr_id']][$row5['variable']][$row5['vre_id']] = $row5['grd_id'];
|
|
}
|
|
// Napolnimo odgovore za predavatelje - checkbox
|
|
$sql5 = sisplet_query("SELECT v.naslov, v.variable, v.vrstni_red, v.id, d.usr_id, s.variable AS spr_variable
|
|
FROM srv_grupa g, srv_spremenljivka s, srv_vrednost v, srv_data_vrednost".$this->db_table." d
|
|
WHERE s.variable LIKE 'mjuPB%' AND g.ank_id='".$this->anketa."'
|
|
AND s.id=v.spr_id AND s.gru_id=g.id AND d.vre_id=v.id AND d.spr_id=s.id");
|
|
while($row5 = mysqli_fetch_array($sql5)){
|
|
$this->data[$row5['usr_id']][$row5['spr_variable']][] = $row5['vrstni_red'];
|
|
}
|
|
}
|
|
|
|
// Izracunamo custom analize (frekvence, povprecja)
|
|
private function analyseData(){
|
|
|
|
foreach($this->data as $usr_id => $usr_data){
|
|
|
|
// mjuU1
|
|
foreach($usr_data['mjuU1'] as $key => $val){
|
|
$this->calculations[$usr_data['mjuUD']]['mjuU1'][$key]['abs'] = $this->calculations[$usr_data['mjuUD']]['mjuU1'][$key]['abs'] + $val;
|
|
$this->calculations[$usr_data['mjuUD']]['mjuU1'][$key]['freq'] = $this->calculations[$usr_data['mjuUD']]['mjuU1'][$key]['freq'] + 1;
|
|
}
|
|
|
|
// mjuU2
|
|
$this->calculations[$usr_data['mjuUD']]['mjuU2'][$usr_data['mjuU2']]['freq'] ++;
|
|
|
|
// mjuU3
|
|
foreach($usr_data['mjuU3'] as $key => $val){
|
|
$this->calculations[$usr_data['mjuUD']]['mjuU3'][$key]['abs'] = $this->calculations[$usr_data['mjuUD']]['mjuU3'][$key]['abs'] + $val;
|
|
$this->calculations[$usr_data['mjuUD']]['mjuU3'][$key]['freq'] = $this->calculations[$usr_data['mjuUD']]['mjuU3'][$key]['freq'] + 1;
|
|
}
|
|
|
|
// mjuU4
|
|
$this->calculations[$usr_data['mjuUD']]['mjuU4'][$usr_data['mjuU4']]['freq'] ++;
|
|
|
|
// mjuU5
|
|
$this->calculations[$usr_data['mjuUD']]['mjuU5'][$usr_data['mjuU5']]['freq'] ++;
|
|
|
|
|
|
foreach($this->vprasanja['predavatelj'] as $keyP => $valP){
|
|
|
|
// mjuPA
|
|
if(substr($valP['variable'], 0, 5) == 'mjuPA'){
|
|
foreach($usr_data[$valP['variable']] as $key => $val){
|
|
$this->calculations[$usr_data['mjuUD']][$valP['variable']][$key]['abs'] = $this->calculations[$usr_data['mjuUD']][$valP['variable']][$key]['abs'] + $val;
|
|
$this->calculations[$usr_data['mjuUD']][$valP['variable']][$key]['freq'] = $this->calculations[$usr_data['mjuUD']][$valP['variable']][$key]['freq'] + 1;
|
|
}
|
|
}
|
|
// mjuPB
|
|
elseif(substr($valP['variable'], 0, 5) == 'mjuPB'){
|
|
//$this->calculations[$usr_data['mjuUD']][$valP['variable']][$usr_data[$valP['variable']]]['freq'] ++;
|
|
foreach($usr_data[$valP['variable']] as $key => $val){
|
|
$this->calculations[$usr_data['mjuUD']][$valP['variable']][$val]['freq'] = $this->calculations[$usr_data['mjuUD']][$valP['variable']][$val]['freq'] + 1;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
// Zgeneriramo poseben xls mju export - enostaven izvoz za anketo udelezenci
|
|
private function executeExportSimple(){
|
|
global $site_path;
|
|
global $lang;
|
|
global $admin_type;
|
|
|
|
$temp_folder = $site_path . TEMP_FOLDER.'/';
|
|
|
|
$file_handler = fopen($temp_folder.'mju2_'.$this->anketa.'.xls',"w");
|
|
|
|
$convertType = 1; // kateri tip konvertiranja uporabimo
|
|
$convertTypes[1] = array('charSet' => "windows-1250",
|
|
'delimit' => ";",
|
|
'newLine' => "\n",
|
|
'BOMchar' => "\xEF\xBB\xBF");
|
|
|
|
# dodami boomchar za utf-8
|
|
fwrite($file_handler, $convertTypes[$convertType]['BOMchar']);
|
|
|
|
fwrite($file_handler,'<table border="1">');
|
|
|
|
|
|
// Prve vrstice tabele
|
|
$row1 = '<tr>';
|
|
$row1 .= '<td rowspan="3">Kazalnik (navedba kazalnika)</td>';
|
|
$row1 .= '<td rowspan="3">Kategorija regije (če je relevantno)</td>';
|
|
|
|
$row1 .= '<td colspan="3">Ciljna vrednost (za leto 2023)</td>';
|
|
|
|
// Vsa leta ki imajo vnos
|
|
foreach($this->calculationsSimple['all'] as $year => $val){
|
|
if($year != 'spol'){
|
|
$row1 .= '<td colspan="2" rowspan="2">'.$year.'</td>';
|
|
}
|
|
}
|
|
|
|
$row1 .= '<td colspan="3" rowspan="2">Zbirna vrednost (izračunana samodejno)</td>';
|
|
|
|
$row1 .= '<td colspan="3">Stopnja uresničevanja</td>';
|
|
$row1 .= '</tr>';
|
|
|
|
|
|
$row1 .= '<tr>';
|
|
$row1 .= '<td colspan="3">razčlenitev glede na spol (za ciljno vrednost) ni obvezna</td>';
|
|
$row1 .= '<td colspan="3">razčlenitev glede na spol ni obvezna</td>';
|
|
$row1 .= '</tr>';
|
|
|
|
|
|
$row1 .= '<tr>';
|
|
$row1 .= '<td>Skupaj</td>';
|
|
$row1 .= '<td>m</td>';
|
|
$row1 .= '<td>ž</td>';
|
|
|
|
// Vsa leta ki imajo vnos
|
|
foreach($this->calculationsSimple['all'] as $year => $val){
|
|
if($year != 'spol'){
|
|
$row1 .= '<td>m</td>';
|
|
$row1 .= '<td>ž</td>';
|
|
}
|
|
}
|
|
|
|
$row1 .= '<td>Skupaj</td>';
|
|
$row1 .= '<td>m</td>';
|
|
$row1 .= '<td>ž</td>';
|
|
|
|
$row1 .= '<td>Skupaj</td>';
|
|
$row1 .= '<td>m</td>';
|
|
$row1 .= '<td>ž</td>';
|
|
|
|
$row1 .= '</tr>';
|
|
fwrite($file_handler, $row1);
|
|
|
|
|
|
// Izpis vrstice s podatki
|
|
$rows = array(
|
|
0 => 'Brezposelni (ESS)',
|
|
1 => 'Brezposelni (pobuda za zaposlovanje mladih)',
|
|
2 => 'Dolgotrajno brezposelni (ESS)',
|
|
3 => 'Dolgotrajno brezposelni (pobuda za zaposlovanje mladih)',
|
|
4 => 'Neaktivni (ESS)',
|
|
5 => 'Neaktivni (pobuda za zaposlovanje mladih)',
|
|
6 => 'Neaktivni, ki niso vključeni v izobraževanje ali usposabljanje (ESS)',
|
|
7 => 'Neaktivni, ki niso vključeni v izobraževanje ali usposabljanje (pobuda za zaposlovanje mladih)',
|
|
8 => 'Zaposleni, vključno s samozaposlenimi',
|
|
9 => 'Mlajši od 25 let (ESS)',
|
|
10 => 'Mlajši od 25 let (pobuda za zaposlovanje mladih)',
|
|
11 => 'Starejši od 54 let',
|
|
12 => 'Starejši od 54 let, ki so brezposelni, vključno z dolgotrajno brezposelnimi, ali neaktivni in niso vključeni v izobraževanje ali usposabljanje',
|
|
13 => 'S primarno (ISCED 1) ali nižjo sekundarno izobrazbo (ISCED 2) (ESS)',
|
|
14 => 'S primarno (ISCED 1) ali nižjo sekundarno izobrazbo (ISCED 2) (pobuda za zaposlovanje mladih)',
|
|
15 => 'Z višjo sekundarno (ISCED 3) ali postsekundarno izobrazbo (ISCED 4) (ESS)',
|
|
16 => 'Z višjo sekundarno (ISCED 3) ali postsekundarno izobrazbo (ISCED 4) (pobuda za zaposlovanje mladih)',
|
|
17 => 'S terciarno izobrazbo (ISCED 5 do 8) (ESS)',
|
|
18 => 'S terciarno izobrazbo (ISCED 5 do 8) (pobuda za zaposlovanje mladih)',
|
|
19 => 'Udeleženci, ki živijo v gospodinjstvu brez delovno aktivnih članov (ESS)',
|
|
20 => 'Udeleženci, ki živijo v gospodinjstvu brez delovno aktivnih članov (pobuda za zaposlovanje mladih)',
|
|
21 => 'Udeleženci, ki živijo v gospodinjstvu brez delovno aktivnih članov z vzdrževanimi otroki (ESS)',
|
|
22 => 'Udeleženci, ki živijo v gospodinjstvu brez delovno aktivnih članov z vzdrževanimi otroki (pobuda za zaposlovanje mladih)'
|
|
);
|
|
|
|
foreach($rows as $key => $val){
|
|
|
|
// Samo te kategorije imajo vrednosti
|
|
if($key == 8 || /*$key == 9 ||*/ $key == 10 || $key == 11){
|
|
|
|
// nad 55 let
|
|
if($key == 11)
|
|
$index = '55';
|
|
// do 25 let
|
|
elseif($key == 9 || $key == 10)
|
|
$index = '25';
|
|
// ostali
|
|
else
|
|
$index = '25-55';
|
|
|
|
|
|
// Nastavimo default vrednosti ce so prazne
|
|
if(!isset($this->calculationsSimple[$index]['spol']['m']))
|
|
$this->calculationsSimple[$index]['spol']['m'] = 0;
|
|
if(!isset($this->calculationsSimple[$index]['spol']['z']))
|
|
$this->calculationsSimple[$index]['spol']['z'] = 0;
|
|
|
|
foreach($this->calculationsSimple['all'] as $year => $x){
|
|
if($year != 'spol'){
|
|
if(!isset($this->calculationsSimple[$index][$year]['m']))
|
|
$this->calculationsSimple[$index][$year]['m'] = 0;
|
|
if(!isset($this->calculationsSimple[$index][$year]['z']))
|
|
$this->calculationsSimple[$index][$year]['z'] = 0;
|
|
}
|
|
}
|
|
|
|
|
|
$rowData = '<tr>';
|
|
|
|
// Naslov
|
|
$rowData .= '<td>'.$val.'</td>';
|
|
|
|
// Kategorija regije
|
|
$rowData .= '<td></td>';
|
|
|
|
// Ciljna vrednost - skupaj
|
|
if($key == 8)
|
|
$rowData .= '<td>20690</td>';
|
|
else
|
|
$rowData .= '<td></td>';
|
|
// Ciljna vrednost - m
|
|
$rowData .= '<td></td>';
|
|
// Ciljna vrednost - z
|
|
$rowData .= '<td></td>';
|
|
|
|
// Podatki po letih
|
|
foreach($this->calculationsSimple['all'] as $year => $val){
|
|
if($year != 'spol'){
|
|
// m
|
|
$rowData .= '<td>'.$this->calculationsSimple[$index][$year]['m'].'</td>';
|
|
// z
|
|
$rowData .= '<td>'.$this->calculationsSimple[$index][$year]['z'].'</td>';
|
|
}
|
|
}
|
|
|
|
|
|
// Zbirna vrednost - skupaj
|
|
$rowData .= '<td>'.($this->calculationsSimple[$index]['spol']['m'] + $this->calculationsSimple[$index]['spol']['z']).'</td>';
|
|
// Zbirna vrednost - m
|
|
$rowData .= '<td>'.$this->calculationsSimple[$index]['spol']['m'].'</td>';
|
|
// Zbirna vrednost - z
|
|
$rowData .= '<td>'.$this->calculationsSimple[$index]['spol']['z'].'</td>';
|
|
|
|
// Stopnja uresnicevanja - skupaj
|
|
if($key == 8)
|
|
$rowData .= '<td>'.round(($this->calculationsSimple[$index]['spol']['m'] + $this->calculationsSimple[$index]['spol']['z']) / 20690 * 100, 2).' %</td>';
|
|
else
|
|
$rowData .= '<td></td>';
|
|
// Stopnja uresnicevanja - m
|
|
$rowData .= '<td></td>';
|
|
// Stopnja uresnicevanja - z
|
|
$rowData .= '<td></td>';
|
|
|
|
$rowData .= '</tr>';
|
|
}
|
|
else{
|
|
$rowData = '<tr>';
|
|
|
|
// Naslov
|
|
$rowData .= '<td>'.$val.'</td>';
|
|
|
|
// Kategorija regije
|
|
$rowData .= '<td>0</td>';
|
|
|
|
// Ciljna vrednost - skupaj
|
|
$rowData .= '<td>0</td>';
|
|
// Ciljna vrednost - m
|
|
$rowData .= '<td>0</td>';
|
|
// Ciljna vrednost - z
|
|
$rowData .= '<td>0</td>';
|
|
|
|
// Podatki po letih
|
|
foreach($this->calculationsSimple['all'] as $year => $val){
|
|
if($year != 'spol'){
|
|
$rowData .= '<td>0</td>';
|
|
$rowData .= '<td>0</td>';
|
|
}
|
|
}
|
|
|
|
// Zbirna vrednost - skupaj
|
|
$rowData .= '<td>0</td>';
|
|
// Zbirna vrednost - m
|
|
$rowData .= '<td>0</td>';
|
|
// Zbirna vrednost - z
|
|
$rowData .= '<td>0</td>';
|
|
|
|
// Stopnja uresnicevanja - skupaj
|
|
$rowData .= '<td>0</td>';
|
|
// Stopnja uresnicevanja - m
|
|
$rowData .= '<td>0</td>';
|
|
// Stopnja uresnicevanja - z
|
|
$rowData .= '<td>0</td>';
|
|
|
|
$rowData .= '</tr>';
|
|
}
|
|
|
|
fwrite($file_handler, $rowData);
|
|
}
|
|
|
|
|
|
fwrite($file_handler, '</table>');
|
|
fclose($file_handler);
|
|
|
|
|
|
ob_clean();
|
|
|
|
$file_url = $temp_folder.'mju2_'.$this->anketa.'.xls';
|
|
header('Content-Type: application/vnd.ms-excel; charset="'.$convertTypes[$convertType]['charSet'].'"');
|
|
header("Content-Transfer-Encoding: Binary");
|
|
header("Content-disposition: attachment; filename=\"" . basename($file_url) . "\"");
|
|
readfile($file_url);
|
|
|
|
unlink ($temp_folder.'mju2_'.$this->anketa.'.xls');
|
|
|
|
exit;
|
|
}
|
|
|
|
// Izracunamo podatke za enostaven izvoz
|
|
private function analyseDataSimple(){
|
|
|
|
// Zakesiramo vse respondente - SAMO STATUS 6 in 5
|
|
$sql = sisplet_query("SELECT id, time_insert FROM srv_user WHERE ank_id='".$this->anketa."' AND lurker='0' AND (last_status='6' OR last_status='5')");
|
|
while($row = mysqli_fetch_array($sql)){
|
|
|
|
$usr_id = $row['id'];
|
|
$usr_insert_year = date('Y', strtotime($row['time_insert']));
|
|
|
|
// Ce se ni izpolnjeval ankete
|
|
$sql2 = sisplet_query("SELECT v.variable, d.usr_id
|
|
FROM srv_spremenljivka s, srv_vrednost v, srv_data_vrednost".$this->db_table." d
|
|
WHERE s.variable='mjuP2' AND d.usr_id='".$usr_id."'
|
|
AND s.id=v.spr_id AND d.vre_id=v.id AND d.spr_id=s.id");
|
|
$row2 = mysqli_fetch_array($sql2);
|
|
if($row2['variable'] == '2'){
|
|
|
|
// Pridobimo spol
|
|
$sql3 = sisplet_query("SELECT v.variable, d.usr_id
|
|
FROM srv_spremenljivka s, srv_vrednost v, srv_data_vrednost".$this->db_table." d
|
|
WHERE s.variable='Spol' AND d.usr_id='".$usr_id."'
|
|
AND s.id=v.spr_id AND d.vre_id=v.id AND d.spr_id=s.id");
|
|
$row3 = mysqli_fetch_array($sql3);
|
|
$spol = $row3['variable'];
|
|
|
|
|
|
// Pridobimo starost
|
|
$sql4 = sisplet_query("SELECT v.variable, d.usr_id
|
|
FROM srv_spremenljivka s, srv_vrednost v, srv_data_vrednost".$this->db_table." d
|
|
WHERE s.variable='Star' AND d.usr_id='".$usr_id."'
|
|
AND s.id=v.spr_id AND d.vre_id=v.id AND d.spr_id=s.id");
|
|
$row4 = mysqli_fetch_array($sql4);
|
|
$starost = $row4['variable'];
|
|
|
|
// Napolnimo vrednost ce so odgovorili na oba
|
|
if($spol > 0 && $starost > 0){
|
|
|
|
// do 25 let
|
|
if($starost == '1'){
|
|
if($spol == '1'){
|
|
$this->calculationsSimple['25']['spol']['m'] = (isset($this->calculationsSimple['25']['spol']['m'])) ? $this->calculationsSimple['25']['spol']['m']+1 : 1;
|
|
$this->calculationsSimple['25'][$usr_insert_year]['m'] = (isset($this->calculationsSimple['25'][$usr_insert_year]['m'])) ? $this->calculationsSimple['25'][$usr_insert_year]['m']+1 : 1;
|
|
}
|
|
elseif($spol == '2'){
|
|
$this->calculationsSimple['25']['spol']['z'] = (isset($this->calculationsSimple['25']['spol']['z'])) ? $this->calculationsSimple['25']['spol']['z']+1 : 1;
|
|
$this->calculationsSimple['25'][$usr_insert_year]['z'] = (isset($this->calculationsSimple['25'][$usr_insert_year]['z'])) ? $this->calculationsSimple['25'][$usr_insert_year]['z']+1 : 1;
|
|
}
|
|
}
|
|
// nad 55 let
|
|
elseif($starost == '4'){
|
|
if($spol == '1'){
|
|
$this->calculationsSimple['55']['spol']['m'] = (isset($this->calculationsSimple['55']['spol']['m'])) ? $this->calculationsSimple['55']['spol']['m']+1 : 1;
|
|
$this->calculationsSimple['55'][$usr_insert_year]['m'] = (isset($this->calculationsSimple['55'][$usr_insert_year]['m'])) ? $this->calculationsSimple['55'][$usr_insert_year]['m']+1 : 1;
|
|
}
|
|
elseif($spol == '2'){
|
|
$this->calculationsSimple['55']['spol']['z'] = (isset($this->calculationsSimple['55']['spol']['z'])) ? $this->calculationsSimple['55']['spol']['z']+1 : 1;
|
|
$this->calculationsSimple['55'][$usr_insert_year]['z'] = (isset($this->calculationsSimple['55'][$usr_insert_year]['z'])) ? $this->calculationsSimple['55'][$usr_insert_year]['z']+1 : 1;
|
|
}
|
|
}
|
|
// ostali
|
|
else{
|
|
if($spol == '1'){
|
|
$this->calculationsSimple['25-55']['spol']['m'] = (isset($this->calculationsSimple['25-55']['spol']['m'])) ? $this->calculationsSimple['25-55']['spol']['m']+1 : 1;
|
|
$this->calculationsSimple['25-55'][$usr_insert_year]['m'] = (isset($this->calculationsSimple['25-55'][$usr_insert_year]['m'])) ? $this->calculationsSimple['25-55'][$usr_insert_year]['m']+1 : 1;
|
|
}
|
|
elseif($spol == '2'){
|
|
$this->calculationsSimple['25-55']['spol']['z'] = (isset($this->calculationsSimple['25-55']['spol']['z'])) ? $this->calculationsSimple['25-55']['spol']['z']+1 : 1;
|
|
$this->calculationsSimple['25-55'][$usr_insert_year]['z'] = (isset($this->calculationsSimple['25-55'][$usr_insert_year]['z'])) ? $this->calculationsSimple['25-55'][$usr_insert_year]['z']+1 : 1;
|
|
}
|
|
}
|
|
|
|
if($spol == '1'){
|
|
$this->calculationsSimple['all']['spol']['m'] = (isset($this->calculationsSimple['all']['spol']['m'])) ? $this->calculationsSimple['all']['spol']['m']+1 : 1;
|
|
$this->calculationsSimple['all'][$usr_insert_year]['m'] = (isset($this->calculationsSimple['all'][$usr_insert_year]['m'])) ? $this->calculationsSimple['all'][$usr_insert_year]['m']+1 : 1;
|
|
}
|
|
elseif($spol == '2'){
|
|
$this->calculationsSimple['all']['spol']['z'] = (isset($this->calculationsSimple['all']['spol']['z'])) ? $this->calculationsSimple['all']['spol']['z']+1 : 1;
|
|
$this->calculationsSimple['all'][$usr_insert_year]['z'] = (isset($this->calculationsSimple['all'][$usr_insert_year]['z'])) ? $this->calculationsSimple['all'][$usr_insert_year]['z']+1 : 1;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
} |