import atexit

from flask import make_response, request, current_app, Flask, jsonify
from functools import update_wrapper
import json

import strype_payement
import wrapper as wp
import ela_user_account as eua
import prj_common as pc
from six import string_types
from datetime import timedelta
import Ela_Spacy as ls
import user_message_mgt as um
import user_session as us
import partners as pa
import prj_common as mycommon
import ela_index_bdd_classes as ela_index_class
import class_mgt as cm
import Dev_api_functions as dev_function
from flask_cors import CORS, cross_origin
import time
from OpenSSL import SSL
from flask import redirect
from flask import Flask, render_template, request, redirect, url_for
import articles_avis as aa
import GlobalVariable as MYSY_GV
import youtubes_analyse as YTA
import test_perso as TP
import ela_factures_mgt as invoice
import product_service as PS
import ela_factures_mgt as factures
import statistics as Stat
import strype_payement as Stripe
import Inscription_mgt as inscription
import emargement as emargement
import Session_Formation as SF
import email_mgt as emails
import email_inscription_mgt as emails_support
import opco as opco
import Attestation_Certificat as Att_Cert
import tools_cherif.tools_cherif as tools_cherif
import business_prices as business_prices
import lms_chamilo.mysy_lms as mysy_lms
import code_promo_mgt as code_promo_mgt
from apscheduler.schedulers.background import BackgroundScheduler
import appel_offre as appel_offre
import partner_client as partner_client
import Contact as Contact
import Activite as Activite
import ressources_humaines as ressources_humaines
import ressources_materiels as ressources_materiels
import partner_order as partner_order
import partner_document_mgt as partner_document_mgt
import user_access_right as user_access_right
import partner_invoice as partner_invoice
import partner_base_setup as partner_base_setup
import attached_file_mgt as attached_file_mgt
import base_specific_fields as base_specific_fields
import agenda as agenda
import base_partner_session_step as base_partner_session_step
import Session_Formation_Sequence as Session_Formation_Sequence

import base_config_modele_journee as base_config_modele_journee
import Dashbord_queries.session_tbd_qries  as session_tbd_qries
import Dashbord_queries.common_tdb_qries as common_tdb_qries
import Dashbord_queries.formation_tbd_qries as formation_tbd_qries
import Dashbord_queries.ressources_humaines_tbd_qries as ressources_humaines_tbd_qries
import Dashbord_queries.inscription_tdb_qries as inscription_tdb_qries


import Collection_Historique as Collection_Historique
import purchase_prices as purchase_prices
import apprenant_mgt as apprenant_mgt
import module_editique as module_editique
import attestation_formation as attestation_formation
import crm_opportunite as crm_opportunite
import site_formation as site_formation
import paiement_condition as paiement_condition
import E_Sign_Document as E_Sign_Document
import competence as competence
import formulaire_mgt as formulaire_mgt
import survey_mgt as survey_mgt


app = Flask(__name__)
cors = CORS(app, resources={r"/foo": {"origins": "*"}})
app.config['CORS_HEADERS'] = 'Content-Type'
app.config['UPLOAD_FOLDER'] = MYSY_GV.upload_folder
app.env = "Production"
app.debug = "Production"

@app.before_request
def before_request():
    if mycommon.check_source_ipv4(str(request.remote_addr)) is False:
        return "Security check : '" + request.remote_addr + "' is not autorized", 404


def crossdomain(origin=None, methods=None, headers=None, max_age=21600,
                attach_to_all=True, automatic_options=True):
    """Decorator function that allows crossdomain requests.
      Courtesy of
      https://blog.skyred.fi/articles/better-crossdomain-snippet-for-flask.html
    """
    if methods is not None:
        methods = ', '.join(sorted(x.upper() for x in methods))
    # use str instead of basestring if using Python 3.x
    if headers is not None and not isinstance(headers, str):
        headers = ', '.join(x.upper() for x in headers)
    # use str instead of basestring if using Python 3.x
    if not isinstance(origin, str):
        origin = ', '.join(origin)
    if isinstance(max_age, timedelta):
        max_age = max_age.total_seconds()

    def get_methods():
        """ Determines which methods are allowed
        """
        if methods is not None:
            return methods

        options_resp = current_app.make_default_options_response()
        return options_resp.headers['allow']

    def decorator(f):
        """The decorator function
        """
        def wrapped_function(*args, **kwargs):
            """Caries out the actual cross domain code
            """
            if automatic_options and request.method == 'OPTIONS':
                resp = current_app.make_default_options_response()
            else:
                resp = make_response(f(*args, **kwargs))
            if not attach_to_all and request.method != 'OPTIONS':
                return resp

            h = resp.headers
            h['Access-Control-Allow-Origin'] = origin
            h['Access-Control-Allow-Methods'] = get_methods()
            h['Access-Control-Max-Age'] = str(max_age)
            h['Access-Control-Allow-Credentials'] = 'true'
            h['Access-Control-Allow-Headers'] = \
                "Origin, X-Requested-With, Content-Type, Accept, Authorization"
            if headers is not None:
                h['Access-Control-Allow-Headers'] = headers
            return resp

        f.provide_automatic_options = False
        return update_wrapper(wrapped_function, f)
    return decorator

@app.after_request
def after_request(response):
  response.headers.add('Access-Control-Allow-Headers', 'Content-Type,Authorization')
  response.headers.add('Access-Control-Allow-Methods', 'GET,PUT,POST,DELETE,OPTIONS')

  return response



'''
cette API gere le login et la creation du token
'''
@app.route('/myclass/api/login/', methods=['POST','GET'])
@crossdomain(origin='*')
def login():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### payload = ",payload)
    status, retval = us.login(payload)
    return jsonify(status=status, message=retval)



'''
cette API recupere les objectifs d'un utilisateur

La clé est l'adresse email.
si le nom de la formation est fourni, alors l'api va retourner la formation donnée
'''
@app.route('/myclass/api/get_user_objectif/', methods=['POST','GET'])
@crossdomain(origin='*')
def get_user_objectif():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### get_user_objectif  : payload = ",payload)
    status, retval = eua.get_user_objectif(payload)
    return jsonify(status=status, message=retval)


'''
Cette API desactive un objectif.
les clés sont : 
- adresse email
- nom de l'objectif

'''
@app.route('/myclass/api/desable_user_objectif/', methods=['POST'])
@crossdomain(origin='*')
def desable_user_objectif():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### payload = ",payload)
    status, retval = eua.desable_user_objectif(payload)
    return jsonify(status=status, message=retval)



'''
Cette API recupere l'historique de recherche
d'un utilisateur
'''
@app.route('/myclass/api/get_user_recherche_history/', methods=['POST','POST'])
@crossdomain(origin='*')
def get_user_recherche_history():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### payload = ",payload)
    status, retval = eua.get_user_recherche_history(payload)
    return jsonify(status=status, message=retval)


'''
Cette API ajoute un objectif à un utilisateur
la clé est l'adresse email
'''
@app.route('/myclass/api/add_update_user_objectif/', methods=['POST'])
@crossdomain(origin='*')
def add_update_user_objectif():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### add_update_user_objectif payload = ",payload)
    status, retval = eua.add_update_user_objectif(payload)  
    return jsonify(status=status, message=retval)


"""
Cette API met à jour le profile d'un utilisateur
"""
@app.route('/myclass/api/add_update_user_profile/', methods=['POST'])
@crossdomain(origin='*')
def add_update_user_profile():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### add_update_user_profile : payload = ",payload)
    status, retval = eua.add_update_user_profile(payload)
    return jsonify(status=status, message=retval)

"""
API de recuperation du profils d'un utilisateur
"""
@app.route('/myclass/api/Get_user_profile/', methods=['POST','GET'])
@crossdomain(origin='*')
def Get_user_profile():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### Get_user_profile : payload = ",payload)
    status, retval = eua.Get_user_profile(payload)
    return jsonify(status=status, message=retval)
'''
Cette Api retourne les info d'un user accout identifié par 
son adresse email.
'''
@app.route('/myclass/api/get_user_account/', methods=['POST','GET'])
@crossdomain(origin='*')
def get_user_account():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### get_user_account : payload = ", payload)
    result, message = eua.get_user_account(payload)
    return jsonify(status=result, message=message)


'''
Cette API créer un compte utilisateur et declenche l'envoi de l'email de notification
'''
@app.route('/myclass/api/add_user_account/', methods=['POST'])
@crossdomain(origin='*')
def add_user_account():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### payload = ",payload)
    result, message = eua.add_user_account(payload)
    return jsonify(status=result, message=message)


'''
Cette API valide une inscription d'un user
'''
@app.route('/myclass/api/valide_user_account/<value>', methods=['GET','POST'])
@crossdomain(origin='*')
def valide_user_account(value):

    print(" ### validation du compte = ",value)
    status, retval = eua.valide_user_account(value)

    url = ""
    if( status ):
        if (MYSY_GV.MYSY_ENV == "PROD"):
            url = 'https://www.mysy-training.com/mysy-account-activated/'
        elif (MYSY_GV.MYSY_ENV == "DEV"):
            url = 'http://localhost:3009/mysy-account-activated/'
        elif (MYSY_GV.MYSY_ENV == "REC"):
            url = 'https://dev.mysy-training.com/mysy-account-activated/'

        elif (MYSY_GV.MYSY_ENV == "DEM"):
            url = 'https://demo.mysy-training.com/mysy-account-activated/'

    else:
        if (MYSY_GV.MYSY_ENV == "PROD"):
            url = 'https://www.mysy-training.com/erreur'

        elif (MYSY_GV.MYSY_ENV == "DEV"):
            url = 'http://localhost:3009/erreur/'

        elif (MYSY_GV.MYSY_ENV == "REC"):
            url = 'https://dev.mysy-training.com/erreur'

        elif (MYSY_GV.MYSY_ENV == "DEM"):
            url = 'https://demo.mysy-training.com/erreur'

    return  redirect(url)


'''
Cette api met à jour un compte utilisateur
'''
@app.route('/myclass/api/update_user_account/', methods=['POST','GET'])
@crossdomain(origin='*')
def update_user_account():
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### payload = ", payload)
    status, retval = eua.update_user_account(payload)
    return jsonify(status=status, message=retval)


@app.route('/myclass/api/create_class/', methods=['POST','GET'])
@crossdomain(origin='*')
def create_class():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### payload = ",payload)
    status, retval = cm.add_class(payload)
    return jsonify(status=status, message=retval)



'''
Cette api recupete et affiche une formation.
la clé d'une formation est le code externe, 
mais pour que l'api fonctionne, il faut lui fournir

- le token du partenaire
'''
@app.route('/myclass/api/get_class/', methods=['POST','GET'])
@crossdomain(origin='*')
def get_class():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### get_class : payload = ",str(payload)+"  IP requester = "+str(request.remote_addr))
    status, retval = cm.get_class(payload)
    return jsonify(status=status, message=retval)

"""
Cette API retourne les X formations du meme organisme de formations
associé à une formation données : current_internal_code

limit : X
condition : internal_url != current_internal_code
partner_owner_recid = current_partner_owner_recid

"""
@app.route('/myclass/api/get_associated_class_of_partnair/', methods=['POST','GET'])
@crossdomain(origin='*')
def get_associated_class_of_partnair():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### payload = ",str(payload)+"  IP requester = "+str(request.remote_addr))
    status, retval = cm.get_associated_class_of_partnair(payload)
    return jsonify(status=status, message=retval)


'''
Cette api recupete la formation d'un partenaire donnée
elle est appelée exclusivement en mode connecté

- le token du partenaire
'''
@app.route('/myclass/api/get_partner_class/', methods=['POST','GET'])
@crossdomain(origin='*')
def get_partner_class():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### get_partner_class payload = ",str(payload)+"  IP requester = "+str(request.remote_addr))
    status, retval = cm.get_partner_class(payload)
    return jsonify(status=status, message=retval)

"""
Cette API fait une recherche au sens large avec des like
"""
@app.route('/myclass/api/find_partner_class_like/', methods=['POST','GET'])
@crossdomain(origin='*')
def find_partner_class_like():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### find_partner_class_like payload = ",str(payload)+"  IP requester = "+str(request.remote_addr))
    status, retval = cm.find_partner_class_like(payload)
    return jsonify(status=status, message=retval)




"""
Cette API retourne le code externe de toutes les formations
d'un partenaire 
"""
@app.route('/myclass/api/get_partner_class_external_code/', methods=['POST','GET'])
@crossdomain(origin='*')
def get_partner_class_external_code():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### get_partner_class_external_code payload = ",str(payload)+"  IP requester = "+str(request.remote_addr))
    status, retval = cm.get_partner_class_external_code(payload)
    return jsonify(status=status, message=retval)




@app.route('/myclass/api/update_class/', methods=['POST'])
@crossdomain(origin='*')
def update_class():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### update_class payload = ",payload)
    status, retval = cm.update_class(payload)
    return jsonify(status=status, message=retval)


'''
deverrouillage  d'une formation  - unlock training

'''
@app.route('/myclass/api/unlock_class/', methods=['POST'])
@crossdomain(origin='*')
def unlock_class():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### payload = ",payload)
    status, retval = cm.unlock_class(payload)
    return jsonify(status=status, message=retval)

'''
Verrouillage  d'une formation  - lock training
'''
@app.route('/myclass/api/lock_class/', methods=['POST'])
@crossdomain(origin='*')
def lock_class():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### payload = ",payload)
    status, retval = cm.lock_class(payload)
    return jsonify(status=status, message=retval)


'''
API de Depublication d'une formation
'''
@app.route('/myclass/api/unpublish_class/', methods=['POST'])
@crossdomain(origin='*')
def unpublish_class():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### payload = ",payload)
    status, retval = cm.unpublish_class(payload)
    return jsonify(status=status, message=retval)


'''
API de Publication d'une formation
'''
@app.route('/myclass/api/pusblish_class/', methods=['POST'])
@crossdomain(origin='*')
def pusblish_class():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### payload = ",payload)
    status, retval = cm.pusblish_class(payload)
    return jsonify(status=status, message=retval)



'''
Desactivé une formation  - disable training

'''
@app.route('/myclass/api/disable_class/', methods=['POST'])
@crossdomain(origin='*')
def disable_class():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### payload = ",payload)
    status, retval = cm.disable_class(payload)
    return jsonify(status=status, message=retval)

'''
Reactivation d'une formation  - enable training
'''
@app.route('/myclass/api/enable_class/', methods=['POST'])
@crossdomain(origin='*')
def enable_class():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### payload = ",payload)
    status, retval = cm.enable_class(payload)
    return jsonify(status=status, message=retval)




'''
Cette api retourne les formations dont "attribut"="valeur"
'''
@app.route('/myclass/api/get_class_by_name/<attribut>,<value>', methods=['GET','POST'])
@crossdomain(origin='*')
def get_all_class_by_attribut(attribut, value):
    result = wp.get_all_class_by_attribut(attribut, value)
    if result:
        #print(" in main result =  ", result)
        return jsonify(result)

    return jsonify(status="False")


'''
Cette api retourne les formations dont "attribut" IN (list_valeurs)
list_valeurs = val1,val2,val3,...,valn
'''
@app.route('/myclass/api/get_class_by_list_attr/<attribut>;<list_values>', methods=['GET'])
@crossdomain(origin='*')
def get_class_by_list_attr(attribut, list_values):
    print(" ### attribut = "+attribut)

    result = wp.get_class_by_list_attr(attribut, list_values)
    if result:
        #print(" in main result =  ", result)
        return jsonify(result)
    return jsonify(status="False")


'''
fonction actuellement utilisé sur le front : 
Cette fonction "get_recherche_gle_class"  prend en argument une phrase et
retourne les formations associées
'''
@app.route('/myclass/api/get_recherche_gle_class/<sentence>', methods=['GET'])
@crossdomain(origin='*')
def get_recherche_gle_class(sentence):

    result = wp.get_recherche_gle_class(sentence)
    if result:
        #print(" in main result =  ", result)
        return jsonify(result)
    return jsonify(status="False")


'''
Fonction utilisée pour la recherche simple d'un texte.
sans utilisation de critère ni de tag

'''
@app.route('/myclass/api/recherche_text_simple/', methods=['GET','POST'])
@crossdomain(origin='*')
def recherche_text_simple():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    #print(" ### payload = ", payload)
    status, result = wp.recherche_text_simple(payload)
    return jsonify(status=status, message=result)



# recherche globale
'''
fonction NON utilisée sur le front : 
Cette fonction fait une recherche globale en prenant une chaine de caractère  - not use on front
'''
@app.route('/myclass/api/get_class_global_search/<search_string>', methods=['GET','POST'])
@crossdomain(origin='*')
def get_class_global_search(search_string):
    result = cm.get_class_global_search(search_string)
    if result:
        #print(" in main result =  ", result)
        return jsonify(result)

    return jsonify(status="False")


@app.route('/myclass/api/get_all_class/', methods=['GET','POST'])
@crossdomain(origin='*')
def get_all_class():
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### get_all_class : payload = ", payload)
    if mycommon.check_source_ipv4(str(request.remote_addr)) is False :
        return  jsonify(status="False", message="Security check : "+request.remote_addr+"' is not autorized")


    status, result = wp.get_all_class(payload)

    response =  jsonify(status=status, message=result)
    response.headers.add("Access-Control-Allow-Origin", "*")
    response.headers.add("Access-Control-Allow-Headers", "*")
    response.headers.add("Access-Control-Allow-Methods", "*")
    return response



@app.route('/myclass/api/update_class_by_attribut/<objId>,<attribut>,<value>', methods=['GET','POST'])
def update_class_by_attribut(objId, attribut, value):
    print(" update_class_by_attribut ")
    result = wp.update_class_by_attribut(objId, attribut, value)
    if result:
        print(" in main result =  ", result)
        return jsonify(result)

    return jsonify(status="False")

# this function update all fields of class.
# First : we retrieve all field of class and display it.
# Second : the user update some fields but all fields will be returned for update
# it means all field are stored in :
# payload =  mycommon.strip_dictionary (request.form.to_dict())
@app.route('/myclass/api/update_class_by_id/<id>', methods=['GET','POST'])
def update_class_by_id(id):
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print("on va modifier l'id (fourni en input) : ", id)
    for key, value in payload.items():
        print(key," : ", value)

    result = wp.update_class(payload)
    #result = "1"
    if result:
        return jsonify(status='True', message='Class updated')
    return jsonify(status='False')


'''
Cette API créer un compte patenaire / client  et declenche l'envoi de l'email de notification
La clé est reste l'adresse email du partenaire (pas du contact du partenaire)
'''
@app.route('/myclass/api/add_partner_account/', methods=['POST','GET'])
@crossdomain(origin='*')
def add_partner_account():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### payload = ",payload)
    status, retval = pa.add_partner_account(payload)
    return jsonify(status=status, message=retval)



'''
Cette API valide une inscription d'un partenaire
'''
@app.route('/myclass/api/valide_partnair_account/<value>', methods=['GET','POST'])
@crossdomain(origin='*')
def valide_partnair_account(value):

    print(" ### validation du compte = ",value)
    result, token = pa.valide_partnair_account(value)

    if (result):
        if (MYSY_GV.MYSY_ENV == "PROD"):
            url = 'https://www.mysy-training.com/PartnerLogin1/'
        elif (MYSY_GV.MYSY_ENV == "DEV"):
            url = 'http://localhost:3009/PartnerLogin1/'
        elif (MYSY_GV.MYSY_ENV == "REC"):
            url = 'https://dev.mysy-training.com/PartnerLogin1/'

        elif (MYSY_GV.MYSY_ENV == "DEM"):
            url = 'https://demo.mysy-training.com/PartnerLogin1/'

    else:
        if (MYSY_GV.MYSY_ENV == "PROD"):
            url = 'https://www.mysy-training.com/erreur'
        elif (MYSY_GV.MYSY_ENV == "DEV"):
            url = 'https://www.mysy-training.com/erreur'
        elif (MYSY_GV.MYSY_ENV == "REC"):
            url = 'https://dev.mysy-training.com/erreur'
        elif (MYSY_GV.MYSY_ENV == "DEM"):
            url = 'https://demo.mysy-training.com/erreur'

    return redirect(url)



'''
Cette fonction modifie/MAJ un partenaire
'''
@app.route('/myclass/api/update_partner_account/', methods=['POST','GET'])
@crossdomain(origin='*')
def update_partner_account():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### update_partner_account payload = ",payload)

    if request.method == 'POST':
        # Create variable for uploaded file
        if( 'file_logo' in request.files.keys() ):
            file_logo = request.files['file_logo']
        else:
            file_logo = None


        if ('file_cachet' in request.files.keys()):
            file_cachet = request.files['file_cachet']
        else:
            file_cachet = None

    status, retval = pa.update_partner_account(file_logo,file_cachet,  app.config['UPLOAD_FOLDER'], payload)

    return jsonify(status=status, message=retval)

"""
API de suppression d'une image enregistrer dans la collection 'mysy_images"
en input, on prend le recid

"""
@app.route('/myclass/api/DeleteClassImage_v2/', methods=['POST','GET'])
@crossdomain(origin='*')
def DeleteClassImage_v2():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### DeleteClassImage_v2 payload = ",payload)
    status, retval = mycommon.DeleteClassImage_v2(payload)
    return jsonify(status=status, message=retval)



'''
Partenair SECURITY : Cette API  modifie/MAJ le mail du  partenaire
'''
@app.route('/myclass/api/update_partner_main_mail/', methods=['POST','GET'])
@crossdomain(origin='*')
def update_partner_main_mail():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### payload = ",payload)
    status, retval = pa.update_partner_main_mail(payload)
    return jsonify(status=status, message=retval)




'''
Partenair SECURITY : Cette API  modifie/MAJ le password du  partenaire
'''
@app.route('/myclass/api/update_partner_pwd/', methods=['POST','GET'])
@crossdomain(origin='*')
def update_partner_pwd():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### update_partner_pwd payload = ",payload)
    status, retval = pa.update_partner_pwd(payload)
    return jsonify(status=status, message=retval)


"""
Cette API met à jour la clé d'insertion d'un nouvel collaborateur
"""
@app.route('/myclass/api/update_partner_insert_key/', methods=['POST','GET'])
@crossdomain(origin='*')
def update_partner_insert_key():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### payload = ",payload)
    status, retval = pa.update_partner_insert_key(payload)
    return jsonify(status=status, message=retval)




'''
Cette fonction recupere les données d'un partenaire

'''
@app.route('/myclass/api/get_partner_account/', methods=['POST','GET'])
@crossdomain(origin='*')
def get_partner_account():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### get_partner_account payload = ",payload)
    status, retval = pa.get_partner_account(payload)
    return jsonify(status=status, message=retval)


"""
Recuperation des images/media d'un partenaire
"""
@app.route('/myclass/api/getRecodedParnterImage_from_front/', methods=['POST','GET'])
@crossdomain(origin='*')
def getRecodedParnterImage_from_front():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### getRecodedParnterImage_from_front payload = ",payload)
    status, retval = pa.getRecodedParnterImage_from_front(payload)
    return jsonify(status=status, message=retval)


'''
Cette API index la base donnée.
La fonction "ela_index_all_classes" va aller chercher chaque cours dans la BDD
et créer les mots clées qui sont ensuite enregister dans la table "elaindex" 

'''
@app.route('/myclass/api/ela_index_all_classes/', methods=['POST','GET'])
@crossdomain(origin='*')
def ela_index_all_classes():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### payload = ",payload)
    status, retval = ela_index_class.ela_index_all_classes()
    return jsonify(status=status, message=retval)


'''
Cette API index la base donnée en se basant sur le title.
La fonction "ela_index_all_classes" va aller chercher chaque cours dans la BDD
et créer les mots clées qui sont ensuite enregister dans la table "elaindex" 

'''
@app.route('/myclass/api/ela_index_all_classes_title/', methods=['POST','GET'])
@crossdomain(origin='*')
def ela_index_all_classes_title():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### payload = ",payload)
    status, retval = ela_index_class.ela_index_all_classes_title()
    return jsonify(status=status, message=retval)



'''
Cette API index la base donnée en se basant sur les videos qui ont une transcription
Le champ en question sera : "video_text".
La fonction "ela_index_all_classes" va aller chercher chaque cours dans la BDD
et créer les mots clées qui sont ensuite enregister dans la table "elaindex" 

'''
@app.route('/myclass/api/ela_index_all_classes_video_text/', methods=['POST','GET'])
@crossdomain(origin='*')
def ela_index_all_classes_video_text():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### payload = ",payload)
    status, retval = ela_index_class.ela_index_all_classes_video_text()
    return jsonify(status=status, message=retval)



''' Analyse Youtubes 
'''
@app.route('/myclass/api/ela_index_all_ytubes_video_transcription/', methods=['POST','GET'])
@crossdomain(origin='*')
def ela_index_all_ytubes_video_transcription():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### payload = ",payload)
    status, retval = YTA.ela_index_all_ytubes_video_transcription()
    return jsonify(status=status, message=retval)



'''
Cette API index la base donnée en se basant sur le description.
La fonction "ela_index_all_classes" va aller chercher chaque cours dans la BDD
et créer les mots clées qui sont ensuite enregister dans la table "elaindex" 

'''
@app.route('/myclass/api/ela_index_all_classes_desc/', methods=['POST','GET'])
@crossdomain(origin='*')
def ela_index_all_classes_desc():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### payload = ",payload)
    status, retval = ela_index_class.ela_index_all_classes_desc()
    return jsonify(status=status, message=retval)



'''
Cette API index la base donnée en se basant sur le objectif.
La fonction "ela_index_all_classes" va aller chercher chaque cours dans la BDD
et créer les mots clées qui sont ensuite enregister dans la table "elaindex" 

'''
@app.route('/myclass/api/ela_index_all_classes_obj/', methods=['POST','GET'])
@crossdomain(origin='*')
def ela_index_all_classes_obj():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### payload = ",payload)
    status, retval = ela_index_class.ela_index_all_classes_obj()
    return jsonify(status=status, message=retval)


'''
Cette API index la base donnée en se basant sur les mots clées (keyword).
La fonction "ela_index_all_classes" va aller chercher chaque cours dans la BDD
et créer les mots clées qui sont ensuite enregister dans la table "elaindex" 

'''
@app.route('/myclass/api/ela_index_all_classes_keywords/', methods=['POST','GET'])
@crossdomain(origin='*')
def ela_index_all_classes_keywords():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### payload = ",payload)
    status, retval = ela_index_class.ela_index_all_classes_keywords()
    return jsonify(status=status, message=retval)




'''
Cette API, utilisée dans phase de developpement
est utilisé pour supprimer le token d'un user

Use case : Uniquement en developpement
'''
@app.route('/myclass/api/Dev_del_user_token/', methods=['POST','GET'])
@crossdomain(origin='*')
def Dev_del_user_token():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### payload = ",payload)
    status, retval = dev_function.Dev_del_user_token(payload)
    return jsonify(status=status, message=retval)

'''
Recherche en mode tips
'''
@app.route('/myclass/api/recherche_tips/', methods=['POST','GET'])
@crossdomain(origin='*')
def recherche_tips():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### payload = ",payload)
    status, retval = wp.recherche_tips(payload)
    return jsonify(status=status, message=retval)



'''
Recuperation de l'historique de recherche d'un user
'''
@app.route('/myclass/api/get_stored_recherche/', methods=['POST','GET'])
@crossdomain(origin='*')
def get_stored_recherche():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### payload = ",payload)
    status, retval = wp.get_stored_recherche(payload)
    return jsonify(status=status, message=retval)


'''
Cette API met à jour le password d'un user
'''
'''
Recuperation de l'historique de recherche d'un user
'''
@app.route('/myclass/api/change_user_pwd/', methods=['POST','GET'])
@crossdomain(origin='*')
def change_user_pwd():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### payload = ",payload)
    status, retval = eua.change_user_pwd(payload)
    return jsonify(status=status, message=retval)


'''
Cette API met à jour le l'adresse email principale d'un user
'''

@app.route('/myclass/api/change_uer_email/', methods=['POST','GET'])
@crossdomain(origin='*')
def change_uer_email():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### payload = ",payload)
    status, retval = eua.change_uer_email(payload)
    return jsonify(status=status, message=retval)

'''
Cette API supprime un compte utilisateur tout en gardant la cohérence
des information.

Cela revient à :
1 - Anonyser le compte tous les champ identifiants une personne
(['adr_street', 'adr_city', 'adr_zip', 'adr_country', 'mob_phone','link_facebook', 'link_twitter', 'token'])
2 - Bloquer le compte
3 - Desactiver le compte
'''
@app.route('/myclass/api/delete_user_account/', methods=['POST','GET'])
@crossdomain(origin='*')
def delete_user_account():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### payload = ",payload)
    status, retval = eua.delete_user_account(payload)
    return jsonify(status=status, message=retval)



'''
Cette API verrouille le compte d'un utilisateur
Cela revient à mettre le champ : "locked" à 1

'''
@app.route('/myclass/api/lock_user_account/', methods=['POST','GET'])
@crossdomain(origin='*')
def lock_user_account():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### payload = ",payload)
    status, retval = eua.lock_user_account(payload)
    return jsonify(status=status, message=retval)



'''
Cette API desactive le compte d'un utilisateur
Cela revient à mettre le champ : "active" à 0 et "locked" a 1

'''
@app.route('/myclass/api/desable_user_account/', methods=['POST','GET'])
@crossdomain(origin='*')
def desable_user_account():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### payload = ",payload)
    status, retval = eua.desable_user_account(payload)
    return jsonify(status=status, message=retval)


'''
Cette API enregistre le message d'un utilisateur
Par pour la gestion des message de "contactez-nous".
'''
@app.route('/myclass/api/add_user_message/', methods=['POST','GET'])
@crossdomain(origin='*')
def add_user_message():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### payload = ",payload)
    status, retval = um.add_user_message(payload)
    return jsonify(status=status, message=retval)

'''
Cette API récupérer le message posté par un utilisateur.
Le premier cas d'usage est la recuperation post effectué sur un article par un 
utilisateur
'''
@app.route('/myclass/api/get_user_message/', methods=['POST','GET'])
@crossdomain(origin='*')
def get_user_message():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### payload = ",payload)
    status, retval = um.get_user_message(payload)
    return jsonify(status=status, message=retval)



'''
Cette API ajoute des formation en masse
par exemple avec un fichier CSV
'''

def allowed_file(filename):
    return '.' in filename and \
           filename.rsplit('.', 1)[1].lower() in MYSY_GV.ALLOWED_EXTENSIONS


@app.route('/myclass/api/add_class_mass/', methods=['POST','GET'])
@crossdomain(origin='*')
def add_class_mass():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### add_class_mass  payload = ",payload)
    print(request.files)

    if request.method == 'POST':
        # Create variable for uploaded file
        f = request.files['File']

        status, retval = cm.add_class_mass(f, MYSY_GV.TEMPORARY_DIRECTORY_V2, payload)

    return jsonify(status=status, message=retval)

'''
Enregistrement d'une image de profil d'un utilisateur
'''
@app.route('/myclass/api/recordImage/', methods=['POST','GET'])
@crossdomain(origin='*')
def recordImage():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### payload = ",payload)
    print(request.files)

    if request.method == 'POST':
        # Create variable for uploaded file
        f = request.files['File']

        status= mycommon.recordImage(f, app.config['UPLOAD_FOLDER'], payload)

    return jsonify(status=status)

'''
Test de recuperation d'une image enregistrée
'''

@app.route('/myclass/api/getRecodedImage/', methods=['POST','GET'])
@crossdomain(origin='*')
def getRecodedImage():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### getRecodedImage : payload = ",payload)
    status, myimg= mycommon.getRecodedImage(payload)
    return jsonify(status=status, message=myimg)




'''
Cette API gere la connexion d'un partenaire.

Pour memo la connexion d'un partenaire est differente de celle d'un user
Pour le partenaire, en plud du mail, passwd, il faut fournir le token qui est "secrete"
'''
@app.route('/myclass/api/partner_login/', methods=['POST','GET'])
@crossdomain(origin='*')
def partner_login():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### partner_login payload = ",payload)
    print(request.files)
    status, retval = pa.partner_login(payload)
    return jsonify(status=status, message=retval)


'''
Cette API récupérer tous les articles et avis sur les formations
'''
@app.route('/myclass/api/get_all_articles_avis/', methods=['POST','GET'])
@crossdomain(origin='*')
def get_all_articles_avis():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### payload = ",payload)
    status, retval = aa.get_all_articles_avis(payload)
    return jsonify(status=status, message=retval)



'''
Cette API recupere un article/avis donné
'''
@app.route('/myclass/api/get_articles_avis/', methods=['POST','GET'])
@crossdomain(origin='*')
def get_articles_avis():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### get_articles_avis : payload = ",payload)
    status, retval = aa.get_articles_avis(payload)
    return jsonify(status=status, message=retval)

'''
Cette API ajouter un article/avis
'''
@app.route('/myclass/api/add_articles_avis/', methods=['POST','GET'])
@crossdomain(origin='*')
def add_articles_avis():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### payload = ",payload)
    status, retval = aa.add_articles_avis(payload)
    return jsonify(status=status, message=retval)


'''
Cette API indexe les articles et avis postés
'''

@app.route('/myclass/api/ela_index_all_articles_avis/', methods=['POST','GET'])
@crossdomain(origin='*')
def ela_index_all_articles_avis():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### payload = ",payload)
    status, retval = ela_index_class.ela_index_all_articles_avis()
    return jsonify(status=status, message=retval)


''' 
Cette API recherche un articles ou un avis en se basant sur le
titre de la formation'''
@app.route('/myclass/api/recherche_articles_avis/', methods=['GET','POST'])
@crossdomain(origin='*')
def recherche_articles_avis():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### payload = ", payload)
    status, result = aa.recherche_articles_avis(payload)
    return jsonify(status=status, message=result)


''' 
Cette API retourne les articles et avis à la Une'''
@app.route('/myclass/api/get_article_avis_alaune/', methods=['GET','POST'])
@crossdomain(origin='*')
def get_article_avis_alaune():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### payload = ", payload)
    status, result = aa.get_article_avis_alaune(payload)
    return jsonify(status=status, message=result)


'''
Cette API reinitialise le mot de passe d'un utilisation
depuis le front office'''
@app.route('/myclass/api/InitUserPasswd/', methods=['GET','POST'])
@crossdomain(origin='*')
def InitUserPasswd():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### InitUserPasswd payload = ", payload)
    status, result = eua.InitUserPasswd(payload)
    return jsonify(status=status, message=result)

'''
Cette API verifie la validité d'un token 
'''
@app.route('/myclass/api/IsUserTokenValide/', methods=['GET','POST'])
@crossdomain(origin='*')
def IsUserTokenValide():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### payload = ", payload)
    status, result = eua.IsUserTokenValide(payload)
    return jsonify(status=status, message=result)

'''
Cette API, modifie le pwd d'un user
en partant d'un token.
l'api est utilisé dans le cas d'un process de reinitialisation du pwd
par le user meme'''
@app.route('/myclass/api/Reset_user_pwd_by_token/', methods=['GET','POST'])
@crossdomain(origin='*')
def Reset_user_pwd_by_token():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### payload = ", payload)
    status, result = eua.Reset_user_pwd_by_token(payload)
    return jsonify(status=status, message=result)



'''
Cette API envoi l'email de suppression du compte utilisateur.
une suppression se passe tjrs 2 phase : 
pahse 1 : envoi de l'email + blocage du compte
pahse 2 : confirmation depuis l'email recu.
'''
@app.route('/myclass/api/send_mail_delete_user/', methods=['GET','POST'])
@crossdomain(origin='*')
def send_mail_delete_user():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### payload = ", payload)
    status, result = eua.send_mail_delete_user(payload)
    return jsonify(status=status, message=result)


'''
Cette API pour des tests perso
'''
@app.route('/myclass/api/mysy_recherche_levenshtein_orig/', methods=['GET','POST'])
@crossdomain(origin='*')
def mysy_recherche_levenshtein_orig():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### payload = ", payload)
    status, result = TP.mysy_recherche_levenshtein_orig()
    return jsonify(status=status, message=result)

'''
Cette API est le cron qui traite les emails stockes dans la collection
'user_message'
'''
@app.route('/myclass/api/CronUSerMessage_Mail/', methods=['GET','POST'])
@crossdomain(origin='*')
def CronUSerMessage_Mail():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### payload = ", payload)
    status, date_treatment, result = mycommon.CronUSerMessage_Mail()
    return jsonify(status=status, date_treatment = str(date_treatment), message=result)

'''
Juste une API pour tester de ptite choses
'''
@app.route('/myclass/api/OrderClassRandomly/', methods=['GET','POST'])
@crossdomain(origin='*')
def OrderClassRandomly():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### payload = ", payload)
    status, result = mycommon.FormationAlaUne()
    return jsonify(status=status,  message=result)


@app.route('/myclass/api/Migration_internal_url/', methods=['GET','POST'])
@crossdomain(origin='*')
def Migration_internal_url():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### payload = ", payload)
    status, result = "none", "none", #mycommon.Migration_internal_url()
    return jsonify(status=status,  message=result)


'''
Correction erreur title mymooc.com
'''
@app.route('/myclass/api/Migration_mooc_title/', methods=['GET','POST'])
@crossdomain(origin='*')
def Migration_mooc_title():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### payload = ", payload)
    status, result = "none", "none", #mycommon.Migration_mooc_title()
    return jsonify(status=status,  message=result)



'''
Cette API va aller chercher dans la collection "elaindex" 
les mots qui contiennent le mot "mot"'''
@app.route('/myclass/api/GetMotFromElaIndex/', methods=['GET','POST'])
@crossdomain(origin='*')
def GetMotFromElaIndex():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### payload = ", payload)
    status, result = mycommon.GetMotFromElaIndex(payload)
    return jsonify(status=status,  message=result)

'''
Cette API retour une formation "coup de coeur" apres
avoir effectué tous les controles
'''
@app.route('/myclass/api/get_class_coup_de_coeur/', methods=['GET','POST'])
@crossdomain(origin='*')
def get_class_coup_de_coeur():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### payload = ", payload)
    status, result = cm.get_class_coup_de_coeur(payload)
    return jsonify(status=status,  message=result)


"""
Cette API clean la collecion "elaindex" 
"""
@app.route('/myclass/api/clean_ElaIndex/', methods=['GET','POST'])
@crossdomain(origin='*')
def clean_ElaIndex():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### payload = ", payload)
    status, result = mycommon.clean_ElaIndex()
    return jsonify(status=status,  message=result)


"""
Cette API clean les internal url de la collection "myclass" 
"""
@app.route('/myclass/api/clean_internal_url/', methods=['GET','POST'])
@crossdomain(origin='*')
def clean_internal_url():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### payload = ", payload)
    status, result = mycommon.clean_internal_url()
    return jsonify(status=status,  message=result)



'''
Cette API retourne les formations par metier
'''
@app.route('/myclass/api/get_class_by_metier/', methods=['GET','POST'])
@crossdomain(origin='*')
def get_class_by_metier():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### payload = ", payload)
    status, result = cm.get_class_by_metier(payload)
    return jsonify(status=status, message=result)


'''
Cette API met à jour les formations en ajoutant les metier
'''
@app.route('/myclass/api/UpdateMetier/', methods=['GET','POST'])
@crossdomain(origin='*')
def UpdateMetier():
    status = mycommon.UpdateMetier()
    return jsonify(status=status)



'''
Cette API effectue la migration d'un compte utilisateur 
vers un compte pro (ou compte partenaire)
'''
@app.route('/myclass/api/UpgradetoPro/', methods=['GET','POST'])
@crossdomain(origin='*')
def UpgradetoPro():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### payload = ", payload)
    status, result = pa.UpgradetoPro(payload)
    return jsonify(status=status,  message=result)



'''
Cette API recupere les facture d'un client en prenant son tokek
'''
@app.route('/myclass/api/get_invoice_by_customer/', methods=['GET','POST'])
@crossdomain(origin='*')
def get_invoice_by_customer():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### payload = ", payload)
    status, result = invoice.get_invoice_by_customer(payload)
    return jsonify(status=status,  message=result)

'''
Cette API recupere les produits et services d'un pack données.
Si le pack n'est pas defini, alors tous les produits valides sont
retournés
'''
@app.route('/myclass/api/get_product_service/', methods=['GET','POST'])
@crossdomain(origin='*')
def get_product_service():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### payload = ", payload)
    status, result = PS.get_product_service(payload)
    return jsonify(status=status,  message=result)


"""
Cette API rengristre un mode depayment (CB ou SEPA) 
"""
@app.route('/myclass/api/add_payement_mode/', methods=['GET','POST'])
@crossdomain(origin='*')
def add_payement_mode():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### payload = ", payload)
    status, result = invoice.add_payement_mode(payload)
    return jsonify(status=status,  message=result)


"""
Cette API recupere le mode de payement par defaut d'un client
"""
@app.route('/myclass/api/get_payement_mode/', methods=['GET','POST'])
@crossdomain(origin='*')
def get_payement_mode():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### payload = ", payload)
    status, result, nb_carte = invoice.get_payement_mode(payload)
    return jsonify(status=status,  message=result, nb_carte=nb_carte)

"""
Cette API recupere les données et crée la commande
"""
@app.route('/myclass/api/createOrder/', methods=['GET','POST'])
@crossdomain(origin='*')
def createOrder():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### payload = ", str(payload))
    status, message, order_id = invoice.createOrder(payload)
    return jsonify(status=status,  message=message, order_id=order_id)

"""
Cette API retourne la liste des mots suggerés pour la recherche
"""
@app.route('/myclass/api/Get_Suggested_Word/', methods=['GET','POST'])
@crossdomain(origin='*')
def Get_Suggested_Word():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### payload = ", str(payload))
    status, message = mycommon.Get_Suggested_Word()
    return jsonify(status=status,  message=message)


"""
Cette API retourne la liste des villes de la france suggerés pour la recherche
"""
@app.route('/myclass/api/Get_Suggested_Fr_Cities/', methods=['GET','POST'])
@crossdomain(origin='*')
def Get_Suggested_Fr_Cities():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### Get_Suggested_Fr_Cities : payload = ", str(payload))
    status, message = mycommon.Get_Suggested_Fr_Cities()
    return jsonify(status=status,  message=message)


"""
Cette API imprime et envoie les factures aux clients
"""
@app.route('/myclass/api/PrintAndSendInvoices/', methods=['GET','POST'])
@crossdomain(origin='*')
def PrintAndSendInvoices():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### payload = ", str(payload))
    status, message = factures.PrintAndSendInvoices()
    return jsonify(status=status,  message=message)


"""
Cette API imprime et envoie les factures aux clients
"""
@app.route('/myclass/api/PutClassNote/', methods=['GET','POST'])
@crossdomain(origin='*')
def PutClassNote():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### payload = ", str(payload))
    status, message = mycommon.PutClassNote()
    return jsonify(status=status,  message=message)

"""
Cette API envoie la facture d'un client
"""

@app.route('/myclass/api/GetCustomerInvoice/<token>/<invoiceid>', methods=['GET','POST'])
@crossdomain(origin='*')
def GetCustomerInvoice(invoiceid, token):
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    payload = {}
    payload['token'] = str(token)
    payload['invoiceid'] = str(invoiceid)
    print(" ### payload facture = ", str(invoiceid), " token = ",str(token))
    return factures.GetCustomerInvoice(payload)




"""
API de facturation automatique des commandes 
"""
@app.route('/myclass/api/AutoamticCreateInvoice/', methods=['GET','POST'])
@crossdomain(origin='*')
def AutoamticCreateInvoice():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### payload = ", str(payload))
    status, message = factures.AutoamticCreateInvoice()
    return jsonify(status=status,  message=message)

"""
API de excuter une fonction de statistique
"""
@app.route('/myclass/api/GetStat_class_view_old/', methods=['GET','POST'])
@crossdomain(origin='*')
def GetStat_class_view_old():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### payload = ", str(payload))
    status, message = Stat.GetStat_class_view_old()
    return jsonify(status=status,  message=message)


"""
API de excuter une fonction de statistique sur la semaine ecoulée
"""
@app.route('/myclass/api/GetStat_class_view/', methods=['GET','POST'])
@crossdomain(origin='*')
def GetStat_class_view():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### payload = ", str(payload))
    status, message = Stat.GetStat_class_view(payload)
    return jsonify(status=status,  message=message)



"""
Cette API retourne les STAT des X formations les plus vues d'un client donné sur 
une periode donnée
"""
@app.route('/myclass/api/GetStat_class_view_topX/', methods=['GET','POST'])
@crossdomain(origin='*')
def GetStat_class_view_topX():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### payload = ", str(payload))
    status, message = Stat.GetStat_class_view_topX(payload)
    return jsonify(status=status,  message=message)



"""
Cette API retourne les X formations les plus vues d'un client donné sur 
une periode donnée
"""
@app.route('/myclass/api/Get_X_Best_Class_On_Given_period/', methods=['GET','POST'])
@crossdomain(origin='*')
def Get_X_Best_Class_On_Given_period():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### payload = ", str(payload))
    status, message = Stat.Get_X_Best_Class_On_Given_period(payload)
    return jsonify(status=status,  message=message)


"""
Cette API retour les statistiques d'une formation données
"""
@app.route('/myclass/api/GetStat_class_by_internal_url/', methods=['GET','POST'])
@crossdomain(origin='*')
def GetStat_class_by_internal_url():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### payload = ", str(payload))
    status, message = Stat.GetStat_class_by_internal_url(payload)
    return jsonify(status=status,  message=message)


@app.route('/myclass/api/test_return/', methods=['GET','POST'])
@crossdomain(origin='*')
def test_return():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### payload = ", str(payload))
    status, message = Stat.test_return()
    return jsonify(status=status,  message=message)


"""
API de suppression du compte de LS"""
@app.route('/myclass/api/removeLSaccount/', methods=['GET','POST'])
@crossdomain(origin='*')
def removeLSaccount():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### payload = ", str(payload))
    status, message = mycommon.removeLSaccount()
    return jsonify(status=status,  message=message)


"""
API de suppression du compte de Nicole"""
@app.route('/myclass/api/removeNBaccount/', methods=['GET','POST'])
@crossdomain(origin='*')
def removeNBaccount():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### removeNBaccount payload = ", str(payload))
    status, message = mycommon.removeNBaccount()
    return jsonify(status=status,  message=message)


"""
Pour des test, et seulement pour les test
cette fonction permet de mettre les formations du user "ls" 
en première page.

Cette fonction doit etre inactive en production 
"""
@app.route('/myclass/api/PutLSClassFirst/', methods=['GET','POST'])
@crossdomain(origin='*')
def PutLSClassFirst():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### PutLSClassFirst : payload = ", str(payload))
    status, message = mycommon.PutLSClassFirst()
    return jsonify(status=status,  message=message)


"""
Correction data - api oneshot
"""
@app.route('/myclass/api/correction_collection/', methods=['GET','POST'])
@crossdomain(origin='*')
def correction_collection():
    # On recupere le corps (payload) de la requete
    print(" correction_collection ")
    status, message = mycommon.correction_collection()
    return jsonify(status=status,  message=message)



"""
Cette API récupérer l'image de profil d'une formation
"""
@app.route('/myclass/api/getRecodedClassImage/', methods=['POST','GET'])
@crossdomain(origin='*')
def getRecodedClassImage():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### getRecodedClassImage payload = ",payload)
    status, myimg= mycommon.getRecodedClassImage(payload)
    return jsonify(status=status, message=myimg)

"""
Cette API supprimer une l'image de profil d'une formation
"""
@app.route('/myclass/api/DeleteRecodedClassImage/', methods=['POST','GET'])
@crossdomain(origin='*')
def DeleteRecodedClassImage():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### DeleteRecodedClassImage payload = ",payload)
    status, message= mycommon.DeleteRecodedClassImage(payload)
    return jsonify(status=status, message=message)

"""
Cette API de Recuperation d'une image de profils d'une formation pour le mode non connecté. c'est a dire depuis le front
"""
@app.route('/myclass/api/getRecodedClassImage_from_front/', methods=['POST','GET'])
@crossdomain(origin='*')
def getRecodedClassImage_from_front():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### getRecodedClassImage_from_front  payload = ",payload)
    status, myimg= mycommon.getRecodedClassImage_from_front(payload)
    return jsonify(status=status, message=myimg)



'''
Enregistrement d'une image de profil d'une formation
'''
@app.route('/myclass/api/recordClassImage/', methods=['POST','GET'])
@crossdomain(origin='*')
def recordClassImage():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### payload = ",payload)
    print(request.files)

    if request.method == 'POST':
        # Create variable for uploaded file
        f = request.files['File']

        status, message = mycommon.recordClassImage(f, app.config['UPLOAD_FOLDER'], payload)
    return  jsonify(status=status, message=message)


"""
Indexation du titre : Cette API va indexer une formation donnée ou toutes les formations d'un partenaire.
Pour ce faire elle prend en argument : 
- internal_url 
- partenaire_recid
"""
@app.route('/myclass/api/ela_index_given_classes_title/', methods=['POST','GET'])
@crossdomain(origin='*')
def ela_index_given_classes_title():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### payload = ",payload)
    status, retval = ela_index_class.ela_index_given_classes_title(payload)
    return jsonify(status=status, message=retval)


"""
Indexation des mots clés : Cette API va indexer une formation donnée ou toutes les formations d'un partenaire.
Pour ce faire elle prend en argument : 
- internal_url 
- partenaire_recid
"""
@app.route('/myclass/api/ela_index_given_classes_keywords/', methods=['POST','GET'])
@crossdomain(origin='*')
def ela_index_given_classes_keywords():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### payload = ",payload)
    status, retval = ela_index_class.ela_index_given_classes_keywords(payload)
    return jsonify(status=status, message=retval)


"""
Stripe Payement : Creation d'un abonnement
"""
@app.route('/myclass/api/create-subscription/', methods=['POST','GET'])
@crossdomain(origin='*')
def strip_create_subscription():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### strip_create_subscription : payload = ",payload)
    localStatus, subscription_id, payment_intent_client_secret = Stripe.create_subscription(payload)

    print(" ### subscription_id = "+str(subscription_id)+"  -- payment_intent_client_secret = "+str(payment_intent_client_secret))
    return jsonify(status=localStatus, subscription_id=subscription_id,payment_intent_client_secret = payment_intent_client_secret )

"""
Stripe Payement : Creation d'un client dans Stripe
"""
@app.route('/myclass/api/create-create_customer/', methods=['POST','GET'])
@crossdomain(origin='*')
def strip_create_customer():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### strip_create_customer : payload = ",payload)
    localStatus, stripe_client_id, payment_intent_client_secret = Stripe.create_customer(payload)
    return jsonify(status=localStatus, stripe_client_id=stripe_client_id )


"""
Stripe Payement : Recuperation des methodes de payement d'un client
"""
@app.route('/myclass/api/get_customer_payement_cards/', methods=['POST','GET'])
@crossdomain(origin='*')
def strip_get_customer_payement_cards():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### strip_create_customer : payload = ",payload)
    localStatus= Stripe.get_customer_payement_cards(payload)
    return jsonify(status=localStatus,  )

"""
Stripe Payement : Creation d'une carte bancaire
"""
@app.route('/myclass/api/create_payment_card/', methods=['POST','GET'])
@crossdomain(origin='*')
def strip_create_payment_card():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### create_payment_card : payload = ",payload)
    localStatus= Stripe.create_update_payment_card(payload)
    return jsonify(status=localStatus,  )


"""
Stripe Payement : Confirmation d'un payement 
"""
@app.route('/myclass/api/confirm_payment/', methods=['POST','GET'])
@crossdomain(origin='*')
def strip_confirm_payment():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### strip_confirm_payment : payload = ",payload)
    localStatus, payement_id, payement_status, secure_url = Stripe.confirm_suscription(payload)
    return jsonify(status=localStatus, payement_id=payement_id, payement_status=payement_status, secure_url=secure_url )


"""
API de gestion des stagiaires à une une formation / Gestion des insciptions
Ajout d'un stagiaire
"""
@app.route('/myclass/api/AddStagiairetoClass/', methods=['POST','GET'])
@crossdomain(origin='*')
def AddStagiairetoClass():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### AddStagiairetoClass : payload = ",payload)
    localStatus, message= inscription.AddStagiairetoClass(payload)
    return jsonify(status=localStatus, message=message )

"""
API de mise à jour d'un stagaire
"""
@app.route('/myclass/api/UpdateStagiairetoClass/', methods=['POST','GET'])
@crossdomain(origin='*')
def UpdateStagiairetoClass():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### UpdateStagiairetoClass : payload = ",payload)
    localStatus, message= inscription.UpdateStagiairetoClass(payload)
    return jsonify(status=localStatus, message=message )


"""
API de recuperation des infos d'un stagiaire
"""
@app.route('/myclass/api/GetStagiaire/', methods=['POST','GET'])
@crossdomain(origin='*')
def GetStagiaire():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### GetStagiaire : payload = ",payload)
    localStatus, message= inscription.GetStagiaire(payload)
    return jsonify(status=localStatus, message=message )


"""
API de recuperation de la liste de tous les stagaires d'une formation
"""
@app.route('/myclass/api/GetAllClassStagiaire/', methods=['POST','GET'])
@crossdomain(origin='*')
def GetAllClassStagiaire():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### GetAllClassStagiaire : payload = ",payload)
    localStatus, message= inscription.GetAllClassStagiaire(payload)
    return jsonify(status=localStatus, message=message )


"""
Cette API Crée la liste d'emargement
"""
@app.route('/myclass/api/CreateTableauEmargement/', methods=['POST','GET'])
@crossdomain(origin='*')
def CreateTableauEmargement():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### CreateTableauEmargement : payload = ",str(payload))
    localStatus, message= emargement.CreateTableauEmargement(payload)
    return jsonify(status=localStatus, message=message )




"""
Cette API Crée la liste d'emargement en partant des sequences déjà crée
23/11/2023 : Evolution en prenant les sequences.
Evolution de la fonction de création du tableau d'emargement.
Dans cette evolution, on plutot recuperer les sequence déjà créesq
"""
@app.route('/myclass/api/CreateTableauEmargement_From_Sequence/', methods=['POST','GET'])
@crossdomain(origin='*')
def CreateTableauEmargement_From_Sequence():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### CreateTableauEmargement_From_Sequence : payload = ",str(payload))
    localStatus, message= emargement.CreateTableauEmargement_From_Sequence(payload)
    return jsonify(status=localStatus, message=message )



"""
API de recuperation du tableau d'emargement d'un session de formation
"""
@app.route('/myclass/api/GetTableauEmargement/', methods=['POST','GET'])
@crossdomain(origin='*')
def GetTableauEmargement():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### GetTableauEmargement : payload = ",payload)
    localStatus, message= emargement.GetTableauEmargement(payload)
    return jsonify(status=localStatus, message=message )

"""
API de mise à jour de l'emargement d'une personne
"""
@app.route('/myclass/api/UpdateUserEmargementDate/', methods=['POST','GET'])
@crossdomain(origin='*')
def UpdateUserEmargementDate():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### UpdateUserEmargementDate : payload = ",str(payload))
    localStatus, message= emargement.UpdateUserEmargementDate(payload)
    return jsonify(status=localStatus, message=message )


"""
API de creation d'une session de formation
"""
@app.route('/myclass/api/Add_Update_SessionFormation/', methods=['POST','GET'])
@crossdomain(origin='*')
def Add_Update_SessionFormation():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### Add_Update_SessionFormation : payload = ",str(payload))
    localStatus, message= SF.Add_Update_SessionFormation(payload)
    return jsonify(status=localStatus, message=message )

"""
API de recuperation de toutes les sessions de formation valides et actives
"""
@app.route('/myclass/api/GetActiveSessionFormation_List/', methods=['POST','GET'])
@crossdomain(origin='*')
def GetActiveSessionFormation_List():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### GetActiveSessionFormation_List : payload = ",str(payload))
    localStatus, message= SF.GetActiveSessionFormation_List(payload)
    return jsonify(status=localStatus, message=message )


"""
API de recuperation des villes  les sessions de formation valides et actives
"""
@app.route('/myclass/api/GetActiveSession_Cities_And_Distance_Formation_List/', methods=['POST','GET'])
@crossdomain(origin='*')
def GetActiveSession_Cities_And_Distance_Formation_List():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### GetActiveSession_Cities_And_Distance_Formation_List : payload = ",str(payload))
    localStatus, message= SF.GetActiveSession_Cities_And_Distance_Formation_List(payload)
    return jsonify(status=localStatus, message=message )





"""
API de toutes sessions de formation valide, (peu importe qu'elles soient terminées ou pas
"""
@app.route('/myclass/api/GetAllValideSessionFormation_List/', methods=['POST','GET'])
@crossdomain(origin='*')
def GetAllValideSessionFormation_List():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### GetAllValideSessionFormation_List : payload = ",str(payload))
    localStatus, message= SF.GetAllValideSessionFormation_List(payload)
    return jsonify(status=localStatus, message=message )

"""
Cette API recupere toutes les sessions de formation d'un partneaire
"""
@app.route('/myclass/api/GetAllValideSessionPartner_List/', methods=['POST','GET'])
@crossdomain(origin='*')
def GetAllValideSessionPartner_List():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### GetAllValideSessionPartner_List : payload = ",str(payload))
    localStatus, message= SF.GetAllValideSessionPartner_List(payload)
    return jsonify(status=localStatus, message=message )

"""
Cette API recupere toutes les sessions de formation d'un partneaire avec des filtres de type like
"""
@app.route('/myclass/api/GetAllValideSessionPartner_List_filter_like/', methods=['POST','GET'])
@crossdomain(origin='*')
def GetAllValideSessionPartner_List_filter_like():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### GetAllValideSessionPartner_List_filter_like : payload = ",str(payload))
    localStatus, message= SF.GetAllValideSessionPartner_List_filter_like(payload)
    return jsonify(status=localStatus, message=message )


"""
Cette API recupere toutes les sessions de formation d'un partneaire sans aucun filtre
"""
@app.route('/myclass/api/GetAllValideSessionPartner_List_no_filter/', methods=['POST','GET'])
@crossdomain(origin='*')
def GetAllValideSessionPartner_List_no_filter():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### GetAllValideSessionPartner_List_no_filter : payload = ",str(payload))
    localStatus, message= SF.GetAllValideSessionPartner_List_no_filter(payload)
    return jsonify(status=localStatus, message=message )





"""
API de recuperation session de formation
"""
@app.route('/myclass/api/GetSessionFormation/', methods=['POST','GET'])
@crossdomain(origin='*')
def GetSessionFormation():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### GetSessionFormation : payload = ",str(payload))
    localStatus, message= SF.GetSessionFormation(payload)
    return jsonify(status=localStatus, message=message )



"""
API de recuperation session de formation, ceci à partir du _Id seulement et token
"""
@app.route('/myclass/api/Get_Given_SessionFormation_From_Id/', methods=['POST','GET'])
@crossdomain(origin='*')
def Get_Given_SessionFormation_From_Id():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### Get_Given_SessionFormation_From_Id : payload = ",str(payload))
    localStatus, message= SF.Get_Given_SessionFormation_From_Id(payload)
    return jsonify(status=localStatus, message=message )


"""
API de suppression d'une session de formation  :
/!\ : il faut s'assurer qu'il n'y a aucune inscription avant de supprimer valide.
Et la session est supprimé, alors supprimer toutes inscriptions (annulée) associés
Ensuite supprimer les affectations d'enseignants et de materiels associée
"""
@app.route('/myclass/api/Delete_SessionFormation/', methods=['POST','GET'])
@crossdomain(origin='*')
def Delete_SessionFormation():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### Delete_SessionFormation : payload = ",str(payload))
    localStatus, message= SF.Delete_SessionFormation(payload)
    return jsonify(status=localStatus, message=message )


"""
Suppression d'une liste de sessions de formation
"""
@app.route('/myclass/api/Delete_List_SessionFormation/', methods=['POST','GET'])
@crossdomain(origin='*')
def Delete_List_SessionFormation():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### Delete_List_SessionFormation : payload = ",str(payload))
    localStatus, message= SF.Delete_List_SessionFormation(payload)
    return jsonify(status=localStatus, message=message )



"""
Cette API verifier des données correspondent à une session : 
- internal_url
         - date_debut
         - date_fin
         - si presentiel : la ville
         - si distance, juste le a distance 

"""
@app.route('/myclass/api/Is_Corresponding_SessionFormation/', methods=['POST','GET'])
@crossdomain(origin='*')
def Is_Corresponding_SessionFormation():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### Is_Corresponding_SessionFormation : payload = ",str(payload))
    localStatus, message= SF.Is_Corresponding_SessionFormation(payload)
    return jsonify(status=localStatus, message=message )


"""
Dupliquer une liste de session de formation
"""
@app.route('/myclass/api/Duplicate_List_Session_Formation/', methods=['POST','GET'])
@crossdomain(origin='*')
def Duplicate_List_Session_Formation():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### Duplicate_List_Session_Formation : payload = ",str(payload))
    localStatus, message= SF.Duplicate_List_Session_Formation(payload)
    return jsonify(status=localStatus, message=message )


"""
API : pour préparer et envoyer les convention en partant d'une session
"""
@app.route('/myclass/api/Prepare_and_Send_Convention_From_Session_By_Email/', methods=['POST','GET'])
@crossdomain(origin='*')
def Prepare_and_Send_Convention_From_Session_By_Email():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### Prepare_and_Send_Convention_From_Session_By_Email : payload = ",str(payload))

    file = []
    if request.method == 'POST':
        # Create variable for uploaded file
        tab_files = []
        for tmp in request.files.getlist("File"):
            tab_files.append(tmp)

    status, retval = SF.Prepare_and_Send_Convention_From_Session_By_Email(tab_files, MYSY_GV.TEMPORARY_DIRECTORY_V2, payload)
    return jsonify(status=status, message=retval)


"""
API : pour préprer et envoyer les conventions PAR DEFAUT en partant d'une session
"""
@app.route('/myclass/api/Prepare_and_Send_Default_Convention_From_Session_By_Email/', methods=['POST','GET'])
@crossdomain(origin='*')
def Prepare_and_Send_Default_Convention_From_Session_By_Email():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### Prepare_and_Send_Default_Convention_From_Session_By_Email : payload = ",str(payload))

    file = []
    if request.method == 'POST':
        # Create variable for uploaded file
        tab_files = []
        for tmp in request.files.getlist("File"):
            tab_files.append(tmp)

    status, retval = SF.Prepare_and_Send_Default_Convention_From_Session_By_Email(tab_files, MYSY_GV.TEMPORARY_DIRECTORY_V2, payload)
    return jsonify(status=status, message=retval)




"""
API : pour préprer et générer un zip de fichier PDF pour les convention en partant d'une session
"""
@app.route('/myclass/api/Prepare_and_Send_Convention_From_Session_By_PDF/<token>/<session_id>/<courrier_template_id>', methods=['POST','GET'])
@crossdomain(origin='*')
def Prepare_and_Send_Convention_From_Session_By_PDF(token, session_id, courrier_template_id):
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    payload = {}
    payload['token'] = str(token)
    payload['session_id'] = str(session_id)
    payload['courrier_template_id'] = str(courrier_template_id)

    print(" ### Prepare_and_Send_Convention_From_Session_By_PDF : payload = ",str(payload))

    localStatus, response= SF.Prepare_and_Send_Convention_From_Session_By_PDF(payload)
    if(localStatus ):
        return response
    else:
        return False


"""
API : pour préprer et générer un zip de fichier PDF pour les convention par defaut en partant d'une session.
ici les convention pdf par default
"""
@app.route('/myclass/api/Prepare_and_Send_Default_Convention_From_Session_By_PDF/<token>/<session_id>/<courrier_template_id>', methods=['POST','GET'])
@crossdomain(origin='*')
def Prepare_and_Send_Default_Convention_From_Session_By_PDF(token, session_id, courrier_template_id):
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    payload = {}
    payload['token'] = str(token)
    payload['session_id'] = str(session_id)
    payload['courrier_template_id'] = str(courrier_template_id)

    print(" ### Prepare_and_Send_Default_Convention_From_Session_By_PDF : payload = ",str(payload))

    localStatus, response= SF.Prepare_and_Send_Default_Convention_From_Session_By_PDF(payload)
    if(localStatus ):
        return response
    else:
        return False



"""
API de generation de liste PDF des liste d'emargement
"""
@app.route('/myclass/api/GerneratePDFEmargementList/<token>/<session_id>/<internal_url>/<courrier_modele_id>', methods=['POST','GET'])
@crossdomain(origin='*')
def GerneratePDFEmargementList(token, session_id, internal_url, courrier_modele_id):
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    payload = {}
    payload['token'] = str(token)
    payload['session_id'] = str(session_id)
    payload['class_internal_url'] = str(internal_url)
    payload['courrier_template_id'] = str(courrier_modele_id)

    print(" ### GerneratePDFEmargementList : payload = ",str(payload))

    localStatus, response= emargement.GerneratePDFEmargementList(payload)
    if(localStatus ):
        return response
    else:
        return False



"""
API d'Envoie de l'email de confirmation de l'inscription 
"""
@app.route('/myclass/api/SendInscriptionConfirmation/', methods=['POST','GET'])
@crossdomain(origin='*')
def SendInscriptionConfirmation():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### incription_training_confirmation_mail : payload = ",str(payload))
    localStatus, message= inscription.SendInscriptionConfirmation(payload)
    return jsonify(status=localStatus, message=message )

"""
API d'Envoie de l'email de pre-inscription à une formation 
"""
@app.route('/myclass/api/SendPre_InscriptionEmail/', methods=['POST','GET'])
@crossdomain(origin='*')
def SendPre_InscriptionEmail():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### SendPre_InscriptionEmail : payload = ",str(payload))
    localStatus, message= inscription.SendPre_InscriptionEmail(payload)
    return jsonify(status=localStatus, message=message )



"""
API pour tester les nice emails de cherif (alternative à sendinblu)
"""
@app.route('/myclass/api/MysyGenericEmail_tpl/', methods=['POST','GET'])
@crossdomain(origin='*')
def MysyGenericEmail_tpl():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### MysyGenericEmail : payload = ",str(payload))
    localStatus, message= emails.MysyGenericEmail_tpl()
    return jsonify(status=localStatus, message=message )

@app.route('/myclass/api/MysyOrderEmail_tpl/', methods=['POST','GET'])
@crossdomain(origin='*')
def MysyOrderEmail_tpl():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### MysyOrderEmail_tpl : payload = ",str(payload))
    localStatus, message= emails.MysyOrderEmail_tpl()
    return jsonify(status=localStatus, message=message )



"""
API de recuperation de liste de OPCO
"""
@app.route('/myclass/api/GetListOpco/', methods=['POST','GET'])
@crossdomain(origin='*')
def GetListOpco():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### GetListOpco : payload = ",str(payload))
    localStatus, message= opco.GetListOpco()
    return jsonify(status=localStatus, message=message )


"""
API de demande d'information sur une formation
"""
@app.route('/myclass/api/RenseignementClass/', methods=['POST','GET'])
@crossdomain(origin='*')
def RenseignementClass():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### RenseignementClass : payload = ",str(payload))
    localStatus, message= cm.RenseignementClass(payload)
    return jsonify(status=localStatus, message=message )



"""
Cette API permet de supprimer une formation si elle n'a aucune session
de formation valide. la fonction utilise l'_id
"""
@app.route('/myclass/api/delete_Class/', methods=['POST','GET'])
@crossdomain(origin='*')
def delete_Class():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### delete_Class : payload = ",str(payload))
    localStatus, message= cm.delete_Class(payload)
    return jsonify(status=localStatus, message=message )


"""
API de suppression d'une liste de formation en utilisant l'_id

"""
@app.route('/myclass/api/delete_list_Class/', methods=['POST','GET'])
@crossdomain(origin='*')
def delete_list_Class():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### delete_list_Class : payload = ",str(payload))
    localStatus, message= cm.delete_list_Class(payload)
    return jsonify(status=localStatus, message=message )


"""
Cette API permet de supprimer une formation si elle n'a aucune session
de formation valide. la fonction utilise l'internal_url
"""
@app.route('/myclass/api/delete_Class_by_internal_url/', methods=['POST','GET'])
@crossdomain(origin='*')
def delete_Class_by_internal_url():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### delete_Class_by_internal_url : payload = ",str(payload))
    localStatus, message= cm.delete_Class_by_internal_url(payload)
    return jsonify(status=localStatus, message=message )


"""
Cette API retourne une formation, en partant de l'internal url de la formation
"""
@app.route('/myclass/api/get_Class_From_Internal_Url/', methods=['POST','GET'])
@crossdomain(origin='*')
def get_Class_From_Internal_Url():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### get_Class_From_Internal_Url : payload = ",str(payload))
    localStatus, message= cm.get_Class_From_Internal_Url(payload)
    return jsonify(status=localStatus, message=message )


"""
Cette API retourne une formation, en partant  l'url de la formation
/!\ : on ne fais pas de controle de recid (car c'est le bot admin qui doit l'utiliser (revoir cette logique plus tard)
"""
@app.route('/myclass/api/get_Class_From_Url/', methods=['POST','GET'])
@crossdomain(origin='*')
def get_Class_From_Url():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### get_Class_From_Url : payload = ",str(payload))
    localStatus, message= cm.get_Class_From_Url(payload)
    return jsonify(status=localStatus, message=message )


"""
API pour dubliquer une formation en partant de l'_id
"""
@app.route('/myclass/api/Duplicate_Class/', methods=['POST','GET'])
@crossdomain(origin='*')
def Duplicate_Class():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### Duplicate_Class : payload = ",str(payload))
    localStatus, message= cm.Duplicate_Class(payload)
    return jsonify(status=localStatus, message=message )



"""
API pour dubliquer une formation en partant de l'internal_url
"""
@app.route('/myclass/api/Duplicate_Class_from_internal_url/', methods=['POST','GET'])
@crossdomain(origin='*')
def Duplicate_Class_from_internal_url():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### Duplicate_Class_from_internal_url : payload = ",str(payload))
    localStatus, message= cm.Duplicate_Class_from_internal_url(payload)
    return jsonify(status=localStatus, message=message )


"""
API pour recuperer la liste des niveaux de formation
"""
@app.route('/myclass/api/Get_List_Class_Niveau_Formation/', methods=['POST','GET'])
@crossdomain(origin='*')
def Get_List_Class_Niveau_Formation():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### Get_List_Class_Niveau_Formation : payload = ",str(payload))
    localStatus, message= cm.Get_List_Class_Niveau_Formation(payload)
    return jsonify(status=localStatus, message=message )




"""
API d'envoi de la liste d'emargement
"""
@app.route('/myclass/api/EmargementMail/', methods=['POST','GET'])
@crossdomain(origin='*')
def EmargementMail():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### EmargementMail : payload = ",str(payload))
    localStatus, message= emails.SendEmargementMail(payload)
    return jsonify(status=localStatus, message=message )



"""
Cette API permet de faire l'emargement par un utilisateur
"""
@app.route('/myclass/api/UserEmargementValidation/<value>/<session>', methods=['GET','POST'])
@crossdomain(origin='*')
def UserEmargementValidation(value, session):

    print(" ### UserEmargementValidation value = "+str(value)+" session =  "+str(session))
    diction = {'value':str(value), 'session':str(session)}
    status, message = mycommon.UserEmargementValidation(diction)

    url = ""

    if( status ):
        if (MYSY_GV.MYSY_ENV == "PROD"):
            url = 'https://www.mysy-training.comEmargement/'
        elif (MYSY_GV.MYSY_ENV == "DEV"):
            url = 'http://localhost:3009/Emargement/'
        elif (MYSY_GV.MYSY_ENV == "REC"):
            url = 'https://dev.mysy-training.com/Emargement/'

        elif (MYSY_GV.MYSY_ENV == "DEM"):
            url = 'https://demo.mysy-training.com/Emargement/'

    else:
        if (MYSY_GV.MYSY_ENV == "PROD"):
            url = 'https://www.mysy-training.com/erreur'

        elif (MYSY_GV.MYSY_ENV == "DEV"):
            url = 'http://localhost:3009/erreur/'

        elif (MYSY_GV.MYSY_ENV == "REC"):
            url = 'https://dev.mysy-training.com/erreur'
        elif (MYSY_GV.MYSY_ENV == "DEM"):
            url = 'https://demo.mysy-training.com/erreur'

    return  redirect(url)

"""
API d'envoi d'une facture manuelle avec RIB
"""
@app.route('/myclass/api/ManualSendInvoiceEmailRIB/', methods=['POST','GET'])
@crossdomain(origin='*')
def ManualSendInvoiceEmailRIB():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### EmargementMail : payload = ",str(payload))
    localStatus, message= emails.ManualSendInvoiceEmailRIB(payload)
    return jsonify(status=localStatus, message=message )


"""
API d'envoi d'une facture manuelle avec RIB pour port cities
"""
@app.route('/myclass/api/ManualSendInvoiceEmailRIB_PortCities/', methods=['POST','GET'])
@crossdomain(origin='*')
def ManualSendInvoiceEmailRIB_PortCities():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### EmargementMail : payload = ",str(payload))
    localStatus, message= emails.ManualSendInvoiceEmailRIB_PortCities(payload)
    return jsonify(status=localStatus, message=message )



"""
API de recuperation au formation CSV de la liste des inscrits à une formation
avec les statuts (validé ou pas)
"""
@app.route('/myclass/api/DownloadParticipantsList/<token>/<sessionid>/<internal_url>', methods=['GET','POST'])
@crossdomain(origin='*')
def DownloadParticipantsList(sessionid, token, internal_url):
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    payload = {}
    payload['token'] = str(token)
    payload['session_id'] = str(sessionid)
    payload['internal_url'] = str(internal_url)
    print(" ### DownloadParticipantsList payload facture = ", str(payload))
    local_status, local_file =  inscription.DownloadParticipantsList(payload)
    if( local_status is False ):
        return ""

    return local_file


"""
Cette API imprime le detail des evaluations d'une formation au format excel
"""
@app.route('/myclass/api/DownloadEvaluationList/<token>/<sessionid>/<internal_url>', methods=['GET','POST'])
@crossdomain(origin='*')
def DownloadEvaluationList(sessionid, token, internal_url):
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    payload = {}
    payload['token'] = str(token)
    payload['session_id'] = str(sessionid)
    payload['internal_url'] = str(internal_url)
    print(" ### DownloadEvaluationList payload facture = ", str(payload))
    local_status, local_file =  inscription.DownloadEvaluationList(payload)
    if( local_status is False ):
        return ""

    return local_file





"""
API d'import des stagaires en masse avec un fichier csv
"""

@app.route('/myclass/api/AddStagiairetoClass_mass/', methods=['POST','GET'])
@crossdomain(origin='*')
def AddStagiairetoClass_mass():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### AddStagiairetoClass_mass payload = ",payload)
    #print(request.files)

    if request.method == 'POST':
        # Create variable for uploaded file
        f = request.files['File']
        localStatus, message = inscription.AddStagiairetoClass_mass(f, MYSY_GV.TEMPORARY_DIRECTORY_V2, payload)
        #status, retval = cm.add_class_mass(f, app.config['UPLOAD_FOLDER'], payload)

        return jsonify(status=localStatus, message=message)



"""
API d'import en masse de stagiaire avec pour plusieurs sessions et formations differentes
"""
@app.route('/myclass/api/AddStagiairetoClass_mass_for_many_session/', methods=['POST','GET'])
@crossdomain(origin='*')
def AddStagiairetoClass_mass_for_many_session():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### AddStagiairetoClass_mass_for_many_session payload = ",payload)
    #print(request.files)

    if request.method == 'POST':
        # Create variable for uploaded file
        f = request.files['File']
        localStatus, message = inscription.AddStagiairetoClass_mass_for_many_session(f, MYSY_GV.TEMPORARY_DIRECTORY_V2, payload)
        #status, retval = cm.add_class_mass(f, app.config['UPLOAD_FOLDER'], payload)

        return jsonify(status=localStatus, message=message)





""" 
API d'import en masse des sessions de formation
"""
@app.route('/myclass/api/Add_Update_SessionFormation_mass/', methods=['POST','GET'])
@crossdomain(origin='*')
def Add_Update_SessionFormation_mass():

# On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### Add_Update_SessionFormation_mass payload = ",payload)
    #print(request.files)

    if request.method == 'POST':
        # Create variable for uploaded file
        f = request.files['File']
        localStatus, message = SF.Add_Update_SessionFormation_mass(f, MYSY_GV.TEMPORARY_DIRECTORY_V2, payload)
        #status, retval = cm.add_class_mass(f, app.config['UPLOAD_FOLDER'], payload)

        return jsonify(status=localStatus, message=message)

""" 
API d'import en masse des sessions pour plusieurs formations dans le meme fichier
"""
@app.route('/myclass/api/Add_Update_SessionFormation_mass_for_many_class/', methods=['POST','GET'])
@crossdomain(origin='*')
def Add_Update_SessionFormation_mass_for_many_class():

# On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### Add_Update_SessionFormation_mass_for_many_class payload = ",payload)
    #print(request.files)

    if request.method == 'POST':
        # Create variable for uploaded file
        f = request.files['File']
        localStatus, message = SF.Add_Update_SessionFormation_mass_for_many_class(f, MYSY_GV.TEMPORARY_DIRECTORY_V2, payload)
        #status, retval = cm.add_class_mass(f, app.config['UPLOAD_FOLDER'], payload)

        return jsonify(status=localStatus, message=message)



"""
API de recuperation des infos detaillées d'un stagiaire pour une session
"""

@app.route('/myclass/api/GetAttendeeDetail_perSession/', methods=['POST','GET'])
@crossdomain(origin='*')
def GetAttendeeDetail_perSession():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### GetAttendeeDetail_perSession : payload = ",str(payload))
    localStatus, message= mycommon.GetAttendeeDetail_perSession(payload)
    return jsonify(status=localStatus, message=message )


"""
API de recuperation, de liste des attestions et certificats
"""
@app.route('/myclass/api/GetPartnerAttestation_Certificat/', methods=['POST','GET'])
@crossdomain(origin='*')
def GetPartnerAttestation_Certificat():
    # On recupere le corps (payload) de la requet
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### GetPartnerAttestation_Certificat : payload = ",str(payload))
    localStatus, message= Att_Cert.GetPartnerAttestation_Certificat(payload)
    return jsonify(status=localStatus, message=message )

"""
API de recuperation des données d'une attestation
"""
@app.route('/myclass/api/GetSpecificPartnerAttestation_Certificat/', methods=['POST','GET'])
@crossdomain(origin='*')
def GetSpecificPartnerAttestation_Certificat():
    # On recupere le corps (payload) de la requet
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### GetSpecificPartnerAttestation_Certificat : payload = ",str(payload))
    localStatus, message= Att_Cert.GetSpecificPartnerAttestation_Certificat(payload)
    return jsonify(status=localStatus, message=message )



"""
API de generation de liste PDF des liste d'emargement
"""
@app.route('/myclass/api/PrintAttendeeDetail_perSession/<token>/<session_id>/<attendee_email>/<internal_url>', methods=['POST','GET'])
@crossdomain(origin='*')
def PrintAttendeeDetail_perSession(token, session_id, attendee_email, internal_url):
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    payload = {}
    payload['token'] = str(token)
    payload['session_id'] = str(session_id)
    payload['attendee_email'] = str(attendee_email)
    payload['internal_url'] = str(internal_url)
    print(" ### PrintAttendeeDetail_perSession : payload = ",str(payload))

    localStatus, response= inscription.PrintAttendeeDetail_perSession(payload)
    if(localStatus ):
        return response
    else:
        return False


""" API de verification du token d'evaluation 
"""
@app.route('/myclass/api/MySyckeckEvaluationToken/', methods=['POST','GET'])
@crossdomain(origin='*')
def MySyckeckEvaluationToken():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### ckeckEvaluationToken : payload = ",payload)
    localStatus, message= inscription.MySyckeckEvaluationToken(payload)
    return jsonify(status=localStatus, message=message )

"""
API d'evaluation d'une formation
"""
@app.route('/myclass/api/Evaluation_Class/', methods=['POST','GET'])
@crossdomain(origin='*')
def Evaluation_Class():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### Evaluation_Class : payload = ",payload)
    localStatus, message= inscription.Evaluation_Class(payload)
    return jsonify(status=localStatus, message=message )

"""
API Qui declenche l'envoi de l'email d'evaluation d'une formation
"""
@app.route('/myclass/api/SendTrainingEvaluationEmail/', methods=['POST','GET'])
@crossdomain(origin='*')
def SendTrainingEvaluationEmail():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### SendTrainingEvaluationEmail : payload = ",payload)
    localStatus, message= inscription.SendTrainingEvaluationEmail(payload)
    return jsonify(status=localStatus, message=message )



"""
Cette fonction envoie l'email de demande d'evaluation from tab_ids
"""
@app.route('/myclass/api/SendTrainingEvaluationEmail_from_tab_ids/', methods=['POST','GET'])
@crossdomain(origin='*')
def SendTrainingEvaluationEmail_from_tab_ids():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### SendTrainingEvaluationEmail_from_tab_ids : payload = ",payload)
    localStatus, message= inscription.SendTrainingEvaluationEmail_from_tab_ids(payload)
    return jsonify(status=localStatus, message=message )




"""
API Qui declenche l'envoi de l'attestation de formation par email
"""
@app.route('/myclass/api/SendAttendeeCertification/', methods=['POST','GET'])
@crossdomain(origin='*')
def SendAttendeeCertification():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### SendAttendeeCertification : payload = ",payload)
    localStatus, message= inscription.SendAttendeeCertification(payload)
    return jsonify(status=localStatus, message=message )

"""
API qui imprime l'attestation de formation d'un participant
"""
@app.route('/myclass/api/PrintAttendeeCertification/<token>/<session_id>/<attendee_email>/<internal_url>', methods=['POST','GET'])
@crossdomain(origin='*')
def PrintAttendeeCertification(token, session_id, attendee_email, internal_url):
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    payload = {}
    payload['token'] = str(token)
    payload['session_id'] = str(session_id)
    payload['attendee_email'] = str(attendee_email)
    payload['internal_url'] = str(internal_url)
    print(" ### PrintAttendeeCertification : payload = ", str(payload))

    localStatus, response = inscription.PrintAttendeeCertification(payload)
    if (localStatus):
        return response
    else:
        return False


"""
Cette API retourne la liste des evalutions d'une session de formation
"""
@app.route('/myclass/api/GetListEvaluation_Session/', methods=['POST','GET'])
@crossdomain(origin='*')
def GetListEvaluation_Session():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### GetListEvaluation_Session : payload = ",payload)
    localStatus, message= inscription.GetListEvaluation_Session(payload)
    return jsonify(status=localStatus, message=message )


"""
API de recuperation de liste des liste_domaine_metier
"""
@app.route('/myclass/api/get_List_domaine_formation/', methods=['POST','GET'])
@crossdomain(origin='*')
def get_List_domaine_formation():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### get_List_domaine_formation : payload = ",str(payload))
    localStatus, message= mycommon.get_List_domaine_formation()
    return jsonify(status=localStatus, message=message )



"""
API de recuperation de liste des liste_domaine_metier en JSON
"""
@app.route('/myclass/api/get_List_domaine_formation_JSON/', methods=['POST','GET'])
@crossdomain(origin='*')
def get_List_domaine_formation_JSON():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### get_List_domaine_formation_JSON : payload = ",str(payload))
    localStatus, message= mycommon.get_List_domaine_formation_JSON()
    return jsonify(status=localStatus, message=message )



"""
Recuperation de la liste des domaines et metier 
"""
@app.route('/myclass/api/get_List_domaine_metier/', methods=['POST','GET'])
@crossdomain(origin='*')
def get_List_domaine_metier():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### get_List_domaine_metier : payload = ",str(payload))
    localStatus, message= mycommon.get_List_domaine_metier()
    return jsonify(status=localStatus, message=message )

"""
Cette API retour la liste distinct des metiers
"""
@app.route('/myclass/api/get_List_metier_formation/', methods=['POST','GET'])
@crossdomain(origin='*')
def get_List_metier_formation():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### get_List_metier_formation : payload = ",str(payload))
    localStatus, message= mycommon.get_List_metier_formation()
    return jsonify(status=localStatus, message=message )


"""
Cette API retour la liste distinct des metiers en mode JSON
"""
@app.route('/myclass/api/get_List_metier_formation_JSON/', methods=['POST','GET'])
@crossdomain(origin='*')
def get_List_metier_formation_JSON():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### get_List_metier_formation_JSON : payload = ",str(payload))
    localStatus, message= mycommon.get_List_metier_formation_JSON()
    return jsonify(status=localStatus, message=message )


"""
API pour recupérer tout le contenu valide de la collection :  liste_domaine_metier
"""
@app.route('/myclass/api/get_List_all_metier_formation/', methods=['POST','GET'])
@crossdomain(origin='*')
def get_List_all_metier_formation():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### get_List_all_metier_formation : payload = ",str(payload))
    localStatus, message= mycommon.get_List_all_metier_formation()
    return jsonify(status=localStatus, message=message )



"""
API de verification de la vlidation d'un email 
"""

@app.route('/myclass/api/email_validation/', methods=['POST','GET'])
@crossdomain(origin='*')
def email_validation():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### email_validation : payload = ",payload)
    localStatus, message= tools_cherif.email_validation()
    return jsonify(status=localStatus, message=message )



"""
Dirty fonction 
"""
@app.route('/myclass/api/dirty/', methods=['POST','GET'])
@crossdomain(origin='*')
def dirty():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### dirty : payload = ",payload)
    localStatus, message= tools_cherif.dirty()
    return jsonify(status=localStatus, message=message )
"""
Cette API test SOAP Mysy 
"""
@app.route('/myclass/api/mysysoap/', methods=['POST','GET'])
@crossdomain(origin='*')
def mysysoap():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### dirty : payload = ",payload)
    localStatus, message= tools_cherif.mysysoap()
    return jsonify(status=localStatus, message=message )


@app.route('/myclass/api/mysylmsdb/', methods=['POST','GET'])
@crossdomain(origin='*')
def mysylmsdb():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### mysylmsdb : payload = ",payload)
    localStatus, message= tools_cherif.mysylmsdb()
    return jsonify(status=localStatus, message=message )


"""
API de test de fonctionnement du webservice 
"""
@app.route('/myclass/api/test_web_service/<token>/<invoiceid>', methods=['POST','GET'])
@crossdomain(origin='*')
def test_web_service(invoiceid, token):
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    payload = {}
    payload['token'] = str(token)
    payload['invoiceid'] = str(invoiceid)

    print(" ### payload facture = ", str(invoiceid), " token = ",str(token))
    localStatus, message= tools_cherif.test_web_service(payload)
    return jsonify(status=localStatus, message=message )


@app.route('/myclass/api/test_web_service2/', methods=['POST','GET'])
@crossdomain(origin='*')
def test_web_service2():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### email_validation : payload = ", payload)
    localStatus, message = tools_cherif.test_web_service2(payload)
    return jsonify(status=localStatus, message=message)

"""
Cette API  permet de tester l'utilisation de jinja2  avec
des informations stockées dans une base de données
"""
@app.route('/myclass/api/test_jnja2_database/', methods=['POST','GET'])
@crossdomain(origin='*')
def test_jnja2_database():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### test_jnja2_database : payload = ", payload)
    localStatus, message = tools_cherif.test_jnja2_database(payload)
    return jsonify(status=localStatus, message=message)


"""
API Test : Recuperation des collections et champ personnalisables
"""
@app.route('/myclass/api/Get_Personnalisable_Collection_Fields/', methods=['POST','GET'])
@crossdomain(origin='*')
def Get_Personnalisable_Collection_Fields():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### Get_Personnalisable_Collection_Fields : payload = ", payload)
    localStatus, message = tools_cherif.Get_Personnalisable_Collection_Fields()
    return jsonify(status=localStatus, message=message)



"API qui retourne la liste des champs personalisables"
@app.route('/myclass/api/Get_Personnalisable_Collection/', methods=['POST','GET'])
@crossdomain(origin='*')
def Get_Personnalisable_Collection():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### Get_Personnalisable_Collection : payload = ", payload)
    localStatus, message = tools_cherif.Get_Personnalisable_Collection()
    return jsonify(status=localStatus, message=message)


"""
API qui lit depuis la base recette et ecrit dans la base de demo
"""
"API qui retourne la liste des champs personalisables"
@app.route('/myclass/api/Delete_And_Load_DB_Collection_to_DB_Collection_For_Demo_Env/', methods=['POST','GET'])
@crossdomain(origin='*')
def Delete_And_Load_DB_Collection_to_DB_Collection_For_Demo_Env():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### Delete_And_Load_DB_Collection_to_DB_Collection_For_Demo_Env : payload = ", payload)
    localStatus, message = tools_cherif.Delete_And_Load_DB_Collection_to_DB_Collection_For_Demo_Env()
    return jsonify(status=localStatus, message=message)

# PROD
@app.route('/myclass/api/Delete_And_Load_DB_Collection_to_DB_Collection_For_PROD_Env/', methods=['POST','GET'])
@crossdomain(origin='*')
def Delete_And_Load_DB_Collection_to_DB_Collection_For_PROD_Env():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### Delete_And_Load_DB_Collection_to_DB_Collection_For_PROD_Env : payload = ", payload)
    localStatus, message = tools_cherif.Delete_And_Load_DB_Collection_to_DB_Collection_For_PROD_Env()
    return jsonify(status=localStatus, message=message)



"""
API de migration des formations
"""
@app.route('/myclass/api/Delete_And_Load_DB_Collection_MyClass_to_DB_Collection_For_Demo_Env/', methods=['POST','GET'])
@crossdomain(origin='*')
def Delete_And_Load_DB_Collection_MyClass_to_DB_Collection_For_Demo_Env():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### Delete_And_Load_DB_Collection_MyClass_to_DB_Collection_For_Demo_Env : payload = ", payload)
    localStatus, message = tools_cherif.Delete_And_Load_DB_Collection_MyClass_to_DB_Collection_For_Demo_Env()
    return jsonify(status=localStatus, message=message)

"""
API de migration des compte partenaires
"""
@app.route('/myclass/api/Delete_And_Load_DB_Collection_partnair_account_to_DB_Collection_For_Demo_Env/', methods=['POST','GET'])
@crossdomain(origin='*')
def Delete_And_Load_DB_Collection_partnair_account_to_DB_Collection_For_Demo_Env():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### Delete_And_Load_DB_Collection_partnair_account_to_DB_Collection_For_Demo_Env : payload = ", payload)
    localStatus, message = tools_cherif.Delete_And_Load_DB_Collection_partnair_account_to_DB_Collection_For_Demo_Env()
    return jsonify(status=localStatus, message=message)



"""
API de migration de collection (a supprimer)
"""
@app.route('/myclass/api/Delete_And_Load_DB_Collection_courrier_template_From_rec_to_Demo_Env/', methods=['POST','GET'])
@crossdomain(origin='*')
def Delete_And_Load_DB_Collection_courrier_template_From_rec_to_Demo_Env():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### Delete_And_Load_DB_Collection_courrier_template_From_rec_to_Demo_Env : payload = ", payload)
    localStatus, message = tools_cherif.Delete_And_Load_DB_Collection_courrier_template_From_rec_to_Demo_Env()
    return jsonify(status=localStatus, message=message)





"""
Cette API créer un user LMS Mysy, c'est a dire un user chamilo
"""
@app.route('/myclass/api/Create_MySy_LMS_User/', methods=['POST','GET'])
@crossdomain(origin='*')
def Create_MySy_LMS_User():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### Create_MySy_LMS_User : payload = ",payload)
    localStatus, message, lms_user_id = mysy_lms.Create_MySy_LMS_User(payload)
    return jsonify(status=localStatus, message=message , lms_user_id=lms_user_id)

"""
Cette API permettre de mettre à jour le mot de passe dans le LMS
"""
@app.route('/myclass/api/Update_Passwd_MySy_LMS_User/', methods=['POST','GET'])
@crossdomain(origin='*')
def Update_Passwd_MySy_LMS_User():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### Update_Passwd_MySy_LMS_User : payload = ",payload)
    localStatus, message, lms_user_id = mysy_lms.Update_Passwd_MySy_LMS_User(payload)
    return jsonify(status=localStatus, message=message, lms_user_id=lms_user_id)

"""
Cette API met à jour le pack et nombre de formations dans LSM Mysy, c'est a dire chamilo
"""
@app.route('/myclass/api/Update_Pack_MySy_LMS_User/', methods=['POST','GET'])
@crossdomain(origin='*')
def Update_Pack_MySy_LMS_User():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### Update_Pack_MySy_LMS_User : payload = ",payload)
    localStatus, message, lms_user_id = mysy_lms.Update_Pack_MySy_LMS_User(payload)
    return jsonify(status=localStatus, message=message, lms_user_id=lms_user_id)

"""
Cette API permet de desactivier un utilisateur ainsi que les formations qui sont rattachées 
"""
@app.route('/myclass/api/Disable_MySy_LMS_User/', methods=['POST','GET'])
@crossdomain(origin='*')
def Disable_MySy_LMS_User():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### Disable_MySy_LMS_User : payload = ",payload)
    localStatus, message = mysy_lms.Disable_MySy_LMS_User(payload)
    return jsonify(status=localStatus, message=message)


"""
Cette API permet de Reactivier le compte utilisateur. on ne reactive pas les formations, s'il y en a. l'utilisateur doit contacter le support pr cela 
"""
@app.route('/myclass/api/Enable_MySy_LMS_User/', methods=['POST','GET'])
@crossdomain(origin='*')
def Enable_MySy_LMS_User():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### Enable_MySy_LMS_User : payload = ",payload)
    localStatus, message = mysy_lms.Enable_MySy_LMS_User(payload)
    return jsonify(status=localStatus, message=message)




@app.route('/myclass/api/email_validation_mairies/', methods=['POST','GET'])
@crossdomain(origin='*')
def email_validation_mairies():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### email_validation_mairies : payload = ",payload)
    localStatus, message= tools_cherif.email_validation_mairies()
    return jsonify(status=localStatus, message=message )

@app.route('/myclass/api/email_validation_hopitaux_ehpad/', methods=['POST','GET'])
@crossdomain(origin='*')
def email_validation_hopitaux_ehpad():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### email_validation_hopitaux_ehpad : payload = ",payload)
    localStatus, message= tools_cherif.email_validation_hopitaux_ehpad()
    return jsonify(status=localStatus, message=message )

@app.route('/myclass/api/email_validation_list_pos_bio/', methods=['POST','GET'])
@crossdomain(origin='*')
def email_validation_list_pos_bio():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### email_validation_list_pos_bio : payload = ",payload)
    localStatus, message= tools_cherif.email_validation_list_pos_bio()
    return jsonify(status=localStatus, message=message )

@app.route('/myclass/api/test_tab_mail/', methods=['POST','GET'])
@crossdomain(origin='*')
def test_tab_mail():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### test_tab_mail : payload = ",payload)
    localStatus, message= tools_cherif.test_tab_mail(payload)
    return jsonify(status=localStatus, message=message )




"""
Cette API permet de desabonner une personne 
"""
@app.route('/myclass/api/Sedesabonner/', methods=['POST','GET'])
@crossdomain(origin='*')
def Sedesabonner():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### Sedesabonner : payload = ",payload)
    localStatus, message= mycommon.Sedesabonner(payload)
    return jsonify(status=localStatus, message=message )


"""
Stripe Payement : Arret d'un abonnement à la fin du mois en cours
"""
@app.route('/myclass/api/stop_strip_subscription/', methods=['POST','GET'])
@crossdomain(origin='*')
def stop_strip_subscription():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### stop_strip_subscription : payload = ",payload)
    localStatus, message = Stripe.stop_strip_subscription(payload)
    return jsonify(status=localStatus, message=message )



"""
Cette API verifie le statut d'un payement 
"""
@app.route('/myclass/api/payment_retrieve_status/', methods=['POST','GET'])
@crossdomain(origin='*')
def payment_retrieve_status():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### payment_retrieve_status : payload = ",payload)
    localStatus, message = Stripe.payment_retrieve_status(payload)
    return jsonify(status=localStatus, message=message )

"""
Cette API envoyer une attestation de formation
"""
@app.route('/myclass/api/SendAttestion_to_attendee_by_email_standalone/', methods=['POST','GET'])
@crossdomain(origin='*')
def SendAttestion_to_attendee_by_email_standalone():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### emails_support : payload = ",payload)
    localStatus, message = emails_support.SendAttestion_to_attendee_by_email_standalone(payload)
    return jsonify(status=localStatus, message=message )


@app.route('/myclass/api/sendmailwith_attached/', methods=['POST','GET'])
@crossdomain(origin='*')
def sendmailwith_attached():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### sendmailwith_attached : payload = ",payload)
    localStatus, message = emails_support.sendmailwith_attached()
    return jsonify(status=localStatus, message=message )



"""
API de test pour envoyer la notif d'evaluation
"""
@app.route('/myclass/api/EmailNotifEvaluation_Done/', methods=['POST','GET'])
@crossdomain(origin='*')
def EmailNotifEvaluation_Done():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### EmailNotifEvaluation_Done : payload = ",payload)
    localStatus, message = emails.EmailNotifEvaluation_Done()
    return jsonify(status=localStatus, message=message )




"""
Cette API verifie l'existance ou non d'une commande vente
"""
@app.route('/myclass/api/CheckSalesOrder/', methods=['POST','GET'])
@crossdomain(origin='*')
def CheckSalesOrder():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### CheckSalesOrder : payload = ",payload)
    localStatus, message = mycommon.CheckSalesOrder(payload)
    return jsonify(status=localStatus, message=message )


"""
Cette API ajoute un business price
"""
@app.route('/myclass/api/add_business_price/', methods=['POST','GET'])
@crossdomain(origin='*')
def add_business_price():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### add_business_price : payload = ",payload)
    localStatus, message = business_prices.add_business_price(payload)
    return jsonify(status=localStatus, message=message )


"""
Cette API modifie  un business price
"""
@app.route('/myclass/api/update_business_price/', methods=['POST','GET'])
@crossdomain(origin='*')
def update_business_price():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### update_business_price : payload = ",payload)
    localStatus, message = business_prices.update_business_price(payload)
    return jsonify(status=localStatus, message=message )

"""
Cette API supprime  un business price
"""
@app.route('/myclass/api/delete_business_price/', methods=['POST','GET'])
@crossdomain(origin='*')
def delete_business_price():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### delete_business_price : payload = ",payload)
    localStatus, message = business_prices.delete_business_price(payload)
    return jsonify(status=localStatus, message=message )

"""
Cette API recupere liste de prix client d'un partenaire
"""
@app.route('/myclass/api/get_cust_prices_by_partner/', methods=['POST','GET'])
@crossdomain(origin='*')
def get_cust_prices_by_partner():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### get_cust_prices_by_partner : payload = ",payload)
    localStatus, message = business_prices.get_cust_prices_by_partner(payload)
    return jsonify(status=localStatus, message=message )


"""
Cette API retourne une ligne de prix donnée
"""
@app.route('/myclass/api/get_cust_specific_prices_by_partner/', methods=['POST','GET'])
@crossdomain(origin='*')
def get_cust_specific_prices_by_partner():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### get_cust_specific_prices_by_partner : payload = ",payload)
    localStatus, message = business_prices.get_cust_specific_prices_by_partner(payload)
    return jsonify(status=localStatus, message=message )



"""
Cette API retourne la liste des client rattaché à partenaire
"""
@app.route('/myclass/api/get_linked_customer_to_partner/', methods=['POST','GET'])
@crossdomain(origin='*')
def get_linked_customer_to_partner():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### get_linked_customer_to_partner : payload = ",payload)
    localStatus, message = business_prices.get_linked_customer_to_partner(payload)
    return jsonify(status=localStatus, message=message )


"""
Cette API recherche  un business price
"""
@app.route('/myclass/api/recherche_business_price/', methods=['POST','GET'])
@crossdomain(origin='*')
def recherche_business_price():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### recherche_business_price : payload = ",payload)
    localStatus, message = business_prices.recherche_business_price(payload)
    return jsonify(status=localStatus, message=message )


"""
Cette API verifie si un client mysy existe sur chamilo.
Si le client n'existe pas, il le crée avec le pack et le bon nombre de formation
/!\ : On stock dans mysy (collection partnair_account) l'id chamilo du user.
    le nom du champ est : mysy_lms_user_id/
"""
@app.route('/myclass/api/Check_MySy_LMS_Account/', methods=['POST','GET'])
@crossdomain(origin='*')
def Check_MySy_LMS_Account():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### Check_MySy_LMS_User : payload = ",payload)
    localStatus, message = mysy_lms.Check_MySy_LMS_Account(payload)
    return jsonify(status=localStatus, message=message)


"""
Cette API récupérer le nombre de formation active dans Mysy et dans le LMS
la valeur retournée est de type : true, nb_active_mysy, nb_active_lms, message
"""
@app.route('/myclass/api/Get_Active_Ftions_Mysy_and_Lms/', methods=['POST','GET'])
@crossdomain(origin='*')
def Get_Active_Ftions_Mysy_and_Lms():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### Get_Active_Ftions_Mysy_and_Lms : payload = ",payload)
    localStatus, mysy_nb_active_class, lms_nb_active_class, message = mysy_lms.Get_Active_Ftions_Mysy_and_Lms(payload)
    return jsonify(status=localStatus, mysy_nb_active_class = mysy_nb_active_class, lms_nb_active_class = lms_nb_active_class, message=message)


"""
Cette API permet de modifier la quantité d'un abonnement.
On reste sur le meme prix. juste la quantité qui change
"""
@app.route('/myclass/api/strip_update_subscription_qty/', methods=['POST','GET'])
@crossdomain(origin='*')
def strip_update_subscription_qty():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### strip_update_subscription_qty : payload = ",payload)
    localStatus, message = Stripe.strip_update_subscription_qty(payload)
    return jsonify(status=localStatus,  message=message)

"""
Cette API permet de changer l'abonnement d'un client. c'est a dire le passage
de gold vers standart par exemple
"""
@app.route('/myclass/api/strip_update_subscription_plan/', methods=['POST','GET'])
@crossdomain(origin='*')
def strip_update_subscription_plan():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### strip_update_subscription_plan : payload = ",payload)
    localStatus, message = Stripe.strip_update_subscription_plan(payload)
    return jsonify(status=localStatus,  message=message)


"""
Cette API permet d'inscrire un utilisateur à une formation LMS chamilo
"""
@app.route('/myclass/api/Add_User_To_LMS_Class/', methods=['POST','GET'])
@crossdomain(origin='*')
def Add_User_To_LMS_Class():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### Add_User_To_LMS_Class : payload = ",payload)
    localStatus, message = mysy_lms.Add_User_To_LMS_Class(payload)
    return jsonify(status=localStatus, message=message)

"""
Cette API permet de desinscrire un utilisateur à une formation LMS chamilo
"""
@app.route('/myclass/api/Remove_User_From_LMS_Class/', methods=['POST','GET'])
@crossdomain(origin='*')
def Remove_User_From_LMS_Class():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### Remove_User_From_LMS_Class : payload = ",payload)
    localStatus, message = mysy_lms.Remove_User_From_LMS_Class(payload)
    return jsonify(status=localStatus, message=message)

"""
Cette API permet de créer un utilisateur apprenant dans le LMS
"""
@app.route('/myclass/api/Create_MySy_LMS_Apprenant/', methods=['POST','GET'])
@crossdomain(origin='*')
def Create_MySy_LMS_Apprenant():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### Create_MySy_LMS_Participant : payload = ",payload)
    localStatus, message, lms_user_id = mysy_lms.Create_MySy_LMS_Apprenant(payload)
    return jsonify(status=localStatus, message=message, lms_user_id=lms_user_id)


""""
Cette API annule des inscription deja validée
"""
@app.route('/myclass/api/CancelAttendeeInscription/', methods=['POST','GET'])
@crossdomain(origin='*')
def CancelAttendeeInscription():
    # On CancelAttendeeInscription le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### CancelAttendeeInscription : payload = ",payload)
    localStatus, message= inscription.CancelAttendeeInscription(payload)
    return jsonify(status=localStatus, message=message )

""""
Cette API supprime defitivement un inscription qui doit etre au statut 'annulé' ou 'prescrit'
"""
@app.route('/myclass/api/DeleteAttendeeInscription/', methods=['POST','GET'])
@crossdomain(origin='*')
def DeleteAttendeeInscription():
    # On CancelAttendeeInscription le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### DeleteAttendeeInscription : payload = ",payload)
    localStatus, message= inscription.DeleteAttendeeInscription(payload)
    return jsonify(status=localStatus, message=message )




"""
API de validation en masse des inscriptions 
"""
@app.route('/myclass/api/Accept_List_AttendeeInscription/', methods=['POST','GET'])
@crossdomain(origin='*')
def Accept_List_AttendeeInscription():
    # On CancelAttendeeInscription le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### Accept_List_AttendeeInscription : payload = ",payload)
    localStatus, message= inscription.Accept_List_AttendeeInscription(payload)
    return jsonify(status=localStatus, message=message )


"""
API de suppression en masse des stagiaires
"""
@app.route('/myclass/api/Delete_List_AttendeeInscription/', methods=['POST','GET'])
@crossdomain(origin='*')
def Delete_List_AttendeeInscription():
    # On CancelAttendeeInscription le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### Delete_List_AttendeeInscription : payload = ",payload)
    localStatus, message= inscription.Delete_List_AttendeeInscription(payload)
    return jsonify(status=localStatus, message=message )


"""
API de d'annulation d'une inscription avec mise à jour du motif
"""
@app.route('/myclass/api/RefuseAttendeeInscription_with_motif/', methods=['POST','GET'])
@crossdomain(origin='*')
def RefuseAttendeeInscription_with_motif():
    # On CancelAttendeeInscription le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### RefuseAttendeeInscription_with_motif : payload = ",payload)
    localStatus, message= inscription.RefuseAttendeeInscription_with_motif(payload)
    return jsonify(status=localStatus, message=message )


"""
API de d'annulation d'une liste inscription avec mise à jour du motif en masse
"""
@app.route('/myclass/api/Refuse_List_AttendeeInscription_with_motif/', methods=['POST','GET'])
@crossdomain(origin='*')
def Refuse_List_AttendeeInscription_with_motif():
    # On CancelAttendeeInscription le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### Refuse_List_AttendeeInscription_with_motif : payload = ",payload)
    localStatus, message= inscription.Refuse_List_AttendeeInscription_with_motif(payload)
    return jsonify(status=localStatus, message=message )


"""
API de validation d'une inscription d'un stagiaire
"""
@app.route('/myclass/api/AcceptAttendeeInscription/', methods=['POST','GET'])
@crossdomain(origin='*')
def AcceptAttendeeInscription():
    # On CancelAttendeeInscription le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### AcceptAttendeeInscription : payload = ",payload)
    localStatus, message= inscription.AcceptAttendeeInscription(payload)
    return jsonify(status=localStatus, message=message )



"""
Cette API permet d'envoyer les identifiants de connexion à la plateforme de plateforme LMS
"""
@app.route('/myclass/api/LMS_Credential_Sending_mail/', methods=['POST','GET'])
@crossdomain(origin='*')
def LMS_Credential_Sending_mail():

    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### LMS_Credential_Sending_mail : payload = ",payload)
    localStatus, message= inscription.Send_LMS_Credentials_to_particpants(payload)
    return jsonify(status=localStatus, message=message )



"""
Cette API récupérer les informations liée au LMS pour une partenaire
"""
@app.route('/myclass/api/LMS_Get_Partner_Data/', methods=['POST','GET'])
@crossdomain(origin='*')
def LMS_Get_Partner_Data():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### LMS_Get_Partner_Data : payload = ",payload)
    localStatus, message = mysy_lms.LMS_Get_Partner_Data(payload)
    return jsonify(status=localStatus, message=message )


"""
API de créer de l'url du lms
"""
@app.route('/myclass/api/LMS_Create_VirtualHost/', methods=['POST','GET'])
@crossdomain(origin='*')
def LMS_Create_VirtualHost():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### LMS_Create_VirtualHost : payload = ",payload)
    localStatus, message, virtualHost_Id, full_url = mysy_lms.LMS_Create_VirtualHost(payload)
    return jsonify(status=localStatus, message=message, virtualHost_Id= virtualHost_Id, full_url=full_url)


"""
API qui permet de récupérer les theme lms pour permettre à l'utilisateur
de configurer le theme qu'il souhaite
"""
@app.route('/myclass/api/Get_Lms_Themes/', methods=['POST','GET'])
@crossdomain(origin='*')
def Get_Lms_Themes():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### Get_Lms_Themes : payload = ",payload)
    localStatus, message = mysy_lms.Get_Lms_Themes(payload)
    return jsonify(status=localStatus, message=message)

"""
API de configuration du theme de LMS Chamilo
"""
@app.route('/myclass/api/Lms_Config_Theme_and_Logo/', methods=['POST','GET'])
@crossdomain(origin='*')
def Lms_Config_Theme_and_Logo():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### Lms_Config_Theme_and_Logo : payload = ",payload)
    localStatus, message = mysy_lms.Lms_Config_Theme_and_Logo(payload)
    return jsonify(status=localStatus, message=message)



"""
API Test de publicat des theme / Design LMS 
"""
@app.route('/myclass/api/Duplicate_LMS_Theme_Design/', methods=['POST','GET'])
@crossdomain(origin='*')
def Duplicate_LMS_Theme_Design():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### Duplicate_LMS_Theme_Design : payload = ",payload)
    localStatus, message = mysy_lms.Duplicate_LMS_Theme_Design(payload)
    return jsonify(status=localStatus, message=message)


"""
API pour supprimer le logo d'un thème
"""
@app.route('/myclass/api/Lms_Delete_Logo_File/', methods=['POST','GET'])
@crossdomain(origin='*')
def Lms_Delete_Logo_File():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### Lms_Delete_Logo_File : payload = ",payload)
    localStatus, message = mysy_lms.Lms_Delete_Logo_File(payload)
    return jsonify(status=localStatus, message=message)





"""
API pour supprimer le logo d'une bannière
"""
@app.route('/myclass/api/Lms_Delete_Banniere_File/', methods=['POST','GET'])
@crossdomain(origin='*')
def Lms_Delete_Banniere_File():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### Lms_Delete_Banniere_File : payload = ",payload)
    localStatus, message = mysy_lms.Lms_Delete_Banniere_File(payload)
    return jsonify(status=localStatus, message=message)



"""
API de recuperation des logo et bannière d'un LMS
"""
@app.route('/myclass/api/Get_LMS_Logo_And_Bannier_Img/', methods=['POST','GET'])
@crossdomain(origin='*')
def Get_LMS_Logo_And_Bannier_Img():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### Get_LMS_Logo_And_Bannier_Img : payload = ",payload)
    localStatus, message = mysy_lms.Get_LMS_Logo_And_Bannier_Img(payload)
    return jsonify(status=localStatus, message=message)

"""
API de recuperation du logo pour configuration du LMS
"""
@app.route('/myclass/api/Lms_Add_Logo_File/', methods=['POST','GET'])
@crossdomain(origin='*')
def Lms_Add_Logo_File():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### Lms_Add_Logo_File : payload = ",payload)
    if request.method == 'POST':
        # Create variable for uploaded file
        f = request.files['File']
        localStatus, message = mysy_lms.Lms_Add_Logo_File(f, app.config['UPLOAD_FOLDER'], payload)
    return jsonify(status=localStatus, message=message)


"""
API de recuperation du background pour configuration du LMS
"""
@app.route('/myclass/api/Lms_Add_BG_File/', methods=['POST','GET'])
@crossdomain(origin='*')
def Lms_Add_BG_File():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### Lms_Add_BG_File : payload = ",payload)
    if request.method == 'POST':
        # Create variable for uploaded file
        f = request.files['File']
        localStatus, message = mysy_lms.Lms_Add_BG_File(f, app.config['UPLOAD_FOLDER'], payload)
    return jsonify(status=localStatus, message=message)


"""
Test connexion localhost phpmyadmin
"""
@app.route('/myclass/api/test_connexion_php_myadmin/', methods=['POST','GET'])
@crossdomain(origin='*')
def test_connexion_php_myadmin():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### test_connexion_php_myadmin : payload = ",payload)
    localStatus, message = mysy_lms.test_connexion_php_myadmin()
    return jsonify(status=localStatus, message=message)


"""
Cette API permet de créer une formation du LMS vers le Search (de chamilo ver mysy)
"""
@app.route('/myclass/api/Create_Class_From_Lms/', methods=['POST','GET'])
@crossdomain(origin='*')
def Create_Class_From_Lms():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### Create_Class_From_Lms : payload = ",payload)
    localStatus, message = mysy_lms.Create_Class_From_Lms(payload)
    return jsonify(status=localStatus, message=message)


"""
Cette API permet de mettre à jour une formation du LMS vers le Search (de chamilo ver mysy)
"""
@app.route('/myclass/api/Update_Class_From_Lms/', methods=['POST','GET'])
@crossdomain(origin='*')
def Update_Class_From_Lms():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### Update_Class_From_Lms : payload = ",payload)
    localStatus, message = mysy_lms.Update_Class_From_Lms(payload)
    return jsonify(status=localStatus, message=message)

"""
Cette API depublie une formation dans le moteur de recherche en partant du LMS
"""
@app.route('/myclass/api/Unpublish_Class_From_Lms/', methods=['POST','GET'])
@crossdomain(origin='*')
def Unpublish_Class_From_Lms():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### Unpublish_Class_From_Lms : payload = ",payload)
    localStatus, message = mysy_lms.Unpublish_Class_From_Lms(payload)
    return jsonify(status=localStatus, message=message)



""" 
Cette API ajoute un code promo
"""
@app.route('/myclass/api/Add_Code_Promo/', methods=['POST','GET'])
@crossdomain(origin='*')
def Add_Code_Promo():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### code_promo_mgt : payload = ",payload)
    localStatus, message = code_promo_mgt.Add_Code_Promo(payload)
    return jsonify(status=localStatus, message=message)

"""
Cette API recupere les codes promo valides
 - valide = 1
 - Date debut et Date fin sont ok
 """
@app.route('/myclass/api/Get_Valide_Code_Promo/', methods=['POST','GET'])
@crossdomain(origin='*')
def Get_Valide_Code_Promo():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### Get_Valide_Code_Promo : payload = ",payload)
    localStatus, message = code_promo_mgt.Get_Valide_Code_Promo(payload)
    return jsonify(status=localStatus, message=message)


"""
Cette API verifie la validité d'un token partenaire
"""
@app.route('/myclass/api/check_partner_token_validity_v2/', methods=['POST','GET'])
@crossdomain(origin='*')
def check_partner_token_validity_v2():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### check_partner_token_validity_v2 : payload = ",payload)
    localStatus = mycommon.check_partner_token_validity_v2(payload)
    return jsonify(status=localStatus)

"""
Cette API retourne tous les codes promo, peut importe la validité
"""
@app.route('/myclass/api/Get_All_Code_Promo/', methods=['POST','GET'])
@crossdomain(origin='*')
def Get_All_Code_Promo():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### Get_All_Code_Promo : payload = ",payload)
    localStatus, message = code_promo_mgt.Get_All_Code_Promo(payload)
    return jsonify(status=localStatus, message=message)

"""
API de mise à jour du code promo
"""
@app.route('/myclass/api/Update_Code_Promo/', methods=['POST','GET'])
@crossdomain(origin='*')
def Update_Code_Promo():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### Update_Code_Promo : payload = ",payload)
    localStatus, message = code_promo_mgt.Get_All_Code_Promo(payload)
    return jsonify(status=localStatus, message=message)

"""
API de recuperation des informations d'un code promo
avec controle de validité
"""
@app.route('/myclass/api/Get_Given_Code_Promo/', methods=['POST','GET'])
@crossdomain(origin='*')
def Get_Given_Code_Promo():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### Get_Given_Code_Promo : payload = ",payload)
    localStatus, message = code_promo_mgt.Get_Given_Code_Promo(payload)
    return jsonify(status=localStatus, message=message)


"""
Cette API Permet de récupérer les données
d'abonnement d'un client
"""
@app.route('/myclass/api/Strip_Get_Customer_Abonnement_Data/', methods=['POST','GET'])
@crossdomain(origin='*')
def Strip_Get_Customer_Abonnement_Data():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### Strip_Get_Customer_Abonnement_Data : payload = ",payload)
    localStatus, message = Stripe.Strip_Get_Customer_Abonnement_Data(payload)
    return jsonify(status=localStatus, message=message)

"""
API d'envoie de l'email avec les infos de la prochaine facturation
"""
@app.route('/myclass/api/Strip_Get_Customer_Upcoming_Invoice/', methods=['POST','GET'])
@crossdomain(origin='*')
def Strip_Get_Customer_Upcoming_Invoice():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### Strip_Get_Customer_Upcoming_Invoice : payload = ",payload)
    localStatus, message = emails.Strip_Get_Customer_Upcoming_Invoice(payload)
    return jsonify(status=localStatus, message=message)


"""
Cette API est job qui envoie a une frequence données
les infos de prefacturation aux clients/partner. 
Les conditions :  

"send_pre_invoice_data" : '1', 
"datetime_pre_invoice_created"  < date_time_now + 5 min.
"""
@app.route('/myclass/api/Cron_Strip_Get_Customer_Abonnement_Data/', methods=['POST','GET'])
@crossdomain(origin='*')
def Cron_Strip_Get_Customer_Abonnement_Data():
    print(" ### Cron_Strip_Get_Customer_Abonnement_Data : payload = ")
    localStatus, message = Stripe.Cron_Strip_Get_Customer_Abonnement_Data()
    return jsonify(status=localStatus, message=message)


"""
Fonction de traitement du cron interne avec Flak.
Flak ne supporte pas "@app.route" pour lancer les cron,
c'est pour cela qu'on recrée la meme entrée sans "@app.route"
"""
def Flask_Cron_Strip_Get_Customer_Abonnement_Data():
    print(" ### Flask_Cron_Strip_Get_Customer_Abonnement_Data : payload = ")
    localStatus, message = Stripe.Cron_Strip_Get_Customer_Abonnement_Data()
    return jsonify(status=localStatus, message=message)



"""
API de test Stripe
"""
@app.route('/myclass/api/test_stripe/', methods=['POST','GET'])
@crossdomain(origin='*')
def test_stripe():
    # On recupere le corps (payload) de la requete
    print(" ### test_stripe : payload = ")
    localStatus, message = Stripe.test_stripe()
    return jsonify(status=localStatus,)

"""
API de creation d'un appel d'offre
"""
@app.route('/myclass/api/Add_Appel_Offre/', methods=['POST','GET'])
@crossdomain(origin='*')
def Add_Appel_Offre():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### Add_Appel_Offre : payload = ",payload)
    localStatus, message = appel_offre.Add_Appel_Offre(payload)
    return jsonify(status=localStatus, message=message)

"""
API de mise à jour d'un appel d'offre
"""
@app.route('/myclass/api/Update_Appel_Offre/', methods=['POST','GET'])
@crossdomain(origin='*')
def Update_Appel_Offre():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### Update_Appel_Offre : payload = ",payload)
    localStatus, message = appel_offre.Update_Appel_Offre(payload)
    return jsonify(status=localStatus, message=message)


"""
API de recuperation d'un appel d'offre donnée
"""
@app.route('/myclass/api/Get_Given_Appel_Offre/', methods=['POST','GET'])
@crossdomain(origin='*')
def Get_Given_Appel_Offre():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### Get_Given_Appel_Offre : payload = ",payload)
    localStatus, message = appel_offre.Get_Given_Appel_Offre(payload)
    return jsonify(status=localStatus, message=message)

"""
API de recuperation d'une liste d'appel d'offre d'un partenaire
"""
@app.route('/myclass/api/Get_List_Appel_Offre/', methods=['POST','GET'])
@crossdomain(origin='*')
def Get_List_Appel_Offre():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### Get_List_Appel_Offre : payload = ",payload)
    localStatus, message = appel_offre.Get_List_Appel_Offre(payload)
    return jsonify(status=localStatus, message=message)


""" 
API qui permet de faire une manifestation d'interet pour une AO
"""
@app.route('/myclass/api/Manifestation_Interet_Appel_Offre/', methods=['POST','GET'])
@crossdomain(origin='*')
def Add_Manifestation_Interet_Appel_Offre():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### Manifestation_Interet_Appel_Offre : payload = ",payload)
    localStatus, message = appel_offre.Manifestation_Interet_Appel_Offre(payload)
    return jsonify(status=localStatus, message=message)


""" 
API qui permet de faire une réponse d'interet pour une AO
"""
@app.route('/myclass/api/Reponse_Appel_Offre/', methods=['POST','GET'])
@crossdomain(origin='*')
def Add_Reponse_Appel_Offre():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### Reponse_Appel_Offre : payload = ",payload)
    localStatus, message = appel_offre.Reponse_Appel_Offre(payload)
    return jsonify(status=localStatus, message=message)

""" 
API qui retourne la liste des manifesations d'interet pour un AO
"""
@app.route('/myclass/api/Get_List_Manifestation_Interet_Appel_Offre/', methods=['POST','GET'])
@crossdomain(origin='*')
def Get_List_Manifestation_Interet_Appel_Offre():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### Get_List_Manifestation_Interet_Appel_Offre : payload = ",payload)
    localStatus, message = appel_offre.Get_List_Manifestation_Interet_Appel_Offre(payload)
    return jsonify(status=localStatus, message=message)

""" 
API qui retourne la liste des réponses  pour un AO
"""
@app.route('/myclass/api/Get_List_Reponse_Appel_Offre/', methods=['POST','GET'])
@crossdomain(origin='*')
def Get_List_Reponse_Appel_Offre():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### Get_List_Reponse_Appel_Offre : payload = ",payload)
    localStatus, message = appel_offre.Get_List_Reponse_Appel_Offre(payload)
    return jsonify(status=localStatus, message=message)

"""
API de creation d'un client d'un partner
"""
@app.route('/myclass/api/Add_Partner_Client/', methods=['POST','GET'])
@crossdomain(origin='*')
def Add_Partner_Client():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### Add_Partner_Client : payload = ",payload)
    localStatus, message = partner_client.Add_Partner_Client(payload)
    return jsonify(status=localStatus, message=message)



""" 
Creation en mass des clients d'un partner
"""
@app.route('/myclass/api/Add_Partner_Client_mass/', methods=['POST','GET'])
@crossdomain(origin='*')
def Add_Partner_Client_mass():


    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### Add_Partner_Client_mass payload = ",payload)
    #print(request.files)

    if request.method == 'POST':
        # Create variable for uploaded file
        f = request.files['File']
        localStatus, message = partner_client.Add_Partner_Client_mass(f, MYSY_GV.TEMPORARY_DIRECTORY_V2, payload)
        #status, retval = cm.add_class_mass(f, app.config['UPLOAD_FOLDER'], payload)

        return jsonify(status=localStatus, message=message)


"""
API de mise à jour du client d'un partner 
"""
@app.route('/myclass/api/Update_Partner_Client/', methods=['POST','GET'])
@crossdomain(origin='*')
def Update_Partner_Client():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### Update_Partner_Client : payload = ",payload)
    localStatus, message = partner_client.Update_Partner_Client(payload)
    return jsonify(status=localStatus, message=message)



"""
API de recuperation de la liste des clients d'un partner
"""
@app.route('/myclass/api/Get_Partner_List_Partner_Client/', methods=['POST','GET'])
@crossdomain(origin='*')
def Get_Partner_List_Partner_Client():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### Get_Partner_List_Partner_Client : payload = ",payload)
    localStatus, message = partner_client.Get_Partner_List_Partner_Client(payload)
    return jsonify(status=localStatus, message=message)



"""
API de recuperation de la liste des clients d'un partner avec des filter like
"""
@app.route('/myclass/api/Get_Partner_List_Partner_Client_with_filter_Like/', methods=['POST','GET'])
@crossdomain(origin='*')
def Get_Partner_List_Partner_Client_with_filter_Like():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### Get_Partner_List_Partner_Client_with_filter_Like : payload = ",payload)
    localStatus, message = partner_client.Get_Partner_List_Partner_Client_with_filter_Like(payload)
    return jsonify(status=localStatus, message=message)



"""
API de recuperation d'un client donné d'un partner en partant de l'email
"""
@app.route('/myclass/api/Get_Given_Partner_Client/', methods=['POST','GET'])
@crossdomain(origin='*')
def Get_Given_Partner_Client():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### Get_Given_Partner_Client : payload = ",payload)
    localStatus, message = partner_client.Get_Given_Partner_Client(payload)
    return jsonify(status=localStatus, message=message)

"""
API de recuperation d'un client donné d'un partner en partant de l'_id
"""
@app.route('/myclass/api/Get_Given_Partner_Client_From_Id/', methods=['POST','GET'])
@crossdomain(origin='*')
def Get_Given_Partner_Client_From_Id():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### Get_Given_Partner_Client_From_Id : payload = ",payload)
    localStatus, message = partner_client.Get_Given_Partner_Client_From_Id(payload)
    return jsonify(status=localStatus, message=message)


"""
API de suppression d'un client
Avant il faut verifier : 
1 - pas de stagiaire associé
2 - Pas de devis associé
3 - Pas de commande associé
"""
@app.route('/myclass/api/Delete_Given_Partner_Client/', methods=['POST','GET'])
@crossdomain(origin='*')
def Delete_Given_Partner_Client():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### Delete_Given_Partner_Client : payload = ",payload)
    localStatus, message = partner_client.Delete_Given_Partner_Client(payload)
    return jsonify(status=localStatus, message=message)


"""
API de recupération de la liste des types de client
"""
@app.route('/myclass/api/Get_Client_Type_List/', methods=['POST','GET'])
@crossdomain(origin='*')
def Get_Client_Type_List():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### Get_Client_Type_List : payload = ",payload)
    localStatus, message = partner_client.Get_Client_Type_List(payload)
    return jsonify(status=localStatus, message=message)


"""
API pour ajouter un type de client
"""
@app.route('/myclass/api/Add_Client_Type/', methods=['POST','GET'])
@crossdomain(origin='*')
def Add_Client_Type():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### Add_Client_Type : payload = ",payload)
    localStatus, message = partner_client.Add_Client_Type(payload)
    return jsonify(status=localStatus, message=message)



"""
API Pour mettre à jour un type de client
"""
@app.route('/myclass/api/Update_Client_Type/', methods=['POST','GET'])
@crossdomain(origin='*')
def Update_Client_Type():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### Update_Client_Type : payload = ",payload)
    localStatus, message = partner_client.Update_Client_Type(payload)
    return jsonify(status=localStatus, message=message)




"""
API pour supprimer un type de client
"""
@app.route('/myclass/api/Delete_Client_Type/', methods=['POST','GET'])
@crossdomain(origin='*')
def Delete_Client_Type():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### Delete_Client_Type : payload = ",payload)
    localStatus, message = partner_client.Delete_Client_Type(payload)
    return jsonify(status=localStatus, message=message)


"""
API de recuperation des contacts d'un client inclus dans la communication
"""
@app.route('/myclass/api/Get_Partner_Client_Communication_Contact/', methods=['POST','GET'])
@crossdomain(origin='*')
def Get_Partner_Client_Communication_Contact():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### Get_Partner_Client_Communication_Contact : payload = ",payload)
    localStatus, message = partner_client.Get_Partner_Client_Communication_Contact(payload)
    return jsonify(status=localStatus, message=message)




"""
API qui permet de modifier un contact donnée (nested list) d'un client de partenaire
"""
@app.route('/myclass/api/Update_Partner_Client_Contact/', methods=['POST','GET'])
@crossdomain(origin='*')
def Update_Partner_Client_Contact():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### Update_Partner_Client_Contact : payload = ",payload)
    localStatus, message = partner_client.Update_Partner_Client_Contact(payload)
    return jsonify(status=localStatus, message=message)


"""
API qui ajoute un contact
"""
@app.route('/myclass/api/Add_Contact/', methods=['POST','GET'])
@crossdomain(origin='*')
def Add_Contact():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### Add_Contact : payload = ",payload)
    localStatus, message = Contact.Add_Contact(payload)
    return jsonify(status=localStatus, message=message)

"""
API qui met à jour un contact
"""
@app.route('/myclass/api/Update_Contact/', methods=['POST','GET'])
@crossdomain(origin='*')
def Update_Contact():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### Update_Contact : payload = ",payload)
    localStatus, message = Contact.Update_Contact(payload)
    return jsonify(status=localStatus, message=message)


"""
API qui recupere la liste des contact d'une entité
"""
@app.route('/myclass/api/Get_List_Entity_Contact/', methods=['POST','GET'])
@crossdomain(origin='*')
def Get_Partner_List_Entity_Contact():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### Get_List_Entity_Contact : payload = ",payload)
    localStatus, message = Contact.Get_List_Entity_Contact(payload)
    return jsonify(status=localStatus, message=message)


"""
API qui recupere un contact donnée
"""
@app.route('/myclass/api/Get_Given_Contact/', methods=['POST','GET'])
@crossdomain(origin='*')
def Get_Given_Contact():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### Get_Given_Contact : payload = ",payload)
    localStatus, message = Contact.Get_Given_Contact(payload)
    return jsonify(status=localStatus, message=message)

"""
API de suppression d'un contact
"""
@app.route('/myclass/api/Delete_Given_Contact/', methods=['POST','GET'])
@crossdomain(origin='*')
def Delete_Given_Contact():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### Delete_Given_Contact : payload = ",payload)
    localStatus, message = Contact.Delete_Given_Contact(payload)
    return jsonify(status=localStatus, message=message)


"""
API qui ajoute une activité
"""
@app.route('/myclass/api/Add_activite/', methods=['POST','GET'])
@crossdomain(origin='*')
def Add_activite():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### Add_activite : payload = ",payload)
    localStatus, message = Activite.Add_activite(payload)
    return jsonify(status=localStatus, message=message)

"""
API qui met à jour une activité
"""
@app.route('/myclass/api/Update_activite/', methods=['POST','GET'])
@crossdomain(origin='*')
def Update_activite():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### Update_activite : payload = ",payload)
    localStatus, message = Activite.Update_activite(payload)
    return jsonify(status=localStatus, message=message)


"""
API qui recupere la liste des activités d'une entité
"""
@app.route('/myclass/api/Get_List_Entity_Activite/', methods=['POST','GET'])
@crossdomain(origin='*')
def Get_List_Entity_Activite():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### Get_List_Entity_Activite : payload = ",payload)
    localStatus, message = Activite.Get_List_Entity_Activite(payload)
    return jsonify(status=localStatus, message=message)


"""
API qui recupere activité donnée
"""
@app.route('/myclass/api/Get_Given_Activite/', methods=['POST','GET'])
@crossdomain(origin='*')
def Get_Given_Activite():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### Get_Given_Activite : payload = ",payload)
    localStatus, message = Activite.Get_Given_Activite(payload)
    return jsonify(status=localStatus, message=message)


"""
Cette API permet de publier/mettre à jour une formation
du LMS Search vers MySy LMS
"""
@app.route('/myclass/api/Push_Class_To_MySy_LMS/', methods=['POST','GET'])
@crossdomain(origin='*')
def Push_Class_To_MySy_LMS():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### Push_Class_To_MySy_LMS : payload = ",payload)
    localStatus, message = mysy_lms.Push_Class_To_MySy_LMS(payload)
    return jsonify(status=localStatus, message=message)



"""
API permettant d'enregister une image en base de données
"""
@app.route('/myclass/api/Update_Stagiaire_Image/', methods=['POST','GET'])
@crossdomain(origin='*')
def Update_Stagiaire_Image():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### Update_Stagiaire_Image : payload = ",payload)

    if request.method == 'POST':
        # Create variable for uploaded file
        if ('file_img' in request.files.keys()):
            file_img = request.files['file_img']
        else:
            file_img = None
            print(" ### recordClassImage_v2 : Aucun fichier image à sauvegarder")
            return False, "Aucun fichier image à enregistrer"

    localStatus, message = inscription.Update_Stagiaire_Image(file_img, MYSY_GV.upload_folder, payload)
    return jsonify(status=localStatus, message=message)

"""
Recuperation de l'image de profil d'un stagiaire
"""
@app.route('/myclass/api/getRecodedStagiaireImage_from_front/', methods=['POST','GET'])
@crossdomain(origin='*')
def getRecodedStagiaireImage_from_front():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### getRecodedStagiaireImage_from_front payload = ",payload)
    status, retval = inscription.getRecodedStagiaireImage_from_front(payload)
    return jsonify(status=status, message=retval)

"""
API qui supprime l'image de profil d'un stagiaire
"""
@app.route('/myclass/api/DeleteImage_Stagiaire_v2/', methods=['POST','GET'])
@crossdomain(origin='*')
def DeleteImage_Stagiaire_v2():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### DeleteImage_Stagiaire_v2 payload = ",payload)
    status, retval = inscription.DeleteImage_Stagiaire_v2(payload)
    return jsonify(status=status, message=retval)

"""
API qui recupere la liste complete des stagaire d'un partener
"""
@app.route('/myclass/api/Get_Statgaire_List_Partner_with_filter/', methods=['POST','GET'])
@crossdomain(origin='*')
def Get_Statgaire_List_Partner_with_filter():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### Get_Statgaire_List_Partner payload = ",payload)
    status, retval = inscription.Get_Statgaire_List_Partner_with_filter(payload)
    return jsonify(status=status, message=retval)


"""
API qui recupere les informations d'une inscription en partant de '_id' de la ligne
"""
@app.route('/myclass/api/GetAttendeeDetail_perSession_from_line_id/', methods=['POST','GET'])
@crossdomain(origin='*')
def GetAttendeeDetail_perSession_from_line_id():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### GetAttendeeDetail_perSession_from_line_id payload = ",payload)
    status, retval = inscription.GetAttendeeDetail_perSession_from_line_id(payload)
    return jsonify(status=status, message=retval)

"""
API qui met à jour le tuteur
"""
@app.route('/myclass/api/UpdateStagiairetoClass_Tuteurs/', methods=['POST','GET'])
@crossdomain(origin='*')
def UpdateStagiairetoClass_Tuteurs():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### UpdateStagiairetoClass_Tuteurs payload = ",payload)
    status, retval = inscription.UpdateStagiairetoClass_Tuteurs(payload)
    return jsonify(status=status, message=retval)


"""
API qui permet de recuperer la liste des convention stagiaires
"""
@app.route('/myclass/api/Get_List_Conventions_Stagiaire/', methods=['POST','GET'])
@crossdomain(origin='*')
def Get_List_Conventions_Stagiaire():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### Get_List_Conventions_Stagiaire payload = ",payload)
    status, retval = inscription.Get_List_Conventions_Stagiaire(payload)
    return jsonify(status=status, message=retval)


"""
API qui permet de recuperer la liste des convention stagiaires avec des options
comme : 
- ref_interne
- nom
- type_doc
"""
@app.route('/myclass/api/Get_List_Conventions_Stagiaire_With_Filter/', methods=['POST','GET'])
@crossdomain(origin='*')
def Get_List_Conventions_Stagiaire_With_Filter():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### Get_List_Conventions_Stagiaire_With_Filter payload = ",payload)
    status, retval = inscription.Get_List_Conventions_Stagiaire_With_Filter(payload)
    return jsonify(status=status, message=retval)



"""
API qui permet de recuperer la liste des conVOcations stagiaires avec des options
comme : 
- ref_interne
- nom
- type_doc
"""
@app.route('/myclass/api/Get_List_Convocations_Stagiaire_With_Filter/', methods=['POST','GET'])
@crossdomain(origin='*')
def Get_List_Convocations_Stagiaire_With_Filter():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### Get_List_Convocations_Stagiaire_With_Filter payload = ",payload)
    status, retval = inscription.Get_List_Convocations_Stagiaire_With_Filter(payload)
    return jsonify(status=status, message=retval)


"""
API pour recuperer seulement les conventions INDIVIDUELLES
"""
@app.route('/myclass/api/Get_List_Conventions_Stagiaire_Individuelles/', methods=['POST','GET'])
@crossdomain(origin='*')
def Get_List_Conventions_Stagiaire_Individuelles():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### Get_List_Conventions_Stagiaire_Individuelles payload = ",payload)
    status, retval = inscription.Get_List_Conventions_Stagiaire_Individuelles(payload)
    return jsonify(status=status, message=retval)


"""
API qui permet de recuperer la liste des modèle de courrier pour 
les emargements
"""
@app.route('/myclass/api/Get_List_Emargement_With_Filter/', methods=['POST','GET'])
@crossdomain(origin='*')
def Get_List_Emargement_With_Filter():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### Get_List_Emargement_With_Filter payload = ",payload)
    status, retval = inscription.Get_List_Emargement_With_Filter(payload)
    return jsonify(status=status, message=retval)



"""
API qui permet d'envoyer  de le convention du stagiaire par email
"""
@app.route('/myclass/api/Sent_Convention_Stagiaire_By_Email/', methods=['POST','GET'])
@crossdomain(origin='*')
def Sent_Convention_Stagiaire_By_Email():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### Sent_Convention_Stagiaire_By_Email payload = ",payload)

    file = []
    if request.method == 'POST':
        # Create variable for uploaded file
        tab_files = []
        for tmp in request.files.getlist("File") :
            tab_files.append(tmp)

    status, retval = inscription.Sent_Convention_Stagiaire_By_Email(tab_files,  MYSY_GV.TEMPORARY_DIRECTORY_V2, payload)
    return jsonify(status=status, message=retval)

"""
API qui est un clone de l'api (Sent_Convention_Stagiaire_By_Email) a quelques details prets.
Cette separation est du à la complexité de la fonction et au souci de ne pas avoir d'effet de bord
"""
@app.route('/myclass/api/Sent_Convention_Individuelle_Stagiaire_By_Email/', methods=['POST','GET'])
@crossdomain(origin='*')
def Sent_Convention_Individuelle_Stagiaire_By_Email():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### Sent_Convention_Individuelle_Stagiaire_By_Email payload = ",payload)

    file = []
    if request.method == 'POST':
        # Create variable for uploaded file
        tab_files = []
        for tmp in request.files.getlist("File") :
            tab_files.append(tmp)

    status, retval = inscription.Sent_Convention_Individuelle_Stagiaire_By_Email(tab_files,  MYSY_GV.TEMPORARY_DIRECTORY_V2, payload)
    return jsonify(status=status, message=retval)



"""
API : Traitement en masse qui permet d'envoyer  de le convention du stagiaire par email
"""
@app.route('/myclass/api/Sent_Convention_Stagiaire_By_Email_mass/', methods=['POST','GET'])
@crossdomain(origin='*')
def Sent_Convention_Stagiaire_By_Email_mass():

    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### Sent_Convention_Stagiaire_By_Email_mass payload = ",payload)

    file = []
    if request.method == 'POST':
        # Create variable for uploaded file
        tab_files = []
        for tmp in request.files.getlist("File") :
            tab_files.append(tmp)

    status, retval = inscription.Sent_Convention_Stagiaire_By_Email_mass(tab_files,  MYSY_GV.TEMPORARY_DIRECTORY_V2, payload)
    return jsonify(status=status, message=retval)


"""
API qui permet de telecharger la convention en mode PDF
"""
@app.route('/myclass/api/Download_Convention_Stagiaire_PDF/<token>/<inscription_id>/<courrier_template_id>', methods=['POST','GET'])
@crossdomain(origin='*')
def Download_Convention_Stagiaire_PDF(token, inscription_id, courrier_template_id):
    # On recupere le corps (payload) de la requete
    payload = mycommon.strip_dictionary(request.form.to_dict())
    payload['token'] = str(token)
    payload['inscription_id'] = str(inscription_id)
    payload['courrier_template_id'] = str(courrier_template_id)


    print(" ### Download_Convention_Stagiaire_PDF payload = ",payload)

    status, retval = inscription.Download_Convention_Stagiaire_PDF(payload)
    if (status):
        return retval
    else:
        return False


"""
API qui permet de telecharger la convention individuelle  en mode PDF
"""
@app.route('/myclass/api/Download_Convention_Individuelle_Stagiaire_PDF/<token>/<inscription_id>/<courrier_template_id>', methods=['POST','GET'])
@crossdomain(origin='*')
def Download_Convention_Individuelle_Stagiaire_PDF(token, inscription_id, courrier_template_id):
    # On recupere le corps (payload) de la requete
    payload = mycommon.strip_dictionary(request.form.to_dict())
    payload['token'] = str(token)
    payload['inscription_id'] = str(inscription_id)
    payload['courrier_template_id'] = str(courrier_template_id)


    print(" ### Download_Convention_Individuelle_Stagiaire_PDF payload = ",payload)

    status, retval = inscription.Download_Convention_Individuelle_Stagiaire_PDF(payload)
    if (status):
        return retval
    else:
        return False


"""
Test teclechargement d'un zip
"""
@app.route('/myclass/api/Download_zip_PDF/', methods=['POST','GET'])
@crossdomain(origin='*')
def Download_zip_PDF():
    # On recupere le corps (payload) de la requete
    payload = mycommon.strip_dictionary(request.form.to_dict())


    print(" ### Download_zip_PDF payload = ",payload)

    status, retval = inscription.Download_zip_PDF()
    if (status):
        return retval
    else:
        return False


"""
API qui permet de telecharger la convention en mode PDF en partant du client (donc liste partipant dans le fichier)
"""
@app.route('/myclass/api/Download_Convention_Stagiaire_PDF_By_Partner_client/<token>/<partner_client_id>/<session_id>/<courrier_template_id>', methods=['POST','GET'])
@crossdomain(origin='*')
def Download_Convention_Stagiaire_PDF_By_Partner_client(token, partner_client_id, session_id, courrier_template_id):
    # On recupere le corps (payload) de la requete
    payload = mycommon.strip_dictionary(request.form.to_dict())
    payload['token'] = str(token)
    payload['partner_client_id'] = str(partner_client_id)
    payload['session_id'] = str(session_id)
    payload['courrier_template_id'] = str(courrier_template_id)


    print(" ### Download_Convention_Stagiaire_PDF_By_Partner_client payload = ",payload)

    status, retval = inscription.Download_Convention_Stagiaire_PDF_By_Partner_client(payload)
    if (status):
        return retval
    else:
        return False


"""
API qui prend une session id et imprime les differentes conventions associées en pfd
"""
@app.route('/myclass/api/Download_Convention_Stagiaire_PDF_By_Partner_client/<token>/<partner_client_id>/<session_id>/<courrier_template_id>', methods=['POST','GET'])
@crossdomain(origin='*')
def Prepare_Download_Convention_Stagiaire_PDF_By_Session(token, partner_client_id, session_id, courrier_template_id):
    # On recupere le corps (payload) de la requete
    payload = mycommon.strip_dictionary(request.form.to_dict())
    payload['token'] = str(token)
    payload['partner_client_id'] = str(partner_client_id)
    payload['session_id'] = str(session_id)
    payload['courrier_template_id'] = str(courrier_template_id)


    print(" ### Download_Convention_Stagiaire_PDF_By_Partner_client payload = ",payload)

    status, retval = inscription.Download_Convention_Stagiaire_PDF_By_Partner_client(payload)
    if (status):
        return retval
    else:
        return False


"""
API qui retourne la liste des adresse email eligibles à la communication
d'un apprenant
(potentiellement inclus les mails des tuteurs si paramettres ok
"""
@app.route('/myclass/api/Get_Stagiaire_Communication_List_Email/', methods=['POST','GET'])
@crossdomain(origin='*')
def Get_Stagiaire_Communication_List_Email():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### Get_Stagiaire_Communication_List_Email payload = ",payload)
    status, retval = inscription.Get_Stagiaire_Communication_List_Email(payload)
    return jsonify(status=status, message=retval)


"""
API qui ajoute une ressource humaine
"""
@app.route('/myclass/api/Add_Ressource_Humaine/', methods=['POST','GET'])
@crossdomain(origin='*')
def Add_Ressource_Humaine():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### Add_Ressource_Humaine payload = ",payload)
    status, retval = ressources_humaines.Add_Ressource_Humaine(payload)
    return jsonify(status=status, message=retval)



@app.route('/myclass/api/Add_Partner_Admin_Ressource_Humaine_No_Toke/', methods=['POST','GET'])
@crossdomain(origin='*')
def Add_Partner_Admin_Ressource_Humaine_No_Toke():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### Add_Partner_Admin_Ressource_Humaine_No_Toke payload = ",payload)
    status, retval = ressources_humaines.Add_Partner_Admin_Ressource_Humaine_No_Toke(payload)
    return jsonify(status=status, message=retval)

### PRDO DATA MIGRATION
@app.route('/myclass/api/PROD_Add_Partner_Admin_Ressource_Humaine_No_Toke/', methods=['POST','GET'])
@crossdomain(origin='*')
def PROD_Add_Partner_Admin_Ressource_Humaine_No_Toke():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### PROD_Add_Partner_Admin_Ressource_Humaine_No_Toke payload = ",payload)
    status, retval = ressources_humaines.PROD_Add_Partner_Admin_Ressource_Humaine_No_Toke(payload)
    return jsonify(status=status, message=retval)

"""
API qui met a jour  une ressource humaine
"""
@app.route('/myclass/api/Update_Ressource_Humaine/', methods=['POST','GET'])
@crossdomain(origin='*')
def Update_Ressource_Humaine():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### Update_Ressource_Humaine payload = ",payload)
    status, retval = ressources_humaines.Update_Ressource_Humaine(payload)
    return jsonify(status=status, message=retval)


"""
API de suppression d'un employé
"""
@app.route('/myclass/api/Delete_Ressource_Humaine/', methods=['POST','GET'])
@crossdomain(origin='*')
def Delete_Ressource_Humaine():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### Delete_Ressource_Humaine payload = ",payload)
    status, retval = ressources_humaines.Delete_Ressource_Humaine(payload)
    return jsonify(status=status, message=retval)

"""
API qui recupere la liste des ressources humaines d'un partenaire
"""
@app.route('/myclass/api/Get_List_Ressource_Humaine/', methods=['POST','GET'])
@crossdomain(origin='*')
def Get_List_Ressource_Humaine():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### Get_List_Ressource_Humaine payload = ",payload)
    status, retval = ressources_humaines.Get_List_Ressource_Humaine(payload)
    return jsonify(status=status, message=retval)



"""
API qui recupere les differents type de profils pour des ressources humaines
"""
@app.route('/myclass/api/Get_List_Profil_Ressource_Humaine/', methods=['POST','GET'])
@crossdomain(origin='*')
def Get_List_Profil_Ressource_Humaine():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### Get_List_Profil_Ressource_Humaine payload = ",payload)
    status, retval = ressources_humaines.Get_List_Profil_Ressource_Humaine(payload)
    return jsonify(status=status, message=retval)



"""
API qui recupere une ressource humaine donnée
"""
@app.route('/myclass/api/Get_Given_Ressource_Humaine/', methods=['POST','GET'])
@crossdomain(origin='*')
def Get_Given_Ressource_Humaine():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### Get_Given_Ressource_Humaine payload = ",payload)
    status, retval = ressources_humaines.Get_Given_Ressource_Humaine(payload)
    return jsonify(status=status, message=retval)


"""
API qui recupere des ressources humaines avec filter sur le nom et l'email
"""
@app.route('/myclass/api/Get_List_Ressource_Humaine_with_filter/', methods=['POST','GET'])
@crossdomain(origin='*')
def Get_List_Ressource_Humaine_with_filter():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### Get_List_Ressource_Humaine_with_filter payload = ",payload)
    status, retval = ressources_humaines.Get_List_Ressource_Humaine_with_filter(payload)
    return jsonify(status=status, message=retval)


"""
API qui retourne la liste des employé sans aucun filtre
"""

@app.route('/myclass/api/Get_List_Ressource_Humaine_no_filter/', methods=['POST','GET'])
@crossdomain(origin='*')
def Get_List_Ressource_Humaine_no_filter():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### Get_List_Ressource_Humaine_no_filter payload = ",payload)
    status, retval = ressources_humaines.Get_List_Ressource_Humaine_no_filter(payload)
    return jsonify(status=status, message=retval)



"""
API qui retour la liste de managers (ismanager = 1)
"""
@app.route('/myclass/api/Get_List_Manager_Ressource_Humaine/', methods=['POST','GET'])
@crossdomain(origin='*')
def Get_List_Manager_Ressource_Humaine():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### Get_List_Manager_Ressource_Humaine payload = ",payload)
    status, retval = ressources_humaines.Get_List_Manager_Ressource_Humaine(payload)
    return jsonify(status=status, message=retval)




"""
API qui enregistre/met à jour l'image d'une ressource humaine
"""
@app.route('/myclass/api/Update_Ressource_Humaine_Image/', methods=['POST','GET'])
@crossdomain(origin='*')
def Update_Ressource_Humaine_Image():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### Update_Ressource_Humaine_Image : payload = ",payload)

    if request.method == 'POST':
        # Create variable for uploaded file
        if ('file_img' in request.files.keys()):
            file_img = request.files['file_img']
        else:
            file_img = None
            return False, "Aucun fichier image à enregistrer"

    localStatus, message = ressources_humaines.Update_Ressource_Humaine_Image(file_img, MYSY_GV.upload_folder, payload)
    return jsonify(status=localStatus, message=message)


"""
API qui supprime l'image de profil d'une ressource humaine
"""
@app.route('/myclass/api/DeleteImage_Ressource_Humaine/', methods=['POST','GET'])
@crossdomain(origin='*')
def DeleteImage_Ressource_Humaine():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### DeleteImage_Ressource_Humaine payload = ",payload)
    status, retval = ressources_humaines.DeleteImage_Ressource_Humaine(payload)
    return jsonify(status=status, message=retval)


"""
Recuperation de l'image de profil d'un employee
"""
@app.route('/myclass/api/getRecoded_Employee_Image_from_front/', methods=['POST','GET'])
@crossdomain(origin='*')
def getRecoded_Employee_Image_from_front():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### getRecodedStagiaireImage_from_front payload = ",payload)
    status, retval = ressources_humaines.getRecoded_Employee_Image_from_front(payload)
    return jsonify(status=status, message=retval)

"""
API qui permet d'importer en masse des employés 
"""
@app.route('/myclass/api/Add_Ressource_Humaine_mass/', methods=['POST','GET'])
@crossdomain(origin='*')
def Add_Ressource_Humaine_mass():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### Add_Ressource_Humaine_mass payload = ",payload)
    #print(request.files)

    if request.method == 'POST':
        # Create variable for uploaded file
        f = request.files['File']
        localStatus, message = ressources_humaines.Add_Ressource_Humaine_mass(f, MYSY_GV.TEMPORARY_DIRECTORY_V2, payload)
        #status, retval = cm.add_class_mass(f, app.config['UPLOAD_FOLDER'], payload)

        return jsonify(status=localStatus, message=message)


"""
Recuperation de la liste des fonctions occupées par un employé
"""
@app.route('/myclass/api/Get_List_Ressource_Humaine_Affectation/', methods=['POST','GET'])
@crossdomain(origin='*')
def Get_List_Ressource_Humaine_Affectation():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### Get_List_Ressource_Humaine_Affectation payload = ",payload)
    status, retval = ressources_humaines.Get_List_Ressource_Humaine_Affectation(payload)
    return jsonify(status=status, message=retval)


"""
API pour affecter un employé a un poste
"""
@app.route('/myclass/api/Add_Affectation_Ressource_Humaine_Poste/', methods=['POST','GET'])
@crossdomain(origin='*')
def Add_Affectation_Ressource_Humaine_Poste():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### Add_Affectation_Ressource_Humaine_Poste payload = ",payload)
    status, retval = ressources_humaines.Add_Affectation_Ressource_Humaine_Poste(payload)
    return jsonify(status=status, message=retval)

"""
API pour mettre à jour une affectation
"""
@app.route('/myclass/api/Update_Affectation_Ressource_Humaine_Poste/', methods=['POST','GET'])
@crossdomain(origin='*')
def Update_Affectation_Ressource_Humaine_Poste():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### Update_Affectation_Ressource_Humaine_Poste payload = ",payload)
    status, retval = ressources_humaines.Update_Affectation_Ressource_Humaine_Poste(payload)
    return jsonify(status=status, message=retval)


"""
API pour supprimer une affectation
"""
@app.route('/myclass/api/Delete_Affectation_Ressource_Humaine_Poste/', methods=['POST','GET'])
@crossdomain(origin='*')
def Delete_Affectation_Ressource_Humaine_Poste():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### Delete_Affectation_Ressource_Humaine_Poste payload = ",payload)
    status, retval = ressources_humaines.Delete_Affectation_Ressource_Humaine_Poste(payload)
    return jsonify(status=status, message=retval)

"""
API pour récupérer une affectation donnée
"""
@app.route('/myclass/api/Get_Given_Affectation_Ressource_Humaine_Poste/', methods=['POST','GET'])
@crossdomain(origin='*')
def Get_Given_Affectation_Ressource_Humaine_Poste():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### Get_Given_Affectation_Ressource_Humaine_Poste payload = ",payload)
    status, retval = ressources_humaines.Get_Given_Affectation_Ressource_Humaine_Poste(payload)
    return jsonify(status=status, message=retval)

"""
API pour  récupérer la liste des 'related_target_collection_object' avec les 'related_target_collection_id_nom'
et de les formater pour une utilisation simple coté front.
"""
@app.route('/myclass/api/Get_Related_Target_Collection_Data/', methods=['POST','GET'])
@crossdomain(origin='*')
def Get_Related_Target_Collection_Data():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### Get_Related_Target_Collection_Data payload = ",payload)
    status, retval = ressources_humaines.Get_Related_Target_Collection_Data(payload)
    return jsonify(status=status, message=retval)


"""
API de creation de compte utilisateur (ou mise à jour) : login & pass
"""
@app.route('/myclass/api/Add_Update_Employee_Login_Pass/', methods=['POST','GET'])
@crossdomain(origin='*')
def Add_Update_Employee_Login_Pass():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### Add_Update_Employee_Login_Pass payload = ",payload)
    status, retval = ressources_humaines.Add_Update_Employee_Login_Pass(payload)
    return jsonify(status=status, message=retval)

"""
API pour créer un contrat pour un employe
"""
@app.route('/myclass/api/Add_Employee_Contrat/', methods=['POST','GET'])
@crossdomain(origin='*')
def Add_Employee_Contrat():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### Add_Employee_Contrat payload = ",payload)
    status, retval = ressources_humaines.Add_Employee_Contrat(payload)
    return jsonify(status=status, message=retval)


"""
API de mise à jour d'un contrat
"""
@app.route('/myclass/api/Update_Employee_Contrat/', methods=['POST','GET'])
@crossdomain(origin='*')
def Update_Employee_Contrat():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### Update_Employee_Contrat payload = ",payload)
    status, retval = ressources_humaines.Update_Employee_Contrat(payload)
    return jsonify(status=status, message=retval)

"""
API de suppression du contrat d'un employe
"""
@app.route('/myclass/api/Delete_Employee_Contrat/', methods=['POST','GET'])
@crossdomain(origin='*')
def Delete_Employee_Contrat():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### Delete_Employee_Contrat payload = ",payload)
    status, retval = ressources_humaines.Delete_Employee_Contrat(payload)
    return jsonify(status=status, message=retval)


"""
API pour recuperer les info d'un contrat donnee
"""
@app.route('/myclass/api/Get_Given_Employee_Contrat/', methods=['POST','GET'])
@crossdomain(origin='*')
def Get_Given_Employee_Contrat():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### Get_Given_Employee_Contrat payload = ",payload)
    status, retval = ressources_humaines.Get_Given_Employee_Contrat(payload)
    return jsonify(status=status, message=retval)

"""
API de recuperation de la liste des contrats d'un employee
"""
@app.route('/myclass/api/Get_List_Employee_Contrat/', methods=['POST','GET'])
@crossdomain(origin='*')
def Get_List_Employee_Contrat():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### Get_List_Employee_Contrat payload = ",payload)
    status, retval = ressources_humaines.Get_List_Employee_Contrat(payload)
    return jsonify(status=status, message=retval)


""""
API de recuperation des types de contrat
"""
@app.route('/myclass/api/Get_Type_Contrat_List/', methods=['POST','GET'])
@crossdomain(origin='*')
def Get_Type_Contrat_List():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### Get_Type_Contrat_List payload = ",payload)
    status, retval = ressources_humaines.Get_Type_Contrat_List(payload)
    return jsonify(status=status, message=retval)


"""
API pour créer un compte enseignant dans le LMS
"""
@app.route('/myclass/api/HR_Create_LMS_Trainer_Account/', methods=['POST','GET'])
@crossdomain(origin='*')
def HR_Create_LMS_Trainer_Account():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### HR_Create_LMS_Trainer_Account payload = ",payload)
    status, retval = ressources_humaines.HR_Create_LMS_Trainer_Account(payload)
    return jsonify(status=status, message=retval)



"""
Cette API desactive le compte utilisateur d'un employé
"""
@app.route('/myclass/api/Lock_partner_account_From_Rh_Id/', methods=['POST','GET'])
@crossdomain(origin='*')
def Lock_partner_account_From_Rh_Id():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### Lock_partner_account_From_Rh_Id payload = ",payload)
    status, retval = ressources_humaines.Lock_partner_account_From_Rh_Id(payload)
    return jsonify(status=status, message=retval)


"""
Cette API reactive le compte utilisateur d'un employé
"""
@app.route('/myclass/api/Unlock_partner_account_From_Rh_Id/', methods=['POST','GET'])
@crossdomain(origin='*')
def Unlock_partner_account_From_Rh_Id():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### Unlock_partner_account_From_Rh_Id payload = ",payload)
    status, retval = ressources_humaines.Unlock_partner_account_From_Rh_Id(payload)
    return jsonify(status=status, message=retval)


"""
Cette API ajoute ou met à jour une compétence d'un employés
"""
@app.route('/myclass/api/Add_Update_RH_Competence/', methods=['POST','GET'])
@crossdomain(origin='*')
def Add_Update_RH_Competence():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### Add_Update_RH_Competence payload = ",payload)
    status, retval = ressources_humaines.Add_Update_RH_Competence(payload)
    return jsonify(status=status, message=retval)

"""
Cette API qui supprime une compétence d'un employés
"""
@app.route('/myclass/api/Delete_RH_Competence/', methods=['POST','GET'])
@crossdomain(origin='*')
def Delete_RH_Competence():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### Delete_RH_Competence payload = ",payload)
    status, retval = ressources_humaines.Delete_RH_Competence(payload)
    return jsonify(status=status, message=retval)



"""
API qui desactive le compte LMS d'un employé, en parant du rh_id
"""
@app.route('/myclass/api/Disable_MySy_LMS_Account/', methods=['POST','GET'])
@crossdomain(origin='*')
def Disable_MySy_LMS_Account():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### Disable_MySy_LMS_Account payload = ",payload)
    status, retval = mysy_lms.Disable_MySy_LMS_Account(payload)
    return jsonify(status=status, message=retval)



"""
API qui ajoute une ressource materielles
"""
@app.route('/myclass/api/Add_Ressource_Materielle/', methods=['POST','GET'])
@crossdomain(origin='*')
def Add_Ressource_Materielle():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### Add_Ressource_Materielle payload = ",payload)
    status, retval = ressources_materiels.Add_Ressource_Materielle(payload)
    return jsonify(status=status, message=retval)


"""
API qui met a jour  une ressource materielle
"""
@app.route('/myclass/api/Update_Ressource_Materielle/', methods=['POST','GET'])
@crossdomain(origin='*')
def Update_Ressource_Materielle():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### Update_Ressource_Materielle payload = ",payload)
    status, retval = ressources_materiels.Update_Ressource_Materielle(payload)
    return jsonify(status=status, message=retval)


"""
API de suppression d'un materielle
"""
@app.route('/myclass/api/Delete_Ressource_Materielle/', methods=['POST','GET'])
@crossdomain(origin='*')
def Delete_Ressource_Materielle():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### Delete_Ressource_Materielle payload = ",payload)
    status, retval = ressources_materiels.Delete_Ressource_Materielle(payload)
    return jsonify(status=status, message=retval)

"""
API qui recupere la liste des ressources materielles d'un partenaire
"""
@app.route('/myclass/api/Get_List_Ressource_Materielle/', methods=['POST','GET'])
@crossdomain(origin='*')
def Get_List_Ressource_Materielle():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### Get_List_Ressource_Materielle payload = ",payload)
    status, retval = ressources_materiels.Get_List_Ressource_Materielle(payload)
    return jsonify(status=status, message=retval)


"""
API qui recupere une ressource materielle donnée
"""
@app.route('/myclass/api/Get_Given_Ressource_Materielle/', methods=['POST','GET'])
@crossdomain(origin='*')
def Get_Given_Ressource_Materielle():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### Get_Given_Ressource_Materielle payload = ",payload)
    status, retval = ressources_materiels.Get_Given_Ressource_Materielle(payload)
    return jsonify(status=status, message=retval)


"""
API qui retourne la liste des ressources materielles sans aucun filtre
"""

@app.route('/myclass/api/Get_List_Ressource_Materielle_no_filter/', methods=['POST','GET'])
@crossdomain(origin='*')
def Get_List_Ressource_Materielle_no_filter():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### Get_List_Ressource_Materielle_no_filter payload = ",payload)
    status, retval = ressources_materiels.Get_List_Ressource_Materielle_no_filter(payload)
    return jsonify(status=status, message=retval)


"""
API qui enregistre/met à jour l'image d'une ressource materielle
"""
@app.route('/myclass/api/Update_Ressource_Materielle_Image/', methods=['POST','GET'])
@crossdomain(origin='*')
def Update_Ressource_Materielle_Image():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### Update_Ressource_Materielle_Image : payload = ",payload)

    if request.method == 'POST':
        # Create variable for uploaded file
        if ('file_img' in request.files.keys()):
            file_img = request.files['file_img']
        else:
            file_img = None
            return False, "Aucun fichier image à enregistrer"

    localStatus, message = ressources_materiels.Update_Ressource_Materielle_Image(file_img, MYSY_GV.upload_folder, payload)
    return jsonify(status=localStatus, message=message)


"""
API qui supprime l'image de profil d'une ressource materielle
"""
@app.route('/myclass/api/DeleteImage_Ressource_Materielle/', methods=['POST','GET'])
@crossdomain(origin='*')
def DeleteImage_Ressource_Materielle():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### DeleteImage_Ressource_Materielle payload = ",payload)
    status, retval = ressources_materiels.DeleteImage_Ressource_Materielle(payload)
    return jsonify(status=status, message=retval)


"""
Recuperation de l'image de profil d'un materiel
"""
@app.route('/myclass/api/getRecoded_Materielle_Image_from_front/', methods=['POST','GET'])
@crossdomain(origin='*')
def getRecoded_Materielle_Image_from_front():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### getRecoded_Materielle_Image_from_front payload = ",payload)
    status, retval = ressources_materiels.getRecoded_Materielle_Image_from_front(payload)
    return jsonify(status=status, message=retval)



"""
Recuperation de la liste des affectatoions  d'un materiel
"""
@app.route('/myclass/api/Get_List_Ressource_Materielle_Affectation/', methods=['POST','GET'])
@crossdomain(origin='*')
def Get_List_Ressource_Materielle_Affectation():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### Get_List_Ressource_Materielle_Affectation payload = ",payload)
    status, retval = ressources_materiels.Get_List_Ressource_Materielle_Affectation(payload)
    return jsonify(status=status, message=retval)


"""
API pour affecter un materiel a un poste
"""
@app.route('/myclass/api/Add_Affectation_Ressource_Materielle_Poste/', methods=['POST','GET'])
@crossdomain(origin='*')
def Add_Affectation_Ressource_Materielle_Poste():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### Add_Affectation_Ressource_Materielle_Poste payload = ",payload)
    status, retval = ressources_materiels.Add_Affectation_Ressource_Materielle_Poste(payload)
    return jsonify(status=status, message=retval)

"""
API pour mettre à jour une affectation d'un materielle
"""
@app.route('/myclass/api/Update_Affectation_Ressource_Materielle_Poste/', methods=['POST','GET'])
@crossdomain(origin='*')
def Update_Affectation_Ressource_Materielle_Poste():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### Update_Affectation_Ressource_Materielle_Poste payload = ",payload)
    status, retval = ressources_materiels.Update_Affectation_Ressource_Materielle_Poste(payload)
    return jsonify(status=status, message=retval)


"""
API pour supprimer une affectation d'un materiel
"""
@app.route('/myclass/api/Delete_Affectation_Ressource_Materielle_Poste/', methods=['POST','GET'])
@crossdomain(origin='*')
def Delete_Affectation_Ressource_Materielle_Poste():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### Delete_Affectation_Ressource_Materielle_Poste payload = ",payload)
    status, retval = ressources_materiels.Delete_Affectation_Ressource_Materielle_Poste(payload)
    return jsonify(status=status, message=retval)

"""
API pour récupérer une affectation donnée d'un materiel
"""
@app.route('/myclass/api/Get_Given_Affectation_Ressource_Materielle_Poste/', methods=['POST','GET'])
@crossdomain(origin='*')
def Get_Given_Affectation_Ressource_Materielle_Poste():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### Get_Given_Affectation_Ressource_Materielle_Poste payload = ",payload)
    status, retval = ressources_materiels.Get_Given_Affectation_Ressource_Materielle_Poste(payload)
    return jsonify(status=status, message=retval)

"""
API pour  récupérer la liste des 'related_target_collection_object' avec les 'related_target_collection_id_nom'
et de les formater pour une utilisation simple coté front pour un materiel
"""
@app.route('/myclass/api/Get_Related_Target_Materiel_Collection_Data/', methods=['POST','GET'])
@crossdomain(origin='*')
def Get_Related_Target_Materiel_Collection_Data():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### Get_Related_Target_Materiel_Collection_Data payload = ",payload)
    status, retval = ressources_materiels.Get_Related_Target_Materiel_Collection_Data(payload)
    return jsonify(status=status, message=retval)

"""
API de recherche d'une recherche materielle avec des filtres
"""
@app.route('/myclass/api/Get_List_Ressource_Materielle_with_filter/', methods=['POST','GET'])
@crossdomain(origin='*')
def Get_List_Ressource_Materielle_with_filter():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### Get_List_Ressource_Materielle_with_filter payload = ",payload)
    status, retval = ressources_materiels.Get_List_Ressource_Materielle_with_filter(payload)
    return jsonify(status=status, message=retval)


"""
API de recherche d'une recherche materielle avec des filtres No Salle, donc hors salle
"""
@app.route('/myclass/api/Get_List_Ressource_Materielle_with_filter_No_Salle/', methods=['POST','GET'])
@crossdomain(origin='*')
def Get_List_Ressource_Materielle_with_filter_No_Salle():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### Get_List_Ressource_Materielle_with_filter_No_Salle payload = ",payload)
    status, retval = ressources_materiels.Get_List_Ressource_Materielle_with_filter_No_Salle(payload)
    return jsonify(status=status, message=retval)


"""
API Pour récuperer la liste des ressources (humaines ou materielles) rattachée
à une ressource materiel (ex : la liste des ordinateurs d'une salle)
"""
@app.route('/myclass/api/Get_List_Ressource_Materielle_Rattachement/', methods=['POST','GET'])
@crossdomain(origin='*')
def Get_List_Ressource_Materielle_Rattachement():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### Get_List_Ressource_Materielle_Rattachement payload = ",payload)
    status, retval = ressources_materiels.Get_List_Ressource_Materielle_Rattachement(payload)
    return jsonify(status=status, message=retval)


"""
API pour recuperer les differents types de ressources materielles
"""
@app.route('/myclass/api/Get_Type_Ressource_Materielle/', methods=['POST','GET'])
@crossdomain(origin='*')
def Get_Type_Ressource_Materielle():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### Get_Type_Ressource_Materielle payload = ",payload)
    status, retval = ressources_materiels.Get_Type_Ressource_Materielle(payload)
    return jsonify(status=status, message=retval)



"""
API pour recuperer les differentes catégories de ressources materielles
"""
@app.route('/myclass/api/Get_Categorie_Ressource_Materielle/', methods=['POST','GET'])
@crossdomain(origin='*')
def Get_Categorie_Ressource_Materielle():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### Get_Categorie_Ressource_Materielle payload = ",payload)
    status, retval = ressources_materiels.Get_Categorie_Ressource_Materielle(payload)
    return jsonify(status=status, message=retval)




"""
API de creation d'une commande client d'un partner
"""
@app.route('/myclass/api/Add_Partner_Order/', methods=['POST','GET'])
@crossdomain(origin='*')
def Add_Partner_Order():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### Add_Partner_Order payload = ",payload)
    status, retmessage, retval = partner_order.Add_Partner_Order(payload)
    return jsonify(status=status, message=retmessage, retval=retval)


"""
API de creation d'un devis client d'un partenaire
"""
@app.route('/myclass/api/Add_Partner_Quotation/', methods=['POST','GET'])
@crossdomain(origin='*')
def Add_Partner_Quotation():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### Add_Partner_Quotation payload = ",payload)
    status, retmessage, retval = partner_order.Add_Partner_Quotation(payload)
    return jsonify(status=status, message=retmessage, retval=retval)





"""
API de recuperation d'une commande client d'un partner en utilisant le '_id'
"""
@app.route('/myclass/api/Get_Given_Partner_Order/', methods=['POST','GET'])
@crossdomain(origin='*')
def Get_Given_Partner_Order():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### Get_Given_Partner_Order payload = ",payload)
    status, retval = partner_order.Get_Given_Partner_Order(payload)
    return jsonify(status=status, message=retval)


"""
API de recuperation d'une commande client d'un partner en utilisant la 'ref_interne'
"""
@app.route('/myclass/api/Get_Given_Partner_Order_From_Internal_ref/', methods=['POST','GET'])
@crossdomain(origin='*')
def Get_Given_Partner_Order_From_Internal_ref():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### Get_Given_Partner_Order_From_Internal_ref payload = ",payload)
    status, retval = partner_order.Get_Given_Partner_Order_From_Internal_ref(payload)
    return jsonify(status=status, message=retval)


"""
API de recuperation de la lise des commandes d'un partenaire, sans auncun filtre
"""
@app.route('/myclass/api/Get_List_Partner_Order_no_filter/', methods=['POST','GET'])
@crossdomain(origin='*')
def Get_List_Partner_Order_no_filter():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### Get_List_Partner_Order_no_filter payload = ",payload)
    status, retval = partner_order.Get_List_Partner_Order_no_filter(payload)
    return jsonify(status=status, message=retval)


"""
API de recuperation de la lise des commandes d'un partenaire, avec des filtres
"""
@app.route('/myclass/api/Get_List_Partner_Order_with_filter/', methods=['POST','GET'])
@crossdomain(origin='*')
def Get_List_Partner_Order_with_filter():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### Get_List_Partner_Order_with_filter payload = ",payload)
    status, retval = partner_order.Get_List_Partner_Order_with_filter(payload)
    return jsonify(status=status, message=retval)


"""
API qui permet de récupérer le detail d'un lignes de la collection "partner_order_line"
"""
@app.route('/myclass/api/Get_Given_Line_Of_Partner_Order_Lines/', methods=['POST','GET'])
@crossdomain(origin='*')
def Get_Given_Line_Of_Partner_Order_Lines():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### Get_Given_Line_Of_Partner_Order_Lines payload = ",payload)
    status, retval = partner_order.Get_Given_Line_Of_Partner_Order_Lines(payload)
    return jsonify(status=status, message=retval)



"""
API de mise à jour d'une entete de commande client d'un partenaire
"""
@app.route('/myclass/api/Update_Partner_Order_Header/', methods=['POST','GET'])
@crossdomain(origin='*')
def Update_Partner_Order_Header():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### Update_Partner_Order_Header payload = ",payload)
    status, retval = partner_order.Update_Partner_Order_Header(payload)
    return jsonify(status=status, message=retval)

"""
API de mise à jour d'une entete d'un devis client d'un partenaire
"""
@app.route('/myclass/api/Update_Partner_Quotation_Header/', methods=['POST','GET'])
@crossdomain(origin='*')
def Update_Partner_Quotation_Header():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### Update_Partner_Quotation_Header payload = ",payload)
    status, retval = partner_order.Update_Partner_Quotation_Header(payload)
    return jsonify(status=status, message=retval)



"""
API de Ajout et mise à jour  d'une ligne  commande client d'un partenaire
"""
@app.route('/myclass/api/Add_Update_Partner_Order_Line/', methods=['POST','GET'])
@crossdomain(origin='*')
def Add_Update_Partner_Order_Line():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### Add_Update_Partner_Order_Line payload = ",payload)
    status, retval = partner_order.Add_Update_Partner_Order_Line(payload)
    return jsonify(status=status, message=retval)


"""
API de confirmation d'un document (devis ou cmd) 
"""

@app.route('/myclass/api/Confirm_Partner_Order_Header_And_Lines/', methods=['POST','GET'])
@crossdomain(origin='*')
def Confirm_Partner_Order_Header_And_Lines():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### Confirm_Partner_Order_Header_And_Lines payload = ",payload)
    status, retval = partner_order.Confirm_Partner_Order_Header_And_Lines(payload)
    return jsonify(status=status, message=retval)


"""
API d'annulation  d'un document (devis ou cmd) 
"""

@app.route('/myclass/api/Annule_Partner_Order_Header_And_Lines/', methods=['POST','GET'])
@crossdomain(origin='*')
def Annule_Partner_Order_Header_And_Lines():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### Annule_Partner_Order_Header_And_Lines payload = ",payload)
    status, retval = partner_order.Annule_Partner_Order_Header_And_Lines(payload)
    return jsonify(status=status, message=retval)





"""
API de suppression d'une commande entière, avec les lignes associée (commande client d'un partenaire), ceci en utilisant l'_id
"""
@app.route('/myclass/api/Delete_Partner_Order_Header_And_Lines/', methods=['POST','GET'])
@crossdomain(origin='*')
def Delete_Partner_Order_Header_And_Lines():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### Delete_Partner_Order_Header_And_Lines payload = ",payload)
    status, retval = partner_order.Delete_Partner_Order_Header_And_Lines(payload)
    return jsonify(status=status, message=retval)

"""
API de suppression d'une commande entière, avec les lignes associée (commande client d'un partenaire), ceci en utilisant order_header_ref_interne
"""
@app.route('/myclass/api/Delete_Partner_Order_Header_And_Lines_From_order_reference/', methods=['POST','GET'])
@crossdomain(origin='*')
def Delete_Partner_Order_Header_And_Lines_From_order_reference():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### Delete_Partner_Order_Header_And_Lines_From_order_reference payload = ",payload)
    status, retval = partner_order.Delete_Partner_Order_Header_And_Lines_From_order_reference(payload)
    return jsonify(status=status, message=retval)

"""
API de suppression d'une ligne d'une commande client d'un partenaire (partner_order_line) 
"""
@app.route('/myclass/api/Delete_Partner_Order_Line/', methods=['POST','GET'])
@crossdomain(origin='*')
def Delete_Partner_Order_Line():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### Delete_Partner_Order_Line payload = ",payload)
    status, retval = partner_order.Delete_Partner_Order_Line(payload)
    return jsonify(status=status, message=retval)


"""
API de recuperation des lignes de commande (partner_order_line) en utilisant le order_header_id
"""
@app.route('/myclass/api/Get_Given_Partner_Order_Lines/', methods=['POST','GET'])
@crossdomain(origin='*')
def Get_Given_Partner_Order_Lines():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### Get_Given_Partner_Order_Lines payload = ",payload)
    status, retval = partner_order.Get_Given_Partner_Order_Lines(payload)
    return jsonify(status=status, message=retval)


"""
API de compute d'un partner_order (calcul des totaux)
"""
@app.route('/myclass/api/Compute_Order_Header/', methods=['POST','GET'])
@crossdomain(origin='*')
def Compute_Order_Header():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### Compute_Order_Header payload = ",payload)
    status, retval = partner_order.Compute_Order_Header(payload)
    return jsonify(status=status, message=retval)



"""
API de recuperation des lignes de commande (partner_order_line) en utilisant le order_header_ref_interne
"""
@app.route('/myclass/api/Get_Given_Partner_Order_Lines_From_order_ref_interne/', methods=['POST','GET'])
@crossdomain(origin='*')
def Get_Given_Partner_Order_Lines_From_order_ref_interne():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### Get_Given_Partner_Order_Lines_From_order_ref_interne payload = ",payload)
    status, retval = partner_order.Get_Given_Partner_Order_Lines_From_order_ref_interne(payload)
    return jsonify(status=status, message=retval)



"""
API qui permet d'ajouter un document personnalisable 
"""
@app.route('/myclass/api/Add_Partner_Document/', methods=['POST','GET'])
@crossdomain(origin='*')
def Add_Partner_Document():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### Add_Partner_Document payload = ",payload)
    status, retval = partner_document_mgt.Add_Partner_Document(payload)
    return jsonify(status=status, message=retval)


"""
API qui permet de modifier  un document personnalisable 
"""
@app.route('/myclass/api/Update_Partner_Document/', methods=['POST','GET'])
@crossdomain(origin='*')
def Update_Partner_Document():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### Update_Partner_Document payload = ",payload)
    status, retval = partner_document_mgt.Update_Partner_Document(payload)
    return jsonify(status=status, message=retval)

"""
API qui permet de récupérer  un document personnalisable donné
"""
@app.route('/myclass/api/Get_Given_Partner_Document/', methods=['POST','GET'])
@crossdomain(origin='*')
def Get_Given_Partner_Document():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### Get_Given_Partner_Document payload = ",payload)
    status, retval = partner_document_mgt.Get_Given_Partner_Document(payload)
    return jsonify(status=status, message=retval)


"""
API de recuperation d'un document par default : un document par defaut qui EST UNIQUEMENT paramettré avec un "partner_owner_recid" =  "default"
"""
@app.route('/myclass/api/Get_Given_DFAULT_Partner_Document/', methods=['POST','GET'])
@crossdomain(origin='*')
def Get_Given_DFAULT_Partner_Document():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### Get_Given_DFAULT_Partner_Document payload = ",payload)
    status, retval = partner_document_mgt.Get_Given_DFAULT_Partner_Document(payload)
    return jsonify(status=status, message=retval)


"""
API de recuperation d'un document d'orignine (template)
"""
@app.route('/myclass/api/Get_Default_Partner_Document_By_Internal_Ref/', methods=['POST','GET'])
@crossdomain(origin='*')
def Get_Default_Partner_Document_By_Internal_Ref():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### Get_Default_Partner_Document_By_Internal_Ref payload = ",payload)
    status, retval = partner_document_mgt.Get_Default_Partner_Document_By_Internal_Ref(payload)
    return jsonify(status=status, message=retval)




"""
API qui permet de supprimer  un document personnalisable 
"""
@app.route('/myclass/api/Delete_Partner_Document/', methods=['POST','GET'])
@crossdomain(origin='*')
def Delete_Partner_Document():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### Delete_Partner_Document payload = ",payload)
    status, retval = partner_document_mgt.Delete_Partner_Document(payload)
    return jsonify(status=status, message=retval)




"""
API qui permet de récupérer la liste des documents personnalisables d'un partenaire 
"""
@app.route('/myclass/api/Get_List_Partner_Document/', methods=['POST','GET'])
@crossdomain(origin='*')
def Get_List_Partner_Document():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### Get_List_Partner_Document payload = ",payload)
    status, retval = partner_document_mgt.Get_List_Partner_Document(payload)
    return jsonify(status=status, message=retval)

"""
API qui permet de récupérer la liste des documents personnalisables d'un partenaire  sans filtre
"""
@app.route('/myclass/api/Get_List_Partner_Document_no_filter/', methods=['POST','GET'])
@crossdomain(origin='*')
def Get_List_Partner_Document_no_filter():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### Get_List_Partner_Document_no_filter payload = ",payload)
    status, retval = partner_document_mgt.Get_List_Partner_Document_no_filter(payload)
    return jsonify(status=status, message=retval)



"""
API qui permet de récupérer la liste des documents personnalisables d'un partenaire  avec filtre
"""
@app.route('/myclass/api/Get_List_Partner_Document_with_filter/', methods=['POST','GET'])
@crossdomain(origin='*')
def Get_List_Partner_Document_with_filter():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### Get_List_Partner_Document_with_filter payload = ",payload)
    status, retval = partner_document_mgt.Get_List_Partner_Document_with_filter(payload)
    return jsonify(status=status, message=retval)


"""
API d'impression pdf d'un commande / devis
"""
@app.route('/myclass/api/GerneratePDF_Partner_Order/<token>/<order_id>', methods=['POST','GET'])
@crossdomain(origin='*')
def GerneratePDF_Partner_Order(token, order_id):
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    payload = {}
    payload['token'] = str(token)
    payload['order_id'] = str(order_id)


    print(" ### GerneratePDF_Partner_Order : payload = ",str(payload))

    localStatus, response= partner_order.GerneratePDF_Partner_Order(payload)
    if(localStatus ):
        return response
    else:
        return False


"""
API qui envoie un partner_order par email au client 
"""
@app.route('/myclass/api/Send_Partner_Order_By_Email/', methods=['GET','POST'])
@crossdomain(origin='*')
def Send_Partner_Order_By_Email():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### Send_Partner_Order_By_Email payload = ", str(payload))
    status, message = partner_order.Send_Partner_Order_By_Email(payload)
    return jsonify(status=status,  message=message)

"""
Conversion d'un devis en commande 
"""
@app.route('/myclass/api/Convert_Quotation_to_Order/', methods=['GET','POST'])
@crossdomain(origin='*')
def Convert_Quotation_to_Order():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### Convert_Quotation_to_Order payload = ", str(payload))
    status, message, retval = partner_order.Convert_Quotation_to_Order(payload)
    return jsonify(status=status,  message=message, retval=retval)


"""
API pour mettre la commande 'pret pour facturation'
"""
"""
Conversion d'un devis en commande 
"""
@app.route('/myclass/api/Order_Ready_To_Invoice/', methods=['GET','POST'])
@crossdomain(origin='*')
def Order_Ready_To_Invoice():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### Order_Ready_To_Invoice payload = ", str(payload))
    status, message = partner_order.Order_Ready_To_Invoice(payload)
    return jsonify(status=status,  message=message)




"""
API de recuperation de tous les champs personnalisables dans un document
"""
@app.route('/myclass/api/Get_All_Personnalisable_Collection_Fields/', methods=['POST','GET'])
@crossdomain(origin='*')
def Get_All_Personnalisable_Collection_Fields():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### Get_All_Personnalisable_Collection_Fields payload = ",payload)
    status, retval = partner_document_mgt.Get_All_Personnalisable_Collection_Fields(payload)
    return jsonify(status=status, message=retval)

"""
API de recuperation des champs personnalisable d'un 'courrier_template_ref_interne' donné
"""
@app.route('/myclass/api/Get_Given_Personnalisable_Fields_By_template_ref_interne/', methods=['POST','GET'])
@crossdomain(origin='*')
def Get_Given_Personnalisable_Fields_By_template_ref_interne():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### Get_Given_Personnalisable_Fields_By_template_ref_interne payload = ",payload)
    status, retval = partner_document_mgt.Get_Given_Personnalisable_Fields_By_template_ref_interne(payload)
    return jsonify(status=status, message=retval)



"""
API de Recuperation des champs personnalisable d'un 'courrier_template_id' donné, avec un partner_owner_recid  = "default"
"""
@app.route('/myclass/api/Get_Given_Personnalisable_Fields_By_courrier_template_id/', methods=['POST','GET'])
@crossdomain(origin='*')
def Get_Given_Personnalisable_Fields_By_courrier_template_id():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### Get_Given_Personnalisable_Fields_By_courrier_template_id payload = ",payload)
    status, retval = partner_document_mgt.Get_Given_Personnalisable_Fields_By_courrier_template_id(payload)
    return jsonify(status=status, message=retval)


"""
API qui permet de dupliquer un document personnalisé
"""

@app.route('/myclass/api/Duplicate_Given_Partner_Document/', methods=['POST','GET'])
@crossdomain(origin='*')
def Duplicate_Given_Partner_Document():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### Duplicate_Given_Partner_Document payload = ",payload)
    status, retval = partner_document_mgt.Duplicate_Given_Partner_Document(payload)
    return jsonify(status=status, message=retval)





"""
API de recuperation de la liste des documents par defautl
"""
@app.route('/myclass/api/Get_List_Default_Partner_Document/', methods=['POST','GET'])
@crossdomain(origin='*')
def Get_List_Default_Partner_Document():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### Get_List_Default_Partner_Document payload = ",payload)
    status, retval = partner_document_mgt.Get_List_Default_Partner_Document(payload)
    return jsonify(status=status, message=retval)


"""
API qui permet de recuperer la liste des modules de 
l'application sous forme de matrice de droits d'acces 
"""
@app.route('/myclass/api/Get_Matrix_Acces_Right/', methods=['POST','GET'])
@crossdomain(origin='*')
def Get_Matrix_Acces_Right():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### Get_Matrix_Acces_Right payload = ",payload)
    status, retval = user_access_right.Get_Matrix_Acces_Right(payload)
    return jsonify(status=status, message=retval)


"""
API qui permet de recuperer la liste des modules de 
l'application sous forme de matrice de droits d'acces, ce pour un profile donne
"""
@app.route('/myclass/api/Get_Matrix_Acces_Right_By_Profil/', methods=['POST','GET'])
@crossdomain(origin='*')
def Get_Matrix_Acces_Right_By_Profil():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### Get_Matrix_Acces_Right_By_Profil payload = ",payload)
    status, retval = user_access_right.Get_Matrix_Acces_Right_By_Profil(payload)
    return jsonify(status=status, message=retval)



"""
Ajout et mise à jour des droits d'acces d'un user (ressource_humaine_id)
"""
@app.route('/myclass/api/Add_Update_User_Access_Right/', methods=['POST','GET'])
@crossdomain(origin='*')
def Add_Update_User_Access_Right():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### Add_Update_User_Access_Right payload = ",payload)
    status, retval = user_access_right.Add_Update_User_Access_Right(payload)
    return jsonify(status=status, message=retval)



"""
Gestion des droits d'acces par user, module et action
"""
@app.route('/myclass/api/Is_User_Has_Right_To_Action/', methods=['POST','GET'])
@crossdomain(origin='*')
def Is_User_Has_Right_To_Action():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### Is_User_Has_Right_To_Action payload = ",payload)
    status, retval = mycommon.Is_User_Has_Right_To_Action(payload)
    return jsonify(status=status, message=retval)


"""
API de facturation des commandes d'un partenaire
"""

@app.route('/myclass/api/Invoice_Partner_Order/', methods=['POST','GET'])
@crossdomain(origin='*')
def Invoice_Partner_Order():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### Invoice_Partner_Order payload = ",payload)
    status, retval, invoice_id = partner_invoice.Invoice_Partner_Order(payload)
    return jsonify(status=status, message=retval)

# --------------

"""
API Recuperation d'une facture donnée
"""
@app.route('/myclass/api/Get_Given_Partner_Invoice/', methods=['POST','GET'])
@crossdomain(origin='*')
def Get_Given_Partner_Invoice():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### Get_Given_Partner_Invoice payload = ",payload)
    status, retval = partner_invoice.Get_Given_Partner_Invoice(payload)
    return jsonify(status=status, message=retval)


"""
API Recuperation des lignes d'une facture à partir de l'invoice_header_id, sans entete
"""
@app.route('/myclass/api/Get_Given_Partner_Invoice_Lines/', methods=['POST','GET'])
@crossdomain(origin='*')
def Get_Given_Partner_Invoice_Lines():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### Get_Given_Partner_Invoice_Lines payload = ",payload)
    status, retval = partner_invoice.Get_Given_Partner_Invoice_Lines(payload)
    return jsonify(status=status, message=retval)


"""
API Recuperation des lignes d'une commande à partir de l' invoice_header_ref_interne, sans entete
"""
@app.route('/myclass/api/Get_Given_Partner_Invoice_Lines_From_Invoice_ref_interne/', methods=['POST','GET'])
@crossdomain(origin='*')
def Get_Given_Partner_Invoice_Lines_From_Invoice_ref_interne():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### Get_Given_Partner_Invoice_Lines_From_Invoice_ref_interne payload = ",payload)
    status, retval = partner_invoice.Get_Given_Partner_Invoice_Lines_From_Invoice_ref_interne(payload)
    return jsonify(status=status, message=retval)


"""
API : Recuperation de la liste des factures d'un partner
"""
@app.route('/myclass/api/Get_List_Partner_Invoice_no_filter/', methods=['POST','GET'])
@crossdomain(origin='*')
def Get_List_Partner_Invoice_no_filter():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### Get_List_Partner_Invoice_no_filter payload = ",payload)
    status, retval = partner_invoice.Get_List_Partner_Invoice_no_filter(payload)
    return jsonify(status=status, message=retval)


"""
API Recuperation de la liste des factures avec des filtres.
les filtres acceptés sont : 
- ref_interne_cmd (commande)
- ref_interne_invoice
- ref_externe
- invoice_date entre date_debut et date_fin  
- nom_client
"""
@app.route('/myclass/api/Get_List_Partner_Invoice_with_filter/', methods=['POST','GET'])
@crossdomain(origin='*')
def Get_List_Partner_Invoice_with_filter():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### Get_List_Partner_Invoice_with_filter payload = ",payload)
    status, retval = partner_invoice.Get_List_Partner_Invoice_with_filter(payload)
    return jsonify(status=status, message=retval)


"""
Cette API  permet de récupérer une ligne de detail d'une facture donnée
c'est a dire, une ligne de la collection 'partner_invoice_line' 
"""

@app.route('/myclass/api/Get_Given_Line_Of_Partner_Invoice_Lines/', methods=['POST','GET'])
@crossdomain(origin='*')
def Get_Given_Line_Of_Partner_Invoice_Lines():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### Get_Given_Line_Of_Partner_Invoice_Lines payload = ",payload)
    status, retval = partner_invoice.Get_Given_Line_Of_Partner_Invoice_Lines(payload)
    return jsonify(status=status, message=retval)


"""
API Impression PDF d'une facture 
"""

@app.route('/myclass/api/GerneratePDF_Partner_Invoice/<token>/<invoice_id>', methods=['POST','GET'])
@crossdomain(origin='*')
def GerneratePDF_Partner_Invoice(token, invoice_id):
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    payload = {}
    payload['token'] = str(token)
    payload['invoice_id'] = str(invoice_id)


    print(" ### GerneratePDF_Partner_Invoice : payload = ",str(payload))

    localStatus, response= partner_invoice.GerneratePDF_Partner_Invoice(payload)
    if(localStatus ):
        return response
    else:
        return False

"""
API Envoie de la facture par email
"""
@app.route('/myclass/api/Send_Partner_Invoice_By_Email/', methods=['POST','GET'])
@crossdomain(origin='*')
def Send_Partner_Invoice_By_Email():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### Send_Partner_Invoice_By_Email payload = ",payload)
    status, retval = partner_invoice.Send_Partner_Invoice_By_Email(payload)
    return jsonify(status=status, message=retval)


"""
API d'ajout / modification d'un point de paramettrage pour le partenaire
"""
@app.route('/myclass/api/Add_Update_Partner_Basic_Setup/', methods=['POST','GET'])
@crossdomain(origin='*')
def Add_Update_Partner_Basic_Setup():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### Add_Update_Partner_Basic_Setup payload = ",payload)
    status, retval = partner_base_setup.Add_Update_Partner_Basic_Setup(payload)
    return jsonify(status=status, message=retval)

"""
API de suppression d'un point de paramétrage pour le partenaire en partant de '_id et du nom du point de config
"""
@app.route('/myclass/api/Delete_Partner_Basic_Setup/', methods=['POST','GET'])
@crossdomain(origin='*')
def Delete_Partner_Basic_Setup():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### Delete_Partner_Basic_Setup payload = ",payload)
    status, retval = partner_base_setup.Delete_Partner_Basic_Setup(payload)
    return jsonify(status=status, message=retval)

"""
API de recuperation de la liste des points de paramettrage
"""
@app.route('/myclass/api/Get_List_Partner_Basic_Setup/', methods=['POST','GET'])
@crossdomain(origin='*')
def Get_List_Partner_Basic_Setup():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### Get_List_Partner_Basic_Setup payload = ",payload)
    status, retval = partner_base_setup.Get_List_Partner_Basic_Setup(payload)
    return jsonify(status=status, message=retval)


"""
API de recuperation d'un point de parametrage donnée 
"""
@app.route('/myclass/api/Get_Given_Partner_Basic_Setup/', methods=['POST','GET'])
@crossdomain(origin='*')
def Get_Given_Partner_Basic_Setup():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### Get_Given_Partner_Basic_Setup payload = ",payload)
    status, retval = partner_base_setup.Get_Given_Partner_Basic_Setup(payload)
    return jsonify(status=status, message=retval)



"""
API de recuperation de la liste des fichiers attaché à 
- une collection
- owner email
"""
@app.route('/myclass/api/Get_List_object_owner_collection_Stored_Files/', methods=['POST','GET'])
@crossdomain(origin='*')
def Get_object_owner_collection_Stored_Files():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### Get_List_object_owner_collection_Stored_Files : payload  = ",payload)
    status, retval = attached_file_mgt.Get_List_object_owner_collection_Stored_Files(payload)
    return jsonify(status=status, message=retval)


"""
API de suppression d'un fichier stocké
"""
@app.route('/myclass/api/Delete_Stored_Downloaded_File/', methods=['POST','GET'])
@crossdomain(origin='*')
def Delete_Stored_Downloaded_File():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### Delete_Stored_Downloaded_File : payload  = ",payload)
    status, retval = attached_file_mgt.Delete_Stored_Downloaded_File(payload)
    return jsonify(status=status, message=retval)



"""
API   d'enregistrement 
d'une pièce jointe
"""
@app.route('/myclass/api/Store_User_Downloaded_File/', methods=['POST','GET'])
@crossdomain(origin='*')
def Store_User_Downloaded_File():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### Store_User_Downloaded_File payload = ",payload)
    print(request.files)

    if request.method == 'POST':
        # Create variable for uploaded file
        f = request.files['File']

        status, retval = attached_file_mgt.Store_User_Downloaded_File(f, app.config['UPLOAD_FOLDER'], payload)

    return jsonify(status=status, message=retval)


"""
API de recuperartion des fichier telechargés par une user
"""


@app.route('/myclass/api/Get_Stored_Downloaded_File/<token>/<file_name>',methods=['POST', 'GET'])
@crossdomain(origin='*')
def Get_Stored_Downloaded_File(token, file_name):
    # On recupere le corps (payload) de la requete
    payload = {}
    payload['token'] = str(token)
    payload['file_name'] = str(file_name)

    payload = mycommon.strip_dictionary(payload)

    print(" ### Get_Stored_Downloaded_File : payload = ",payload)
    status, retval = attached_file_mgt.Get_Stored_Downloaded_File(payload)
    if (status is False):
        return ""

    return retval



"""
API d'ajout d'un champ personnalisé
"""
@app.route('/myclass/api/Add_specific_field/', methods=['POST','GET'])
@crossdomain(origin='*')
def Add_specific_field():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### Add_specific_field : payload  = ",payload)
    status, retval = base_specific_fields.Add_specific_field(payload)
    return jsonify(status=status, message=retval)


"""
API de mise à jour d'un champ personnalisé
"""
@app.route('/myclass/api/Update_specific_field/', methods=['POST','GET'])
@crossdomain(origin='*')
def Update_specific_field():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### Update_specific_field : payload = ",payload)
    status, retval = base_specific_fields.Update_specific_field(payload)
    return jsonify(status=status, message=retval)

"""
API de recuperation d'un champ personnalisé donné
"""
@app.route('/myclass/api/get_given_specific_field/', methods=['POST','GET'])
@crossdomain(origin='*')
def get_given_specific_field():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### get_given_specific_field : payload = ",payload)
    status, retval = base_specific_fields.get_given_specific_field(payload)
    return jsonify(status=status, message=retval)

"""
API de suppression d'un champ personnalisé donnée si toutes les regles sont remplies
"""
@app.route('/myclass/api/delete_given_specific_field/', methods=['POST','GET'])
@crossdomain(origin='*')
def delete_given_specific_field():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### delete_given_specific_field : payload = ",payload)
    status, retval = base_specific_fields.delete_given_specific_field(payload)
    return jsonify(status=status, message=retval)


"""
API de recuperation de liste des champs spécifique d'un partenaire sans filtres.
il est important de ne prendre que ceux qui sont valide et avec is_displayed = 1
car cette fonction est utilisée pour remplir les champs.

"""
@app.route('/myclass/api/Get_Partner_Object_Specific_Valide_Displayed_Fields/', methods=['POST','GET'])
@crossdomain(origin='*')
def Get_Partner_Object_Specific_Valide_Displayed_Fields():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### Get_Partner_Object_Specific_Valide_Displayed_Fields : payload = ",payload)
    status, retval = base_specific_fields.Get_Partner_Object_Specific_Valide_Displayed_Fields(payload)
    return jsonify(status=status, message=retval)





"""
API de recuperation de liste des champs spécifique d'un partenaire sans filtres
"""
@app.route('/myclass/api/get_list_specific_field_partner_no_filter/', methods=['POST','GET'])
@crossdomain(origin='*')
def get_list_specific_field_partner_no_filter():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### get_list_specific_field_partner_no_filter : payload = ",payload)
    status, retval = base_specific_fields.get_list_specific_field_partner_no_filter(payload)
    return jsonify(status=status, message=retval)


"""
API de recuperation de liste des champs spécifique d'un partenaire avec des filtres sur : 
- objet metier
- nom du champs
"""
@app.route('/myclass/api/get_list_specific_field_partner_with_filter/', methods=['POST','GET'])
@crossdomain(origin='*')
def get_list_specific_field_partner_with_filter():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### get_list_specific_field_partner_with_filter : payload = ",payload)
    status, retval = base_specific_fields.get_list_specific_field_partner_with_filter(payload)
    return jsonify(status=status, message=retval)





"""
API de Recuperation de liste de champs spécifique d'un objet pou un partenaire
"""
@app.route('/myclass/api/get_list_specific_field_partner_by_object/', methods=['POST','GET'])
@crossdomain(origin='*')
def get_list_specific_field_partner_by_object():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### get_list_specific_field_partner_by_object : payload  = ",payload)
    status, retval = base_specific_fields.get_list_specific_field_partner_by_object(payload)
    return jsonify(status=status, message=retval)




"""
Cette API retourne la liste des objet metier eligibles
pour l'ajout de champs spécifiques
"""
@app.route('/myclass/api/Get_Collection_Eligible_Champ_Specific/', methods=['POST','GET'])
@crossdomain(origin='*')
def Get_Collection_Eligible_Champ_Specific():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### Get_Collection_Eligible_Champ_Specific : payload  = ",payload)
    status, retval = base_specific_fields.Get_Collection_Eligible_Champ_Specific()
    return jsonify(status=status, message=retval)


"""
API de la recuperation de la liste des evenements dans l'agenda 
"""
@app.route('/myclass/api/get_Agenda_Event_List/', methods=['POST','GET'])
@crossdomain(origin='*')
def get_Agenda_Event_List():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### get_Agenda_Event_List : payload  = ",payload)
    status, retval = agenda.get_Agenda_Event_List(payload)
    return jsonify(status=status, message=retval)


"""
API de la recuperation de la liste des evenements dans l'agenda pour un stagiaire
"""
@app.route('/myclass/api/get_Agenda_Event_List_Stagiaire/', methods=['POST','GET'])
@crossdomain(origin='*')
def get_Agenda_Event_List_Stagiaire():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### get_Agenda_Event_List_Stagiaire : payload  = ",payload)
    status, retval = agenda.get_Agenda_Event_List_Stagiaire(payload)
    return jsonify(status=status, message=retval)



"""
API de la recuperation de la liste des evenements dans l'agenda avec des filtre
"""
@app.route('/myclass/api/get_Agenda_Event_List_With_Filter/', methods=['POST','GET'])
@crossdomain(origin='*')
def get_Agenda_Event_List_With_Filter():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### get_Agenda_Event_List_With_Filter : payload  = ",payload)
    status, retval = agenda.get_Agenda_Event_List_With_Filter(payload)
    return jsonify(status=status, message=retval)



"""
API d'ajout ou mise à jour d'un evenement
/!\ : Important : 
- Pour les eemployé et le materiel, on utilise le  related_collection_recid
"""
@app.route('/myclass/api/Add_Update_Agenda_Event/', methods=['POST','GET'])
@crossdomain(origin='*')
def Add_Update_Agenda_Event():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### Add_Update_Agenda_Event : payload  = ",payload)
    status, retval = agenda.Add_Update_Agenda_Event(payload)
    return jsonify(status=status, message=retval)

"""
API d'ajout ou mise à jour d'un evenement pour les apprenants
/!\ : Important : 
- Pour les apprenant (inscription), on utilise 'related_collection_email' car la clé des apprenant est l'email
"""
@app.route('/myclass/api/Add_Update_Agenda_Event_Stagiaire/', methods=['POST','GET'])
@crossdomain(origin='*')
def Add_Update_Agenda_Event_Stagiaire():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### Add_Update_Agenda_Event_Stagiaire : payload  = ",payload)
    status, retval = agenda.Add_Update_Agenda_Event_Stagiaire(payload)
    return jsonify(status=status, message=retval)


""" API de suppression d'un evenement dans un agenda
"""
@app.route('/myclass/api/Delete_Agenda_Event/', methods=['POST','GET'])
@crossdomain(origin='*')
def Delete_Agenda_Event():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### Delete_Agenda_Event : payload  = ",payload)
    status, retval = agenda.Delete_Agenda_Event(payload)
    return jsonify(status=status, message=retval)

"""
API qui retourne les data d'une ressource (materielle ou humaine)
"""
@app.route('/myclass/api/get_Ressource_Info_Data/', methods=['POST','GET'])
@crossdomain(origin='*')
def get_Ressource_Info_Data():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### get_Ressource_Info_Data : payload  = ",payload)
    status, retval = agenda.get_Ressource_Info_Data(payload)
    return jsonify(status=status, message=retval)



"""
API qui retourne les data d'une ressource pour un stagiaire
"""
@app.route('/myclass/api/get_Ressource_Info_Data_Satgiaire/', methods=['POST','GET'])
@crossdomain(origin='*')
def get_Ressource_Info_Data_Satgiaire():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### get_Ressource_Info_Data_Satgiaire : payload  = ",payload)
    status, retval = agenda.get_Ressource_Info_Data_Satgiaire(payload)
    return jsonify(status=status, message=retval)



""" 
API pour ajouter ou modifier un parametrage : etape des sessions de formation
"""

@app.route('/myclass/api/Add_Update_Partner_session_step/', methods=['POST','GET'])
@crossdomain(origin='*')
def Add_Update_Partner_session_step():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### base_partner_session_step payload = ",payload)
    status, retval = base_partner_session_step.Add_Update_Partner_session_step(payload)
    return jsonify(status=status, message=retval)

"""
API de suppression d'une étape de session
"""
@app.route('/myclass/api/Delete_Partner_session_step/', methods=['POST','GET'])
@crossdomain(origin='*')
def Delete_Partner_session_step():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### Delete_Partner_session_step payload = ",payload)
    status, retval = base_partner_session_step.Delete_Partner_session_step(payload)
    return jsonify(status=status, message=retval)

"""
API pour recuperer la liste des etapes de session d'un partner
"""
@app.route('/myclass/api/Get_List_Partner_session_step/', methods=['POST','GET'])
@crossdomain(origin='*')
def Get_List_Partner_session_step():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### Get_List_Partner_session_step payload = ",payload)
    status, retval = base_partner_session_step.Get_List_Partner_session_step(payload)
    return jsonify(status=status, message=retval)


"""
API qui permet de recuperer étape de session valide (celles partenaire s'il l'a configurer si non celles par default)
"""
@app.route('/myclass/api/Get_List_Partner_Or_Default_session_step/', methods=['POST','GET'])
@crossdomain(origin='*')
def Get_List_Partner_Or_Default_session_step():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### Get_List_Partner_Or_Default_session_step payload = ",payload)
    status, retval = base_partner_session_step.Get_List_Partner_Or_Default_session_step(payload)
    return jsonify(status=status, message=retval)


"""
API de recuperation des données d'une étape session donnée
"""
@app.route('/myclass/api/Get_Given_Partner_session_step/', methods=['POST','GET'])
@crossdomain(origin='*')
def Get_Given_Partner_session_step():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### Get_Given_Partner_session_step payload = ",payload)
    status, retval = base_partner_session_step.Get_Given_Partner_session_step(payload)
    return jsonify(status=status, message=retval)


"""
API qui ajoute une sequence à une session de formation 
"""
@app.route('/myclass/api/Add_Session_Sequence/', methods=['POST','GET'])
@crossdomain(origin='*')
def Add_Session_Sequence():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### Add_Session_Sequence payload = ",payload)
    status, retval = Session_Formation_Sequence.Add_Session_Sequence(payload)
    return jsonify(status=status, message=retval)



"""
API qui met à jour une sequence à une session de formation 
"""
@app.route('/myclass/api/Update_Session_Sequence/', methods=['POST','GET'])
@crossdomain(origin='*')
def Update_Session_Sequence():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### Update_Session_Sequence payload = ",payload)
    status, retval = Session_Formation_Sequence.Update_Session_Sequence(payload)
    return jsonify(status=status, message=retval)



"""
API qui recupere la liste des séquences d'une session de formation
"""
@app.route('/myclass/api/Get_Session_Sequence_List/', methods=['POST','GET'])
@crossdomain(origin='*')
def Get_Session_Sequence_List():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### Get_Session_Sequence_List payload = ",payload)
    status, retval = Session_Formation_Sequence.Get_Session_Sequence_List(payload)
    return jsonify(status=status, message=retval)


"""
API qui recupere les données d'une séquence d'une session de formation
"""
@app.route('/myclass/api/Get_Given_Session_Sequence/', methods=['POST','GET'])
@crossdomain(origin='*')
def Get_Given_Session_Sequence():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### Get_Given_Session_Sequence payload = ",payload)
    status, retval = Session_Formation_Sequence.Get_Given_Session_Sequence(payload)
    return jsonify(status=status, message=retval)


"""
API qui supprime une sequence à une session de formation 
"""
@app.route('/myclass/api/Delete_Given_Session_Sequence/', methods=['POST','GET'])
@crossdomain(origin='*')
def Delete_Given_Session_Sequence():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### Delete_Given_Session_Sequence payload = ",payload)
    status, retval = Session_Formation_Sequence.Delete_Given_Session_Sequence(payload)
    return jsonify(status=status, message=retval)



"""
API qui supprime une sequence à une session de formation  en masse
"""
@app.route('/myclass/api/Delete_Given_Session_Sequence_Mass/', methods=['POST','GET'])
@crossdomain(origin='*')
def Delete_Given_Session_Sequence_Mass():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### Delete_Given_Session_Sequence_Mass payload = ",payload)
    status, retval = Session_Formation_Sequence.Delete_Given_Session_Sequence_Mass(payload)
    return jsonify(status=status, message=retval)




"""
API Affecter une ressource à une sequence (humaine ou materielle)
"""
@app.route('/myclass/api/Add_Sequence_Affectation_Ressource_Poste/', methods=['POST','GET'])
@crossdomain(origin='*')
def Add_Sequence_Affectation_Ressource_Poste():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### Add_Sequence_Affectation_Ressource_Poste payload = ",payload)
    status, retval = Session_Formation_Sequence.Add_Sequence_Affectation_Ressource_Poste(payload)
    return jsonify(status=status, message=retval)


"""
API Affecter une ressource à une sequence (humaine ou materielle) en masse
"""
@app.route('/myclass/api/Add_Sequence_Affectation_Ressource_Poste_Mass/', methods=['POST','GET'])
@crossdomain(origin='*')
def Add_Sequence_Affectation_Ressource_Poste_Mass():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### Add_Sequence_Affectation_Ressource_Poste_Mass payload = ",payload)
    status, retval = Session_Formation_Sequence.Add_Sequence_Affectation_Ressource_Poste_Mass(payload)
    return jsonify(status=status, message=retval)



"""
API AMettre à jour une affectation de ressource
"""
@app.route('/myclass/api/Update_Sequence_Affectation_Ressource_Poste/', methods=['POST','GET'])
@crossdomain(origin='*')
def Update_Sequence_Affectation_Ressource_Poste():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### Update_Sequence_Affectation_Ressource_Poste payload = ",payload)
    status, retval = Session_Formation_Sequence.Update_Sequence_Affectation_Ressource_Poste(payload)
    return jsonify(status=status, message=retval)


"""
API Supprimer une affectation de ressource à une sequence
"""
@app.route('/myclass/api/Delete_Sequence_Affectation_Ressource_Poste/', methods=['POST','GET'])
@crossdomain(origin='*')
def Delete_Sequence_Affectation_Ressource_Poste():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### Delete_Sequence_Affectation_Ressource_Poste payload = ",payload)
    status, retval = Session_Formation_Sequence.Delete_Sequence_Affectation_Ressource_Poste(payload)
    return jsonify(status=status, message=retval)


"""
API Recuperer la liste des affectations de ressource à une sequence
"""
@app.route('/myclass/api/Get_List_Sequence_Ressource_Affectation/', methods=['POST','GET'])
@crossdomain(origin='*')
def Get_List_Sequence_Ressource_Affectation():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### Get_List_Sequence_Ressource_Affectation payload = ",payload)
    status, retval = Session_Formation_Sequence.Get_List_Sequence_Ressource_Affectation(payload)
    return jsonify(status=status, message=retval)


"""
API Creation automatique des sequence selon les modeles de jounée de travail
"""
@app.route('/myclass/api/Create_Automatic_Sequence/', methods=['POST','GET'])
@crossdomain(origin='*')
def Create_Automatic_Sequence():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### Create_Automatic_Sequence payload = ",payload)
    status, retval = Session_Formation_Sequence.Create_Automatic_Sequence(payload)
    return jsonify(status=status, message=retval)



"""
API Creation d'un modèle journée de travail
"""
@app.route('/myclass/api/Add_Update_Modele_Journee/', methods=['POST','GET'])
@crossdomain(origin='*')
def Add_Update_Modele_Journee():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### Add_Update_Modele_Journee payload = ",payload)
    status, retval = base_config_modele_journee.Add_Update_Modele_Journee(payload)
    return jsonify(status=status, message=retval)


"""
API Recuperation du modèle journée de travail du partenaire ou celui par defaut du système
"""
@app.route('/myclass/api/Get_Default_Modele_Journee/', methods=['POST','GET'])
@crossdomain(origin='*')
def Get_Default_Modele_Journee():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### Get_Default_Modele_Journee payload = ",payload)
    status, retval = base_config_modele_journee.Get_Default_Modele_Journee(payload)
    return jsonify(status=status, message=retval)


"""
API Recuperation des heures de début et de fin de journée pour les planning.
"""
@app.route('/myclass/api/Get_Default_Debut_Fin_journee_Modele_Journee/', methods=['POST','GET'])
@crossdomain(origin='*')
def Get_Default_Debut_Fin_journee_Modele_Journee():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### Get_Default_Debut_Fin_journee_Modele_Journee payload = ",payload)
    status, retval = base_config_modele_journee.Get_Default_Debut_Fin_journee_Modele_Journee(payload)
    return jsonify(status=status, message=retval)


"""
API / TBD / QRY : Recuperation des données des sessions  de formation 
"""
@app.route('/myclass/api/Get_Qery_List_Session_Data/', methods=['POST','GET'])
@crossdomain(origin='*')
def Get_Qery_List_Session_Data():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### Get_Qery_List_Session_Data payload = ",payload)
    status, retval = session_tbd_qries.Get_Qery_List_Session_Data(payload)
    return jsonify(status=status, message=retval)


"""
API / TBD / QRY : Recuperation des sessions par formateur sur une periode
"""
@app.route('/myclass/api/Get_Qery_Session_By_Trainer_By_Periode/', methods=['POST','GET'])
@crossdomain(origin='*')
def Get_Qery_Session_By_Trainer_By_Periode():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### Get_Qery_Session_By_Trainer_By_Periode payload = ",payload)
    status, retval = session_tbd_qries.Get_Qery_Session_By_Trainer_By_Periode(payload)
    return jsonify(status=status, message=retval)


"""
API / TBD / QRY : Repartition du pourcentage de session par formateur
"""
@app.route('/myclass/api/Get_Qery_Session_Repartition_Session_By_Trainer_By_Periode/', methods=['POST','GET'])
@crossdomain(origin='*')
def Get_Qery_Session_Repartition_Session_By_Trainer_By_Periode():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### Get_Qery_Session_Repartition_Session_By_Trainer_By_Periode payload = ",payload)
    status, retval = session_tbd_qries.Get_Qery_Session_Repartition_Session_By_Trainer_By_Periode(payload)
    return jsonify(status=status, message=retval)


"""
API d'export excel/csv des resultats d'un dashbord
"""
""" 
@app.route('/myclass/api/Export_Dashbord_To_Csv/', methods=['POST','GET'])
@crossdomain(origin='*')
def Export_Dashbord_To_Csv():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### Export_Dashbord_To_Csv payload = ",payload)
    status, retval = session_tbd_qries.Export_Dashbord_To_Csv(payload)
    return jsonify(status=status, message=retval)
"""

@app.route('/myclass/api/Export_Dashbord_To_Csv/<token>/<user_dashbord_id>', methods=['POST','GET'])
@crossdomain(origin='*')
def Export_Dashbord_To_Csv(token, user_dashbord_id):
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    payload = {}
    payload['token'] = str(token)
    payload['user_dashbord_id'] = str(user_dashbord_id)

    print(" ### Export_Dashbord_To_Csv payload = ",payload)

    status, retval = session_tbd_qries.Export_Dashbord_To_Csv(payload)
    if(status ):
        return retval
    else:
        return False


"""
API Recuperation de liste des tableaux de bord disponible d'un partenaire (magasin tableaux de bord)
"""
@app.route('/myclass/api/Get_List_Partner_Dashbord/', methods=['POST','GET'])
@crossdomain(origin='*')
def Get_List_Partner_Dashbord():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### Get_List_Partner_Dashbord payload = ",payload)
    status, retval = common_tdb_qries.Get_List_Partner_Dashbord(payload)
    return jsonify(status=status, message=retval)


"""
API de récupération de la liste des API d'un utilisateur connecté (Mon tableau de bord)
"""
@app.route('/myclass/api/Get_Connected_User_List_Dashbord/', methods=['POST','GET'])
@crossdomain(origin='*')
def Get_Connected_User_List_Dashbord():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### Get_Connected_User_List_Dashbord payload = ",payload)
    status, retval = common_tdb_qries.Get_Connected_User_List_Dashbord(payload)
    return jsonify(status=status, message=retval)




"""
API pour ajouter un tbd à la list des tbd d'un user
"""
@app.route('/myclass/api/Add_To_User_Dashbord/', methods=['POST','GET'])
@crossdomain(origin='*')
def Add_To_User_Dashbord():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### Add_To_User_Dashbord payload = ",payload)
    status, retval = common_tdb_qries.Add_To_User_Dashbord(payload)
    return jsonify(status=status, message=retval)


"""
API pour supprimer un tbd à la list des tbd d'un user
"""
@app.route('/myclass/api/Delete_To_User_Dashbord/', methods=['POST','GET'])
@crossdomain(origin='*')
def Delete_To_User_Dashbord():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### Delete_To_User_Dashbord payload = ",payload)
    status, retval = common_tdb_qries.Delete_To_User_Dashbord(payload)
    return jsonify(status=status, message=retval)

"""
API/ TBD / QERY / Formation 
"""
@app.route('/myclass/api/Get_Qery_Formation_By_Session_By_Periode/', methods=['POST','GET'])
@crossdomain(origin='*')
def Get_Qery_Formation_By_Session_By_Periode():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### Get_Qery_Formation_By_Session_By_Periode payload = ",payload)
    status, retval = formation_tbd_qries.Get_Qery_Formation_By_Session_By_Periode(payload)
    return jsonify(status=status, message=retval)


"""
API/ TBD / QERY / Formation  ==> Export CSV/EXCEL
"""
@app.route('/myclass/api/Get_Qery_Formation_By_Session_By_Periode_Export_CSV/<token>/<user_dashbord_id>', methods=['POST','GET'])
@crossdomain(origin='*')
def Get_Qery_Formation_By_Session_By_Periode_Export_CSV(token, user_dashbord_id):
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    payload = {}
    payload['token'] = str(token)
    payload['user_dashbord_id'] = str(user_dashbord_id)


    print(" ### Get_Qery_Formation_By_Session_By_Periode_Export_CSV payload = ",payload)

    status, retval = formation_tbd_qries.Get_Qery_Formation_By_Session_By_Periode_Export_CSV(payload)
    if(status ):
        return retval
    else:
        return False


"""
API/ TBD / QERY / Ressources Humaines 
"""
@app.route('/myclass/api/Get_Humain_Ressource_With_Planning/', methods=['POST','GET'])
@crossdomain(origin='*')
def Get_Humain_Ressource_With_Planning():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### Get_Humain_Ressource_With_Planning payload = ",payload)
    status, retval = ressources_humaines_tbd_qries.Get_Humain_Ressource_With_Planning(payload)
    return jsonify(status=status, message=retval)


"""
API qui permet d'ajouter une action dans l'historique des évènements d'une entité
"""
@app.route('/myclass/api/Add_Historique_Event/', methods=['POST','GET'])
@crossdomain(origin='*')
def Add_Historique_Event():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### Add_Historique_Event payload = ",payload)
    status, retval = Collection_Historique.Add_Historique_Event(payload)
    return jsonify(status=status, message=retval)



"""
API qui permet de recupérer la liste des  actions l'historique des évènements d'une entité
"""
@app.route('/myclass/api/Get_Action_Historique_List/', methods=['POST','GET'])
@crossdomain(origin='*')
def Get_Action_Historique_List():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### Get_Action_Historique_List payload = ",payload)
    status, retval = Collection_Historique.Get_Action_Historique_List(payload)
    return jsonify(status=status, message=retval)


"""
Clean session date : cette fontion transforme les formats de date en jj/mm/aaaa, en supprimant les h:m:s
"""
@app.route('/myclass/api/clean_session_dates/', methods=['POST','GET'])
@crossdomain(origin='*')
def clean_session_dates():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### clean_session_dates payload = ",payload)
    status, retval = mycommon.clean_session_dates()
    return jsonify(status=status, message=retval)


"""
Test perso 
"""
@app.route('/myclass/api/Get_Dictionnary_data_For_Template/', methods=['POST','GET'])
@crossdomain(origin='*')
def Get_Dictionnary_data_For_Template():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### clean_session_dates payload = ",payload)
    status, retval = mycommon.Get_Dictionnary_data_For_Template(payload)
    return jsonify(status=status, message=retval)


"""
API de creation d'un groupe de prix d'achat
"""
@app.route('/myclass/api/Add_Group_Purchase_Price/', methods=['POST','GET'])
@crossdomain(origin='*')
def Add_Group_Purchase_Price():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### Add_Group_Purchase_Price payload = ",payload)
    status, retval = purchase_prices.Add_Group_Purchase_Price(payload)
    return jsonify(status=status, message=retval)

"""
API de mise à jour  d'un groupe de prix d'achat
"""
@app.route('/myclass/api/Update_Group_Purchase_Price/', methods=['POST','GET'])
@crossdomain(origin='*')
def Update_Group_Purchase_Price():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### Update_Group_Purchase_Price payload = ",payload)
    status, retval = purchase_prices.Update_Group_Purchase_Price(payload)
    return jsonify(status=status, message=retval)

"""
API de suppresion d'un groupe de prix d'achat
"""
@app.route('/myclass/api/Delete_Group_Purchase_Price/', methods=['POST','GET'])
@crossdomain(origin='*')
def Delete_Group_Purchase_Price():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### Delete_Group_Purchase_Price payload = ",payload)
    status, retval = purchase_prices.Delete_Group_Purchase_Price(payload)
    return jsonify(status=status, message=retval)


"""
API de récupération de la liste des groupes de prix d'achat d'un partner
"""
@app.route('/myclass/api/Get_Partner_Group_Purchase_Price_List/', methods=['POST','GET'])
@crossdomain(origin='*')
def Get_Partner_Group_Purchase_Price_List():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### Get_Partner_Group_Purchase_Price_List payload = ",payload)
    status, retval = purchase_prices.Get_Partner_Group_Purchase_Price_List(payload)
    return jsonify(status=status, message=retval)


"""
API de récupération des data d'un groupe de prix d'achat donné
"""
@app.route('/myclass/api/Get_Partner_Given_Group_Purchase_Price/', methods=['POST','GET'])
@crossdomain(origin='*')
def Get_Partner_Given_Group_Purchase_Price():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### Get_Partner_Given_Group_Purchase_Price payload = ",payload)
    status, retval = purchase_prices.Get_Partner_Given_Group_Purchase_Price(payload)
    return jsonify(status=status, message=retval)


"""
API Pour ajouter un apprenant
"""
@app.route('/myclass/api/Add_Apprenant/', methods=['POST','GET'])
@crossdomain(origin='*')
def Add_Apprenant():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### Add_Apprenant payload = ",payload)
    status, retval = apprenant_mgt.Add_Apprenant(payload)
    return jsonify(status=status, message=retval)

"""
API pour mettre à jour un apprenant
"""
@app.route('/myclass/api/Update_Apprenant/', methods=['POST','GET'])
@crossdomain(origin='*')
def Update_Apprenant():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### Update_Apprenant payload = ",payload)
    status, retval = apprenant_mgt.Update_Apprenant(payload)
    return jsonify(status=status, message=retval)

"""
API pour supprimer un apprenant
"""
@app.route('/myclass/api/Delete_Given_Apprenant/', methods=['POST','GET'])
@crossdomain(origin='*')
def Delete_Given_Apprenant():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### Delete_Given_Apprenant payload = ",payload)
    status, retval = apprenant_mgt.Delete_Given_Apprenant(payload)
    return jsonify(status=status, message=retval)

"""
API pour recuperer une apprenant donnée
"""
@app.route('/myclass/api/Get_Given_Apprenant_Data/', methods=['POST','GET'])
@crossdomain(origin='*')
def Get_Given_Apprenant_Data():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### Get_Given_Apprenant_Data payload = ",payload)
    status, retval = apprenant_mgt.Get_Given_Apprenant_Data(payload)
    return jsonify(status=status, message=retval)


"""
API pour recuperer la liste des apprenant d'un partenaire
"""
@app.route('/myclass/api/Get_List_Partner_Apprenant/', methods=['POST','GET'])
@crossdomain(origin='*')
def Get_List_Partner_Apprenant():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### Get_List_Partner_Apprenant payload = ",payload)
    status, retval = apprenant_mgt.Get_List_Partner_Apprenant(payload)
    return jsonify(status=status, message=retval)


"""
API pour recuperer la liste des apprenant d'un partenaire avec filtre
"""
@app.route('/myclass/api/Get_Apprenant_List_Partner_with_filter/', methods=['POST','GET'])
@crossdomain(origin='*')
def Get_Apprenant_List_Partner_with_filter():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### Get_Apprenant_List_Partner_with_filter payload = ",payload)
    status, retval = apprenant_mgt.Get_Apprenant_List_Partner_with_filter(payload)
    return jsonify(status=status, message=retval)


"""
API Pour Inscrire un apprenant à une session de formation
"""
@app.route('/myclass/api/Apprenant_Inscrire_Session/', methods=['POST','GET'])
@crossdomain(origin='*')
def Apprenant_Inscrire_Session():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### Apprenant_Inscrire_Session payload = ",payload)
    status, retval = apprenant_mgt.Apprenant_Inscrire_Session(payload)
    return jsonify(status=status, message=retval)


"""
API pour inscrire une liste d'apprenants à une session de formation
"""
@app.route('/myclass/api/Apprenant_Inscrire_Session_List/', methods=['POST','GET'])
@crossdomain(origin='*')
def Apprenant_Inscrire_Session_List():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### Apprenant_Inscrire_Session_List payload = ",payload)
    status, retval = apprenant_mgt.Apprenant_Inscrire_Session_List(payload)
    return jsonify(status=status, message=retval)




"""
API Pour recuperer la liste des inscription et preinscription d'un apprenant
"""
@app.route('/myclass/api/Get_Apprenant_List_Inscription/', methods=['POST','GET'])
@crossdomain(origin='*')
def Get_Apprenant_List_Inscription():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### Get_Apprenant_List_Inscription payload = ",payload)
    status, retval = apprenant_mgt.Get_Apprenant_List_Inscription(payload)
    return jsonify(status=status, message=retval)



"""
API pour enregister ou mettre à jour une image d'un apprenant
"""
@app.route('/myclass/api/Add_Update_Apprenant_Image/', methods=['POST','GET'])
@crossdomain(origin='*')
def Add_Update_Apprenant_Image():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### Add_Update_Apprenant_Image : payload = ",payload)

    if request.method == 'POST':
        # Create variable for uploaded file
        if ('file_img' in request.files.keys()):
            file_img = request.files['file_img']
        else:
            file_img = None
            return False, "Aucun fichier image à enregistrer"

    localStatus, message = apprenant_mgt.Add_Update_Apprenant_Image(file_img, MYSY_GV.upload_folder, payload)
    return jsonify(status=localStatus, message=message)


"""
API pour supprimer l'image d'un apprenant
"""
@app.route('/myclass/api/Delete_Apprenant_Image/', methods=['POST','GET'])
@crossdomain(origin='*')
def Delete_Apprenant_Image():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### Delete_Apprenant_Image payload = ",payload)
    status, retval = apprenant_mgt.Delete_Apprenant_Image(payload)
    return jsonify(status=status, message=retval)


"""
API pour importer en masse des apprenants
"""
@app.route('/myclass/api/Add_Apprenant_mass/', methods=['POST','GET'])
@crossdomain(origin='*')
def Add_Apprenant_mass():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### AddStagiairetoClass_mass_for_many_session payload = ",payload)
    #print(request.files)

    if request.method == 'POST':
        # Create variable for uploaded file
        f = request.files['File']
        localStatus, message = apprenant_mgt.Add_Apprenant_mass(f, MYSY_GV.TEMPORARY_DIRECTORY_V2, payload)

        return jsonify(status=localStatus, message=message)



"""
API pour recuperer l'image d'un apprenant
"""
@app.route('/myclass/api/Get_Apprenant_Recorded_Image_from_front/', methods=['POST','GET'])
@crossdomain(origin='*')
def Get_Apprenant_Recorded_Image_from_front():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### Get_Apprenant_Recorded_Image_from_front payload = ",payload)
    status, retval = apprenant_mgt.Get_Apprenant_Recorded_Image_from_front(payload)
    return jsonify(status=status, message=retval)



"""
API pour mettre à jour les tuteurs d'un apprenant
"""
@app.route('/myclass/api/Update_Apprenant_Tuteurs/', methods=['POST','GET'])
@crossdomain(origin='*')
def Update_Apprenant_Tuteurs():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### Update_Apprenant_Tuteurs payload = ",payload)
    status, retval = apprenant_mgt.Update_Apprenant_Tuteurs(payload)
    return jsonify(status=status, message=retval)


"""
API de Suppression des apprenants en mass avec du controle de cohérence
"""
@app.route('/myclass/api/Delete_List_Apprenant/', methods=['POST','GET'])
@crossdomain(origin='*')
def Delete_List_Apprenant():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### Delete_List_Apprenant payload = ",payload)
    status, retval = apprenant_mgt.Delete_List_Apprenant(payload)
    return jsonify(status=status, message=retval)


"""
API pour imprimer la fiche d'un apprenant au format PDF
"""
@app.route('/myclass/api/Print_Apprenant_PDF/<token>/<_id>/<courrier_template_id>', methods=['POST','GET'])
@crossdomain(origin='*')
def Print_Apprenant_PDF(token, _id, courrier_template_id):
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    payload = {}
    payload['token'] = str(token)
    payload['_id'] = str(_id)
    payload['courrier_template_id'] = str(courrier_template_id)

    print(" ### Print_Apprenant_PDF payload = ",payload)

    localStatus, response= apprenant_mgt.Print_Apprenant_PDF(payload)
    if(localStatus ):
        return response
    else:
        return False


"""
API pour recuperer les modele de courrier pour les : FICHE_APPRENANT 
"""
@app.route('/myclass/api/Get_List_Fiche_Apprenant/', methods=['POST','GET'])
@crossdomain(origin='*')
def Get_List_Fiche_Apprenant():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### Get_List_Fiche_Apprenant payload = ",payload)
    status, retval = apprenant_mgt.Get_List_Fiche_Apprenant(payload)
    return jsonify(status=status, message=retval)

"""
API pour exporter en csv les donnes du tableau de bord : tbd_rh_01
"""
@app.route('/myclass/api/TBD_RH_01_Export_Dashbord_To_Csv/<token>/<user_dashbord_id>', methods=['POST','GET'])
@crossdomain(origin='*')
def TBD_RH_01_Export_Dashbord_To_Csv(token, user_dashbord_id):
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    payload = {}
    payload['token'] = str(token)
    payload['user_dashbord_id'] = str(user_dashbord_id)

    print(" ### TBD_RH_01_Export_Dashbord_To_Csv payload = ",payload)

    status, retval = ressources_humaines_tbd_qries.TBD_RH_01_Export_Dashbord_To_Csv(payload)
    if(status ):
        return retval
    else:
        return False


"""
API pour exporter en Excel les donnes du tableau de bord : tbd_rh_01
"""
@app.route('/myclass/api/TBD_RH_01_Export_Dashbord_To_Excel/<token>/<user_dashbord_id>', methods=['POST','GET'])
@crossdomain(origin='*')
def TBD_RH_01_Export_Dashbord_To_Excel(token, user_dashbord_id):
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    payload = {}
    payload['token'] = str(token)
    payload['user_dashbord_id'] = str(user_dashbord_id)

    print(" ### TBD_RH_01_Export_Dashbord_To_Excel payload = ",payload)

    status, retval = ressources_humaines_tbd_qries.TBD_RH_01_Export_Dashbord_To_Excel(payload)
    if(status ):
        return retval
    else:
        return False

"""
API/ TBD / QERY / Ressources Humaines avec le cout par tache réalisée
"""
@app.route('/myclass/api/Get_Humain_Ressource_With_Planning_And_Cost/', methods=['POST','GET'])
@crossdomain(origin='*')
def Get_Humain_Ressource_With_Planning_And_Cost():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### Get_Humain_Ressource_With_Planning_And_Cost payload = ",payload)
    status, retval = ressources_humaines_tbd_qries.Get_Humain_Ressource_With_Planning_And_Cost(payload)
    return jsonify(status=status, message=retval)



"""
API / TBD / QRY : Recuperation des données des inscriptions 01 
"""
@app.route('/myclass/api/Get_Qery_Inscription_By_Session_By_Periode/', methods=['POST','GET'])
@crossdomain(origin='*')
def Get_Qery_Inscription_By_Session_By_Periode():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### Get_Qery_Inscription_By_Session_By_Periode payload = ",payload)
    status, retval = inscription_tdb_qries.Get_Qery_Inscription_By_Session_By_Periode(payload)
    return jsonify(status=status, message=retval)



"""
API pour exporter en csv les donnes du tableau de bord : Inscription
"""
@app.route('/myclass/api/TBD_Inscription_Export_Dashbord_To_Csv/<token>/<user_dashbord_id>', methods=['POST','GET'])
@crossdomain(origin='*')
def TBD_Inscription_Export_Dashbord_To_Csv(token, user_dashbord_id):
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    payload = {}
    payload['token'] = str(token)
    payload['user_dashbord_id'] = str(user_dashbord_id)

    print(" ### TBD_Inscription_Export_Dashbord_To_Csv payload = ",payload)

    status, retval = inscription_tdb_qries.TBD_Inscription_Export_Dashbord_To_Csv(payload)
    if(status ):
        return retval
    else:
        return False


"""
API  Export des formations dans un fichier excel / csv
"""
@app.route('/myclass/api/Export_Class_To_Excel_From_from_List_Id/<token>/<tab_id>', methods=['POST','GET'])
@crossdomain(origin='*')
def Export_Class_To_Csv_From_from_List_Id(token, tab_id):
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    payload = {}
    payload['token'] = str(token)
    payload['tab_id'] = str(tab_id)

    print(" ### Export_Class_To_Excel_From_from_List_Id payload = ",payload)

    status, retval = cm.Export_Class_To_Excel_From_from_List_Id(payload)
    if(status ):
        return retval
    else:
        return False

"""
API  Export des apprenants dans un fichier excel / csv
"""
@app.route('/myclass/api/Export_Apprenant_To_Excel_From_from_List_Id/<token>/<tab_id>', methods=['POST','GET'])
@crossdomain(origin='*')
def Export_Apprenant_To_Excel_From_from_List_Id(token, tab_id):
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    payload = {}
    payload['token'] = str(token)
    payload['tab_id'] = str(tab_id)

    print(" ### Export_Apprenant_To_Excel_From_from_List_Id payload = ",payload)

    status, retval = apprenant_mgt.Export_Apprenant_To_Excel_From_from_List_Id(payload)
    if(status ):
        return retval
    else:
        return False



"""
API  Export des inscrits dans un fichier excel / csv
"""
@app.route('/myclass/api/Export_Inscription_To_Excel_From_from_List_Id/<token>/<tab_id>', methods=['POST','GET'])
@crossdomain(origin='*')
def Export_Inscription_To_Excel_From_from_List_Id(token, tab_id):
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    payload = {}
    payload['token'] = str(token)
    payload['tab_id'] = str(tab_id)

    print(" ### Export_Inscription_To_Excel_From_from_List_Id payload = ",payload)

    status, retval = inscription.Export_Inscription_To_Excel_From_from_List_Id(payload)
    if(status ):
        return retval
    else:
        return False


"""
Cette API verrouille le compte utilisateur d'un personne (partner ou employé)
"""
@app.route('/myclass/api/Lock_partner_account/', methods=['POST','GET'])
@crossdomain(origin='*')
def Lock_partner_account():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### Lock_partner_account payload = ",payload)
    print(request.files)
    status, retval = pa.Lock_partner_account(payload)
    return jsonify(status=status, message=retval)


"""
Cette API retourne * la liste de documents editable par une 
- un partner
"""
@app.route('/myclass/api/Get_Editable_Document_By_Partner/', methods=['POST','GET'])
@crossdomain(origin='*')
def Get_Editable_Document_By_Partner():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### Get_Editable_Document_By_Partner payload = ",payload)
    print(request.files)
    status, retval = module_editique.Get_Editable_Document_By_Partner(payload)
    return jsonify(status=status, message=retval)


"""
Cette API retourne retourne la liste de documents editable par une 
- un partner
- une collection (ex : session_formation).

important : ici on recuperer juste la liste des document tracké, pas l'historique de traitement
"""
@app.route('/myclass/api/Get_Editable_Document_By_Partner_By_Collection/', methods=['POST','GET'])
@crossdomain(origin='*')
def Get_Editable_Document_By_Partner_By_Collection():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### Get_Editable_Document_By_Partner_By_Collection payload = ",payload)
    print(request.files)
    status, retval = module_editique.Get_Editable_Document_By_Partner_By_Collection(payload)
    return jsonify(status=status, message=retval)


"""
Cette API retourne l'HISTORIQUE des telechargements et envois de mail 
des documents tracés, pour :
- un partner (Obligatoire)
- un related_collection_recid (Obligatoire) (ex : l'_id de la session)
"""
@app.route('/myclass/api/Get_Editable_History_Document_By_Partner_By_Collection/', methods=['POST','GET'])
@crossdomain(origin='*')
def Get_Editable_History_Document_By_Partner_By_Collection():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### Get_Editable_Document_By_Partner_By_Collection payload = ",payload)
    print(request.files)
    status, retval = module_editique.Get_Editable_History_Document_By_Partner_By_Collection(payload)
    return jsonify(status=status, message=retval)


"""
API Pour initialiser la traçabilité des documents
"""
@app.route('/myclass/api/Init_And_Update_courrier_template_tracking/', methods=['POST','GET'])
@crossdomain(origin='*')
def Init_And_Update_courrier_template_tracking():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### Init_And_Update_courrier_template_tracking payload = ",payload)
    print(request.files)
    status, retval = module_editique.Init_And_Update_courrier_template_tracking(payload)
    return jsonify(status=status, message=retval)


"""
API des test des actions server
"""
@app.route('/myclass/api/Action_Server_send_convention_entreprise_mail/', methods=['POST','GET'])
@crossdomain(origin='*')
def Action_Server_send_convention_entreprise_mail():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### Action_Server_send_convention_entreprise_mail payload = ",payload)
    return jsonify(status=True, message=" OK Action_Server_send_convention_entreprise_mail")




"""
API : pour préprer et générer un zip de fichier PDF pour les convocation en partant d'une session
"""
@app.route('/myclass/api/Prepare_and_Send_Convocation_From_Session_By_PDF/<token>/<session_id>/<courrier_template_id>', methods=['POST','GET'])
@crossdomain(origin='*')
def Prepare_and_Send_Convocation_From_Session_By_PDF(token, session_id, courrier_template_id):
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    payload = {}
    payload['token'] = str(token)
    payload['session_id'] = str(session_id)
    payload['courrier_template_id'] = str(courrier_template_id)

    print(" ### Prepare_and_Send_Convocation_From_Session_By_PDF : payload = ",str(payload))

    localStatus, response= SF.Prepare_and_Send_Convocation_From_Session_By_PDF(payload)
    if(localStatus ):
        return response
    else:
        return False



"""
API : pour préprer et envoyer les convocations en partant d'une session
"""
@app.route('/myclass/api/Prepare_and_Send_Convocation_From_Session_By_Email/', methods=['POST','GET'])
@crossdomain(origin='*')
def Prepare_and_Send_Convocation_From_Session_By_Email():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### Prepare_and_Send_Convocation_From_Session_By_Email : payload = ",str(payload))

    file = []
    if request.method == 'POST':
        # Create variable for uploaded file
        tab_files = []
        for tmp in request.files.getlist("File"):
            tab_files.append(tmp)

    status, retval = SF.Prepare_and_Send_Convocation_From_Session_By_Email(tab_files, MYSY_GV.TEMPORARY_DIRECTORY_V2, payload)
    return jsonify(status=status, message=retval)



"""
API pour initialiser les attestation de formation pour une session données 
"""
@app.route('/myclass/api/Init_Attestation_Formation_With_Template/', methods=['POST','GET'])
@crossdomain(origin='*')
def Init_Attestation_Formation_With_Template():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### Init_Attestation_Formation_With_Template payload = ",payload)
    print(request.files)
    status, retval = attestation_formation.Init_Attestation_Formation_With_Template(payload)
    return jsonify(status=status, message=retval)


"""
API pour l'initialisation de la liste des attestation pour toutes les inscription d'une session.
ici on ne prend pas une inscription specifique
"""
@app.route('/myclass/api/Init_Attestation_Formation_With_Template_For_All_Inscription/', methods=['POST','GET'])
@crossdomain(origin='*')
def Init_Attestation_Formation_With_Template_For_All_Inscription():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### Init_Attestation_Formation_With_Template_For_All_Inscription payload = ",payload)
    print(request.files)
    status, retval = attestation_formation.Init_Attestation_Formation_With_Template_For_All_Inscription(payload)
    return jsonify(status=status, message=retval)



"""
API pour recuperer la listes des attestation de formation pour une session données 
"""
@app.route('/myclass/api/Get_Attestion_By_Session/', methods=['POST','GET'])
@crossdomain(origin='*')
def Get_Attestion_By_Session():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### Get_Attestion_By_Session payload = ",payload)
    print(request.files)
    status, retval = attestation_formation.Get_Attestion_By_Session(payload)
    return jsonify(status=status, message=retval)


"""
API pour recuperer les differentes modele d'attestation de formation de stagiaire avec des option comme
"""
@app.route('/myclass/api/Get_List_Modele_Attestion_Formation_With_Filter/', methods=['POST','GET'])
@crossdomain(origin='*')
def Get_List_Modele_Attestion_Formation_With_Filter():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### Get_List_Modele_Attestion_Formation_With_Filter payload = ",payload)
    print(request.files)
    status, retval = attestation_formation.Get_List_Modele_Attestion_Formation_With_Filter(payload)
    return jsonify(status=status, message=retval)



"""
API Pour envoyer les attestation par email
"""
@app.route('/myclass/api/Prepare_and_Send_Attestation_From_Session_By_Email/', methods=['POST','GET'])
@crossdomain(origin='*')
def Prepare_and_Send_Attestation_From_Session_By_Email():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### Prepare_and_Send_Attestation_From_Session_By_Email : payload = ",str(payload))

    file = []
    if request.method == 'POST':
        # Create variable for uploaded file
        tab_files = []
        for tmp in request.files.getlist("File"):
            tab_files.append(tmp)

    status, retval = SF.Prepare_and_Send_Attestation_From_Session_By_Email(tab_files, MYSY_GV.TEMPORARY_DIRECTORY_V2, payload)
    return jsonify(status=status, message=retval)


"""
API de creation d'une étape d'opportunité CRM
"""
@app.route('/myclass/api/Add_CRM_Opportunite_Etape/', methods=['POST','GET'])
@crossdomain(origin='*')
def Add_CRM_Opportunite_Etape():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### Add_CRM_Opportunite_Etape payload = ",payload)
    print(request.files)
    status, retval = crm_opportunite.Add_CRM_Opportunite_Etape(payload)
    return jsonify(status=status, message=retval)



"""
API de récuperation de la liste des étapes d'opportunité CRM
"""
@app.route('/myclass/api/Get_CRM_List_Opportunite_Etape/', methods=['POST','GET'])
@crossdomain(origin='*')
def Get_CRM_List_Opportunite_Etape():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### Get_CRM_List_Opportunite_Etape payload = ",payload)
    print(request.files)
    status, retval = crm_opportunite.Get_CRM_List_Opportunite_Etape(payload)
    return jsonify(status=status, message=retval)



"""
API de suppression d'un étape d'opportunité
"""
@app.route('/myclass/api/Delete_CRM_List_Opportunite_Etape/', methods=['POST','GET'])
@crossdomain(origin='*')
def Delete_CRM_List_Opportunite_Etape():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### Delete_CRM_List_Opportunite_Etape payload = ",payload)
    print(request.files)
    status, retval = crm_opportunite.Delete_CRM_List_Opportunite_Etape(payload)
    return jsonify(status=status, message=retval)


"""
API de mise à jour  d'un étape d'opportunité
"""
@app.route('/myclass/api/Update_CRM_List_Opportunite_Etape/', methods=['POST','GET'])
@crossdomain(origin='*')
def Update_CRM_List_Opportunite_Etape():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### Update_CRM_List_Opportunite_Etape payload = ",payload)
    print(request.files)
    status, retval = crm_opportunite.Update_CRM_List_Opportunite_Etape(payload)
    return jsonify(status=status, message=retval)




"""
API de creation d'une opportinité
"""
@app.route('/myclass/api/Add_CRM_Opportunite/', methods=['POST','GET'])
@crossdomain(origin='*')
def Add_CRM_Opportunite():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### Add_CRM_Opportunite payload = ",payload)
    print(request.files)
    status, retval = crm_opportunite.Add_CRM_Opportunite(payload)
    return jsonify(status=status, message=retval)


"""
API de mise à jour d'une opportinité
"""
@app.route('/myclass/api/Update_CRM_Opportunite/', methods=['POST','GET'])
@crossdomain(origin='*')
def Update_CRM_Opportunite():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### Update_CRM_Opportunite payload = ",payload)
    print(request.files)
    status, retval = crm_opportunite.Update_CRM_Opportunite(payload)
    return jsonify(status=status, message=retval)


"""
API de recuperation de la liste des opportunité avec filtre
"""
@app.route('/myclass/api/Get_List_CRM_Opportunite_with_filter/', methods=['POST','GET'])
@crossdomain(origin='*')
def Get_List_CRM_Opportunite_with_filter():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### Get_List_CRM_Opportunite_with_filter payload = ",payload)
    print(request.files)
    status, retval = crm_opportunite.Get_List_CRM_Opportunite_with_filter(payload)
    return jsonify(status=status, message=retval)




"""
API de recuperation de la liste des opportunité sans filtre
"""
@app.route('/myclass/api/Get_List_CRM_Opportunite_no_filter/', methods=['POST','GET'])
@crossdomain(origin='*')
def Get_List_CRM_Opportunite_no_filter():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### Get_List_CRM_Opportunite_no_filter payload = ",payload)
    print(request.files)
    status, retval = crm_opportunite.Get_List_CRM_Opportunite_no_filter(payload)
    return jsonify(status=status, message=retval)



"""
API de recuperation des data d'une opportunité données
"""
@app.route('/myclass/api/Get_Given_CRM_Opportunite/', methods=['POST','GET'])
@crossdomain(origin='*')
def Get_Given_CRM_Opportunite():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### Get_Given_CRM_Opportunite payload = ",payload)
    print(request.files)
    status, retval = crm_opportunite.Get_Given_CRM_Opportunite(payload)
    return jsonify(status=status, message=retval)


"""
API de suppression des data d'une opportunité données
"""
@app.route('/myclass/api/Delete_Given_CRM_Opportunite/', methods=['POST','GET'])
@crossdomain(origin='*')
def Delete_Given_CRM_Opportunite():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### Delete_Given_CRM_Opportunite payload = ",payload)
    print(request.files)
    status, retval = crm_opportunite.Delete_Given_CRM_Opportunite(payload)
    return jsonify(status=status, message=retval)







"""
EDITIQUE : API de migration des compte partnaire (admin). A supprimer
"""
@app.route('/myclass/api/Account_Migration_to_delete/', methods=['POST','GET'])
@crossdomain(origin='*')
def Account_Migration_to_delete():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### Account_Migration_to_delete payload = ",payload)
    print(request.files)
    status, retval = module_editique.Account_Migration_to_delete(payload)
    return jsonify(status=status, message=retval)


"""
API pour ajouter un site de formation
"""
@app.route('/myclass/api/Add_Site_Formation/', methods=['POST','GET'])
@crossdomain(origin='*')
def Add_Site_Formation():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### Add_Site_Formation payload = ",payload)
    print(request.files)
    status, retval = site_formation.Add_Site_Formation(payload)
    return jsonify(status=status, message=retval)


"""
API pour mettre à jour  un site de formation
"""
@app.route('/myclass/api/Update_Site_Formation/', methods=['POST','GET'])
@crossdomain(origin='*')
def Update_Site_Formation():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### Update_Site_Formation payload = ",payload)
    print(request.files)
    status, retval = site_formation.Update_Site_Formation(payload)
    return jsonify(status=status, message=retval)


"""
API pour recuperer la liste des site de formation d'un partenaire avec des filtres
"""
@app.route('/myclass/api/Get_List_Site_Formation_with_filter/', methods=['POST','GET'])
@crossdomain(origin='*')
def Get_List_Site_Formation_with_filter():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### Get_List_Site_Formation_with_filter payload = ",payload)
    print(request.files)
    status, retval = site_formation.Get_List_Site_Formation_with_filter(payload)
    return jsonify(status=status, message=retval)

"""
API pour recuperer les données d'un site de formation donnée
"""
@app.route('/myclass/api/Get_Given_Site_Formation/', methods=['POST','GET'])
@crossdomain(origin='*')
def Get_Given_Site_Formation():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### Get_Given_Site_Formation payload = ",payload)
    print(request.files)
    status, retval = site_formation.Get_Given_Site_Formation(payload)
    return jsonify(status=status, message=retval)



"""
API pour supprimer les données d'un site de formation donnée
"""
@app.route('/myclass/api/Delete_Given_Site_Formation/', methods=['POST','GET'])
@crossdomain(origin='*')
def Delete_Given_Site_Formation():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### Delete_Given_Site_Formation payload = ",payload)
    print(request.files)
    status, retval = site_formation.Delete_Given_Site_Formation(payload)
    return jsonify(status=status, message=retval)




"""
API : pour préparer et envoyer les factures en partant d'une session
"""
@app.route('/myclass/api/Prepare_and_Send_Facture_From_Session_By_Email/', methods=['POST','GET'])
@crossdomain(origin='*')
def Prepare_and_Send_Facture_From_Session_By_Email():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### Prepare_and_Send_Facture_From_Session_By_Email : payload = ",str(payload))

    file = []
    if request.method == 'POST':
        # Create variable for uploaded file
        tab_files = []
        for tmp in request.files.getlist("File"):
            tab_files.append(tmp)

    status, retval, invoice_ref = SF.Prepare_and_Send_Facture_From_Session_By_Email(tab_files, MYSY_GV.TEMPORARY_DIRECTORY_V2, payload)
    return jsonify(status=status, message=retval, invoice_ref=invoice_ref)





"""
API : pour préparer et envoyer les factures en partant d'une session, pour une liste d'inscrit.
(la facturation partielle)
"""
@app.route('/myclass/api/Prepare_and_Send_Facture_From_Session_By_Inscription_Id/', methods=['POST','GET'])
@crossdomain(origin='*')
def Prepare_and_Send_Facture_From_Session_By_Inscription_Id():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### Prepare_and_Send_Facture_From_Session_By_Inscription_Id : payload = ",str(payload))

    file = []
    if request.method == 'POST':
        # Create variable for uploaded file
        tab_files = []
        for tmp in request.files.getlist("File"):
            tab_files.append(tmp)

    status, retval, invoice_ref = SF.Prepare_and_Send_Facture_From_Session_By_Inscription_Id(tab_files, MYSY_GV.TEMPORARY_DIRECTORY_V2, payload)
    return jsonify(status=status, message=retval, invoice_ref=invoice_ref)





"""
API: Ajout d'une condition de paiement
"""
@app.route('/myclass/api/Add_Paiement_Condition/', methods=['POST','GET'])
@crossdomain(origin='*')
def Add_Paiement_Condition():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### Add_Paiement_Condition payload = ",payload)
    print(request.files)
    status, retval = paiement_condition.Add_Paiement_Condition(payload)
    return jsonify(status=status, message=retval)


"""
API: Mise à jour d'une condition de paiement
"""
@app.route('/myclass/api/Update_Paiement_Condition/', methods=['POST','GET'])
@crossdomain(origin='*')
def Update_Paiement_Condition():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### Update_Paiement_Condition payload = ",payload)
    print(request.files)
    status, retval = paiement_condition.Update_Paiement_Condition(payload)
    return jsonify(status=status, message=retval)


"""
API: Suppression d'une condition de paiement
"""
@app.route('/myclass/api/Delete_Paiement_Condition/', methods=['POST','GET'])
@crossdomain(origin='*')
def Delete_Paiement_Condition():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### Delete_Paiement_Condition payload = ",payload)
    print(request.files)
    status, retval = paiement_condition.Delete_Paiement_Condition(payload)
    return jsonify(status=status, message=retval)


"""
API: Recuperer la liste des conditions de paiement d'un partenaire
"""
@app.route('/myclass/api/Get_List_Paiement_Condition/', methods=['POST','GET'])
@crossdomain(origin='*')
def Get_List_Paiement_Condition():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### Get_List_Paiement_Condition payload = ",payload)
    print(request.files)
    status, retval = paiement_condition.Get_List_Paiement_Condition(payload)
    return jsonify(status=status, message=retval)


"""
API: Recuperer les données d'un conditions de paiement d'un partenaire
"""
@app.route('/myclass/api/Get_Given_Paiement_Condition/', methods=['POST','GET'])
@crossdomain(origin='*')
def Get_Given_Paiement_Condition():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### Get_Given_Paiement_Condition payload = ",payload)
    status, retval = paiement_condition.Get_Given_Paiement_Condition(payload)
    return jsonify(status=status, message=retval)



"""
API  permet d'initialiser les elements de configuration d'un partenaire.
Les document /  modele de journée de travail / Les étapes d'un session.... voir la fonction pour plus de detail
"""
@app.route('/myclass/api/Configure_Partner_Init_Setup_No_Token/', methods=['POST','GET'])
@crossdomain(origin='*')
def Configure_Partner_Init_Setup_No_Token():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### Configure_Partner_Init_Setup_No_Token payload = ",payload)
    status, retval = mycommon.Configure_Partner_Init_Setup_No_Token(payload)
    return jsonify(status=status, message=retval)


"""
API permet de savoir si un partenaire dispose de la signature digital
"""
@app.route('/myclass/api/Is_Partnair_Has_Digital_Signature/', methods=['POST','GET'])
@crossdomain(origin='*')
def Is_Partnair_Has_Digital_Signature():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### Is_Partnair_Has_Digital_Signature payload = ",payload)
    status, retval = mycommon.Is_Partnair_Has_Digital_Signature(payload)
    return jsonify(status=status, message=retval)




"""
API pour ajouter un document electronique à signer
"""
@app.route('/myclass/api/Create_E_Document/', methods=['POST','GET'])
@crossdomain(origin='*')
def Create_E_Document():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### Create_E_Document payload = ",payload)
    status, retval = E_Sign_Document.Create_E_Document(payload)
    return jsonify(status=status, message=retval)


"""
API Pour recuperer un documen électronique deja signé. c'est a dire pour un controle d'une tierce partie
"""
@app.route('/myclass/api/Get_Given_E_Document_Signed_No_Token/', methods=['POST','GET'])
@crossdomain(origin='*')
def Get_Given_E_Document_Signed_No_Token():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### Get_Given_E_Document_Signed_No_Token payload = ",payload)
    status, retval = E_Sign_Document.Get_Given_E_Document_Signed_No_Token(payload)
    return jsonify(status=status, message=retval)


"""
API pour ajouter un document electronique à signer
"""
@app.route('/myclass/api/Get_Given_E_Document_Not_Signed_No_Token/', methods=['POST','GET'])
@crossdomain(origin='*')
def Get_Given_E_Document_Not_Signed_No_Token():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### Get_Given_E_Document_Not_Signed_No_Token payload = ",payload)
    status, retval = E_Sign_Document.Get_Given_E_Document_Not_Signed_No_Token(payload)
    return jsonify(status=status, message=retval)



"""
API pour signer electroniquement un document
"""
@app.route('/myclass/api/Create_E_Signature_For_E_Document/', methods=['POST','GET'])
@crossdomain(origin='*')
def Create_E_Signature_For_E_Document():
    # On recupere le corps (payload) de la requete

    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### Create_E_Signature_For_E_Document payload = ",payload)

    file_img = None
    if request.method == 'POST':
        # Create variable for uploaded file
        if ('signature_img' in request.files.keys() and request.files['signature_img']):
            file_img = request.files['signature_img']


    user_ip = ""
    headers_list = request.headers.getlist("X-Forwarded-For")
    user_ip = headers_list[0] if headers_list else request.remote_addr

    payload['user_ip'] = user_ip
    if( "signature_img" in payload.keys() ):
        del payload['signature_img']

    status, retval = E_Sign_Document.Create_E_Signature_For_E_Document(file_img, MYSY_GV.TEMPORARY_DIRECTORY_V2, payload)
    return jsonify(status=status, message=retval)


"""
API Pour auditer une session
"""
@app.route('/myclass/api/Audit_Session_Action_Inscrit/', methods=['POST','GET'])
@crossdomain(origin='*')
def Audit_Session_Action_Inscrit():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### Audit_Session_Action_Inscrit : payload = ",str(payload))
    localStatus, message= SF.Audit_Session_Action_Inscrit(payload)
    return jsonify(status=localStatus, message=message )


"""
API qui permet de recuperer la liste des niveaux pour les compétences
"""
@app.route('/myclass/api/Get_Competence_Level/', methods=['POST','GET'])
@crossdomain(origin='*')
def Get_Competence_Level():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### Get_Competence_Level payload = ",payload)
    status, retval = mycommon.Get_Competence_Level()
    return jsonify(status=status, message=retval)


"""
API pour créer une compétence
"""
@app.route('/myclass/api/Add_Competence/', methods=['POST','GET'])
@crossdomain(origin='*')
def Add_Competence():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### Add_Competence payload = ",payload)
    status, retval = competence.Add_Competence(payload)
    return jsonify(status=status, message=retval)



"""
API pour mettre à jour une compétence
"""
@app.route('/myclass/api/Update_Competence/', methods=['POST','GET'])
@crossdomain(origin='*')
def Update_Competence():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### Update_Competence payload = ",payload)
    status, retval = competence.Update_Competence(payload)
    return jsonify(status=status, message=retval)


"""
API pour recuperer la liste des compétences d'un partenaire
"""
@app.route('/myclass/api/Get_Competence_no_filter/', methods=['POST','GET'])
@crossdomain(origin='*')
def Get_Competence_no_filter():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### Get_Competence_no_filter payload = ",payload)
    status, retval = competence.Get_Competence_no_filter(payload)
    return jsonify(status=status, message=retval)



"""
API pour supprimer une compétence
"""
@app.route('/myclass/api/Delete_Given_Competence/', methods=['POST','GET'])
@crossdomain(origin='*')
def Delete_Given_Competence():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### Delete_Given_Competence payload = ",payload)
    status, retval = competence.Delete_Given_Competence(payload)
    return jsonify(status=status, message=retval)


"""
API pour ajouter un formulaire 
"""
@app.route('/myclass/api/Add_Formulaire/', methods=['POST','GET'])
@crossdomain(origin='*')
def Add_Formulaire():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### Add_Formulaire payload = ",payload)
    status, retval = formulaire_mgt.Add_Formulaire(payload)
    return jsonify(status=status, message=retval)


"""
API pour ajouter une question a un formulaire 
"""
@app.route('/myclass/api/Add_Update_Question_Formulaire/', methods=['POST','GET'])
@crossdomain(origin='*')
def Add_Update_Question_Formulaire():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### Add_Update_Question_Formulaire payload = ",payload)
    status, retval = formulaire_mgt.Add_Update_Question_Formulaire(payload)
    return jsonify(status=status, message=retval)


"""
API pour supprimer une question d'un formulaire
"""
@app.route('/myclass/api/Delete_Question_Formulaire/', methods=['POST','GET'])
@crossdomain(origin='*')
def Delete_Question_Formulaire():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### Delete_Question_Formulaire payload = ",payload)
    status, retval = formulaire_mgt.Delete_Question_Formulaire(payload)
    return jsonify(status=status, message=retval)


"""
API pour  supprimer un formulaire
"""
@app.route('/myclass/api/Delete_Formulaire/', methods=['POST','GET'])
@crossdomain(origin='*')
def Delete_Formulaire():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### Delete_Formulaire payload = ",payload)
    status, retval = formulaire_mgt.Delete_Formulaire(payload)
    return jsonify(status=status, message=retval)



"""
API pour recuperer la listes des formulaire d'un partenaire, sans filtre
"""
@app.route('/myclass/api/Get_List_Formulaire/', methods=['POST','GET'])
@crossdomain(origin='*')
def Get_List_Formulaire():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### Get_List_Formulaire payload = ",payload)
    status, retval = formulaire_mgt.Get_List_Formulaire(payload)
    return jsonify(status=status, message=retval)



"""
API pour recuperer la listes des formulaire d'un partenaire, avec filtre
"""
@app.route('/myclass/api/Get_List_Formulaire_with_filter/', methods=['POST','GET'])
@crossdomain(origin='*')
def Get_List_Formulaire_with_filter():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### Get_List_Formulaire_with_filter payload = ",payload)
    status, retval = formulaire_mgt.Get_List_Formulaire_with_filter(payload)
    return jsonify(status=status, message=retval)



"""
API pour  recuperer les données d'un formulaire données
"""
@app.route('/myclass/api/Get_Given_Formulaire/', methods=['POST','GET'])
@crossdomain(origin='*')
def Get_Given_Formulaire():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### Get_Given_Formulaire payload = ",payload)
    status, retval = formulaire_mgt.Get_Given_Formulaire(payload)
    return jsonify(status=status, message=retval)


"""
API pour mettre à jour les données
d'un formulaire 
"""
@app.route('/myclass/api/Update_Formulaire/', methods=['POST','GET'])
@crossdomain(origin='*')
def Update_Formulaire():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### Update_Formulaire payload = ",payload)
    status, retval = formulaire_mgt.Update_Formulaire(payload)
    return jsonify(status=status, message=retval)



"""
API pour recuperer les données d'une enquete
"""
@app.route('/myclass/api/Get_Given_Survey_Data_No_Token/', methods=['POST','GET'])
@crossdomain(origin='*')
def Get_Given_Survey_Data_No_Token():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### Get_Given_Survey_Data_No_Token payload = ",payload)
    status, retval = survey_mgt.Get_Given_Survey_Data_No_Token(payload)
    return jsonify(status=status, message=retval)


"""
API pour enregistrer les resultat d'une enquete
"""
@app.route('/myclass/api/Record_Survey_Data_No_Token/', methods=['POST','GET'])
@crossdomain(origin='*')
def Record_Survey_Data_No_Token():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### Record_Survey_Data_No_Token payload = ",payload)
    status, retval = survey_mgt.Record_Survey_Data_No_Token(payload)
    return jsonify(status=status, message=retval)


"""
API pour envoyer une demande d'enquete à une liste d'inscrit (pas le client)
"""
@app.route('/myclass/api/Add_Survey_Tab_Inscrit/', methods=['POST','GET'])
@crossdomain(origin='*')
def Add_Survey_Tab_Inscrit():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### Add_Survey_Tab_Inscrit payload = ",payload)
    status, retval = survey_mgt.Add_Survey_Tab_Inscrit(payload)
    return jsonify(status=status, message=retval)

"""
API pour  initialiset (suppression et creation ) d'une enquete pour tous
les inscrits d'un session.
algorithm :
On supprime tous enregistrements avec le clé : 
- session_id, 
"""
@app.route('/myclass/api/Init_Survey_Tab_For_All_Session_Inscrit/', methods=['POST','GET'])
@crossdomain(origin='*')
def Init_Survey_Tab_For_All_Session_Inscrit():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### Init_Survey_Tab_For_All_Session_Inscrit payload = ",payload)
    status, retval = survey_mgt.Init_Survey_Tab_For_All_Session_Inscrit(payload)
    return jsonify(status=status, message=retval)


"""
API pour recuperer la liste des survey avec des filtre sur 
- sesson_id,
- formulaire_type - ['pos', 'hot_eval', 'cool_eval']
"""
@app.route('/myclass/api/Get_List_Survey_with_filter/', methods=['POST','GET'])
@crossdomain(origin='*')
def Get_List_Survey_with_filter():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### Get_List_Survey_with_filter payload = ",payload)
    status, retval = survey_mgt.Get_List_Survey_with_filter(payload)
    return jsonify(status=status, message=retval)


"""
API qui envoyer le mail de demande d'enquete
"""
@app.route('/myclass/api/Send_Survey_TabIds/', methods=['POST','GET'])
@crossdomain(origin='*')
def Send_Survey_TabIds():
    # On recupere le corps (payload) de la requete
    payload =  mycommon.strip_dictionary (request.form.to_dict())
    print(" ### Send_Survey_TabIds payload = ",payload)
    status, retval = survey_mgt.Send_Survey_TabIds(payload)
    return jsonify(status=status, message=retval)



if __name__ == '__main__':
    print(" debut api")
    context = SSL.Context(SSL.SSLv23_METHOD)
    if (MYSY_GV.MYSY_ENV == "PROD"):
        mycommon.myprint(" ++++  ENVIRONNEMENT PRODUCTION ++++ ")
        mycommon.myprint("++ DATABASE "+MYSY_GV.CONNECTION_STRING+" ++")
        mycommon.myprint("++ DBNAME " + str(MYSY_GV.dbname) + " ++")
        mycommon.myprint("++ FLASK PORT " + str(MYSY_GV.MYSY_PORT_PROD) + " ++")
        mycommon.myprint("++ LMS_BAS_URL " + str(MYSY_GV.LMS_BAS_URL) + " ++")
        app.run(host='localhost', port=MYSY_GV.MYSY_PORT_PROD, debug=True, threaded=True)

    elif (MYSY_GV.MYSY_ENV == "DEV"):
        mycommon.myprint(" ++++ ENVIRONNEMENT DEVELOPPEMENT ++++")
        mycommon.myprint("++ DATABASE " + MYSY_GV.CONNECTION_STRING + " ++")
        mycommon.myprint("++ DBNAME " + str(MYSY_GV.dbname) + " ++")
        mycommon.myprint("++ FLASK PORT " + str(MYSY_GV.MYSY_PORT_DEV) + " ++")
        mycommon.myprint("++ LMS_BAS_URL " + str(MYSY_GV.LMS_BAS_URL) + " ++")

        """
        /!\ Dasactivé en dev pour pas consommer de ressource pr rien.
        scheduler = BackgroundScheduler()
        # Create the job
        scheduler.add_job(func=Flask_Cron_Strip_Get_Customer_Abonnement_Data, trigger="interval", minutes=5)
        # Start the scheduler
        scheduler.start()

        # /!\ IMPORTANT /!\ : Shut down the scheduler when exiting the app
        atexit.register(lambda: scheduler.shutdown())
        """
        app.run(host='localhost', port=MYSY_GV.MYSY_PORT_DEV, debug=True, threaded=True)
        # Create the background scheduler


    elif (MYSY_GV.MYSY_ENV == "REC"):
        mycommon.myprint(" ++++ ENVIRONNEMENT RECETTE ++++")
        mycommon.myprint("++ DATABASE " + MYSY_GV.CONNECTION_STRING + " ++")
        mycommon.myprint("++ DBNAME " + str(MYSY_GV.dbname) + " ++")
        mycommon.myprint("++ FLASK PORT " + str(MYSY_GV.MYSY_PORT_REC) + " ++")
        mycommon.myprint("++ LMS_BAS_URL " + str(MYSY_GV.LMS_BAS_URL) + " ++")

        scheduler = BackgroundScheduler()
        # Create the job
        scheduler.add_job(func=Flask_Cron_Strip_Get_Customer_Abonnement_Data, trigger="interval", minutes=5)
        # Start the scheduler
        scheduler.start()

        # /!\ IMPORTANT /!\ : Shut down the scheduler when exiting the app
        atexit.register(lambda: scheduler.shutdown())


        app.run(host='localhost', port=MYSY_GV.MYSY_PORT_REC, debug=True, threaded=True)


    elif (MYSY_GV.MYSY_ENV == "DEM"):
        mycommon.myprint(" ++++ ENVIRONNEMENT DEMONSTRATION ++++")
        mycommon.myprint("++ DATABASE " + MYSY_GV.CONNECTION_STRING + " ++")
        mycommon.myprint("++ DBNAME " + str(MYSY_GV.dbname) + " ++")
        mycommon.myprint("++ FLASK PORT " + str(MYSY_GV.MYSY_PORT_DEM) + " ++")
        mycommon.myprint("++ LMS_BAS_URL " + str(MYSY_GV.LMS_BAS_URL) + " ++")

        scheduler = BackgroundScheduler()
        # Create the job
        scheduler.add_job(func=Flask_Cron_Strip_Get_Customer_Abonnement_Data, trigger="interval", minutes=5)
        # Start the scheduler
        scheduler.start()

        # /!\ IMPORTANT /!\ : Shut down the scheduler when exiting the app
        atexit.register(lambda: scheduler.shutdown())


        app.run(host='localhost', port=MYSY_GV.MYSY_PORT_DEM, debug=True, threaded=True)






