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';
51 global $langs, $conf, $db, $user;
53 $langs->load(
"companies");
55 $sql =
"SELECT c.rowid";
56 $sql .=
" FROM ".MAIN_DB_PREFIX.
"socpeople as c";
57 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"societe as s ON c.fk_soc = s.rowid";
58 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"socpeople_extrafields as spe ON spe.fk_object = c.rowid";
59 $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))";
60 $sql .=
" AND spe.datapolicy_send IS NULL";
61 $sql .=
" AND c.entity=".$conf->entity;
62 $resql = $this->db->query($sql);
64 $num = $this->db->num_rows($resql);
67 $obj = $this->db->fetch_object($resql);
69 $contact->fetch($obj->rowid);
75 $this->error = $this->db->error();
89 global $langs, $conf, $db, $user;
91 $langs->load(
"companies");
93 $sql =
"SELECT s.rowid";
94 $sql .=
" FROM ".MAIN_DB_PREFIX.
"societe as s";
95 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"societe_extrafields as se ON se.fk_object = s.rowid";
96 $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)";
97 $sql .=
" AND se.datapolicy_send IS NULL";
98 $sql .=
" AND s.entity=".$conf->entity;
99 $resql = $this->db->query($sql);
101 $num = $this->db->num_rows($resql);
104 $obj = $this->db->fetch_object($resql);
106 $societe->fetch($obj->rowid);
112 $this->error = $this->db->error();
126 global $langs, $conf, $db, $user;
128 $langs->load(
"adherent");
130 $sql =
"SELECT a.rowid";
131 $sql .=
" FROM ".MAIN_DB_PREFIX.
"adherent as a";
132 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"adherent_extrafields as ae ON ae.fk_object = a.rowid";
133 $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)";
134 $sql .=
" AND ae.datapolicy_send IS NULL";
135 $sql .=
" AND a.entity=".$conf->entity;
136 $resql = $this->db->query($sql);
138 $num = $this->db->num_rows($resql);
141 $obj = $this->db->fetch_object($resql);
143 $adherent->fetch($obj->rowid);
149 $this->error = $this->db->error();
164 global $langs, $conf, $db, $user;
168 $from = $user->getFullName($langs).
' <'.$user->email.
'>';
170 $sendto = $contact->email;
171 $code =
dol_hash($contact->email,
'md5');
172 if (!empty($contact->default_lang)) {
173 $l = $contact->default_lang;
175 $l = $langs->defaultlang;
178 $s =
"DATAPOLICYSUBJECT_".$l;
179 $ma =
"DATAPOLICYCONTENT_".$l;
180 $la =
'TXTLINKDATAPOLICYACCEPT_'.$l;
181 $lr =
'TXTLINKDATAPOLICYREFUSE_'.$l;
183 $subject = $conf->global->$s;
184 $message = $conf->global->$ma;
185 $linka = $conf->global->$la;
186 $linkr = $conf->global->$lr;
187 $sendtocc = $sendtobcc =
'';
188 $filepath = $mimetype = $filename = array();
189 $deliveryreceipt = 0;
191 $substitutionarray = array(
192 '__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>',
193 '__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>',
194 '__FIRSTNAME__' => $contact->firstname,
195 '__NAME__' => $contact->lastname,
196 '__CIVILITY__' => $contact->civility,
201 $actiontypecode =
'AC_EMAIL';
202 $actionmsg = $langs->transnoentities(
'MailSentBy').
' '.$from.
' '.$langs->transnoentities(
'To').
' '.$sendto;
205 $actionmsg =
dol_concatdesc($actionmsg, $langs->transnoentities(
'Bcc').
": ".$sendtocc);
207 $actionmsg =
dol_concatdesc($actionmsg, $langs->transnoentities(
'MailTopic').
": ".$subject);
208 $actionmsg =
dol_concatdesc($actionmsg, $langs->transnoentities(
'TextUsedInTheMessageBody').
":");
214 require_once DOL_DOCUMENT_ROOT.
'/core/class/CMailFile.class.php';
215 $mailfile =
new CMailFile($subject, $sendto, $from, $message, $filepath, $mimetype, $filename, $sendtocc, $sendtobcc, $deliveryreceipt, -1);
217 if ($mailfile->error) {
218 $resultmasssend .=
'<div class="error">'.$mailfile->error.
'</div>';
220 $result4 = $mailfile->sendfile();
222 $resultmasssend .= $langs->trans(
"MailSent").
': '.$sendto.
"<br>";
223 $contact->array_options[
'options_datapolicy_send'] = date(
'Y-m-d', time());
224 $contact->update($contact->id);
240 global $langs, $conf, $db, $user;
244 $from = $user->getFullName($langs).
' <'.$user->email.
'>';
246 $sendto = $societe->email;
248 $code =
dol_hash($societe->email,
'md5');
249 if (!empty($societe->default_lang)) {
250 $l = $societe->default_lang;
252 $l = $langs->defaultlang;
255 $s =
"DATAPOLICYSUBJECT_".$l;
256 $ma =
"DATAPOLICYCONTENT_".$l;
257 $la =
'TXTLINKDATAPOLICYACCEPT_'.$l;
258 $lr =
'TXTLINKDATAPOLICYREFUSE_'.$l;
260 $subject = $conf->global->$s;
261 $message = $conf->global->$ma;
262 $linka = $conf->global->$la;
263 $linkr = $conf->global->$lr;
264 $sendtocc = $sendtobcc =
'';
265 $filepath = $mimetype = $filename = array();
266 $deliveryreceipt = 0;
268 $substitutionarray = array(
269 '__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>',
270 '__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>',
275 $actiontypecode =
'AC_EMAIL';
276 $actionmsg = $langs->transnoentities(
'MailSentBy').
' '.$from.
' '.$langs->transnoentities(
'To').
' '.$sendto;
279 $actionmsg =
dol_concatdesc($actionmsg, $langs->transnoentities(
'Bcc').
": ".$sendtocc);
281 $actionmsg =
dol_concatdesc($actionmsg, $langs->transnoentities(
'MailTopic').
": ".$subject);
282 $actionmsg =
dol_concatdesc($actionmsg, $langs->transnoentities(
'TextUsedInTheMessageBody').
":");
287 require_once DOL_DOCUMENT_ROOT.
'/core/class/CMailFile.class.php';
288 $mailfile =
new CMailFile($subject, $sendto, $from, $message, $filepath, $mimetype, $filename, $sendtocc, $sendtobcc, $deliveryreceipt, -1);
289 if ($mailfile->error) {
290 $resultmasssend .=
'<div class="error">'.$mailfile->error.
'</div>';
292 $result4 = $mailfile->sendfile();
295 $resultmasssend .= $langs->trans(
"MailSent").
': '.$sendto.
"<br>";
296 $societe->array_options[
'options_datapolicy_send'] = date(
'Y-m-d', time());
297 $societe->update($societe->id);
313 global $langs, $conf, $db, $user;
317 $from = $user->getFullName($langs).
' <'.$user->email.
'>';
319 $sendto = $adherent->email;
321 $code =
dol_hash($adherent->email,
'md5');
322 if (!empty($adherent->default_lang)) {
323 $l = $adherent->default_lang;
325 $l = $langs->defaultlang;
328 $s =
'TXTLINKDATAPOLICYSUBJECT_'.$l;
329 $ma =
'TXTLINKDATAPOLICYMESSAGE_'.$l;
330 $la =
'TXTLINKDATAPOLICYACCEPT_'.$l;
331 $lr =
'TXTLINKDATAPOLICYREFUSE_'.$l;
333 $subject = $conf->global->$s;
334 $message = $conf->global->$ma;
335 $linka = $conf->global->$la;
336 $linkr = $conf->global->$lr;
337 $sendtocc = $sendtobcc =
'';
338 $filepath = $mimetype = $filename = array();
339 $deliveryreceipt = 0;
341 $substitutionarray = array(
342 '__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>',
343 '__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>',
348 $actiontypecode =
'AC_EMAIL';
349 $actionmsg = $langs->transnoentities(
'MailSentBy').
' '.$from.
' '.$langs->transnoentities(
'To').
' '.$sendto;
352 $actionmsg =
dol_concatdesc($actionmsg, $langs->transnoentities(
'Bcc').
": ".$sendtocc);
354 $actionmsg =
dol_concatdesc($actionmsg, $langs->transnoentities(
'MailTopic').
": ".$subject);
355 $actionmsg =
dol_concatdesc($actionmsg, $langs->transnoentities(
'TextUsedInTheMessageBody').
":");
361 require_once DOL_DOCUMENT_ROOT.
'/core/class/CMailFile.class.php';
362 $mailfile =
new CMailFile($subject, $sendto, $from, $message, $filepath, $mimetype, $filename, $sendtocc, $sendtobcc, $deliveryreceipt, -1);
363 if ($mailfile->error) {
364 $resultmasssend .=
'<div class="error">'.$mailfile->error.
'</div>';
366 $result4 = $mailfile->sendfile();
369 $resultmasssend .= $langs->trans(
"MailSent").
': '.$sendto.
"<br>";
370 $adherent->array_options[
'options_datapolicy_send'] = date(
'Y-m-d', time());
371 $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')
Returns a hash (non reversible encryption) of a string.