22/04/2024 - 17h30

master
cherif 2024-04-22 17:30:27 +02:00
parent 8cc1075ba9
commit 21d17d11d6
7 changed files with 9785 additions and 43 deletions

View File

@ -1,12 +1,13 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ChangeListManager">
<list default="true" id="c6d0259a-16e1-410d-91a1-830590ee2a08" name="Changes" comment="20/04/2024 - 20h44">
<list default="true" id="c6d0259a-16e1-410d-91a1-830590ee2a08" name="Changes" comment="sss">
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/E_Sign_Document.py" beforeDir="false" afterPath="$PROJECT_DIR$/E_Sign_Document.py" 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$/Session_Formation.py" beforeDir="false" afterPath="$PROJECT_DIR$/Session_Formation.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/main.py" beforeDir="false" afterPath="$PROJECT_DIR$/main.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/attached_file_mgt.py" beforeDir="false" afterPath="$PROJECT_DIR$/attached_file_mgt.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/partner_order.py" beforeDir="false" afterPath="$PROJECT_DIR$/partner_order.py" afterDir="false" />
</list>
<option name="SHOW_DIALOG" value="false" />
@ -77,13 +78,6 @@
<option name="presentableId" value="Default" />
<updated>1680804787304</updated>
</task>
<task id="LOCAL-00225" summary="23/02/2024 - 22h30">
<created>1708724600232</created>
<option name="number" value="00225" />
<option name="presentableId" value="LOCAL-00225" />
<option name="project" value="LOCAL" />
<updated>1708724600233</updated>
</task>
<task id="LOCAL-00226" summary="24/02/2024 - 22h30">
<created>1708808985842</created>
<option name="number" value="00226" />
@ -420,7 +414,14 @@
<option name="project" value="LOCAL" />
<updated>1713638681959</updated>
</task>
<option name="localTasksCounter" value="274" />
<task id="LOCAL-00274" summary="sss">
<created>1713719597944</created>
<option name="number" value="00274" />
<option name="presentableId" value="LOCAL-00274" />
<option name="project" value="LOCAL" />
<updated>1713719597944</updated>
</task>
<option name="localTasksCounter" value="275" />
<servers />
</component>
<component name="Vcs.Log.Tabs.Properties">
@ -462,7 +463,6 @@
</option>
</component>
<component name="VcsManagerConfiguration">
<MESSAGE value="20/03/2024 - 22h30dss" />
<MESSAGE value="25/03/2024 - 18h30" />
<MESSAGE value="26/03/2024 - 21h30" />
<MESSAGE value="fff" />
@ -487,6 +487,7 @@
<MESSAGE value="19/04/2024 - 22h22" />
<MESSAGE value="20/04/2024 - 13h" />
<MESSAGE value="20/04/2024 - 20h44" />
<option name="LAST_COMMIT_MESSAGE" value="20/04/2024 - 20h44" />
<MESSAGE value="sss" />
<option name="LAST_COMMIT_MESSAGE" value="sss" />
</component>
</project>

View File

@ -48,6 +48,8 @@ import json
from bson import ObjectId
import re
from datetime import datetime, time
import partner_order
import prj_common as mycommon
import secrets
import inspect
@ -107,7 +109,7 @@ def Create_E_Document(diction):
Verification des input acceptés
"""
field_list = ['token', 'file_name', 'related_collection', 'related_collection_id',
'email_destinataire', 'source_document']
'email_destinataire', 'source_document', 'type']
incom_keys = diction.keys()
for val in incom_keys:
@ -180,6 +182,11 @@ def Create_E_Document(diction):
new_diction['update_by'] = str(my_partner['_id'])
new_diction['created_by'] = str(my_partner['_id'])
if( "type" in diction.keys() ):
new_diction['type'] = str(diction['type'])
else:
new_diction['type'] = ""
val = MYSY_GV.dbname['e_document_signe'].insert_one(new_diction)
@ -590,6 +597,12 @@ def Create_E_Signature_For_E_Document(file_img=None, Folder=None, diction=None):
return False, " L'idientifiant du E-Document est invalide "
e_document_data = MYSY_GV.dbname['e_document_signe'].find_one(qry)
e_docment_type = ""
if( "type" in e_document_data.keys() and e_document_data['type']):
e_docment_type = e_document_data['type']
local_signature_digitale = ""
if ("email_destinataire" in e_document_data.keys() and e_document_data['email_destinataire']):
list_email = str(e_document_data['email_destinataire']).replace(",", ";")
@ -650,9 +663,6 @@ def Create_E_Signature_For_E_Document(file_img=None, Folder=None, diction=None):
'secret_key_signature': str(diction['secret_key_signature']),
'email_destinataire': str(diction['email_destinataire'])}
print(" ### new_data = ", new_data)
print(" ### qry_key = ", qry_key)
result = MYSY_GV.dbname['e_document_signe'].find_one_and_update(
qry_key,
@ -772,10 +782,15 @@ def Create_E_Signature_For_E_Document(file_img=None, Folder=None, diction=None):
sourceHtml = contenu_doc_Template.render(params=body["params"])
todays_date = str(datetime.today().strftime("%d_%m_%Y"))
ts = datetime.now().timestamp()
ts = str(ts).replace(".", "").replace(",", "")[-5:]
ts = str(ts).replace(".", "").replace(",", "")[-2:]
if (str(e_docment_type).strip() != ""):
orig_file_name = str(e_docment_type).strip()+"_Signe_" + str(todays_date)+"_"+str(ts) + ".pdf"
else:
orig_file_name = "Document_Signe_" + str(todays_date)+"_"+str(ts) + ".pdf"
orig_file_name = "Convention_Signe_" + str(ts) + ".pdf"
outputFilename = str(MYSY_GV.TEMPORARY_DIRECTORY) + "/" + str(orig_file_name)
# open output file for writing (truncated binary)
@ -977,7 +992,10 @@ def Create_E_Signature_For_E_Document(file_img=None, Folder=None, diction=None):
msg.attach(html_mime)
msg['From'] = partner_SMTP_COUNT_From_User
msg['Bcc'] = 'contact@mysy-training.com'
msg['Subject'] = " Votre Convention Signée "
if( str(e_docment_type).strip() != ""):
msg['Subject'] = " Votre Document "+str(e_docment_type)+" Signé "
else :
msg['Subject'] = " Votre Document Signé "
msg['cc'] = user_created_e_document['email']
msg['to'] = str(diction['email_destinataire'])
@ -993,7 +1011,10 @@ def Create_E_Signature_For_E_Document(file_img=None, Folder=None, diction=None):
msg.attach(html_mime)
msg['From'] = MYSY_GV.O365_SMTP_COUNT_From_User
msg['Bcc'] = 'contact@mysy-training.com'
msg['Subject'] = " Votre Convention Signée"
if (str(e_docment_type).strip() != ""):
msg['Subject'] = " Votre Document " + str(e_docment_type) + " Signé "
else:
msg['Subject'] = " Votre Document Signé "
msg['cc'] = user_created_e_document['email']
msg['to'] = msg['to'] = str(diction['email_destinataire'])
@ -1009,30 +1030,107 @@ def Create_E_Signature_For_E_Document(file_img=None, Folder=None, diction=None):
smtpserver.close()
print(" Email envoyé " + str(val))
"""
Recuperer les données du client associé à la quotation
"""
quotation_client_data = None
if(e_document_date_2['related_collection'] == "quotation" ):
qry = {'partner_owner_recid':local_partner_owner_recid,
'_id':ObjectId(str(e_document_date_2['related_collection_id'])),
'valide':'1',
'locked':'0'}
print(" ### qry = ", qry)
quotation_data = MYSY_GV.dbname['partner_order_header'].find_one({'partner_owner_recid':local_partner_owner_recid,
'_id':ObjectId(str(e_document_date_2['related_collection_id'])),
'valide':'1',
'locked':'0'})
if( quotation_data is None ):
mycommon.myprint(
str(inspect.stack()[0][3]) + " L'identifiant du devis n'est pas valide ")
return False, " L'identifiant du devis n'est pas valide "
qry2 = {'partner_recid': local_partner_owner_recid,
'_id': ObjectId(str(quotation_data['order_header_client_id'])),
'valide': '1',
'locked': '0'}
print(" ### qry2 = ", qry2)
quotation_client_data = None
quotation_client_data = MYSY_GV.dbname['partner_client'].find_one(
{'partner_recid': local_partner_owner_recid,
'_id': ObjectId(str(quotation_data['order_header_client_id'])),
'valide': '1',
'locked': '0'})
if (quotation_client_data is None):
mycommon.myprint(
str(inspect.stack()[0][3]) + " Le client associé au devis n'est pas valide ")
return False, " Le client associé au devis n'est pas valide "
"""
Le fichier est envoyé par email, il faudrait à present le stocker
le fichier dans l'espace documentaire du client
-field_list = ['token', 'file_business_object', 'file_name', 'status','object_owner_collection', 'object_owner_id']
"""
ts = datetime.now().timestamp()
ts = str(ts).replace(".", "").replace(",", "")[-3:]
todays_date = str(datetime.today().strftime("%d%m%Y"))
new_file = {}
new_file['token'] = temp_admin_account['token']
new_file['file_business_object'] = "e_Convention_signe_"+str(ts)
if (str(e_docment_type).strip() != ""):
new_file['file_business_object'] = "e_"+str(e_docment_type)+"_signe_" + str(todays_date)
else:
new_file['file_business_object'] = "e_Document_signe_" + str(todays_date)
new_file['file_name'] = str(orig_file_name)
new_file['status'] = "1"
new_file['object_owner_collection'] = e_document_date_2['related_collection']
new_file['object_owner_id'] = e_document_date_2['related_collection_id']
if( e_document_date_2['related_collection'] == "quotation"):
new_file['object_owner_collection'] = "partner_client"
new_file['object_owner_id'] = str(quotation_client_data['_id'])
else:
new_file['object_owner_collection'] = e_document_date_2['related_collection']
new_file['object_owner_id'] = e_document_date_2['related_collection_id']
new_file['file_name_to_store'] = outputFilename
print(" new_file == ", new_file)
#print(" ### new_file new_file = ", new_file)
local_status, local_retval = attached_file_mgt.Internal_Usage_Store_User_Downloaded_File(MYSY_GV.upload_folder, new_file)
if( local_status is False ):
print(" ## WARNONGGG Impossible de stocker le fichier")
"""
Si il s'agit d'un devis, alors on procede a la resevation des places
"""
if (str(e_docment_type).strip() == "quotation"):
"""
Recuperer les données de la quotation
"""
new_local_diction = {}
new_local_diction['partner_owner_recid'] = str(e_document_data['partner_owner_recid'])
new_local_diction['quotation_id'] = str(e_document_data['related_collection_id'])
new_local_diction['request_digital_signature'] = "0"
local_status, local_retval = partner_order.Insert_Quotation_To_Session_From_Partner_Owner_Recid(new_local_diction)
if( local_status is False ):
print(" ## WARNONGGG Impossible deInsert_Quotation_To_Session_From_Partner_Owner_Recid ")
return True, " Le document a été correction signé. Vous allez recevoir le document par email"
except Exception as e:
@ -1104,6 +1202,8 @@ def Sent_E_Document_Signature_Request(diction):
e_document_open_code = ""
e_document_data = {}
e_document_type = ""
for New_retVal in MYSY_GV.dbname['e_document_signe'].find(qry).sort([("_id", pymongo.DESCENDING), ]):
if ("email_destinataire" in New_retVal.keys() and New_retVal['email_destinataire']):
list_email = str(New_retVal['email_destinataire']).replace(",", ";")
@ -1113,6 +1213,9 @@ def Sent_E_Document_Signature_Request(diction):
e_document_data = New_retVal
e_document_open_code = New_retVal['secret_key_open']
if('type' in New_retVal.keys() and New_retVal['type']):
e_document_type = New_retVal['type']
if( is_e_document_valide == "0" ):
mycommon.myprint(
str(inspect.stack()[0][3]) + " L'adresse email du destinataire n'est pas autorisée ")
@ -1120,7 +1223,7 @@ def Sent_E_Document_Signature_Request(diction):
"""
Si le document est valide, alors on envoie la demande de signture
Si le document est valide, alors on envoie la demande de signature
"""
url_signature = MYSY_GV.CLIENT_URL_BASE+"E_Signature/"+str(e_document_data['_id'])
@ -1266,7 +1369,10 @@ def Sent_E_Document_Signature_Request(diction):
msg.attach(html_mime)
msg['From'] = partner_SMTP_COUNT_From_User
msg['Bcc'] = 'contact@mysy-training.com'
msg['Subject'] = " Demande signature électronique document"
if( str(e_document_type).strip() != "" ):
msg['Subject'] = str(e_document_type)+" : Demande signature électronique document"
else:
msg['Subject'] = " Demande signature électronique document"
# msg['to'] = "billardman01@hotmail.com"
msg['to'] = str(diction['user_email'])

View File

@ -9779,7 +9779,7 @@ def Sent_Convention_Stagiaire_By_Email_By_Partner_client(tab_files_name_full_pat
return False, " Aucune adresse email n'a été fourni. "
print(" ## laaa : tab_emails_destinataire lalala = ", tab_emails_destinataire)
#print(" ## laaa : tab_emails_destinataire lalala = ", tab_emails_destinataire)
# Verifier que le 'courrier_template_id' est valide
# Ici le template doit etre un email
@ -9853,7 +9853,7 @@ def Sent_Convention_Stagiaire_By_Email_By_Partner_client(tab_files_name_full_pat
tab_apprenant.append(ObjectId(str(val['apprenant_id'])))
print(" ### tab_participant = ", tab_participant)
#print(" ### tab_participant = ", tab_participant)
# Recuperations des info de la session de formation
session_data = MYSY_GV.dbname['session_formation'].find_one({'_id': ObjectId(str(diction['session_id']))})
@ -9899,7 +9899,7 @@ def Sent_Convention_Stagiaire_By_Email_By_Partner_client(tab_files_name_full_pat
convention_dictionnary_data = local_retval
print(" ")
## Creation du PDF
body = {

File diff suppressed because one or more lines are too long

View File

@ -4337,7 +4337,7 @@ def Prepare_and_Send_Convention_From_Session_By_Email(tab_files, Folder, diction
new_diction_client['request_digital_signature'] = diction['request_digital_signature']
print(" ##### new_diction_client 0102 = ", new_diction_client)
#print(" ##### new_diction_client 0102 = ", new_diction_client)
local_status, local_retval = Inscription_mgt.Sent_Convention_Stagiaire_By_Email_By_Partner_client(tab_saved_file_full_path, Folder, new_diction_client)

View File

@ -281,8 +281,6 @@ def Internal_Usage_Store_User_Downloaded_File(Folder=None, diction=None):
if diction['document_display_order']:
document_display_order = diction['document_display_order']
mydata = {}
mydata['file_business_object'] = file_business_object
mydata['date_update'] = str(datetime.now())
@ -300,6 +298,7 @@ def Internal_Usage_Store_User_Downloaded_File(Folder=None, diction=None):
'object_owner_collection':str(object_owner_collection),
'object_owner_id':str(object_owner_id),
'partner_owner_recid': str(my_partner['recid']),
'file_name':str(partial_file_name_without_folder),
'valide': '1'},
{"$set": mydata},
upsert=True,

View File

@ -11,14 +11,17 @@ order_header et order_lines comme suit :
order {order_header_ref:'xxx', order_header_amount:'yyyy', order_line[ {order_line1}, {order_line2}, ....,{}] }
"""
import ast
import bson
import pymongo
from pymongo import MongoClient
import json
from bson import ObjectId
import re
from datetime import datetime
from datetime import datetime, date
import E_Sign_Document
import Inscription_mgt
import prj_common as mycommon
import secrets
@ -4319,7 +4322,7 @@ def GerneratePDF_Partner_Order(diction):
# Verification de la validité de l'order
qry = {'_id': ObjectId(str(diction['order_id'])), 'valide': '1', 'locked': '0',
'partner_owner_recid': str(my_partner['recid'])}
print(" ### qry = ", qry)
#print(" ### qry = ", qry)
is_Order_Existe_Count = MYSY_GV.dbname['partner_order_header'].count_documents(
{'_id': ObjectId(str(diction['order_id'])),
@ -4547,12 +4550,271 @@ def GerneratePDF_Partner_Order(diction):
return False, False
"""
Cette fonction créer un fichier PDF, stock le fichier en local et retour le nom complet du fichier
"""
def Gernerate_Stock_PDF_Partner_Order(diction):
try:
field_list = ['order_id', 'token', ]
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]) + " - La valeur '" + val + "' n'est pas presente dans liste ")
return False, " Les informations fournies sont incorrectes", False
"""
Verification de la liste des champs obligatoires
"""
field_list_obligatoire = ['order_id', '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", False
query_get_data = {}
mytoken = ""
if ("token" in diction.keys()):
if diction['token']:
mytoken = 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, False
# Verification de la validité de l'order
qry = {'_id': ObjectId(str(diction['order_id'])), 'valide': '1', 'locked': '0',
'partner_owner_recid': str(my_partner['recid'])}
#print(" ### qry = ", qry)
is_Order_Existe_Count = MYSY_GV.dbname['partner_order_header'].count_documents(
{'_id': ObjectId(str(diction['order_id'])),
'valide': '1', 'locked': '0',
'partner_owner_recid': str(my_partner['recid'])})
if (is_Order_Existe_Count != 1):
mycommon.myprint(
str(inspect.stack()[0][3]) + " - La commande n'est pas valide ")
return False, " La commande n'est pas valide", False
Order_header_data = MYSY_GV.dbname['partner_order_header'].find_one({'_id': ObjectId(str(diction['order_id'])),
'valide': '1', 'locked': '0',
'partner_owner_recid': str(
my_partner['recid'])})
partner_document_CONF_ORDER_data_qry = {'partner_owner_recid': str(my_partner['recid']),
'valide': '1', 'locked': '0', 'ref_interne': 'PART_ORDER', 'type_doc':'pdf'}
print(" ### partner_document_CONF_ORDER_data_qry = ", partner_document_CONF_ORDER_data_qry)
partner_document_CONF_ORDER_data = MYSY_GV.dbname['courrier_template'].find_one(
{'partner_owner_recid': str(my_partner['recid']),
'valide': '1', 'locked': '0', 'ref_interne': 'PART_ORDER', 'type_doc':'pdf'})
if (partner_document_CONF_ORDER_data is None):
# Il n'existe pas de personnalisation de la preinscription pour ce partenaire, on va aller récupérer la presinscription pa defaut
partner_document_CONF_ORDER_data = MYSY_GV.dbname['courrier_template'].find_one(
{'partner_owner_recid': 'default',
'valide': '1', 'locked': '0', 'ref_interne': 'PART_ORDER', 'type_doc':'pdf'})
if (partner_document_CONF_ORDER_data is None):
mycommon.myprint(
str(inspect.stack()[0][
3]) + "Aucun document paramétré ")
return False, "Aucun document paramétré ", False
if ("contenu_doc" not in partner_document_CONF_ORDER_data or len(
str(partner_document_CONF_ORDER_data['contenu_doc'])) <= 0):
mycommon.myprint(str(inspect.stack()[0][
3]) + " - Le parametrage du document est invalide")
return False, " Le parametrage du document est invalide "
# Recuperation des données du client
if ("order_header_client_id" in Order_header_data.keys()):
Order_header_client_data = MYSY_GV.dbname['partner_client'].find_one(
{'_id': ObjectId(str(Order_header_data['order_header_client_id'])),
'partner_recid': str(my_partner['recid']), 'valide': '1', 'locked': '0'})
if (Order_header_client_data is None):
mycommon.myprint(str(inspect.stack()[0][
3]) + " - Le client est invalide")
return False, " Le client est invalide", False
### Ajout des données du client sur l'entete de la commande, exemple : le nom, email, etc
if("raison_sociale" in Order_header_client_data.keys() ):
Order_header_data['client_raison_sociale'] = Order_header_client_data['raison_sociale']
if ("nom" in Order_header_client_data.keys()):
Order_header_data['client_nom'] = Order_header_client_data['nom']
if ("email" in Order_header_client_data.keys()):
Order_header_data['client_email'] = Order_header_client_data['email']
# Recuperation des details de lignes de : partner_order_line
filt_class_partner_recid = {'partner_owner_recid': str(my_partner['recid'])}
filt_order_header_order_id = {'order_header_id': str(diction['order_id'])}
query = [{'$match': {'$and': [filt_order_header_order_id,
{'partner_owner_recid': str(my_partner['recid'])}]}},
{'$lookup':
{
'from': 'myclass',
'localField': 'order_line_formation',
'foreignField': 'internal_url',
'pipeline': [{'$match': {'$and': [filt_class_partner_recid]}},
{'$project': {'title': 1, 'domaine': 1,
'duration': 1,
'duration_unit': 1,
'external_code':1}}],
'as': 'myclass_collection'
}
}
]
#print("#### Get_Given_Partner_Order_Lines_From_order_ref_interne : query pip= ", query)
val_tmp = 0
Order_header_lines_data = []
for retval in MYSY_GV.dbname['partner_order_line'].aggregate(query):
if ('myclass_collection' in retval.keys() and len(retval['myclass_collection']) > 0):
user = {}
user['id'] = str(val_tmp)
val_tmp = val_tmp + 1
user['_id'] = retval['_id']
user['order_line_formation'] = retval['order_line_formation']
user['order_line_qty'] = retval['order_line_qty']
user['order_line_prix_unitaire'] = retval['order_line_prix_unitaire']
user['order_header_id'] = retval['order_header_id']
user['order_header_ref_interne'] = retval['order_header_ref_interne']
user['valide'] = retval['valide']
user['locked'] = retval['locked']
if ("order_line_montant_reduction" in retval.keys()):
user['order_line_montant_reduction'] = retval['order_line_montant_reduction']
else:
user['order_line_montant_reduction'] = "0"
if ("order_line_montant_toutes_taxes" in retval.keys()):
user['order_line_montant_toutes_taxes'] = retval['order_line_montant_toutes_taxes']
else:
user['order_line_montant_toutes_taxes'] = "0"
if ("order_line_tax" in retval.keys()):
user['order_line_tax'] = retval['order_line_tax']
else:
user['order_line_tax'] = ""
if ("order_line_tax_amount" in retval.keys()):
user['order_line_tax_amount'] = retval['order_line_tax_amount']
else:
user['order_line_tax_amount'] = "0"
if ("order_line_type_reduction" in retval.keys()):
user['order_line_type_reduction'] = retval['order_line_type_reduction']
else:
user['order_line_montant_reduction'] = ""
if ("order_line_type_valeur" in retval.keys()):
user['order_line_type_valeur'] = retval['order_line_type_valeur']
else:
user['order_line_type_valeur'] = "0"
if ("order_line_montant_hors_taxes" in retval.keys()):
user['order_line_montant_hors_taxes'] = str(round(mycommon.tryFloat(str(retval['order_line_montant_hors_taxes'])), 2))
else:
user['order_line_montant_hors_taxes'] = "0"
user['date_update'] = retval['date_update']
user['partner_owner_recid'] = retval['partner_owner_recid']
user['order_line_type'] = retval['order_line_type']
user['order_line_status'] = retval['order_line_status']
if ("order_line_comment" in retval.keys()):
user['order_line_comment'] = retval['order_line_comment']
else:
user['order_line_comment'] = ""
user['title'] = retval['myclass_collection'][0]['title']
user['order_line_formation_external_code'] = retval['myclass_collection'][0]['external_code']
if( "domaine" in retval['myclass_collection'][0].keys() ):
user['domaine'] = retval['myclass_collection'][0]['domaine']
else:
user['domaine'] = ""
user['duration'] = retval['myclass_collection'][0]['duration']
user['duration_unit'] = retval['myclass_collection'][0]['duration_unit']
if (str(retval['myclass_collection'][0]['duration_unit']) == "heure"):
user['duration_concat'] = str(retval['myclass_collection'][0]['duration']) + " h"
elif (str(retval['myclass_collection'][0]['duration_unit']) == "jour"):
user['duration_concat'] = str(retval['myclass_collection'][0]['duration']) + " j"
elif (str(retval['myclass_collection'][0]['duration_unit']) == "semaine"):
user['duration_concat'] = str(retval['myclass_collection'][0]['duration']) + " s"
elif (str(retval['myclass_collection'][0]['duration_unit']) == "mois"):
user['duration_concat'] = str(retval['myclass_collection'][0]['duration']) + " m"
elif (str(retval['myclass_collection'][0]['duration_unit']) == "annee"):
user['duration_concat'] = str(retval['myclass_collection'][0]['duration']) + " a"
elif (str(retval['myclass_collection'][0]['duration_unit']) == "user_rythme"):
user['duration_concat'] = str(retval['myclass_collection'][0]['duration']) + " u"
else:
user['duration_concat'] = str(retval['myclass_collection'][0]['duration']) + " ?"
Order_header_lines_data.append(user)
if (len(Order_header_lines_data) <= 0):
mycommon.myprint(str(inspect.stack()[0][
3]) + " - Aucune ligne de détail pour cette commande ")
return False, " Aucune ligne de détail pour cette commande ", False
#print(" ### Order_header_lines_data = ", Order_header_lines_data)
contenu_doc_Template = jinja2.Template(str(partner_document_CONF_ORDER_data['contenu_doc']))
#print(" #### Order_header_data = ", Order_header_data)
#sourceHtml = contenu_doc_Template.render(params=Order_header_data)
Order_header_data['order_header_type'] = str(Order_header_data['order_header_type']).capitalize()
sourceHtml = contenu_doc_Template.render(params=Order_header_data, param_order_lines=Order_header_lines_data)
orig_file_name = "Partner_Order_"+str(Order_header_data['order_header_ref_interne'])+".pdf"
outputFilename = str(MYSY_GV.TEMPORARY_DIRECTORY) +"/"+ str(orig_file_name)
# open output file for writing (truncated binary)
resultFile = open(outputFilename, "w+b")
# convert HTML to PDF
pisaStatus = pisa.CreatePDF(
src=sourceHtml, # the HTML to convert
dest=resultFile) # file handle to receive result
# close output file
resultFile.close()
return True, outputFilename, sourceHtml
except Exception as e:
exc_type, exc_obj, exc_tb = sys.exc_info()
print(str(inspect.stack()[0][3]) + " -" + str(e) + " - ERRORRRR AT Line : " + str(exc_tb.tb_lineno))
return False, False, False
"""
Envoie de la commande par email
"""
def Send_Partner_Order_By_Email(diction):
try:
field_list = ['order_id', 'token', ]
field_list = ['order_id', 'token', 'request_digital_signature']
incom_keys = diction.keys()
for val in incom_keys:
if val not in field_list and val.startswith('my_') is False:
@ -4581,6 +4843,25 @@ def Send_Partner_Order_By_Email(diction):
if (local_status is not True):
return local_status, my_partner
"""
20/03/2024 : Creation du E-Document à signer
On verifier si le partenaire dispose de l'option "signature_digital" dans la collection base_partner_setup
ET SI DEPUIS LE FRONT, L'UTILISATEUR DECIDE DE L'UTILISER
"""
is_partner_digital_signature = ""
if ("request_digital_signature" in diction.keys() and diction['request_digital_signature'] == "1"):
is_signature_digital_count = MYSY_GV.dbname['base_partner_setup'].count_documents(
{'partner_owner_recid': str(my_partner['recid']),
'config_name': 'signature_digital',
'valide': '1',
'locked': '0',
'config_value': '1'})
if (is_signature_digital_count == 1):
is_partner_digital_signature = "1"
# Verification de la validité de l'order
qry = {'_id': ObjectId(str(diction['order_id'])), 'valide': '1', 'locked': '0',
'partner_owner_recid': str(my_partner['recid'])}
@ -4604,7 +4885,7 @@ def Send_Partner_Order_By_Email(diction):
partner_document_CONF_ORDER_data_qry = {'partner_owner_recid': str(my_partner['recid']),
'valide': '1', 'locked': '0', 'ref_interne': 'PART_ORDER', 'type_doc':'email'}
print(" ### partner_document_CONF_ORDER_data_qry = ", partner_document_CONF_ORDER_data_qry)
#print(" ### partner_document_CONF_ORDER_data_qry = ", partner_document_CONF_ORDER_data_qry)
partner_document_CONF_ORDER_data = MYSY_GV.dbname['courrier_template'].find_one(
{'partner_owner_recid': str(my_partner['recid']),
'valide': '1', 'locked': '0', 'ref_interne': 'PART_ORDER', 'type_doc':'email'})
@ -4764,8 +5045,6 @@ def Send_Partner_Order_By_Email(diction):
#print(" ### Order_header_lines_data = ", Order_header_lines_data)
contenu_doc_Template = jinja2.Template(str(partner_document_CONF_ORDER_data['contenu_doc']))
contenu_doc_Template_subject = jinja2.Template(str(partner_document_CONF_ORDER_data['sujet']))
@ -4774,7 +5053,28 @@ def Send_Partner_Order_By_Email(diction):
Order_header_data['order_header_type'] = str(Order_header_data['order_header_type']).capitalize()
sourceHtml = contenu_doc_Template.render(params=Order_header_data, param_order_lines=Order_header_lines_data)
sujetHtml = str(Order_header_data['order_header_type']) + " : "+ str(Order_header_data['order_header_ref_interne'])
#print(" #### sourceHtml = ", sourceHtml)
new_model_courrier_with_code_tag = str(
sourceHtml) + " <p style='width: 300px; text-align: right;'> Signature Client <br/> <img style='height:250px; width:250px;' src='{{ params.mysy_manual_signature_img }}'>&nbsp;</p> <br/> " \
" <p style='width: 300px; text-align: center;'> <img style='height:150px; width:150px;' src='{{ params.mysy_qrcode_securite }}'>&nbsp;</p> "
todays_date = str(date.today().strftime("%d_%m_%Y"))
ts = datetime.now().timestamp()
ts = str(ts).replace(".", "").replace(",", "")[-2:]
orig_file_name = "Devis_" + str(my_partner['recid'])[0:5] + "_" + str(todays_date)+"_"+str(ts) + ".pdf"
outputFilename = str(MYSY_GV.TEMPORARY_DIRECTORY) + "/" + str(orig_file_name)
# open output file for writing (truncated binary)
resultFile = open(outputFilename, "w+b")
# convert HTML to PDF
pisaStatus = pisa.CreatePDF(
src=sourceHtml, # the HTML to convert
dest=resultFile) # file handle to receive result
# close output file
resultFile.close()
"""
Recuperation des parametre SMTP du partner si le client a decidé d'utiliser son propre smpt
@ -4861,6 +5161,8 @@ def Send_Partner_Order_By_Email(diction):
smtpserver.close()
print(" Email envoyé " + str(val))
else:
print("debut envoi mail de test ")
@ -4906,8 +5208,90 @@ def Send_Partner_Order_By_Email(diction):
smtpserver.close()
print(" Email envoyé " + str(val))
"""
Gestion de la E-Signature
20/03/2024 : la convention pdf a été créée.
Si le partenaire a l'option de signature digitale, alors on créé le e-document
"""
if (is_partner_digital_signature == "1"):
tab_client = []
tab_client.append(ObjectId(str(Order_header_data['order_header_client_id'])))
new_diction = {}
new_diction['token'] = diction['token']
new_diction['list_stagiaire_id'] = []
new_diction['list_session_id'] = []
new_diction['list_class_id'] = []
new_diction['list_client_id'] = tab_client
local_status, local_retval = mycommon.Get_Dictionnary_data_For_Template(new_diction)
if (local_status is False):
return local_status, local_retval
convention_dictionnary_data = local_retval
client_data = convention_dictionnary_data['list_client_data']
# print(client_data[0]['list_contact_communication'] )
tab_emails_destinataire = []
for tmp in client_data[0]['list_contact_communication']:
if ("email" in tmp.keys() and tmp['email']):
tab_emails_destinataire.append(tmp['email'])
new_e_document_diction = {}
new_e_document_diction['token'] = diction['token']
new_e_document_diction['file_name'] = outputFilename
toaddrs = ", ".join(tab_emails_destinataire)
new_e_document_diction['email_destinataire'] = str(toaddrs)
new_e_document_diction['source_document'] = new_model_courrier_with_code_tag
new_e_document_diction['type'] = "quotation"
new_e_document_diction['related_collection'] = "quotation"
new_e_document_diction['related_collection_id'] = str(diction['order_id'])
local_status_e_doc, local_retval_e_doc = E_Sign_Document.Create_E_Document(new_e_document_diction)
if (local_status_e_doc is False):
return local_status_e_doc, local_retval_e_doc
"""
Apres la creation du document electronique, on envoie la demande de validation
/!\ on envoie le mail à chaque destinataire
"""
for email in tab_emails_destinataire:
print(" ### traitement du mail : ", email)
new_send_e_document_diction = {}
new_send_e_document_diction['token'] = diction['token']
new_send_e_document_diction['e_doc_id'] = str(local_retval_e_doc)
new_send_e_document_diction['user_email'] = str(email)
local_status_send_e_doc, local_send_retval_e_doc = E_Sign_Document.Sent_E_Document_Signature_Request(
new_send_e_document_diction)
if (local_status_send_e_doc is False):
return local_status_send_e_doc, local_send_retval_e_doc
"""
Mettre à jour la commande /devis pour dire que quand le document a été envoyé
"""
updata_data = {}
updata_data['date_update'] = datetime.now()
updata_data['update_by'] = str(my_partner['recid'])
updata_data['date_envoi_quotation'] = datetime.now()
MYSY_GV.dbname['partner_order_header'].find_one_and_update(
{'_id': ObjectId(str(Order_header_data['_id'])),
'partner_owner_recid': str(Order_header_data['partner_owner_recid'])},
{'$set': updata_data})
return True, " Le document a été envoyé par email à :'"+str(client_main_mail_tmp)+"' "
return True, " La commande a été envoyée par email à :'"+str(client_main_mail_tmp)+"' "
except Exception as e:
exc_type, exc_obj, exc_tb = sys.exc_info()
print(str(inspect.stack()[0][3]) + " -" + str(e) + " - ERRORRRR AT Line : " + str(exc_tb.tb_lineno))
@ -5218,9 +5602,9 @@ A la validation, pour chaque ligne du devis,
nom = num_devis_Nom_cpt
prenom = num_devis_Prenom_cpt
email = num_devis_cpt@email.com
3 - Apres la reservation, si le partenaire a activier et demandé d'appliquer la signature electronique
alors on declenche le processus de signature electronique
"""
def Insert_Quotation_To_Session(diction):
@ -5232,7 +5616,7 @@ def Insert_Quotation_To_Session(diction):
# Ici on doit mettre tous les champs possible (obligatoire ou non) de la BDD dans la liste
# field_list.
'''
field_list = ['token', 'quotation_id' ]
field_list = ['token', 'quotation_id', 'request_digital_signature' ]
incom_keys = diction.keys()
for val in incom_keys:
@ -5413,6 +5797,443 @@ def Insert_Quotation_To_Session(diction):
# Verification si le process de e-signature doit etre declenché
if( "request_digital_signature" in diction.keys() and str(diction['request_digital_signature']) == "1"):
"""
Verifier que le partenaire a bien le droit à l'option de e-signature
"""
is_partner_digital_signature = ""
is_signature_digital_count = MYSY_GV.dbname['base_partner_setup'].count_documents(
{'partner_owner_recid': str(my_partner['recid']),
'config_name': 'signature_digital',
'valide': '1',
'locked': '0',
'config_value': '1'})
if (is_signature_digital_count == 1):
is_partner_digital_signature = "1"
"""
On va generer le fichier PDF
"""
local_diction = {}
local_diction['token'] = diction['token']
local_diction['order_id'] = str(diction['quotation_id'])
local_file_status, local_file_retaval_PDF, local_file_retaval_SourceHtml= Gernerate_Stock_PDF_Partner_Order(local_diction)
if( local_file_status is False ):
return local_file_status, local_file_retaval_PDF
outputFilename = local_file_retaval_PDF
sourceHtml = local_file_retaval_SourceHtml
new_model_courrier_with_code_tag = str(
sourceHtml) + " <p style='width: 300px; text-align: right;'> Signature Client <br/> <img style='height:250px; width:250px;' src='{{ params.mysy_manual_signature_img }}'>&nbsp;</p> <br/> " \
" <p style='width: 300px; text-align: center;'> <img style='height:150px; width:150px;' src='{{ params.mysy_qrcode_securite }}'>&nbsp;</p> "
if (is_partner_digital_signature == "1"):
print("is_valide_qotation_data = ", is_valide_qotation_data)
tab_client = []
tab_client.append(ObjectId(str(is_valide_qotation_data['order_header_client_id'])))
print("tab_client = ", tab_client)
new_diction = {}
new_diction['token'] = diction['token']
new_diction['list_stagiaire_id'] = []
new_diction['list_session_id'] = []
new_diction['list_class_id'] = []
new_diction['list_client_id'] = tab_client
local_status, local_retval = mycommon.Get_Dictionnary_data_For_Template(new_diction)
if (local_status is False):
return local_status, local_retval
convention_dictionnary_data = local_retval
client_data = convention_dictionnary_data['list_client_data']
#print(client_data[0]['list_contact_communication'] )
tab_emails_destinataire = []
for tmp in client_data[0]['list_contact_communication'] :
if( "email" in tmp.keys() and tmp['email']):
tab_emails_destinataire.append(tmp['email'])
new_e_document_diction = {}
new_e_document_diction['token'] = diction['token']
new_e_document_diction['file_name'] = outputFilename
toaddrs = ", ".join(tab_emails_destinataire)
new_e_document_diction['email_destinataire'] = str(toaddrs)
new_e_document_diction['source_document'] = new_model_courrier_with_code_tag
new_e_document_diction['type'] = "quotation"
new_e_document_diction['related_collection'] = "quotation"
new_e_document_diction['related_collection_id'] = str(diction['quotation_id'])
local_status_e_doc, local_retval_e_doc = E_Sign_Document.Create_E_Document(new_e_document_diction)
if (local_status_e_doc is False):
return local_status_e_doc, local_retval_e_doc
"""
Apres la creation du document electronique, on envoie la demande de validation
/!\ on envoie le mail à chaque destinataire
"""
for email in tab_emails_destinataire:
print(" ### traitement du mail : ", email)
new_send_e_document_diction = {}
new_send_e_document_diction['token'] = diction['token']
new_send_e_document_diction['e_doc_id'] = str(local_retval_e_doc)
new_send_e_document_diction['user_email'] = str(email)
local_status_send_e_doc, local_send_retval_e_doc = E_Sign_Document.Sent_E_Document_Signature_Request(
new_send_e_document_diction)
if (local_status_send_e_doc is False):
return local_status_send_e_doc, local_send_retval_e_doc
if (is_warning == "1"):
return True, str(warning_msg)
return True, " Le devis a été correctement mis à jour. ("+str(nb_resa_line)+") réservation(s) faite(s)"
except Exception as e:
exc_type, exc_obj, exc_tb = sys.exc_info()
mycommon.myprint(str(inspect.stack()[0][3]) + " -" + str(e) + " - ERRORRRR AT Line : " + str(exc_tb.tb_lineno))
return False, "Impossible de créer / mettre à jour la session de formation"
"""
Inser quotation from partner_owner_recid
"""
def Insert_Quotation_To_Session_From_Partner_Owner_Recid(diction):
try:
# Dictionnaire des champs utilisables
'''
# Verification que les champs reçus dans l'API sont bien dans la liste des champs autorisés
# Cela evite le cas ou une entité tierce ajouter les valeurs inconnu dans l'API
# Ici on doit mettre tous les champs possible (obligatoire ou non) de la BDD dans la liste
# field_list.
'''
field_list = ['partner_owner_recid', 'quotation_id', 'request_digital_signature' ]
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'est pas autorisé")
return False, "Impossible de créer le stagiaire. Toutes les informations fournies ne sont pas valables"
"""
Verification de la liste des champs obligatoires
"""
field_list_obligatoire = ['partner_owner_recid', 'quotation_id' ]
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, "Impossible de créer le stagiaire. La valeur '" + val + "' n'est pas presente dans liste"
my_partner = {}
my_partner['recid'] = diction['partner_owner_recid']
"""
Verifier la validité du devis
"""
qry = {'_id':ObjectId(str(diction['quotation_id'])),
'partner_owner_recid':str(my_partner['recid']),
'order_header_type':'devis',
'valide':'1',
'locked':'0'}
print(" ### qty = ", qry )
is_valide_qotation = MYSY_GV.dbname['partner_order_header'].count_documents({'_id':ObjectId(str(diction['quotation_id'])),
'partner_owner_recid':str(my_partner['recid']),
'order_header_type':'devis',
'valide':'1',
'locked':'0'})
if(is_valide_qotation != 1 ):
mycommon.myprint(
str(inspect.stack()[0][3]) + " L'identifiant du devis n'est pas valide ")
return False, " L'identifiant du devis n'est pas valide "
is_valide_qotation_data = MYSY_GV.dbname['partner_order_header'].find_one(
{'_id': ObjectId(str(diction['quotation_id'])),
'partner_owner_recid': str(my_partner['recid']),
'order_header_type': 'devis',
'valide': '1',
'locked': '0'})
if ("order_header_date_expiration" in is_valide_qotation_data.keys() and is_valide_qotation_data['order_header_date_expiration']):
qotation_date_expiration = str(is_valide_qotation_data['order_header_date_expiration']).strip()[0:10]
if (mycommon.CheckisDate(qotation_date_expiration) is False):
mycommon.myprint(
str(inspect.stack()[0][3]) + " La date d'expiration du devis n'est pas au format jj/mm/aaaa ")
return False, " La date d'expiration du devis n'est pas au format jj/mm/aaaa "
date_today = datetime.now().strftime("%d/%m/%Y")
if (datetime.strptime(str(qotation_date_expiration), '%d/%m/%Y') <= datetime.strptime(str(date_today), '%d/%m/%Y')):
mycommon.myprint(
str(inspect.stack()[0][
3]) + " La date d'expiration du devis " + str(qotation_date_expiration) + " est déjà dépassée ")
return False, " La date d'expiration du devis " + str(qotation_date_expiration) + " est déjà dépassée "
warning_msg = ""
is_warning = ""
"""
Recuperer les lignes du devis
"""
nb_resa_line = 0
for qotation_line in MYSY_GV.dbname['partner_order_line'].find({'order_header_id':str(diction['quotation_id']),
'partner_owner_recid':str(my_partner['recid']),
'order_line_type':'devis',
'valide':'1',
'locked':'0'}):
if( "order_line_session_id" in qotation_line.keys() and qotation_line['order_line_session_id']):
print(" ### la ligne suivant a une order_line_session_id : ", qotation_line)
# Verifier la validité de la session
is_order_line_session_id_valide = MYSY_GV.dbname['session_formation'].count_documents({'_id':ObjectId(str(qotation_line['order_line_session_id'])),
'valide':'1',
'partner_owner_recid':str(my_partner['recid'])})
if( is_order_line_session_id_valide != 1 ):
mycommon.myprint(
str(inspect.stack()[0][3]) + " L'identifiant de la session de formation n'est pas valide ")
return False, " L'identifiant de la session de formation n'est pas valide "
is_order_line_session_id_data = MYSY_GV.dbname['session_formation'].find_one(
{'_id': ObjectId(str(qotation_line['order_line_session_id'])),
'valide': '1',
'partner_owner_recid': str(my_partner['recid'])})
session_date_du = str(is_order_line_session_id_data['date_debut']).strip()[0:10]
if( mycommon.CheckisDate(session_date_du) is False ):
mycommon.myprint(
str(inspect.stack()[0][3]) + " La date de debut de session n'est pas au format jj/mm/aaaa ")
return False, " La date de debut de session n'est pas au format jj/mm/aaaa "
date_today = datetime.now().strftime("%d/%m/%Y")
if (datetime.strptime(str(session_date_du), '%d/%m/%Y') <= datetime.strptime( str(date_today), '%d/%m/%Y')):
mycommon.myprint(
str(inspect.stack()[0][
3]) + " La date de debut de session "+str(session_date_du)+" est déjà dépassée ")
return False, " La date de debut de session "+str(session_date_du)+" est déjà dépassée "
"""
1 - Suppression des eventuelles preinscrit dans cette session ayant le meme devis
"""
MYSY_GV.dbname['inscription'].delete_many({'partner_owner_recid':str(my_partner['recid']),
'session_id':str(qotation_line['order_line_session_id']),
'status':'0',
'quotation_id':str(diction['quotation_id'])})
"""
2 - Inserer les nouvelles lignes
"""
line_qotation_qty = mycommon.tryInt(str(qotation_line['order_line_qty']))
cpt = 0
while( cpt < line_qotation_qty ):
cpt = cpt + 1
new_data = {}
new_data['nom'] = str(qotation_line['order_header_ref_interne'])+"_Reservation_Nom_"+str(cpt)
new_data['prenom'] = str(qotation_line['order_header_ref_interne']) + "_Reservation_Prenom_" + str(cpt)
new_data['email'] = str(qotation_line['order_header_ref_interne']) + "_Reservation_mail_" + str(cpt)+"@mail.com"
new_data['telephone'] = "01010101"
new_data['modefinancement'] = ""
new_data['class_internal_url'] = str(is_order_line_session_id_data['class_internal_url'])
new_data['session_id'] = str(qotation_line['order_line_session_id'])
new_data['client_rattachement_id'] = str(is_valide_qotation_data['order_header_client_id'])
new_data['civilite'] = "neutre"
new_data['quotation_id'] = str(qotation_line['order_header_id'])
new_data['status'] = "0"
"""
/!\
22/04/2024 :On a besoin du token pour utiliser la fonction standard.
On va aller recuperer le token du compte principale du partner
/!\
"""
main_account_data = MYSY_GV.dbname['partnair_account'].find_one({'recid':str(diction['partner_owner_recid']),
'active':'1', 'is_partner_admin_account':'1'})
new_data['token'] = str(main_account_data['token'])
local_insert_status, local_insert_retval = Inscription_mgt.AddStagiairetoClass(new_data)
if( local_insert_status is False ):
is_warning = "1"
warning_msg = warning_msg + "\n" + str(local_insert_retval)
else:
nb_resa_line = nb_resa_line + 1
"""
Mettre à jour du devis avec la date de validation et de reservation
"""
now = str(datetime.now())
update_data = {}
update_data['date_update'] = now
update_data['update_by'] = "client"
update_data['date_validation'] = now
update_data['date_reservation'] = now
update_data['mode_reservation'] = "automatique"
update_data['validation_by'] = "client"
update_data['reservation_by'] = "client"
MYSY_GV.dbname['partner_order_header'].update_many({'_id': ObjectId(str(diction['quotation_id'])),
'partner_owner_recid': str(my_partner['recid']),
'order_header_type': 'devis',
'valide': '1',
'locked': '0'},
{"$set": update_data},
)
# Verification si le process de e-signature doit etre declenché
if( "request_digital_signature" in diction.keys() and str(diction['request_digital_signature']) == "1"):
"""
Verifier que le partenaire a bien le droit à l'option de e-signature
"""
is_partner_digital_signature = ""
is_signature_digital_count = MYSY_GV.dbname['base_partner_setup'].count_documents(
{'partner_owner_recid': str(my_partner['recid']),
'config_name': 'signature_digital',
'valide': '1',
'locked': '0',
'config_value': '1'})
if (is_signature_digital_count == 1):
is_partner_digital_signature = "1"
"""
On va generer le fichier PDF
"""
local_diction = {}
local_diction['token'] = diction['token']
local_diction['order_id'] = str(diction['quotation_id'])
local_file_status, local_file_retaval_PDF, local_file_retaval_SourceHtml= Gernerate_Stock_PDF_Partner_Order(local_diction)
if( local_file_status is False ):
return local_file_status, local_file_retaval_PDF
outputFilename = local_file_retaval_PDF
sourceHtml = local_file_retaval_SourceHtml
new_model_courrier_with_code_tag = str(
sourceHtml) + " <p style='width: 300px; text-align: right;'> Signature Client <br/> <img style='height:250px; width:250px;' src='{{ params.mysy_manual_signature_img }}'>&nbsp;</p> <br/> " \
" <p style='width: 300px; text-align: center;'> <img style='height:150px; width:150px;' src='{{ params.mysy_qrcode_securite }}'>&nbsp;</p> "
if (is_partner_digital_signature == "1"):
print("is_valide_qotation_data = ", is_valide_qotation_data)
tab_client = []
tab_client.append(ObjectId(str(is_valide_qotation_data['order_header_client_id'])))
print("tab_client = ", tab_client)
new_diction = {}
new_diction['token'] = diction['token']
new_diction['list_stagiaire_id'] = []
new_diction['list_session_id'] = []
new_diction['list_class_id'] = []
new_diction['list_client_id'] = tab_client
local_status, local_retval = mycommon.Get_Dictionnary_data_For_Template(new_diction)
if (local_status is False):
return local_status, local_retval
convention_dictionnary_data = local_retval
client_data = convention_dictionnary_data['list_client_data']
#print(client_data[0]['list_contact_communication'] )
tab_emails_destinataire = []
for tmp in client_data[0]['list_contact_communication'] :
if( "email" in tmp.keys() and tmp['email']):
tab_emails_destinataire.append(tmp['email'])
new_e_document_diction = {}
new_e_document_diction['token'] = diction['token']
new_e_document_diction['file_name'] = outputFilename
toaddrs = ", ".join(tab_emails_destinataire)
new_e_document_diction['email_destinataire'] = str(toaddrs)
new_e_document_diction['source_document'] = new_model_courrier_with_code_tag
new_e_document_diction['type'] = "quotation"
new_e_document_diction['related_collection'] = "quotation"
new_e_document_diction['related_collection_id'] = str(diction['quotation_id'])
local_status_e_doc, local_retval_e_doc = E_Sign_Document.Create_E_Document(new_e_document_diction)
if (local_status_e_doc is False):
return local_status_e_doc, local_retval_e_doc
"""
Apres la creation du document electronique, on envoie la demande de validation
/!\ on envoie le mail à chaque destinataire
"""
for email in tab_emails_destinataire:
print(" ### traitement du mail : ", email)
new_send_e_document_diction = {}
new_send_e_document_diction['token'] = diction['token']
new_send_e_document_diction['e_doc_id'] = str(local_retval_e_doc)
new_send_e_document_diction['user_email'] = str(email)
local_status_send_e_doc, local_send_retval_e_doc = E_Sign_Document.Sent_E_Document_Signature_Request(
new_send_e_document_diction)
if (local_status_send_e_doc is False):
return local_status_send_e_doc, local_send_retval_e_doc
if (is_warning == "1"):
return True, str(warning_msg)