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 opacitylow justify small margintoponly"><br>';
663 print $langs->trans(
"NewSubscriptionDesc",
getDolGlobalString(
"MAIN_INFO_SOCIETE_MAIL")).
"<br>\n";
671if ($action ==
"subscription") {
672 $urltocall = DOL_URL_ROOT.
'/public/payment/newpayment.php?source=member&ref='.
$object->id;
673 print $form->formconfirm($urltocall, $langs->trans(
"CorrespondingMemberFound"), $langs->trans(
"CorrespondingMemberFoundQuestion"),
"confirm_subscription",
'',
'no', 1);
677print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST" name="newmember" id="newmember">'.
"\n";
678print
'<input type="hidden" name="token" value="'.newToken().
'" />';
679print
'<input type="hidden" name="entity" value="'.$entity.
'" />';
680print
'<input type="hidden" name="page_y" value="" />';
683 if ($action ==
'subscription') {
684 print
'<input type="hidden" name="nofetchmember" value="nofetchmember" />';
686 print
'<input type="hidden" name="action" value="add" />';
695 if ($conf->use_javascript_ajax) {
696 print
"\n".
'<script type="text/javascript">'.
"\n";
697 print
'jQuery(document).ready(function () {
698 jQuery("#selectcountry_id").change(function() {
699 console.log("We change country, so we reload page");
700 document.newmember.action.value="create";
701 jQuery("#newmember").submit();
703 function initfieldrequired() {
704 console.log("initfieldrequired");
705 jQuery("#tdcompany").removeClass("fieldrequired");
706 jQuery("#tdlastname").removeClass("fieldrequired");
707 jQuery("#tdfirstname").removeClass("fieldrequired");
708 if (jQuery(\'input[name="morphy"]:checked\').val() == \'mor\') {
709 jQuery("#tdcompany").addClass("fieldrequired");
711 if (jQuery(\'input[name="morphy"]:checked\').val() == \'phy\') {
712 jQuery("#tdlastname").addClass("fieldrequired");
713 jQuery("#tdfirstname").addClass("fieldrequired");
716 jQuery(\'input[name="morphy"]\').change(function() {
721 print
'</script>'.
"\n";
724 print
'<table class="border" summary="form to subscribe" id="tablesubscribe">'.
"\n";
729 print
'<tr><td class="fieldrequired titlefieldmiddle">'.$langs->trans(
"MemberType").
'</td><td>';
730 $listetype = $adht->liste_array(1);
731 print
img_picto(
'', $adht->picto,
'class="pictofixedwidth"');
732 if (count($listetype)) {
733 print $form->selectarray(
"typeid", $listetype, (
GETPOSTINT(
'typeid') ?
GETPOSTINT(
'typeid') : $typeid), (count($listetype) > 1 ? 1 : 0), 0, 0,
'', 0, 0, 0,
'',
'minwidth150 maxwidth300 widthcentpercentminusx', 1);
735 print
'<span class="error">'.$langs->trans(
"NoTypeDefinedGoToSetup").
'</span>';
737 print
'</td></tr>'.
"\n";
740 print
'<input type="hidden" id="typeid" name="typeid" value="' .
getDolGlobalString(
'MEMBER_NEWFORM_FORCETYPE').
'">';
745 "phy" => $langs->trans(
"Physical"),
746 "mor" => $langs->trans(
"Moral"),
748 $checkednature =
GETPOST(
"morphy",
'alpha');
749 $listetype_natures = $adht->morphyByType(1);
750 $listetype_natures_json = json_encode($listetype_natures);
753 if (empty($checkednature) && !empty($listetype_natures[
GETPOSTINT(
'typeid')])) {
754 $checkednature = $listetype_natures[
GETPOSTINT(
'typeid')];
757 print
'<tr><td class="fieldrequired titlefieldmiddle">'.$langs->trans(
"MemberNature").
"</td><td>\n";
763 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>';
764 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>';
767 if ($conf->use_javascript_ajax) {
769 var listetype_natures = '.$listetype_natures_json.
';
772 function refreshNatureCss() {
773 $(".spannature").each(function(index) {
774 let $span = $("#spannature" + (index + 1));
775 let checked = $span.find(".checkforselect").is(":checked");
779 $span.addClass("member-individual-back").removeClass("nonature-back member-company-back");
780 } else if (index === 1) {
781 $span.addClass("member-company-back").removeClass("nonature-back member-individual-back");
784 $span.removeClass("member-individual-back member-company-back")
785 .addClass("nonature-back");
790 $(".spannature").on("click", function() {
791 console.log("Nature clicked");
795 $("#typeid").on("change", function() {
796 console.log("Type of membership is modified");
797 let morphy = listetype_natures[$(this).val()];
798 console.log("morphy="+morphy);
800 let $phyInput = $("#phisicalinput");
801 let $morInput = $("#moralinput");
802 let $tdLast = $("#tdlastname");
803 let $tdFirst = $("#tdfirstname");
804 let $tdCompany = $("#tdcompany");
805 let $span1 = $("#spannature1");
806 let $span2 = $("#spannature2");
810 /* $phyInput.prop({disabled: false, checked: true});
811 $morInput.prop({disabled: true, checked: false}); */
812 $span1.addClass("member-individual-back").removeClass("nonature-back");
813 $span2.removeClass("member-company-back").addClass("nonature-back");
814 $("#phisicalinput").prop("checked", true);
815 $tdLast.addClass("fieldrequired");
816 $tdFirst.addClass("fieldrequired");
817 $tdCompany.removeClass("fieldrequired");
821 /* $phyInput.prop({disabled: true, checked: false});
822 $morInput.prop({disabled: false, checked: true}); */
823 $span2.addClass("member-company-back").removeClass("nonature-back");
824 $span1.removeClass("member-individual-back").addClass("nonature-back");
825 $("#moralinput").prop("checked", true);
826 $tdCompany.addClass("fieldrequired");
827 $tdLast.removeClass("fieldrequired");
828 $tdFirst.removeClass("fieldrequired");
832 if ($action !=
"subscription" && !
GETPOST(
'morphy')) {
834 $phyInput.prop({disabled: false, checked: false});
835 $morInput.prop({disabled: false, checked: false});
836 $span1.removeClass("member-individual-back").addClass("nonature-back");
837 $span2.removeClass("member-company-back").addClass("nonature-back");';
847 print
'</td></tr>'.
"\n";
850 print
'<input type="hidden" id="morphy" name="morphy" value="' .
getDolGlobalString(
'MEMBER_NEWFORM_FORCEMORPHY').
'">';
854 print
'<tr id="trcompany" class="trcompany"><td id="tdcompany" class="titlefieldmiddle paddingrightonly'.($checkednature ==
"mor" ?
' fieldrequired"' :
'').
'">'.$langs->trans(
"Company").
'</td><td>';
855 print
img_picto(
'',
'company',
'class="pictofixedwidth paddingright"');
856 print
'<input type="text" name="societe" class="minwidth150 widthcentpercentminusx" value="'.dol_escape_htmltag(
GETPOST(
'societe')).
'"></td></tr>'.
"\n";
860 print
'<tr><td>'.$langs->trans(
'UserTitle').
'</td><td>';
861 print $formcompany->select_civility(
GETPOST(
'civility_id'),
'civility_id').
'</td></tr>'.
"\n";
865 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";
868 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";
871 print
'<tr><td>'.(getDolGlobalString(
'ADHERENT_MAIL_REQUIRED') ?
'<span class="fieldrequired">' :
'').$langs->trans(
"EMail").(getDolGlobalString(
'ADHERENT_MAIL_REQUIRED') ?
'</span>' :
'').
'</td>';
872 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";
876 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";
877 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";
878 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";
882 print
'<tr><td>'.$langs->trans(
"Gender").
'</td>';
884 $arraygender = array(
'man' => $langs->trans(
"Genderman"),
'woman' => $langs->trans(
"Genderwoman"),
'other' => $langs->trans(
"Genderother"));
885 print $form->selectarray(
'gender', $arraygender,
GETPOST(
'gender',
'alphanohtml'), 1, 0, 0,
'', 0, 0, 0,
'',
'minwidth150 maxwidth300 widthcentpercentminusx', 1);
889 print
'<tr><td>'.$langs->trans(
"Address").
'</td><td>'.
"\n";
890 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";
893 print
'<tr><td>'.$langs->trans(
'Zip').
' / '.$langs->trans(
'Town').
'</td><td>';
894 print $formcompany->select_ziptown(
GETPOST(
'zipcode'),
'zipcode', array(
'town',
'selectcountry_id',
'state_id'), 0, 1,
'',
'width75');
896 print $formcompany->select_ziptown(
GETPOST(
'town'),
'town', array(
'zipcode',
'selectcountry_id',
'state_id'), 0, 1);
902 print
'<tr><td class="fieldrequired">'.$langs->trans(
'Country').
'</td><td>';
903 print
img_picto(
'',
'country',
'class="pictofixedwidth paddingright"');
907 if (!$country_id && !empty($conf->geoipmaxmind->enabled)) {
911 $new_country_id =
getCountry($country_code,
'3', $db, $langs);
913 if ($new_country_id) {
914 $country_id = $new_country_id;
918 $country_code =
getCountry($country_id,
'2', $db, $langs);
919 print $form->select_country($country_id,
'country_id',
'', 0,
'minwidth150 maxwidth300 widthcentpercentminusx reposition');
924 print
'<tr><td>'.$langs->trans(
'State').
'</td><td>';
926 print
img_picto(
'',
'state',
'class="pictofixedwidth paddingright"');
927 print $formcompany->select_state(
GETPOSTINT(
"state_id"), $country_code,
'state_id',
'minwidth150 maxwidth300 widthcentpercentminusx');
933 print
'<tr><td>'.$langs->trans(
"PhonePro").
'</td>';
934 print
'<td>'.img_picto(
'',
'object_phoning',
'class="pictofixedwidth"').
'<input type="text" name="phone" class="maxwidth300 widthcentpercentminusx" value="'.
dol_escape_htmltag(
GETPOST(
'phone')).
'"></td></tr>';
937 print
'<tr><td>'.$langs->trans(
"PhonePerso").
'</td>';
938 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>';
941 print
'<tr><td>'.$langs->trans(
"PhoneMobile").
'</td>';
942 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>';
945 print
'<tr id="trbirth" class="trbirth"><td>'.$langs->trans(
"DateOfBirth").
'</td><td>';
946 print $form->selectDate(!empty($birthday) ? $birthday :
"",
'birth', 0, 0, 1,
"newmember", 1, 0);
947 print
'</td></tr>'.
"\n";
950 print
'<tr><td>'.$langs->trans(
"URLPhoto").
'</td><td><input type="text" name="photo" class="minwidth150" value="'.
dol_escape_htmltag(
GETPOST(
'photo')).
'"></td></tr>'.
"\n";
954 $linkofpubliclist = DOL_MAIN_URL_ROOT.
'/public/members/public_list.php'.((
isModEnabled(
'multicompany')) ?
'?entity='.$conf->entity :
'');
955 $publiclabel = $langs->trans(
"Public",
getDolGlobalString(
'MAIN_INFO_SOCIETE_NOM'), $linkofpubliclist);
956 print
'<tr><td>'.$form->textwithpicto($langs->trans(
"MembershipPublic"), $publiclabel).
'</td><td><input type="checkbox" name="public"></td></tr>'.
"\n";
960 $parameters[
'tpl_context'] =
'public';
961 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_add.tpl.php';
965 print
'<td class="tdtop"></td>';
966 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>';
973 $adht->fetch($typeid);
974 $caneditamount = $adht->caneditamount;
975 $amountbytype = $adht->amountByType(1);
976 foreach ($amountbytype as $k => $v) {
977 $amount = max(0, (
float) $v, (
float)
getDolGlobalInt(
"MEMBER_NEWFORM_AMOUNT"));
978 $amountbytype[$k] = $amount;
981 $amountbytype_json = json_encode($amountbytype);
982 $caneditamountbytype = $adht->caneditamountByType(1);
983 $caneditamountbytype_json = json_encode($caneditamountbytype);
988 $amount = empty($amountbytype[$typeid]) ? 0 : $amountbytype[$typeid];
994 if (empty($amount)) {
998 $amount = max(0, (
float) $amount, (
float)
getDolGlobalInt(
"MEMBER_MIN_AMOUNT"));
1006 $parameters = array(
'country_id' => $country_id,
'mode' =>
'new');
1007 $reshook = $hookmanager->executeHooks(
'membershipNewSubscriptionPublicForm', $parameters, $object, $action);
1015 $s = $langs->trans(
"AreYouAPreferredPartner",
'<a href="https://partners.dolibarr.org" target="_blank">{s1}</a>');
1016 $s = str_replace(
'{s1}',
'Preferred Partner', $s);
1017 print
'<tr id="trbudget" class="trcompany"><td class="paddingrightonly"><label for="pp" class="small">'.$s.
'</label></td><td>';
1018 print
'<input type="checkbox" name="pp" id="pp" value="1"'.(GETPOST(
'pp') ?
' checked="checked"' :
'').
' class="reposition">';
1021 print
'<tr id="trbudget" class="trcompany"><td class="fieldrequired paddingrightonly"><span class="small">'.$langs->trans(
"TurnoverOrBudget").
'</span></td><td>';
1023 $country_code =
dol_getIdFromCode($db, $country_id,
'c_country',
'rowid',
'code');
1024 if ($country_code ===
'FR' && $checkednature ===
'mor' &&
GETPOST(
'pp')) {
1025 print
'<input type="text" name="budget" id="budget" class="flat turnover right width100" value="'.GETPOST(
'budget').
'" required>';
1027 $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+');
1028 print $form->selectarray(
'budget', $arraybudget,
GETPOSTINT(
'budget'), 1, 0,
'', 0, 0, 0,
'');
1032 print
'<script type="text/javascript">
1033 jQuery(document).ready(function() {
1036 newamount = initturnover();
1037 jQuery("#amount").val(newamount);
1041 jQuery("#selectcountry_id").change(function() {
1042 console.log("We change country (code added for association, replace common code), so we reload page");
1043 jQuery("#budget").val(\'\');
1044 jQuery("#amount").val(\'\');
1045 jQuery("#amounthidden").val(\'\');
1047 jQuery("#phisicalinput,#moralinput").click(function() {
1048 console.log("We change the nature of membership");
1049 newamount = initturnover();
1050 jQuery("#amount").val(newamount);
1052 jQuery("#pp").change(function() {
1053 console.log("We change the preferred partner status");
1054 selectcountry_id = jQuery("#selectcountry_id").val();
1055 morphy = jQuery("#moralinput").is(\':checked\') ? \'mor\' : \'phy\';
1056 jQuery("#budget").val(\'\');
1057 jQuery("#amount").val(\'\');
1058 jQuery("#amounthidden").val(\'\');
1059 document.newmember.action.value="create";
1060 jQuery("#newmember").submit();
1062 jQuery("#budget").change(function() {
1063 console.log("Turnover amount has been modified on change");
1064 newamount = initturnover();
1065 jQuery("#amount").val(newamount);
1066 jQuery("#amounthidden").val(newamount);
1068 jQuery("#budget").keyup(function() {
1069 console.log("Turnover amount has been modified on keyup");
1070 newamount = initturnover();
1071 jQuery("#amount").val(newamount);
1072 jQuery("#amounthidden").val(newamount);
1075 function initturnover() {
1078 morphy = jQuery("#moralinput").is(\':checked\') ? \'mor\' : \'phy\';
1079 selectcountry_id = jQuery("#selectcountry_id").val();
1080 pp = jQuery("#pp").is(\':checked\') ? true : false;
1081 console.log("Set fields according to nature and other properties");
1082 console.log("morphy="+morphy);
1083 console.log("selectcountry_id="+selectcountry_id);
1084 console.log("pp="+pp);
1086 if (morphy == \'phy\') {
1087 jQuery(".amount").val('.((float) $amount).
');
1088 jQuery("#trbirth").show();
1089 jQuery(".trcompany").hide();
1090 jQuery(".trbudget").hide();
1091 newamount = '.((float) $amount).
';
1093 jQuery(".amount").val(\'\');
1094 jQuery("#trbirth").hide();
1095 jQuery(".trcompany").show();
1096 jQuery(".trbudget").show();
1097 jQuery(".hideifautoturnover").hide();
1099 jQuery("#budget").val(\'\');
1102 if (selectcountry_id == 1) {
1104 console.log("value selected in input text field is "+jQuery("#budget").val());
1105 newamount = Math.max(Math.round(price2numjs(jQuery("#budget").val()) * 0.005), 50);
1106 console.log("newamount = "+newamount);
1108 console.log("not a pp");
1109 if (jQuery("#budget").val() > 0) {
1110 console.log("value found in budget is "+jQuery("#budget").val());
1111 newamount = jQuery("#budget").val();
1113 jQuery("#budget").val(\'\');
1118 if (jQuery("#budget").val() > 0) {
1119 newamount = jQuery("#budget").val();
1121 jQuery("#budget").val(\'\');
1124 console.log("newamount="+newamount);
1132 print
'</td></tr>'.
"\n";
1136 print
'<tr><td>'.$langs->trans(
"Subscription");
1139 print
'<a href="' .
getDolGlobalString(
'MEMBER_EXT_URL_SUBSCRIPTION_INFO').
'" rel="external" target="_blank" rel="noopener noreferrer">';
1140 print
img_picto(
'',
'url',
'class="pictofixedwidth"').$langs->trans(
"SeeHere");
1143 print
'</td><td class="nowrap">';
1149 $showedamount = $amount > 0 ? $amount : 0;
1150 if ($caneditamount ===
"1") {
1151 print
'<input type="text" name="amount" id="amount" class="flat amount right width75" value="'.$showedamount.
'">';
1152 print
'<input type="text" name="amount" id="amounthidden" class="flat amount width75 hidden" disabled value="'.$showedamount.
'">';
1153 print
' '.$langs->getCurrencySymbol($conf->currency).
'<span class="opacitymedium hideifautoturnover small">';
1156 print $amount > 0 ? $langs->trans(
"AnyAmountWithAdvisedAmount",
price($amount, 0, $langs, 1, -1, -1, $conf->currency)) : $langs->trans(
"AnyAmountWithoutAdvisedAmount");
1160 print
'<input type="text" name="amount" id="amount" class="flat amount width75 right hidden" value="'.$showedamount.
'">';
1161 print
'<input type="text" name="amount" id="amounthidden" class="flat amount width75" disabled value="'.$showedamount.
'">';
1162 print
' '.$langs->getCurrencySymbol($conf->currency).
'<span class="opacitymedium hideifautoturnover hidden small">';
1165 print $amount > 0 ? $langs->trans(
"AnyAmountWithAdvisedAmount",
price($amount, 0, $langs, 1, -1, -1, $conf->currency)) : $langs->trans(
"AnyAmountWithoutAdvisedAmount");
1172 if ($conf->use_javascript_ajax) {
1174 var amountbytype = $amountbytype_json;
1175 var canEditAmount = $caneditamountbytype_json;
1179 jQuery(function($) {
1180 $("#typeid").on("change", function() {
1181 console.log("Type of membership changed, we force amount update");
1182 let typeId = $(this).val();
1183 let amountVal = amountbytype[typeId] || 0;
1184 let formattedAmount = parseFloat(amountVal);
1186 if (canEditAmount[typeId] === "1") {
1188 $("#amount").val(formattedAmount).prop("disabled", false).removeClass("hidden");
1189 $("#amounthidden").addClass("hidden");
1190 $(".hideifautoturnover").removeClass("hidden");
1193 $("#amounthidden").val(formattedAmount).prop("disabled", true).removeClass("hidden");
1194 $("#amount").addClass("hidden");
1195 $(".hideifautoturnover").addClass("hidden");
1199 // Trigger it once so the amount matches the initial selection
1200 $("#typeid").trigger("change");
1207 if (
getDolGlobalString(
'MAIN_SECURITY_ENABLECAPTCHA_MEMBER') && is_object($captchaobj)) {
1208 print
'<tr><td><label><span class="fieldrequired">'.$langs->trans(
"SecurityCode").
'</span></label></td><td><br>';
1209 if (method_exists($captchaobj,
'getCaptchaCodeForForm')) {
1210 print $captchaobj->getCaptchaCodeForForm(
'');
1212 print
'Error, the captcha handler '.get_class($captchaobj).
' does not have any method getCaptchaCodeForForm()';
1214 print
'<br></td></tr>';
1222 print
'<div class="center">';
1223 print
'<input type="submit" value="'.$langs->trans(
"GetMembershipButtonLabel").
'" id="submitsave" class="button">';
1224 if (!empty($backtopage)) {
1225 print
' <input type="submit" value="'.$langs->trans(
"Cancel").
'" id="submitcancel" class="button button-cancel">';
1232 print
'</div></div>';
1235 $measuringUnits =
new CUnits($db);
1236 $result = $measuringUnits->fetchAll(
'',
'', 0, 0, array(
't.active' => 1));
1238 foreach ($measuringUnits->records as $lines) {
1239 $units[$lines->short_label] = $langs->trans(ucfirst((
string) $lines->label));
1245 $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,";
1246 $sql .=
" COUNT(a.rowid) AS membercount";
1247 $sql .=
" FROM ".MAIN_DB_PREFIX.
"adherent_type as d";
1248 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"adherent as a";
1249 $sql .=
" ON d.rowid = a.fk_adherent_type AND a.statut > 0";
1250 $sql .=
" WHERE d.entity IN (".getEntity(
'member_type').
")";
1251 $sql .=
" AND d.statut=1";
1252 $sql .=
" GROUP BY d.rowid, d.libelle, d.subscription, d.amount, d.caneditamount, d.vote, d.note, d.duration, d.statut, d.morphy";
1254 $result = $db->query($sql);
1256 $num = $db->num_rows($result);
1258 print
'<br><div class="div-table-responsive">';
1259 print
'<table class="tagtable liste noborder">'.
"\n";
1260 print
'<input type="hidden" name="action" value="create">';
1262 print
'<tr class="liste_titre">';
1263 print
'<th>'.$langs->trans(
"Label").
'</th>';
1264 print
'<th class="center">'.$langs->trans(
"MembershipDuration").
'</th>';
1265 print
'<th class="center">'.$langs->trans(
"Amount").
'</th>';
1266 print
'<th class="center">'.$langs->trans(
"MembersNature").
'</th>';
1267 if (empty($hidevoteallowed)) {
1268 print
'<th class="center">'.$langs->trans(
"VoteAllowed").
'</th>';
1270 if ($publiccounters) {
1271 print
'<th class="center">'.$langs->trans(
"Members").
'</th>';
1273 print
'<th class="center">'.$langs->trans(
"NewSubscription").
'</th>';
1278 $objp = $db->fetch_object($result);
1280 $caneditamount = $objp->caneditamount;
1281 $amountbytype = $adht->amountByType(1);
1283 print
'<tr class="oddeven">';
1287 print
'<div class="twolinesmax-normallineheight minwidth200onall">';
1293 print
'<td class="center">';
1294 $unit = preg_replace(
"/[^a-zA-Z]+/",
"", $objp->duration);
1295 print
'<span class="badge badge-primary">';
1296 print max(1, intval($objp->duration)).
' '.$units[$unit];
1301 print
'<td class="center"><span class="amount nowrap">';
1305 $amount = empty($amountbytype[$objp->rowid]) ? 0 : $amountbytype[$objp->rowid];
1311 if (empty($amount)) {
1315 $amount = max(0, (
float) $amount, (
float)
getDolGlobalInt(
"MEMBER_MIN_AMOUNT"));
1317 $displayedamount = $amount;
1319 if ($objp->subscription) {
1320 if ($displayedamount > 0 || !$caneditamount) {
1321 print
price($displayedamount, 1, $langs, 1, 0, -1, $conf->currency);
1323 if ($caneditamount && $displayedamount > 0) {
1324 print $form->textwithpicto(
'', $langs->transnoentities(
"CanEditAmountShortForValues"), 1,
'help',
'', 0, 3);
1325 } elseif ($caneditamount) {
1326 print $langs->transnoentities(
"CanEditAmountShort");
1331 print
'</span></td>';
1333 print
'<td class="center minwidth100">';
1334 if ($objp->morphy ==
'phy') {
1335 print $langs->trans(
"Physical");
1336 } elseif ($objp->morphy ==
'mor') {
1337 print $langs->trans(
"Moral");
1339 print $langs->trans(
"MorAndPhy");
1343 if (empty($hidevoteallowed)) {
1344 print
'<td class="center">'.yn($objp->vote).
'</td>';
1346 $membercount = $objp->membercount > 0 ? $objp->membercount :
"–";
1347 if ($publiccounters) {
1348 print
'<td class="center">'.$membercount.
'</td>';
1350 print
'<td class="center"><button class="button button-save reposition" name="typeid" type="submit" name="submit" value="'.$objp->rowid.
'">'.$langs->trans(
"GetMembershipButtonLabel").
'</button></td>';
1358 print
'<tr><td colspan="'.$colspan.
'" class="opacitymedium">'.$langs->trans(
"NoRecordFound").
'</td></tr>';