code syntax opensurvey directory
This commit is contained in:
parent
be59a70e39
commit
155aeb6213
@ -32,7 +32,9 @@ require_once DOL_DOCUMENT_ROOT."/opensurvey/fonctions.php";
|
||||
|
||||
|
||||
// Security check
|
||||
if (!$user->rights->opensurvey->read) accessforbidden();
|
||||
if (!$user->rights->opensurvey->read) {
|
||||
accessforbidden();
|
||||
}
|
||||
|
||||
// Initialisation des variables
|
||||
$action = GETPOST('action', 'aZ09');
|
||||
@ -62,17 +64,21 @@ $expiredate = dol_mktime(0, 0, 0, GETPOST('expiremonth'), GETPOST('expireday'),
|
||||
|
||||
$parameters = array('id' => $numsondage);
|
||||
$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
|
||||
if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
|
||||
if ($reshook < 0) {
|
||||
setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
|
||||
}
|
||||
|
||||
if (empty($reshook))
|
||||
{
|
||||
if ($cancel) $action = '';
|
||||
if (empty($reshook)) {
|
||||
if ($cancel) {
|
||||
$action = '';
|
||||
}
|
||||
|
||||
// Delete
|
||||
if ($action == 'delete_confirm')
|
||||
{
|
||||
if ($action == 'delete_confirm') {
|
||||
// Security check
|
||||
if (!$user->rights->opensurvey->write) accessforbidden();
|
||||
if (!$user->rights->opensurvey->write) {
|
||||
accessforbidden();
|
||||
}
|
||||
|
||||
$result = $object->delete($user, '', $numsondage);
|
||||
|
||||
@ -81,36 +87,33 @@ if (empty($reshook))
|
||||
}
|
||||
|
||||
// Close
|
||||
if ($action == 'close')
|
||||
{
|
||||
if ($action == 'close') {
|
||||
$object->status = Opensurveysondage::STATUS_CLOSED;
|
||||
$object->update($user);
|
||||
}
|
||||
|
||||
// Reopend
|
||||
if ($action == 'reopen')
|
||||
{
|
||||
if ($action == 'reopen') {
|
||||
$object->status = Opensurveysondage::STATUS_VALIDATED;
|
||||
$object->update($user);
|
||||
}
|
||||
|
||||
// Update
|
||||
if ($action == 'update')
|
||||
{
|
||||
if ($action == 'update') {
|
||||
// Security check
|
||||
if (!$user->rights->opensurvey->write) accessforbidden();
|
||||
if (!$user->rights->opensurvey->write) {
|
||||
accessforbidden();
|
||||
}
|
||||
|
||||
$error = 0;
|
||||
|
||||
if (!GETPOST('nouveautitre'))
|
||||
{
|
||||
if (!GETPOST('nouveautitre')) {
|
||||
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Title")), null, 'errors');
|
||||
$error++;
|
||||
$action = 'edit';
|
||||
}
|
||||
|
||||
if (!$error)
|
||||
{
|
||||
if (!$error) {
|
||||
$object->title = (string) GETPOST('nouveautitre', 'alphanohtml');
|
||||
$object->description = (string) GETPOST('nouveauxcommentaires', 'restricthtml');
|
||||
$object->mail_admin = (string) GETPOST('nouvelleadresse', 'alpha');
|
||||
@ -128,8 +131,7 @@ if (empty($reshook))
|
||||
}
|
||||
|
||||
// Add comment
|
||||
if (GETPOST('ajoutcomment'))
|
||||
{
|
||||
if (GETPOST('ajoutcomment')) {
|
||||
$error = 0;
|
||||
|
||||
if (!GETPOST('comment')) {
|
||||
@ -147,8 +149,7 @@ if (empty($reshook))
|
||||
|
||||
$resql = $object->addComment($comment, $comment_user);
|
||||
|
||||
if (!$resql)
|
||||
{
|
||||
if (!$resql) {
|
||||
setEventMessages($langs->trans('ErrorInsertingComment'), null, 'errors');
|
||||
}
|
||||
}
|
||||
@ -156,17 +157,20 @@ if (empty($reshook))
|
||||
|
||||
// Delete comment
|
||||
$idcomment = GETPOST('deletecomment', 'int');
|
||||
if ($idcomment)
|
||||
{
|
||||
if ($idcomment) {
|
||||
// Security check
|
||||
if (!$user->rights->opensurvey->write) accessforbidden();
|
||||
if (!$user->rights->opensurvey->write) {
|
||||
accessforbidden();
|
||||
}
|
||||
|
||||
$resql = $object->deleteComment($idcomment);
|
||||
}
|
||||
|
||||
if ($action == 'edit') {
|
||||
// Security check
|
||||
if (!$user->rights->opensurvey->write) accessforbidden();
|
||||
if (!$user->rights->opensurvey->write) {
|
||||
accessforbidden();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -177,8 +181,7 @@ if (empty($reshook))
|
||||
|
||||
$form = new Form($db);
|
||||
|
||||
if ($object->fk_user_creat)
|
||||
{
|
||||
if ($object->fk_user_creat) {
|
||||
$userstatic = new User($db);
|
||||
$userstatic->fetch($object->fk_user_creat);
|
||||
}
|
||||
@ -193,8 +196,7 @@ llxHeader('', $title, $helpurl, 0, 0, 0, $arrayofjs, $arrayofcss);
|
||||
// Define format of choices
|
||||
$toutsujet = explode(",", $object->sujet);
|
||||
$listofanswers = array();
|
||||
foreach ($toutsujet as $value)
|
||||
{
|
||||
foreach ($toutsujet as $value) {
|
||||
$tmp = explode('@', $value);
|
||||
$listofanswers[] = array('label'=>$tmp[0], 'format'=>($tmp[1] ? $tmp[1] : 'checkbox'));
|
||||
}
|
||||
@ -232,16 +234,16 @@ print ' '.$langs->trans($type == 'classic' ? "TypeClassic" : "TypeDate").'</td><
|
||||
print '<tr><td>';
|
||||
$adresseadmin = $object->mail_admin;
|
||||
print $langs->trans("Title").'</td><td colspan="2">';
|
||||
if ($action == 'edit')
|
||||
{
|
||||
if ($action == 'edit') {
|
||||
print '<input type="text" name="nouveautitre" style="width: 95%" value="'.dol_escape_htmltag(dol_htmlentities($object->title)).'">';
|
||||
} else print dol_htmlentities($object->title);
|
||||
} else {
|
||||
print dol_htmlentities($object->title);
|
||||
}
|
||||
print '</td></tr>';
|
||||
|
||||
// Description
|
||||
print '<tr><td class="tdtop">'.$langs->trans("Description").'</td><td colspan="2">';
|
||||
if ($action == 'edit')
|
||||
{
|
||||
if ($action == 'edit') {
|
||||
$doleditor = new DolEditor('nouveauxcommentaires', $object->description, '', 120, 'dolibarr_notes', 'In', 1, 1, 1, ROWS_7, '90%');
|
||||
$doleditor->Create(0, '');
|
||||
} else {
|
||||
@ -253,17 +255,17 @@ print '</td></tr>';
|
||||
//If linked user, then emails are going to be sent to users' email
|
||||
if (!$object->fk_user_creat) {
|
||||
print '<tr><td>'.$langs->trans("EMail").'</td><td colspan="2">';
|
||||
if ($action == 'edit')
|
||||
{
|
||||
if ($action == 'edit') {
|
||||
print '<input type="text" name="nouvelleadresse" class="minwith200" value="'.$object->mail_admin.'">';
|
||||
} else print dol_print_email($object->mail_admin, 0, 0, 1);
|
||||
} else {
|
||||
print dol_print_email($object->mail_admin, 0, 0, 1);
|
||||
}
|
||||
print '</td></tr>';
|
||||
}
|
||||
|
||||
// Receive an email with each vote
|
||||
print '<tr><td>'.$langs->trans('ToReceiveEMailForEachVote').'</td><td colspan="2">';
|
||||
if ($action == 'edit')
|
||||
{
|
||||
if ($action == 'edit') {
|
||||
print '<input type="checkbox" name="mailsonde" '.($object->mailsonde ? 'checked="checked"' : '').'">';
|
||||
} else {
|
||||
print yn($object->mailsonde);
|
||||
@ -279,26 +281,31 @@ print '</td></tr>';
|
||||
|
||||
// Users can comment
|
||||
print '<tr><td>'.$langs->trans('CanComment').'</td><td colspan="2">';
|
||||
if ($action == 'edit')
|
||||
{
|
||||
if ($action == 'edit') {
|
||||
print '<input type="checkbox" name="cancomment" '.($object->allow_comments ? 'checked="checked"' : '').'">';
|
||||
} else print yn($object->allow_comments);
|
||||
} else {
|
||||
print yn($object->allow_comments);
|
||||
}
|
||||
print '</td></tr>';
|
||||
|
||||
// Users can see others vote
|
||||
print '<tr><td>'.$langs->trans('CanSeeOthersVote').'</td><td colspan="2">';
|
||||
if ($action == 'edit')
|
||||
{
|
||||
if ($action == 'edit') {
|
||||
print '<input type="checkbox" name="canseeothersvote" '.($object->allow_spy ? 'checked="checked"' : '').'">';
|
||||
} else print yn($object->allow_spy);
|
||||
} else {
|
||||
print yn($object->allow_spy);
|
||||
}
|
||||
print '</td></tr>';
|
||||
|
||||
// Expire date
|
||||
print '<tr><td>'.$langs->trans('ExpireDate').'</td><td colspan="2">';
|
||||
if ($action == 'edit') print $form->selectDate($expiredate ? $expiredate : $object->date_fin, 'expire', 0, 0, 0, '', 1, 0);
|
||||
else {
|
||||
if ($action == 'edit') {
|
||||
print $form->selectDate($expiredate ? $expiredate : $object->date_fin, 'expire', 0, 0, 0, '', 1, 0);
|
||||
} else {
|
||||
print dol_print_date($object->date_fin, 'day');
|
||||
if ($object->date_fin && $object->date_fin < dol_now() && $object->status == Opensurveysondage::STATUS_VALIDATED) print img_warning($langs->trans("Expired"));
|
||||
if ($object->date_fin && $object->date_fin < dol_now() && $object->status == Opensurveysondage::STATUS_VALIDATED) {
|
||||
print img_warning($langs->trans("Expired"));
|
||||
}
|
||||
}
|
||||
print '</td></tr>';
|
||||
|
||||
@ -322,7 +329,9 @@ $urlwithroot = $urlwithouturlroot.DOL_URL_ROOT; // This is to use external domai
|
||||
|
||||
$url = $urlwithroot.'/public/opensurvey/studs.php?sondage='.$object->id_sondage;
|
||||
print '<input type="text" style="width: 60%" '.($action == 'edit' ? 'disabled' : '').' id="opensurveyurl" name="opensurveyurl" value="'.$url.'">';
|
||||
if ($action != 'edit') print ajax_autoselect("opensurveyurl", $url);
|
||||
if ($action != 'edit') {
|
||||
print ajax_autoselect("opensurveyurl", $url);
|
||||
}
|
||||
|
||||
print '</td></tr>';
|
||||
|
||||
@ -332,8 +341,7 @@ print '</div>';
|
||||
|
||||
print dol_get_fiche_end();
|
||||
|
||||
if ($action == 'edit')
|
||||
{
|
||||
if ($action == 'edit') {
|
||||
print '<div class="center">';
|
||||
print '<input type="submit" class="button button-save" name="save" value="'.dol_escape_htmltag($langs->trans("Save")).'">';
|
||||
print ' ';
|
||||
@ -354,13 +362,11 @@ if ($action != 'edit' && $user->rights->opensurvey->write) {
|
||||
//Modify button
|
||||
print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?action=edit&id='.$numsondage.'">'.$langs->trans("Modify").'</a>';
|
||||
|
||||
if ($object->status == Opensurveysondage::STATUS_VALIDATED)
|
||||
{
|
||||
if ($object->status == Opensurveysondage::STATUS_VALIDATED) {
|
||||
//Close button
|
||||
print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?action=close&id='.$numsondage.'">'.$langs->trans("Close").'</a>';
|
||||
}
|
||||
if ($object->status == Opensurveysondage::STATUS_CLOSED)
|
||||
{
|
||||
if ($object->status == Opensurveysondage::STATUS_CLOSED) {
|
||||
//Opened button
|
||||
print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?action=reopen&id='.$numsondage.'">'.$langs->trans("ReOpen").'</a>';
|
||||
}
|
||||
@ -371,8 +377,7 @@ if ($action != 'edit' && $user->rights->opensurvey->write) {
|
||||
|
||||
print '</div>';
|
||||
|
||||
if ($action == 'delete')
|
||||
{
|
||||
if ($action == 'delete') {
|
||||
print $form->formconfirm($_SERVER["PHP_SELF"].'?&id='.$numsondage, $langs->trans("RemovePoll"), $langs->trans("ConfirmRemovalOfPoll", $id), 'delete_confirm', '', '', 1);
|
||||
}
|
||||
|
||||
|
||||
@ -175,7 +175,7 @@ class Opensurveysondage extends CommonObject
|
||||
$sql .= "allow_comments,";
|
||||
$sql .= "allow_spy,";
|
||||
$sql .= "sujet,";
|
||||
$sql .= "entity";
|
||||
$sql .= "entity";
|
||||
$sql .= ") VALUES (";
|
||||
$sql .= "'".$this->db->escape($this->id_sondage)."',";
|
||||
$sql .= " ".(empty($this->description) ? 'NULL' : "'".$this->db->escape($this->description)."'").",";
|
||||
@ -188,21 +188,25 @@ class Opensurveysondage extends CommonObject
|
||||
$sql .= " ".((int) $this->allow_comments).",";
|
||||
$sql .= " ".((int) $this->allow_spy).",";
|
||||
$sql .= " '".$this->db->escape($this->sujet)."',";
|
||||
$sql .= " ".((int) $conf->entity);
|
||||
$sql .= " ".((int) $conf->entity);
|
||||
$sql .= ")";
|
||||
|
||||
$this->db->begin();
|
||||
|
||||
dol_syslog(get_class($this)."::create", LOG_DEBUG);
|
||||
$resql = $this->db->query($sql);
|
||||
if (!$resql) { $error++; $this->errors[] = "Error ".$this->db->lasterror(); }
|
||||
if (!$resql) {
|
||||
$error++; $this->errors[] = "Error ".$this->db->lasterror();
|
||||
}
|
||||
|
||||
if (!$error && !$notrigger) {
|
||||
global $langs, $conf;
|
||||
|
||||
// Call trigger
|
||||
$result = $this->call_trigger('OPENSURVEY_CREATE', $user);
|
||||
if ($result < 0) $error++;
|
||||
if ($result < 0) {
|
||||
$error++;
|
||||
}
|
||||
// End call triggers
|
||||
}
|
||||
|
||||
@ -250,10 +254,8 @@ class Opensurveysondage extends CommonObject
|
||||
|
||||
dol_syslog(get_class($this)."::fetch", LOG_DEBUG);
|
||||
$resql = $this->db->query($sql);
|
||||
if ($resql)
|
||||
{
|
||||
if ($this->db->num_rows($resql))
|
||||
{
|
||||
if ($resql) {
|
||||
if ($this->db->num_rows($resql)) {
|
||||
$obj = $this->db->fetch_object($resql);
|
||||
|
||||
$this->id_sondage = $obj->id_sondage;
|
||||
@ -336,15 +338,15 @@ class Opensurveysondage extends CommonObject
|
||||
if (!$error && !$notrigger) {
|
||||
// Call trigger
|
||||
$result = $this->call_trigger('OPENSURVEY_MODIFY', $user);
|
||||
if ($result < 0) $error++;
|
||||
if ($result < 0) {
|
||||
$error++;
|
||||
}
|
||||
// End call triggers
|
||||
}
|
||||
|
||||
// Commit or rollback
|
||||
if ($error)
|
||||
{
|
||||
foreach ($this->errors as $errmsg)
|
||||
{
|
||||
if ($error) {
|
||||
foreach ($this->errors as $errmsg) {
|
||||
dol_syslog(get_class($this)."::update ".$errmsg, LOG_ERR);
|
||||
$this->error .= ($this->error ? ', '.$errmsg : $errmsg);
|
||||
}
|
||||
@ -369,8 +371,7 @@ class Opensurveysondage extends CommonObject
|
||||
global $conf, $langs;
|
||||
$error = 0;
|
||||
|
||||
if (empty($numsondage))
|
||||
{
|
||||
if (empty($numsondage)) {
|
||||
$numsondage = $this->id_sondage;
|
||||
}
|
||||
|
||||
@ -379,12 +380,13 @@ class Opensurveysondage extends CommonObject
|
||||
if (!$error && !$notrigger) {
|
||||
// Call trigger
|
||||
$result = $this->call_trigger('OPENSURVEY_DELETE', $user);
|
||||
if ($result < 0) $error++;
|
||||
if ($result < 0) {
|
||||
$error++;
|
||||
}
|
||||
// End call triggers
|
||||
}
|
||||
|
||||
if (!$error)
|
||||
{
|
||||
if (!$error) {
|
||||
$sql = 'DELETE FROM '.MAIN_DB_PREFIX."opensurvey_comments WHERE id_sondage = '".$this->db->escape($numsondage)."'";
|
||||
dol_syslog(get_class($this)."::delete", LOG_DEBUG);
|
||||
$resql = $this->db->query($sql);
|
||||
@ -397,14 +399,14 @@ class Opensurveysondage extends CommonObject
|
||||
|
||||
dol_syslog(get_class($this)."::delete", LOG_DEBUG);
|
||||
$resql = $this->db->query($sql);
|
||||
if (!$resql) { $error++; $this->errors[] = "Error ".$this->db->lasterror(); }
|
||||
if (!$resql) {
|
||||
$error++; $this->errors[] = "Error ".$this->db->lasterror();
|
||||
}
|
||||
}
|
||||
|
||||
// Commit or rollback
|
||||
if ($error)
|
||||
{
|
||||
foreach ($this->errors as $errmsg)
|
||||
{
|
||||
if ($error) {
|
||||
foreach ($this->errors as $errmsg) {
|
||||
dol_syslog(get_class($this)."::delete ".$errmsg, LOG_ERR);
|
||||
$this->error .= ($this->error ? ', '.$errmsg : $errmsg);
|
||||
}
|
||||
@ -431,7 +433,9 @@ class Opensurveysondage extends CommonObject
|
||||
global $dolibarr_main_authentication, $dolibarr_main_demo;
|
||||
global $menumanager;
|
||||
|
||||
if (!empty($conf->dol_no_mouse_hover)) $notooltip = 1; // Force disable tooltips
|
||||
if (!empty($conf->dol_no_mouse_hover)) {
|
||||
$notooltip = 1; // Force disable tooltips
|
||||
}
|
||||
|
||||
$result = '';
|
||||
|
||||
@ -444,14 +448,16 @@ class Opensurveysondage extends CommonObject
|
||||
|
||||
// Add param to save lastsearch_values or not
|
||||
$add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0);
|
||||
if ($save_lastsearch_value == -1 && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) $add_save_lastsearch_values = 1;
|
||||
if ($add_save_lastsearch_values) $url .= '&save_lastsearch_values=1';
|
||||
if ($save_lastsearch_value == -1 && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) {
|
||||
$add_save_lastsearch_values = 1;
|
||||
}
|
||||
if ($add_save_lastsearch_values) {
|
||||
$url .= '&save_lastsearch_values=1';
|
||||
}
|
||||
|
||||
$linkclose = '';
|
||||
if (empty($notooltip))
|
||||
{
|
||||
if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER))
|
||||
{
|
||||
if (empty($notooltip)) {
|
||||
if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) {
|
||||
$label = $langs->trans("ShowMyObject");
|
||||
$linkclose .= ' alt="'.dol_escape_htmltag($label, 1).'"';
|
||||
}
|
||||
@ -466,8 +472,12 @@ class Opensurveysondage extends CommonObject
|
||||
$linkend = '</a>';
|
||||
|
||||
$result .= $linkstart;
|
||||
if ($withpicto) $result .= img_object(($notooltip ? '' : $label), $this->picto, ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : 'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip ? 0 : 1);
|
||||
if ($withpicto != 2) $result .= $this->ref;
|
||||
if ($withpicto) {
|
||||
$result .= img_object(($notooltip ? '' : $label), $this->picto, ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : 'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip ? 0 : 1);
|
||||
}
|
||||
if ($withpicto != 2) {
|
||||
$result .= $this->ref;
|
||||
}
|
||||
$result .= $linkend;
|
||||
|
||||
return $result;
|
||||
@ -488,19 +498,19 @@ class Opensurveysondage extends CommonObject
|
||||
$sql .= " WHERE id_sondage = '".$this->db->escape($this->id_sondage)."'";
|
||||
$resql = $this->db->query($sql);
|
||||
|
||||
if ($resql)
|
||||
{
|
||||
if ($resql) {
|
||||
$num = $this->db->num_rows($resql);
|
||||
$i = 0;
|
||||
while ($i < $num)
|
||||
{
|
||||
while ($i < $num) {
|
||||
$obj = $this->db->fetch_object($resql);
|
||||
$tmp = array('id_users'=>$obj->id_users, 'nom'=>$obj->name, 'reponses'=>$obj->reponses);
|
||||
|
||||
$ret[] = $tmp;
|
||||
$i++;
|
||||
}
|
||||
} else dol_print_error($this->db);
|
||||
} else {
|
||||
dol_print_error($this->db);
|
||||
}
|
||||
|
||||
$this->lines = $ret;
|
||||
|
||||
@ -543,14 +553,11 @@ class Opensurveysondage extends CommonObject
|
||||
$sql .= " ORDER BY id_comment";
|
||||
$resql = $this->db->query($sql);
|
||||
|
||||
if ($resql)
|
||||
{
|
||||
if ($resql) {
|
||||
$num_rows = $this->db->num_rows($resql);
|
||||
|
||||
if ($num_rows > 0)
|
||||
{
|
||||
while ($obj = $this->db->fetch_object($resql))
|
||||
{
|
||||
if ($num_rows > 0) {
|
||||
while ($obj = $this->db->fetch_object($resql)) {
|
||||
$comments[] = $obj;
|
||||
}
|
||||
}
|
||||
@ -642,8 +649,7 @@ class Opensurveysondage extends CommonObject
|
||||
// phpcs:enable
|
||||
global $langs, $conf;
|
||||
|
||||
if (empty($this->labelStatus) || empty($this->labelStatusShort))
|
||||
{
|
||||
if (empty($this->labelStatus) || empty($this->labelStatusShort)) {
|
||||
global $langs;
|
||||
//$langs->load("mymodule");
|
||||
$this->labelStatus[self::STATUS_DRAFT] = $langs->trans('Draft');
|
||||
@ -656,10 +662,15 @@ class Opensurveysondage extends CommonObject
|
||||
|
||||
$statusType = 'status'.$status;
|
||||
if ($status == self::STATUS_VALIDATED) {
|
||||
if (0) $statusType = 'status1';
|
||||
else $statusType = 'status4';
|
||||
if (0) {
|
||||
$statusType = 'status1';
|
||||
} else {
|
||||
$statusType = 'status4';
|
||||
}
|
||||
}
|
||||
if ($status == self::STATUS_CLOSED) {
|
||||
$statusType = 'status6';
|
||||
}
|
||||
if ($status == self::STATUS_CLOSED) $statusType = 'status6';
|
||||
|
||||
return dolGetStatus($this->labelStatus[$status], $this->labelStatusShort[$status], '', $statusType, $mode);
|
||||
}
|
||||
|
||||
@ -30,14 +30,15 @@ require_once DOL_DOCUMENT_ROOT."/opensurvey/class/opensurveysondage.class.php";
|
||||
|
||||
$action = GETPOST('action', 'aZ09');
|
||||
$numsondage = '';
|
||||
if (GETPOST('id'))
|
||||
{
|
||||
if (GETPOST('id')) {
|
||||
$numsondage = GETPOST("id", 'alpha');
|
||||
}
|
||||
|
||||
$object = new Opensurveysondage($db);
|
||||
$result = $object->fetch(0, $numsondage);
|
||||
if ($result <= 0) dol_print_error('', 'Failed to get survey id '.$numsondage);
|
||||
if ($result <= 0) {
|
||||
dol_print_error('', 'Failed to get survey id '.$numsondage);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
@ -57,10 +58,8 @@ $toutsujet = explode(",", $object->sujet);
|
||||
|
||||
// affichage des sujets du sondage
|
||||
$input .= $langs->trans("Name").";";
|
||||
for ($i = 0; $toutsujet[$i]; $i++)
|
||||
{
|
||||
if ($object->format == "D")
|
||||
{
|
||||
for ($i = 0; $toutsujet[$i]; $i++) {
|
||||
if ($object->format == "D") {
|
||||
$input .= ''.dol_print_date($toutsujet[$i], 'dayhour').';';
|
||||
} else {
|
||||
$input .= ''.$toutsujet[$i].';';
|
||||
@ -69,11 +68,9 @@ for ($i = 0; $toutsujet[$i]; $i++)
|
||||
|
||||
$input .= "\r\n";
|
||||
|
||||
if (strpos($object->sujet, '@') !== false)
|
||||
{
|
||||
if (strpos($object->sujet, '@') !== false) {
|
||||
$input .= ";";
|
||||
for ($i = 0; $toutsujet[$i]; $i++)
|
||||
{
|
||||
for ($i = 0; $toutsujet[$i]; $i++) {
|
||||
$heures = explode("@", $toutsujet[$i]);
|
||||
$input .= ''.$heures[1].';';
|
||||
}
|
||||
@ -87,12 +84,10 @@ $sql .= ' FROM '.MAIN_DB_PREFIX."opensurvey_user_studs";
|
||||
$sql .= " WHERE id_sondage='".$db->escape($numsondage)."'";
|
||||
$sql .= " ORDER BY id_users";
|
||||
$resql = $db->query($sql);
|
||||
if ($resql)
|
||||
{
|
||||
if ($resql) {
|
||||
$num = $db->num_rows($resql);
|
||||
$i = 0;
|
||||
while ($i < $num)
|
||||
{
|
||||
while ($i < $num) {
|
||||
$obj = $db->fetch_object($resql);
|
||||
|
||||
// Le name de l'utilisateur
|
||||
@ -101,15 +96,12 @@ if ($resql)
|
||||
|
||||
//affichage des resultats
|
||||
$ensemblereponses = $obj->reponses;
|
||||
for ($k = 0; $k < $nbcolonnes; $k++)
|
||||
{
|
||||
for ($k = 0; $k < $nbcolonnes; $k++) {
|
||||
$car = substr($ensemblereponses, $k, 1);
|
||||
if ($car == "1")
|
||||
{
|
||||
if ($car == "1") {
|
||||
$input .= 'OK;';
|
||||
$somme[$k]++;
|
||||
} elseif ($car == "2")
|
||||
{
|
||||
} elseif ($car == "2") {
|
||||
$input .= 'KO;';
|
||||
$somme[$k]++;
|
||||
} else {
|
||||
@ -120,7 +112,9 @@ if ($resql)
|
||||
$input .= "\r\n";
|
||||
$i++;
|
||||
}
|
||||
} else dol_print_error($db);
|
||||
} else {
|
||||
dol_print_error($db);
|
||||
}
|
||||
|
||||
|
||||
$filesize = strlen($input);
|
||||
|
||||
@ -96,19 +96,16 @@ function llxHeaderSurvey($title, $head = "", $disablejs = 0, $disablehead = 0, $
|
||||
// Define urllogo
|
||||
$urllogo = '';
|
||||
$urllogofull = '';
|
||||
if (!empty($logosmall) && is_readable($conf->mycompany->dir_output.'/logos/thumbs/'.$logosmall))
|
||||
{
|
||||
if (!empty($logosmall) && is_readable($conf->mycompany->dir_output.'/logos/thumbs/'.$logosmall)) {
|
||||
$urllogo = DOL_URL_ROOT.'/viewimage.php?modulepart=mycompany&entity='.$conf->entity.'&file='.urlencode('logos/thumbs/'.$logosmall);
|
||||
$urllogofull = $dolibarr_main_url_root.'/viewimage.php?modulepart=mycompany&entity='.$conf->entity.'&file='.urlencode('logos/thumbs/'.$logosmall);
|
||||
} elseif (!empty($logo) && is_readable($conf->mycompany->dir_output.'/logos/'.$logo))
|
||||
{
|
||||
} elseif (!empty($logo) && is_readable($conf->mycompany->dir_output.'/logos/'.$logo)) {
|
||||
$urllogo = DOL_URL_ROOT.'/viewimage.php?modulepart=mycompany&entity='.$conf->entity.'&file='.urlencode('logos/'.$logo);
|
||||
$urllogofull = $dolibarr_main_url_root.'/viewimage.php?modulepart=mycompany&entity='.$conf->entity.'&file='.urlencode('logos/'.$logo);
|
||||
}
|
||||
|
||||
// Output html code for logo
|
||||
if ($urllogo)
|
||||
{
|
||||
if ($urllogo) {
|
||||
print '<div class="backgreypublicpayment">';
|
||||
print '<div class="logopublicpayment">';
|
||||
print '<img id="dolpaymentlogo" src="'.$urllogo.'"';
|
||||
|
||||
@ -31,7 +31,9 @@ require_once DOL_DOCUMENT_ROOT."/core/lib/files.lib.php";
|
||||
$langs->load("opensurvey");
|
||||
|
||||
// Security check
|
||||
if (!$user->rights->opensurvey->read) accessforbidden();
|
||||
if (!$user->rights->opensurvey->read) {
|
||||
accessforbidden();
|
||||
}
|
||||
|
||||
$hookmanager = new HookManager($db);
|
||||
|
||||
@ -48,11 +50,12 @@ $sql = 'SELECT COUNT(*) as nb';
|
||||
$sql .= ' FROM '.MAIN_DB_PREFIX.'opensurvey_sondage';
|
||||
$sql .= ' WHERE entity IN ('.getEntity('survey').')';
|
||||
$resql = $db->query($sql);
|
||||
if ($resql)
|
||||
{
|
||||
if ($resql) {
|
||||
$obj = $db->fetch_object($resql);
|
||||
$nbsondages = $obj->nb;
|
||||
} else dol_print_error($db, '');
|
||||
} else {
|
||||
dol_print_error($db, '');
|
||||
}
|
||||
|
||||
|
||||
$title = $langs->trans("OpenSurveyArea");
|
||||
|
||||
@ -50,7 +50,9 @@ $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit;
|
||||
$sortfield = GETPOST('sortfield', 'aZ09comma');
|
||||
$sortorder = GETPOST('sortorder', 'aZ09comma');
|
||||
$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
|
||||
if (empty($page) || $page == -1 || GETPOST('button_search', 'alpha') || GETPOST('button_removefilter', 'alpha') || (empty($toselect) && $massaction === '0')) { $page = 0; } // If $page is not defined, or '' or -1 or if we click on clear filters or if we select empty mass action
|
||||
if (empty($page) || $page == -1 || GETPOST('button_search', 'alpha') || GETPOST('button_removefilter', 'alpha') || (empty($toselect) && $massaction === '0')) {
|
||||
$page = 0;
|
||||
} // If $page is not defined, or '' or -1 or if we click on clear filters or if we select empty mass action
|
||||
$offset = $limit * $page;
|
||||
$pageprev = $page - 1;
|
||||
$pagenext = $page + 1;
|
||||
@ -67,24 +69,29 @@ $extrafields->fetch_name_optionals_label($object->table_element);
|
||||
$search_array_options = $extrafields->getOptionalsFromPost($object->table_element, '', 'search_');
|
||||
|
||||
// Default sort order (if not yet defined by previous GETPOST)
|
||||
if (!$sortfield) $sortfield = "p.date_fin";
|
||||
if (!$sortorder) $sortorder = "DESC";
|
||||
if (!$sortfield) {
|
||||
$sortfield = "p.date_fin";
|
||||
}
|
||||
if (!$sortorder) {
|
||||
$sortorder = "DESC";
|
||||
}
|
||||
|
||||
// Security check
|
||||
if (!$user->rights->opensurvey->read) accessforbidden();
|
||||
if (!$user->rights->opensurvey->read) {
|
||||
accessforbidden();
|
||||
}
|
||||
|
||||
// Definition of fields for list
|
||||
$arrayfields = array();
|
||||
foreach ($arrayfields as $key => $val)
|
||||
{
|
||||
foreach ($arrayfields as $key => $val) {
|
||||
// If $val['visible']==0, then we never show the field
|
||||
if (!empty($val['visible'])) $arrayfields['t.'.$key] = array('label'=>$val['label'], 'checked'=>(($val['visible'] < 0) ? 0 : 1), 'enabled'=>$val['enabled'], 'position'=>$val['position']);
|
||||
if (!empty($val['visible'])) {
|
||||
$arrayfields['t.'.$key] = array('label'=>$val['label'], 'checked'=>(($val['visible'] < 0) ? 0 : 1), 'enabled'=>$val['enabled'], 'position'=>$val['position']);
|
||||
}
|
||||
}
|
||||
// Extra fields
|
||||
if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label']) > 0)
|
||||
{
|
||||
foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val)
|
||||
{
|
||||
if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label']) > 0) {
|
||||
foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) {
|
||||
if (!empty($extrafields->attributes[$object->table_element]['list'][$key])) {
|
||||
$arrayfields["ef.".$key] = array(
|
||||
'label'=>$extrafields->attributes[$object->table_element]['label'][$key],
|
||||
@ -107,21 +114,25 @@ $permissiontodelete = $user->rights->opensurvey->delete;
|
||||
* Actions
|
||||
*/
|
||||
|
||||
if (GETPOST('cancel', 'alpha')) { $action = 'list'; $massaction = ''; }
|
||||
if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') { $massaction = ''; }
|
||||
if (GETPOST('cancel', 'alpha')) {
|
||||
$action = 'list'; $massaction = '';
|
||||
}
|
||||
if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') {
|
||||
$massaction = '';
|
||||
}
|
||||
|
||||
$parameters = array();
|
||||
$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
|
||||
if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
|
||||
if ($reshook < 0) {
|
||||
setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
|
||||
}
|
||||
|
||||
if (empty($reshook))
|
||||
{
|
||||
if (empty($reshook)) {
|
||||
// Selection of new fields
|
||||
include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php';
|
||||
|
||||
// Purge search criteria
|
||||
if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) // All tests are required to be compatible with all browsers
|
||||
{
|
||||
if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) { // All tests are required to be compatible with all browsers
|
||||
$search_status = '';
|
||||
$search_title = '';
|
||||
$search_ref = '';
|
||||
@ -129,8 +140,7 @@ if (empty($reshook))
|
||||
$search_array_options = array();
|
||||
}
|
||||
if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')
|
||||
|| GETPOST('button_search_x', 'alpha') || GETPOST('button_search.x', 'alpha') || GETPOST('button_search', 'alpha'))
|
||||
{
|
||||
|| GETPOST('button_search_x', 'alpha') || GETPOST('button_search.x', 'alpha') || GETPOST('button_search', 'alpha')) {
|
||||
$massaction = ''; // Protection to avoid mass action if we force a new search during a mass action confirmation
|
||||
}
|
||||
|
||||
@ -160,11 +170,21 @@ $sql .= " u.login, u.firstname, u.lastname";
|
||||
$sql .= " FROM ".MAIN_DB_PREFIX."opensurvey_sondage as p";
|
||||
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."user u ON u.rowid = p.fk_user_creat";
|
||||
$sql .= " WHERE p.entity IN (".getEntity('survey').")";
|
||||
if ($search_status != '-1' && $search_status != '') $sql .= natural_search("p.status", $search_status, 2);
|
||||
if ($search_expired == 'expired') $sql .= " AND p.date_fin < '".$db->idate($now)."'";
|
||||
if ($search_expired == 'opened') $sql .= " AND p.date_fin >= '".$db->idate($now)."'";
|
||||
if ($search_ref) $sql .= natural_search("p.id_sondage", $search_ref);
|
||||
if ($search_title) $sql .= natural_search("p.titre", $search_title);
|
||||
if ($search_status != '-1' && $search_status != '') {
|
||||
$sql .= natural_search("p.status", $search_status, 2);
|
||||
}
|
||||
if ($search_expired == 'expired') {
|
||||
$sql .= " AND p.date_fin < '".$db->idate($now)."'";
|
||||
}
|
||||
if ($search_expired == 'opened') {
|
||||
$sql .= " AND p.date_fin >= '".$db->idate($now)."'";
|
||||
}
|
||||
if ($search_ref) {
|
||||
$sql .= natural_search("p.id_sondage", $search_ref);
|
||||
}
|
||||
if ($search_title) {
|
||||
$sql .= natural_search("p.titre", $search_title);
|
||||
}
|
||||
// Add where from extra fields
|
||||
include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php';
|
||||
// Add where from hooks
|
||||
@ -176,26 +196,22 @@ $sql .= $db->order($sortfield, $sortorder);
|
||||
|
||||
// Count total nb of records
|
||||
$nbtotalofrecords = '';
|
||||
if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST))
|
||||
{
|
||||
if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) {
|
||||
$resql = $db->query($sql);
|
||||
$nbtotalofrecords = $db->num_rows($resql);
|
||||
if (($page * $limit) > $nbtotalofrecords) // if total of record found is smaller than page * limit, goto and load page 0
|
||||
{
|
||||
if (($page * $limit) > $nbtotalofrecords) { // if total of record found is smaller than page * limit, goto and load page 0
|
||||
$page = 0;
|
||||
$offset = 0;
|
||||
}
|
||||
}
|
||||
// if total of record found is smaller than limit, no need to do paging and to restart another select with limits set.
|
||||
if (is_numeric($nbtotalofrecords) && $limit > $nbtotalofrecords)
|
||||
{
|
||||
if (is_numeric($nbtotalofrecords) && $limit > $nbtotalofrecords) {
|
||||
$num = $nbtotalofrecords;
|
||||
} else {
|
||||
$sql .= $db->plimit($limit + 1, $offset);
|
||||
|
||||
$resql = $db->query($sql);
|
||||
if (!$resql)
|
||||
{
|
||||
if (!$resql) {
|
||||
dol_print_error($db);
|
||||
exit;
|
||||
}
|
||||
@ -204,8 +220,7 @@ if (is_numeric($nbtotalofrecords) && $limit > $nbtotalofrecords)
|
||||
}
|
||||
|
||||
// Direct jump if only one record found
|
||||
if ($num == 1 && !empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && $search_all)
|
||||
{
|
||||
if ($num == 1 && !empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && $search_all) {
|
||||
$obj = $db->fetch_object($resql);
|
||||
$id = $obj->rowid;
|
||||
header("Location: ".dol_buildpath('/opensurvey/card.php', 1).'?id='.$id);
|
||||
@ -221,11 +236,17 @@ llxHeader('', $title, $help_url);
|
||||
$arrayofselected = is_array($toselect) ? $toselect : array();
|
||||
|
||||
$param = '';
|
||||
if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.urlencode($contextpage);
|
||||
if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.urlencode($limit);
|
||||
if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) {
|
||||
$param .= '&contextpage='.urlencode($contextpage);
|
||||
}
|
||||
if ($limit > 0 && $limit != $conf->liste_limit) {
|
||||
$param .= '&limit='.urlencode($limit);
|
||||
}
|
||||
$fieldtosortuser = empty($conf->global->MAIN_FIRSTNAME_NAME_POSITION) ? 'firstname' : 'lastname';
|
||||
|
||||
if ($optioncss != '') $param .= '&optioncss='.urlencode($optioncss);
|
||||
if ($optioncss != '') {
|
||||
$param .= '&optioncss='.urlencode($optioncss);
|
||||
}
|
||||
// Add $param from extra fields
|
||||
include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php';
|
||||
|
||||
@ -234,15 +255,21 @@ $arrayofmassactions = array(
|
||||
//'presend'=>$langs->trans("SendByMail"),
|
||||
//'builddoc'=>$langs->trans("PDFMerge"),
|
||||
);
|
||||
if ($permissiontodelete) $arrayofmassactions['predelete'] = '<span class="fa fa-trash paddingrightonly"></span>'.$langs->trans("Delete");
|
||||
if (GETPOST('nomassaction', 'int') || in_array($massaction, array('presend', 'predelete'))) $arrayofmassactions = array();
|
||||
if ($permissiontodelete) {
|
||||
$arrayofmassactions['predelete'] = '<span class="fa fa-trash paddingrightonly"></span>'.$langs->trans("Delete");
|
||||
}
|
||||
if (GETPOST('nomassaction', 'int') || in_array($massaction, array('presend', 'predelete'))) {
|
||||
$arrayofmassactions = array();
|
||||
}
|
||||
$massactionbutton = $form->selectMassAction('', $arrayofmassactions);
|
||||
|
||||
|
||||
// List of surveys into database
|
||||
|
||||
print '<form method="POST" id="searchFormList" action="'.$_SERVER["PHP_SELF"].'">';
|
||||
if ($optioncss != '') print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
|
||||
if ($optioncss != '') {
|
||||
print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
|
||||
}
|
||||
print '<input type="hidden" name="token" value="'.newToken().'">';
|
||||
print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
|
||||
print '<input type="hidden" name="action" value="list">';
|
||||
@ -261,9 +288,10 @@ $objecttmp = new Opensurveysondage($db);
|
||||
$trackid = 'surv'.$object->id;
|
||||
include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php';
|
||||
|
||||
if ($sall)
|
||||
{
|
||||
foreach ($fieldstosearchall as $key => $val) $fieldstosearchall[$key] = $langs->trans($val);
|
||||
if ($sall) {
|
||||
foreach ($fieldstosearchall as $key => $val) {
|
||||
$fieldstosearchall[$key] = $langs->trans($val);
|
||||
}
|
||||
print '<div class="divsearchfieldfilter">'.$langs->trans("FilterOnInto", $sall).join(', ', $fieldstosearchall).'</div>';
|
||||
}
|
||||
|
||||
@ -274,11 +302,13 @@ $moreforfilter.= '</div>';*/
|
||||
|
||||
$parameters = array();
|
||||
$reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters, $object); // Note that $action and $object may have been modified by hook
|
||||
if (empty($reshook)) $moreforfilter .= $hookmanager->resPrint;
|
||||
else $moreforfilter = $hookmanager->resPrint;
|
||||
if (empty($reshook)) {
|
||||
$moreforfilter .= $hookmanager->resPrint;
|
||||
} else {
|
||||
$moreforfilter = $hookmanager->resPrint;
|
||||
}
|
||||
|
||||
if (!empty($moreforfilter))
|
||||
{
|
||||
if (!empty($moreforfilter)) {
|
||||
print '<div class="liste_titre liste_titre_bydiv centpercent">';
|
||||
print $moreforfilter;
|
||||
print '</div>';
|
||||
@ -346,18 +376,20 @@ print '</tr>'."\n";
|
||||
// --------------------------------------------------------------------
|
||||
$i = 0;
|
||||
$totalarray = array();
|
||||
while ($i < min($num, $limit))
|
||||
{
|
||||
while ($i < min($num, $limit)) {
|
||||
$obj = $db->fetch_object($resql);
|
||||
if (empty($obj)) break; // Should not happen
|
||||
if (empty($obj)) {
|
||||
break; // Should not happen
|
||||
}
|
||||
|
||||
$sql2 = 'select COUNT(*) as nb from '.MAIN_DB_PREFIX."opensurvey_user_studs where id_sondage='".$db->escape($obj->rowid)."'";
|
||||
$resql2 = $db->query($sql2);
|
||||
if ($resql2)
|
||||
{
|
||||
if ($resql2) {
|
||||
$obj2 = $db->fetch_object($resql2);
|
||||
$nbuser = $obj2->nb;
|
||||
} else dol_print_error($db);
|
||||
} else {
|
||||
dol_print_error($db);
|
||||
}
|
||||
|
||||
$opensurvey_static->id = $obj->rowid;
|
||||
$opensurvey_static->ref = $obj->rowid;
|
||||
@ -372,11 +404,15 @@ while ($i < min($num, $limit))
|
||||
print '<td>';
|
||||
print $opensurvey_static->getNomUrl(1);
|
||||
print '</td>';
|
||||
if (!$i) $totalarray['nbfield']++;
|
||||
if (!$i) {
|
||||
$totalarray['nbfield']++;
|
||||
}
|
||||
|
||||
// Title
|
||||
print '<td>'.dol_htmlentities($obj->title).'</td>';
|
||||
if (!$i) $totalarray['nbfield']++;
|
||||
if (!$i) {
|
||||
$totalarray['nbfield']++;
|
||||
}
|
||||
|
||||
// Type
|
||||
print '<td>';
|
||||
@ -384,7 +420,9 @@ while ($i < min($num, $limit))
|
||||
print img_picto('', dol_buildpath('/opensurvey/img/'.($type == 'classic' ? 'chart-32.png' : 'calendar-32.png'), 1), 'width="16"', 1);
|
||||
print ' '.$langs->trans($type == 'classic' ? "TypeClassic" : "TypeDate");
|
||||
print '</td>';
|
||||
if (!$i) $totalarray['nbfield']++;
|
||||
if (!$i) {
|
||||
$totalarray['nbfield']++;
|
||||
}
|
||||
|
||||
print '<td>';
|
||||
// Author
|
||||
@ -400,23 +438,35 @@ while ($i < min($num, $limit))
|
||||
print dol_htmlentities($obj->nom_admin);
|
||||
}
|
||||
print '</td>';
|
||||
if (!$i) $totalarray['nbfield']++;
|
||||
if (!$i) {
|
||||
$totalarray['nbfield']++;
|
||||
}
|
||||
|
||||
// Nb of voters
|
||||
print'<td class="right">'.$nbuser.'</td>'."\n";
|
||||
if (!$i) $totalarray['nbfield']++;
|
||||
if (!$i) {
|
||||
$totalarray['nbfield']++;
|
||||
}
|
||||
|
||||
print '<td class="center">'.dol_print_date($db->jdate($obj->date_fin), 'day');
|
||||
if ($db->jdate($obj->date_fin) < $now && $obj->status == Opensurveysondage::STATUS_VALIDATED) { print img_warning($langs->trans("Expired")); }
|
||||
if ($db->jdate($obj->date_fin) < $now && $obj->status == Opensurveysondage::STATUS_VALIDATED) {
|
||||
print img_warning($langs->trans("Expired"));
|
||||
}
|
||||
print '</td>';
|
||||
if (!$i) $totalarray['nbfield']++;
|
||||
if (!$i) {
|
||||
$totalarray['nbfield']++;
|
||||
}
|
||||
|
||||
print '<td class="center">'.dol_print_date($db->jdate($obj->tms), 'dayhour');
|
||||
print '</td>';
|
||||
if (!$i) $totalarray['nbfield']++;
|
||||
if (!$i) {
|
||||
$totalarray['nbfield']++;
|
||||
}
|
||||
|
||||
print '<td class="center">'.$opensurvey_static->getLibStatut(5).'</td>'."\n";
|
||||
if (!$i) $totalarray['nbfield']++;
|
||||
if (!$i) {
|
||||
$totalarray['nbfield']++;
|
||||
}
|
||||
|
||||
// Extra fields
|
||||
include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php';
|
||||
@ -426,14 +476,17 @@ while ($i < min($num, $limit))
|
||||
print $hookmanager->resPrint;
|
||||
// Action column
|
||||
print '<td class="nowrap center">';
|
||||
if ($massactionbutton || $massaction) // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
|
||||
{
|
||||
if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
|
||||
$selected = 0;
|
||||
if (in_array($obj->rowid, $arrayofselected)) $selected = 1;
|
||||
if (in_array($obj->rowid, $arrayofselected)) {
|
||||
$selected = 1;
|
||||
}
|
||||
print '<input id="cb'.$obj->rowid.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$obj->rowid.'"'.($selected ? ' checked="checked"' : '').'>';
|
||||
}
|
||||
print '</td>';
|
||||
if (!$i) $totalarray['nbfield']++;
|
||||
if (!$i) {
|
||||
$totalarray['nbfield']++;
|
||||
}
|
||||
|
||||
print '</tr>'."\n";
|
||||
$i++;
|
||||
@ -444,10 +497,13 @@ include DOL_DOCUMENT_ROOT.'/core/tpl/list_print_total.tpl.php';
|
||||
|
||||
|
||||
// If no record found
|
||||
if ($num == 0)
|
||||
{
|
||||
if ($num == 0) {
|
||||
$colspan = 8;
|
||||
foreach ($arrayfields as $key => $val) { if (!empty($val['checked'])) $colspan++; }
|
||||
foreach ($arrayfields as $key => $val) {
|
||||
if (!empty($val['checked'])) {
|
||||
$colspan++;
|
||||
}
|
||||
}
|
||||
print '<tr><td colspan="'.$colspan.'" class="opacitymedium">'.$langs->trans("NoRecordFound").'</td></tr>';
|
||||
}
|
||||
|
||||
@ -463,10 +519,11 @@ print '</div>'."\n";
|
||||
|
||||
print '</form>'."\n";
|
||||
|
||||
if (in_array('builddoc', $arrayofmassactions) && ($nbtotalofrecords === '' || $nbtotalofrecords))
|
||||
{
|
||||
if (in_array('builddoc', $arrayofmassactions) && ($nbtotalofrecords === '' || $nbtotalofrecords)) {
|
||||
$hidegeneratedfilelistifempty = 1;
|
||||
if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) $hidegeneratedfilelistifempty = 0;
|
||||
if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) {
|
||||
$hidegeneratedfilelistifempty = 0;
|
||||
}
|
||||
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
|
||||
$formfile = new FormFile($db);
|
||||
|
||||
@ -31,7 +31,9 @@ require_once DOL_DOCUMENT_ROOT."/opensurvey/fonctions.php";
|
||||
|
||||
|
||||
// Security check
|
||||
if (!$user->rights->opensurvey->read) accessforbidden();
|
||||
if (!$user->rights->opensurvey->read) {
|
||||
accessforbidden();
|
||||
}
|
||||
|
||||
|
||||
// Init vars
|
||||
@ -40,7 +42,9 @@ $numsondage = GETPOST("id");
|
||||
|
||||
$object = new Opensurveysondage($db);
|
||||
$result = $object->fetch(0, $numsondage);
|
||||
if ($result <= 0) dol_print_error('', 'Failed to get survey id '.$numsondage);
|
||||
if ($result <= 0) {
|
||||
dol_print_error('', 'Failed to get survey id '.$numsondage);
|
||||
}
|
||||
|
||||
$nblines = $object->fetch_lines();
|
||||
|
||||
@ -58,20 +62,15 @@ if (GETPOST('retoursondage')) {
|
||||
$nbcolonnes = substr_count($object->sujet, ',') + 1;
|
||||
|
||||
// Add vote
|
||||
if (GETPOST("boutonp") || GETPOST("boutonp.x") || GETPOST("boutonp_x")) // boutonp for chrome, boutonp.x for firefox
|
||||
{
|
||||
if (GETPOST('nom'))
|
||||
{
|
||||
if (GETPOST("boutonp") || GETPOST("boutonp.x") || GETPOST("boutonp_x")) { // boutonp for chrome, boutonp.x for firefox
|
||||
if (GETPOST('nom')) {
|
||||
$erreur_prenom = false;
|
||||
|
||||
$nouveauchoix = '';
|
||||
for ($i = 0; $i < $nbcolonnes; $i++)
|
||||
{
|
||||
if (isset($_POST["choix$i"]) && $_POST["choix$i"] == '1')
|
||||
{
|
||||
for ($i = 0; $i < $nbcolonnes; $i++) {
|
||||
if (isset($_POST["choix$i"]) && $_POST["choix$i"] == '1') {
|
||||
$nouveauchoix .= "1";
|
||||
} elseif (isset($_POST["choix$i"]) && $_POST["choix$i"] == '2')
|
||||
{
|
||||
} elseif (isset($_POST["choix$i"]) && $_POST["choix$i"] == '2') {
|
||||
$nouveauchoix .= "2";
|
||||
} else { // sinon c'est 0
|
||||
$nouveauchoix .= "0";
|
||||
@ -87,15 +86,16 @@ if (GETPOST("boutonp") || GETPOST("boutonp.x") || GETPOST("boutonp_x")) // bout
|
||||
$sql .= ' ORDER BY id_users';
|
||||
$resql = $db->query($sql);
|
||||
$num_rows = $db->num_rows($resql);
|
||||
if ($num_rows > 0)
|
||||
{
|
||||
if ($num_rows > 0) {
|
||||
setEventMessages($langs->trans("VoteNameAlreadyExists"), null, 'errors');
|
||||
$error++;
|
||||
} else {
|
||||
$sql = 'INSERT INTO '.MAIN_DB_PREFIX.'opensurvey_user_studs (nom, id_sondage, reponses)';
|
||||
$sql .= " VALUES ('".$db->escape($nom)."', '".$db->escape($numsondage)."','".$db->escape($nouveauchoix)."')";
|
||||
$resql = $db->query($sql);
|
||||
if (!$resql) dol_print_error($db);
|
||||
if (!$resql) {
|
||||
dol_print_error($db);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -104,35 +104,30 @@ if (GETPOST("boutonp") || GETPOST("boutonp.x") || GETPOST("boutonp_x")) // bout
|
||||
$testmodifier = false;
|
||||
$testligneamodifier = false;
|
||||
$ligneamodifier = -1;
|
||||
for ($i = 0; $i < $nblines; $i++)
|
||||
{
|
||||
if (isset($_POST['modifierligne'.$i]))
|
||||
{
|
||||
for ($i = 0; $i < $nblines; $i++) {
|
||||
if (isset($_POST['modifierligne'.$i])) {
|
||||
$ligneamodifier = $i;
|
||||
$testligneamodifier = true;
|
||||
}
|
||||
|
||||
//test pour voir si une ligne est a modifier
|
||||
if (isset($_POST['validermodifier'.$i]))
|
||||
{
|
||||
if (isset($_POST['validermodifier'.$i])) {
|
||||
$modifier = $i;
|
||||
$testmodifier = true;
|
||||
}
|
||||
}
|
||||
if ($testmodifier)
|
||||
{
|
||||
if ($testmodifier) {
|
||||
// Security check
|
||||
if (!$user->rights->opensurvey->write) accessforbidden();
|
||||
if (!$user->rights->opensurvey->write) {
|
||||
accessforbidden();
|
||||
}
|
||||
|
||||
$nouveauchoix = '';
|
||||
for ($i = 0; $i < $nbcolonnes; $i++)
|
||||
{
|
||||
for ($i = 0; $i < $nbcolonnes; $i++) {
|
||||
//var_dump($_POST["choix$i"]);
|
||||
if (isset($_POST["choix$i"]) && $_POST["choix$i"] == '1')
|
||||
{
|
||||
if (isset($_POST["choix$i"]) && $_POST["choix$i"] == '1') {
|
||||
$nouveauchoix .= "1";
|
||||
} elseif (isset($_POST["choix$i"]) && $_POST["choix$i"] == '2')
|
||||
{
|
||||
} elseif (isset($_POST["choix$i"]) && $_POST["choix$i"] == '2') {
|
||||
$nouveauchoix .= "2";
|
||||
} else { // sinon c'est 0
|
||||
$nouveauchoix .= "0";
|
||||
@ -145,14 +140,17 @@ if ($testmodifier)
|
||||
$sql .= " WHERE id_users = '".$db->escape($idtomodify)."'";
|
||||
|
||||
$resql = $db->query($sql);
|
||||
if (!$resql) dol_print_error($db);
|
||||
if (!$resql) {
|
||||
dol_print_error($db);
|
||||
}
|
||||
}
|
||||
|
||||
// Add column (not for date)
|
||||
if (GETPOST("ajoutercolonne") && GETPOST('nouvellecolonne') && $object->format == "A")
|
||||
{
|
||||
if (GETPOST("ajoutercolonne") && GETPOST('nouvellecolonne') && $object->format == "A") {
|
||||
// Security check
|
||||
if (!$user->rights->opensurvey->write) accessforbidden();
|
||||
if (!$user->rights->opensurvey->write) {
|
||||
accessforbidden();
|
||||
}
|
||||
|
||||
$nouveauxsujets = $object->sujet;
|
||||
|
||||
@ -165,17 +163,19 @@ if (GETPOST("ajoutercolonne") && GETPOST('nouvellecolonne') && $object->format =
|
||||
$sql .= " SET sujet = '".$db->escape($nouveauxsujets)."'";
|
||||
$sql .= " WHERE id_sondage = '".$db->escape($numsondage)."'";
|
||||
$resql = $db->query($sql);
|
||||
if (!$resql) dol_print_error($db);
|
||||
else {
|
||||
if (!$resql) {
|
||||
dol_print_error($db);
|
||||
} else {
|
||||
header('Location: results.php?id='.$object->id_sondage);
|
||||
}
|
||||
}
|
||||
|
||||
// Add column (with format date)
|
||||
if (isset($_POST["ajoutercolonne"]) && $object->format == "D")
|
||||
{
|
||||
if (isset($_POST["ajoutercolonne"]) && $object->format == "D") {
|
||||
// Security check
|
||||
if (!$user->rights->opensurvey->write) accessforbidden();
|
||||
if (!$user->rights->opensurvey->write) {
|
||||
accessforbidden();
|
||||
}
|
||||
|
||||
$nouveauxsujets = $object->sujet;
|
||||
|
||||
@ -223,8 +223,7 @@ if (isset($_POST["ajoutercolonne"]) && $object->format == "D")
|
||||
$cleinsertion = count($datesbase);
|
||||
} else {
|
||||
$nbdatesbase = count($datesbase);
|
||||
for ($i = 0; $i < $nbdatesbase; $i++)
|
||||
{
|
||||
for ($i = 0; $i < $nbdatesbase; $i++) {
|
||||
$j = $i + 1;
|
||||
if ($nouvelledate > $datesbase[$i] && $nouvelledate < $datesbase[$j]) {
|
||||
$cleinsertion = $j;
|
||||
@ -244,14 +243,14 @@ if (isset($_POST["ajoutercolonne"]) && $object->format == "D")
|
||||
$dateinsertion = substr("$dateinsertion", 1);
|
||||
|
||||
// update with new topics into database
|
||||
if (isset($erreur_ajout_date) && empty($erreur_ajout_date))
|
||||
{
|
||||
if (isset($erreur_ajout_date) && empty($erreur_ajout_date)) {
|
||||
$sql = 'UPDATE '.MAIN_DB_PREFIX."opensurvey_sondage";
|
||||
$sql .= " SET sujet = '".$db->escape($dateinsertion)."'";
|
||||
$sql .= " WHERE id_sondage = '".$db->escape($numsondage)."'";
|
||||
$resql = $db->query($sql);
|
||||
if (!$resql) dol_print_error($db);
|
||||
else {
|
||||
if (!$resql) {
|
||||
dol_print_error($db);
|
||||
} else {
|
||||
header('Location: results.php?id='.$object->id_sondage);
|
||||
}
|
||||
}
|
||||
@ -263,12 +262,12 @@ if (isset($_POST["ajoutercolonne"]) && $object->format == "D")
|
||||
}
|
||||
|
||||
// Delete line
|
||||
for ($i = 0; $i < $nblines; $i++)
|
||||
{
|
||||
if (GETPOST("effaceligne".$i) || GETPOST("effaceligne".$i."_x") || GETPOST("effaceligne".$i.".x")) // effacelignei for chrome, effacelignei_x for firefox
|
||||
{
|
||||
// Security check
|
||||
if (!$user->rights->opensurvey->write) accessforbidden();
|
||||
for ($i = 0; $i < $nblines; $i++) {
|
||||
if (GETPOST("effaceligne".$i) || GETPOST("effaceligne".$i."_x") || GETPOST("effaceligne".$i.".x")) { // effacelignei for chrome, effacelignei_x for firefox
|
||||
// Security check
|
||||
if (!$user->rights->opensurvey->write) {
|
||||
accessforbidden();
|
||||
}
|
||||
|
||||
$compteur = 0;
|
||||
|
||||
@ -278,14 +277,14 @@ for ($i = 0; $i < $nblines; $i++)
|
||||
$sql .= " FROM ".MAIN_DB_PREFIX."opensurvey_user_studs";
|
||||
$sql .= " WHERE id_sondage = '".$db->escape($numsondage)."'";
|
||||
$resql = $db->query($sql);
|
||||
if (!$resql) dol_print_error($db);
|
||||
if (!$resql) {
|
||||
dol_print_error($db);
|
||||
}
|
||||
$num = $db->num_rows($resql);
|
||||
while ($compteur < $num)
|
||||
{
|
||||
while ($compteur < $num) {
|
||||
$obj = $db->fetch_object($resql);
|
||||
|
||||
if ($compteur == $i)
|
||||
{
|
||||
if ($compteur == $i) {
|
||||
$sql2 = 'DELETE FROM '.MAIN_DB_PREFIX.'opensurvey_user_studs';
|
||||
$sql2 .= ' WHERE id_users = '.$db->escape($obj->id_users);
|
||||
$resql2 = $db->query($sql2);
|
||||
@ -297,13 +296,13 @@ for ($i = 0; $i < $nblines; $i++)
|
||||
}
|
||||
|
||||
// Delete column
|
||||
for ($i = 0; $i < $nbcolonnes; $i++)
|
||||
{
|
||||
for ($i = 0; $i < $nbcolonnes; $i++) {
|
||||
if ((GETPOST("effacecolonne".$i) || GETPOST("effacecolonne".$i."_x") || GETPOST("effacecolonne".$i.".x"))
|
||||
&& $nbcolonnes > 1) // effacecolonnei for chrome, effacecolonnei_x for firefox
|
||||
{
|
||||
// Security check
|
||||
if (!$user->rights->opensurvey->write) accessforbidden();
|
||||
&& $nbcolonnes > 1) { // effacecolonnei for chrome, effacecolonnei_x for firefox
|
||||
// Security check
|
||||
if (!$user->rights->opensurvey->write) {
|
||||
accessforbidden();
|
||||
}
|
||||
|
||||
$db->begin();
|
||||
|
||||
@ -312,12 +311,12 @@ for ($i = 0; $i < $nbcolonnes; $i++)
|
||||
$nouveauxsujets = '';
|
||||
|
||||
//parcours de tous les sujets actuels
|
||||
while (isset($toutsujet[$j]))
|
||||
{
|
||||
while (isset($toutsujet[$j])) {
|
||||
//si le sujet n'est pas celui qui a été effacé alors on concatene
|
||||
if ($i != $j)
|
||||
{
|
||||
if (!empty($nouveauxsujets)) $nouveauxsujets .= ',';
|
||||
if ($i != $j) {
|
||||
if (!empty($nouveauxsujets)) {
|
||||
$nouveauxsujets .= ',';
|
||||
}
|
||||
$nouveauxsujets .= $toutsujet[$j];
|
||||
}
|
||||
|
||||
@ -328,7 +327,9 @@ for ($i = 0; $i < $nbcolonnes; $i++)
|
||||
$sql = 'UPDATE '.MAIN_DB_PREFIX."opensurvey_sondage";
|
||||
$sql .= " SET sujet = '".$db->escape($nouveauxsujets)."' WHERE id_sondage = '".$db->escape($numsondage)."'";
|
||||
$resql = $db->query($sql);
|
||||
if (!$resql) dol_print_error($db);
|
||||
if (!$resql) {
|
||||
dol_print_error($db);
|
||||
}
|
||||
|
||||
// Clean current answer to remove deleted columns
|
||||
$compteur = 0;
|
||||
@ -337,22 +338,19 @@ for ($i = 0; $i < $nbcolonnes; $i++)
|
||||
$sql .= " WHERE id_sondage = '".$db->escape($numsondage)."'";
|
||||
dol_syslog('sql='.$sql);
|
||||
$resql = $db->query($sql);
|
||||
if (!$resql)
|
||||
{
|
||||
if (!$resql) {
|
||||
dol_print_error($db);
|
||||
exit;
|
||||
}
|
||||
$num = $db->num_rows($resql);
|
||||
while ($compteur < $num)
|
||||
{
|
||||
while ($compteur < $num) {
|
||||
$obj = $db->fetch_object($resql);
|
||||
|
||||
$newcar = '';
|
||||
$ensemblereponses = $obj->reponses;
|
||||
|
||||
// parcours de toutes les réponses actuelles
|
||||
for ($j = 0; $j < $nbcolonnes; $j++)
|
||||
{
|
||||
for ($j = 0; $j < $nbcolonnes; $j++) {
|
||||
$car = substr($ensemblereponses, $j, 1);
|
||||
//si les reponses ne concerne pas la colonne effacée, on concatene
|
||||
if ($i != $j) {
|
||||
@ -389,8 +387,7 @@ if ($object->fk_user_creat) {
|
||||
}
|
||||
|
||||
$result = $object->fetch(0, $numsondage);
|
||||
if ($result <= 0)
|
||||
{
|
||||
if ($result <= 0) {
|
||||
dol_print_error($db, $object->error);
|
||||
exit;
|
||||
}
|
||||
@ -405,8 +402,7 @@ llxHeader('', $title, $helpurl, 0, 0, 0, $arrayofjs, $arrayofcss);
|
||||
// Define format of choices
|
||||
$toutsujet = explode(",", $object->sujet);
|
||||
$listofanswers = array();
|
||||
foreach ($toutsujet as $value)
|
||||
{
|
||||
foreach ($toutsujet as $value) {
|
||||
$tmp = explode('@', $value);
|
||||
$listofanswers[] = array('label'=>$tmp[0], 'format'=>($tmp[1] ? $tmp[1] : 'checkbox'));
|
||||
}
|
||||
@ -452,10 +448,13 @@ print '</td></tr>';
|
||||
|
||||
// Expire date
|
||||
print '<tr><td>'.$langs->trans('ExpireDate').'</td><td colspan="2">';
|
||||
if ($action == 'edit') print $form->selectDate($expiredate ? $expiredate : $object->date_fin, 'expire', 0, 0, 0, '', 1, 0);
|
||||
else {
|
||||
if ($action == 'edit') {
|
||||
print $form->selectDate($expiredate ? $expiredate : $object->date_fin, 'expire', 0, 0, 0, '', 1, 0);
|
||||
} else {
|
||||
print dol_print_date($object->date_fin, 'day');
|
||||
if ($object->date_fin && $object->date_fin < dol_now() && $object->status == Opensurveysondage::STATUS_VALIDATED) print img_warning($langs->trans("Expired"));
|
||||
if ($object->date_fin && $object->date_fin < dol_now() && $object->status == Opensurveysondage::STATUS_VALIDATED) {
|
||||
print img_warning($langs->trans("Expired"));
|
||||
}
|
||||
}
|
||||
print '</td></tr>';
|
||||
|
||||
@ -480,8 +479,7 @@ $urlwithroot = $urlwithouturlroot.DOL_URL_ROOT; // This is to use external domai
|
||||
$url = $urlwithouturlroot.dol_buildpath('/public/opensurvey/studs.php', 1).'?sondage='.$object->id_sondage;
|
||||
$urllink = '<input type="text" style="width: 60%" '.($action == 'edit' ? 'disabled' : '').' id="opensurveyurl" name="opensurveyurl" value="'.$url.'">';
|
||||
print $urllink;
|
||||
if ($action != 'edit')
|
||||
{
|
||||
if ($action != 'edit') {
|
||||
print '<script type="text/javascript">
|
||||
jQuery(document).ready(function () {
|
||||
jQuery("#opensurveyurl").click(function() { jQuery(this).select(); } );
|
||||
@ -511,10 +509,11 @@ print '</div>';
|
||||
|
||||
|
||||
// Show form to add a new field/column
|
||||
if (GETPOST('ajoutsujet'))
|
||||
{
|
||||
if (GETPOST('ajoutsujet')) {
|
||||
// Security check
|
||||
if (!$user->rights->opensurvey->write) accessforbidden();
|
||||
if (!$user->rights->opensurvey->write) {
|
||||
accessforbidden();
|
||||
}
|
||||
|
||||
print '<form name="formulaire" action="" method="POST">'."\n";
|
||||
print '<input type="hidden" name="token" value="'.newToken().'">';
|
||||
@ -524,8 +523,7 @@ if (GETPOST('ajoutsujet'))
|
||||
print "<br><br>\n";
|
||||
|
||||
// Add new column
|
||||
if ($object->format == "A")
|
||||
{
|
||||
if ($object->format == "A") {
|
||||
print $langs->trans("AddNewColumn").':<br><br>';
|
||||
print $langs->trans("Title").' <input type="text" name="nouvellecolonne" size="40"><br>';
|
||||
$tmparray = array('checkbox'=>$langs->trans("CheckBox"), 'yesno'=>$langs->trans("YesNoList"), 'foragainst'=>$langs->trans("PourContreList"));
|
||||
@ -628,8 +626,7 @@ print '</tr>'."\n";
|
||||
|
||||
|
||||
// Show choice titles
|
||||
if ($object->format == "D")
|
||||
{
|
||||
if ($object->format == "D") {
|
||||
//affichage des sujets du sondage
|
||||
print '<tr>'."\n";
|
||||
print '<td></td>'."\n";
|
||||
@ -638,8 +635,7 @@ if ($object->format == "D")
|
||||
//affichage des années
|
||||
$colspan = 1;
|
||||
$nbofsujet = count($toutsujet);
|
||||
for ($i = 0; $i < $nbofsujet; $i++)
|
||||
{
|
||||
for ($i = 0; $i < $nbofsujet; $i++) {
|
||||
$current = $toutsujet[$i];
|
||||
|
||||
if (strpos($toutsujet[$i], '@') !== false) {
|
||||
@ -653,15 +649,20 @@ if ($object->format == "D")
|
||||
}
|
||||
|
||||
$currenty = 0;
|
||||
if ($current) $currenty = strftime("%Y", $current);
|
||||
if ($current) {
|
||||
$currenty = strftime("%Y", $current);
|
||||
}
|
||||
$next = 0;
|
||||
if ($next) $nexty = strftime("%Y", $next);
|
||||
if (isset($toutsujet[$i + 1]) && ($currenty == $nexty))
|
||||
{
|
||||
if ($next) {
|
||||
$nexty = strftime("%Y", $next);
|
||||
}
|
||||
if (isset($toutsujet[$i + 1]) && ($currenty == $nexty)) {
|
||||
$colspan++;
|
||||
} else {
|
||||
print '<td colspan='.$colspan.' class="annee">';
|
||||
if ($current) print strftime("%Y", $current);
|
||||
if ($current) {
|
||||
print strftime("%Y", $current);
|
||||
}
|
||||
print '</td>'."\n";
|
||||
$colspan = 1;
|
||||
}
|
||||
@ -756,8 +757,7 @@ if ($object->format == "D")
|
||||
print '<td></td>'."\n";
|
||||
print '<td></td>'."\n";
|
||||
|
||||
for ($i = 0; isset($toutsujet[$i]); $i++)
|
||||
{
|
||||
for ($i = 0; isset($toutsujet[$i]); $i++) {
|
||||
$tmp = explode('@', $toutsujet[$i]);
|
||||
print '<td class="sujet">'.dol_htmlentities($tmp[0]).'</td>'."\n";
|
||||
}
|
||||
@ -776,14 +776,12 @@ $sql .= " FROM ".MAIN_DB_PREFIX."opensurvey_user_studs";
|
||||
$sql .= " WHERE id_sondage = '".$db->escape($numsondage)."'";
|
||||
dol_syslog('sql='.$sql);
|
||||
$resql = $db->query($sql);
|
||||
if (!$resql)
|
||||
{
|
||||
if (!$resql) {
|
||||
dol_print_error($db);
|
||||
exit;
|
||||
}
|
||||
$num = $db->num_rows($resql);
|
||||
while ($compteur < $num)
|
||||
{
|
||||
while ($compteur < $num) {
|
||||
$obj = $db->fetch_object($resql);
|
||||
|
||||
$ensemblereponses = $obj->reponses;
|
||||
@ -798,121 +796,167 @@ while ($compteur < $num)
|
||||
print '</td><td class="nom">'.dol_htmlentities($obj->name).'</td>'."\n";
|
||||
|
||||
// si la ligne n'est pas a changer, on affiche les données
|
||||
if (!$testligneamodifier)
|
||||
{
|
||||
for ($i = 0; $i < $nbcolonnes; $i++)
|
||||
{
|
||||
if (!$testligneamodifier) {
|
||||
for ($i = 0; $i < $nbcolonnes; $i++) {
|
||||
$car = substr($ensemblereponses, $i, 1);
|
||||
//print 'xx'.$i."-".$car.'-'.$listofanswers[$i]['format'].'zz';
|
||||
|
||||
if (empty($listofanswers[$i]['format']) || !in_array($listofanswers[$i]['format'], array('yesno', 'foragainst')))
|
||||
{
|
||||
if (((string) $car) == "1") print '<td class="ok">OK</td>'."\n";
|
||||
else print '<td class="non">KO</td>'."\n";
|
||||
if (empty($listofanswers[$i]['format']) || !in_array($listofanswers[$i]['format'], array('yesno', 'foragainst'))) {
|
||||
if (((string) $car) == "1") {
|
||||
print '<td class="ok">OK</td>'."\n";
|
||||
} else {
|
||||
print '<td class="non">KO</td>'."\n";
|
||||
}
|
||||
// Total
|
||||
if (!isset($sumfor[$i])) $sumfor[$i] = 0;
|
||||
if (((string) $car) == "1") $sumfor[$i]++;
|
||||
if (!isset($sumfor[$i])) {
|
||||
$sumfor[$i] = 0;
|
||||
}
|
||||
if (((string) $car) == "1") {
|
||||
$sumfor[$i]++;
|
||||
}
|
||||
}
|
||||
if (!empty($listofanswers[$i]['format']) && $listofanswers[$i]['format'] == 'yesno')
|
||||
{
|
||||
if (((string) $car) == "1") print '<td class="ok">'.$langs->trans("Yes").'</td>'."\n";
|
||||
elseif (((string) $car) == "0") print '<td class="non">'.$langs->trans("No").'</td>'."\n";
|
||||
else print '<td class="vide"> </td>'."\n";
|
||||
if (!empty($listofanswers[$i]['format']) && $listofanswers[$i]['format'] == 'yesno') {
|
||||
if (((string) $car) == "1") {
|
||||
print '<td class="ok">'.$langs->trans("Yes").'</td>'."\n";
|
||||
} elseif (((string) $car) == "0") {
|
||||
print '<td class="non">'.$langs->trans("No").'</td>'."\n";
|
||||
} else {
|
||||
print '<td class="vide"> </td>'."\n";
|
||||
}
|
||||
// Total
|
||||
if (!isset($sumfor[$i])) $sumfor[$i] = 0;
|
||||
if (!isset($sumagainst[$i])) $sumagainst[$i] = 0;
|
||||
if (((string) $car) == "1") $sumfor[$i]++;
|
||||
if (((string) $car) == "0") $sumagainst[$i]++;
|
||||
if (!isset($sumfor[$i])) {
|
||||
$sumfor[$i] = 0;
|
||||
}
|
||||
if (!isset($sumagainst[$i])) {
|
||||
$sumagainst[$i] = 0;
|
||||
}
|
||||
if (((string) $car) == "1") {
|
||||
$sumfor[$i]++;
|
||||
}
|
||||
if (((string) $car) == "0") {
|
||||
$sumagainst[$i]++;
|
||||
}
|
||||
}
|
||||
if (!empty($listofanswers[$i]['format']) && $listofanswers[$i]['format'] == 'foragainst')
|
||||
{
|
||||
if (((string) $car) == "1") print '<td class="ok">'.$langs->trans("For").'</td>'."\n";
|
||||
elseif (((string) $car) == "0") print '<td class="non">'.$langs->trans("Against").'</td>'."\n";
|
||||
else print '<td class="vide"> </td>'."\n";
|
||||
if (!empty($listofanswers[$i]['format']) && $listofanswers[$i]['format'] == 'foragainst') {
|
||||
if (((string) $car) == "1") {
|
||||
print '<td class="ok">'.$langs->trans("For").'</td>'."\n";
|
||||
} elseif (((string) $car) == "0") {
|
||||
print '<td class="non">'.$langs->trans("Against").'</td>'."\n";
|
||||
} else {
|
||||
print '<td class="vide"> </td>'."\n";
|
||||
}
|
||||
// Total
|
||||
if (!isset($sumfor[$i])) $sumfor[$i] = 0;
|
||||
if (!isset($sumagainst[$i])) $sumagainst[$i] = 0;
|
||||
if (((string) $car) == "1") $sumfor[$i]++;
|
||||
if (((string) $car) == "0") $sumagainst[$i]++;
|
||||
if (!isset($sumfor[$i])) {
|
||||
$sumfor[$i] = 0;
|
||||
}
|
||||
if (!isset($sumagainst[$i])) {
|
||||
$sumagainst[$i] = 0;
|
||||
}
|
||||
if (((string) $car) == "1") {
|
||||
$sumfor[$i]++;
|
||||
}
|
||||
if (((string) $car) == "0") {
|
||||
$sumagainst[$i]++;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
//sinon on remplace les choix de l'utilisateur par une ligne de checkbox pour recuperer de nouvelles valeurs
|
||||
if ($compteur == $ligneamodifier)
|
||||
{
|
||||
for ($i = 0; $i < $nbcolonnes; $i++)
|
||||
{
|
||||
if ($compteur == $ligneamodifier) {
|
||||
for ($i = 0; $i < $nbcolonnes; $i++) {
|
||||
$car = substr($ensemblereponses, $i, 1);
|
||||
print '<td class="vide">';
|
||||
if (empty($listofanswers[$i]['format']) || !in_array($listofanswers[$i]['format'], array('yesno', 'foragainst')))
|
||||
{
|
||||
if (empty($listofanswers[$i]['format']) || !in_array($listofanswers[$i]['format'], array('yesno', 'foragainst'))) {
|
||||
print '<input type="checkbox" name="choix'.$i.'" value="1" ';
|
||||
if ($car == '1') print 'checked';
|
||||
if ($car == '1') {
|
||||
print 'checked';
|
||||
}
|
||||
print '>';
|
||||
}
|
||||
if (!empty($listofanswers[$i]['format']) && $listofanswers[$i]['format'] == 'yesno')
|
||||
{
|
||||
if (!empty($listofanswers[$i]['format']) && $listofanswers[$i]['format'] == 'yesno') {
|
||||
$arraychoice = array('2'=>' ', '0'=>$langs->trans("No"), '1'=>$langs->trans("Yes"));
|
||||
print $form->selectarray("choix".$i, $arraychoice, $car);
|
||||
}
|
||||
if (!empty($listofanswers[$i]['format']) && $listofanswers[$i]['format'] == 'foragainst')
|
||||
{
|
||||
if (!empty($listofanswers[$i]['format']) && $listofanswers[$i]['format'] == 'foragainst') {
|
||||
$arraychoice = array('2'=>' ', '0'=>$langs->trans("Against"), '1'=>$langs->trans("For"));
|
||||
print $form->selectarray("choix".$i, $arraychoice, $car);
|
||||
}
|
||||
print '</td>'."\n";
|
||||
}
|
||||
} else {
|
||||
for ($i = 0; $i < $nbcolonnes; $i++)
|
||||
{
|
||||
for ($i = 0; $i < $nbcolonnes; $i++) {
|
||||
$car = substr($ensemblereponses, $i, 1);
|
||||
if (empty($listofanswers[$i]['format']) || !in_array($listofanswers[$i]['format'], array('yesno', 'foragainst')))
|
||||
{
|
||||
if (((string) $car) == "1") print '<td class="ok">OK</td>'."\n";
|
||||
else print '<td class="non">KO</td>'."\n";
|
||||
if (empty($listofanswers[$i]['format']) || !in_array($listofanswers[$i]['format'], array('yesno', 'foragainst'))) {
|
||||
if (((string) $car) == "1") {
|
||||
print '<td class="ok">OK</td>'."\n";
|
||||
} else {
|
||||
print '<td class="non">KO</td>'."\n";
|
||||
}
|
||||
// Total
|
||||
if (!isset($sumfor[$i])) $sumfor[$i] = 0;
|
||||
if (((string) $car) == "1") $sumfor[$i]++;
|
||||
if (!isset($sumfor[$i])) {
|
||||
$sumfor[$i] = 0;
|
||||
}
|
||||
if (((string) $car) == "1") {
|
||||
$sumfor[$i]++;
|
||||
}
|
||||
}
|
||||
if (!empty($listofanswers[$i]['format']) && $listofanswers[$i]['format'] == 'yesno')
|
||||
{
|
||||
if (((string) $car) == "1") print '<td class="ok">'.$langs->trans("For").'</td>'."\n";
|
||||
elseif (((string) $car) == "0") print '<td class="non">'.$langs->trans("Against").'</td>'."\n";
|
||||
else print '<td class="vide"> </td>'."\n";
|
||||
if (!empty($listofanswers[$i]['format']) && $listofanswers[$i]['format'] == 'yesno') {
|
||||
if (((string) $car) == "1") {
|
||||
print '<td class="ok">'.$langs->trans("For").'</td>'."\n";
|
||||
} elseif (((string) $car) == "0") {
|
||||
print '<td class="non">'.$langs->trans("Against").'</td>'."\n";
|
||||
} else {
|
||||
print '<td class="vide"> </td>'."\n";
|
||||
}
|
||||
// Total
|
||||
if (!isset($sumfor[$i])) $sumfor[$i] = 0;
|
||||
if (!isset($sumagainst[$i])) $sumagainst[$i] = 0;
|
||||
if (((string) $car) == "1") $sumfor[$i]++;
|
||||
if (((string) $car) == "0") $sumagainst[$i]++;
|
||||
if (!isset($sumfor[$i])) {
|
||||
$sumfor[$i] = 0;
|
||||
}
|
||||
if (!isset($sumagainst[$i])) {
|
||||
$sumagainst[$i] = 0;
|
||||
}
|
||||
if (((string) $car) == "1") {
|
||||
$sumfor[$i]++;
|
||||
}
|
||||
if (((string) $car) == "0") {
|
||||
$sumagainst[$i]++;
|
||||
}
|
||||
}
|
||||
if (!empty($listofanswers[$i]['format']) && $listofanswers[$i]['format'] == 'foragainst')
|
||||
{
|
||||
if (((string) $car) == "1") print '<td class="ok">'.$langs->trans("For").'</td>'."\n";
|
||||
elseif (((string) $car) == "0") print '<td class="non">'.$langs->trans("Against").'</td>'."\n";
|
||||
else print '<td class="vide"> </td>'."\n";
|
||||
if (!empty($listofanswers[$i]['format']) && $listofanswers[$i]['format'] == 'foragainst') {
|
||||
if (((string) $car) == "1") {
|
||||
print '<td class="ok">'.$langs->trans("For").'</td>'."\n";
|
||||
} elseif (((string) $car) == "0") {
|
||||
print '<td class="non">'.$langs->trans("Against").'</td>'."\n";
|
||||
} else {
|
||||
print '<td class="vide"> </td>'."\n";
|
||||
}
|
||||
// Total
|
||||
if (!isset($sumfor[$i])) $sumfor[$i] = 0;
|
||||
if (!isset($sumagainst[$i])) $sumagainst[$i] = 0;
|
||||
if (((string) $car) == "1") $sumfor[$i]++;
|
||||
if (((string) $car) == "0") $sumagainst[$i]++;
|
||||
if (!isset($sumfor[$i])) {
|
||||
$sumfor[$i] = 0;
|
||||
}
|
||||
if (!isset($sumagainst[$i])) {
|
||||
$sumagainst[$i] = 0;
|
||||
}
|
||||
if (((string) $car) == "1") {
|
||||
$sumfor[$i]++;
|
||||
}
|
||||
if (((string) $car) == "0") {
|
||||
$sumagainst[$i]++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Button edit at end of line
|
||||
if ($compteur != $ligneamodifier && ($user->rights->opensurvey->write))
|
||||
{
|
||||
if ($compteur != $ligneamodifier && ($user->rights->opensurvey->write)) {
|
||||
print '<td class="casevide"><input type="submit" class="button" name="modifierligne'.$compteur.'" value="'.dol_escape_htmltag($langs->trans("Edit")).'"></td>'."\n";
|
||||
}
|
||||
|
||||
//demande de confirmation pour modification de ligne
|
||||
for ($i = 0; $i < $nblines; $i++)
|
||||
{
|
||||
if (GETPOSTISSET("modifierligne".$i))
|
||||
{
|
||||
if ($compteur == $i)
|
||||
{
|
||||
for ($i = 0; $i < $nblines; $i++) {
|
||||
if (GETPOSTISSET("modifierligne".$i)) {
|
||||
if ($compteur == $i) {
|
||||
print '<td class="casevide">';
|
||||
print '<input type="hidden" name="idtomodify'.$compteur.'" value="'.$obj->id_users.'">';
|
||||
print '<input type="submit" class="button button-save" name="validermodifier'.$compteur.'" value="'.dol_escape_htmltag($langs->trans("Save")).'">';
|
||||
@ -926,33 +970,27 @@ while ($compteur < $num)
|
||||
}
|
||||
|
||||
// Add line to add new record
|
||||
if (empty($testligneamodifier))
|
||||
{
|
||||
if (empty($testligneamodifier)) {
|
||||
print '<tr>'."\n";
|
||||
print '<td></td>'."\n";
|
||||
print '<td class="nom">'."\n";
|
||||
print '<input type="text" placeholder="'.dol_escape_htmltag($langs->trans("Name")).'" name="nom" maxlength="64" size="24">'."\n";
|
||||
print '</td>'."\n";
|
||||
|
||||
for ($i = 0; $i < $nbcolonnes; $i++)
|
||||
{
|
||||
for ($i = 0; $i < $nbcolonnes; $i++) {
|
||||
print '<td class="vide">';
|
||||
if (empty($listofanswers[$i]['format']) || !in_array($listofanswers[$i]['format'], array('yesno', 'foragainst')))
|
||||
{
|
||||
if (empty($listofanswers[$i]['format']) || !in_array($listofanswers[$i]['format'], array('yesno', 'foragainst'))) {
|
||||
print '<input type="checkbox" name="choix'.$i.'" value="1"';
|
||||
if (GETPOSTISSET('choix'.$i) && GETPOST('choix'.$i) == '1')
|
||||
{
|
||||
if (GETPOSTISSET('choix'.$i) && GETPOST('choix'.$i) == '1') {
|
||||
print ' checked';
|
||||
}
|
||||
print '>';
|
||||
}
|
||||
if (!empty($listofanswers[$i]['format']) && $listofanswers[$i]['format'] == 'yesno')
|
||||
{
|
||||
if (!empty($listofanswers[$i]['format']) && $listofanswers[$i]['format'] == 'yesno') {
|
||||
$arraychoice = array('2'=>' ', '0'=>$langs->trans("No"), '1'=>$langs->trans("Yes"));
|
||||
print $form->selectarray("choix".$i, $arraychoice);
|
||||
}
|
||||
if (!empty($listofanswers[$i]['format']) && $listofanswers[$i]['format'] == 'foragainst')
|
||||
{
|
||||
if (!empty($listofanswers[$i]['format']) && $listofanswers[$i]['format'] == 'foragainst') {
|
||||
$arraychoice = array('2'=>' ', '0'=>$langs->trans("Against"), '1'=>$langs->trans("For"));
|
||||
print $form->selectarray("choix".$i, $arraychoice);
|
||||
}
|
||||
@ -966,18 +1004,15 @@ if (empty($testligneamodifier))
|
||||
|
||||
// Select value of best choice (for checkbox columns only)
|
||||
$nbofcheckbox = 0;
|
||||
for ($i = 0; $i < $nbcolonnes + 1; $i++)
|
||||
{
|
||||
if (empty($listofanswers[$i]['format']) || !in_array($listofanswers[$i]['format'], array('yesno', 'foragainst')))
|
||||
$nbofcheckbox++;
|
||||
if (isset($sumfor[$i]))
|
||||
{
|
||||
if ($i == 0)
|
||||
{
|
||||
for ($i = 0; $i < $nbcolonnes + 1; $i++) {
|
||||
if (empty($listofanswers[$i]['format']) || !in_array($listofanswers[$i]['format'], array('yesno', 'foragainst'))) {
|
||||
$nbofcheckbox++;
|
||||
}
|
||||
if (isset($sumfor[$i])) {
|
||||
if ($i == 0) {
|
||||
$meilleurecolonne = $sumfor[$i];
|
||||
}
|
||||
if (isset($sumfor[$i]) && $sumfor[$i] > $meilleurecolonne)
|
||||
{
|
||||
if (isset($sumfor[$i]) && $sumfor[$i] > $meilleurecolonne) {
|
||||
$meilleurecolonne = $sumfor[$i];
|
||||
}
|
||||
}
|
||||
@ -988,29 +1023,36 @@ for ($i = 0; $i < $nbcolonnes + 1; $i++)
|
||||
print '<tr>'."\n";
|
||||
print '<td></td>'."\n";
|
||||
print '<td class="center">'.$langs->trans("Total").'</td>'."\n";
|
||||
for ($i = 0; $i < $nbcolonnes; $i++)
|
||||
{
|
||||
for ($i = 0; $i < $nbcolonnes; $i++) {
|
||||
$showsumfor = isset($sumfor[$i]) ? $sumfor[$i] : '';
|
||||
$showsumagainst = isset($sumagainst[$i]) ? $sumagainst[$i] : '';
|
||||
if (empty($showsumfor)) $showsumfor = 0;
|
||||
if (empty($showsumagainst)) $showsumagainst = 0;
|
||||
if (empty($showsumfor)) {
|
||||
$showsumfor = 0;
|
||||
}
|
||||
if (empty($showsumagainst)) {
|
||||
$showsumagainst = 0;
|
||||
}
|
||||
|
||||
print '<td>';
|
||||
if (empty($listofanswers[$i]['format']) || !in_array($listofanswers[$i]['format'], array('yesno', 'foragainst'))) print $showsumfor;
|
||||
if (!empty($listofanswers[$i]['format']) && $listofanswers[$i]['format'] == 'yesno') print $langs->trans("Yes").': '.$showsumfor.'<br>'.$langs->trans("No").': '.$showsumagainst;
|
||||
if (!empty($listofanswers[$i]['format']) && $listofanswers[$i]['format'] == 'foragainst') print $langs->trans("For").': '.$showsumfor.'<br>'.$langs->trans("Against").': '.$showsumagainst;
|
||||
if (empty($listofanswers[$i]['format']) || !in_array($listofanswers[$i]['format'], array('yesno', 'foragainst'))) {
|
||||
print $showsumfor;
|
||||
}
|
||||
if (!empty($listofanswers[$i]['format']) && $listofanswers[$i]['format'] == 'yesno') {
|
||||
print $langs->trans("Yes").': '.$showsumfor.'<br>'.$langs->trans("No").': '.$showsumagainst;
|
||||
}
|
||||
if (!empty($listofanswers[$i]['format']) && $listofanswers[$i]['format'] == 'foragainst') {
|
||||
print $langs->trans("For").': '.$showsumfor.'<br>'.$langs->trans("Against").': '.$showsumagainst;
|
||||
}
|
||||
print '</td>'."\n";
|
||||
}
|
||||
print '</tr>';
|
||||
// Show picto winner
|
||||
if ($nbofcheckbox >= 2)
|
||||
{
|
||||
if ($nbofcheckbox >= 2) {
|
||||
print '<tr>'."\n";
|
||||
print '<td></td>'."\n";
|
||||
print '<td></td>'."\n";
|
||||
for ($i = 0; $i < $nbcolonnes; $i++) {
|
||||
if (empty($listofanswers[$i]['format']) || !in_array($listofanswers[$i]['format'], array('yesno', 'foragainst')) && isset($sumfor[$i]) && isset($meilleurecolonne) && $sumfor[$i] == $meilleurecolonne)
|
||||
{
|
||||
if (empty($listofanswers[$i]['format']) || !in_array($listofanswers[$i]['format'], array('yesno', 'foragainst')) && isset($sumfor[$i]) && isset($meilleurecolonne) && $sumfor[$i] == $meilleurecolonne) {
|
||||
print '<td class="somme"><img src="'.dol_buildpath('/opensurvey/img/medaille.png', 1).'"></td>'."\n";
|
||||
} else {
|
||||
print '<td class="somme"></td>'."\n";
|
||||
@ -1041,10 +1083,8 @@ $toutsujet = explode(",", $object->sujet); // With old versions, this field was
|
||||
|
||||
$compteursujet = 0;
|
||||
$meilleursujet = '';
|
||||
for ($i = 0; $i < $nbcolonnes; $i++)
|
||||
{
|
||||
if (isset($sumfor[$i]) === true && isset($meilleurecolonne) === true && $sumfor[$i] == $meilleurecolonne)
|
||||
{
|
||||
for ($i = 0; $i < $nbcolonnes; $i++) {
|
||||
if (isset($sumfor[$i]) === true && isset($meilleurecolonne) === true && $sumfor[$i] == $meilleurecolonne) {
|
||||
$meilleursujet .= ", ";
|
||||
|
||||
if ($object->format == "D") {
|
||||
@ -1068,8 +1108,7 @@ $meilleursujet = substr($meilleursujet, 1);
|
||||
$meilleursujet = str_replace("°", "'", $meilleursujet);
|
||||
|
||||
// Show best choice
|
||||
if ($nbofcheckbox >= 2)
|
||||
{
|
||||
if ($nbofcheckbox >= 2) {
|
||||
$vote_str = $langs->trans('votes');
|
||||
print '<p class="affichageresultats">'."\n";
|
||||
|
||||
|
||||
@ -28,7 +28,9 @@ require_once DOL_DOCUMENT_ROOT."/core/lib/files.lib.php";
|
||||
require_once DOL_DOCUMENT_ROOT."/opensurvey/fonctions.php";
|
||||
|
||||
// Security check
|
||||
if (!$user->rights->opensurvey->write) accessforbidden();
|
||||
if (!$user->rights->opensurvey->write) {
|
||||
accessforbidden();
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -53,20 +55,16 @@ if (isset($_SESSION["nbrecases"])) {
|
||||
$_SESSION["nbrecases"] = 5;
|
||||
}
|
||||
|
||||
if (GETPOST("ajoutcases") || GETPOST("ajoutcases_x"))
|
||||
{
|
||||
if (GETPOST("ajoutcases") || GETPOST("ajoutcases_x")) {
|
||||
$_SESSION["nbrecases"] = $_SESSION["nbrecases"] + 5;
|
||||
}
|
||||
|
||||
// Create survey into database
|
||||
if (GETPOSTISSET("confirmecreation"))
|
||||
{
|
||||
if (GETPOSTISSET("confirmecreation")) {
|
||||
//recuperation des données de champs textes
|
||||
$toutchoix = '';
|
||||
for ($i = 0; $i < $_SESSION["nbrecases"] + 1; $i++)
|
||||
{
|
||||
if (!empty($arrayofchoices[$i]))
|
||||
{
|
||||
for ($i = 0; $i < $_SESSION["nbrecases"] + 1; $i++) {
|
||||
if (!empty($arrayofchoices[$i])) {
|
||||
$toutchoix .= ',';
|
||||
$toutchoix .= str_replace(array(",", "@"), " ", $arrayofchoices[$i]).(empty($arrayoftypecolumn[$i]) ? '' : '@'.$arrayoftypecolumn[$i]);
|
||||
}
|
||||
@ -77,10 +75,8 @@ if (GETPOSTISSET("confirmecreation"))
|
||||
|
||||
//test de remplissage des cases
|
||||
$testremplissage = '';
|
||||
for ($i = 0; $i < $_SESSION["nbrecases"]; $i++)
|
||||
{
|
||||
if (isset($arrayofchoices[$i]))
|
||||
{
|
||||
for ($i = 0; $i < $_SESSION["nbrecases"]; $i++) {
|
||||
if (isset($arrayofchoices[$i])) {
|
||||
$testremplissage = "ok";
|
||||
}
|
||||
}
|
||||
@ -107,8 +103,7 @@ $arrayofjs = array();
|
||||
$arrayofcss = array('/opensurvey/css/style.css');
|
||||
llxHeader('', $langs->trans("OpenSurvey"), "", '', 0, 0, $arrayofjs, $arrayofcss);
|
||||
|
||||
if (empty($_SESSION['title']))
|
||||
{
|
||||
if (empty($_SESSION['title'])) {
|
||||
dol_print_error('', $langs->trans('ErrorOpenSurveyFillFirstSection'));
|
||||
llxFooter();
|
||||
exit;
|
||||
|
||||
@ -28,7 +28,9 @@ require_once DOL_DOCUMENT_ROOT."/core/lib/files.lib.php";
|
||||
require_once DOL_DOCUMENT_ROOT."/opensurvey/fonctions.php";
|
||||
|
||||
// Security check
|
||||
if (!$user->rights->opensurvey->write) accessforbidden();
|
||||
if (!$user->rights->opensurvey->write) {
|
||||
accessforbidden();
|
||||
}
|
||||
|
||||
// Survey type is DATE
|
||||
$_SESSION["formatsondage"] = "D";
|
||||
@ -40,19 +42,15 @@ $erreur = false;
|
||||
*/
|
||||
|
||||
// Insert survey
|
||||
if (GETPOST('confirmation'))
|
||||
{
|
||||
if (GETPOST('confirmation')) {
|
||||
// We save hours entered
|
||||
if (issetAndNoEmpty('totalchoixjour', $_SESSION) === true && issetAndNoEmpty('nbrecaseshoraires', $_SESSION) === true)
|
||||
{
|
||||
if (issetAndNoEmpty('totalchoixjour', $_SESSION) === true && issetAndNoEmpty('nbrecaseshoraires', $_SESSION) === true) {
|
||||
$nbofchoice = count($_SESSION["totalchoixjour"]);
|
||||
$errheure = array();
|
||||
|
||||
for ($i = 0; $i < $nbofchoice; $i++)
|
||||
{
|
||||
for ($i = 0; $i < $nbofchoice; $i++) {
|
||||
// Show hours choices
|
||||
for ($j = 0; $j < $_SESSION["nbrecaseshoraires"]; $j++)
|
||||
{
|
||||
for ($j = 0; $j < $_SESSION["nbrecaseshoraires"]; $j++) {
|
||||
$_SESSION["horaires$i"][$j] = $_POST["horaires$i"][$j];
|
||||
|
||||
$tmphorairesi = GETPOST('horaires'.$i, 'array');
|
||||
@ -170,8 +168,7 @@ if (GETPOST('confirmation'))
|
||||
}
|
||||
|
||||
// Add survey into database
|
||||
if (!$erreur)
|
||||
{
|
||||
if (!$erreur) {
|
||||
$_SESSION["toutchoix"] = substr("$choixdate", 1);
|
||||
|
||||
ajouter_sondage();
|
||||
@ -179,11 +176,9 @@ if (GETPOST('confirmation'))
|
||||
}
|
||||
|
||||
// Reset days
|
||||
if (GETPOST('reset'))
|
||||
{
|
||||
if (GETPOST('reset')) {
|
||||
$nbofchoice = count($_SESSION["totalchoixjour"]);
|
||||
for ($i = 0; $i < $nbofchoice; $i++)
|
||||
{
|
||||
for ($i = 0; $i < $nbofchoice; $i++) {
|
||||
for ($j = 0; $j < $_SESSION["nbrecaseshoraires"]; $j++) {
|
||||
unset($_SESSION["horaires$i"][$j]);
|
||||
}
|
||||
@ -199,8 +194,7 @@ if (GETPOST('reset'))
|
||||
* View
|
||||
*/
|
||||
|
||||
if (!isset($_SESSION['description']) && !isset($_SESSION['mail']))
|
||||
{
|
||||
if (!isset($_SESSION['description']) && !isset($_SESSION['mail'])) {
|
||||
dol_print_error('', $langs->trans('ErrorOpenSurveyFillFirstSection'));
|
||||
exit;
|
||||
}
|
||||
@ -210,11 +204,9 @@ $arrayofcss = array('/opensurvey/css/style.css');
|
||||
llxHeader('', $langs->trans("OpenSurvey"), "", '', 0, 0, $arrayofjs, $arrayofcss);
|
||||
|
||||
//nombre de cases par défaut
|
||||
if (!isset($_SESSION["nbrecaseshoraires"]))
|
||||
{
|
||||
if (!isset($_SESSION["nbrecaseshoraires"])) {
|
||||
$_SESSION["nbrecaseshoraires"] = 5;
|
||||
} elseif (GETPOST('ajoutcases') && $_SESSION["nbrecaseshoraires"] == 5)
|
||||
{
|
||||
} elseif (GETPOST('ajoutcases') && $_SESSION["nbrecaseshoraires"] == 5) {
|
||||
$_SESSION["nbrecaseshoraires"] = 10;
|
||||
}
|
||||
|
||||
@ -224,9 +216,15 @@ $moisAJ = date("n");
|
||||
$anneeAJ = date("Y");
|
||||
|
||||
// Initialisation des jour, mois et année
|
||||
if (!isset($_SESSION['jour'])) $_SESSION['jour'] = date('j');
|
||||
if (!isset($_SESSION['mois'])) $_SESSION['mois'] = date('n');
|
||||
if (!isset($_SESSION['annee'])) $_SESSION['annee'] = date('Y');
|
||||
if (!isset($_SESSION['jour'])) {
|
||||
$_SESSION['jour'] = date('j');
|
||||
}
|
||||
if (!isset($_SESSION['mois'])) {
|
||||
$_SESSION['mois'] = date('n');
|
||||
}
|
||||
if (!isset($_SESSION['annee'])) {
|
||||
$_SESSION['annee'] = date('Y');
|
||||
}
|
||||
|
||||
//mise a jour des valeurs de session si bouton retour a aujourd'hui
|
||||
if (!issetAndNoEmpty('choixjourajout') && !issetAndNoEmpty('choixjourretrait') && (issetAndNoEmpty('retourmois') || issetAndNoEmpty('retourmois_x'))) {
|
||||
@ -245,8 +243,7 @@ if (issetAndNoEmpty('moisavant_x') || issetAndNoEmpty('moisavant')) {
|
||||
}
|
||||
|
||||
//On sauvegarde les heures deja entrées
|
||||
if (issetAndNoEmpty('totalchoixjour', $_SESSION) === true)
|
||||
{
|
||||
if (issetAndNoEmpty('totalchoixjour', $_SESSION) === true) {
|
||||
$nbofchoice = count($_SESSION["totalchoixjour"]);
|
||||
for ($i = 0; $i < $nbofchoice; $i++) {
|
||||
//affichage des 5 cases horaires
|
||||
@ -267,11 +264,9 @@ if (issetAndNoEmpty('moisapres_x') || issetAndNoEmpty('moisapres')) {
|
||||
}
|
||||
|
||||
//On sauvegarde les heures deja entrées
|
||||
if (issetAndNoEmpty('totalchoixjour', $_SESSION) === true)
|
||||
{
|
||||
if (issetAndNoEmpty('totalchoixjour', $_SESSION) === true) {
|
||||
$nbofchoice = count($_SESSION["totalchoixjour"]);
|
||||
for ($i = 0; $i < $nbofchoice; $i++)
|
||||
{
|
||||
for ($i = 0; $i < $nbofchoice; $i++) {
|
||||
//affichage des 5 cases horaires
|
||||
for ($j = 0; $j < $_SESSION["nbrecaseshoraires"]; $j++) {
|
||||
$_SESSION["horaires$i"][$j] = $_POST["horaires$i"][$j];
|
||||
@ -285,8 +280,7 @@ if (issetAndNoEmpty('anneeavant_x') || issetAndNoEmpty('anneeavant')) {
|
||||
$_SESSION["annee"] -= 1;
|
||||
|
||||
//On sauvegarde les heures deja entrées
|
||||
if (issetAndNoEmpty('totalchoixjour', $_SESSION) === true)
|
||||
{
|
||||
if (issetAndNoEmpty('totalchoixjour', $_SESSION) === true) {
|
||||
$nbofchoice = count($_SESSION["totalchoixjour"]);
|
||||
for ($i = 0; $i < $nbofchoice; $i++) {
|
||||
//affichage des 5 cases horaires
|
||||
@ -302,8 +296,7 @@ if (issetAndNoEmpty('anneeapres_x') || issetAndNoEmpty('anneeapres')) {
|
||||
$_SESSION["annee"] += 1;
|
||||
|
||||
//On sauvegarde les heures deja entrées
|
||||
if (issetAndNoEmpty('totalchoixjour', $_SESSION) === true)
|
||||
{
|
||||
if (issetAndNoEmpty('totalchoixjour', $_SESSION) === true) {
|
||||
$nbofchoice = count($_SESSION["totalchoixjour"]);
|
||||
for ($i = 0; $i < $nbofchoice; $i++) {
|
||||
//affichage des 5 cases horaires
|
||||
@ -319,8 +312,7 @@ $nbrejourmois = date("t", mktime(0, 0, 0, $_SESSION["mois"], 1, $_SESSION["annee
|
||||
$premierjourmois = date("N", mktime(0, 0, 0, $_SESSION["mois"], 1, $_SESSION["annee"])) - 1;
|
||||
|
||||
//traduction de la valeur du mois
|
||||
if (is_integer($_SESSION["mois"]) && $_SESSION["mois"] > 0 && $_SESSION["mois"] < 13)
|
||||
{
|
||||
if (is_integer($_SESSION["mois"]) && $_SESSION["mois"] > 0 && $_SESSION["mois"] < 13) {
|
||||
$motmois = dol_print_date(mktime(0, 0, 0, $_SESSION["mois"], 10), '%B');
|
||||
} else {
|
||||
$motmois = dol_print_date(dol_now(), '%B');
|
||||
@ -356,8 +348,7 @@ print '<table align="center">'."\n"; // The div class=center has no effect on ta
|
||||
print '<tr>'."\n";
|
||||
|
||||
//affichage des jours de la semaine en haut du tableau
|
||||
for ($i = 0; $i < 7; $i++)
|
||||
{
|
||||
for ($i = 0; $i < 7; $i++) {
|
||||
print '<td align="center" class="joursemaine">'.dol_print_date(mktime(0, 0, 0, 0, $i, 10), '%A').'</td>';
|
||||
}
|
||||
|
||||
@ -371,8 +362,7 @@ if (issetAndNoEmpty('choixjourajout')) {
|
||||
|
||||
// Test pour éviter les doublons dans la variable qui contient toutes les dates
|
||||
$journeuf = true;
|
||||
if (issetAndNoEmpty('totalchoixjour', $_SESSION) === true && issetAndNoEmpty('choixjourajout') === true)
|
||||
{
|
||||
if (issetAndNoEmpty('totalchoixjour', $_SESSION) === true && issetAndNoEmpty('choixjourajout') === true) {
|
||||
$nbofchoice = count($_SESSION["totalchoixjour"]);
|
||||
for ($i = 0; $i < $nbofchoice; $i++) {
|
||||
if ($_SESSION["totalchoixjour"][$i] == mktime(0, 0, 0, $_SESSION["mois"], $_POST["choixjourajout"][0], $_SESSION["annee"])) {
|
||||
@ -421,10 +411,8 @@ if (issetAndNoEmpty('choixjourretrait')) {
|
||||
}
|
||||
}
|
||||
|
||||
for ($i = 0; $i < $nbofchoice; $i++)
|
||||
{
|
||||
if ($_SESSION["totalchoixjour"][$i] == mktime(0, 0, 0, $_SESSION["mois"], $_POST["choixjourretrait"][0], $_SESSION["annee"]))
|
||||
{
|
||||
for ($i = 0; $i < $nbofchoice; $i++) {
|
||||
if ($_SESSION["totalchoixjour"][$i] == mktime(0, 0, 0, $_SESSION["mois"], $_POST["choixjourretrait"][0], $_SESSION["annee"])) {
|
||||
for ($j = $i; $j < $nbofchoice; $j++) {
|
||||
$k = $j + 1;
|
||||
$_SESSION["horaires$j"] = $_SESSION["horaires$k"];
|
||||
@ -468,8 +456,7 @@ for ($i = 0; $i < $nbrejourmois + $premierjourmois; $i++) {
|
||||
if ($i < $premierjourmois) {
|
||||
print '<td class="avant"></td>'."\n";
|
||||
} else {
|
||||
if (issetAndNoEmpty('totalchoixjour', $_SESSION) === true)
|
||||
{
|
||||
if (issetAndNoEmpty('totalchoixjour', $_SESSION) === true) {
|
||||
$nbofchoice = count($_SESSION["totalchoixjour"]);
|
||||
for ($j = 0; $j < $nbofchoice; $j++) {
|
||||
// show red buttons
|
||||
@ -501,8 +488,7 @@ print '</div></div>'."\n";
|
||||
print '<div class="bodydate"><div class="center">'."\n";
|
||||
|
||||
// affichage de tous les jours choisis
|
||||
if (issetAndNoEmpty('totalchoixjour', $_SESSION) || $erreur)
|
||||
{
|
||||
if (issetAndNoEmpty('totalchoixjour', $_SESSION) || $erreur) {
|
||||
//affichage des jours
|
||||
print '<br>'."\n";
|
||||
print '<div align="left">';
|
||||
@ -528,8 +514,7 @@ if (issetAndNoEmpty('totalchoixjour', $_SESSION) || $erreur)
|
||||
//affichage de la liste des jours choisis
|
||||
$nbofchoice = count($_SESSION["totalchoixjour"]);
|
||||
|
||||
for ($i = 0; $i < $nbofchoice; $i++)
|
||||
{
|
||||
for ($i = 0; $i < $nbofchoice; $i++) {
|
||||
print '<tr>'."\n";
|
||||
print '<td>'.dol_print_date($_SESSION["totalchoixjour"][$i], 'daytext').' ('.dol_print_date($_SESSION["totalchoixjour"][$i], '%A').')</td>';
|
||||
|
||||
|
||||
@ -31,7 +31,9 @@ require_once DOL_DOCUMENT_ROOT."/core/class/doleditor.class.php";
|
||||
require_once DOL_DOCUMENT_ROOT."/opensurvey/fonctions.php";
|
||||
|
||||
// Security check
|
||||
if (!$user->rights->opensurvey->write) accessforbidden();
|
||||
if (!$user->rights->opensurvey->write) {
|
||||
accessforbidden();
|
||||
}
|
||||
|
||||
$langs->load("opensurvey");
|
||||
|
||||
@ -43,9 +45,10 @@ $creation_sondage_autre = GETPOST('creation_sondage_autre');
|
||||
|
||||
// We init some session variable to avoir warning
|
||||
$session_var = array('title', 'description', 'mailsonde');
|
||||
foreach ($session_var as $var)
|
||||
{
|
||||
if (isset($_SESSION[$var])) $_SESSION[$var] = null;
|
||||
foreach ($session_var as $var) {
|
||||
if (isset($_SESSION[$var])) {
|
||||
$_SESSION[$var] = null;
|
||||
}
|
||||
}
|
||||
|
||||
// On initialise également les autres variables
|
||||
@ -53,8 +56,7 @@ $cocheplus = '';
|
||||
$cochemail = '';
|
||||
|
||||
// Jump to correct page
|
||||
if (!empty($creation_sondage_date) || !empty($creation_sondage_autre))
|
||||
{
|
||||
if (!empty($creation_sondage_date) || !empty($creation_sondage_autre)) {
|
||||
$_SESSION["title"] = $title;
|
||||
$_SESSION["description"] = $description;
|
||||
|
||||
@ -79,11 +81,9 @@ if (!empty($creation_sondage_date) || !empty($creation_sondage_autre))
|
||||
$testdate = false;
|
||||
$champdatefin = dol_mktime(0, 0, 0, GETPOST('champdatefinmonth'), GETPOST('champdatefinday'), GETPOST('champdatefinyear'));
|
||||
|
||||
if ($champdatefin && ($champdatefin > 0)) // A date was provided
|
||||
{
|
||||
// Expire date is not before today
|
||||
if ($champdatefin >= dol_now())
|
||||
{
|
||||
if ($champdatefin && ($champdatefin > 0)) { // A date was provided
|
||||
// Expire date is not before today
|
||||
if ($champdatefin >= dol_now()) {
|
||||
$testdate = true;
|
||||
$_SESSION['champdatefin'] = dol_print_date($champdatefin, 'dayrfc');
|
||||
} else {
|
||||
@ -99,16 +99,13 @@ if (!empty($creation_sondage_date) || !empty($creation_sondage_autre))
|
||||
setEventMessages($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv("ExpireDate")), null, 'errors');
|
||||
}
|
||||
|
||||
if ($title && $testdate)
|
||||
{
|
||||
if (!empty($creation_sondage_date))
|
||||
{
|
||||
if ($title && $testdate) {
|
||||
if (!empty($creation_sondage_date)) {
|
||||
header("Location: choix_date.php");
|
||||
exit();
|
||||
}
|
||||
|
||||
if (!empty($creation_sondage_autre))
|
||||
{
|
||||
if (!empty($creation_sondage_autre)) {
|
||||
header("Location: choix_autre.php");
|
||||
exit();
|
||||
}
|
||||
@ -140,8 +137,7 @@ print dol_get_fiche_head();
|
||||
print '<table class="border centpercent">'."\n";
|
||||
|
||||
print '<tr><td class="titlefieldcreate fieldrequired">'.$langs->trans("PollTitle").'</td><td><input type="text" name="title" class="minwidth300" maxlength="80" value="'.$_SESSION["title"].'"></td>'."\n";
|
||||
if (!$_SESSION["title"] && (GETPOST('creation_sondage_date') || GETPOST('creation_sondage_autre')))
|
||||
{
|
||||
if (!$_SESSION["title"] && (GETPOST('creation_sondage_date') || GETPOST('creation_sondage_autre'))) {
|
||||
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("PollTitle")), null, 'errors');
|
||||
}
|
||||
|
||||
@ -170,22 +166,34 @@ print '<br>'."\n";
|
||||
|
||||
// Check or not
|
||||
|
||||
if ($_SESSION["mailsonde"]) $cochemail = "checked";
|
||||
if ($_SESSION["mailsonde"]) {
|
||||
$cochemail = "checked";
|
||||
}
|
||||
|
||||
print '<input type="checkbox" name="mailsonde" '.$cochemail.'> '.$langs->trans("ToReceiveEMailForEachVote").'<br>'."\n";
|
||||
|
||||
if ($_SESSION['allow_comments']) $allow_comments = 'checked';
|
||||
if (GETPOSTISSET('allow_comments')) $allow_comments = GETPOST('allow_comments') ? 'checked' : '';
|
||||
if ($_SESSION['allow_comments']) {
|
||||
$allow_comments = 'checked';
|
||||
}
|
||||
if (GETPOSTISSET('allow_comments')) {
|
||||
$allow_comments = GETPOST('allow_comments') ? 'checked' : '';
|
||||
}
|
||||
print '<input type="checkbox" name="allow_comments" '.$allow_comments.'"> '.$langs->trans('CanComment').'<br>'."\n";
|
||||
|
||||
if ($_SESSION['allow_spy']) $allow_spy = 'checked';
|
||||
if (GETPOSTISSET('allow_spy')) $allow_spy = GETPOST('allow_spy') ? 'checked' : '';
|
||||
if ($_SESSION['allow_spy']) {
|
||||
$allow_spy = 'checked';
|
||||
}
|
||||
if (GETPOSTISSET('allow_spy')) {
|
||||
$allow_spy = GETPOST('allow_spy') ? 'checked' : '';
|
||||
}
|
||||
print '<input type="checkbox" name="allow_spy" '.$allow_spy.'> '.$langs->trans('CanSeeOthersVote').'<br>'."\n";
|
||||
|
||||
if (GETPOST('choix_sondage'))
|
||||
{
|
||||
if (GETPOST('choix_sondage') == 'date') print '<input type="hidden" name="creation_sondage_date" value="date">';
|
||||
else print '<input type="hidden" name="creation_sondage_autre" value="autre">';
|
||||
if (GETPOST('choix_sondage')) {
|
||||
if (GETPOST('choix_sondage') == 'date') {
|
||||
print '<input type="hidden" name="creation_sondage_date" value="date">';
|
||||
} else {
|
||||
print '<input type="hidden" name="creation_sondage_autre" value="autre">';
|
||||
}
|
||||
print '<input type="hidden" name="choix_sondage" value="'.GETPOST('choix_sondage').'">';
|
||||
print '<br><input type="submit" class="button" name="submit" value="'.$langs->trans("CreatePoll").' ('.(GETPOST('choix_sondage') == 'date' ? $langs->trans("TypeDate") : $langs->trans("TypeClassic")).')">';
|
||||
} else {
|
||||
|
||||
@ -19,7 +19,9 @@
|
||||
*/
|
||||
|
||||
|
||||
if (!defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL', '1');
|
||||
if (!defined('NOTOKENRENEWAL')) {
|
||||
define('NOTOKENRENEWAL', '1');
|
||||
}
|
||||
|
||||
require '../../main.inc.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
|
||||
@ -27,7 +29,9 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/opensurvey/fonctions.php';
|
||||
|
||||
// Security check
|
||||
if (!$user->rights->opensurvey->write) accessforbidden();
|
||||
if (!$user->rights->opensurvey->write) {
|
||||
accessforbidden();
|
||||
}
|
||||
|
||||
$langs->load("opensurvey");
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user