/*
  MSIN - Acces evenement v2 - Exemple pilote (MANUEL)

  NE PAS executer tel quel : remplacer com_id et eve_id.
  Executer UN bloc a la fois dans votre client SQL.
*/


/*
  Etape A - Verifications

  SELECT com_id, com_courriel FROM inscriptions_comptes WHERE com_courriel = 'pilote@example.com';
  SELECT eve_id, eve_nom_fr FROM inscriptions_evenements WHERE eve_id = 1234;
  SELECT role_id, role_code, role_label_fr FROM inscriptions_eve_roles WHERE role_actif = 1;
*/


/*
  Etape B - Acces pilote gestion inscriptions 30 jours

INSERT INTO inscriptions_eve_acces
  (com_id, eve_id, role_id, ea_statut, ea_expires_at, ea_expire_days, ea_granted_by, ea_note)
SELECT
  15464,
  1234,
  r.role_id,
  'actif',
  DATE_ADD(NOW(), INTERVAL 30 DAY),
  30,
  1,
  'Pilote prod - gestion inscriptions v2'
FROM inscriptions_eve_roles r
WHERE r.role_code = 'gestion_ops'
LIMIT 1;
*/


/*
  Etape C - Validation

  SELECT * FROM v_eve_acces_actif WHERE com_id = 15464;
  SELECT * FROM v_eve_acces_permissions WHERE com_id = 15464 AND eve_id = 1234;
  SELECT com_id, com_eve_promoteur FROM inscriptions_comptes WHERE com_id = 15464;
*/


/*
  Etape D - Revocation (sans toucher au legacy)

UPDATE inscriptions_eve_acces
SET ea_statut = 'revoke',
    ea_revoked_at = NOW(),
    ea_revoked_by = 1
WHERE com_id = 15464 AND eve_id = 1234;

INSERT INTO inscriptions_eve_acces_log
  (ea_id, com_id, eve_id, role_id, log_action, log_detail, log_by_com_id)
SELECT ea_id, com_id, eve_id, role_id, 'revoke', 'Revoke manuel - fin pilote', 1
FROM inscriptions_eve_acces
WHERE com_id = 15464 AND eve_id = 1234;
*/
