0){ $this->anketa = $anketa; # polovimo vrsto tabel (aktivne / neaktivne) SurveyInfo :: getInstance()->SurveyInit($this->anketa); if (SurveyInfo::getInstance()->getSurveyColumn('db_table') == 1) { $this->db_table = '_active'; } } else { echo 'Invalid Survey ID!'; exit(); } } function displayTable(){ global $lang; // Legenda statusov $statuses = array( -1 => $lang['srv_vsi'], 0 => $lang['srv_urejanje'], 1 => $lang['import_data'], 2 => $lang['export_analisys'], 3 => $lang['srv_reporti'], 4 => $lang['srv_podatki'], 5 => $lang['srv_inv_nav_email'], 20 => $lang['srv_hierarchy'], // Splošni podatki o hierarhiji 21 => $lang['srv_hierarchy_structure'], // Grajenje hierarhije 22 => $lang['srv_hierarchy_users'], // Urejanje uporabnikov ); //se ponovi v funkciji ajax_drawContinuEditsTable if ($_GET['seansa'] > 0) $seansa = $_GET['seansa']; else $seansa = '30'; if (isset ($_GET['time'])) $time = $_GET['time']; else $time = '1 month'; if (isset ($_GET['status'])) $status = $_GET['status']; else $status = 0; if (isset ($_GET['from'])) $from = $_GET['from']; else $from = ''; if (isset ($_GET['to'])) $to = $_GET['to']; else $to = ''; echo '
'; echo ''; echo ''; echo ''.$lang['srv_edits_analysis_seansa'].' '; echo ''.$lang['status'].' '.$lang['srv_diagnostics_in'].' '; echo ' '; // Datum - od echo ''.$lang['srv_diagnostics_orfrom'].' '; echo ' '; // Datum - do echo ' '.$lang['srv_diagnostics_to'].' '; echo ' '; echo ''; echo '
'; //create iterval - SQL where statement $interval = $this->createInterval($time, $from, $to); //get object of all edits data $data = $this->getData($status, $interval); if(sizeof($data) == 0) $this->echoNoData(); else{ echo '
'; echo '
'; $sum_data = $this->drawTimeEdits($data['timeEdits'], $seansa*60, $status); echo '
'; $this->GraphData($this->graphQuery($status, $interval)); echo '
'; echo ''; echo ''; //draw edits counter and sums of editors $this->drawCountEdits($sum_data); //draw continuous editing box $continu_data = $this->continuEditsQuery($status, $interval); $this->drawContinuEdits($continu_data, $sum_data); echo ''; echo '
'; //prestavi vse tabele na konec, da bo info na vrhu echo''; } echo '
'; } function GraphData($data){ global $lang, $site_url; //error_log(json_encode($data)); //$DataSetJson = json_decode('{"Data":[{"Vrednosti":5,"Vrednosti2":2,"Name":0,"Variable":"0-1000"},{"Vrednosti":20,"Vrednosti2":15,"Name":1,"Variable":"1001-5000"},{"Vrednosti":20,"Vrednosti2":20,"Name":2,"Variable":"5001-10000"},{"Vrednosti":0,"Vrednosti2":8,"Name":3,"Variable":"10001-50000"}],' // . '"DataDescription":{"Position":"Variable","Format":{"X":"number","Y":"number"},"Unit":{"X":null,"Y":null},"Values":["Vrednosti", "Vrednosti2"],"Description":{"Vrednosti":"prvi-prvi-prvi-prvi-prvi", "Vrednosti2":"drugi-drugi-drugi-drugi-drugi"}},"numerus":45,"average":4721,"Other":[]}'); //polnimo podatke $DataSet = new pData; $vrednosti = array(); $vrednostiVariable = array(); $avg_count = 0; $avg_sum = 0; /*foreach ($DataSetJson->Data as $value){ $vrednosti[] = $value->Vrednosti; $vrednosti2[] = $value->Vrednosti2; $avg_sum+=$value->Vrednosti; $vrednostiVariable[] = $value->Variable; $avg_count++; }*/ $start_date = new DateTime($data['first_date']); $temp_date = $start_date; $end_date = new DateTime($data['last_date']); $diff = $this->differDateTimeInDays($start_date, $end_date); $DayFormat = ''; $DayIncrease = 'month'; if($diff < 32){ $DayFormat = '-d'; $DayIncrease = 'day'; } else $temp_date->setDate($start_date->format('Y'), $start_date->format('m'), 1); while ($temp_date <= $end_date){ foreach($data['edits'] as $user=>$value){ $datestring = $temp_date->format('Y-m'.$DayFormat); $cnt = isset($value[$datestring]) ? $value[$datestring] : 0; $vrednosti[$user][] = $cnt; $avg_sum+=$cnt; } $vrednostiVariable[] = $datestring; $avg_count++; $temp_date->modify('+1 '.$DayIncrease); } foreach($data['edits'] as $user=>$value){ $DataSet->AddPoint($vrednosti[$user],$user); $DataSet->AddSerie($user); $DataSet->SetSerieName($user,$user); } // nastavimo NUMERUS, ki se izpise pod legendo $numerus = $avg_sum; $DataSet->SetNumerus($numerus); // nastavimo POVPRECJE $avg = ($avg_count > 0) ? $avg_sum / $avg_count : 0; $DataSet->SetAverage(round($avg, 1)); $DataSet->AddPoint($vrednostiVariable,"Variable"); $DataSet->SetAbsciseLabelSerie("Variable"); //$DataSet->SetYAxisUnit("null"); $DataSet->SetYAxisFormat("number"); $Cache = new pCache(dirname(__FILE__).'/../../pChart/Cache/'); $ID = self::generateChartId($DataSet->GetNumerus()); echo '
'; echo '
'; echo '
'. $lang['srv_edits_analysis_graph']; echo ''; echo '(n = '.$DataSet->GetNumerus().')'; echo ''; echo '
'; if(!$Cache->isInCache($ID, $DataSet->GetData())){ $graph = SurveyChart::createLine($DataSet, null, 1); $Cache->WriteToCache($ID,$DataSet->GetData(),$graph); } // dobimo ime slike c cache-u $imgName = $Cache->GetHash($ID,$DataSet->GetData()); $imgPath = 'pChart/Cache/'.$imgName; $imgUrl = $site_url . 'admin/survey/' . $imgPath; echo '
'; // dodamo timestamp ker browser shrani sliko v cache in jo v dolocenih primerih ajaxa ne refresha echo ''; echo '
'; } /** * Run querry for action times * @param type $status - int of status * @param type $interval - where clause for time interval * @return type array of results from DB */ function graphQuery($status, $interval){ $sql2 = "SELECT min(DATE_FORMAT(st.datetime, '%Y-%m-%d')) as first_date, max(DATE_FORMAT(st.datetime, '%Y-%m-%d')) as last_date" . " FROM srv_tracking$this->db_table st, users u WHERE st.ank_id='$this->anketa' AND u.id = st.user ". ($status != -1 ? "AND st.status=$status " : "") ."$interval "; $output2=sisplet_query($sql2, 'obj'); $diff = $this->differDateTimeInDays(new DateTime($output2->first_date), new DateTime($output2->last_date)); $queryDayFormat = ''; $queryDayGroup = ''; if($diff < 32){ $queryDayFormat = '-%d'; $queryDayGroup = ', DAY(st.datetime)'; } $sql = "SELECT count(*) as cnt, u.email, u.id, DATE_FORMAT(st.datetime, '%Y-%m$queryDayFormat') as date" . " FROM srv_tracking$this->db_table st, users u WHERE st.ank_id='$this->anketa' AND u.id = st.user ". ($status != -1 ? "AND st.status=$status " : "") ."$interval " . "GROUP BY u.email, YEAR(st.datetime), MONTH(st.datetime)$queryDayGroup " . "ORDER BY u.email, date ASC"; $output=sisplet_query($sql, 'array'); $data = array('edits'=>array(), 'first_date'=>$output2->first_date, 'last_date'=>$output2->last_date); foreach($output as $row){ $data['edits'][$row['email']][$row['date']]=$row['cnt']; } return $data; } private function differDateTimeInDays($start_date, $end_date){ return $end_date->diff($start_date)->format("%a"); } // Zgeneriramo ID grafa za hash private function generateChartId($numerus){ $ID = $this->anketa.'_chart_'.$numerus.'edits_analysis'; return $ID; } /** * Get data to show in table * * @param type $status - status or type of edits * @param type $interval - where statement including interval for SQL * @return type */ function getData($status, $interval){ $data = array(); $data_temp = $this->timeEditsQuery($status, $interval); if(sizeof($data_temp) == 0) return array(); else $data['timeEdits'] = $data_temp; return $data; } /** * Create interval for SQL query from criteria * * @param type $time - time selected from dropdown * @param type $from - from calendat * @param type $to - to calendar * @return type - string WHERE statement */ function createInterval($time, $from, $to){ if($time == 'lifetime' || ($time == '99date' && $from == '' && $to == '')) $interval = ""; else if ($from == '' && $to == '') $interval = "AND st.datetime > NOW() - INTERVAL $time"; else if ($to == '') $interval = "AND '$from' <= st.datetime"; else if ($from == '') $interval = "AND st.datetime <= '$to'"; else $interval = "AND '$from' <= st.datetime AND st.datetime <= '$to'"; return $interval; } /** * Run querry for action times * @param type $status - int of status * @param type $interval - where clause for time interval * @return type array of results from DB */ function timeEditsQuery($status, $interval){ $sql = "SELECT u.email, u.id, st.datetime". ($status == 0 ? ", st.get, st.post" : "") . ($status == -1 ? ", st.status" : "") . " FROM srv_tracking$this->db_table st, users u WHERE st.ank_id='$this->anketa' AND u.id = st.user ". ($status != -1 ? "AND st.status=$status " : "") ."$interval ORDER BY u.email, st.datetime DESC"; return sisplet_query($sql, 'array'); } /** * Draw box of number of edit actions * @global type $lang * @param type $data - object data of sums */ function drawCountEdits($data){ global $lang; echo ''; $sum_akcij = 0; $sum_time = 0; $sum_seans = 0; echo '
'."\n"; echo ''.$lang['srv_edits_analysis_counter']; echo ''; echo '

'; echo '' . $lang['srv_edits_analysis_counter_editors'] .' :' . sizeof($data).'

'; echo ''; echo '' . '' . '' . ''; foreach ($data as $key => $value) { $this->echoCountEditsRow($key, $this->calculateTimeFromSeconds($value['time_sum']), $value['st_akcij_sum'], $value['st_seans_sum'], $value['user_id']); $sum_akcij += $value['st_akcij_sum']; $sum_time += $value['time_sum']; $sum_seans += $value['st_seans_sum']; } // vsota vlejavnih $this->echoCounterEditsFootRow($sum_time, $sum_akcij, $sum_seans); echo '
'.$lang['srv_edits_analysis_counter_editor'].''.$lang['srv_edits_analysis_time_time'].''.$lang['srv_edits_analysis_num_sessions'].''.$lang['srv_edits_analysis_time_actions'].'
'; echo '
'; echo ''; } /** * Run querry for continuous editing * @param type $status - int of status * @param type $interval - where clause for time interval * @param type $interval_criteria - criteria for interval - continued 'day' or 'hour' * @return type array of results from DB */ function continuEditsQuery($status, $interval, $interval_criteria = 'day', $user_criteria = 'all'){ $interval_criteria = ($interval_criteria == 'day') ? '' : ' %H'; $sqlString = "SELECT DATE_FORMAT(st.datetime, '%Y-%m-%d$interval_criteria') AS formatdate, count(*) as cnt FROM srv_tracking$this->db_table st WHERE ank_id = '$this->anketa' ". ($status != -1 ? "AND st.status=$status " : "")."". ($user_criteria != 'all' ? "AND st.user=$user_criteria " : "")."$interval GROUP BY formatdate ORDER BY formatdate desc"; return sisplet_query($sqlString, 'array'); } /** * Draw box of continuous editing * @global type $lang * @param type $data - object data of continued editing * @param type $sum_data - object data of sums * @param type $interval_criteria - criteria for interval - continued 'day' or 'hour' */ function drawContinuEdits($data, $sum_data, $interval_criteria = 'day'){ global $lang; echo ''; echo '
'."\n"; echo ''.$lang['srv_edits_analysis_countinu']; echo ''; echo '

'; //user/s echo ''; echo $lang['srv_edits_analysis_counter_editor'].': '; echo ' '; echo ''; // Oblika echo ''; echo ':'."\n"; echo ''."\n"; echo ''; //data table echo '
'."\n"; //draw table $this->drawContinuEditsTable($data, $interval_criteria); echo '
'; } /** * Draw table with bars od continued editing * @param type $data - object data of continued editing * @param type $interval_criteria - criteria for interval - continued 'day' or 'hour' */ function drawContinuEditsTable($data, $interval_criteria = 'day'){ $maxValue = 0; $interval_seconds = ($interval_criteria == 'day') ? 86400 : 3600; $interval_crit = ($interval_criteria == 'day') ? '' : ' H'; echo ''."\n"; if ($data) { $temp_time = null; //units $zapored = 0; $results = array(); foreach ($data as $row) { if($temp_time == null) $temp_time = DateTime::createFromFormat('Y-m-d'.$interval_crit, $row['formatdate']); else{ //calculate seconds between actions (rounded on 3600 or 86400) $interval = $this->calculateTimeBetweenActions($temp_time, DateTime::createFromFormat('Y-m-d'.$interval_crit, $row['formatdate'])); //if interval between actions are 1 unit (1 hour or 1 day), add it to continued editing session if($interval/$interval_seconds-$zapored < 2){ $zapored++; //set maxValue, needed for width of bars $maxValue = max($maxValue, $zapored); } //interval is more than 1 unit apart, not in continued editing session else{ //if there is continued editing session until previous action, store it to array - ignore otherwise if($zapored > 0) array_push($results, array('time' => $temp_time, 'zapored' => $zapored)); //restart all $temp_time = DateTime::createFromFormat('Y-m-d'.$interval_crit, $row['formatdate']); $zapored = 0; } } } //if there is continued editing session in last actions, store it to array - ignore otherwise if($zapored > 0) //$this->drawContinuRow($temp_time, $zapored, $maxValue, $value); array_push($results, array('time' => $temp_time, 'zapored' => $zapored)); if(!$results) $this->echoNoData(); else{ //reduce bars a little $maxValue *= GRAPH_REDUCE;//najvecje stevilo //draw all data and bars foreach ($results as $row) { $this->drawContinuRow($row['time'], $row['zapored'], $maxValue, $interval_criteria); } } } else $this->echoNoData(); echo '
'."\n"; } /** * Draws a row with bar of continuous editing * @param type $temp_time - the last edit * @param type $zapored - hour of continuoed editing * @param type $maxValue - max value of bars * @param type $interval_criteria - criteria for interval - continued 'day' or 'hour' */ function drawContinuRow($temp_time, $zapored, $maxValue, $interval_criteria){ $time_last = clone $temp_time; //edit DateTime get starting of continued editting session by subtracting units $temp_time->modify('- '.$zapored.' '.$interval_criteria); //if hour criteria if($interval_criteria == 'hour'){ //add 1 hour because of from to view $time_last->modify('+ 1 '.$interval_criteria); $s_time = $temp_time->format('Y-m-d H:00') .' - '. $time_last->format('H:00'); } else if($interval_criteria == 'day') $s_time = $temp_time->format('Y-m-d') .' - '. $time_last->format('Y-m-d'); //echo data echo ''."\n"; echo '' . $s_time . ''."\n"; $width = ($maxValue && $zapored) ? (round($zapored / $maxValue * 100, 0)) : "0"; echo '
 
'.($zapored+1).''."\n"; echo ''."\n"; } /** * Draw box of editing times * @param type $data - $data['timeEdits'] * @param type $seansa - cas nastavljene dolzine seanse v min * @param type $status - code of status criteria * @return Object - object of editors e.g. {admin:{time_sum:500, st_akcij_sum:30, st_seans_sum:5}, ...} */ function drawTimeEdits($data, $seansa, $status){ global $lang; $sum_data = array(); $datetime_last = null; $datetime_start = null; $st_akcij = 0; $st_akcij_sum = 0; $st_seans_sum = 0; $time_sum = 0; $user_temp = null; $user_id = 0; $row_id = 0; $action_type = null; $action_type_sum = null; $statuses = null; if($status == -1){ $statuses = array( 0 => array("name"=>$lang['srv_urejanje'], "sum"=>0), 1 => array("name"=>$lang['import_data'], "sum"=>0), 2 => array("name"=>$lang['export_analisys'], "sum"=>0), 3 => array("name"=>$lang['srv_reporti'], "sum"=>0), 4 => array("name"=>$lang['srv_podatki'], "sum"=>0), 5 => array("name"=>$lang['srv_inv_nav_email'], "sum"=>0), //20 => array("name"=>$lang['srv_hierarchy'], "sum"=>0),// Splošni podatki o hierarhiji //21 => array("name"=>$lang['srv_hierarchy_structure'], "sum"=>0),// Grajenje hierarhije //22 => array("name"=>$lang['srv_hierarchy_users'], "sum"=>0),// Urejanje uporabnikov ); $action_type = $statuses; $action_type_sum = $statuses; } else if($status == 0){ $statuses = array(); $action_type = array(); $action_type_sum = array(); } echo '

'.$lang["srv_edits_analysis_editing_details"].'

'; foreach ($data as $rowGrupa) { //$post = $this->convertToJSON($rowGrupa['post']); $akcija = null; if($status == -1) $akcija = $rowGrupa['status']; else if($status == 0){ $get = $this->convertToJSON($rowGrupa['get']); $akcija = $get['a']; } //zacetek risanja if(!isset($user_temp)){ $user_temp = $rowGrupa['email']; $user_id = $rowGrupa['id']; echo ''; //border zaradi printa - css na strani ga povozi $this->echoTimeTalbeHeader($user_temp, $status, $user_id); } //naslednji editor else if($user_temp != $rowGrupa['email']){ //izrisi se zadnjo vrstico prejsnjega urejevalca $time_sum += $this -> drawTimeEditsRow($datetime_start, $datetime_last, $st_akcij, $action_type, $user_id.'_'.$row_id); $this -> echoTimeEditsFootRow($time_sum, $st_akcij_sum, $action_type_sum, $user_id.'_sum'); $sum_data[$user_temp]['time_sum']=$time_sum; $sum_data[$user_temp]['st_akcij_sum']=$st_akcij_sum; $sum_data[$user_temp]['st_seans_sum']=$st_seans_sum; $sum_data[$user_temp]['user_id']=$user_id; $action_type_sum = $statuses; //nova tabela - nov urejevalec $user_temp = $rowGrupa['email']; $user_id = $rowGrupa['id']; $this->echoTimeTalbeHeader($user_temp, $status, $user_id); //ponastavi spremenljivke $datetime_last = null; $datetime_start = null; $st_akcij = 0; $st_akcij_sum = 0; $st_seans_sum = 0; $time_sum = 0; } //izpis vrstic //nov start seanse if(!isset($datetime_start)){ $datetime_start = new DateTime($rowGrupa['datetime']); $st_akcij++; $st_seans_sum++; $action_type = $statuses; } //se ni druge akcije else if(!isset($datetime_last)){ $temp_time = new DateTime($rowGrupa['datetime']); $interval = $this->calculateTimeBetweenActions($datetime_start, $temp_time); //ce je akcija od starta v kriteriju seanse, jo dodaj k seansi if($interval <= $seansa){ $datetime_last = clone $temp_time; $st_akcij++; } //akcija je izven kriterija seanse, izpisi samo to akcijo else{ $datetime_last = clone $datetime_start; $datetime_last->add(new DateInterval('PT5S')); $time_sum += $this -> drawTimeEditsRow($datetime_start, $datetime_last, $st_akcij, $action_type, $user_id.'_'.$row_id); $st_akcij = 1; $st_seans_sum++; $datetime_start = clone $temp_time; $datetime_last = null; $action_type = $statuses; } } //seasna ze ima vsaj dve akciji else{ $temp_time = new DateTime($rowGrupa['datetime']); $interval = $this->calculateTimeBetweenActions($datetime_last, $temp_time); //ce je akcija od prejsnje v kriteriju seanse, jo dodaj k seansi if($interval <= $seansa){ $datetime_last = clone $temp_time; $st_akcij++; } //akcija je izven kriterija seanse, izpisi vse prejsnje akcije else{ $time_sum += $this -> drawTimeEditsRow($datetime_start, $datetime_last, $st_akcij, $action_type, $user_id.'_'.$row_id); $st_akcij = 1; $st_seans_sum++; $datetime_start = clone $temp_time; $datetime_last = null; $action_type = $statuses; } } $st_akcij_sum++; $row_id++; if($status == -1){ $action_type[$akcija]['sum'] ++; $action_type_sum[$akcija]['sum'] ++; } else if($status == 0){ $action_type[$akcija] = isset($action_type[$akcija]) ? $action_type[$akcija]+1 : 1; $action_type_sum[$akcija] = isset($action_type_sum[$akcija]) ? $action_type_sum[$akcija]+1 : 1; } } //izrisi se zadnjo vrstico, ki jo ni foreach ter footer if($datetime_last == null){ $datetime_last = clone $datetime_start; $datetime_last->add(new DateInterval('PT5S')); } $time_sum += $this -> drawTimeEditsRow($datetime_start, $datetime_last, $st_akcij, $action_type, $user_id.'_'.$row_id); $this -> echoTimeEditsFootRow($time_sum, $st_akcij_sum, $action_type_sum, $user_id.'_sum'); $sum_data[$user_temp]['time_sum']=$time_sum; $sum_data[$user_temp]['st_akcij_sum']=$st_akcij_sum; $sum_data[$user_temp]['st_seans_sum']=$st_seans_sum; $sum_data[$user_temp]['user_id']=$user_id; echo '
'; return $sum_data; } /** * Izrisi header tabele za cas urejanja vsakega urejevalca * @param type $user_temp - email of user * @param type $status - status from criteria * @param type $user_num - int sequence nuber of user (unique, for this site, no need to be ID) */ function echoTimeTalbeHeader($user_temp, $status, $user_num){ global $lang; echo ''.$user_temp.''; echo ''.$lang['srv_edits_analysis_time_span'].''.$lang['srv_edits_analysis_time_time']. ''.$lang['srv_edits_analysis_time_actions'].''.($status < 1 ? ''.$lang['srv_edits_analysis_action_type'].'' : '').''; } /** * Nastavi in kasneje izrise vrstico urejanja * * @param type $datetime_start - datetime start of editing * @param type $datetime_last - datetime end of editing * @param type $st_akcij - num ob actions during editing * @param type $action_type - string of type of action * @param type $row_id - int sequence nuber of row (unique, for this site, no need to be ID) * @return type int - calculated second of editing session */ function drawTimeEditsRow($datetime_start, $datetime_last, $st_akcij, $action_type = null, $row_id = null){ $seconds = 0; //create string of actions type $action_type_string = ($action_type != null) ? $this -> createActionsTypeString($action_type, $row_id) : null; if(isset($datetime_last)){ $seconds = $this->calculateTimeBetweenActions($datetime_start, $datetime_last); $this -> echoTimeEditsRow($datetime_last->format('Y-m-d H:i:s') .' - '. $datetime_start->format('Y-m-d H:i:s'), $this->calculateTimeFromSeconds($seconds), $st_akcij, $action_type_string); } //ce je samo ena akcija else $this -> echoTimeEditsRow($datetime_start->format('Y-m-d H:i:s'), 0 ,1, $action_type_string); return $seconds; } /** * Create/convert array of action types to string for table cell * @param type $action_type - array of action types * @param type $row_id - int sequence nuber of row (unique user int and row in table) * @return string - converter array to string to put it in table cell */ function createActionsTypeString($action_type, $row_id){ $action_type_string = ''; //urejanje - ali drug specificen status if(!isset($action_type[0]['sum'])){ global $lang; $i = 0; foreach ($action_type as $key => $at){ if($i == 3) $action_type_string .= ''; if($i < 3) $action_type_string .= '
'.$key.' ('.$at.')'.'
'; else $action_type_string .= '
'.$key.' ('.$at.')'.'
'; $i++; } if($i > 3) $action_type_string .= ''; } //vsi statusi else{ foreach ($action_type as $at){ if($at['sum'] > 0){ if($action_type_string != '') $action_type_string .= '
'; $action_type_string .= $at['name'].' ('.$at['sum'].')'; } } } return $action_type_string; } /** * Izrise vrstico urejanja * @param type $datetime - string from to editing * @param type $cas_seanse - editing time * @param type $st_akcij - num of editing actions * @param type $action_type - string of type of action */ function echoTimeEditsRow($datetime, $cas_seanse, $st_akcij, $action_type = null){ //casovni razpon urejanja echo ''.$datetime.''; //cas urejanja echo ''.$cas_seanse.''; //stevilo akcij echo ''.$st_akcij.''; if($action_type != null) //vrsta akcij echo ''.$action_type.''; echo ''; } /** * Izrise vrstico editor info * @param type $user - string of editor * @param type $time_sum - editing time * @param type $st_akcij - num of sum editing actions * @param type $st_seans_sum - num of sessions * @param type $user_num - int sequence nuber of user (unique user int and row in table) */ function echoCountEditsRow($user, $time_sum, $st_akcij, $st_seans_sum, $user_num){ //casovni razpon urejanja echo ''.$user.''; //cas urejanja echo ''.$time_sum.''; //stevilo seans echo ''.$st_seans_sum.''; //stevilo akcij echo ''.$st_akcij.''; echo ''; } /** * Izrise total/footer vrstico urejanja * @param type $time - seconds of editing * @param type $st_akcij - num of editing actions * @param type $action_type - string of type of actions * @param type $row_id - int sequence nuber of user (unique, for this site, no need to be ID) */ function echoTimeEditsFootRow($time, $st_akcij, $action_type = null, $row_id = 0){ global $lang; //casovni razpon urejanja echo ''.$lang['srv_edits_analysis_time_total'].''; //cas urejanja echo ''.$this->calculateTimeFromSeconds($time).''; //stevilo akcij echo ''.$st_akcij.''; if($action_type != null) //vrsta akcij echo ''.$this->createActionsTypeString($action_type, $row_id).''; echo ''; } /** * Izrise total/footer vrstico urejanja * @param type $time - seconds of editing * @param type $st_akcij - num of editing actions * @param type $st_seans_sum - num of sessions */ function echoCounterEditsFootRow($time, $st_akcij, $st_seans_sum){ global $lang; //casovni razpon urejanja echo ''.$lang['srv_edits_analysis_time_total'].''; //cas urejanja echo ''.$this->calculateTimeFromSeconds($time).''; //stevilo seans echo ''.$st_seans_sum.''; //stevilo akcij echo ''.$st_akcij.''; echo ''; } /** * Calculate * @param type $datetime_start - datetime start of editing * @param type $datetime_last - datetime end of editing * @return type - float in time in minutes between actions */ function calculateTimeBetweenActions($datetime_start, $datetime_last){ return abs($datetime_last ->getTimestamp() - $datetime_start->getTimestamp()); } /** * Get readable time from seconds * @param type $seconds - time in seconds * @return type string - readable time */ function calculateTimeFromSeconds($seconds){ $hours = floor($seconds / 3600); $mins = floor($seconds / 60 % 60); $secs = floor($seconds % 60); return sprintf('%02d:%02d:%02d', $hours, $mins, $secs); } /** * Convert false JSON (with keys without quotes and no stat and end braces) * from DB to valid JSON * @param type $toJSON string to convert to JSON (with keys without * quotes and no stat and end braces) * @return type valid converted JSON */ function convertToJSON($toJSON){ $toJSON = preg_replace('/("(.*?)"|(\w+))(\s*:\s*(".*?"|.))/s', '"$2$3"$4', $toJSON); $toJSON = '{'.$toJSON.'}'; return json_decode($toJSON, true); } /** * Echo 'no data in DB' */ function echoNoData(){ global $lang; echo '

'.$lang['srv_edits_analysis_no_data'].'

'."\n"; } function ajax_drawContinuEditsTable(){ if (isset ($_POST['user'])) $user = $_POST['user']; else $user = 'all'; if (isset ($_POST['period'])) $period = $_POST['period']; else $period = 'day'; if (isset($_POST['time'])) $time = $_POST['time']; else $time = '1 month'; if (isset ($_POST['status'])) $status = $_POST['status']; else $status = 0; if (isset ($_POST['from'])) $from = $_POST['from']; else $from = ''; if (isset ($_POST['to'])) $to = $_POST['to']; else $to = ''; //create iterval - SQL where statement $interval = $this->createInterval($time, $from, $to); //get data $data = $this->continuEditsQuery($status, $interval, $period, $user); //draw table $this->drawContinuEditsTable($data, $period); } function getList($status, $interval){ $sql = "SELECT st.datetime, u.email, st.post, st.get FROM srv_tracking$this->db_table st, users u WHERE st.ank_id='$this->anketa' AND u.id = st.user ". ($status != -1 ? "AND st.status=$status " : "") ."$interval"; // Loop cez vse vrednosti v vprasanjih na straneh v anketi $sqlGrupa = sisplet_query($sql); $vrstic = 0; while($rowGrupa = mysqli_fetch_array($sqlGrupa)){ $vrstic++; } } }