* Copyright (C) 2006-2015 Laurent Destailleur * Copyright (C) 2006-2012 Regis Houssin * Copyright (C) 2011 Juanjo Menent * Copyright (C) 2024 Alexandre Spangaro * Copyright (C) 2024-2025 Frédéric France * Copyright (C) 2025 MDW * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ /** * \file htdocs/adherents/admin/website.php * \ingroup member * \brief File of main public page for member module */ // Load Dolibarr environment require '../../main.inc.php'; /** * @var Conf $conf * @var DoliDB $db * @var HookManager $hookmanager * @var Societe $mysoc * @var Translate $langs * @var User $user * * @var string $dolibarr_main_url_root */ require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/member.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/payments.lib.php'; require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent_type.class.php'; // Load translation files required by the page $langs->loadLangs(array("admin", "members")); $action = GETPOST('action', 'aZ09'); // Hook to be used by external payment modules (ie Payzen, ...) $hookmanager = new HookManager($db); $hookmanager->initHooks(array('newpayment')); if (!$user->admin) { accessforbidden(); } $error = 0; /* * Actions */ if ($action == 'setMEMBER_ENABLE_PUBLIC') { if (GETPOST('value')) { dolibarr_set_const($db, 'MEMBER_ENABLE_PUBLIC', 1, 'chaine', 0, '', $conf->entity); } else { dolibarr_set_const($db, 'MEMBER_ENABLE_PUBLIC', 0, 'chaine', 0, '', $conf->entity); } } if ($action == 'update') { $public = GETPOST('MEMBER_ENABLE_PUBLIC'); if (GETPOST('MEMBER_NEWFORM_AMOUNT') !== '') { $amount = price2num(GETPOST('MEMBER_NEWFORM_AMOUNT'), 'MT', 2); } else { $amount = ''; } $minamount = GETPOST('MEMBER_MIN_AMOUNT'); $publiccounters = GETPOST('MEMBER_COUNTERS_ARE_PUBLIC'); $showtable = GETPOST('MEMBER_SHOW_TABLE'); $showvoteallowed = GETPOST('MEMBER_SHOW_VOTE_ALLOWED'); $payonline = GETPOST('MEMBER_NEWFORM_PAYONLINE'); $forcetype = GETPOSTINT('MEMBER_NEWFORM_FORCETYPE'); $forcemorphy = GETPOST('MEMBER_NEWFORM_FORCEMORPHY', 'aZ09'); $res = dolibarr_set_const($db, "MEMBER_ENABLE_PUBLIC", $public, 'chaine', 0, '', $conf->entity); $res = dolibarr_set_const($db, "MEMBER_NEWFORM_AMOUNT", $amount, 'chaine', 0, '', $conf->entity); $res = dolibarr_set_const($db, "MEMBER_MIN_AMOUNT", $minamount, 'chaine', 0, '', $conf->entity); $res = dolibarr_set_const($db, "MEMBER_COUNTERS_ARE_PUBLIC", $publiccounters, 'chaine', 0, '', $conf->entity); $res = dolibarr_set_const($db, "MEMBER_SKIP_TABLE", $showtable ? 0 : 1, 'chaine', 0, '', $conf->entity); // Logic is reversed for retrocompatibility: "skip -> show" $res = dolibarr_set_const($db, "MEMBER_HIDE_VOTE_ALLOWED", $showvoteallowed ? 0 : 1, 'chaine', 0, '', $conf->entity); // Logic is reversed for retrocompatibility: "hide -> show" $res = dolibarr_set_const($db, "MEMBER_NEWFORM_PAYONLINE", $payonline, 'chaine', 0, '', $conf->entity); if ($forcetype < 0) { $res = dolibarr_del_const($db, "MEMBER_NEWFORM_FORCETYPE", $conf->entity); } else { $res = dolibarr_set_const($db, "MEMBER_NEWFORM_FORCETYPE", $forcetype, 'chaine', 0, '', $conf->entity); } if (empty($forcemorphy) || $forcemorphy == '-1') { $res = dolibarr_del_const($db, "MEMBER_NEWFORM_FORCEMORPHY", $conf->entity); } else { $res = dolibarr_set_const($db, "MEMBER_NEWFORM_FORCEMORPHY", $forcemorphy, 'chaine', 0, '', $conf->entity); } if (!($res > 0)) { $error++; } if (!$error) { setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); } else { setEventMessages($langs->trans("Error"), null, 'errors'); } } /* * View */ $form = new Form($db); $title = $langs->trans("MembersSetup"); $help_url = 'EN:Module_Foundations|FR:Module_Adhérents|ES:Módulo_Miembros|DE:Modul_Mitglieder'; llxHeader('', $title, $help_url, '', 0, 0, '', '', '', 'mod-member page-admin_website'); $linkback = ''.img_picto($langs->trans("BackToModuleList"), 'back', 'class="pictofixedwidth"').''.$langs->trans("BackToModuleList").''; print load_fiche_titre($title, $linkback, 'title_setup'); $head = member_admin_prepare_head(); print '
'; print ''; print ''; print dol_get_fiche_head($head, 'website', $langs->trans("Members"), -1, 'user'); if ($conf->use_javascript_ajax) { print "\n".''."\n"; } print ''.$langs->trans("BlankSubscriptionFormDesc").'

'; $param = ''; $enabledisablehtml = $langs->trans("EnablePublicSubscriptionForm").' '; if (!getDolGlobalString('MEMBER_ENABLE_PUBLIC')) { // Button off, click to enable $enabledisablehtml .= ''; $enabledisablehtml .= img_picto($langs->trans("Disabled"), 'switch_off'); $enabledisablehtml .= ''; } else { // Button on, click to disable $enabledisablehtml .= ''; $enabledisablehtml .= img_picto($langs->trans("Activated"), 'switch_on'); $enabledisablehtml .= ''; } print $enabledisablehtml; print ''; print '

'; if (getDolGlobalString('MEMBER_ENABLE_PUBLIC')) { print '
'; print img_picto('', 'globe').' '.$langs->trans('BlankSubscriptionForm').'
'; if (isModEnabled('multicompany')) { $entity_qr = '?entity='.((int) $conf->entity); } else { $entity_qr = ''; } // Define $urlwithroot $urlwithouturlroot = preg_replace('/'.preg_quote(DOL_URL_ROOT, '/').'$/i', '', trim($dolibarr_main_url_root)); $urlwithroot = $urlwithouturlroot.DOL_URL_ROOT; // This is to use external domain name found into config file //$urlwithroot=DOL_MAIN_URL_ROOT; // This is to use same domain name than current print ''; print ajax_autoselect('publicurlmember'); print '

'; print '
'; print ''; print ''; print ''; print ''; print "\n"; // Force Type $adht = new AdherentType($db); print '\n"; // Force nature of member (mor/phy) $morphys = [ "phy" => $langs->trans("Physical"), "mor" => $langs->trans("Moral"), ]; print '\n"; // Amount print '\n"; // Min amount print '\n"; // SHow counter of validated members publicly print '\n"; // Show the table of all available membership types. If not, show a form (as the default was for Dolibarr <=16.0) $skiptable = getDolGlobalInt('MEMBER_SKIP_TABLE'); print '\n"; // Show "vote allowed" setting for membership types $hidevoteallowed = getDolGlobalInt('MEMBER_HIDE_VOTE_ALLOWED'); print '\n"; // Jump to an online payment page print '\n"; print '
'.$langs->trans("Parameter").'
'; print $langs->trans("ForceMemberType"); print ''; $listofval = array(); $listofval += $adht->liste_array(1); $forcetype = getDolGlobalInt('MEMBER_NEWFORM_FORCETYPE', -1); print $form->selectarray("MEMBER_NEWFORM_FORCETYPE", $listofval, $forcetype, $langs->trans("No"), 0, 0, '', 0, 0, 0, '', 'width200'); print "
'; print $langs->trans("ForceMemberNature"); print ''; $forcenature = getDolGlobalString('MEMBER_NEWFORM_FORCEMORPHY'); // 'phy' or 'mor' print $form->selectarray("MEMBER_NEWFORM_FORCEMORPHY", $morphys, $forcenature, $langs->trans("No"), 0, 0, '', 0, 0, 0, '', 'width200'); print "
'; print $langs->trans("DefaultAmount"); print ''; print ''; print ' '.$langs->getCurrencySymbol($mysoc->currency_code).''; print "
'; print $langs->trans("MinimumAmount"); print ''; print ''; print ' '.$langs->getCurrencySymbol($mysoc->currency_code).''; print "
'; print $langs->trans("MemberCountersArePublic"); print ''; print $form->selectyesno("MEMBER_COUNTERS_ARE_PUBLIC", getDolGlobalInt('MEMBER_COUNTERS_ARE_PUBLIC'), 1, false, 0, 1); print "
'; print $langs->trans("MembersShowMembershipTypesTable"); print ''; print $form->selectyesno("MEMBER_SHOW_TABLE", (int) !$skiptable, 1, false, 0, 1); // Reverse the logic "hide -> show" for retrocompatibility print "
'; print $langs->trans("MembersShowVotesAllowed"); print ''; print $form->selectyesno("MEMBER_SHOW_VOTE_ALLOWED", (int) !$hidevoteallowed, 1, false, 0, 1); // Reverse the logic "hide -> show" for retrocompatibility print "
'; print $langs->trans("MEMBER_NEWFORM_PAYONLINE"); print ''; // Initialize $validpaymentmethod // The list can be complete by the hook 'doValidatePayment' executed inside getValidOnlinePaymentMethods() $validpaymentmethod = getValidOnlinePaymentMethods('', 1); // Define $listofval using the $validpaymentmethod $listofval = array(); $listofval['-1'] = array('label' => $langs->trans('No')); $listofval['all'] = array('label' => $langs->trans('Yes').' ('.$langs->trans("VisitorCanChooseItsPaymentMode").')', 'data-html' => $langs->trans('Yes').'   ('.$langs->trans("VisitorCanChooseItsPaymentMode").')'); foreach ($validpaymentmethod as $key => $val) { if (is_array($val)) { $listofval[$key] = $val; } else { $listofval[$key] = array('label' => $key, 'status' => 'valid'); } } print $form->selectarray("MEMBER_NEWFORM_PAYONLINE", $listofval, getDolGlobalString('MEMBER_NEWFORM_PAYONLINE'), 0); print "
'; print '
'; print '
'; print ''; print '
'; } print dol_get_fiche_end(); print '
'; // End of page llxFooter(); $db->close();