28/02/26 - 22h

Signed-off-by: Cherif <cbalde@mysy-training.com>
master_Elyos_FI
Cherif 2026-02-28 21:43:13 +01:00
parent a5927683ad
commit 8e977acbcb
5 changed files with 3252 additions and 228 deletions

View File

@ -4,13 +4,12 @@
<option name="autoReloadType" value="SELECTIVE" />
</component>
<component name="ChangeListManager">
<list default="true" id="c6d0259a-16e1-410d-91a1-830590ee2a08" name="Changes" comment="26/02/26 - 19h30">
<list default="true" id="c6d0259a-16e1-410d-91a1-830590ee2a08" name="Changes" comment="27/02/26 - 19h30">
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/Inscription_mgt.py" beforeDir="false" afterPath="$PROJECT_DIR$/Inscription_mgt.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$/apprenant_mgt.py" beforeDir="false" afterPath="$PROJECT_DIR$/apprenant_mgt.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/Session_Formation.py" beforeDir="false" afterPath="$PROJECT_DIR$/Session_Formation.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/class_mgt.py" beforeDir="false" afterPath="$PROJECT_DIR$/class_mgt.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/prj_common.py" beforeDir="false" afterPath="$PROJECT_DIR$/prj_common.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/notes_apprenant_mgt.py" beforeDir="false" afterPath="$PROJECT_DIR$/notes_apprenant_mgt.py" afterDir="false" />
</list>
<option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" />
@ -454,7 +453,7 @@
<option name="project" value="LOCAL" />
<updated>1747251650255</updated>
</task>
<option name="localTasksCounter" value="541" />
<option name="localTasksCounter" value="542" />
<servers />
</component>
<component name="Vcs.Log.Tabs.Properties">
@ -496,7 +495,6 @@
</option>
</component>
<component name="VcsManagerConfiguration">
<MESSAGE value="23/11/25 - 21h30" />
<MESSAGE value="23/11/25 - 21h30dd" />
<MESSAGE value="25/11/25 - 21h30dd" />
<MESSAGE value="07/12/25 - 14h" />
@ -521,6 +519,7 @@
<MESSAGE value="24/02/26 - 19h30" />
<MESSAGE value="25/02/26 - 19h30" />
<MESSAGE value="26/02/26 - 19h30" />
<option name="LAST_COMMIT_MESSAGE" value="26/02/26 - 19h30" />
<MESSAGE value="27/02/26 - 19h30" />
<option name="LAST_COMMIT_MESSAGE" value="27/02/26 - 19h30" />
</component>
</project>

File diff suppressed because it is too large Load Diff

View File

@ -1784,11 +1784,44 @@ def GetAllValideSessionPartner_List_Without_Scope_Action(diction):
}
}
]
#print("#### GetAllValideSessionPartner_List_Without_Scope_Action query = ", query)
query2 = [{'$match':{ "$and" : [{'partner_owner_recid':str(my_partner['recid'])}, filt_archive, filt_type_session]} },
{'$sort': {'_id': -1}},
{'$lookup':
{
'from': 'myclass',
'let': {'class_id': "$class_id", 'partner_owner_recid': '$partner_owner_recid'},
'pipeline': [
{'$match':
{'$expr':
{'$and':
[
{'$eq': ["$_id", {'$convert': {
'input': "$$class_id",
'to': "objectId",
'onError': {'error': 'true'},
'onNull': {'isnull': 'true'}
}}]},
{'$eq': ["$valide", "1"]},
{'$eq': ["$partner_owner_recid", '$$partner_owner_recid']},
]
}
}
},
],
'as': 'myclass_collection'
}
},
]
#print("#### GetAllValideSessionPartner_List_Without_Scope_Action query = ", query2)
RetObject = []
cpt = 0
for retVal in MYSY_GV.dbname['session_formation'].aggregate(query):
for retVal in MYSY_GV.dbname['session_formation'].aggregate(query2):
if ('myclass_collection' in retVal.keys() and len(retVal['myclass_collection']) > 0):
val = {}
val['id'] = str(cpt)
@ -1974,7 +2007,42 @@ def GetAllValideSessionPartner_List(diction):
}
}
]
print("#### GetAllValideSessionPartner_List query = ", query)
query2 = [{'$match': {
"$and": [{'partner_owner_recid': str(my_partner['recid'])}, filt_scope_class_id, filt_scope_session_id, filt_archive, filt_type_session]}},
{'$sort': {'_id': -1}},
{'$lookup':
{
'from': 'myclass',
'let': {'class_id': "$class_id", 'partner_owner_recid': '$partner_owner_recid'},
'pipeline': [
{'$match':
{'$expr':
{'$and':
[
{'$eq': ["$_id", {'$convert': {
'input': "$$class_id",
'to': "objectId",
'onError': {'error': 'true'},
'onNull': {'isnull': 'true'}
}}]},
{'$eq': ["$valide", "1"]},
{'$eq': ["$partner_owner_recid", '$$partner_owner_recid']},
]
}
}
},
],
'as': 'myclass_collection'
}
},
]
print("#### GetAllValideSessionPartner_List query2 = ", query2)
mytoday_add_30j = datetime.today() + timedelta(days=30)
mytoday_minus_5j = datetime.today() - timedelta(days=5)
@ -2150,7 +2218,7 @@ def GetAllValideSessionPartner_List(diction):
## 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']),
{'session_id': str(retVal['_id']), 'class_id': str(retVal['class_id']),
'status': "1", 'partner_owner_recid': str(my_partner['recid'])})
qry_nb_inscrit = {'session_id': str(retVal['_id']),
@ -2161,7 +2229,7 @@ def GetAllValideSessionPartner_List(diction):
## Recuperation du nombre de preinscrits
Count_Preinscrit = MYSY_GV.dbname['inscription'].count_documents(
{'session_id': str(retVal['_id']), 'class_internal_url': str(retVal['class_internal_url']),
{'session_id': str(retVal['_id']), 'class_id': str(retVal['class_id']),
'status': "0",
'partner_owner_recid': str(my_partner['recid'])})
@ -2169,100 +2237,108 @@ def GetAllValideSessionPartner_List(diction):
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)
taux_remplissage = round(
int(mycommon.tryInt(Count_Inscrit)) / int(mycommon.tryInt(nb_participant)),
2)
val['taux_remplissage'] = str(taux_remplissage)
"""
29/05/2024 : On va aller recuperer le nombre de personnes inscrites sur des devis non envoyés et non validés.
Ceci permet de connaitre le nombre potentiel d'inscription en attentes.
if( retVal['type_session'] == "0"):
Regles : Cela concerne uniquement les devis envoyés aux clients et prospects mais non validé
"""
"""
29/05/2024 : On va aller recuperer le nombre de personnes inscrites sur des devis non envoyés et non validés.
Ceci permet de connaitre le nombre potentiel d'inscription en attentes.
Regles : Cela concerne uniquement les devis envoyés aux clients et prospects mais non validé
"""
locl_find_qry = {
'$and': [{'partner_owner_recid': str(my_partner['recid']), 'valide': '1', 'locked': '0',
'order_header_type': 'devis', 'is_validated': '0',
'date_envoi_quotation': {"$exists": True}}, {}, ]}
locl_find_qry = {
'$and': [{'partner_owner_recid': str(my_partner['recid']), 'valide': '1', 'locked': '0',
'order_header_type': 'devis', 'is_validated': '0',
'date_envoi_quotation': {"$exists": True}}, {}, ]}
local_new_myquery_find_order = [{'$match': locl_find_qry},
{'$sort': {'_id': -1}},
{"$addFields": {"partner_order_header_Id": {"$toString": "$_id"}}},
{'$lookup':
local_new_myquery_find_order = [{'$match': locl_find_qry},
{'$sort': {'_id': -1}},
{"$addFields": {"partner_order_header_Id": {"$toString": "$_id"}}},
{'$lookup':
{
'from': 'partner_order_line',
'localField': "partner_order_header_Id",
'foreignField': 'order_header_id',
'pipeline': [
{'$match':
{'$and':
[
{'order_line_formation': str(
retVal['class_internal_url'])},
{'partner_owner_recid': str(
my_partner['recid']),
'order_line_session_id': str(retVal['_id'])},
{'valide': '1'}]}}, ],
'as': 'partner_order_line_collection'
}
},
{
'from': 'partner_order_line',
'localField': "partner_order_header_Id",
'foreignField': 'order_header_id',
'pipeline': [
{'$match':
{'$and':
[
{'order_line_formation': str(
retVal['class_internal_url'])},
{'partner_owner_recid': str(
my_partner['recid']),
'order_line_session_id': str(retVal['_id'])},
{'valide': '1'}]}}, ],
'as': 'partner_order_line_collection'
'$unwind': '$partner_order_line_collection'
}
},
{
'$unwind': '$partner_order_line_collection'
}
]
total_qty = 0
tab_quotation_ref = []
]
total_qty = 0
tab_quotation_ref = []
for local_New_retVal in MYSY_GV.dbname['partner_order_header'].aggregate(local_new_myquery_find_order):
# print(" ### local_New_retVal = ", local_New_retVal)
if ("partner_order_line_collection" in local_New_retVal.keys()):
if ("order_line_qty" in local_New_retVal['partner_order_line_collection'].keys() and
len(str(local_New_retVal['date_envoi_quotation'])) > 5):
total_qty = total_qty + mycommon.tryFloat(
local_New_retVal['partner_order_line_collection']['order_line_qty'])
tab_quotation_ref.append(str(local_New_retVal['order_header_ref_interne']))
for local_New_retVal in MYSY_GV.dbname['partner_order_header'].aggregate(local_new_myquery_find_order):
# print(" ### local_New_retVal = ", local_New_retVal)
if ("partner_order_line_collection" in local_New_retVal.keys()):
if ("order_line_qty" in local_New_retVal['partner_order_line_collection'].keys() and
len(str(local_New_retVal['date_envoi_quotation'])) > 5):
total_qty = total_qty + mycommon.tryFloat(
local_New_retVal['partner_order_line_collection']['order_line_qty'])
tab_quotation_ref.append(str(local_New_retVal['order_header_ref_interne']))
# print(" ### total_qty = ", total_qty)
# print(" ### tab_quotation_ref = ", tab_quotation_ref)
# print(" ### total_qty = ", total_qty)
# print(" ### tab_quotation_ref = ", tab_quotation_ref)
val['qty_in_quotation'] = str(total_qty)
val['qty_in_quotation_list_quotation'] = ', '.join(tab_quotation_ref)
val['qty_in_quotation'] = str(total_qty)
val['qty_in_quotation_list_quotation'] = ', '.join(tab_quotation_ref)
"""
Pour chaque session recuperer le statut de controle d'alert
"""
is_session_alert = ""
session_alert_message = ""
"""
Pour chaque session recuperer le statut de controle d'alert
"""
is_session_alert = ""
session_alert_message = ""
local_diction = {}
local_diction['token'] = str(diction['token'])
local_diction['session_id'] = str(retVal['_id'])
local_diction = {}
local_diction['token'] = str(diction['token'])
local_diction['session_id'] = str(retVal['_id'])
"""
25/06/2025 -
On ne fait le controle d'alerte que sur les session dont la date début < today - 5 jours jour ou > today + 30 jour
"""
"""
25/06/2025 -
On ne fait le controle d'alerte que sur les session dont la date début < today - 5 jours jour ou > today + 30 jour
"""
#print(" ### CMP de datetime.strptime(val['date_debut'], '%d/%m/%Y') = ", datetime.strptime(val['date_debut'], '%d/%m/%Y'))
#print(" ### CMP de mytoday_add_30j = ", mytoday_add_30j)
#print(" ### CMP de datetime.strptime(val['date_debut'], '%d/%m/%Y') = ", datetime.strptime(val['date_debut'], '%d/%m/%Y'))
#print(" ### CMP de mytoday_add_30j = ", mytoday_add_30j)
if( datetime.strptime(val['date_debut'], '%d/%m/%Y') < mytoday_add_30j and datetime.strptime(val['date_debut'], '%d/%m/%Y') > mytoday_minus_5j):
# On est dans l'interval de controle.
local_check_session_alert_status, local_check_session_alert_retval, local_check_session_alert_is_warning = mycommon.Check_Partner_Session_Alert(
local_diction)
if( datetime.strptime(val['date_debut'], '%d/%m/%Y') < mytoday_add_30j and datetime.strptime(val['date_debut'], '%d/%m/%Y') > mytoday_minus_5j):
# On est dans l'interval de controle.
local_check_session_alert_status, local_check_session_alert_retval, local_check_session_alert_is_warning = mycommon.Check_Partner_Session_Alert(
local_diction)
if (local_check_session_alert_status):
is_session_alert = local_check_session_alert_is_warning
session_alert_message = local_check_session_alert_retval
if (local_check_session_alert_status):
is_session_alert = local_check_session_alert_is_warning
session_alert_message = local_check_session_alert_retval
val['is_session_alert'] = is_session_alert
val['session_alert_message'] = session_alert_message
val['is_session_alert'] = is_session_alert
val['session_alert_message'] = session_alert_message
else:
val['qty_in_quotation'] = ""
val['qty_in_quotation_list_quotation'] = ""
val['is_session_alert'] = ""
val['session_alert_message'] = ""
RetObject.append(mycommon.JSONEncoder().encode(val))
@ -2320,23 +2396,43 @@ def GetAllValideSessionPartner_List_filter_like(diction):
filt_class_title = {}
filt_class_title_v2 = {}
tab_class_id = []
if ("class_title" in diction.keys()):
filt_class_title = {'title': {'$regex': mycommon.regex_replace_cartere(str(diction['class_title'])),"$options": "i"}}
for tmp in MYSY_GV.dbname['myclass'].find(filt_class_title, {'_id':1}):
if( str(tmp['_id']) not in tab_class_id ):
tab_class_id.append(str(tmp['_id']))
filt_class_id = {}
if ("class_id" in diction.keys()):
filt_class_title = {
'class_id': str(diction['class_id'])}
if ("class_id" in diction.keys() and diction['class_id']):
if( str(diction['class_id']) not in tab_class_id ):
tab_class_id.append(str(diction['class_id']))
filt_class_internal_url = {}
if ("class_internal_url" in diction.keys()):
filt_class_internal_url = {'internal_url': {'$regex': mycommon.regex_replace_cartere(str(diction['class_internal_url'])),"$options": "i"}}
for tmp in MYSY_GV.dbname['myclass'].find(filt_class_internal_url, {'_id':1}):
if( str(tmp['_id']) not in tab_class_id ):
tab_class_id.append(str(tmp['_id']))
filt_class_external_code = {}
if ("class_external_code" in diction.keys()):
filt_class_external_code = {'external_code': {'$regex': mycommon.regex_replace_cartere(str(diction['class_external_code'])), "$options": "i"}}
for tmp in MYSY_GV.dbname['myclass'].find(filt_class_external_code, {'_id':1}):
if( str(tmp['_id']) not in tab_class_id ):
tab_class_id.append(str(tmp['_id']))
if (len(tab_class_id) > 0):
filt_class_title_v2 = {'class_id': {'$in': tab_class_id}}
filt_code_session = {}
if ("code_session" in diction.keys()):
@ -2392,31 +2488,46 @@ def GetAllValideSessionPartner_List_filter_like(diction):
filt_scope_session_id['_id'] = {'$in':tab_session_id_ObjectId}
coll_session = MYSY_GV.dbname['session_formation']
query = [ {'$match':{ '$and' : [ filt_code_session,{'partner_owner_recid':str(my_partner['recid'])}, filt_scope_class_id, filt_scope_session_id,
filt_archive, filt_type_session, filt_class_id] }} ,
{'$sort': {'_id': -1}},
query2 = [{'$match':{ '$and' : [ filt_code_session,{'partner_owner_recid':str(my_partner['recid'])}, filt_scope_class_id, filt_scope_session_id,
filt_archive, filt_type_session, filt_class_title_v2] }},
{'$sort': {'_id': -1}},
{'$lookup':
{
'from': 'myclass',
'localField': 'class_internal_url',
'foreignField': 'internal_url',
'pipeline': [{'$match': { '$and' : [ filt_class_title, filt_class_internal_url, filt_class_external_code, {'partner_owner_recid':str(my_partner['recid'])} ]} }, {'$project': {'title': 1, 'domaine':1,
'duration':1, 'duration_unit':1, 'external_code':1,
'recyclage_delai':1, '_id':1,
'recyclage_periodicite':1,
'lms_class_code':1}}],
'let': {'class_id': "$class_id", 'partner_owner_recid': '$partner_owner_recid'},
'pipeline': [
{'$match':
{'$expr':
{'$and':
[
{'$eq': ["$_id", {'$convert': {
'input': "$$class_id",
'to': "objectId",
'onError': {'error': 'true'},
'onNull': {'isnull': 'true'}
}}]},
{'$eq': ["$valide", "1"]},
{'$eq': ["$partner_owner_recid", '$$partner_owner_recid']},
]
}
}
},
],
'as': 'myclass_collection'
}
}
},
]
#print("#### GetAllValideSessionPartner_List_filter_likequery = ", query)
print("#### GetAllValideSessionPartner_List_filter_likequery22 = ", query2)
RetObject = []
cpt = 0
for retVal in MYSY_GV.dbname['session_formation'].aggregate(query):
for retVal in MYSY_GV.dbname['session_formation'].aggregate(query2):
if( 'myclass_collection' in retVal.keys() and len(retVal['myclass_collection']) > 0 ):
val = {}
@ -2617,82 +2728,87 @@ def GetAllValideSessionPartner_List_filter_like(diction):
val['taux_remplissage'] = str(taux_remplissage)
"""
29/05/2024 : On va aller recuperer le nombre de personnes inscrites sur des devis non envoyés et non validés.
Ceci permet de connaitre le nombre potentiel d'inscription en attentes.
if( retVal["type_session"] == "0"):
"""
29/05/2024 : On va aller recuperer le nombre de personnes inscrites sur des devis non envoyés et non validés.
Ceci permet de connaitre le nombre potentiel d'inscription en attentes.
Regles : Cela concerne uniquement les devis envoyés aux clients et prospects mais non validé
"""
Regles : Cela concerne uniquement les devis envoyés aux clients et prospects mais non validé
locl_find_qry = {
'$and': [{'partner_owner_recid': str(my_partner['recid']), 'valide': '1', 'locked': '0',
'order_header_type': 'devis', 'is_validated': '0',
'date_envoi_quotation': {"$exists": True}}, {}, ]}
"""
locl_find_qry = {
'$and': [{'partner_owner_recid': str(my_partner['recid']), 'valide': '1', 'locked': '0',
'order_header_type': 'devis', 'is_validated': '0',
'date_envoi_quotation': {"$exists": True}}, {}, ]}
local_new_myquery_find_order = [{'$match': locl_find_qry},
{'$sort': {'_id': -1}},
{"$addFields": {"partner_order_header_Id": {"$toString": "$_id"}}},
{'$lookup':
local_new_myquery_find_order = [{'$match': locl_find_qry},
{'$sort': {'_id': -1}},
{"$addFields": {"partner_order_header_Id": {"$toString": "$_id"}}},
{'$lookup':
{
'from': 'partner_order_line',
'localField': "partner_order_header_Id",
'foreignField': 'order_header_id',
'pipeline': [
{'$match':
{'$and':
[
{'order_line_formation': str(
retVal['class_internal_url'])},
{'partner_owner_recid': str(
my_partner['recid']),
'order_line_session_id': str(retVal['_id'])},
{'valide': '1'}]}}, ],
'as': 'partner_order_line_collection'
}
},
{
'from': 'partner_order_line',
'localField': "partner_order_header_Id",
'foreignField': 'order_header_id',
'pipeline': [
{'$match':
{'$and':
[
{'order_line_formation': str(
retVal['class_internal_url'])},
{'partner_owner_recid': str(
my_partner['recid']),
'order_line_session_id': str(retVal['_id'])},
{'valide': '1'}]}}, ],
'as': 'partner_order_line_collection'
'$unwind': '$partner_order_line_collection'
}
},
{
'$unwind': '$partner_order_line_collection'
}
]
total_qty = 0
tab_quotation_ref = []
]
total_qty = 0
tab_quotation_ref = []
for local_New_retVal in MYSY_GV.dbname['partner_order_header'].aggregate(local_new_myquery_find_order):
# print(" ### local_New_retVal = ", local_New_retVal)
if ("partner_order_line_collection" in local_New_retVal.keys()):
if ("order_line_qty" in local_New_retVal['partner_order_line_collection'].keys() and
len(str(local_New_retVal['date_envoi_quotation'])) > 5):
total_qty = total_qty + mycommon.tryFloat(
local_New_retVal['partner_order_line_collection']['order_line_qty'])
tab_quotation_ref.append(str(local_New_retVal['order_header_ref_interne']))
for local_New_retVal in MYSY_GV.dbname['partner_order_header'].aggregate(local_new_myquery_find_order):
# print(" ### local_New_retVal = ", local_New_retVal)
if ("partner_order_line_collection" in local_New_retVal.keys()):
if ("order_line_qty" in local_New_retVal['partner_order_line_collection'].keys() and
len(str(local_New_retVal['date_envoi_quotation'])) > 5):
total_qty = total_qty + mycommon.tryFloat(
local_New_retVal['partner_order_line_collection']['order_line_qty'])
tab_quotation_ref.append(str(local_New_retVal['order_header_ref_interne']))
# print(" ### total_qty = ", total_qty)
# print(" ### tab_quotation_ref = ", tab_quotation_ref)
# print(" ### total_qty = ", total_qty)
# print(" ### tab_quotation_ref = ", tab_quotation_ref)
val['qty_in_quotation'] = str(total_qty)
val['qty_in_quotation_list_quotation'] = ', '.join(tab_quotation_ref)
val['qty_in_quotation'] = str(total_qty)
val['qty_in_quotation_list_quotation'] = ', '.join(tab_quotation_ref)
"""
Pour chaque session recuperer le statut de controle d'alert
"""
is_session_alert = ""
session_alert_message = ""
"""
Pour chaque session recuperer le statut de controle d'alert
"""
is_session_alert = ""
session_alert_message = ""
local_diction = {}
local_diction['token'] = str(diction['token'])
local_diction['session_id'] = str(retVal['_id'])
local_diction = {}
local_diction['token'] = str(diction['token'])
local_diction['session_id'] = str(retVal['_id'])
local_check_session_alert_status, local_check_session_alert_retval, local_check_session_alert_is_warning = mycommon.Check_Partner_Session_Alert(
local_diction)
local_check_session_alert_status, local_check_session_alert_retval, local_check_session_alert_is_warning = mycommon.Check_Partner_Session_Alert(
local_diction)
if (local_check_session_alert_status):
is_session_alert = local_check_session_alert_is_warning
session_alert_message = local_check_session_alert_retval
val['is_session_alert'] = is_session_alert
val['session_alert_message'] = session_alert_message
if (local_check_session_alert_status):
is_session_alert = local_check_session_alert_is_warning
session_alert_message = local_check_session_alert_retval
val['is_session_alert'] = is_session_alert
val['session_alert_message'] = session_alert_message
else:
val['qty_in_quotation'] = ""
val['qty_in_quotation_list_quotation'] = ""
val['is_session_alert'] = ""
val['session_alert_message'] = ""
if (filt_session_start_date and filt_session_end_date):
@ -2720,10 +2836,10 @@ def GetAllValideSessionPartner_List_filter_like(diction):
str(filt_session_end_date).strip(), '%d/%m/%Y'))):
RetObject.append(mycommon.JSONEncoder().encode(val))
else:
RetObject.append(mycommon.JSONEncoder().encode(val))
return True, RetObject
@ -2801,10 +2917,44 @@ def GetAllValideSessionPartner_List_no_filter(diction):
}
]
#print("#### GetAllValideSessionPartner_List_filter_likequery = ", query)
query2 = [{'$match':{"$and": [{'partner_owner_recid': str(my_partner['recid'])}, filt_archive, filt_type_session]} },
{'$sort': {'_id': -1}},
{'$lookup':
{
'from': 'myclass',
'let': {'class_id': "$class_id", 'partner_owner_recid': '$partner_owner_recid'},
'pipeline': [
{'$match':
{'$expr':
{'$and':
[
{'$eq': ["$_id", {'$convert': {
'input': "$$class_id",
'to': "objectId",
'onError': {'error': 'true'},
'onNull': {'isnull': 'true'}
}}]},
{'$eq': ["$valide", "1"]},
{'$eq': ["$partner_owner_recid", '$$partner_owner_recid']},
]
}
}
},
],
'as': 'myclass_collection'
}
},
]
#print("#### GetAllValideSessionPartner_List_filter_likequery = ", query2)
RetObject = []
cpt = 0
for retVal in MYSY_GV.dbname['session_formation'].aggregate(query):
for retVal in MYSY_GV.dbname['session_formation'].aggregate(query2):
if( 'myclass_collection' in retVal.keys() and len(retVal['myclass_collection']) > 0 ):
val = {}
val['id'] = str(cpt)
@ -2985,61 +3135,69 @@ def GetAllValideSessionPartner_List_no_filter(diction):
val['taux_remplissage'] = str(taux_remplissage)
"""
29/05/2024 : On va aller recuperer le nombre de personnes inscrites sur des devis non envoyés et non validés.
Ceci permet de connaitre le nombre potentiel d'inscription en attentes.
if( retVal["type_session"] == "0"):
Regles : Cela concerne uniquement les devis envoyés aux clients et prospects mais non validé
"""
29/05/2024 : On va aller recuperer le nombre de personnes inscrites sur des devis non envoyés et non validés.
Ceci permet de connaitre le nombre potentiel d'inscription en attentes.
Regles : Cela concerne uniquement les devis envoyés aux clients et prospects mais non validé
"""
"""
locl_find_qry = {
'$and': [{'partner_owner_recid': str(my_partner['recid']), 'valide': '1', 'locked': '0',
'order_header_type': 'devis', 'is_validated': '0',
'date_envoi_quotation': {"$exists": True}}, {}, ]}
locl_find_qry = {
'$and': [{'partner_owner_recid': str(my_partner['recid']), 'valide': '1', 'locked': '0',
'order_header_type': 'devis', 'is_validated': '0',
'date_envoi_quotation': {"$exists": True}}, {}, ]}
local_new_myquery_find_order = [{'$match': locl_find_qry},
{'$sort': {'_id': -1}},
{"$addFields": {"partner_order_header_Id": {"$toString": "$_id"}}},
{'$lookup':
local_new_myquery_find_order = [{'$match': locl_find_qry},
{'$sort': {'_id': -1}},
{"$addFields": {"partner_order_header_Id": {"$toString": "$_id"}}},
{'$lookup':
{
'from': 'partner_order_line',
'localField': "partner_order_header_Id",
'foreignField': 'order_header_id',
'pipeline': [
{'$match':
{'$and':
[
{'order_line_formation': str(
retVal['class_internal_url'])},
{'partner_owner_recid': str(
my_partner['recid']),
'order_line_session_id': str(retVal['_id'])},
{'valide': '1'}]}}, ],
'as': 'partner_order_line_collection'
}
},
{
'from': 'partner_order_line',
'localField': "partner_order_header_Id",
'foreignField': 'order_header_id',
'pipeline': [
{'$match':
{'$and':
[
{'order_line_formation': str(
retVal['class_internal_url'])},
{'partner_owner_recid': str(
my_partner['recid']),
'order_line_session_id': str(retVal['_id'])},
{'valide': '1'}]}}, ],
'as': 'partner_order_line_collection'
'$unwind': '$partner_order_line_collection'
}
},
{
'$unwind': '$partner_order_line_collection'
}
]
total_qty = 0
tab_quotation_ref = []
]
total_qty = 0
tab_quotation_ref = []
for local_New_retVal in MYSY_GV.dbname['partner_order_header'].aggregate(local_new_myquery_find_order):
# print(" ### local_New_retVal = ", local_New_retVal)
if ("partner_order_line_collection" in local_New_retVal.keys()):
if ("order_line_qty" in local_New_retVal['partner_order_line_collection'].keys() and
len(str(local_New_retVal['date_envoi_quotation'])) > 5):
total_qty = total_qty + mycommon.tryFloat(
local_New_retVal['partner_order_line_collection']['order_line_qty'])
tab_quotation_ref.append(str(local_New_retVal['order_header_ref_interne']))
for local_New_retVal in MYSY_GV.dbname['partner_order_header'].aggregate(local_new_myquery_find_order):
# print(" ### local_New_retVal = ", local_New_retVal)
if ("partner_order_line_collection" in local_New_retVal.keys()):
if ("order_line_qty" in local_New_retVal['partner_order_line_collection'].keys() and
len(str(local_New_retVal['date_envoi_quotation'])) > 5):
total_qty = total_qty + mycommon.tryFloat(
local_New_retVal['partner_order_line_collection']['order_line_qty'])
tab_quotation_ref.append(str(local_New_retVal['order_header_ref_interne']))
# print(" ### total_qty = ", total_qty)
# print(" ### tab_quotation_ref = ", tab_quotation_ref)
# print(" ### total_qty = ", total_qty)
# print(" ### tab_quotation_ref = ", tab_quotation_ref)
val['qty_in_quotation'] = str(total_qty)
val['qty_in_quotation_list_quotation'] = ', '.join(tab_quotation_ref)
val['qty_in_quotation'] = str(total_qty)
val['qty_in_quotation_list_quotation'] = ', '.join(tab_quotation_ref)
else:
val['qty_in_quotation'] = ""
val['qty_in_quotation_list_quotation'] = ""
val['is_session_alert'] = ""
val['session_alert_message'] = ""
RetObject.append(mycommon.JSONEncoder().encode(val))

View File

@ -8119,6 +8119,8 @@ def Add_Update_UE_To_Class(diction):
"""
Cette fonction permet de supprimer une UE d'une formation.
Important : : Pour rappel, on est en mode nested json sur la collection myclass
il faut supprimer cette UE de la collectio : class_unite_enseignement_type_evaluation pour cette formation
"""
def Delete_UE_From_Class(diction):
try:
@ -8203,6 +8205,14 @@ def Delete_UE_From_Class(diction):
return False, " L'identifiant de la formation est invalide "
"""
Suppression d'une eventuelle ligne de la collection : class_unite_enseignement_type_evaluation pour la formation
"""
MYSY_GV.dbname['class_unite_enseignement_type_evaluation'].delete_one({'class_id':diction['class_id'],
'class_ue_id':diction['ue_id']})
is_class_exist_data = MYSY_GV.dbname['myclass'].find_one(
{'partner_owner_recid': my_partner['recid'],
'valide': '1',

View File

@ -726,10 +726,14 @@ def Get_List_Class_Evaluation(diction):
RetObject = []
val_tmp = 0
for retval in MYSY_GV.dbname['class_unite_enseignement_type_evaluation'].find(data_cle).sort([("_id", pymongo.DESCENDING), ]):
for retval in MYSY_GV.dbname['class_unite_enseignement_type_evaluation'].find(data_cle).sort([("_id", pymongo.ASCENDING), ]):
user = retval
user['id'] = str(val_tmp)
is_valide_type_eval = ""
is_valide_ue = ""
type_evaluation_code = ""
if( "type_evaluation_id" in retval.keys() and retval['type_evaluation_id']):
type_evaluation_data = MYSY_GV.dbname['type_evaluation'].find_one({'_id':ObjectId(str(retval['type_evaluation_id'])),
@ -739,11 +743,22 @@ def Get_List_Class_Evaluation(diction):
if( type_evaluation_data and 'code' in type_evaluation_data.keys() ):
type_evaluation_code= type_evaluation_data['code']
is_valide_type_eval = "1"
user['type_evaluation_code'] = type_evaluation_code
class_ue_code = ""
if ("class_ue_id" in retval.keys() and retval['class_ue_id']):
"""
Verifier que l'UE en question est bien rattaché à cette formation
myclass.list_unite_enseignement
"""
is_valide_ue_for_class_count = MYSY_GV.dbname['myclass'].count_documents({'_id':ObjectId(retval['class_id']), 'list_unite_enseignement._id':str(retval['class_ue_id']),
'partner_owner_recid':str(my_partner['recid'])})
if ("class_ue_id" in retval.keys() and retval['class_ue_id'] and is_valide_ue_for_class_count > 0 ):
class_ue_data = MYSY_GV.dbname['unite_enseignement'].find_one(
{'_id': ObjectId(str(retval['class_ue_id'])),
'valide': '1',
@ -752,22 +767,24 @@ def Get_List_Class_Evaluation(diction):
if (class_ue_data and 'code' in class_ue_data.keys()):
class_ue_code = class_ue_data['code']
is_valide_ue = "1"
user['class_ue_code'] = class_ue_code
if( is_valide_type_eval == "1" and is_valide_ue == "1"):
user['class_ue_code'] = class_ue_code
if("ponderation_type_eval" not in user.keys()):
user['ponderation_type_eval'] = "1"
if("ponderation_type_eval" not in user.keys()):
user['ponderation_type_eval'] = "1"
if ("type_notation" not in user.keys()):
user['type_notation'] = "num"
if ("type_notation" not in user.keys()):
user['type_notation'] = "num"
if ("max_note" not in user.keys()):
user['max_note'] = "20"
if ("max_note" not in user.keys()):
user['max_note'] = "20"
val_tmp = val_tmp + 1
val_tmp = val_tmp + 1
RetObject.append(mycommon.JSONEncoder().encode(user))
RetObject.append(mycommon.JSONEncoder().encode(user))
return True, RetObject