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