'==', # ==
'1'=>'≠', # ≠
'2'=>'<', # <
'3'=>'>', # >
'4'=>'<=', # <=
'5'=>'>=', # >=
'6'=>'interval' # interval
);
/**
* konstruktor
*
* @param mixed $anketa
*/
function __construct ($anketa = 0, $spremenljivka = 0) {
if ((int)$anketa > 0 && (int)$spremenljivka > 0) {
self::$anketa = $anketa;
self::$spremenljivka = $spremenljivka;
SurveyInfo::getInstance()->SurveyInit($anketa);
self::$db_table = SurveyInfo::getInstance()->getSurveyArchiveDBString();
# polovimo manjkajoče privzete vrednosti ankete
self::$smv = new SurveyMissingValues(self::$anketa);
self::$smv -> Init();
self::$cacheSpremenljivka = Cache::srv_spremenljivka(self::$spremenljivka);
}
}
public static function DisplayMissingValuesForQuestion($displayForm=true) {
global $lang;
echo '
';
}
/** Naloži manjkajoče vrednosti za spremenljivko
*
*
* Enter description here ...
*/
private static function LoadSpremenljivkaMissingValues($spremenljivka=null) {
global $lang;
if ($spremenljivka == null) {
$spremenljivka = self::$spremenljivka;
}
$cacheSpremenljivka = Cache::srv_spremenljivka($spremenljivka);
self::$options = array();
self::$variables = array();
if ((int)$spremenljivka > 0) {
self::$options['_0_'] = array('naslov'=>$lang['srv_recode_type0'], 'variable'=>null, 'type'=>0);
switch ($cacheSpremenljivka['tip']) {
case 1: # radio
case 3: # select
$sql1 = sisplet_query("SELECT id, naslov, variable FROM srv_vrednost WHERE spr_id = '".$spremenljivka."' ORDER BY vrstni_red ASC");
if (!$sql1) echo mysqli_error($GLOBALS['connect_db']);
if (mysqli_num_rows($sql1)) {
while ($row1 = mysqli_fetch_assoc($sql1)) {
self::$variables[$row1['id']] = array('naslov'=>$row1['naslov'], 'variable'=>$row1['variable']);
self::$options[$row1['id']] = array('naslov'=>$row1['naslov'], 'variable'=>$row1['variable'], 'type'=>0);
}
}
break;
case 17: # razvrščanje
$sql1 = sisplet_query("SELECT id, naslov, vrstni_red FROM srv_vrednost WHERE spr_id = '".$spremenljivka."' ORDER BY vrstni_red ASC");
if (!$sql1) echo mysqli_error($GLOBALS['connect_db']);
if (mysqli_num_rows($sql1)) {
while ($row1 = mysqli_fetch_assoc($sql1)) {
self::$variables[$row1['id']] = array('naslov'=>$row1['naslov'], 'variable'=>$row1['vrstni_red']);
self::$options[$row1['id']] = array('naslov'=>$row1['naslov'], 'variable'=>$row1['vrstni_red'], 'type'=>0);
}
}
break;
case 2: # checkbox
self::$variables['1'] = array('naslov'=>'izbran', 'variable'=>'1');
self::$variables['0'] = array('naslov'=>'neizbran', 'variable'=>'0');
self::$options['1'] = array('naslov'=>'izbran', 'variable'=>'1', 'type'=>0);
self::$options['0'] = array('naslov'=>'neizbran', 'variable'=>'0', 'type'=>0);
break;
case 6: # multiradio
case 19: # multitext
case 20: # multinumber
$sql1 = sisplet_query("SELECT naslov, variable FROM srv_grid WHERE spr_id='".$spremenljivka."' ORDER BY vrstni_red ASC");
if (!$sql1) echo mysqli_error($GLOBALS['connect_db']);
if (mysqli_num_rows($sql1)) {
while ($row1 = mysqli_fetch_assoc($sql1)) {
self::$variables[$row1['variable']] = array('naslov'=>$row1['naslov'], 'variable'=>$row1['variable']);
self::$options[$row1['variable']] = array('naslov'=>$row1['naslov'], 'variable'=>$row1['variable']);
}
}
break;
case 16: # multicheckbox
self::$variables['0'] = array('naslov'=>'izbran', 'variable'=>'0');
self::$variables['1'] = array('naslov'=>'neizbran', 'variable'=>'1');
self::$options['0'] = array('naslov'=>'izbran', 'variable'=>'0', 'type'=>0);
self::$options['1'] = array('naslov'=>'neizbran', 'variable'=>'1', 'type'=>0);
break;
}
}
# dodamo manjkajoče vrednosti če še niso
# preberemo možne manjkajoče vrednosti
$smvs = self::$smv-> GetSystemFlterByType(array(1));
# zgeneriramo matriko izbranih manjkajočih vrednosti za anketo (anketne oz. sistemske mv)
self::$options['_1_'] = array('naslov'=>$lang['srv_recode_type1'], 'variable'=>null, 'type'=>0);
if (count($smvs)> 0) {
foreach ($smvs AS $key => $value) {
self::$options[$key] = array('naslov'=>$value, 'variable'=>$key, 'type'=>1);
}
}
$smvs = self::$smv-> GetSystemFlterByType(array(2,3));
# zgeneriramo matriko izbranih manjkajočih vrednosti za anketo (anketne oz. sistemske mv)
self::$options['_2_'] = array('naslov'=>$lang['srv_recode_type2'], 'variable'=>null, 'type'=>0);
if (count($smvs)> 0) {
foreach ($smvs AS $key => $value) {
self::$options[$key] = array('naslov'=>$value, 'variable'=>$key, 'type'=>2);
}
}
}
private static function show_new_mv_div() {
echo '';
self::show_new_mv();
echo '
';
}
private static function show_new_mv() {
global $lang;
echo 'Izberi vrednost:';
echo '';
echo '
';
echo self::$spremenljivka;
echo '
';
echo '';
echo ''.$lang['add'].'';
echo '';
echo '';
echo ''.$lang['srv_cancel'].'';
echo '';
}
private static function new_mv_add() {
echo 'Napaka!!!';
self::show_new_mv();
}
public static function Ajax() {
switch ($_GET['a']) {
case 'show_new_mv':
self::show_new_mv_div();
break;
case 'new_mv_add':
#self::new_mv_add();
break;
case 'refresh_mv':
self::DisplayMissingValuesForQuestion();
break;
case 'add_new_numeric':
self::AddNewNumericRecode();
break;
case 'changeRecodeType':
self::changeRecodeType();
break;
default:
# print_r($_POST);
# print_r($_GET);
break;
}
}
public function removeRecodeForQuestion() {
if ((int)self::$anketa > 0 && (int)self::$spremenljivka > 0) {
# odstranimo rekodiranje za spremenljivko
$sql = sisplet_query("DELETE FROM srv_recode WHERE ank_id = '".self::$anketa."' AND spr_id = '".self::$spremenljivka."'");
if (!$sql) echo mysqli_error($GLOBALS['connect_db']);
# preverimo ali imamo rekodiranje v novo spremenljivko, če ja, kasneje ponudimo tud izbris psremenljivke
$qry = sisplet_query("SELECT to_spr_id FROM srv_recode_spremenljivka WHERE ank_id = '".self::$anketa."' AND spr_id = '".self::$spremenljivka."'");
list($spr_id) = mysqli_fetch_row($qry);
# pobrišemo še zapise v srv_recode_vrednost in srv_recode spremenljika
$sql = sisplet_query("DELETE FROM srv_recode_spremenljivka WHERE ank_id = '".self::$anketa."' AND spr_id = '".self::$spremenljivka."'");
if (!$sql) echo mysqli_error($GLOBALS['connect_db']);
$sql = sisplet_query("DELETE FROM srv_recode_vrednost WHERE ank_id = '".self::$anketa."' AND spr1 = '".self::$spremenljivka."'");
if (!$sql) echo mysqli_error($GLOBALS['connect_db']);
sisplet_query("COMMIT");
return (int)$spr_id;
} else {
return 0;
}
}
public function SetUpMissingValuesForQuestion() {
if ((int)self::$anketa > 0 ) {
# pobrišemo rekodirane vrednosti za morebitno rekodiranje v novo spremenljivko
if (isset($_REQUEST['recodeToSpr']) && (int)$_REQUEST['recodeToSpr'] > 0) {
$sql = sisplet_query("DELETE FROM srv_recode_vrednost WHERE ank_id = '".self::$anketa."' AND spr2 = '".(int)$_REQUEST['recodeToSpr']."'");
if (!$sql) echo mysqli_error($GLOBALS['connect_db']);
}
# če imamo spremembe je potrebno na novo zgenerirati datoteko
$strSelect = "SELECT search, value, operator FROM srv_recode WHERE ank_id = '".self::$anketa."' AND spr_id = '".self::$spremenljivka."' ORDER BY vrstni_red";
$sqlSelect = sisplet_query($strSelect);
$rowsBefore = array();
$rowsAfter = array();
while (list($search, $value, $operator) = mysqli_fetch_row($sqlSelect)) {
$rowsBefore[] = $search."_".$value."_".(int)$operator;
}
# pobrišemo vse obstoječe zamenjave
$sql = sisplet_query("DELETE FROM srv_recode WHERE ank_id = '".self::$anketa."' AND spr_id = '".self::$spremenljivka."'");
if (!$sql) echo mysqli_error($GLOBALS['connect_db']);
#rekodiramo kategorije
if ( isset($_REQUEST['edit_recode_mv']) ) {
# dodamo potrebne zamenjave za
$_for_replace = "";
foreach ($_REQUEST as $key => $value) {
$_tmp_value = substr($key, 5);
if (substr($key, 0, 5) == 'MVFQ_' && $_tmp_value != $value) {
if ($_for_replace != "") { $_for_replace .= ","; }
$_for_replace .= " ('".self::$anketa."', '".self::$spremenljivka."', '$_tmp_value', '$value') ";
}
}
# če moramo uporabiti zamenjave:
if ($_for_replace != "") {
$insertString = 'INSERT INTO srv_recode (ank_id, spr_id, search, value) VALUES '.$_for_replace;
$sql1 = sisplet_query($insertString);
}
} else if( isset($_REQUEST['edit_recode_number']) ){
# rekodiramo numerične
$recoded = array();
if (isset($_REQUEST['recode_number_operator'])) {
foreach ($_REQUEST['recode_number_operator'] as $key => $value) {
$recoded[$key]['operator'] = $value;
}
}
if (isset($_REQUEST['recode_number_search'])) {
foreach ($_REQUEST['recode_number_search'] as $key => $value) {
$recoded[$key]['search'] = trim($value);
}
}
if (isset($_REQUEST['recode_number_search1'])) {
foreach ($_REQUEST['recode_number_search1'] as $key => $value) {
$recoded[$key]['search1'] = trim($value);
}
}
if (isset($_REQUEST['recode_number_search2'])) {
foreach ($_REQUEST['recode_number_search2'] as $key => $value) {
$recoded[$key]['search2'] = trim($value);
}
}
if (isset($_REQUEST['recode_number_value'])) {
foreach ($_REQUEST['recode_number_value'] as $key => $value) {
$recoded[$key]['value'] = trim($value);
}
}
# pripravimo query
if (count($recoded) > 0) {
$_for_replace = "";
$already_set = array();
$vrstni_red = 1;
foreach ($recoded AS $rKey => $recode) {
$opreand = (int)$recode['operator'];
if ( $opreand != 6) {
$_search = $recode['search'];
} else {
$_search = $recode['search1'].','.$recode['search2'];
}
if ( $_search != '' && $recode['value'] != ''
#preprečimo zamenjavo iste vrednosti z istim operatorejm.
&& !( isset($already_set[$_search.'_'.$recode['operator']] ))
) {
if ($_for_replace != "") {
$_for_replace .= ",";
}
$_for_replace .= " ('".self::$anketa."', '".self::$spremenljivka."', '$vrstni_red', '$_search', '".trim($recode['value'])."', '".(int)trim($recode['operator'])."') ";
$already_set[$_search.'_'.$recode['operator']] = true;
}
$vrstni_red ++;
}
if ($_for_replace != "") {
# izvedemo insert query
$insertString = 'INSERT INTO srv_recode (ank_id, spr_id, vrstni_red, search, value, operator) VALUES '.$_for_replace;
$sql1 = sisplet_query($insertString);
if (!$sql1) {
print_r(mysqli_error($GLOBALS['connect_db']));
}
}
}
}
sisplet_query("COMMIT");
# če imamo spremembe je potrebno na novo zgenerirati datoteko
$strSelect = "SELECT search, value, operator FROM srv_recode WHERE ank_id = '".self::$anketa."' AND spr_id = '".self::$spremenljivka."' ORDER BY vrstni_red";
$sqlSelect = sisplet_query($strSelect);
while (list($search, $value, $operator) = mysqli_fetch_row($sqlSelect)) {
$rowsAfter[] = $search."_".$value."_".(int)$operator;
}
if ( (count( array_diff($rowsBefore, $rowsAfter) ) + count( array_diff($rowsAfter, $rowsBefore) ) ) > 0) {
# array-a nista enaka, imamo spremembe
# pobrišimo datoteko, da se podatki zgenerirajo na novo
global $site_path;
$data_file_name = $site_path.'admin/survey/SurveyData/export_data_'.self::$anketa.'.dat';
if (file_exists($data_file_name)) {
unlink($data_file_name);
}
return true;
}
return false;
}
return false;
}
public function SetRecodeNumberNewVrednost() {
if ((int)self::$anketa > 0 && (int)$_REQUEST['recode_type']== 1 && (int)$_REQUEST['edit_recode_number'] == 1) {
# pobrišemo rekodirane vrednosti za morebitno rekodiranje v novo spremenljivko
if ((int)self::$spremenljivka > 0) {
$sql = sisplet_query("DELETE FROM srv_recode_vrednost WHERE ank_id = '".self::$anketa."' AND spr1 = '".(int)self::$spremenljivka."'");
if (!$sql) echo mysqli_error($GLOBALS['connect_db']);
}
# pobrišemo vse mmorebitne obstoječe zamenjave za normalni number
$sql = sisplet_query("DELETE FROM srv_recode WHERE ank_id = '".self::$anketa."' AND spr_id = '".self::$spremenljivka."'");
if (!$sql) echo mysqli_error($GLOBALS['connect_db']);
# pobrišemo vse morebitne obstoječe zamenjave za number
$sql = sisplet_query("DELETE FROM srv_recode_number WHERE ank_id = '".self::$anketa."' AND spr_id = '".self::$spremenljivka."'");
if (!$sql) echo mysqli_error($GLOBALS['connect_db']);
if( isset($_REQUEST['recode_number_vrednost']) ){
# rekodiramo numerične
$recoded = array();
if (isset($_REQUEST['recode_number_operator'])) {
foreach ($_REQUEST['recode_number_operator'] as $key => $value) {
$recoded[$key]['operator'] = $value;
}
}
if (isset($_REQUEST['recode_number_search'])) {
foreach ($_REQUEST['recode_number_search'] as $key => $value) {
$recoded[$key]['search'] = trim($value);
}
}
if (isset($_REQUEST['recode_number_search1'])) {
foreach ($_REQUEST['recode_number_search1'] as $key => $value) {
$recoded[$key]['search1'] = trim($value);
}
}
if (isset($_REQUEST['recode_number_search2'])) {
foreach ($_REQUEST['recode_number_search2'] as $key => $value) {
$recoded[$key]['search2'] = trim($value);
}
}
if (isset($_REQUEST['recode_number_vrednost'])) {
foreach ($_REQUEST['recode_number_vrednost'] as $key => $value) {
$recoded[$key]['value'] = trim($value);
}
}
# pripravimo query
if (count($recoded) > 0) {
$_for_replace = "";
$already_set = array();
$vrstni_red = 1;
foreach ($recoded AS $rKey => $recode) {
$opreand = (int)$recode['operator'];
if ( $opreand != 6) {
$_search = $recode['search'];
} else {
$_search = $recode['search1'].','.$recode['search2'];
}
if ( $_search != '' && $recode['value'] != ''
#preprečimo zamenjavo iste vrednosti z istim operatorejm.
&& !( isset($already_set[$_search.'_'.$recode['operator']] ))
) {
if ($_for_replace != "") {
$_for_replace .= ",";
}
$_for_replace .= " ('".self::$anketa."', '".self::$spremenljivka."', '$vrstni_red', '$_search', '".trim($recode['value'])."', '".(int)trim($recode['operator'])."') ";
$already_set[$_search.'_'.$recode['operator']] = true;
}
$vrstni_red ++;
}
if ($_for_replace != "") {
# izvedemo insert query
$insertString = 'INSERT INTO srv_recode_number (ank_id, spr_id, vrstni_red, search, vred_id, operator) VALUES '.$_for_replace;
$sql1 = sisplet_query($insertString);
if (!$sql1) {
print_r(mysqli_error($GLOBALS['connect_db']));
}
}
}
}
sisplet_query("COMMIT");
}
return false;
}
public function AddNewNumericRecode() {
global $lang;
$recode_type = (int)$_POST['recode_type'];
self::LoadSpremenljivkaMissingValues();
if ( $recode_type == 0) {
echo '';
echo '';
printf($lang['srv_recode_number_if'],self::$cacheSpremenljivka['variable']);
echo ' ';
#echo ' ';
echo '';
echo ' ';
echo '';
echo '';
echo ' [,';
echo ']';
echo '';
echo ' '.$lang['srv_recode_number_to'];
echo '';
echo ' ';
echo ' ';
echo '';
} else {
# polovimo osnovne lastnosti rekodiranja
$selectString = "SELECT to_spr_id FROM srv_recode_spremenljivka WHERE ank_id='".self::$anketa."' AND spr_id='".self::$spremenljivka."'";
$sqlSelect = sisplet_query($selectString);
if (!$sqlSelect) echo mysqli_error($GLOBALS['connect_db']);
list($to_spr_id) = mysqli_fetch_row($sqlSelect);
self::LoadSpremenljivkaMissingValues($to_spr_id);
$new_spr_vrednosti = self::$options;
self::LoadSpremenljivkaMissingValues(self::$spremenljivka);
echo '';
echo '';
printf($lang['srv_recode_number_if'],self::$cacheSpremenljivka['variable']);
echo ' ';
#echo ' ';
echo '';
echo ' ';
echo '';
echo '';
echo ' [,';
echo ']';
echo '';
echo ' '.$lang['srv_recode_number_to'];
# imamo rekodiranje v novo spremenljivko
$recode['vred_id'] = '-1';
echo '';
echo ' ';
echo '';
}
return;
}
public function hasRecodedValues() {
#preštejemo koliko rekodiranj imamo za spremenljivko
$strSelect = "SELECT count(*) FROM srv_recode WHERE ank_id = '".self::$anketa."' AND spr_id = '".self::$spremenljivka."'";
$sqlSelect = sisplet_query($strSelect);
list($count) = mysqli_fetch_row($sqlSelect);
return (int)$count;
}
public function changeRecodeType() {
$insertString = "INSERT INTO srv_recode_spremenljivka (ank_id, spr_id, recode_type, to_spr_id) VALUES ('".self::$anketa."', '".self::$spremenljivka."', '".(int)$_POST['recode_type']."', '".(int)$_POST['recodeToSpr']."') ON DUPLICATE KEY UPDATE recode_type = '".(int)$_POST['recode_type']."', to_spr_id = '".(int)$_POST['recodeToSpr']."'";
$sqlInsert = sisplet_query($insertString);
self::displayRecodeType();
}
public static function displayRecodeType() {
global $lang;
$tip = self::$cacheSpremenljivka['tip'];
if (in_array($tip, array(
1, # radio
2, # checkbox
3, # select
6, # multiradio
16, # multicheck
17 # razvrščanje
))) {
$displayType=1;
} else if (in_array($tip, array(
7, # number
18, # vsota
20, # multinumber
22, # multinumber
21, # textovni
))) {
$displayType=2;
}
# polovimo osnovne lastnosti rekodiranja
$selectString = "SELECT recode_type, to_spr_id FROM srv_recode_spremenljivka WHERE ank_id='".self::$anketa."' AND spr_id='".self::$spremenljivka."'";
$sqlSelect = sisplet_query($selectString);
if (!$sqlSelect) echo mysqli_error($GLOBALS['connect_db']);
list($recode_type, $to_spr_id) = mysqli_fetch_row($sqlSelect);
if ((int)$recode_type == 0) {
self::LoadSpremenljivkaMissingValues(self::$spremenljivka);
# polovimo missinge za spremenljivko
$strSelect = "SELECT search, value, operator FROM srv_recode WHERE ank_id = '".self::$anketa."' AND spr_id = '".self::$spremenljivka."' ORDER BY vrstni_red";
$sqlSelect = sisplet_query($strSelect);
if (!$sqlSelect) echo mysqli_error($GLOBALS['connect_db']);
$recoded = array();
if (mysqli_num_rows($sqlSelect)) {
while ($rowSelect = mysqli_fetch_assoc($sqlSelect)) {
$recoded[$rowSelect['search'].'_'.$rowSelect['operator']] = array('search'=>$rowSelect['search'],'value'=>$rowSelect['value'],'operator'=>$rowSelect['operator']);
}
}
} else {
if ($displayType == 1) {
# polovimo še vrednosti če imamo rekodirano v drugo spremenljivko
$qry_str = "select vre1, spr2, vre2 from srv_recode_vrednost WHERE ank_id = '".self::$anketa."' AND spr1 = '".self::$spremenljivka."'";
$sql = sisplet_query($qry_str);
$recodedFrom = array();
while (list($vre1, $spr1, $vre2) = mysqli_fetch_row($sql)) {
$recodedFrom[$vre1] = $vre2;
}
} else {
# polovimo missinge za spremenljivko
$strSelect = "SELECT search, vred_id, operator FROM srv_recode_number WHERE ank_id = '".self::$anketa."' AND spr_id = '".self::$spremenljivka."' ORDER BY vrstni_red";
$sqlSelect = sisplet_query($strSelect);
if (!$sqlSelect) echo mysqli_error($GLOBALS['connect_db']);
$recoded = array();
if (mysqli_num_rows($sqlSelect)) {
while ($rowSelect = mysqli_fetch_assoc($sqlSelect)) {
$recoded[$rowSelect['search'].'_'.$rowSelect['operator']] = array('search'=>$rowSelect['search'],'vred_id'=>$rowSelect['vred_id'],'operator'=>$rowSelect['operator']);
}
}
}
self::LoadSpremenljivkaMissingValues($to_spr_id);
$new_spr_vrednosti = self::$options;
self::LoadSpremenljivkaMissingValues(self::$spremenljivka);
# preverimo ali spremenljvka obstaja
#$new_spr_vrednosti = array();
if ((int)$to_spr_id > 0) {
$sqlSpremenljivka = sisplet_query("SELECT s.naslov, s.variable, s.tip FROM srv_spremenljivka s WHERE s.id = '$to_spr_id'");
$rowSpremenljivka = mysqli_fetch_assoc($sqlSpremenljivka);
if (mysqli_num_rows($sqlSpremenljivka) == 0) {
$to_spr_id = 0;
}
}
}
echo '';
echo '';
echo '';
echo '';
if ( $_GET['t'] == 'charts' || $_POST['recIsCharts'] == 1 ) {
# če smo v grafih in smo na spremenljivki katera je že rekodirana iz druge, potem onemogočimo nadaljnje kodiranje
$strSel = "SELECT count(*) FROM srv_recode_spremenljivka WHERE to_spr_id = '".self::$spremenljivka."'";
$qry = sisplet_query($strSel);
list($cnt) = mysqli_fetch_row($qry);
if ((int)$cnt > 0) {
echo $lang['srv_recoded_advancetNote_recoded3'];
echo self::$cacheSpremenljivka['variable'].' - '.self::$cacheSpremenljivka['naslov'];
echo $lang['srv_recoded_advancetNote_recoded4'];
return;
}
}
if (self::$cacheSpremenljivka['tip'] == 1 || self::$cacheSpremenljivka['tip'] == 3 || self::$cacheSpremenljivka['tip'] == 7) {
if ( (int)$recode_type == 1 && ((int)(($_GET['t'] == 'charts')||((int)$_POST['recIsCharts'] == 1))) ) {
echo '
';
echo $lang['srv_recoded_advancetNote'].''.$lang['srv_here'].'';
echo Help::display('srv_recode_chart_advanced');
echo '
';
echo '
';
echo $lang['srv_recoded_advancetNote_recoded1'];
echo self::$cacheSpremenljivka['variable'];
echo ' - '.strip_tags(self::$cacheSpremenljivka['naslov']);
echo $lang['srv_recoded_advancetNote_recoded2'];
echo $rowSpremenljivka['variable'].' - '.$rowSpremenljivka['naslov'];
return;
}
$sugestedName = strip_tags(self::$cacheSpremenljivka['naslov'].' - recoded');
echo'';
echo '';
} else {
echo '';
echo '';
}
echo '
';
if ((int)$recode_type == 1) {
echo'';
if ((int)$to_spr_id == 0) {
echo '
';
//echo $lang['srv_recode_to_spr_add_spr'].'
';
echo '
';
echo '
'.$lang['srv_recode_to_spr_name'].' ';
#echo ''.$lang['add'].'';
echo '';
echo '
';
echo '
';
echo '
';
} else {
echo '
'.$rowSpremenljivka['variable'].' - '.skrajsaj(strip_tags($rowSpremenljivka['naslov']), 40).'';
$sql1 = sisplet_query("SELECT naslov FROM srv_vrednost WHERE spr_id='$to_spr_id' ORDER BY vrstni_red ASC");
$count = 0;
echo '
'.$lang['srv_recode_valueset'];
while ($row1 = mysqli_fetch_array($sql1)) {
if ($rowSpremenljivka['tip'] == 1) {
if ($count == 0) {
$count = 1;
}
else {
echo ', ';
}
echo $row1['naslov'];
}
}
echo '
';
echo '
';
if (mysqli_num_rows($sql1) == 0) {
echo ' '.$lang['srv_novavrednost'].': '; $margin='0';
} else { $margin = 'none-left';
}
echo '
0?' placeholder="'.$lang['srv_novavrednost'].'" ':'').' /> ';
echo '
';
echo '
Napredne spremembe:'.Help::display('srv_recode_advanced_edit').'
';
echo '
';
}
echo '
';
}
}
if ( $displayType == 1 ) {
if (count(self::$variables)> 0) {
if ((int)$recode_type == 0) {
echo '';
} else {
# rekodiramo v novo spremenljivko
echo '';
}
//echo '';
echo '';
echo '';
echo '';
echo $lang['srv_recode_original'];
echo ' | ';
echo '';
echo $lang['srv_recode_to'];
echo ' | ';
echo '
';
echo '';
echo '';
echo $lang['srv_label'];
echo ' | ';
echo '';
echo $lang['srv_vrednost'];
echo ' | ';
echo '';
echo ' | ';
echo '
';
foreach (self::$variables AS $vKey => $variable) {
echo '';
echo '';
echo $variable['naslov'];
echo ' | ';
echo '';
echo ' ['.$variable['variable'].']';
echo ' | ';
echo '';
if ((int)$recode_type == 0) {
# imamo klasično rekodiranje
echo '';
} else {
# imamo rekodiranje v novo spremenljivko
if (!isset($recodedFrom[$vKey])) {
$recodedFrom[$vKey] = '-1';
}
echo '';
}
echo ' | ';
echo '
';
}
echo '
';
}
} else if ( $displayType == 2) {
# number
if ((int)$recode_type == 0) {
echo '';
echo '';
echo '';
echo ' '.$lang['srv_recode_add_number'].'';
} else {
# number
# recode to new spr
echo '';
echo '';
echo '';
echo ' '.$lang['srv_recode_add_number'].''; }
} else {
echo '
'.$lang['srv_recoding_not_set_jet'].'('.$tip.')
';
}
}
function SetRecodeNewVrednost() {
# pobrišemo morebtne vrednosti v srv_recode (če je bilo predhodno nastavljeno klasično rekodiranje)
$sqlD = sisplet_query("DELETE FROM srv_recode WHERE ank_id = '".self::$anketa."' AND spr_id = '".$_REQUEST['spr_id']."'");
if (!$sqlD) echo mysqli_error($GLOBALS['connect_db']);
sisplet_query("COMMIT");
$newSpr = $_REQUEST['recodeToSpr'];
$_for_replace = "";
if ((int)$newSpr > 0)
foreach ($_REQUEST as $key => $newVrednost) {
if (substr($key, 0, 7) == 'MVSNFQ_' && trim($newVrednost) != '') {
# id stare vrednosti
$oldVrednost = substr($key, 7);
if ($_for_replace != "") {
$_for_replace .= ",";
}
$_for_replace .= " ('".self::$anketa."','".self::$spremenljivka."','$oldVrednost','$newSpr','$newVrednost') ";
}
}
# najprej pobrišemo vse obstoječe vrednosti
$sql = sisplet_query("DELETE FROM srv_recode_vrednost WHERE ank_id = '".self::$anketa."' AND spr1 = '".self::$spremenljivka."'");
if (!$sql) echo mysqli_error($GLOBALS['connect_db']);
sisplet_query("COMMIT");
# če moramo uporabiti zamenjave:
if ($_for_replace != "") {
$insertString = 'INSERT INTO srv_recode_vrednost (ank_id, spr1, vre1, spr2, vre2) VALUES '.$_for_replace;
$sql1 = sisplet_query($insertString);
}
sisplet_query("COMMIT");
}
}