25include_once DOL_DOCUMENT_ROOT.
'/contact/class/contact.class.php';
26include_once DOL_DOCUMENT_ROOT.
'/societe/class/societe.class.php';
27include_once DOL_DOCUMENT_ROOT.
'/adherents/class/adherent.class.php';
28include_once DOL_DOCUMENT_ROOT.
'/core/lib/security.lib.php';
64 global $langs,
$conf, $db, $user;
66 $langs->load(
"companies");
68 $sql =
"SELECT c.rowid";
69 $sql .=
" FROM ".MAIN_DB_PREFIX.
"socpeople as c";
70 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"societe as s ON c.fk_soc = s.rowid";
71 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"socpeople_extrafields as spe ON spe.fk_object = c.rowid";
72 $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))";
73 $sql .=
" AND spe.datapolicy_send IS NULL";
74 $sql .=
" AND c.entity=".$conf->entity;
75 $resql = $this->db->query($sql);
77 $num = $this->db->num_rows($resql);
80 $obj = $this->db->fetch_object($resql);
82 $contact->fetch($obj->rowid);
88 $this->error = $this->db->error();
102 global $langs,
$conf, $db, $user;
104 $langs->load(
"companies");
106 $sql =
"SELECT s.rowid";
107 $sql .=
" FROM ".MAIN_DB_PREFIX.
"societe as s";
108 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"societe_extrafields as se ON se.fk_object = s.rowid";
109 $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)";
110 $sql .=
" AND se.datapolicy_send IS NULL";
111 $sql .=
" AND s.entity=".$conf->entity;
112 $resql = $this->db->query($sql);
114 $num = $this->db->num_rows($resql);
117 $obj = $this->db->fetch_object($resql);
119 $societe->fetch($obj->rowid);
125 $this->error = $this->db->error();
139 global $langs,
$conf, $db, $user;
141 $langs->load(
"adherent");
143 $sql =
"SELECT a.rowid";
144 $sql .=
" FROM ".MAIN_DB_PREFIX.
"adherent as a";
145 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"adherent_extrafields as ae ON ae.fk_object = a.rowid";
146 $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)";
147 $sql .=
" AND ae.datapolicy_send IS NULL";
148 $sql .=
" AND a.entity=".$conf->entity;
149 $resql = $this->db->query($sql);
151 $num = $this->db->num_rows($resql);
154 $obj = $this->db->fetch_object($resql);
156 $adherent->fetch($obj->rowid);
162 $this->error = $this->db->error();
177 global $langs,
$conf, $db, $user;
181 $from = $user->getFullName($langs).
' <'.$user->email.
'>';
183 $sendto = $contact->email;
184 $code =
dol_hash($contact->email,
'md5');
185 if (!empty($contact->default_lang)) {
186 $l = $contact->default_lang;
188 $l = $langs->defaultlang;
191 $s =
"DATAPOLICYSUBJECT_".$l;
192 $ma =
"DATAPOLICYCONTENT_".$l;
193 $la =
'TXTLINKDATAPOLICYACCEPT_'.$l;
194 $lr =
'TXTLINKDATAPOLICYREFUSE_'.$l;
200 $sendtocc = $sendtobcc =
'';
201 $filepath = $mimetype = $filename = array();
202 $deliveryreceipt = 0;
204 $substitutionarray = array(
205 '__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>',
206 '__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>',
207 '__FIRSTNAME__' => $contact->firstname,
208 '__NAME__' => $contact->lastname,
209 '__CIVILITY__' => $contact->civility,
214 $actiontypecode =
'AC_EMAIL';
215 $actionmsg = $langs->transnoentities(
'MailSentByTo', $from, $sendto);
218 $actionmsg =
dol_concatdesc($actionmsg, $langs->transnoentities(
'Bcc').
": ".$sendtocc);
220 $actionmsg =
dol_concatdesc($actionmsg, $langs->transnoentities(
'MailTopic').
": ".$subject);
221 $actionmsg =
dol_concatdesc($actionmsg, $langs->transnoentities(
'TextUsedInTheMessageBody').
":");
227 require_once DOL_DOCUMENT_ROOT.
'/core/class/CMailFile.class.php';
228 $mailfile =
new CMailFile($subject, $sendto, $from, $message, $filepath, $mimetype, $filename, $sendtocc, $sendtobcc, $deliveryreceipt, -1);
230 $resultmasssend =
'';
231 if ($mailfile->error) {
232 $resultmasssend .=
'<div class="error">'.$mailfile->error.
'</div>';
234 $resultmail = $mailfile->sendfile();
237 $resultmasssend .= $langs->trans(
"MailSent").
': '.$sendto.
"<br>";
238 $contact->array_options[
'options_datapolicy_send'] = date(
'Y-m-d', time());
239 $contact->update($contact->id);
255 global $langs,
$conf, $db, $user;
259 $from = $user->getFullName($langs).
' <'.$user->email.
'>';
261 $sendto = $societe->email;
263 $code =
dol_hash($societe->email,
'md5');
264 if (!empty($societe->default_lang)) {
265 $l = $societe->default_lang;
267 $l = $langs->defaultlang;
270 $s =
"DATAPOLICYSUBJECT_".$l;
271 $ma =
"DATAPOLICYCONTENT_".$l;
272 $la =
'TXTLINKDATAPOLICYACCEPT_'.$l;
273 $lr =
'TXTLINKDATAPOLICYREFUSE_'.$l;
279 $sendtocc = $sendtobcc =
'';
280 $filepath = $mimetype = $filename = array();
281 $deliveryreceipt = 0;
283 $substitutionarray = array(
284 '__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>',
285 '__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>',
290 $actiontypecode =
'AC_EMAIL';
291 $actionmsg = $langs->transnoentities(
'MailSentByTo', $from, $sendto);
294 $actionmsg =
dol_concatdesc($actionmsg, $langs->transnoentities(
'Bcc').
": ".$sendtocc);
296 $actionmsg =
dol_concatdesc($actionmsg, $langs->transnoentities(
'MailTopic').
": ".$subject);
297 $actionmsg =
dol_concatdesc($actionmsg, $langs->transnoentities(
'TextUsedInTheMessageBody').
":");
302 require_once DOL_DOCUMENT_ROOT.
'/core/class/CMailFile.class.php';
303 $mailfile =
new CMailFile($subject, $sendto, $from, $message, $filepath, $mimetype, $filename, $sendtocc, $sendtobcc, $deliveryreceipt, -1);
305 $resultmasssend =
'';
306 if ($mailfile->error) {
307 $resultmasssend .=
'<div class="error">'.$mailfile->error.
'</div>';
309 $resultmail = $mailfile->sendfile();
312 $resultmasssend .= $langs->trans(
"MailSent").
': '.$sendto.
"<br>";
313 $societe->array_options[
'options_datapolicy_send'] = date(
'Y-m-d', time());
314 $societe->update($societe->id, $user);
330 global $langs,
$conf, $db, $user;
334 $from = $user->getFullName($langs).
' <'.$user->email.
'>';
336 $sendto = $adherent->email;
338 $code =
dol_hash($adherent->email,
'md5');
339 if (!empty($adherent->default_lang)) {
340 $l = $adherent->default_lang;
342 $l = $langs->defaultlang;
345 $s =
'TXTLINKDATAPOLICYSUBJECT_'.$l;
346 $ma =
'TXTLINKDATAPOLICYMESSAGE_'.$l;
347 $la =
'TXTLINKDATAPOLICYACCEPT_'.$l;
348 $lr =
'TXTLINKDATAPOLICYREFUSE_'.$l;
354 $sendtocc = $sendtobcc =
'';
355 $filepath = $mimetype = $filename = array();
356 $deliveryreceipt = 0;
358 $substitutionarray = array(
359 '__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>',
360 '__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>',
365 $actiontypecode =
'AC_EMAIL';
366 $actionmsg = $langs->transnoentities(
'MailSentByTo', $from, $sendto);
369 $actionmsg =
dol_concatdesc($actionmsg, $langs->transnoentities(
'Bcc').
": ".$sendtocc);
371 $actionmsg =
dol_concatdesc($actionmsg, $langs->transnoentities(
'MailTopic').
": ".$subject);
372 $actionmsg =
dol_concatdesc($actionmsg, $langs->transnoentities(
'TextUsedInTheMessageBody').
":");
378 require_once DOL_DOCUMENT_ROOT.
'/core/class/CMailFile.class.php';
379 $mailfile =
new CMailFile($subject, $sendto, $from, $message, $filepath, $mimetype, $filename, $sendtocc, $sendtobcc, $deliveryreceipt, -1);
381 $resultmasssend =
'';
382 if ($mailfile->error) {
383 $resultmasssend .=
'<div class="error">'.$mailfile->error.
'</div>';
385 $resultmail = $mailfile->sendfile();
388 $resultmasssend .= $langs->trans(
"MailSent").
': '.$sendto.
"<br>";
389 $adherent->array_options[
'options_datapolicy_send'] = date(
'Y-m-d', time());
390 $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.