Skip to content

Commit

Permalink
BUGFIX : type is not used for survey type.
Browse files Browse the repository at this point in the history
  • Loading branch information
mate-infotel committed Sep 9, 2019
1 parent 214e783 commit a352a52
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions inc/dashboard.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,10 @@ function satisfactionSurvey($widgetId, $opt = []) {

// Recover survey associed to current entity
$pluginSatisfactionSurvey = new PluginSatisfactionSurvey();
if (!$pluginSatisfactionSurvey->getFromDBByCrit(['entities_id' => $_SESSION['glpiactive_entity']])) {
if (!$pluginSatisfactionSurvey->getFromDBByCrit([
'entities_id' => $_SESSION['glpiactive_entity'],
'is_active' => 1
])) {
$content.= '<div class="center">';
$content.= '<br><br>';
$content.= '<h3>'.__("There are no survey for current entity", "satisfaction").'</h3>';
Expand All @@ -216,7 +219,7 @@ function addDateCriteria(&$query, $dateBegin, $dateEnd){

// Number of satisfaction survey
$query = "SELECT count(*) as nb FROM " . TicketSatisfaction::getTable();
$query .= " WHERE type = " . $pluginSatisfactionSurvey->getID();
$query .= " WHERE 1=1";
addDateCriteria($query, $opt['begin'], $opt['end']);

$result = $DB->query($query);
Expand All @@ -229,7 +232,7 @@ function addDateCriteria(&$query, $dateBegin, $dateEnd){

// Number of concerned tickets
$query = "SELECT count(DISTINCT tickets_id) as nb FROM " . TicketSatisfaction::getTable();
$query .= " WHERE type = " . $pluginSatisfactionSurvey->getID();
$query .= " WHERE 1=1";
addDateCriteria($query, $opt['begin'], $opt['end']);

$result = $DB->query($query);
Expand All @@ -242,7 +245,7 @@ function addDateCriteria(&$query, $dateBegin, $dateEnd){

// Survey not answered
$query = "SELECT count(*) as nb FROM " . TicketSatisfaction::getTable();
$query .= " WHERE type = " . $pluginSatisfactionSurvey->getID();
$query .= " WHERE 1=1";
$query .= " AND date_answered IS NULL";
addDateCriteria($query, $opt['begin'], $opt['end']);

Expand All @@ -256,7 +259,7 @@ function addDateCriteria(&$query, $dateBegin, $dateEnd){

// Survey answered
$query = "SELECT count(DISTINCT tickets_id) as nb FROM " . TicketSatisfaction::getTable();
$query .= " WHERE type = " . $pluginSatisfactionSurvey->getID();
$query .= " WHERE 1=1";
$query .= " AND date_answered IS NOT NULL";
addDateCriteria($query, $opt['begin'], $opt['end']);

Expand All @@ -270,7 +273,7 @@ function addDateCriteria(&$query, $dateBegin, $dateEnd){

// Global satisfaction
$query = "SELECT AVG(satisfaction) as nb FROM " . TicketSatisfaction::getTable();
$query .= " WHERE type = " . $pluginSatisfactionSurvey->getID();
$query .= " WHERE 1=1";
$query .= " AND date_answered IS NOT NULL";
addDateCriteria($query, $opt['begin'], $opt['end']);

Expand Down

0 comments on commit a352a52

Please sign in to comment.