13/07/2024 - 22h
parent
47cd3eb277
commit
065a9ac763
|
@ -3,11 +3,14 @@
|
|||
<component name="ChangeListManager">
|
||||
<list default="true" id="c6d0259a-16e1-410d-91a1-830590ee2a08" name="Changes" comment="11/07/2024 - 13h14">
|
||||
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/Dashbord_queries/formation_tbd_qries.py" beforeDir="false" afterPath="$PROJECT_DIR$/Dashbord_queries/formation_tbd_qries.py" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/Dashbord_queries/inscription_tdb_qries.py" beforeDir="false" afterPath="$PROJECT_DIR$/Dashbord_queries/inscription_tdb_qries.py" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/Contact.py" beforeDir="false" afterPath="$PROJECT_DIR$/Contact.py" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/Dashbord_queries/factures_tbd_qries.py" beforeDir="false" afterPath="$PROJECT_DIR$/Dashbord_queries/factures_tbd_qries.py" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/Dashbord_queries/session_tbd_qries.py" beforeDir="false" afterPath="$PROJECT_DIR$/Dashbord_queries/session_tbd_qries.py" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/Log/log_file.log" beforeDir="false" afterPath="$PROJECT_DIR$/Log/log_file.log" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/formulaire_mgt.py" beforeDir="false" afterPath="$PROJECT_DIR$/formulaire_mgt.py" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/main.py" beforeDir="false" afterPath="$PROJECT_DIR$/main.py" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/prj_common.py" beforeDir="false" afterPath="$PROJECT_DIR$/prj_common.py" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/partner_invoice.py" beforeDir="false" afterPath="$PROJECT_DIR$/partner_invoice.py" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/survey_mgt.py" beforeDir="false" afterPath="$PROJECT_DIR$/survey_mgt.py" afterDir="false" />
|
||||
</list>
|
||||
<option name="SHOW_DIALOG" value="false" />
|
||||
<option name="HIGHLIGHT_CONFLICTS" value="true" />
|
||||
|
@ -77,13 +80,6 @@
|
|||
<option name="presentableId" value="Default" />
|
||||
<updated>1680804787304</updated>
|
||||
</task>
|
||||
<task id="LOCAL-00300" summary="sdsdd">
|
||||
<created>1715805416758</created>
|
||||
<option name="number" value="00300" />
|
||||
<option name="presentableId" value="LOCAL-00300" />
|
||||
<option name="project" value="LOCAL" />
|
||||
<updated>1715805416759</updated>
|
||||
</task>
|
||||
<task id="LOCAL-00301" summary="ddd">
|
||||
<created>1715857414078</created>
|
||||
<option name="number" value="00301" />
|
||||
|
@ -420,7 +416,14 @@
|
|||
<option name="project" value="LOCAL" />
|
||||
<updated>1720696494605</updated>
|
||||
</task>
|
||||
<option name="localTasksCounter" value="349" />
|
||||
<task id="LOCAL-00349" summary="11/07/2024 - 13h14">
|
||||
<created>1720853546536</created>
|
||||
<option name="number" value="00349" />
|
||||
<option name="presentableId" value="LOCAL-00349" />
|
||||
<option name="project" value="LOCAL" />
|
||||
<updated>1720853546538</updated>
|
||||
</task>
|
||||
<option name="localTasksCounter" value="350" />
|
||||
<servers />
|
||||
</component>
|
||||
<component name="Vcs.Log.Tabs.Properties">
|
||||
|
|
29
Contact.py
29
Contact.py
|
@ -147,7 +147,11 @@ def Add_Contact(diction):
|
|||
civilite = ""
|
||||
if ("civilite" in diction.keys()):
|
||||
if diction['civilite']:
|
||||
civilite = str(diction['civilite']).lower()
|
||||
civilite = str(diction['civilite']).lower().strip()
|
||||
if( civilite not in MYSY_GV.CIVILITE ):
|
||||
civilite = "neutre"
|
||||
|
||||
|
||||
data['civilite'] = civilite
|
||||
|
||||
|
||||
|
@ -388,7 +392,10 @@ def Update_Contact(diction):
|
|||
|
||||
civilite = ""
|
||||
if ("civilite" in diction.keys()):
|
||||
civilite = diction['civilite']
|
||||
civilite = str(diction['civilite']).lower().strip()
|
||||
if (civilite not in MYSY_GV.CIVILITE):
|
||||
civilite = "neutre"
|
||||
|
||||
data_update['civilite'] = str(diction['civilite']).lower()
|
||||
|
||||
include_com = ""
|
||||
|
@ -414,8 +421,11 @@ def Update_Contact(diction):
|
|||
|
||||
civilite = ""
|
||||
if ("civilite" in diction.keys()):
|
||||
civilite = diction['civilite']
|
||||
data_update['civilite'] = str(diction['civilite']).lower()
|
||||
civilite = str(diction['civilite']).lower().strip()
|
||||
if (civilite not in MYSY_GV.CIVILITE):
|
||||
civilite = "neutre"
|
||||
|
||||
data_update['civilite'] = str(civilite)
|
||||
|
||||
adr_adresse = ""
|
||||
if ("adr_adresse" in diction.keys()):
|
||||
|
@ -589,6 +599,7 @@ def Get_List_Entity_Contact(diction):
|
|||
RetObject = []
|
||||
val_tmp = 1
|
||||
|
||||
|
||||
for retval in MYSY_GV.dbname['contact'].find(data_cle):
|
||||
user = retval
|
||||
user['id'] = str(val_tmp)
|
||||
|
@ -665,6 +676,16 @@ def Get_Given_Contact(diction):
|
|||
for retval in MYSY_GV.dbname['contact'].find(data_cle):
|
||||
user = retval
|
||||
user['id'] = str(val_tmp)
|
||||
|
||||
local_civilite = ""
|
||||
if( "civilite" in retval.keys() ):
|
||||
local_civilite = str(retval['civilite']).lower().strip()
|
||||
if( local_civilite not in MYSY_GV.CIVILITE ):
|
||||
local_civilite = "neutre"
|
||||
|
||||
user['civilite'] = local_civilite
|
||||
|
||||
|
||||
val_tmp = val_tmp + 1
|
||||
RetObject.append(mycommon.JSONEncoder().encode(user))
|
||||
|
||||
|
|
|
@ -252,6 +252,232 @@ def Get_Qery_List_Factures_Data_By_Periode(diction):
|
|||
return False, " Impossible de récupérer les données "
|
||||
|
||||
|
||||
"""
|
||||
Recuperation du chiffre d'affaire par formation
|
||||
important : seulement les formation ayant un CA > 0
|
||||
|
||||
"""
|
||||
def Get_Qery_List_Factures_Data_By_Class(diction):
|
||||
try:
|
||||
diction = mycommon.strip_dictionary(diction)
|
||||
|
||||
"""
|
||||
Verification des input acceptés
|
||||
"""
|
||||
field_list = ['token', 'periode_start_date', 'periode_end_date', 'filter_value', ]
|
||||
|
||||
incom_keys = diction.keys()
|
||||
for val in incom_keys:
|
||||
if val not in field_list and val.startswith('my_') is False:
|
||||
mycommon.myprint(str(
|
||||
inspect.stack()[0][3]) + " Le champ '" + val + "' n'existe pas")
|
||||
return False, " Les informations fournies sont incorrectes",
|
||||
|
||||
"""
|
||||
Verification des champs obligatoires
|
||||
"""
|
||||
field_list_obligatoire = ['token', ]
|
||||
for val in field_list_obligatoire:
|
||||
if val not in diction:
|
||||
mycommon.myprint(
|
||||
str(inspect.stack()[0][3]) + " - La valeur '" + val + "' n'est pas presente dans liste ")
|
||||
return False, " Les informations fournies sont incorrectes",
|
||||
|
||||
"""
|
||||
Verification de l'identité et autorisation de l'entité qui
|
||||
appelle cette API
|
||||
"""
|
||||
token = ""
|
||||
if ("token" in diction.keys()):
|
||||
if diction['token']:
|
||||
token = diction['token']
|
||||
|
||||
local_status, my_partner = mycommon.Check_Connexion_And_Return_Partner_Data(diction)
|
||||
if (local_status is not True):
|
||||
return local_status, my_partner
|
||||
|
||||
|
||||
filt_periode_start_date = ""
|
||||
if ("periode_start_date" in diction.keys() and diction['periode_start_date']):
|
||||
filt_periode_start_date = str(diction['periode_start_date'])[0:10]
|
||||
local_status = mycommon.CheckisDate(filt_periode_start_date)
|
||||
if (local_status is False):
|
||||
mycommon.myprint(str(
|
||||
inspect.stack()[0][3]) + " Le filtre : 'date de debut' n'est pas au format jj/mm/aaaa.")
|
||||
return False, " Le filtre : 'date de debut' n'est pas au format jj/mm/aaaa."
|
||||
|
||||
filt_periode_end_date = ""
|
||||
if ("periode_end_date" in diction.keys() and diction['periode_end_date']):
|
||||
filt_periode_end_date = str(diction['periode_end_date'])[0:10]
|
||||
local_status = mycommon.CheckisDate(filt_periode_end_date)
|
||||
if (local_status is False):
|
||||
mycommon.myprint(str(
|
||||
inspect.stack()[0][3]) + " Le filtre : 'date de fin' n'est pas au format jj/mm/aaaa.")
|
||||
return False, " Le filtre : 'date de fin' n'est pas au format jj/mm/aaaa."
|
||||
|
||||
|
||||
|
||||
"""
|
||||
Si la valeur de 'filter_value' est m0 ou m1, on va aller recuperer les date du mois correspondant.
|
||||
On ecrase les valeur de filt_session_start_date et filt_session_end_date
|
||||
"""
|
||||
if ('filter_value' in diction.keys()):
|
||||
# print(" filter_value = ", diction['filter_value'])
|
||||
if (str(diction['filter_value']) == "m0"):
|
||||
# On recupere les date du mois en cours
|
||||
local_status, start_current_month_date, end_current_month_date = mycommon.Get_Current_Month_Start_End_Date()
|
||||
if (local_status is False):
|
||||
return local_status, start_current_month_date
|
||||
|
||||
filt_periode_start_date = start_current_month_date
|
||||
filt_periode_end_date = end_current_month_date
|
||||
|
||||
# print(" ### filt_session_start_date = ", filt_session_start_date, " ### filt_session_end_date = ", filt_session_end_date)
|
||||
|
||||
elif (str(diction['filter_value']) == "m1"):
|
||||
# On recupere les date du mois en cours
|
||||
local_status, start_current_month_date, end_current_month_date = mycommon.Get_Previous_Month_Start_End_Date()
|
||||
if (local_status is False):
|
||||
return local_status, start_current_month_date
|
||||
|
||||
filt_periode_start_date = start_current_month_date
|
||||
filt_periode_end_date = end_current_month_date
|
||||
|
||||
|
||||
|
||||
filt_periode_start_date_ISODATE = datetime.strptime(str(filt_periode_start_date), '%d/%m/%Y')
|
||||
filt_periode_end_date_ISODATE = datetime.strptime(str(filt_periode_end_date), '%d/%m/%Y')
|
||||
|
||||
|
||||
|
||||
|
||||
qery_match = {'$and': [{"partner_owner_recid": str(my_partner['recid'])},
|
||||
{"valide": '1'},
|
||||
{
|
||||
'mysy_invoice_date': {'$gte': filt_periode_start_date_ISODATE,
|
||||
'$lte': filt_periode_end_date_ISODATE}}, ]}
|
||||
|
||||
pipe_qry = ([
|
||||
{"$addFields": {
|
||||
"mysy_invoice_date": {
|
||||
'$dateFromString': {
|
||||
'dateString': '$invoice_date',
|
||||
'format': "%d/%m/%Y"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
{'$match': qery_match},
|
||||
{'$lookup': {
|
||||
'from': 'partner_invoice_line',
|
||||
"let": {"invoice_header_id": {'$toString': "$_id"},
|
||||
'partner_invoice_line_partner_owner_recid': '$partner_owner_recid',
|
||||
'partner_invoice_line_invoice_header_ref_interne': '$invoice_header_ref_interne'},
|
||||
'pipeline': [
|
||||
{'$match':
|
||||
{'$expr':
|
||||
{'$and':
|
||||
[
|
||||
{'$eq': ["$valide", "1"]},
|
||||
{'$eq': ["$invoice_header_ref_interne",
|
||||
'$$partner_invoice_line_invoice_header_ref_interne']},
|
||||
{'$eq': ["$partner_owner_recid", '$$partner_invoice_line_partner_owner_recid']},
|
||||
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
],
|
||||
'as': 'collection_partner_invoice_line'
|
||||
}
|
||||
},
|
||||
{
|
||||
'$unwind': '$collection_partner_invoice_line'
|
||||
},
|
||||
{'$group': {
|
||||
'_id': {
|
||||
"class_internal_url": "$collection_partner_invoice_line.order_line_formation",
|
||||
},
|
||||
"TotalAmount_HT": {
|
||||
"$sum": {'$toDouble': '$collection_partner_invoice_line.order_line_montant_hors_taxes'}},
|
||||
"count": {"$sum": 1}
|
||||
}
|
||||
},
|
||||
{
|
||||
'$sort': {'count': -1}
|
||||
},
|
||||
|
||||
])
|
||||
|
||||
print(" ### Get_Qery_List_Factures_Data_By_Class ici pipe_qry = ", pipe_qry)
|
||||
|
||||
RetObject = []
|
||||
val_tmp = 0
|
||||
|
||||
axis_data = []
|
||||
series_TotalAmount_data = []
|
||||
|
||||
tab_data = []
|
||||
tab_axis_data_class_code = []
|
||||
tab_axis_data_class_title = []
|
||||
"""
|
||||
On recupere les données, on les format dans le 'range_date_month' et on retourne"""
|
||||
for retval in MYSY_GV.dbname['partner_invoice_header'].aggregate(pipe_qry):
|
||||
val_tmp = val_tmp + 1
|
||||
|
||||
node = {}
|
||||
node['class_internal_url'] = retval['_id']['class_internal_url']
|
||||
node['TotalAmount_HT'] = retval['TotalAmount_HT']
|
||||
node['label'] = retval['TotalAmount_HT']
|
||||
node['nb_line'] = retval['count']
|
||||
|
||||
# Recuperation des données de la formation
|
||||
|
||||
class_data = MYSY_GV.dbname['myclass'].find_one({'internal_url':str(retval['_id']['class_internal_url']),
|
||||
'partner_owner_recid':str(my_partner['recid']),
|
||||
'valide':'1'})
|
||||
|
||||
|
||||
if( class_data and "title" in class_data.keys() ):
|
||||
node['class_title'] = class_data['title']
|
||||
tab_axis_data_class_title.append(class_data['title'])
|
||||
else:
|
||||
node['class_title'] = ""
|
||||
tab_axis_data_class_title.append("")
|
||||
|
||||
if (class_data and "external_code" in class_data.keys()):
|
||||
node['class_external_code'] = class_data['external_code']
|
||||
tab_axis_data_class_code.append(class_data['external_code'])
|
||||
else:
|
||||
node['class_external_code'] = ""
|
||||
tab_axis_data_class_code.append("")
|
||||
|
||||
tab_data.append(node)
|
||||
|
||||
|
||||
|
||||
|
||||
json_retval = {}
|
||||
json_retval['data'] = tab_data
|
||||
json_retval['axis_class_code'] = tab_axis_data_class_code
|
||||
json_retval['axis_class_title'] = tab_axis_data_class_title
|
||||
|
||||
print(" ### Get_Qery_List_Factures_Data_By_Class json_retval = ", json_retval)
|
||||
RetObject.append(mycommon.JSONEncoder().encode(json_retval))
|
||||
|
||||
return True, RetObject
|
||||
|
||||
|
||||
except Exception as e:
|
||||
exc_type, exc_obj, exc_tb = sys.exc_info()
|
||||
mycommon.myprint(str(inspect.stack()[0][3]) + " -" + str(e) + " - Line : " + str(exc_tb.tb_lineno))
|
||||
return False, " Impossible de récupérer les données "
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
"""
|
||||
Affichage du chiffre d'affaire par client sur une periode
|
||||
|
|
|
@ -4,6 +4,7 @@ Ce fichier contient les requetes utilisées dans les tableaux de bord des sessio
|
|||
import ast
|
||||
import dateutil
|
||||
import pymongo
|
||||
from dateutil.relativedelta import relativedelta
|
||||
from flask import send_file
|
||||
from pymongo import MongoClient
|
||||
import json
|
||||
|
@ -196,7 +197,7 @@ def Get_Qery_List_Session_Data(diction):
|
|||
|
||||
#RetObject.append(mycommon.JSONEncoder().encode(user))
|
||||
|
||||
#print(" #### RetObject = ", RetObject)
|
||||
print(" #### Get_Qery_List_Session_Data RetObject = ", RetObject)
|
||||
return True, RetObject
|
||||
|
||||
|
||||
|
@ -206,6 +207,231 @@ def Get_Qery_List_Session_Data(diction):
|
|||
return False, " Impossible de récupérer les données "
|
||||
|
||||
|
||||
|
||||
"""
|
||||
V2 : Recuperation des sessions avec le taux de remplissage
|
||||
"""
|
||||
def Get_Qery_List_Taux_Remplissage_Session_Data_V2(diction):
|
||||
try:
|
||||
diction = mycommon.strip_dictionary(diction)
|
||||
|
||||
"""
|
||||
Verification des input acceptés
|
||||
"""
|
||||
field_list = ['token', 'session_start_date', 'session_end_date', 'filter_value', ]
|
||||
|
||||
incom_keys = diction.keys()
|
||||
for val in incom_keys:
|
||||
if val not in field_list and val.startswith('my_') is False:
|
||||
mycommon.myprint(str(
|
||||
inspect.stack()[0][3]) + " Le champ '" + val + "' n'existe pas")
|
||||
return False, " Les informations fournies sont incorrectes",
|
||||
|
||||
"""
|
||||
Verification des champs obligatoires
|
||||
"""
|
||||
field_list_obligatoire = ['token', 'session_start_date', 'session_end_date']
|
||||
for val in field_list_obligatoire:
|
||||
if val not in diction:
|
||||
mycommon.myprint(
|
||||
str(inspect.stack()[0][3]) + " - La valeur '" + val + "' n'est pas presente dans liste ")
|
||||
return False, " Les informations fournies sont incorrectes",
|
||||
|
||||
"""
|
||||
Verification de l'identité et autorisation de l'entité qui
|
||||
appelle cette API
|
||||
"""
|
||||
token = ""
|
||||
if ("token" in diction.keys()):
|
||||
if diction['token']:
|
||||
token = diction['token']
|
||||
|
||||
local_status, my_partner = mycommon.Check_Connexion_And_Return_Partner_Data(diction)
|
||||
if (local_status is not True):
|
||||
return local_status, my_partner
|
||||
|
||||
filt_session_start_date = ""
|
||||
if ("session_start_date" in diction.keys() and diction['session_start_date']):
|
||||
filt_session_start_date = str(diction['session_start_date'])[0:10]
|
||||
local_status = mycommon.CheckisDate(filt_session_start_date)
|
||||
if (local_status is False):
|
||||
mycommon.myprint(str(
|
||||
inspect.stack()[0][3]) + " Le filtre : 'date de debut de session' n'est pas au format jj/mm/aaaa.")
|
||||
return False, " Le filtre : 'date de debut de session' n'est pas au format jj/mm/aaaa."
|
||||
|
||||
filt_session_end_date = ""
|
||||
if ("session_end_date" in diction.keys() and diction['session_end_date']):
|
||||
filt_session_end_date = str(diction['session_end_date'])[0:10]
|
||||
local_status = mycommon.CheckisDate(filt_session_end_date)
|
||||
if (local_status is False):
|
||||
mycommon.myprint(str(
|
||||
inspect.stack()[0][3]) + " Le filtre : 'date de fin de session' n'est pas au format jj/mm/aaaa.")
|
||||
return False, " Le filtre : 'date de fin de session' n'est pas au format jj/mm/aaaa."
|
||||
|
||||
"""
|
||||
Si la valeur de 'filter_value' est m0 ou m1, on va aller recuperer les date du mois correspondant.
|
||||
On ecrase les valeur de filt_session_start_date et filt_session_end_date
|
||||
"""
|
||||
if ('filter_value' in diction.keys()):
|
||||
if (str(diction['filter_value']) == "m0"):
|
||||
# On recupere les date du mois en cours
|
||||
local_status, start_current_month_date, end_current_month_date = mycommon.Get_Current_Month_Start_End_Date()
|
||||
if (local_status is False):
|
||||
return local_status, start_current_month_date
|
||||
|
||||
filt_session_start_date = start_current_month_date
|
||||
filt_session_end_date = end_current_month_date
|
||||
|
||||
elif (str(diction['filter_value']) == "m1"):
|
||||
# On recupere les date du mois en cours
|
||||
local_status, start_current_month_date, end_current_month_date = mycommon.Get_Previous_Month_Start_End_Date()
|
||||
if (local_status is False):
|
||||
return local_status, start_current_month_date
|
||||
|
||||
filt_session_start_date = start_current_month_date
|
||||
filt_session_end_date = end_current_month_date
|
||||
|
||||
RetObject = []
|
||||
val_tmp = 1
|
||||
|
||||
filt_session_start_date_ISODATE = datetime.strptime(str(filt_session_start_date), '%d/%m/%Y')
|
||||
filt_session_end_date_ISODATE = datetime.strptime(str(filt_session_end_date), '%d/%m/%Y')
|
||||
|
||||
"""
|
||||
Creation de la range des mois entre filt_periode_start_date_ISODATE et
|
||||
filt_periode_end_date_ISODATE
|
||||
"""
|
||||
range_date_month = []
|
||||
start = filt_session_start_date_ISODATE
|
||||
end = filt_session_end_date_ISODATE
|
||||
while start <= end:
|
||||
node = {}
|
||||
node['month_year'] = '{:02d}'.format(start.month) + "_" + str(start.year)
|
||||
node['label'] = '{:02d}'.format(start.month) + "_" + str(start.year)
|
||||
node['TotalAmount'] = 0
|
||||
node['value'] = 0
|
||||
node['count'] = 0
|
||||
|
||||
range_date_month.append(node)
|
||||
start += relativedelta(months=1)
|
||||
|
||||
|
||||
|
||||
filt_session_start_date_ISODATE_work = filt_session_start_date_ISODATE
|
||||
filt_session_end_date_ISODATE_work = filt_session_end_date_ISODATE
|
||||
|
||||
qery_match = {'$and': [{"partner_owner_recid": str(my_partner['recid'])}, {"valide": '1'},
|
||||
|
||||
{'mysy_date_debut_session': {'$gte': filt_session_start_date_ISODATE,
|
||||
'$lte': filt_session_end_date_ISODATE}},
|
||||
]}
|
||||
"""
|
||||
|
||||
qery_match = {'$and': [{"partner_owner_recid": str(my_partner['recid'])}, {"valide": '1'},
|
||||
{"apprenant_id": {"$exists": True}},
|
||||
]}
|
||||
"""
|
||||
|
||||
# print(" ### qery_match = ", qery_match)
|
||||
|
||||
pipe_qry = ([
|
||||
{"$addFields": {
|
||||
"mysy_date_debut_session": {
|
||||
'$dateFromString': {
|
||||
'dateString': '$date_debut',
|
||||
'format': "%d/%m/%Y"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
{'$match': qery_match},
|
||||
|
||||
|
||||
])
|
||||
|
||||
|
||||
print(" ### Get_Qery_List_Taux_Remplissage_Session_Data_V2 ici pipe_qry = ", pipe_qry)
|
||||
|
||||
axis_data = []
|
||||
my_data = []
|
||||
cpt = 0
|
||||
tab_lines_inscription_data = []
|
||||
|
||||
tab_serie_taux_replissage = []
|
||||
tab_serie_taux_non_replissage = []
|
||||
tab_serie_label = []
|
||||
|
||||
for retval in MYSY_GV.dbname['session_formation'].aggregate(pipe_qry):
|
||||
cpt = cpt + 1
|
||||
axis_data.append(str(retval['code_session']))
|
||||
node = {}
|
||||
node['session_code'] = str(retval['code_session'])
|
||||
node['session_title'] = str(retval['titre'])
|
||||
node['label'] = str(retval['code_session'])
|
||||
|
||||
|
||||
|
||||
### gestion des taux
|
||||
nb_participant = "1"
|
||||
if ("nb_participant" in retval.keys()):
|
||||
nb_participant = retval['nb_participant']
|
||||
|
||||
node['nb_participant'] = nb_participant
|
||||
|
||||
## Recuperation du nombre d'inscrits
|
||||
Count_Inscrit = MYSY_GV.dbname['inscription'].count_documents(
|
||||
{'session_id': str(retval['_id']), 'class_internal_url': str(retval['class_internal_url']),
|
||||
'status': "1", 'partner_owner_recid': str(my_partner['recid'])})
|
||||
|
||||
qry_nb_inscrit = {'session_id': str(retval['_id']), 'class_internal_url': str(retval['class_internal_url']),
|
||||
'status': "1", 'partner_owner_recid': str(my_partner['recid'])}
|
||||
|
||||
node['nb_inscrit'] = str(Count_Inscrit)
|
||||
taux_remplissage = "0"
|
||||
if (str(nb_participant) != "0" and str(nb_participant).strip() != ""):
|
||||
taux_remplissage = round(int(mycommon.tryInt(Count_Inscrit)) / int(mycommon.tryInt(nb_participant)), 2)
|
||||
|
||||
node['taux_remplissage'] = str(taux_remplissage)
|
||||
|
||||
taux_non_remplissage = round(1 - taux_remplissage, 2)
|
||||
|
||||
tab_serie_taux_replissage.append(taux_remplissage)
|
||||
tab_serie_taux_non_replissage.append(taux_non_remplissage)
|
||||
tab_serie_label.append( str(retval['code_session']))
|
||||
|
||||
|
||||
my_data.append(node)
|
||||
|
||||
|
||||
RetObject = []
|
||||
json_retval = {}
|
||||
json_retval['axis_data'] = axis_data
|
||||
|
||||
node_taux_replissage = {}
|
||||
node_taux_replissage['data'] = tab_serie_taux_replissage
|
||||
node_taux_replissage['label'] = "Taux Remplissage"
|
||||
json_retval['taux_replissage'] = node_taux_replissage
|
||||
|
||||
node_taux_non_replissage = {}
|
||||
node_taux_non_replissage['data'] = tab_serie_taux_non_replissage
|
||||
node_taux_non_replissage['label'] = "Taux non Remplissage"
|
||||
json_retval['taux_non_replissage'] = node_taux_non_replissage
|
||||
|
||||
print(" ### Get_Qery_List_Taux_Remplissage_Session_Data_V2 json_retval = ", json_retval)
|
||||
|
||||
RetObject.append(mycommon.JSONEncoder().encode(json_retval))
|
||||
|
||||
#print(" ### Get_Qery_List_Taux_Remplissage_Session_Data_V2 RetObject = ", RetObject)
|
||||
|
||||
return True, RetObject
|
||||
except Exception as e:
|
||||
exc_type, exc_obj, exc_tb = sys.exc_info()
|
||||
mycommon.myprint(str(inspect.stack()[0][3]) + " -" + str(e) + " - Line : " + str(exc_tb.tb_lineno))
|
||||
return False, " Impossible de récupérer les données "
|
||||
|
||||
|
||||
|
||||
"""
|
||||
Recuperation des sessions par formateur sur une periode
|
||||
"""
|
||||
|
|
3714
Log/log_file.log
3714
Log/log_file.log
File diff suppressed because one or more lines are too long
|
@ -214,8 +214,12 @@ def Add_Update_Question_Formulaire(diction):
|
|||
|
||||
local_status, local_note_max = mycommon.IsInt(str(diction['max_note']).strip())
|
||||
if(local_status is False ):
|
||||
mycommon.myprint(" Pour ce type de question, une note maximale doit être un nombre entier ")
|
||||
return False, " Pour ce type de question, une note maximale doit être un nombre entier "
|
||||
mycommon.myprint(" Pour ce type de question, une note maximale doit être un nombre entier supérieure a '1' ")
|
||||
return False, " Pour ce type de question, une note maximale doit être un nombre entier supérieure a '1'"
|
||||
|
||||
if( local_note_max <= 1 ):
|
||||
mycommon.myprint(" Pour ce type de question, la note maximale doit être supérieure a '1' ")
|
||||
return False, " Pour ce type de question, la note maximale doit être supérieure a '1' "
|
||||
|
||||
|
||||
|
||||
|
@ -349,6 +353,10 @@ def Add_Update_Question_Formulaire(diction):
|
|||
else:
|
||||
new_data['max_note'] = ""
|
||||
|
||||
if ("is_statistic" in diction.keys() and str(diction['is_statistic']).strip() in ['0', '1'] ):
|
||||
new_data['is_statistic'] = str(diction['is_statistic']).strip()
|
||||
else:
|
||||
new_data['is_statistic'] = "0"
|
||||
|
||||
tab_list_choix = []
|
||||
if ("list_choix" in diction.keys() and str(diction['type']) == "qcm"):
|
||||
|
|
27
main.py
27
main.py
|
@ -7080,6 +7080,18 @@ def Get_Qery_List_Session_Data():
|
|||
return jsonify(status=status, message=retval)
|
||||
|
||||
|
||||
"""
|
||||
V2 : API / TBD / QRY : Recuperation le taux de replissage des sessions
|
||||
"""
|
||||
@app.route('/myclass/api/Get_Qery_List_Taux_Remplissage_Session_Data_V2/', methods=['POST','GET'])
|
||||
@crossdomain(origin='*')
|
||||
def Get_Qery_List_Taux_Remplissage_Session_Data_V2():
|
||||
# On recupere le corps (payload) de la requete
|
||||
payload = mycommon.strip_dictionary (request.form.to_dict())
|
||||
print(" ### Get_Qery_List_Taux_Remplissage_Session_Data_V2 payload = ",payload)
|
||||
status, retval = session_tbd_qries.Get_Qery_List_Taux_Remplissage_Session_Data_V2(payload)
|
||||
return jsonify(status=status, message=retval)
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -8912,6 +8924,21 @@ def Get_Qery_List_Factures_Data_By_Periode():
|
|||
|
||||
|
||||
|
||||
"""
|
||||
API / TBD / QRY : Recuperation du chiffre d'affaire par formation
|
||||
"""
|
||||
@app.route('/myclass/api/Get_Qery_List_Factures_Data_By_Class/', methods=['POST','GET'])
|
||||
@crossdomain(origin='*')
|
||||
def Get_Qery_List_Factures_Data_By_Class():
|
||||
# On recupere le corps (payload) de la requete
|
||||
payload = mycommon.strip_dictionary (request.form.to_dict())
|
||||
print(" ### Get_Qery_List_Factures_Data_By_Class payload = ",payload)
|
||||
status, retval = factures_tbd_qries.Get_Qery_List_Factures_Data_By_Class(payload)
|
||||
return jsonify(status=status, message=retval)
|
||||
|
||||
|
||||
|
||||
|
||||
"""
|
||||
API / TBD / QRY : Recuperation des factures PREVISIONNELLES sur une periode
|
||||
"""
|
||||
|
|
|
@ -1189,7 +1189,7 @@ def Get_List_Partner_Invoice_with_filter(diction):
|
|||
user['order_header_client_nom'] = str(Client_data['nom'])
|
||||
|
||||
# Si le champ 'order_header_vendeur_id' alors on va chercher le nom et prenom du vendeur (employe)
|
||||
if ('order_header_vendeur_id' in New_retVal.keys()):
|
||||
if ('order_header_vendeur_id' in New_retVal.keys() and New_retVal['order_header_vendeur_id'] ):
|
||||
Employee_data = MYSY_GV.dbname['ressource_humaine'].find_one(
|
||||
{'_id': ObjectId(str(New_retVal['order_header_vendeur_id'])), 'valide': '1', 'locked': '0',
|
||||
'partner_recid': str(my_partner['recid'])})
|
||||
|
|
115
survey_mgt.py
115
survey_mgt.py
|
@ -80,8 +80,6 @@ def Get_Given_Survey_Data_No_Token(diction):
|
|||
if diction['token']:
|
||||
token = diction['token']
|
||||
|
||||
|
||||
|
||||
RetObject = []
|
||||
val_tmp = 1
|
||||
|
||||
|
@ -146,9 +144,62 @@ def Get_Given_Survey_Data_No_Token(diction):
|
|||
user['list_questions'] = list_questions
|
||||
user['message_introduction'] = formulaire_message_introduction
|
||||
|
||||
"""
|
||||
13/067/2024 :
|
||||
S'il s'agit de l'evaluation d'une ressource humaine, ( related_collection = 'ressource_humaine' et related_collection_id : est valide)
|
||||
on va aller chercher la personne concernée dans la collection 'ressource_humaine'.
|
||||
|
||||
par exemple pour evaluer un enseignant, on va aller recuperer les données de l'enseignant
|
||||
|
||||
"""
|
||||
related_rh_data = None
|
||||
if ("related_collection" in New_retVal.keys() and New_retVal['related_collection'] and New_retVal['related_collection'] == "ressource_humaine" and
|
||||
'related_collection_id' in New_retVal.keys() and New_retVal[
|
||||
'related_collection_id']):
|
||||
# Verifier la validité de la ressource humaine concernée
|
||||
is_valide_related_collection_id = MYSY_GV.dbname['ressource_humaine'].count_documents(
|
||||
{'_id': ObjectId(str(New_retVal['related_collection_id'])),
|
||||
'valide': '1', 'locked': '0', 'partner_recid': str(New_retVal['partner_owner_recid'])})
|
||||
|
||||
|
||||
|
||||
if ( is_valide_related_collection_id != 1):
|
||||
str(inspect.stack()[0][3]) + " L'identifiant de la personne à évaluer est invalide "
|
||||
return False, " L'identifiant de la personne à évaluer est invalide "
|
||||
|
||||
related_rh_data = MYSY_GV.dbname['ressource_humaine'].find_one(
|
||||
{'_id': ObjectId(str(New_retVal['related_collection_id'])),
|
||||
'valide': '1', 'locked': '0', 'partner_recid': str(New_retVal['partner_owner_recid'])}, {'_id':1, 'nom':1, 'prenom':1, 'email':1, 'civilite':1})
|
||||
|
||||
if (related_rh_data and "_id" in related_rh_data.keys()):
|
||||
user["related_rh_data_is_valide"] = "1"
|
||||
else:
|
||||
user["related_rh_data_is_valide"] = "0"
|
||||
|
||||
if (related_rh_data and "civilite" in related_rh_data.keys()):
|
||||
user["related_rh_data_civilite"] = str(related_rh_data['civilite']).capitalize()
|
||||
else:
|
||||
user["related_rh_data_is_valide"] = "neutre".capitalize()
|
||||
|
||||
if( related_rh_data and "email" in related_rh_data.keys()):
|
||||
user["related_rh_data_email"] = str(related_rh_data['email'])
|
||||
else:
|
||||
user["related_rh_data_email"] = ""
|
||||
|
||||
if (related_rh_data and "prenom" in related_rh_data.keys()):
|
||||
user["related_rh_data_prenom"] = str(related_rh_data['prenom'])
|
||||
else:
|
||||
user["related_rh_data_prenom"] = ""
|
||||
|
||||
if (related_rh_data and "nom" in related_rh_data.keys()):
|
||||
user["related_rh_data_nom"] = str(related_rh_data['nom'])
|
||||
else:
|
||||
user["related_rh_data_nom"] = ""
|
||||
|
||||
|
||||
RetObject.append(mycommon.JSONEncoder().encode(user))
|
||||
|
||||
print(" ### RetObject = ", RetObject)
|
||||
#print(" ### RetObject = ", RetObject)
|
||||
return True, RetObject
|
||||
|
||||
|
||||
|
@ -1088,7 +1139,7 @@ def Send_Survey_TabIds(diction):
|
|||
# Verifier que les survey sont valides
|
||||
qry = { '_id':ObjectId(str(my_survey_id)), 'partner_owner_recid': str(my_partner['recid']),'valide':'1', 'locked':'0'}
|
||||
|
||||
print(" qry2 === ", qry)
|
||||
|
||||
tmp_count = MYSY_GV.dbname['survey'].count_documents(qry)
|
||||
|
||||
if (tmp_count <= 0):
|
||||
|
@ -1156,6 +1207,35 @@ def Send_Survey_TabIds(diction):
|
|||
mycommon.myprint(str(inspect.stack()[0][3]) + " L'identifiant de l'inscrit est invalide ")
|
||||
return False, " L'identifiant de l'inscrit est invalide "
|
||||
|
||||
"""
|
||||
13/067/2024 :
|
||||
S'il s'agit de l'evaluation d'une ressource humaine, ( related_collection = 'ressource_humaine' et related_collection_id : est valide)
|
||||
on va aller chercher la personne concernée dans la collection 'ressource_humaine'.
|
||||
|
||||
par exemple pour evaluer un enseignant, on va aller recuperer les données de l'enseignant
|
||||
|
||||
"""
|
||||
related_rh_data = None
|
||||
|
||||
if ("related_collection" in local_survey_retval.keys() and local_survey_retval['related_collection'] and local_survey_retval['related_collection'] == "ressource_humaine" and
|
||||
'related_collection_id' in local_survey_retval.keys() and local_survey_retval[
|
||||
'related_collection_id'] ):
|
||||
# Verifier la validité de la ressource humaine concernée
|
||||
is_valide_related_collection_id = MYSY_GV.dbname['ressource_humaine'].count_documents(
|
||||
{'_id': ObjectId(str(local_survey_retval['related_collection_id'])),
|
||||
'valide': '1', 'locked': '0', 'partner_recid': str(my_partner['recid'])})
|
||||
|
||||
|
||||
|
||||
if ( is_valide_related_collection_id != 1):
|
||||
str(inspect.stack()[0][3]) + " L'identifiant de la personne à évaluer est invalide "
|
||||
return False, " L'identifiant de la personne à évaluer est invalide "
|
||||
|
||||
related_rh_data = MYSY_GV.dbname['ressource_humaine'].find_one(
|
||||
{'_id': ObjectId(str(local_survey_retval['related_collection_id'])),
|
||||
'valide': '1', 'locked': '0', 'partner_recid': str(my_partner['recid'])}, {'_id':1, 'nom':1, 'prenom':1, 'email':1, 'civilite':1})
|
||||
|
||||
|
||||
print(" ### local_survey_retval = ",local_survey_retval)
|
||||
courrier_ref_interne = ""
|
||||
if ( "survey_type" in local_survey_retval.keys() and local_survey_retval['survey_type'] == "pos"):
|
||||
|
@ -1239,7 +1319,6 @@ def Send_Survey_TabIds(diction):
|
|||
new_diction['list_stagiaire_id'].append(ObjectId(str( local_survey_retval['inscription_id'])))
|
||||
|
||||
|
||||
|
||||
new_diction['list_session_id'] = []
|
||||
if ("session_id" in local_survey_retval.keys() and local_survey_retval['session_id']):
|
||||
new_diction['list_session_id'].append(ObjectId(str(local_survey_retval['session_id'])))
|
||||
|
@ -1253,7 +1332,6 @@ def Send_Survey_TabIds(diction):
|
|||
new_diction['list_apprenant_id'] = []
|
||||
|
||||
|
||||
|
||||
local_status, local_retval = mycommon.Get_Dictionnary_data_For_Template(new_diction)
|
||||
|
||||
if (local_status is False):
|
||||
|
@ -1268,6 +1346,31 @@ def Send_Survey_TabIds(diction):
|
|||
convention_dictionnary_data["servey_nom"] = str(local_survey_retval['nom'])
|
||||
convention_dictionnary_data["servey_prenom"] =str(local_survey_retval['prenom'])
|
||||
|
||||
if (related_rh_data and "_id" in related_rh_data.keys()):
|
||||
convention_dictionnary_data["related_rh_data_is_valide"] = "1"
|
||||
else:
|
||||
convention_dictionnary_data["related_rh_data_is_valide"] = "0"
|
||||
|
||||
if (related_rh_data and "civilite" in related_rh_data.keys()):
|
||||
convention_dictionnary_data["related_rh_data_civilite"] = str(related_rh_data['civilite']).capitalize()
|
||||
else:
|
||||
convention_dictionnary_data["related_rh_data_is_valide"] = "neutre".capitalize()
|
||||
|
||||
if( related_rh_data and "email" in related_rh_data.keys()):
|
||||
convention_dictionnary_data["related_rh_data_email"] = str(related_rh_data['email'])
|
||||
else:
|
||||
convention_dictionnary_data["related_rh_data_email"] = ""
|
||||
|
||||
if (related_rh_data and "prenom" in related_rh_data.keys()):
|
||||
convention_dictionnary_data["related_rh_data_prenom"] = str(related_rh_data['prenom'])
|
||||
else:
|
||||
convention_dictionnary_data["related_rh_data_prenom"] = ""
|
||||
|
||||
if (related_rh_data and "nom" in related_rh_data.keys()):
|
||||
convention_dictionnary_data["related_rh_data_nom"] = str(related_rh_data['nom'])
|
||||
else:
|
||||
convention_dictionnary_data["related_rh_data_nom"] = ""
|
||||
|
||||
|
||||
body = {
|
||||
"params": convention_dictionnary_data
|
||||
|
|
Loading…
Reference in New Issue