diff --git a/htdocs/opensurvey/card.php b/htdocs/opensurvey/card.php index bc018a2dda1..fdb138eaf76 100644 --- a/htdocs/opensurvey/card.php +++ b/htdocs/opensurvey/card.php @@ -28,7 +28,7 @@ require_once DOL_DOCUMENT_ROOT."/core/lib/admin.lib.php"; require_once DOL_DOCUMENT_ROOT."/core/lib/files.lib.php"; require_once DOL_DOCUMENT_ROOT."/core/class/doleditor.class.php"; require_once DOL_DOCUMENT_ROOT."/opensurvey/class/opensurveysondage.class.php"; -require_once DOL_DOCUMENT_ROOT."/opensurvey/fonctions.php"; +require_once DOL_DOCUMENT_ROOT."/opensurvey/lib/opensurvey.lib.php"; // Security check diff --git a/htdocs/opensurvey/class/opensurveysondage.class.php b/htdocs/opensurvey/class/opensurveysondage.class.php index c4cbcb9f96a..cae73d0c2b2 100644 --- a/htdocs/opensurvey/class/opensurveysondage.class.php +++ b/htdocs/opensurvey/class/opensurveysondage.class.php @@ -674,4 +674,31 @@ class Opensurveysondage extends CommonObject return dolGetStatus($this->labelStatus[$status], $this->labelStatusShort[$status], '', $statusType, $mode); } + + + /** + * Return number of votes done for this survey. + * + * @return int Number of votes + */ + public function countVotes() + { + $result = 0; + + $sql .= " SELECT COUNT(id_users) as nb FROM ".MAIN_DB_PREFIX."opensurvey_user_studs"; + $sql .= " WHERE id_sondage = '".$this->db->escape($this->ref)."'"; + + $resql = $this->db->query($sql); + if ($resql) { + $obj = $this->db->fetch_object($resql); + if ($obj) { + $result = $obj->nb; + } + } else { + $this->error = $this->db->lasterror(); + $this->errors[] = $this->error; + } + + return $result; + } } diff --git a/htdocs/opensurvey/fonctions.php b/htdocs/opensurvey/lib/opensurvey.lib.php similarity index 98% rename from htdocs/opensurvey/fonctions.php rename to htdocs/opensurvey/lib/opensurvey.lib.php index f844921720b..c9c75b01d26 100644 --- a/htdocs/opensurvey/fonctions.php +++ b/htdocs/opensurvey/lib/opensurvey.lib.php @@ -43,6 +43,10 @@ function opensurvey_prepare_head(Opensurveysondage $object) $head[1][0] = 'results.php?id='.$object->id_sondage; $head[1][1] = $langs->trans("SurveyResults"); + $nbVotes = $object->countVotes(); + if ($nbVotes > 0) { + $head[$h][1] .= ''.($nbVotes).''; + } $head[1][2] = 'preview'; $h++; diff --git a/htdocs/opensurvey/results.php b/htdocs/opensurvey/results.php index f372e847455..99b8b502402 100644 --- a/htdocs/opensurvey/results.php +++ b/htdocs/opensurvey/results.php @@ -27,7 +27,7 @@ require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT."/core/lib/admin.lib.php"; require_once DOL_DOCUMENT_ROOT."/core/lib/files.lib.php"; require_once DOL_DOCUMENT_ROOT."/opensurvey/class/opensurveysondage.class.php"; -require_once DOL_DOCUMENT_ROOT."/opensurvey/fonctions.php"; +require_once DOL_DOCUMENT_ROOT."/opensurvey/lib/opensurvey.lib.php"; // Security check if (empty($user->rights->opensurvey->read)) { diff --git a/htdocs/opensurvey/wizard/choix_autre.php b/htdocs/opensurvey/wizard/choix_autre.php index 4919006a5f1..be9396646d5 100644 --- a/htdocs/opensurvey/wizard/choix_autre.php +++ b/htdocs/opensurvey/wizard/choix_autre.php @@ -25,7 +25,7 @@ require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT."/core/lib/admin.lib.php"; require_once DOL_DOCUMENT_ROOT."/core/lib/files.lib.php"; -require_once DOL_DOCUMENT_ROOT."/opensurvey/fonctions.php"; +require_once DOL_DOCUMENT_ROOT."/opensurvey/lib/opensurvey.lib.php"; // Security check if (!$user->rights->opensurvey->write) { diff --git a/htdocs/opensurvey/wizard/choix_date.php b/htdocs/opensurvey/wizard/choix_date.php index 762770acee6..dcf0bc436b3 100644 --- a/htdocs/opensurvey/wizard/choix_date.php +++ b/htdocs/opensurvey/wizard/choix_date.php @@ -25,7 +25,7 @@ require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT."/core/lib/admin.lib.php"; require_once DOL_DOCUMENT_ROOT."/core/lib/files.lib.php"; -require_once DOL_DOCUMENT_ROOT."/opensurvey/fonctions.php"; +require_once DOL_DOCUMENT_ROOT."/opensurvey/lib/opensurvey.lib.php"; // Security check if (!$user->rights->opensurvey->write) { diff --git a/htdocs/opensurvey/wizard/create_survey.php b/htdocs/opensurvey/wizard/create_survey.php index 6ed1f2073d2..d35e7b3f5d9 100644 --- a/htdocs/opensurvey/wizard/create_survey.php +++ b/htdocs/opensurvey/wizard/create_survey.php @@ -28,7 +28,7 @@ require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT."/core/lib/admin.lib.php"; require_once DOL_DOCUMENT_ROOT."/core/lib/files.lib.php"; require_once DOL_DOCUMENT_ROOT."/core/class/doleditor.class.php"; -require_once DOL_DOCUMENT_ROOT."/opensurvey/fonctions.php"; +require_once DOL_DOCUMENT_ROOT."/opensurvey/lib/opensurvey.lib.php"; // Security check if (!$user->rights->opensurvey->write) { diff --git a/htdocs/opensurvey/wizard/index.php b/htdocs/opensurvey/wizard/index.php index fa3d734a488..e55385e33a4 100644 --- a/htdocs/opensurvey/wizard/index.php +++ b/htdocs/opensurvey/wizard/index.php @@ -26,7 +26,7 @@ if (!defined('NOTOKENRENEWAL')) { require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; -require_once DOL_DOCUMENT_ROOT.'/opensurvey/fonctions.php'; +require_once DOL_DOCUMENT_ROOT.'/opensurvey/lib/opensurvey.lib.php'; // Security check if (!$user->rights->opensurvey->write) { diff --git a/htdocs/public/opensurvey/studs.php b/htdocs/public/opensurvey/studs.php index 21fe3d9d7a1..305c45fdaae 100644 --- a/htdocs/public/opensurvey/studs.php +++ b/htdocs/public/opensurvey/studs.php @@ -39,7 +39,7 @@ require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT."/core/lib/admin.lib.php"; require_once DOL_DOCUMENT_ROOT."/core/lib/files.lib.php"; require_once DOL_DOCUMENT_ROOT."/opensurvey/class/opensurveysondage.class.php"; -require_once DOL_DOCUMENT_ROOT."/opensurvey/fonctions.php"; +require_once DOL_DOCUMENT_ROOT."/opensurvey/lib/opensurvey.lib.php"; // Init vars