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";
221$parameters = array();
223$reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
230if (empty($reshook) &&
getDolGlobalInt(
"MEMBER_SEARCH_MEMBER_PUBLIC_FORM_CREATE") && $action ==
'add' && !GETPOSTISSET(
"nofetchmember")) {
231 $memberfound =
false;
236 $sql =
"SELECT rowid as id";
237 $sql .=
" FROM ".MAIN_DB_PREFIX.
"adherent as a";
238 $sql .=
" WHERE a.login = '".$db->escape(
GETPOST(
'login')).
"'";
239 $sql .=
" AND statut = 1";
240 $sql .=
" AND entity IN (".getEntity(
$object->element).
")";
241 $resql = $db->query($sql);
243 if ($db->num_rows($resql) == 1) {
244 $obj = $db->fetch_object($resql);
253 if (!$memberfound &&
GETPOST(
"morphy") ==
'mor' && GETPOSTISSET(
"societe") ) {
254 $sql =
"SELECT a.rowid as id";
255 $sql .=
" FROM ".MAIN_DB_PREFIX.
"adherent as a";
256 $sql .=
" JOIN ".MAIN_DB_PREFIX.
"societe as s";
257 $sql .=
" ON a.fk_soc = s.rowid";
258 $sql .=
" WHERE s.nom = '".$db->escape(
GETPOST(
"societe",
'alphanohtml')).
"'";
259 $sql .=
" AND a.email = '".$db->escape(preg_replace(
'/\s+/',
'',
GETPOST(
"member_email",
'aZ09arobase'))).
"'";
260 $sql .=
" AND a.statut = 1";
261 $sql .=
" AND a.entity IN (".getEntity(
$object->element).
")";
262 $resql = $db->query($sql);
264 if ($db->num_rows($resql) == 1) {
265 $obj = $db->fetch_object($resql);
274 if (!$memberfound &&
GETPOST(
"morphy") ==
'phy' && GETPOSTISSET(
"lastname") && GETPOSTISSET(
"firstname") && !empty(
GETPOST(
"member_email",
'aZ09arobase'))) {
275 $sql =
"SELECT rowid as id";
276 $sql .=
" FROM ".MAIN_DB_PREFIX.
"adherent";
277 $sql .=
" WHERE firstname = '".$db->escape(
GETPOST(
"firstname",
'alphanohtml')).
"'";
278 $sql .=
" AND lastname = '".$db->escape(
GETPOST(
"lastname",
'alphanohtml')).
"'";
279 $sql .=
" AND email = '".$db->escape(preg_replace(
'/\s+/',
'',
GETPOST(
"member_email",
'aZ09arobase'))).
"'";
280 $sql .=
" AND statut = 1";
281 $sql .=
" AND entity IN (".getEntity(
$object->element).
")";
282 $resql = $db->query($sql);
284 if ($db->num_rows($resql) == 1) {
285 $obj = $db->fetch_object($resql);
295 $action =
'subscription';
300if (empty($reshook) && $action ==
'add') {
306 $morphy =
GETPOST(
"morphy",
'alphanohtml');
307 $lastname =
GETPOST(
"lastname",
'alphanohtml');
308 $firstname =
GETPOST(
"firstname",
'alphanohtml');
309 $societe =
GETPOST(
"societe",
'alphanohtml');
310 $email = preg_replace(
'/\s+/',
'',
GETPOST(
"member_email",
'aZ09arobase'));
313 if (!in_array($morphy, array(
'mor',
'phy'))) {
315 $errmsg .= $langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
'MemberNature')).
"<br>\n";
320 if (!
GETPOST(
'member_email')) {
322 $errmsg .= $langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"EMail")).
"<br>\n";
326 $errmsg .= $langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Login")).
"<br>\n";
328 $sql =
"SELECT login FROM ".MAIN_DB_PREFIX.
"adherent WHERE login = '".$db->escape(
GETPOST(
'login')).
"'";
329 $result = $db->query($sql);
331 $num = $db->num_rows($result);
335 $langs->load(
"errors");
336 $errmsg .= $langs->trans(
"ErrorLoginAlreadyExists").
"<br>\n";
338 if (!GETPOSTISSET(
"pass1") || !GETPOSTISSET(
"pass2") ||
GETPOST(
"pass1",
'none') ==
'' ||
GETPOST(
"pass2",
'none') ==
'' ||
GETPOST(
"pass1",
'none') !=
GETPOST(
"pass2",
'none')) {
340 $langs->load(
"errors");
341 $errmsg .= $langs->trans(
"ErrorPasswordsMustMatch").
"<br>\n";
346 $errmsg .= $langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Type")).
"<br>\n";
349 if ($morphy && $morphy !=
'mor' && empty($lastname)) {
351 $langs->load(
"errors");
352 $errmsg .= $langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"Lastname"));
354 if ($morphy && $morphy !=
'mor' && (!isset($firstname) || $firstname ==
'')) {
356 $langs->load(
"errors");
357 $errmsg .= $langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"Firstname"));
359 if ($morphy ==
'mor' && empty($societe)) {
361 $langs->load(
"errors");
362 $errmsg .= $langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"Company"));
364 if (empty($country_id)) {
366 $langs->load(
"errors");
367 $errmsg .= $langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"Country"));
371 $langs->load(
"errors");
372 $errmsg .= $langs->trans(
"ErrorBadEMail", $email);
375 if (
GETPOST(
"birthmonth") && empty($birthday)) {
377 $langs->load(
"errors");
378 $errmsg .= $langs->trans(
"ErrorBadDateFormat").
"<br>\n";
385 $errmsg .= $langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"TurnoverOrBudget")).
"<br>\n";
391 if (
getDolGlobalString(
'MAIN_SECURITY_ENABLECAPTCHA_MEMBER') && is_object($captchaobj)) {
392 if (method_exists($captchaobj,
'validateCodeAfterLoginSubmit')) {
393 $ok = $captchaobj->validateCodeAfterLoginSubmit();
395 print
'Error, the captcha handler '.get_class($captchaobj).
' does not have any method validateCodeAfterLoginSubmit()';
399 $langs->load(
"errors");
400 $errmsg .= $langs->trans(
"ErrorBadValueForCode").
"<br>\n";
405 $public = GETPOSTISSET(
'public') ? 1 : 0;
412 $adh->public = $public;
413 $adh->firstname =
GETPOST(
'firstname');
414 $adh->lastname =
GETPOST(
'lastname');
415 $adh->gender =
GETPOST(
'gender');
416 $adh->civility_id =
GETPOST(
'civility_id');
417 $adh->company =
GETPOST(
'societe');
418 $adh->societe = $adh->company;
419 $adh->address =
GETPOST(
'address');
420 $adh->zip =
GETPOST(
'zipcode');
422 $adh->email =
GETPOST(
'member_email',
'aZ09arobase');
424 $adh->login =
GETPOST(
'login');
425 $adh->pass =
GETPOST(
'pass1',
'password');
427 $adh->photo =
GETPOST(
'photo');
431 $adh->note_private =
GETPOST(
'note_private');
433 $adh->birth = $birthday;
434 $adh->phone =
GETPOST(
'phone');
435 $adh->phone_perso =
GETPOST(
'phone_perso');
436 $adh->phone_mobile=
GETPOST(
'phone_mobile');
440 $nb_post_max =
getDolGlobalInt(
"MAIN_SECURITY_MAX_POST_ON_PUBLIC_PAGES_BY_IP_ADDRESS", 200);
445 if ($nb_post_max > 0) {
446 $sql =
"SELECT COUNT(ref) as nb_adh";
447 $sql .=
" FROM ".MAIN_DB_PREFIX.
"adherent";
448 $sql .=
" WHERE ip = '".$db->escape($adh->ip).
"'";
449 $sql .=
" AND datec > '".$db->idate($minmonthpost).
"'";
450 $resql = $db->query($sql);
452 $num = $db->num_rows($resql);
456 $obj = $db->fetch_object($resql);
457 $nb_post_ip = $obj->nb_adh;
464 $extrafields->fetch_name_optionals_label($adh->table_element);
465 $ret = $extrafields->setOptionalsFromPost(
null, $adh);
468 $errmsg .= $adh->error;
471 if ($nb_post_max > 0 && $nb_post_ip >= $nb_post_max) {
473 $errmsg .= $langs->trans(
"AlreadyTooMuchPostOnThisIPAdress");
474 array_push($adh->errors, $langs->trans(
"AlreadyTooMuchPostOnThisIPAdress"));
478 $result = $adh->create($user);
480 require_once DOL_DOCUMENT_ROOT.
'/core/class/CMailFile.class.php';
491 include_once DOL_DOCUMENT_ROOT.
'/core/class/html.formmail.class.php';
495 $outputlangs->setDefaultLang(empty(
$object->thirdparty->default_lang) ?
$mysoc->default_lang :
$object->thirdparty->default_lang);
497 $outputlangs->loadLangs(array(
"main",
"members"));
499 $arraydefaultmessage =
null;
502 if (!empty($labeltouse)) {
503 $arraydefaultmessage = $formmail->getEMailTemplate($db,
'member', $user, $outputlangs, 0, 1, $labeltouse);
506 if (!empty($labeltouse) && is_object($arraydefaultmessage) && $arraydefaultmessage->id > 0) {
507 $subject = $arraydefaultmessage->topic;
508 $msg = $arraydefaultmessage->content;
511 $substitutionarray = getCommonSubstitutionArray($outputlangs, 0,
null, $object);
516 if ($subjecttosend && $texttosend) {
517 $moreinheader =
'X-Dolibarr-Info: send_an_email by public/members/new.php'.
"\r\n";
519 $result =
$object->sendEmail($texttosend, $subjecttosend, array(), array(), array(),
"",
"", 0, -1,
'', $moreinheader);
531 $appli = constant(
'DOL_APPLICATION_TITLE');
534 if (preg_match(
'/\d\.\d/', $appli)) {
535 if (!preg_match(
'/'.preg_quote(DOL_VERSION,
'/').
'/', $appli)) {
536 $appli .=
" (".DOL_VERSION.
")";
539 $appli .=
" ".DOL_VERSION;
542 $appli .=
" ".DOL_VERSION;
561 if (!$mailfile->sendfile()) {
562 dol_syslog($langs->trans(
"ErrorFailedToSendMail", $from, $to), LOG_ERR);
569 $result = $company->create_from_member($adh);
572 $errmsg .= implode(
'<br>', $company->errors);
576 if (!empty($backtopage)) {
577 $urlback = $backtopage;
582 $urlback = $_SERVER[
"PHP_SELF"].
"?action=added&token=".
newToken();
586 if (empty($adht->caneditamount)) {
591 $urlback = getOnlinePaymentUrl(0,
'member', $adh->ref, (
float)
price2num(
GETPOST(
'amount',
'alpha'),
'MT'),
'', 0);
594 $urlback .=
'&email='.urlencode(
GETPOST(
'member_email'));
597 $urlback .=
'&paymentmethod='.urlencode(
getDolGlobalString(
'MEMBER_NEWFORM_PAYONLINE'));
600 if (!empty($entity)) {
601 $urlback .=
'&entity='.((int) $entity);
606 $errmsg .= implode(
'<br>', $adh->errors);
614 header(
"Location: ".$urlback);
626if (empty($reshook) && $action ==
'added') {
631 print
'<div class="center">';
632 print $langs->trans(
"NewMemberbyWeb");
644$form =
new Form($db);
647$extrafields->fetch_name_optionals_label(
$object->table_element);
653print
load_fiche_titre(
img_picto(
'',
'member_nocolor',
'class="pictofixedwidth"').
' '.$langs->trans(
"NewSubscription"),
'',
'', 0,
'',
'center');
656print
'<div align="center">';
657print
'<div id="divsubscribe">';
659print
'<div class="center subscriptionformhelptext opacitymedium justify">';
663 print $langs->trans(
"NewSubscriptionDesc",
getDolGlobalString(
"MAIN_INFO_SOCIETE_MAIL")).
"<br>\n";
670if ($action ==
"subscription") {
671 $urltocall = DOL_URL_ROOT.
'/public/payment/newpayment.php?source=member&ref='.
$object->id;
672 print $form->formconfirm($urltocall, $langs->trans(
"CorrespondingMemberFound"), $langs->trans(
"CorrespondingMemberFoundQuestion"),
"confirm_subscription",
'',
'no', 1);
676print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST" name="newmember" id="newmember">'.
"\n";
677print
'<input type="hidden" name="token" value="'.newToken().
'" />';
678print
'<input type="hidden" name="entity" value="'.$entity.
'" />';
679print
'<input type="hidden" name="page_y" value="" />';
682 if ($action ==
'subscription') {
683 print
'<input type="hidden" name="nofetchmember" value="nofetchmember" />';
685 print
'<input type="hidden" name="action" value="add" />';
694 if ($conf->use_javascript_ajax) {
695 print
"\n".
'<script type="text/javascript">'.
"\n";
696 print
'jQuery(document).ready(function () {
697 jQuery("#selectcountry_id").change(function() {
698 console.log("We change country, so we reload page");
699 document.newmember.action.value="create";
700 jQuery("#newmember").submit();
702 function initfieldrequired() {
703 console.log("initfieldrequired");
704 jQuery("#tdcompany").removeClass("fieldrequired");
705 jQuery("#tdlastname").removeClass("fieldrequired");
706 jQuery("#tdfirstname").removeClass("fieldrequired");
707 if (jQuery(\'input[name="morphy"]:checked\').val() == \'mor\') {
708 jQuery("#tdcompany").addClass("fieldrequired");
710 if (jQuery(\'input[name="morphy"]:checked\').val() == \'phy\') {
711 jQuery("#tdlastname").addClass("fieldrequired");
712 jQuery("#tdfirstname").addClass("fieldrequired");
715 jQuery(\'input[name="morphy"]\').change(function() {
720 print
'</script>'.
"\n";
723 print
'<table class="border" summary="form to subscribe" id="tablesubscribe">'.
"\n";
728 print
'<tr><td class="fieldrequired titlefieldmiddle">'.$langs->trans(
"MemberType").
'</td><td>';
729 $listetype = $adht->liste_array(1);
730 print
img_picto(
'', $adht->picto,
'class="pictofixedwidth"');
731 if (count($listetype)) {
732 print $form->selectarray(
"typeid", $listetype, (
GETPOSTINT(
'typeid') ?
GETPOSTINT(
'typeid') : $typeid), (count($listetype) > 1 ? 1 : 0), 0, 0,
'', 0, 0, 0,
'',
'minwidth150 maxwidth300 widthcentpercentminusx', 1);
734 print
'<span class="error">'.$langs->trans(
"NoTypeDefinedGoToSetup").
'</span>';
736 print
'</td></tr>'.
"\n";
739 print
'<input type="hidden" id="typeid" name="typeid" value="' .
getDolGlobalString(
'MEMBER_NEWFORM_FORCETYPE').
'">';
744 "phy" => $langs->trans(
"Physical"),
745 "mor" => $langs->trans(
"Moral"),
747 $checkednature =
GETPOST(
"morphy",
'alpha');
748 $listetype_natures = $adht->morphyByType(1);
749 $listetype_natures_json = json_encode($listetype_natures);
752 if (empty($checkednature) && !empty($listetype_natures[
GETPOSTINT(
'typeid')])) {
753 $checkednature = $listetype_natures[
GETPOSTINT(
'typeid')];
756 print
'<tr><td class="fieldrequired titlefieldmiddle">'.$langs->trans(
"MemberNature").
"</td><td>\n";
762 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>';
763 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>';
766 if ($conf->use_javascript_ajax) {
768 var listetype_natures = '.$listetype_natures_json.
';
771 function refreshNatureCss() {
772 $(".spannature").each(function(index) {
773 let $span = $("#spannature" + (index + 1));
774 let checked = $span.find(".checkforselect").is(":checked");
778 $span.addClass("member-individual-back").removeClass("nonature-back member-company-back");
779 } else if (index === 1) {
780 $span.addClass("member-company-back").removeClass("nonature-back member-individual-back");
783 $span.removeClass("member-individual-back member-company-back")
784 .addClass("nonature-back");
789 $(".spannature").on("click", function() {
790 console.log("Nature clicked");
794 $("#typeid").on("change", function() {
795 console.log("Type of membership is modified");
796 let morphy = listetype_natures[$(this).val()];
797 console.log("morphy="+morphy);
799 let $phyInput = $("#phisicalinput");
800 let $morInput = $("#moralinput");
801 let $tdLast = $("#tdlastname");
802 let $tdFirst = $("#tdfirstname");
803 let $tdCompany = $("#tdcompany");
804 let $span1 = $("#spannature1");
805 let $span2 = $("#spannature2");
809 /* $phyInput.prop({disabled: false, checked: true});
810 $morInput.prop({disabled: true, checked: false}); */
811 $span1.addClass("member-individual-back").removeClass("nonature-back");
812 $span2.removeClass("member-company-back").addClass("nonature-back");
813 $("#phisicalinput").prop("checked", true);
814 $tdLast.addClass("fieldrequired");
815 $tdFirst.addClass("fieldrequired");
816 $tdCompany.removeClass("fieldrequired");
820 /* $phyInput.prop({disabled: true, checked: false});
821 $morInput.prop({disabled: false, checked: true}); */
822 $span2.addClass("member-company-back").removeClass("nonature-back");
823 $span1.removeClass("member-individual-back").addClass("nonature-back");
824 $("#moralinput").prop("checked", true);
825 $tdCompany.addClass("fieldrequired");
826 $tdLast.removeClass("fieldrequired");
827 $tdFirst.removeClass("fieldrequired");
831 if ($action !=
"subscription" && !
GETPOST(
'morphy')) {
833 $phyInput.prop({disabled: false, checked: false});
834 $morInput.prop({disabled: false, checked: false});
835 $span1.removeClass("member-individual-back").addClass("nonature-back");
836 $span2.removeClass("member-company-back").addClass("nonature-back");';
846 print
'</td></tr>'.
"\n";
849 print
'<input type="hidden" id="morphy" name="morphy" value="' .
getDolGlobalString(
'MEMBER_NEWFORM_FORCEMORPHY').
'">';
853 print
'<tr id="trcompany" class="trcompany"><td id="tdcompany" class="titlefieldmiddle paddingrightonly'.($checkednature ==
"mor" ?
' fieldrequired"' :
'').
'">'.$langs->trans(
"Company").
'</td><td>';
854 print
img_picto(
'',
'company',
'class="pictofixedwidth paddingright"');
855 print
'<input type="text" name="societe" class="minwidth150 widthcentpercentminusx" value="'.dol_escape_htmltag(
GETPOST(
'societe')).
'"></td></tr>'.
"\n";
859 print
'<tr><td>'.$langs->trans(
'UserTitle').
'</td><td>';
860 print $formcompany->select_civility(
GETPOST(
'civility_id'),
'civility_id').
'</td></tr>'.
"\n";
864 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";
867 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";
870 print
'<tr><td>'.(getDolGlobalString(
'ADHERENT_MAIL_REQUIRED') ?
'<span class="fieldrequired">' :
'').$langs->trans(
"EMail").(getDolGlobalString(
'ADHERENT_MAIL_REQUIRED') ?
'</span>' :
'').
'</td>';
871 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";
875 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";
876 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";
877 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";
881 print
'<tr><td>'.$langs->trans(
"Gender").
'</td>';
883 $arraygender = array(
'man' => $langs->trans(
"Genderman"),
'woman' => $langs->trans(
"Genderwoman"),
'other' => $langs->trans(
"Genderother"));
884 print $form->selectarray(
'gender', $arraygender,
GETPOST(
'gender',
'alphanohtml'), 1, 0, 0,
'', 0, 0, 0,
'',
'minwidth150 maxwidth300 widthcentpercentminusx', 1);
888 print
'<tr><td>'.$langs->trans(
"Address").
'</td><td>'.
"\n";
889 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";
892 print
'<tr><td>'.$langs->trans(
'Zip').
' / '.$langs->trans(
'Town').
'</td><td>';
893 print $formcompany->select_ziptown(
GETPOST(
'zipcode'),
'zipcode', array(
'town',
'selectcountry_id',
'state_id'), 0, 1,
'',
'width75');
895 print $formcompany->select_ziptown(
GETPOST(
'town'),
'town', array(
'zipcode',
'selectcountry_id',
'state_id'), 0, 1);
901 print
'<tr><td class="fieldrequired">'.$langs->trans(
'Country').
'</td><td>';
902 print
img_picto(
'',
'country',
'class="pictofixedwidth paddingright"');
906 if (!$country_id && !empty($conf->geoipmaxmind->enabled)) {
910 $new_country_id =
getCountry($country_code,
'3', $db, $langs);
912 if ($new_country_id) {
913 $country_id = $new_country_id;
917 $country_code =
getCountry($country_id,
'2', $db, $langs);
918 print $form->select_country($country_id,
'country_id',
'', 0,
'minwidth150 maxwidth300 widthcentpercentminusx reposition');
923 print
'<tr><td>'.$langs->trans(
'State').
'</td><td>';
925 print
img_picto(
'',
'state',
'class="pictofixedwidth paddingright"');
926 print $formcompany->select_state(
GETPOSTINT(
"state_id"), $country_code,
'state_id',
'minwidth150 maxwidth300 widthcentpercentminusx');
932 print
'<tr><td>'.$langs->trans(
"PhonePro").
'</td>';
933 print
'<td>'.img_picto(
'',
'object_phoning',
'class="pictofixedwidth"').
'<input type="text" name="phone" class="maxwidth300 widthcentpercentminusx" value="'.
dol_escape_htmltag(
GETPOST(
'phone')).
'"></td></tr>';
936 print
'<tr><td>'.$langs->trans(
"PhonePerso").
'</td>';
937 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>';
940 print
'<tr><td>'.$langs->trans(
"PhoneMobile").
'</td>';
941 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>';
944 print
'<tr id="trbirth" class="trbirth"><td>'.$langs->trans(
"DateOfBirth").
'</td><td>';
945 print $form->selectDate(!empty($birthday) ? $birthday :
"",
'birth', 0, 0, 1,
"newmember", 1, 0);
946 print
'</td></tr>'.
"\n";
949 print
'<tr><td>'.$langs->trans(
"URLPhoto").
'</td><td><input type="text" name="photo" class="minwidth150" value="'.
dol_escape_htmltag(
GETPOST(
'photo')).
'"></td></tr>'.
"\n";
953 $linkofpubliclist = DOL_MAIN_URL_ROOT.
'/public/members/public_list.php'.((
isModEnabled(
'multicompany')) ?
'?entity='.$conf->entity :
'');
954 $publiclabel = $langs->trans(
"Public",
getDolGlobalString(
'MAIN_INFO_SOCIETE_NOM'), $linkofpubliclist);
955 print
'<tr><td>'.$form->textwithpicto($langs->trans(
"MembershipPublic"), $publiclabel).
'</td><td><input type="checkbox" name="public"></td></tr>'.
"\n";
959 $parameters[
'tpl_context'] =
'public';
960 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_add.tpl.php';
964 print
'<td class="tdtop"></td>';
965 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>';
972 $adht->fetch($typeid);
973 $caneditamount = $adht->caneditamount;
974 $amountbytype = $adht->amountByType(1);
975 foreach ($amountbytype as $k => $v) {
976 $amount = max(0, (
float) $v, (
float)
getDolGlobalInt(
"MEMBER_NEWFORM_AMOUNT"));
977 $amountbytype[$k] = $amount;
980 $amountbytype_json = json_encode($amountbytype);
981 $caneditamountbytype = $adht->caneditamountByType(1);
982 $caneditamountbytype_json = json_encode($caneditamountbytype);
987 $amount = empty($amountbytype[$typeid]) ? 0 : $amountbytype[$typeid];
993 if (empty($amount)) {
997 $amount = max(0, (
float) $amount, (
float)
getDolGlobalInt(
"MEMBER_MIN_AMOUNT"));
1005 $parameters = array(
'country_id' => $country_id,
'mode' =>
'new');
1006 $reshook = $hookmanager->executeHooks(
'membershipNewSubscriptionPublicForm', $parameters, $object, $action);
1014 $s = $langs->trans(
"AreYouAPreferredPartner",
'<a href="https://partners.dolibarr.org" target="_blank">{s1}</a>');
1015 $s = str_replace(
'{s1}',
'Preferred Partner', $s);
1016 print
'<tr id="trbudget" class="trcompany"><td class="paddingrightonly"><label for="pp" class="small">'.$s.
'</label></td><td>';
1017 print
'<input type="checkbox" name="pp" id="pp" value="1"'.(GETPOST(
'pp') ?
' checked="checked"' :
'').
' class="reposition">';
1020 print
'<tr id="trbudget" class="trcompany"><td class="fieldrequired paddingrightonly"><span class="small">'.$langs->trans(
"TurnoverOrBudget").
'</span></td><td>';
1022 $country_code =
dol_getIdFromCode($db, $country_id,
'c_country',
'rowid',
'code');
1023 if ($country_code ===
'FR' && $checkednature ===
'mor' &&
GETPOST(
'pp')) {
1024 print
'<input type="text" name="budget" id="budget" class="flat turnover right width100" value="'.GETPOST(
'budget').
'" required>';
1026 $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+');
1027 print $form->selectarray(
'budget', $arraybudget,
GETPOSTINT(
'budget'), 1, 0,
'', 0, 0, 0,
'');
1031 print
'<script type="text/javascript">
1032 jQuery(document).ready(function() {
1035 newamount = initturnover();
1036 jQuery("#amount").val(newamount);
1040 jQuery("#selectcountry_id").change(function() {
1041 console.log("We change country (code added for association, replace common code), so we reload page");
1042 jQuery("#budget").val(\'\');
1043 jQuery("#amount").val(\'\');
1044 jQuery("#amounthidden").val(\'\');
1046 jQuery("#phisicalinput,#moralinput").click(function() {
1047 console.log("We change the nature of membership");
1048 newamount = initturnover();
1049 jQuery("#amount").val(newamount);
1051 jQuery("#pp").change(function() {
1052 console.log("We change the preferred partner status");
1053 selectcountry_id = jQuery("#selectcountry_id").val();
1054 morphy = jQuery("#moralinput").is(\':checked\') ? \'mor\' : \'phy\';
1055 jQuery("#budget").val(\'\');
1056 jQuery("#amount").val(\'\');
1057 jQuery("#amounthidden").val(\'\');
1058 document.newmember.action.value="create";
1059 jQuery("#newmember").submit();
1061 jQuery("#budget").change(function() {
1062 console.log("Turnover amount has been modified on change");
1063 newamount = initturnover();
1064 jQuery("#amount").val(newamount);
1065 jQuery("#amounthidden").val(newamount);
1067 jQuery("#budget").keyup(function() {
1068 console.log("Turnover amount has been modified on keyup");
1069 newamount = initturnover();
1070 jQuery("#amount").val(newamount);
1071 jQuery("#amounthidden").val(newamount);
1074 function initturnover() {
1077 morphy = jQuery("#moralinput").is(\':checked\') ? \'mor\' : \'phy\';
1078 selectcountry_id = jQuery("#selectcountry_id").val();
1079 pp = jQuery("#pp").is(\':checked\') ? true : false;
1080 console.log("Set fields according to nature and other properties");
1081 console.log("morphy="+morphy);
1082 console.log("selectcountry_id="+selectcountry_id);
1083 console.log("pp="+pp);
1085 if (morphy == \'phy\') {
1086 jQuery(".amount").val('.((float) $amount).
');
1087 jQuery("#trbirth").show();
1088 jQuery(".trcompany").hide();
1089 jQuery(".trbudget").hide();
1090 newamount = '.((float) $amount).
';
1092 jQuery(".amount").val(\'\');
1093 jQuery("#trbirth").hide();
1094 jQuery(".trcompany").show();
1095 jQuery(".trbudget").show();
1096 jQuery(".hideifautoturnover").hide();
1098 jQuery("#budget").val(\'\');
1101 if (selectcountry_id == 1) {
1103 console.log("value selected in input text field is "+jQuery("#budget").val());
1104 newamount = Math.max(Math.round(price2numjs(jQuery("#budget").val()) * 0.005), 50);
1105 console.log("newamount = "+newamount);
1107 console.log("not a pp");
1108 if (jQuery("#budget").val() > 0) {
1109 console.log("value found in budget is "+jQuery("#budget").val());
1110 newamount = jQuery("#budget").val();
1112 jQuery("#budget").val(\'\');
1117 if (jQuery("#budget").val() > 0) {
1118 newamount = jQuery("#budget").val();
1120 jQuery("#budget").val(\'\');
1123 console.log("newamount="+newamount);
1131 print
'</td></tr>'.
"\n";
1135 print
'<tr><td>'.$langs->trans(
"Subscription");
1138 print
'<a href="' .
getDolGlobalString(
'MEMBER_EXT_URL_SUBSCRIPTION_INFO').
'" rel="external" target="_blank" rel="noopener noreferrer">';
1139 print
img_picto(
'',
'url',
'class="pictofixedwidth"').$langs->trans(
"SeeHere");
1142 print
'</td><td class="nowrap">';
1148 $showedamount = $amount > 0 ? $amount : 0;
1149 if ($caneditamount ===
"1") {
1150 print
'<input type="text" name="amount" id="amount" class="flat amount right width75" value="'.$showedamount.
'">';
1151 print
'<input type="text" name="amount" id="amounthidden" class="flat amount width75 hidden" disabled value="'.$showedamount.
'">';
1152 print
' '.$langs->getCurrencySymbol($conf->currency).
'<span class="opacitymedium hideifautoturnover small">';
1155 print $amount > 0 ? $langs->trans(
"AnyAmountWithAdvisedAmount",
price($amount, 0, $langs, 1, -1, -1, $conf->currency)) : $langs->trans(
"AnyAmountWithoutAdvisedAmount");
1159 print
'<input type="text" name="amount" id="amount" class="flat amount width75 right hidden" value="'.$showedamount.
'">';
1160 print
'<input type="text" name="amount" id="amounthidden" class="flat amount width75" disabled value="'.$showedamount.
'">';
1161 print
' '.$langs->getCurrencySymbol($conf->currency).
'<span class="opacitymedium hideifautoturnover hidden small">';
1164 print $amount > 0 ? $langs->trans(
"AnyAmountWithAdvisedAmount",
price($amount, 0, $langs, 1, -1, -1, $conf->currency)) : $langs->trans(
"AnyAmountWithoutAdvisedAmount");
1171 if ($conf->use_javascript_ajax) {
1173 var amountbytype = $amountbytype_json;
1174 var canEditAmount = $caneditamountbytype_json;
1178 jQuery(function($) {
1179 $("#typeid").on("change", function() {
1180 console.log("Type of membership changed, we force amount update");
1181 let typeId = $(this).val();
1182 let amountVal = amountbytype[typeId] || 0;
1183 let formattedAmount = parseFloat(amountVal);
1185 if (canEditAmount[typeId] === "1") {
1187 $("#amount").val(formattedAmount).prop("disabled", false).removeClass("hidden");
1188 $("#amounthidden").addClass("hidden");
1189 $(".hideifautoturnover").removeClass("hidden");
1192 $("#amounthidden").val(formattedAmount).prop("disabled", true).removeClass("hidden");
1193 $("#amount").addClass("hidden");
1194 $(".hideifautoturnover").addClass("hidden");
1198 // Trigger it once so the amount matches the initial selection
1199 $("#typeid").trigger("change");
1206 if (
getDolGlobalString(
'MAIN_SECURITY_ENABLECAPTCHA_MEMBER') && is_object($captchaobj)) {
1207 print
'<tr><td><label><span class="fieldrequired">'.$langs->trans(
"SecurityCode").
'</span></label></td><td><br>';
1208 if (method_exists($captchaobj,
'getCaptchaCodeForForm')) {
1209 print $captchaobj->getCaptchaCodeForForm(
'');
1211 print
'Error, the captcha handler '.get_class($captchaobj).
' does not have any method getCaptchaCodeForForm()';
1213 print
'<br></td></tr>';
1221 print
'<div class="center">';
1222 print
'<input type="submit" value="'.$langs->trans(
"GetMembershipButtonLabel").
'" id="submitsave" class="button">';
1223 if (!empty($backtopage)) {
1224 print
' <input type="submit" value="'.$langs->trans(
"Cancel").
'" id="submitcancel" class="button button-cancel">';
1231 print
'</div></div>';
1234 $measuringUnits =
new CUnits($db);
1235 $result = $measuringUnits->fetchAll(
'',
'', 0, 0, array(
't.active' => 1));
1237 foreach ($measuringUnits->records as $lines) {
1238 $units[$lines->short_label] = $langs->trans(ucfirst((
string) $lines->label));
1244 $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,";
1245 $sql .=
" COUNT(a.rowid) AS membercount";
1246 $sql .=
" FROM ".MAIN_DB_PREFIX.
"adherent_type as d";
1247 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"adherent as a";
1248 $sql .=
" ON d.rowid = a.fk_adherent_type AND a.statut > 0";
1249 $sql .=
" WHERE d.entity IN (".getEntity(
'member_type').
")";
1250 $sql .=
" AND d.statut=1";
1251 $sql .=
" GROUP BY d.rowid, d.libelle, d.subscription, d.amount, d.caneditamount, d.vote, d.note, d.duration, d.statut, d.morphy";
1253 $result = $db->query($sql);
1255 $num = $db->num_rows($result);
1257 print
'<br><div class="div-table-responsive">';
1258 print
'<table class="tagtable liste">'.
"\n";
1259 print
'<input type="hidden" name="action" value="create">';
1261 print
'<tr class="liste_titre">';
1262 print
'<th>'.$langs->trans(
"Label").
'</th>';
1263 print
'<th class="center">'.$langs->trans(
"MembershipDuration").
'</th>';
1264 print
'<th class="center">'.$langs->trans(
"Amount").
'</th>';
1265 print
'<th class="center">'.$langs->trans(
"MembersNature").
'</th>';
1266 if (empty($hidevoteallowed)) {
1267 print
'<th class="center">'.$langs->trans(
"VoteAllowed").
'</th>';
1269 if ($publiccounters) {
1270 print
'<th class="center">'.$langs->trans(
"Members").
'</th>';
1272 print
'<th class="center">'.$langs->trans(
"NewSubscription").
'</th>';
1277 $objp = $db->fetch_object($result);
1279 $caneditamount = $objp->caneditamount;
1280 $amountbytype = $adht->amountByType(1);
1282 print
'<tr class="oddeven">';
1284 print
'<td>'.dolPrintHTML($objp->label).
'</td>';
1286 print
'<td class="center">';
1287 $unit = preg_replace(
"/[^a-zA-Z]+/",
"", $objp->duration);
1288 print max(1, intval($objp->duration)).
' '.$units[$unit];
1291 print
'<td class="center"><span class="amount nowrap">';
1295 $amount = empty($amountbytype[$objp->rowid]) ? 0 : $amountbytype[$objp->rowid];
1301 if (empty($amount)) {
1305 $amount = max(0, (
float) $amount, (
float)
getDolGlobalInt(
"MEMBER_MIN_AMOUNT"));
1307 $displayedamount = $amount;
1309 if ($objp->subscription) {
1310 if ($displayedamount > 0 || !$caneditamount) {
1311 print
price($displayedamount, 1, $langs, 1, 0, -1, $conf->currency);
1313 if ($caneditamount && $displayedamount > 0) {
1314 print $form->textwithpicto(
'', $langs->transnoentities(
"CanEditAmountShortForValues"), 1,
'help',
'', 0, 3);
1315 } elseif ($caneditamount) {
1316 print $langs->transnoentities(
"CanEditAmountShort");
1321 print
'</span></td>';
1322 print
'<td class="center">';
1323 if ($objp->morphy ==
'phy') {
1324 print $langs->trans(
"Physical");
1325 } elseif ($objp->morphy ==
'mor') {
1326 print $langs->trans(
"Moral");
1328 print $langs->trans(
"MorAndPhy");
1331 if (empty($hidevoteallowed)) {
1332 print
'<td class="center">'.yn($objp->vote).
'</td>';
1334 $membercount = $objp->membercount > 0 ? $objp->membercount :
"–";
1335 if ($publiccounters) {
1336 print
'<td class="center">'.$membercount.
'</td>';
1338 print
'<td class="center"><button class="button button-save reposition" name="typeid" type="submit" name="submit" value="'.$objp->rowid.
'">'.$langs->trans(
"GetMembershipButtonLabel").
'</button></td>';
1346 print
'<tr><td colspan="'.$colspan.
'" class="opacitymedium">'.$langs->trans(
"NoRecordFound").
'</td></tr>';