Passed
Push — master ( 7e4a07...284492 )
by Alxarafe
19:58
created

dolibarr/htdocs/adherents/type.php (1 issue)

Labels
Severity
1
<?php
2
/* Copyright (C) 2001-2002	Rodolphe Quiedeville		<[email protected]>
3
 * Copyright (C) 2003		Jean-Louis Bergamo		<[email protected]>
4
 * Copyright (C) 2004-2011	Laurent Destailleur		<[email protected]>
5
 * Copyright (C) 2005-2017	Regis Houssin			<[email protected]>
6
 * Copyright (C) 2013		Florian Henry			<[email protected]>
7
 * Copyright (C) 2015		Alexandre Spangaro		<[email protected]>
8
 * Copyright (C) 2019       Alxarafe                <[email protected]>
9
 *
10
 * This program is free software; you can redistribute it and/or modify
11
 * it under the terms of the GNU General Public License as published by
12
 * the Free Software Foundation; either version 3 of the License, or
13
 * (at your option) any later version.
14
 *
15
 * This program is distributed in the hope that it will be useful,
16
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18
 * GNU General Public License for more details.
19
 *
20
 * You should have received a copy of the GNU General Public License
21
 * along with this program. If not, see <http://www.gnu.org/licenses/>.
22
 */
23
defined('BASE_PATH') or die('Single entry point through the index.php of the main folder');
24
25
/**
26
 *      \file       htdocs/adherents/type.php
27
 *      \ingroup    member
28
 *      \brief      Member's type setup
29
 */
30
31
require DOL_BASE_PATH . '/main.inc.php';
32
33
require_once DOL_DOCUMENT_ROOT . '/core/lib/member.lib.php';
34
require_once DOL_DOCUMENT_ROOT . '/adherents/class/adherent.class.php';
35
require_once DOL_DOCUMENT_ROOT . '/adherents/class/adherent_type.class.php';
36
require_once DOL_DOCUMENT_ROOT . '/core/class/extrafields.class.php';
37
38
$langs->load("members");
39
40
$rowid = GETPOST('rowid', 'int');
41
$action = GETPOST('action', 'alpha', 3);
42
$cancel = GETPOST('cancel', 'alpha');
43
$backtopage = GETPOST('backtopage', 'alpha');
44
45
$search_lastname = GETPOST('search_lastname', 'alpha');
46
$search_login = GETPOST('search_login', 'alpha');
47
$search_email = GETPOST('search_email', 'alpha');
48
$type = GETPOST('type', 'alpha');
49
$status = GETPOST('status', 'alpha');
50
51
$limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit;
52
$sortfield = GETPOST("sortfield", 'alpha');
53
$sortorder = GETPOST("sortorder", 'alpha');
54
$page = GETPOST("page", 'int');
55
if (empty($page) || $page == -1) {
56
    $page = 0;
57
}     // If $page is not defined, or '' or -1
58
$offset = $limit * $page;
59
$pageprev = $page - 1;
60
$pagenext = $page + 1;
61
if (!$sortorder) {
62
    $sortorder = "DESC";
63
}
64
if (!$sortfield) {
65
    $sortfield = "d.lastname";
66
}
67
68
$label = GETPOST("label", "alpha");
69
$subscription = GETPOST("subscription", "int");
70
$vote = GETPOST("vote", "int");
71
$comment = GETPOST("comment");
72
$mail_valid = GETPOST("mail_valid");
73
74
// Security check
75
$result = restrictedArea($user, 'adherent', $rowid, 'adherent_type');
76
77
$object = new AdherentType($db);
78
79
$extrafields = new ExtraFields($db);
80
81
// fetch optionals attributes and labels
82
$extralabels = $extrafields->fetch_name_optionals_label('adherent_type');
83
84
if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter', 'alpha')) { // All tests are required to be compatible with all browsers
85
    $search_lastname = "";
86
    $search_login = "";
87
    $search_email = "";
88
    $type = "";
89
    $sall = "";
90
}
91
92
// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
93
$hookmanager->initHooks(array('membertypecard', 'globalcard'));
94
95
/*
96
 * 	Actions
97
 */
98
99
if ($cancel) {
100
101
    $action = '';
102
103
    if (!empty($backtopage)) {
104
        header("Location: " . $backtopage);
105
        exit;
106
    }
107
}
108
109
if ($action == 'add' && $user->rights->adherent->configurer) {
110
    $object->label = trim($label);
111
    $object->subscription = (int) trim($subscription);
112
    $object->note = trim($comment);
113
    $object->mail_valid = trim($mail_valid);
114
    $object->vote = (boolean) trim($vote);
115
116
    // Fill array 'array_options' with data from add form
117
    $ret = $extrafields->setOptionalsFromPost($extralabels, $object);
118
    if ($ret < 0)
119
        $error++;
120
121
    if (empty($object->label)) {
122
        $error++;
123
        setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("Label")), null, 'errors');
124
    } else {
125
        $sql = "SELECT libelle FROM " . MAIN_DB_PREFIX . "adherent_type WHERE libelle='" . $db->escape($object->label) . "'";
126
        $result = $db->query($sql);
127
        if ($result) {
128
            $num = $db->num_rows($result);
129
        }
130
        if ($num) {
131
            $error++;
132
            $langs->load("errors");
133
            setEventMessages($langs->trans("ErrorLabelAlreadyExists", $login), null, 'errors');
134
        }
135
    }
136
137
    if (!$error) {
138
        $id = $object->create($user);
139
        if ($id > 0) {
140
            header("Location: " . $_SERVER["PHP_SELF"]);
141
            exit;
142
        } else {
143
            setEventMessages($object->error, $object->errors, 'errors');
144
            $action = 'create';
145
        }
146
    } else {
147
        $action = 'create';
148
    }
149
}
150
151
if ($action == 'update' && $user->rights->adherent->configurer) {
152
    $object->fetch($rowid);
153
154
    $object->oldcopy = clone $object;
155
156
    $object->label = trim($label);
157
    $object->subscription = (int) trim($subscription);
158
    $object->note = trim($comment);
159
    $object->mail_valid = trim($mail_valid);
160
    $object->vote = (boolean) trim($vote);
161
162
    // Fill array 'array_options' with data from add form
163
    $ret = $extrafields->setOptionalsFromPost($extralabels, $object);
164
    if ($ret < 0)
165
        $error++;
166
167
    $ret = $object->update($user);
168
169
    if ($ret >= 0 && !count($object->errors)) {
170
        setEventMessages($langs->trans("MemberTypeModified"), null, 'mesgs');
171
    } else {
172
        setEventMessages($object->error, $object->errors, 'errors');
173
    }
174
175
    //header("Location: ".$_SERVER["PHP_SELF"]."?rowid=".$object->id);
176
    header("Location: " . $_SERVER["PHP_SELF"] . "&rowid=" . $object->id);
177
    exit;
178
}
179
180
if ($action == 'confirm_delete' && $user->rights->adherent->configurer) {
181
    $object->fetch($rowid);
182
    $res = $object->delete();
183
184
    if ($res > 0) {
185
        setEventMessages($langs->trans("MemberTypeDeleted"), null, 'mesgs');
186
        header("Location: " . $_SERVER["PHP_SELF"]);
187
        exit;
188
    } else {
189
        setEventMessages($langs->trans("MemberTypeCanNotBeDeleted"), null, 'errors');
190
        $action = '';
191
    }
192
}
193
194
195
/*
196
 * View
197
 */
198
199
$form = new Form($db);
200
201
llxHeader('', $langs->trans("MembersTypeSetup"), 'EN:Module_Foundations|FR:Module_Adh&eacute;rents|ES:M&oacute;dulo_Miembros');
202
203
204
// List of members type
205
if (!$rowid && $action != 'create' && $action != 'edit') {
206
    //dol_fiche_head('');
207
208
    $sql = "SELECT d.rowid, d.libelle as label, d.subscription, d.vote";
209
    $sql .= " FROM " . MAIN_DB_PREFIX . "adherent_type as d";
210
    $sql .= " WHERE d.entity IN (" . getEntity('member_type') . ")";
211
212
    $result = $db->query($sql);
213
    if ($result) {
214
        $num = $db->num_rows($result);
215
        $nbtotalofrecords = $num;
216
217
        $i = 0;
218
219
        $param = '';
220
221
        $newcardbutton = '';
222
        if ($user->rights->adherent->configurer) {
223
            $newcardbutton = '<a class="butActionNew" href="' . DOL_URL_ROOT . '/adherents/type.php?action=create"><span class="valignmiddle">' . $langs->trans('NewMemberType') . '</span>';
224
            $newcardbutton .= '<span class="fa fa-plus-circle valignmiddle"></span>';
225
            $newcardbutton .= '</a>';
226
        }
227
228
        // print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'">';
229
        print '<form method="POST" href="' . $_SERVER["PHP_SELF"] . '">';
230
        if ($optioncss != '') {
231
            print '<input type="hidden" name="optioncss" value="' . $optioncss . '">';
232
        }
233
        print '<input type="hidden" name="token" value="' . $_SESSION['newtoken'] . '">';
234
        print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
235
        print '<input type="hidden" name="action" value="list">';
236
        print '<input type="hidden" name="sortfield" value="' . $sortfield . '">';
237
        print '<input type="hidden" name="page" value="' . $page . '">';
238
        print '<input type="hidden" name="sortorder" value="' . $sortorder . '">';
239
240
        print_barre_liste($langs->trans("MembersTypes"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, $nbtotalofrecords, 'title_generic.png', 0, $newcardbutton, '', $limit);
241
242
        $moreforfilter = '';
243
244
        print '<div class="div-table-responsive">';
245
        print '<table class="tagtable liste' . ($moreforfilter ? " listwithfilterbefore" : "") . '">' . "\n";
246
247
        print '<tr class="liste_titre">';
248
        print '<th>' . $langs->trans("Ref") . '</th>';
249
        print '<th>' . $langs->trans("Label") . '</th>';
250
        print '<th align="center">' . $langs->trans("SubscriptionRequired") . '</th>';
251
        print '<th align="center">' . $langs->trans("VoteAllowed") . '</th>';
252
        print '<th>&nbsp;</th>';
253
        print "</tr>\n";
254
255
        $membertype = new AdherentType($db);
256
257
        while ($i < $num) {
258
            $objp = $db->fetch_object($result);
259
260
            $membertype->id = $objp->rowid;
261
            $membertype->ref = $objp->rowid;
262
            $membertype->label = $objp->rowid;
263
264
            print '<tr class="oddeven">';
265
            print '<td>';
266
            print $membertype->getNomUrl(1);
267
            //<a href="'.$_SERVER["PHP_SELF"].'?rowid='.$objp->rowid.'">'.img_object($langs->trans("ShowType"),'group').' '.$objp->rowid.'</a>
268
            print '</td>';
269
            print '<td>' . dol_escape_htmltag($objp->label) . '</td>';
270
            print '<td align="center">' . yn($objp->subscription) . '</td>';
271
            print '<td align="center">' . yn($objp->vote) . '</td>';
272
            if ($user->rights->adherent->configurer) {
273
                print '<td align="right"><a href="' . $_SERVER["PHP_SELF"] . '?action=edit&rowid=' . $objp->rowid . '">' . img_edit() . '</a></td>';
274
            } else
275
                print '<td align="right">&nbsp;</td>';
276
            print "</tr>";
277
            $i++;
278
        }
279
        print "</table>";
280
        print '</div>';
281
282
        print '</form>';
283
    }
284
    else {
285
        dol_print_error($db);
286
    }
287
}
288
289
290
/* * ************************************************************************* */
291
/*                                                                            */
292
/* Creation mode                                                              */
293
/*                                                                            */
294
/* * ************************************************************************* */
295
if ($action == 'create') {
296
    $object = new AdherentType($db);
297
298
    print load_fiche_titre($langs->trans("NewMemberType"));
299
300
    //print '<form action="'.$_SERVER['PHP_SELF'].'" method="POST">';
301
    print '<form href="' . $_SERVER['PHP_SELF'] . '" method="POST">';
302
    print '<input type="hidden" name="token" value="' . $_SESSION['newtoken'] . '">';
303
    print '<input type="hidden" name="action" value="add">';
304
305
    dol_fiche_head('');
306
307
    print '<table class="border" width="100%">';
308
    print '<tbody>';
309
310
    print '<tr><td class="titlefieldcreate fieldrequired">' . $langs->trans("Label") . '</td><td><input type="text" class="minwidth200" name="label" autofocus="autofocus"></td></tr>';
311
312
    print '<tr><td>' . $langs->trans("SubscriptionRequired") . '</td><td>';
313
    print $form->selectyesno("subscription", 1, 1);
314
    print '</td></tr>';
315
316
    print '<tr><td>' . $langs->trans("VoteAllowed") . '</td><td>';
317
    print $form->selectyesno("vote", 0, 1);
318
    print '</td></tr>';
319
320
    print '<tr><td class="tdtop">' . $langs->trans("Description") . '</td><td>';
321
    print '<textarea name="comment" wrap="soft" class="centpercent" rows="3"></textarea></td></tr>';
322
323
    print '<tr><td class="tdtop">' . $langs->trans("WelcomeEMail") . '</td><td>';
324
    require_once DOL_DOCUMENT_ROOT . '/core/class/doleditor.class.php';
325
    $doleditor = new DolEditor('mail_valid', $object->mail_valid, '', 280, 'dolibarr_notes', '', false, true, $conf->fckeditor->enabled, 15, '90%');
326
    $doleditor->Create();
327
    print '</td></tr>';
328
329
    // Other attributes
330
    $parameters = array();
331
    $reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $act, $action);    // Note that $action and $object may have been modified by hook
332
    print $hookmanager->resPrint;
333
    if (empty($reshook)) {
334
        print $object->showOptionals($extrafields, 'edit');
335
    }
336
    print '<tbody>';
337
    print "</table>\n";
338
339
    dol_fiche_end();
340
341
    print '<div class="center">';
342
    print '<input type="submit" name="button" class="button" value="' . $langs->trans("Add") . '">';
343
    print '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
344
    print '<input type="submit" name="cancel" class="button" value="' . $langs->trans("Cancel") . '" onclick="history.go(-1)" />';
345
    print '</div>';
346
347
    print "</form>\n";
348
}
349
350
/* * ************************************************************************* */
351
/*                                                                            */
352
/* View mode                                                                  */
353
/*                                                                            */
354
/* * ************************************************************************* */
355
if ($rowid > 0) {
356
    if ($action != 'edit') {
357
        $object = new AdherentType($db);
358
        $object->fetch($rowid);
359
        $object->fetch_optionals();
360
361
        /*
362
         * Confirmation suppression
363
         */
364
        if ($action == 'delete') {
365
            print $form->formconfirm($_SERVER['PHP_SELF'] . "&rowid=" . $object->id, $langs->trans("DeleteAMemberType"), $langs->trans("ConfirmDeleteMemberType", $object->label), "confirm_delete", '', 0, 1);
366
        }
367
368
        $head = member_type_prepare_head($object);
369
370
        dol_fiche_head($head, 'card', $langs->trans("MemberType"), -1, 'group');
371
372
        //$linkback = '<a href="'.DOL_URL_ROOT.'/adherents/type.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>';
373
        $linkback = '<a href="' . BASE_URI . '?controller=adherents&method=type&restore_lastsearch_values=1">' . $langs->trans("BackToList") . '</a>';
0 ignored issues
show
The constant BASE_URI was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
374
375
        dol_banner_tab($object, 'rowid', $linkback);
376
377
        print '<div class="fichecenter">';
378
        print '<div class="underbanner clearboth"></div>';
379
380
        print '<table class="border" width="100%">';
381
382
        print '<tr><td class="titlefield">' . $langs->trans("SubscriptionRequired") . '</td><td>';
383
        print yn($object->subscription);
384
        print '</tr>';
385
386
        print '<tr><td>' . $langs->trans("VoteAllowed") . '</td><td>';
387
        print yn($object->vote);
388
        print '</tr>';
389
390
        print '<tr><td class="tdtop">' . $langs->trans("Description") . '</td><td>';
391
        print nl2br($object->note) . "</td></tr>";
392
393
        print '<tr><td class="tdtop">' . $langs->trans("WelcomeEMail") . '</td><td>';
394
        print nl2br($object->mail_valid) . "</td></tr>";
395
396
        // Other attributes
397
        include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_view.tpl.php';
398
399
        print '</table>';
400
        print '</div>';
401
402
        dol_fiche_end();
403
404
        /*
405
         * Buttons
406
         */
407
408
        print '<div class="tabsAction">';
409
410
        // Edit
411
        if ($user->rights->adherent->configurer) {
412
            print '<div class="inline-block divButAction"><a class="butAction" href="' . $_SERVER['PHP_SELF'] . '&action=edit&amp;rowid=' . $object->id . '">' . $langs->trans("Modify") . '</a></div>';
413
        }
414
415
        // Add
416
        print '<div class="inline-block divButAction"><a class="butAction" href="card.php&action=create&typeid=' . $object->id . '&backtopage=' . urlencode($_SERVER["PHP_SELF"] . '&rowid=' . $object->id) . '">' . $langs->trans("AddMember") . '</a></div>';
417
418
        // Delete
419
        if ($user->rights->adherent->configurer) {
420
            print '<div class="inline-block divButAction"><a class="butActionDelete" href="' . $_SERVER['PHP_SELF'] . '&action=delete&rowid=' . $object->id . '">' . $langs->trans("DeleteType") . '</a></div>';
421
        }
422
423
        print "</div>";
424
425
426
        // Show list of members (nearly same code than in page list.php)
427
428
        $membertypestatic = new AdherentType($db);
429
430
        $now = dol_now();
431
432
        $sql = "SELECT d.rowid, d.login, d.firstname, d.lastname, d.societe, ";
433
        $sql .= " d.datefin,";
434
        $sql .= " d.email, d.fk_adherent_type as type_id, d.morphy, d.statut,";
435
        $sql .= " t.libelle as type, t.subscription";
436
        $sql .= " FROM " . MAIN_DB_PREFIX . "adherent as d, " . MAIN_DB_PREFIX . "adherent_type as t";
437
        $sql .= " WHERE d.fk_adherent_type = t.rowid ";
438
        $sql .= " AND d.entity IN (" . getEntity('adherent') . ")";
439
        $sql .= " AND t.rowid = " . $object->id;
440
        if ($sall) {
441
            $sql .= natural_search(array("f.firstname", "d.lastname", "d.societe", "d.email", "d.login", "d.address", "d.town", "d.note_public", "d.note_private"), $sall);
442
        }
443
        if ($status != '') {
444
            $sql .= natural_search('d.statut', $status, 2);
445
        }
446
        if ($action == 'search') {
447
            if (GETPOST('search', 'alpha')) {
448
                $sql .= natural_search(array("d.firstname", "d.lastname"), GETPOST('search', 'alpha'));
449
            }
450
        }
451
        if (!empty($search_lastname)) {
452
            $sql .= natural_search(array("d.firstname", "d.lastname"), $search_lastname);
453
        }
454
        if (!empty($search_login)) {
455
            $sql .= natural_search("d.login", $search_login);
456
        }
457
        if (!empty($search_email)) {
458
            $sql .= natural_search("d.email", $search_email);
459
        }
460
        if ($filter == 'uptodate') {
461
            $sql .= " AND datefin >= '" . $db->idate($now) . "'";
462
        }
463
        if ($filter == 'outofdate') {
464
            $sql .= " AND datefin < '" . $db->idate($now) . "'";
465
        }
466
467
        $sql .= " " . $db->order($sortfield, $sortorder);
468
469
        // Count total nb of records
470
        $nbtotalofrecords = '';
471
        if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) {
472
            $resql = $db->query($sql);
473
            if ($resql)
474
                $nbtotalofrecords = $db->num_rows($result);
475
            else
476
                dol_print_error($db);
477
            if (($page * $limit) > $nbtotalofrecords) { // if total resultset is smaller then paging size (filtering), goto and load page 0
478
                $page = 0;
479
                $offset = 0;
480
            }
481
        }
482
483
        $sql .= " " . $db->plimit($conf->liste_limit + 1, $offset);
484
485
        $resql = $db->query($sql);
486
        if ($resql) {
487
            $num = $db->num_rows($resql);
488
            $i = 0;
489
490
            $titre = $langs->trans("MembersList");
491
            if ($status != '') {
492
                if ($status == '-1,1') {
493
                    $titre = $langs->trans("MembersListQualified");
494
                } else if ($status == '-1') {
495
                    $titre = $langs->trans("MembersListToValid");
496
                } else if ($status == '1' && !$filter) {
497
                    $titre = $langs->trans("MembersListValid");
498
                } else if ($status == '1' && $filter == 'uptodate') {
499
                    $titre = $langs->trans("MembersListUpToDate");
500
                } else if ($status == '1' && $filter == 'outofdate') {
501
                    $titre = $langs->trans("MembersListNotUpToDate");
502
                } else if ($status == '0') {
503
                    $titre = $langs->trans("MembersListResiliated");
504
                }
505
            } elseif ($action == 'search') {
506
                $titre = $langs->trans("MembersListQualified");
507
            }
508
509
            if ($type > 0) {
510
                $membertype = new AdherentType($db);
511
                $result = $membertype->fetch($type);
512
                $titre .= " (" . $membertype->label . ")";
513
            }
514
515
            $param = "&rowid=" . $object->id;
516
            if (!empty($status))
517
                $param .= "&status=" . $status;
518
            if (!empty($search_lastname))
519
                $param .= "&search_lastname=" . $search_lastname;
520
            if (!empty($search_firstname))
521
                $param .= "&search_firstname=" . $search_firstname;
522
            if (!empty($search_login))
523
                $param .= "&search_login=" . $search_login;
524
            if (!empty($search_email))
525
                $param .= "&search_email=" . $search_email;
526
            if (!empty($filter))
527
                $param .= "&filter=" . $filter;
528
529
            if ($sall) {
530
                print $langs->trans("Filter") . " (" . $langs->trans("Lastname") . ", " . $langs->trans("Firstname") . ", " . $langs->trans("EMail") . ", " . $langs->trans("Address") . " " . $langs->trans("or") . " " . $langs->trans("Town") . "): " . $sall;
531
            }
532
533
            //print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'">';
534
            print '<form method="POST" href="' . $_SERVER["PHP_SELF"] . '">';
535
            print '<input class="flat" type="hidden" name="rowid" value="' . $object->id . '" size="12"></td>';
536
537
            print '<br>';
538
            print_barre_liste('', $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, $nbtotalofrecords);
539
540
            $moreforfilter = '';
541
542
            print '<div class="div-table-responsive">';
543
            print '<table class="tagtable liste' . ($moreforfilter ? " listwithfilterbefore" : "") . '">' . "\n";
544
545
            // Lignes des champs de filtre
546
            print '<tr class="liste_titre_filter">';
547
548
            print '<td class="liste_titre" align="left">';
549
            print '<input class="flat" type="text" name="search_lastname" value="' . dol_escape_htmltag($search_lastname) . '" size="12"></td>';
550
551
            print '<td class="liste_titre" align="left">';
552
            print '<input class="flat" type="text" name="search_login" value="' . dol_escape_htmltag($search_login) . '" size="7"></td>';
553
554
            print '<td class="liste_titre">&nbsp;</td>';
555
556
            print '<td class="liste_titre" align="left">';
557
            print '<input class="flat" type="text" name="search_email" value="' . dol_escape_htmltag($search_email) . '" size="12"></td>';
558
559
            print '<td class="liste_titre">&nbsp;</td>';
560
561
            print '<td align="right" colspan="2" class="liste_titre">';
562
            print '<input type="image" class="liste_titre" src="' . DOL_URL_ROOT . '/theme/' . $conf->theme . '/img/search.png" name="button_search" value="' . dol_escape_htmltag($langs->trans("Search")) . '" title="' . dol_escape_htmltag($langs->trans("Search")) . '">';
563
            print '&nbsp; ';
564
            print '<input type="image" class="liste_titre" src="' . DOL_URL_ROOT . '/theme/' . $conf->theme . '/img/searchclear.png" name="button_removefilter" value="' . dol_escape_htmltag($langs->trans("RemoveFilter")) . '" title="' . dol_escape_htmltag($langs->trans("RemoveFilter")) . '">';
565
            print '</td>';
566
567
            print "</tr>\n";
568
569
            print '<tr class="liste_titre">';
570
            print_liste_field_titre($langs->trans("Name") . " / " . $langs->trans("Company"), $_SERVER["PHP_SELF"], "d.lastname", $param, "", "", $sortfield, $sortorder);
571
            print_liste_field_titre("Login", $_SERVER["PHP_SELF"], "d.login", $param, "", "", $sortfield, $sortorder);
572
            print_liste_field_titre("Nature", $_SERVER["PHP_SELF"], "d.morphy", $param, "", "", $sortfield, $sortorder);
573
            print_liste_field_titre("EMail", $_SERVER["PHP_SELF"], "d.email", $param, "", "", $sortfield, $sortorder);
574
            print_liste_field_titre("Status", $_SERVER["PHP_SELF"], "d.statut,d.datefin", $param, "", "", $sortfield, $sortorder);
575
            print_liste_field_titre("EndSubscription", $_SERVER["PHP_SELF"], "d.datefin", $param, "", 'align="center"', $sortfield, $sortorder);
576
            print_liste_field_titre("Action", $_SERVER["PHP_SELF"], "", $param, "", 'width="60" align="center"', $sortfield, $sortorder);
577
            print "</tr>\n";
578
579
            while ($i < $num && $i < $conf->liste_limit) {
580
                $objp = $db->fetch_object($resql);
581
582
                $datefin = $db->jdate($objp->datefin);
583
584
                $adh = new Adherent($db);
585
                $adh->lastname = $objp->lastname;
586
                $adh->firstname = $objp->firstname;
587
588
                // Lastname
589
                print '<tr class="oddeven">';
590
                if ($objp->societe != '') {
591
                    // print '<td><a href="card.php?rowid='.$objp->rowid.'">'.img_object($langs->trans("ShowMember"),"user").' '.$adh->getFullName($langs,0,-1,20).' / '.dol_trunc($objp->societe,12).'</a></td>'."\n";
592
                    print '<td><a href="' . BASE_URI . '?controller=adherent&method=card&rowid=' . $objp->rowid . '">' . img_object($langs->trans("ShowMember"), "user") . ' ' . $adh->getFullName($langs, 0, -1, 20) . ' / ' . dol_trunc($objp->societe, 12) . '</a></td>' . "\n";
593
                } else {
594
                    // print '<td><a href="card.php?rowid='.$objp->rowid.'">'.img_object($langs->trans("ShowMember"),"user").' '.$adh->getFullName($langs,0,-1,32).'</a></td>'."\n";
595
                    print '<td><a href="' . BASE_URI . '?adherent&method=card&rowid=' . $objp->rowid . '">' . img_object($langs->trans("ShowMember"), "user") . ' ' . $adh->getFullName($langs, 0, -1, 32) . '</a></td>' . "\n";
596
                }
597
598
                // Login
599
                print "<td>" . $objp->login . "</td>\n";
600
601
                // Type
602
                /* print '<td class="nowrap">';
603
                  $membertypestatic->id=$objp->type_id;
604
                  $membertypestatic->label=$objp->type;
605
                  print $membertypestatic->getNomUrl(1,12);
606
                  print '</td>';
607
                 */
608
609
                // Moral/Physique
610
                print "<td>" . $adh->getmorphylib($objp->morphy) . "</td>\n";
611
612
                // EMail
613
                print "<td>" . dol_print_email($objp->email, 0, 0, 1) . "</td>\n";
614
615
                // Statut
616
                print '<td class="nowrap">';
617
                print $adh->LibStatut($objp->statut, $objp->subscription, $datefin, 2);
618
                print "</td>";
619
620
                // Date end subscription
621
                if ($datefin) {
622
                    print '<td align="center" class="nowrap">';
623
                    if ($datefin < dol_now() && $objp->statut > 0) {
624
                        print dol_print_date($datefin, 'day') . " " . img_warning($langs->trans("SubscriptionLate"));
625
                    } else {
626
                        print dol_print_date($datefin, 'day');
627
                    }
628
                    print '</td>';
629
                } else {
630
                    print '<td align="left" class="nowrap">';
631
                    if ($objp->subscription == 'yes') {
632
                        print $langs->trans("SubscriptionNotReceived");
633
                        if ($objp->statut > 0)
634
                            print " " . img_warning();
635
                    }
636
                    else {
637
                        print '&nbsp;';
638
                    }
639
                    print '</td>';
640
                }
641
642
                // Actions
643
                print '<td align="center">';
644
                if ($user->rights->adherent->creer) {
645
                    // print '<a href="card.php?rowid=' . $objp->rowid . '&action=edit&backtopage=' . urlencode($_SERVER["PHP_SELF"] . '?rowid=' . $object->id) . '">' . img_edit() . '</a>';
646
                    print '<a href="' . BASE_URI . '?controller=adherent&method=card&rowid=' . $objp->rowid . '&action=edit&backtopage=' . urlencode($_SERVER["PHP_SELF"] . '&rowid=' . $object->id) . '">' . img_edit() . '</a>';
647
                }
648
                print '&nbsp;';
649
                if ($user->rights->adherent->supprimer) {
650
                    // print '<a href="card.php?rowid=' . $objp->rowid . '&action=resign">' . img_picto($langs->trans("Resiliate"), 'disable.png') . '</a>';
651
                    print '<a href="' . BASE_URI . '?controller=adherent&method=card&rowid=' . $objp->rowid . '&action=resign">' . img_picto($langs->trans("Resiliate"), 'disable.png') . '</a>';
652
                }
653
                print "</td>";
654
655
                print "</tr>\n";
656
                $i++;
657
            }
658
659
            print "</table>\n";
660
            print '</div>';
661
            print '</form>';
662
663
            if ($num > $conf->liste_limit) {
664
                print_barre_liste('', $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, $nbtotalofrecords, '');
665
            }
666
        } else {
667
            dol_print_error($db);
668
        }
669
    }
670
671
    /*     * ************************************************************************* */
672
    /*                                                                            */
673
    /* Edition mode                                                               */
674
    /*                                                                            */
675
    /*     * ************************************************************************* */
676
677
    if ($action == 'edit') {
678
        $object = new AdherentType($db);
679
        $object->fetch($rowid);
680
        $object->fetch_optionals();
681
682
        $head = member_type_prepare_head($object);
683
684
        //print '<form method="post" action="'.$_SERVER["PHP_SELF"].'?rowid='.$object->id.'">';
685
        print '<form method="post" href="' . $_SERVER["PHP_SELF"] . '&rowid=' . $object->id . '">';
686
        print '<input type="hidden" name="token" value="' . $_SESSION['newtoken'] . '">';
687
        print '<input type="hidden" name="rowid" value="' . $object->id . '">';
688
        print '<input type="hidden" name="action" value="update">';
689
690
        dol_fiche_head($head, 'card', $langs->trans("MemberType"), 0, 'group');
691
692
        print '<table class="border" width="100%">';
693
694
        print '<tr><td class="titlefield">' . $langs->trans("Ref") . '</td><td>' . $object->id . '</td></tr>';
695
696
        print '<tr><td class="fieldrequired">' . $langs->trans("Label") . '</td><td><input type="text" name="label" size="40" value="' . dol_escape_htmltag($object->label) . '"></td></tr>';
697
698
        print '<tr><td>' . $langs->trans("SubscriptionRequired") . '</td><td>';
699
        print $form->selectyesno("subscription", $object->subscription, 1);
700
        print '</td></tr>';
701
702
        print '<tr><td>' . $langs->trans("VoteAllowed") . '</td><td>';
703
        print $form->selectyesno("vote", $object->vote, 1);
704
        print '</td></tr>';
705
706
        print '<tr><td class="tdtop">' . $langs->trans("Description") . '</td><td>';
707
        print '<textarea name="comment" wrap="soft" class="centpercent" rows="3">' . $object->note . '</textarea></td></tr>';
708
709
        print '<tr><td class="tdtop">' . $langs->trans("WelcomeEMail") . '</td><td>';
710
        require_once DOL_DOCUMENT_ROOT . '/core/class/doleditor.class.php';
711
        $doleditor = new DolEditor('mail_valid', $object->mail_valid, '', 280, 'dolibarr_notes', '', false, true, $conf->fckeditor->enabled, 15, '90%');
712
        $doleditor->Create();
713
        print "</td></tr>";
714
715
        // Other attributes
716
        $parameters = array();
717
        $reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $act, $action);    // Note that $action and $object may have been modified by hook
718
        print $hookmanager->resPrint;
719
        if (empty($reshook)) {
720
            print $object->showOptionals($extrafields, 'edit');
721
        }
722
723
        print '</table>';
724
725
        // Extra field
726
        if (empty($reshook)) {
727
            print '<br><br><table class="border" width="100%">';
728
            foreach ($extrafields->attribute_label as $key => $label) {
729
                if (isset($_POST["options_" . $key])) {
730
                    if (is_array($_POST["options_" . $key])) {
731
                        // $_POST["options"] is an array but following code expects a comma separated string
732
                        $value = implode(",", $_POST["options_" . $key]);
733
                    } else {
734
                        $value = $_POST["options_" . $key];
735
                    }
736
                } else {
737
                    $value = $adht->array_options["options_" . $key];
738
                }
739
                print '<tr><td width="30%">' . $label . '</td><td>';
740
                print $extrafields->showInputField($key, $value);
741
                print "</td></tr>\n";
742
            }
743
            print '</table><br><br>';
744
        }
745
746
        dol_fiche_end();
747
748
        print '<div class="center">';
749
        print '<input type="submit" class="button" value="' . $langs->trans("Save") . '">';
750
        print '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
751
        print '<input type="submit" name="cancel" class="button" value="' . $langs->trans("Cancel") . '">';
752
        print '</div>';
753
754
        print "</form>";
755
    }
756
}
757
758
// End of page
759
llxFooter();
760
$db->close();
761