diff --git a/ChangeLog b/ChangeLog index d2447b1c02139ac5d515e596df2cd1ad59f2dd39..12c79ad77c85d9bd2f50e2577a93448261add0f4 100644 --- a/ChangeLog +++ b/ChangeLog @@ -17,8 +17,13 @@ For users: - New: Add option MAIN_AUTO_TIMESTAMP_IN_PUBLIC_NOTES and MAIN_AUTO_TIMESTAMP_IN_PRIVATE_NOTES to automatically add timestamp and user line into edition field when editing a note. - New: Add button cancel into edition of notes. -- New: Improved Opensurvey module and added options to disable comments and disable - public votes. +- New: Improved Opensurvey module: + Added options to disable comments and disable public votes. + Limit dates use calendar popup. + Description of survey use wysiwig editor. + More information shown on result tab. + Renamed "survey" into "poll" (better translation). +- New: Add filter on text and status into survey list. Can also sort on id, text and date end. - New: The box "balance of bank accounts" show all opened accounts. - New: Add option MAIN_ADD_SALE_REP_SIGNATURE_IN_NOTE to add sale represnative into public note of generated documents. @@ -26,7 +31,6 @@ For users: - New: Increase length of url into bookmark module. - New: Automatic events sending mails add info about linked objects into email content. - New: Price management enhancement (multiprice level, price by customer, if MAIN_FEATURES_LEVEL=2 Price by qty). -- New: Add filter on text and status into survey list. Can also sort on id, text and date end. - New: Add option MAIN_FAVICON_URL. - New: Created {line_price_ht_locale}, {line_price_vat_locale} and {line_price_ttc_locale} ODT tags. - New: Add filter on project status into task list. By default, only "opened" project are visible. diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index f59a9d20b80313b3491c7cbe7bdff43640e0e8fa..05d2d75bf9f76dea4ac9699f9b9fc84d524e9df1 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -999,7 +999,7 @@ function dol_getdate($timestamp,$fast=false) * @param int $year Year * @param int $gm 1=Input informations are GMT values, otherwise local to server TZ * @param int $check 0=No check on parameters (Can use day 32, etc...) - * @return int Date as a timestamp, '' if error + * @return int Date as a timestamp, '' if error * @see dol_print_date, dol_stringtotime, dol_getdate */ function dol_mktime($hour,$minute,$second,$month,$day,$year,$gm=false,$check=1) diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang index c85e74f0b48cb12065dab497507e81792cbfbf69..872c3f4db6969cb4fe6d811b0a362b7e8a66cb6a 100644 --- a/htdocs/langs/en_US/admin.lang +++ b/htdocs/langs/en_US/admin.lang @@ -512,8 +512,8 @@ Module50200Name= Paypal Module50200Desc= Module to offer an online payment page by credit card with Paypal Module54000Name=PrintIPP Module54000Desc=Print via Cups IPP Printer. -Module55000Name=Open Survey -Module55000Desc=Module to make online surveys (like Doodle, Studs, Rdvz, ...) +Module55000Name=Open Poll +Module55000Desc=Module to make online polls (like Doodle, Studs, Rdvz, ...) Module59000Name=Margins Module59000Desc=Module to manage margins Module60000Name=Commissions @@ -732,8 +732,8 @@ Permission50101=Use Point of sales Permission50201=Read transactions Permission50202=Import transactions Permission54001=Print -Permission55001=Read surveys -Permission55002=Create/modify surveys +Permission55001=Read polls +Permission55002=Create/modify polls Permission59001=Read commercial margins Permission59002=Define commercial margins DictionaryCompanyType=Thirdparties type diff --git a/htdocs/langs/en_US/bills.lang b/htdocs/langs/en_US/bills.lang index 7495d6c1aadbd29e292245f34f30286d5363d047..6a4199ef326f6ea3f9eb7510784959ccd48b749b 100644 --- a/htdocs/langs/en_US/bills.lang +++ b/htdocs/langs/en_US/bills.lang @@ -225,8 +225,6 @@ DispenseMontantLettres=The written invoices through mecanographic procedures are NonPercuRecuperable=Non-recoverable SetConditions=Set payment terms SetMode=Set payment mode -SetDate= Set date -SelectDate=Select a date Billed=Billed RepeatableInvoice=Pre-defined invoice RepeatableInvoices=Pre-defined invoices diff --git a/htdocs/langs/en_US/main.lang b/htdocs/langs/en_US/main.lang index ef13f96e85cc34bc35762314b3a3db7b829c85d5..56f970696cf5c668272be15b443065f008b78d39 100644 --- a/htdocs/langs/en_US/main.lang +++ b/htdocs/langs/en_US/main.lang @@ -60,6 +60,8 @@ ErrorNoSocialContributionForSellerCountry=Error, no social contribution type def ErrorFailedToSaveFile=Error, failed to save file. ErrorOnlyPngJpgSupported=Error, only .png and .jpg image format file are supported. ErrorImageFormatNotSupported=Your PHP does not support functions to convert images of this format. +SetDate=Set date +SelectDate=Select a date SeeAlso=See also %s BackgroundColorByDefault=Default background color FileWasNotUploaded=A file is selected for attachment but was not yet uploaded. Click on "Attach file" for this. diff --git a/htdocs/langs/en_US/opensurvey.lang b/htdocs/langs/en_US/opensurvey.lang index 48fbdc388b34967cb752a3b375e786f2a8db2a81..3b34bd661c7ec95b68c3b04237396e2dfe873371 100644 --- a/htdocs/langs/en_US/opensurvey.lang +++ b/htdocs/langs/en_US/opensurvey.lang @@ -1,18 +1,18 @@ # Dolibarr language file - Source file is en_US - opensurvey -Survey=Survey -Surveys=Surveys -OrganizeYourMeetingEasily=Organize your meetings and surveys easily. First select type of survey... -NewSurvey=New survey -NoSurveysInDatabase=%s survey(s) into database. -OpenSurveyArea=Surveys area -AddACommentForPoll=You can add a comment into survey... +Survey=Poll +Surveys=Polls +OrganizeYourMeetingEasily=Organize your meetings and polls easily. First select type of poll... +NewSurvey=New poll +NoSurveysInDatabase=%s poll(s) into database. +OpenSurveyArea=Polls area +AddACommentForPoll=You can add a comment into poll... AddComment=Add comment CreatePoll=Create poll PollTitle=Poll title -ToReceiveEMailForEachVote=To receive an email for each vote +ToReceiveEMailForEachVote=Receive an email for each vote TypeDate=Type date TypeClassic=Type standard -OpenSurveyStep2=Select your dates amoung the free days (green). The selected days are in blue. You can unselect a day previously selected by clicking again on it +OpenSurveyStep2=Select your dates amoung the free days (grey). The selected days are green. You can unselect a day previously selected by clicking again on it RemoveAllDays=Remove all days CopyHoursOfFirstDay=Copy hours of first day RemoveAllHours=Remove all hours @@ -24,10 +24,10 @@ OpenSurveyHowTo=If you agree to vote in this poll, you have to give your name, c CommentsOfVoters=Comments of voters ConfirmRemovalOfPoll=Are you sure you want to remove this poll (and all votes) RemovePoll=Remove poll -UrlForSurvey=URL to communicate to get a direct access to survey +UrlForSurvey=URL to communicate to get a direct access to poll PollOnChoice=You are creating a poll to make a multi-choice for a poll. First enter all possible choices for your poll: -CreateSurveyDate=Create a date survey -CreateSurveyStandard=Create a standard survey +CreateSurveyDate=Create a date poll +CreateSurveyStandard=Create a standard poll CheckBox=Simple checkbox YesNoList=List (empty/yes/no) PourContreList=List (empty/for/against) @@ -35,7 +35,7 @@ AddNewColumn=Add new column TitleChoice=Choice label ExportSpreadsheet=Export result spreadsheet ExpireDate=Limit date -NbOfSurveys=Number of surveys +NbOfSurveys=Number of polls NbOfVoters=Nb of voters SurveyResults=Results PollAdminDesc=You are allowed to change all vote lines of this poll with button "Edit". You can, as well, remove a column or a line with %s. You can also add a new column with %s. diff --git a/htdocs/opensurvey/card.php b/htdocs/opensurvey/card.php index 7bd3471c82567af1d6b92f07552669a426c36ef8..3bf55fbe847c4b89d60107075e8d79fa45439210 100644 --- a/htdocs/opensurvey/card.php +++ b/htdocs/opensurvey/card.php @@ -1,6 +1,6 @@ <?php -/* Copyright (C) 2013 Laurent Destailleur <eldy@users.sourceforge.net> - * Copyright (C) 2014 Marcos García <marcosgdf@gmail.com> +/* Copyright (C) 2013-2014 Laurent Destailleur <eldy@users.sourceforge.net> + * Copyright (C) 2014 Marcos García <marcosgdf@gmail.com> * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -25,6 +25,7 @@ require_once('../main.inc.php'); require_once(DOL_DOCUMENT_ROOT."/core/lib/admin.lib.php"); require_once(DOL_DOCUMENT_ROOT."/core/lib/files.lib.php"); +require_once(DOL_DOCUMENT_ROOT."/core/class/doleditor.class.php"); require_once(DOL_DOCUMENT_ROOT."/opensurvey/class/opensurveysondage.class.php"); require_once(DOL_DOCUMENT_ROOT."/opensurvey/fonctions.php"); @@ -63,7 +64,7 @@ if ($action == 'delete_confirm') { // Security check if (!$user->rights->opensurvey->write) accessforbidden(); - + $result=$object->delete($user,'',$numsondage); header('Location: '.dol_buildpath('/opensurvey/list.php',1)); @@ -127,7 +128,7 @@ if (GETPOST('ajoutcomment')) $comment_user = GETPOST('commentuser'); $resql = $object->addComment($comment, $comment_user); - + if (! $resql) { setEventMessage($langs->trans('ErrorInsertingComment'), 'errors'); @@ -141,12 +142,12 @@ if ($idcomment) { // Security check if (!$user->rights->opensurvey->write) accessforbidden(); - + $resql = $object->deleteComment($idcomment); } if ($action == 'edit') { - + // Security check if (!$user->rights->opensurvey->write) accessforbidden(); } @@ -216,23 +217,22 @@ if ($action == 'edit') else print dol_htmlentities($object->titre); print '</td></tr>'; -// Author -print '<tr><td>'; -print $langs->trans("Author") .'</td><td colspan="2">'; -if ($object->fk_user_creat) { - print $userstatic->getLoginUrl(1); -} else { - print dol_htmlentities($object->nom_admin); -} -print '</td></tr>'; - // Description -print '<tr><td>'.$langs->trans("Description") .'</td><td colspan="2">'; +print '<tr><td valign="top">'.$langs->trans("Description") .'</td><td colspan="2">'; if ($action == 'edit') { - print '<textarea name="nouveauxcommentaires" rows="7" cols="80">'. dol_htmlentities($object->commentaires).'</textarea>'."\n"; + $doleditor=new DolEditor('nouveauxcommentaires', dol_htmlentities($object->commentaires),'',120,'dolibarr_notes','In',1,1,1,ROWS_7,120); + $doleditor->Create(0,''); +} +else +{ + if (empty($conf->fckeditor->enabled)) print dol_htmlentitiesbr($object->commentaires); + else + { + $doleditor=new DolEditor('nouveauxcommentaires', dol_htmlentities($object->commentaires),'',120,'dolibarr_notes','In',1,1,1,ROWS_7,120,1); + $doleditor->Create(0,''); + } } -else print dol_nl2br(dol_htmlentities($object->commentaires)); print '</td></tr>'; // EMail @@ -255,7 +255,7 @@ if ($action == 'edit') } else { print yn($object->mailsonde); - + //If option is active and linked user does not have an email, we show a warning if ($object->fk_user_creat && $object->mailsonde) { if (!$userstatic->email) { @@ -289,6 +289,15 @@ if ($action == 'edit') print $form->select_date($expiredate?$expiredate:$object- else print dol_print_date($object->date_fin,'day'); print '</td></tr>'; +// Author +print '<tr><td>'; +print $langs->trans("Author") .'</td><td colspan="2">'; +if ($object->fk_user_creat) { + print $userstatic->getLoginUrl(1); +} else { + print dol_htmlentities($object->nom_admin); +} +print '</td></tr>'; // Link print '<tr><td>'.img_picto('','object_globe.png').' '.$langs->trans("UrlForSurvey",'').'</td><td colspan="2">'; @@ -317,7 +326,7 @@ dol_fiche_end(); print '<div class="tabsAction">'; if ($action != 'edit' && $user->rights->opensurvey->write) { - + //Modify button print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?action=edit&id=' . $numsondage . '">'.$langs->trans("Modify") . '</a>'; @@ -349,7 +358,7 @@ if ($comments) { if ($user->rights->opensurvey->write) { print '<a href="'.dol_buildpath('/opensurvey/card.php',1).'?deletecomment='.$comment->id_comment.'&id='.$numsondage.'"> '.img_picto('', 'delete.png').'</a> '; } - + print dol_htmlentities($comment->usercomment).': '.dol_nl2br(dol_htmlentities($comment->comment))." <br>"; } } diff --git a/htdocs/opensurvey/class/opensurveysondage.class.php b/htdocs/opensurvey/class/opensurveysondage.class.php index 862381d232256b4009e8f41bff369e3702d1bedd..c98993526f5ecf563b9862c8995097e881f868fe 100644 --- a/htdocs/opensurvey/class/opensurveysondage.class.php +++ b/htdocs/opensurvey/class/opensurveysondage.class.php @@ -44,21 +44,21 @@ class Opensurveysondage extends CommonObject var $id_sondage; var $commentaires; - + var $mail_admin; var $nom_admin; - + /** * Id of user author of the poll * @var int */ public $fk_user_creat; - + var $titre; var $date_fin=''; var $format; var $mailsonde; - + public $sujet; /** @@ -66,7 +66,7 @@ class Opensurveysondage extends CommonObject * @var bool */ public $allow_comments; - + /** * Allow users see others vote * @var bool @@ -127,9 +127,9 @@ class Opensurveysondage extends CommonObject $sql.= " ".$this->db->escape($this->allow_comments).","; $sql.= " ".$this->db->escape($this->allow_spy).","; $sql.= " '".$this->db->escape($this->sujet)."'"; - + $sql.= ")"; - + $this->db->begin(); dol_syslog(get_class($this)."::create sql=".$sql, LOG_DEBUG); @@ -141,7 +141,7 @@ class Opensurveysondage extends CommonObject if (! $notrigger) { global $langs, $conf; - + //// Call triggers include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php'; $interface=new Interfaces($this->db); @@ -150,7 +150,7 @@ class Opensurveysondage extends CommonObject //// End call triggers } } - + // Commit or rollback if ($error) { @@ -181,7 +181,7 @@ class Opensurveysondage extends CommonObject { $sql = "SELECT"; $sql.= " t.id_sondage,"; - $sql.= " t.commentaires,"; + $sql.= " t.commentaires as description,"; $sql.= " t.mail_admin,"; $sql.= " t.nom_admin,"; $sql.= " t.fk_user_creat,"; @@ -207,8 +207,9 @@ class Opensurveysondage extends CommonObject $this->id_sondage = $obj->id_sondage; //For compatibility $this->ref = $this->id_sondage; - - $this->commentaires = $obj->commentaires; + + $this->commentaires = $obj->description; // deprecated + $this->description = $obj->description; $this->mail_admin = $obj->mail_admin; $this->nom_admin = $obj->nom_admin; $this->titre = $obj->titre; @@ -275,7 +276,7 @@ class Opensurveysondage extends CommonObject $sql.= " mailsonde=".(isset($this->mailsonde)?$this->db->escape($this->mailsonde):"null").","; $sql.= " allow_comments=".$this->db->escape($this->allow_comments).","; $sql.= " allow_spy=".$this->db->escape($this->allow_spy); - + $sql.= " WHERE id_sondage='".$this->db->escape($this->id_sondage)."'"; $this->db->begin(); @@ -437,75 +438,75 @@ class Opensurveysondage extends CommonObject /** * Returns all comments for the current opensurvey poll - * + * * @return Object[] */ public function getComments() { - + $sql = 'SELECT id_comment, usercomment, comment'; $sql.= ' FROM '.MAIN_DB_PREFIX.'opensurvey_comments'; $sql.= " WHERE id_sondage='".$this->db->escape($this->id_sondage)."'"; $sql.= " ORDER BY id_comment"; $resql = $this->db->query($sql); - + $num_rows=$this->db->num_rows($resql); - + $comments = array(); - + if ($num_rows > 0) { while ($obj = $this->db->fetch_object($resql)) { $comments[] = $obj; } } - + return $comments; } - + /** * Adds a comment to the poll - * + * * @param string $comment Comment content * @param string $comment_user Comment author * @return boolean False in case of the query fails, true if it was successful */ public function addComment($comment, $comment_user) { - + $sql = "INSERT INTO ".MAIN_DB_PREFIX."opensurvey_comments (id_sondage, comment, usercomment)"; $sql.= " VALUES ('".$this->db->escape($this->id_sondage)."','".$this->db->escape($comment)."','".$this->db->escape($comment_user)."')"; $resql = $this->db->query($sql); dol_syslog("sql=".$sql); - + if (!$resql) { return false; } - + return true; } - + /** * Deletes a comment of the poll - * + * * @param int $id_comment Id of the comment * @return boolean False in case of the query fails, true if it was successful */ public function deleteComment($id_comment) { $sql = 'DELETE FROM '.MAIN_DB_PREFIX.'opensurvey_comments WHERE id_comment = '.$id_comment.' AND id_sondage = '.$this->id_sondage; $resql = $this->db->query($sql); - + if (!$resql) { return false; } - + return true; } - + /** * Cleans all the class variables before doing an update or an insert - * + * * @return void */ private function cleanParameters() { - + $this->id_sondage = trim($this->id_sondage); $this->commentaires = trim($this->commentaires); $this->mail_admin = trim($this->mail_admin); diff --git a/htdocs/opensurvey/public/studs.php b/htdocs/opensurvey/public/studs.php index f59a9d6e57215a6e1ddc14c90af57340b1b63413..bd0ff34073ecbfad6f41e57b88790f812e718621 100644 --- a/htdocs/opensurvey/public/studs.php +++ b/htdocs/opensurvey/public/studs.php @@ -192,11 +192,11 @@ if ($testmodifier) for ($i=0;$i<$nbcolonnes;$i++) { //var_dump($_POST["choix$i"]); - if (isset($_POST["choix$i"]) && $_POST["choix$i"] == '1') + if (isset($_POST["choix".$i]) && $_POST["choix".$i] == '1') { $nouveauchoix.="1"; } - else if (isset($_POST["choix$i"]) && $_POST["choix$i"] == '2') + else if (isset($_POST["choix".$i]) && $_POST["choix".$i] == '2') { $nouveauchoix.="2"; } @@ -257,13 +257,12 @@ print '<div class="corps"> '."\n"; //affichage du titre du sondage $titre=str_replace("\\","",$object->titre); -print '<strong>'.dol_htmlentities($titre).'</strong><br>'."\n"; +print '<strong>'.dol_htmlentities($titre).'</strong><br><br>'."\n"; //affichage des commentaires du sondage if ($object->commentaires) { - $commentaires=dol_nl2br(dol_htmlentities($object->commentaires)); - print $commentaires; + print dol_htmlentitiesbr($object->commentaires); print '<br>'."\n"; } diff --git a/htdocs/opensurvey/results.php b/htdocs/opensurvey/results.php index a17cea45759ed7718d2dbf742a14db3ce1ba369c..7ac3dbb0d6d4f4cba8d9be2aed1b0ab454bcfd3f 100644 --- a/htdocs/opensurvey/results.php +++ b/htdocs/opensurvey/results.php @@ -395,6 +395,11 @@ for ($i = 0; $i < $nbcolonnes; $i++) * View */ +if ($object->fk_user_creat) { + $userstatic = new User($db); + $userstatic->fetch($object->fk_user_creat); +} + $form=new Form($db); $result=$object->fetch(0,$numsondage); @@ -435,7 +440,7 @@ $linkback = '<a href="'.dol_buildpath('/opensurvey/list.php',1).(! empty($socid) // Ref print '<tr><td width="18%">'.$langs->trans('Ref').'</td>'; print '<td colspan="3">'; -print $form->showrefnav($object, 'sondage', $linkback, 1, 'id_sondage', 'id_sondage'); +print $form->showrefnav($object, 'id', $linkback, 1, 'id_sondage', 'id_sondage'); print '</td>'; print '</tr>'; @@ -445,6 +450,33 @@ print '<tr><td>'.$langs->trans("Type").'</td><td colspan="2">'; 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").'</td></tr>'; +// Title +print '<tr><td>'; +$adresseadmin=$object->mail_admin; +print $langs->trans("Title") .'</td><td colspan="2">'; +if ($action == 'edit') +{ + print '<input type="text" name="nouveautitre" size="40" value="'.dol_escape_htmltag(dol_htmlentities($object->titre)).'">'; +} +else print dol_htmlentities($object->titre); +print '</td></tr>'; + +// Expire date +print '<tr><td>'.$langs->trans('ExpireDate').'</td><td colspan="2">'; +if ($action == 'edit') print $form->select_date($expiredate?$expiredate:$object->date_fin,'expire'); +else print dol_print_date($object->date_fin,'day'); +print '</td></tr>'; + +// Author +print '<tr><td>'; +print $langs->trans("Author") .'</td><td colspan="2">'; +if ($object->fk_user_creat) { + print $userstatic->getLoginUrl(1); +} else { + print dol_htmlentities($object->nom_admin); +} +print '</td></tr>'; + // Link print '<tr><td>'.img_picto('','object_globe.png').' '.$langs->trans("UrlForSurvey",'').'</td><td>'; diff --git a/htdocs/opensurvey/wizard/create_survey.php b/htdocs/opensurvey/wizard/create_survey.php index 26411fa18b5c6c00dbf492ba918215c8dca60bf8..a1e08f2563204e49d6f4ee9be2d636f7604b0148 100644 --- a/htdocs/opensurvey/wizard/create_survey.php +++ b/htdocs/opensurvey/wizard/create_survey.php @@ -1,6 +1,6 @@ <?php -/* Copyright (C) 2013 Laurent Destailleur <eldy@users.sourceforge.net> - * Copyright (C) 2014 Marcos García <marcosgdf@gmail.com> +/* Copyright (C) 2013-2014 Laurent Destailleur <eldy@users.sourceforge.net> + * Copyright (C) 2014 Marcos García <marcosgdf@gmail.com> * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -25,6 +25,7 @@ require_once('../../main.inc.php'); require_once(DOL_DOCUMENT_ROOT."/core/lib/admin.lib.php"); require_once(DOL_DOCUMENT_ROOT."/core/lib/files.lib.php"); +require_once(DOL_DOCUMENT_ROOT."/core/class/doleditor.class.php"); require_once(DOL_DOCUMENT_ROOT."/opensurvey/fonctions.php"); // Security check @@ -62,39 +63,39 @@ if (GETPOST("creation_sondage_date") || GETPOST("creation_sondage_autre")) } else { $_SESSION["mailsonde"] = false; } - + if (GETPOST('allow_comments') == 'on') { $_SESSION['allow_comments'] = true; } else { $_SESSION['allow_comments'] = false; } - + if (GETPOST('allow_spy') == 'on') { $_SESSION['allow_spy'] = true; } else { $_SESSION['allow_spy'] = false; } - + $testdate = false; - - if (GETPOST('champdatefin')) + $champdatefin = dol_mktime(0,0,0,GETPOST('champdatefinmonth'),GETPOST('champdatefinday'),GETPOST('champdatefinyear')); + + if (GETPOST('champdatefin') && $champdatefin) // A date was provided { - $registredate=explode("/",$_POST["champdatefin"]); - if (is_array($registredate) && count($registredate) === 3) { - $time = mktime(0,0,0,$registredate[1],$registredate[0],$registredate[2]); - - if ($time !== false && date('d/m/Y', $time) === $_POST["champdatefin"]) { - //Expire date is not before today - if ($time - dol_now() > 0) { - $testdate = true; - $_SESSION['champdatefin'] = $time; - } - } + // Expire date is not before today + if ($champdatefin - dol_now() > 0) + { + $testdate = true; + $_SESSION['champdatefin'] = dol_print_date($champdatefin,'dayrfc'); + } + else + { + $testdate = true; + //setEventMessage($langs->trans('ExpiredDate'),'errors'); } } - - if (!$testdate) { - setEventMessage($langs->trans('ErrorOpenSurveyDateFormat'), 'errors'); + + if (! $testdate) { + setEventMessage($langs->trans('ErrorFieldRequired',$langs->transnoentitiesnoconv("ExpireDate")), 'errors'); } if ($titre && $testdate) @@ -141,19 +142,15 @@ if (! $_SESSION["titre"] && (GETPOST('creation_sondage_date') || GETPOST('creati } print '</tr>'."\n"; -print '<tr><td>'. $langs->trans("Description") .'</td><td><textarea name="commentaires" rows="7" cols="40">'.$_SESSION["commentaires"].'</textarea></td>'."\n"; +print '<tr><td>'. $langs->trans("Description") .'</td><td>'; +$doleditor=new DolEditor('commentaires', $_SESSION["commentaires"],'',120,'dolibarr_notes','In',1,1,1,ROWS_7,120); +$doleditor->Create(0,''); +print '</td>'."\n"; print '</tr>'."\n"; print '<tr><td class="fieldrequired">'. $langs->trans("ExpireDate") .'</td><td>'; -if (!GETPOST('champdatefin')) { - //172800 = 48 hours - $champdatefin = time() + 172800; -} else { - $champdatefin = -1; -} - -print $form->select_date($champdatefin,'champdatefin','','','',"add",1,0); +print $form->select_date($champdatefin?$champdatefin:-1,'champdatefin','','','',"add",1,0); print '</tr>'."\n"; print '</table>'."\n"; @@ -171,12 +168,12 @@ if ($_SESSION["mailsonde"]) $cochemail="checked"; print '<input type="checkbox" name="mailsonde" '.$cochemail.'> '. $langs->trans("ToReceiveEMailForEachVote") .'<br>'."\n"; -if ($_SESSION['allow_comments']) $allow_comments = "checked"; - -print '<input type="checkbox" name="allow_comments" '.$allow_comments.'> '.$langs->trans('CanComment').'<br />'."\n"; - -if ($_SESSION['allow_spy']) $allow_spy = "checked"; +if ($_SESSION['allow_comments']) $allow_comments = 'checked="checked"'; +if (isset($_POST['allow_comments'])) $allow_comments=GETPOST('allow_comments')?'checked="checked"':''; +print '<input type="checkbox" name="allow_comments" '.$allow_comments.'"> '.$langs->trans('CanComment').'<br />'."\n"; +if ($_SESSION['allow_spy']) $allow_spy = 'checed="checked"'; +if (isset($_POST['allow_spy'])) $allow_spy=GETPOST('allow_spy')?'checked="checked"':''; print '<input type="checkbox" name="allow_spy" '.$allow_spy.'> '.$langs->trans('CanSeeOthersVote').'<br />'."\n"; if (GETPOST('choix_sondage'))