summaryrefslogtreecommitdiffstats
path: root/admin/survey/classes/tracking/TrackingClass.php
diff options
context:
space:
mode:
Diffstat (limited to 'admin/survey/classes/tracking/TrackingClass.php')
-rw-r--r--admin/survey/classes/tracking/TrackingClass.php242
1 files changed, 138 insertions, 104 deletions
diff --git a/admin/survey/classes/tracking/TrackingClass.php b/admin/survey/classes/tracking/TrackingClass.php
index f635d4f..fe31ddf 100644
--- a/admin/survey/classes/tracking/TrackingClass.php
+++ b/admin/survey/classes/tracking/TrackingClass.php
@@ -23,12 +23,11 @@ class TrackingClass
# poiščemo aktivno anketo
SurveyInfo :: getInstance()->SurveyInit($this->anketa);
- if (SurveyInfo::getInstance()->getSurveyColumn('db_table') == 1)
- $this->db_table = '_active';
+ $this->db_table = SurveyInfo::getInstance()->getSurveyArchiveDBString();
- if ($_GET['m'] == 'tracking_data')
+ if (isset($_GET['m']) && $_GET['m'] == 'tracking_data')
$this->sub = 'data';
- elseif ($_GET['appendMerge'] == '1')
+ elseif (isset($_GET['appendMerge']) && $_GET['appendMerge'] == '1')
$this->sub = 'append';
else
$this->sub = 'survey';
@@ -118,15 +117,11 @@ class TrackingClass
{
global $lang;
+ $surveyName = SurveyInfo::getInstance()->getSurveyTitle();
+
echo '<fieldset>';
echo '<legend>' . $lang['srv_survey_archives_tracking_' . $this->sub] . '</legend>';
- // Izvoz v Excel
- echo '<p><a href="index.php?anketa=' . $this->anketa . '&a=' . $_GET['a'] . '&d=download">Download Excel</a></p>';
-
-
- echo '<table id="tracking">';
-
// Tabela s podatki o spremembah podatkov
if ($this->sub == 'data') {
@@ -139,74 +134,96 @@ class TrackingClass
OR (`get` LIKE \'%urejanje: "1"%\' AND status=\'4\')
)';
- // Prva vrstica
- echo '<tr>';
- echo ' <th>' . $lang['date'] . '</th>';
- echo ' <th>User</th>';
- echo ' <th class="center">IP</th>';
- echo ' <th class="center">Recnum</th>';
- echo ' <th>GET</th>';
- echo ' <th>POST</th>';
- echo '</tr>';
-
+
// Vrstice s podatki
- $sql = sisplet_query("SELECT * FROM srv_tracking".$this->db_table." WHERE ank_id = '$this->anketa' " . $appendMerge . " " . $data . " ORDER BY datetime DESC");
- while ($row = mysqli_fetch_array($sql)) {
+ $sql = sisplet_query("SELECT * FROM srv_tracking".$this->db_table." WHERE ank_id = '$this->anketa' " . $data . " ORDER BY datetime DESC");
+
+ if(!empty(mysqli_fetch_array($sql))) {
+
+
+ echo '<p class="bottom16">'.$lang['srv_survey_archives_tracking_survey_text1'].' '.$lang['srv_survey_archives_tracking_survey_text1b'].' <a href="index.php?anketa=' . $this->anketa . '&a=data">\'<span class="caps">'.$lang['navigation_NAVI_RESULTS'].'</span>\' - \''.$lang['navigation_NAVI_DATA'].'\'</a> '.$lang['srv_survey_archives_tracking_survey_text1c'].' \''.$surveyName.'\'. '.$lang['srv_survey_archives_tracking_survey_text2'].' <a href="index.php?anketa=' . $this->anketa . '&a=' . $_GET['a'] . '&d=download">'.$lang['srv_survey_archives_tracking_survey_text3'].'</a>.</p>';
+
+ // Izvoz v Excel
+ echo '<div class="izvoz_nad_tabelo">';
+ echo '<a class="noline" href="index.php?anketa=' . $this->anketa . '&a=' . $_GET['a'] . '&d=download"><span class="faicon xls green link-right"></span>'.$lang['srv_export_excel'].'</a>';
+ echo '</div>';
+
+ echo '<table id="tracking" class="fullwidth">';
+ // Prva vrstica
echo '<tr>';
+ echo ' <th>' . $lang['date'] . '</th>';
+ echo ' <th>' . $lang['user'] . '</th>';
+ echo ' <th>IP</th>';
+ echo ' <th>Respondent</th>';
+ echo ' <th>GET</th>';
+ echo ' <th>POST</th>';
+ echo '</tr>';
- $sqlu = sisplet_query("SELECT name, surname FROM users WHERE id = '$row[user]'");
- $rowu = mysqli_fetch_array($sqlu);
+ $count = 0;
+ while ($row = mysqli_fetch_array($sql)) {
+ echo '<tr '.($count > 24 ? 'class="displayNone"' : '').($count == 24 ? ' class="show_as_last_row"' : '').'>';
- // Pri podatkih dobimo posebej podatke o editiranem respondentu
- $usr_id = '';
- $cookie = '';
+ $sqlu = sisplet_query("SELECT name, surname FROM users WHERE id = '$row[user]'");
+ $rowu = mysqli_fetch_array($sqlu);
- // Preverimo ce imamo usr_id v GET-u
- $get_array_temp = explode(', ', $row['get']);
- foreach ($get_array_temp AS $get_val) {
- $param = explode(': ', $get_val);
- $get_array[$param[0]] = $param[1];
- }
+ // Pri podatkih dobimo posebej podatke o editiranem respondentu
+ $usr_id = '';
+ $cookie = '';
- if (isset($get_array['usr_id']) && $get_array['usr_id'] != '') {
- $usr_id = trim($get_array['usr_id'], '"');
- } // Preverimo ce iammo slucajno cookie
- elseif (isset($get_array['survey-' . $this->anketa]) && $get_array['survey-' . $this->anketa] != '') {
- $cookie = trim($get_array['survey-' . $this->anketa], '"');
- } else {
- // Preverimo ce imamo usr_id v POST-u
- $post_array_temp = explode(', ', $row['post']);
- foreach ($post_array_temp AS $post_val) {
- $param = explode(': ', $post_val);
- $post_array[$param[0]] = $param[1];
+ // Preverimo ce imamo usr_id v GET-u
+ $get_array_temp = explode(', ', $row['get']);
+ foreach ($get_array_temp AS $get_val) {
+ $param = explode(': ', $get_val);
+ $get_array[$param[0]] = $param[1];
}
- if (isset($post_array['usr_id']) && $post_array['usr_id'] != '')
- $usr_id = trim($post_array['usr_id'], '"');
- }
+ if (isset($get_array['usr_id']) && $get_array['usr_id'] != '') {
+ $usr_id = trim($get_array['usr_id'], '"');
+ } // Preverimo ce iammo slucajno cookie
+ elseif (isset($get_array['survey-' . $this->anketa]) && $get_array['survey-' . $this->anketa] != '') {
+ $cookie = trim($get_array['survey-' . $this->anketa], '"');
+ } else {
+ // Preverimo ce imamo usr_id v POST-u
+ $post_array_temp = explode(', ', $row['post']);
+ foreach ($post_array_temp AS $post_val) {
+ $param = explode(': ', $post_val);
+ $post_array[$param[0]] = $param[1];
+ }
+
+ if (isset($post_array['usr_id']) && $post_array['usr_id'] != '')
+ $usr_id = trim($post_array['usr_id'], '"');
+ }
- if ($usr_id != '') {
- $sqlR = sisplet_query("SELECT recnum FROM srv_user WHERE id = '$usr_id'");
- $rowR = mysqli_fetch_array($sqlR);
+ if ($usr_id != '') {
+ $sqlR = sisplet_query("SELECT recnum FROM srv_user WHERE id = '$usr_id'");
+ $rowR = mysqli_fetch_array($sqlR);
- $recnum = $rowR['recnum'];
- } elseif ($cookie != '') {
- $sqlR = sisplet_query("SELECT recnum FROM srv_user WHERE cookie = '$cookie'");
- $rowR = mysqli_fetch_array($sqlR);
+ $recnum = $rowR['recnum'];
+ } elseif ($cookie != '') {
+ $sqlR = sisplet_query("SELECT recnum FROM srv_user WHERE cookie = '$cookie'");
+ $rowR = mysqli_fetch_array($sqlR);
- $recnum = $rowR['recnum'];
- } else
- $recnum = 0;
+ $recnum = $rowR['recnum'];
+ } else
+ $recnum = 0;
- echo ' <td>' . datetime($row['datetime']) . '</td>';
- echo ' <td>' . $rowu['name'] . ' ' . $rowu['surname'] . '</td>';
- echo ' <td class="center">' . $row['ip'] . '</td>';
- echo ' <td class="center">' . $recnum . '</td>';
- echo ' <td>' . $row['get'] . '</td>';
- echo ' <td>' . $row['post'] . '</td>';
+ echo ' <td><div class="no_wrap">' . datetime($row['datetime']) . '</div></td>';
+ echo ' <td><div class="no_wrap">' . $rowu['name'] . ' ' . $rowu['surname'] . '</div></td>';
+ echo ' <td>' . $row['ip'] . '</td>';
+ echo ' <td>' . $recnum . '</td>';
+ echo ' <td><div class="postget_wrap">' . $row['get'] . '</div></td>';
+ echo ' <td><div class="postget_wrap">' . (($row['post'] != "") ? $row['post'] : '/') . '</div></td>';
- echo '</tr>';
+ echo '</tr>';
+
+ $count++;
+ }
+ }
+ else {
+ echo '<p>'.ucfirst($lang['srv_survey_archives_tracking_survey_text1b']).' <a href="index.php?anketa=' . $this->anketa . '&a=data">\'<span class="caps">'.$lang['navigation_NAVI_RESULTS'].'</span>\' - \''.$lang['navigation_NAVI_DATA'].'\'</a> '.$lang['srv_survey_archives_tracking_survey_text1d'].'.</p>';
}
+
+
} // Tabela s podatki o spremembah - vse oz. merge/append
else {
@@ -231,32 +248,53 @@ class TrackingClass
else
$appendMerge = "";
- // Prva vrstica
- echo '<tr>';
- echo ' <th>' . $lang['date'] . '</th>';
- echo ' <th>User</th>';
- echo ' <th class="center">IP</th>';
- echo ' <th class="center">Podstran</th>';
- echo ' <th>GET</th>';
- echo ' <th>POST</th>';
- echo '</tr>';
// Vrstice s podatki
- $sql = sisplet_query("SELECT * FROM srv_tracking".$this->db_table." WHERE ank_id = '$this->anketa' " . $this->status . " " . $appendMerge . " " . $data . " ORDER BY datetime DESC");
- while ($row = mysqli_fetch_array($sql)) {
+ $sql = sisplet_query("SELECT * FROM srv_tracking".$this->db_table." WHERE ank_id = '$this->anketa' " . $this->status . " " . $appendMerge . " ORDER BY datetime DESC");
+
+ if(!empty(mysqli_fetch_array($sql))) {
+
+ if($appendMerge == "")
+ echo '<p class="bottom16">'.$lang['srv_survey_archives_tracking_survey_text1'].' '.$lang['srv_survey_archives_tracking_survey_text1a'].' \''. $surveyName .'\'. '.$lang['srv_survey_archives_tracking_survey_text2'].' <a href="index.php?anketa=' . $this->anketa . '&a=' . $_GET['a'] . '&d=download">'.$lang['srv_survey_archives_tracking_survey_text3'].'</a>.</p>';
+ else
+ echo '<p class="bottom16">'.$lang['srv_survey_archives_tracking_survey_text1'].', '.$lang['srv_survey_archives_tracking_survey_text_appendmerge'].' '.$lang['srv_survey_archives_tracking_survey_text1a'].' \''. $surveyName .'\'. '.$lang['srv_survey_archives_tracking_survey_text2'].' <a href="index.php?anketa=' . $this->anketa . '&a=' . $_GET['a'] . '&d=download">'.$lang['srv_survey_archives_tracking_survey_text3'].'</a>.</p>';
+
+ // Izvoz v Excel
+ echo '<div class="izvoz_nad_tabelo">';
+ echo '<a class="noline" href="index.php?anketa=' . $this->anketa . '&a=' . $_GET['a'] . '&d=download"><span class="faicon xls green link-right"></span>'.$lang['srv_export_excel'].'</a>';
+ echo '</div>';
+
+ echo '<table id="tracking" class="fullwidth">';
+ // Prva vrstica
echo '<tr>';
-
- $sqlu = sisplet_query("SELECT name, surname FROM users WHERE id = '$row[user]'");
- $rowu = mysqli_fetch_array($sqlu);
-
- echo ' <td>' . datetime($row['datetime']) . '</td>';
- echo ' <td>' . $rowu['name'] . ' ' . $rowu['surname'] . '</td>';
- echo ' <td class="center">' . $row['ip'] . '</td>';
- echo ' <td class="center">' . $statuses[$row['status']] . '</td>';
- echo ' <td>' . $row['get'] . '</td>';
- echo ' <td>' . $row['post'] . '</td>';
-
+ echo ' <th>' . $lang['date'] . '</th>';
+ echo ' <th>' . $lang['user'] . '</th>';
+ echo ' <th>IP</th>';
+ echo ' <th>Podstran</th>';
+ echo ' <th>GET</th>';
+ echo ' <th>POST</th>';
echo '</tr>';
+
+ $count = 0;
+ while ($row = mysqli_fetch_array($sql)) {
+ echo '<tr '.($count > 24 ? 'class="displayNone"' : '').($count == 24 ? ' class="show_as_last_row"' : '').'>';
+
+ $sqlu = sisplet_query("SELECT name, surname FROM users WHERE id = '$row[user]'");
+ $rowu = mysqli_fetch_array($sqlu);
+
+ echo ' <td><div class="no_wrap">' . datetime($row['datetime']) . '</div></td>';
+ echo ' <td><div class="no_wrap">' . $rowu['name'] . ' ' . $rowu['surname'] . '</div></td>';
+ echo ' <td>' . $row['ip'] . '</td>';
+ echo ' <td>' . $statuses[$row['status']] . '</td>';
+ echo ' <td><div class="postget_wrap">' . $row['get'] . '</div></td>';
+ echo ' <td><div class="postget_wrap">' . (($row['post'] != "") ? $row['post'] : '/') . '</div></td>';
+
+ echo '</tr>';
+ $count++;
+ }
+ }
+ else{
+ echo $lang['srv_survey_archives_tracking_append_no_data'];
}
}
@@ -265,13 +303,13 @@ class TrackingClass
echo '</fieldset>';
}
- public function csvExport()
- {
+ public function csvExport(){
+
define('delimiter', ';');
-
$podatki = 'datetime' . delimiter;
- $podatki .= 'uid' . delimiter;
+ $podatki .= 'user_id' . delimiter;
+ $podatki .= 'user_name' . delimiter;
$podatki .= 'ip' . delimiter;
$podatki .= 'status' . delimiter;
$podatki .= 'parameter' . delimiter;
@@ -279,18 +317,19 @@ class TrackingClass
$podatki .= 'parameter' . delimiter;
$podatki .= 'value' . delimiter;
-
$podatki .= "\n";
- $sql = sisplet_query("SELECT * FROM srv_tracking".$this->db_table." WHERE ank_id = '" . $this->anketa . "' " . $this->status . " ORDER BY datetime DESC");
+ $sql = sisplet_query("SELECT t.*, u.name, u.surname
+ FROM srv_tracking".$this->db_table." t, users u
+ WHERE t.ank_id = '" . $this->anketa."' ".str_replace('status', 't.status', $this->status)."
+ AND u.id=t.user
+ ORDER BY t.datetime DESC
+ ");
while ($row = mysqli_fetch_array($sql)) {
-
- $sqlu = sisplet_query("SELECT name, surname, id FROM users WHERE id = '$row[user]'");
- $rowu = mysqli_fetch_array($sqlu);
-
$podatki .= '' . datetime($row['datetime']) . delimiter;
- $podatki .= '' . $rowu['id'] . delimiter;
+ $podatki .= '' . $row['user'] . delimiter;
+ $podatki .= '' . $row['name'].' '.$row['surname'] . delimiter;
$podatki .= '' . $row['ip'] . delimiter;
$podatki .= '' . $row['status'] . delimiter;
@@ -304,6 +343,7 @@ class TrackingClass
}
$ime = str_replace('-', '_', $_GET['a']);
+
return Export::init()->csv('Spremembe_' . $ime, $podatki);
}
@@ -322,7 +362,7 @@ class TrackingClass
# poiščemo aktivno anketo
SurveyInfo :: getInstance()->SurveyInit($anketa);
- $db_table = (SurveyInfo::getInstance()->getSurveyColumn('db_table') == 1) ? '_active' : '';
+ $db_table = SurveyInfo::getInstance()->getSurveyArchiveDBString();
$get = '';
foreach ($_GET AS $key => $val) {
@@ -336,9 +376,6 @@ class TrackingClass
if ($post != '')
$post .= ', ';
-// if (is_array($val))
-// $val = implode(',', $val);
-
if (is_array($val))
$val = self::arrayToString($val);
@@ -374,9 +411,6 @@ class TrackingClass
if ($post != '')
$post .= ', ';
-// if (is_array($val))
-// $val = implode(',', $val);
-
if (is_array($val))
$val = self::arrayToString($val);