NEW Show number of votes into the label of tab "Results" of a survey
This commit is contained in:
parent
a51c868a8e
commit
256b2f4493
@ -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/lib/files.lib.php";
|
||||||
require_once DOL_DOCUMENT_ROOT."/core/class/doleditor.class.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/class/opensurveysondage.class.php";
|
||||||
require_once DOL_DOCUMENT_ROOT."/opensurvey/fonctions.php";
|
require_once DOL_DOCUMENT_ROOT."/opensurvey/lib/opensurvey.lib.php";
|
||||||
|
|
||||||
|
|
||||||
// Security check
|
// Security check
|
||||||
|
|||||||
@ -674,4 +674,31 @@ class Opensurveysondage extends CommonObject
|
|||||||
|
|
||||||
return dolGetStatus($this->labelStatus[$status], $this->labelStatusShort[$status], '', $statusType, $mode);
|
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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -43,6 +43,10 @@ function opensurvey_prepare_head(Opensurveysondage $object)
|
|||||||
|
|
||||||
$head[1][0] = 'results.php?id='.$object->id_sondage;
|
$head[1][0] = 'results.php?id='.$object->id_sondage;
|
||||||
$head[1][1] = $langs->trans("SurveyResults");
|
$head[1][1] = $langs->trans("SurveyResults");
|
||||||
|
$nbVotes = $object->countVotes();
|
||||||
|
if ($nbVotes > 0) {
|
||||||
|
$head[$h][1] .= '<span class="badge marginleftonlyshort">'.($nbVotes).'</span>';
|
||||||
|
}
|
||||||
$head[1][2] = 'preview';
|
$head[1][2] = 'preview';
|
||||||
$h++;
|
$h++;
|
||||||
|
|
||||||
@ -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/admin.lib.php";
|
||||||
require_once DOL_DOCUMENT_ROOT."/core/lib/files.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/class/opensurveysondage.class.php";
|
||||||
require_once DOL_DOCUMENT_ROOT."/opensurvey/fonctions.php";
|
require_once DOL_DOCUMENT_ROOT."/opensurvey/lib/opensurvey.lib.php";
|
||||||
|
|
||||||
// Security check
|
// Security check
|
||||||
if (empty($user->rights->opensurvey->read)) {
|
if (empty($user->rights->opensurvey->read)) {
|
||||||
|
|||||||
@ -25,7 +25,7 @@
|
|||||||
require '../../main.inc.php';
|
require '../../main.inc.php';
|
||||||
require_once DOL_DOCUMENT_ROOT."/core/lib/admin.lib.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/lib/files.lib.php";
|
||||||
require_once DOL_DOCUMENT_ROOT."/opensurvey/fonctions.php";
|
require_once DOL_DOCUMENT_ROOT."/opensurvey/lib/opensurvey.lib.php";
|
||||||
|
|
||||||
// Security check
|
// Security check
|
||||||
if (!$user->rights->opensurvey->write) {
|
if (!$user->rights->opensurvey->write) {
|
||||||
|
|||||||
@ -25,7 +25,7 @@
|
|||||||
require '../../main.inc.php';
|
require '../../main.inc.php';
|
||||||
require_once DOL_DOCUMENT_ROOT."/core/lib/admin.lib.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/lib/files.lib.php";
|
||||||
require_once DOL_DOCUMENT_ROOT."/opensurvey/fonctions.php";
|
require_once DOL_DOCUMENT_ROOT."/opensurvey/lib/opensurvey.lib.php";
|
||||||
|
|
||||||
// Security check
|
// Security check
|
||||||
if (!$user->rights->opensurvey->write) {
|
if (!$user->rights->opensurvey->write) {
|
||||||
|
|||||||
@ -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/admin.lib.php";
|
||||||
require_once DOL_DOCUMENT_ROOT."/core/lib/files.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."/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
|
// Security check
|
||||||
if (!$user->rights->opensurvey->write) {
|
if (!$user->rights->opensurvey->write) {
|
||||||
|
|||||||
@ -26,7 +26,7 @@ if (!defined('NOTOKENRENEWAL')) {
|
|||||||
require '../../main.inc.php';
|
require '../../main.inc.php';
|
||||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.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/lib/files.lib.php';
|
||||||
require_once DOL_DOCUMENT_ROOT.'/opensurvey/fonctions.php';
|
require_once DOL_DOCUMENT_ROOT.'/opensurvey/lib/opensurvey.lib.php';
|
||||||
|
|
||||||
// Security check
|
// Security check
|
||||||
if (!$user->rights->opensurvey->write) {
|
if (!$user->rights->opensurvey->write) {
|
||||||
|
|||||||
@ -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/admin.lib.php";
|
||||||
require_once DOL_DOCUMENT_ROOT."/core/lib/files.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/class/opensurveysondage.class.php";
|
||||||
require_once DOL_DOCUMENT_ROOT."/opensurvey/fonctions.php";
|
require_once DOL_DOCUMENT_ROOT."/opensurvey/lib/opensurvey.lib.php";
|
||||||
|
|
||||||
|
|
||||||
// Init vars
|
// Init vars
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user