|
|
@@ -31,6 +31,95 @@ class event
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ public static function add()
|
|
|
+ {
|
|
|
+ db::query("INSERT INTO " . DB_T_EVENTS . " (md5, titre, description, startDate, endDate, type_emargement, type_inscription, actif, id_user) VALUES (:md5, :titre, :description, :startDate, :endDate, :type_emargement, :type_inscription, :actif, :id_user)");
|
|
|
+
|
|
|
+ db::bind(':md5', md5(time().rand(1000000000, 9999999999)));
|
|
|
+ db::bind(':titre', core::getPost("titre"));
|
|
|
+ db::bind(':description', core::getPost("description"));
|
|
|
+ db::bind(':startDate', core::getPost("startDate"));
|
|
|
+ db::bind(':endDate', core::getPost("endDate"));
|
|
|
+ db::bind(':type_emargement', core::getPost("type_emargement"));
|
|
|
+ db::bind(':type_inscription', core::getPost("type_inscription"));
|
|
|
+ db::bind(':actif', core::getPost("actif"));
|
|
|
+ db::bind(':id_user', session::getId());
|
|
|
+
|
|
|
+ try {
|
|
|
+ db::execute();
|
|
|
+ return TRUE;
|
|
|
+ } catch (Exception $ex) {
|
|
|
+ return FALSE;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ public static function update()
|
|
|
+ {
|
|
|
+ db::query("UPDATE " . DB_T_EVENTS . " SET "
|
|
|
+ . "titre = :titre, "
|
|
|
+ . "description = :description, "
|
|
|
+ . "startDate = :startDate, "
|
|
|
+ . "endDate = :endDate, "
|
|
|
+ . "type_emargement = :type_emargement, "
|
|
|
+ . "type_inscription = :type_inscription, "
|
|
|
+ . "actif = :actif, "
|
|
|
+ . "id_user = :id_user "
|
|
|
+ . "WHERE id = :id");
|
|
|
+
|
|
|
+ db::bind(':titre', core::getPost("titre"));
|
|
|
+ db::bind(':description', core::getPost("description"));
|
|
|
+ db::bind(':startDate', core::getPost("startDate"));
|
|
|
+ db::bind(':endDate', core::getPost("endDate"));
|
|
|
+ db::bind(':type_emargement', core::getPost("type_emargement"));
|
|
|
+ db::bind(':type_inscription', core::getPost("type_inscription"));
|
|
|
+ db::bind(':actif', core::getPost("actif"));
|
|
|
+ db::bind(':id_user', session::getId());
|
|
|
+ db::bind(':id', core::getPost("id"));
|
|
|
+
|
|
|
+ try {
|
|
|
+ db::execute();
|
|
|
+ return TRUE;
|
|
|
+ } catch (Exception $ex) {
|
|
|
+ return FALSE;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ public static function subscribe(int $_salarie = NULL)
|
|
|
+ {
|
|
|
+ if($_salarie == NULL){
|
|
|
+ $salarie = core::getPost("salarie");
|
|
|
+ } else {
|
|
|
+ $salarie = $_salarie;
|
|
|
+ }
|
|
|
+
|
|
|
+ db::query("INSERT INTO " . DB_T_EVENTS_INSCRITS . " (id_evenement, id_salarie, sel, id_user) VALUES (:id_evenement, :id_salarie, :sel, :id_user)");
|
|
|
+ db::bind(':sel', md5(core::getPost("event")."-".time().rand(100000000000000, 999999999999999)));
|
|
|
+ db::bind(':id_evenement', core::getPost("event"));
|
|
|
+ db::bind(':id_salarie', $salarie);
|
|
|
+ db::bind(':id_user', session::getId());
|
|
|
+
|
|
|
+ try {
|
|
|
+ db::execute();
|
|
|
+ return TRUE;
|
|
|
+ } catch (Exception $ex) {
|
|
|
+ return FALSE;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ public static function unsubscribe()
|
|
|
+ {
|
|
|
+ db::query("DELETE FROM " . DB_T_EVENTS_INSCRITS . " WHERE id_evenement = :id_evenement AND id_salarie = :id_salarie");
|
|
|
+ db::bind(':id_evenement', core::getPost("event"));
|
|
|
+ db::bind(':id_salarie', core::getPost("salarie"));
|
|
|
+
|
|
|
+ try {
|
|
|
+ db::execute();
|
|
|
+ return TRUE;
|
|
|
+ } catch (Exception $ex) {
|
|
|
+ return FALSE;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
public static function getEvents()
|
|
|
{
|
|
|
db::query("SELECT "
|
|
|
@@ -211,6 +300,8 @@ class event
|
|
|
return db::resultset();
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+
|
|
|
public static function checkEvenementBySalarie(string $_md5)
|
|
|
{
|
|
|
|
|
|
@@ -250,9 +341,6 @@ class event
|
|
|
db::bind(':md5', $_md5);
|
|
|
$evenement = db::single();
|
|
|
|
|
|
- // print_r($inscription); echo "<br />";
|
|
|
- // print_r($evenement); echo "<br />";
|
|
|
-
|
|
|
if ($salarie["id"] == NULL) {
|
|
|
$return["result"] = FALSE;
|
|
|
$return["description"] = "Vous n'êtes pas un salarié rattaché à notre CSE";
|
|
|
@@ -316,7 +404,6 @@ class event
|
|
|
|
|
|
public static function emargementEvenementByQRCode()
|
|
|
{
|
|
|
-
|
|
|
$idSalarie = core::getGet("s");
|
|
|
$md5Evenement = core::getGet("e");
|
|
|
$key = core::getGet("k");
|