* Copyright (C) 2001-2002 Jean-Louis Bergamo * Copyright (C) 2006-2013 Laurent Destailleur * Copyright (C) 2012 Regis Houssin * Copyright (C) 2012 J. Fernando Lagrange * Copyright (C) 2018-2019 Frédéric France * Copyright (C) 2018 Alexandre Spangaro * Copyright (C) 2021 Waël Almoman * Copyright (C) 2022 Udo Tamm * * 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/public/members/new.php * \ingroup member * \brief Example of form to add a new member * * Note that you can add following constant to change behaviour of page * MEMBER_NEWFORM_AMOUNT Default amount for auto-subscribe form * MEMBER_MIN_AMOUNT Minimum amount * MEMBER_NEWFORM_PAYONLINE Suggest payment with paypal, paybox or stripe * MEMBER_NEWFORM_DOLIBARRTURNOVER Show field turnover (specific for dolibarr foundation) * MEMBER_URL_REDIRECT_SUBSCRIPTION Url to redirect once registration form has been submitted (hidden option, by default we just show a message on same page or redirect to the payment page) * MEMBER_NEWFORM_FORCETYPE Force type of member * MEMBER_NEWFORM_FORCEMORPHY Force nature of member (mor/phy) * MEMBER_NEWFORM_FORCECOUNTRYCODE Force country */ if (!defined('NOLOGIN')) { define("NOLOGIN", 1); // This means this output page does not require to be logged. } if (!defined('NOCSRFCHECK')) { define("NOCSRFCHECK", 1); // We accept to go on this page from external web site. } if (!defined('NOBROWSERNOTIF')) { define('NOBROWSERNOTIF', '1'); } if (!defined('NOIPCHECK')) { define('NOIPCHECK', '1'); // Do not check IP defined into conf $dolibarr_main_restrict_ip } // For MultiCompany module. // Do not use GETPOST here, function is not defined and define must be done before including main.inc.php $entity = (!empty($_GET['entity']) ? (int) $_GET['entity'] : (!empty($_POST['entity']) ? (int) $_POST['entity'] : 1)); if (is_numeric($entity)) { define("DOLENTITY", $entity); } // Load Dolibarr environment require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/payments.lib.php'; require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php'; require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent_type.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/cunits.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; // Init vars $backtopage = GETPOST('backtopage', 'alpha'); $action = GETPOST('action', 'aZ09'); $errmsg = ''; $num = 0; $error = 0; // Load translation files $langs->loadLangs(array("main", "members", "companies", "install", "other")); // Security check if (empty($conf->adherent->enabled)) { httponly_accessforbidden('Module Membership not enabled'); } if (empty($conf->global->MEMBER_ENABLE_PUBLIC)) { httponly_accessforbidden("Auto subscription form for public visitors has not been enabled"); } // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context $hookmanager->initHooks(array('publicnewmembercard', 'globalcard')); $extrafields = new ExtraFields($db); $object = new Adherent($db); $user->loadDefaultValues(); /** * Show header for new member * * @param string $title Title * @param string $head Head array * @param int $disablejs More content into html header * @param int $disablehead More content into html header * @param array $arrayofjs Array of complementary js files * @param array $arrayofcss Array of complementary css files * @return void */ function llxHeaderVierge($title, $head = "", $disablejs = 0, $disablehead = 0, $arrayofjs = '', $arrayofcss = '') { global $user, $conf, $langs, $mysoc; top_htmlhead($head, $title, $disablejs, $disablehead, $arrayofjs, $arrayofcss); // Show html headers print ''; // Define urllogo $urllogo = DOL_URL_ROOT.'/theme/common/login_logo.png'; if (!empty($mysoc->logo_small) && is_readable($conf->mycompany->dir_output.'/logos/thumbs/'.$mysoc->logo_small)) { $urllogo = DOL_URL_ROOT.'/viewimage.php?cache=1&modulepart=mycompany&file='.urlencode('logos/thumbs/'.$mysoc->logo_small); } elseif (!empty($mysoc->logo) && is_readable($conf->mycompany->dir_output.'/logos/'.$mysoc->logo)) { $urllogo = DOL_URL_ROOT.'/viewimage.php?cache=1&modulepart=mycompany&file='.urlencode('logos/'.$mysoc->logo); } elseif (is_readable(DOL_DOCUMENT_ROOT.'/theme/dolibarr_logo.svg')) { $urllogo = DOL_URL_ROOT.'/theme/dolibarr_logo.svg'; } print '
'; // Output html code for logo if ($urllogo) { print '
'; print '
'; print ''; print '
'; if (empty($conf->global->MAIN_HIDE_POWERED_BY)) { print ''; } print '
'; } if (!empty($conf->global->MEMBER_IMAGE_PUBLIC_REGISTRATION)) { print '
'; print ''; print '
'; } print '
'; print '
'; } /** * Show footer for new member * * @return void */ function llxFooterVierge() { print '
'; printCommonFooter('public'); print "\n"; print "\n"; } /* * Actions */ $parameters = array(); // Note that $action and $object may have been modified by some hooks $reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); if ($reshook < 0) { setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); } // Action called when page is submitted if (empty($reshook) && $action == 'add') { $error = 0; $urlback = ''; $db->begin(); // test if login already exists if (empty($conf->global->ADHERENT_LOGIN_NOT_REQUIRED)) { if (!GETPOST('login')) { $error++; $errmsg .= $langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Login"))."
\n"; } $sql = "SELECT login FROM ".MAIN_DB_PREFIX."adherent WHERE login = '".$db->escape(GETPOST('login'))."'"; $result = $db->query($sql); if ($result) { $num = $db->num_rows($result); } if ($num != 0) { $error++; $langs->load("errors"); $errmsg .= $langs->trans("ErrorLoginAlreadyExists")."
\n"; } if (!GETPOSTISSET("pass1") || !GETPOSTISSET("pass2") || GETPOST("pass1", 'none') == '' || GETPOST("pass2", 'none') == '' || GETPOST("pass1", 'none') != GETPOST("pass2", 'none')) { $error++; $langs->load("errors"); $errmsg .= $langs->trans("ErrorPasswordsMustMatch")."
\n"; } if (!GETPOST('email')) { $error++; $errmsg .= $langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("EMail"))."
\n"; } } if (GETPOST('typeid') <= 0) { $error++; $errmsg .= $langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Type"))."
\n"; } if (!in_array(GETPOST('morphy'), array('mor', 'phy'))) { $error++; $errmsg .= $langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv('Nature'))."
\n"; } if (!GETPOST('lastname')) { $error++; $errmsg .= $langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Lastname"))."
\n"; } if (!GETPOST('firstname')) { $error++; $errmsg .= $langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Firstname"))."
\n"; } if (!empty($conf->global->ADHERENT_MAIL_REQUIRED) && empty(GETPOST('email'))) { $error++; $errmsg .= $langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv('Email'))."
\n"; } elseif (GETPOST("email") && !isValidEmail(GETPOST("email"))) { $langs->load('errors'); $error++; $errmsg .= $langs->trans("ErrorBadEMail", GETPOST("email"))."
\n"; } $birthday = dol_mktime(GETPOST("birthhour", 'int'), GETPOST("birthmin", 'int'), GETPOST("birthsec", 'int'), GETPOST("birthmonth", 'int'), GETPOST("birthday", 'int'), GETPOST("birthyear", 'int')); if (GETPOST("birthmonth") && empty($birthday)) { $error++; $langs->load("errors"); $errmsg .= $langs->trans("ErrorBadDateFormat")."
\n"; } if (!empty($conf->global->MEMBER_NEWFORM_DOLIBARRTURNOVER)) { if (GETPOST("morphy") == 'mor' && GETPOST('budget') <= 0) { $error++; $errmsg .= $langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("TurnoverOrBudget"))."
\n"; } } $public = GETPOSTISSET('public') ? 1 : 0; if (!$error) { // E-mail looks OK and login does not exist $adh = new Adherent($db); $adh->statut = -1; $adh->public = $public; $adh->firstname = GETPOST('firstname'); $adh->lastname = GETPOST('lastname'); $adh->gender = GETPOST('gender'); $adh->civility_id = GETPOST('civility_id'); $adh->societe = GETPOST('societe'); $adh->address = GETPOST('address'); $adh->zip = GETPOST('zipcode'); $adh->town = GETPOST('town'); $adh->email = GETPOST('email'); if (empty($conf->global->ADHERENT_LOGIN_NOT_REQUIRED)) { $adh->login = GETPOST('login'); $adh->pass = GETPOST('pass1'); } $adh->photo = GETPOST('photo'); $adh->country_id = getDolGlobalString("MEMBER_NEWFORM_FORCECOUNTRYCODE", GETPOST('country_id', 'int')); $adh->state_id = GETPOST('state_id', 'int'); $adh->typeid = getDolGlobalString("MEMBER_NEWFORM_FORCETYPE", GETPOST('typeid', 'int')); $adh->note_private = GETPOST('note_private'); $adh->morphy = getDolGlobalString("MEMBER_NEWFORM_FORCEMORPHY", GETPOST('morphy')); $adh->birth = $birthday; $adh->ip = getUserRemoteIP(); $nb_post_max = getDolGlobalInt("MAIN_SECURITY_MAX_POST_ON_PUBLIC_PAGES_BY_IP_ADDRESS", 200); $now = dol_now(); $minmonthpost = dol_time_plus_duree($now, -1, "m"); // Calculate nb of post for IP $nb_post_ip = 0; if ($nb_post_max > 0) { // Calculate only if there is a limit to check $sql = "SELECT COUNT(ref) as nb_adh"; $sql .= " FROM ".MAIN_DB_PREFIX."adherent"; $sql .= " WHERE ip = '".$db->escape($adh->ip)."'"; $sql .= " AND datec > '".$db->idate($minmonthpost)."'"; $resql = $db->query($sql); if ($resql) { $num = $db->num_rows($resql); $i = 0; while ($i < $num) { $i++; $obj = $db->fetch_object($resql); $nb_post_ip = $obj->nb_adh; } } } // Fill array 'array_options' with data from add form $extrafields->fetch_name_optionals_label($adh->table_element); $ret = $extrafields->setOptionalsFromPost(null, $adh); if ($ret < 0) { $error++; $errmsg .= $adh->error; } if ($nb_post_max > 0 && $nb_post_ip >= $nb_post_max) { $error++; $errmsg .= $langs->trans("AlreadyTooMuchPostOnThisIPAdress"); array_push($adh->errors, $langs->trans("AlreadyTooMuchPostOnThisIPAdress")); } if (!$error) { $result = $adh->create($user); if ($result > 0) { require_once DOL_DOCUMENT_ROOT.'/core/class/CMailFile.class.php'; $object = $adh; $adht = new AdherentType($db); $adht->fetch($object->typeid); if ($object->email) { $subject = ''; $msg = ''; // Send subscription email include_once DOL_DOCUMENT_ROOT.'/core/class/html.formmail.class.php'; $formmail = new FormMail($db); // Set output language $outputlangs = new Translate('', $conf); $outputlangs->setDefaultLang(empty($object->thirdparty->default_lang) ? $mysoc->default_lang : $object->thirdparty->default_lang); // Load traductions files required by page $outputlangs->loadLangs(array("main", "members")); // Get email content from template $arraydefaultmessage = null; $labeltouse = $conf->global->ADHERENT_EMAIL_TEMPLATE_AUTOREGISTER; if (!empty($labeltouse)) { $arraydefaultmessage = $formmail->getEMailTemplate($db, 'member', $user, $outputlangs, 0, 1, $labeltouse); } if (!empty($labeltouse) && is_object($arraydefaultmessage) && $arraydefaultmessage->id > 0) { $subject = $arraydefaultmessage->topic; $msg = $arraydefaultmessage->content; } $substitutionarray = getCommonSubstitutionArray($outputlangs, 0, null, $object); complete_substitutions_array($substitutionarray, $outputlangs, $object); $subjecttosend = make_substitutions($subject, $substitutionarray, $outputlangs); $texttosend = make_substitutions(dol_concatdesc($msg, $adht->getMailOnValid()), $substitutionarray, $outputlangs); if ($subjecttosend && $texttosend) { $moreinheader = 'X-Dolibarr-Info: send_an_email by public/members/new.php'."\r\n"; $result = $object->send_an_email($texttosend, $subjecttosend, array(), array(), array(), "", "", 0, -1, '', $moreinheader); } /*if ($result < 0) { $error++; setEventMessages($object->error, $object->errors, 'errors'); }*/ } // Send email to the foundation to say a new member subscribed with autosubscribe form if (!empty($conf->global->MAIN_INFO_SOCIETE_MAIL) && !empty($conf->global->ADHERENT_AUTOREGISTER_NOTIF_MAIL_SUBJECT) && !empty($conf->global->ADHERENT_AUTOREGISTER_NOTIF_MAIL)) { // Define link to login card $appli = constant('DOL_APPLICATION_TITLE'); if (!empty($conf->global->MAIN_APPLICATION_TITLE)) { $appli = $conf->global->MAIN_APPLICATION_TITLE; if (preg_match('/\d\.\d/', $appli)) { if (!preg_match('/'.preg_quote(DOL_VERSION).'/', $appli)) { $appli .= " (".DOL_VERSION.")"; // If new title contains a version that is different than core } } else { $appli .= " ".DOL_VERSION; } } else { $appli .= " ".DOL_VERSION; } $to = $adh->makeSubstitution($conf->global->MAIN_INFO_SOCIETE_MAIL); $from = $conf->global->ADHERENT_MAIL_FROM; $mailfile = new CMailFile( '['.$appli.'] '.$conf->global->ADHERENT_AUTOREGISTER_NOTIF_MAIL_SUBJECT, $to, $from, $adh->makeSubstitution($conf->global->ADHERENT_AUTOREGISTER_NOTIF_MAIL), array(), array(), array(), "", "", 0, -1 ); if (!$mailfile->sendfile()) { dol_syslog($langs->trans("ErrorFailedToSendMail", $from, $to), LOG_ERR); } } // Auto-create thirdparty on member creation if (!empty($conf->global->ADHERENT_DEFAULT_CREATE_THIRDPARTY)) { $company = new Societe($db); $result = $company->create_from_member($adh); if ($result < 0) { $error++; $errmsg .= join('
', $company->errors); } } if (!empty($backtopage)) { $urlback = $backtopage; } elseif (!empty($conf->global->MEMBER_URL_REDIRECT_SUBSCRIPTION)) { $urlback = $conf->global->MEMBER_URL_REDIRECT_SUBSCRIPTION; // TODO Make replacement of __AMOUNT__, etc... } else { $urlback = $_SERVER["PHP_SELF"]."?action=added&token=".newToken(); } if (!empty($conf->global->MEMBER_NEWFORM_PAYONLINE) && $conf->global->MEMBER_NEWFORM_PAYONLINE != '-1') { if (empty($adht->caneditamount)) { // If edition of amount not allowed // TODO Check amount is same than the amount required for the type of member or if not defined as the defeault amount into $conf->global->MEMBER_NEWFORM_AMOUNT // It is not so important because a test is done on return of payment validation. } $urlback = getOnlinePaymentUrl(0, 'member', $adh->ref, price2num(GETPOST('amount', 'alpha'), 'MT'), '', 0); if (GETPOST('email')) { $urlback .= '&email='.urlencode(GETPOST('email')); } if ($conf->global->MEMBER_NEWFORM_PAYONLINE != '-1' && $conf->global->MEMBER_NEWFORM_PAYONLINE != 'all') { $urlback .= '&paymentmethod='.urlencode($conf->global->MEMBER_NEWFORM_PAYONLINE); } } else { if (!empty($entity)) { $urlback .= '&entity='.((int) $entity); } } } else { $error++; $errmsg .= join('
', $adh->errors); } } } if (!$error) { $db->commit(); Header("Location: ".$urlback); exit; } else { $db->rollback(); $action = "create"; } } // Action called after a submitted was send and member created successfully // If MEMBER_URL_REDIRECT_SUBSCRIPTION is set to an url, we never go here because a redirect was done to this url. Same if we ask to redirect to the payment page. // backtopage parameter with an url was set on member submit page, we never go here because a redirect was done to this url. if (empty($reshook) && $action == 'added') { llxHeaderVierge($langs->trans("NewMemberForm")); // If we have not been redirected print '

'; print '
'; print $langs->trans("NewMemberbyWeb"); print '
'; llxFooterVierge(); exit; } /* * View */ $form = new Form($db); $formcompany = new FormCompany($db); $adht = new AdherentType($db); $extrafields->fetch_name_optionals_label($object->table_element); // fetch optionals attributes and labels llxHeaderVierge($langs->trans("NewSubscription")); print '
'; print load_fiche_titre($langs->trans("NewSubscription"), '', '', 0, 0, 'center'); print '
'; print '
'; print '
'; if (!empty($conf->global->MEMBER_NEWFORM_TEXT)) { print $langs->trans($conf->global->MEMBER_NEWFORM_TEXT)."
\n"; } else { print $langs->trans("NewSubscriptionDesc", getDolGlobalString("MAIN_INFO_SOCIETE_MAIL"))."
\n"; } print '
'; dol_htmloutput_errors($errmsg); dol_htmloutput_events(); // Print form print '
'."\n"; print ''; print ''; if (!empty($conf->global->MEMBER_SKIP_TABLE) || !empty($conf->global->MEMBER_NEWFORM_FORCETYPE) || $action == 'create') { print ''; print '
'; print '
'.$langs->trans("FieldsWithAreMandatory", '*').'
'; //print $langs->trans("FieldsWithIsForPublic",'**').'
'; print dol_get_fiche_head(''); print ''; print ''."\n"; // Type if (empty($conf->global->MEMBER_NEWFORM_FORCETYPE)) { $listoftype = $adht->liste_array(); $tmp = array_keys($listoftype); $defaulttype = ''; $isempty = 1; if (count($listoftype) == 1) { $defaulttype = $tmp[0]; $isempty = 0; } print ''."\n"; } else { $adht->fetch($conf->global->MEMBER_NEWFORM_FORCETYPE); print ''; } // Moral/Physic attribute $morphys["phy"] = $langs->trans("Physical"); $morphys["mor"] = $langs->trans("Moral"); if (empty($conf->global->MEMBER_NEWFORM_FORCEMORPHY)) { print ''."\n"; } else { //print $morphys[$conf->global->MEMBER_NEWFORM_FORCEMORPHY]; print ''; } // Company // TODO : optional hide print ''."\n"; // Title print ''."\n"; // Lastname print ''."\n"; // Firstname print ''."\n"; // EMail print ''."\n"; // Login if (empty($conf->global->ADHERENT_LOGIN_NOT_REQUIRED)) { print ''."\n"; print ''."\n"; print ''."\n"; } // Gender print ''; print ''; // Address print ''."\n"; // Zip / Town print ''; // Country print ''; // State if (empty($conf->global->SOCIETE_DISABLE_STATE)) { print ''; } // Birthday print ''."\n"; // Photo print ''."\n"; // Public print ''."\n"; // Other attributes $parameters['tpl_context']='public'; // define template context to public include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_add.tpl.php'; // Comments print ''; print ''; print ''; print ''."\n"; // Add specific fields used by Dolibarr foundation for example // TODO Move this into generic feature. if (!empty($conf->global->MEMBER_NEWFORM_DOLIBARRTURNOVER)) { $arraybudget = array('50'=>'<= 100 000', '100'=>'<= 200 000', '200'=>'<= 500 000', '300'=>'<= 1 500 000', '600'=>'<= 3 000 000', '1000'=>'<= 5 000 000', '2000'=>'5 000 000+'); print ''."\n"; } if (!empty($conf->global->MEMBER_NEWFORM_PAYONLINE)) { $typeid = $conf->global->MEMBER_NEWFORM_FORCETYPE ? $conf->global->MEMBER_NEWFORM_FORCETYPE : GETPOST('typeid', 'int'); $adht = new AdherentType($db); $adht->fetch($typeid); $caneditamount = $adht->caneditamount; // Set amount for the subscription: // - First check the amount of the member type. $amountbytype = $adht->amountByType(1); // Load the array of amount per type $amount = empty($amountbytype[$typeid]) ? (isset($amount) ? $amount : 0) : $amountbytype[$typeid]; // - If not found, take the default amount only of the user is authorized to edit it if ($caneditamount && empty($amount) && !empty($conf->global->MEMBER_NEWFORM_AMOUNT)) { $amount = $conf->global->MEMBER_NEWFORM_AMOUNT; } // - If not set, we accept ot have amount defined as parameter (for backward compatibility). if (empty($amount)) { $amount = (GETPOST('amount') ? price2num(GETPOST('amount', 'alpha'), 'MT', 2) : ''); } // Clean the amount $amount = price2num($amount); $showedamount = $amount>0? $amount: 0; // $conf->global->MEMBER_NEWFORM_PAYONLINE is 'paypal', 'paybox' or 'stripe' print ''; } print "
'.$langs->trans("Type").' *'; print $form->selectarray("typeid", $adht->liste_array(1), GETPOST('typeid') ? GETPOST('typeid') : $defaulttype, $isempty); print '
'.$langs->trans('MemberNature').' *'."\n"; print $form->selectarray("morphy", $morphys, GETPOST('morphy'), 1); print '
'.$langs->trans("Company").''; print img_picto('', 'company', 'class="pictofixedwidth"'); print '
'.$langs->trans('UserTitle').''; print $formcompany->select_civility(GETPOST('civility_id'), 'civility_id').'
'.$langs->trans("Lastname").' *
'.$langs->trans("Firstname").' *
'.$langs->trans("Email").(getDolGlobalString("ADHERENT_MAIL_REQUIRED") ? ' *' : '').''; //print img_picto('', 'email', 'class="pictofixedwidth"'); print '
'.$langs->trans("Login").' *
'.$langs->trans("Password").' *
'.$langs->trans("PasswordRetype").' *
'.$langs->trans("Gender").''; $arraygender = array('man'=>$langs->trans("Genderman"), 'woman'=>$langs->trans("Genderwoman"), 'other'=>$langs->trans("Genderother")); print $form->selectarray('gender', $arraygender, GETPOST('gender', 'alphanohtml'), 1, 0, 0, '', 0, 0, 0, '', '', 1); print '
'.$langs->trans("Address").''."\n"; print '
'.$langs->trans('Zip').' / '.$langs->trans('Town').''; print $formcompany->select_ziptown(GETPOST('zipcode'), 'zipcode', array('town', 'selectcountry_id', 'state_id'), 0, 1, '', 'width75'); print ' / '; print $formcompany->select_ziptown(GETPOST('town'), 'town', array('zipcode', 'selectcountry_id', 'state_id'), 0, 1); print '
'.$langs->trans('Country').''; print img_picto('', 'country', 'class="pictofixedwidth"'); $country_id = GETPOST('country_id', 'int'); if (!$country_id && !empty($conf->global->MEMBER_NEWFORM_FORCECOUNTRYCODE)) { $country_id = getCountry($conf->global->MEMBER_NEWFORM_FORCECOUNTRYCODE, 2, $db, $langs); } if (!$country_id && !empty($conf->geoipmaxmind->enabled)) { $country_code = dol_user_country(); //print $country_code; if ($country_code) { $new_country_id = getCountry($country_code, 3, $db, $langs); //print 'xxx'.$country_code.' - '.$new_country_id; if ($new_country_id) { $country_id = $new_country_id; } } } $country_code = getCountry($country_id, 2, $db, $langs); print $form->select_country($country_id, 'country_id'); print '
'.$langs->trans('State').''; if ($country_code) { print $formcompany->select_state(GETPOST("state_id"), $country_code); } print '
'.$langs->trans("DateOfBirth").''; print $form->selectDate(!empty($birthday) ? $birthday : "", 'birth', 0, 0, 1, "newmember", 1, 0); print '
'.$langs->trans("URLPhoto").'
'.$langs->trans("Public").'
'.$langs->trans("Comments").'
'.$langs->trans("TurnoverOrBudget").' *'; print $form->selectarray('budget', $arraybudget, GETPOST('budget'), 1); print ' € or $'; print ''; print '
'.$langs->trans("Subscription"); if (!empty($conf->global->MEMBER_EXT_URL_SUBSCRIPTION_INFO)) { print ' - '.$langs->trans("SeeHere").''; } print ''; if (empty($amount) && !empty($conf->global->MEMBER_NEWFORM_AMOUNT)) { $amount = $conf->global->MEMBER_NEWFORM_AMOUNT; } if ($caneditamount) { print ''; print ' '.$langs->trans("Currency".$conf->currency).' – '; print $amount > 0 ? $langs->trans("AnyAmountWithAdvisedAmount", price($amount, 0, $langs, 1, -1, -1, $conf->currency)): $langs->trans("AnyAmountWithoutAdvisedAmount"); print ''; } else { print ''; print ''; print ' '.$langs->trans("Currency".$conf->currency); } print '
\n"; print dol_get_fiche_end(); // Save / Submit print '
'; print ''; if (!empty($backtopage)) { print '     '; } print '
'; print "
\n"; print "
"; print '
'; } else { // Show the table of membership types // Get units $measuringUnits = new CUnits($db); $result = $measuringUnits->fetchAll('', '', 0, 0, array('t.active' => 1)); $units = array(); foreach ($measuringUnits->records as $lines) $units[$lines->short_label] = $langs->trans(ucfirst($lines->label)); $publiccounters = getDolGlobalString("MEMBER_COUNTERS_ARE_PUBLIC"); $sql = "SELECT d.rowid, d.libelle as label, d.subscription, d.amount, d.caneditamount, d.vote, d.note, d.duration, d.statut as status, d.morphy,"; $sql .= " COUNT(a.rowid) AS membercount"; $sql .= " FROM ".MAIN_DB_PREFIX."adherent_type as d"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."adherent as a"; $sql .= " ON d.rowid = a.fk_adherent_type AND a.statut > 0"; $sql .= " WHERE d.entity IN (".getEntity('member_type').")"; $sql .= " AND d.statut=1"; $sql .= " GROUP BY d.rowid, d.libelle, d.subscription, d.amount, d.caneditamount, d.vote, d.note, d.duration, d.statut, d.morphy"; $result = $db->query($sql); if ($result) { $num = $db->num_rows($result); print '
'; print ''."\n"; print ''; print ''; print ''; print ''; print ''; print ''; print ''; if ($publiccounters) print ''; print ''; print "\n"; $i = 0; while ($i < $num) { $objp = $db->fetch_object($result); // Load the member type and information on it print ''; print ''; print ''; print ''; print ''; print ''; $membercount = $objp->membercount>0? $objp->membercount: "–"; if ($publiccounters) print ''; print ''; print ""; $i++; } // If no record found if ($num == 0) { $colspan = 8; print ''; } print "
'.$langs->trans("Label").''.$langs->trans("MembershipDuration").''.$langs->trans("Amount").''.$langs->trans("MembersNature").''.$langs->trans("VoteAllowed").''.$langs->trans("Members").''.$langs->trans("NewSubscription").'
'.dol_escape_htmltag($objp->label).''; $unit = preg_replace("/[^a-zA-Z]+/", "", $objp->duration); print max(1, intval($objp->duration)).' '.$units[$unit]; print ''; $displayedamount = max(intval($objp->amount), intval(getDolGlobalInt("MEMBER_MIN_AMOUNT"))); $caneditamount = $objp->caneditamount; if ($objp->subscription) { if ($displayedamount > 0 || !$caneditamount) { print $displayedamount.' '.strtoupper($conf->currency); } if ($caneditamount && $displayedamount>0) { print $form->textwithpicto('', $langs->transnoentities("CanEditAmountShortForValues"), 1, 'help', '', 0, 3); } elseif ($caneditamount) { print $langs->transnoentities("CanEditAmountShort"); } } else { print "–"; // No subscription required } print ''; if ($objp->morphy == 'phy') { print $langs->trans("Physical"); } elseif ($objp->morphy == 'mor') { print $langs->trans("Moral"); } else { print $langs->trans("MorAndPhy"); } print ''.yn($objp->vote).''.$membercount.'
'.$langs->trans("NoRecordFound").'
"; print '
'; print ''; } else { dol_print_error($db); } } llxFooterVierge(); $db->close();