Commit b27ad9ff authored by Nathan Peraldi's avatar Nathan Peraldi

add: event displaying now depending on the date

parent c43a199d
...@@ -18,7 +18,7 @@ function actualMonthYear($plus = 0) ...@@ -18,7 +18,7 @@ function actualMonthYear($plus = 0)
} }
$month = addZero($month); $month = addZero($month);
$year = addZero($year); $year = addZero($year);
return $month . "/01/" . $year;; return $month . "/01/" . $year;
} }
function addZero($number) function addZero($number)
......
...@@ -12,13 +12,17 @@ ...@@ -12,13 +12,17 @@
* $args - the args passed onto EM_Events::output() * $args - the args passed onto EM_Events::output()
*/ */
//initialisation des variables
$sinscrire = "S'inscrire à l'évènement >";
$inscriptions_closes = "Inscription closes";
function recup_nombre() function recup_nombre()
{ {
global $wpdb; global $wpdb;
$search = "ag-adullact-2019"; $search = "ag-adullact-2019";
$post = "post_name"; $post = "post_name";
$link = $_SERVER["REQUEST_URI"]; $link = $_SERVER["REQUEST_URI"];
$search = explode("/",$link)[2]; $search = explode("/", $link)[2];
$query = "SELECT count(meta_value) as number FROM wp5304_postmeta WHERE meta_value LIKE '%" . $search . "%' && meta_value LIKE '%" . $post . "%'"; $query = "SELECT count(meta_value) as number FROM wp5304_postmeta WHERE meta_value LIKE '%" . $search . "%' && meta_value LIKE '%" . $post . "%'";
$result = $wpdb->get_results($query); $result = $wpdb->get_results($query);
...@@ -28,31 +32,56 @@ function recup_nombre() ...@@ -28,31 +32,56 @@ function recup_nombre()
global $EM_Event; global $EM_Event;
/* @var $EM_Event EM_Event */ /* @var $EM_Event EM_Event */
recup_nombre(); $the_event = $EM_Event->output_single();
echo str_replace("Carte non disponible","",$EM_Event->output_single()); ?> //on enlève ce texte inutile de cette manière car aucun moyen de faire autrement !
$the_event = str_replace("Carte non disponible", "", $the_event);
<script> //si "button" détecté, alors on s'occupe du formulaire d'inscription
if (strpos($the_event, "BUTTON") !== false) {
recup_nombre();
//on se prépare à comparer la date actuelle avec la date de l'évènement pour ouvrir / fermer les inscriptions.
$timestamp_event = strtotime($EM_Event->start_date);
$timestamp_actual = time();
if ($timestamp_event > $timestamp_actual) {
$the_event = str_replace("BUTTON", "<button id='adullact-display-mask'>" . $sinscrire . "</button>", $the_event);
echo $the_event;
?>
<script>
//on effectue les opérations pour afficher / cacher le formulaire d'inscription à l'évènement
function display_mask() {
if (the_form.style.display === "block") {
the_form.style.display = "none";
document.getElementById("adullact-display-mask").style.color = "dimgrey";
document.getElementById("adullact-display-mask").style.backgroundColor = "white"
//on effectue les opérations pour afficher / cacher le formulaire d'inscription à l'évènement } else {
function display_mask(){ the_form.style.display = "block";
if (the_form.style.display==="block"){ document.getElementById("adullact-display-mask").style.color = "white";
the_form.style.display="none"; document.getElementById("adullact-display-mask").style.backgroundColor = "#3f7ca2"
document.getElementById("adullact-display-mask").style.color="dimgrey"; }
document.getElementById("adullact-display-mask").style.backgroundColor="white" }
} var results = document.getElementsByClassName("wpcf7");
else{ var the_form = results[0];
the_form.style.display="block"; the_form.style.display = "none";
document.getElementById("adullact-display-mask").style.color="white"; var the_button = document.getElementById("adullact-display-mask");
document.getElementById("adullact-display-mask").style.backgroundColor="#3f7ca2" the_button.addEventListener("click", display_mask);
} </script>
<?php
} else {
$the_event = str_replace("BUTTON", "<button id='adullact-display-mask'>" . $inscriptions_closes . "</button>", $the_event);
echo $the_event;
?>
<script>
var results = document.getElementsByClassName("wpcf7");
var the_form = results[0];
var the_parent = document.getElementsByClassName("entry-content")[0];
the_parent.removeChild(the_form);
</script>
<?php
} }
} else {
var results = document.getElementsByClassName("wpcf7"); //puisqu'il n'y a pas de formulaire d'inscription, on affiche simplement l'évènement.
var the_form = results[0]; echo $the_event;
the_form.style.display="none"; }
var the_button = document.getElementById("adullact-display-mask"); \ No newline at end of file
the_button.addEventListener("click",display_mask);
</script>
Markdown is supported
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