|
@@ -28,11 +28,26 @@ config.read(args.config)
|
|
|
confac = config['ac']
|
|
|
confdoli = config['dolibarr']
|
|
|
confsympa = config['sympa']
|
|
|
+confsmtp = config['smtp']
|
|
|
|
|
|
conn = psycopg2.connect(host=confdoli['host'], database=confdoli['database'],
|
|
|
user=confdoli['user'], password=confdoli['password'])
|
|
|
|
|
|
doli = dolibarr.Instance(conn)
|
|
|
+s = smtplib.SMTP(confsmtp.get('host', 'localhost'))
|
|
|
+pp = pprint.PrettyPrinter()
|
|
|
+
|
|
|
+if confac.get('audit_dolibarr_users', False):
|
|
|
+ usrfields = ["firstname", "lastname", "email"]
|
|
|
+ cur = doli.get_users(fields=usrfields, active_user=True, active_member=False)
|
|
|
+ badusers = cur.fetchall()
|
|
|
+ if len(badusers) != 0:
|
|
|
+ body = "Salut, \n\nDes utilisateurs ne sont pas associés à un membre actif : \n\n" + pp.pformat(badusers)
|
|
|
+ msg = MIMEText(body)
|
|
|
+ msg['Subject'] = "Rapport utilisateurs Dolibarr"
|
|
|
+ msg['From'] = confsmtp.get('from', 'root')
|
|
|
+ msg['To'] = confac.get('audit_recipients', 'root')
|
|
|
+ s.send_message(msg)
|
|
|
|
|
|
fields = ["rowid", "firstname", "lastname", "email"]
|
|
|
fieldsextra = ['email_second']
|
|
@@ -100,10 +115,6 @@ for editor in editors:
|
|
|
|
|
|
reportFormat = open('/etc/fcntoolbox/fcn-report.format', 'r').read()
|
|
|
|
|
|
-s = smtplib.SMTP('localhost')
|
|
|
-
|
|
|
-pp = pprint.PrettyPrinter()
|
|
|
-
|
|
|
def sendReport(listname, tosubscribe, tounsubscribe, removeeditors):
|
|
|
body = reportFormat.format(
|
|
|
list = listname,
|