24include_once DOL_DOCUMENT_ROOT.
'/contact/class/contact.class.php';
25include_once DOL_DOCUMENT_ROOT.
'/societe/class/societe.class.php';
26include_once DOL_DOCUMENT_ROOT.
'/adherents/class/adherent.class.php';
27include_once DOL_DOCUMENT_ROOT.
'/core/lib/security.lib.php';
60 global $langs, $conf, $db, $user;
62 $langs->load(
"companies");
64 $sql =
"SELECT c.rowid";
65 $sql .=
" FROM ".MAIN_DB_PREFIX.
"socpeople as c";
66 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"societe as s ON c.fk_soc = s.rowid";
67 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"socpeople_extrafields as spe ON spe.fk_object = c.rowid";
68 $sql .=
" WHERE (c.statut=1 AND c.no_email=0 AND (spe.datapolicy_consentement=0 OR spe.datapolicy_consentement IS NULL) AND (spe.datapolicy_opposition_traitement=0 OR spe.datapolicy_opposition_traitement IS NULL) AND (spe.datapolicy_opposition_prospection=0 OR spe.datapolicy_opposition_prospection IS NULL))";
69 $sql .=
" AND spe.datapolicy_send IS NULL";
70 $sql .=
" AND c.entity=".$conf->entity;
71 $resql = $this->db->query($sql);
73 $num = $this->db->num_rows($resql);
76 $obj = $this->db->fetch_object($resql);
78 $contact->fetch($obj->rowid);
84 $this->error = $this->db->error();
98 global $langs, $conf, $db, $user;
100 $langs->load(
"companies");
102 $sql =
"SELECT s.rowid";
103 $sql .=
" FROM ".MAIN_DB_PREFIX.
"societe as s";
104 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"societe_extrafields as se ON se.fk_object = s.rowid";
105 $sql .=
" WHERE s.statut=0 AND (se.datapolicy_consentement=0 OR se.datapolicy_consentement IS NULL) AND (se.datapolicy_opposition_traitement=0 OR se.datapolicy_opposition_traitement IS NULL) AND (se.datapolicy_opposition_prospection=0 OR se.datapolicy_opposition_prospection IS NULL)";
106 $sql .=
" AND se.datapolicy_send IS NULL";
107 $sql .=
" AND s.entity=".$conf->entity;
108 $resql = $this->db->query($sql);
110 $num = $this->db->num_rows($resql);
113 $obj = $this->db->fetch_object($resql);
115 $societe->fetch($obj->rowid);
121 $this->error = $this->db->error();
135 global $langs, $conf, $db, $user;
137 $langs->load(
"adherent");
139 $sql =
"SELECT a.rowid";
140 $sql .=
" FROM ".MAIN_DB_PREFIX.
"adherent as a";
141 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"adherent_extrafields as ae ON ae.fk_object = a.rowid";
142 $sql .=
" WHERE a.statut=0 AND (ae.datapolicy_consentement=0 OR ae.datapolicy_consentement IS NULL) AND (ae.datapolicy_opposition_traitement=0 OR ae.datapolicy_opposition_traitement IS NULL) AND (ae.datapolicy_opposition_prospection=0 OR ae.datapolicy_opposition_prospection IS NULL)";
143 $sql .=
" AND ae.datapolicy_send IS NULL";
144 $sql .=
" AND a.entity=".$conf->entity;
145 $resql = $this->db->query($sql);
147 $num = $this->db->num_rows($resql);
150 $obj = $this->db->fetch_object($resql);
152 $adherent->fetch($obj->rowid);
158 $this->error = $this->db->error();
173 global $langs, $conf, $db, $user;
177 $from = $user->getFullName($langs).
' <'.$user->email.
'>';
179 $sendto = $contact->email;
180 $code =
dol_hash($contact->email,
'md5');
181 if (!empty($contact->default_lang)) {
182 $l = $contact->default_lang;
184 $l = $langs->defaultlang;
187 $s =
"DATAPOLICYSUBJECT_".$l;
188 $ma =
"DATAPOLICYCONTENT_".$l;
189 $la =
'TXTLINKDATAPOLICYACCEPT_'.$l;
190 $lr =
'TXTLINKDATAPOLICYREFUSE_'.$l;
196 $sendtocc = $sendtobcc =
'';
197 $filepath = $mimetype = $filename = array();
198 $deliveryreceipt = 0;
200 $substitutionarray = array(
201 '__LINKACCEPT__' =>
'<a href="'.
dol_buildpath(
'/public/datapolicy/index.php?action=1&c='.$contact->id.
'&l='.$l.
'&key='.$code, 3).
'" target="_blank" rel="noopener noreferrer">'.$linka.
'</a>',
202 '__LINKREFUSED__' =>
'<a href="'.dol_buildpath(
'/public/datapolicy/index.php?action=2&c='.$contact->id.
'&l='.$l.
'&key='.$code, 3).
'" target="_blank" rel="noopener noreferrer">'.$linkr.
'</a>',
203 '__FIRSTNAME__' => $contact->firstname,
204 '__NAME__' => $contact->lastname,
205 '__CIVILITY__' => $contact->civility,
210 $actiontypecode =
'AC_EMAIL';
211 $actionmsg = $langs->transnoentities(
'MailSentByTo', $from, $sendto);
214 $actionmsg =
dol_concatdesc($actionmsg, $langs->transnoentities(
'Bcc').
": ".$sendtocc);
216 $actionmsg =
dol_concatdesc($actionmsg, $langs->transnoentities(
'MailTopic').
": ".$subject);
217 $actionmsg =
dol_concatdesc($actionmsg, $langs->transnoentities(
'TextUsedInTheMessageBody').
":");
223 require_once DOL_DOCUMENT_ROOT.
'/core/class/CMailFile.class.php';
224 $mailfile =
new CMailFile($subject, $sendto, $from, $message, $filepath, $mimetype, $filename, $sendtocc, $sendtobcc, $deliveryreceipt, -1);
226 $resultmasssend =
'';
227 if ($mailfile->error) {
228 $resultmasssend .=
'<div class="error">'.$mailfile->error.
'</div>';
230 $resultmail = $mailfile->sendfile();
233 $resultmasssend .= $langs->trans(
"MailSent").
': '.$sendto.
"<br>";
234 $contact->array_options[
'options_datapolicy_send'] = date(
'Y-m-d', time());
235 $contact->update($contact->id);
251 global $langs, $conf, $db, $user;
255 $from = $user->getFullName($langs).
' <'.$user->email.
'>';
257 $sendto = $societe->email;
259 $code =
dol_hash($societe->email,
'md5');
260 if (!empty($societe->default_lang)) {
261 $l = $societe->default_lang;
263 $l = $langs->defaultlang;
266 $s =
"DATAPOLICYSUBJECT_".$l;
267 $ma =
"DATAPOLICYCONTENT_".$l;
268 $la =
'TXTLINKDATAPOLICYACCEPT_'.$l;
269 $lr =
'TXTLINKDATAPOLICYREFUSE_'.$l;
275 $sendtocc = $sendtobcc =
'';
276 $filepath = $mimetype = $filename = array();
277 $deliveryreceipt = 0;
279 $substitutionarray = array(
280 '__LINKACCEPT__' =>
'<a href="'.
dol_buildpath(
'/public/datapolicy/index.php?action=1&s='.$societe->id.
'&l='.$l.
'&key='.$code, 3).
'" target="_blank" rel="noopener noreferrer">'.$linka.
'</a>',
281 '__LINKREFUSED__' =>
'<a href="'.dol_buildpath(
'/public/datapolicy/index.php?action=2&s='.$societe->id.
'&l='.$l.
'&key='.$code, 3).
'" target="_blank" rel="noopener noreferrer">'.$linkr.
'</a>',
286 $actiontypecode =
'AC_EMAIL';
287 $actionmsg = $langs->transnoentities(
'MailSentByTo', $from, $sendto);
290 $actionmsg =
dol_concatdesc($actionmsg, $langs->transnoentities(
'Bcc').
": ".$sendtocc);
292 $actionmsg =
dol_concatdesc($actionmsg, $langs->transnoentities(
'MailTopic').
": ".$subject);
293 $actionmsg =
dol_concatdesc($actionmsg, $langs->transnoentities(
'TextUsedInTheMessageBody').
":");
298 require_once DOL_DOCUMENT_ROOT.
'/core/class/CMailFile.class.php';
299 $mailfile =
new CMailFile($subject, $sendto, $from, $message, $filepath, $mimetype, $filename, $sendtocc, $sendtobcc, $deliveryreceipt, -1);
301 $resultmasssend =
'';
302 if ($mailfile->error) {
303 $resultmasssend .=
'<div class="error">'.$mailfile->error.
'</div>';
305 $resultmail = $mailfile->sendfile();
308 $resultmasssend .= $langs->trans(
"MailSent").
': '.$sendto.
"<br>";
309 $societe->array_options[
'options_datapolicy_send'] = date(
'Y-m-d', time());
310 $societe->update($societe->id, $user);
326 global $langs, $conf, $db, $user;
330 $from = $user->getFullName($langs).
' <'.$user->email.
'>';
332 $sendto = $adherent->email;
334 $code =
dol_hash($adherent->email,
'md5');
335 if (!empty($adherent->default_lang)) {
336 $l = $adherent->default_lang;
338 $l = $langs->defaultlang;
341 $s =
'TXTLINKDATAPOLICYSUBJECT_'.$l;
342 $ma =
'TXTLINKDATAPOLICYMESSAGE_'.$l;
343 $la =
'TXTLINKDATAPOLICYACCEPT_'.$l;
344 $lr =
'TXTLINKDATAPOLICYREFUSE_'.$l;
350 $sendtocc = $sendtobcc =
'';
351 $filepath = $mimetype = $filename = array();
352 $deliveryreceipt = 0;
354 $substitutionarray = array(
355 '__LINKACCEPT__' =>
'<a href="'.
dol_buildpath(
'/public/datapolicy/index.php?action=1&a='.$adherent->id.
'&l='.$l.
'&key='.$code, 3).
'" target="_blank" rel="noopener noreferrer">'.$linka.
'</a>',
356 '__LINKREFUSED__' =>
'<a href="'.dol_buildpath(
'/public/datapolicy/index.php?action=2&a='.$adherent->id.
'&l='.$l.
'&key='.$code, 3).
'" target="_blank" rel="noopener noreferrer">'.$linkr.
'</a>',
361 $actiontypecode =
'AC_EMAIL';
362 $actionmsg = $langs->transnoentities(
'MailSentByTo', $from, $sendto);
365 $actionmsg =
dol_concatdesc($actionmsg, $langs->transnoentities(
'Bcc').
": ".$sendtocc);
367 $actionmsg =
dol_concatdesc($actionmsg, $langs->transnoentities(
'MailTopic').
": ".$subject);
368 $actionmsg =
dol_concatdesc($actionmsg, $langs->transnoentities(
'TextUsedInTheMessageBody').
":");
374 require_once DOL_DOCUMENT_ROOT.
'/core/class/CMailFile.class.php';
375 $mailfile =
new CMailFile($subject, $sendto, $from, $message, $filepath, $mimetype, $filename, $sendtocc, $sendtobcc, $deliveryreceipt, -1);
377 $resultmasssend =
'';
378 if ($mailfile->error) {
379 $resultmasssend .=
'<div class="error">'.$mailfile->error.
'</div>';
381 $resultmail = $mailfile->sendfile();
384 $resultmasssend .= $langs->trans(
"MailSent").
': '.$sendto.
"<br>";
385 $adherent->array_options[
'options_datapolicy_send'] = date(
'Y-m-d', time());
386 $adherent->update($user);
Class to manage members of a foundation.
Class to send emails (with attachments or not) Usage: $mailfile = new CMailFile($subject,...
__construct($db)
Constructor.
static sendMailDataPolicyAdherent($adherent)
sendMailDataPolicyAdherent
getAllContactNotInformed()
getAllContactNotInformed
static sendMailDataPolicyContact($contact)
sendMailDataPolicyContact
getAllCompaniesNotInformed()
getAllCompaniesNotInformed
getAllAdherentsNotInformed()
getAllAdherentsNotInformed
static sendMailDataPolicyCompany($societe)
sendMailDataPolicyCompany
Class to manage third parties objects (customers, suppliers, prospects...)
setEventMessage($mesgs, $style='mesgs', $noduplicate=0, $attop=0)
Set event message in dol_events session object.
dol_concatdesc($text1, $text2, $forxml=false, $invert=false)
Concat 2 descriptions with a new line between them (second operand after first one with appropriate n...
make_substitutions($text, $substitutionarray, $outputlangs=null, $converttextinhtmlifnecessary=0)
Make substitution into a text string, replacing keys with vals from $substitutionarray (oldval=>newva...
dol_buildpath($path, $type=0, $returnemptyifnotfound=0)
Return path of url or filesystem.
dol_print_error($db=null, $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
dol_hash($chain, $type='0', $nosalt=0)
Returns a hash (non reversible encryption) of a string.