0) {
$this->ank_id = $anketa;
// polovimo vrsto tabel (aktivne / neaktivne)
SurveyInfo :: getInstance()->SurveyInit($this->ank_id);
$this->db_table = SurveyInfo::getInstance()->getSurveyArchiveDBString();
// Inicializiramo in polovimo nastavitve missing profila
SurveyStatusProfiles::Init($this->ank_id);
SurveyUserSetting::getInstance()->Init($this->ank_id, $global_user_id);
SurveyStatusProfiles::Init($this->ank_id);
SurveyMissingProfiles :: Init($this->ank_id,$global_user_id);
SurveyConditionProfiles :: Init($this->ank_id, $global_user_id);
SurveyZankaProfiles :: Init($this->ank_id, $global_user_id);
SurveyTimeProfiles :: Init($this->ank_id, $global_user_id);
SurveyDataSettingProfiles :: Init($this->ank_id);
#inicializiramo class za datoteke
$SDF = SurveyDataFile::get_instance();
$SDF->init($anketa);
$this->headFileName = $SDF->getHeaderFileName();
$this->dataFileName = $SDF->getDataFileName();
$this->dataFileStatus = $SDF->getStatus();
SurveyAnalysis::Init($this->ank_id);
//polovimo podatke o nastavitvah trenutnega profila (missingi..)
SurveyAnalysis::$missingProfileData = SurveyMissingProfiles::getProfile(SurveyAnalysis::$currentMissingProfile);
#preberemo HEADERS iz datoteke
SurveyAnalysis::$_HEADERS = unserialize(file_get_contents($this->headFileName));
# odstranimo sistemske variable tipa email, ime, priimek, geslo
SurveyAnalysis::removeSystemVariables();
# polovimo frekvence
SurveyAnalysis::getFrequencys();
$this->creportProfile = SurveyUserSetting :: getInstance()->getSettings('default_creport_profile');
$this->creportProfile = isset($this->creportProfile) && $this->creportProfile != '' ? $this->creportProfile : 0;
$this->creportAuthor = SurveyUserSetting :: getInstance()->getSettings('default_creport_author');
$this->creportAuthor = isset($this->creportAuthor) && $this->creportAuthor != '' ? $this->creportAuthor : $global_user_id;
$this->expanded = (isset($_GET['expanded'])) ? $_GET['expanded'] : 0;
}
else {
echo 'Invalid Survey ID!';
exit();
}
}
// Izrisemo izdelano porocilo
function displayReport(){
global $lang;
global $global_user_id;
# zakeširamo vsebino, in jo nato po potrebi zapišpemo v html
if ($this->returnAsHtml != false) {
ob_start();
}
if ($this->isArchive == false && $this->publicCReport == false) {
echo '';
$this->displayProfilePopups();
// Prva vrstica - seznam poročil
echo '
';
// Seznam porocil
echo '
';
// Seznam avtorjevih porocil
// Prvo default porocilo
$sql = sisplet_query("SELECT value FROM srv_user_setting_for_survey WHERE sid='$this->ank_id' AND uid='$global_user_id' AND what='creport_default_profile_name'");
if(mysqli_num_rows($sql) == 0){
echo '
';
}
// Loop po ostalih lastnih porocilih
$sqlReports = sisplet_query("SELECT * FROM srv_custom_report_profiles WHERE ank_id='$this->ank_id' AND usr_id='$global_user_id'");
while($rowReports = mysqli_fetch_array($sqlReports)){
echo '
';
echo $rowReports['name'];
echo '
';
}
// Loop po deljenih porocilih
$sqlSharedReports = sisplet_query("SELECT s.*, u.email FROM srv_custom_report_share s, users u WHERE ank_id='$this->ank_id' AND share_usr_id='$global_user_id' AND u.id=s.author_usr_id");
while($rowSharedReports = mysqli_fetch_array($sqlSharedReports)){
// Ce gre za osnovno porocilo ki ga ne more pobrisati
if($rowSharedReports['profile_id'] == 0){
// Dobimo ime osnovnega porocila
$what = 'creport_default_profile_name';
$sqlN = sisplet_query("SELECT value FROM srv_user_setting_for_survey WHERE sid='$this->ank_id' AND uid='".$rowSharedReports['author_usr_id']."' AND what='$what'");
if(mysqli_num_rows($sqlN) == '0'){
$default_name = $lang['srv_custom_report_default'];
}
else{
$rowN = mysqli_fetch_array($sqlN);
$default_name = ($rowN['value'] == '') ? $lang['srv_custom_report_default'] : $rowN['value'];
}
echo '
';
}
// Ce gre za dodatno porocilo ga imamo normalno v bazi
else{
$sql = sisplet_query("SELECT * FROM srv_custom_report_profiles WHERE ank_id='$this->ank_id' AND usr_id='".$rowSharedReports['author_usr_id']."'");
while($row = mysqli_fetch_array($sql)){
echo '
';
if(isset($reportElement['spr1'])&&$expanded != 0){
SurveyAnalysis::displayDescriptives($reportElement['spr1']);
// Na novo napolnimo headers ker se resetira??
SurveyAnalysis::$_HEADERS = unserialize(file_get_contents($this->headFileName));
}
echo '
';
// Loop po lastnih porocilih
$sql = sisplet_query("SELECT * FROM srv_custom_report_profiles WHERE ank_id='$this->ank_id' AND usr_id='$global_user_id'");
while($row = mysqli_fetch_array($sql)){
echo '
'.$row['name'].'
';
// Preberemo cas kreiranja porocila
if($this->creportProfile == $row['id'])
$time_created = $row['time_created'];
}
// Loop po deljenih porocilih drugih urednikov ankete
$sqlA = sisplet_query("SELECT s.*, u.email FROM srv_custom_report_share s, users u WHERE ank_id='$this->ank_id' AND share_usr_id='$global_user_id' AND u.id=s.author_usr_id");
while($rowA = mysqli_fetch_array($sqlA)){
// Ce gre za osnovno porocilo ki ga ne more pobrisati
if($rowA['profile_id'] == 0){
// Dobimo ime osnovnega porocila
$what = 'creport_default_profile_name';
$sqlN = sisplet_query("SELECT value FROM srv_user_setting_for_survey WHERE sid='$this->ank_id' AND uid='".$rowA['author_usr_id']."' AND what='$what'");
if(mysqli_num_rows($sqlN) == '0'){
$default_name = $lang['srv_custom_report_default'];
}
else{
$rowN = mysqli_fetch_array($sqlN);
$default_name = ($rowN['value'] == '') ? $lang['srv_custom_report_default'] : $rowN['value'];
}
echo '
';
}
// Ce gre za dodatno porocilo ga imamo normalno v bazi
else{
$sql = sisplet_query("SELECT * FROM srv_custom_report_profiles WHERE ank_id='$this->ank_id' AND usr_id='".$rowA['author_usr_id']."'");
while($row = mysqli_fetch_array($sql)){
echo '
';
// Preberemo cas kreiranja porocila
if($this->creportProfile == $row['id'])
$time_created = $row['time_created'];
}
}
}
echo '';
// Ce je izbran custom profil imamo na dnu gumba brisi in preimenuj, pri default pa samo preimenuj
// Preimenuje, brise in share lahko samo za lastna porocila
if($this->creportAuthor == $global_user_id){
echo '
'.$lang['srv_rename_profile'].'
';
if($this->creportProfile > 0)
echo '
'.$lang['srv_delete_profile'].'
';
echo '
'.$lang['srv_custom_report_share'].'
';
}
/*/ Preberemo najkasneje editiran element (cas spreminjanja)
$sqlt = sisplet_query("SELECT MAX(time_edit) FROM srv_custom_report WHERE ank_id='$this->ank_id' AND usr_id='$this->creportAuthor' AND profile='$this->creportProfile'");
if(mysqli_num_rows($sqlt) > 0){
$rowt = mysqli_fetch_array($sqlt);
$time_edit = $rowt['MAX(time_edit)'];
}
else
$time_edit = $time_created;
// Cas kreirranja in urejanja profila
echo '
';
$what = 'creport_comment_profile_'.$this->creportProfile;
$sql = sisplet_query("SELECT value FROM srv_user_setting_for_survey WHERE sid='$this->ank_id' AND uid='$this->creportAuthor' AND what='$what'");
if(mysqli_num_rows($sql) == 0){
$comment = '';
}
else{
$row = mysqli_fetch_array($sql);
$comment = $row['value'];
}
echo '
'.$lang['srv_inv_archive_comment'].':
';
// Komentar lahko popravlja samo avtor porocila
if($this->creportAuthor == $global_user_id)
echo '';
else
echo ''.$comment.'';
echo '
';
// cover Div
echo ''."\n";
echo '
';
echo '';
echo '';
echo '';
echo '
';
}
function displayProfilePopups(){
global $lang;
//global $global_user_id;
$profile = $this->getProfile($this->creportProfile);
//$name = $profile['name'];
// div za kreacijo novega
echo '
';
echo '';
echo '';
}
// Funkcije ajaxa
public function ajax() {
global $lang;
global $global_user_id;
global $site_url;
$_GET['m'] = 'analysis_creport';
if (isset ($_POST['anketa']))
$this->ank_id = $_POST['anketa'];
if (isset ($_POST['element_id']))
$element_id = $_POST['element_id'];
if (isset ($_POST['what']))
$what = $_POST['what'];
if (isset ($_POST['value']))
$value = $_POST['value'];
// Nastavimo se nacin (skrcen/razsirjen)
$this->expanded = (isset($_POST['expanded']) ? $_POST['expanded'] : 0);
// Dodajanje praznega elementa v report
if($_GET['a'] == 'add_empty_element'){
// dodajanje vmes
if($element_id > 0){
$sql = sisplet_query("SELECT vrstni_red FROM srv_custom_report WHERE ank_id='$this->ank_id' AND usr_id='$this->creportAuthor' AND id='$element_id' AND profile='$this->creportProfile'");
$row = mysqli_fetch_assoc($sql);
$vrstni_red = $row['vrstni_red'] + 1;
// Prestevilcimo elemente
$sql = sisplet_query("UPDATE srv_custom_report SET vrstni_red=vrstni_red+1 WHERE ank_id='$this->ank_id' AND usr_id='$this->creportAuthor' AND vrstni_red>='$vrstni_red' AND profile='$this->creportProfile'");
$s = sisplet_query("INSERT INTO srv_custom_report (ank_id, usr_id, vrstni_red, profile, time_edit) VALUES('$this->ank_id', '$this->creportAuthor', '$vrstni_red', '$this->creportProfile', NOW())");
if (!$s) echo mysqli_error($GLOBALS['connect_db']);
$el_id = mysqli_insert_id($GLOBALS['connect_db']);
}
//dodajanje na zacetku
elseif($element_id == -1){
// Prestevilcimo elemente
$sql = sisplet_query("UPDATE srv_custom_report SET vrstni_red=vrstni_red+1 WHERE ank_id='$this->ank_id' AND usr_id='$this->creportAuthor' AND profile='$this->creportProfile'");
$s = sisplet_query("INSERT INTO srv_custom_report (ank_id, usr_id, vrstni_red, profile, time_edit) VALUES('$this->ank_id', '$this->creportAuthor', '1', '$this->creportProfile', NOW())");
if (!$s) echo mysqli_error($GLOBALS['connect_db']);
$el_id = mysqli_insert_id($GLOBALS['connect_db']);
}
// dodajanje na koncu
else{
$sql = sisplet_query("SELECT vrstni_red FROM srv_custom_report WHERE ank_id='$this->ank_id' AND usr_id='$this->creportAuthor' AND profile='$this->creportProfile' ORDER BY vrstni_red DESC");
if(mysqli_num_rows($sql) > 0){
$row = mysqli_fetch_assoc($sql);
$vrstni_red = $row['vrstni_red'] + 1;
}
else
$vrstni_red = 1;
$s = sisplet_query("INSERT INTO srv_custom_report (ank_id, usr_id, vrstni_red, profile, time_edit) VALUES('$this->ank_id', '$this->creportAuthor', '$vrstni_red', '$this->creportProfile', NOW())");
if (!$s) echo mysqli_error($GLOBALS['connect_db']);
$el_id = mysqli_insert_id($GLOBALS['connect_db']);
}
$this->displayReport();
echo '';
}
// Dodajanje ze nastavljenega elementa v report (klik na zvezdico)
if($_GET['a'] == 'add_element'){
if (isset ($_POST['type']))
$type = $_POST['type'];
if (isset ($_POST['sub_type']))
$sub_type = $_POST['sub_type'];
if (isset ($_POST['spr1']))
$spr1 = $_POST['spr1'];
if (isset ($_POST['spr2']))
$spr2 = $_POST['spr2'];
if (isset ($_POST['insert']))
$insert = $_POST['insert'];
// Vstavljanje
if($insert == 1){
// Razberemo vrstni red
$sql = sisplet_query("SELECT vrstni_red FROM srv_custom_report WHERE ank_id='$this->ank_id' AND usr_id='$this->creportAuthor' AND profile='$this->creportProfile' ORDER BY vrstni_red DESC");
if(mysqli_num_rows($sql) > 0){
$row = mysqli_fetch_assoc($sql);
$vrstni_red = $row['vrstni_red'] + 1;
}
else
$vrstni_red = 1;
$sql = sisplet_query("INSERT INTO srv_custom_report (ank_id, usr_id, vrstni_red, type, sub_type, spr1, spr2, profile, time_edit) VALUES('$this->ank_id', '$this->creportAuthor', '$vrstni_red', '$type', '$sub_type', '$spr1', '$spr2', '$this->creportProfile', NOW())");
if (!$sql) echo mysqli_error($GLOBALS['connect_db']);
echo $vrstni_red;
}
// brisanje
else{
// Preberemo vrstni red elementa, ki ga brisemo
$sql = sisplet_query("SELECT id, vrstni_red FROM srv_custom_report WHERE ank_id='$this->ank_id' AND usr_id='$this->creportAuthor' AND type='$type' AND sub_type='$sub_type' AND spr1='$spr1' AND spr2='$spr2' AND profile='$this->creportProfile'");
$row = mysqli_fetch_array($sql);
$vrstni_red = $row['vrstni_red'];
$element_id = $row['id'];
$sql = sisplet_query("DELETE FROM srv_custom_report WHERE ank_id='$this->ank_id' AND usr_id='$this->creportAuthor' AND id='$element_id' AND profile='$this->creportProfile'");
if (!$sql) echo mysqli_error($GLOBALS['connect_db']);
// Prestevilcimo elemente
$sql = sisplet_query("UPDATE srv_custom_report SET vrstni_red=vrstni_red-1, time_edit=NOW() WHERE ank_id='$this->ank_id' AND usr_id='$this->creportAuthor' AND vrstni_red>'$vrstni_red' AND profile='$this->creportProfile'");
echo -1;
}
}
// Brisanje elementa
if($_GET['a'] == 'delete_element'){
$sql = sisplet_query("SELECT vrstni_red FROM srv_custom_report WHERE ank_id='$this->ank_id' AND usr_id='$this->creportAuthor' AND id='$element_id' AND profile='$this->creportProfile'");
$row = mysqli_fetch_array($sql);
$vrstni_red = $row['vrstni_red'];
$sql = sisplet_query("DELETE FROM srv_custom_report WHERE ank_id='$this->ank_id' AND id='$element_id' AND profile='$this->creportProfile'");
if (!$sql) echo mysqli_error($GLOBALS['connect_db']);
// Prestevilcimo elemente
$sql = sisplet_query("UPDATE srv_custom_report SET vrstni_red=vrstni_red-1, time_edit=NOW() WHERE ank_id='$this->ank_id' AND usr_id='$this->creportAuthor' AND vrstni_red>'$vrstni_red' AND profile='$this->creportProfile'");
$this->displayReport();
}
// Editiranje elementa v reportu
if($_GET['a'] == 'edit_element'){
// Preklop na navaden tip (freq, sums, graf, desc)
if($what == 'type' && $value < 5){
$sql = sisplet_query("SELECT type FROM srv_custom_report WHERE ank_id='$this->ank_id' AND id='$element_id' AND profile='$this->creportProfile'");
$row = mysqli_fetch_array($sql);
// Ce preklapljamo iz crosstabov, meansov ali ttesta - resetiramo spremenljivke
if($row['type'] > 4){
$s = sisplet_query("UPDATE srv_custom_report SET $what='$value', spr1='', spr2='', time_edit=NOW() WHERE ank_id='$this->ank_id' AND id='$element_id' AND profile='$this->creportProfile'");
}
else{
$s = sisplet_query("UPDATE srv_custom_report SET $what='$value', time_edit=NOW() WHERE ank_id='$this->ank_id' AND id='$element_id' AND profile='$this->creportProfile'");
if (!$s) echo mysqli_error($GLOBALS['connect_db']);
}
}
// Ce preklopimo na crosstabe, means ali ttest resetiramo vse spremenljivke
elseif($what == 'type' && $value > 4){
$s = sisplet_query("UPDATE srv_custom_report SET $what='$value', spr1='', spr2='', time_edit=NOW() WHERE ank_id='$this->ank_id' AND id='$element_id' AND profile='$this->creportProfile'");
if (!$s) echo mysqli_error($GLOBALS['connect_db']);
}
// Ostali preklopi
else{
$s = sisplet_query("UPDATE srv_custom_report SET $what='$value', time_edit=NOW() WHERE ank_id='$this->ank_id' AND id='$element_id' AND profile='$this->creportProfile'");
if (!$s) echo mysqli_error($GLOBALS['connect_db']);
}
$expanded = isset($_POST['expanded']) ? $_POST['expanded'] : 1;
$this->displayReportElement($element_id, $expanded);
}
if($_GET['a'] == 'copy_element'){
$sql = sisplet_query("SELECT * FROM srv_custom_report WHERE ank_id='$this->ank_id' AND usr_id='$this->creportAuthor' AND id='$element_id' AND profile='$this->creportProfile'");
$row = mysqli_fetch_array($sql);
// najprej prestevilcimo elemente ki so za kopiranim
$sql2 = sisplet_query("UPDATE srv_custom_report SET vrstni_red=vrstni_red+1 WHERE ank_id='$this->ank_id' AND usr_id='$this->creportAuthor' AND vrstni_red>'$row[vrstni_red]' AND profile='$this->creportProfile'");
$vrstni_red = $row['vrstni_red'] + 1;
$sqlInsert = sisplet_query("INSERT INTO srv_custom_report (ank_id, usr_id, vrstni_red, type, sub_type, spr1, spr2, text, profile, time_edit) VALUES('$this->ank_id', '$this->creportAuthor', '$vrstni_red', '$row[type]', '$row[sub_type]', '$row[spr1]', '$row[spr2]', '$row[text]', '$row[profile]', NOW())");
if (!$sqlInsert) echo mysqli_error($GLOBALS['connect_db']);
$this->displayReport();
}
// Sortiranje elementov
if($_GET['a'] == 'change_order'){
$sortable = $_POST['sortable'];
$exploded = explode('&', $sortable);
$i = 1;
foreach ($exploded AS $key) {
$key = str_replace('variabla_', '', $key);
$explode = explode('[]=', $key);
$sql = sisplet_query("UPDATE srv_custom_report SET vrstni_red = '$i', time_edit = NOW() WHERE id = '$explode[1]' AND profile='$this->creportProfile'");
if (!$sql) echo mysqli_error($GLOBALS['connect_db']);
$i++;
}
}
// Alert pri dodajanju prvega
if($_GET['a'] == 'first_alert'){
echo '
';
}
// Alert pri dodajanju vseh elementov istega tipa v report
if($_GET['a'] == 'all_elements_alert'){
$type = (isset($_POST['type'])) ? $_POST['type'] : 0;
echo '
';
}
// Dodajanje vseh elementov istega tipa v report
if($_GET['a'] == 'all_elements_add'){
$type = (isset($_POST['type'])) ? $_POST['type'] : 0;
$sql = sisplet_query("SELECT MAX(vrstni_red) FROM srv_custom_report WHERE ank_id='$this->ank_id' AND usr_id='$this->creportAuthor' AND profile='$this->creportProfile'");
if(mysqli_num_rows($sql) > 0){
$row = mysqli_fetch_assoc($sql);
$vrstni_red = $row['MAX(vrstni_red)'] + 1;
}
else
$vrstni_red = 1;
// Vstavljamo BREAK
if($type == 9){
// Ustvarimo instanco breaka
$this->classInstance = new SurveyBreak($this->ank_id);
$spr1 = (isset($_POST['spr1'])) ? $_POST['spr1'] : 0;
$spremenljivka = explode("-", $spr1);
$sub_type = (isset($_POST['sub_type'])) ? $_POST['sub_type'] : 0;
// Loop po odvisnih spremenljivkah in variablah
$variables = $this->getBreakDependentVariableList();
foreach ($variables as $variable) {
// Ce ne gre za disablan element in ne gre za isto spremenljivko kot spr1
if((int)$variable['canChoose'] == 1 && $variable['spr_id'] != $spremenljivka[1]){
$spr2 = $variable['sequence'].'-'.$variable['spr_id'].'-undefined';
// Vstavimo element v bazo
$sqlInsert = sisplet_query("INSERT INTO srv_custom_report (ank_id, usr_id, vrstni_red, type, sub_type, spr1, spr2, profile, time_edit) VALUES('$this->ank_id', '$this->creportAuthor', '$vrstni_red', '9', '$sub_type', '$spr1', '$spr2', '$this->creportProfile', NOW())");
if (!$s) echo mysqli_error($GLOBALS['connect_db']);
$vrstni_red++;
}
}
}
// Vstavljamo ostale osnove (sums, grafi, freq, desc)
else{
# preberemo header
foreach (SurveyAnalysis::$_HEADERS AS $spid => $spremenljivka) {
# preverjamo ali je meta
if ($spremenljivka['tip'] != 'm' && in_array($spremenljivka['tip'], SurveyAnalysis::$_FILTRED_TYPES )){
# preverimo ali prikazujemo spremenljivko, glede na veljavne odgovore
$only_valid = 0;
if (count($spremenljivka['grids']) > 0) {
foreach ($spremenljivka['grids'] AS $gid => $grid) {
# dodamo dodatne vrstice z albelami grida
if (count($grid['variables']) > 0 )
foreach ($grid['variables'] AS $vid => $variable ){
$_sequence = $variable['sequence']; # id kolone z podatki
$only_valid += (int)SurveyAnalysis::$_FREQUENCYS[$_sequence]['validCnt'];
}
}
}
// Ce ja kaksen veljaven oz ce prikazujemo tudi prazne
if(SurveyDataSettingProfiles :: getSetting('hideEmpty') != 1 || $only_valid > 0){
$sqlInsert = sisplet_query("INSERT INTO srv_custom_report (ank_id, usr_id, vrstni_red, type, spr1, profile, time_edit) VALUES('$this->ank_id', '$this->creportAuthor', '$vrstni_red', '$type', '$spid', '$this->creportProfile', NOW())");
if (!$s) echo mysqli_error($GLOBALS['connect_db']);
$vrstni_red++;
}
}
}
}
//$this->displayReport();
}
// Odpremo okno za izbiro/save profila
if($_GET['a'] == 'creport_show_profiles') {
$this->displaySettingsProfiles();
}
// Spreminjamo profil
if($_GET['a'] == 'creport_change_profile') {
if (isset ($_POST['id']))
$id = $_POST['id'];
if (isset ($_POST['author']))
$author = $_POST['author'];
$this->creportProfile = $id;
$this->creportAuthor = $author;
$this->displaySettingsProfiles();
}
// preimenujemo profil
if($_GET['a'] == 'renameProfile') {
if (isset ($_POST['id']))
$id = $_POST['id'];
if (isset ($_POST['name']))
$name = $_POST['name'];
// Default profil shranimo drugam ker ga ni v bazi (prevec komplikacij ker je bilo to naknadno delano)
if($id == 0){
$what = 'creport_default_profile_name';
$sql = sisplet_query("INSERT INTO srv_user_setting_for_survey (sid, uid, what, value) VALUES ('$this->ank_id', '$global_user_id', '$what', '$name') ON DUPLICATE KEY UPDATE value='$name'");
}
else
$sql = sisplet_query("UPDATE srv_custom_report_profiles SET name='$name' WHERE id='$id'");
$this->displaySettingsProfiles();
}
// pobrisemo profil
if($_GET['a'] == 'deleteProfile') {
if (isset ($_POST['id']))
$id = $_POST['id'];
$sql = sisplet_query("DELETE FROM srv_custom_report_profiles WHERE ank_id='$this->ank_id' AND usr_id='$global_user_id' AND id='$id'");
$sql = sisplet_query("DELETE FROM srv_custom_report WHERE ank_id='$this->ank_id' AND usr_id='$global_user_id' AND profile='$id'");
$this->displaySettingsProfiles();
}
// shranimo kot nov profil
if($_GET['a'] == 'newProfile') {
if (isset ($_POST['name']))
$name = $_POST['name'];
if (isset ($_POST['comment']))
$comment = $_POST['comment'];
$sql = sisplet_query("INSERT INTO srv_custom_report_profiles (ank_id, usr_id, name, time_created) VALUES('$this->ank_id', '$global_user_id', '$name', NOW())");
$profile_id = mysqli_insert_id($GLOBALS['connect_db']);
SurveyUserSetting :: getInstance()->saveSettings('default_creport_profile', $profile_id);
$this->creportProfile = $profile_id;
SurveyUserSetting :: getInstance()->saveSettings('default_creport_author', $global_user_id);
$this->creportAuthor = $global_user_id;
// Dodamo se komentar porocila
$what = 'creport_comment_profile_'.$this->creportProfile;
if($comment != ''){
$s = sisplet_query("INSERT INTO srv_user_setting_for_survey (sid, uid, what, value) VALUES ('$this->ank_id', '$global_user_id', '$what', '$comment') ON DUPLICATE KEY UPDATE value='$comment'");
if (!$s) echo mysqli_error($GLOBALS['connect_db']);
}
else{
$s = sisplet_query("DELETE FROM srv_user_setting_for_survey WHERE sid='$this->ank_id' AND uid='$global_user_id' AND what='$what'");
if (!$s) echo mysqli_error($GLOBALS['connect_db']);
}
//$this->displaySettingsProfiles();
}
// pozenemo izbran profil
if($_GET['a'] == 'use_creport_profile') {
if (isset ($_POST['id']))
$id = $_POST['id'];
if (isset ($_POST['author']))
$author = $_POST['author'];
SurveyUserSetting :: getInstance()->saveSettings('default_creport_profile', $id);
SurveyUserSetting :: getInstance()->saveSettings('default_creport_author', $author);
}
// urejanje komentarja profila
if($_GET['a'] == 'edit_profile_comment') {
$what = 'creport_comment_profile_'.$this->creportProfile;
if($value != ''){
$s = sisplet_query("INSERT INTO srv_user_setting_for_survey (sid, uid, what, value) VALUES ('$this->ank_id', '$global_user_id', '$what', '$value') ON DUPLICATE KEY UPDATE value='$value'");
if (!$s) echo mysqli_error($GLOBALS['connect_db']);
}
else{
$s = sisplet_query("DELETE FROM srv_user_setting_for_survey WHERE sid='$this->ank_id' AND uid='$global_user_id' AND what='$what'");
if (!$s) echo mysqli_error($GLOBALS['connect_db']);
}
}
// prikazemo deljenje profila z drugimi uredniki
if($_GET['a'] == 'shareProfileShow') {
echo '
';
echo ''.$lang['srv_custom_report_share_long'].':';
if (isset ($_POST['id'])){
$id = $_POST['id'];
// Loop cez vse urednike ankete z dostopom do analiz
$d = new Dostop();
$users = $d->getUsersDostop();
foreach($users as $user){
if($user['id'] != $global_user_id){
$sql = sisplet_query("SELECT * FROM srv_custom_report_share WHERE ank_id='".$this->ank_id."' AND profile_id='".$id."' AND author_usr_id='".$global_user_id."' AND share_usr_id='".$user['id']."' LIMIT 1");
$checked = (mysqli_num_rows($sql) > 0) ? ' checked="checked"' : '';
echo '
';
echo ' ';
echo '';
echo '
';
}
}
}
echo '
';
echo '';
echo '
';
echo '';
echo '';
echo '
';
}
// delimo profil z drugimi uredniki
if($_GET['a'] == 'shareProfile') {
if (isset ($_POST['id']) && isset ($_POST['users'])){
$id = $_POST['id'];
$users = $_POST['users'];
// Dodamo dostop ostalim urednikom za to porocilo
foreach($users as $user_id){
$sql = sisplet_query("INSERT INTO srv_custom_report_share
(ank_id, profile_id, author_usr_id, share_usr_id)
VALUES
('".$this->ank_id."', '".$id."', '".$global_user_id."', '".$user_id."')");
}
// Pobrisemo dostop neoznacenim urednikom do tega porocila
$sql = sisplet_query("DELETE FROM srv_custom_report_share
WHERE ank_id='".$this->ank_id."' AND profile_id='".$id."' AND author_usr_id='".$global_user_id."' AND share_usr_id NOT IN (".implode(',', $users).")");
}
elseif(isset($_POST['id'])){
$id = $_POST['id'];
// Pobrisemo dostop vsem urednikom do tega porocila
$sql = sisplet_query("DELETE FROM srv_custom_report_share
WHERE ank_id='".$this->ank_id."' AND profile_id='".$id."' AND author_usr_id='".$global_user_id."'");
}
$this->displaySettingsProfiles();
}
}
}
?>