rename last_emailing to rappels_rdv
This commit is contained in:
@@ -19,3 +19,92 @@ def batch_nuit(request):
|
||||
|
||||
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