200 global
$conf, $langs;
206 if (!empty(
$conf->use_javascript_ajax)) {
207 print
"\n".
'<!-- Includes JS Footer of Dolibarr -->'.
"\n";
208 print
'<script src="'.DOL_URL_ROOT.
'/core/js/lib_foot.js.php?lang='.$langs->defaultlang.
'"></script>'.
"\n";
222$parameters = array();
224$reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
231if (empty($reshook) &&
getDolGlobalInt(
"MEMBER_SEARCH_MEMBER_PUBLIC_FORM_CREATE") && $action ==
'add' && !GETPOSTISSET(
"nofetchmember")) {
232 $memberfound =
false;
237 $sql =
"SELECT rowid as id";
238 $sql .=
" FROM ".MAIN_DB_PREFIX.
"adherent as a";
239 $sql .=
" WHERE a.login = '".$db->escape(
GETPOST(
'login')).
"'";
240 $sql .=
" AND statut = 1";
241 $sql .=
" AND entity IN (".getEntity(
$object->element).
")";
242 $resql =
$db->query($sql);
244 if (
$db->num_rows($resql) == 1) {
245 $obj =
$db->fetch_object($resql);
254 if (!$memberfound &&
GETPOST(
"morphy") ==
'mor' && GETPOSTISSET(
"societe")) {
255 $sql =
"SELECT a.rowid as id";
256 $sql .=
" FROM ".MAIN_DB_PREFIX.
"adherent as a";
257 $sql .=
" JOIN ".MAIN_DB_PREFIX.
"societe as s";
258 $sql .=
" ON a.fk_soc = s.rowid";
259 $sql .=
" WHERE s.nom = '".$db->escape(
GETPOST(
"societe",
'alphanohtml')).
"'";
260 $sql .=
" AND a.email = '".$db->escape(preg_replace(
'/\s+/',
'',
GETPOST(
"member_email",
'aZ09arobase'))).
"'";
261 $sql .=
" AND a.statut = 1";
262 $sql .=
" AND a.entity IN (".getEntity(
$object->element).
")";
263 $resql =
$db->query($sql);
265 if (
$db->num_rows($resql) == 1) {
266 $obj =
$db->fetch_object($resql);
275 if (!$memberfound &&
GETPOST(
"morphy") ==
'phy' && GETPOSTISSET(
"lastname") && GETPOSTISSET(
"firstname") && !empty(
GETPOST(
"member_email",
'aZ09arobase'))) {
276 $sql =
"SELECT rowid as id";
277 $sql .=
" FROM ".MAIN_DB_PREFIX.
"adherent";
278 $sql .=
" WHERE firstname = '".$db->escape(
GETPOST(
"firstname",
'alphanohtml')).
"'";
279 $sql .=
" AND lastname = '".$db->escape(
GETPOST(
"lastname",
'alphanohtml')).
"'";
280 $sql .=
" AND email = '".$db->escape(preg_replace(
'/\s+/',
'',
GETPOST(
"member_email",
'aZ09arobase'))).
"'";
281 $sql .=
" AND statut = 1";
282 $sql .=
" AND entity IN (".getEntity(
$object->element).
")";
283 $resql =
$db->query($sql);
285 if (
$db->num_rows($resql) == 1) {
286 $obj =
$db->fetch_object($resql);
296 $action =
'subscription';
301if (empty($reshook) && $action ==
'add') {
307 $morphy =
GETPOST(
"morphy",
'alphanohtml');
308 $lastname =
GETPOST(
"lastname",
'alphanohtml');
309 $firstname =
GETPOST(
"firstname",
'alphanohtml');
310 $societe =
GETPOST(
"societe",
'alphanohtml');
311 $email = preg_replace(
'/\s+/',
'',
GETPOST(
"member_email",
'aZ09arobase'));
315 if (!in_array($morphy, array(
'mor',
'phy'))) {
317 $errmsg .= $langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
'MemberNature')).
"<br>\n";
322 if (!
GETPOST(
'member_email')) {
324 $errmsg .= $langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"EMail")).
"<br>\n";
328 $errmsg .= $langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Login")).
"<br>\n";
330 $sql =
"SELECT login FROM ".MAIN_DB_PREFIX.
"adherent WHERE login = '".
$db->escape(
GETPOST(
'login')).
"'";
331 $result =
$db->query($sql);
333 $num =
$db->num_rows($result);
337 $langs->load(
"errors");
338 $errmsg .= $langs->trans(
"ErrorLoginAlreadyExists").
"<br>\n";
340 if (!GETPOSTISSET(
"pass1") || !GETPOSTISSET(
"pass2") ||
GETPOST(
"pass1",
'none') ==
'' ||
GETPOST(
"pass2",
'none') ==
'' ||
GETPOST(
"pass1",
'none') !=
GETPOST(
"pass2",
'none')) {
342 $langs->load(
"errors");
343 $errmsg .= $langs->trans(
"ErrorPasswordsMustMatch").
"<br>\n";
348 $errmsg .= $langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Type")).
"<br>\n";
351 if ($morphy && $morphy !=
'mor' && empty($lastname)) {
353 $langs->load(
"errors");
354 $errmsg .= $langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"Lastname"));
356 if ($morphy && $morphy !=
'mor' && (!isset($firstname) || $firstname ==
'')) {
358 $langs->load(
"errors");
359 $errmsg .= $langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"Firstname"));
361 if ($morphy ==
'mor' && empty($societe)) {
363 $langs->load(
"errors");
364 $errmsg .= $langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"Company"));
366 if (empty($country_id)) {
368 $langs->load(
"errors");
369 $errmsg .= $langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"Country"));
373 $langs->load(
"errors");
374 $errmsg .= $langs->trans(
"ErrorBadEMail", $email);
377 if (
GETPOST(
"birthmonth") && empty($birthday)) {
379 $langs->load(
"errors");
380 $errmsg .= $langs->trans(
"ErrorBadDateFormat").
"<br>\n";
387 $errmsg .= $langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"TurnoverOrBudget")).
"<br>\n";
393 if (
getDolGlobalString(
'MAIN_SECURITY_ENABLECAPTCHA_MEMBER') && is_object($captchaobj)) {
394 if (method_exists($captchaobj,
'validateCodeAfterLoginSubmit')) {
395 $ok = $captchaobj->validateCodeAfterLoginSubmit();
397 print
'Error, the captcha handler '.get_class($captchaobj).
' does not have any method validateCodeAfterLoginSubmit()';
401 $langs->load(
"errors");
402 $errmsg .= $langs->trans(
"ErrorBadValueForCode").
"<br>\n";
407 $public = GETPOSTISSET(
'public') ? 1 : 0;
414 $adh->public = $public;
415 $adh->firstname =
GETPOST(
'firstname');
416 $adh->lastname =
GETPOST(
'lastname');
417 $adh->gender =
GETPOST(
'gender');
418 $adh->civility_id =
GETPOST(
'civility_id');
419 $adh->company =
GETPOST(
'societe');
420 $adh->societe = $adh->company;
421 $adh->address =
GETPOST(
'address');
422 $adh->zip =
GETPOST(
'zipcode');
424 $adh->email =
GETPOST(
'member_email',
'aZ09arobase');
426 $adh->login =
GETPOST(
'login');
427 $adh->pass =
GETPOST(
'pass1',
'password');
429 $adh->photo =
GETPOST(
'photo');
430 $adh->country_id = $country_id;
433 $adh->note_private =
GETPOST(
'note_private');
435 $adh->birth = $birthday;
436 $adh->phone =
GETPOST(
'phone');
437 $adh->phone_perso =
GETPOST(
'phone_perso');
438 $adh->phone_mobile =
GETPOST(
'phone_mobile');
442 $nb_post_max =
getDolGlobalInt(
"MAIN_SECURITY_MAX_POST_ON_PUBLIC_PAGES_BY_IP_ADDRESS", 200);
447 if ($nb_post_max > 0) {
448 $sql =
"SELECT COUNT(ref) as nb_adh";
449 $sql .=
" FROM ".MAIN_DB_PREFIX.
"adherent";
450 $sql .=
" WHERE ip = '".$db->escape($adh->ip).
"'";
451 $sql .=
" AND datec > '".$db->idate($minmonthpost).
"'";
452 $resql =
$db->query($sql);
454 $num =
$db->num_rows($resql);
458 $obj =
$db->fetch_object($resql);
459 $nb_post_ip = $obj->nb_adh;
466 $extrafields->fetch_name_optionals_label($adh->table_element);
467 $ret = $extrafields->setOptionalsFromPost(
null, $adh);
470 $errmsg .= $adh->error;
473 if ($nb_post_max > 0 && $nb_post_ip >= $nb_post_max) {
475 $errmsg .= $langs->trans(
"AlreadyTooMuchPostOnThisIPAdress");
476 array_push($adh->errors, $langs->trans(
"AlreadyTooMuchPostOnThisIPAdress"));
480 $result = $adh->create($user);
482 require_once DOL_DOCUMENT_ROOT.
'/core/class/CMailFile.class.php';
493 include_once DOL_DOCUMENT_ROOT.
'/core/class/html.formmail.class.php';
497 $outputlangs->setDefaultLang(empty(
$object->thirdparty->default_lang) ?
$mysoc->default_lang :
$object->thirdparty->default_lang);
499 $outputlangs->loadLangs(array(
"main",
"members"));
501 $arraydefaultmessage =
null;
504 if (!empty($labeltouse)) {
505 $arraydefaultmessage = $formmail->getEMailTemplate(
$db,
'member', $user, $outputlangs, 0, 1, $labeltouse);
508 if (!empty($labeltouse) && is_object($arraydefaultmessage) && $arraydefaultmessage->id > 0) {
509 $subject = $arraydefaultmessage->topic;
510 $msg = $arraydefaultmessage->content;
513 $substitutionarray = getCommonSubstitutionArray($outputlangs, 0,
null, $object);
518 if ($subjecttosend && $texttosend) {
519 $moreinheader =
'X-Dolibarr-Info: send_an_email by public/members/new.php'.
"\r\n";
521 $result =
$object->sendEmail($texttosend, $subjecttosend, array(), array(), array(),
"",
"", 0, -1,
'', $moreinheader);
533 $appli = constant(
'DOL_APPLICATION_TITLE');
536 if (preg_match(
'/\d\.\d/', $appli)) {
537 if (!preg_match(
'/'.preg_quote(DOL_VERSION,
'/').
'/', $appli)) {
538 $appli .=
" (".DOL_VERSION.
")";
541 $appli .=
" ".DOL_VERSION;
544 $appli .=
" ".DOL_VERSION;
563 if (!$mailfile->sendfile()) {
564 dol_syslog($langs->trans(
"ErrorFailedToSendMail", $from, $to), LOG_ERR);
571 $result = $company->create_from_member($adh);
574 $errmsg .= implode(
'<br>', $company->errors);
578 if (!empty($backtopage)) {
579 $urlback = $backtopage;
584 $urlback = $_SERVER[
"PHP_SELF"].
"?action=added&token=".
newToken();
588 if (empty($adht->caneditamount)) {
593 $minimumamountbytype = $adht->minimumamountbytype(1);
594 $minimumamount = empty($minimumamountbytype[$adh->typeid]) ? 0 : $minimumamountbytype[$adh->typeid];
596 $urlback = getOnlinePaymentUrl(0,
'member', $adh->ref, (
float) $amount,
'', 0);
597 if ($amount < max(
getDolGlobalInt(
"MEMBER_MIN_AMOUNT"), $minimumamount)) {
599 $errmsg .= $langs->trans(
"MinimumAmountShort").
" : ".
price(max(
getDolGlobalInt(
"MEMBER_MIN_AMOUNT"), $minimumamount), 0, $langs, 1, -1, -1,
$conf->currency).
"<br>\n";
603 $urlback .=
'&email='.urlencode(
GETPOST(
'member_email'));
606 $urlback .=
'&paymentmethod='.urlencode(
getDolGlobalString(
'MEMBER_NEWFORM_PAYONLINE'));
609 if (!empty($entity)) {
610 $urlback .=
'&entity='.((int) $entity);
615 $errmsg .= implode(
'<br>', $adh->errors);
623 header(
"Location: ".$urlback);
635if (empty($reshook) && $action ==
'added') {
640 print
'<div class="center">';
641 print $langs->trans(
"NewMemberbyWeb");
656$extrafields->fetch_name_optionals_label(
$object->table_element);
662print
load_fiche_titre(
img_picto(
'',
'member_nocolor',
'class="pictofixedwidth"').
' '.$langs->trans(
"NewSubscription"),
'',
'', 0,
'',
'center');
665print
'<div align="center">';
666print
'<div id="divsubscribe">';
668print
'<div class="center subscriptionformhelptext opacitylow justify small margintoponly"><br>';
672 print $langs->trans(
"NewSubscriptionDesc",
getDolGlobalString(
"MAIN_INFO_SOCIETE_MAIL")).
"<br>\n";
680if ($action ==
"subscription") {
681 $urltocall = DOL_URL_ROOT.
'/public/payment/newpayment.php?source=member&ref='.
$object->id;
682 print $form->formconfirm($urltocall, $langs->trans(
"CorrespondingMemberFound"), $langs->trans(
"CorrespondingMemberFoundQuestion"),
"confirm_subscription",
'',
'no', 1);
686print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST" name="newmember" id="newmember">'.
"\n";
687print
'<input type="hidden" name="token" value="'.newToken().
'" />';
688print
'<input type="hidden" name="entity" value="'.$entity.
'" />';
689print
'<input type="hidden" name="page_y" value="" />';
692 if ($action ==
'subscription') {
693 print
'<input type="hidden" name="nofetchmember" value="nofetchmember" />';
695 print
'<input type="hidden" name="action" value="add" />';
704 if (
$conf->use_javascript_ajax) {
705 print
"\n".
'<script type="text/javascript">'.
"\n";
706 print
'jQuery(document).ready(function () {
707 jQuery("#selectcountry_id").change(function() {
708 console.log("We change country, so we reload page");
709 document.newmember.action.value="create";
710 jQuery("#newmember").submit();
712 function initfieldrequired() {
713 console.log("initfieldrequired");
714 jQuery("#tdcompany").removeClass("fieldrequired");
715 jQuery("#tdlastname").removeClass("fieldrequired");
716 jQuery("#tdfirstname").removeClass("fieldrequired");
717 if (jQuery(\'input[name="morphy"]:checked\').val() == \'mor\') {
718 jQuery("#tdcompany").addClass("fieldrequired");
720 if (jQuery(\'input[name="morphy"]:checked\').val() == \'phy\') {
721 jQuery("#tdlastname").addClass("fieldrequired");
722 jQuery("#tdfirstname").addClass("fieldrequired");
725 jQuery(\'input[name="morphy"]\').change(function() {
730 print
'</script>'.
"\n";
733 print
'<table class="border" summary="form to subscribe" id="tablesubscribe">'.
"\n";
738 print
'<tr><td class="fieldrequired titlefieldmiddle">'.$langs->trans(
"MemberType").
'</td><td>';
739 $listetype = $adht->liste_array(1);
740 print
img_picto(
'', $adht->picto,
'class="pictofixedwidth"');
741 if (count($listetype)) {
742 print $form->selectarray(
"typeid", $listetype, (
GETPOSTINT(
'typeid') ?
GETPOSTINT(
'typeid') : $typeid), (count($listetype) > 1 ? 1 : 0), 0, 0,
'', 0, 0, 0,
'',
'minwidth150 maxwidth300 widthcentpercentminusx', 1);
744 print
'<span class="error">'.$langs->trans(
"NoTypeDefinedGoToSetup").
'</span>';
746 print
'</td></tr>'.
"\n";
749 print
'<input type="hidden" id="typeid" name="typeid" value="' .
getDolGlobalString(
'MEMBER_NEWFORM_FORCETYPE').
'">';
754 "phy" => $langs->trans(
"Physical"),
755 "mor" => $langs->trans(
"Moral"),
757 $checkednature =
GETPOST(
"morphy",
'alpha');
758 $listetype_natures = $adht->morphyByType(1);
759 $listetype_natures_json = json_encode($listetype_natures);
762 if (empty($checkednature) && !empty($listetype_natures[
GETPOSTINT(
'typeid')])) {
763 $checkednature = $listetype_natures[
GETPOSTINT(
'typeid')];
766 print
'<tr><td class="fieldrequired titlefieldmiddle">'.$langs->trans(
"MemberNature").
"</td><td>\n";
772 print
'<span id="spannature1" class="nonature-back spannature paddinglarge marginrightonly"><label for="phisicalinput" class="valignmiddle">'.$morphys[
"phy"].
'<input id="phisicalinput" class="flat checkforselect marginleftonly valignmiddle" type="radio" name="morphy" value="phy"'.($checkednature ==
"phy" ?
' checked="checked"' :
'').$disabledphy.
'></label></span>';
773 print
'<span id="spannature2" class="nonature-back spannature paddinglarge marginrightonly"><label for="moralinput" class="valignmiddle">'.$morphys[
"mor"].
'<input id="moralinput" class="flat checkforselect marginleftonly valignmiddle" type="radio" name="morphy" value="mor"'.($checkednature ==
"mor" ?
' checked="checked"' :
'').$disabledmor.
'></label></span>';
776 if (
$conf->use_javascript_ajax) {
778 var listetype_natures = '.$listetype_natures_json.
';
781 function refreshNatureCss() {
782 $(".spannature").each(function(index) {
783 let $span = $("#spannature" + (index + 1));
784 let checked = $span.find(".checkforselect").is(":checked");
788 $span.addClass("member-individual-back").removeClass("nonature-back member-company-back");
789 } else if (index === 1) {
790 $span.addClass("member-company-back").removeClass("nonature-back member-individual-back");
793 $span.removeClass("member-individual-back member-company-back")
794 .addClass("nonature-back");
799 $(".spannature").on("click", function() {
800 console.log("Nature clicked");
804 $("#typeid").on("change", function() {
805 console.log("Type of membership is modified");
806 let morphy = listetype_natures[$(this).val()];
807 console.log("morphy="+morphy);
809 let $phyInput = $("#phisicalinput");
810 let $morInput = $("#moralinput");
811 let $tdLast = $("#tdlastname");
812 let $tdFirst = $("#tdfirstname");
813 let $tdCompany = $("#tdcompany");
814 let $span1 = $("#spannature1");
815 let $span2 = $("#spannature2");
819 $phyInput.prop({disabled: false, checked: true});
820 $morInput.prop({disabled: true, checked: false});
821 $span1.addClass("member-individual-back").removeClass("nonature-back");
822 $span2.removeClass("member-company-back").addClass("nonature-back");
823 $("#phisicalinput").prop("checked", true);
824 $tdLast.addClass("fieldrequired");
825 $tdFirst.addClass("fieldrequired");
826 $tdCompany.removeClass("fieldrequired");
830 $phyInput.prop({disabled: true, checked: false});
831 $morInput.prop({disabled: false, checked: true});
832 $span2.addClass("member-company-back").removeClass("nonature-back");
833 $span1.removeClass("member-individual-back").addClass("nonature-back");
834 $("#moralinput").prop("checked", true);
835 $tdCompany.addClass("fieldrequired");
836 $tdLast.removeClass("fieldrequired");
837 $tdFirst.removeClass("fieldrequired");
841 $phyInput.prop({disabled: false});
842 $morInput.prop({disabled: false});';
843 if ($action !=
"subscription" && !
GETPOST(
'morphy')) {
845 $phyInput.prop({checked: false});
846 $morInput.prop({checked: false});
847 $span1.removeClass("member-individual-back").addClass("nonature-back");
848 $span2.removeClass("member-company-back").addClass("nonature-back");';
858 print
'</td></tr>'.
"\n";
861 print
'<input type="hidden" id="morphy" name="morphy" value="' .
getDolGlobalString(
'MEMBER_NEWFORM_FORCEMORPHY').
'">';
865 print
'<tr id="trcompany" class="trcompany"><td id="tdcompany" class="titlefieldmiddle paddingrightonly'.($checkednature ==
"mor" ?
' fieldrequired"' :
'').
'">'.$langs->trans(
"Company").
'</td><td>';
866 print
img_picto(
'',
'company',
'class="pictofixedwidth paddingright"');
867 print
'<input type="text" name="societe" class="minwidth150 widthcentpercentminusx" value="'.dol_escape_htmltag(
GETPOST(
'societe')).
'"></td></tr>'.
"\n";
871 print
'<tr><td>'.$langs->trans(
'UserTitle').
'</td><td>';
872 print $formcompany->select_civility(
GETPOST(
'civility_id'),
'civility_id').
'</td></tr>'.
"\n";
876 print
'<tr><td id="tdfirstname" class="classfortooltip'.($checkednature ==
"phy" ?
' fieldrequired"' :
'').
'">'.$langs->trans(
"Firstname").
'</td><td><input type="text" name="firstname" class="minwidth150" value="'.
dol_escape_htmltag(
GETPOST(
'firstname')).
'" spellcheck="false"></td></tr>'.
"\n";
879 print
'<tr><td id="tdlastname" class="classfortooltip'.($checkednature ==
"phy" ?
' fieldrequired"' :
'').
'">'.$langs->trans(
"Lastname").
'</td><td><input type="text" name="lastname" class="minwidth150" value="'.
dol_escape_htmltag(
GETPOST(
'lastname')).
'" spellcheck="false"></td></tr>'.
"\n";
882 print
'<tr><td>'.(getDolGlobalString(
'ADHERENT_MAIL_REQUIRED') ?
'<span class="fieldrequired">' :
'').$langs->trans(
"EMail").(getDolGlobalString(
'ADHERENT_MAIL_REQUIRED') ?
'</span>' :
'').
'</td>';
883 print
'<td>'.img_picto(
'',
'object_email').
' <input type="text" name="member_email" class="minwidth150 maxwidth300 widthcentpercentminusx" maxlength="255" value="'.
dol_escape_htmltag(
GETPOST(
'member_email',
"aZ09arobase")).
'" spellcheck="false"></td></tr>'.
"\n";
887 print
'<tr><td><span class="fieldrequired">'.$langs->trans(
"Login").
' / '.$langs->trans(
"Id").
'</span></td><td><input type="text" name="login" maxlength="50" class="minwidth100" value="'.(GETPOSTISSET(
"login") ?
GETPOST(
"login",
'alphanohtml', 2) :
$object->login).
'"></td></tr>'.
"\n";
888 print
'<tr><td><span class="fieldrequired">'.$langs->trans(
"Password").
'</span></td><td><input type="password" maxlength="128" name="pass1" class="minwidth100" value="'.
dol_escape_htmltag(
GETPOST(
"pass1",
"none", 2)).
'"></td></tr>'.
"\n";
889 print
'<tr><td><span class="fieldrequired">'.$langs->trans(
"PasswordRetype").
'</span></td><td><input type="password" maxlength="128" name="pass2" class="minwidth100" value="'.
dol_escape_htmltag(
GETPOST(
"pass2",
"none", 2)).
'"></td></tr>'.
"\n";
893 print
'<tr><td>'.$langs->trans(
"Gender").
'</td>';
895 $arraygender = array(
'man' => $langs->trans(
"Genderman"),
'woman' => $langs->trans(
"Genderwoman"),
'other' => $langs->trans(
"Genderother"));
896 print $form->selectarray(
'gender', $arraygender,
GETPOST(
'gender',
'alphanohtml'), 1, 0, 0,
'', 0, 0, 0,
'',
'minwidth150 maxwidth300 widthcentpercentminusx', 1);
900 print
'<tr><td>'.$langs->trans(
"Address").
'</td><td>'.
"\n";
901 print
'<textarea name="address" id="address" wrap="soft" class="quatrevingtpercent" rows="'.ROWS_3.
'">'.
dol_escape_htmltag(
GETPOST(
'address',
'restricthtml'), 0, 1).
'</textarea></td></tr>'.
"\n";
904 print
'<tr><td>'.$langs->trans(
'Zip').
' / '.$langs->trans(
'Town').
'</td><td>';
905 print $formcompany->select_ziptown(
GETPOST(
'zipcode'),
'zipcode', array(
'town',
'selectcountry_id',
'state_id'), 0, 1,
'',
'width75');
907 print $formcompany->select_ziptown(
GETPOST(
'town'),
'town', array(
'zipcode',
'selectcountry_id',
'state_id'), 0, 1);
913 print
'<tr><td class="fieldrequired">'.$langs->trans(
'Country').
'</td><td>';
914 print
img_picto(
'',
'country',
'class="pictofixedwidth paddingright"');
918 if (!$country_id && !empty(
$conf->geoipmaxmind->enabled)) {
922 $new_country_id =
getCountry($country_code,
'3',
$db, $langs);
924 if ($new_country_id) {
925 $country_id = $new_country_id;
930 print $form->select_country($country_id,
'country_id',
'', 0,
'minwidth150 maxwidth300 widthcentpercentminusx reposition');
935 print
'<tr><td>'.$langs->trans(
'State').
'</td><td>';
937 print
img_picto(
'',
'state',
'class="pictofixedwidth paddingright"');
938 print $formcompany->select_state(
GETPOSTINT(
"state_id"), $country_code,
'state_id',
'minwidth150 maxwidth300 widthcentpercentminusx');
944 print
'<tr><td>'.$langs->trans(
"PhonePro").
'</td>';
945 print
'<td>'.img_picto(
'',
'object_phoning',
'class="pictofixedwidth"').
'<input type="text" name="phone" class="maxwidth300 widthcentpercentminusx" value="'.
dol_escape_htmltag(
GETPOST(
'phone')).
'"></td></tr>';
948 print
'<tr><td>'.$langs->trans(
"PhonePerso").
'</td>';
949 print
'<td>'.img_picto(
'',
'object_phoning',
'class="pictofixedwidth"').
'<input type="text" name="phone_perso" class="maxwidth300 widthcentpercentminusx" value="'.
dol_escape_htmltag(
GETPOST(
'phone_perso')).
'"></td></tr>';
952 print
'<tr><td>'.$langs->trans(
"PhoneMobile").
'</td>';
953 print
'<td>'.img_picto(
'',
'object_phoning_mobile',
'class="pictofixedwidth"').
'<input type="text" name="phone_mobile" class="maxwidth300 widthcentpercentminusx" value="'.
dol_escape_htmltag(
GETPOST(
'phone_mobile')).
'"></td></tr>';
956 print
'<tr id="trbirth" class="trbirth"><td>'.$langs->trans(
"DateOfBirth").
'</td><td>';
957 print $form->selectDate(!empty($birthday) ? $birthday :
"",
'birth', 0, 0, 1,
"newmember", 1, 0);
958 print
'</td></tr>'.
"\n";
961 print
'<tr><td>'.$langs->trans(
"URLPhoto").
'</td><td><input type="text" name="photo" class="minwidth150" value="'.
dol_escape_htmltag(
GETPOST(
'photo')).
'"></td></tr>'.
"\n";
965 $linkofpubliclist = DOL_MAIN_URL_ROOT.
'/public/members/public_list.php'.((
isModEnabled(
'multicompany')) ?
'?entity='.
$conf->entity :
'');
966 $publiclabel = $langs->trans(
"Public",
getDolGlobalString(
'MAIN_INFO_SOCIETE_NOM'), $linkofpubliclist);
967 print
'<tr><td>'.$form->textwithpicto($langs->trans(
"MembershipPublic"), $publiclabel).
'</td><td><input type="checkbox" name="public"></td></tr>'.
"\n";
971 $parameters[
'tpl_context'] =
'public';
972 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_add.tpl.php';
976 print
'<td class="tdtop"></td>';
977 print
'<td class="tdtop"><textarea placeholder="'.dolPrintHTML($langs->trans(
"Comments")).
'" name="note_private" id="note_private" wrap="soft" class="quatrevingtpercent" rows="'.ROWS_3.
'">'.
dol_escape_htmltag(
GETPOST(
'note_private',
'restricthtml'), 0, 1).
'</textarea></td>';
984 $adht->fetch($typeid);
985 $caneditamount = $adht->caneditamount;
986 $amountbytype = $adht->amountByType(1);
987 $minimumamountbytype = $adht->minimumamountbytype(1);
988 foreach ($amountbytype as $k => $v) {
989 $amount = max(0, (
float) $v, (
float)
getDolGlobalInt(
"MEMBER_MIN_AMOUNT"), $minimumamountbytype[$k]);
990 $amountbytype[$k] = $amount;
993 $caneditamountbytype = $adht->caneditamountByType(1);
994 $amountformuladescriptionbytype = $adht->amountformuladescriptionbytype(1);
998 $amount = empty($amountbytype[$typeid]) ? 0 : $amountbytype[$typeid];
1000 if (empty($amount)) {
1004 $minimumamount = empty($minimumamountbytype[$typeid]) ? 0 : $minimumamountbytype[$typeid];
1005 $amount = max(0, (
float) $amount, (
float)
getDolGlobalInt(
"MEMBER_MIN_AMOUNT"), (
float) $minimumamount);
1012 $parameters = array(
'country_id' => $country_id,
'mode' =>
'new');
1013 $reshook = $hookmanager->executeHooks(
'membershipNewSubscriptionPublicForm', $parameters, $object, $action);
1020 $s = $langs->trans(
"AreYouAPreferredPartner",
'<a href="https://partners.dolibarr.org" target="_blank">{s1}</a>');
1021 $s = str_replace(
'{s1}',
'Preferred Partner', $s);
1022 print
'<tr id="trbudget" class="trcompany"><td class="paddingrightonly"><label for="pp" class="small">'.$s.
'</label></td><td>';
1023 print
'<input type="checkbox" name="pp" id="pp" value="1"'.(GETPOST(
'pp') ?
' checked="checked"' :
'').
' class="reposition">';
1026 print
'<tr id="trbudget" class="trcompany"><td class="fieldrequired paddingrightonly"><span class="small">'.$langs->trans(
"TurnoverOrBudget").
'</span></td><td>';
1029 if ($country_code ===
'FR' && $checkednature ===
'mor' &&
GETPOST(
'pp')) {
1030 print
'<input type="text" name="budget" id="budget" class="flat turnover right width100" value="'.GETPOST(
'budget').
'" required>';
1032 $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+');
1033 print $form->selectarray(
'budget', $arraybudget,
GETPOSTINT(
'budget'), 1, 0, 0,
'', 0, 0, 0,
'');
1037 print
'<script type="text/javascript">
1038 jQuery(document).ready(function() {
1041 newamount = initturnover();
1042 jQuery("#amount").val(newamount);
1046 jQuery("#selectcountry_id").change(function() {
1047 console.log("We change country (code added for association, replace common code), so we reload page");
1048 jQuery("#budget").val(\'\');
1049 jQuery("#amount").val(\'\');
1050 jQuery("#amounthidden").val(\'\');
1052 jQuery("#phisicalinput,#moralinput").click(function() {
1053 console.log("We change the nature of membership");
1054 newamount = initturnover();
1055 jQuery("#amount").val(newamount);
1057 jQuery("#pp").change(function() {
1058 console.log("We change the preferred partner status");
1059 selectcountry_id = jQuery("#selectcountry_id").val();
1060 morphy = jQuery("#moralinput").is(\':checked\') ? \'mor\' : \'phy\';
1061 jQuery("#budget").val(\'\');
1062 jQuery("#amount").val(\'\');
1063 jQuery("#amounthidden").val(\'\');
1064 document.newmember.action.value="create";
1065 jQuery("#newmember").submit();
1067 jQuery("#budget").change(function() {
1068 console.log("Turnover amount has been modified on change");
1069 newamount = initturnover();
1070 jQuery("#amount").val(newamount);
1071 jQuery("#amounthidden").val(newamount);
1073 jQuery("#budget").keyup(function() {
1074 console.log("Turnover amount has been modified on keyup");
1075 newamount = initturnover();
1076 jQuery("#amount").val(newamount);
1077 jQuery("#amounthidden").val(newamount);
1080 function initturnover() {
1083 morphy = jQuery("#moralinput").is(\':checked\') ? \'mor\' : \'phy\';
1084 selectcountry_id = jQuery("#selectcountry_id").val();
1085 pp = jQuery("#pp").is(\':checked\') ? true : false;
1086 console.log("Set fields according to nature and other properties");
1087 console.log("morphy="+morphy);
1088 console.log("selectcountry_id="+selectcountry_id);
1089 console.log("pp="+pp);
1091 if (morphy == \'phy\') {
1092 jQuery(".amount").val('.((float) $amount).
');
1093 jQuery("#trbirth").show();
1094 jQuery(".trcompany").hide();
1095 jQuery(".trbudget").hide();
1096 newamount = '.((float) $amount).
';
1098 jQuery(".amount").val(\'\');
1099 jQuery("#trbirth").hide();
1100 jQuery(".trcompany").show();
1101 jQuery(".trbudget").show();
1102 jQuery(".hideifautoturnover").hide();
1104 jQuery("#budget").val(\'\');
1107 if (selectcountry_id == 1) {
1109 console.log("value selected in input text field is "+jQuery("#budget").val());
1110 newamount = Math.max(Math.round(price2numjs(jQuery("#budget").val()) * 0.005), 50);
1111 console.log("newamount = "+newamount);
1113 console.log("not a pp");
1114 if (jQuery("#budget").val() > 0) {
1115 console.log("value found in budget is "+jQuery("#budget").val());
1116 newamount = jQuery("#budget").val();
1118 jQuery("#budget").val(\'\');
1123 if (jQuery("#budget").val() > 0) {
1124 newamount = jQuery("#budget").val();
1126 jQuery("#budget").val(\'\');
1129 console.log("newamount="+newamount);
1137 print
'</td></tr>'.
"\n";
1141 print
'<tr><td>'.$langs->trans(
"Subscription");
1144 print
'<a href="' .
getDolGlobalString(
'MEMBER_EXT_URL_SUBSCRIPTION_INFO').
'" rel="external" target="_blank" rel="noopener noreferrer">';
1145 print
img_picto(
'',
'url',
'class="pictofixedwidth"').$langs->trans(
"SeeHere");
1148 print
'</td><td class="nowrap">';
1150 $amountformuladescription = $amountformuladescriptionbytype[$typeid];
1152 $showedamount = $amount > 0 ? $amount : 0;
1153 if ($caneditamount ===
"1") {
1154 print
'<input type="text" name="amount" id="amount" class="flat amount right width75" value="'.$showedamount.
'">';
1155 print
'<input type="text" name="amount" id="amounthidden" class="flat amount width75 hidden" disabled value="'.$showedamount.
'">';
1156 print
' '.$langs->getCurrencySymbol(
$conf->currency).
'<span class="opacitymedium amountdescription hideifautoturnover small">';
1159 if (empty($amountformuladescription)) {
1160 print $amount > 0 ? $langs->trans(
"AnyAmountWithAdvisedAmount",
price($amount, 0, $langs, 1, -1, -1,
$conf->currency)) : $langs->trans(
"AnyAmountWithoutAdvisedAmount");
1162 print $amountformuladescription;
1166 print
'</span><br><span id="minimumamount" class="opacitymedium small">'.$langs->trans(
"MinimumAmountShort").
' : '.
price(max(
getDolGlobalInt(
"MEMBER_MIN_AMOUNT"), $minimumamount), 0, $langs, 1, -1, -1,
$conf->currency);
1170 print
'<input type="text" name="amount" id="amount" class="flat amount width75 right hidden" value="'.$showedamount.
'">';
1171 print
'<input type="text" name="amount" id="amounthidden" class="flat amount width75" disabled value="'.$showedamount.
'">';
1172 print
' '.$langs->getCurrencySymbol(
$conf->currency).
'<span class="opacitymedium amountdescription hideifautoturnover hidden small">';
1175 print $amount > 0 ? $langs->trans(
"AnyAmountWithAdvisedAmount",
price($amount, 0, $langs, 1, -1, -1,
$conf->currency)) : $langs->trans(
"AnyAmountWithoutAdvisedAmount");
1183 if (
getDolGlobalString(
'MAIN_SECURITY_ENABLECAPTCHA_MEMBER') && is_object($captchaobj)) {
1184 print
'<tr><td><label><span class="fieldrequired">'.$langs->trans(
"SecurityCode").
'</span></label></td><td><br>';
1185 if (method_exists($captchaobj,
'getCaptchaCodeForForm')) {
1186 print $captchaobj->getCaptchaCodeForForm(
'');
1188 print
'Error, the captcha handler '.get_class($captchaobj).
' does not have any method getCaptchaCodeForForm()';
1190 print
'<br></td></tr>';
1198 print
'<div class="center">';
1199 print
'<input type="submit" value="'.$langs->trans(
"GetMembershipButtonLabel").
'" id="submitsave" class="button">';
1200 if (!empty($backtopage)) {
1201 print
' <input type="submit" value="'.$langs->trans(
"Cancel").
'" id="submitcancel" class="button button-cancel">';
1208 $adht->fetch($typeid);
1209 $caneditamountbytype = $adht->caneditamountByType(1);
1210 $minimumamountbytype = $adht->minimumamountbytype(1);
1211 $amountbytype = $adht->amountByType(1);
1212 $amountformuladescriptionbytype = $adht->amountformuladescriptionbytype(1);
1214 $caneditamountbytype_json = json_encode($caneditamountbytype);
1215 $minimumamountbytype_json = json_encode($minimumamountbytype);
1216 $amountbytype_json = json_encode($amountbytype);
1217 $amountformuladescriptionbytype_json = json_encode($amountformuladescriptionbytype);
1218 $currencysymbol = $langs->getCurrencySymbol(
$conf->currency);
1220 if (
$conf->use_javascript_ajax) {
1222 // ----- Shared data -----
1223 var amountByType = ' . $amountbytype_json .
';
1224 var canEditAmountByType = ' . $caneditamountbytype_json .
';
1225 var amountFormulaDescriptionByType = ' . $amountformuladescriptionbytype_json .
';
1226 var minimumAmountByType = ' . $minimumamountbytype_json .
';
1228 var currencySymbol = ' . json_encode($currencysymbol) .
';
1230 // Translations prepared by PHP
1232 AnyAmountWithAdvisedAmount: ' . json_encode($langs->trans(
"AnyAmountWithAdvisedAmount",
"__VAL__")) .
',
1233 AnyAmountWithoutAdvisedAmount: ' . json_encode($langs->trans(
"AnyAmountWithoutAdvisedAmount")) .
',
1234 MinimumAmountShort: ' . json_encode($langs->trans(
"MinimumAmountShort",
"__VAL__")) .
',
1235 trans: function(key, val) {
1236 if (!this[key]) return key;
1237 return this[key].replace("__VAL__", val || "");
1241 jQuery(function($) {
1242 // ----- Helpers -----
1243 function getCurrentMin() {
1244 let typeId = $("#typeid").val() || 0;
1245 let minimumAmount = minimumAmountByType[typeId] || 0;
1246 return Math.max(memberMinAmount, minimumAmount);
1249 function checkAmount() {
1250 let raw = $("#amount").val() || "";
1251 let val = parseFloat(raw.replace(",", ".")) || 0;
1252 let minimum = getCurrentMin();
1253 if (val < minimum) {
1254 $("#submitsave").prop("disabled", true);
1256 $("#submitsave").prop("disabled", false);
1260 function updateAmountAndTexts() {
1261 let typeId = $("#typeid").val();
1262 let amountVal = amountByType[typeId] || 0;
1263 let formattedAmount = parseFloat(amountVal);
1264 let canEdit = canEditAmountByType[typeId] === "1";
1265 let amountFormulaDescription = amountFormulaDescriptionByType[typeId] || "";
1266 let minimumAmount = minimumAmountByType[typeId] || 0;
1267 let minimum = Math.max(memberMinAmount, minimumAmount);
1271 $("#amount").val(formattedAmount).prop("disabled", false).removeClass("hidden");
1272 $("#amounthidden").addClass("hidden");
1273 $(".hideifautoturnover").removeClass("hidden");
1275 // Description formula or default text
1276 if (amountFormulaDescription.trim() !== "") {
1277 $(".amountdescription").html(" - " + amountFormulaDescription);
1279 if (amountVal > 0) {
1280 $(".amountdescription").html(" - " + langs.trans("AnyAmountWithAdvisedAmount", formattedAmount + " " + currencySymbol));
1282 $(".amountdescription").html(" - " + langs.trans("AnyAmountWithoutAdvisedAmount"));
1286 // Minimum amount label
1289 .html(langs.trans("MinimumAmountShort") + " : " + minimum + " " + currencySymbol)
1290 .removeClass("hidden");
1292 $("#minimumamount").addClass("hidden");
1296 $("#amounthidden").val(formattedAmount).prop("disabled", true).removeClass("hidden");
1297 $("#amount").addClass("hidden");
1298 $(".hideifautoturnover").addClass("hidden");
1299 $("#minimumamount").addClass("hidden");
1302 // After updating fields, re‑check the amount validity
1306 // ----- Bind events -----
1307 $("#typeid").on("change", function() {
1308 console.log("Type of membership changed, update amount, description and minimum");
1309 updateAmountAndTexts();
1312 $("#amount").on("keyup change", function() {
1321 print
'</div></div>';
1325 $result = $measuringUnits->fetchAll(
'',
'', 0, 0, array(
't.active' => 1));
1327 foreach ($measuringUnits->records as $lines) {
1328 $units[$lines->short_label] = $langs->trans(ucfirst((
string) $lines->label));
1334 $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,";
1335 $sql .=
" COUNT(a.rowid) AS membercount";
1336 $sql .=
" FROM ".MAIN_DB_PREFIX.
"adherent_type as d";
1337 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"adherent as a";
1338 $sql .=
" ON d.rowid = a.fk_adherent_type AND a.statut > 0";
1339 $sql .=
" WHERE d.entity IN (".getEntity(
'member_type').
")";
1340 $sql .=
" AND d.statut=1";
1341 $sql .=
" GROUP BY d.rowid, d.libelle, d.subscription, d.amount, d.caneditamount, d.vote, d.note, d.duration, d.statut, d.morphy";
1343 $result =
$db->query($sql);
1345 $num =
$db->num_rows($result);
1347 print
'<br><div class="div-table-responsive">';
1348 print
'<table class="tagtable liste noborder">'.
"\n";
1349 print
'<input type="hidden" name="action" value="create">';
1351 print
'<tr class="liste_titre">';
1352 print
'<th>'.$langs->trans(
"Label").
'</th>';
1353 print
'<th class="center">'.$langs->trans(
"MembershipDuration").
'</th>';
1354 print
'<th class="center">'.$langs->trans(
"RecommendedAmount").
'</th>';
1355 print
'<th class="center">'.$langs->trans(
"MembersNature").
'</th>';
1356 if (empty($hidevoteallowed)) {
1357 print
'<th class="center">'.$langs->trans(
"VoteAllowed").
'</th>';
1359 if ($publiccounters) {
1360 print
'<th class="center">'.$langs->trans(
"Members").
'</th>';
1362 print
'<th class="center"></th>';
1367 $objp =
$db->fetch_object($result);
1369 $caneditamount = $objp->caneditamount;
1370 $amountbytype = $adht->amountByType(1);
1371 $minimumamountbytype = $adht->minimumamountbytype(1);
1373 print
'<tr class="oddeven">';
1377 print
'<div class="twolinesmax-normallineheight minwidth200onall">';
1383 print
'<td class="center">';
1384 $unit = preg_replace(
"/[^a-zA-Z]+/",
"", $objp->duration);
1385 print
'<span class="badge badge-primary">';
1386 print max(1, intval($objp->duration)).
' '.$units[$unit];
1391 print
'<td class="center"><span class="amount nowrap">';
1395 $amount = empty($amountbytype[$objp->rowid]) ? 0 : $amountbytype[$objp->rowid];
1396 $minimumamount = empty($minimumamountbytype[$objp->rowid]) ? 0 : $minimumamountbytype[$objp->rowid];
1398 if (empty($amount)) {
1402 $amount = max(0, (
float) $amount, (
float)
getDolGlobalInt(
"MEMBER_MIN_AMOUNT"), (
float) $minimumamount);
1404 $displayedamount = $amount;
1406 if ($objp->subscription) {
1407 if ($displayedamount > 0 || !$caneditamount) {
1408 print
price($displayedamount, 1, $langs, 1, 0, -1,
$conf->currency);
1410 if ($caneditamount && $displayedamount > 0) {
1411 print $form->textwithpicto(
'', $langs->transnoentities(
"CanEditAmountShortForValues"), 1,
'help',
'', 0, 3);
1412 } elseif ($caneditamount) {
1413 print $langs->transnoentities(
"CanEditAmountShort");
1418 print
'</span></td>';
1420 print
'<td class="center minwidth100">';
1421 if ($objp->morphy ==
'phy') {
1422 print $langs->trans(
"Physical");
1423 } elseif ($objp->morphy ==
'mor') {
1424 print $langs->trans(
"Moral");
1426 print $langs->trans(
"MorAndPhy");
1430 if (empty($hidevoteallowed)) {
1431 print
'<td class="center">'.yn($objp->vote).
'</td>';
1433 $membercount = $objp->membercount > 0 ? $objp->membercount :
"–";
1434 if ($publiccounters) {
1435 print
'<td class="center">'.$membercount.
'</td>';
1437 print
'<td class="center"><button class="button button-save reposition" name="typeid" type="submit" name="submit" value="'.$objp->rowid.
'">'.$langs->trans(
"GetMembershipButtonLabel").
'</button></td>';
1445 print
'<tr><td colspan="'.$colspan.
'" class="opacitymedium">'.$langs->trans(
"NoRecordFound").
'</td></tr>';