Commit 5a70f6c1 authored by Loïc DAYOT's avatar Loïc DAYOT
Browse files

fix(): default date in campaign administration

Now dates in new campaign edit form are around today.
parent 4603eee9
......@@ -43,74 +43,74 @@ $id = get_safe_integer('id', 0);
switch ($op) // compute
{
case "update" :
{
$campaign = new campaign($db, $id);
$campaign = new campaign($db, $id);
$campaign->fromForm();
if (! $campaign->check())
{
// affichage des erreurs
echo $campaign->message;
$op = 'edit2';
} else {
// affichage des avertissements s'il y en a
echo $campaign->message;
if ($campaign->is_preview) { // prévisualisation
echo "<h3>Prévisualisation</h3>";
echo $campaign->formatHtml();
$op='edit2';
} else { // enregistrement
if ($campaign->save())
{
header("Location: campaigns.php?op=saved&id={$campaign->id}");
exit;
} else {
echo $campaign->message;
$op='edit2';
}
}
}
break;
if (! $campaign->check())
{
// affichage des erreurs
echo $campaign->message;
$op = 'edit2';
} else {
// affichage des avertissements s'il y en a
echo $campaign->message;
if ($campaign->is_preview) { // prévisualisation
echo "<h3>Prévisualisation</h3>";
echo $campaign->formatHtml();
$op='edit2';
} else { // enregistrement
if ($campaign->save())
{
header("Location: campaigns.php?op=saved&id={$campaign->id}");
exit;
} else {
echo $campaign->message;
$op='edit2';
}
}
}
break;
}
case 'saved' :
{
echo "<p>Campagne enregistrée.</p>";
$op='info';
break;
}
case 'saved' :
{
echo "<p>Campagne enregistrée.</p>";
$op='info';
break;
}
case "delete" :
{
$campaign = new campaign($db, $id);
$campaign->fromConfirmDelFormHtml();
if ($campaign->error)
{
echo $campaign->message;
$id = $campaign->id;
$op='info';
} else {
if ($campaign->delete())
{
header("Location: campaigns.php?op=deleted");;
exit;
} else {
echo $campaign->message;
$id= $campaign->id;
$op='info';
}
}
$campaign = new campaign($db, $id);
$campaign->fromConfirmDelFormHtml();
if ($campaign->error)
{
echo $campaign->message;
$id = $campaign->id;
$op='info';
} else {
if ($campaign->delete())
{
header("Location: campaigns.php?op=deleted");;
exit;
} else {
echo $campaign->message;
$id= $campaign->id;
$op='info';
}
}
break;
}
case "deleted" :
{
echo "<p>Campagne supprimée.</p>";
$op="list";
break;
}
echo "<p>Campagne supprimée.</p>";
$op="list";
break;
}
} // end switch compute
......@@ -120,44 +120,47 @@ switch ($op) // display
case "del" :
{
echo "<h3>Suppression d'une campagne</h3>";
$campaign = new campaign($db, $id);
echo "<h3>Suppression d'une campagne</h3>";
$campaign = new campaign($db, $id);
echo $campaign->confirmDelFormHtml($id);
break;
}
case "new" :
{
echo "<h3>Édition d'une nouvelle campagne</h3>";
$campaign = new campaign($db, 0);
echo $campaign->formHtml(false);
echo "<h3>Édition d'une nouvelle campagne</h3>";
$campaign = new campaign($db, 0);
$campaign->start = time();
$campaign->end = $campaign->start + 60*60*24;
$campaign->tag_explainstart = $campaign->start - 60*60*24*7;
echo $campaign->formHtml(false);
break;
}
case "dupl" :
{
$campaign = new campaign($db, $id);
echo "<h3>Édition d'après une campagne existante</h3>";
$campaign = new campaign($db, $id);
echo "<h3>Édition d'après une campagne existante</h3>";
echo $campaign->formHtml(true);
break;
}
case "edit" :
{
$campaign = new campaign($db, $id);
$campaign = new campaign($db, $id);
}
case "edit2" :
{
echo "<h3>Édition</h3>";
echo "<h3>Édition</h3>";
echo $campaign->formHtml(false);
break;
}
case "info" :
{
echo $campaigns->formatHtml($id);
break;
}
case "info" :
{
echo $campaigns->formatHtml($id);
break;
}
default : // list campagnes
{
......
......@@ -177,9 +177,7 @@ class campaign {
$html.= "<input type='hidden' name='camp[id]' value='{$this->id}' />";
$html.= "<input type='hidden' name='id' value='{$this->id}' />";
}
$html .= "<tr class='odd'><td>Nom*</td><th><input type='text' required name='camp[name]' value=\"".
stripslashes(htmlentities($this->name)).
"\" title=\"Saisir un nom de préférence unique qui servira de code pour reconnaître la campagne.\"/></th></tr>\n";
$html .= "<tr class='odd'><td>Nom*</td><th><input type='text' required name='camp[name]' value='{$this->name}' title=\"Saisir un nom de préférence unique qui servira de code pour reconnaître la campagne.\"/></th></tr>\n";
$html .= "<tr><td>Période*</td><th>".
"du <input type='date' required name=camp[start] value='". date_timestamp2mysqldate($this->start). "' title=\"Date de début de la campagne, au format MYSQL aaaa-mm-jj.\" />".
"<br/> au <input type='date' required name=camp[end] value='". date_timestamp2mysqldate($this->end). "' title=\"Date de fin de la campagne, au format jj/mm/aaaa.\" /></th></tr>\n";
......@@ -197,7 +195,7 @@ class campaign {
"Tag&nbsp;: <input type='text' name='camp[tag]' title=\"Saisir le tag associté à la campagne.\" value=\"". $this->tag. "\" />".
"<br />Message&nbsp;: <textarea name='camp[tag_messagehtml]' cols=80 rows=6 title=\"Ecrire le code HTML du message qui apparaîtra lorsqu'un événement portera le tag.\">". stripslashes(htmlentities($this->tag_messagehtml)). "</textarea>".
"<br />Explication à la saisie&nbsp;: <textarea name='camp[tag_explainhtml]' cols=80 rows=6 title=\"Ecrire le code HTML du message d'explication lors de la saisie des tags.\">". stripslashes(htmlentities($this->tag_explainhtml)). "</textarea>".
"<br/>À partir du&nbsp: <input type='date' name=camp[tag_explainstart] value='". date("d/m/Y", $this->tag_explainstart). "' title=\"Date de début d'affichage de l'explication du tag, au format MYSQL aaaa-mm-jj.\" />".
"<br/>À partir du&nbsp: <input type='date' name=camp[tag_explainstart] value='". date_timestamp2mysqldate($this->tag_explainstart). "' title=\"Date de début d'affichage de l'explication du tag, au format MYSQL aaaa-mm-jj.\" />".
"</td></tr>\n";
$html .= "<tr><th></th><th><input type=\"submit\" name=\"camp[preview]\" value=\"". _("Prévisualisation"). "\" /> <input type=\"submit\" name=\"submit\" value=\"". _("Enregistrement"). "\" /></th></tr>\n";
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment