summaryrefslogtreecommitdiffstats
path: root/admin/survey/classes/surveyAnalysis/class.SurveyAnalysisHelper.php
blob: 9e944a73bc19cee7cd123aff6c6b6f1fca492c2d (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
<?php
class SurveyAnalysisHelper {
	
	static private $instance;
	static private $anketa;
	static private $db_table = '';
	
	/**
	 * Poskrbimo za samo eno instanco
	 */
	static function getInstance()
	{
		if(!self::$instance)
		{
			self::$instance = new SurveyAnalysisHelper();
		}
		return self::$instance;
	}
	
	/**
	 * Inicializacija
	 *
	 * @param int $anketa
	 */
	function Init( $anketa = null )
	{
		if ($anketa) {
			self::$anketa = $anketa;
				
			SurveyInfo::getInstance()->SurveyInit(self::$anketa);
			
            self::$db_table = SurveyInfo::getInstance()->getSurveyArchiveDBString();		
		}
	}
	
	function addCustomReportElement($type, $sub_type, $spr1, $spr2=''){
		global $lang;
		global $global_user_id;
	
		if((!isset($_GET['m']) || $_GET['m'] != 'analysis_creport') && $_GET['t'] != 'custom_report'){
			$creportProfile = SurveyUserSetting :: getInstance()->getSettings('default_creport_profile');
			$creportProfile = isset($creportProfile) ? $creportProfile : 0;
			
			$creportAuthor = SurveyUserSetting :: getInstance()->getSettings('default_creport_author');
			$creportAuthor = isset($creportAuthor) ? $creportAuthor : $global_user_id;
	
			$sql = sisplet_query("SELECT id FROM srv_custom_report WHERE ank_id='".self::$anketa."' AND usr_id='".$creportAuthor."' AND type='$type' AND sub_type='$sub_type' AND spr1='$spr1' AND spr2='$spr2' AND profile='$creportProfile'");
			$insert = (mysqli_num_rows($sql)) ? 0 : 1;
			$id = $type.'-'.$sub_type.'-'.$spr1.'-'.$spr2;

			// Samo zvezdica (sums, grafi, freq...)
			if($type < 5)
				echo '<a href="#" title="'.($insert == 0 ? $lang['srv_custom_report_inserted_title'] : $lang['srv_custom_report_insert_title']).'" onClick="addCustomReportElement(\''.$type.'\', \''.$sub_type.'\', \''.$spr1.'\', \''.$spr2.'\', 0); return false;"><span id="'.$id.'" class="faicon pointer '.($insert == 0 ? ' star_on' : ' star_off').'"></span> <div class= "icon_text star_icon">'.$lang['srv_custom_report_insert_title'].'</div></a>';

			// Zvezdica s textom
			else{
				echo '<div class="custom_report_include">';
					
				echo '<a href="#" title="'.($insert == 0 ? $lang['srv_custom_report_inserted_title'] : $lang['srv_custom_report_insert_title']).'" onClick="addCustomReportElement(\''.$type.'\', \''.$sub_type.'\', \''.$spr1.'\', \''.$spr2.'\', 1); return false;">';
				echo '<span id="'.$id.'" class="faicon pointer '.($insert == 0 ? ' star_on' : ' star_off').'"> </span>';
				echo '<span id="'.$id.'_insert" '.($insert == 0 ? ' style="display:none;" ' : '').'> '.$lang['srv_custom_report_insert'].'</span>';
				echo '<span id="'.$id.'_inserted" '.($insert == 0 ? '' : ' style="display:none;" ').'> '.$lang['srv_custom_report_inserted'].'</span>';
				echo '</a>';
	
				echo '</div>';
			}
		}
	}
	
	function displayMissingLegend(){
		global $lang;	
		
		echo '<div id="bottom_data_legend_missing" class="legend_box">';

		echo '<div class="legend_title" onclick="$(\'#bottom_data_legend_detail_missing\').toggle(\'fast\');">';
		echo '<span class="faicon arrow2_r"></span>'.$lang['srv_bottom_data_legend_note'];
		echo '</div>';

		echo '<div id="bottom_data_legend_detail_missing" class="legend_details">';
		echo '  <ul>';
		echo '      <li>'.$lang['srv_bottom_data_legend_note_li1'].'</li>';
		echo '      <li>'.$lang['srv_bottom_data_legend_note_li2'].'</li>';
		echo '      <li>'.$lang['srv_bottom_data_legend_note_li3'].'</li>';
		echo '      <li>'.$lang['srv_bottom_data_legend_note_li4'].'</li>';
		echo '      <li>'.$lang['srv_bottom_data_legend_note_li5'].'</li>';
		echo '      <li>'.$lang['srv_bottom_data_legend_note_li99'].'</li>';
		echo '      <li>'.$lang['srv_bottom_data_legend_note_li98'].'</li>';
		echo '      <li>'.$lang['srv_bottom_data_legend_note_li97'].'</li>';
		echo '      <li>'.$lang['srv_bottom_data_legend_note_li0'].'</li>';
		echo '  </ul>';
		echo '</div>';

		echo '</div>';
	}
	
	function displayStatusLegend(){
		global $lang;

		echo '<div id="bottom_data_legend_status" class="legend_box">';

		echo '<div class="legend_title">';
		echo '  <span onclick="$(\'#bottom_data_legend_detail_status\').toggle(\'fast\');"><span class="faicon arrow2_r"></span>'.$lang['srv_bottom_data_legend_status_note'].'</span>';
		echo '</div>';

		echo '<div id="bottom_data_legend_detail_status" class="legend_details">';
		echo '  <ul>';
		for ($i = 0; $i <= 6; $i++) {
			echo '      <li>'.$i.' - '.$lang['srv_userstatus_'.$i].'</li>';
		}
		echo '      <li>'.$lang['srv_bottom_data_legend_note_li0'].'</li>';
		echo '  </ul>';
		echo '</div>';

		echo '</div>';
	}
	
	function displayTestLegend(){
		global $lang;
		
		echo '<div id="bottom_data_legend_test" class="legend_box">';

		echo '<div class="legend_title">';
		echo '  <span onclick="$(\'#bottom_data_legend_detail_test\').toggle(\'fast\');"><span class="faicon arrow2_r"></span>'.$lang['srv_bottom_data_legend_test_note'].'</span>';
		echo '</div>';

		echo '<div id="bottom_data_legend_detail_test" class="legend_details">';
		echo '  <ul>';
		echo '      <li>0 - '.$lang['srv_bottom_data_legend_test_note_li0'].'</li>';
		echo '      <li>1 - '.$lang['srv_bottom_data_legend_test_note_li1'].'</li>';
		echo '      <li>2 - '.$lang['srv_bottom_data_legend_test_note_li2'].'</li>';
		echo '  </ul>';
		echo '</div>';

		echo '</div>';
	}
}