26include_once DOL_DOCUMENT_ROOT.
'/contact/class/contact.class.php';
27include_once DOL_DOCUMENT_ROOT.
'/societe/class/societe.class.php';
28include_once DOL_DOCUMENT_ROOT.
'/adherents/class/adherent.class.php';
29include_once DOL_DOCUMENT_ROOT.
'/core/lib/security.lib.php';
65 global $langs,
$conf, $db;
67 $langs->load(
"companies");
69 $sql =
"SELECT c.rowid";
70 $sql .=
" FROM ".MAIN_DB_PREFIX.
"socpeople as c";
71 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"societe as s ON c.fk_soc = s.rowid";
72 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"socpeople_extrafields as spe ON spe.fk_object = c.rowid";
73 $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))";
74 $sql .=
" AND spe.datapolicy_send IS NULL";
75 $sql .=
" AND c.entity = ".((int)
$conf->entity);
76 $resql = $this->db->query($sql);
78 $num = $this->db->num_rows($resql);
81 $obj = $this->db->fetch_object($resql);
83 $contact->fetch($obj->rowid);
89 $this->error = $this->db->error();
103 global $langs,
$conf, $db;
105 $langs->load(
"companies");
107 $sql =
"SELECT s.rowid";
108 $sql .=
" FROM ".MAIN_DB_PREFIX.
"societe as s";
109 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"societe_extrafields as se ON se.fk_object = s.rowid";
110 $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)";
111 $sql .=
" AND se.datapolicy_send IS NULL";
112 $sql .=
" AND s.entity = ".((int)
$conf->entity);
113 $resql = $this->db->query($sql);
115 $num = $this->db->num_rows($resql);
118 $obj = $this->db->fetch_object($resql);
120 $societe->fetch($obj->rowid);
126 $this->error = $this->db->error();
140 global $langs,
$conf, $db;
142 $langs->load(
"adherent");
144 $sql =
"SELECT a.rowid";
145 $sql .=
" FROM ".MAIN_DB_PREFIX.
"adherent as a";
146 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"adherent_extrafields as ae ON ae.fk_object = a.rowid";
147 $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)";
148 $sql .=
" AND ae.datapolicy_send IS NULL";
149 $sql .=
" AND a.entity = ".((int)
$conf->entity);
150 $resql = $this->db->query($sql);
152 $num = $this->db->num_rows($resql);
155 $obj = $this->db->fetch_object($resql);
157 $adherent->fetch($obj->rowid);
163 $this->error = $this->db->error();
178 global $langs, $db, $user;
182 $from = $user->getFullName($langs).
' <'.$user->email.
'>';
184 $sendto = $contact->email;
185 $code =
dol_hash($contact->email,
'md5');
186 if (!empty($contact->default_lang)) {
187 $l = $contact->default_lang;
189 $l = $langs->defaultlang;
192 $s =
"DATAPOLICYSUBJECT_".$l;
193 $ma =
"DATAPOLICYCONTENT_".$l;
194 $la =
'TXTLINKDATAPOLICYACCEPT_'.$l;
195 $lr =
'TXTLINKDATAPOLICYREFUSE_'.$l;
201 $sendtocc = $sendtobcc =
'';
202 $filepath = $mimetype = $filename = array();
203 $deliveryreceipt = 0;
205 $substitutionarray = array(
206 '__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>',
207 '__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>',
208 '__FIRSTNAME__' => $contact->firstname,
209 '__NAME__' => $contact->lastname,
210 '__CIVILITY__' => $contact->civility,
215 $actiontypecode =
'AC_EMAIL';
216 $actionmsg = $langs->transnoentities(
'MailSentByTo', $from, $sendto);
219 $actionmsg =
dol_concatdesc($actionmsg, $langs->transnoentities(
'Bcc').
": ".$sendtocc);
221 $actionmsg =
dol_concatdesc($actionmsg, $langs->transnoentities(
'MailTopic').
": ".$subject);
222 $actionmsg =
dol_concatdesc($actionmsg, $langs->transnoentities(
'TextUsedInTheMessageBody').
":");
228 require_once DOL_DOCUMENT_ROOT.
'/core/class/CMailFile.class.php';
229 $mailfile =
new CMailFile($subject, $sendto, $from, $message, $filepath, $mimetype, $filename, $sendtocc, $sendtobcc, $deliveryreceipt, -1);
231 $resultmasssend =
'';
232 if ($mailfile->error) {
233 $resultmasssend .=
'<div class="error">'.$mailfile->error.
'</div>';
235 $resultmail = $mailfile->sendfile();
238 $resultmasssend .= $langs->trans(
"MailSent").
': '.$sendto.
"<br>";
239 $contact->array_options[
'options_datapolicy_send'] = date(
'Y-m-d', time());
240 $contact->update($contact->id);
256 global $langs, $db, $user;
260 $from = $user->getFullName($langs).
' <'.$user->email.
'>';
262 $sendto = $societe->email;
264 $code =
dol_hash($societe->email,
'md5');
265 if (!empty($societe->default_lang)) {
266 $l = $societe->default_lang;
268 $l = $langs->defaultlang;
271 $s =
"DATAPOLICYSUBJECT_".$l;
272 $ma =
"DATAPOLICYCONTENT_".$l;
273 $la =
'TXTLINKDATAPOLICYACCEPT_'.$l;
274 $lr =
'TXTLINKDATAPOLICYREFUSE_'.$l;
280 $sendtocc = $sendtobcc =
'';
281 $filepath = $mimetype = $filename = array();
282 $deliveryreceipt = 0;
284 $substitutionarray = array(
285 '__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>',
286 '__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>',
291 $actiontypecode =
'AC_EMAIL';
292 $actionmsg = $langs->transnoentities(
'MailSentByTo', $from, $sendto);
295 $actionmsg =
dol_concatdesc($actionmsg, $langs->transnoentities(
'Bcc').
": ".$sendtocc);
297 $actionmsg =
dol_concatdesc($actionmsg, $langs->transnoentities(
'MailTopic').
": ".$subject);
298 $actionmsg =
dol_concatdesc($actionmsg, $langs->transnoentities(
'TextUsedInTheMessageBody').
":");
303 require_once DOL_DOCUMENT_ROOT.
'/core/class/CMailFile.class.php';
304 $mailfile =
new CMailFile($subject, $sendto, $from, $message, $filepath, $mimetype, $filename, $sendtocc, $sendtobcc, $deliveryreceipt, -1);
306 $resultmasssend =
'';
307 if ($mailfile->error) {
308 $resultmasssend .=
'<div class="error">'.$mailfile->error.
'</div>';
310 $resultmail = $mailfile->sendfile();
313 $resultmasssend .= $langs->trans(
"MailSent").
': '.$sendto.
"<br>";
314 $societe->array_options[
'options_datapolicy_send'] = date(
'Y-m-d', time());
315 $societe->update($societe->id, $user);
331 global $langs, $db, $user;
335 $from = $user->getFullName($langs).
' <'.$user->email.
'>';
337 $sendto = $adherent->email;
339 $code =
dol_hash($adherent->email,
'md5');
340 if (!empty($adherent->default_lang)) {
341 $l = $adherent->default_lang;
343 $l = $langs->defaultlang;
346 $s =
'TXTLINKDATAPOLICYSUBJECT_'.$l;
347 $ma =
'TXTLINKDATAPOLICYMESSAGE_'.$l;
348 $la =
'TXTLINKDATAPOLICYACCEPT_'.$l;
349 $lr =
'TXTLINKDATAPOLICYREFUSE_'.$l;
355 $sendtocc = $sendtobcc =
'';
356 $filepath = $mimetype = $filename = array();
357 $deliveryreceipt = 0;
359 $substitutionarray = array(
360 '__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>',
361 '__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>',
366 $actiontypecode =
'AC_EMAIL';
367 $actionmsg = $langs->transnoentities(
'MailSentByTo', $from, $sendto);
370 $actionmsg =
dol_concatdesc($actionmsg, $langs->transnoentities(
'Bcc').
": ".$sendtocc);
372 $actionmsg =
dol_concatdesc($actionmsg, $langs->transnoentities(
'MailTopic').
": ".$subject);
373 $actionmsg =
dol_concatdesc($actionmsg, $langs->transnoentities(
'TextUsedInTheMessageBody').
":");
379 require_once DOL_DOCUMENT_ROOT.
'/core/class/CMailFile.class.php';
380 $mailfile =
new CMailFile($subject, $sendto, $from, $message, $filepath, $mimetype, $filename, $sendtocc, $sendtobcc, $deliveryreceipt, -1);
382 $resultmasssend =
'';
383 if ($mailfile->error) {
384 $resultmasssend .=
'<div class="error">'.$mailfile->error.
'</div>';
386 $resultmail = $mailfile->sendfile();
389 $resultmasssend .= $langs->trans(
"MailSent").
': '.$sendto.
"<br>";
390 $adherent->array_options[
'options_datapolicy_send'] = date(
'Y-m-d', time());
391 $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.
global $conf
The following vars must be defined: $type2label $form $conf, $lang, The following vars may also be de...
dol_hash($chain, $type='0', $nosalt=0)
Returns a hash (non reversible encryption) of a string.