<?php

if (core::ifPost("from") AND core::getPost("from") == "lottery-winners") {

    $tirageAuSort = lottery::getSortInscription(core::getPost("lottery"), core::getPost("nb_winners"));

    foreach ($tirageAuSort as $value) {
        if(lottery::setSortLottery($value["id_dossier"]) == TRUE){
            alert::recSuccess($value["prenom"] . " " . $value["nom"] . " vient d'être tiré au sort."); 
        }
    }

    if(lottery::setDateLottery(core::getPost("lottery"), core::getPost("nb_winners")) == TRUE){
        alert::recSuccess("Le tirage au sort est terminé."); 
    }

    header("Location: /lottery-".core::getPost("lottery").".html");
    exit();
} else {
    header('HTTP/1.0 401 Unauthorized');
    exit();
}

