# NODE.JS

## DÉMARRAGE DU PROJET
    cd /Users/juliechaumard/Documents/GitHub/Aduzuki_v2
    npm start

# DOCUMENTATION
- Dans ce dossier sous /documentation
- MindMap : GoogleDrive-juliechaumard@gmail.com/Mon Drive/Projets/Suzuki/Adusuki/dev
- Notion

# DOMAIN
    inscription.afpedagogiesuzuki.fr
DOMAIN_EXTERNE="https://inscription.afpedagogiesuzuki.fr/"


# SITE DE DEV

## NEW
### URL
aduzuki.darkweb.land



# URLs

## ACCUEIL
    https://www.adhesion.afpedagogiesuzuki.fr/inscription/accueil

## FORMULAIRE ADHÉSION
    http://localhost:8890/adhesion
    https://www.adusuki.juliechaumard.paris/adhesion
    https://inscription.afpedagogiesuzuki.fr/adhesion
    

### GESTION DES ADHÉSION
    https://inscription.afpedagogiesuzuki.fr/adhesion/maj_googlesheet
    https://www.inscription.afpedagogiesuzuki.fr/adhesion/maj_googlesheet

## ENVOIE CARTE ADHÉRENT ET JUSTIFICATIF DE DON MANUEL
    http://localhost:8888/inscription/adhesion/carte_manuelle
    https://www.adusuki.juliechaumard.paris/inscription/adhesion/carte_manuelle
    https://inscription.afpedagogiesuzuki.fr/adhesion/carte_manuelle

## SYNC PROF ANNUAIRE ADUZUKI <=> STRAPI
    http://localhost:8890/adhesion/sync_prof_strapi
    https://inscription.afpedagogiesuzuki.fr/adhesion/sync_prof_strapi

## STAGE ANNUEL
    http://localhost:8890/stagenational
    https://adusuki.juliechaumard.paris/stagenational
    https://inscription.afpedagogiesuzuki.fr/stagenational

### GESTION DU STAGE
    https://www.inscription.afpedagogiesuzuki.fr/adhesion/admin

## RASSEMBLEMENT IDF
    http://localhost:8890/rassemblementidf
    https://www.adusuki.juliechaumard.paris/rassemblementidf
    https://inscription.afpedagogiesuzuki.fr/rassemblementidf

## RASSEMBLEMENT RA
    http://localhost:8890/rassemblementra
    https://adusuki.juliechaumard.paris/rassemblementra
    https://inscription.afpedagogiesuzuki.fr/rassemblementra

## CONCERT UNESCO
    http://localhost:8890/concert
    https://www.adusuki.juliechaumard.paris/concert
    https://www.inscription.afpedagogiesuzuki.fr/concert
    https://inscription.afpedagogiesuzuki.fr/
    https://inscription.afpedagogiesuzuki.fr/concert/concert_paiement/annule?id={CHECKOUT_SESSION_ID}
    https://inscription.afpedagogiesuzuki.fr/concert/concert_paiement/reussi?id={CHECKOUT_SESSION_ID}

## BOUTIQUE
### VIDÉOS
    https://inscription.afpedagogiesuzuki.fr/boutique/videos


# MISE EN PROD
- varirable d'environnement pour stipe dans les controllers l'envoi vers Stripe et celui de retour de Stripe (STRIPE_PRIVATE_KEY, STRIPE_PRIVATE_KEY_TEST)


## DEV

### GNROK
    https://bf89-2a01-e0a-5ee-1510-4021-f309-9a2c-823.ngrok-free.app/wh_stripe
    https://9243-2a01-e0a-5ee-1510-4c7b-ac31-5c89-f077.ngrok-free.app

## MODULES
    npm-node14 install htmltopdf-weasyprint


        
# ABBRÉVIATIONS
SN ou stn = STAGE NATIONAL

# LOGGING
Exemples de traces

    N'importe où
        logger.info("NOUS SOMMES DANS LE FICHIER : " + __filename,
 { label: __filename });

    Dans une fonction req res :
        logger.info('bonjour Julie',
 { numsession: req.session.id });
        logger.info('process.env.PORT : ' + process.env.PORT),
 { numsession: req.session.id }, { label: __filename };


        logger.info("XXX" + ZZZ, { numsession: req.session.id }, { label: __filename });


# ENV
Si on change une variable d'environnement, il faut redémarrer le projet

# HTACCESS
--ORIGINAL
RewriteEngine On
RewriteCond %{ENV:HTTPS} !on
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

# PDF
    try {
        var pdf_html = fs.readFileSync(path.resolve(__dirname,"../pdf/template/carte_adherent.html"), "utf8");
        var pdf_buffer = await weasyprint(pdf_html);
        fs.writeFileSync("juju.pdf", pdf_buffer);
    } catch (error) {
        logger.info("Erreur durant la création du PDF : " + error, { numsession: req.session.id });
    }

# STRIPE
TEST CARD

    ok normal
    4242424242424242
    4242 4242 4242 4242

    ok 3DS
    4000000000003063

    pb
    4000000000000002

RETOUR
    https://www.adusuki.afpedagogiesuzuki.fr/inscription/adhesion_paiement/reussi?id=cs_test_b1teU2a5wbTFwdPKGefvrKS1N6deBGPK86xFhdbxqKo9dtmgCzwoYZ8fJ6

Rassemblement Rhône-Alpes
25€ ou 40€



# INSCRIPTION MAJ Google Sheet automatique
CRON
- le cron est lancé par la librairie cron de NodeJS
- fichier modules/adhesion/majgs_webhook.js
- mise en prod
    - ne pas oublier de changer l'URL à lancer dans le fichier majgs_webhook.js : commenter l'URL de dev localhost et décommenter l'URL de prod
    - pm2 start /var/www/aduzuki/modules/adhesion/majgs_webhook.js --name majgs_webhook


# MAINTENANCE
## ADHESION REQUETE SAISON

> [!NOTE]
> Vérifier que le champ saison soit au bon format

```sql
    SELECT *
    FROM aduzuki.adherent_professeur
    WHERE saison != '2025/2026'

    UPDATE aduzuki.adherent_professeur
    SET saison = '2025/2026'
    WHERE saison != '2025/2026'

# DATABASE

## Stage NATIONAL
CREATE TABLE `stn_participant` (
  `ID_participant` int NOT NULL AUTO_INCREMENT,
  `identifiant` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `date_maj` datetime DEFAULT NULL,
  `stn_part_nom` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `stn_part_prenom` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `prise_charge_famille` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `stn_part_date_naiss` varchar(10) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `stn_part_age` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `stn_part_profilage` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `stn_role` varchar(200) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `stn_profil` varchar(200) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `stn_transport` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `stn_arret` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `instrument` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `instrument_ensemble` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `instrument_collectif` varchar(50) COLLATE utf8mb4_unicode_520_ci DEFAULT NULL,
  `cahier` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `piece` varchar(200) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `prof_nom` varchar(200) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `prof_mail` varchar(200) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `concert_solo_piece` varchar(200) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `concert_solo_cahier` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `cours_individuel` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `decouverte_alto` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `option_choral` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `option_rythmique` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `option_eveil` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `option_collectif` varchar(40) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_520_ci DEFAULT NULL,
  `option_ensemble` varchar(40) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_520_ci DEFAULT NULL,
  `option_particulier` varchar(40) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_520_ci DEFAULT NULL,
  `cout_hebergement` int DEFAULT NULL,
  `cout_transport` int DEFAULT NULL,
  `eveil_cout` int DEFAULT NULL,
  `dalcroze_cout` int DEFAULT NULL,
  `collectif_cout` int DEFAULT NULL,
  `ensemble_cout` int DEFAULT NULL,
  `particulier_cout` int DEFAULT NULL,
  `observation_cout` int DEFAULT NULL,
  `cours_cout` int DEFAULT NULL,
  `coursindividuel_cout` int DEFAULT NULL,
  `decouvrealto_cout` int DEFAULT NULL,
  `chant_cout` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_520_ci DEFAULT NULL,
  `statut_suppression` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_520_ci DEFAULT NULL,
  PRIMARY KEY (`ID_participant`)
) ENGINE=InnoDB AUTO_INCREMENT=393 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_520_ci