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

ActionsDatapolicies::beforePDFCreation()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 18

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
nc 2
nop 3
dl 0
loc 18
rs 9.6666
c 0
b 0
f 0
1
<?php
2
/* Copyright (C) 2018       SuperAdmin
3
 * Copyright (C) 2018       Frédéric France         <[email protected]>
4
 *
5
 * This program is free software: you can redistribute it and/or modify
6
 * it under the terms of the GNU General Public License as published by
7
 * the Free Software Foundation, either version 3 of the License, or
8
 * (at your option) any later version.
9
 *
10
 * This program is distributed in the hope that it will be useful,
11
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
 * GNU General Public License for more details.
14
 *
15
 * You should have received a copy of the GNU General Public License
16
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
17
 */
18
19
/**
20
 * \file    datapolicies/class/actions_datapolicies.class.php
21
 * \ingroup datapolicies
22
 * \brief   Example hook overload.
23
 */
24
25
/**
26
 * Class ActionsDatapolicies
27
 */
28
class ActionsDatapolicies
29
{
30
    /**
31
     * @var DoliDB Database handler.
32
     */
33
    public $db;
34
35
    /**
36
     * @var string Error
37
     */
38
    public $error = '';
39
40
    /**
41
     * @var array Errors
42
     */
43
    public $errors = array();
44
45
    /**
46
     * @var array Hook results. Propagated to $hookmanager->resArray for later reuse
47
     */
48
    public $results = array();
49
50
    /**
51
     * @var string String displayed by executeHook() immediately after return
52
     */
53
    public $resprints;
54
55
    /**
56
     * Constructor
57
     *
58
     *  @param  DoliDB      $db      Database handler
59
     */
60
    public function __construct($db)
61
    {
62
        $this->db = $db;
63
    }
64
65
    /**
66
     * Execute action
67
     *
68
     * @param   array           $parameters		Array of parameters
69
     * @param   CommonObject    $object         The object to process (an invoice if you are in invoice module, a propale in propale's module, etc...)
70
     * @param   string          $action      	'add', 'update', 'view'
71
     * @return  int         					<0 if KO,
72
     *                           				=0 if OK but we want to process standard actions too,
73
     *                            				>0 if OK and we want to replace standard actions.
74
     */
75
    function getNomUrl($parameters, &$object, &$action)
76
    {
77
        global $db, $langs, $conf, $user;
78
        $this->resprints = '';
79
        return 0;
80
    }
81
82
    /**
83
     * Overloading the doActions function : replacing the parent's function with the one below
84
     *
85
     * @param   array           $parameters     Hook metadatas (context, etc...)
86
     * @param   CommonObject    $object         The object to process (an invoice if you are in invoice module, a propale in propale's module, etc...)
87
     * @param   string          $action         Current action (if set). Generally create or edit or null
88
     * @param   HookManager     $hookmanager    Hook manager propagated to allow calling another hook
89
     * @return  int                             < 0 on error, 0 on success, 1 to replace standard code
90
     */
91
    public function doActions($parameters, &$object, &$action, $hookmanager)
92
    {
93
        global $conf, $user, $langs;
94
        $langs->load('datapolicies@datapolicies');
95
        $error = 0; // Error counter
96
97
        if (GETPOST('socid') && $parameters['currentcontext'] == 'thirdpartycard') {
98
            $object->fetch(GETPOST('socid'));
99
        }
100
101
        // FIXME Removed hard coded id, use codes
102
        if ($parameters['currentcontext'] == 'thirdpartycard' && $action == 'anonymiser' && (in_array($object->forme_juridique_code, array(11, 12, 13, 15, 17, 18, 19, 35, 60, 200, 311, 312, 316, 401, 600, 700, 1005)) || $object->typent_id == 8)) {
103
            // on verifie si l'objet est utilisé
104
            if ($object->isObjectUsed(GETPOST('socid'))) {
105
                $object->name = $langs->trans('ANONYME');
106
                $object->name_bis = '';
107
                $object->name_alias = '';
108
                $object->address = '';
109
                $object->town = '';
110
                $object->zip = '';
111
                $object->phone = '';
112
                $object->email = '';
113
                $object->url = '';
114
                $object->fax = '';
115
                $object->state = '';
116
                $object->country = '';
117
                $object->state_id = '';
118
                $object->skype = '';
119
                $object->country_id = '';
120
                $object->note_private = $object->note_private . '<br/>' . $langs->trans('ANONYMISER_AT', dol_print_date(time()));
121
122
                if ($object->update($object->id, $user, 0)) {
0 ignored issues
show
Bug introduced by
The method update() does not exist on CommonObject. Did you maybe mean update_contact()?

This check marks calls to methods that do not seem to exist on an object.

This is most likely the result of a method being renamed without all references to it being renamed likewise.

Loading history...
123
124
                    // On supprime les contacts associé
125
                    $sql = "DELETE FROM " . MAIN_DB_PREFIX . "socpeople WHERE fk_soc = " . $object->id;
126
                    $this->db->query($sql);
127
128
                    setEventMessages($langs->trans('ANONYMISER_SUCCESS'), array());
129
                    header('Location:' . $_SERVER["PHP_SELF"] . "?socid=" . $object->id);
130
                }
131
            }
132
        } elseif ($parameters['currentcontext'] == 'thirdpartycard' && $action == 'datapolicies_portabilite') {
133
            header('Content-Type: application/csv');
134
            header('Content-Disposition: attachment; filename=datapolicies_portabilite.csv');
135
            header('Pragma: no-cache');
136
            $object->fetch(GETPOST('socid'));
137
            echo 'Nom;Prénom;Civilite;Tiers;Poste/Fonction;Adresse;CP;Ville;Département;Pays;Email;Tel Pro;Tel Perso;Tel Portable;Messagerie instantanée;Date de naissance;' . PHP_EOL;
138
            echo $object->name . ';';
139
            echo ';';
140
            echo ';';
141
            echo ';';
142
            echo ';';
143
            echo $object->address . ';';
144
            echo $object->zip . ';';
145
            echo $object->town . ';';
146
            echo $object->state . ';';
147
            echo $object->country . ';';
148
            echo $object->email . ';';
149
            echo $object->phone . ';';
150
            echo ';';
151
            echo ';';
152
            echo $object->skype . ';';
153
            echo ';';
154
            exit;
155
        } elseif ($parameters['currentcontext'] == 'membercard' && $action == 'datapolicies_portabilite') {
156
            header('Content-Type: application/csv');
157
            header('Content-Disposition: attachment; filename=datapolicies_portabilite.csv');
158
            header('Pragma: no-cache');
159
            $soc = $object->fetch_thirdparty();
160
161
            echo 'Nom;Prénom;Civilite;Tiers;Poste/Fonction;Adresse;CP;Ville;Département;Pays;Email;Tel Pro;Tel Perso;Tel Portable;Messagerie instantanée;Date de naissance;' . PHP_EOL;
162
            echo $object->lastname . ';';
163
            echo $object->firstname . ';';
164
            echo $object->getCivilityLabel() . ';';
165
            echo ($soc != -1 ? $object->thirdparty->name : '') . ';';
166
            echo ';';
167
            echo $object->address . ';';
168
            echo $object->zip . ';';
169
            echo $object->town . ';';
170
            echo $object->state . ';';
171
            echo $object->country . ';';
172
            echo $object->email . ';';
173
            echo $object->phone . ';';
174
            echo $object->phone_perso . ';';
175
            echo $object->phone_mobile . ';';
176
            echo $object->skype . ';';
177
            echo dol_print_date($object->birth) . ';';
178
            exit;
179
        } elseif ($parameters['currentcontext'] == 'contactcard' && $action == 'datapolicies_portabilite') {
180
            $object->fetch(GETPOST('id'));
181
            header('Content-Type: application/csv');
182
            header('Content-Disposition: attachment; filename=datapolicies_portabilite.csv');
183
            header('Pragma: no-cache');
184
            $soc = $object->fetch_thirdparty();
185
            echo 'Nom;Prénom;Civilite;Tiers;Poste/Fonction;Adresse;CP;Ville;Département;Pays;Email;Tel Pro;Tel Perso;Tel Portable;Messagerie instantanée;Date de naissance;' . PHP_EOL;
186
            echo $object->lastname . ';';
187
            echo $object->firstname . ';';
188
            echo $object->getCivilityLabel() . ';';
189
            echo ($soc != -1 ? $object->thirdparty->name : '') . ';';
190
            echo $object->poste . ';';
191
            echo $object->address . ';';
192
            echo $object->zip . ';';
193
            echo $object->town . ';';
194
            echo $object->state . ';';
195
            echo $object->country . ';';
196
            echo $object->email . ';';
197
            echo $object->phone_pro . ';';
198
            echo $object->phone_perso . ';';
199
            echo $object->phone_mobile . ';';
200
            echo $object->jabberid . ';';
201
            echo dol_print_date($object->birth) . ';';
202
            exit;
203
        } elseif ($parameters['currentcontext'] == 'contactcard' && $action == 'send_datapolicies') {
204
            $object->fetch(GETPOST('id'));
205
206
            require_once  DOL_DOCUMENT_ROOT . '/contact/class/contact.class.php';
207
            require_once  DOL_DOCUMENT_ROOT . '/datapolicies/class/datapolicies.class.php';
208
            DataPolicies::sendMailDataPoliciesContact($object);
209
        }
210
         elseif ($parameters['currentcontext'] == 'membercard' && $action == 'send_datapolicies') {
211
             $object->fetch(GETPOST('id'));
212
            require_once  DOL_DOCUMENT_ROOT . '/adherents/class/adherent.class.php';
213
            require_once  DOL_DOCUMENT_ROOT . '/datapolicies/class/datapolicies.class.php';
214
            DataPolicies::sendMailDataPoliciesAdherent($object);
1 ignored issue
show
Compatibility introduced by
$object of type object<CommonObject> is not a sub-type of object<Adherent>. It seems like you assume a child class of the class CommonObject to be always present.

This check looks for parameters that are defined as one type in their type hint or doc comment but seem to be used as a narrower type, i.e an implementation of an interface or a subclass.

Consider changing the type of the parameter or doing an instanceof check before assuming your parameter is of the expected type.

Loading history...
215
        } elseif ($parameters['currentcontext'] == 'thirdpartycard' && $action == 'send_datapolicies') {
216
            $object->fetch(GETPOST('socid'));
217
            require_once  DOL_DOCUMENT_ROOT . '/societe/class/societe.class.php';
218
            require_once  DOL_DOCUMENT_ROOT . '/datapolicies/class/datapolicies.class.php';
219
            DataPolicies::sendMailDataPoliciesCompany($object);
220
        }
221
222
223
        if (!$error) {
224
            $this->results = array('myreturn' => 999);
225
            $this->resprints = 'A text to show';
226
            return 0; // or return 1 to replace standard code
227
        } else {
228
            $this->errors[] = 'Error message';
229
            return -1;
230
        }
231
    }
232
233
    /**
234
     * Overloading the doActions function : replacing the parent's function with the one below
235
     *
236
     * @param   array           $parameters     Hook metadatas (context, etc...)
237
     * @param   CommonObject    $object         The object to process (an invoice if you are in invoice module, a propale in propale's module, etc...)
238
     * @param   string          $action         Current action (if set). Generally create or edit or null
239
     * @param   HookManager     $hookmanager    Hook manager propagated to allow calling another hook
240
     * @return  int                             < 0 on error, 0 on success, 1 to replace standard code
241
     */
242
    public function doMassActions($parameters, &$object, &$action, $hookmanager)
243
    {
244
        global $conf, $user, $langs;
245
246
        $error = 0; // Error counter
247
248
        /* print_r($parameters); print_r($object); echo "action: " . $action; */
249
        //if (in_array($parameters['currentcontext'], array('somecontext1', 'somecontext2'))) {
250
        //    // do something only for the context 'somecontext1' or 'somecontext2'
251
        //    foreach ($parameters['toselect'] as $objectid) {
252
        //        // Do action on each object id
253
        //    }
254
        //}
255
256
        if (!$error) {
257
            $this->results = array('myreturn' => 999);
258
            $this->resprints = 'A text to show';
259
            return 0; // or return 1 to replace standard code
260
        } else {
261
            $this->errors[] = 'Error message';
262
            return -1;
263
        }
264
    }
265
266
    /**
267
     * Overloading the addMoreMassActions function : replacing the parent's function with the one below
268
     *
269
     * @param   array           $parameters		Hook metadatas (context, etc...)
270
     * @param   CommonObject    $object         The object to process (an invoice if you are in invoice module, a propale in propale's module, etc...)
271
     * @param   string          $action         Current action (if set). Generally create or edit or null
272
     * @param   HookManager     $hookmanager    Hook manager propagated to allow calling another hook
273
     * @return  int                             < 0 on error, 0 on success, 1 to replace standard code
274
     */
275
    public function addMoreMassActions($parameters, &$object, &$action, $hookmanager)
276
    {
277
        global $conf, $user, $langs;
278
279
        $error = 0; // Error counter
280
281
        /* print_r($parameters); print_r($object); echo "action: " . $action; */
282
        if (in_array($parameters['currentcontext'], array('somecontext1', 'somecontext2'))) {  // do something only for the context 'somecontext1' or 'somecontext2'
283
            $this->resprints = '<option value="0"' . ($disabled ? ' disabled="disabled"' : '') . '>' . $langs->trans("datapoliciesMassAction") . '</option>';
0 ignored issues
show
Bug introduced by
The variable $disabled 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...
284
        }
285
286
        if (!$error) {
287
            return 0; // or return 1 to replace standard code
288
        } else {
289
            $this->errors[] = 'Error message';
290
            return -1;
291
        }
292
    }
293
294
    /**
295
     * Execute action
296
     *
297
     * @param   array	$parameters		Array of parameters
298
     * @param   Object	$object		   	Object output on PDF
299
     * @param   string	$action     	'add', 'update', 'view'
300
     * @return  int 		        	<0 if KO,
301
     *                          		=0 if OK but we want to process standard actions too,
302
     *  	                            >0 if OK and we want to replace standard actions.
303
     */
304
    function beforePDFCreation($parameters, &$object, &$action)
305
    {
306
        global $conf, $user, $langs;
307
        global $hookmanager;
308
309
        $outputlangs = $langs;
310
311
        $ret = 0;
312
        $deltemp = array();
313
        dol_syslog(get_class($this) . '::executeHooks action=' . $action);
314
315
        /* print_r($parameters); print_r($object); echo "action: " . $action; */
316
        if (in_array($parameters['currentcontext'], array('somecontext1', 'somecontext2'))) {  // do something only for the context 'somecontext1' or 'somecontext2'
317
318
        }
319
320
        return $ret;
321
    }
322
323
    /**
324
     * Execute action
325
     *
326
     * @param	array	$parameters		Array of parameters
327
     * @param   Object	$pdfhandler   	PDF builder handler
328
     * @param   string	$action     	'add', 'update', 'view'
329
     * @return  int 		        	<0 if KO,
330
     *                          		=0 if OK but we want to process standard actions too,
331
     *  	                            >0 if OK and we want to replace standard actions.
332
     */
333
    function afterPDFCreation($parameters, &$pdfhandler, &$action)
334
    {
335
        global $conf, $user, $langs;
336
        global $hookmanager;
337
338
        $outputlangs = $langs;
339
340
        $ret = 0;
341
        $deltemp = array();
342
        dol_syslog(get_class($this) . '::executeHooks action=' . $action);
343
344
        /* print_r($parameters); print_r($object); echo "action: " . $action; */
345
        if (in_array($parameters['currentcontext'], array('somecontext1', 'somecontext2'))) {  // do something only for the context 'somecontext1' or 'somecontext2'
346
347
        }
348
349
        return $ret;
350
    }
351
352
    /**
353
     * addMoreActionsButtons
354
     *
355
     * @param array 		$parameters		array of parameters
356
     * @param Object	 	$object			Object
357
     * @param string		$action			Actions
358
     * @param HookManager	$hookmanager	Hook manager
359
     * @return void
360
     */
361
    function addMoreActionsButtons($parameters, &$object, &$action, $hookmanager)
362
    {
363
        global $conf, $user, $langs;
364
        $langs->load('datapolicies@datapolicies');
365
366
        $dialog = '<div id="dialogdatapolicies" style="display:none;" title="' . $langs->trans('DATAPOLICIES_PORTABILITE_TITLE') . '">';
367
        $dialog .= '<div class="confirmmessage">' . img_help('', '') . ' ' . $langs->trans('DATAPOLICIES_PORTABILITE_CONFIRMATION') . '</div>';
368
        $dialog .= "</div>";
369
        $dialog .= '<script>
370
                  $( function() {
371
                    $("#rpgpdbtn").on("click", function(){
372
                        var href = $(this).attr("href");
373
                        $( "#dialogdatapolicies" ).dialog({
374
                          modal: true,
375
                          buttons: {
376
                            "OK": function() {
377
                              window.open(href);
378
                              $( this ).dialog( "close" );
379
                            },
380
                            "' . $langs->trans('Cancel') . '": function() {
381
                              $( this ).dialog( "close" );
382
                            }
383
                          }
384
                        });
385
386
387
                    return false;
388
                    });
389
                  } );
390
                  </script>';
391
        echo $dialog;
392
        if ($parameters['currentcontext'] == 'thirdpartycard' && in_array($object->forme_juridique_code, array(11, 12, 13, 15, 17, 18, 19, 35, 60, 200, 311, 312, 316, 401, 600, 700, 1005)) || $object->typent_id == 8) {
393
            echo '<div class="inline-block divButAction"><a target="_blank" id="rpgpdbtn" class="butAction" href="' . $_SERVER["PHP_SELF"] . "?socid=" . $object->id . '&action=datapolicies_portabilite" title="' . $langs->trans('DATAPOLICIES_PORTABILITE_TITLE') . '">' . $langs->trans("DATAPOLICIES_PORTABILITE") . '</a></div>';
394
        } elseif ($parameters['currentcontext'] == 'membercard') {
395
            echo '<div class="inline-block divButAction"><a target="_blank" id="rpgpdbtn" class="butAction" href="' . $_SERVER["PHP_SELF"] . "?rowid=" . $object->id . '&action=datapolicies_portabilite" title="' . $langs->trans('DATAPOLICIES_PORTABILITE_TITLE') . '">' . $langs->trans("DATAPOLICIES_PORTABILITE") . '</a></div>';
396
        } elseif ($parameters['currentcontext'] == 'contactcard') {
397
            echo '<div class="inline-block divButAction"><a target="_blank" id="rpgpdbtn" class="butAction" href="' . $_SERVER["PHP_SELF"] . "?id=" . $object->id . '&action=datapolicies_portabilite" title="' . $langs->trans('DATAPOLICIES_PORTABILITE_TITLE') . '">' . $langs->trans("DATAPOLICIES_PORTABILITE") . '</a></div>';
398
        }
399
        if (!empty($object->mail) && empty($object->array_options['options_datapolicies_send']) && $parameters['currentcontext'] == 'thirdpartycard' && in_array($object->forme_juridique_code, array(11, 12, 13, 15, 17, 18, 19, 35, 60, 200, 311, 312, 316, 401, 600, 700, 1005)) || $object->typent_id == 8) {
400
            echo '<div class="inline-block divButAction"><a class="butAction" href="' . $_SERVER["PHP_SELF"] . "?socid=" . $object->id . '&action=send_datapolicies" title="' . $langs->trans('DATAPOLICIES_SEND') . '">' . $langs->trans("DATAPOLICIES_SEND") . '</a></div>';
401
        } elseif (!empty($object->mail) && empty($object->array_options['options_datapolicies_send']) && $parameters['currentcontext'] == 'membercard') {
402
            echo '<div class="inline-block divButAction"><a class="butAction" href="' . $_SERVER["PHP_SELF"] . "?rowid=" . $object->id . '&action=send_datapolicies" title="' . $langs->trans('DATAPOLICIES_SEND') . '">' . $langs->trans("DATAPOLICIES_SEND") . '</a></div>';
403
        } elseif (!empty($object->mail) && empty($object->array_options['options_datapolicies_send']) && $parameters['currentcontext'] == 'contactcard') {
404
            echo '<div class="inline-block divButAction"><a class="butAction" href="' . $_SERVER["PHP_SELF"] . "?id=" . $object->id . '&action=send_datapolicies" title="' . $langs->trans('DATAPOLICIES_SEND') . '">' . $langs->trans("DATAPOLICIES_SEND") . '</a></div>';
405
        }
406
    }
407
408
    /**
409
     * printCommonFooter
410
     *
411
     * @param array 		$parameters		array of parameters
412
     * @param Object	 	$object			Object
413
     * @param string		$action			Actions
414
     * @param HookManager	$hookmanager	Hook manager
415
     * @return void
416
     */
417
    function printCommonFooter($parameters, &$object, &$action, $hookmanager)
418
    {
419
        global $conf, $user, $langs;
420
421
        $jsscript = '';
422
        if ($parameters['currentcontext'] == 'thirdpartycard') {
423
            if (GETPOST('action') == 'create' || GETPOST('action') == 'edit' || GETPOST('action') == '') {
424
                $jsscript .= '<script>';
425
                $jsscript .= "var elementToHide = 'tr.societe_extras_datapolicies_consentement, tr.societe_extras_datapolicies_opposition_traitement, tr.societe_extras_datapolicies_opposition_prospection';" . PHP_EOL;
426
                $jsscript .= "var forme_juridique = [" . PHP_EOL;
427
                $jsscript .= "11, 12, 13, 15, 17, 18, 19, 35, 60, 200, 311, 312, 316, 401, 600, 700, 1005" . PHP_EOL;
428
                $jsscript .= "];" . PHP_EOL;
429
                $jsscript .= "function hideRgPD() { if ($('#typent_id').val() == 8 || forme_juridique.indexOf(parseInt($('#forme_juridique_code').val())) > -1) { console.log(elementToHide); $('tr.societe_extras_datapolicies_consentement, tr.societe_extras_datapolicies_opposition_traitement, tr.societe_extras_datapolicies_opposition_prospection').show(); } else { $('tr.societe_extras_datapolicies_consentement, tr.societe_extras_datapolicies_opposition_traitement, tr.societe_extras_datapolicies_opposition_prospection').hide(); }}" . PHP_EOL;
430
                $jsscript .= "hideRgPD();" . PHP_EOL;
431
                $jsscript .= "$('#forme_juridique_code, #typent_id').change(function(){ hideRgPD(); });" . PHP_EOL;
432
                $jsscript .= '</script>';
433
            } elseif (GETPOST('action') == 'confirm_delete' && GETPOST('confirm') == 'yes' && GETPOST('socid') > 0) {
434
435
                // La suppression n'a pas été possible
436
                require_once DOL_DOCUMENT_ROOT . '/societe/class/societe.class.php';
437
                $societe = new Societe($this->db);
438
                $societe->fetch(GETPOST('socid'));
439
                // On vérifie si il est utilisé
440
                if ((in_array($object->forme_juridique_code, array(11, 12, 13, 15, 17, 18, 19, 35, 60, 200, 311, 312, 316, 401, 600, 700, 1005)) || $societe->typent_id == 8) && $societe->isObjectUsed(GETPOST('socid'))) {
441
442
                    require_once DOL_DOCUMENT_ROOT . '/core/class/html.form.class.php';
443
                    $form = new Form($this->db);
444
                    echo $form->formconfirm($_SERVER["PHP_SELF"] . "?socid=" . GETPOST('socid'), substr($langs->trans("DATAPOLICIES_POPUP_ANONYME_TITLE"), 0, strlen($langs->trans("DATAPOLICIES_POPUP_ANONYME_TITLE")) - 2), $langs->trans("DATAPOLICIES_POPUP_ANONYME_TEXTE"), 'anonymiser', '', '', 1);
445
                }
446
            }
447
448
            if (GETPOST('socid')) {
449
                require_once DOL_DOCUMENT_ROOT . '/societe/class/societe.class.php';
450
                $societe = new Societe($this->db);
451
                $societe->fetch(GETPOST('socid'));
452
453
                if (!in_array($object->forme_juridique_code, array(11, 12, 13, 15, 17, 18, 19, 35, 60, 200, 311, 312, 316, 401, 600, 700, 1005)) && $societe->typent_id != 8) {
454
455
                    require_once DOL_DOCUMENT_ROOT . '/core/class/html.form.class.php';
456
                    $jsscript .= '<script>';
457
                    $jsscript .= "var elementToHide = 'td.societe_extras_datapolicies_opposition_traitement, td.societe_extras_datapolicies_opposition_prospection, td.societe_extras_datapolicies_consentement';" . PHP_EOL;
458
                    $jsscript .= "$(elementToHide).parent('tr').hide();" . PHP_EOL;
459
                    $jsscript .= '</script>';
460
                }
461
            }
462
        } elseif ($parameters['currentcontext'] == 'contactcard') {
463
            if (GETPOST('action') == 'create' || GETPOST('action') == 'edit') {
464
                $jsscript .= '<script>';
465
                $jsscript .= "$('#options_datapolicies_opposition_traitement, #options_datapolicies_opposition_prospection, input[name=\"options_datapolicies_opposition_traitement\"], input[name=\"options_datapolicies_opposition_prospection\"]').change(function(){
466
                    if($('#options_datapolicies_opposition_traitement').prop('checked') == true || $('input[name=options_datapolicies_opposition_traitement]').prop('checked') || $('#options_datapolicies_opposition_prospection').prop('checked') || $('input[name=options_datapolicies_opposition_prospection]').prop('checked')) {
467
                        $('#no_email').val(1);
468
                    }
469
                });";
470
                $jsscript .= '</script>';
471
            }
472
        }
473
474
        echo $jsscript;
475
    }
476
}
477