Total Complexity | 1417 |
Total Lines | 7605 |
Duplicated Lines | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
Complex classes like AdherentController often do a lot of different things. To break such a class down, we need to identify a cohesive component within that class. A common approach to find such a component is to look for fields/methods that share the same prefixes, or suffixes.
Once you have determined the fields that belong together, you can apply the Extract Class refactoring. If the component makes sense as a sub-class, Extract Subclass is also a candidate, and is often faster.
While breaking up the class, it is a good idea to analyze how other classes use AdherentController, and based on these observations, apply Extract Interface, too.
1 | <?php |
||
104 | class AdherentController extends DolibarrController |
||
105 | { |
||
106 | /** |
||
107 | * \file htdocs/adherents/agenda.php |
||
108 | * \ingroup member |
||
109 | * \brief Page of members events |
||
110 | */ |
||
111 | public function agenda() |
||
112 | { |
||
113 | global $conf; |
||
114 | global $db; |
||
115 | global $user; |
||
116 | global $hookmanager; |
||
117 | global $user; |
||
118 | global $menumanager; |
||
119 | global $langs; |
||
120 | |||
121 | // Load translation files required by the page |
||
122 | $langs->loadLangs(array('companies', 'members')); |
||
123 | |||
124 | // Get Parameters |
||
125 | $id = GETPOSTINT('id') ? GETPOSTINT('id') : GETPOSTINT('rowid'); |
||
126 | |||
127 | // Pagination |
||
128 | $limit = GETPOSTINT('limit') ? GETPOSTINT('limit') : $conf->liste_limit; |
||
129 | $sortfield = GETPOST('sortfield', 'aZ09comma'); |
||
130 | $sortorder = GETPOST('sortorder', 'aZ09comma'); |
||
131 | $page = GETPOSTISSET('pageplusone') ? (GETPOSTINT('pageplusone') - 1) : GETPOSTINT("page"); |
||
132 | if (empty($page) || $page == -1) { |
||
133 | $page = 0; |
||
134 | } // If $page is not defined, or '' or -1 |
||
135 | $offset = $limit * $page; |
||
136 | $pageprev = $page - 1; |
||
137 | $pagenext = $page + 1; |
||
138 | if (!$sortfield) { |
||
139 | $sortfield = 'a.datep,a.id'; |
||
140 | } |
||
141 | if (!$sortorder) { |
||
142 | $sortorder = 'DESC'; |
||
143 | } |
||
144 | |||
145 | if (GETPOST('actioncode', 'array')) { |
||
146 | $actioncode = GETPOST('actioncode', 'array', 3); |
||
147 | if (!count($actioncode)) { |
||
148 | $actioncode = '0'; |
||
149 | } |
||
150 | } else { |
||
151 | $actioncode = GETPOST("actioncode", "alpha", 3) ? GETPOST("actioncode", "alpha", 3) : (GETPOST("actioncode") == '0' ? '0' : getDolGlobalString('AGENDA_DEFAULT_FILTER_TYPE_FOR_OBJECT')); |
||
152 | } |
||
153 | $search_rowid = GETPOST('search_rowid'); |
||
154 | $search_agenda_label = GETPOST('search_agenda_label'); |
||
155 | |||
156 | // Get object canvas (By default, this is not defined, so standard usage of dolibarr) |
||
157 | $objcanvas = null; |
||
158 | |||
159 | // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context |
||
160 | $hookmanager->initHooks(array('memberagenda', 'globalcard')); |
||
161 | |||
162 | // Security check |
||
163 | $result = restrictedArea($user, 'adherent', $id); |
||
164 | |||
165 | // Initialize technical objects |
||
166 | $object = new Adherent($db); |
||
167 | $result = $object->fetch($id); |
||
168 | if ($result > 0) { |
||
169 | $object->fetch_thirdparty(); |
||
170 | |||
171 | $adht = new AdherentType($db); |
||
172 | $result = $adht->fetch($object->typeid); |
||
173 | } |
||
174 | |||
175 | |||
176 | /* |
||
177 | * Actions |
||
178 | */ |
||
179 | |||
180 | $parameters = array('id' => $id, 'objcanvas' => $objcanvas); |
||
181 | $reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks |
||
182 | if ($reshook < 0) { |
||
183 | setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); |
||
184 | } |
||
185 | |||
186 | if (empty($reshook)) { |
||
187 | // Cancel |
||
188 | if (GETPOST('cancel', 'alpha') && !empty($backtopage)) { |
||
189 | header("Location: " . $backtopage); |
||
190 | exit; |
||
191 | } |
||
192 | |||
193 | // Purge search criteria |
||
194 | if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) { // All test are required to be compatible with all browsers |
||
195 | $actioncode = ''; |
||
196 | $search_rowid = ''; |
||
197 | $search_agenda_label = ''; |
||
198 | } |
||
199 | } |
||
200 | |||
201 | |||
202 | |||
203 | /* |
||
204 | * View |
||
205 | */ |
||
206 | |||
207 | $contactstatic = new Contact($db); |
||
208 | |||
209 | $form = new Form($db); |
||
210 | |||
211 | |||
212 | if ($object->id > 0) { |
||
213 | require_once DOL_DOCUMENT_ROOT . '/core/lib/company.lib.php'; |
||
214 | require_once DOL_DOCUMENT_ROOT . '/societe/class/societe.class.php'; |
||
215 | |||
216 | $langs->load("companies"); |
||
217 | |||
218 | $title = $langs->trans("Member") . " - " . $langs->trans("Agenda"); |
||
219 | |||
220 | $help_url = "EN:Module_Foundations|FR:Module_Adhérents|ES:Módulo_Miembros|DE:Modul_Mitglieder"; |
||
221 | |||
222 | llxHeader("", $title, $help_url); |
||
223 | |||
224 | if (isModEnabled('notification')) { |
||
225 | $langs->load("mails"); |
||
226 | } |
||
227 | $head = member_prepare_head($object); |
||
228 | |||
229 | print dol_get_fiche_head($head, 'agenda', $langs->trans("Member"), -1, 'user'); |
||
230 | |||
231 | $linkback = '<a href="' . DOL_URL_ROOT . '/adherents/list.php?restore_lastsearch_values=1">' . $langs->trans("BackToList") . '</a>'; |
||
232 | |||
233 | $morehtmlref = '<a href="' . DOL_URL_ROOT . '/adherents/vcard.php?id=' . $object->id . '" class="refid">'; |
||
234 | $morehtmlref .= img_picto($langs->trans("Download") . ' ' . $langs->trans("VCard"), 'vcard.png', 'class="valignmiddle marginleftonly paddingrightonly"'); |
||
235 | $morehtmlref .= '</a>'; |
||
236 | |||
237 | dol_banner_tab($object, 'rowid', $linkback, 1, 'rowid', 'ref', $morehtmlref); |
||
238 | |||
239 | print '<div class="fichecenter">'; |
||
240 | |||
241 | print '<div class="underbanner clearboth"></div>'; |
||
242 | |||
243 | $object->info($id); |
||
244 | dol_print_object_info($object, 1); |
||
245 | |||
246 | print '</div>'; |
||
247 | |||
248 | print dol_get_fiche_end(); |
||
249 | |||
250 | |||
251 | //print '<div class="tabsAction">'; |
||
252 | //print '</div>'; |
||
253 | |||
254 | |||
255 | $newcardbutton = ''; |
||
256 | if (isModEnabled('agenda')) { |
||
257 | $newcardbutton .= dolGetButtonTitle($langs->trans('AddAction'), '', 'fa fa-plus-circle', DOL_URL_ROOT . '/comm/action/card.php?action=create&backtopage=' . urlencode($_SERVER['PHP_SELF']) . ($object->id > 0 ? '?id=' . $object->id : '') . '&origin=member&originid=' . $id); |
||
258 | } |
||
259 | |||
260 | if (isModEnabled('agenda') && ($user->hasRight('agenda', 'myactions', 'read') || $user->hasRight('agenda', 'allactions', 'read'))) { |
||
261 | print '<br>'; |
||
262 | |||
263 | $param = '&id=' . $id; |
||
264 | if (!empty($contextpage) && $contextpage != $_SERVER['PHP_SELF']) { |
||
265 | $param .= '&contextpage=' . $contextpage; |
||
266 | } |
||
267 | if ($limit > 0 && $limit != $conf->liste_limit) { |
||
268 | $param .= '&limit=' . $limit; |
||
269 | } |
||
270 | |||
271 | print_barre_liste($langs->trans("ActionsOnMember"), 0, $_SERVER['PHP_SELF'], '', $sortfield, $sortorder, '', 0, -1, '', '', $newcardbutton, '', 0, 1, 1); |
||
272 | |||
273 | // List of all actions |
||
274 | $filters = array(); |
||
275 | $filters['search_agenda_label'] = $search_agenda_label; |
||
276 | $filters['search_rowid'] = $search_rowid; |
||
277 | |||
278 | // TODO Replace this with same code than into list.php |
||
279 | show_actions_done($conf, $langs, $db, $object, null, 0, $actioncode, '', $filters, $sortfield, $sortorder); |
||
280 | } |
||
281 | } |
||
282 | |||
283 | // End of page |
||
284 | llxFooter(); |
||
285 | $db->close(); |
||
286 | } |
||
287 | |||
288 | /** |
||
289 | * \file htdocs/adherents/card.php |
||
290 | * \ingroup member |
||
291 | * \brief Page of a member |
||
292 | */ |
||
293 | public function card() |
||
294 | { |
||
295 | global $conf; |
||
296 | global $db; |
||
297 | global $user; |
||
298 | global $hookmanager; |
||
299 | global $user; |
||
300 | global $menumanager; |
||
301 | global $langs; |
||
302 | |||
303 | // Load translation files required by the page |
||
304 | $langs->loadLangs(array("companies", "bills", "members", "users", "other", "paypal")); |
||
305 | |||
306 | |||
307 | // Get parameters |
||
308 | $action = GETPOST('action', 'aZ09'); |
||
309 | $cancel = GETPOST('cancel', 'alpha'); |
||
310 | $backtopage = GETPOST('backtopage', 'alpha'); |
||
311 | $confirm = GETPOST('confirm', 'alpha'); |
||
312 | $rowid = GETPOSTINT('rowid'); |
||
313 | $id = GETPOST('id') ? GETPOSTINT('id') : $rowid; |
||
314 | $typeid = GETPOSTINT('typeid'); |
||
315 | $userid = GETPOSTINT('userid'); |
||
316 | $socid = GETPOSTINT('socid'); |
||
317 | $ref = GETPOST('ref', 'alpha'); |
||
318 | |||
319 | if (isModEnabled('mailmanspip')) { |
||
320 | include_once DOL_DOCUMENT_ROOT . '/mailmanspip/class/mailmanspip.class.php'; |
||
321 | |||
322 | $langs->load('mailmanspip'); |
||
323 | |||
324 | $mailmanspip = new MailmanSpip($db); |
||
325 | } |
||
326 | |||
327 | $object = new Adherent($db); |
||
328 | $extrafields = new ExtraFields($db); |
||
329 | |||
330 | // fetch optionals attributes and labels |
||
331 | $extrafields->fetch_name_optionals_label($object->table_element); |
||
332 | |||
333 | $socialnetworks = getArrayOfSocialNetworks(); |
||
334 | |||
335 | // Get object canvas (By default, this is not defined, so standard usage of dolibarr) |
||
336 | $object->getCanvas($id); |
||
337 | $canvas = $object->canvas ? $object->canvas : GETPOST("canvas"); |
||
338 | $objcanvas = null; |
||
339 | if (!empty($canvas)) { |
||
340 | require_once DOL_DOCUMENT_ROOT . '/core/class/canvas.class.php'; |
||
341 | $objcanvas = new Canvas($db, $action); |
||
342 | $objcanvas->getCanvas('adherent', 'membercard', $canvas); |
||
343 | } |
||
344 | |||
345 | // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context |
||
346 | $hookmanager->initHooks(array('membercard', 'globalcard')); |
||
347 | |||
348 | // Fetch object |
||
349 | if ($id > 0 || !empty($ref)) { |
||
350 | // Load member |
||
351 | $result = $object->fetch($id, $ref); |
||
352 | |||
353 | // Define variables to know what current user can do on users |
||
354 | $canadduser = ($user->admin || $user->hasRight('user', 'user', 'creer')); |
||
355 | // Define variables to know what current user can do on properties of user linked to edited member |
||
356 | if ($object->user_id) { |
||
357 | // $User is the user who edits, $object->user_id is the id of the related user in the edited member |
||
358 | $caneditfielduser = ((($user->id == $object->user_id) && $user->hasRight('user', 'self', 'creer')) |
||
359 | || (($user->id != $object->user_id) && $user->hasRight('user', 'user', 'creer'))); |
||
360 | $caneditpassworduser = ((($user->id == $object->user_id) && $user->hasRight('user', 'self', 'password')) |
||
361 | || (($user->id != $object->user_id) && $user->hasRight('user', 'user', 'password'))); |
||
362 | } |
||
363 | } |
||
364 | |||
365 | // Define variables to determine what the current user can do on the members |
||
366 | $canaddmember = $user->hasRight('adherent', 'creer'); |
||
367 | // Define variables to determine what the current user can do on the properties of a member |
||
368 | if ($id) { |
||
369 | $caneditfieldmember = $user->hasRight('adherent', 'creer'); |
||
370 | } |
||
371 | |||
372 | // Security check |
||
373 | $result = restrictedArea($user, 'adherent', $object->id, '', '', 'socid', 'rowid', 0); |
||
374 | |||
375 | if (!$user->hasRight('adherent', 'creer') && $action == 'edit') { |
||
376 | accessforbidden('Not enough permission'); |
||
377 | } |
||
378 | |||
379 | $linkofpubliclist = DOL_MAIN_URL_ROOT . '/public/members/public_list.php' . ((isModEnabled('multicompany')) ? '?entity=' . $conf->entity : ''); |
||
380 | |||
381 | |||
382 | /* |
||
383 | * Actions |
||
384 | */ |
||
385 | |||
386 | $parameters = array('id' => $id, 'rowid' => $id, 'objcanvas' => $objcanvas, 'confirm' => $confirm); |
||
387 | $reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks |
||
388 | if ($reshook < 0) { |
||
389 | setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); |
||
390 | } |
||
391 | |||
392 | if (empty($reshook)) { |
||
393 | $backurlforlist = '/adherents/list.php'; |
||
394 | |||
395 | if (empty($backtopage) || ($cancel && empty($id))) { |
||
396 | if (empty($backtopage) || ($cancel && strpos($backtopage, '__ID__'))) { |
||
397 | if (empty($id) && (($action != 'add' && $action != 'create') || $cancel)) { |
||
398 | $backtopage = $backurlforlist; |
||
399 | } else { |
||
400 | $backtopage = '/adherents/card.php?id=' . ((!empty($id) && $id > 0) ? $id : '__ID__'); |
||
401 | } |
||
402 | } |
||
403 | } |
||
404 | |||
405 | if ($cancel) { |
||
406 | if (!empty($backtopageforcancel)) { |
||
407 | header("Location: " . $backtopageforcancel); |
||
408 | exit; |
||
409 | } elseif (!empty($backtopage)) { |
||
410 | header("Location: " . $backtopage); |
||
411 | exit; |
||
412 | } |
||
413 | $action = ''; |
||
414 | } |
||
415 | |||
416 | if ($action == 'setuserid' && ($user->hasRight('user', 'self', 'creer') || $user->hasRight('user', 'user', 'creer'))) { |
||
417 | $error = 0; |
||
418 | if (!$user->hasRight('user', 'user', 'creer')) { // If can edit only itself user, we can link to itself only |
||
419 | if ($userid != $user->id && $userid != $object->user_id) { |
||
420 | $error++; |
||
421 | setEventMessages($langs->trans("ErrorUserPermissionAllowsToLinksToItselfOnly"), null, 'errors'); |
||
422 | } |
||
423 | } |
||
424 | |||
425 | if (!$error) { |
||
426 | if ($userid != $object->user_id) { // If link differs from currently in database |
||
427 | $result = $object->setUserId($userid); |
||
428 | if ($result < 0) { |
||
429 | dol_print_error($object->db, $object->error); |
||
430 | } |
||
431 | $action = ''; |
||
432 | } |
||
433 | } |
||
434 | } |
||
435 | |||
436 | if ($action == 'setsocid') { |
||
437 | $error = 0; |
||
438 | if (!$error) { |
||
439 | if ($socid != $object->socid) { // If link differs from currently in database |
||
440 | $sql = "SELECT rowid FROM " . MAIN_DB_PREFIX . "adherent"; |
||
441 | $sql .= " WHERE socid = " . ((int) $socid); |
||
442 | $sql .= " AND entity = " . $conf->entity; |
||
443 | $resql = $db->query($sql); |
||
444 | if ($resql) { |
||
445 | $obj = $db->fetch_object($resql); |
||
446 | if ($obj && $obj->rowid > 0) { |
||
447 | $othermember = new Adherent($db); |
||
448 | $othermember->fetch($obj->rowid); |
||
449 | $thirdparty = new Societe($db); |
||
450 | $thirdparty->fetch($socid); |
||
451 | $error++; |
||
452 | setEventMessages($langs->trans("ErrorMemberIsAlreadyLinkedToThisThirdParty", $othermember->getFullName($langs), $othermember->login, $thirdparty->name), null, 'errors'); |
||
453 | } |
||
454 | } |
||
455 | |||
456 | if (!$error) { |
||
457 | $result = $object->setThirdPartyId($socid); |
||
458 | if ($result < 0) { |
||
459 | dol_print_error($object->db, $object->error); |
||
460 | } |
||
461 | $action = ''; |
||
462 | } |
||
463 | } |
||
464 | } |
||
465 | } |
||
466 | |||
467 | // Create user from a member |
||
468 | if ($action == 'confirm_create_user' && $confirm == 'yes' && $user->hasRight('user', 'user', 'creer')) { |
||
469 | if ($result > 0) { |
||
470 | // Creation user |
||
471 | $nuser = new User($db); |
||
472 | $tmpuser = dol_clone($object); |
||
473 | if (GETPOST('internalorexternal', 'aZ09') == 'internal') { |
||
474 | $tmpuser->fk_soc = 0; |
||
475 | } |
||
476 | |||
477 | $result = $nuser->create_from_member($tmpuser, GETPOST('login', 'alphanohtml')); |
||
478 | |||
479 | if ($result < 0) { |
||
480 | $langs->load("errors"); |
||
481 | setEventMessages($langs->trans($nuser->error), null, 'errors'); |
||
482 | } else { |
||
483 | setEventMessages($langs->trans("NewUserCreated", $nuser->login), null, 'mesgs'); |
||
484 | $action = ''; |
||
485 | } |
||
486 | } else { |
||
487 | setEventMessages($object->error, $object->errors, 'errors'); |
||
488 | } |
||
489 | } |
||
490 | |||
491 | // Create third party from a member |
||
492 | if ($action == 'confirm_create_thirdparty' && $confirm == 'yes' && $user->hasRight('societe', 'creer')) { |
||
493 | if ($result > 0) { |
||
494 | // User creation |
||
495 | $company = new Societe($db); |
||
496 | $result = $company->create_from_member($object, GETPOST('companyname', 'alpha'), GETPOST('companyalias', 'alpha')); |
||
497 | |||
498 | if ($result < 0) { |
||
499 | $langs->load("errors"); |
||
500 | setEventMessages($langs->trans($company->error), null, 'errors'); |
||
501 | setEventMessages($company->error, $company->errors, 'errors'); |
||
502 | } |
||
503 | } else { |
||
504 | setEventMessages($object->error, $object->errors, 'errors'); |
||
505 | } |
||
506 | } |
||
507 | |||
508 | if ($action == 'update' && !$cancel && $user->hasRight('adherent', 'creer')) { |
||
509 | require_once DOL_DOCUMENT_ROOT . '/core/lib/files.lib.php'; |
||
510 | |||
511 | $birthdate = ''; |
||
512 | if (GETPOSTINT("birthday") && GETPOSTINT("birthmonth") && GETPOSTINT("birthyear")) { |
||
513 | $birthdate = dol_mktime(12, 0, 0, GETPOSTINT("birthmonth"), GETPOSTINT("birthday"), GETPOSTINT("birthyear")); |
||
514 | } |
||
515 | $lastname = GETPOST("lastname", 'alphanohtml'); |
||
516 | $firstname = GETPOST("firstname", 'alphanohtml'); |
||
517 | $gender = GETPOST("gender", 'alphanohtml'); |
||
518 | $societe = GETPOST("societe", 'alphanohtml'); |
||
519 | $morphy = GETPOST("morphy", 'alphanohtml'); |
||
520 | $login = GETPOST("login", 'alphanohtml'); |
||
521 | if ($morphy != 'mor' && empty($lastname)) { |
||
522 | $error++; |
||
523 | $langs->load("errors"); |
||
524 | setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("Lastname")), null, 'errors'); |
||
525 | } |
||
526 | if ($morphy != 'mor' && (!isset($firstname) || $firstname == '')) { |
||
527 | $error++; |
||
528 | $langs->load("errors"); |
||
529 | setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("Firstname")), null, 'errors'); |
||
530 | } |
||
531 | if ($morphy == 'mor' && empty($societe)) { |
||
532 | $error++; |
||
533 | $langs->load("errors"); |
||
534 | setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("Company")), null, 'errors'); |
||
535 | } |
||
536 | // Check if the login already exists |
||
537 | if (!getDolGlobalString('ADHERENT_LOGIN_NOT_REQUIRED')) { |
||
538 | if (empty($login)) { |
||
539 | $error++; |
||
540 | setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Login")), null, 'errors'); |
||
541 | } |
||
542 | } |
||
543 | // Create new object |
||
544 | if ($result > 0 && !$error) { |
||
545 | $object->oldcopy = dol_clone($object, 2); |
||
546 | |||
547 | // Change values |
||
548 | $object->civility_id = trim(GETPOST("civility_id", 'alphanohtml')); |
||
549 | $object->firstname = trim(GETPOST("firstname", 'alphanohtml')); |
||
550 | $object->lastname = trim(GETPOST("lastname", 'alphanohtml')); |
||
551 | $object->gender = trim(GETPOST("gender", 'alphanohtml')); |
||
552 | $object->login = trim(GETPOST("login", 'alphanohtml')); |
||
553 | if (GETPOSTISSET('pass')) { |
||
554 | $object->pass = trim(GETPOST("pass", 'none')); // For password, we must use 'none' |
||
555 | } |
||
556 | |||
557 | $object->societe = trim(GETPOST("societe", 'alphanohtml')); // deprecated |
||
558 | $object->company = trim(GETPOST("societe", 'alphanohtml')); |
||
559 | |||
560 | $object->address = trim(GETPOST("address", 'alphanohtml')); |
||
561 | $object->zip = trim(GETPOST("zipcode", 'alphanohtml')); |
||
562 | $object->town = trim(GETPOST("town", 'alphanohtml')); |
||
563 | $object->state_id = GETPOSTINT("state_id"); |
||
564 | $object->country_id = GETPOSTINT("country_id"); |
||
565 | |||
566 | $object->phone = trim(GETPOST("phone", 'alpha')); |
||
567 | $object->phone_perso = trim(GETPOST("phone_perso", 'alpha')); |
||
568 | $object->phone_mobile = trim(GETPOST("phone_mobile", 'alpha')); |
||
569 | $object->email = preg_replace('/\s+/', '', GETPOST("member_email", 'alpha')); |
||
570 | $object->url = trim(GETPOST('member_url', 'custom', 0, FILTER_SANITIZE_URL)); |
||
571 | $object->socialnetworks = array(); |
||
572 | foreach ($socialnetworks as $key => $value) { |
||
573 | if (GETPOSTISSET($key) && GETPOST($key, 'alphanohtml') != '') { |
||
574 | $object->socialnetworks[$key] = trim(GETPOST($key, 'alphanohtml')); |
||
575 | } |
||
576 | } |
||
577 | $object->birth = $birthdate; |
||
578 | $object->default_lang = GETPOST('default_lang', 'alpha'); |
||
579 | $object->typeid = GETPOSTINT("typeid"); |
||
580 | //$object->note = trim(GETPOST("comment", "restricthtml")); |
||
581 | $object->morphy = GETPOST("morphy", 'alpha'); |
||
582 | |||
583 | if (GETPOST('deletephoto', 'alpha')) { |
||
584 | $object->photo = ''; |
||
585 | } elseif (!empty($_FILES['photo']['name'])) { |
||
586 | $object->photo = dol_sanitizeFileName($_FILES['photo']['name']); |
||
587 | } |
||
588 | |||
589 | // Get status and public property |
||
590 | $object->statut = GETPOSTINT("statut"); |
||
591 | $object->status = GETPOSTINT("statut"); |
||
592 | $object->public = GETPOSTINT("public"); |
||
593 | |||
594 | // Fill array 'array_options' with data from add form |
||
595 | $ret = $extrafields->setOptionalsFromPost(null, $object, '@GETPOSTISSET'); |
||
596 | if ($ret < 0) { |
||
597 | $error++; |
||
598 | } |
||
599 | |||
600 | // Check if we need to also synchronize user information |
||
601 | $nosyncuser = 0; |
||
602 | if ($object->user_id) { // If linked to a user |
||
603 | if ($user->id != $object->user_id && !$user->hasRight('user', 'user', 'creer')) { |
||
604 | $nosyncuser = 1; // Disable synchronizing |
||
605 | } |
||
606 | } |
||
607 | |||
608 | // Check if we need to also synchronize password information |
||
609 | $nosyncuserpass = 1; // no by default |
||
610 | if (GETPOSTISSET('pass')) { |
||
611 | if ($object->user_id) { // If member is linked to a user |
||
612 | $nosyncuserpass = 0; // We may try to sync password |
||
613 | if ($user->id == $object->user_id) { |
||
614 | if (!$user->hasRight('user', 'self', 'password')) { |
||
615 | $nosyncuserpass = 1; // Disable synchronizing |
||
616 | } |
||
617 | } else { |
||
618 | if (!$user->hasRight('user', 'user', 'password')) { |
||
619 | $nosyncuserpass = 1; // Disable synchronizing |
||
620 | } |
||
621 | } |
||
622 | } |
||
623 | } |
||
624 | |||
625 | if (!$error) { |
||
626 | $result = $object->update($user, 0, $nosyncuser, $nosyncuserpass); |
||
627 | |||
628 | if ($result >= 0 && !count($object->errors)) { |
||
629 | $categories = GETPOST('memcats', 'array'); |
||
630 | $object->setCategories($categories); |
||
631 | |||
632 | // Logo/Photo save |
||
633 | $dir = $conf->adherent->dir_output . '/' . get_exdir(0, 0, 0, 1, $object, 'member') . '/photos'; |
||
634 | $file_OK = is_uploaded_file($_FILES['photo']['tmp_name']); |
||
635 | if ($file_OK) { |
||
636 | if (GETPOST('deletephoto')) { |
||
637 | require_once DOL_DOCUMENT_ROOT . '/core/lib/files.lib.php'; |
||
638 | $fileimg = $conf->adherent->dir_output . '/' . get_exdir(0, 0, 0, 1, $object, 'member') . '/photos/' . $object->photo; |
||
639 | $dirthumbs = $conf->adherent->dir_output . '/' . get_exdir(0, 0, 0, 1, $object, 'member') . '/photos/thumbs'; |
||
640 | dol_delete_file($fileimg); |
||
641 | dol_delete_dir_recursive($dirthumbs); |
||
642 | } |
||
643 | |||
644 | if (image_format_supported($_FILES['photo']['name']) > 0) { |
||
645 | dol_mkdir($dir); |
||
646 | |||
647 | if (@is_dir($dir)) { |
||
648 | $newfile = $dir . '/' . dol_sanitizeFileName($_FILES['photo']['name']); |
||
649 | if (!dol_move_uploaded_file($_FILES['photo']['tmp_name'], $newfile, 1, 0, $_FILES['photo']['error']) > 0) { |
||
650 | setEventMessages($langs->trans("ErrorFailedToSaveFile"), null, 'errors'); |
||
651 | } else { |
||
652 | // Create thumbs |
||
653 | $object->addThumbs($newfile); |
||
654 | } |
||
655 | } |
||
656 | } else { |
||
657 | setEventMessages("ErrorBadImageFormat", null, 'errors'); |
||
658 | } |
||
659 | } else { |
||
660 | switch ($_FILES['photo']['error']) { |
||
661 | case 1: //uploaded file exceeds the upload_max_filesize directive in php.ini |
||
662 | case 2: //uploaded file exceeds the MAX_FILE_SIZE directive that was specified in the html form |
||
663 | $errors[] = "ErrorFileSizeTooLarge"; |
||
664 | break; |
||
665 | case 3: //uploaded file was only partially uploaded |
||
666 | $errors[] = "ErrorFilePartiallyUploaded"; |
||
667 | break; |
||
668 | } |
||
669 | } |
||
670 | |||
671 | $rowid = $object->id; |
||
672 | $id = $object->id; |
||
673 | $action = ''; |
||
674 | |||
675 | if (!empty($backtopage)) { |
||
676 | header("Location: " . $backtopage); |
||
677 | exit; |
||
678 | } |
||
679 | } else { |
||
680 | setEventMessages($object->error, $object->errors, 'errors'); |
||
681 | $action = ''; |
||
682 | } |
||
683 | } else { |
||
684 | $action = 'edit'; |
||
685 | } |
||
686 | } else { |
||
687 | $action = 'edit'; |
||
688 | } |
||
689 | } |
||
690 | |||
691 | if ($action == 'add' && $user->hasRight('adherent', 'creer')) { |
||
692 | if ($canvas) { |
||
693 | $object->canvas = $canvas; |
||
694 | } |
||
695 | $birthdate = ''; |
||
696 | if (GETPOSTISSET("birthday") && GETPOST("birthday") && GETPOSTISSET("birthmonth") && GETPOST("birthmonth") && GETPOSTISSET("birthyear") && GETPOST("birthyear")) { |
||
697 | $birthdate = dol_mktime(12, 0, 0, GETPOSTINT("birthmonth"), GETPOSTINT("birthday"), GETPOSTINT("birthyear")); |
||
698 | } |
||
699 | $datesubscription = ''; |
||
700 | if (GETPOSTISSET("reday") && GETPOSTISSET("remonth") && GETPOSTISSET("reyear")) { |
||
701 | $datesubscription = dol_mktime(12, 0, 0, GETPOSTINT("remonth"), GETPOSTINT("reday"), GETPOSTINT("reyear")); |
||
702 | } |
||
703 | |||
704 | $typeid = GETPOSTINT("typeid"); |
||
705 | $civility_id = GETPOST("civility_id", 'alphanohtml'); |
||
706 | $lastname = GETPOST("lastname", 'alphanohtml'); |
||
707 | $firstname = GETPOST("firstname", 'alphanohtml'); |
||
708 | $gender = GETPOST("gender", 'alphanohtml'); |
||
709 | $societe = GETPOST("societe", 'alphanohtml'); |
||
710 | $address = GETPOST("address", 'alphanohtml'); |
||
711 | $zip = GETPOST("zipcode", 'alphanohtml'); |
||
712 | $town = GETPOST("town", 'alphanohtml'); |
||
713 | $state_id = GETPOSTINT("state_id"); |
||
714 | $country_id = GETPOSTINT("country_id"); |
||
715 | |||
716 | $phone = GETPOST("phone", 'alpha'); |
||
717 | $phone_perso = GETPOST("phone_perso", 'alpha'); |
||
718 | $phone_mobile = GETPOST("phone_mobile", 'alpha'); |
||
719 | $email = preg_replace('/\s+/', '', GETPOST("member_email", 'alpha')); |
||
720 | $url = trim(GETPOST('url', 'custom', 0, FILTER_SANITIZE_URL)); |
||
721 | $login = GETPOST("member_login", 'alphanohtml'); |
||
722 | $pass = GETPOST("password", 'none'); // For password, we use 'none' |
||
723 | $photo = GETPOST("photo", 'alphanohtml'); |
||
724 | $morphy = GETPOST("morphy", 'alphanohtml'); |
||
725 | $public = GETPOST("public", 'alphanohtml'); |
||
726 | |||
727 | $userid = GETPOSTINT("userid"); |
||
728 | $socid = GETPOSTINT("socid"); |
||
729 | $default_lang = GETPOST('default_lang', 'alpha'); |
||
730 | |||
731 | $object->civility_id = $civility_id; |
||
732 | $object->firstname = $firstname; |
||
733 | $object->lastname = $lastname; |
||
734 | $object->gender = $gender; |
||
735 | $object->societe = $societe; // deprecated |
||
736 | $object->company = $societe; |
||
737 | $object->address = $address; |
||
738 | $object->zip = $zip; |
||
739 | $object->town = $town; |
||
740 | $object->state_id = $state_id; |
||
741 | $object->country_id = $country_id; |
||
742 | $object->phone = $phone; |
||
743 | $object->phone_perso = $phone_perso; |
||
744 | $object->phone_mobile = $phone_mobile; |
||
745 | $object->socialnetworks = array(); |
||
746 | if (isModEnabled('socialnetworks')) { |
||
747 | foreach ($socialnetworks as $key => $value) { |
||
748 | if (GETPOSTISSET($key) && GETPOST($key, 'alphanohtml') != '') { |
||
749 | $object->socialnetworks[$key] = GETPOST("member_" . $key, 'alphanohtml'); |
||
750 | } |
||
751 | } |
||
752 | } |
||
753 | |||
754 | $object->email = $email; |
||
755 | $object->url = $url; |
||
756 | $object->login = $login; |
||
757 | $object->pass = $pass; |
||
758 | $object->birth = $birthdate; |
||
759 | $object->photo = $photo; |
||
760 | $object->typeid = $typeid; |
||
761 | //$object->note = $comment; |
||
762 | $object->morphy = $morphy; |
||
763 | $object->user_id = $userid; |
||
764 | $object->socid = $socid; |
||
765 | $object->public = $public; |
||
766 | $object->default_lang = $default_lang; |
||
767 | // Fill array 'array_options' with data from add form |
||
768 | $ret = $extrafields->setOptionalsFromPost(null, $object); |
||
769 | if ($ret < 0) { |
||
770 | $error++; |
||
771 | } |
||
772 | |||
773 | // Check parameters |
||
774 | if (empty($morphy) || $morphy == "-1") { |
||
775 | $error++; |
||
776 | setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("MemberNature")), null, 'errors'); |
||
777 | } |
||
778 | // Tests if the login already exists |
||
779 | if (!getDolGlobalString('ADHERENT_LOGIN_NOT_REQUIRED')) { |
||
780 | if (empty($login)) { |
||
781 | $error++; |
||
782 | setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Login")), null, 'errors'); |
||
783 | } else { |
||
784 | $sql = "SELECT login FROM " . MAIN_DB_PREFIX . "adherent WHERE login='" . $db->escape($login) . "'"; |
||
785 | $result = $db->query($sql); |
||
786 | if ($result) { |
||
787 | $num = $db->num_rows($result); |
||
788 | } |
||
789 | if ($num) { |
||
790 | $error++; |
||
791 | $langs->load("errors"); |
||
792 | setEventMessages($langs->trans("ErrorLoginAlreadyExists", $login), null, 'errors'); |
||
793 | } |
||
794 | } |
||
795 | if (empty($pass)) { |
||
796 | $error++; |
||
797 | setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("Password")), null, 'errors'); |
||
798 | } |
||
799 | } |
||
800 | if ($morphy == 'mor' && empty($societe)) { |
||
801 | $error++; |
||
802 | $langs->load("errors"); |
||
803 | setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("Company")), null, 'errors'); |
||
804 | } |
||
805 | if ($morphy != 'mor' && empty($lastname)) { |
||
806 | $error++; |
||
807 | $langs->load("errors"); |
||
808 | setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("Lastname")), null, 'errors'); |
||
809 | } |
||
810 | if ($morphy != 'mor' && (!isset($firstname) || $firstname == '')) { |
||
811 | $error++; |
||
812 | $langs->load("errors"); |
||
813 | setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("Firstname")), null, 'errors'); |
||
814 | } |
||
815 | if (!($typeid > 0)) { // Keep () before ! |
||
816 | $error++; |
||
817 | setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Type")), null, 'errors'); |
||
818 | } |
||
819 | if (getDolGlobalString('ADHERENT_MAIL_REQUIRED') && !isValidEmail($email)) { |
||
820 | $error++; |
||
821 | $langs->load("errors"); |
||
822 | setEventMessages($langs->trans("ErrorBadEMail", $email), null, 'errors'); |
||
823 | } |
||
824 | if (!empty($object->url) && !isValidUrl($object->url)) { |
||
825 | $langs->load("errors"); |
||
826 | setEventMessages($langs->trans("ErrorBadUrl", $object->url), null, 'errors'); |
||
827 | } |
||
828 | $public = 0; |
||
829 | if (isset($public)) { |
||
830 | $public = 1; |
||
831 | } |
||
832 | |||
833 | if (!$error) { |
||
834 | $db->begin(); |
||
835 | |||
836 | // Create the member |
||
837 | $result = $object->create($user); |
||
838 | if ($result > 0) { |
||
839 | // Foundation categories |
||
840 | $memcats = GETPOST('memcats', 'array'); |
||
841 | $object->setCategories($memcats); |
||
842 | |||
843 | $db->commit(); |
||
844 | |||
845 | $rowid = $object->id; |
||
846 | $id = $object->id; |
||
847 | |||
848 | $backtopage = preg_replace('/__ID__/', $id, $backtopage); |
||
849 | } else { |
||
850 | $db->rollback(); |
||
851 | |||
852 | $error++; |
||
853 | setEventMessages($object->error, $object->errors, 'errors'); |
||
854 | } |
||
855 | |||
856 | // Auto-create thirdparty on member creation |
||
857 | if (getDolGlobalString('ADHERENT_DEFAULT_CREATE_THIRDPARTY')) { |
||
858 | if ($result > 0) { |
||
859 | // Create third party out of a member |
||
860 | $company = new Societe($db); |
||
861 | $result = $company->create_from_member($object); |
||
862 | if ($result < 0) { |
||
863 | $langs->load("errors"); |
||
864 | setEventMessages($langs->trans($company->error), null, 'errors'); |
||
865 | setEventMessages($company->error, $company->errors, 'errors'); |
||
866 | } |
||
867 | } else { |
||
868 | setEventMessages($object->error, $object->errors, 'errors'); |
||
869 | } |
||
870 | } |
||
871 | } |
||
872 | $action = ($result < 0 || !$error) ? '' : 'create'; |
||
873 | |||
874 | if (!$error && $backtopage) { |
||
875 | header("Location: " . $backtopage); |
||
876 | exit; |
||
877 | } |
||
878 | } |
||
879 | |||
880 | if ($user->hasRight('adherent', 'supprimer') && $action == 'confirm_delete' && $confirm == 'yes') { |
||
881 | $result = $object->delete($user); |
||
882 | if ($result > 0) { |
||
883 | setEventMessages($langs->trans("RecordDeleted"), null, 'errors'); |
||
884 | if (!empty($backtopage) && !preg_match('/' . preg_quote($_SERVER['PHP_SELF'], '/') . '/', $backtopage)) { |
||
885 | header("Location: " . $backtopage); |
||
886 | exit; |
||
887 | } else { |
||
888 | header("Location: list.php"); |
||
889 | exit; |
||
890 | } |
||
891 | } else { |
||
892 | setEventMessages($object->error, null, 'errors'); |
||
893 | } |
||
894 | } |
||
895 | |||
896 | if ($user->hasRight('adherent', 'creer') && $action == 'confirm_valid' && $confirm == 'yes') { |
||
897 | $error = 0; |
||
898 | |||
899 | $db->begin(); |
||
900 | |||
901 | $adht = new AdherentType($db); |
||
902 | $adht->fetch($object->typeid); |
||
903 | |||
904 | $result = $object->validate($user); |
||
905 | |||
906 | if ($result >= 0 && !count($object->errors)) { |
||
907 | // Send confirmation email (according to parameters of member type. Otherwise generic) |
||
908 | if ($object->email && GETPOST("send_mail")) { |
||
909 | $subject = ''; |
||
910 | $msg = ''; |
||
911 | |||
912 | // Send subscription email |
||
913 | include_once DOL_DOCUMENT_ROOT . '/core/class/html.formmail.class.php'; |
||
914 | $formmail = new FormMail($db); |
||
915 | // Set output language |
||
916 | $outputlangs = new Translate('', $conf); |
||
917 | $outputlangs->setDefaultLang(empty($object->thirdparty->default_lang) ? $mysoc->default_lang : $object->thirdparty->default_lang); |
||
918 | // Load traductions files required by page |
||
919 | $outputlangs->loadLangs(array("main", "members", "companies", "install", "other")); |
||
920 | // Get email content from template |
||
921 | $arraydefaultmessage = null; |
||
922 | $labeltouse = getDolGlobalString('ADHERENT_EMAIL_TEMPLATE_MEMBER_VALIDATION'); |
||
923 | |||
924 | if (!empty($labeltouse)) { |
||
925 | $arraydefaultmessage = $formmail->getEMailTemplate($db, 'member', $user, $outputlangs, 0, 1, $labeltouse); |
||
926 | } |
||
927 | |||
928 | if (!empty($labeltouse) && is_object($arraydefaultmessage) && $arraydefaultmessage->id > 0) { |
||
929 | $subject = $arraydefaultmessage->topic; |
||
930 | $msg = $arraydefaultmessage->content; |
||
931 | } |
||
932 | |||
933 | if (empty($labeltouse) || (int) $labeltouse === -1) { |
||
934 | //fallback on the old configuration. |
||
935 | $langs->load("errors"); |
||
936 | setEventMessages('<a href="' . DOL_URL_ROOT . '/adherents/admin/member_emails.php">' . $langs->trans('WarningMandatorySetupNotComplete') . '</a>', null, 'errors'); |
||
937 | $error++; |
||
938 | } else { |
||
939 | $substitutionarray = getCommonSubstitutionArray($outputlangs, 0, null, $object); |
||
940 | complete_substitutions_array($substitutionarray, $outputlangs, $object); |
||
941 | $subjecttosend = make_substitutions($subject, $substitutionarray, $outputlangs); |
||
942 | $texttosend = make_substitutions(dol_concatdesc($msg, $adht->getMailOnValid()), $substitutionarray, $outputlangs); |
||
943 | |||
944 | $moreinheader = 'X-Dolibarr-Info: send_an_email by adherents/card.php' . "\r\n"; |
||
945 | |||
946 | $result = $object->sendEmail($texttosend, $subjecttosend, array(), array(), array(), "", "", 0, -1, '', $moreinheader); |
||
947 | if ($result < 0) { |
||
948 | $error++; |
||
949 | setEventMessages($object->error, $object->errors, 'errors'); |
||
950 | } |
||
951 | } |
||
952 | } |
||
953 | } else { |
||
954 | $error++; |
||
955 | setEventMessages($object->error, $object->errors, 'errors'); |
||
956 | } |
||
957 | |||
958 | if (!$error) { |
||
959 | $db->commit(); |
||
960 | } else { |
||
961 | $db->rollback(); |
||
962 | } |
||
963 | $action = ''; |
||
964 | } |
||
965 | |||
966 | if ($user->hasRight('adherent', 'supprimer') && $action == 'confirm_resiliate') { |
||
967 | $error = 0; |
||
968 | |||
969 | if ($confirm == 'yes') { |
||
970 | $adht = new AdherentType($db); |
||
971 | $adht->fetch($object->typeid); |
||
972 | |||
973 | $result = $object->resiliate($user); |
||
974 | |||
975 | if ($result >= 0 && !count($object->errors)) { |
||
976 | if ($object->email && GETPOST("send_mail")) { |
||
977 | $subject = ''; |
||
978 | $msg = ''; |
||
979 | |||
980 | // Send subscription email |
||
981 | include_once DOL_DOCUMENT_ROOT . '/core/class/html.formmail.class.php'; |
||
982 | $formmail = new FormMail($db); |
||
983 | // Set output language |
||
984 | $outputlangs = new Translate('', $conf); |
||
985 | $outputlangs->setDefaultLang(empty($object->thirdparty->default_lang) ? $mysoc->default_lang : $object->thirdparty->default_lang); |
||
986 | // Load traductions files required by page |
||
987 | $outputlangs->loadLangs(array("main", "members", "companies", "install", "other")); |
||
988 | // Get email content from template |
||
989 | $arraydefaultmessage = null; |
||
990 | $labeltouse = getDolGlobalString('ADHERENT_EMAIL_TEMPLATE_CANCELATION'); |
||
991 | |||
992 | if (!empty($labeltouse)) { |
||
993 | $arraydefaultmessage = $formmail->getEMailTemplate($db, 'member', $user, $outputlangs, 0, 1, $labeltouse); |
||
994 | } |
||
995 | |||
996 | if (!empty($labeltouse) && is_object($arraydefaultmessage) && $arraydefaultmessage->id > 0) { |
||
997 | $subject = $arraydefaultmessage->topic; |
||
998 | $msg = $arraydefaultmessage->content; |
||
999 | } |
||
1000 | |||
1001 | if (empty($labeltouse) || (int) $labeltouse === -1) { |
||
1002 | //fallback on the old configuration. |
||
1003 | setEventMessages('WarningMandatorySetupNotComplete', null, 'errors'); |
||
1004 | $error++; |
||
1005 | } else { |
||
1006 | $substitutionarray = getCommonSubstitutionArray($outputlangs, 0, null, $object); |
||
1007 | complete_substitutions_array($substitutionarray, $outputlangs, $object); |
||
1008 | $subjecttosend = make_substitutions($subject, $substitutionarray, $outputlangs); |
||
1009 | $texttosend = make_substitutions(dol_concatdesc($msg, $adht->getMailOnResiliate()), $substitutionarray, $outputlangs); |
||
1010 | |||
1011 | $moreinheader = 'X-Dolibarr-Info: send_an_email by adherents/card.php' . "\r\n"; |
||
1012 | |||
1013 | $result = $object->sendEmail($texttosend, $subjecttosend, array(), array(), array(), "", "", 0, -1, '', $moreinheader); |
||
1014 | if ($result < 0) { |
||
1015 | $error++; |
||
1016 | setEventMessages($object->error, $object->errors, 'errors'); |
||
1017 | } |
||
1018 | } |
||
1019 | } |
||
1020 | } else { |
||
1021 | $error++; |
||
1022 | |||
1023 | setEventMessages($object->error, $object->errors, 'errors'); |
||
1024 | $action = ''; |
||
1025 | } |
||
1026 | } |
||
1027 | if (!empty($backtopage) && !$error) { |
||
1028 | header("Location: " . $backtopage); |
||
1029 | exit; |
||
1030 | } |
||
1031 | } |
||
1032 | |||
1033 | if ($user->hasRight('adherent', 'supprimer') && $action == 'confirm_exclude') { |
||
1034 | $error = 0; |
||
1035 | |||
1036 | if ($confirm == 'yes') { |
||
1037 | $adht = new AdherentType($db); |
||
1038 | $adht->fetch($object->typeid); |
||
1039 | |||
1040 | $result = $object->exclude($user); |
||
1041 | |||
1042 | if ($result >= 0 && !count($object->errors)) { |
||
1043 | if ($object->email && GETPOST("send_mail")) { |
||
1044 | $subject = ''; |
||
1045 | $msg = ''; |
||
1046 | |||
1047 | // Send subscription email |
||
1048 | include_once DOL_DOCUMENT_ROOT . '/core/class/html.formmail.class.php'; |
||
1049 | $formmail = new FormMail($db); |
||
1050 | // Set output language |
||
1051 | $outputlangs = new Translate('', $conf); |
||
1052 | $outputlangs->setDefaultLang(empty($object->thirdparty->default_lang) ? $mysoc->default_lang : $object->thirdparty->default_lang); |
||
1053 | // Load traductions files required by page |
||
1054 | $outputlangs->loadLangs(array("main", "members", "companies", "install", "other")); |
||
1055 | // Get email content from template |
||
1056 | $arraydefaultmessage = null; |
||
1057 | $labeltouse = getDolGlobalString('ADHERENT_EMAIL_TEMPLATE_EXCLUSION'); |
||
1058 | |||
1059 | if (!empty($labeltouse)) { |
||
1060 | $arraydefaultmessage = $formmail->getEMailTemplate($db, 'member', $user, $outputlangs, 0, 1, $labeltouse); |
||
1061 | } |
||
1062 | |||
1063 | if (!empty($labeltouse) && is_object($arraydefaultmessage) && $arraydefaultmessage->id > 0) { |
||
1064 | $subject = $arraydefaultmessage->topic; |
||
1065 | $msg = $arraydefaultmessage->content; |
||
1066 | } |
||
1067 | |||
1068 | if (empty($labeltouse) || (int) $labeltouse === -1) { |
||
1069 | //fallback on the old configuration. |
||
1070 | setEventMessages('WarningMandatorySetupNotComplete', null, 'errors'); |
||
1071 | $error++; |
||
1072 | } else { |
||
1073 | $substitutionarray = getCommonSubstitutionArray($outputlangs, 0, null, $object); |
||
1074 | complete_substitutions_array($substitutionarray, $outputlangs, $object); |
||
1075 | $subjecttosend = make_substitutions($subject, $substitutionarray, $outputlangs); |
||
1076 | $texttosend = make_substitutions(dol_concatdesc($msg, $adht->getMailOnExclude()), $substitutionarray, $outputlangs); |
||
1077 | |||
1078 | $moreinheader = 'X-Dolibarr-Info: send_an_email by adherents/card.php' . "\r\n"; |
||
1079 | |||
1080 | $result = $object->sendEmail($texttosend, $subjecttosend, array(), array(), array(), "", "", 0, -1, '', $moreinheader); |
||
1081 | if ($result < 0) { |
||
1082 | $error++; |
||
1083 | setEventMessages($object->error, $object->errors, 'errors'); |
||
1084 | } |
||
1085 | } |
||
1086 | } |
||
1087 | } else { |
||
1088 | $error++; |
||
1089 | |||
1090 | setEventMessages($object->error, $object->errors, 'errors'); |
||
1091 | $action = ''; |
||
1092 | } |
||
1093 | } |
||
1094 | if (!empty($backtopage) && !$error) { |
||
1095 | header("Location: " . $backtopage); |
||
1096 | exit; |
||
1097 | } |
||
1098 | } |
||
1099 | |||
1100 | // SPIP Management |
||
1101 | if ($user->hasRight('adherent', 'supprimer') && $action == 'confirm_del_spip' && $confirm == 'yes') { |
||
1102 | if (!count($object->errors)) { |
||
1103 | if (!$mailmanspip->del_to_spip($object)) { |
||
1104 | setEventMessages($langs->trans('DeleteIntoSpipError') . ': ' . $mailmanspip->error, null, 'errors'); |
||
1105 | } |
||
1106 | } |
||
1107 | } |
||
1108 | |||
1109 | if ($user->hasRight('adherent', 'creer') && $action == 'confirm_add_spip' && $confirm == 'yes') { |
||
1110 | if (!count($object->errors)) { |
||
1111 | if (!$mailmanspip->add_to_spip($object)) { |
||
1112 | setEventMessages($langs->trans('AddIntoSpipError') . ': ' . $mailmanspip->error, null, 'errors'); |
||
1113 | } |
||
1114 | } |
||
1115 | } |
||
1116 | |||
1117 | // Actions when printing a doc from card |
||
1118 | include DOL_DOCUMENT_ROOT . '/core/actions_printing.inc.php'; |
||
1119 | |||
1120 | // Actions to build doc |
||
1121 | $upload_dir = $conf->adherent->dir_output; |
||
1122 | $permissiontoadd = $user->hasRight('adherent', 'creer'); |
||
1123 | include DOL_DOCUMENT_ROOT . '/core/actions_builddoc.inc.php'; |
||
1124 | |||
1125 | // Actions to send emails |
||
1126 | $triggersendname = 'MEMBER_SENTBYMAIL'; |
||
1127 | $paramname = 'id'; |
||
1128 | $mode = 'emailfrommember'; |
||
1129 | $trackid = 'mem' . $object->id; |
||
1130 | include DOL_DOCUMENT_ROOT . '/core/actions_sendmails.inc.php'; |
||
1131 | } |
||
1132 | |||
1133 | |||
1134 | /* |
||
1135 | * View |
||
1136 | */ |
||
1137 | |||
1138 | $form = new Form($db); |
||
1139 | $formfile = new FormFile($db); |
||
1140 | $formadmin = new FormAdmin($db); |
||
1141 | $formcompany = new FormCompany($db); |
||
1142 | |||
1143 | $title = $langs->trans("Member") . " - " . $langs->trans("Card"); |
||
1144 | $help_url = 'EN:Module_Foundations|FR:Module_Adhérents|ES:Módulo_Miembros|DE:Modul_Mitglieder'; |
||
1145 | llxHeader('', $title, $help_url); |
||
1146 | |||
1147 | $countrynotdefined = $langs->trans("ErrorSetACountryFirst") . ' (' . $langs->trans("SeeAbove") . ')'; |
||
1148 | |||
1149 | if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { |
||
1150 | // ----------------------------------------- |
||
1151 | // When used with CANVAS |
||
1152 | // ----------------------------------------- |
||
1153 | if (empty($object->error) && $id) { |
||
1154 | $object = new Adherent($db); |
||
1155 | $result = $object->fetch($id); |
||
1156 | if ($result <= 0) { |
||
1157 | dol_print_error(null, $object->error); |
||
1158 | } |
||
1159 | } |
||
1160 | $objcanvas->assign_values($action, $object->id, $object->ref); // Set value for templates |
||
1161 | $objcanvas->display_canvas($action); // Show template |
||
1162 | } else { |
||
1163 | // ----------------------------------------- |
||
1164 | // When used in standard mode |
||
1165 | // ----------------------------------------- |
||
1166 | |||
1167 | // Create mode |
||
1168 | if ($action == 'create') { |
||
1169 | $object->canvas = $canvas; |
||
1170 | $object->state_id = GETPOSTINT('state_id'); |
||
1171 | |||
1172 | // We set country_id, country_code and country for the selected country |
||
1173 | $object->country_id = GETPOSTINT('country_id') ? GETPOSTINT('country_id') : $mysoc->country_id; |
||
1174 | if ($object->country_id) { |
||
1175 | $tmparray = getCountry($object->country_id, 'all'); |
||
1176 | $object->country_code = $tmparray['code']; |
||
1177 | $object->country = $tmparray['label']; |
||
1178 | } |
||
1179 | |||
1180 | $soc = new Societe($db); |
||
1181 | if (!empty($socid)) { |
||
1182 | if ($socid > 0) { |
||
1183 | $soc->fetch($socid); |
||
1184 | } |
||
1185 | |||
1186 | if (!($soc->id > 0)) { |
||
1187 | $langs->load("errors"); |
||
1188 | print($langs->trans('ErrorRecordNotFound')); |
||
1189 | exit; |
||
|
|||
1190 | } |
||
1191 | } |
||
1192 | |||
1193 | $adht = new AdherentType($db); |
||
1194 | |||
1195 | print load_fiche_titre($langs->trans("NewMember"), '', $object->picto); |
||
1196 | |||
1197 | if ($conf->use_javascript_ajax) { |
||
1198 | print "\n" . '<script type="text/javascript">' . "\n"; |
||
1199 | print 'jQuery(document).ready(function () { |
||
1200 | jQuery("#selectcountry_id").change(function() { |
||
1201 | document.formsoc.action.value="create"; |
||
1202 | document.formsoc.submit(); |
||
1203 | }); |
||
1204 | function initfieldrequired() { |
||
1205 | jQuery("#tdcompany").removeClass("fieldrequired"); |
||
1206 | jQuery("#tdlastname").removeClass("fieldrequired"); |
||
1207 | jQuery("#tdfirstname").removeClass("fieldrequired"); |
||
1208 | if (jQuery("#morphy").val() == \'mor\') { |
||
1209 | jQuery("#tdcompany").addClass("fieldrequired"); |
||
1210 | } |
||
1211 | if (jQuery("#morphy").val() == \'phy\') { |
||
1212 | jQuery("#tdlastname").addClass("fieldrequired"); |
||
1213 | jQuery("#tdfirstname").addClass("fieldrequired"); |
||
1214 | } |
||
1215 | } |
||
1216 | jQuery("#morphy").change(function() { |
||
1217 | initfieldrequired(); |
||
1218 | }); |
||
1219 | initfieldrequired(); |
||
1220 | })'; |
||
1221 | print '</script>' . "\n"; |
||
1222 | } |
||
1223 | |||
1224 | print '<form name="formsoc" action="' . $_SERVER['PHP_SELF'] . '" method="post" enctype="multipart/form-data">'; |
||
1225 | print '<input type="hidden" name="token" value="' . newToken() . '">'; |
||
1226 | print '<input type="hidden" name="action" value="add">'; |
||
1227 | print '<input type="hidden" name="socid" value="' . $socid . '">'; |
||
1228 | if ($backtopage) { |
||
1229 | print '<input type="hidden" name="backtopage" value="' . ($backtopage != '1' ? $backtopage : $_SERVER["HTTP_REFERER"]) . '">'; |
||
1230 | } |
||
1231 | |||
1232 | print dol_get_fiche_head(''); |
||
1233 | |||
1234 | print '<table class="border centpercent">'; |
||
1235 | print '<tbody>'; |
||
1236 | |||
1237 | // Login |
||
1238 | if (!getDolGlobalString('ADHERENT_LOGIN_NOT_REQUIRED')) { |
||
1239 | print '<tr><td><span class="fieldrequired">' . $langs->trans("Login") . ' / ' . $langs->trans("Id") . '</span></td><td><input type="text" name="member_login" class="minwidth300" maxlength="50" value="' . (GETPOSTISSET("member_login") ? GETPOST("member_login", 'alphanohtml', 2) : $object->login) . '" autofocus="autofocus"></td></tr>'; |
||
1240 | } |
||
1241 | |||
1242 | // Password |
||
1243 | if (!getDolGlobalString('ADHERENT_LOGIN_NOT_REQUIRED')) { |
||
1244 | require_once DOL_DOCUMENT_ROOT . '/core/lib/security2.lib.php'; |
||
1245 | $generated_password = getRandomPassword(false); |
||
1246 | print '<tr><td><span class="fieldrequired">' . $langs->trans("Password") . '</span></td><td>'; |
||
1247 | print '<input type="text" class="minwidth300" maxlength="50" name="password" value="' . dol_escape_htmltag($generated_password) . '">'; |
||
1248 | print '</td></tr>'; |
||
1249 | } |
||
1250 | |||
1251 | // Type |
||
1252 | print '<tr><td class="fieldrequired">' . $langs->trans("MemberType") . '</td><td>'; |
||
1253 | $listetype = $adht->liste_array(1); |
||
1254 | print img_picto('', $adht->picto, 'class="pictofixedwidth"'); |
||
1255 | if (count($listetype)) { |
||
1256 | print $form->selectarray("typeid", $listetype, (GETPOSTINT('typeid') ? GETPOSTINT('typeid') : $typeid), (count($listetype) > 1 ? 1 : 0), 0, 0, '', 0, 0, 0, '', '', 1); |
||
1257 | } else { |
||
1258 | print '<span class="error">' . $langs->trans("NoTypeDefinedGoToSetup") . '</span>'; |
||
1259 | } |
||
1260 | print "</td>\n"; |
||
1261 | |||
1262 | // Morphy |
||
1263 | $morphys = array(); |
||
1264 | $morphys["phy"] = $langs->trans("Physical"); |
||
1265 | $morphys["mor"] = $langs->trans("Moral"); |
||
1266 | print '<tr><td class="fieldrequired">' . $langs->trans("MemberNature") . "</td><td>\n"; |
||
1267 | print $form->selectarray("morphy", $morphys, (GETPOST('morphy', 'alpha') ? GETPOST('morphy', 'alpha') : $object->morphy), 1, 0, 0, '', 0, 0, 0, '', '', 1); |
||
1268 | print "</td>\n"; |
||
1269 | |||
1270 | // Company |
||
1271 | print '<tr><td id="tdcompany">' . $langs->trans("Company") . '</td><td><input type="text" name="societe" class="minwidth300" maxlength="128" value="' . (GETPOSTISSET('societe') ? GETPOST('societe', 'alphanohtml') : $soc->name) . '"></td></tr>'; |
||
1272 | |||
1273 | // Civility |
||
1274 | print '<tr><td>' . $langs->trans("UserTitle") . '</td><td>'; |
||
1275 | print $formcompany->select_civility(GETPOSTINT('civility_id') ? GETPOSTINT('civility_id') : $object->civility_id, 'civility_id', 'maxwidth150', 1) . '</td>'; |
||
1276 | print '</tr>'; |
||
1277 | |||
1278 | // Lastname |
||
1279 | print '<tr><td id="tdlastname">' . $langs->trans("Lastname") . '</td><td><input type="text" name="lastname" class="minwidth300" maxlength="50" value="' . (GETPOSTISSET('lastname') ? GETPOST('lastname', 'alphanohtml') : $object->lastname) . '"></td>'; |
||
1280 | print '</tr>'; |
||
1281 | |||
1282 | // Firstname |
||
1283 | print '<tr><td id="tdfirstname">' . $langs->trans("Firstname") . '</td><td><input type="text" name="firstname" class="minwidth300" maxlength="50" value="' . (GETPOSTISSET('firstname') ? GETPOST('firstname', 'alphanohtml') : $object->firstname) . '"></td>'; |
||
1284 | print '</tr>'; |
||
1285 | |||
1286 | // Gender |
||
1287 | print '<tr><td>' . $langs->trans("Gender") . '</td>'; |
||
1288 | print '<td>'; |
||
1289 | $arraygender = array('man' => $langs->trans("Genderman"), 'woman' => $langs->trans("Genderwoman"), 'other' => $langs->trans("Genderother")); |
||
1290 | print $form->selectarray('gender', $arraygender, GETPOST('gender', 'alphanohtml'), 1, 0, 0, '', 0, 0, 0, '', '', 1); |
||
1291 | print '</td></tr>'; |
||
1292 | |||
1293 | |||
1294 | print '<tr><td>' . (getDolGlobalString('ADHERENT_MAIL_REQUIRED') ? '<span class="fieldrequired">' : '') . $langs->trans("EMail") . (getDolGlobalString('ADHERENT_MAIL_REQUIRED') ? '</span>' : '') . '</td>'; |
||
1295 | print '<td>' . img_picto('', 'object_email') . ' <input type="text" name="member_email" class="minwidth300" maxlength="255" value="' . (GETPOSTISSET('member_email') ? GETPOST('member_email', 'alpha') : $soc->email) . '"></td></tr>'; |
||
1296 | |||
1297 | // Website |
||
1298 | print '<tr><td>' . $form->editfieldkey('Web', 'member_url', GETPOST('member_url', 'alpha'), $object, 0) . '</td>'; |
||
1299 | print '<td>' . img_picto('', 'globe') . ' <input type="text" class="maxwidth500 widthcentpercentminusx" name="member_url" id="member_url" value="' . (GETPOSTISSET('member_url') ? GETPOST('member_url', 'alpha') : $object->url) . '"></td></tr>'; |
||
1300 | |||
1301 | // Address |
||
1302 | print '<tr><td class="tdtop">' . $langs->trans("Address") . '</td><td>'; |
||
1303 | print '<textarea name="address" wrap="soft" class="quatrevingtpercent" rows="2">' . (GETPOSTISSET('address') ? GETPOST('address', 'alphanohtml') : $soc->address) . '</textarea>'; |
||
1304 | print '</td></tr>'; |
||
1305 | |||
1306 | // Zip / Town |
||
1307 | print '<tr><td>' . $langs->trans("Zip") . ' / ' . $langs->trans("Town") . '</td><td>'; |
||
1308 | print $formcompany->select_ziptown((GETPOSTISSET('zipcode') ? GETPOST('zipcode', 'alphanohtml') : $soc->zip), 'zipcode', array('town', 'selectcountry_id', 'state_id'), 6); |
||
1309 | print ' '; |
||
1310 | print $formcompany->select_ziptown((GETPOSTISSET('town') ? GETPOST('town', 'alphanohtml') : $soc->town), 'town', array('zipcode', 'selectcountry_id', 'state_id')); |
||
1311 | print '</td></tr>'; |
||
1312 | |||
1313 | // Country |
||
1314 | if (empty($soc->country_id)) { |
||
1315 | $soc->country_id = $mysoc->country_id; |
||
1316 | $soc->country_code = $mysoc->country_code; |
||
1317 | $soc->state_id = $mysoc->state_id; |
||
1318 | } |
||
1319 | print '<tr><td>' . $langs->trans('Country') . '</td><td>'; |
||
1320 | print img_picto('', 'country', 'class="pictofixedwidth"'); |
||
1321 | print $form->select_country(GETPOSTISSET('country_id') ? GETPOST('country_id', 'alpha') : $soc->country_id, 'country_id'); |
||
1322 | if ($user->admin) { |
||
1323 | print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1); |
||
1324 | } |
||
1325 | print '</td></tr>'; |
||
1326 | |||
1327 | // State |
||
1328 | if (!getDolGlobalString('MEMBER_DISABLE_STATE')) { |
||
1329 | print '<tr><td>' . $langs->trans('State') . '</td><td>'; |
||
1330 | if ($soc->country_id) { |
||
1331 | print img_picto('', 'state', 'class="pictofixedwidth"'); |
||
1332 | print $formcompany->select_state(GETPOSTISSET('state_id') ? GETPOSTINT('state_id') : $soc->state_id, $soc->country_code); |
||
1333 | } else { |
||
1334 | print $countrynotdefined; |
||
1335 | } |
||
1336 | print '</td></tr>'; |
||
1337 | } |
||
1338 | |||
1339 | // Pro phone |
||
1340 | print '<tr><td>' . $langs->trans("PhonePro") . '</td>'; |
||
1341 | print '<td>' . img_picto('', 'object_phoning', 'class="pictofixedwidth"') . '<input type="text" name="phone" size="20" value="' . (GETPOSTISSET('phone') ? GETPOST('phone', 'alpha') : $soc->phone) . '"></td></tr>'; |
||
1342 | |||
1343 | // Personal phone |
||
1344 | print '<tr><td>' . $langs->trans("PhonePerso") . '</td>'; |
||
1345 | print '<td>' . img_picto('', 'object_phoning', 'class="pictofixedwidth"') . '<input type="text" name="phone_perso" size="20" value="' . (GETPOSTISSET('phone_perso') ? GETPOST('phone_perso', 'alpha') : $object->phone_perso) . '"></td></tr>'; |
||
1346 | |||
1347 | // Mobile phone |
||
1348 | print '<tr><td>' . $langs->trans("PhoneMobile") . '</td>'; |
||
1349 | print '<td>' . img_picto('', 'object_phoning_mobile', 'class="pictofixedwidth"') . '<input type="text" name="phone_mobile" size="20" value="' . (GETPOSTISSET('phone_mobile') ? GETPOST('phone_mobile', 'alpha') : $object->phone_mobile) . '"></td></tr>'; |
||
1350 | |||
1351 | if (isModEnabled('socialnetworks')) { |
||
1352 | foreach ($socialnetworks as $key => $value) { |
||
1353 | if (!$value['active']) { |
||
1354 | break; |
||
1355 | } |
||
1356 | $val = (GETPOSTISSET('member_' . $key) ? GETPOST('member_' . $key, 'alpha') : (empty($object->socialnetworks[$key]) ? '' : $object->socialnetworks[$key])); |
||
1357 | print '<tr><td>' . $langs->trans($value['label']) . '</td><td><input type="text" name="member_' . $key . '" size="40" value="' . $val . '"></td></tr>'; |
||
1358 | } |
||
1359 | } |
||
1360 | |||
1361 | // Birth Date |
||
1362 | print "<tr><td>" . $langs->trans("DateOfBirth") . "</td><td>\n"; |
||
1363 | print img_picto('', 'object_calendar', 'class="pictofixedwidth"') . $form->selectDate(($object->birth ? $object->birth : -1), 'birth', 0, 0, 1, 'formsoc'); |
||
1364 | print "</td></tr>\n"; |
||
1365 | |||
1366 | // Public profil |
||
1367 | print "<tr><td>"; |
||
1368 | $htmltext = $langs->trans("Public", getDolGlobalString('MAIN_INFO_SOCIETE_NOM'), $linkofpubliclist); |
||
1369 | print $form->textwithpicto($langs->trans("MembershipPublic"), $htmltext, 1, 'help', '', 0, 3, 'membershippublic'); |
||
1370 | print "</td><td>\n"; |
||
1371 | print $form->selectyesno("public", $object->public, 1); |
||
1372 | print "</td></tr>\n"; |
||
1373 | |||
1374 | // Categories |
||
1375 | if (isModEnabled('category') && $user->hasRight('categorie', 'lire')) { |
||
1376 | print '<tr><td>' . $form->editfieldkey("Categories", 'memcats', '', $object, 0) . '</td><td>'; |
||
1377 | $cate_arbo = $form->select_all_categories(Categorie::TYPE_MEMBER, null, 'parent', null, null, 1); |
||
1378 | print img_picto('', 'category') . $form->multiselectarray('memcats', $cate_arbo, GETPOST('memcats', 'array'), null, null, 'quatrevingtpercent widthcentpercentminusx', 0, 0); |
||
1379 | print "</td></tr>"; |
||
1380 | } |
||
1381 | |||
1382 | // Other attributes |
||
1383 | include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_add.tpl.php'; |
||
1384 | |||
1385 | print '<tbody>'; |
||
1386 | print "</table>\n"; |
||
1387 | |||
1388 | print dol_get_fiche_end(); |
||
1389 | |||
1390 | print $form->buttonsSaveCancel("AddMember"); |
||
1391 | |||
1392 | print "</form>\n"; |
||
1393 | } |
||
1394 | |||
1395 | // Edit mode |
||
1396 | if ($action == 'edit') { |
||
1397 | $res = $object->fetch($id); |
||
1398 | if ($res < 0) { |
||
1399 | dol_print_error($db, $object->error); |
||
1400 | exit; |
||
1401 | } |
||
1402 | $res = $object->fetch_optionals(); |
||
1403 | if ($res < 0) { |
||
1404 | dol_print_error($db); |
||
1405 | exit; |
||
1406 | } |
||
1407 | |||
1408 | $adht = new AdherentType($db); |
||
1409 | $adht->fetch($object->typeid); |
||
1410 | |||
1411 | // We set country_id, and country_code, country of the chosen country |
||
1412 | $country = GETPOSTINT('country'); |
||
1413 | if (!empty($country) || $object->country_id) { |
||
1414 | $sql = "SELECT rowid, code, label from " . MAIN_DB_PREFIX . "c_country"; |
||
1415 | $sql .= " WHERE rowid = " . (int) (!empty($country) ? $country : $object->country_id); |
||
1416 | $resql = $db->query($sql); |
||
1417 | if ($resql) { |
||
1418 | $obj = $db->fetch_object($resql); |
||
1419 | } else { |
||
1420 | dol_print_error($db); |
||
1421 | } |
||
1422 | $object->country_id = $obj->rowid; |
||
1423 | $object->country_code = $obj->code; |
||
1424 | $object->country = $langs->trans("Country" . $obj->code) ? $langs->trans("Country" . $obj->code) : $obj->label; |
||
1425 | } |
||
1426 | |||
1427 | $head = member_prepare_head($object); |
||
1428 | |||
1429 | |||
1430 | if ($conf->use_javascript_ajax) { |
||
1431 | print "\n" . '<script type="text/javascript">'; |
||
1432 | print 'jQuery(document).ready(function () { |
||
1433 | jQuery("#selectcountry_id").change(function() { |
||
1434 | document.formsoc.action.value="edit"; |
||
1435 | document.formsoc.submit(); |
||
1436 | }); |
||
1437 | function initfieldrequired() { |
||
1438 | jQuery("#tdcompany").removeClass("fieldrequired"); |
||
1439 | jQuery("#tdlastname").removeClass("fieldrequired"); |
||
1440 | jQuery("#tdfirstname").removeClass("fieldrequired"); |
||
1441 | if (jQuery("#morphy").val() == \'mor\') { |
||
1442 | jQuery("#tdcompany").addClass("fieldrequired"); |
||
1443 | } |
||
1444 | if (jQuery("#morphy").val() == \'phy\') { |
||
1445 | jQuery("#tdlastname").addClass("fieldrequired"); |
||
1446 | jQuery("#tdfirstname").addClass("fieldrequired"); |
||
1447 | } |
||
1448 | } |
||
1449 | jQuery("#morphy").change(function() { |
||
1450 | initfieldrequired(); |
||
1451 | }); |
||
1452 | initfieldrequired(); |
||
1453 | })'; |
||
1454 | print '</script>' . "\n"; |
||
1455 | } |
||
1456 | |||
1457 | print '<form name="formsoc" action="' . $_SERVER['PHP_SELF'] . '" method="post" enctype="multipart/form-data">'; |
||
1458 | print '<input type="hidden" name="token" value="' . newToken() . '" />'; |
||
1459 | print '<input type="hidden" name="action" value="update" />'; |
||
1460 | print '<input type="hidden" name="rowid" value="' . $id . '" />'; |
||
1461 | print '<input type="hidden" name="statut" value="' . $object->statut . '" />'; |
||
1462 | if ($backtopage) { |
||
1463 | print '<input type="hidden" name="backtopage" value="' . ($backtopage != '1' ? $backtopage : $_SERVER["HTTP_REFERER"]) . '">'; |
||
1464 | } |
||
1465 | |||
1466 | print dol_get_fiche_head($head, 'general', $langs->trans("Member"), 0, 'user'); |
||
1467 | |||
1468 | print '<table class="border centpercent">'; |
||
1469 | |||
1470 | // Ref |
||
1471 | print '<tr><td class="titlefieldcreate">' . $langs->trans("Ref") . '</td><td class="valeur">' . $object->ref . '</td></tr>'; |
||
1472 | |||
1473 | // Login |
||
1474 | if (!getDolGlobalString('ADHERENT_LOGIN_NOT_REQUIRED')) { |
||
1475 | print '<tr><td><span class="fieldrequired">' . $langs->trans("Login") . ' / ' . $langs->trans("Id") . '</span></td><td><input type="text" name="login" class="minwidth300" maxlength="50" value="' . (GETPOSTISSET("login") ? GETPOST("login", 'alphanohtml', 2) : $object->login) . '"></td></tr>'; |
||
1476 | } |
||
1477 | |||
1478 | // Password |
||
1479 | if (!getDolGlobalString('ADHERENT_LOGIN_NOT_REQUIRED')) { |
||
1480 | print '<tr><td class="fieldrequired">' . $langs->trans("Password") . '</td><td><input type="password" name="pass" class="minwidth300" maxlength="50" value="' . dol_escape_htmltag(GETPOSTISSET("pass") ? GETPOST("pass", 'none', 2) : '') . '"></td></tr>'; |
||
1481 | } |
||
1482 | |||
1483 | // Type |
||
1484 | print '<tr><td class="fieldrequired">' . $langs->trans("Type") . '</td><td>'; |
||
1485 | if ($user->hasRight('adherent', 'creer')) { |
||
1486 | print $form->selectarray("typeid", $adht->liste_array(), (GETPOSTISSET("typeid") ? GETPOSTINT("typeid") : $object->typeid), 0, 0, 0, '', 0, 0, 0, '', '', 1); |
||
1487 | } else { |
||
1488 | print $adht->getNomUrl(1); |
||
1489 | print '<input type="hidden" name="typeid" value="' . $object->typeid . '">'; |
||
1490 | } |
||
1491 | print "</td></tr>"; |
||
1492 | |||
1493 | // Morphy |
||
1494 | $morphys["phy"] = $langs->trans("Physical"); |
||
1495 | $morphys["mor"] = $langs->trans("Moral"); |
||
1496 | print '<tr><td><span class="fieldrequired">' . $langs->trans("MemberNature") . '</span></td><td>'; |
||
1497 | print $form->selectarray("morphy", $morphys, (GETPOSTISSET("morphy") ? GETPOST("morphy", 'alpha') : $object->morphy), 0, 0, 0, '', 0, 0, 0, '', '', 1); |
||
1498 | print "</td></tr>"; |
||
1499 | |||
1500 | // Company |
||
1501 | print '<tr><td id="tdcompany">' . $langs->trans("Company") . '</td><td><input type="text" name="societe" class="minwidth300" maxlength="128" value="' . (GETPOSTISSET("societe") ? GETPOST("societe", 'alphanohtml', 2) : $object->company) . '"></td></tr>'; |
||
1502 | |||
1503 | // Civility |
||
1504 | print '<tr><td>' . $langs->trans("UserTitle") . '</td><td>'; |
||
1505 | print $formcompany->select_civility(GETPOSTISSET("civility_id") ? GETPOST("civility_id", 'alpha') : $object->civility_id, 'civility_id', 'maxwidth150', 1); |
||
1506 | print '</td>'; |
||
1507 | print '</tr>'; |
||
1508 | |||
1509 | // Lastname |
||
1510 | print '<tr><td id="tdlastname">' . $langs->trans("Lastname") . '</td><td><input type="text" name="lastname" class="minwidth300" maxlength="50" value="' . (GETPOSTISSET("lastname") ? GETPOST("lastname", 'alphanohtml', 2) : $object->lastname) . '"></td>'; |
||
1511 | print '</tr>'; |
||
1512 | |||
1513 | // Firstname |
||
1514 | print '<tr><td id="tdfirstname">' . $langs->trans("Firstname") . '</td><td><input type="text" name="firstname" class="minwidth300" maxlength="50" value="' . (GETPOSTISSET("firstname") ? GETPOST("firstname", 'alphanohtml', 3) : $object->firstname) . '"></td>'; |
||
1515 | print '</tr>'; |
||
1516 | |||
1517 | // Gender |
||
1518 | print '<tr><td>' . $langs->trans("Gender") . '</td>'; |
||
1519 | print '<td>'; |
||
1520 | $arraygender = array('man' => $langs->trans("Genderman"), 'woman' => $langs->trans("Genderwoman"), 'other' => $langs->trans("Genderother")); |
||
1521 | print $form->selectarray('gender', $arraygender, GETPOSTISSET('gender') ? GETPOST('gender', 'alphanohtml') : $object->gender, 1, 0, 0, '', 0, 0, 0, '', '', 1); |
||
1522 | print '</td></tr>'; |
||
1523 | |||
1524 | // Photo |
||
1525 | print '<tr><td>' . $langs->trans("Photo") . '</td>'; |
||
1526 | print '<td class="hideonsmartphone" valign="middle">'; |
||
1527 | print $form->showphoto('memberphoto', $object) . "\n"; |
||
1528 | if ($caneditfieldmember) { |
||
1529 | if ($object->photo) { |
||
1530 | print "<br>\n"; |
||
1531 | } |
||
1532 | print '<table class="nobordernopadding">'; |
||
1533 | if ($object->photo) { |
||
1534 | print '<tr><td><input type="checkbox" class="flat photodelete" name="deletephoto" id="photodelete"> ' . $langs->trans("Delete") . '<br><br></td></tr>'; |
||
1535 | } |
||
1536 | print '<tr><td>' . $langs->trans("PhotoFile") . '</td></tr>'; |
||
1537 | print '<tr><td>'; |
||
1538 | $maxfilesizearray = getMaxFileSizeArray(); |
||
1539 | $maxmin = $maxfilesizearray['maxmin']; |
||
1540 | if ($maxmin > 0) { |
||
1541 | print '<input type="hidden" name="MAX_FILE_SIZE" value="' . ($maxmin * 1024) . '">'; // MAX_FILE_SIZE must precede the field type=file |
||
1542 | } |
||
1543 | print '<input type="file" class="flat" name="photo" id="photoinput">'; |
||
1544 | print '</td></tr>'; |
||
1545 | print '</table>'; |
||
1546 | } |
||
1547 | print '</td></tr>'; |
||
1548 | |||
1549 | |||
1550 | print '<tr><td>' . (getDolGlobalString("ADHERENT_MAIL_REQUIRED") ? '<span class="fieldrequired">' : '') . $langs->trans("EMail") . (getDolGlobalString("ADHERENT_MAIL_REQUIRED") ? '</span>' : '') . '</td>'; |
||
1551 | print '<td>' . img_picto('', 'object_email', 'class="pictofixedwidth"') . '<input type="text" name="member_email" class="minwidth300" maxlength="255" value="' . (GETPOSTISSET("member_email") ? GETPOST("member_email", '', 2) : $object->email) . '"></td></tr>'; |
||
1552 | |||
1553 | // Website |
||
1554 | print '<tr><td>' . $form->editfieldkey('Web', 'member_url', GETPOST('member_url', 'alpha'), $object, 0) . '</td>'; |
||
1555 | print '<td>' . img_picto('', 'globe', 'class="pictofixedwidth"') . '<input type="text" name="member_url" id="member_url" class="maxwidth200onsmartphone maxwidth500 widthcentpercentminusx " value="' . (GETPOSTISSET('member_url') ? GETPOST('member_url', 'alpha') : $object->url) . '"></td></tr>'; |
||
1556 | |||
1557 | // Address |
||
1558 | print '<tr><td>' . $langs->trans("Address") . '</td><td>'; |
||
1559 | print '<textarea name="address" wrap="soft" class="quatrevingtpercent" rows="' . ROWS_2 . '">' . (GETPOSTISSET("address") ? GETPOST("address", 'alphanohtml', 2) : $object->address) . '</textarea>'; |
||
1560 | print '</td></tr>'; |
||
1561 | |||
1562 | // Zip / Town |
||
1563 | print '<tr><td>' . $langs->trans("Zip") . ' / ' . $langs->trans("Town") . '</td><td>'; |
||
1564 | print $formcompany->select_ziptown((GETPOSTISSET("zipcode") ? GETPOST("zipcode", 'alphanohtml', 2) : $object->zip), 'zipcode', array('town', 'selectcountry_id', 'state_id'), 6); |
||
1565 | print ' '; |
||
1566 | print $formcompany->select_ziptown((GETPOSTISSET("town") ? GETPOST("town", 'alphanohtml', 2) : $object->town), 'town', array('zipcode', 'selectcountry_id', 'state_id')); |
||
1567 | print '</td></tr>'; |
||
1568 | |||
1569 | // Country |
||
1570 | //$object->country_id=$object->country_id?$object->country_id:$mysoc->country_id; // In edit mode we don't force to company country if not defined |
||
1571 | print '<tr><td>' . $langs->trans('Country') . '</td><td>'; |
||
1572 | print img_picto('', 'country', 'class="pictofixedwidth"'); |
||
1573 | print $form->select_country(GETPOSTISSET("country_id") ? GETPOST("country_id", "alpha") : $object->country_id, 'country_id'); |
||
1574 | if ($user->admin) { |
||
1575 | print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1); |
||
1576 | } |
||
1577 | print '</td></tr>'; |
||
1578 | |||
1579 | // State |
||
1580 | if (!getDolGlobalString('MEMBER_DISABLE_STATE')) { |
||
1581 | print '<tr><td>' . $langs->trans('State') . '</td><td>'; |
||
1582 | print img_picto('', 'state', 'class="pictofixedwidth"'); |
||
1583 | print $formcompany->select_state($object->state_id, GETPOSTISSET("country_id") ? GETPOST("country_id", "alpha") : $object->country_id); |
||
1584 | print '</td></tr>'; |
||
1585 | } |
||
1586 | |||
1587 | // Pro phone |
||
1588 | print '<tr><td>' . $langs->trans("PhonePro") . '</td>'; |
||
1589 | print '<td>' . img_picto('', 'object_phoning', 'class="pictofixedwidth"') . '<input type="text" name="phone" value="' . (GETPOSTISSET("phone") ? GETPOST("phone") : $object->phone) . '"></td></tr>'; |
||
1590 | |||
1591 | // Personal phone |
||
1592 | print '<tr><td>' . $langs->trans("PhonePerso") . '</td>'; |
||
1593 | print '<td>' . img_picto('', 'object_phoning', 'class="pictofixedwidth"') . '<input type="text" name="phone_perso" value="' . (GETPOSTISSET("phone_perso") ? GETPOST("phone_perso") : $object->phone_perso) . '"></td></tr>'; |
||
1594 | |||
1595 | // Mobile phone |
||
1596 | print '<tr><td>' . $langs->trans("PhoneMobile") . '</td>'; |
||
1597 | print '<td>' . img_picto('', 'object_phoning_mobile', 'class="pictofixedwidth"') . '<input type="text" name="phone_mobile" value="' . (GETPOSTISSET("phone_mobile") ? GETPOST("phone_mobile") : $object->phone_mobile) . '"></td></tr>'; |
||
1598 | |||
1599 | if (isModEnabled('socialnetworks')) { |
||
1600 | foreach ($socialnetworks as $key => $value) { |
||
1601 | if (!$value['active']) { |
||
1602 | break; |
||
1603 | } |
||
1604 | print '<tr><td>' . $langs->trans($value['label']) . '</td><td><input type="text" name="' . $key . '" class="minwidth100" value="' . (GETPOSTISSET($key) ? GETPOST($key, 'alphanohtml') : (isset($object->socialnetworks[$key]) ? $object->socialnetworks[$key] : null)) . '"></td></tr>'; |
||
1605 | } |
||
1606 | } |
||
1607 | |||
1608 | // Birth Date |
||
1609 | print "<tr><td>" . $langs->trans("DateOfBirth") . "</td><td>\n"; |
||
1610 | print img_picto('', 'object_calendar', 'class="pictofixedwidth"') . $form->selectDate(($object->birth ? $object->birth : -1), 'birth', 0, 0, 1, 'formsoc'); |
||
1611 | print "</td></tr>\n"; |
||
1612 | |||
1613 | // Default language |
||
1614 | if (getDolGlobalInt('MAIN_MULTILANGS')) { |
||
1615 | print '<tr><td>' . $form->editfieldkey('DefaultLang', 'default_lang', '', $object, 0) . '</td><td colspan="3">' . "\n"; |
||
1616 | print img_picto('', 'language', 'class="pictofixedwidth"') . $formadmin->select_language($object->default_lang, 'default_lang', 0, 0, 1); |
||
1617 | print '</td>'; |
||
1618 | print '</tr>'; |
||
1619 | } |
||
1620 | |||
1621 | // Public profil |
||
1622 | print "<tr><td>"; |
||
1623 | $htmltext = $langs->trans("Public", getDolGlobalString('MAIN_INFO_SOCIETE_NOM'), $linkofpubliclist); |
||
1624 | print $form->textwithpicto($langs->trans("MembershipPublic"), $htmltext, 1, 'help', '', 0, 3, 'membershippublic'); |
||
1625 | print "</td><td>\n"; |
||
1626 | print $form->selectyesno("public", (GETPOSTISSET("public") ? GETPOST("public", 'alphanohtml', 2) : $object->public), 1); |
||
1627 | print "</td></tr>\n"; |
||
1628 | |||
1629 | // Categories |
||
1630 | if (isModEnabled('category') && $user->hasRight('categorie', 'lire')) { |
||
1631 | print '<tr><td>' . $form->editfieldkey("Categories", 'memcats', '', $object, 0) . '</td>'; |
||
1632 | print '<td>'; |
||
1633 | $cate_arbo = $form->select_all_categories(Categorie::TYPE_MEMBER, null, null, null, null, 1); |
||
1634 | $c = new Categorie($db); |
||
1635 | $cats = $c->containing($object->id, Categorie::TYPE_MEMBER); |
||
1636 | $arrayselected = array(); |
||
1637 | if (is_array($cats)) { |
||
1638 | foreach ($cats as $cat) { |
||
1639 | $arrayselected[] = $cat->id; |
||
1640 | } |
||
1641 | } |
||
1642 | print $form->multiselectarray('memcats', $cate_arbo, $arrayselected, '', 0, '', 0, '100%'); |
||
1643 | print "</td></tr>"; |
||
1644 | } |
||
1645 | |||
1646 | // Third party Dolibarr |
||
1647 | if (isModEnabled('societe')) { |
||
1648 | print '<tr><td>' . $langs->trans("LinkedToDolibarrThirdParty") . '</td><td colspan="2" class="valeur">'; |
||
1649 | if ($object->socid) { |
||
1650 | $company = new Societe($db); |
||
1651 | $result = $company->fetch($object->socid); |
||
1652 | print $company->getNomUrl(1); |
||
1653 | } else { |
||
1654 | print $langs->trans("NoThirdPartyAssociatedToMember"); |
||
1655 | } |
||
1656 | print '</td></tr>'; |
||
1657 | } |
||
1658 | |||
1659 | // Login Dolibarr |
||
1660 | print '<tr><td>' . $langs->trans("LinkedToDolibarrUser") . '</td><td colspan="2" class="valeur">'; |
||
1661 | if ($object->user_id) { |
||
1662 | $form->form_users($_SERVER['PHP_SELF'] . '?rowid=' . $object->id, $object->user_id, 'none'); |
||
1663 | } else { |
||
1664 | print $langs->trans("NoDolibarrAccess"); |
||
1665 | } |
||
1666 | print '</td></tr>'; |
||
1667 | |||
1668 | // Other attributes. Fields from hook formObjectOptions and Extrafields. |
||
1669 | include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_add.tpl.php'; |
||
1670 | |||
1671 | print '</table>'; |
||
1672 | print dol_get_fiche_end(); |
||
1673 | |||
1674 | print $form->buttonsSaveCancel("Save", 'Cancel'); |
||
1675 | |||
1676 | print '</form>'; |
||
1677 | } |
||
1678 | |||
1679 | // View |
||
1680 | if ($id > 0 && $action != 'edit') { |
||
1681 | $res = $object->fetch($id); |
||
1682 | if ($res < 0) { |
||
1683 | dol_print_error($db, $object->error); |
||
1684 | exit; |
||
1685 | } |
||
1686 | $res = $object->fetch_optionals(); |
||
1687 | if ($res < 0) { |
||
1688 | dol_print_error($db); |
||
1689 | exit; |
||
1690 | } |
||
1691 | |||
1692 | $adht = new AdherentType($db); |
||
1693 | $res = $adht->fetch($object->typeid); |
||
1694 | if ($res < 0) { |
||
1695 | dol_print_error($db); |
||
1696 | exit; |
||
1697 | } |
||
1698 | |||
1699 | /* |
||
1700 | * Show tabs |
||
1701 | */ |
||
1702 | $head = member_prepare_head($object); |
||
1703 | |||
1704 | print dol_get_fiche_head($head, 'general', $langs->trans("Member"), -1, 'user'); |
||
1705 | |||
1706 | // Confirm create user |
||
1707 | if ($action == 'create_user') { |
||
1708 | $login = (GETPOSTISSET('login') ? GETPOST('login', 'alphanohtml') : $object->login); |
||
1709 | if (empty($login)) { |
||
1710 | // Full firstname and name separated with a dot : firstname.name |
||
1711 | include_once DOL_DOCUMENT_ROOT . '/core/lib/functions2.lib.php'; |
||
1712 | $login = dol_buildlogin($object->lastname, $object->firstname); |
||
1713 | } |
||
1714 | if (empty($login)) { |
||
1715 | $login = strtolower(substr($object->firstname, 0, 4)) . strtolower(substr($object->lastname, 0, 4)); |
||
1716 | } |
||
1717 | |||
1718 | // Create a form array |
||
1719 | $formquestion = array( |
||
1720 | array('label' => $langs->trans("LoginToCreate"), 'type' => 'text', 'name' => 'login', 'value' => $login) |
||
1721 | ); |
||
1722 | if (isModEnabled('societe') && $object->socid > 0) { |
||
1723 | $object->fetch_thirdparty(); |
||
1724 | $formquestion[] = array('label' => $langs->trans("UserWillBe"), 'type' => 'radio', 'name' => 'internalorexternal', 'default' => 'external', 'values' => array('external' => $langs->trans("External") . ' - ' . $langs->trans("LinkedToDolibarrThirdParty") . ' ' . $object->thirdparty->getNomUrl(1, '', 0, 1), 'internal' => $langs->trans("Internal"))); |
||
1725 | } |
||
1726 | $text = ''; |
||
1727 | if (isModEnabled('societe') && $object->socid <= 0) { |
||
1728 | $text .= $langs->trans("UserWillBeInternalUser") . '<br>'; |
||
1729 | } |
||
1730 | $text .= $langs->trans("ConfirmCreateLogin"); |
||
1731 | print $form->formconfirm($_SERVER['PHP_SELF'] . "?rowid=" . $object->id, $langs->trans("CreateDolibarrLogin"), $text, "confirm_create_user", $formquestion, 'yes'); |
||
1732 | } |
||
1733 | |||
1734 | // Confirm create third party |
||
1735 | if ($action == 'create_thirdparty') { |
||
1736 | $companyalias = ''; |
||
1737 | $fullname = $object->getFullName($langs); |
||
1738 | |||
1739 | if ($object->morphy == 'mor') { |
||
1740 | $companyname = $object->company; |
||
1741 | if (!empty($fullname)) { |
||
1742 | $companyalias = $fullname; |
||
1743 | } |
||
1744 | } else { |
||
1745 | $companyname = $fullname; |
||
1746 | if (!empty($object->company)) { |
||
1747 | $companyalias = $object->company; |
||
1748 | } |
||
1749 | } |
||
1750 | |||
1751 | // Create a form array |
||
1752 | $formquestion = array( |
||
1753 | array('label' => $langs->trans("NameToCreate"), 'type' => 'text', 'name' => 'companyname', 'value' => $companyname, 'morecss' => 'minwidth300', 'moreattr' => 'maxlength="128"'), |
||
1754 | array('label' => $langs->trans("AliasNames"), 'type' => 'text', 'name' => 'companyalias', 'value' => $companyalias, 'morecss' => 'minwidth300', 'moreattr' => 'maxlength="128"') |
||
1755 | ); |
||
1756 | |||
1757 | print $form->formconfirm($_SERVER['PHP_SELF'] . "?rowid=" . $object->id, $langs->trans("CreateDolibarrThirdParty"), $langs->trans("ConfirmCreateThirdParty"), "confirm_create_thirdparty", $formquestion, 'yes'); |
||
1758 | } |
||
1759 | |||
1760 | // Confirm validate member |
||
1761 | if ($action == 'valid') { |
||
1762 | $langs->load("mails"); |
||
1763 | |||
1764 | $adht = new AdherentType($db); |
||
1765 | $adht->fetch($object->typeid); |
||
1766 | |||
1767 | $subject = ''; |
||
1768 | $msg = ''; |
||
1769 | |||
1770 | // Send subscription email |
||
1771 | include_once DOL_DOCUMENT_ROOT . '/core/class/html.formmail.class.php'; |
||
1772 | $formmail = new FormMail($db); |
||
1773 | // Set output language |
||
1774 | $outputlangs = new Translate('', $conf); |
||
1775 | $outputlangs->setDefaultLang(empty($object->thirdparty->default_lang) ? $mysoc->default_lang : $object->thirdparty->default_lang); |
||
1776 | // Load traductions files required by page |
||
1777 | $outputlangs->loadLangs(array("main", "members", "companies", "install", "other")); |
||
1778 | // Get email content from template |
||
1779 | $arraydefaultmessage = null; |
||
1780 | $labeltouse = getDolGlobalString("ADHERENT_EMAIL_TEMPLATE_MEMBER_VALIDATION"); |
||
1781 | |||
1782 | if (!empty($labeltouse)) { |
||
1783 | $arraydefaultmessage = $formmail->getEMailTemplate($db, 'member', $user, $outputlangs, 0, 1, $labeltouse); |
||
1784 | } |
||
1785 | |||
1786 | if (!empty($labeltouse) && is_object($arraydefaultmessage) && $arraydefaultmessage->id > 0) { |
||
1787 | $subject = $arraydefaultmessage->topic; |
||
1788 | $msg = $arraydefaultmessage->content; |
||
1789 | } |
||
1790 | |||
1791 | $substitutionarray = getCommonSubstitutionArray($outputlangs, 0, null, $object); |
||
1792 | complete_substitutions_array($substitutionarray, $outputlangs, $object); |
||
1793 | $subjecttosend = make_substitutions($subject, $substitutionarray, $outputlangs); |
||
1794 | $texttosend = make_substitutions(dol_concatdesc($msg, $adht->getMailOnValid()), $substitutionarray, $outputlangs); |
||
1795 | |||
1796 | $tmp = $langs->trans("SendingAnEMailToMember"); |
||
1797 | $tmp .= '<br>' . $langs->trans("MailFrom") . ': <b>' . getDolGlobalString('ADHERENT_MAIL_FROM') . '</b>, '; |
||
1798 | $tmp .= '<br>' . $langs->trans("MailRecipient") . ': <b>' . $object->email . '</b>'; |
||
1799 | $helpcontent = ''; |
||
1800 | $helpcontent .= '<b>' . $langs->trans("MailFrom") . '</b>: ' . getDolGlobalString('ADHERENT_MAIL_FROM') . '<br>' . "\n"; |
||
1801 | $helpcontent .= '<b>' . $langs->trans("MailRecipient") . '</b>: ' . $object->email . '<br>' . "\n"; |
||
1802 | $helpcontent .= '<b>' . $langs->trans("Subject") . '</b>:<br>' . "\n"; |
||
1803 | $helpcontent .= $subjecttosend . "\n"; |
||
1804 | $helpcontent .= "<br>"; |
||
1805 | $helpcontent .= '<b>' . $langs->trans("Content") . '</b>:<br>'; |
||
1806 | $helpcontent .= dol_htmlentitiesbr($texttosend) . "\n"; |
||
1807 | // @phan-suppress-next-line PhanPluginSuspiciousParamOrder |
||
1808 | $label = $form->textwithpicto($tmp, $helpcontent, 1, 'help'); |
||
1809 | |||
1810 | // Create form popup |
||
1811 | $formquestion = array(); |
||
1812 | if ($object->email) { |
||
1813 | $formquestion[] = array('type' => 'checkbox', 'name' => 'send_mail', 'label' => $label, 'value' => (getDolGlobalString('ADHERENT_DEFAULT_SENDINFOBYMAIL') ? true : false)); |
||
1814 | } |
||
1815 | if (isModEnabled('mailman') && getDolGlobalString('ADHERENT_USE_MAILMAN')) { |
||
1816 | $formquestion[] = array('type' => 'other', 'label' => $langs->transnoentitiesnoconv("SynchroMailManEnabled"), 'value' => ''); |
||
1817 | } |
||
1818 | if (isModEnabled('mailman') && getDolGlobalString('ADHERENT_USE_SPIP')) { |
||
1819 | $formquestion[] = array('type' => 'other', 'label' => $langs->transnoentitiesnoconv("SynchroSpipEnabled"), 'value' => ''); |
||
1820 | } |
||
1821 | print $form->formconfirm("card.php?rowid=" . $id, $langs->trans("ValidateMember"), $langs->trans("ConfirmValidateMember"), "confirm_valid", $formquestion, 'yes', 1, 220); |
||
1822 | } |
||
1823 | |||
1824 | // Confirm resiliate |
||
1825 | if ($action == 'resiliate') { |
||
1826 | $langs->load("mails"); |
||
1827 | |||
1828 | $adht = new AdherentType($db); |
||
1829 | $adht->fetch($object->typeid); |
||
1830 | |||
1831 | $subject = ''; |
||
1832 | $msg = ''; |
||
1833 | |||
1834 | // Send subscription email |
||
1835 | include_once DOL_DOCUMENT_ROOT . '/core/class/html.formmail.class.php'; |
||
1836 | $formmail = new FormMail($db); |
||
1837 | // Set output language |
||
1838 | $outputlangs = new Translate('', $conf); |
||
1839 | $outputlangs->setDefaultLang(empty($object->thirdparty->default_lang) ? $mysoc->default_lang : $object->thirdparty->default_lang); |
||
1840 | // Load traductions files required by page |
||
1841 | $outputlangs->loadLangs(array("main", "members")); |
||
1842 | // Get email content from template |
||
1843 | $arraydefaultmessage = null; |
||
1844 | $labeltouse = getDolGlobalString('ADHERENT_EMAIL_TEMPLATE_CANCELATION'); |
||
1845 | |||
1846 | if (!empty($labeltouse)) { |
||
1847 | $arraydefaultmessage = $formmail->getEMailTemplate($db, 'member', $user, $outputlangs, 0, 1, $labeltouse); |
||
1848 | } |
||
1849 | |||
1850 | if (!empty($labeltouse) && is_object($arraydefaultmessage) && $arraydefaultmessage->id > 0) { |
||
1851 | $subject = $arraydefaultmessage->topic; |
||
1852 | $msg = $arraydefaultmessage->content; |
||
1853 | } |
||
1854 | |||
1855 | $substitutionarray = getCommonSubstitutionArray($outputlangs, 0, null, $object); |
||
1856 | complete_substitutions_array($substitutionarray, $outputlangs, $object); |
||
1857 | $subjecttosend = make_substitutions($subject, $substitutionarray, $outputlangs); |
||
1858 | $texttosend = make_substitutions(dol_concatdesc($msg, $adht->getMailOnResiliate()), $substitutionarray, $outputlangs); |
||
1859 | |||
1860 | $tmp = $langs->trans("SendingAnEMailToMember"); |
||
1861 | $tmp .= '<br>(' . $langs->trans("MailFrom") . ': <b>' . getDolGlobalString('ADHERENT_MAIL_FROM') . '</b>, '; |
||
1862 | $tmp .= $langs->trans("MailRecipient") . ': <b>' . $object->email . '</b>)'; |
||
1863 | $helpcontent = ''; |
||
1864 | $helpcontent .= '<b>' . $langs->trans("MailFrom") . '</b>: ' . getDolGlobalString('ADHERENT_MAIL_FROM') . '<br>' . "\n"; |
||
1865 | $helpcontent .= '<b>' . $langs->trans("MailRecipient") . '</b>: ' . $object->email . '<br>' . "\n"; |
||
1866 | $helpcontent .= '<b>' . $langs->trans("Subject") . '</b>:<br>' . "\n"; |
||
1867 | $helpcontent .= $subjecttosend . "\n"; |
||
1868 | $helpcontent .= "<br>"; |
||
1869 | $helpcontent .= '<b>' . $langs->trans("Content") . '</b>:<br>'; |
||
1870 | $helpcontent .= dol_htmlentitiesbr($texttosend) . "\n"; |
||
1871 | // @phan-suppress-next-line PhanPluginSuspiciousParamOrder |
||
1872 | $label = $form->textwithpicto($tmp, $helpcontent, 1, 'help'); |
||
1873 | |||
1874 | // Create an array |
||
1875 | $formquestion = array(); |
||
1876 | if ($object->email) { |
||
1877 | $formquestion[] = array('type' => 'checkbox', 'name' => 'send_mail', 'label' => $label, 'value' => (getDolGlobalString('ADHERENT_DEFAULT_SENDINFOBYMAIL') ? 'true' : 'false')); |
||
1878 | } |
||
1879 | if ($backtopage) { |
||
1880 | $formquestion[] = array('type' => 'hidden', 'name' => 'backtopage', 'value' => ($backtopage != '1' ? $backtopage : $_SERVER["HTTP_REFERER"])); |
||
1881 | } |
||
1882 | print $form->formconfirm("card.php?rowid=" . $id, $langs->trans("ResiliateMember"), $langs->trans("ConfirmResiliateMember"), "confirm_resiliate", $formquestion, 'no', 1, 240); |
||
1883 | } |
||
1884 | |||
1885 | // Confirm exclude |
||
1886 | if ($action == 'exclude') { |
||
1887 | $langs->load("mails"); |
||
1888 | |||
1889 | $adht = new AdherentType($db); |
||
1890 | $adht->fetch($object->typeid); |
||
1891 | |||
1892 | $subject = ''; |
||
1893 | $msg = ''; |
||
1894 | |||
1895 | // Send subscription email |
||
1896 | include_once DOL_DOCUMENT_ROOT . '/core/class/html.formmail.class.php'; |
||
1897 | $formmail = new FormMail($db); |
||
1898 | // Set output language |
||
1899 | $outputlangs = new Translate('', $conf); |
||
1900 | $outputlangs->setDefaultLang(empty($object->thirdparty->default_lang) ? $mysoc->default_lang : $object->thirdparty->default_lang); |
||
1901 | // Load traductions files required by page |
||
1902 | $outputlangs->loadLangs(array("main", "members")); |
||
1903 | // Get email content from template |
||
1904 | $arraydefaultmessage = null; |
||
1905 | $labeltouse = getDolGlobalString('ADHERENT_EMAIL_TEMPLATE_EXCLUSION'); |
||
1906 | |||
1907 | if (!empty($labeltouse)) { |
||
1908 | $arraydefaultmessage = $formmail->getEMailTemplate($db, 'member', $user, $outputlangs, 0, 1, $labeltouse); |
||
1909 | } |
||
1910 | |||
1911 | if (!empty($labeltouse) && is_object($arraydefaultmessage) && $arraydefaultmessage->id > 0) { |
||
1912 | $subject = $arraydefaultmessage->topic; |
||
1913 | $msg = $arraydefaultmessage->content; |
||
1914 | } |
||
1915 | |||
1916 | $substitutionarray = getCommonSubstitutionArray($outputlangs, 0, null, $object); |
||
1917 | complete_substitutions_array($substitutionarray, $outputlangs, $object); |
||
1918 | $subjecttosend = make_substitutions($subject, $substitutionarray, $outputlangs); |
||
1919 | $texttosend = make_substitutions(dol_concatdesc($msg, $adht->getMailOnExclude()), $substitutionarray, $outputlangs); |
||
1920 | |||
1921 | $tmp = $langs->trans("SendingAnEMailToMember"); |
||
1922 | $tmp .= '<br>(' . $langs->trans("MailFrom") . ': <b>' . getDolGlobalString('ADHERENT_MAIL_FROM') . '</b>, '; |
||
1923 | $tmp .= $langs->trans("MailRecipient") . ': <b>' . $object->email . '</b>)'; |
||
1924 | $helpcontent = ''; |
||
1925 | $helpcontent .= '<b>' . $langs->trans("MailFrom") . '</b>: ' . getDolGlobalString('ADHERENT_MAIL_FROM') . '<br>' . "\n"; |
||
1926 | $helpcontent .= '<b>' . $langs->trans("MailRecipient") . '</b>: ' . $object->email . '<br>' . "\n"; |
||
1927 | $helpcontent .= '<b>' . $langs->trans("Subject") . '</b>:<br>' . "\n"; |
||
1928 | $helpcontent .= $subjecttosend . "\n"; |
||
1929 | $helpcontent .= "<br>"; |
||
1930 | $helpcontent .= '<b>' . $langs->trans("Content") . '</b>:<br>'; |
||
1931 | $helpcontent .= dol_htmlentitiesbr($texttosend) . "\n"; |
||
1932 | // @phan-suppress-next-line PhanPluginSuspiciousParamOrder |
||
1933 | $label = $form->textwithpicto($tmp, $helpcontent, 1, 'help'); |
||
1934 | |||
1935 | // Create an array |
||
1936 | $formquestion = array(); |
||
1937 | if ($object->email) { |
||
1938 | $formquestion[] = array('type' => 'checkbox', 'name' => 'send_mail', 'label' => $label, 'value' => (getDolGlobalString('ADHERENT_DEFAULT_SENDINFOBYMAIL') ? 'true' : 'false')); |
||
1939 | } |
||
1940 | if ($backtopage) { |
||
1941 | $formquestion[] = array('type' => 'hidden', 'name' => 'backtopage', 'value' => ($backtopage != '1' ? $backtopage : $_SERVER["HTTP_REFERER"])); |
||
1942 | } |
||
1943 | print $form->formconfirm("card.php?rowid=" . $id, $langs->trans("ExcludeMember"), $langs->trans("ConfirmExcludeMember"), "confirm_exclude", $formquestion, 'no', 1, 240); |
||
1944 | } |
||
1945 | |||
1946 | // Confirm remove member |
||
1947 | if ($action == 'delete') { |
||
1948 | $formquestion = array(); |
||
1949 | if ($backtopage) { |
||
1950 | $formquestion[] = array('type' => 'hidden', 'name' => 'backtopage', 'value' => ($backtopage != '1' ? $backtopage : $_SERVER["HTTP_REFERER"])); |
||
1951 | } |
||
1952 | print $form->formconfirm("card.php?rowid=" . $id, $langs->trans("DeleteMember"), $langs->trans("ConfirmDeleteMember"), "confirm_delete", $formquestion, 'no', 1); |
||
1953 | } |
||
1954 | |||
1955 | // Confirm add in spip |
||
1956 | if ($action == 'add_spip') { |
||
1957 | print $form->formconfirm("card.php?rowid=" . $id, $langs->trans('AddIntoSpip'), $langs->trans('AddIntoSpipConfirmation'), 'confirm_add_spip'); |
||
1958 | } |
||
1959 | // Confirm removed from spip |
||
1960 | if ($action == 'del_spip') { |
||
1961 | print $form->formconfirm("card.php?rowid=$id", $langs->trans('DeleteIntoSpip'), $langs->trans('DeleteIntoSpipConfirmation'), 'confirm_del_spip'); |
||
1962 | } |
||
1963 | |||
1964 | $rowspan = 17; |
||
1965 | if (!getDolGlobalString('ADHERENT_LOGIN_NOT_REQUIRED')) { |
||
1966 | $rowspan++; |
||
1967 | } |
||
1968 | if (isModEnabled('societe')) { |
||
1969 | $rowspan++; |
||
1970 | } |
||
1971 | |||
1972 | $linkback = '<a href="' . DOL_URL_ROOT . '/adherents/list.php?restore_lastsearch_values=1">' . $langs->trans("BackToList") . '</a>'; |
||
1973 | |||
1974 | $morehtmlref = '<a href="' . DOL_URL_ROOT . '/adherents/vcard.php?id=' . $object->id . '" class="refid">'; |
||
1975 | $morehtmlref .= img_picto($langs->trans("Download") . ' ' . $langs->trans("VCard"), 'vcard.png', 'class="valignmiddle marginleftonly paddingrightonly"'); |
||
1976 | $morehtmlref .= '</a>'; |
||
1977 | |||
1978 | |||
1979 | dol_banner_tab($object, 'rowid', $linkback, 1, 'rowid', 'ref', $morehtmlref); |
||
1980 | |||
1981 | print '<div class="fichecenter">'; |
||
1982 | print '<div class="fichehalfleft">'; |
||
1983 | |||
1984 | print '<div class="underbanner clearboth"></div>'; |
||
1985 | print '<table class="border tableforfield centpercent">'; |
||
1986 | |||
1987 | // Login |
||
1988 | if (!getDolGlobalString('ADHERENT_LOGIN_NOT_REQUIRED')) { |
||
1989 | print '<tr><td class="titlefield">' . $langs->trans("Login") . ' / ' . $langs->trans("Id") . '</td><td class="valeur">' . dol_escape_htmltag($object->login) . '</td></tr>'; |
||
1990 | } |
||
1991 | |||
1992 | // Type |
||
1993 | print '<tr><td class="titlefield">' . $langs->trans("Type") . '</td>'; |
||
1994 | print '<td class="valeur">' . $adht->getNomUrl(1) . "</td></tr>\n"; |
||
1995 | |||
1996 | // Morphy |
||
1997 | print '<tr><td>' . $langs->trans("MemberNature") . '</td>'; |
||
1998 | print '<td class="valeur" >' . $object->getmorphylib('', 1) . '</td>'; |
||
1999 | print '</tr>'; |
||
2000 | |||
2001 | // Company |
||
2002 | print '<tr><td>' . $langs->trans("Company") . '</td><td class="valeur">' . dol_escape_htmltag($object->company) . '</td></tr>'; |
||
2003 | |||
2004 | // Civility |
||
2005 | print '<tr><td>' . $langs->trans("UserTitle") . '</td><td class="valeur">' . $object->getCivilityLabel() . '</td>'; |
||
2006 | print '</tr>'; |
||
2007 | |||
2008 | // Password |
||
2009 | if (!getDolGlobalString('ADHERENT_LOGIN_NOT_REQUIRED')) { |
||
2010 | print '<tr><td>' . $langs->trans("Password") . '</td><td>'; |
||
2011 | if ($object->pass) { |
||
2012 | print preg_replace('/./i', '*', $object->pass); |
||
2013 | } else { |
||
2014 | if ($user->admin) { |
||
2015 | print '<!-- ' . $langs->trans("Crypted") . ': ' . $object->pass_indatabase_crypted . ' -->'; |
||
2016 | } |
||
2017 | print '<span class="opacitymedium">' . $langs->trans("Hidden") . '</span>'; |
||
2018 | } |
||
2019 | if (!empty($object->pass_indatabase) && empty($object->user_id)) { // Show warning only for old password still in clear (does not happen anymore) |
||
2020 | $langs->load("errors"); |
||
2021 | $htmltext = $langs->trans("WarningPasswordSetWithNoAccount"); |
||
2022 | print ' ' . $form->textwithpicto('', $htmltext, 1, 'warning'); |
||
2023 | } |
||
2024 | print '</td></tr>'; |
||
2025 | } |
||
2026 | |||
2027 | // Date end subscription |
||
2028 | print '<tr><td>' . $langs->trans("SubscriptionEndDate") . '</td><td class="valeur">'; |
||
2029 | if ($object->datefin) { |
||
2030 | print dol_print_date($object->datefin, 'day'); |
||
2031 | if ($object->hasDelay()) { |
||
2032 | print " " . img_warning($langs->trans("Late")); |
||
2033 | } |
||
2034 | } else { |
||
2035 | if ($object->need_subscription == 0) { |
||
2036 | print $langs->trans("SubscriptionNotNeeded"); |
||
2037 | } elseif (!$adht->subscription) { |
||
2038 | print $langs->trans("SubscriptionNotRecorded"); |
||
2039 | if (Adherent::STATUS_VALIDATED == $object->statut) { |
||
2040 | print " " . img_warning($langs->trans("Late")); // displays delay Pictogram only if not a draft, not excluded and not resiliated |
||
2041 | } |
||
2042 | } else { |
||
2043 | print $langs->trans("SubscriptionNotReceived"); |
||
2044 | if (Adherent::STATUS_VALIDATED == $object->statut) { |
||
2045 | print " " . img_warning($langs->trans("Late")); // displays delay Pictogram only if not a draft, not excluded and not resiliated |
||
2046 | } |
||
2047 | } |
||
2048 | } |
||
2049 | print '</td></tr>'; |
||
2050 | |||
2051 | print '</table>'; |
||
2052 | |||
2053 | print '</div>'; |
||
2054 | |||
2055 | print '<div class="fichehalfright">'; |
||
2056 | print '<div class="underbanner clearboth"></div>'; |
||
2057 | |||
2058 | print '<table class="border tableforfield centpercent">'; |
||
2059 | |||
2060 | // Tags / Categories |
||
2061 | if (isModEnabled('category') && $user->hasRight('categorie', 'lire')) { |
||
2062 | print '<tr><td>' . $langs->trans("Categories") . '</td>'; |
||
2063 | print '<td colspan="2">'; |
||
2064 | print $form->showCategories($object->id, Categorie::TYPE_MEMBER, 1); |
||
2065 | print '</td></tr>'; |
||
2066 | } |
||
2067 | |||
2068 | // Birth Date |
||
2069 | print '<tr><td class="titlefield">' . $langs->trans("DateOfBirth") . '</td><td class="valeur">' . dol_print_date($object->birth, 'day') . '</td></tr>'; |
||
2070 | |||
2071 | // Default language |
||
2072 | if (getDolGlobalInt('MAIN_MULTILANGS')) { |
||
2073 | require_once DOL_DOCUMENT_ROOT . '/core/lib/functions2.lib.php'; |
||
2074 | print '<tr><td>' . $langs->trans("DefaultLang") . '</td><td>'; |
||
2075 | //$s=picto_from_langcode($object->default_lang); |
||
2076 | //print ($s?$s.' ':''); |
||
2077 | $langs->load("languages"); |
||
2078 | $labellang = ($object->default_lang ? $langs->trans('Language_' . $object->default_lang) : ''); |
||
2079 | print picto_from_langcode($object->default_lang, 'class="paddingrightonly saturatemedium opacitylow"'); |
||
2080 | print $labellang; |
||
2081 | print '</td></tr>'; |
||
2082 | } |
||
2083 | |||
2084 | // Public |
||
2085 | print '<tr><td>'; |
||
2086 | $htmltext = $langs->trans("Public", getDolGlobalString('MAIN_INFO_SOCIETE_NOM'), $linkofpubliclist); |
||
2087 | print $form->textwithpicto($langs->trans("MembershipPublic"), $htmltext, 1, 'help', '', 0, 3, 'membershippublic'); |
||
2088 | print '</td><td class="valeur">' . yn($object->public) . '</td></tr>'; |
||
2089 | |||
2090 | // Other attributes |
||
2091 | include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_view.tpl.php'; |
||
2092 | |||
2093 | // Third party Dolibarr |
||
2094 | if (isModEnabled('societe')) { |
||
2095 | print '<tr><td>'; |
||
2096 | $editenable = $user->hasRight('adherent', 'creer'); |
||
2097 | print $form->editfieldkey('LinkedToDolibarrThirdParty', 'thirdparty', '', $object, $editenable); |
||
2098 | print '</td><td colspan="2" class="valeur">'; |
||
2099 | if ($action == 'editthirdparty') { |
||
2100 | $htmlname = 'socid'; |
||
2101 | print '<form method="POST" action="' . $_SERVER['PHP_SELF'] . '" name="form' . $htmlname . '">'; |
||
2102 | print '<input type="hidden" name="rowid" value="' . $object->id . '">'; |
||
2103 | print '<input type="hidden" name="action" value="set' . $htmlname . '">'; |
||
2104 | print '<input type="hidden" name="token" value="' . newToken() . '">'; |
||
2105 | print '<table class="nobordernopadding">'; |
||
2106 | print '<tr><td>'; |
||
2107 | print $form->select_company($object->socid, 'socid', '', 1); |
||
2108 | print '</td>'; |
||
2109 | print '<td class="left"><input type="submit" class="button button-edit" value="' . $langs->trans("Modify") . '"></td>'; |
||
2110 | print '</tr></table></form>'; |
||
2111 | } else { |
||
2112 | if ($object->socid) { |
||
2113 | $company = new Societe($db); |
||
2114 | $result = $company->fetch($object->socid); |
||
2115 | print $company->getNomUrl(1); |
||
2116 | |||
2117 | // Show link to invoices |
||
2118 | $tmparray = $company->getOutstandingBills('customer'); |
||
2119 | if (!empty($tmparray['refs'])) { |
||
2120 | print ' - ' . img_picto($langs->trans("Invoices"), 'bill', 'class="paddingright"') . '<a href="' . DOL_URL_ROOT . '/compta/facture/list.php?socid=' . $object->socid . '">' . $langs->trans("Invoices") . ' (' . count($tmparray['refs']) . ')'; |
||
2121 | // TODO Add alert if warning on at least one invoice late |
||
2122 | print '</a>'; |
||
2123 | } |
||
2124 | } else { |
||
2125 | print '<span class="opacitymedium">' . $langs->trans("NoThirdPartyAssociatedToMember") . '</span>'; |
||
2126 | } |
||
2127 | } |
||
2128 | print '</td></tr>'; |
||
2129 | } |
||
2130 | |||
2131 | // Login Dolibarr - Link to user |
||
2132 | print '<tr><td>'; |
||
2133 | $editenable = $user->hasRight('adherent', 'creer') && $user->hasRight('user', 'user', 'creer'); |
||
2134 | print $form->editfieldkey('LinkedToDolibarrUser', 'login', '', $object, $editenable); |
||
2135 | print '</td><td colspan="2" class="valeur">'; |
||
2136 | if ($action == 'editlogin') { |
||
2137 | $form->form_users($_SERVER['PHP_SELF'] . '?rowid=' . $object->id, $object->user_id, 'userid', ''); |
||
2138 | } else { |
||
2139 | if ($object->user_id) { |
||
2140 | $linkeduser = new User($db); |
||
2141 | $linkeduser->fetch($object->user_id); |
||
2142 | print $linkeduser->getNomUrl(-1); |
||
2143 | } else { |
||
2144 | print '<span class="opacitymedium">' . $langs->trans("NoDolibarrAccess") . '</span>'; |
||
2145 | } |
||
2146 | } |
||
2147 | print '</td></tr>'; |
||
2148 | |||
2149 | print "</table>\n"; |
||
2150 | |||
2151 | print "</div></div>\n"; |
||
2152 | print '<div class="clearboth"></div>'; |
||
2153 | |||
2154 | print dol_get_fiche_end(); |
||
2155 | |||
2156 | |||
2157 | /* |
||
2158 | * Action bar |
||
2159 | */ |
||
2160 | |||
2161 | print '<div class="tabsAction">'; |
||
2162 | $isinspip = 0; |
||
2163 | $parameters = array(); |
||
2164 | $reshook = $hookmanager->executeHooks('addMoreActionsButtons', $parameters, $object, $action); // Note that $action and $object may have been |
||
2165 | if (empty($reshook)) { |
||
2166 | if ($action != 'editlogin' && $action != 'editthirdparty') { |
||
2167 | // Send |
||
2168 | if (empty($user->socid)) { |
||
2169 | if (Adherent::STATUS_VALIDATED == $object->statut) { |
||
2170 | print '<a class="butAction" href="' . $_SERVER['PHP_SELF'] . '?id=' . ((int) $object->id) . '&action=presend&mode=init#formmailbeforetitle">' . $langs->trans('SendMail') . '</a>' . "\n"; |
||
2171 | } |
||
2172 | } |
||
2173 | |||
2174 | // Send card by email |
||
2175 | // TODO Remove this to replace with a template |
||
2176 | /* |
||
2177 | if ($user->hasRight('adherent', 'creer')) { |
||
2178 | if (Adherent::STATUS_VALIDATED == $object->statut) { |
||
2179 | if ($object->email) print '<a class="butAction" href="card.php?rowid='.$object->id.'&action=sendinfo">'.$langs->trans("SendCardByMail")."</a>\n"; |
||
2180 | else print '<a class="butActionRefused classfortooltip" href="#" title="'.dol_escape_htmltag($langs->trans("NoEMail")).'">'.$langs->trans("SendCardByMail")."</a>\n"; |
||
2181 | } else { |
||
2182 | print '<span class="butActionRefused classfortooltip" title="'.dol_escape_htmltag($langs->trans("ValidateBefore")).'">'.$langs->trans("SendCardByMail")."</span>"; |
||
2183 | } |
||
2184 | } else { |
||
2185 | print '<span class="butActionRefused classfortooltip" title="'.dol_escape_htmltag($langs->trans("NotEnoughPermissions")).'">'.$langs->trans("SendCardByMail")."</span>"; |
||
2186 | }*/ |
||
2187 | |||
2188 | // Modify |
||
2189 | if ($user->hasRight('adherent', 'creer')) { |
||
2190 | print '<a class="butAction" href="card.php?rowid=' . ((int) $object->id) . '&action=edit&token=' . newToken() . '">' . $langs->trans("Modify") . '</a>' . "\n"; |
||
2191 | } else { |
||
2192 | print '<span class="butActionRefused classfortooltip" title="' . dol_escape_htmltag($langs->trans("NotEnoughPermissions")) . '">' . $langs->trans("Modify") . '</span>' . "\n"; |
||
2193 | } |
||
2194 | |||
2195 | // Validate |
||
2196 | if (Adherent::STATUS_DRAFT == $object->statut) { |
||
2197 | if ($user->hasRight('adherent', 'creer')) { |
||
2198 | print '<a class="butAction" href="card.php?rowid=' . ((int) $object->id) . '&action=valid&token=' . newToken() . '">' . $langs->trans("Validate") . '</a>' . "\n"; |
||
2199 | } else { |
||
2200 | print '<span class="butActionRefused classfortooltip" title="' . dol_escape_htmltag($langs->trans("NotEnoughPermissions")) . '">' . $langs->trans("Validate") . '</span>' . "\n"; |
||
2201 | } |
||
2202 | } |
||
2203 | |||
2204 | // Reactivate |
||
2205 | if (Adherent::STATUS_RESILIATED == $object->statut || Adherent::STATUS_EXCLUDED == $object->statut) { |
||
2206 | if ($user->hasRight('adherent', 'creer')) { |
||
2207 | print '<a class="butAction" href="card.php?rowid=' . ((int) $object->id) . '&action=valid">' . $langs->trans("Reenable") . "</a>\n"; |
||
2208 | } else { |
||
2209 | print '<span class="butActionRefused classfortooltip" title="' . dol_escape_htmltag($langs->trans("NotEnoughPermissions")) . '">' . $langs->trans("Reenable") . '</span>' . "\n"; |
||
2210 | } |
||
2211 | } |
||
2212 | |||
2213 | // Resiliate |
||
2214 | if (Adherent::STATUS_VALIDATED == $object->statut) { |
||
2215 | if ($user->hasRight('adherent', 'supprimer')) { |
||
2216 | print '<a class="butAction" href="card.php?rowid=' . ((int) $object->id) . '&action=resiliate">' . $langs->trans("Resiliate") . "</a></span>\n"; |
||
2217 | } else { |
||
2218 | print '<span class="butActionRefused classfortooltip" title="' . dol_escape_htmltag($langs->trans("NotEnoughPermissions")) . '">' . $langs->trans("Resiliate") . '</span>' . "\n"; |
||
2219 | } |
||
2220 | } |
||
2221 | |||
2222 | // Exclude |
||
2223 | if (Adherent::STATUS_VALIDATED == $object->statut) { |
||
2224 | if ($user->hasRight('adherent', 'supprimer')) { |
||
2225 | print '<a class="butAction" href="card.php?rowid=' . ((int) $object->id) . '&action=exclude">' . $langs->trans("Exclude") . "</a></span>\n"; |
||
2226 | } else { |
||
2227 | print '<span class="butActionRefused classfortooltip" title="' . dol_escape_htmltag($langs->trans("NotEnoughPermissions")) . '">' . $langs->trans("Exclude") . '</span>' . "\n"; |
||
2228 | } |
||
2229 | } |
||
2230 | |||
2231 | // Create third party |
||
2232 | if (isModEnabled('societe') && !$object->socid) { |
||
2233 | if ($user->hasRight('societe', 'creer')) { |
||
2234 | if (Adherent::STATUS_DRAFT != $object->statut) { |
||
2235 | print '<a class="butAction" href="' . $_SERVER['PHP_SELF'] . '?rowid=' . ((int) $object->id) . '&action=create_thirdparty" title="' . dol_escape_htmltag($langs->trans("CreateDolibarrThirdPartyDesc")) . '">' . $langs->trans("CreateDolibarrThirdParty") . '</a>' . "\n"; |
||
2236 | } else { |
||
2237 | print '<a class="butActionRefused classfortooltip" href="#" title="' . dol_escape_htmltag($langs->trans("ValidateBefore")) . '">' . $langs->trans("CreateDolibarrThirdParty") . '</a>' . "\n"; |
||
2238 | } |
||
2239 | } else { |
||
2240 | print '<span class="butActionRefused classfortooltip" title="' . dol_escape_htmltag($langs->trans("NotEnoughPermissions")) . '">' . $langs->trans("CreateDolibarrThirdParty") . '</span>' . "\n"; |
||
2241 | } |
||
2242 | } |
||
2243 | |||
2244 | // Create user |
||
2245 | if (!$user->socid && !$object->user_id) { |
||
2246 | if ($user->hasRight('user', 'user', 'creer')) { |
||
2247 | if (Adherent::STATUS_DRAFT != $object->statut) { |
||
2248 | print '<a class="butAction" href="' . $_SERVER['PHP_SELF'] . '?rowid=' . ((int) $object->id) . '&action=create_user" title="' . dol_escape_htmltag($langs->trans("CreateDolibarrLoginDesc")) . '">' . $langs->trans("CreateDolibarrLogin") . '</a>' . "\n"; |
||
2249 | } else { |
||
2250 | print '<a class="butActionRefused classfortooltip" href="#" title="' . dol_escape_htmltag($langs->trans("ValidateBefore")) . '">' . $langs->trans("CreateDolibarrLogin") . '</a>' . "\n"; |
||
2251 | } |
||
2252 | } else { |
||
2253 | print '<span class="butActionRefused classfortooltip" title="' . dol_escape_htmltag($langs->trans("NotEnoughPermissions")) . '">' . $langs->trans("CreateDolibarrLogin") . '</span>' . "\n"; |
||
2254 | } |
||
2255 | } |
||
2256 | |||
2257 | // Action SPIP |
||
2258 | if (isModEnabled('mailmanspip') && getDolGlobalString('ADHERENT_USE_SPIP')) { |
||
2259 | $isinspip = $mailmanspip->is_in_spip($object); |
||
2260 | |||
2261 | if ($isinspip == 1) { |
||
2262 | print '<a class="butAction" href="card.php?rowid=' . ((int) $object->id) . '&action=del_spip&token=' . newToken() . '">' . $langs->trans("DeleteIntoSpip") . '</a>' . "\n"; |
||
2263 | } |
||
2264 | if ($isinspip == 0) { |
||
2265 | print '<a class="butAction" href="card.php?rowid=' . ((int) $object->id) . '&action=add_spip&token=' . newToken() . '">' . $langs->trans("AddIntoSpip") . '</a>' . "\n"; |
||
2266 | } |
||
2267 | } |
||
2268 | |||
2269 | // Delete |
||
2270 | if ($user->hasRight('adherent', 'supprimer')) { |
||
2271 | print '<a class="butActionDelete" href="card.php?rowid=' . ((int) $object->id) . '&action=delete&token=' . newToken() . '">' . $langs->trans("Delete") . '</a>' . "\n"; |
||
2272 | } else { |
||
2273 | print '<span class="butActionRefused classfortooltip" title="' . dol_escape_htmltag($langs->trans("NotEnoughPermissions")) . '">' . $langs->trans("Delete") . '</span>' . "\n"; |
||
2274 | } |
||
2275 | } |
||
2276 | } |
||
2277 | print '</div>'; |
||
2278 | |||
2279 | if ($isinspip == -1) { |
||
2280 | print '<br><br><span class="error">' . $langs->trans('SPIPConnectionFailed') . ': ' . $mailmanspip->error . '</span>'; |
||
2281 | } |
||
2282 | |||
2283 | |||
2284 | // Select mail models is same action as presend |
||
2285 | if (GETPOST('modelselected')) { |
||
2286 | $action = 'presend'; |
||
2287 | } |
||
2288 | |||
2289 | if ($action != 'presend') { |
||
2290 | print '<div class="fichecenter"><div class="fichehalfleft">'; |
||
2291 | print '<a name="builddoc"></a>'; // ancre |
||
2292 | |||
2293 | // Generated documents |
||
2294 | $filename = dol_sanitizeFileName($object->ref); |
||
2295 | $filedir = $conf->adherent->dir_output . '/' . get_exdir(0, 0, 0, 1, $object, 'member'); |
||
2296 | $urlsource = $_SERVER['PHP_SELF'] . '?id=' . $object->id; |
||
2297 | $genallowed = $user->hasRight('adherent', 'lire'); |
||
2298 | $delallowed = $user->hasRight('adherent', 'creer'); |
||
2299 | |||
2300 | print $formfile->showdocuments('member', $filename, $filedir, $urlsource, $genallowed, $delallowed, $object->model_pdf, 1, 0, 0, 28, 0, '', '', '', (empty($object->default_lang) ? '' : $object->default_lang), '', $object); |
||
2301 | $somethingshown = $formfile->numoffiles; |
||
2302 | |||
2303 | // Show links to link elements |
||
2304 | //$linktoelem = $form->showLinkToObjectBlock($object, null, array('subscription')); |
||
2305 | //$somethingshown = $form->showLinkedObjectBlock($object, ''); |
||
2306 | |||
2307 | // Show links to link elements |
||
2308 | /*$linktoelem = $form->showLinkToObjectBlock($object,array('order')); |
||
2309 | if ($linktoelem) { |
||
2310 | print ($somethingshown?'':'<br>').$linktoelem; |
||
2311 | } |
||
2312 | */ |
||
2313 | |||
2314 | // Show online payment link |
||
2315 | $useonlinepayment = (isModEnabled('paypal') || isModEnabled('stripe') || isModEnabled('paybox')); |
||
2316 | |||
2317 | $parameters = array(); |
||
2318 | $reshook = $hookmanager->executeHooks('doShowOnlinePaymentUrl', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks |
||
2319 | if ($reshook < 0) { |
||
2320 | setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); |
||
2321 | } else { |
||
2322 | $useonlinepayment = $reshook; |
||
2323 | } |
||
2324 | |||
2325 | if ($useonlinepayment) { |
||
2326 | print '<br>'; |
||
2327 | if (empty($amount)) { // Take the maximum amount among what the member is supposed to pay / has paid in the past |
||
2328 | $amount = max($adht->amount, $object->first_subscription_amount, $object->last_subscription_amount); |
||
2329 | } |
||
2330 | if (empty($amount)) { |
||
2331 | $amount = 0; |
||
2332 | } |
||
2333 | require_once DOL_DOCUMENT_ROOT . '/core/lib/payments.lib.php'; |
||
2334 | print showOnlinePaymentUrl('membersubscription', $object->ref, $amount); |
||
2335 | } |
||
2336 | |||
2337 | print '</div><div class="fichehalfright">'; |
||
2338 | |||
2339 | $MAX = 10; |
||
2340 | |||
2341 | $morehtmlcenter = dolGetButtonTitle($langs->trans('SeeAll'), '', 'fa fa-bars imgforviewmode', DOL_URL_ROOT . '/adherents/agenda.php?id=' . $object->id); |
||
2342 | |||
2343 | // List of actions on element |
||
2344 | include_once DOL_DOCUMENT_ROOT . '/core/class/html.formactions.class.php'; |
||
2345 | $formactions = new FormActions($db); |
||
2346 | $somethingshown = $formactions->showactions($object, $object->element, $socid, 1, 'listactions', $MAX, '', $morehtmlcenter); |
||
2347 | |||
2348 | print '</div></div>'; |
||
2349 | } |
||
2350 | |||
2351 | // Presend form |
||
2352 | $modelmail = 'member'; |
||
2353 | $defaulttopic = 'CardContent'; |
||
2354 | $diroutput = $conf->adherent->dir_output; |
||
2355 | $trackid = 'mem' . $object->id; |
||
2356 | |||
2357 | include DOL_DOCUMENT_ROOT . '/core/tpl/card_presend.tpl.php'; |
||
2358 | } |
||
2359 | } |
||
2360 | |||
2361 | // End of page |
||
2362 | llxFooter(); |
||
2363 | $db->close(); |
||
2364 | } |
||
2365 | |||
2366 | /** |
||
2367 | * \file htdocs/adherents/document.php |
||
2368 | * \brief Tab for documents linked to third party |
||
2369 | * \ingroup societe |
||
2370 | */ |
||
2371 | public function document() |
||
2549 | } |
||
2550 | |||
2551 | /** |
||
2552 | * \file htdocs/adherents/index.php |
||
2553 | * \ingroup member |
||
2554 | * \brief Home page of membership module |
||
2555 | */ |
||
2556 | public function index() |
||
2557 | { |
||
2558 | global $conf; |
||
2559 | global $db; |
||
2560 | global $user; |
||
2561 | global $hookmanager; |
||
2562 | global $user; |
||
2563 | global $menumanager; |
||
2564 | global $langs; |
||
2565 | |||
2566 | // Load translation files required by the page |
||
2567 | $langs->loadLangs(["companies", "members"]); |
||
2568 | |||
2569 | // $hookmanager = new HookManager($db); |
||
2570 | |||
2571 | // Initialize technical object to manage hooks. Note that conf->hooks_modules contains array |
||
2572 | $hookmanager->initHooks(['membersindex']); |
||
2573 | |||
2574 | // Security check |
||
2575 | $result = restrictedArea($user, 'adherent'); |
||
2576 | |||
2577 | /* |
||
2578 | * Actions |
||
2579 | */ |
||
2580 | |||
2581 | $userid = GETPOSTINT('userid'); |
||
2582 | if (GETPOST('addbox')) { |
||
2583 | // Add box (when submit is done from a form when ajax disabled) |
||
2584 | require_once DOL_DOCUMENT_ROOT . '/core/class/infobox.class.php'; |
||
2585 | $zone = GETPOSTINT('areacode'); |
||
2586 | $boxorder = GETPOST('boxorder', 'aZ09'); |
||
2587 | $boxorder .= GETPOST('boxcombo', 'aZ09'); |
||
2588 | $result = InfoBox::saveboxorder($db, $zone, $boxorder, $userid); |
||
2589 | if ($result > 0) { |
||
2590 | setEventMessages($langs->trans("BoxAdded"), null); |
||
2591 | } |
||
2592 | } |
||
2593 | |||
2594 | /* |
||
2595 | * View |
||
2596 | */ |
||
2597 | |||
2598 | $form = new Form($db); |
||
2599 | |||
2600 | // Load $resultboxes (selectboxlist + boxactivated + boxlista + boxlistb) |
||
2601 | $resultboxes = FormOther::getBoxesArea($user, "2"); |
||
2602 | |||
2603 | llxHeader('', $langs->trans("Members"), 'EN:Module_Foundations|FR:Module_Adhérents|ES:Módulo_Miembros|DE:Modul_Mitglieder'); |
||
2604 | |||
2605 | $staticmember = new Adherent($db); |
||
2606 | $statictype = new AdherentType($db); |
||
2607 | $subscriptionstatic = new Subscription($db); |
||
2608 | |||
2609 | print load_fiche_titre($langs->trans("MembersArea"), $resultboxes['selectboxlist'], 'members'); |
||
2610 | |||
2611 | /* |
||
2612 | * Statistics |
||
2613 | */ |
||
2614 | |||
2615 | $boxgraph = ''; |
||
2616 | if ($conf->use_javascript_ajax) { |
||
2617 | $year = date('Y'); |
||
2618 | $numberyears = getDolGlobalInt("MAIN_NB_OF_YEAR_IN_MEMBERSHIP_WIDGET_GRAPH"); |
||
2619 | |||
2620 | $boxgraph .= '<div class="div-table-responsive-no-min">'; |
||
2621 | $boxgraph .= '<table class="noborder nohover centpercent">'; |
||
2622 | $boxgraph .= '<tr class="liste_titre"><th colspan="2">' . $langs->trans("Statistics") . ($numberyears ? ' (' . ($year - $numberyears) . ' - ' . $year . ')' : '') . '</th></tr>'; |
||
2623 | $boxgraph .= '<tr><td class="center" colspan="2">'; |
||
2624 | |||
2625 | $stats = new AdherentStats($db, 0, $userid); |
||
2626 | |||
2627 | // Show array |
||
2628 | $sumMembers = $stats->countMembersByTypeAndStatus($numberyears); |
||
2629 | if (is_array($sumMembers) && !empty($sumMembers)) { |
||
2630 | $total = $sumMembers['total']['members_draft'] + $sumMembers['total']['members_pending'] + $sumMembers['total']['members_uptodate'] + $sumMembers['total']['members_expired'] + $sumMembers['total']['members_excluded'] + $sumMembers['total']['members_resiliated']; |
||
2631 | } else { |
||
2632 | $total = 0; |
||
2633 | } |
||
2634 | foreach (['members_draft', 'members_pending', 'members_uptodate', 'members_expired', 'members_excluded', 'members_resiliated'] as $val) { |
||
2635 | if (empty($sumMembers['total'][$val])) { |
||
2636 | $sumMembers['total'][$val] = 0; |
||
2637 | } |
||
2638 | } |
||
2639 | |||
2640 | $dataseries = []; |
||
2641 | $dataseries[] = [$langs->transnoentitiesnoconv("MembersStatusToValid"), $sumMembers['total']['members_draft']]; // Draft, not yet validated |
||
2642 | $dataseries[] = [$langs->transnoentitiesnoconv("WaitingSubscription"), $sumMembers['total']['members_pending']]; |
||
2643 | $dataseries[] = [$langs->transnoentitiesnoconv("UpToDate"), $sumMembers['total']['members_uptodate']]; |
||
2644 | $dataseries[] = [$langs->transnoentitiesnoconv("OutOfDate"), $sumMembers['total']['members_expired']]; |
||
2645 | $dataseries[] = [$langs->transnoentitiesnoconv("MembersStatusExcluded"), $sumMembers['total']['members_excluded']]; |
||
2646 | $dataseries[] = [$langs->transnoentitiesnoconv("MembersStatusResiliated"), $sumMembers['total']['members_resiliated']]; |
||
2647 | |||
2648 | include DOL_DOCUMENT_ROOT . '/theme/' . $conf->theme . '/theme_vars.inc.php'; |
||
2649 | |||
2650 | include_once DOL_DOCUMENT_ROOT . '/core/class/dolgraph.class.php'; |
||
2651 | $dolgraph = new DolGraph(); |
||
2652 | $dolgraph->SetData($dataseries); |
||
2653 | $dolgraph->SetDataColor(['-' . $badgeStatus0, $badgeStatus1, $badgeStatus4, $badgeStatus8, '-' . $badgeStatus8, $badgeStatus6]); |
||
2654 | $dolgraph->setShowLegend(2); |
||
2655 | $dolgraph->setShowPercent(1); |
||
2656 | $dolgraph->SetType(['pie']); |
||
2657 | $dolgraph->setHeight('200'); |
||
2658 | $dolgraph->draw('idgraphstatus'); |
||
2659 | $boxgraph .= $dolgraph->show($total ? 0 : 1); |
||
2660 | |||
2661 | $boxgraph .= '</td></tr>'; |
||
2662 | $boxgraph .= '<tr class="liste_total"><td>' . $langs->trans("Total") . '</td><td class="right">'; |
||
2663 | $boxgraph .= $total; |
||
2664 | $boxgraph .= '</td></tr>'; |
||
2665 | $boxgraph .= '</table>'; |
||
2666 | $boxgraph .= '</div>'; |
||
2667 | $boxgraph .= '<br>'; |
||
2668 | } |
||
2669 | |||
2670 | // boxes |
||
2671 | print '<div class="clearboth"></div>'; |
||
2672 | print '<div class="fichecenter fichecenterbis">'; |
||
2673 | |||
2674 | print '<div class="twocolumns">'; |
||
2675 | |||
2676 | print '<div class="firstcolumn fichehalfleft boxhalfleft" id="boxhalfleft">'; |
||
2677 | |||
2678 | print $boxgraph; |
||
2679 | |||
2680 | print $resultboxes['boxlista']; |
||
2681 | |||
2682 | print '</div>' . "\n"; |
||
2683 | |||
2684 | print '<div class="secondcolumn fichehalfright boxhalfright" id="boxhalfright">'; |
||
2685 | |||
2686 | print $resultboxes['boxlistb']; |
||
2687 | |||
2688 | print '</div>' . "\n"; |
||
2689 | |||
2690 | print '</div>'; |
||
2691 | print '</div>'; |
||
2692 | |||
2693 | $parameters = ['user' => $user]; |
||
2694 | $reshook = $hookmanager->executeHooks('dashboardMembers', $parameters, $object); // Note that $action and $object may have been modified by hook |
||
2695 | |||
2696 | // End of page |
||
2697 | llxFooter(); |
||
2698 | $db->close(); |
||
2699 | } |
||
2700 | |||
2701 | /** |
||
2702 | * \file htdocs/adherents/ldap.php |
||
2703 | * \ingroup ldap member |
||
2704 | * \brief Page fiche LDAP adherent |
||
2705 | */ |
||
2706 | public function ldap() |
||
2907 | } |
||
2908 | |||
2909 | /** |
||
2910 | * \file htdocs/adherents/list.php |
||
2911 | * \ingroup member |
||
2912 | * \brief Page to list all members of foundation |
||
2913 | */ |
||
2914 | public function list() |
||
2915 | { |
||
2916 | global $conf; |
||
2917 | global $db; |
||
2918 | global $user; |
||
2919 | global $hookmanager; |
||
2920 | global $user; |
||
2921 | global $menumanager; |
||
2922 | global $langs; |
||
2923 | |||
2924 | // Load translation files required by the page |
||
2925 | $langs->loadLangs(["members", "companies", "categories"]); |
||
2926 | |||
2927 | |||
2928 | // Get parameters |
||
2929 | $action = GETPOST('action', 'aZ09'); |
||
2930 | $massaction = GETPOST('massaction', 'alpha'); |
||
2931 | $show_files = GETPOSTINT('show_files'); |
||
2932 | $confirm = GETPOST('confirm', 'alpha'); |
||
2933 | $cancel = GETPOST('cancel', 'alpha'); |
||
2934 | $toselect = GETPOST('toselect', 'array'); |
||
2935 | $contextpage = GETPOST('contextpage', 'aZ') ? GETPOST('contextpage', 'aZ') : 'memberslist'; // To manage different context of search |
||
2936 | $backtopage = GETPOST('backtopage', 'alpha'); |
||
2937 | $optioncss = GETPOST('optioncss', 'aZ'); |
||
2938 | $mode = GETPOST('mode', 'alpha'); |
||
2939 | |||
2940 | // Search fields |
||
2941 | $search = GETPOST("search", 'alpha'); |
||
2942 | $search_ref = GETPOST("search_ref", 'alpha'); |
||
2943 | $search_lastname = GETPOST("search_lastname", 'alpha'); |
||
2944 | $search_firstname = GETPOST("search_firstname", 'alpha'); |
||
2945 | $search_gender = GETPOST("search_gender", 'alpha'); |
||
2946 | $search_civility = GETPOST("search_civility", 'alpha'); |
||
2947 | $search_company = GETPOST('search_company', 'alphanohtml'); |
||
2948 | $search_login = GETPOST("search_login", 'alpha'); |
||
2949 | $search_address = GETPOST("search_address", 'alpha'); |
||
2950 | $search_zip = GETPOST("search_zip", 'alpha'); |
||
2951 | $search_town = GETPOST("search_town", 'alpha'); |
||
2952 | $search_state = GETPOST("search_state", 'alpha'); // county / departement / federal state |
||
2953 | $search_country = GETPOST("search_country", 'alpha'); |
||
2954 | $search_phone = GETPOST("search_phone", 'alpha'); |
||
2955 | $search_phone_perso = GETPOST("search_phone_perso", 'alpha'); |
||
2956 | $search_phone_mobile = GETPOST("search_phone_mobile", 'alpha'); |
||
2957 | $search_type = GETPOST("search_type", 'alpha'); |
||
2958 | $search_email = GETPOST("search_email", 'alpha'); |
||
2959 | $search_categ = GETPOSTINT("search_categ"); |
||
2960 | $search_morphy = GETPOST("search_morphy", 'alpha'); |
||
2961 | $search_import_key = trim(GETPOST("search_import_key", 'alpha')); |
||
2962 | |||
2963 | $catid = GETPOSTINT("catid"); |
||
2964 | $socid = GETPOSTINT('socid'); |
||
2965 | |||
2966 | $search_filter = GETPOST("search_filter", 'alpha'); |
||
2967 | $search_status = GETPOST("search_status", 'intcomma'); // status |
||
2968 | $search_datec_start = dol_mktime(0, 0, 0, GETPOSTINT('search_datec_start_month'), GETPOSTINT('search_datec_start_day'), GETPOSTINT('search_datec_start_year')); |
||
2969 | $search_datec_end = dol_mktime(23, 59, 59, GETPOSTINT('search_datec_end_month'), GETPOSTINT('search_datec_end_day'), GETPOSTINT('search_datec_end_year')); |
||
2970 | $search_datem_start = dol_mktime(0, 0, 0, GETPOSTINT('search_datem_start_month'), GETPOSTINT('search_datem_start_day'), GETPOSTINT('search_datem_start_year')); |
||
2971 | $search_datem_end = dol_mktime(23, 59, 59, GETPOSTINT('search_datem_end_month'), GETPOSTINT('search_datem_end_day'), GETPOSTINT('search_datem_end_year')); |
||
2972 | |||
2973 | $filter = GETPOST("filter", 'alpha'); |
||
2974 | if ($filter) { |
||
2975 | $search_filter = $filter; // For backward compatibility |
||
2976 | } |
||
2977 | |||
2978 | $statut = GETPOST("statut", 'alpha'); |
||
2979 | if ($statut != '') { |
||
2980 | $search_status = $statut; // For backward compatibility |
||
2981 | } |
||
2982 | |||
2983 | $search_all = trim((GETPOST('search_all', 'alphanohtml') != '') ? GETPOST('search_all', 'alphanohtml') : GETPOST('sall', 'alphanohtml')); |
||
2984 | |||
2985 | if ($search_status < -2) { |
||
2986 | $search_status = ''; |
||
2987 | } |
||
2988 | |||
2989 | // Pagination parameters |
||
2990 | $limit = GETPOSTINT('limit') ? GETPOSTINT('limit') : $conf->liste_limit; |
||
2991 | $sortfield = GETPOST('sortfield', 'aZ09comma'); |
||
2992 | $sortorder = GETPOST('sortorder', 'aZ09comma'); |
||
2993 | $page = GETPOSTISSET('pageplusone') ? (GETPOSTINT('pageplusone') - 1) : GETPOSTINT("page"); |
||
2994 | if (empty($page) || $page == -1) { |
||
2995 | $page = 0; |
||
2996 | } // If $page is not defined, or '' or -1 |
||
2997 | $offset = $limit * $page; |
||
2998 | $pageprev = $page - 1; |
||
2999 | $pagenext = $page + 1; |
||
3000 | if (!$sortorder) { |
||
3001 | $sortorder = ($filter == 'outofdate' ? "DESC" : "ASC"); |
||
3002 | } |
||
3003 | if (!$sortfield) { |
||
3004 | $sortfield = ($filter == 'outofdate' ? "d.datefin" : "d.lastname"); |
||
3005 | } |
||
3006 | |||
3007 | $object = new Adherent($db); |
||
3008 | |||
3009 | // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context |
||
3010 | $hookmanager->initHooks(['memberlist']); |
||
3011 | $extrafields = new ExtraFields($db); |
||
3012 | |||
3013 | // fetch optionals attributes and labels |
||
3014 | $extrafields->fetch_name_optionals_label($object->table_element); |
||
3015 | |||
3016 | $search_array_options = $extrafields->getOptionalsFromPost($object->table_element, '', 'search_'); |
||
3017 | |||
3018 | // List of fields to search into when doing a "search in all" |
||
3019 | $fieldstosearchall = [ |
||
3020 | 'd.ref' => 'Ref', |
||
3021 | 'd.login' => 'Login', |
||
3022 | 'd.lastname' => 'Lastname', |
||
3023 | 'd.firstname' => 'Firstname', |
||
3024 | 'd.societe' => "Company", |
||
3025 | 'd.email' => 'EMail', |
||
3026 | 'd.address' => 'Address', |
||
3027 | 'd.zip' => 'Zip', |
||
3028 | 'd.town' => 'Town', |
||
3029 | 'd.phone' => "Phone", |
||
3030 | 'd.phone_perso' => "PhonePerso", |
||
3031 | 'd.phone_mobile' => "PhoneMobile", |
||
3032 | 'd.note_public' => 'NotePublic', |
||
3033 | 'd.note_private' => 'NotePrivate', |
||
3034 | ]; |
||
3035 | |||
3036 | $arrayfields = [ |
||
3037 | 'd.ref' => ['label' => "Ref", 'checked' => 1], |
||
3038 | 'd.civility' => ['label' => "Civility", 'checked' => 0], |
||
3039 | 'd.lastname' => ['label' => "Lastname", 'checked' => 1], |
||
3040 | 'd.firstname' => ['label' => "Firstname", 'checked' => 1], |
||
3041 | 'd.gender' => ['label' => "Gender", 'checked' => 0], |
||
3042 | 'd.company' => ['label' => "Company", 'checked' => 1, 'position' => 70], |
||
3043 | 'd.login' => ['label' => "Login", 'checked' => 1], |
||
3044 | 'd.morphy' => ['label' => "MemberNature", 'checked' => 1], |
||
3045 | 't.libelle' => ['label' => "Type", 'checked' => 1, 'position' => 55], |
||
3046 | 'd.address' => ['label' => "Address", 'checked' => 0], |
||
3047 | 'd.zip' => ['label' => "Zip", 'checked' => 0], |
||
3048 | 'd.town' => ['label' => "Town", 'checked' => 0], |
||
3049 | 'd.phone' => ['label' => "Phone", 'checked' => 0], |
||
3050 | 'd.phone_perso' => ['label' => "PhonePerso", 'checked' => 0], |
||
3051 | 'd.phone_mobile' => ['label' => "PhoneMobile", 'checked' => 0], |
||
3052 | 'd.email' => ['label' => "Email", 'checked' => 1], |
||
3053 | 'state.nom' => ['label' => "State", 'checked' => 0, 'position' => 90], |
||
3054 | 'country.code_iso' => ['label' => "Country", 'checked' => 0, 'position' => 95], |
||
3055 | /*'d.note_public'=>array('label'=>"NotePublic", 'checked'=>0), |
||
3056 | 'd.note_private'=>array('label'=>"NotePrivate", 'checked'=>0),*/ |
||
3057 | 'd.datefin' => ['label' => "EndSubscription"], |
||
3058 | 'd.datec' => ['label' => "DateCreation"], |
||
3059 | 'd.birth' => ['label' => "Birthday"], |
||
3060 | 'd.tms' => ['label' => "DateModificationShort"], |
||
3061 | 'd.statut' => ['label' => "Status"], |
||
3062 | 'd.import_key' => ['label' => "ImportId"], |
||
3063 | ]; |
||
3064 | |||
3065 | // Extra fields |
||
3066 | include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_list_array_fields.tpl.php'; |
||
3067 | |||
3068 | $object->fields = dol_sort_array($object->fields, 'position'); |
||
3069 | //$arrayfields['anotherfield'] = array('type'=>'integer', 'label'=>'AnotherField', 'checked'=>1, 'enabled'=>1, 'position'=>90, 'csslist'=>'right'); |
||
3070 | |||
3071 | // Complete array of fields for columns |
||
3072 | $tableprefix = 'd'; |
||
3073 | foreach ($object->fields as $key => $val) { |
||
3074 | if (!array_key_exists($tableprefix . '.' . $key, $arrayfields)) { // Discard record not into $arrayfields |
||
3075 | continue; |
||
3076 | } |
||
3077 | // If $val['visible']==0, then we never show the field |
||
3078 | |||
3079 | if (!empty($val['visible'])) { |
||
3080 | $visible = (int) dol_eval($val['visible'], 1); |
||
3081 | $arrayfields[$tableprefix . '.' . $key] = [ |
||
3082 | 'label' => $val['label'], |
||
3083 | 'checked' => (($visible < 0) ? 0 : 1), |
||
3084 | 'enabled' => (abs($visible) != 3 && (int) dol_eval($val['enabled'], 1)), |
||
3085 | 'position' => $val['position'], |
||
3086 | 'help' => isset($val['help']) ? $val['help'] : '', |
||
3087 | ]; |
||
3088 | } |
||
3089 | } |
||
3090 | $arrayfields = dol_sort_array($arrayfields, 'position'); |
||
3091 | //var_dump($arrayfields);exit; |
||
3092 | |||
3093 | // Security check |
||
3094 | $result = restrictedArea($user, 'adherent'); |
||
3095 | |||
3096 | |||
3097 | /* |
||
3098 | * Actions |
||
3099 | */ |
||
3100 | |||
3101 | if (GETPOST('cancel', 'alpha')) { |
||
3102 | $action = 'list'; |
||
3103 | $massaction = ''; |
||
3104 | } |
||
3105 | if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') { |
||
3106 | $massaction = ''; |
||
3107 | } |
||
3108 | |||
3109 | $parameters = ['socid' => isset($socid) ? $socid : null]; |
||
3110 | $reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks |
||
3111 | if ($reshook < 0) { |
||
3112 | setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); |
||
3113 | } |
||
3114 | |||
3115 | if (empty($reshook)) { |
||
3116 | // Selection of new fields |
||
3117 | include DOL_DOCUMENT_ROOT . '/core/actions_changeselectedfields.inc.php'; |
||
3118 | |||
3119 | // Purge search criteria |
||
3120 | 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 |
||
3121 | $statut = ''; |
||
3122 | $filter = ''; |
||
3123 | |||
3124 | $search = ""; |
||
3125 | $search_ref = ""; |
||
3126 | $search_lastname = ""; |
||
3127 | $search_firstname = ""; |
||
3128 | $search_gender = ""; |
||
3129 | $search_civility = ""; |
||
3130 | $search_login = ""; |
||
3131 | $search_company = ""; |
||
3132 | $search_type = ""; |
||
3133 | $search_email = ""; |
||
3134 | $search_address = ""; |
||
3135 | $search_zip = ""; |
||
3136 | $search_town = ""; |
||
3137 | $search_state = ""; |
||
3138 | $search_country = ''; |
||
3139 | $search_phone = ''; |
||
3140 | $search_phone_perso = ''; |
||
3141 | $search_phone_mobile = ''; |
||
3142 | $search_morphy = ""; |
||
3143 | $search_categ = ""; |
||
3144 | $search_filter = ""; |
||
3145 | $search_status = ""; |
||
3146 | $search_import_key = ''; |
||
3147 | $catid = ""; |
||
3148 | $search_all = ""; |
||
3149 | $toselect = []; |
||
3150 | $search_datec_start = ''; |
||
3151 | $search_datec_end = ''; |
||
3152 | $search_datem_start = ''; |
||
3153 | $search_datem_end = ''; |
||
3154 | $search_array_options = []; |
||
3155 | } |
||
3156 | |||
3157 | // Close |
||
3158 | if ($massaction == 'close' && $user->hasRight('adherent', 'creer')) { |
||
3159 | $tmpmember = new Adherent($db); |
||
3160 | $error = 0; |
||
3161 | $nbclose = 0; |
||
3162 | |||
3163 | $db->begin(); |
||
3164 | |||
3165 | foreach ($toselect as $idtoclose) { |
||
3166 | $tmpmember->fetch($idtoclose); |
||
3167 | $result = $tmpmember->resiliate($user); |
||
3168 | |||
3169 | if ($result < 0 && !count($tmpmember->errors)) { |
||
3170 | setEventMessages($tmpmember->error, $tmpmember->errors, 'errors'); |
||
3171 | } else { |
||
3172 | if ($result > 0) { |
||
3173 | $nbclose++; |
||
3174 | } |
||
3175 | } |
||
3176 | } |
||
3177 | |||
3178 | if (!$error) { |
||
3179 | setEventMessages($langs->trans("XMembersClosed", $nbclose), null, 'mesgs'); |
||
3180 | |||
3181 | $db->commit(); |
||
3182 | } else { |
||
3183 | $db->rollback(); |
||
3184 | } |
||
3185 | } |
||
3186 | |||
3187 | // Create external user |
||
3188 | if ($massaction == 'createexternaluser' && $user->hasRight('adherent', 'creer') && $user->hasRight('user', 'user', 'creer')) { |
||
3189 | $tmpmember = new Adherent($db); |
||
3190 | $error = 0; |
||
3191 | $nbcreated = 0; |
||
3192 | |||
3193 | $db->begin(); |
||
3194 | |||
3195 | foreach ($toselect as $idtoclose) { |
||
3196 | $tmpmember->fetch($idtoclose); |
||
3197 | |||
3198 | if (!empty($tmpmember->fk_soc)) { |
||
3199 | $nuser = new User($db); |
||
3200 | $tmpuser = dol_clone($tmpmember); |
||
3201 | |||
3202 | $result = $nuser->create_from_member($tmpuser, $tmpmember->login); |
||
3203 | |||
3204 | if ($result < 0 && !count($tmpmember->errors)) { |
||
3205 | setEventMessages($tmpmember->error, $tmpmember->errors, 'errors'); |
||
3206 | } else { |
||
3207 | if ($result > 0) { |
||
3208 | $nbcreated++; |
||
3209 | } |
||
3210 | } |
||
3211 | } |
||
3212 | } |
||
3213 | |||
3214 | if (!$error) { |
||
3215 | setEventMessages($langs->trans("XExternalUserCreated", $nbcreated), null, 'mesgs'); |
||
3216 | |||
3217 | $db->commit(); |
||
3218 | } else { |
||
3219 | $db->rollback(); |
||
3220 | } |
||
3221 | } |
||
3222 | |||
3223 | // Create external user |
||
3224 | if ($action == 'createsubscription_confirm' && $confirm == "yes" && $user->hasRight('adherent', 'creer')) { |
||
3225 | $tmpmember = new Adherent($db); |
||
3226 | $adht = new AdherentType($db); |
||
3227 | $error = 0; |
||
3228 | $nbcreated = 0; |
||
3229 | $now = dol_now(); |
||
3230 | $amount = price2num(GETPOST('amount', 'alpha')); |
||
3231 | $db->begin(); |
||
3232 | foreach ($toselect as $id) { |
||
3233 | $res = $tmpmember->fetch($id); |
||
3234 | if ($res > 0) { |
||
3235 | $result = $tmpmember->subscription($now, $amount); |
||
3236 | if ($result < 0) { |
||
3237 | $error++; |
||
3238 | } else { |
||
3239 | $nbcreated++; |
||
3240 | } |
||
3241 | } else { |
||
3242 | $error++; |
||
3243 | } |
||
3244 | } |
||
3245 | |||
3246 | if (!$error) { |
||
3247 | setEventMessages($langs->trans("XSubsriptionCreated", $nbcreated), null, 'mesgs'); |
||
3248 | $db->commit(); |
||
3249 | } else { |
||
3250 | setEventMessages($langs->trans("XSubsriptionError", $error), null, 'mesgs'); |
||
3251 | $db->rollback(); |
||
3252 | } |
||
3253 | } |
||
3254 | |||
3255 | // Mass actions |
||
3256 | $objectclass = 'Adherent'; |
||
3257 | $objectlabel = 'Members'; |
||
3258 | $permissiontoread = $user->hasRight('adherent', 'lire'); |
||
3259 | $permissiontodelete = $user->hasRight('adherent', 'supprimer'); |
||
3260 | $permissiontoadd = $user->hasRight('adherent', 'creer'); |
||
3261 | $uploaddir = $conf->adherent->dir_output; |
||
3262 | include DOL_DOCUMENT_ROOT . '/core/actions_massactions.inc.php'; |
||
3263 | } |
||
3264 | |||
3265 | |||
3266 | /* |
||
3267 | * View |
||
3268 | */ |
||
3269 | |||
3270 | $form = new Form($db); |
||
3271 | $formother = new FormOther($db); |
||
3272 | $membertypestatic = new AdherentType($db); |
||
3273 | $memberstatic = new Adherent($db); |
||
3274 | |||
3275 | $now = dol_now(); |
||
3276 | |||
3277 | // Page Header |
||
3278 | $title = $langs->trans("Members") . " - " . $langs->trans("List"); |
||
3279 | $help_url = 'EN:Module_Foundations|FR:Module_Adhérents|ES:Módulo_Miembros|DE:Modul_Mitglieder'; |
||
3280 | $morejs = []; |
||
3281 | $morecss = []; |
||
3282 | |||
3283 | |||
3284 | // Build and execute select |
||
3285 | // -------------------------------------------------------------------- |
||
3286 | if ((!empty($search_categ) && $search_categ > 0) || !empty($catid)) { |
||
3287 | $sql = "SELECT DISTINCT"; |
||
3288 | } else { |
||
3289 | $sql = "SELECT"; |
||
3290 | } |
||
3291 | $sql .= " d.rowid, d.ref, d.login, d.lastname, d.firstname, d.gender, d.societe as company, d.fk_soc,"; |
||
3292 | $sql .= " d.civility, d.datefin, d.address, d.zip, d.town, d.state_id, d.country,"; |
||
3293 | $sql .= " d.email, d.phone, d.phone_perso, d.phone_mobile, d.birth, d.public, d.photo,"; |
||
3294 | $sql .= " d.fk_adherent_type as type_id, d.morphy, d.statut as status, d.datec as date_creation, d.tms as date_modification,"; |
||
3295 | $sql .= " d.note_private, d.note_public, d.import_key,"; |
||
3296 | $sql .= " s.nom,"; |
||
3297 | $sql .= " " . $db->ifsql("d.societe IS NULL", "s.nom", "d.societe") . " as companyname,"; |
||
3298 | $sql .= " t.libelle as type, t.subscription,"; |
||
3299 | $sql .= " state.code_departement as state_code, state.nom as state_name"; |
||
3300 | |||
3301 | // Add fields from extrafields |
||
3302 | if (!empty($extrafields->attributes[$object->table_element]['label'])) { |
||
3303 | foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) { |
||
3304 | $sql .= ($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? ", ef." . $key . " as options_" . $key : ''); |
||
3305 | } |
||
3306 | } |
||
3307 | |||
3308 | // Add fields from hooks |
||
3309 | $parameters = []; |
||
3310 | $reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters, $object, $action); // Note that $action and $object may have been modified by hook |
||
3311 | $sql .= $hookmanager->resPrint; |
||
3312 | $sql = preg_replace('/,\s*$/', '', $sql); |
||
3313 | |||
3314 | $sqlfields = $sql; // $sql fields to remove for count total |
||
3315 | |||
3316 | // SQL Alias adherent |
||
3317 | $sql .= " FROM " . MAIN_DB_PREFIX . "adherent as d"; // maybe better to use ad (adh) instead of d |
||
3318 | if (!empty($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) { |
||
3319 | $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . $object->table_element . "_extrafields as ef on (d.rowid = ef.fk_object)"; |
||
3320 | } |
||
3321 | $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "c_country as country on (country.rowid = d.country)"; |
||
3322 | $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "c_departements as state on (state.rowid = d.state_id)"; |
||
3323 | $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "societe as s on (s.rowid = d.fk_soc)"; |
||
3324 | |||
3325 | // SQL Alias adherent_type |
||
3326 | $sql .= ", " . MAIN_DB_PREFIX . "adherent_type as t"; |
||
3327 | $sql .= " WHERE d.fk_adherent_type = t.rowid"; |
||
3328 | |||
3329 | if ($catid && empty($search_categ)) { |
||
3330 | $search_categ = $catid; |
||
3331 | } |
||
3332 | |||
3333 | $searchCategoryContactList = $search_categ ? [$search_categ] : []; |
||
3334 | $searchCategoryContactOperator = 0; |
||
3335 | // Search for tag/category ($searchCategoryContactList is an array of ID) |
||
3336 | if (!empty($searchCategoryContactList)) { |
||
3337 | $searchCategoryContactSqlList = []; |
||
3338 | $listofcategoryid = ''; |
||
3339 | foreach ($searchCategoryContactList as $searchCategoryContact) { |
||
3340 | if (intval($searchCategoryContact) == -2) { |
||
3341 | $searchCategoryContactSqlList[] = "NOT EXISTS (SELECT ck.fk_categorie FROM " . MAIN_DB_PREFIX . "categorie_member as ck WHERE d.rowid = ck.fk_member)"; |
||
3342 | } elseif (intval($searchCategoryContact) > 0) { |
||
3343 | if ($searchCategoryContactOperator == 0) { |
||
3344 | $searchCategoryContactSqlList[] = " EXISTS (SELECT ck.fk_categorie FROM " . MAIN_DB_PREFIX . "categorie_member as ck WHERE d.rowid = ck.fk_member AND ck.fk_categorie = " . ((int) $searchCategoryContact) . ")"; |
||
3345 | } else { |
||
3346 | $listofcategoryid .= ($listofcategoryid ? ', ' : '') . ((int) $searchCategoryContact); |
||
3347 | } |
||
3348 | } |
||
3349 | } |
||
3350 | if ($listofcategoryid) { |
||
3351 | $searchCategoryContactSqlList[] = " EXISTS (SELECT ck.fk_categorie FROM " . MAIN_DB_PREFIX . "categorie_member as ck WHERE d.rowid = ck.fk_member AND ck.fk_categorie IN (" . $db->sanitize($listofcategoryid) . "))"; |
||
3352 | } |
||
3353 | if ($searchCategoryContactOperator == 1) { |
||
3354 | if (!empty($searchCategoryContactSqlList)) { |
||
3355 | $sql .= " AND (" . implode(' OR ', $searchCategoryContactSqlList) . ")"; |
||
3356 | } |
||
3357 | } else { |
||
3358 | if (!empty($searchCategoryContactSqlList)) { |
||
3359 | $sql .= " AND (" . implode(' AND ', $searchCategoryContactSqlList) . ")"; |
||
3360 | } |
||
3361 | } |
||
3362 | } |
||
3363 | |||
3364 | $sql .= " AND d.entity IN (" . getEntity('adherent') . ")"; |
||
3365 | if ($search_all) { |
||
3366 | $sql .= natural_search(array_keys($fieldstosearchall), $search_all); |
||
3367 | } |
||
3368 | if ($search_type > 0) { |
||
3369 | $sql .= " AND t.rowid=" . ((int) $search_type); |
||
3370 | } |
||
3371 | if ($search_filter == 'withoutsubscription') { |
||
3372 | $sql .= " AND (datefin IS NULL)"; |
||
3373 | } |
||
3374 | if ($search_filter == 'waitingsubscription') { |
||
3375 | $sql .= " AND (datefin IS NULL AND t.subscription = '1')"; |
||
3376 | } |
||
3377 | if ($search_filter == 'uptodate') { |
||
3378 | $sql .= " AND (datefin >= '" . $db->idate($now) . "' OR (datefin IS NULL AND t.subscription = '0'))"; |
||
3379 | } |
||
3380 | if ($search_filter == 'outofdate') { |
||
3381 | $sql .= " AND (datefin < '" . $db->idate($now) . "')"; |
||
3382 | } |
||
3383 | if ($search_status != '') { |
||
3384 | // Peut valoir un nombre ou liste de nombre separates par virgules |
||
3385 | $sql .= " AND d.statut in (" . $db->sanitize($db->escape($search_status)) . ")"; |
||
3386 | } |
||
3387 | if ($search_morphy != '' && $search_morphy != '-1') { |
||
3388 | $sql .= natural_search("d.morphy", $search_morphy); |
||
3389 | } |
||
3390 | if ($search_ref) { |
||
3391 | $sql .= natural_search("d.ref", $search_ref); |
||
3392 | } |
||
3393 | if ($search_civility) { |
||
3394 | $sql .= natural_search("d.civility", $search_civility); |
||
3395 | } |
||
3396 | if ($search_firstname) { |
||
3397 | $sql .= natural_search("d.firstname", $search_firstname); |
||
3398 | } |
||
3399 | if ($search_lastname) { |
||
3400 | $sql .= natural_search(["d.firstname", "d.lastname", "d.societe"], $search_lastname); |
||
3401 | } |
||
3402 | if ($search_gender != '' && $search_gender != '-1') { |
||
3403 | $sql .= natural_search("d.gender", $search_gender); |
||
3404 | } |
||
3405 | if ($search_login) { |
||
3406 | $sql .= natural_search("d.login", $search_login); |
||
3407 | } |
||
3408 | if ($search_company) { |
||
3409 | $sql .= natural_search("s.nom", $search_company); |
||
3410 | } |
||
3411 | if ($search_email) { |
||
3412 | $sql .= natural_search("d.email", $search_email); |
||
3413 | } |
||
3414 | if ($search_address) { |
||
3415 | $sql .= natural_search("d.address", $search_address); |
||
3416 | } |
||
3417 | if ($search_town) { |
||
3418 | $sql .= natural_search("d.town", $search_town); |
||
3419 | } |
||
3420 | if ($search_zip) { |
||
3421 | $sql .= natural_search("d.zip", $search_zip); |
||
3422 | } |
||
3423 | if ($search_state) { |
||
3424 | $sql .= natural_search("state.nom", $search_state); |
||
3425 | } |
||
3426 | if ($search_phone) { |
||
3427 | $sql .= natural_search("d.phone", $search_phone); |
||
3428 | } |
||
3429 | if ($search_phone_perso) { |
||
3430 | $sql .= natural_search("d.phone_perso", $search_phone_perso); |
||
3431 | } |
||
3432 | if ($search_phone_mobile) { |
||
3433 | $sql .= natural_search("d.phone_mobile", $search_phone_mobile); |
||
3434 | } |
||
3435 | if ($search_country) { |
||
3436 | $sql .= " AND d.country IN (" . $db->sanitize($search_country) . ')'; |
||
3437 | } |
||
3438 | if ($search_import_key) { |
||
3439 | $sql .= natural_search("d.import_key", $search_import_key); |
||
3440 | } |
||
3441 | if ($search_datec_start) { |
||
3442 | $sql .= " AND d.datec >= '" . $db->idate($search_datec_start) . "'"; |
||
3443 | } |
||
3444 | if ($search_datec_end) { |
||
3445 | $sql .= " AND d.datec <= '" . $db->idate($search_datec_end) . "'"; |
||
3446 | } |
||
3447 | if ($search_datem_start) { |
||
3448 | $sql .= " AND d.tms >= '" . $db->idate($search_datem_start) . "'"; |
||
3449 | } |
||
3450 | if ($search_datem_end) { |
||
3451 | $sql .= " AND d.tms <= '" . $db->idate($search_datem_end) . "'"; |
||
3452 | } |
||
3453 | // Add where from extra fields |
||
3454 | include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_list_search_sql.tpl.php'; |
||
3455 | // Add where from hooks |
||
3456 | $parameters = []; |
||
3457 | $reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters, $object, $action); // Note that $action and $object may have been modified by hook |
||
3458 | $sql .= $hookmanager->resPrint; |
||
3459 | |||
3460 | // Count total nb of records |
||
3461 | $nbtotalofrecords = ''; |
||
3462 | if (!getDolGlobalInt('MAIN_DISABLE_FULL_SCANLIST')) { |
||
3463 | /* The fast and low memory method to get and count full list converts the sql into a sql count */ |
||
3464 | $sqlforcount = preg_replace('/^' . preg_quote($sqlfields, '/') . '/', 'SELECT COUNT(*) as nbtotalofrecords', $sql); |
||
3465 | $sqlforcount = preg_replace('/GROUP BY .*$/', '', $sqlforcount); |
||
3466 | $resql = $db->query($sqlforcount); |
||
3467 | if ($resql) { |
||
3468 | $objforcount = $db->fetch_object($resql); |
||
3469 | $nbtotalofrecords = $objforcount->nbtotalofrecords; |
||
3470 | } else { |
||
3471 | dol_print_error($db); |
||
3472 | } |
||
3473 | |||
3474 | if (($page * $limit) > $nbtotalofrecords) { // if total resultset is smaller than the paging size (filtering), goto and load page 0 |
||
3475 | $page = 0; |
||
3476 | $offset = 0; |
||
3477 | } |
||
3478 | $db->free($resql); |
||
3479 | } |
||
3480 | //print $sql; |
||
3481 | |||
3482 | // Complete request and execute it with limit |
||
3483 | $sql .= $db->order($sortfield, $sortorder); |
||
3484 | if ($limit) { |
||
3485 | $sql .= $db->plimit($limit + 1, $offset); |
||
3486 | } |
||
3487 | |||
3488 | $resql = $db->query($sql); |
||
3489 | if (!$resql) { |
||
3490 | dol_print_error($db); |
||
3491 | exit; |
||
3492 | } |
||
3493 | |||
3494 | $num = $db->num_rows($resql); |
||
3495 | |||
3496 | |||
3497 | // Direct jump if only one record found |
||
3498 | if ($num == 1 && getDolGlobalString('MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE') && $search_all && !$page) { |
||
3499 | $obj = $db->fetch_object($resql); |
||
3500 | $id = $obj->rowid; |
||
3501 | header("Location: " . DOL_URL_ROOT . '/adherents/card.php?id=' . $id); |
||
3502 | exit; |
||
3503 | } |
||
3504 | |||
3505 | // Output page |
||
3506 | // -------------------------------------------------------------------- |
||
3507 | |||
3508 | llxHeader('', $title, $help_url, '', 0, 0, $morejs, $morecss, '', 'bodyforlist'); // Can use also classforhorizontalscrolloftabs instead of bodyforlist for no horizontal scroll |
||
3509 | |||
3510 | $arrayofselected = is_array($toselect) ? $toselect : []; |
||
3511 | |||
3512 | |||
3513 | if ($search_type > 0) { |
||
3514 | $membertype = new AdherentType($db); |
||
3515 | $result = $membertype->fetch($search_type); |
||
3516 | $title .= " (" . $membertype->label . ")"; |
||
3517 | } |
||
3518 | |||
3519 | // $parameters |
||
3520 | $param = ''; |
||
3521 | if (!empty($mode)) { |
||
3522 | $param .= '&mode=' . urlencode($mode); |
||
3523 | } |
||
3524 | if (!empty($contextpage) && $contextpage != $_SERVER['PHP_SELF']) { |
||
3525 | $param .= '&contextpage=' . urlencode($contextpage); |
||
3526 | } |
||
3527 | if ($limit > 0 && $limit != $conf->liste_limit) { |
||
3528 | $param .= '&limit=' . ((int) $limit); |
||
3529 | } |
||
3530 | if ($optioncss != '') { |
||
3531 | $param .= '&optioncss=' . urlencode($optioncss); |
||
3532 | } |
||
3533 | if ($search_all != "") { |
||
3534 | $param .= "&search_all=" . urlencode($search_all); |
||
3535 | } |
||
3536 | if ($search_ref) { |
||
3537 | $param .= "&search_ref=" . urlencode($search_ref); |
||
3538 | } |
||
3539 | if ($search_civility) { |
||
3540 | $param .= "&search_civility=" . urlencode($search_civility); |
||
3541 | } |
||
3542 | if ($search_firstname) { |
||
3543 | $param .= "&search_firstname=" . urlencode($search_firstname); |
||
3544 | } |
||
3545 | if ($search_lastname) { |
||
3546 | $param .= "&search_lastname=" . urlencode($search_lastname); |
||
3547 | } |
||
3548 | if ($search_gender) { |
||
3549 | $param .= "&search_gender=" . urlencode($search_gender); |
||
3550 | } |
||
3551 | if ($search_login) { |
||
3552 | $param .= "&search_login=" . urlencode($search_login); |
||
3553 | } |
||
3554 | if ($search_email) { |
||
3555 | $param .= "&search_email=" . urlencode($search_email); |
||
3556 | } |
||
3557 | if ($search_categ > 0 || $search_categ == -2) { |
||
3558 | $param .= "&search_categ=" . urlencode((string) ($search_categ)); |
||
3559 | } |
||
3560 | if ($search_company) { |
||
3561 | $param .= "&search_company=" . urlencode($search_company); |
||
3562 | } |
||
3563 | if ($search_address != '') { |
||
3564 | $param .= "&search_address=" . urlencode($search_address); |
||
3565 | } |
||
3566 | if ($search_town != '') { |
||
3567 | $param .= "&search_town=" . urlencode($search_town); |
||
3568 | } |
||
3569 | if ($search_zip != '') { |
||
3570 | $param .= "&search_zip=" . urlencode($search_zip); |
||
3571 | } |
||
3572 | if ($search_state != '') { |
||
3573 | $param .= "&search_state=" . urlencode($search_state); |
||
3574 | } |
||
3575 | if ($search_country != '') { |
||
3576 | $param .= "&search_country=" . urlencode($search_country); |
||
3577 | } |
||
3578 | if ($search_phone != '') { |
||
3579 | $param .= "&search_phone=" . urlencode($search_phone); |
||
3580 | } |
||
3581 | if ($search_phone_perso != '') { |
||
3582 | $param .= "&search_phone_perso=" . urlencode($search_phone_perso); |
||
3583 | } |
||
3584 | if ($search_phone_mobile != '') { |
||
3585 | $param .= "&search_phone_mobile=" . urlencode($search_phone_mobile); |
||
3586 | } |
||
3587 | if ($search_filter && $search_filter != '-1') { |
||
3588 | $param .= "&search_filter=" . urlencode($search_filter); |
||
3589 | } |
||
3590 | if ($search_status != "" && $search_status != -3) { |
||
3591 | $param .= "&search_status=" . urlencode($search_status); |
||
3592 | } |
||
3593 | if ($search_import_key != '') { |
||
3594 | $param .= '&search_import_key=' . urlencode($search_import_key); |
||
3595 | } |
||
3596 | if ($search_type > 0) { |
||
3597 | $param .= "&search_type=" . urlencode($search_type); |
||
3598 | } |
||
3599 | if ($search_datec_start) { |
||
3600 | $param .= '&search_datec_start_day=' . dol_print_date($search_datec_start, '%d') . '&search_datec_start_month=' . dol_print_date($search_datec_start, '%m') . '&search_datec_start_year=' . dol_print_date($search_datec_start, '%Y'); |
||
3601 | } |
||
3602 | if ($search_datem_end) { |
||
3603 | $param .= '&search_datem_end_day=' . dol_print_date($search_datem_end, '%d') . '&search_datem_end_month=' . dol_print_date($search_datem_end, '%m') . '&search_datem_end_year=' . dol_print_date($search_datem_end, '%Y'); |
||
3604 | } |
||
3605 | |||
3606 | // Add $param from extra fields |
||
3607 | include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_list_search_param.tpl.php'; |
||
3608 | |||
3609 | // List of mass actions available |
||
3610 | $arrayofmassactions = [ |
||
3611 | //'presend'=>img_picto('', 'email', 'class="pictofixedwidth"').$langs->trans("SendByMail"), |
||
3612 | //'builddoc'=>img_picto('', 'pdf', 'class="pictofixedwidth"').$langs->trans("PDFMerge"), |
||
3613 | ]; |
||
3614 | if ($user->hasRight('adherent', 'creer')) { |
||
3615 | $arrayofmassactions['close'] = img_picto('', 'close_title', 'class="pictofixedwidth"') . $langs->trans("Resiliate"); |
||
3616 | } |
||
3617 | if ($user->hasRight('adherent', 'supprimer')) { |
||
3618 | $arrayofmassactions['predelete'] = img_picto('', 'delete', 'class="pictofixedwidth"') . $langs->trans("Delete"); |
||
3619 | } |
||
3620 | if (isModEnabled('category') && $user->hasRight('adherent', 'creer')) { |
||
3621 | $arrayofmassactions['preaffecttag'] = img_picto('', 'category', 'class="pictofixedwidth"') . $langs->trans("AffectTag"); |
||
3622 | } |
||
3623 | if ($user->hasRight('adherent', 'creer') && $user->hasRight('user', 'user', 'creer')) { |
||
3624 | $arrayofmassactions['createexternaluser'] = img_picto('', 'user', 'class="pictofixedwidth"') . $langs->trans("CreateExternalUser"); |
||
3625 | } |
||
3626 | if ($user->hasRight('adherent', 'creer')) { |
||
3627 | $arrayofmassactions['createsubscription'] = img_picto('', 'payment', 'class="pictofixedwidth"') . $langs->trans("CreateSubscription"); |
||
3628 | } |
||
3629 | if (GETPOSTINT('nomassaction') || in_array($massaction, ['presend', 'predelete', 'preaffecttag'])) { |
||
3630 | $arrayofmassactions = []; |
||
3631 | } |
||
3632 | $massactionbutton = $form->selectMassAction('', $arrayofmassactions); |
||
3633 | |||
3634 | print '<form method="POST" id="searchFormList" action="' . $_SERVER['PHP_SELF'] . '">' . "\n"; |
||
3635 | if ($optioncss != '') { |
||
3636 | print '<input type="hidden" name="optioncss" value="' . $optioncss . '">'; |
||
3637 | } |
||
3638 | print '<input type="hidden" name="token" value="' . newToken() . '">'; |
||
3639 | print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">'; |
||
3640 | print '<input type="hidden" name="action" value="list">'; |
||
3641 | print '<input type="hidden" name="sortfield" value="' . $sortfield . '">'; |
||
3642 | print '<input type="hidden" name="sortorder" value="' . $sortorder . '">'; |
||
3643 | print '<input type="hidden" name="page" value="' . $page . '">'; |
||
3644 | print '<input type="hidden" name="contextpage" value="' . $contextpage . '">'; |
||
3645 | print '<input type="hidden" name="page_y" value="">'; |
||
3646 | print '<input type="hidden" name="mode" value="' . $mode . '">'; |
||
3647 | |||
3648 | |||
3649 | $newcardbutton = ''; |
||
3650 | $newcardbutton .= dolGetButtonTitle($langs->trans('ViewList'), '', 'fa fa-bars imgforviewmode', $_SERVER['PHP_SELF'] . '?mode=common' . preg_replace('/(&|\?)*mode=[^&]+/', '', $param), '', ((empty($mode) || $mode == 'common') ? 2 : 1), ['morecss' => 'reposition']); |
||
3651 | $newcardbutton .= dolGetButtonTitle($langs->trans('ViewKanban'), '', 'fa fa-th-list imgforviewmode', $_SERVER['PHP_SELF'] . '?mode=kanban' . preg_replace('/(&|\?)*mode=[^&]+/', '', $param), '', ($mode == 'kanban' ? 2 : 1), ['morecss' => 'reposition']); |
||
3652 | if ($user->hasRight('adherent', 'creer')) { |
||
3653 | $newcardbutton .= dolGetButtonTitleSeparator(); |
||
3654 | $newcardbutton .= dolGetButtonTitle($langs->trans('NewMember'), '', 'fa fa-plus-circle', DOL_URL_ROOT . '/adherents/card.php?action=create'); |
||
3655 | } |
||
3656 | |||
3657 | print_barre_liste($title, $page, $_SERVER['PHP_SELF'], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, $object->picto, 0, $newcardbutton, '', $limit, 0, 0, 1); |
||
3658 | |||
3659 | $topicmail = "Information"; |
||
3660 | $modelmail = "member"; |
||
3661 | $objecttmp = new Adherent($db); |
||
3662 | $trackid = 'mem' . $object->id; |
||
3663 | if ($massaction == 'createsubscription') { |
||
3664 | $tmpmember = new Adherent($db); |
||
3665 | $adht = new AdherentType($db); |
||
3666 | $amount = 0; |
||
3667 | foreach ($toselect as $id) { |
||
3668 | $now = dol_now(); |
||
3669 | $tmpmember->fetch($id); |
||
3670 | $res = $adht->fetch($tmpmember->typeid); |
||
3671 | if ($res > 0) { |
||
3672 | $amounttmp = $adht->amount; |
||
3673 | if (!empty($tmpmember->last_subscription_amount) && !GETPOSTISSET('newamount') && is_numeric($amounttmp)) { |
||
3674 | $amounttmp = max($tmpmember->last_subscription_amount, $amount); |
||
3675 | } |
||
3676 | $amount = max(0, $amounttmp, $amount); |
||
3677 | } else { |
||
3678 | $error++; |
||
3679 | } |
||
3680 | } |
||
3681 | |||
3682 | $date = dol_print_date(dol_now(), "%d/%m/%Y"); |
||
3683 | $formquestion = [ |
||
3684 | ['label' => $langs->trans("DateSubscription"), 'type' => 'other', 'value' => $date], |
||
3685 | ['label' => $langs->trans("Amount"), 'type' => 'text', 'value' => price($amount, 0, '', 0), 'name' => 'amount'], |
||
3686 | ['type' => 'separator'], |
||
3687 | ['label' => $langs->trans("MoreActions"), 'type' => 'other', 'value' => $langs->trans("None") . ' ' . img_warning($langs->trans("WarningNoComplementaryActionDone"))], |
||
3688 | ]; |
||
3689 | print $form->formconfirm($_SERVER['PHP_SELF'], $langs->trans("ConfirmMassSubsriptionCreation"), $langs->trans("ConfirmMassSubsriptionCreationQuestion", count($toselect)), "createsubscription_confirm", $formquestion, '', 0, 200, 500, 1); |
||
3690 | } |
||
3691 | include DOL_DOCUMENT_ROOT . '/core/tpl/massactions_pre.tpl.php'; |
||
3692 | |||
3693 | if ($search_all) { |
||
3694 | $setupstring = ''; |
||
3695 | foreach ($fieldstosearchall as $key => $val) { |
||
3696 | $fieldstosearchall[$key] = $langs->trans($val); |
||
3697 | $setupstring .= $key . "=" . $val . ";"; |
||
3698 | } |
||
3699 | print '<!-- Search done like if MYOBJECT_QUICKSEARCH_ON_FIELDS = ' . $setupstring . ' -->' . "\n"; |
||
3700 | print '<div class="divsearchfieldfilter">' . $langs->trans("FilterOnInto", $search_all) . implode(', ', $fieldstosearchall) . '</div>' . "\n"; |
||
3701 | } |
||
3702 | |||
3703 | $varpage = empty($contextpage) ? $_SERVER['PHP_SELF'] : $contextpage; |
||
3704 | $selectedfields = ($mode != 'kanban' ? $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage, getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) : ''); // This also change content of $arrayfields |
||
3705 | $selectedfields .= (count($arrayofmassactions) ? $form->showCheckAddButtons('checkforselect', 1) : ''); |
||
3706 | |||
3707 | $moreforfilter = ''; |
||
3708 | // Filter on categories |
||
3709 | if (isModEnabled('category') && $user->hasRight('categorie', 'lire')) { |
||
3710 | require_once BASE_PATH . '/categories/class/categorie.class.php'; |
||
3711 | $moreforfilter .= '<div class="divsearchfield">'; |
||
3712 | $moreforfilter .= img_picto($langs->trans('Categories'), 'category', 'class="pictofixedwidth"') . $formother->select_categories(Categorie::TYPE_MEMBER, $search_categ, 'search_categ', 1, $langs->trans("MembersCategoriesShort")); |
||
3713 | $moreforfilter .= '</div>'; |
||
3714 | } |
||
3715 | $parameters = [ |
||
3716 | 'arrayfields' => &$arrayfields, |
||
3717 | ]; |
||
3718 | $reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters, $object, $action); // Note that $action and $object may have been modified by hook |
||
3719 | if (empty($reshook)) { |
||
3720 | $moreforfilter .= $hookmanager->resPrint; |
||
3721 | } else { |
||
3722 | $moreforfilter = $hookmanager->resPrint; |
||
3723 | } |
||
3724 | if (!empty($moreforfilter)) { |
||
3725 | print '<div class="liste_titre liste_titre_bydiv centpercent">'; |
||
3726 | print $moreforfilter; |
||
3727 | $parameters = []; |
||
3728 | $reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters, $object, $action); // Note that $action and $object may have been modified by hook |
||
3729 | print $hookmanager->resPrint; |
||
3730 | print '</div>'; |
||
3731 | } |
||
3732 | |||
3733 | print '<div class="div-table-responsive">'; |
||
3734 | print '<table class="tagtable nobottomiftotal liste' . ($moreforfilter ? " listwithfilterbefore" : "") . '">' . "\n"; |
||
3735 | |||
3736 | // Fields title search |
||
3737 | // -------------------------------------------------------------------- |
||
3738 | print '<tr class="liste_titre_filter">'; |
||
3739 | |||
3740 | // Action column |
||
3741 | if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { |
||
3742 | print '<td class="liste_titre center maxwidthsearch">'; |
||
3743 | $searchpicto = $form->showFilterButtons('left'); |
||
3744 | print $searchpicto; |
||
3745 | print '</td>'; |
||
3746 | } |
||
3747 | |||
3748 | // Line numbering |
||
3749 | if (getDolGlobalString('MAIN_SHOW_TECHNICAL_ID')) { |
||
3750 | print '<td class="liste_titre"> </td>'; |
||
3751 | } |
||
3752 | |||
3753 | // Ref |
||
3754 | if (!empty($arrayfields['d.ref']['checked'])) { |
||
3755 | print '<td class="liste_titre">'; |
||
3756 | print '<input type="text" class="flat maxwidth75imp" name="search_ref" value="' . dol_escape_htmltag($search_ref) . '">'; |
||
3757 | print '</td>'; |
||
3758 | } |
||
3759 | |||
3760 | // Civility |
||
3761 | if (!empty($arrayfields['d.civility']['checked'])) { |
||
3762 | print '<td class="liste_titre left">'; |
||
3763 | print '<input class="flat maxwidth50imp" type="text" name="search_civility" value="' . dol_escape_htmltag($search_civility) . '"></td>'; |
||
3764 | } |
||
3765 | |||
3766 | // First Name |
||
3767 | if (!empty($arrayfields['d.firstname']['checked'])) { |
||
3768 | print '<td class="liste_titre left">'; |
||
3769 | print '<input class="flat maxwidth75imp" type="text" name="search_firstname" value="' . dol_escape_htmltag($search_firstname) . '"></td>'; |
||
3770 | } |
||
3771 | |||
3772 | // Last Name |
||
3773 | if (!empty($arrayfields['d.lastname']['checked'])) { |
||
3774 | print '<td class="liste_titre left">'; |
||
3775 | print '<input class="flat maxwidth75imp" type="text" name="search_lastname" value="' . dol_escape_htmltag($search_lastname) . '"></td>'; |
||
3776 | } |
||
3777 | |||
3778 | // Gender |
||
3779 | if (!empty($arrayfields['d.gender']['checked'])) { |
||
3780 | print '<td class="liste_titre">'; |
||
3781 | $arraygender = ['man' => $langs->trans("Genderman"), 'woman' => $langs->trans("Genderwoman"), 'other' => $langs->trans("Genderother")]; |
||
3782 | print $form->selectarray('search_gender', $arraygender, $search_gender, 1); |
||
3783 | print '</td>'; |
||
3784 | } |
||
3785 | |||
3786 | // Company |
||
3787 | if (!empty($arrayfields['d.company']['checked'])) { |
||
3788 | print '<td class="liste_titre left">'; |
||
3789 | print '<input class="flat maxwidth75imp" type="text" name="search_company" value="' . dol_escape_htmltag($search_company) . '"></td>'; |
||
3790 | } |
||
3791 | |||
3792 | // Login |
||
3793 | if (!empty($arrayfields['d.login']['checked'])) { |
||
3794 | print '<td class="liste_titre left">'; |
||
3795 | print '<input class="flat maxwidth75imp" type="text" name="search_login" value="' . dol_escape_htmltag($search_login) . '"></td>'; |
||
3796 | } |
||
3797 | |||
3798 | // Nature |
||
3799 | if (!empty($arrayfields['d.morphy']['checked'])) { |
||
3800 | print '<td class="liste_titre center">'; |
||
3801 | $arraymorphy = ['mor' => $langs->trans("Moral"), 'phy' => $langs->trans("Physical")]; |
||
3802 | print $form->selectarray('search_morphy', $arraymorphy, $search_morphy, 1, 0, 0, '', 0, 0, 0, '', 'maxwidth100'); |
||
3803 | print '</td>'; |
||
3804 | } |
||
3805 | |||
3806 | // Member Type |
||
3807 | if (!empty($arrayfields['t.libelle']['checked'])) { |
||
3808 | print '</td>'; |
||
3809 | } |
||
3810 | if (!empty($arrayfields['t.libelle']['checked'])) { |
||
3811 | print '<td class="liste_titre">'; |
||
3812 | $listetype = $membertypestatic->liste_array(); |
||
3813 | // @phan-suppress-next-line PhanPluginSuspiciousParamOrder |
||
3814 | print $form->selectarray("search_type", $listetype, $search_type, 1, 0, 0, '', 0, 32); |
||
3815 | print '</td>'; |
||
3816 | } |
||
3817 | |||
3818 | // Address - Street |
||
3819 | if (!empty($arrayfields['d.address']['checked'])) { |
||
3820 | print '<td class="liste_titre left">'; |
||
3821 | print '<input class="flat maxwidth75imp" type="text" name="search_address" value="' . dol_escape_htmltag($search_address) . '"></td>'; |
||
3822 | } |
||
3823 | |||
3824 | // ZIP |
||
3825 | if (!empty($arrayfields['d.zip']['checked'])) { |
||
3826 | print '<td class="liste_titre left">'; |
||
3827 | print '<input class="flat maxwidth50imp" type="text" name="search_zip" value="' . dol_escape_htmltag($search_zip) . '"></td>'; |
||
3828 | } |
||
3829 | |||
3830 | // Town/City |
||
3831 | if (!empty($arrayfields['d.town']['checked'])) { |
||
3832 | print '<td class="liste_titre left">'; |
||
3833 | print '<input class="flat maxwidth75imp" type="text" name="search_town" value="' . dol_escape_htmltag($search_town) . '"></td>'; |
||
3834 | } |
||
3835 | |||
3836 | // State / County / Departement |
||
3837 | if (!empty($arrayfields['state.nom']['checked'])) { |
||
3838 | print '<td class="liste_titre">'; |
||
3839 | print '<input class="flat searchstring maxwidth75imp" type="text" name="search_state" value="' . dol_escape_htmltag($search_state) . '">'; |
||
3840 | print '</td>'; |
||
3841 | } |
||
3842 | |||
3843 | // Country |
||
3844 | if (!empty($arrayfields['country.code_iso']['checked'])) { |
||
3845 | print '<td class="liste_titre center">'; |
||
3846 | print $form->select_country($search_country, 'search_country', '', 0, 'minwidth100imp maxwidth100'); |
||
3847 | print '</td>'; |
||
3848 | } |
||
3849 | |||
3850 | // Phone pro |
||
3851 | if (!empty($arrayfields['d.phone']['checked'])) { |
||
3852 | print '<td class="liste_titre left">'; |
||
3853 | print '<input class="flat maxwidth75imp" type="text" name="search_phone" value="' . dol_escape_htmltag($search_phone) . '"></td>'; |
||
3854 | } |
||
3855 | |||
3856 | // Phone perso |
||
3857 | if (!empty($arrayfields['d.phone_perso']['checked'])) { |
||
3858 | print '<td class="liste_titre left">'; |
||
3859 | print '<input class="flat maxwidth75imp" type="text" name="search_phone_perso" value="' . dol_escape_htmltag($search_phone_perso) . '"></td>'; |
||
3860 | } |
||
3861 | |||
3862 | // Phone mobile |
||
3863 | if (!empty($arrayfields['d.phone_mobile']['checked'])) { |
||
3864 | print '<td class="liste_titre left">'; |
||
3865 | print '<input class="flat maxwidth75imp" type="text" name="search_phone_mobile" value="' . dol_escape_htmltag($search_phone_mobile) . '"></td>'; |
||
3866 | } |
||
3867 | |||
3868 | |||
3869 | if (!empty($arrayfields['d.email']['checked'])) { |
||
3870 | print '<td class="liste_titre left">'; |
||
3871 | print '<input class="flat maxwidth75imp" type="text" name="search_email" value="' . dol_escape_htmltag($search_email) . '"></td>'; |
||
3872 | } |
||
3873 | |||
3874 | // End of subscription date |
||
3875 | if (!empty($arrayfields['d.datefin']['checked'])) { |
||
3876 | print '<td class="liste_titre center">'; |
||
3877 | //$selectarray = array('-1'=>'', 'withoutsubscription'=>$langs->trans("WithoutSubscription"), 'uptodate'=>$langs->trans("UpToDate"), 'outofdate'=>$langs->trans("OutOfDate")); |
||
3878 | $selectarray = ['-1' => '', 'waitingsubscription' => $langs->trans("WaitingSubscription"), 'uptodate' => $langs->trans("UpToDate"), 'outofdate' => $langs->trans("OutOfDate")]; |
||
3879 | print $form->selectarray('search_filter', $selectarray, $search_filter); |
||
3880 | print '</td>'; |
||
3881 | } |
||
3882 | |||
3883 | // Extra fields |
||
3884 | include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_list_search_input.tpl.php'; |
||
3885 | |||
3886 | // Fields from hook |
||
3887 | $parameters = ['arrayfields' => $arrayfields]; |
||
3888 | $reshook = $hookmanager->executeHooks('printFieldListOption', $parameters); // Note that $action and $object may have been modified by hook |
||
3889 | print $hookmanager->resPrint; |
||
3890 | |||
3891 | // Date creation |
||
3892 | if (!empty($arrayfields['d.datec']['checked'])) { |
||
3893 | print '<td class="liste_titre">'; |
||
3894 | print '<div class="nowrapfordate">'; |
||
3895 | print $form->selectDate($search_datec_start ? $search_datec_start : -1, 'search_datec_start_', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('From')); |
||
3896 | print '</div>'; |
||
3897 | print '<div class="nowrapfordate">'; |
||
3898 | print $form->selectDate($search_datec_end ? $search_datec_end : -1, 'search_datec_end_', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('to')); |
||
3899 | print '</div>'; |
||
3900 | print '</td>'; |
||
3901 | } |
||
3902 | |||
3903 | // Birthday |
||
3904 | if (!empty($arrayfields['d.birth']['checked'])) { |
||
3905 | print '<td class="liste_titre">'; |
||
3906 | print '</td>'; |
||
3907 | } |
||
3908 | |||
3909 | // Date modification |
||
3910 | if (!empty($arrayfields['d.tms']['checked'])) { |
||
3911 | print '<td class="liste_titre">'; |
||
3912 | print '<div class="nowrapfordate">'; |
||
3913 | print $form->selectDate($search_datem_start ? $search_datem_start : -1, 'search_datem_start_', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('From')); |
||
3914 | print '</div>'; |
||
3915 | print '<div class="nowrapfordate">'; |
||
3916 | print $form->selectDate($search_datem_end ? $search_datem_end : -1, 'search_datem_end_', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('to')); |
||
3917 | print '</div>'; |
||
3918 | print '</td>'; |
||
3919 | } |
||
3920 | |||
3921 | // Import Key |
||
3922 | if (!empty($arrayfields['d.import_key']['checked'])) { |
||
3923 | print '<td class="liste_titre center">'; |
||
3924 | print '<input class="flat searchstring maxwidth50" type="text" name="search_import_key" value="' . dol_escape_htmltag($search_import_key) . '">'; |
||
3925 | print '</td>'; |
||
3926 | } |
||
3927 | |||
3928 | // Status |
||
3929 | if (!empty($arrayfields['d.statut']['checked'])) { |
||
3930 | print '<td class="liste_titre center parentonrightofpage">'; |
||
3931 | $liststatus = [ |
||
3932 | Adherent::STATUS_DRAFT => $langs->trans("Draft"), |
||
3933 | Adherent::STATUS_VALIDATED => $langs->trans("Validated"), |
||
3934 | Adherent::STATUS_RESILIATED => $langs->trans("MemberStatusResiliatedShort"), |
||
3935 | Adherent::STATUS_EXCLUDED => $langs->trans("MemberStatusExcludedShort"), |
||
3936 | ]; |
||
3937 | // @phan-suppress-next-line PhanPluginSuspiciousParamOrder |
||
3938 | print $form->selectarray('search_status', $liststatus, $search_status, -3, 0, 0, '', 0, 0, 0, '', 'search_status width100 onrightofpage'); |
||
3939 | print '</td>'; |
||
3940 | } |
||
3941 | |||
3942 | // Action column |
||
3943 | if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { |
||
3944 | print '<td class="liste_titre center maxwidthsearch">'; |
||
3945 | $searchpicto = $form->showFilterButtons(); |
||
3946 | print $searchpicto; |
||
3947 | print '</td>'; |
||
3948 | } |
||
3949 | print '</tr>' . "\n"; |
||
3950 | |||
3951 | $totalarray = []; |
||
3952 | $totalarray['nbfield'] = 0; |
||
3953 | |||
3954 | // Fields title label |
||
3955 | // -------------------------------------------------------------------- |
||
3956 | print '<tr class="liste_titre">'; |
||
3957 | // Action column |
||
3958 | if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { |
||
3959 | print_liste_field_titre($selectedfields, $_SERVER['PHP_SELF'], "", '', '', '', $sortfield, $sortorder, 'center maxwidthsearch actioncolumn '); |
||
3960 | $totalarray['nbfield']++; |
||
3961 | } |
||
3962 | if (getDolGlobalString('MAIN_SHOW_TECHNICAL_ID')) { |
||
3963 | print_liste_field_titre("ID", $_SERVER['PHP_SELF'], '', '', $param, '', $sortfield, $sortorder, 'center '); |
||
3964 | $totalarray['nbfield']++; |
||
3965 | } |
||
3966 | if (!empty($arrayfields['d.ref']['checked'])) { |
||
3967 | print_liste_field_titre($arrayfields['d.ref']['label'], $_SERVER['PHP_SELF'], 'd.ref', '', $param, '', $sortfield, $sortorder); |
||
3968 | $totalarray['nbfield']++; |
||
3969 | } |
||
3970 | if (!empty($arrayfields['d.civility']['checked'])) { |
||
3971 | print_liste_field_titre($arrayfields['d.civility']['label'], $_SERVER['PHP_SELF'], 'd.civility', '', $param, '', $sortfield, $sortorder); |
||
3972 | $totalarray['nbfield']++; |
||
3973 | } |
||
3974 | if (!empty($arrayfields['d.firstname']['checked'])) { |
||
3975 | print_liste_field_titre($arrayfields['d.firstname']['label'], $_SERVER['PHP_SELF'], 'd.firstname', '', $param, '', $sortfield, $sortorder); |
||
3976 | $totalarray['nbfield']++; |
||
3977 | } |
||
3978 | if (!empty($arrayfields['d.lastname']['checked'])) { |
||
3979 | print_liste_field_titre($arrayfields['d.lastname']['label'], $_SERVER['PHP_SELF'], 'd.lastname', '', $param, '', $sortfield, $sortorder); |
||
3980 | $totalarray['nbfield']++; |
||
3981 | } |
||
3982 | if (!empty($arrayfields['d.gender']['checked'])) { |
||
3983 | print_liste_field_titre($arrayfields['d.gender']['label'], $_SERVER['PHP_SELF'], 'd.gender', $param, "", "", $sortfield, $sortorder); |
||
3984 | $totalarray['nbfield']++; |
||
3985 | } |
||
3986 | if (!empty($arrayfields['d.company']['checked'])) { |
||
3987 | print_liste_field_titre($arrayfields['d.company']['label'], $_SERVER['PHP_SELF'], 'companyname', '', $param, '', $sortfield, $sortorder); |
||
3988 | $totalarray['nbfield']++; |
||
3989 | } |
||
3990 | if (!empty($arrayfields['d.login']['checked'])) { |
||
3991 | print_liste_field_titre($arrayfields['d.login']['label'], $_SERVER['PHP_SELF'], 'd.login', '', $param, '', $sortfield, $sortorder); |
||
3992 | $totalarray['nbfield']++; |
||
3993 | } |
||
3994 | if (!empty($arrayfields['d.morphy']['checked'])) { |
||
3995 | print_liste_field_titre($arrayfields['d.morphy']['label'], $_SERVER['PHP_SELF'], 'd.morphy', '', $param, '', $sortfield, $sortorder); |
||
3996 | $totalarray['nbfield']++; |
||
3997 | } |
||
3998 | if (!empty($arrayfields['t.libelle']['checked'])) { |
||
3999 | print_liste_field_titre($arrayfields['t.libelle']['label'], $_SERVER['PHP_SELF'], 't.libelle', '', $param, '', $sortfield, $sortorder); |
||
4000 | $totalarray['nbfield']++; |
||
4001 | } |
||
4002 | if (!empty($arrayfields['d.address']['checked'])) { |
||
4003 | print_liste_field_titre($arrayfields['d.address']['label'], $_SERVER['PHP_SELF'], 'd.address', '', $param, '', $sortfield, $sortorder); |
||
4004 | $totalarray['nbfield']++; |
||
4005 | } |
||
4006 | if (!empty($arrayfields['d.zip']['checked'])) { |
||
4007 | print_liste_field_titre($arrayfields['d.zip']['label'], $_SERVER['PHP_SELF'], 'd.zip', '', $param, '', $sortfield, $sortorder); |
||
4008 | $totalarray['nbfield']++; |
||
4009 | } |
||
4010 | if (!empty($arrayfields['d.town']['checked'])) { |
||
4011 | print_liste_field_titre($arrayfields['d.town']['label'], $_SERVER['PHP_SELF'], 'd.town', '', $param, '', $sortfield, $sortorder); |
||
4012 | $totalarray['nbfield']++; |
||
4013 | } |
||
4014 | if (!empty($arrayfields['state.nom']['checked'])) { |
||
4015 | print_liste_field_titre($arrayfields['state.nom']['label'], $_SERVER['PHP_SELF'], "state.nom", "", $param, '', $sortfield, $sortorder); |
||
4016 | $totalarray['nbfield']++; |
||
4017 | } |
||
4018 | if (!empty($arrayfields['country.code_iso']['checked'])) { |
||
4019 | print_liste_field_titre($arrayfields['country.code_iso']['label'], $_SERVER['PHP_SELF'], "country.code_iso", "", $param, '', $sortfield, $sortorder, 'center '); |
||
4020 | $totalarray['nbfield']++; |
||
4021 | } |
||
4022 | if (!empty($arrayfields['d.phone']['checked'])) { |
||
4023 | print_liste_field_titre($arrayfields['d.phone']['label'], $_SERVER['PHP_SELF'], 'd.phone', '', $param, '', $sortfield, $sortorder); |
||
4024 | $totalarray['nbfield']++; |
||
4025 | } |
||
4026 | if (!empty($arrayfields['d.phone_perso']['checked'])) { |
||
4027 | print_liste_field_titre($arrayfields['d.phone_perso']['label'], $_SERVER['PHP_SELF'], 'd.phone_perso', '', $param, '', $sortfield, $sortorder); |
||
4028 | $totalarray['nbfield']++; |
||
4029 | } |
||
4030 | if (!empty($arrayfields['d.phone_mobile']['checked'])) { |
||
4031 | print_liste_field_titre($arrayfields['d.phone_mobile']['label'], $_SERVER['PHP_SELF'], 'd.phone_mobile', '', $param, '', $sortfield, $sortorder); |
||
4032 | $totalarray['nbfield']++; |
||
4033 | } |
||
4034 | if (!empty($arrayfields['d.email']['checked'])) { |
||
4035 | print_liste_field_titre($arrayfields['d.email']['label'], $_SERVER['PHP_SELF'], 'd.email', '', $param, '', $sortfield, $sortorder); |
||
4036 | $totalarray['nbfield']++; |
||
4037 | } |
||
4038 | if (!empty($arrayfields['d.datefin']['checked'])) { |
||
4039 | print_liste_field_titre($arrayfields['d.datefin']['label'], $_SERVER['PHP_SELF'], 'd.datefin,t.subscription', '', $param, '', $sortfield, $sortorder, 'center '); |
||
4040 | $totalarray['nbfield']++; |
||
4041 | } |
||
4042 | // Extra fields |
||
4043 | include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_list_search_title.tpl.php'; |
||
4044 | |||
4045 | // Hook fields |
||
4046 | $parameters = ['arrayfields' => $arrayfields, 'totalarray' => &$totalarray, 'param' => $param, 'sortfield' => $sortfield, 'sortorder' => $sortorder]; |
||
4047 | $reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters); // Note that $action and $object may have been modified by hook |
||
4048 | print $hookmanager->resPrint; |
||
4049 | |||
4050 | if (!empty($arrayfields['d.datec']['checked'])) { |
||
4051 | print_liste_field_titre($arrayfields['d.datec']['label'], $_SERVER['PHP_SELF'], "d.datec", "", $param, '', $sortfield, $sortorder, 'center nowrap '); |
||
4052 | $totalarray['nbfield']++; |
||
4053 | } |
||
4054 | if (!empty($arrayfields['d.birth']['checked'])) { |
||
4055 | print_liste_field_titre($arrayfields['d.birth']['label'], $_SERVER['PHP_SELF'], "d.birth", "", $param, '', $sortfield, $sortorder, 'center nowrap '); |
||
4056 | $totalarray['nbfield']++; |
||
4057 | } |
||
4058 | if (!empty($arrayfields['d.tms']['checked'])) { |
||
4059 | print_liste_field_titre($arrayfields['d.tms']['label'], $_SERVER['PHP_SELF'], "d.tms", "", $param, '', $sortfield, $sortorder, 'center nowrap '); |
||
4060 | $totalarray['nbfield']++; |
||
4061 | } |
||
4062 | if (!empty($arrayfields['d.import_key']['checked'])) { |
||
4063 | print_liste_field_titre($arrayfields['d.import_key']['label'], $_SERVER['PHP_SELF'], "d.import_key", "", $param, '', $sortfield, $sortorder, 'center '); |
||
4064 | $totalarray['nbfield']++; |
||
4065 | } |
||
4066 | if (!empty($arrayfields['d.statut']['checked'])) { |
||
4067 | print_liste_field_titre($arrayfields['d.statut']['label'], $_SERVER['PHP_SELF'], "d.statut,t.subscription,d.datefin", "", $param, '', $sortfield, $sortorder, 'center '); |
||
4068 | $totalarray['nbfield']++; |
||
4069 | } |
||
4070 | if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { |
||
4071 | print_liste_field_titre($selectedfields, $_SERVER['PHP_SELF'], "", '', '', '', $sortfield, $sortorder, 'maxwidthsearch center '); |
||
4072 | $totalarray['nbfield']++; |
||
4073 | } |
||
4074 | print "</tr>\n"; |
||
4075 | |||
4076 | // Loop on record |
||
4077 | // -------------------------------------------------------------------- |
||
4078 | $i = 0; |
||
4079 | $savnbfield = $totalarray['nbfield']; |
||
4080 | $totalarray = []; |
||
4081 | $totalarray['nbfield'] = 0; |
||
4082 | $imaxinloop = ($limit ? min($num, $limit) : $num); |
||
4083 | while ($i < $imaxinloop) { |
||
4084 | $obj = $db->fetch_object($resql); |
||
4085 | if (empty($obj)) { |
||
4086 | break; // Should not happen |
||
4087 | } |
||
4088 | |||
4089 | $datefin = $db->jdate($obj->datefin); |
||
4090 | |||
4091 | $memberstatic->id = $obj->rowid; |
||
4092 | $memberstatic->ref = $obj->ref; |
||
4093 | $memberstatic->civility_id = $obj->civility; |
||
4094 | $memberstatic->login = $obj->login; |
||
4095 | $memberstatic->lastname = $obj->lastname; |
||
4096 | $memberstatic->firstname = $obj->firstname; |
||
4097 | $memberstatic->gender = $obj->gender; |
||
4098 | $memberstatic->statut = $obj->status; |
||
4099 | $memberstatic->status = $obj->status; |
||
4100 | $memberstatic->datefin = $datefin; |
||
4101 | $memberstatic->socid = $obj->fk_soc; |
||
4102 | $memberstatic->photo = $obj->photo; |
||
4103 | $memberstatic->email = $obj->email; |
||
4104 | $memberstatic->morphy = $obj->morphy; |
||
4105 | $memberstatic->note_public = $obj->note_public; |
||
4106 | $memberstatic->note_private = $obj->note_private; |
||
4107 | $memberstatic->need_subscription = $obj->subscription; |
||
4108 | |||
4109 | if (!empty($obj->fk_soc)) { |
||
4110 | $memberstatic->fetch_thirdparty(); |
||
4111 | if ($memberstatic->thirdparty->id > 0) { |
||
4112 | $companyname = $memberstatic->thirdparty->name; |
||
4113 | $companynametoshow = $memberstatic->thirdparty->getNomUrl(1); |
||
4114 | } |
||
4115 | } else { |
||
4116 | $companyname = $obj->company; |
||
4117 | $companynametoshow = $obj->company; |
||
4118 | } |
||
4119 | $memberstatic->company = $companyname; |
||
4120 | |||
4121 | $object = $memberstatic; |
||
4122 | |||
4123 | if ($mode == 'kanban') { |
||
4124 | if ($i == 0) { |
||
4125 | print '<tr class="trkanban"><td colspan="' . $savnbfield . '">'; |
||
4126 | print '<div class="box-flex-container kanban">'; |
||
4127 | } |
||
4128 | $membertypestatic->id = $obj->type_id; |
||
4129 | $membertypestatic->label = $obj->type; |
||
4130 | $memberstatic->type = $membertypestatic->label; |
||
4131 | $memberstatic->photo = $obj->photo; |
||
4132 | // Output Kanban |
||
4133 | print $memberstatic->getKanbanView('', ['selected' => in_array($object->id, $arrayofselected)]); |
||
4134 | if ($i == (min($num, $limit) - 1)) { |
||
4135 | print '</div>'; |
||
4136 | print '</td></tr>'; |
||
4137 | } |
||
4138 | } else { |
||
4139 | // Show line of result |
||
4140 | $j = 0; |
||
4141 | print '<tr data-rowid="' . $object->id . '" class="oddeven">'; |
||
4142 | |||
4143 | // Action column |
||
4144 | if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { |
||
4145 | print '<td class="nowrap center">'; |
||
4146 | if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined |
||
4147 | $selected = 0; |
||
4148 | if (in_array($obj->rowid, $arrayofselected)) { |
||
4149 | $selected = 1; |
||
4150 | } |
||
4151 | print '<input id="cb' . $obj->rowid . '" class="flat checkforselect" type="checkbox" name="toselect[]" value="' . $obj->rowid . '"' . ($selected ? ' checked="checked"' : '') . '>'; |
||
4152 | } |
||
4153 | print '</td>'; |
||
4154 | if (!$i) { |
||
4155 | $totalarray['nbfield']++; |
||
4156 | } |
||
4157 | } |
||
4158 | // Technical ID |
||
4159 | if (getDolGlobalString('MAIN_SHOW_TECHNICAL_ID')) { |
||
4160 | print '<td class="center" data-key="id">' . $obj->rowid . '</td>'; |
||
4161 | if (!$i) { |
||
4162 | $totalarray['nbfield']++; |
||
4163 | } |
||
4164 | } |
||
4165 | // Ref |
||
4166 | if (!empty($arrayfields['d.ref']['checked'])) { |
||
4167 | print "<td>"; |
||
4168 | print $memberstatic->getNomUrl(-1, 0, 'card', 'ref', '', -1, 0, 1); |
||
4169 | print "</td>\n"; |
||
4170 | if (!$i) { |
||
4171 | $totalarray['nbfield']++; |
||
4172 | } |
||
4173 | } |
||
4174 | // Civility |
||
4175 | if (!empty($arrayfields['d.civility']['checked'])) { |
||
4176 | print "<td>"; |
||
4177 | print $obj->civility; |
||
4178 | print "</td>\n"; |
||
4179 | if (!$i) { |
||
4180 | $totalarray['nbfield']++; |
||
4181 | } |
||
4182 | } |
||
4183 | // Firstname |
||
4184 | if (!empty($arrayfields['d.firstname']['checked'])) { |
||
4185 | print '<td class="tdoverflowmax150" title="' . dol_escape_htmltag($obj->firstname) . '">'; |
||
4186 | print $memberstatic->getNomUrl(0, 0, 'card', 'firstname'); |
||
4187 | //print $obj->firstname; |
||
4188 | print "</td>\n"; |
||
4189 | if (!$i) { |
||
4190 | $totalarray['nbfield']++; |
||
4191 | } |
||
4192 | } |
||
4193 | // Lastname |
||
4194 | if (!empty($arrayfields['d.lastname']['checked'])) { |
||
4195 | print '<td class="tdoverflowmax150" title="' . dol_escape_htmltag($obj->lastname) . '">'; |
||
4196 | print $memberstatic->getNomUrl(0, 0, 'card', 'lastname'); |
||
4197 | //print $obj->lastname; |
||
4198 | print "</td>\n"; |
||
4199 | if (!$i) { |
||
4200 | $totalarray['nbfield']++; |
||
4201 | } |
||
4202 | } |
||
4203 | // Gender |
||
4204 | if (!empty($arrayfields['d.gender']['checked'])) { |
||
4205 | print '<td>'; |
||
4206 | if ($obj->gender) { |
||
4207 | print $langs->trans("Gender" . $obj->gender); |
||
4208 | } |
||
4209 | print '</td>'; |
||
4210 | if (!$i) { |
||
4211 | $totalarray['nbfield']++; |
||
4212 | } |
||
4213 | } |
||
4214 | // Company |
||
4215 | if (!empty($arrayfields['d.company']['checked'])) { |
||
4216 | print '<td class="tdoverflowmax150" title="' . dol_escape_htmltag($companyname) . '">'; |
||
4217 | print $companynametoshow; |
||
4218 | print "</td>\n"; |
||
4219 | } |
||
4220 | // Login |
||
4221 | if (!empty($arrayfields['d.login']['checked'])) { |
||
4222 | print '<td class="tdoverflowmax150" title="' . dol_escape_htmltag($obj->login) . '">' . $obj->login . "</td>\n"; |
||
4223 | if (!$i) { |
||
4224 | $totalarray['nbfield']++; |
||
4225 | } |
||
4226 | } |
||
4227 | // Nature (Moral/Physical) |
||
4228 | if (!empty($arrayfields['d.morphy']['checked'])) { |
||
4229 | print '<td class="center">'; |
||
4230 | print $memberstatic->getmorphylib('', 2); |
||
4231 | print "</td>\n"; |
||
4232 | if (!$i) { |
||
4233 | $totalarray['nbfield']++; |
||
4234 | } |
||
4235 | } |
||
4236 | // Type label |
||
4237 | if (!empty($arrayfields['t.libelle']['checked'])) { |
||
4238 | $membertypestatic->id = $obj->type_id; |
||
4239 | $membertypestatic->label = $obj->type; |
||
4240 | print '<td class="nowraponall">'; |
||
4241 | print $membertypestatic->getNomUrl(1, 32); |
||
4242 | print '</td>'; |
||
4243 | if (!$i) { |
||
4244 | $totalarray['nbfield']++; |
||
4245 | } |
||
4246 | } |
||
4247 | // Address |
||
4248 | if (!empty($arrayfields['d.address']['checked'])) { |
||
4249 | print '<td class="nocellnopadd tdoverflowmax200" title="' . dol_escape_htmltag($obj->address) . '">'; |
||
4250 | print $obj->address; |
||
4251 | print '</td>'; |
||
4252 | if (!$i) { |
||
4253 | $totalarray['nbfield']++; |
||
4254 | } |
||
4255 | } |
||
4256 | // Zip |
||
4257 | if (!empty($arrayfields['d.zip']['checked'])) { |
||
4258 | print '<td class="nocellnopadd">'; |
||
4259 | print $obj->zip; |
||
4260 | print '</td>'; |
||
4261 | if (!$i) { |
||
4262 | $totalarray['nbfield']++; |
||
4263 | } |
||
4264 | } |
||
4265 | // Town |
||
4266 | if (!empty($arrayfields['d.town']['checked'])) { |
||
4267 | print '<td class="nocellnopadd">'; |
||
4268 | print $obj->town; |
||
4269 | print '</td>'; |
||
4270 | if (!$i) { |
||
4271 | $totalarray['nbfield']++; |
||
4272 | } |
||
4273 | } |
||
4274 | // State / County / Departement |
||
4275 | if (!empty($arrayfields['state.nom']['checked'])) { |
||
4276 | print "<td>" . $obj->state_name . "</td>\n"; |
||
4277 | if (!$i) { |
||
4278 | $totalarray['nbfield']++; |
||
4279 | } |
||
4280 | } |
||
4281 | // Country |
||
4282 | if (!empty($arrayfields['country.code_iso']['checked'])) { |
||
4283 | $tmparray = getCountry($obj->country, 'all'); |
||
4284 | print '<td class="center tdoverflowmax100" title="' . dol_escape_htmltag($tmparray['label']) . '">'; |
||
4285 | print dol_escape_htmltag($tmparray['label']); |
||
4286 | print '</td>'; |
||
4287 | if (!$i) { |
||
4288 | $totalarray['nbfield']++; |
||
4289 | } |
||
4290 | } |
||
4291 | // Phone pro |
||
4292 | if (!empty($arrayfields['d.phone']['checked'])) { |
||
4293 | print '<td class="nocellnopadd">'; |
||
4294 | print $obj->phone; |
||
4295 | print '</td>'; |
||
4296 | if (!$i) { |
||
4297 | $totalarray['nbfield']++; |
||
4298 | } |
||
4299 | } |
||
4300 | // Phone perso |
||
4301 | if (!empty($arrayfields['d.phone_perso']['checked'])) { |
||
4302 | print '<td class="nocellnopadd">'; |
||
4303 | print $obj->phone_perso; |
||
4304 | print '</td>'; |
||
4305 | if (!$i) { |
||
4306 | $totalarray['nbfield']++; |
||
4307 | } |
||
4308 | } |
||
4309 | // Phone mobile |
||
4310 | if (!empty($arrayfields['d.phone_mobile']['checked'])) { |
||
4311 | print '<td class="nocellnopadd">'; |
||
4312 | print $obj->phone_mobile; |
||
4313 | print '</td>'; |
||
4314 | if (!$i) { |
||
4315 | $totalarray['nbfield']++; |
||
4316 | } |
||
4317 | } |
||
4318 | |||
4319 | if (!empty($arrayfields['d.email']['checked'])) { |
||
4320 | print '<td class="tdoverflowmax150" title="' . dol_escape_htmltag($obj->email) . '">'; |
||
4321 | print dol_print_email($obj->email, 0, 0, 1, 64, 1, 1); |
||
4322 | print "</td>\n"; |
||
4323 | if (!$i) { |
||
4324 | $totalarray['nbfield']++; |
||
4325 | } |
||
4326 | } |
||
4327 | // End of subscription date |
||
4328 | $datefin = $db->jdate($obj->datefin); |
||
4329 | if (!empty($arrayfields['d.datefin']['checked'])) { |
||
4330 | print '<td class="nowraponall center">'; |
||
4331 | if ($datefin) { |
||
4332 | print dol_print_date($datefin, 'day'); |
||
4333 | if ($memberstatic->hasDelay()) { |
||
4334 | $textlate = ' (' . $langs->trans("DateReference") . ' > ' . $langs->trans("DateToday") . ' ' . (ceil($conf->adherent->subscription->warning_delay / 60 / 60 / 24) >= 0 ? '+' : '') . ceil($conf->adherent->subscription->warning_delay / 60 / 60 / 24) . ' ' . $langs->trans("days") . ')'; |
||
4335 | print " " . img_warning($langs->trans("SubscriptionLate") . $textlate); |
||
4336 | } |
||
4337 | } else { |
||
4338 | if (!empty($obj->subscription)) { |
||
4339 | print '<span class="opacitymedium">' . $langs->trans("SubscriptionNotReceived") . '</span>'; |
||
4340 | if ($obj->status > 0) { |
||
4341 | print " " . img_warning(); |
||
4342 | } |
||
4343 | } else { |
||
4344 | print ' '; |
||
4345 | } |
||
4346 | } |
||
4347 | print '</td>'; |
||
4348 | if (!$i) { |
||
4349 | $totalarray['nbfield']++; |
||
4350 | } |
||
4351 | } |
||
4352 | // Extra fields |
||
4353 | include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_list_print_fields.tpl.php'; |
||
4354 | // Fields from hook |
||
4355 | $parameters = ['arrayfields' => $arrayfields, 'obj' => $obj, 'i' => $i, 'totalarray' => &$totalarray]; |
||
4356 | $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters); // Note that $action and $object may have been modified by hook |
||
4357 | print $hookmanager->resPrint; |
||
4358 | // Date creation |
||
4359 | if (!empty($arrayfields['d.datec']['checked'])) { |
||
4360 | print '<td class="nowrap center">'; |
||
4361 | print dol_print_date($db->jdate($obj->date_creation), 'dayhour', 'tzuser'); |
||
4362 | print '</td>'; |
||
4363 | if (!$i) { |
||
4364 | $totalarray['nbfield']++; |
||
4365 | } |
||
4366 | } |
||
4367 | // Birth |
||
4368 | if (!empty($arrayfields['d.birth']['checked'])) { |
||
4369 | print '<td class="nowrap center">'; |
||
4370 | print dol_print_date($db->jdate($obj->birth), 'day', 'tzuser'); |
||
4371 | print '</td>'; |
||
4372 | if (!$i) { |
||
4373 | $totalarray['nbfield']++; |
||
4374 | } |
||
4375 | } |
||
4376 | // Date modification |
||
4377 | if (!empty($arrayfields['d.tms']['checked'])) { |
||
4378 | print '<td class="nowrap center">'; |
||
4379 | print dol_print_date($db->jdate($obj->date_modification), 'dayhour', 'tzuser'); |
||
4380 | print '</td>'; |
||
4381 | if (!$i) { |
||
4382 | $totalarray['nbfield']++; |
||
4383 | } |
||
4384 | } |
||
4385 | // Import key |
||
4386 | if (!empty($arrayfields['d.import_key']['checked'])) { |
||
4387 | print '<td class="tdoverflowmax100 center" title="' . dol_escape_htmltag($obj->import_key) . '">'; |
||
4388 | print dol_escape_htmltag($obj->import_key); |
||
4389 | print "</td>\n"; |
||
4390 | if (!$i) { |
||
4391 | $totalarray['nbfield']++; |
||
4392 | } |
||
4393 | } |
||
4394 | // Status |
||
4395 | if (!empty($arrayfields['d.statut']['checked'])) { |
||
4396 | print '<td class="nowrap center">'; |
||
4397 | print $memberstatic->LibStatut($obj->status, $obj->subscription, $datefin, 5); |
||
4398 | print '</td>'; |
||
4399 | if (!$i) { |
||
4400 | $totalarray['nbfield']++; |
||
4401 | } |
||
4402 | } |
||
4403 | // Action column |
||
4404 | if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { |
||
4405 | print '<td class="center">'; |
||
4406 | if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined |
||
4407 | $selected = 0; |
||
4408 | if (in_array($obj->rowid, $arrayofselected)) { |
||
4409 | $selected = 1; |
||
4410 | } |
||
4411 | print '<input id="cb' . $obj->rowid . '" class="flat checkforselect" type="checkbox" name="toselect[]" value="' . $obj->rowid . '"' . ($selected ? ' checked="checked"' : '') . '>'; |
||
4412 | } |
||
4413 | print '</td>'; |
||
4414 | if (!$i) { |
||
4415 | $totalarray['nbfield']++; |
||
4416 | } |
||
4417 | } |
||
4418 | |||
4419 | print '</tr>' . "\n"; |
||
4420 | } |
||
4421 | $i++; |
||
4422 | } |
||
4423 | |||
4424 | // Show total line |
||
4425 | include DOL_DOCUMENT_ROOT . '/core/tpl/list_print_total.tpl.php'; |
||
4426 | |||
4427 | |||
4428 | // If no record found |
||
4429 | if ($num == 0) { |
||
4430 | $colspan = 1; |
||
4431 | foreach ($arrayfields as $key => $val) { |
||
4432 | if (!empty($val['checked'])) { |
||
4433 | $colspan++; |
||
4434 | } |
||
4435 | } |
||
4436 | print '<tr><td colspan="' . $colspan . '"><span class="opacitymedium">' . $langs->trans("NoRecordFound") . '</span></td></tr>'; |
||
4437 | } |
||
4438 | |||
4439 | $db->free($resql); |
||
4440 | |||
4441 | $parameters = ['arrayfields' => $arrayfields, 'sql' => $sql]; |
||
4442 | $reshook = $hookmanager->executeHooks('printFieldListFooter', $parameters, $object, $action); // Note that $action and $object may have been modified by hook |
||
4443 | print $hookmanager->resPrint; |
||
4444 | |||
4445 | print '</table>' . "\n"; |
||
4446 | print '</div>' . "\n"; |
||
4447 | |||
4448 | print '</form>' . "\n"; |
||
4449 | |||
4450 | if (in_array('builddoc', array_keys($arrayofmassactions)) && ($nbtotalofrecords === '' || $nbtotalofrecords)) { |
||
4451 | $hidegeneratedfilelistifempty = 1; |
||
4452 | if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) { |
||
4453 | $hidegeneratedfilelistifempty = 0; |
||
4454 | } |
||
4455 | |||
4456 | require_once DOL_DOCUMENT_ROOT . '/core/class/html.formfile.class.php'; |
||
4457 | $formfile = new FormFile($db); |
||
4458 | |||
4459 | // Show list of available documents |
||
4460 | $urlsource = $_SERVER['PHP_SELF'] . '?sortfield=' . $sortfield . '&sortorder=' . $sortorder; |
||
4461 | $urlsource .= str_replace('&', '&', $param); |
||
4462 | |||
4463 | $filedir = $diroutputmassaction; |
||
4464 | $genallowed = $permissiontoread; |
||
4465 | $delallowed = $permissiontoadd; |
||
4466 | |||
4467 | print $formfile->showdocuments('massfilesarea_' . $object->module, '', $filedir, $urlsource, 0, $delallowed, '', 1, 1, 0, 48, 1, $param, $title, '', '', '', null, $hidegeneratedfilelistifempty); |
||
4468 | } |
||
4469 | |||
4470 | // End of page |
||
4471 | llxFooter(); |
||
4472 | $db->close(); |
||
4473 | } |
||
4474 | |||
4475 | /** |
||
4476 | * \file htdocs/adherents/note.php |
||
4477 | * \ingroup member |
||
4478 | * \brief Tab for note of a member |
||
4479 | */ |
||
4480 | public function note() |
||
4481 | { |
||
4482 | global $conf; |
||
4483 | global $db; |
||
4484 | global $user; |
||
4485 | global $hookmanager; |
||
4486 | global $user; |
||
4487 | global $menumanager; |
||
4488 | global $langs; |
||
4489 | |||
4490 | // Load translation files required by the page |
||
4491 | $langs->loadLangs(array("companies", "members", "bills")); |
||
4492 | |||
4493 | |||
4494 | // Get parameters |
||
4495 | $action = GETPOST('action', 'aZ09'); |
||
4496 | $id = GETPOSTINT('id'); |
||
4497 | $ref = GETPOST('ref', 'alphanohtml'); |
||
4498 | |||
4499 | |||
4500 | // Initialize objects |
||
4501 | $object = new Adherent($db); |
||
4502 | |||
4503 | $result = $object->fetch($id); |
||
4504 | if ($result > 0) { |
||
4505 | $adht = new AdherentType($db); |
||
4506 | $result = $adht->fetch($object->typeid); |
||
4507 | } |
||
4508 | |||
4509 | |||
4510 | $permissionnote = $user->hasRight('adherent', 'creer'); // Used by the include of actions_setnotes.inc.php |
||
4511 | |||
4512 | // Fetch object |
||
4513 | if ($id > 0 || !empty($ref)) { |
||
4514 | // Load member |
||
4515 | $result = $object->fetch($id, $ref); |
||
4516 | |||
4517 | // Define variables to know what current user can do on users |
||
4518 | $canadduser = ($user->admin || $user->hasRight('user', 'user', 'creer')); |
||
4519 | // Define variables to know what current user can do on properties of user linked to edited member |
||
4520 | if ($object->user_id) { |
||
4521 | // $User is the user who edits, $object->user_id is the id of the related user in the edited member |
||
4522 | $caneditfielduser = ((($user->id == $object->user_id) && $user->hasRight('user', 'self', 'creer')) |
||
4523 | || (($user->id != $object->user_id) && $user->hasRight('user', 'user', 'creer'))); |
||
4524 | $caneditpassworduser = ((($user->id == $object->user_id) && $user->hasRight('user', 'self', 'password')) |
||
4525 | || (($user->id != $object->user_id) && $user->hasRight('user', 'user', 'password'))); |
||
4526 | } |
||
4527 | } |
||
4528 | |||
4529 | // Define variables to determine what the current user can do on the members |
||
4530 | $canaddmember = $user->hasRight('adherent', 'creer'); |
||
4531 | // Define variables to determine what the current user can do on the properties of a member |
||
4532 | if ($id) { |
||
4533 | $caneditfieldmember = $user->hasRight('adherent', 'creer'); |
||
4534 | } |
||
4535 | |||
4536 | $hookmanager->initHooks(array('membernote')); |
||
4537 | |||
4538 | // Security check |
||
4539 | $result = restrictedArea($user, 'adherent', $object->id, '', '', 'socid', 'rowid', 0); |
||
4540 | |||
4541 | /* |
||
4542 | * Actions |
||
4543 | */ |
||
4544 | $parameters = array(); |
||
4545 | $reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks |
||
4546 | if ($reshook < 0) { |
||
4547 | setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); |
||
4548 | } |
||
4549 | if (empty($reshook)) { |
||
4550 | include DOL_DOCUMENT_ROOT . '/core/actions_setnotes.inc.php'; // Must be include, not include_once |
||
4551 | } |
||
4552 | |||
4553 | |||
4554 | /* |
||
4555 | * View |
||
4556 | */ |
||
4557 | |||
4558 | $title = $langs->trans("Member") . " - " . $langs->trans("Note"); |
||
4559 | |||
4560 | $help_url = "EN:Module_Foundations|FR:Module_Adhérents|ES:Módulo_Miembros|DE:Modul_Mitglieder"; |
||
4561 | |||
4562 | llxHeader("", $title, $help_url); |
||
4563 | |||
4564 | $form = new Form($db); |
||
4565 | |||
4566 | if ($id) { |
||
4567 | $head = member_prepare_head($object); |
||
4568 | |||
4569 | print dol_get_fiche_head($head, 'note', $langs->trans("Member"), -1, 'user'); |
||
4570 | |||
4571 | print '<form method="POST" action="' . $_SERVER['PHP_SELF'] . '">'; |
||
4572 | print '<input type="hidden" name="token" value="' . newToken() . '">'; |
||
4573 | |||
4574 | $linkback = '<a href="' . DOL_URL_ROOT . '/adherents/list.php?restore_lastsearch_values=1">' . $langs->trans("BackToList") . '</a>'; |
||
4575 | |||
4576 | $morehtmlref = '<a href="' . DOL_URL_ROOT . '/adherents/vcard.php?id=' . $object->id . '" class="refid">'; |
||
4577 | $morehtmlref .= img_picto($langs->trans("Download") . ' ' . $langs->trans("VCard"), 'vcard.png', 'class="valignmiddle marginleftonly paddingrightonly"'); |
||
4578 | $morehtmlref .= '</a>'; |
||
4579 | |||
4580 | dol_banner_tab($object, 'id', $linkback, 1, 'rowid', 'ref', $morehtmlref); |
||
4581 | |||
4582 | print '<div class="fichecenter">'; |
||
4583 | |||
4584 | print '<div class="underbanner clearboth"></div>'; |
||
4585 | print '<table class="border centpercent tableforfield">'; |
||
4586 | |||
4587 | // Login |
||
4588 | if (!getDolGlobalString('ADHERENT_LOGIN_NOT_REQUIRED')) { |
||
4589 | print '<tr><td class="titlefield">' . $langs->trans("Login") . ' / ' . $langs->trans("Id") . '</td><td class="valeur">' . dol_escape_htmltag($object->login) . '</td></tr>'; |
||
4590 | } |
||
4591 | |||
4592 | // Type |
||
4593 | print '<tr><td>' . $langs->trans("Type") . '</td>'; |
||
4594 | print '<td class="valeur">' . $adht->getNomUrl(1) . "</td></tr>\n"; |
||
4595 | |||
4596 | // Morphy |
||
4597 | print '<tr><td class="titlefield">' . $langs->trans("MemberNature") . '</td>'; |
||
4598 | print '<td class="valeur" >' . $object->getmorphylib('', 1) . '</td>'; |
||
4599 | print '</tr>'; |
||
4600 | |||
4601 | // Company |
||
4602 | print '<tr><td>' . $langs->trans("Company") . '</td><td class="valeur">' . dol_escape_htmltag($object->company) . '</td></tr>'; |
||
4603 | |||
4604 | // Civility |
||
4605 | print '<tr><td>' . $langs->trans("UserTitle") . '</td><td class="valeur">' . $object->getCivilityLabel() . '</td>'; |
||
4606 | print '</tr>'; |
||
4607 | |||
4608 | print "</table>"; |
||
4609 | |||
4610 | print '</div>'; |
||
4611 | |||
4612 | |||
4613 | $cssclass = 'titlefield'; |
||
4614 | $permission = $user->hasRight('adherent', 'creer'); // Used by the include of notes.tpl.php |
||
4615 | include DOL_DOCUMENT_ROOT . '/core/tpl/notes.tpl.php'; |
||
4616 | |||
4617 | |||
4618 | print dol_get_fiche_end(); |
||
4619 | } |
||
4620 | |||
4621 | // End of page |
||
4622 | llxFooter(); |
||
4623 | $db->close(); |
||
4624 | } |
||
4625 | |||
4626 | /** |
||
4627 | * \file partnership_card.php |
||
4628 | * \ingroup partnership |
||
4629 | * \brief Page to create/edit/view partnership |
||
4630 | */ |
||
4631 | public function partnership() |
||
4632 | { |
||
4633 | global $conf; |
||
4634 | global $db; |
||
4635 | global $user; |
||
4636 | global $hookmanager; |
||
4637 | global $user; |
||
4638 | global $menumanager; |
||
4639 | global $langs; |
||
4640 | |||
4641 | // Load translation files required by the page |
||
4642 | $langs->loadLangs(array("companies","members","partnership", "other")); |
||
4643 | |||
4644 | // Get parameters |
||
4645 | $id = GETPOSTINT('rowid') ? GETPOSTINT('rowid') : GETPOSTINT('id'); |
||
4646 | $ref = GETPOST('ref', 'alpha'); |
||
4647 | $action = GETPOST('action', 'aZ09'); |
||
4648 | $confirm = GETPOST('confirm', 'alpha'); |
||
4649 | $cancel = GETPOST('cancel', 'aZ09'); |
||
4650 | $contextpage = GETPOST('contextpage', 'aZ') ? GETPOST('contextpage', 'aZ') : 'partnershipcard'; // To manage different context of search |
||
4651 | $backtopage = GETPOST('backtopage', 'alpha'); |
||
4652 | $backtopageforcancel = GETPOST('backtopageforcancel', 'alpha'); |
||
4653 | //$lineid = GETPOST('lineid', 'int'); |
||
4654 | |||
4655 | $object = new Adherent($db); |
||
4656 | if ($id > 0) { |
||
4657 | $object->fetch($id); |
||
4658 | } |
||
4659 | |||
4660 | // Initialize technical objects |
||
4661 | $object = new Partnership($db); |
||
4662 | $extrafields = new ExtraFields($db); |
||
4663 | $adht = new AdherentType($db); |
||
4664 | $diroutputmassaction = $conf->partnership->dir_output . '/temp/massgeneration/' . $user->id; |
||
4665 | $hookmanager->initHooks(array('partnershipthirdparty', 'globalcard')); // Note that conf->hooks_modules contains array |
||
4666 | |||
4667 | // Fetch optionals attributes and labels |
||
4668 | $extrafields->fetch_name_optionals_label($object->table_element); |
||
4669 | |||
4670 | $search_array_options = $extrafields->getOptionalsFromPost($object->table_element, '', 'search_'); |
||
4671 | |||
4672 | // Initialize array of search criteria |
||
4673 | $search_all = GETPOST("search_all", 'alpha'); |
||
4674 | $search = array(); |
||
4675 | |||
4676 | foreach ($object->fields as $key => $val) { |
||
4677 | if (GETPOST('search_' . $key, 'alpha')) { |
||
4678 | $search[$key] = GETPOST('search_' . $key, 'alpha'); |
||
4679 | } |
||
4680 | } |
||
4681 | |||
4682 | // Load object |
||
4683 | include DOL_DOCUMENT_ROOT . '/core/actions_fetchobject.inc.php'; // Must be include, not include_once. |
||
4684 | |||
4685 | $permissiontoread = $user->hasRight('partnership', 'read'); |
||
4686 | $permissiontoadd = $user->hasRight('partnership', 'write'); // Used by the include of actions_addupdatedelete.inc.php and actions_lineupdown.inc.php |
||
4687 | $permissiontodelete = $user->hasRight('partnership', 'delete') || ($permissiontoadd && isset($object->status) && $object->status == $object::STATUS_DRAFT); |
||
4688 | $permissionnote = $user->hasRight('partnership', 'write'); // Used by the include of actions_setnotes.inc.php |
||
4689 | $permissiondellink = $user->hasRight('partnership', 'write'); // Used by the include of actions_dellink.inc.php |
||
4690 | $usercanclose = $user->hasRight('partnership', 'write'); // Used by the include of actions_addupdatedelete.inc.php and actions_lineupdown.inc.php |
||
4691 | $upload_dir = $conf->partnership->multidir_output[isset($object->entity) ? $object->entity : 1]; |
||
4692 | |||
4693 | |||
4694 | if (getDolGlobalString('PARTNERSHIP_IS_MANAGED_FOR') != 'member') { |
||
4695 | accessforbidden('Partnership module is not activated for members'); |
||
4696 | } |
||
4697 | if (!isModEnabled('partnership')) { |
||
4698 | accessforbidden(); |
||
4699 | } |
||
4700 | if (empty($permissiontoread)) { |
||
4701 | accessforbidden(); |
||
4702 | } |
||
4703 | if ($action == 'edit' && empty($permissiontoadd)) { |
||
4704 | accessforbidden(); |
||
4705 | } |
||
4706 | if (($action == 'update' || $action == 'edit') && $object->status != $object::STATUS_DRAFT) { |
||
4707 | accessforbidden(); |
||
4708 | } |
||
4709 | |||
4710 | |||
4711 | // Security check |
||
4712 | $result = restrictedArea($user, 'adherent', $id, '', '', 'socid', 'rowid', 0); |
||
4713 | |||
4714 | |||
4715 | /* |
||
4716 | * Actions |
||
4717 | */ |
||
4718 | |||
4719 | $parameters = array(); |
||
4720 | $reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks |
||
4721 | if ($reshook < 0) { |
||
4722 | setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); |
||
4723 | } |
||
4724 | |||
4725 | $date_start = dol_mktime(0, 0, 0, GETPOSTINT('date_partnership_startmonth'), GETPOSTINT('date_partnership_startday'), GETPOSTINT('date_partnership_startyear')); |
||
4726 | $date_end = dol_mktime(0, 0, 0, GETPOSTINT('date_partnership_endmonth'), GETPOSTINT('date_partnership_endday'), GETPOSTINT('date_partnership_endyear')); |
||
4727 | |||
4728 | if (empty($reshook)) { |
||
4729 | $error = 0; |
||
4730 | |||
4731 | $backtopage = dol_buildpath('/partnership/partnership.php', 1) . '?rowid=' . ($id > 0 ? $id : '__ID__'); |
||
4732 | |||
4733 | // Actions when linking object each other |
||
4734 | include DOL_DOCUMENT_ROOT . '/core/actions_dellink.inc.php'; |
||
4735 | } |
||
4736 | |||
4737 | $object->fields['fk_member']['visible'] = 0; |
||
4738 | if ($object->id > 0 && $object->status == $object::STATUS_REFUSED && empty($action)) { |
||
4739 | $object->fields['reason_decline_or_cancel']['visible'] = 1; |
||
4740 | } |
||
4741 | $object->fields['note_public']['visible'] = 1; |
||
4742 | |||
4743 | |||
4744 | /* |
||
4745 | * View |
||
4746 | */ |
||
4747 | |||
4748 | $form = new Form($db); |
||
4749 | $formfile = new FormFile($db); |
||
4750 | |||
4751 | $title = $langs->trans("Partnership"); |
||
4752 | llxHeader('', $title); |
||
4753 | |||
4754 | $form = new Form($db); |
||
4755 | |||
4756 | if ($id > 0) { |
||
4757 | $langs->load("members"); |
||
4758 | |||
4759 | $object = new Adherent($db); |
||
4760 | $result = $object->fetch($id); |
||
4761 | |||
4762 | if (isModEnabled('notification')) { |
||
4763 | $langs->load("mails"); |
||
4764 | } |
||
4765 | |||
4766 | $adht->fetch($object->typeid); |
||
4767 | |||
4768 | $head = member_prepare_head($object); |
||
4769 | |||
4770 | print dol_get_fiche_head($head, 'partnership', $langs->trans("ThirdParty"), -1, 'user'); |
||
4771 | |||
4772 | $linkback = '<a href="' . DOL_URL_ROOT . '/adherents/list.php?restore_lastsearch_values=1">' . $langs->trans("BackToList") . '</a>'; |
||
4773 | |||
4774 | dol_banner_tab($object, 'rowid', $linkback); |
||
4775 | |||
4776 | print '<div class="fichecenter">'; |
||
4777 | |||
4778 | print '<div class="underbanner clearboth"></div>'; |
||
4779 | print '<table class="border centpercent tableforfield">'; |
||
4780 | |||
4781 | // Login |
||
4782 | if (!getDolGlobalString('ADHERENT_LOGIN_NOT_REQUIRED')) { |
||
4783 | print '<tr><td class="titlefield">' . $langs->trans("Login") . ' / ' . $langs->trans("Id") . '</td><td class="valeur">' . $object->login . ' </td></tr>'; |
||
4784 | } |
||
4785 | |||
4786 | // Type |
||
4787 | print '<tr><td class="titlefield">' . $langs->trans("Type") . '</td><td class="valeur">' . $adht->getNomUrl(1) . "</td></tr>\n"; |
||
4788 | |||
4789 | // Morphy |
||
4790 | print '<tr><td>' . $langs->trans("MemberNature") . '</td><td class="valeur" >' . $object->getmorphylib() . '</td>'; |
||
4791 | print '</tr>'; |
||
4792 | |||
4793 | // Company |
||
4794 | print '<tr><td>' . $langs->trans("Company") . '</td><td class="valeur">' . $object->company . '</td></tr>'; |
||
4795 | |||
4796 | // Civility |
||
4797 | print '<tr><td>' . $langs->trans("UserTitle") . '</td><td class="valeur">' . $object->getCivilityLabel() . ' </td>'; |
||
4798 | print '</tr>'; |
||
4799 | |||
4800 | print '</table>'; |
||
4801 | |||
4802 | print '</div>'; |
||
4803 | |||
4804 | print dol_get_fiche_end(); |
||
4805 | } else { |
||
4806 | dol_print_error(null, 'Parameter rowid not defined'); |
||
4807 | } |
||
4808 | |||
4809 | |||
4810 | // Part to show record |
||
4811 | if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'create'))) { |
||
4812 | // Buttons for actions |
||
4813 | |||
4814 | if ($action != 'presend') { |
||
4815 | print '<div class="tabsAction">' . "\n"; |
||
4816 | $parameters = array(); |
||
4817 | $reshook = $hookmanager->executeHooks('addMoreActionsButtons', $parameters, $object, $action); // Note that $action and $object may have been modified by hook |
||
4818 | if ($reshook < 0) { |
||
4819 | setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); |
||
4820 | } |
||
4821 | |||
4822 | if (empty($reshook)) { |
||
4823 | // Show |
||
4824 | if ($permissiontoadd) { |
||
4825 | print dolGetButtonAction($langs->trans('AddPartnership'), '', 'default', DOL_URL_ROOT . '/partnership/partnership_card.php?action=create&fk_member=' . $object->id . '&backtopage=' . urlencode(DOL_URL_ROOT . '/adherents/partnership.php?id=' . $object->id), '', $permissiontoadd); |
||
4826 | } |
||
4827 | } |
||
4828 | print '</div>' . "\n"; |
||
4829 | } |
||
4830 | |||
4831 | |||
4832 | //$morehtmlright = 'partnership/partnership_card.php?action=create&backtopage=%2Fdolibarr%2Fhtdocs%2Fpartnership%2Fpartnership_list.php'; |
||
4833 | $morehtmlright = ''; |
||
4834 | |||
4835 | print load_fiche_titre($langs->trans("PartnershipDedicatedToThisMember", $langs->transnoentitiesnoconv("Partnership")), $morehtmlright, ''); |
||
4836 | |||
4837 | $memberid = $object->id; |
||
4838 | |||
4839 | |||
4840 | // TODO Replace this card with the list of all partnerships. |
||
4841 | |||
4842 | $object = new Partnership($db); |
||
4843 | $partnershipid = $object->fetch(0, "", $memberid); |
||
4844 | |||
4845 | if ($partnershipid > 0) { |
||
4846 | print '<div class="fichecenter">'; |
||
4847 | print '<div class="fichehalfleft">'; |
||
4848 | print '<div class="underbanner clearboth"></div>'; |
||
4849 | print '<table class="border centpercent tableforfield">' . "\n"; |
||
4850 | |||
4851 | // Common attributes |
||
4852 | //$keyforbreak='fieldkeytoswitchonsecondcolumn'; // We change column just before this field |
||
4853 | //unset($object->fields['fk_project']); // Hide field already shown in banner |
||
4854 | //unset($object->fields['fk_member']); // Hide field already shown in banner |
||
4855 | include DOL_DOCUMENT_ROOT . '/core/tpl/commonfields_view.tpl.php'; |
||
4856 | |||
4857 | // End of subscription date |
||
4858 | $fadherent = new Adherent($db); |
||
4859 | $fadherent->fetch($object->fk_member); |
||
4860 | print '<tr><td>' . $langs->trans("SubscriptionEndDate") . '</td><td class="valeur">'; |
||
4861 | if ($fadherent->datefin) { |
||
4862 | print dol_print_date($fadherent->datefin, 'day'); |
||
4863 | if ($fadherent->hasDelay()) { |
||
4864 | print " " . img_warning($langs->trans("Late")); |
||
4865 | } |
||
4866 | } else { |
||
4867 | if (!$adht->subscription) { |
||
4868 | print $langs->trans("SubscriptionNotRecorded"); |
||
4869 | if ($fadherent->statut > 0) { |
||
4870 | print " " . img_warning($langs->trans("Late")); // Display a delay picto only if it is not a draft and is not canceled |
||
4871 | } |
||
4872 | } else { |
||
4873 | print $langs->trans("SubscriptionNotReceived"); |
||
4874 | if ($fadherent->statut > 0) { |
||
4875 | print " " . img_warning($langs->trans("Late")); // Display a delay picto only if it is not a draft and is not canceled |
||
4876 | } |
||
4877 | } |
||
4878 | } |
||
4879 | print '</td></tr>'; |
||
4880 | |||
4881 | print '</table>'; |
||
4882 | print '</div>'; |
||
4883 | } |
||
4884 | } |
||
4885 | |||
4886 | // End of page |
||
4887 | llxFooter(); |
||
4888 | $db->close(); |
||
4889 | } |
||
4890 | |||
4891 | /** |
||
4892 | * \file htdocs/adherents/subscription.php |
||
4893 | * \ingroup member |
||
4894 | * \brief tab for Adding, editing, deleting a member's memberships |
||
4895 | */ |
||
4896 | public function subscription() |
||
4897 | { |
||
4898 | global $conf; |
||
4899 | global $db; |
||
4900 | global $user; |
||
4901 | global $hookmanager; |
||
4902 | global $user; |
||
4903 | global $menumanager; |
||
4904 | global $langs; |
||
4905 | |||
4906 | $langs->loadLangs(array("companies", "bills", "members", "users", "mails", 'other')); |
||
4907 | |||
4908 | $action = GETPOST('action', 'aZ09'); |
||
4909 | $confirm = GETPOST('confirm', 'alpha'); |
||
4910 | $contextpage = GETPOST('contextpage', 'aZ09'); |
||
4911 | $optioncss = GETPOST('optioncss', 'aZ'); // Option for the css output (always '' except when 'print') |
||
4912 | |||
4913 | $id = GETPOSTINT('rowid') ? GETPOSTINT('rowid') : GETPOSTINT('id'); |
||
4914 | $rowid = $id; |
||
4915 | $ref = GETPOST('ref', 'alphanohtml'); |
||
4916 | $typeid = GETPOSTINT('typeid'); |
||
4917 | $cancel = GETPOST('cancel'); |
||
4918 | |||
4919 | // Load variable for pagination |
||
4920 | $limit = GETPOSTINT('limit') ? GETPOSTINT('limit') : $conf->liste_limit; |
||
4921 | $sortfield = GETPOST('sortfield', 'aZ09comma'); |
||
4922 | $sortorder = GETPOST('sortorder', 'aZ09comma'); |
||
4923 | $page = GETPOSTISSET('pageplusone') ? (GETPOSTINT('pageplusone') - 1) : GETPOSTINT("page"); |
||
4924 | if (empty($page) || $page == -1) { |
||
4925 | $page = 0; |
||
4926 | } // If $page is not defined, or '' or -1 |
||
4927 | $offset = $limit * $page; |
||
4928 | $pageprev = $page - 1; |
||
4929 | $pagenext = $page + 1; |
||
4930 | |||
4931 | // Default sort order (if not yet defined by previous GETPOST) |
||
4932 | if (!$sortfield) { |
||
4933 | $sortfield = "c.rowid"; |
||
4934 | } |
||
4935 | if (!$sortorder) { |
||
4936 | $sortorder = "DESC"; |
||
4937 | } |
||
4938 | |||
4939 | $object = new Adherent($db); |
||
4940 | $extrafields = new ExtraFields($db); |
||
4941 | $adht = new AdherentType($db); |
||
4942 | |||
4943 | // fetch optionals attributes and labels |
||
4944 | $extrafields->fetch_name_optionals_label($object->table_element); |
||
4945 | |||
4946 | $errmsg = ''; |
||
4947 | |||
4948 | // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context |
||
4949 | $hookmanager->initHooks(array('subscription')); |
||
4950 | |||
4951 | |||
4952 | $hidedetails = (GETPOSTINT('hidedetails') ? GETPOSTINT('hidedetails') : (getDolGlobalString('MAIN_GENERATE_DOCUMENTS_HIDE_DETAILS') ? 1 : 0)); |
||
4953 | $hidedesc = (GETPOSTINT('hidedesc') ? GETPOSTINT('hidedesc') : (getDolGlobalString('MAIN_GENERATE_DOCUMENTS_HIDE_DESC') ? 1 : 0)); |
||
4954 | $hideref = (GETPOSTINT('hideref') ? GETPOSTINT('hideref') : (getDolGlobalString('MAIN_GENERATE_DOCUMENTS_HIDE_REF') ? 1 : 0)); |
||
4955 | |||
4956 | $datefrom = 0; |
||
4957 | $dateto = 0; |
||
4958 | $paymentdate = -1; |
||
4959 | |||
4960 | // Fetch object |
||
4961 | if ($id > 0 || !empty($ref)) { |
||
4962 | // Load member |
||
4963 | $result = $object->fetch($id, $ref); |
||
4964 | |||
4965 | // Define variables to know what current user can do on users |
||
4966 | $canadduser = ($user->admin || $user->hasRight("user", "user", "creer")); |
||
4967 | // Define variables to know what current user can do on properties of user linked to edited member |
||
4968 | if ($object->user_id) { |
||
4969 | // $User is the user who edits, $object->user_id is the id of the related user in the edited member |
||
4970 | $caneditfielduser = ((($user->id == $object->user_id) && $user->hasRight("user", "self", "creer")) |
||
4971 | || (($user->id != $object->user_id) && $user->hasRight("user", "user", "creer"))); |
||
4972 | $caneditpassworduser = ((($user->id == $object->user_id) && $user->hasRight("user", "self", "password")) |
||
4973 | || (($user->id != $object->user_id) && $user->hasRight("user", "user", "password"))); |
||
4974 | } |
||
4975 | } |
||
4976 | |||
4977 | // Define variables to determine what the current user can do on the members |
||
4978 | $canaddmember = $user->hasRight('adherent', 'creer'); |
||
4979 | // Define variables to determine what the current user can do on the properties of a member |
||
4980 | if ($id) { |
||
4981 | $caneditfieldmember = $user->hasRight('adherent', 'creer'); |
||
4982 | } |
||
4983 | |||
4984 | // Security check |
||
4985 | $result = restrictedArea($user, 'adherent', $object->id, '', '', 'socid', 'rowid', 0); |
||
4986 | |||
4987 | |||
4988 | /* |
||
4989 | * Actions |
||
4990 | */ |
||
4991 | |||
4992 | $parameters = array(); |
||
4993 | $reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); |
||
4994 | if ($reshook < 0) { |
||
4995 | setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); |
||
4996 | } |
||
4997 | |||
4998 | // Create third party from a member |
||
4999 | if (empty($reshook) && $action == 'confirm_create_thirdparty' && $confirm == 'yes' && $user->hasRight('societe', 'creer')) { |
||
5000 | if ($result > 0) { |
||
5001 | // Creation of thirdparty |
||
5002 | $company = new Societe($db); |
||
5003 | $result = $company->create_from_member($object, GETPOST('companyname', 'alpha'), GETPOST('companyalias', 'alpha'), GETPOST('customercode', 'alpha')); |
||
5004 | |||
5005 | if ($result < 0) { |
||
5006 | $langs->load("errors"); |
||
5007 | setEventMessages($company->error, $company->errors, 'errors'); |
||
5008 | } else { |
||
5009 | $action = 'addsubscription'; |
||
5010 | } |
||
5011 | } else { |
||
5012 | setEventMessages($object->error, $object->errors, 'errors'); |
||
5013 | } |
||
5014 | } |
||
5015 | |||
5016 | if (empty($reshook) && $action == 'setuserid' && ($user->hasRight('user', 'self', 'creer') || $user->hasRight('user', 'user', 'creer'))) { |
||
5017 | $error = 0; |
||
5018 | if (!$user->hasRight('user', 'user', 'creer')) { // If can edit only itself user, we can link to itself only |
||
5019 | if (GETPOSTINT("userid") != $user->id && GETPOSTINT("userid") != $object->user_id) { |
||
5020 | $error++; |
||
5021 | setEventMessages($langs->trans("ErrorUserPermissionAllowsToLinksToItselfOnly"), null, 'errors'); |
||
5022 | } |
||
5023 | } |
||
5024 | |||
5025 | if (!$error) { |
||
5026 | if (GETPOSTINT("userid") != $object->user_id) { // If link differs from currently in database |
||
5027 | $result = $object->setUserId(GETPOSTINT("userid")); |
||
5028 | if ($result < 0) { |
||
5029 | dol_print_error(null, $object->error); |
||
5030 | } |
||
5031 | $action = ''; |
||
5032 | } |
||
5033 | } |
||
5034 | } |
||
5035 | |||
5036 | if (empty($reshook) && $action == 'setsocid') { |
||
5037 | $error = 0; |
||
5038 | if (!$error) { |
||
5039 | if (GETPOSTINT('socid') != $object->fk_soc) { // If link differs from currently in database |
||
5040 | $sql = "SELECT rowid FROM " . MAIN_DB_PREFIX . "adherent"; |
||
5041 | $sql .= " WHERE fk_soc = '" . GETPOSTINT('socid') . "'"; |
||
5042 | $resql = $db->query($sql); |
||
5043 | if ($resql) { |
||
5044 | $obj = $db->fetch_object($resql); |
||
5045 | if ($obj && $obj->rowid > 0) { |
||
5046 | $othermember = new Adherent($db); |
||
5047 | $othermember->fetch($obj->rowid); |
||
5048 | $thirdparty = new Societe($db); |
||
5049 | $thirdparty->fetch(GETPOSTINT('socid')); |
||
5050 | $error++; |
||
5051 | setEventMessages($langs->trans("ErrorMemberIsAlreadyLinkedToThisThirdParty", $othermember->getFullName($langs), $othermember->login, $thirdparty->name), null, 'errors'); |
||
5052 | } |
||
5053 | } |
||
5054 | |||
5055 | if (!$error) { |
||
5056 | $result = $object->setThirdPartyId(GETPOSTINT('socid')); |
||
5057 | if ($result < 0) { |
||
5058 | dol_print_error(null, $object->error); |
||
5059 | } |
||
5060 | $action = ''; |
||
5061 | } |
||
5062 | } |
||
5063 | } |
||
5064 | } |
||
5065 | |||
5066 | if ($user->hasRight('adherent', 'cotisation', 'creer') && $action == 'subscription' && !$cancel) { |
||
5067 | $error = 0; |
||
5068 | |||
5069 | $langs->load("banks"); |
||
5070 | |||
5071 | $result = $object->fetch($rowid); |
||
5072 | $result = $adht->fetch($object->typeid); |
||
5073 | |||
5074 | // Subscription information |
||
5075 | $datesubscription = 0; |
||
5076 | $datesubend = 0; |
||
5077 | $defaultdelay = !empty($adht->duration_value) ? $adht->duration_value : 1; |
||
5078 | $defaultdelayunit = !empty($adht->duration_unit) ? $adht->duration_unit : 'y'; |
||
5079 | $paymentdate = ''; // Do not use 0 here, default value is '' that means not filled where 0 means 1970-01-01 |
||
5080 | if (GETPOSTINT("reyear") && GETPOSTINT("remonth") && GETPOSTINT("reday")) { |
||
5081 | $datesubscription = dol_mktime(0, 0, 0, GETPOSTINT("remonth"), GETPOSTINT("reday"), GETPOSTINT("reyear")); |
||
5082 | } |
||
5083 | if (GETPOSTINT("endyear") && GETPOSTINT("endmonth") && GETPOSTINT("endday")) { |
||
5084 | $datesubend = dol_mktime(0, 0, 0, GETPOSTINT("endmonth"), GETPOSTINT("endday"), GETPOSTINT("endyear")); |
||
5085 | } |
||
5086 | if (GETPOSTINT("paymentyear") && GETPOSTINT("paymentmonth") && GETPOSTINT("paymentday")) { |
||
5087 | $paymentdate = dol_mktime(0, 0, 0, GETPOSTINT("paymentmonth"), GETPOSTINT("paymentday"), GETPOSTINT("paymentyear")); |
||
5088 | } |
||
5089 | $amount = price2num(GETPOST("subscription", 'alpha')); // Amount of subscription |
||
5090 | $label = GETPOST("label"); |
||
5091 | |||
5092 | // Payment information |
||
5093 | $accountid = GETPOSTINT("accountid"); |
||
5094 | $operation = GETPOST("operation", "alphanohtml"); // Payment mode |
||
5095 | $num_chq = GETPOST("num_chq", "alphanohtml"); |
||
5096 | $emetteur_nom = GETPOST("chqemetteur"); |
||
5097 | $emetteur_banque = GETPOST("chqbank"); |
||
5098 | $option = GETPOST("paymentsave"); |
||
5099 | if (empty($option)) { |
||
5100 | $option = 'none'; |
||
5101 | } |
||
5102 | $sendalsoemail = GETPOST("sendmail", 'alpha'); |
||
5103 | |||
5104 | // Check parameters |
||
5105 | if (!$datesubscription) { |
||
5106 | $error++; |
||
5107 | $langs->load("errors"); |
||
5108 | $errmsg = $langs->trans("ErrorBadDateFormat", $langs->transnoentitiesnoconv("DateSubscription")); |
||
5109 | setEventMessages($errmsg, null, 'errors'); |
||
5110 | $action = 'addsubscription'; |
||
5111 | } |
||
5112 | if (GETPOST('end') && !$datesubend) { |
||
5113 | $error++; |
||
5114 | $langs->load("errors"); |
||
5115 | $errmsg = $langs->trans("ErrorBadDateFormat", $langs->transnoentitiesnoconv("DateEndSubscription")); |
||
5116 | setEventMessages($errmsg, null, 'errors'); |
||
5117 | $action = 'addsubscription'; |
||
5118 | } |
||
5119 | if (!$datesubend) { |
||
5120 | $datesubend = dol_time_plus_duree(dol_time_plus_duree($datesubscription, $defaultdelay, $defaultdelayunit), -1, 'd'); |
||
5121 | } |
||
5122 | if (($option == 'bankviainvoice' || $option == 'bankdirect') && !$paymentdate) { |
||
5123 | $error++; |
||
5124 | $errmsg = $langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("DatePayment")); |
||
5125 | setEventMessages($errmsg, null, 'errors'); |
||
5126 | $action = 'addsubscription'; |
||
5127 | } |
||
5128 | |||
5129 | // Check if a payment is mandatory or not |
||
5130 | if ($adht->subscription) { // Member type need subscriptions |
||
5131 | if (!is_numeric($amount)) { |
||
5132 | // If field is '' or not a numeric value |
||
5133 | $errmsg = $langs->trans("ErrorFieldRequired", $langs->transnoentities("Amount")); |
||
5134 | setEventMessages($errmsg, null, 'errors'); |
||
5135 | $error++; |
||
5136 | $action = 'addsubscription'; |
||
5137 | } else { |
||
5138 | // If an amount has been provided, we check also fields that becomes mandatory when amount is not null. |
||
5139 | if (isModEnabled('bank') && GETPOST("paymentsave") != 'none') { |
||
5140 | if (GETPOST("subscription")) { |
||
5141 | if (!GETPOST("label")) { |
||
5142 | $errmsg = $langs->trans("ErrorFieldRequired", $langs->transnoentities("Label")); |
||
5143 | setEventMessages($errmsg, null, 'errors'); |
||
5144 | $error++; |
||
5145 | $action = 'addsubscription'; |
||
5146 | } |
||
5147 | if (GETPOST("paymentsave") != 'invoiceonly' && !GETPOST("operation")) { |
||
5148 | $errmsg = $langs->trans("ErrorFieldRequired", $langs->transnoentities("PaymentMode")); |
||
5149 | setEventMessages($errmsg, null, 'errors'); |
||
5150 | $error++; |
||
5151 | $action = 'addsubscription'; |
||
5152 | } |
||
5153 | if (GETPOST("paymentsave") != 'invoiceonly' && !(GETPOSTINT("accountid") > 0)) { |
||
5154 | $errmsg = $langs->trans("ErrorFieldRequired", $langs->transnoentities("FinancialAccount")); |
||
5155 | setEventMessages($errmsg, null, 'errors'); |
||
5156 | $error++; |
||
5157 | $action = 'addsubscription'; |
||
5158 | } |
||
5159 | } else { |
||
5160 | if (GETPOSTINT("accountid")) { |
||
5161 | $errmsg = $langs->trans("ErrorDoNotProvideAccountsIfNullAmount"); |
||
5162 | setEventMessages($errmsg, null, 'errors'); |
||
5163 | $error++; |
||
5164 | $action = 'addsubscription'; |
||
5165 | } |
||
5166 | } |
||
5167 | } |
||
5168 | } |
||
5169 | } |
||
5170 | |||
5171 | // Record the subscription then complementary actions |
||
5172 | if (!$error && $action == 'subscription') { |
||
5173 | $db->begin(); |
||
5174 | |||
5175 | // Create subscription |
||
5176 | $crowid = $object->subscription($datesubscription, $amount, $accountid, $operation, $label, $num_chq, $emetteur_nom, $emetteur_banque, $datesubend); |
||
5177 | if ($crowid <= 0) { |
||
5178 | $error++; |
||
5179 | $errmsg = $object->error; |
||
5180 | setEventMessages($object->error, $object->errors, 'errors'); |
||
5181 | } |
||
5182 | |||
5183 | if (!$error) { |
||
5184 | $result = $object->subscriptionComplementaryActions($crowid, $option, $accountid, $datesubscription, $paymentdate, $operation, $label, $amount, $num_chq, $emetteur_nom, $emetteur_banque); |
||
5185 | if ($result < 0) { |
||
5186 | $error++; |
||
5187 | setEventMessages($object->error, $object->errors, 'errors'); |
||
5188 | } else { |
||
5189 | // If an invoice was created, it is into $object->invoice |
||
5190 | } |
||
5191 | } |
||
5192 | |||
5193 | if (!$error) { |
||
5194 | $db->commit(); |
||
5195 | } else { |
||
5196 | $db->rollback(); |
||
5197 | $action = 'addsubscription'; |
||
5198 | } |
||
5199 | |||
5200 | if (!$error) { |
||
5201 | setEventMessages("SubscriptionRecorded", null, 'mesgs'); |
||
5202 | } |
||
5203 | |||
5204 | // Send email |
||
5205 | if (!$error) { |
||
5206 | // Send confirmation Email |
||
5207 | if ($object->email && $sendalsoemail) { // $object is 'Adherent' |
||
5208 | $parameters = array( |
||
5209 | 'datesubscription' => $datesubscription, |
||
5210 | 'amount' => $amount, |
||
5211 | 'ccountid' => $accountid, |
||
5212 | 'operation' => $operation, |
||
5213 | 'label' => $label, |
||
5214 | 'num_chq' => $num_chq, |
||
5215 | 'emetteur_nom' => $emetteur_nom, |
||
5216 | 'emetteur_banque' => $emetteur_banque, |
||
5217 | 'datesubend' => $datesubend |
||
5218 | ); |
||
5219 | $reshook = $hookmanager->executeHooks('sendMail', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks |
||
5220 | if ($reshook < 0) { |
||
5221 | setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); |
||
5222 | } |
||
5223 | |||
5224 | if (empty($reshook)) { |
||
5225 | $subject = ''; |
||
5226 | $msg = ''; |
||
5227 | |||
5228 | // Send subscription email |
||
5229 | include_once DOL_DOCUMENT_ROOT . '/core/class/html.formmail.class.php'; |
||
5230 | $formmail = new FormMail($db); |
||
5231 | // Set output language |
||
5232 | $outputlangs = new Translate('', $conf); |
||
5233 | $outputlangs->setDefaultLang(empty($object->thirdparty->default_lang) ? $mysoc->default_lang : $object->thirdparty->default_lang); |
||
5234 | // Load traductions files required by page |
||
5235 | $outputlangs->loadLangs(array("main", "members")); |
||
5236 | |||
5237 | // Get email content from template |
||
5238 | $arraydefaultmessage = null; |
||
5239 | $labeltouse = getDolGlobalString('ADHERENT_EMAIL_TEMPLATE_SUBSCRIPTION'); |
||
5240 | |||
5241 | if (!empty($labeltouse)) { |
||
5242 | $arraydefaultmessage = $formmail->getEMailTemplate($db, 'member', $user, $outputlangs, 0, 1, $labeltouse); |
||
5243 | } |
||
5244 | |||
5245 | if (!empty($labeltouse) && is_object($arraydefaultmessage) && $arraydefaultmessage->id > 0) { |
||
5246 | $subject = $arraydefaultmessage->topic; |
||
5247 | $msg = $arraydefaultmessage->content; |
||
5248 | } |
||
5249 | |||
5250 | $substitutionarray = getCommonSubstitutionArray($outputlangs, 0, null, $object); |
||
5251 | complete_substitutions_array($substitutionarray, $outputlangs, $object); |
||
5252 | $subjecttosend = make_substitutions($subject, $substitutionarray, $outputlangs); |
||
5253 | $texttosend = make_substitutions(dol_concatdesc($msg, $adht->getMailOnSubscription()), $substitutionarray, $outputlangs); |
||
5254 | |||
5255 | // Attach a file ? |
||
5256 | $file = ''; |
||
5257 | $listofpaths = array(); |
||
5258 | $listofnames = array(); |
||
5259 | $listofmimes = array(); |
||
5260 | if (is_object($object->invoice) && (!is_object($arraydefaultmessage) || intval($arraydefaultmessage->joinfiles))) { |
||
5261 | $invoicediroutput = $conf->facture->dir_output; |
||
5262 | $fileparams = dol_most_recent_file($invoicediroutput . '/' . $object->invoice->ref, preg_quote($object->invoice->ref, '/') . '[^\-]+'); |
||
5263 | $file = $fileparams['fullname']; |
||
5264 | |||
5265 | $listofpaths = array($file); |
||
5266 | $listofnames = array(basename($file)); |
||
5267 | $listofmimes = array(dol_mimetype($file)); |
||
5268 | } |
||
5269 | |||
5270 | $moreinheader = 'X-Dolibarr-Info: send_an_email by adherents/subscription.php' . "\r\n"; |
||
5271 | |||
5272 | $result = $object->sendEmail($texttosend, $subjecttosend, $listofpaths, $listofmimes, $listofnames, "", "", 0, -1, '', $moreinheader); |
||
5273 | if ($result < 0) { |
||
5274 | $errmsg = $object->error; |
||
5275 | setEventMessages($object->error, $object->errors, 'errors'); |
||
5276 | } else { |
||
5277 | setEventMessages($langs->trans("EmailSentToMember", $object->email), null, 'mesgs'); |
||
5278 | } |
||
5279 | } |
||
5280 | } else { |
||
5281 | setEventMessages($langs->trans("NoEmailSentToMember"), null, 'mesgs'); |
||
5282 | } |
||
5283 | } |
||
5284 | |||
5285 | // Clean some POST vars |
||
5286 | if (!$error) { |
||
5287 | $_POST["subscription"] = ''; |
||
5288 | $_POST["accountid"] = ''; |
||
5289 | $_POST["operation"] = ''; |
||
5290 | $_POST["label"] = ''; |
||
5291 | $_POST["num_chq"] = ''; |
||
5292 | } |
||
5293 | } |
||
5294 | } |
||
5295 | |||
5296 | |||
5297 | |||
5298 | /* |
||
5299 | * View |
||
5300 | */ |
||
5301 | |||
5302 | $form = new Form($db); |
||
5303 | |||
5304 | $now = dol_now(); |
||
5305 | |||
5306 | $title = $langs->trans("Member") . " - " . $langs->trans("Subscriptions"); |
||
5307 | |||
5308 | $help_url = "EN:Module_Foundations|FR:Module_Adhérents|ES:Módulo_Miembros|DE:Modul_Mitglieder"; |
||
5309 | |||
5310 | llxHeader("", $title, $help_url); |
||
5311 | |||
5312 | |||
5313 | $param = ''; |
||
5314 | if (!empty($contextpage) && $contextpage != $_SERVER['PHP_SELF']) { |
||
5315 | $param .= '&contextpage=' . urlencode($contextpage); |
||
5316 | } |
||
5317 | if ($limit > 0 && $limit != $conf->liste_limit) { |
||
5318 | $param .= '&limit=' . ((int) $limit); |
||
5319 | } |
||
5320 | $param .= '&id=' . $rowid; |
||
5321 | if ($optioncss != '') { |
||
5322 | $param .= '&optioncss=' . urlencode($optioncss); |
||
5323 | } |
||
5324 | // Add $param from extra fields |
||
5325 | //include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php'; |
||
5326 | |||
5327 | |||
5328 | if (! ($object->id > 0)) { |
||
5329 | $langs->load("errors"); |
||
5330 | print $langs->trans("ErrorRecordNotFound"); |
||
5331 | } |
||
5332 | |||
5333 | /*$res = $object->fetch($rowid); |
||
5334 | if ($res < 0) { |
||
5335 | dol_print_error($db, $object->error); |
||
5336 | exit; |
||
5337 | } |
||
5338 | */ |
||
5339 | |||
5340 | $adht->fetch($object->typeid); |
||
5341 | |||
5342 | $defaultdelay = !empty($adht->duration_value) ? $adht->duration_value : 1; |
||
5343 | $defaultdelayunit = !empty($adht->duration_unit) ? $adht->duration_unit : 'y'; |
||
5344 | |||
5345 | $head = member_prepare_head($object); |
||
5346 | |||
5347 | $rowspan = 10; |
||
5348 | if (!getDolGlobalString('ADHERENT_LOGIN_NOT_REQUIRED')) { |
||
5349 | $rowspan++; |
||
5350 | } |
||
5351 | if (isModEnabled('societe')) { |
||
5352 | $rowspan++; |
||
5353 | } |
||
5354 | |||
5355 | print '<form action="' . $_SERVER['PHP_SELF'] . '" method="POST">'; |
||
5356 | print '<input type="hidden" name="token" value="' . newToken() . '">'; |
||
5357 | print '<input type="hidden" name="rowid" value="' . $object->id . '">'; |
||
5358 | |||
5359 | print dol_get_fiche_head($head, 'subscription', $langs->trans("Member"), -1, 'user'); |
||
5360 | |||
5361 | $linkback = '<a href="' . DOL_URL_ROOT . '/adherents/list.php?restore_lastsearch_values=1">' . $langs->trans("BackToList") . '</a>'; |
||
5362 | |||
5363 | $morehtmlref = '<a href="' . DOL_URL_ROOT . '/adherents/vcard.php?id=' . $object->id . '" class="refid">'; |
||
5364 | $morehtmlref .= img_picto($langs->trans("Download") . ' ' . $langs->trans("VCard"), 'vcard.png', 'class="valignmiddle marginleftonly paddingrightonly"'); |
||
5365 | $morehtmlref .= '</a>'; |
||
5366 | |||
5367 | dol_banner_tab($object, 'rowid', $linkback, 1, 'rowid', 'ref', $morehtmlref); |
||
5368 | |||
5369 | print '<div class="fichecenter">'; |
||
5370 | print '<div class="fichehalfleft">'; |
||
5371 | |||
5372 | print '<div class="underbanner clearboth"></div>'; |
||
5373 | print '<table class="border centpercent tableforfield">'; |
||
5374 | |||
5375 | // Login |
||
5376 | if (!getDolGlobalString('ADHERENT_LOGIN_NOT_REQUIRED')) { |
||
5377 | print '<tr><td class="titlefield">' . $langs->trans("Login") . ' / ' . $langs->trans("Id") . '</td><td class="valeur">' . dol_escape_htmltag($object->login) . '</td></tr>'; |
||
5378 | } |
||
5379 | |||
5380 | // Type |
||
5381 | print '<tr><td class="titlefield">' . $langs->trans("Type") . '</td>'; |
||
5382 | print '<td class="valeur">' . $adht->getNomUrl(1) . "</td></tr>\n"; |
||
5383 | |||
5384 | // Morphy |
||
5385 | print '<tr><td>' . $langs->trans("MemberNature") . '</td>'; |
||
5386 | print '<td class="valeur" >' . $object->getmorphylib('', 1) . '</td>'; |
||
5387 | print '</tr>'; |
||
5388 | |||
5389 | // Company |
||
5390 | print '<tr><td>' . $langs->trans("Company") . '</td><td class="valeur">' . dol_escape_htmltag($object->company) . '</td></tr>'; |
||
5391 | |||
5392 | // Civility |
||
5393 | print '<tr><td>' . $langs->trans("UserTitle") . '</td><td class="valeur">' . $object->getCivilityLabel() . '</td>'; |
||
5394 | print '</tr>'; |
||
5395 | |||
5396 | // Password |
||
5397 | if (!getDolGlobalString('ADHERENT_LOGIN_NOT_REQUIRED')) { |
||
5398 | print '<tr><td>' . $langs->trans("Password") . '</td><td>'; |
||
5399 | if ($object->pass) { |
||
5400 | print preg_replace('/./i', '*', $object->pass); |
||
5401 | } else { |
||
5402 | if ($user->admin) { |
||
5403 | print '<!-- ' . $langs->trans("Crypted") . ': ' . $object->pass_indatabase_crypted . ' -->'; |
||
5404 | } |
||
5405 | print '<span class="opacitymedium">' . $langs->trans("Hidden") . '</span>'; |
||
5406 | } |
||
5407 | if (!empty($object->pass_indatabase) && empty($object->user_id)) { // Show warning only for old password still in clear (does not happen anymore) |
||
5408 | $langs->load("errors"); |
||
5409 | $htmltext = $langs->trans("WarningPasswordSetWithNoAccount"); |
||
5410 | print ' ' . $form->textwithpicto('', $htmltext, 1, 'warning'); |
||
5411 | } |
||
5412 | print '</td></tr>'; |
||
5413 | } |
||
5414 | |||
5415 | // Date end subscription |
||
5416 | print '<tr><td>' . $langs->trans("SubscriptionEndDate") . '</td><td class="valeur">'; |
||
5417 | if ($object->datefin) { |
||
5418 | print dol_print_date($object->datefin, 'day'); |
||
5419 | if ($object->hasDelay()) { |
||
5420 | print " " . img_warning($langs->trans("Late")); |
||
5421 | } |
||
5422 | } else { |
||
5423 | if ($object->need_subscription == 0) { |
||
5424 | print $langs->trans("SubscriptionNotNeeded"); |
||
5425 | } elseif (!$adht->subscription) { |
||
5426 | print $langs->trans("SubscriptionNotRecorded"); |
||
5427 | if (Adherent::STATUS_VALIDATED == $object->statut) { |
||
5428 | print " " . img_warning($langs->trans("Late")); // displays delay Pictogram only if not a draft, not excluded and not resiliated |
||
5429 | } |
||
5430 | } else { |
||
5431 | print $langs->trans("SubscriptionNotReceived"); |
||
5432 | if (Adherent::STATUS_VALIDATED == $object->statut) { |
||
5433 | print " " . img_warning($langs->trans("Late")); // displays delay Pictogram only if not a draft, not excluded and not resiliated |
||
5434 | } |
||
5435 | } |
||
5436 | } |
||
5437 | print '</td></tr>'; |
||
5438 | |||
5439 | print '</table>'; |
||
5440 | |||
5441 | print '</div>'; |
||
5442 | |||
5443 | print '<div class="fichehalfright">'; |
||
5444 | print '<div class="underbanner clearboth"></div>'; |
||
5445 | |||
5446 | print '<table class="border tableforfield centpercent">'; |
||
5447 | |||
5448 | // Tags / Categories |
||
5449 | if (isModEnabled('category') && $user->hasRight('categorie', 'lire')) { |
||
5450 | print '<tr><td>' . $langs->trans("Categories") . '</td>'; |
||
5451 | print '<td colspan="2">'; |
||
5452 | print $form->showCategories($object->id, Categorie::TYPE_MEMBER, 1); |
||
5453 | print '</td></tr>'; |
||
5454 | } |
||
5455 | |||
5456 | // Birth Date |
||
5457 | print '<tr><td class="titlefield">' . $langs->trans("DateOfBirth") . '</td><td class="valeur">' . dol_print_date($object->birth, 'day') . '</td></tr>'; |
||
5458 | |||
5459 | // Default language |
||
5460 | if (getDolGlobalInt('MAIN_MULTILANGS')) { |
||
5461 | require_once DOL_DOCUMENT_ROOT . '/core/lib/functions2.lib.php'; |
||
5462 | print '<tr><td>' . $langs->trans("DefaultLang") . '</td><td>'; |
||
5463 | //$s=picto_from_langcode($object->default_lang); |
||
5464 | //print ($s?$s.' ':''); |
||
5465 | $langs->load("languages"); |
||
5466 | $labellang = ($object->default_lang ? $langs->trans('Language_' . $object->default_lang) : ''); |
||
5467 | print picto_from_langcode($object->default_lang, 'class="paddingrightonly saturatemedium opacitylow"'); |
||
5468 | print $labellang; |
||
5469 | print '</td></tr>'; |
||
5470 | } |
||
5471 | |||
5472 | // Public |
||
5473 | $linkofpubliclist = DOL_MAIN_URL_ROOT . '/public/members/public_list.php' . ((isModEnabled('multicompany')) ? '?entity=' . $conf->entity : ''); |
||
5474 | print '<tr><td>' . $form->textwithpicto($langs->trans("PublicFile"), $langs->trans("Public", getDolGlobalString('MAIN_INFO_SOCIETE_NOM'), $linkofpubliclist), 1, 'help', '', 0, 3, 'publicfile') . '</td><td class="valeur">' . yn($object->public) . '</td></tr>'; |
||
5475 | |||
5476 | // Other attributes |
||
5477 | $cols = 2; |
||
5478 | include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_view.tpl.php'; |
||
5479 | |||
5480 | // Third party Dolibarr |
||
5481 | if (isModEnabled('societe')) { |
||
5482 | print '<tr><td>'; |
||
5483 | print '<table class="nobordernopadding" width="100%"><tr><td>'; |
||
5484 | print $langs->trans("LinkedToDolibarrThirdParty"); |
||
5485 | print '</td>'; |
||
5486 | if ($action != 'editthirdparty' && $user->hasRight('adherent', 'creer')) { |
||
5487 | print '<td class="right"><a class="editfielda" href="' . $_SERVER['PHP_SELF'] . '?action=editthirdparty&token=' . newToken() . '&rowid=' . $object->id . '">' . img_edit($langs->trans('SetLinkToThirdParty'), 1) . '</a></td>'; |
||
5488 | } |
||
5489 | print '</tr></table>'; |
||
5490 | print '</td><td colspan="2" class="valeur">'; |
||
5491 | if ($action == 'editthirdparty') { |
||
5492 | $htmlname = 'socid'; |
||
5493 | print '<form method="POST" action="' . $_SERVER['PHP_SELF'] . '" name="form' . $htmlname . '">'; |
||
5494 | print '<input type="hidden" name="rowid" value="' . $object->id . '">'; |
||
5495 | print '<input type="hidden" name="action" value="set' . $htmlname . '">'; |
||
5496 | print '<input type="hidden" name="token" value="' . newToken() . '">'; |
||
5497 | print '<table class="nobordernopadding">'; |
||
5498 | print '<tr><td>'; |
||
5499 | print $form->select_company($object->fk_soc, 'socid', '', 1); |
||
5500 | print '</td>'; |
||
5501 | print '<td class="left"><input type="submit" class="button button-edit" value="' . $langs->trans("Modify") . '"></td>'; |
||
5502 | print '</tr></table></form>'; |
||
5503 | } else { |
||
5504 | if ($object->fk_soc) { |
||
5505 | $company = new Societe($db); |
||
5506 | $result = $company->fetch($object->fk_soc); |
||
5507 | print $company->getNomUrl(1); |
||
5508 | |||
5509 | // Show link to invoices |
||
5510 | $tmparray = $company->getOutstandingBills('customer'); |
||
5511 | if (!empty($tmparray['refs'])) { |
||
5512 | print ' - ' . img_picto($langs->trans("Invoices"), 'bill', 'class="paddingright"') . '<a href="' . DOL_URL_ROOT . '/compta/facture/list.php?socid=' . $object->socid . '">' . $langs->trans("Invoices") . ' (' . count($tmparray['refs']) . ')'; |
||
5513 | // TODO Add alert if warning on at least one invoice late |
||
5514 | print '</a>'; |
||
5515 | } |
||
5516 | } else { |
||
5517 | print '<span class="opacitymedium">' . $langs->trans("NoThirdPartyAssociatedToMember") . '</span>'; |
||
5518 | } |
||
5519 | } |
||
5520 | print '</td></tr>'; |
||
5521 | } |
||
5522 | |||
5523 | // Login Dolibarr - Link to user |
||
5524 | print '<tr><td>'; |
||
5525 | print '<table class="nobordernopadding" width="100%"><tr><td>'; |
||
5526 | print $langs->trans("LinkedToDolibarrUser"); |
||
5527 | print '</td>'; |
||
5528 | if ($action != 'editlogin' && $user->hasRight('adherent', 'creer')) { |
||
5529 | print '<td class="right">'; |
||
5530 | if ($user->hasRight("user", "user", "creer")) { |
||
5531 | print '<a class="editfielda" href="' . $_SERVER['PHP_SELF'] . '?action=editlogin&token=' . newToken() . '&rowid=' . $object->id . '">' . img_edit($langs->trans('SetLinkToUser'), 1) . '</a>'; |
||
5532 | } |
||
5533 | print '</td>'; |
||
5534 | } |
||
5535 | print '</tr></table>'; |
||
5536 | print '</td><td colspan="2" class="valeur">'; |
||
5537 | if ($action == 'editlogin') { |
||
5538 | $form->form_users($_SERVER['PHP_SELF'] . '?rowid=' . $object->id, $object->user_id, 'userid', ''); |
||
5539 | } else { |
||
5540 | if ($object->user_id) { |
||
5541 | $linkeduser = new User($db); |
||
5542 | $linkeduser->fetch($object->user_id); |
||
5543 | print $linkeduser->getNomUrl(-1); |
||
5544 | } else { |
||
5545 | print '<span class="opacitymedium">' . $langs->trans("NoDolibarrAccess") . '</span>'; |
||
5546 | } |
||
5547 | } |
||
5548 | print '</td></tr>'; |
||
5549 | |||
5550 | print "</table>\n"; |
||
5551 | |||
5552 | print "</div></div>\n"; |
||
5553 | print '<div class="clearboth"></div>'; |
||
5554 | |||
5555 | print dol_get_fiche_end(); |
||
5556 | |||
5557 | |||
5558 | /* |
||
5559 | * Action bar |
||
5560 | */ |
||
5561 | |||
5562 | // Button to create a new subscription if member no draft (-1) neither resiliated (0) neither excluded (-2) |
||
5563 | if ($user->hasRight('adherent', 'cotisation', 'creer')) { |
||
5564 | if ($action != 'addsubscription' && $action != 'create_thirdparty') { |
||
5565 | print '<div class="tabsAction">'; |
||
5566 | |||
5567 | if ($object->statut > 0) { |
||
5568 | print '<div class="inline-block divButAction"><a class="butAction" href="' . $_SERVER['PHP_SELF'] . '?rowid=' . $rowid . '&action=addsubscription&token=' . newToken() . '">' . $langs->trans("AddSubscription") . "</a></div>"; |
||
5569 | } else { |
||
5570 | print '<div class="inline-block divButAction"><a class="butActionRefused classfortooltip" href="#" title="' . dol_escape_htmltag($langs->trans("ValidateBefore")) . '">' . $langs->trans("AddSubscription") . '</a></div>'; |
||
5571 | } |
||
5572 | |||
5573 | print '</div>'; |
||
5574 | } |
||
5575 | } |
||
5576 | |||
5577 | /* |
||
5578 | * List of subscriptions |
||
5579 | */ |
||
5580 | if ($action != 'addsubscription' && $action != 'create_thirdparty') { |
||
5581 | $sql = "SELECT d.rowid, d.firstname, d.lastname, d.societe, d.fk_adherent_type as type,"; |
||
5582 | $sql .= " c.rowid as crowid, c.subscription,"; |
||
5583 | $sql .= " c.datec, c.fk_type as cfk_type,"; |
||
5584 | $sql .= " c.dateadh as dateh,"; |
||
5585 | $sql .= " c.datef,"; |
||
5586 | $sql .= " c.fk_bank,"; |
||
5587 | $sql .= " b.rowid as bid,"; |
||
5588 | $sql .= " ba.rowid as baid, ba.label, ba.bank, ba.ref, ba.account_number, ba.fk_accountancy_journal, ba.number, ba.currency_code"; |
||
5589 | $sql .= " FROM " . MAIN_DB_PREFIX . "adherent as d, " . MAIN_DB_PREFIX . "subscription as c"; |
||
5590 | $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "bank as b ON c.fk_bank = b.rowid"; |
||
5591 | $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "bank_account as ba ON b.fk_account = ba.rowid"; |
||
5592 | $sql .= " WHERE d.rowid = c.fk_adherent AND d.rowid=" . ((int) $rowid); |
||
5593 | $sql .= $db->order($sortfield, $sortorder); |
||
5594 | |||
5595 | $result = $db->query($sql); |
||
5596 | if ($result) { |
||
5597 | $subscriptionstatic = new Subscription($db); |
||
5598 | |||
5599 | $num = $db->num_rows($result); |
||
5600 | |||
5601 | print '<table class="noborder centpercent">' . "\n"; |
||
5602 | |||
5603 | print '<tr class="liste_titre">'; |
||
5604 | print_liste_field_titre('Ref', $_SERVER['PHP_SELF'], 'c.rowid', '', $param, '', $sortfield, $sortorder); |
||
5605 | print_liste_field_titre('DateCreation', $_SERVER['PHP_SELF'], '', '', $param, '', $sortfield, $sortorder, 'center '); |
||
5606 | print_liste_field_titre('Type', $_SERVER['PHP_SELF'], '', '', $param, '', $sortfield, $sortorder, 'center '); |
||
5607 | print_liste_field_titre('DateStart', $_SERVER['PHP_SELF'], '', '', $param, '', $sortfield, $sortorder, 'center '); |
||
5608 | print_liste_field_titre('DateEnd', $_SERVER['PHP_SELF'], '', '', $param, '', $sortfield, $sortorder, 'center '); |
||
5609 | print_liste_field_titre('Amount', $_SERVER['PHP_SELF'], '', '', $param, '', $sortfield, $sortorder, 'right '); |
||
5610 | if (isModEnabled('bank')) { |
||
5611 | print_liste_field_titre('Account', $_SERVER['PHP_SELF'], '', '', $param, '', $sortfield, $sortorder, 'right '); |
||
5612 | } |
||
5613 | print "</tr>\n"; |
||
5614 | |||
5615 | $accountstatic = new Account($db); |
||
5616 | $adh = new Adherent($db); |
||
5617 | $adht = new AdherentType($db); |
||
5618 | |||
5619 | $i = 0; |
||
5620 | while ($i < $num) { |
||
5621 | $objp = $db->fetch_object($result); |
||
5622 | |||
5623 | $adh->id = $objp->rowid; |
||
5624 | $adh->typeid = $objp->type; |
||
5625 | |||
5626 | $subscriptionstatic->ref = $objp->crowid; |
||
5627 | $subscriptionstatic->id = $objp->crowid; |
||
5628 | |||
5629 | $typeid = $objp->cfk_type; |
||
5630 | if ($typeid > 0) { |
||
5631 | $adht->fetch($typeid); |
||
5632 | } |
||
5633 | |||
5634 | print '<tr class="oddeven">'; |
||
5635 | print '<td>' . $subscriptionstatic->getNomUrl(1) . '</td>'; |
||
5636 | print '<td class="center">' . dol_print_date($db->jdate($objp->datec), 'dayhour') . "</td>\n"; |
||
5637 | print '<td class="center">'; |
||
5638 | if ($typeid > 0) { |
||
5639 | print $adht->getNomUrl(1); |
||
5640 | } |
||
5641 | print '</td>'; |
||
5642 | print '<td class="center">' . dol_print_date($db->jdate($objp->dateh), 'day') . "</td>\n"; |
||
5643 | print '<td class="center">' . dol_print_date($db->jdate($objp->datef), 'day') . "</td>\n"; |
||
5644 | print '<td class="right amount">' . price($objp->subscription) . '</td>'; |
||
5645 | if (isModEnabled('bank')) { |
||
5646 | print '<td class="right">'; |
||
5647 | if ($objp->bid) { |
||
5648 | $accountstatic->label = $objp->label; |
||
5649 | $accountstatic->id = $objp->baid; |
||
5650 | $accountstatic->number = $objp->number; |
||
5651 | $accountstatic->account_number = $objp->account_number; |
||
5652 | $accountstatic->currency_code = $objp->currency_code; |
||
5653 | |||
5654 | if (isModEnabled('accounting') && $objp->fk_accountancy_journal > 0) { |
||
5655 | $accountingjournal = new AccountingJournal($db); |
||
5656 | $accountingjournal->fetch($objp->fk_accountancy_journal); |
||
5657 | |||
5658 | $accountstatic->accountancy_journal = $accountingjournal->getNomUrl(0, 1, 1, '', 1); |
||
5659 | } |
||
5660 | |||
5661 | $accountstatic->ref = $objp->ref; |
||
5662 | print $accountstatic->getNomUrl(1); |
||
5663 | } else { |
||
5664 | print ' '; |
||
5665 | } |
||
5666 | print '</td>'; |
||
5667 | } |
||
5668 | print "</tr>"; |
||
5669 | $i++; |
||
5670 | } |
||
5671 | |||
5672 | if (empty($num)) { |
||
5673 | $colspan = 6; |
||
5674 | if (isModEnabled('bank')) { |
||
5675 | $colspan++; |
||
5676 | } |
||
5677 | print '<tr><td colspan="' . $colspan . '"><span class="opacitymedium">' . $langs->trans("None") . '</span></td></tr>'; |
||
5678 | } |
||
5679 | |||
5680 | print "</table>"; |
||
5681 | } else { |
||
5682 | dol_print_error($db); |
||
5683 | } |
||
5684 | } |
||
5685 | |||
5686 | |||
5687 | if (($action != 'addsubscription' && $action != 'create_thirdparty')) { |
||
5688 | // Shon online payment link |
||
5689 | $useonlinepayment = (isModEnabled('paypal') || isModEnabled('stripe') || isModEnabled('paybox')); |
||
5690 | |||
5691 | $parameters = array(); |
||
5692 | $reshook = $hookmanager->executeHooks('doShowOnlinePaymentUrl', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks |
||
5693 | if ($reshook > 0) { |
||
5694 | if (isset($hookmanager->resArray['showonlinepaymenturl'])) { |
||
5695 | $useonlinepayment = $hookmanager->resArray['showonlinepaymenturl']; |
||
5696 | } |
||
5697 | } |
||
5698 | |||
5699 | if ($useonlinepayment) { |
||
5700 | print '<br>'; |
||
5701 | |||
5702 | require_once DOL_DOCUMENT_ROOT . '/core/lib/payments.lib.php'; |
||
5703 | print showOnlinePaymentUrl('membersubscription', $object->ref); |
||
5704 | print '<br>'; |
||
5705 | } |
||
5706 | } |
||
5707 | |||
5708 | /* |
||
5709 | * Add new subscription form |
||
5710 | */ |
||
5711 | if (($action == 'addsubscription' || $action == 'create_thirdparty') && $user->hasRight('adherent', 'cotisation', 'creer')) { |
||
5712 | print '<br>'; |
||
5713 | |||
5714 | print load_fiche_titre($langs->trans("NewCotisation")); |
||
5715 | |||
5716 | // Define default choice for complementary actions |
||
5717 | $bankdirect = 0; // 1 means option by default is write to bank direct with no invoice |
||
5718 | $invoiceonly = 0; // 1 means option by default is invoice only |
||
5719 | $bankviainvoice = 0; // 1 means option by default is write to bank via invoice |
||
5720 | if (GETPOST('paymentsave')) { |
||
5721 | if (GETPOST('paymentsave') == 'bankdirect') { |
||
5722 | $bankdirect = 1; |
||
5723 | } |
||
5724 | if (GETPOST('paymentsave') == 'invoiceonly') { |
||
5725 | $invoiceonly = 1; |
||
5726 | } |
||
5727 | if (GETPOST('paymentsave') == 'bankviainvoice') { |
||
5728 | $bankviainvoice = 1; |
||
5729 | } |
||
5730 | } else { |
||
5731 | if (getDolGlobalString('ADHERENT_BANK_USE') == 'bankviainvoice' && isModEnabled('bank') && isModEnabled('societe') && isModEnabled('invoice')) { |
||
5732 | $bankviainvoice = 1; |
||
5733 | } elseif (getDolGlobalString('ADHERENT_BANK_USE') == 'bankdirect' && isModEnabled('bank')) { |
||
5734 | $bankdirect = 1; |
||
5735 | } elseif (getDolGlobalString('ADHERENT_BANK_USE') == 'invoiceonly' && isModEnabled('bank') && isModEnabled('societe') && isModEnabled('invoice')) { |
||
5736 | $invoiceonly = 1; |
||
5737 | } |
||
5738 | } |
||
5739 | |||
5740 | print "\n\n<!-- Form add subscription -->\n"; |
||
5741 | |||
5742 | if ($conf->use_javascript_ajax) { |
||
5743 | //var_dump($bankdirect.'-'.$bankviainvoice.'-'.$invoiceonly); |
||
5744 | print "\n" . '<script type="text/javascript">'; |
||
5745 | print '$(document).ready(function () { |
||
5746 | $(".bankswitchclass, .bankswitchclass2").' . (($bankdirect || $bankviainvoice) ? 'show()' : 'hide()') . '; |
||
5747 | $("#none, #invoiceonly").click(function() { |
||
5748 | $(".bankswitchclass").hide(); |
||
5749 | $(".bankswitchclass2").hide(); |
||
5750 | }); |
||
5751 | $("#bankdirect, #bankviainvoice").click(function() { |
||
5752 | $(".bankswitchclass").show(); |
||
5753 | $(".bankswitchclass2").show(); |
||
5754 | }); |
||
5755 | $("#selectoperation").change(function() { |
||
5756 | var code = $(this).val(); |
||
5757 | if (code == "CHQ") |
||
5758 | { |
||
5759 | $(".fieldrequireddyn").addClass("fieldrequired"); |
||
5760 | if ($("#fieldchqemetteur").val() == "") |
||
5761 | { |
||
5762 | $("#fieldchqemetteur").val($("#memberlabel").val()); |
||
5763 | } |
||
5764 | } |
||
5765 | else |
||
5766 | { |
||
5767 | $(".fieldrequireddyn").removeClass("fieldrequired"); |
||
5768 | } |
||
5769 | }); |
||
5770 | '; |
||
5771 | if (GETPOST('paymentsave')) { |
||
5772 | print '$("#' . GETPOST('paymentsave', 'aZ09') . '").prop("checked", true);'; |
||
5773 | } |
||
5774 | print '});'; |
||
5775 | print '</script>' . "\n"; |
||
5776 | } |
||
5777 | |||
5778 | |||
5779 | // Confirm create third party |
||
5780 | if ($action == 'create_thirdparty') { |
||
5781 | $companyalias = ''; |
||
5782 | $fullname = $object->getFullName($langs); |
||
5783 | |||
5784 | if ($object->morphy == 'mor') { |
||
5785 | $companyname = $object->company; |
||
5786 | if (!empty($fullname)) { |
||
5787 | $companyalias = $fullname; |
||
5788 | } |
||
5789 | } else { |
||
5790 | $companyname = $fullname; |
||
5791 | if (!empty($object->company)) { |
||
5792 | $companyalias = $object->company; |
||
5793 | } |
||
5794 | } |
||
5795 | |||
5796 | // Create a form array |
||
5797 | $formquestion = array( |
||
5798 | array('label' => $langs->trans("NameToCreate"), 'type' => 'text', 'name' => 'companyname', 'value' => $companyname, 'morecss' => 'minwidth300', 'moreattr' => 'maxlength="128"'), |
||
5799 | array('label' => $langs->trans("AliasNames"), 'type' => 'text', 'name' => 'companyalias', 'value' => $companyalias, 'morecss' => 'minwidth300', 'moreattr' => 'maxlength="128"') |
||
5800 | ); |
||
5801 | // If customer code was forced to "required", we ask it at creation to avoid error later |
||
5802 | if (getDolGlobalString('MAIN_COMPANY_CODE_ALWAYS_REQUIRED')) { |
||
5803 | $tmpcompany = new Societe($db); |
||
5804 | $tmpcompany->name = $companyname; |
||
5805 | $tmpcompany->get_codeclient($tmpcompany, 0); |
||
5806 | $customercode = $tmpcompany->code_client; |
||
5807 | $formquestion[] = array( |
||
5808 | 'label' => $langs->trans("CustomerCode"), |
||
5809 | 'type' => 'text', |
||
5810 | 'name' => 'customercode', |
||
5811 | 'value' => $customercode, |
||
5812 | 'morecss' => 'minwidth300', |
||
5813 | 'moreattr' => 'maxlength="128"', |
||
5814 | ); |
||
5815 | } |
||
5816 | // @todo Add other extrafields mandatory for thirdparty creation |
||
5817 | |||
5818 | print $form->formconfirm($_SERVER['PHP_SELF'] . "?rowid=" . $object->id, $langs->trans("CreateDolibarrThirdParty"), $langs->trans("ConfirmCreateThirdParty"), "confirm_create_thirdparty", $formquestion, 1); |
||
5819 | } |
||
5820 | |||
5821 | |||
5822 | print '<form name="subscription" method="POST" action="' . $_SERVER['PHP_SELF'] . '">'; |
||
5823 | print '<input type="hidden" name="token" value="' . newToken() . '">'; |
||
5824 | print '<input type="hidden" name="action" value="subscription">'; |
||
5825 | print '<input type="hidden" name="rowid" value="' . $rowid . '">'; |
||
5826 | print '<input type="hidden" name="memberlabel" id="memberlabel" value="' . dol_escape_htmltag($object->getFullName($langs)) . '">'; |
||
5827 | print '<input type="hidden" name="thirdpartylabel" id="thirdpartylabel" value="' . dol_escape_htmltag($object->company) . '">'; |
||
5828 | |||
5829 | print dol_get_fiche_head(''); |
||
5830 | |||
5831 | print '<div class="div-table-responsive">'; |
||
5832 | print '<table class="border centpercent">' . "\n"; |
||
5833 | print '<tbody>'; |
||
5834 | |||
5835 | // Date payment |
||
5836 | if (GETPOST('paymentyear') && GETPOST('paymentmonth') && GETPOST('paymentday')) { |
||
5837 | $paymentdate = dol_mktime(0, 0, 0, GETPOST('paymentmonth'), GETPOST('paymentday'), GETPOST('paymentyear')); |
||
5838 | } |
||
5839 | |||
5840 | print '<tr>'; |
||
5841 | // Date start subscription |
||
5842 | $currentyear = dol_print_date($now, "%Y"); |
||
5843 | $currentmonth = dol_print_date($now, "%m"); |
||
5844 | print '<td class="fieldrequired">' . $langs->trans("DateSubscription") . '</td><td>'; |
||
5845 | if (GETPOST('reday')) { |
||
5846 | $datefrom = dol_mktime(0, 0, 0, GETPOSTINT('remonth'), GETPOSTINT('reday'), GETPOSTINT('reyear')); |
||
5847 | } |
||
5848 | if (!$datefrom) { |
||
5849 | $datefrom = $object->datevalid; |
||
5850 | if (getDolGlobalString('MEMBER_SUBSCRIPTION_START_AFTER')) { |
||
5851 | $datefrom = dol_time_plus_duree($now, (int) substr(getDolGlobalString('MEMBER_SUBSCRIPTION_START_AFTER'), 0, -1), substr(getDolGlobalString('MEMBER_SUBSCRIPTION_START_AFTER'), -1)); |
||
5852 | } elseif ($object->datefin > 0 && dol_time_plus_duree($object->datefin, $defaultdelay, $defaultdelayunit) > $now) { |
||
5853 | $datefrom = dol_time_plus_duree($object->datefin, 1, 'd'); |
||
5854 | } |
||
5855 | |||
5856 | if (getDolGlobalString('MEMBER_SUBSCRIPTION_START_FIRST_DAY_OF') === "m") { |
||
5857 | $datefrom = dol_get_first_day(dol_print_date($datefrom, "%Y"), dol_print_date($datefrom, "%m")); |
||
5858 | } elseif (getDolGlobalString('MEMBER_SUBSCRIPTION_START_FIRST_DAY_OF') === "Y") { |
||
5859 | $datefrom = dol_get_first_day(dol_print_date($datefrom, "%Y")); |
||
5860 | } |
||
5861 | } |
||
5862 | print $form->selectDate($datefrom, '', 0, 0, 0, "subscription", 1, 1); |
||
5863 | print "</td></tr>"; |
||
5864 | |||
5865 | // Date end subscription |
||
5866 | if (GETPOST('endday')) { |
||
5867 | $dateto = dol_mktime(0, 0, 0, GETPOSTINT('endmonth'), GETPOSTINT('endday'), GETPOSTINT('endyear')); |
||
5868 | } |
||
5869 | if (!$dateto) { |
||
5870 | if (getDolGlobalInt('MEMBER_SUBSCRIPTION_SUGGEST_END_OF_MONTH')) { |
||
5871 | $dateto = dol_get_last_day(dol_print_date($datefrom, "%Y"), dol_print_date($datefrom, "%m")); |
||
5872 | } elseif (getDolGlobalInt('MEMBER_SUBSCRIPTION_SUGGEST_END_OF_YEAR')) { |
||
5873 | $dateto = dol_get_last_day(dol_print_date($datefrom, "%Y")); |
||
5874 | } else { |
||
5875 | $dateto = -1; // By default, no date is suggested |
||
5876 | } |
||
5877 | } |
||
5878 | print '<tr><td>' . $langs->trans("DateEndSubscription") . '</td><td>'; |
||
5879 | print $form->selectDate($dateto, 'end', 0, 0, 0, "subscription", 1, 0); |
||
5880 | print "</td></tr>"; |
||
5881 | |||
5882 | if ($adht->subscription) { |
||
5883 | // Amount |
||
5884 | print '<tr><td class="fieldrequired">' . $langs->trans("Amount") . '</td><td><input type="text" name="subscription" size="6" value="' . (GETPOSTISSET('subscription') ? GETPOST('subscription') : price($adht->amount, 0, '', 0)) . '"> ' . $langs->trans("Currency" . $conf->currency) . '</td></tr>'; |
||
5885 | |||
5886 | // Label |
||
5887 | print '<tr><td>' . $langs->trans("Label") . '</td>'; |
||
5888 | print '<td><input name="label" type="text" size="32" value="'; |
||
5889 | if (!getDolGlobalString('MEMBER_NO_DEFAULT_LABEL')) { |
||
5890 | print $langs->trans("Subscription") . ' ' . dol_print_date(($datefrom ? $datefrom : time()), "%Y"); |
||
5891 | } |
||
5892 | print '"></td></tr>'; |
||
5893 | |||
5894 | // Complementary action |
||
5895 | if ((isModEnabled('bank') || isModEnabled('invoice')) && !getDolGlobalString('ADHERENT_SUBSCRIPTION_HIDECOMPLEMENTARYACTIONS')) { |
||
5896 | $company = new Societe($db); |
||
5897 | if ($object->socid) { |
||
5898 | $result = $company->fetch($object->socid); |
||
5899 | } |
||
5900 | |||
5901 | // No more action |
||
5902 | print '<tr><td class="tdtop fieldrequired">' . $langs->trans('MoreActions'); |
||
5903 | print '</td>'; |
||
5904 | print '<td class="line-height-large">'; |
||
5905 | |||
5906 | print '<input type="radio" class="moreaction" id="none" name="paymentsave" value="none"' . (empty($bankdirect) && empty($invoiceonly) && empty($bankviainvoice) ? ' checked' : '') . '>'; |
||
5907 | print '<label for="none"> ' . $langs->trans("None") . '</label><br>'; |
||
5908 | // Add entry into bank account |
||
5909 | if (isModEnabled('bank')) { |
||
5910 | print '<input type="radio" class="moreaction" id="bankdirect" name="paymentsave" value="bankdirect"' . (!empty($bankdirect) ? ' checked' : ''); |
||
5911 | print '><label for="bankdirect"> ' . $langs->trans("MoreActionBankDirect") . '</label><br>'; |
||
5912 | } |
||
5913 | // Add invoice with no payments |
||
5914 | if (isModEnabled('societe') && isModEnabled('invoice')) { |
||
5915 | print '<input type="radio" class="moreaction" id="invoiceonly" name="paymentsave" value="invoiceonly"' . (!empty($invoiceonly) ? ' checked' : ''); |
||
5916 | //if (empty($object->fk_soc)) print ' disabled'; |
||
5917 | print '><label for="invoiceonly"> ' . $langs->trans("MoreActionInvoiceOnly"); |
||
5918 | if ($object->fk_soc) { |
||
5919 | print ' (' . $langs->trans("ThirdParty") . ': ' . $company->getNomUrl(1) . ')'; |
||
5920 | } else { |
||
5921 | print ' ('; |
||
5922 | if (empty($object->fk_soc)) { |
||
5923 | print img_warning($langs->trans("NoThirdPartyAssociatedToMember")); |
||
5924 | } |
||
5925 | print $langs->trans("NoThirdPartyAssociatedToMember"); |
||
5926 | print ' - <a href="' . $_SERVER['PHP_SELF'] . '?rowid=' . $object->id . '&action=create_thirdparty">'; |
||
5927 | print $langs->trans("CreateDolibarrThirdParty"); |
||
5928 | print '</a>)'; |
||
5929 | } |
||
5930 | if (!getDolGlobalString('ADHERENT_VAT_FOR_SUBSCRIPTIONS') || getDolGlobalString('ADHERENT_VAT_FOR_SUBSCRIPTIONS') != 'defaultforfoundationcountry') { |
||
5931 | print '. <span class="opacitymedium">' . $langs->trans("NoVatOnSubscription", 0) . '</span>'; |
||
5932 | } |
||
5933 | if (getDolGlobalString('ADHERENT_PRODUCT_ID_FOR_SUBSCRIPTIONS') && (isModEnabled('product') || isModEnabled('service'))) { |
||
5934 | $prodtmp = new Product($db); |
||
5935 | $result = $prodtmp->fetch(getDolGlobalString('ADHERENT_PRODUCT_ID_FOR_SUBSCRIPTIONS')); |
||
5936 | if ($result < 0) { |
||
5937 | setEventMessage($prodtmp->error, 'errors'); |
||
5938 | } |
||
5939 | print '. ' . $langs->transnoentitiesnoconv("ADHERENT_PRODUCT_ID_FOR_SUBSCRIPTIONS", $prodtmp->getNomUrl(1)); // must use noentitiesnoconv to avoid to encode html into getNomUrl of product |
||
5940 | } |
||
5941 | print '</label><br>'; |
||
5942 | } |
||
5943 | // Add invoice with payments |
||
5944 | if (isModEnabled('bank') && isModEnabled('societe') && isModEnabled('invoice')) { |
||
5945 | print '<input type="radio" class="moreaction" id="bankviainvoice" name="paymentsave" value="bankviainvoice"' . (!empty($bankviainvoice) ? ' checked' : ''); |
||
5946 | //if (empty($object->fk_soc)) print ' disabled'; |
||
5947 | print '><label for="bankviainvoice"> ' . $langs->trans("MoreActionBankViaInvoice"); |
||
5948 | if ($object->socid) { |
||
5949 | print ' (' . $langs->trans("ThirdParty") . ': ' . $company->getNomUrl(1) . ')'; |
||
5950 | } else { |
||
5951 | print ' ('; |
||
5952 | if (empty($object->socid)) { |
||
5953 | print img_warning($langs->trans("NoThirdPartyAssociatedToMember")); |
||
5954 | } |
||
5955 | print $langs->trans("NoThirdPartyAssociatedToMember"); |
||
5956 | print ' - <a href="' . $_SERVER['PHP_SELF'] . '?rowid=' . $object->id . '&action=create_thirdparty">'; |
||
5957 | print $langs->trans("CreateDolibarrThirdParty"); |
||
5958 | print '</a>)'; |
||
5959 | } |
||
5960 | if (!getDolGlobalString('ADHERENT_VAT_FOR_SUBSCRIPTIONS') || getDolGlobalString('ADHERENT_VAT_FOR_SUBSCRIPTIONS') != 'defaultforfoundationcountry') { |
||
5961 | print '. <span class="opacitymedium">' . $langs->trans("NoVatOnSubscription", 0) . '</span>'; |
||
5962 | } |
||
5963 | if (getDolGlobalString('ADHERENT_PRODUCT_ID_FOR_SUBSCRIPTIONS') && (isModEnabled('product') || isModEnabled('service'))) { |
||
5964 | $prodtmp = new Product($db); |
||
5965 | $result = $prodtmp->fetch(getDolGlobalString('ADHERENT_PRODUCT_ID_FOR_SUBSCRIPTIONS')); |
||
5966 | if ($result < 0) { |
||
5967 | setEventMessage($prodtmp->error, 'errors'); |
||
5968 | } |
||
5969 | print '. ' . $langs->transnoentitiesnoconv("ADHERENT_PRODUCT_ID_FOR_SUBSCRIPTIONS", $prodtmp->getNomUrl(1)); // must use noentitiesnoconv to avoid to encode html into getNomUrl of product |
||
5970 | } |
||
5971 | print '</label><br>'; |
||
5972 | } |
||
5973 | print '</td></tr>'; |
||
5974 | |||
5975 | // Bank account |
||
5976 | print '<tr class="bankswitchclass"><td class="fieldrequired">' . $langs->trans("FinancialAccount") . '</td><td>'; |
||
5977 | print img_picto('', 'bank_account'); |
||
5978 | $form->select_comptes(GETPOST('accountid'), 'accountid', 0, '', 2, '', 0, 'minwidth200'); |
||
5979 | print "</td></tr>\n"; |
||
5980 | |||
5981 | // Payment mode |
||
5982 | print '<tr class="bankswitchclass"><td class="fieldrequired">' . $langs->trans("PaymentMode") . '</td><td>'; |
||
5983 | print $form->select_types_paiements(GETPOST('operation'), 'operation', '', 2, 1, 0, 0, 1, 'minwidth200', 1); |
||
5984 | print "</td></tr>\n"; |
||
5985 | |||
5986 | // Date of payment |
||
5987 | print '<tr class="bankswitchclass"><td class="fieldrequired">' . $langs->trans("DatePayment") . '</td><td>'; |
||
5988 | print $form->selectDate(isset($paymentdate) ? $paymentdate : -1, 'payment', 0, 0, 1, 'subscription', 1, 1); |
||
5989 | print "</td></tr>\n"; |
||
5990 | |||
5991 | print '<tr class="bankswitchclass2"><td>' . $langs->trans('Numero'); |
||
5992 | print ' <em>(' . $langs->trans("ChequeOrTransferNumber") . ')</em>'; |
||
5993 | print '</td>'; |
||
5994 | print '<td><input id="fieldnum_chq" name="num_chq" type="text" size="8" value="' . (!GETPOST('num_chq') ? '' : GETPOST('num_chq')) . '"></td></tr>'; |
||
5995 | |||
5996 | print '<tr class="bankswitchclass2 fieldrequireddyn"><td>' . $langs->trans('CheckTransmitter'); |
||
5997 | print ' <em>(' . $langs->trans("ChequeMaker") . ')</em>'; |
||
5998 | print '</td>'; |
||
5999 | print '<td><input id="fieldchqemetteur" name="chqemetteur" size="32" type="text" value="' . (!GETPOST('chqemetteur') ? '' : GETPOST('chqemetteur')) . '"></td></tr>'; |
||
6000 | |||
6001 | print '<tr class="bankswitchclass2"><td>' . $langs->trans('Bank'); |
||
6002 | print ' <em>(' . $langs->trans("ChequeBank") . ')</em>'; |
||
6003 | print '</td>'; |
||
6004 | print '<td><input id="chqbank" name="chqbank" size="32" type="text" value="' . (!GETPOST('chqbank') ? '' : GETPOST('chqbank')) . '"></td></tr>'; |
||
6005 | } |
||
6006 | } |
||
6007 | |||
6008 | print '<tr><td></td><td></td></tr>'; |
||
6009 | |||
6010 | print '<tr><td>' . $langs->trans("SendAcknowledgementByMail") . '</td>'; |
||
6011 | print '<td>'; |
||
6012 | if (!$object->email) { |
||
6013 | print $langs->trans("NoEMail"); |
||
6014 | } else { |
||
6015 | $adht = new AdherentType($db); |
||
6016 | $adht->fetch($object->typeid); |
||
6017 | |||
6018 | // Send subscription email |
||
6019 | $subject = ''; |
||
6020 | $msg = ''; |
||
6021 | |||
6022 | // Send subscription email |
||
6023 | include_once DOL_DOCUMENT_ROOT . '/core/class/html.formmail.class.php'; |
||
6024 | $formmail = new FormMail($db); |
||
6025 | // Set output language |
||
6026 | $outputlangs = new Translate('', $conf); |
||
6027 | $outputlangs->setDefaultLang(empty($object->thirdparty->default_lang) ? $mysoc->default_lang : $object->thirdparty->default_lang); |
||
6028 | // Load traductions files required by page |
||
6029 | $outputlangs->loadLangs(array("main", "members")); |
||
6030 | // Get email content from template |
||
6031 | $arraydefaultmessage = null; |
||
6032 | $labeltouse = getDolGlobalString('ADHERENT_EMAIL_TEMPLATE_SUBSCRIPTION'); |
||
6033 | |||
6034 | if (!empty($labeltouse)) { |
||
6035 | $arraydefaultmessage = $formmail->getEMailTemplate($db, 'member', $user, $outputlangs, 0, 1, $labeltouse); |
||
6036 | } |
||
6037 | |||
6038 | if (!empty($labeltouse) && is_object($arraydefaultmessage) && $arraydefaultmessage->id > 0) { |
||
6039 | $subject = $arraydefaultmessage->topic; |
||
6040 | $msg = $arraydefaultmessage->content; |
||
6041 | } |
||
6042 | |||
6043 | $substitutionarray = getCommonSubstitutionArray($outputlangs, 0, null, $object); |
||
6044 | complete_substitutions_array($substitutionarray, $outputlangs, $object); |
||
6045 | $subjecttosend = make_substitutions($subject, $substitutionarray, $outputlangs); |
||
6046 | $texttosend = make_substitutions(dol_concatdesc($msg, $adht->getMailOnSubscription()), $substitutionarray, $outputlangs); |
||
6047 | |||
6048 | $tmp = '<input name="sendmail" type="checkbox"' . (GETPOST('sendmail', 'alpha') ? ' checked' : (getDolGlobalString('ADHERENT_DEFAULT_SENDINFOBYMAIL') ? ' checked' : '')) . '>'; |
||
6049 | $helpcontent = ''; |
||
6050 | $helpcontent .= '<b>' . $langs->trans("MailFrom") . '</b>: ' . getDolGlobalString('ADHERENT_MAIL_FROM') . '<br>' . "\n"; |
||
6051 | $helpcontent .= '<b>' . $langs->trans("MailRecipient") . '</b>: ' . $object->email . '<br>' . "\n"; |
||
6052 | $helpcontent .= '<b>' . $langs->trans("MailTopic") . '</b>:<br>' . "\n"; |
||
6053 | if ($subjecttosend) { |
||
6054 | $helpcontent .= $subjecttosend . "\n"; |
||
6055 | } else { |
||
6056 | $langs->load("errors"); |
||
6057 | $helpcontent .= '<span class="error">' . $langs->trans("ErrorModuleSetupNotComplete", $langs->transnoentitiesnoconv("Module310Name")) . '</span>' . "\n"; |
||
6058 | } |
||
6059 | $helpcontent .= "<br>"; |
||
6060 | $helpcontent .= '<b>' . $langs->trans("MailText") . '</b>:<br>'; |
||
6061 | if ($texttosend) { |
||
6062 | $helpcontent .= dol_htmlentitiesbr($texttosend) . "\n"; |
||
6063 | } else { |
||
6064 | $langs->load("errors"); |
||
6065 | $helpcontent .= '<span class="error">' . $langs->trans("ErrorModuleSetupNotComplete", $langs->transnoentitiesnoconv("Module310Name")) . '</span>' . "\n"; |
||
6066 | } |
||
6067 | // @phan-suppress-next-line PhanPluginSuspiciousParamOrder |
||
6068 | print $form->textwithpicto($tmp, $helpcontent, 1, 'help', '', 0, 2, 'helpemailtosend'); |
||
6069 | } |
||
6070 | print '</td></tr>'; |
||
6071 | print '</tbody>'; |
||
6072 | print '</table>'; |
||
6073 | print '</div>'; |
||
6074 | |||
6075 | print dol_get_fiche_end(); |
||
6076 | |||
6077 | print '<div class="center">'; |
||
6078 | $parameters = array(); |
||
6079 | $reshook = $hookmanager->executeHooks('addMoreActionsButtons', $parameters, $object, $action); |
||
6080 | if (empty($reshook)) { |
||
6081 | print '<input type="submit" class="button" name="add" value="' . $langs->trans("AddSubscription") . '">'; |
||
6082 | print ' '; |
||
6083 | print '<input type="submit" class="button button-cancel" name="cancel" value="' . $langs->trans("Cancel") . '">'; |
||
6084 | } |
||
6085 | print '</div>'; |
||
6086 | |||
6087 | print '</form>'; |
||
6088 | |||
6089 | print "\n<!-- End form subscription -->\n\n"; |
||
6090 | } |
||
6091 | |||
6092 | |||
6093 | // End of page |
||
6094 | llxFooter(); |
||
6095 | $db->close(); |
||
6096 | } |
||
6097 | |||
6098 | /** |
||
6099 | * \file htdocs/adherents/type.php |
||
6100 | * \ingroup member |
||
6101 | * \brief Member's type setup |
||
6102 | */ |
||
6103 | public function type() |
||
7092 | } |
||
7093 | |||
7094 | /** |
||
7095 | * \file htdocs/adherents/type_ldap.php |
||
7096 | * \ingroup ldap |
||
7097 | * \brief Page fiche LDAP members types |
||
7098 | */ |
||
7099 | public function type_ldap() |
||
7100 | { |
||
7101 | global $conf; |
||
7102 | global $db; |
||
7103 | global $user; |
||
7104 | global $hookmanager; |
||
7105 | global $user; |
||
7106 | global $menumanager; |
||
7107 | global $langs; |
||
7108 | |||
7109 | // Load translation files required by the page |
||
7110 | $langs->loadLangs(array("admin", "members", "ldap")); |
||
7111 | |||
7112 | $id = GETPOSTINT('rowid'); |
||
7113 | $action = GETPOST('action', 'aZ09'); |
||
7114 | |||
7115 | // Security check |
||
7116 | $result = restrictedArea($user, 'adherent', $id, 'adherent_type'); |
||
7117 | |||
7118 | $object = new AdherentType($db); |
||
7119 | $object->fetch($id); |
||
7120 | |||
7121 | // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context |
||
7122 | $hookmanager->initHooks(array('membertypeldapcard', 'globalcard')); |
||
7123 | |||
7124 | /* |
||
7125 | * Actions |
||
7126 | */ |
||
7127 | |||
7128 | |||
7129 | $parameters = array(); |
||
7130 | $reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks |
||
7131 | if ($reshook < 0) { |
||
7132 | setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); |
||
7133 | } |
||
7134 | |||
7135 | if (empty($reshook)) { |
||
7136 | if ($action == 'dolibarr2ldap') { |
||
7137 | $ldap = new Ldap(); |
||
7138 | $result = $ldap->connectBind(); |
||
7139 | |||
7140 | if ($result > 0) { |
||
7141 | $object->listMembersForMemberType('', 1); |
||
7142 | |||
7143 | $info = $object->_load_ldap_info(); |
||
7144 | $dn = $object->_load_ldap_dn($info); |
||
7145 | $olddn = $dn; // We can say that old dn = dn as we force synchro |
||
7146 | |||
7147 | $result = $ldap->update($dn, $info, $user, $olddn); |
||
7148 | } |
||
7149 | |||
7150 | if ($result >= 0) { |
||
7151 | setEventMessages($langs->trans("MemberTypeSynchronized"), null, 'mesgs'); |
||
7152 | } else { |
||
7153 | setEventMessages($ldap->error, $ldap->errors, 'errors'); |
||
7154 | } |
||
7155 | } |
||
7156 | } |
||
7157 | |||
7158 | /* |
||
7159 | * View |
||
7160 | */ |
||
7161 | |||
7162 | llxHeader(); |
||
7163 | |||
7164 | $form = new Form($db); |
||
7165 | |||
7166 | $head = member_type_prepare_head($object); |
||
7167 | |||
7168 | print dol_get_fiche_head($head, 'ldap', $langs->trans("MemberType"), -1, 'group'); |
||
7169 | |||
7170 | $linkback = '<a href="' . DOL_URL_ROOT . '/adherents/type.php?restore_lastsearch_values=1">' . $langs->trans("BackToList") . '</a>'; |
||
7171 | |||
7172 | dol_banner_tab($object, 'rowid', $linkback); |
||
7173 | |||
7174 | print '<div class="fichecenter">'; |
||
7175 | print '<div class="underbanner clearboth"></div>'; |
||
7176 | |||
7177 | print '<table class="border centpercent">'; |
||
7178 | |||
7179 | // LDAP DN |
||
7180 | print '<tr><td>LDAP ' . $langs->trans("LDAPMemberTypeDn") . '</td><td class="valeur">' . getDolGlobalString('LDAP_MEMBER_TYPE_DN') . "</td></tr>\n"; |
||
7181 | |||
7182 | // LDAP Cle |
||
7183 | print '<tr><td>LDAP ' . $langs->trans("LDAPNamingAttribute") . '</td><td class="valeur">' . getDolGlobalString('LDAP_KEY_MEMBERS_TYPES') . "</td></tr>\n"; |
||
7184 | |||
7185 | // LDAP Server |
||
7186 | print '<tr><td>LDAP ' . $langs->trans("Type") . '</td><td class="valeur">' . getDolGlobalString('LDAP_SERVER_TYPE') . "</td></tr>\n"; |
||
7187 | print '<tr><td>LDAP ' . $langs->trans("Version") . '</td><td class="valeur">' . getDolGlobalString('LDAP_SERVER_PROTOCOLVERSION') . "</td></tr>\n"; |
||
7188 | print '<tr><td>LDAP ' . $langs->trans("LDAPPrimaryServer") . '</td><td class="valeur">' . getDolGlobalString('LDAP_SERVER_HOST') . "</td></tr>\n"; |
||
7189 | print '<tr><td>LDAP ' . $langs->trans("LDAPSecondaryServer") . '</td><td class="valeur">' . getDolGlobalString('LDAP_SERVER_HOST_SLAVE') . "</td></tr>\n"; |
||
7190 | print '<tr><td>LDAP ' . $langs->trans("LDAPServerPort") . '</td><td class="valeur">' . getDolGlobalString('LDAP_SERVER_PORT') . "</td></tr>\n"; |
||
7191 | |||
7192 | print '</table>'; |
||
7193 | |||
7194 | print '</div>'; |
||
7195 | |||
7196 | print dol_get_fiche_end(); |
||
7197 | |||
7198 | /* |
||
7199 | * Action bar |
||
7200 | */ |
||
7201 | |||
7202 | print '<div class="tabsAction">'; |
||
7203 | |||
7204 | if (getDolGlobalInt('LDAP_MEMBER_TYPE_ACTIVE') === Ldap::SYNCHRO_DOLIBARR_TO_LDAP) { |
||
7205 | print '<a class="butAction" href="' . $_SERVER['PHP_SELF'] . '?rowid=' . $object->id . '&action=dolibarr2ldap">' . $langs->trans("ForceSynchronize") . '</a>'; |
||
7206 | } |
||
7207 | |||
7208 | print "</div>\n"; |
||
7209 | |||
7210 | if (getDolGlobalInt('LDAP_MEMBER_TYPE_ACTIVE') === Ldap::SYNCHRO_DOLIBARR_TO_LDAP) { |
||
7211 | print "<br>\n"; |
||
7212 | } |
||
7213 | |||
7214 | |||
7215 | |||
7216 | // Display LDAP attributes |
||
7217 | print load_fiche_titre($langs->trans("LDAPInformationsForThisMemberType")); |
||
7218 | |||
7219 | print '<table width="100%" class="noborder">'; |
||
7220 | |||
7221 | print '<tr class="liste_titre">'; |
||
7222 | print '<td>' . $langs->trans("LDAPAttributes") . '</td>'; |
||
7223 | print '<td>' . $langs->trans("Value") . '</td>'; |
||
7224 | print '</tr>'; |
||
7225 | |||
7226 | // LDAP reading |
||
7227 | $ldap = new Ldap(); |
||
7228 | $result = $ldap->connectBind(); |
||
7229 | if ($result > 0) { |
||
7230 | $info = $object->_load_ldap_info(); |
||
7231 | $dn = $object->_load_ldap_dn($info, 1); |
||
7232 | $search = "(" . $object->_load_ldap_dn($info, 2) . ")"; |
||
7233 | |||
7234 | $records = $ldap->getAttribute($dn, $search); |
||
7235 | |||
7236 | //print_r($records); |
||
7237 | |||
7238 | // Show tree |
||
7239 | if (((!is_numeric($records)) || $records != 0) && (!isset($records['count']) || $records['count'] > 0)) { |
||
7240 | if (!is_array($records)) { |
||
7241 | print '<tr class="oddeven"><td colspan="2"><span class="error">' . $langs->trans("ErrorFailedToReadLDAP") . '</span></td></tr>'; |
||
7242 | } else { |
||
7243 | $result = show_ldap_content($records, 0, $records['count'], true); |
||
7244 | } |
||
7245 | } else { |
||
7246 | print '<tr class="oddeven"><td colspan="2">' . $langs->trans("LDAPRecordNotFound") . ' (dn=' . dol_escape_htmltag($dn) . ' - search=' . dol_escape_htmltag($search) . ')</td></tr>'; |
||
7247 | } |
||
7248 | |||
7249 | $ldap->unbind(); |
||
7250 | } else { |
||
7251 | setEventMessages($ldap->error, $ldap->errors, 'errors'); |
||
7252 | } |
||
7253 | |||
7254 | print '</table>'; |
||
7255 | |||
7256 | // End of page |
||
7257 | llxFooter(); |
||
7258 | $db->close(); |
||
7259 | } |
||
7260 | |||
7261 | /** |
||
7262 | * \file htdocs/adherents/type_translation.php |
||
7263 | * \ingroup product |
||
7264 | * \brief Member translation page |
||
7265 | */ |
||
7266 | public function type_translation() |
||
7551 | } |
||
7552 | |||
7553 | /** |
||
7554 | * \file htdocs/adherents/vcard.php |
||
7555 | * \ingroup societe |
||
7556 | * \brief Vcard tab of a member |
||
7557 | */ |
||
7558 | public function vcard() |
||
7709 | } |
||
7710 | |||
7711 | } |
||
7712 |
In general, usage of exit should be done with care and only when running in a scripting context like a CLI script.