23include_once DOL_DOCUMENT_ROOT.
'/contact/class/contact.class.php';
24include_once DOL_DOCUMENT_ROOT.
'/societe/class/societe.class.php';
25include_once DOL_DOCUMENT_ROOT.
'/adherents/class/adherent.class.php';
26include_once DOL_DOCUMENT_ROOT.
'/core/lib/security.lib.php';
59 global $langs, $conf, $db, $user;
61 $langs->load(
"companies");
63 $sql =
"SELECT c.rowid";
64 $sql .=
" FROM ".MAIN_DB_PREFIX.
"socpeople as c";
65 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"societe as s ON c.fk_soc = s.rowid";
66 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"socpeople_extrafields as spe ON spe.fk_object = c.rowid";
67 $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))";
68 $sql .=
" AND spe.datapolicy_send IS NULL";
69 $sql .=
" AND c.entity=".$conf->entity;
70 $resql = $this->db->query($sql);
72 $num = $this->db->num_rows($resql);
75 $obj = $this->db->fetch_object($resql);
77 $contact->fetch($obj->rowid);
83 $this->error = $this->db->error();
97 global $langs, $conf, $db, $user;
99 $langs->load(
"companies");
101 $sql =
"SELECT s.rowid";
102 $sql .=
" FROM ".MAIN_DB_PREFIX.
"societe as s";
103 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"societe_extrafields as se ON se.fk_object = s.rowid";
104 $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)";
105 $sql .=
" AND se.datapolicy_send IS NULL";
106 $sql .=
" AND s.entity=".$conf->entity;
107 $resql = $this->db->query($sql);
109 $num = $this->db->num_rows($resql);
112 $obj = $this->db->fetch_object($resql);
114 $societe->fetch($obj->rowid);
120 $this->error = $this->db->error();
134 global $langs, $conf, $db, $user;
136 $langs->load(
"adherent");
138 $sql =
"SELECT a.rowid";
139 $sql .=
" FROM ".MAIN_DB_PREFIX.
"adherent as a";
140 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"adherent_extrafields as ae ON ae.fk_object = a.rowid";
141 $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)";
142 $sql .=
" AND ae.datapolicy_send IS NULL";
143 $sql .=
" AND a.entity=".$conf->entity;
144 $resql = $this->db->query($sql);
146 $num = $this->db->num_rows($resql);
149 $obj = $this->db->fetch_object($resql);
151 $adherent->fetch($obj->rowid);
157 $this->error = $this->db->error();
172 global $langs, $conf, $db, $user;
176 $from = $user->getFullName($langs).
' <'.$user->email.
'>';
178 $sendto = $contact->email;
179 $code =
dol_hash($contact->email,
'md5');
180 if (!empty($contact->default_lang)) {
181 $l = $contact->default_lang;
183 $l = $langs->defaultlang;
186 $s =
"DATAPOLICYSUBJECT_".$l;
187 $ma =
"DATAPOLICYCONTENT_".$l;
188 $la =
'TXTLINKDATAPOLICYACCEPT_'.$l;
189 $lr =
'TXTLINKDATAPOLICYREFUSE_'.$l;
191 $subject = $conf->global->$s;
192 $message = $conf->global->$ma;
193 $linka = $conf->global->$la;
194 $linkr = $conf->global->$lr;
195 $sendtocc = $sendtobcc =
'';
196 $filepath = $mimetype = $filename = array();
197 $deliveryreceipt = 0;
199 $substitutionarray = array(
200 '__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>',
201 '__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>',
202 '__FIRSTNAME__' => $contact->firstname,
203 '__NAME__' => $contact->lastname,
204 '__CIVILITY__' => $contact->civility,
209 $actiontypecode =
'AC_EMAIL';
210 $actionmsg = $langs->transnoentities(
'MailSentBy').
' '.$from.
' '.$langs->transnoentities(
'To').
' '.$sendto;
213 $actionmsg =
dol_concatdesc($actionmsg, $langs->transnoentities(
'Bcc').
": ".$sendtocc);
215 $actionmsg =
dol_concatdesc($actionmsg, $langs->transnoentities(
'MailTopic').
": ".$subject);
216 $actionmsg =
dol_concatdesc($actionmsg, $langs->transnoentities(
'TextUsedInTheMessageBody').
":");
222 require_once DOL_DOCUMENT_ROOT.
'/core/class/CMailFile.class.php';
223 $mailfile =
new CMailFile($subject, $sendto, $from, $message, $filepath, $mimetype, $filename, $sendtocc, $sendtobcc, $deliveryreceipt, -1);
225 $resultmasssend =
'';
226 if ($mailfile->error) {
227 $resultmasssend .=
'<div class="error">'.$mailfile->error.
'</div>';
229 $resultmail = $mailfile->sendfile();
232 $resultmasssend .= $langs->trans(
"MailSent").
': '.$sendto.
"<br>";
233 $contact->array_options[
'options_datapolicy_send'] = date(
'Y-m-d', time());
234 $contact->update($contact->id);
250 global $langs, $conf, $db, $user;
254 $from = $user->getFullName($langs).
' <'.$user->email.
'>';
256 $sendto = $societe->email;
258 $code =
dol_hash($societe->email,
'md5');
259 if (!empty($societe->default_lang)) {
260 $l = $societe->default_lang;
262 $l = $langs->defaultlang;
265 $s =
"DATAPOLICYSUBJECT_".$l;
266 $ma =
"DATAPOLICYCONTENT_".$l;
267 $la =
'TXTLINKDATAPOLICYACCEPT_'.$l;
268 $lr =
'TXTLINKDATAPOLICYREFUSE_'.$l;
270 $subject = $conf->global->$s;
271 $message = $conf->global->$ma;
272 $linka = $conf->global->$la;
273 $linkr = $conf->global->$lr;
274 $sendtocc = $sendtobcc =
'';
275 $filepath = $mimetype = $filename = array();
276 $deliveryreceipt = 0;
278 $substitutionarray = array(
279 '__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>',
280 '__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>',
285 $actiontypecode =
'AC_EMAIL';
286 $actionmsg = $langs->transnoentities(
'MailSentBy').
' '.$from.
' '.$langs->transnoentities(
'To').
' '.$sendto;
289 $actionmsg =
dol_concatdesc($actionmsg, $langs->transnoentities(
'Bcc').
": ".$sendtocc);
291 $actionmsg =
dol_concatdesc($actionmsg, $langs->transnoentities(
'MailTopic').
": ".$subject);
292 $actionmsg =
dol_concatdesc($actionmsg, $langs->transnoentities(
'TextUsedInTheMessageBody').
":");
297 require_once DOL_DOCUMENT_ROOT.
'/core/class/CMailFile.class.php';
298 $mailfile =
new CMailFile($subject, $sendto, $from, $message, $filepath, $mimetype, $filename, $sendtocc, $sendtobcc, $deliveryreceipt, -1);
300 $resultmasssend =
'';
301 if ($mailfile->error) {
302 $resultmasssend .=
'<div class="error">'.$mailfile->error.
'</div>';
304 $resultmail = $mailfile->sendfile();
307 $resultmasssend .= $langs->trans(
"MailSent").
': '.$sendto.
"<br>";
308 $societe->array_options[
'options_datapolicy_send'] = date(
'Y-m-d', time());
309 $societe->update($societe->id);
325 global $langs, $conf, $db, $user;
329 $from = $user->getFullName($langs).
' <'.$user->email.
'>';
331 $sendto = $adherent->email;
333 $code =
dol_hash($adherent->email,
'md5');
334 if (!empty($adherent->default_lang)) {
335 $l = $adherent->default_lang;
337 $l = $langs->defaultlang;
340 $s =
'TXTLINKDATAPOLICYSUBJECT_'.$l;
341 $ma =
'TXTLINKDATAPOLICYMESSAGE_'.$l;
342 $la =
'TXTLINKDATAPOLICYACCEPT_'.$l;
343 $lr =
'TXTLINKDATAPOLICYREFUSE_'.$l;
345 $subject = $conf->global->$s;
346 $message = $conf->global->$ma;
347 $linka = $conf->global->$la;
348 $linkr = $conf->global->$lr;
349 $sendtocc = $sendtobcc =
'';
350 $filepath = $mimetype = $filename = array();
351 $deliveryreceipt = 0;
353 $substitutionarray = array(
354 '__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>',
355 '__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>',
360 $actiontypecode =
'AC_EMAIL';
361 $actionmsg = $langs->transnoentities(
'MailSentBy').
' '.$from.
' '.$langs->transnoentities(
'To').
' '.$sendto;
364 $actionmsg =
dol_concatdesc($actionmsg, $langs->transnoentities(
'Bcc').
": ".$sendtocc);
366 $actionmsg =
dol_concatdesc($actionmsg, $langs->transnoentities(
'MailTopic').
": ".$subject);
367 $actionmsg =
dol_concatdesc($actionmsg, $langs->transnoentities(
'TextUsedInTheMessageBody').
":");
373 require_once DOL_DOCUMENT_ROOT.
'/core/class/CMailFile.class.php';
374 $mailfile =
new CMailFile($subject, $sendto, $from, $message, $filepath, $mimetype, $filename, $sendtocc, $sendtobcc, $deliveryreceipt, -1);
376 $resultmasssend =
'';
377 if ($mailfile->error) {
378 $resultmasssend .=
'<div class="error">'.$mailfile->error.
'</div>';
380 $resultmail = $mailfile->sendfile();
383 $resultmasssend .= $langs->trans(
"MailSent").
': '.$sendto.
"<br>";
384 $adherent->array_options[
'options_datapolicy_send'] = date(
'Y-m-d', time());
385 $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...)
dol_print_error($db='', $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
setEventMessage($mesgs, $style='mesgs', $noduplicate=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_hash($chain, $type='0', $nosalt=0)
Returns a hash (non reversible encryption) of a string.