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)
}
$month = addZero($month);
$year = addZero($year);
return $month . "/01/" . $year;;
return $month . "/01/" . $year;
}
function addZero($number)
......
......@@ -12,13 +12,17 @@
* $args - the args passed onto EM_Events::output()
*/
//initialisation des variables
$sinscrire = "S'inscrire à l'évènement >";
$inscriptions_closes = "Inscription closes";
function recup_nombre()
{
global $wpdb;
$search = "ag-adullact-2019";
$post = "post_name";
$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 . "%'";
$result = $wpdb->get_results($query);
......@@ -28,31 +32,56 @@ function recup_nombre()
global $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
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"
} else {
the_form.style.display = "block";
document.getElementById("adullact-display-mask").style.color = "white";
document.getElementById("adullact-display-mask").style.backgroundColor = "#3f7ca2"
}
}
}
else{
the_form.style.display="block";
document.getElementById("adullact-display-mask").style.color="white";
document.getElementById("adullact-display-mask").style.backgroundColor="#3f7ca2"
}
var results = document.getElementsByClassName("wpcf7");
var the_form = results[0];
the_form.style.display = "none";
var the_button = document.getElementById("adullact-display-mask");
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
}
var results = document.getElementsByClassName("wpcf7");
var the_form = results[0];
the_form.style.display="none";
var the_button = document.getElementById("adullact-display-mask");
the_button.addEventListener("click",display_mask);
</script>
} else {
//puisqu'il n'y a pas de formulaire d'inscription, on affiche simplement l'évènement.
echo $the_event;
}
\ No newline at end of file
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