Fix: date was not saved if not in future.
This commit is contained in:
parent
db091896a5
commit
41ab5a0ce2
@ -1,6 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
/* Copyright (C) 2013 Laurent Destailleur <eldy@users.sourceforge.net>
|
/* Copyright (C) 2013-2014 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||||
* Copyright (C) 2014 Marcos García <marcosgdf@gmail.com>
|
* Copyright (C) 2014 Marcos García <marcosgdf@gmail.com>
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* 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
|
* it under the terms of the GNU General Public License as published by
|
||||||
@ -100,7 +100,12 @@ class Opensurveysondage extends CommonObject
|
|||||||
$this->cleanParameters();
|
$this->cleanParameters();
|
||||||
|
|
||||||
// Check parameters
|
// Check parameters
|
||||||
// Put here code to add control on parameters values
|
if (! $this->date_fin > 0)
|
||||||
|
{
|
||||||
|
$this->error='BadValueForEndDate';
|
||||||
|
dol_syslog(get_class($this)."::create ".$this->error, LOG_ERR);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
// Insert request
|
// Insert request
|
||||||
$sql = "INSERT INTO ".MAIN_DB_PREFIX."opensurvey_sondage(";
|
$sql = "INSERT INTO ".MAIN_DB_PREFIX."opensurvey_sondage(";
|
||||||
|
|||||||
@ -30,10 +30,9 @@ require_once(DOL_DOCUMENT_ROOT."/opensurvey/fonctions.php");
|
|||||||
// Security check
|
// Security check
|
||||||
if (!$user->rights->opensurvey->write) accessforbidden();
|
if (!$user->rights->opensurvey->write) accessforbidden();
|
||||||
|
|
||||||
//le format du sondage est DATE
|
// Survey type is DATE
|
||||||
$_SESSION["formatsondage"] = "D";
|
$_SESSION["formatsondage"] = "D";
|
||||||
|
|
||||||
//traitement de l'entrée des heures dans les cases texte
|
|
||||||
$erreur = false;
|
$erreur = false;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -44,15 +43,16 @@ $erreur = false;
|
|||||||
if (GETPOST('confirmation'))
|
if (GETPOST('confirmation'))
|
||||||
{
|
{
|
||||||
|
|
||||||
//On sauvegarde les heures deja entrées
|
// 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"]);
|
||||||
|
|
||||||
for ($i = 0; $i < $nbofchoice; $i++) {
|
for ($i = 0; $i < $nbofchoice; $i++)
|
||||||
//affichage des 5 cases horaires
|
{
|
||||||
for ($j = 0; $j < $_SESSION["nbrecaseshoraires"]; $j++) {
|
// Show hours choices
|
||||||
|
for ($j = 0; $j < $_SESSION["nbrecaseshoraires"]; $j++)
|
||||||
|
{
|
||||||
$_SESSION["horaires$i"][$j] = $_POST["horaires$i"][$j];
|
$_SESSION["horaires$i"][$j] = $_POST["horaires$i"][$j];
|
||||||
|
|
||||||
$case = $j + 1;
|
$case = $j + 1;
|
||||||
@ -128,7 +128,7 @@ if (GETPOST('confirmation'))
|
|||||||
$errheure[$i][$j]=true;
|
$errheure[$i][$j]=true;
|
||||||
$erreur=true;
|
$erreur=true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (issetAndNoEmpty('horaires'.$i, $_SESSION) === false || issetAndNoEmpty($j, $_SESSION['horaires'.$i]) === false) {
|
if (issetAndNoEmpty('horaires'.$i, $_SESSION) === false || issetAndNoEmpty($j, $_SESSION['horaires'.$i]) === false) {
|
||||||
if (issetAndNoEmpty('horaires'.$i, $_SESSION) === true) {
|
if (issetAndNoEmpty('horaires'.$i, $_SESSION) === true) {
|
||||||
$_SESSION["horaires$i"][$j] = '';
|
$_SESSION["horaires$i"][$j] = '';
|
||||||
@ -138,7 +138,7 @@ if (GETPOST('confirmation'))
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($_SESSION["horaires$i"][0] == "" && $_SESSION["horaires$i"][1] == "" && $_SESSION["horaires$i"][2] == "" && $_SESSION["horaires$i"][3] == "" && $_SESSION["horaires$i"][4] == "") {
|
if ($_SESSION["horaires$i"][0] == "" && $_SESSION["horaires$i"][1] == "" && $_SESSION["horaires$i"][2] == "" && $_SESSION["horaires$i"][3] == "" && $_SESSION["horaires$i"][4] == "") {
|
||||||
$choixdate.=",";
|
$choixdate.=",";
|
||||||
$choixdate .= $_SESSION["totalchoixjour"][$i];
|
$choixdate .= $_SESSION["totalchoixjour"][$i];
|
||||||
@ -154,7 +154,7 @@ if (GETPOST('confirmation'))
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isset($errheure)) {
|
if (isset($errheure)) {
|
||||||
setEventMessage($langs->trans("ErrorBadFormat"), 'errors');
|
setEventMessage($langs->trans("ErrorBadFormat"), 'errors');
|
||||||
}
|
}
|
||||||
@ -165,17 +165,22 @@ if (GETPOST('confirmation'))
|
|||||||
setEventMessage($langs->trans("MoreChoices"), 'errors');
|
setEventMessage($langs->trans("MoreChoices"), 'errors');
|
||||||
$erreur=true;
|
$erreur=true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!$erreur) {
|
// Add survey into database
|
||||||
|
if (!$erreur)
|
||||||
|
{
|
||||||
$_SESSION["toutchoix"]=substr("$choixdate",1);
|
$_SESSION["toutchoix"]=substr("$choixdate",1);
|
||||||
|
|
||||||
ajouter_sondage();
|
ajouter_sondage();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 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]);
|
||||||
}
|
}
|
||||||
@ -238,7 +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++) {
|
||||||
@ -260,10 +265,10 @@ 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++) {
|
||||||
@ -278,7 +283,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++) {
|
||||||
@ -295,7 +300,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++) {
|
||||||
@ -361,7 +366,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++) {
|
||||||
@ -411,9 +416,9 @@ 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;
|
||||||
@ -458,9 +463,9 @@ 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++) {
|
||||||
//affichage des boutons ROUGES
|
//affichage des boutons ROUGES
|
||||||
if (date("j", $_SESSION["totalchoixjour"][$j]) == $numerojour && date("n", $_SESSION["totalchoixjour"][$j]) == $_SESSION["mois"] && date("Y", $_SESSION["totalchoixjour"][$j]) == $_SESSION["annee"]) {
|
if (date("j", $_SESSION["totalchoixjour"][$j]) == $numerojour && date("n", $_SESSION["totalchoixjour"][$j]) == $_SESSION["mois"] && date("Y", $_SESSION["totalchoixjour"][$j]) == $_SESSION["annee"]) {
|
||||||
@ -513,7 +518,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";
|
||||||
@ -525,7 +530,7 @@ if (issetAndNoEmpty('totalchoixjour', $_SESSION) || $erreur)
|
|||||||
if (isset($errheure[$i][$j]) && $errheure[$i][$j]) {
|
if (isset($errheure[$i][$j]) && $errheure[$i][$j]) {
|
||||||
print '<td><input type=text size="10" maxlength="11" name=horaires'.$i.'[] value="'.$_SESSION["horaires$i"][$j].'" style="background-color:#FF6666;"></td>'."\n";
|
print '<td><input type=text size="10" maxlength="11" name=horaires'.$i.'[] value="'.$_SESSION["horaires$i"][$j].'" style="background-color:#FF6666;"></td>'."\n";
|
||||||
} else { //sinon la case est vide normalement
|
} else { //sinon la case est vide normalement
|
||||||
|
|
||||||
print '<td><input type=text size="10" maxlength="11" name=horaires'.$i.'[] value="'.$_SESSION["horaires$i"][$j].'"></td>'."\n";
|
print '<td><input type=text size="10" maxlength="11" name=horaires'.$i.'[] value="'.$_SESSION["horaires$i"][$j].'"></td>'."\n";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -79,10 +79,10 @@ if (GETPOST("creation_sondage_date") || GETPOST("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 (GETPOST('champdatefin') && $champdatefin) // A date was provided
|
if (GETPOST('champdatefin') && ($champdatefin > 0)) // A date was provided
|
||||||
{
|
{
|
||||||
// Expire date is not before today
|
// Expire date is not before today
|
||||||
if ($champdatefin - dol_now() > 0)
|
if ($champdatefin >= dol_now())
|
||||||
{
|
{
|
||||||
$testdate = true;
|
$testdate = true;
|
||||||
$_SESSION['champdatefin'] = dol_print_date($champdatefin,'dayrfc');
|
$_SESSION['champdatefin'] = dol_print_date($champdatefin,'dayrfc');
|
||||||
@ -90,6 +90,8 @@ if (GETPOST("creation_sondage_date") || GETPOST("creation_sondage_autre"))
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
$testdate = true;
|
$testdate = true;
|
||||||
|
//$testdate = false;
|
||||||
|
//$_SESSION['champdatefin'] = dol_print_date($champdatefin,'dayrfc');
|
||||||
//setEventMessage($langs->trans('ExpiredDate'),'errors');
|
//setEventMessage($langs->trans('ExpiredDate'),'errors');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user