<?php 
if(session::isConnect("salarie")){
    $evenements = event::presentEvenement(session::getId("salarie"));
    if (empty($evenements)) {
        echo json_encode(array(NULL));
    } else {
        $return = array();
        foreach ($evenements as $nb => $ev) {
            $ev["nb"] = $nb;
            $ev["url_qrcode"] = core::base64_url_encode("https://" . DOMAIN_CONTROL . "/json.php?jsonData=check-control-emargement&s=".session::getId("salarie")."&e=".$ev["md5"]."&k=".md5($ev["md5"].session::getValue("sel", "salarie"))); 
            $ev["startDate"] = core::convertDate($ev["startDate"]);
            $ev["endDate"] = core::convertDate($ev["endDate"]);
            $ev["present"] = (isset($ev["present"])) ? core::convertDate($ev["present"]) : NULL;
            $return[] = $ev;       
        }
        echo json_encode($return);
    }
}
