Completed
Branch develop (6390f5)
by
unknown
27:55
created

DataPolicies::sendMailDataPoliciesAdherent()   B

Complexity

Conditions 6
Paths 18

Size

Total Lines 60

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 6
nc 18
nop 1
dl 0
loc 60
rs 8.2505
c 0
b 0
f 0

How to fix   Long Method   

Long Method

Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.

For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.

Commonly applied refactorings include:

1
<?php
2
/* Copyright (C) 2018 SuperAdmin
3
 *
4
 * This program is free software: you can redistribute it and/or modify
5
 * it under the terms of the GNU General Public License as published by
6
 * the Free Software Foundation, either version 3 of the License, or
7
 * (at your option) any later version.
8
 *
9
 * This program is distributed in the hope that it will be useful,
10
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12
 * GNU General Public License for more details.
13
 *
14
 * You should have received a copy of the GNU General Public License
15
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
16
 */
17
18
/**
19
 * \file    datapolicies/class/actions_datapolicies.class.php
20
 * \ingroup datapolicies
21
 * \brief   Example hook overload.
22
 *
23
 * Put detailed description here.
24
 */
25
include_once DOL_DOCUMENT_ROOT . '/contact/class/contact.class.php';
26
include_once DOL_DOCUMENT_ROOT . '/societe/class/societe.class.php';
27
include_once DOL_DOCUMENT_ROOT . '/adherents/class/adherent.class.php';
28
29
30
/**
31
 * Class DataPolicies
32
 */
33
Class DataPolicies extends Contact
34
{
35
	/**
36
	 * getAllContactNotInformed
37
	 *
38
	 * @return number
39
	 */
40
    function getAllContactNotInformed()
41
    {
42
        global $langs, $conf, $db, $user;
43
44
        $langs->load("companies");
45
46
        $sql = "SELECT c.rowid";
47
        $sql .= " FROM " . MAIN_DB_PREFIX . "socpeople as c";
48
        $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "societe as s ON c.fk_soc = s.rowid";
49
        $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "socpeople_extrafields as spe ON spe.fk_object = c.rowid";
50
        $sql .= " WHERE (c.statut=1 AND c.no_email=0 AND (spe.datapolicies_consentement=0 OR spe.datapolicies_consentement IS NULL) AND (spe.datapolicies_opposition_traitement=0 OR spe.datapolicies_opposition_traitement IS NULL) AND (spe.datapolicies_opposition_prospection=0 OR spe.datapolicies_opposition_prospection IS NULL))";
51
        $sql .= " AND spe.datapolicies_send IS NULL";
52
        $sql .= " AND c.entity=" . $conf->entity;
53
        $resql = $this->db->query($sql);
54
        if ($resql) {
55
            $num = $this->db->num_rows($resql);
56
            $i = 0;
57
            while ($i < $num) {
58
                $obj = $this->db->fetch_object($resql);
59
                //echo "<pre>".print_r($obj,1)."</pre>";
60
                $contact = new Contact($db);
61
                $contact->fetch($obj->rowid);
62
63
                DataPolicies::sendMailDataPoliciesContact($contact);
64
                $i++;
65
            }
66
        } else {
67
            $this->error = $this->db->error();
68
            return -1;
69
        }
70
    }
71
72
    /**
73
     * getAllCompaniesNotInformed
74
     *
75
     * @return number
76
     */
77
    function getAllCompaniesNotInformed()
78
    {
79
        global $langs, $conf, $db, $user;
80
81
        $langs->load("companies");
82
83
        $sql = "SELECT s.rowid";
84
        $sql .= " FROM " . MAIN_DB_PREFIX . "societe as s";
85
        $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "societe_extrafields as se ON se.fk_object = s.rowid";
86
        $sql .= " WHERE s.statut=0 AND (se.datapolicies_consentement=0 OR se.datapolicies_consentement IS NULL) AND (se.datapolicies_opposition_traitement=0 OR se.datapolicies_opposition_traitement IS NULL) AND (se.datapolicies_opposition_prospection=0 OR se.datapolicies_opposition_prospection IS NULL)";
87
        $sql .= " AND se.datapolicies_send IS NULL";
88
        $sql .= " AND s.entity=" . $conf->entity;
89
        $resql = $this->db->query($sql);
90
        if ($resql) {
91
            $num = $this->db->num_rows($resql);
92
            $i = 0;
93
            while ($i < $num) {
94
                $obj = $this->db->fetch_object($resql);
95
                //echo "<pre>".print_r($obj,1)."</pre>";
96
                $societe = new Societe($db);
97
                $societe->fetch($obj->rowid);
98
99
                DataPolicies::sendMailDataPoliciesCompany($societe);
100
                $i++;
101
            }
102
        } else {
103
            $this->error = $this->db->error();
104
            return -1;
105
        }
106
    }
107
108
    /**
109
     * getAllAdherentsNotInformed
110
     *
111
     * @return number
112
     */
113
    function getAllAdherentsNotInformed()
114
    {
115
        global $langs, $conf, $db, $user;
116
117
        $langs->load("adherent");
118
119
        $sql = "SELECT a.rowid";
120
        $sql .= " FROM " . MAIN_DB_PREFIX . "adherent as a";
121
        $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "adherent_extrafields as ae ON ae.fk_object = a.rowid";
122
        $sql .= " WHERE a.statut=0 AND (ae.datapolicies_consentement=0 OR ae.datapolicies_consentement IS NULL) AND (ae.datapolicies_opposition_traitement=0 OR ae.datapolicies_opposition_traitement IS NULL) AND (ae.datapolicies_opposition_prospection=0 OR ae.datapolicies_opposition_prospection IS NULL)";
123
        $sql .= " AND ae.datapolicies_send IS NULL";
124
        $sql .= " AND a.entity=" . $conf->entity;
125
        $resql = $this->db->query($sql);
126
        if ($resql) {
127
            $num = $this->db->num_rows($resql);
128
            $i = 0;
129
            while ($i < $num) {
130
                $obj = $this->db->fetch_object($resql);
131
                //echo "<pre>".print_r($obj,1)."</pre>";
132
                $adherent = new Adherent($db);
133
                $adherent->fetch($obj->rowid);
134
135
                DataPolicies::sendMailDataPoliciesAdherent($adherent);
136
                $i++;
137
            }
138
        } else {
139
            $this->error = $this->db->error();
140
            return -1;
141
        }
142
    }
143
144
    /**
145
     * sendMailDataPoliciesContact
146
     *
147
     * @param 	mixed		$contact		Contact
148
     * @return	void
149
     */
150
    function sendMailDataPoliciesContact($contact)
151
    {
152
     	global $langs, $conf, $db, $user;
153
     	$from = $user->getFullName($langs) . ' <' . $user->email . '>';
154
     	$replyto = $from;
155
     	$sendto = $contact->email;
156
     	//echo "<pre>".print_r($contact,1)."</pre>";
157
     	$code= md5($contact->email);
158
     	if (!empty($contact->default_lang)) {
159
     		$l = $contact->default_lang;
160
     	} else {
161
     		$l = $langs->defaultlang;
162
     	}
163
     	$s = "DATAPOLICIESSUBJECT_" . $l;
164
     	$ma = "DATAPOLICIESCONTENT_" . $l;
165
     	$la = 'TXTLINKDATAPOLICIESACCEPT_' . $l;
166
     	$lr = 'TXTLINKDATAPOLICIESREFUSE_' . $l;
167
168
     	$subject = $conf->global->$s;
169
     	$message = $conf->global->$ma;
170
     	$linka = $conf->global->$la;
171
     	$linkr = $conf->global->$lr;
172
173
     	$substitutionarray = array(
174
     	'__LINKACCEPT__' => '<a href="'.dol_buildpath('/datapolicies/public/index.php?action=1&c='.$contact->id.'&l='.$l.'&key='.$code,3).'" target="_blank">'.$linka.'</a>',
175
     	'__LINKREFUSED__' => '<a href="'.dol_buildpath('/datapolicies/public/index.php?action=2&c='.$contact->id.'&l='.$l.'&key='.$code,3).'" target="_blank">'.$linkr.'</a>',
176
     	'__FIRSTNAME__' => $contact->firstname,
177
     	'__NAME__' => $contact->lastname,
178
     	'__CIVILITY__' => $contact->civility,
179
     	);
180
     	$subject = make_substitutions($subject, $substitutionarray);
181
     	$message = make_substitutions($message, $substitutionarray);
182
183
     	$actiontypecode = 'AC_EMAIL';
184
     	$actionmsg = $langs->transnoentities('MailSentBy') . ' ' . $from . ' ' . $langs->transnoentities('To') . ' ' . $sendto;
185
     	if ($message) {
186
     		if ($sendtocc)
0 ignored issues
show
Bug introduced by
The variable $sendtocc does not exist. Did you mean $sendto?

This check looks for variables that are accessed but have not been defined. It raises an issue if it finds another variable that has a similar name.

The variable may have been renamed without also renaming all references.

Loading history...
187
     			$actionmsg = dol_concatdesc($actionmsg, $langs->transnoentities('Bcc') . ": " . $sendtocc);
0 ignored issues
show
Bug introduced by
The variable $sendtocc does not exist. Did you mean $sendto?

This check looks for variables that are accessed but have not been defined. It raises an issue if it finds another variable that has a similar name.

The variable may have been renamed without also renaming all references.

Loading history...
188
     			$actionmsg = dol_concatdesc($actionmsg, $langs->transnoentities('MailTopic') . ": " . $subject);
189
     			$actionmsg = dol_concatdesc($actionmsg, $langs->transnoentities('TextUsedInTheMessageBody') . ":");
190
     			$actionmsg = dol_concatdesc($actionmsg, $message);
191
     	}
192
193
194
     	// Send mail
195
     	require_once DOL_DOCUMENT_ROOT . '/core/class/CMailFile.class.php';
196
     	$mailfile = new CMailFile($subject, $sendto, $from, $message, $filepath, $mimetype, $filename, $sendtocc, $sendtobcc, $deliveryreceipt, -1);
0 ignored issues
show
Bug introduced by
The variable $filepath does not exist. Did you forget to declare it?

This check marks access to variables or properties that have not been declared yet. While PHP has no explicit notion of declaring a variable, accessing it before a value is assigned to it is most likely a bug.

Loading history...
Bug introduced by
The variable $mimetype does not exist. Did you forget to declare it?

This check marks access to variables or properties that have not been declared yet. While PHP has no explicit notion of declaring a variable, accessing it before a value is assigned to it is most likely a bug.

Loading history...
Bug introduced by
The variable $filename does not exist. Did you forget to declare it?

This check marks access to variables or properties that have not been declared yet. While PHP has no explicit notion of declaring a variable, accessing it before a value is assigned to it is most likely a bug.

Loading history...
Bug introduced by
The variable $sendtocc does not exist. Did you mean $sendto?

This check looks for variables that are accessed but have not been defined. It raises an issue if it finds another variable that has a similar name.

The variable may have been renamed without also renaming all references.

Loading history...
Bug introduced by
The variable $sendtobcc does not exist. Did you mean $sendto?

This check looks for variables that are accessed but have not been defined. It raises an issue if it finds another variable that has a similar name.

The variable may have been renamed without also renaming all references.

Loading history...
Bug introduced by
The variable $deliveryreceipt does not exist. Did you forget to declare it?

This check marks access to variables or properties that have not been declared yet. While PHP has no explicit notion of declaring a variable, accessing it before a value is assigned to it is most likely a bug.

Loading history...
197
198
     	if ($mailfile->error) {
199
     		$resultmasssend .= '<div class="error">' . $mailfile->error . '</div>';
0 ignored issues
show
Bug introduced by
The variable $resultmasssend does not exist. Did you forget to declare it?

This check marks access to variables or properties that have not been declared yet. While PHP has no explicit notion of declaring a variable, accessing it before a value is assigned to it is most likely a bug.

Loading history...
200
     	} else {
201
     		$result4 = $mailfile->sendfile();
202
     		if (!$error) {
0 ignored issues
show
Bug introduced by
The variable $error does not exist. Did you forget to declare it?

This check marks access to variables or properties that have not been declared yet. While PHP has no explicit notion of declaring a variable, accessing it before a value is assigned to it is most likely a bug.

Loading history...
203
204
     			$resultmasssend .= $langs->trans("MailSent") . ': ' . $sendto . "<br>";
205
     			$contact->array_options['options_datapolicies_send'] = date('Y-m-d', time());
206
     			$contact->update($contact->id);
207
208
     		} else {
209
     			dol_print_error($db);
210
     		}
211
     	}
212
     	setEventMessage($resultmasssend);
213
    }
214
215
    /**
216
     * sendMailDataPoliciesCompany
217
     *
218
     * @param Societe	$societe	Object societe
219
     * @return	void
220
     */
221
    function sendMailDataPoliciesCompany($societe)
222
    {
223
     	global $langs, $conf, $db, $user;
224
     	$from = $user->getFullName($langs) . ' <' . $user->email . '>';
225
     	$replyto = $from;
226
     	$sendto = $societe->email;
227
228
     	$code= md5($societe->email);
229
     	if (!empty($societe->default_lang)) {
230
     		$l = $societe->default_lang;
231
     	} else {
232
     		$l = $langs->defaultlang;
233
     	}
234
     	$s = "DATAPOLICIESSUBJECT_" . $l;
235
     	$ma = "DATAPOLICIESCONTENT_" . $l;
236
     	$la = 'TXTLINKDATAPOLICIESACCEPT_' . $l;
237
     	$lr = 'TXTLINKDATAPOLICIESREFUSE_' . $l;
238
239
     	$subject = $conf->global->$s;
240
     	$message = $conf->global->$ma;
241
     	$linka = $conf->global->$la;
242
     	$linkr = $conf->global->$lr;
243
244
245
     	$substitutionarray = array(
246
            '__LINKACCEPT__' => '<a href="'.dol_buildpath('/datapolicies/public/index.php?action=1&c='.$societe->id.'&l='.$l.'&key='.$code,3).'" target="_blank">'.$linka.'</a>',
247
            '__LINKREFUSED__' => '<a href="'.dol_buildpath('/datapolicies/public/index.php?action=2&c='.$societe->id.'&l='.$l.'&key='.$code,3).'" target="_blank">'.$linkr.'</a>',
248
     	);
249
     	$subject = make_substitutions($subject, $substitutionarray);
250
     	$message = make_substitutions($message, $substitutionarray);
251
252
     	$actiontypecode = 'AC_EMAIL';
253
     	$actionmsg = $langs->transnoentities('MailSentBy') . ' ' . $from . ' ' . $langs->transnoentities('To') . ' ' . $sendto;
254
     	if ($message) {
255
     		if ($sendtocc) {
0 ignored issues
show
Bug introduced by
The variable $sendtocc does not exist. Did you mean $sendto?

This check looks for variables that are accessed but have not been defined. It raises an issue if it finds another variable that has a similar name.

The variable may have been renamed without also renaming all references.

Loading history...
256
                 $actionmsg .= dol_concatdesc($actionmsg, $langs->transnoentities('Bcc') . ": " . $sendtocc);
0 ignored issues
show
Bug introduced by
The variable $sendtocc does not exist. Did you mean $sendto?

This check looks for variables that are accessed but have not been defined. It raises an issue if it finds another variable that has a similar name.

The variable may have been renamed without also renaming all references.

Loading history...
257
             }
258
            $actionmsg .= dol_concatdesc($actionmsg, $langs->transnoentities('MailTopic') . ": " . $subject);
259
            $actionmsg .= dol_concatdesc($actionmsg, $langs->transnoentities('TextUsedInTheMessageBody') . ":");
260
            $actionmsg .= dol_concatdesc($actionmsg, $message);
261
        }
262
263
     	// Send mail
264
     	require_once DOL_DOCUMENT_ROOT . '/core/class/CMailFile.class.php';
265
     	$mailfile = new CMailFile($subject, $sendto, $from, $message, $filepath, $mimetype, $filename, $sendtocc, $sendtobcc, $deliveryreceipt, -1);
0 ignored issues
show
Bug introduced by
The variable $filepath does not exist. Did you forget to declare it?

This check marks access to variables or properties that have not been declared yet. While PHP has no explicit notion of declaring a variable, accessing it before a value is assigned to it is most likely a bug.

Loading history...
Bug introduced by
The variable $mimetype does not exist. Did you forget to declare it?

This check marks access to variables or properties that have not been declared yet. While PHP has no explicit notion of declaring a variable, accessing it before a value is assigned to it is most likely a bug.

Loading history...
Bug introduced by
The variable $filename does not exist. Did you forget to declare it?

This check marks access to variables or properties that have not been declared yet. While PHP has no explicit notion of declaring a variable, accessing it before a value is assigned to it is most likely a bug.

Loading history...
Bug introduced by
The variable $sendtocc does not exist. Did you mean $sendto?

This check looks for variables that are accessed but have not been defined. It raises an issue if it finds another variable that has a similar name.

The variable may have been renamed without also renaming all references.

Loading history...
Bug introduced by
The variable $sendtobcc does not exist. Did you mean $sendto?

This check looks for variables that are accessed but have not been defined. It raises an issue if it finds another variable that has a similar name.

The variable may have been renamed without also renaming all references.

Loading history...
Bug introduced by
The variable $deliveryreceipt does not exist. Did you forget to declare it?

This check marks access to variables or properties that have not been declared yet. While PHP has no explicit notion of declaring a variable, accessing it before a value is assigned to it is most likely a bug.

Loading history...
266
     	if ($mailfile->error) {
267
     		$resultmasssend .= '<div class="error">' . $mailfile->error . '</div>';
0 ignored issues
show
Bug introduced by
The variable $resultmasssend does not exist. Did you forget to declare it?

This check marks access to variables or properties that have not been declared yet. While PHP has no explicit notion of declaring a variable, accessing it before a value is assigned to it is most likely a bug.

Loading history...
268
     	} else {
269
     		$result4 = $mailfile->sendfile();
270
271
     		if (!$error) {
0 ignored issues
show
Bug introduced by
The variable $error does not exist. Did you forget to declare it?

This check marks access to variables or properties that have not been declared yet. While PHP has no explicit notion of declaring a variable, accessing it before a value is assigned to it is most likely a bug.

Loading history...
272
     			$resultmasssend .= $langs->trans("MailSent") . ': ' . $sendto . "<br>";
273
     			$societe->array_options['options_datapolicies_send'] = date('Y-m-d', time());
274
     			$societe->update($societe->id);
275
     		} else {
276
     			dol_print_error($db);
277
     		}
278
     	}
279
     	setEventMessage($resultmasssend);
280
    }
281
282
    /**
283
     * sendMailDataPoliciesAdherent
284
     *
285
     * @param Adherent	$adherent		Member
286
     * @return void
287
     */
288
    function sendMailDataPoliciesAdherent($adherent)
289
    {
290
    	global $langs, $conf, $db, $user;
291
    	$from = $user->getFullName($langs) . ' <' . $user->email . '>';
292
    	$replyto = $from;
293
    	$sendto = $adherent->email;
294
295
    	$code= md5($adherent->email);
296
    	if (!empty($adherent->default_lang)) {
297
    		$l = $adherent->default_lang;
298
    	} else {
299
    		$l = $langs->defaultlang;
300
    	}
301
    	$la = 'TXTLINKDATAPOLICIESACCEPT_' . $l;
302
    	$lr = 'TXTLINKDATAPOLICIESREFUSE_' . $l;
303
304
    	$subject = $conf->global->$s;
0 ignored issues
show
Bug introduced by
The variable $s does not exist. Did you forget to declare it?

This check marks access to variables or properties that have not been declared yet. While PHP has no explicit notion of declaring a variable, accessing it before a value is assigned to it is most likely a bug.

Loading history...
305
    	$message = $conf->global->$ma;
0 ignored issues
show
Bug introduced by
The variable $ma does not exist. Did you forget to declare it?

This check marks access to variables or properties that have not been declared yet. While PHP has no explicit notion of declaring a variable, accessing it before a value is assigned to it is most likely a bug.

Loading history...
306
    	$linka = $conf->global->$la;
307
    	$linkr = $conf->global->$lr;
308
309
310
    	$substitutionarray = array(
311
            '__LINKACCEPT__' => '<a href="'.dol_buildpath('/datapolicies/public/index.php?action=1&c='.$adherent->id.'&l='.$l.'&key='.$code,3).'" target="_blank">'.$linka.'</a>',
312
            '__LINKREFUSED__' => '<a href="'.dol_buildpath('/datapolicies/public/index.php?action=2&c='.$adherent->id.'&l='.$l.'&key='.$code,3).'" target="_blank">'.$linkr.'</a>',
313
    	);
314
    	$subject = make_substitutions($subject, $substitutionarray);
315
    	$message = make_substitutions($message, $substitutionarray);
316
317
    	$actiontypecode = 'AC_EMAIL';
318
    	$actionmsg = $langs->transnoentities('MailSentBy') . ' ' . $from . ' ' . $langs->transnoentities('To') . ' ' . $sendto;
319
    	if ($message) {
320
    		if ($sendtocc) {
0 ignored issues
show
Bug introduced by
The variable $sendtocc does not exist. Did you mean $sendto?

This check looks for variables that are accessed but have not been defined. It raises an issue if it finds another variable that has a similar name.

The variable may have been renamed without also renaming all references.

Loading history...
321
                $actionmsg .= dol_concatdesc($actionmsg, $langs->transnoentities('Bcc') . ": " . $sendtocc);
0 ignored issues
show
Bug introduced by
The variable $sendtocc does not exist. Did you mean $sendto?

This check looks for variables that are accessed but have not been defined. It raises an issue if it finds another variable that has a similar name.

The variable may have been renamed without also renaming all references.

Loading history...
322
            }
323
            $actionmsg .= dol_concatdesc($actionmsg, $langs->transnoentities('MailTopic') . ": " . $subject);
324
            $actionmsg .= dol_concatdesc($actionmsg, $langs->transnoentities('TextUsedInTheMessageBody') . ":");
325
            $actionmsg .= dol_concatdesc($actionmsg, $message);
326
    	}
327
328
329
    	// Send mail
330
    	require_once DOL_DOCUMENT_ROOT . '/core/class/CMailFile.class.php';
331
    	$mailfile = new CMailFile($subject, $sendto, $from, $message, $filepath, $mimetype, $filename, $sendtocc, $sendtobcc, $deliveryreceipt, -1);
0 ignored issues
show
Bug introduced by
The variable $filepath does not exist. Did you forget to declare it?

This check marks access to variables or properties that have not been declared yet. While PHP has no explicit notion of declaring a variable, accessing it before a value is assigned to it is most likely a bug.

Loading history...
Bug introduced by
The variable $mimetype does not exist. Did you forget to declare it?

This check marks access to variables or properties that have not been declared yet. While PHP has no explicit notion of declaring a variable, accessing it before a value is assigned to it is most likely a bug.

Loading history...
Bug introduced by
The variable $filename does not exist. Did you forget to declare it?

This check marks access to variables or properties that have not been declared yet. While PHP has no explicit notion of declaring a variable, accessing it before a value is assigned to it is most likely a bug.

Loading history...
Bug introduced by
The variable $sendtocc does not exist. Did you mean $sendto?

This check looks for variables that are accessed but have not been defined. It raises an issue if it finds another variable that has a similar name.

The variable may have been renamed without also renaming all references.

Loading history...
Bug introduced by
The variable $sendtobcc does not exist. Did you mean $sendto?

This check looks for variables that are accessed but have not been defined. It raises an issue if it finds another variable that has a similar name.

The variable may have been renamed without also renaming all references.

Loading history...
Bug introduced by
The variable $deliveryreceipt does not exist. Did you forget to declare it?

This check marks access to variables or properties that have not been declared yet. While PHP has no explicit notion of declaring a variable, accessing it before a value is assigned to it is most likely a bug.

Loading history...
332
    	if ($mailfile->error) {
333
    		$resultmasssend .= '<div class="error">' . $mailfile->error . '</div>';
0 ignored issues
show
Bug introduced by
The variable $resultmasssend does not exist. Did you forget to declare it?

This check marks access to variables or properties that have not been declared yet. While PHP has no explicit notion of declaring a variable, accessing it before a value is assigned to it is most likely a bug.

Loading history...
334
    	} else {
335
    		$result4 = $mailfile->sendfile();
336
337
    		if (!$error) {
0 ignored issues
show
Bug introduced by
The variable $error does not exist. Did you forget to declare it?

This check marks access to variables or properties that have not been declared yet. While PHP has no explicit notion of declaring a variable, accessing it before a value is assigned to it is most likely a bug.

Loading history...
338
    			$resultmasssend .= $langs->trans("MailSent") . ': ' . $sendto . "<br>";
339
    			$adherent->array_options['options_datapolicies_send'] = date('Y-m-d', time());
340
    			$adherent->update($user);
341
342
    		} else {
343
    			dol_print_error($db);
344
    		}
345
    	}
346
    	setEventMessage($resultmasssend);
347
    }
348
}
349