23 include_once DOL_DOCUMENT_ROOT.
'/contact/class/contact.class.php';
24 include_once DOL_DOCUMENT_ROOT.
'/societe/class/societe.class.php';
25 include_once DOL_DOCUMENT_ROOT.
'/adherents/class/adherent.class.php';
50 global $langs, $conf, $db, $user;
52 $langs->load(
"companies");
54 $sql =
"SELECT c.rowid";
55 $sql .=
" FROM ".MAIN_DB_PREFIX.
"socpeople as c";
56 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"societe as s ON c.fk_soc = s.rowid";
57 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"socpeople_extrafields as spe ON spe.fk_object = c.rowid";
58 $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))";
59 $sql .=
" AND spe.datapolicy_send IS NULL";
60 $sql .=
" AND c.entity=".$conf->entity;
66 $obj = $this->
db->fetch_object(
$resql);
68 $contact->fetch($obj->rowid);
74 $this->error = $this->
db->error();
86 global $langs, $conf, $db, $user;
88 $langs->load(
"companies");
90 $sql =
"SELECT s.rowid";
91 $sql .=
" FROM ".MAIN_DB_PREFIX.
"societe as s";
92 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"societe_extrafields as se ON se.fk_object = s.rowid";
93 $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)";
94 $sql .=
" AND se.datapolicy_send IS NULL";
95 $sql .=
" AND s.entity=".$conf->entity;
101 $obj = $this->
db->fetch_object(
$resql);
103 $societe->fetch($obj->rowid);
109 $this->error = $this->
db->error();
121 global $langs, $conf, $db, $user;
123 $langs->load(
"adherent");
125 $sql =
"SELECT a.rowid";
126 $sql .=
" FROM ".MAIN_DB_PREFIX.
"adherent as a";
127 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"adherent_extrafields as ae ON ae.fk_object = a.rowid";
128 $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)";
129 $sql .=
" AND ae.datapolicy_send IS NULL";
130 $sql .=
" AND a.entity=".$conf->entity;
136 $obj = $this->
db->fetch_object(
$resql);
138 $adherent->fetch($obj->rowid);
144 $this->error = $this->
db->error();
157 global $langs, $conf, $db, $user;
161 $from = $user->getFullName($langs).
' <'.$user->email.
'>';
163 $sendto = $contact->email;
164 $code = md5($contact->email);
165 if (!empty($contact->default_lang)) {
166 $l = $contact->default_lang;
168 $l = $langs->defaultlang;
171 $s =
"DATAPOLICIESSUBJECT_".$l;
172 $ma =
"DATAPOLICIESCONTENT_".$l;
173 $la =
'TXTLINKDATAPOLICIESACCEPT_'.$l;
174 $lr =
'TXTLINKDATAPOLICIESREFUSE_'.$l;
176 $subject = $conf->global->$s;
177 $message = $conf->global->$ma;
178 $linka = $conf->global->$la;
179 $linkr = $conf->global->$lr;
180 $sendtocc = $sendtobcc =
'';
181 $filepath = $mimetype = $filename = array();
182 $deliveryreceipt = 0;
184 $substitutionarray = array(
185 '__LINKACCEPT__' =>
'<a href="'.
dol_buildpath(
'/datapolicy/public/index.php?action=1&c='.$contact->id.
'&l='.$l.
'&key='.$code, 3).
'" target="_blank" rel="noopener noreferrer">'.$linka.
'</a>',
186 '__LINKREFUSED__' =>
'<a href="'.dol_buildpath(
'/datapolicy/public/index.php?action=2&c='.$contact->id.
'&l='.$l.
'&key='.$code, 3).
'" target="_blank" rel="noopener noreferrer">'.$linkr.
'</a>',
187 '__FIRSTNAME__' => $contact->firstname,
188 '__NAME__' => $contact->lastname,
189 '__CIVILITY__' => $contact->civility,
194 $actiontypecode =
'AC_EMAIL';
195 $actionmsg = $langs->transnoentities(
'MailSentBy').
' '.$from.
' '.$langs->transnoentities(
'To').
' '.$sendto;
198 $actionmsg =
dol_concatdesc($actionmsg, $langs->transnoentities(
'Bcc').
": ".$sendtocc);
200 $actionmsg =
dol_concatdesc($actionmsg, $langs->transnoentities(
'MailTopic').
": ".$subject);
201 $actionmsg =
dol_concatdesc($actionmsg, $langs->transnoentities(
'TextUsedInTheMessageBody').
":");
207 require_once DOL_DOCUMENT_ROOT.
'/core/class/CMailFile.class.php';
208 $mailfile =
new CMailFile($subject, $sendto, $from, $message, $filepath, $mimetype, $filename, $sendtocc, $sendtobcc, $deliveryreceipt, -1);
210 if ($mailfile->error) {
211 $resultmasssend .=
'<div class="error">'.$mailfile->error.
'</div>';
213 $result4 = $mailfile->sendfile();
215 $resultmasssend .= $langs->trans(
"MailSent").
': '.$sendto.
"<br>";
216 $contact->array_options[
'options_datapolicy_send'] = date(
'Y-m-d', time());
217 $contact->update($contact->id);
233 global $langs, $conf, $db, $user;
237 $from = $user->getFullName($langs).
' <'.$user->email.
'>';
239 $sendto = $societe->email;
241 $code = md5($societe->email);
242 if (!empty($societe->default_lang)) {
243 $l = $societe->default_lang;
245 $l = $langs->defaultlang;
248 $s =
"DATAPOLICIESSUBJECT_".$l;
249 $ma =
"DATAPOLICIESCONTENT_".$l;
250 $la =
'TXTLINKDATAPOLICIESACCEPT_'.$l;
251 $lr =
'TXTLINKDATAPOLICIESREFUSE_'.$l;
253 $subject = $conf->global->$s;
254 $message = $conf->global->$ma;
255 $linka = $conf->global->$la;
256 $linkr = $conf->global->$lr;
257 $sendtocc = $sendtobcc =
'';
258 $filepath = $mimetype = $filename = array();
259 $deliveryreceipt = 0;
261 $substitutionarray = array(
262 '__LINKACCEPT__' =>
'<a href="'.
dol_buildpath(
'/datapolicy/public/index.php?action=1&s='.$societe->id.
'&l='.$l.
'&key='.$code, 3).
'" target="_blank" rel="noopener noreferrer">'.$linka.
'</a>',
263 '__LINKREFUSED__' =>
'<a href="'.dol_buildpath(
'/datapolicy/public/index.php?action=2&s='.$societe->id.
'&l='.$l.
'&key='.$code, 3).
'" target="_blank" rel="noopener noreferrer">'.$linkr.
'</a>',
268 $actiontypecode =
'AC_EMAIL';
269 $actionmsg = $langs->transnoentities(
'MailSentBy').
' '.$from.
' '.$langs->transnoentities(
'To').
' '.$sendto;
272 $actionmsg =
dol_concatdesc($actionmsg, $langs->transnoentities(
'Bcc').
": ".$sendtocc);
274 $actionmsg =
dol_concatdesc($actionmsg, $langs->transnoentities(
'MailTopic').
": ".$subject);
275 $actionmsg =
dol_concatdesc($actionmsg, $langs->transnoentities(
'TextUsedInTheMessageBody').
":");
280 require_once DOL_DOCUMENT_ROOT.
'/core/class/CMailFile.class.php';
281 $mailfile =
new CMailFile($subject, $sendto, $from, $message, $filepath, $mimetype, $filename, $sendtocc, $sendtobcc, $deliveryreceipt, -1);
282 if ($mailfile->error) {
283 $resultmasssend .=
'<div class="error">'.$mailfile->error.
'</div>';
285 $result4 = $mailfile->sendfile();
288 $resultmasssend .= $langs->trans(
"MailSent").
': '.$sendto.
"<br>";
289 $societe->array_options[
'options_datapolicy_send'] = date(
'Y-m-d', time());
290 $societe->update($societe->id);
306 global $langs, $conf, $db, $user;
310 $from = $user->getFullName($langs).
' <'.$user->email.
'>';
312 $sendto = $adherent->email;
314 $code = md5($adherent->email);
315 if (!empty($adherent->default_lang)) {
316 $l = $adherent->default_lang;
318 $l = $langs->defaultlang;
321 $s =
'TXTLINKDATAPOLICIESSUBJECT_'.$l;
322 $ma =
'TXTLINKDATAPOLICIESMESSAGE_'.$l;
323 $la =
'TXTLINKDATAPOLICIESACCEPT_'.$l;
324 $lr =
'TXTLINKDATAPOLICIESREFUSE_'.$l;
326 $subject = $conf->global->$s;
327 $message = $conf->global->$ma;
328 $linka = $conf->global->$la;
329 $linkr = $conf->global->$lr;
330 $sendtocc = $sendtobcc =
'';
331 $filepath = $mimetype = $filename = array();
332 $deliveryreceipt = 0;
334 $substitutionarray = array(
335 '__LINKACCEPT__' =>
'<a href="'.
dol_buildpath(
'/datapolicy/public/index.php?action=1&a='.$adherent->id.
'&l='.$l.
'&key='.$code, 3).
'" target="_blank" rel="noopener noreferrer">'.$linka.
'</a>',
336 '__LINKREFUSED__' =>
'<a href="'.dol_buildpath(
'/datapolicy/public/index.php?action=2&a='.$adherent->id.
'&l='.$l.
'&key='.$code, 3).
'" target="_blank" rel="noopener noreferrer">'.$linkr.
'</a>',
341 $actiontypecode =
'AC_EMAIL';
342 $actionmsg = $langs->transnoentities(
'MailSentBy').
' '.$from.
' '.$langs->transnoentities(
'To').
' '.$sendto;
345 $actionmsg =
dol_concatdesc($actionmsg, $langs->transnoentities(
'Bcc').
": ".$sendtocc);
347 $actionmsg =
dol_concatdesc($actionmsg, $langs->transnoentities(
'MailTopic').
": ".$subject);
348 $actionmsg =
dol_concatdesc($actionmsg, $langs->transnoentities(
'TextUsedInTheMessageBody').
":");
354 require_once DOL_DOCUMENT_ROOT.
'/core/class/CMailFile.class.php';
355 $mailfile =
new CMailFile($subject, $sendto, $from, $message, $filepath, $mimetype, $filename, $sendtocc, $sendtobcc, $deliveryreceipt, -1);
356 if ($mailfile->error) {
357 $resultmasssend .=
'<div class="error">'.$mailfile->error.
'</div>';
359 $result4 = $mailfile->sendfile();
362 $resultmasssend .= $langs->trans(
"MailSent").
': '.$sendto.
"<br>";
363 $adherent->array_options[
'options_datapolicy_send'] = date(
'Y-m-d', time());
364 $adherent->update($user);