3 * This software is governed by the CeCILL-B license. If a copy of this license
4 * is not distributed with this file, you can obtain one at
5 * http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.txt
7 * Authors of STUdS (initial project): Guilhem BORGHESI (borghesi@unistra.fr) and Raphaël DROZ
8 * Authors of Framadate/OpenSondate: Framasoft (https://github.com/framasoft)
10 * =============================
12 * Ce logiciel est régi par la licence CeCILL-B. Si une copie de cette licence
13 * ne se trouve pas avec ce fichier vous pouvez l'obtenir sur
14 * http://www.cecill.info/licences/Licence_CeCILL-B_V1-fr.txt
16 * Auteurs de STUdS (projet initial) : Guilhem BORGHESI (borghesi@unistra.fr) et Raphaël DROZ
17 * Auteurs de Framadate/OpenSondage : Framasoft (https://github.com/framasoft)
23 include_once('creation_sondage.php');
25 if (is_readable('bandeaux_local.php')) {
26 include_once('bandeaux_local.php');
28 include_once('bandeaux.php');
31 // Step 1/3 : error if $_SESSION from info_sondage are not valid
32 if (Utils
::issetAndNoEmpty('titre', $_SESSION) === false || Utils
::issetAndNoEmpty('nom', $_SESSION) === false ||
(($config['use_smtp']) ? Utils
::issetAndNoEmpty('adresse', $_SESSION) === false : false)) {
34 Utils
::print_header ( _("Error!") );
35 bandeau_titre(_("Error!"));
38 <div class="alert alter-danger">
39 <h3>' . _("You haven't filled the first section of the poll creation.") . ' !</h3>
40 <p>' . _("Back to the homepage of ") . ' ' . '<a href="' . Utils
::get_server_name() . '">' . NOMAPPLICATION
. '</a>.</p>
46 // Step 4 : Data prepare before insert in DB
47 if (Utils
::issetAndNoEmpty('confirmation')) {
48 $temp_results = array();
50 if (Utils
::issetAndNoEmpty('totalchoixjour', $_SESSION) === true) {
51 for ($i = 0; $i < count($_SESSION["totalchoixjour"]); $i++
) {
52 if(count($_SESSION['horaires'.$i])!=0) {
53 for ($j=0;$j< min(count($_SESSION['horaires'.$i]),12);$j++
) {
54 if ($_SESSION['horaires'.$i][$j]!="") {
55 array_push($temp_results, $_SESSION["totalchoixjour"][$i].'@'.$_SESSION['horaires'.$i][$j]);
57 array_push($temp_results, $_SESSION["totalchoixjour"][$i]);
61 array_push($temp_results, $_SESSION["totalchoixjour"][$i]);
67 // Sort and remove doublons
68 $temp_results = array_unique($temp_results);
70 for ($i=0;$i<count($temp_results);$i++
) {
71 if (isset($temp_results[$i])) {
72 $choixdate.=','.$temp_results[$i];
76 $_SESSION["toutchoix"]=substr($choixdate,1);
78 // Expiration date → 6 months after last day if not filled or in bad format
79 $_SESSION["champdatefin"]=end($temp_results)+
(86400 * $config['default_poll_duration']);
81 if (Utils
::issetAndNoEmpty('champdatefin')) {
82 $registredate = explode("/",$_POST["champdatefin"]);
83 if (is_array($registredate) == true && count($registredate) == 3) {
84 $time = mktime(0,0,0,$registredate[1],$registredate[0],$registredate[2]);
85 if ($time > time() +
(24*60*60)) {
86 $_SESSION["champdatefin"]=$time;
94 if (Utils
::issetAndNoEmpty('days')) {
95 if (!isset($_SESSION["totalchoixjour"])) {
96 $_SESSION["totalchoixjour"]=array();
99 for ($i = 0; $i < count($_POST["days"]); $i++
) {
100 if (isset($_POST["days"][$i]) && $_POST["days"][$i] !='') {
101 $_SESSION['totalchoixjour'][$k] = mktime(0, 0, 0, substr($_POST["days"][$i],3,2),substr($_POST["days"][$i],0,2),substr($_POST["days"][$i],6,4));
104 for($j = 0; $j < count($_POST['horaires'.$i]); $j++
) {
105 if (isset($_POST['horaires'.$i][$j]) && $_POST['horaires'.$i][$j] != '') {
106 $_SESSION['horaires'.$k][$l] = $_POST['horaires'.$i][$j];
116 //le format du sondage est DATE
117 $_SESSION["formatsondage"] = "D".$_SESSION["studsplus"];
119 // Step 3/3 : Confirm poll creation
120 if (Utils
::issetAndNoEmpty('choixheures') && Utils
::issetAndNoEmpty('totalchoixjour', $_SESSION)) {
122 Utils
::print_header ( _("Removal date and confirmation (3 on 3)") );
123 bandeau_titre(_("Removal date and confirmation (3 on 3)"));
125 $temp_array = array_unique($_SESSION["totalchoixjour"]);
127 $removal_date=utf8_encode(strftime($date_format['txt_full'], end($temp_array)+
(86400 * $config['default_poll_duration'])));
131 for ($i=0;$i<count($_SESSION["totalchoixjour"]);$i++
) {
132 $summary .= '<li>'.strftime($date_format['txt_full'], $_SESSION["totalchoixjour"][$i]);
133 for ($j=0;$j<count($_SESSION['horaires'.$i]);$j++
) {
134 if (isset($_SESSION['horaires'.$i][$j])) {
135 $summary .= ($j==0) ?
' : ' : ', ';
136 $summary .= $_SESSION['horaires'.$i][$j];
139 $summary .= '</li>'."\n";
144 <form name="formulaire" action="' . Utils
::get_server_name() . 'choix_date.php" method="POST" class="form-horizontal" role="form">
145 <div class="row" id="selected-days">
146 <div class="col-md-8 col-md-offset-2">
147 <h3>'. _("Confirm the creation of your poll") .'</h3>
148 <div class="well summary">
149 <h4>'. _("List of your choices").'</h4>
152 <div class="alert alert-info clearfix">
153 <p>' . _("Your poll will be automatically removed "). $config['default_poll_duration'] . ' ' . _("days") ._(" after the last date of your poll:") . ' <strong>'.$removal_date.'</strong>.<br />' . _("You can fix another removal date for it.") .'</p>
154 <div class="form-group">
155 <label for="champdatefin" class="col-sm-5 control-label">'. _("Removal date (optional)") .'</label>
156 <div class="col-sm-6">
157 <div class="input-group date">
158 <span class="input-group-addon"><i class="glyphicon glyphicon-calendar text-info"></i></span>
159 <input type="text" class="form-control" id="champdatefin" data-date-format="'. _("dd/mm/yyyy") .'" aria-describedby="dateformat" name="champdatefin" value="" size="10" maxlength="10" placeholder="'. _("dd/mm/yyyy") .'" />
162 <span id="dateformat" class="sr-only">'. _("(dd/mm/yyyy)") .'</span>
165 <div class="alert alert-warning">
166 <p>'. _("Once you have confirmed the creation of your poll, you will be automatically redirected on the administration page of your poll."). '</p>';
167 if($config['use_smtp']==true){
169 <p>' . _("Then, you will receive quickly two emails: one contening the link of your poll for sending it to the voters, the other contening the link to the administration page of your poll.") .'</p>';
173 <p class="text-right">
174 <button class="btn btn-default" onclick="javascript:window.history.back();" title="'. _('Back to step 2') . '">'. _('Back') . '</button>
175 <button name="confirmation" value="confirmation" type="submit" class="btn btn-success">'. _('Create the poll') . '</button>
183 // Step 2/3 : Select dates of the poll
185 Utils
::print_header ( _("Poll dates (2 on 3)") );
186 bandeau_titre(_("Poll dates (2 on 3)"));
189 <form name="formulaire" action="' . Utils
::get_server_name() . 'choix_date.php" method="POST" class="form-horizontal" role="form">
190 <div class="row" id="selected-days">
191 <div class="col-md-10 col-md-offset-1">
192 <h3>'. _("Choose the dates of your poll") .'</h3>
193 <div class="alert alert-info">
194 <p>'. _("To schedule an event, it's better to propose at least two choices (two hours for one day or two days).").'</p>
195 <p>'. _("You can add or remove additionnal days and hours with the buttons") .' <span class="glyphicon glyphicon-minus text-info"></span><span class="sr-only">'. _("Remove") .'</span> <span class="glyphicon glyphicon-plus text-success"></span><span class="sr-only">'. _("Add") .'</span></p>
196 <p>'. _("For each selected day, you can choose, or not, meeting hours (e.g.: \"8h\", \"8:30\", \"8h-10h\", \"evening\", etc.)").'</p>
199 // Fields days : 3 by default
200 $nb_days = (isset($_SESSION["totalchoixjour"])) ?
count($_SESSION["totalchoixjour"]) : 3;
201 for ($i=0;$i<$nb_days;$i++
) {
202 $day_value = isset($_SESSION["totalchoixjour"][$i]) ?
strftime( "%d/%m/%Y", $_SESSION["totalchoixjour"][$i]) : '';
205 <div class="form-group">
207 <label class="sr-only" for="day'.$i.'">'. _("Day") .' '. ($i+
1) .'</label>
208 <div class="input-group date col-xs-7">
209 <span class="input-group-addon"><i class="glyphicon glyphicon-calendar text-info"></i></span>
210 <input type="text" class="form-control" id="day'.$i.'" title="'. _("Day") .' '. ($i+
1) .'" data-date-format="'. _("dd/mm/yyyy") .'" aria-describedby="dateformat'.$i.'" name="days[]" value="'.$day_value.'" size="10" maxlength="10" placeholder="'. _("dd/mm/yyyy") .'" />
212 <span id="dateformat'.$i.'" class="sr-only">'. _("(dd/mm/yyyy)") .'</span>
215 // Fields hours : 3 by default
216 for ($j=0;$j<max(count(isset($_SESSION["horaires".$i]) ?
$_SESSION["horaires".$i] : 0),3);$j++
) {
217 $hour_value = isset($_SESSION["horaires".$i][$j]) ?
$_SESSION["horaires".$i][$j] : '';
219 <div class="col-sm-2">
220 <label for="d'.$i.'-h'.$j.'" class="sr-only control-label">'. _("Time") .' '. ($j+
1) .'</label>
221 <input type="text" class="form-control hours" title="'.$day_value.' - '. _("Time") .' '. ($j+
1) .'" placeholder="'. _("Time") .' '. ($j+
1) .'" id="d'.$i.'-h'.$j.'" name="horaires'.$i.'[]" value="'.$hour_value.'" />
225 <div class="col-sm-2"><div class="btn-group btn-group-xs" style="margin-top: 5px;">
226 <button type="button" title="'. _("Remove an hour") .'" class="remove-an-hour btn btn-default"><span class="glyphicon glyphicon-minus text-info"></span><span class="sr-only">'. _("Remove an hour") .'</span></button>
227 <button type="button" title="'. _("Add an hour") .'" class="add-an-hour btn btn-default"><span class="glyphicon glyphicon-plus text-success"></span><span class="sr-only">'. _("Add an hour") .'</span></button>
233 <div class="col-md-4">
234 <button type="button" id="copyhours" class="btn btn-default disabled" title="'. _("Copy hours of the first day") .'"><span class="glyphicon glyphicon-sort-by-attributes-alt text-info"></span><span class="sr-only">'. _("Copy hours of the first day") .'</span></button>
235 <div class="btn-group btn-group">
236 <button type="button" id="remove-a-day" class="btn btn-default disabled" title="'. _("Remove a day") .'"><span class="glyphicon glyphicon-minus text-info"></span><span class="sr-only">'. _("Remove a day") .'</span></button>
237 <button type="button" id="add-a-day" class="btn btn-default" title="'. _("Add a day") .'"><span class="glyphicon glyphicon-plus text-success"></span><span class="sr-only">'. _("Add a day") .'</span></button>
240 <div class="col-md-8 text-right">
241 <div class="btn-group">
242 <button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown">
243 <span class="glyphicon glyphicon-remove text-danger"></span> '. _("Remove") . ' <span class="caret"></span>
245 <ul class="dropdown-menu" role="menu">
246 <li><a id="resetdays" href="javascript:void(0)">'. _("Remove all days") .'</a></li>
247 <li><a id="resethours" href="javascript:void(0)">'. _("Remove all hours") .'</a></li>
250 <a class="btn btn-default" href="'.Utils
::get_server_name().'infos_sondage.php?choix_sondage=date" title="'. _('Back to step 1') . '">'. _('Back') . '</a>
251 <button name="choixheures" value="'. _("Next") .'" type="submit" class="btn btn-success disabled" title="'. _('Go to step 3') . '">'. _("Next") .'</button>