Fix: date was not saved if not in future.
This commit is contained in:
parent
db091896a5
commit
41ab5a0ce2
@ -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
|
||||
@ -100,7 +100,12 @@ class Opensurveysondage extends CommonObject
|
||||
$this->cleanParameters();
|
||||
|
||||
// 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
|
||||
$sql = "INSERT INTO ".MAIN_DB_PREFIX."opensurvey_sondage(";
|
||||
|
||||
@ -30,10 +30,9 @@ require_once(DOL_DOCUMENT_ROOT."/opensurvey/fonctions.php");
|
||||
// Security check
|
||||
if (!$user->rights->opensurvey->write) accessforbidden();
|
||||
|
||||
//le format du sondage est DATE
|
||||
// Survey type is DATE
|
||||
$_SESSION["formatsondage"] = "D";
|
||||
|
||||
//traitement de l'entrée des heures dans les cases texte
|
||||
$erreur = false;
|
||||
|
||||
/*
|
||||
@ -44,15 +43,16 @@ $erreur = false;
|
||||
if (GETPOST('confirmation'))
|
||||
{
|
||||
|
||||
//On sauvegarde les heures deja entrées
|
||||
// We save hours entered
|
||||
if (issetAndNoEmpty('totalchoixjour', $_SESSION) === true && issetAndNoEmpty('nbrecaseshoraires', $_SESSION) === true)
|
||||
{
|
||||
$nbofchoice=count($_SESSION["totalchoixjour"]);
|
||||
|
||||
for ($i = 0; $i < $nbofchoice; $i++) {
|
||||
//affichage des 5 cases horaires
|
||||
for ($j = 0; $j < $_SESSION["nbrecaseshoraires"]; $j++) {
|
||||
|
||||
for ($i = 0; $i < $nbofchoice; $i++)
|
||||
{
|
||||
// Show hours choices
|
||||
for ($j = 0; $j < $_SESSION["nbrecaseshoraires"]; $j++)
|
||||
{
|
||||
$_SESSION["horaires$i"][$j] = $_POST["horaires$i"][$j];
|
||||
|
||||
$case = $j + 1;
|
||||
@ -166,16 +166,21 @@ if (GETPOST('confirmation'))
|
||||
$erreur=true;
|
||||
}
|
||||
|
||||
if (!$erreur) {
|
||||
// Add survey into database
|
||||
if (!$erreur)
|
||||
{
|
||||
$_SESSION["toutchoix"]=substr("$choixdate",1);
|
||||
|
||||
ajouter_sondage();
|
||||
}
|
||||
}
|
||||
|
||||
// Reset days
|
||||
if (GETPOST('reset')) {
|
||||
if (GETPOST('reset'))
|
||||
{
|
||||
$nbofchoice=count($_SESSION["totalchoixjour"]);
|
||||
for ($i = 0; $i < $nbofchoice; $i++) {
|
||||
for ($i = 0; $i < $nbofchoice; $i++)
|
||||
{
|
||||
for ($j = 0; $j < $_SESSION["nbrecaseshoraires"]; $j++) {
|
||||
unset($_SESSION["horaires$i"][$j]);
|
||||
}
|
||||
|
||||
@ -79,10 +79,10 @@ if (GETPOST("creation_sondage_date") || GETPOST("creation_sondage_autre"))
|
||||
$testdate = false;
|
||||
$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
|
||||
if ($champdatefin - dol_now() > 0)
|
||||
if ($champdatefin >= dol_now())
|
||||
{
|
||||
$testdate = true;
|
||||
$_SESSION['champdatefin'] = dol_print_date($champdatefin,'dayrfc');
|
||||
@ -90,6 +90,8 @@ if (GETPOST("creation_sondage_date") || GETPOST("creation_sondage_autre"))
|
||||
else
|
||||
{
|
||||
$testdate = true;
|
||||
//$testdate = false;
|
||||
//$_SESSION['champdatefin'] = dol_print_date($champdatefin,'dayrfc');
|
||||
//setEventMessage($langs->trans('ExpiredDate'),'errors');
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user