rename last_emailing to rappels_rdv
This commit is contained in:
@@ -26,7 +26,7 @@ def get_log_nuit(request, ):
|
|||||||
results = request.dbsession.execute(query, )
|
results = request.dbsession.execute(query, )
|
||||||
return results.fetchall()
|
return results.fetchall()
|
||||||
|
|
||||||
def get_last_emailing(request):
|
def get_rappels_rdv(request):
|
||||||
"""Lire les 200 derniers envois d'emails"""
|
"""Lire les 200 derniers envois d'emails"""
|
||||||
query = "SELECT * FROM email_rappels ORDER BY no_id DESC LIMIT 400;"
|
query = "SELECT * FROM email_rappels ORDER BY no_id DESC LIMIT 400;"
|
||||||
results = request.dbsession.execute(query, {})
|
results = request.dbsession.execute(query, {})
|
||||||
@@ -47,7 +47,7 @@ def get_dossiers_byChantier(request, societe, name):
|
|||||||
def get_cabinets_by_id(request, code):
|
def get_cabinets_by_id(request, code):
|
||||||
# lire les cabinets
|
# lire les cabinets
|
||||||
if code == '0':
|
if code == '0':
|
||||||
query = """SELECT * FROM P_CABINET WHERE afficher <> 0 ORDER BY nom;"""
|
query = """SELECT * FROM P_CABINET ORDER BY nom;"""
|
||||||
results = request.dbsession.execute(query).fetchall()
|
results = request.dbsession.execute(query).fetchall()
|
||||||
else:
|
else:
|
||||||
query = """SELECT * FROM P_CABINET WHERE code=:code;"""
|
query = """SELECT * FROM P_CABINET WHERE code=:code;"""
|
||||||
@@ -209,3 +209,6 @@ def delete_expert(request, code_cab, code_exp):
|
|||||||
query = "DELETE FROM p_experts WHERE code_cab = :code_cab AND code_exp = :code_exp;"
|
query = "DELETE FROM p_experts WHERE code_cab = :code_cab AND code_exp = :code_exp;"
|
||||||
execute_query(request, query, {'code_cab': code_cab, 'code_exp': code_exp})
|
execute_query(request, query, {'code_cab': code_cab, 'code_exp': code_exp})
|
||||||
|
|
||||||
|
def update_rappels(request):
|
||||||
|
query = "CALL spUPD_RAPPELS();"
|
||||||
|
execute_query(request, query)
|
||||||
|
|||||||
@@ -59,8 +59,8 @@ def includeme(config):
|
|||||||
config.add_route('emails_sent', '/emails_sent')
|
config.add_route('emails_sent', '/emails_sent')
|
||||||
config.add_route('expert_edit', '/expert_edit/{code_cab}/{code_exp}')
|
config.add_route('expert_edit', '/expert_edit/{code_cab}/{code_exp}')
|
||||||
config.add_route('infrastructure', '/infrastructure')
|
config.add_route('infrastructure', '/infrastructure')
|
||||||
config.add_route('last_emailing', '/last_emailing')
|
|
||||||
config.add_route('orphans_de', '/orphans_de/{societe}')
|
config.add_route('orphans_de', '/orphans_de/{societe}')
|
||||||
|
config.add_route('rappels_rdv', '/rappels_rdv')
|
||||||
config.add_route('rdf_cause_edit', '/rdf_cause_edit/{code}')
|
config.add_route('rdf_cause_edit', '/rdf_cause_edit/{code}')
|
||||||
config.add_route('rdf_causes', '/rdf_causes')
|
config.add_route('rdf_causes', '/rdf_causes')
|
||||||
config.add_route('text_edit', '/text_edit/{text_id}')
|
config.add_route('text_edit', '/text_edit/{text_id}')
|
||||||
|
|||||||
@@ -85,7 +85,7 @@
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
"createdRow": function( row, data, dataIndex ){
|
createdRow: function( row, data, dataIndex ){
|
||||||
if ( data[6] == "Humidité" ) {
|
if ( data[6] == "Humidité" ) {
|
||||||
$('td', row).eq(6).css('background-color', 'Crimson').css('color', 'white');
|
$('td', row).eq(6).css('background-color', 'Crimson').css('color', 'white');
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,6 +17,7 @@
|
|||||||
<th>Tél. 2</th>
|
<th>Tél. 2</th>
|
||||||
<th>Portable</th>
|
<th>Portable</th>
|
||||||
<th>Ville</th>
|
<th>Ville</th>
|
||||||
|
<th></th>
|
||||||
<th>Modif le</th>
|
<th>Modif le</th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
@@ -46,6 +47,11 @@
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
|
createdRow: function( row, data, dataIndex ){
|
||||||
|
if ( data[6] == "0" ) {
|
||||||
|
$('td', row).eq(0).css('background-color', 'OrangeRed').css('color', 'white');
|
||||||
|
}
|
||||||
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
|
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<h2>Derniers traitements différés</h2>
|
<h2>Derniers traitements différés</h2>
|
||||||
<p><a href="/last_emailing">[ Consulter les derniers envois de mail ]</a></p>
|
<p><a href="/rappels_rdv">[ Consulter les derniers envois de mail ]</a></p>
|
||||||
<table class="table table-condensed">
|
<table class="table table-condensed">
|
||||||
<tr tal:repeat="item log_nuit">
|
<tr tal:repeat="item log_nuit">
|
||||||
<td>${item.date.strftime('%d %b, %H:%M')}</td>
|
<td>${item.date.strftime('%d %b, %H:%M')}</td>
|
||||||
|
|||||||
@@ -1,8 +1,16 @@
|
|||||||
<metal:block use-macro="main_template">
|
<metal:block use-macro="main_template">
|
||||||
<div metal:fill-slot="content">
|
<div metal:fill-slot="content">
|
||||||
|
<br />
|
||||||
|
<form id="login-form" role="form" action="${url}" method="post" >
|
||||||
|
<div class="form-group">
|
||||||
|
<button class="btn btn-success" type="submit" name="form.generate">
|
||||||
|
<span class="glyphicon glyphicon-flash"></span> Générer les rappels</button>
|
||||||
|
<button class="btn btn-primary" type="submit" name="form.emailing">
|
||||||
|
<span class="glyphicon glyphicon-send"></span> Envoyer les rappels</button>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
|
||||||
|
<table id="rappels_rdv" class="table table-condensed table-striped table-bordered">
|
||||||
<table id="last_emailing" class="table table-condensed table-striped table-bordered">
|
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
<th>Date RDV</th>
|
<th>Date RDV</th>
|
||||||
@@ -24,7 +32,7 @@
|
|||||||
|
|
||||||
$(document).ready(function() {
|
$(document).ready(function() {
|
||||||
$.fn.dataTable.moment('DD-MM-YYYY HH:mm');
|
$.fn.dataTable.moment('DD-MM-YYYY HH:mm');
|
||||||
$('#last_emailing').DataTable({
|
$('#rappels_rdv').DataTable({
|
||||||
data: dataSet,
|
data: dataSet,
|
||||||
pageLength: 100,
|
pageLength: 100,
|
||||||
bLengthChange: false,
|
bLengthChange: false,
|
||||||
@@ -179,12 +179,21 @@ def dashboard(request):
|
|||||||
'log_nuit': log_nuit,
|
'log_nuit': log_nuit,
|
||||||
}
|
}
|
||||||
|
|
||||||
@view_config(route_name='last_emailing', renderer='../templates/parametres/last_emailing.pt', permission='manage')
|
@view_config(route_name='rappels_rdv', renderer='../templates/parametres/rappels_rdv.pt', permission='manage')
|
||||||
def last_emailing(request):
|
def rappels_rdv(request):
|
||||||
|
|
||||||
items = get_last_emailing(request)
|
if 'form.generate' in request.params:
|
||||||
|
update_rappels(request)
|
||||||
|
request.session.flash(u"Les rappels ont été générés avec succès.", 'success')
|
||||||
|
|
||||||
# construire la liste
|
if 'form.emailing' in request.params:
|
||||||
|
notifier_rappels(request)
|
||||||
|
request.session.flash(u"Les rappels ont été envoyés par email avec succès.", 'success')
|
||||||
|
|
||||||
|
# lires les rappels générés
|
||||||
|
items = get_rappels_rdv(request)
|
||||||
|
|
||||||
|
# construire la liste des RDV
|
||||||
liste=[]
|
liste=[]
|
||||||
for item in items:
|
for item in items:
|
||||||
if item.rdv_date:
|
if item.rdv_date:
|
||||||
@@ -201,8 +210,9 @@ def last_emailing(request):
|
|||||||
liste.append(d)
|
liste.append(d)
|
||||||
|
|
||||||
return {
|
return {
|
||||||
'page_title': 'Liste des derniers emailing',
|
'page_title': 'Derniers rappels de RDV',
|
||||||
'dt_data': json.dumps(liste),
|
'dt_data': json.dumps(liste),
|
||||||
|
'url': request.route_url('rappels_rdv'),
|
||||||
}
|
}
|
||||||
|
|
||||||
@view_config(route_name='orphans_de', renderer='../templates/parametres/orphans_de.pt', permission='manage')
|
@view_config(route_name='orphans_de', renderer='../templates/parametres/orphans_de.pt', permission='manage')
|
||||||
@@ -539,7 +549,7 @@ def cabinets(request):
|
|||||||
# construire la liste
|
# construire la liste
|
||||||
liste=[]
|
liste=[]
|
||||||
for item in items:
|
for item in items:
|
||||||
modif_le = item.modif_le.strftime('%d/%m/%Y')
|
modif_le = item.modif_le.strftime('%d/%m/%Y')
|
||||||
d = (item.CODE, item.NOM, item.TEL1, item.TEL2, item.TELP, item.VILLE, str(item.afficher), modif_le)
|
d = (item.CODE, item.NOM, item.TEL1, item.TEL2, item.TELP, item.VILLE, str(item.afficher), modif_le)
|
||||||
liste.append(d)
|
liste.append(d)
|
||||||
|
|
||||||
@@ -697,3 +707,4 @@ def expert_edit(request):
|
|||||||
'expert': expert,
|
'expert': expert,
|
||||||
'code_exp': code_exp,
|
'code_exp': code_exp,
|
||||||
'message': message,
|
'message': message,
|
||||||
|
}
|
||||||
|
|||||||
@@ -19,3 +19,92 @@ def batch_nuit(request):
|
|||||||
|
|
||||||
return Response('Batch nuit terminé OK')
|
return Response('Batch nuit terminé OK')
|
||||||
|
|
||||||
|
def notifier_rappels(request):
|
||||||
|
|
||||||
|
szSQL = "insert t_log_nuit (proc,msg) values ('RAPPELS','- Début ENVOI emails');"
|
||||||
|
ExecQuery(ctDSN_AEM, szSQL)
|
||||||
|
|
||||||
|
szSQL = "SELECT r.*, e.c_qualite, e.c_nom, e.c_adr, e.c_adr2, e.c_ville, e.c_email, s.tel, s.nom as nom_societe FROM email_rappels r " & _
|
||||||
|
"INNER JOIN dem_devis e ON r.societe = e.societe AND r.nochantier = e.no_id " & _
|
||||||
|
"INNER JOIN p_societe s ON r.societe = s.societe " & _
|
||||||
|
"WHERE ISNULL(envoye_le) ORDER BY no_id;"
|
||||||
|
GetRecordset(ctDSN_AEM, szSQL, rsRappel)
|
||||||
|
|
||||||
|
Do While Not rsRappel.EOF
|
||||||
|
nbLus += 1
|
||||||
|
If rsRappel.Fields("c_email").Value.ToString.Length = 0 Then
|
||||||
|
nbEmailVide += 1
|
||||||
|
szSQL = "insert t_log_nuit (proc,msg) values ('RAPPELS', '--> email vide : " & rsRappel.Fields("societe").Value & "-" & nq(rsRappel.Fields("nochantier").Value) & _
|
||||||
|
" - " & rsRappel.Fields("c_qualite").Value & " " & nq(rsRappel.Fields("c_nom").Value) & "');"
|
||||||
|
ExecQuery(ctDSN_AEM, szSQL)
|
||||||
|
Else
|
||||||
|
' RDV ayant une heure
|
||||||
|
date_heure = Format(rsRappel.Fields("rdv_date").Value, "dd/MM/yyyy à HH:mm")
|
||||||
|
szBody = "<html><body><p>Bonjour " & nv(rsRappel.Fields("c_qualite").Value) & " " & rsRappel.Fields("c_nom").Value & ",</p>" & _
|
||||||
|
"<p>L’entreprise " & rsRappel.Fields("nom_societe").Value & " vous rappelle votre prochain rendez-vous, pris d'un commun accord,</p>" & _
|
||||||
|
"<p>le <b>" & date_heure & "</b><br />" & _
|
||||||
|
rsRappel.Fields("c_adr").Value & "<br />" &
|
||||||
|
IIf(rsRappel.Fields("c_adr2").Value.ToString.Length > 0, rsRappel.Fields("c_adr2").Value & "<br />", "") & _
|
||||||
|
rsRappel.Fields("c_ville").Value & "<br />" & "<p>" & _
|
||||||
|
"<p>En cas d'empêchement, veuillez nous contacter au <b>" & rsRappel.Fields("tel").Value & "</b>." & _
|
||||||
|
"<p>Veuillez agréer nos sincères salutations.</p>" & _
|
||||||
|
"<p>L'entreprise " & rsRappel.Fields("nom_societe").Value & "</p></body></html>"
|
||||||
|
|
||||||
|
SendNotification(ctDSN_AEM, "RAPPEL : rendez-vous le " & date_heure, szBody, rsRappel.Fields("c_email").Value, rsRappel.Fields("societe").Value)
|
||||||
|
nbEnvoyes += 1
|
||||||
|
End If
|
||||||
|
' marquer le rdv comme envoyé ou traité
|
||||||
|
szSQL = "UPDATE email_rappels SET envoye_le = NOW() WHERE no_id = " & rsRappel.Fields("no_id").Value
|
||||||
|
ExecQuery(ctDSN_AEM, szSQL)
|
||||||
|
' Get the next record
|
||||||
|
rsRappel.MoveNext()
|
||||||
|
Loop
|
||||||
|
' Close the recordset AND connection.
|
||||||
|
rsRappel.Close()
|
||||||
|
|
||||||
|
szSQL = "insert t_log_nuit (proc,msg) values ('RAPPELS','- Fin ENVOI emails : " & nbLus & " rdv lus, " & nbEnvoyes & " rappels envoyés, soit " &
|
||||||
|
Math.Round(nbEnvoyes * 100 / nbLus, 0).ToString & " % envoyés.');"
|
||||||
|
ExecQuery(ctDSN_AEM, szSQL)
|
||||||
|
|
||||||
|
return
|
||||||
|
|
||||||
|
def email_rappels:
|
||||||
|
' Lire la societe
|
||||||
|
szSQL = "SELECT * FROM p_societe WHERE societe='" & societe & "';"
|
||||||
|
GetRecordset(ctDSN_AEM, szSQL, rs)
|
||||||
|
If rs.RecordCount > 0 Then
|
||||||
|
szFrom = rs.Fields("email_from").Value
|
||||||
|
Else
|
||||||
|
szFrom = "peinture@entreprise-dumas.com"
|
||||||
|
End If
|
||||||
|
rs.Close()
|
||||||
|
rs = Nothing
|
||||||
|
|
||||||
|
' Set the SMTP server
|
||||||
|
Dim Smtp_Server As New SmtpClient(My.Settings.SmtpHost, My.Settings.SmtpPort)
|
||||||
|
If My.Settings.SmtpSSL = "True" Then
|
||||||
|
' envoyer la notification avec le compte de l'agence
|
||||||
|
Smtp_Server.Credentials = New Net.NetworkCredential(My.Settings.SmtpUsername, My.Settings.SmtpPassword)
|
||||||
|
End If
|
||||||
|
Smtp_Server.EnableSsl = My.Settings.SmtpSSL
|
||||||
|
If My.Settings.SmtpUsername = "cao.thien-phuoc@orange.fr" Then
|
||||||
|
szFrom = My.Settings.SmtpUsername
|
||||||
|
szEmail = "ctphuoc@gmail.com"
|
||||||
|
szCCI = "ctphuoc@gmail.com"
|
||||||
|
End If
|
||||||
|
|
||||||
|
' create the mail message
|
||||||
|
Dim mail As New MailMessage()
|
||||||
|
mail.From = New MailAddress(szFrom, "Entreprise DUMAS")
|
||||||
|
'set the content
|
||||||
|
mail.Subject = szSubjet
|
||||||
|
mail.IsBodyHtml = True
|
||||||
|
mail.Body = szBody
|
||||||
|
|
||||||
|
mail.To.Add(szEmail)
|
||||||
|
Try
|
||||||
|
Smtp_Server.Send(mail)
|
||||||
|
Catch error_t As Exception
|
||||||
|
MsgBox(error_t.ToString, MsgBoxStyle.Critical)
|
||||||
|
Exit Sub
|
||||||
|
End Try
|
||||||
|
|||||||
Reference in New Issue
Block a user