From 17f84c4edc1e4b98b524190c4e5265bb8a1fbd04 Mon Sep 17 00:00:00 2001 From: daraelmin Date: Sat, 17 Apr 2021 14:18:42 +0200 Subject: [PATCH 1/6] Fix new member form use getpost instead FORCEXXX ## Fix use FORCETYPE, FORCECOUNTRYCODE, FORCEMORPHY even if GETPOST bas value ## Fix code style : typeid is note type ## Fix reset amount when $amount is set by script or by hook ## Fix some code style --- htdocs/public/members/new.php | 82 +++++++++++++++++------------------ 1 file changed, 40 insertions(+), 42 deletions(-) diff --git a/htdocs/public/members/new.php b/htdocs/public/members/new.php index e6b7a3e7a38..19fa23af080 100644 --- a/htdocs/public/members/new.php +++ b/htdocs/public/members/new.php @@ -201,12 +201,12 @@ if (empty($reshook) && $action == 'add') { $langs->load("errors"); $errmsg .= $langs->trans("ErrorPasswordsMustMatch")."
\n"; } - if (!GETPOST("email")) { + if (!GETPOST('email')) { $error++; $errmsg .= $langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("EMail"))."
\n"; } } - if (GETPOST('type') <= 0) { + if (GETPOST('typeid') <= 0) { $error++; $errmsg .= $langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Type"))."
\n"; } @@ -214,21 +214,21 @@ if (empty($reshook) && $action == 'add') { $error++; $errmsg .= $langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv('Nature'))."
\n"; } - if (!GETPOST("lastname")) { + if (!GETPOST('lastname')) { $error++; $errmsg .= $langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Lastname"))."
\n"; } - if (!GETPOST("firstname")) { + if (!GETPOST('firstname') { $error++; $errmsg .= $langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Firstname"))."
\n"; } - if (GETPOST("email") && !isValidEmail(GETPOST("email"))) { + if (GETPOST('email') && !isValidEmail(GETPOST('email'))) { $error++; $langs->load("errors"); - $errmsg .= $langs->trans("ErrorBadEMail", GETPOST("email"))."
\n"; + $errmsg .= $langs->trans("ErrorBadEMail", GETPOST('email'))."
\n"; } - $birthday = dol_mktime(GETPOST("birthhour", 'int'), GETPOST("birthmin", 'int'), GETPOST("birthsec", 'int'), GETPOST("birthmonth", 'int'), GETPOST("birthday", 'int'), GETPOST("birthyear", 'int')); - if (GETPOSTISSET("birthmonth") && empty($birthday)) { + $birthday = dol_mktime(GETPOST("birthhour", 'int'), GETPOST('birthmin', 'int'), GETPOST('birthsec', 'int'), GETPOST('birthmonth', 'int'), GETPOST('birthday', 'int'), GETPOST('birthyear', 'int')); + if GETPOSTISSET('birthmonth') && empty($birthday)) { $error++; $langs->load("errors"); $errmsg .= $langs->trans("ErrorBadDateFormat")."
\n"; @@ -240,36 +240,32 @@ if (empty($reshook) && $action == 'add') { } } - if (GETPOSTISSET('public')) { - $public = 1; - } else { - $public = 0; - } + $public = GETPOSTISSET('public') ? 1 : 0; if (!$error) { // email a peu pres correct et le login n'existe pas $adh = new Adherent($db); $adh->statut = -1; $adh->public = $public; - $adh->firstname = GETPOST("firstname"); - $adh->lastname = GETPOST("lastname"); - $adh->gender = GETPOST("gender"); - $adh->civility_id = GETPOST("civility_id"); - $adh->societe = GETPOST("societe"); - $adh->address = GETPOST("address"); - $adh->zip = GETPOST("zipcode"); - $adh->town = GETPOST("town"); - $adh->email = GETPOST("email"); + $adh->firstname = GETPOST('firstname'); + $adh->lastname = GETPOST('lastname'); + $adh->gender = GETPOST('gender'); + $adh->civility_id = GETPOST('civility_id'); + $adh->societe = GETPOST('societe'); + $adh->address = GETPOST('address'); + $adh->zip = GETPOST('zipcode'); + $adh->town = GETPOST('town'); + $adh->email = GETPOST('email'); if (empty($conf->global->ADHERENT_LOGIN_NOT_REQUIRED)) { - $adh->login = GETPOST("login"); - $adh->pass = GETPOST("pass1"); + $adh->login = GETPOST('login'); + $adh->pass = GETPOST('pass1'); } - $adh->photo = GETPOST("photo"); - $adh->country_id = GETPOST("country_id", 'int'); - $adh->state_id = GETPOST("state_id", 'int'); - $adh->typeid = GETPOST("type", 'int'); - $adh->note_private = GETPOST("note_private"); - $adh->morphy = GETPOST("morphy"); + $adh->photo = GETPOST('photo'); + $adh->country_id = $conf->global->MEMBER_NEWFORM_FORCECOUNTRYCODE ? $conf->global->MEMBER_NEWFORM_FORCECOUNTRYCODE : GETPOST('country_id', 'int'); + $adh->state_id = GETPOST('state_id', 'int'); + $adh->typeid = $conf->global->MEMBER_NEWFORM_FORCETYPE ? $conf->global->MEMBER_NEWFORM_FORCETYPE : GETPOST('typeid', 'int'); + $adh->note_private = GETPOST('note_private'); + $adh->morphy = $conf->global->MEMBER_NEWFORM_FORCEMORPHY ? $conf->global->MEMBER_NEWFORM_FORCEMORPHY : GETPOST('morphy'); $adh->birth = $birthday; @@ -562,11 +558,11 @@ if (empty($conf->global->MEMBER_NEWFORM_FORCETYPE)) { $isempty = 0; } print ''.$langs->trans("Type").' *'; - print $form->selectarray("type", $adht->liste_array(), GETPOST('type') ?GETPOST('type') : $defaulttype, $isempty); + print $form->selectarray("typeid", $adht->liste_array(), GETPOST('typeid') ? GETPOST('typeid') : $defaulttype, $isempty); print ''."\n"; } else { $adht->fetch($conf->global->MEMBER_NEWFORM_FORCETYPE); - print ''; + print ''; } // Moral/Physic attribute $morphys["phy"] = $langs->trans("Physical"); @@ -628,8 +624,6 @@ if (empty($conf->global->SOCIETE_DISABLE_STATE)) { print ''.$langs->trans('State').''; if ($country_code) { print $formcompany->select_state(GETPOST("state_id"), $country_code); - } else { - print ''; } print ''; } @@ -650,7 +644,7 @@ print ''.$langs->trans("URLPhoto").''."\n"; // Other attributes -$tpl_context = 'public'; // define templae context to public +$tpl_context = 'public'; // define template context to public include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_add.tpl.php'; // Comments print ''; @@ -675,11 +669,11 @@ if (!empty($conf->global->MEMBER_NEWFORM_DOLIBARRTURNOVER)) { if (jQuery("#budget").val() > 0) { jQuery(".amount").val(jQuery("#budget").val()); } else { jQuery("#budget").val(\'\'); } }); - /*jQuery("#type").change(function() { - if (jQuery("#type").val()==1) { jQuery("#morphy").val(\'mor\'); } - if (jQuery("#type").val()==2) { jQuery("#morphy").val(\'phy\'); } - if (jQuery("#type").val()==3) { jQuery("#morphy").val(\'mor\'); } - if (jQuery("#type").val()==4) { jQuery("#morphy").val(\'mor\'); } + /*jQuery("#typeid").change(function() { + if (jQuery("#typeid").val()==1) { jQuery("#morphy").val(\'mor\'); } + if (jQuery("#typeid").val()==2) { jQuery("#morphy").val(\'phy\'); } + if (jQuery("#typeid").val()==3) { jQuery("#morphy").val(\'mor\'); } + if (jQuery("#typeid").val()==4) { jQuery("#morphy").val(\'mor\'); } initturnover(); });*/ function initturnover() { @@ -702,14 +696,18 @@ if (!empty($conf->global->MEMBER_NEWFORM_DOLIBARRTURNOVER)) { print ''."\n"; } if (!empty($conf->global->MEMBER_NEWFORM_AMOUNT) || !empty($conf->global->MEMBER_NEWFORM_PAYONLINE)) { + // $conf->global->MEMBER_NEWFORM_SHOWAMOUNT is an amount - $amount = 0; + + // Set amount for the subscription + $amount = isset($amount) ? $amount : 0; + if (!empty($conf->global->MEMBER_NEWFORM_AMOUNT)) { $amount = $conf->global->MEMBER_NEWFORM_AMOUNT; } if (!empty($conf->global->MEMBER_NEWFORM_PAYONLINE)) { - $amount = GETPOST('amount') ?GETPOST('amount') : $conf->global->MEMBER_NEWFORM_AMOUNT; + $amount = $amount ? $amount : (GETPOST('amount') ? GETPOST('amount') : $conf->global->MEMBER_NEWFORM_AMOUNT); } // $conf->global->MEMBER_NEWFORM_PAYONLINE is 'paypal', 'paybox' or 'stripe' print ''.$langs->trans("Subscription").''; From fcbea36605cc16f51715a9bb8036f2b4164d48d0 Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Sat, 17 Apr 2021 12:21:40 +0000 Subject: [PATCH 2/6] Fixing style errors. --- htdocs/public/members/new.php | 305 +++++++++++++++++----------------- 1 file changed, 152 insertions(+), 153 deletions(-) diff --git a/htdocs/public/members/new.php b/htdocs/public/members/new.php index 19fa23af080..0920e5976b1 100644 --- a/htdocs/public/members/new.php +++ b/htdocs/public/members/new.php @@ -221,12 +221,12 @@ if (empty($reshook) && $action == 'add') { if (!GETPOST('firstname') { $error++; $errmsg .= $langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Firstname"))."
\n"; - } - if (GETPOST('email') && !isValidEmail(GETPOST('email'))) { - $error++; - $langs->load("errors"); - $errmsg .= $langs->trans("ErrorBadEMail", GETPOST('email'))."
\n"; - } +} +if (GETPOST('email') && !isValidEmail(GETPOST('email'))) { + $error++; + $langs->load("errors"); + $errmsg .= $langs->trans("ErrorBadEMail", GETPOST('email'))."
\n"; +} $birthday = dol_mktime(GETPOST("birthhour", 'int'), GETPOST('birthmin', 'int'), GETPOST('birthsec', 'int'), GETPOST('birthmonth', 'int'), GETPOST('birthday', 'int'), GETPOST('birthyear', 'int')); if GETPOSTISSET('birthmonth') && empty($birthday)) { $error++; @@ -545,121 +545,121 @@ jQuery(document).ready(function () { '; -print ''."\n"; + print '
'."\n"; -// Type -if (empty($conf->global->MEMBER_NEWFORM_FORCETYPE)) { - $listoftype = $adht->liste_array(); - $tmp = array_keys($listoftype); - $defaulttype = ''; - $isempty = 1; - if (count($listoftype) == 1) { - $defaulttype = $tmp[0]; - $isempty = 0; + // Type + if (empty($conf->global->MEMBER_NEWFORM_FORCETYPE)) { + $listoftype = $adht->liste_array(); + $tmp = array_keys($listoftype); + $defaulttype = ''; + $isempty = 1; + if (count($listoftype) == 1) { + $defaulttype = $tmp[0]; + $isempty = 0; + } + print ''."\n"; + } else { + $adht->fetch($conf->global->MEMBER_NEWFORM_FORCETYPE); + print ''; } - print ''."\n"; -} else { - $adht->fetch($conf->global->MEMBER_NEWFORM_FORCETYPE); - print ''; -} -// Moral/Physic attribute -$morphys["phy"] = $langs->trans("Physical"); -$morphys["mor"] = $langs->trans("Moral"); -if (empty($conf->global->MEMBER_NEWFORM_FORCEMORPHY)) { - print ''."\n"; -} else { - print $morphys[$conf->global->MEMBER_NEWFORM_FORCEMORPHY]; - print ''; -} -// Civility -print ''."\n"; -// Lastname -print ''."\n"; -// Firstname -print ''."\n"; -// Gender -print ''; -print ''; -// Company -print ''."\n"; -// Address -print ''."\n"; -// Zip / Town -print ''; -// Country -print ''."\n"; + } else { + print $morphys[$conf->global->MEMBER_NEWFORM_FORCEMORPHY]; + print ''; + } + // Civility + print ''."\n"; + // Lastname + print ''."\n"; + // Firstname + print ''."\n"; + // Gender + print ''; + print ''; + // Company + print ''."\n"; + // Address + print ''."\n"; + // Zip / Town + print ''; + // Country + print ''; -// State -if (empty($conf->global->SOCIETE_DISABLE_STATE)) { - print ''; -} -// EMail -print ''."\n"; -// Login -if (empty($conf->global->ADHERENT_LOGIN_NOT_REQUIRED)) { - print ''."\n"; - print ''."\n"; - print ''."\n"; -} -// Birthday -print ''."\n"; -// Photo -print ''."\n"; -// Public -print ''."\n"; -// Other attributes -$tpl_context = 'public'; // define template context to public -include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_add.tpl.php'; -// Comments -print ''; -print ''; -print ''; -print ''."\n"; + // State + if (empty($conf->global->SOCIETE_DISABLE_STATE)) { + print ''; + } + // EMail + print ''."\n"; + // Login + if (empty($conf->global->ADHERENT_LOGIN_NOT_REQUIRED)) { + print ''."\n"; + print ''."\n"; + print ''."\n"; + } + // Birthday + print ''."\n"; + // Photo + print ''."\n"; + // Public + print ''."\n"; + // Other attributes + $tpl_context = 'public'; // define template context to public + include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_add.tpl.php'; + // Comments + print ''; + print ''; + print ''; + print ''."\n"; -// Add specific fields used by Dolibarr foundation for example -if (!empty($conf->global->MEMBER_NEWFORM_DOLIBARRTURNOVER)) { - $arraybudget = array('50'=>'<= 100 000', '100'=>'<= 200 000', '200'=>'<= 500 000', '300'=>'<= 1 500 000', '600'=>'<= 3 000 000', '1000'=>'<= 5 000 000', '2000'=>'5 000 000+'); - print ''."\n"; -} -if (!empty($conf->global->MEMBER_NEWFORM_AMOUNT) || !empty($conf->global->MEMBER_NEWFORM_PAYONLINE)) { - - // $conf->global->MEMBER_NEWFORM_SHOWAMOUNT is an amount - - // Set amount for the subscription - $amount = isset($amount) ? $amount : 0; - - if (!empty($conf->global->MEMBER_NEWFORM_AMOUNT)) { - $amount = $conf->global->MEMBER_NEWFORM_AMOUNT; + print ''."\n"; } + if (!empty($conf->global->MEMBER_NEWFORM_AMOUNT) || !empty($conf->global->MEMBER_NEWFORM_PAYONLINE)) { + // $conf->global->MEMBER_NEWFORM_SHOWAMOUNT is an amount - if (!empty($conf->global->MEMBER_NEWFORM_PAYONLINE)) { - $amount = $amount ? $amount : (GETPOST('amount') ? GETPOST('amount') : $conf->global->MEMBER_NEWFORM_AMOUNT); + // Set amount for the subscription + $amount = isset($amount) ? $amount : 0; + + if (!empty($conf->global->MEMBER_NEWFORM_AMOUNT)) { + $amount = $conf->global->MEMBER_NEWFORM_AMOUNT; + } + + if (!empty($conf->global->MEMBER_NEWFORM_PAYONLINE)) { + $amount = $amount ? $amount : (GETPOST('amount') ? GETPOST('amount') : $conf->global->MEMBER_NEWFORM_AMOUNT); + } + // $conf->global->MEMBER_NEWFORM_PAYONLINE is 'paypal', 'paybox' or 'stripe' + print ''; } - // $conf->global->MEMBER_NEWFORM_PAYONLINE is 'paypal', 'paybox' or 'stripe' - print '
'.$langs->trans("Type").' *'; + print $form->selectarray("typeid", $adht->liste_array(), GETPOST('typeid') ? GETPOST('typeid') : $defaulttype, $isempty); + print '
'.$langs->trans("Type").' *'; - print $form->selectarray("typeid", $adht->liste_array(), GETPOST('typeid') ? GETPOST('typeid') : $defaulttype, $isempty); - print '
'.$langs->trans('MemberNature').' *'."\n"; - print $form->selectarray("morphy", $morphys, GETPOST('morphy'), 1); - print '
'.$langs->trans('UserTitle').''; -print $formcompany->select_civility(GETPOST('civility_id'), 'civility_id').'
'.$langs->trans("Lastname").' *
'.$langs->trans("Firstname").' *
'.$langs->trans("Gender").''; -$arraygender = array('man'=>$langs->trans("Genderman"), 'woman'=>$langs->trans("Genderwoman")); -print $form->selectarray('gender', $arraygender, GETPOST('gender') ?GETPOST('gender') : $object->gender, 1); -print '
'.$langs->trans("Company").'
'.$langs->trans("Address").''."\n"; -print '
'.$langs->trans('Zip').' / '.$langs->trans('Town').''; -print $formcompany->select_ziptown(GETPOST('zipcode'), 'zipcode', array('town', 'selectcountry_id', 'state_id'), 6, 1); -print ' / '; -print $formcompany->select_ziptown(GETPOST('town'), 'town', array('zipcode', 'selectcountry_id', 'state_id'), 0, 1); -print '
'.$langs->trans('Country').''; -$country_id = GETPOST('country_id'); -if (!$country_id && !empty($conf->global->MEMBER_NEWFORM_FORCECOUNTRYCODE)) { - $country_id = getCountry($conf->global->MEMBER_NEWFORM_FORCECOUNTRYCODE, 2, $db, $langs); -} -if (!$country_id && !empty($conf->geoipmaxmind->enabled)) { - $country_code = dol_user_country(); - //print $country_code; - if ($country_code) { - $new_country_id = getCountry($country_code, 3, $db, $langs); - //print 'xxx'.$country_code.' - '.$new_country_id; - if ($new_country_id) { - $country_id = $new_country_id; + // Moral/Physic attribute + $morphys["phy"] = $langs->trans("Physical"); + $morphys["mor"] = $langs->trans("Moral"); + if (empty($conf->global->MEMBER_NEWFORM_FORCEMORPHY)) { + print '
'.$langs->trans('MemberNature').' *'."\n"; + print $form->selectarray("morphy", $morphys, GETPOST('morphy'), 1); + print '
'.$langs->trans('UserTitle').''; + print $formcompany->select_civility(GETPOST('civility_id'), 'civility_id').'
'.$langs->trans("Lastname").' *
'.$langs->trans("Firstname").' *
'.$langs->trans("Gender").''; + $arraygender = array('man'=>$langs->trans("Genderman"), 'woman'=>$langs->trans("Genderwoman")); + print $form->selectarray('gender', $arraygender, GETPOST('gender') ?GETPOST('gender') : $object->gender, 1); + print '
'.$langs->trans("Company").'
'.$langs->trans("Address").''."\n"; + print '
'.$langs->trans('Zip').' / '.$langs->trans('Town').''; + print $formcompany->select_ziptown(GETPOST('zipcode'), 'zipcode', array('town', 'selectcountry_id', 'state_id'), 6, 1); + print ' / '; + print $formcompany->select_ziptown(GETPOST('town'), 'town', array('zipcode', 'selectcountry_id', 'state_id'), 0, 1); + print '
'.$langs->trans('Country').''; + $country_id = GETPOST('country_id'); + if (!$country_id && !empty($conf->global->MEMBER_NEWFORM_FORCECOUNTRYCODE)) { + $country_id = getCountry($conf->global->MEMBER_NEWFORM_FORCECOUNTRYCODE, 2, $db, $langs); + } + if (!$country_id && !empty($conf->geoipmaxmind->enabled)) { + $country_code = dol_user_country(); + //print $country_code; + if ($country_code) { + $new_country_id = getCountry($country_code, 3, $db, $langs); + //print 'xxx'.$country_code.' - '.$new_country_id; + if ($new_country_id) { + $country_id = $new_country_id; + } } } -} -$country_code = getCountry($country_id, 2, $db, $langs); -print $form->select_country($country_id, 'country_id'); -print '
'.$langs->trans('State').''; - if ($country_code) { - print $formcompany->select_state(GETPOST("state_id"), $country_code); - } + $country_code = getCountry($country_id, 2, $db, $langs); + print $form->select_country($country_id, 'country_id'); print '
'.$langs->trans("Email").' *
'.$langs->trans("Login").' *
'.$langs->trans("Password").' *
'.$langs->trans("PasswordAgain").' *
'.$langs->trans("DateOfBirth").''; -print $form->selectDate($birthday, 'birth', 0, 0, 1, "newmember", 1, 0); -print '
'.$langs->trans("URLPhoto").'
'.$langs->trans("Public").'
'.$langs->trans("Comments").'
'.$langs->trans('State').''; + if ($country_code) { + print $formcompany->select_state(GETPOST("state_id"), $country_code); + } + print '
'.$langs->trans("Email").' *
'.$langs->trans("Login").' *
'.$langs->trans("Password").' *
'.$langs->trans("PasswordAgain").' *
'.$langs->trans("DateOfBirth").''; + print $form->selectDate($birthday, 'birth', 0, 0, 1, "newmember", 1, 0); + print '
'.$langs->trans("URLPhoto").'
'.$langs->trans("Public").'
'.$langs->trans("Comments").'
'.$langs->trans("TurnoverOrBudget").' *'; - print $form->selectarray('budget', $arraybudget, GETPOST('budget'), 1); - print ' € or $'; + // Add specific fields used by Dolibarr foundation for example + if (!empty($conf->global->MEMBER_NEWFORM_DOLIBARRTURNOVER)) { + $arraybudget = array('50'=>'<= 100 000', '100'=>'<= 200 000', '200'=>'<= 500 000', '300'=>'<= 1 500 000', '600'=>'<= 3 000 000', '1000'=>'<= 5 000 000', '2000'=>'5 000 000+'); + print '
'.$langs->trans("TurnoverOrBudget").' *'; + print $form->selectarray('budget', $arraybudget, GETPOST('budget'), 1); + print ' € or $'; - print ''; - print '
'.$langs->trans("Subscription").''; + if (!empty($conf->global->MEMBER_NEWFORM_EDITAMOUNT)) { + print ''; + } else { + print ''; + print ''; + } + print ' '.$langs->trans("Currency".$conf->currency); + print '
'.$langs->trans("Subscription").''; - if (!empty($conf->global->MEMBER_NEWFORM_EDITAMOUNT)) { - print ''; - } else { - print ''; - print ''; + print "
\n"; + + print dol_get_fiche_end(); + + // Save + print '
'; + print ''; + if (!empty($backtopage)) { + print '     '; } - print ' '.$langs->trans("Currency".$conf->currency); - print ''; -} -print "\n"; - -print dol_get_fiche_end(); - -// Save -print '
'; -print ''; -if (!empty($backtopage)) { - print '     '; -} -print '
'; + print '
'; -print "\n"; -print "
"; -print ''; + print "\n"; + print "
"; + print ''; -llxFooterVierge(); + llxFooterVierge(); -$db->close(); + $db->close(); From d6085fb68a1214dcfd116fe8bbf8bcb80dc0f99b Mon Sep 17 00:00:00 2001 From: daraelmin Date: Sat, 17 Apr 2021 14:29:02 +0200 Subject: [PATCH 3/6] Update new.php --- htdocs/public/members/new.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/public/members/new.php b/htdocs/public/members/new.php index 0920e5976b1..dcf64ed7634 100644 --- a/htdocs/public/members/new.php +++ b/htdocs/public/members/new.php @@ -218,7 +218,7 @@ if (empty($reshook) && $action == 'add') { $error++; $errmsg .= $langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Lastname"))."
\n"; } - if (!GETPOST('firstname') { + if (!GETPOST('firstname')) ä{ $error++; $errmsg .= $langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Firstname"))."
\n"; } From d23e74660912b0b712f249d6eadc8c5089ba2e08 Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Sat, 17 Apr 2021 12:29:23 +0000 Subject: [PATCH 4/6] Fixing style errors. --- htdocs/public/members/new.php | 172 +++++++++++++++++----------------- 1 file changed, 86 insertions(+), 86 deletions(-) diff --git a/htdocs/public/members/new.php b/htdocs/public/members/new.php index dcf64ed7634..13705796ad5 100644 --- a/htdocs/public/members/new.php +++ b/htdocs/public/members/new.php @@ -218,17 +218,17 @@ if (empty($reshook) && $action == 'add') { $error++; $errmsg .= $langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Lastname"))."
\n"; } - if (!GETPOST('firstname')) ä{ + if (!GETPOST('firstname')) { ä $error++; $errmsg .= $langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Firstname"))."
\n"; -} -if (GETPOST('email') && !isValidEmail(GETPOST('email'))) { - $error++; - $langs->load("errors"); - $errmsg .= $langs->trans("ErrorBadEMail", GETPOST('email'))."
\n"; -} + } + if (GETPOST('email') && !isValidEmail(GETPOST('email'))) { + $error++; + $langs->load("errors"); + $errmsg .= $langs->trans("ErrorBadEMail", GETPOST('email'))."
\n"; + } $birthday = dol_mktime(GETPOST("birthhour", 'int'), GETPOST('birthmin', 'int'), GETPOST('birthsec', 'int'), GETPOST('birthmonth', 'int'), GETPOST('birthday', 'int'), GETPOST('birthyear', 'int')); - if GETPOSTISSET('birthmonth') && empty($birthday)) { + if GETPOSTISSET('birthmonth') { && empty($birthday)) $error++; $langs->load("errors"); $errmsg .= $langs->trans("ErrorBadDateFormat")."
\n"; @@ -548,33 +548,33 @@ jQuery(document).ready(function () { print ''."\n"; // Type - if (empty($conf->global->MEMBER_NEWFORM_FORCETYPE)) { - $listoftype = $adht->liste_array(); - $tmp = array_keys($listoftype); - $defaulttype = ''; - $isempty = 1; - if (count($listoftype) == 1) { - $defaulttype = $tmp[0]; - $isempty = 0; - } - print ''."\n"; - } else { - $adht->fetch($conf->global->MEMBER_NEWFORM_FORCETYPE); - print ''; +if (empty($conf->global->MEMBER_NEWFORM_FORCETYPE)) { + $listoftype = $adht->liste_array(); + $tmp = array_keys($listoftype); + $defaulttype = ''; + $isempty = 1; + if (count($listoftype) == 1) { + $defaulttype = $tmp[0]; + $isempty = 0; } + print ''."\n"; +} else { + $adht->fetch($conf->global->MEMBER_NEWFORM_FORCETYPE); + print ''; +} // Moral/Physic attribute $morphys["phy"] = $langs->trans("Physical"); $morphys["mor"] = $langs->trans("Moral"); - if (empty($conf->global->MEMBER_NEWFORM_FORCEMORPHY)) { - print ''."\n"; - } else { - print $morphys[$conf->global->MEMBER_NEWFORM_FORCEMORPHY]; - print ''; - } +if (empty($conf->global->MEMBER_NEWFORM_FORCEMORPHY)) { + print ''."\n"; +} else { + print $morphys[$conf->global->MEMBER_NEWFORM_FORCEMORPHY]; + print ''; +} // Civility print ''."\n"; @@ -602,39 +602,39 @@ jQuery(document).ready(function () { // Country print ''; // State - if (empty($conf->global->SOCIETE_DISABLE_STATE)) { - print ''; +if (empty($conf->global->SOCIETE_DISABLE_STATE)) { + print ''; +} // EMail print ''."\n"; // Login - if (empty($conf->global->ADHERENT_LOGIN_NOT_REQUIRED)) { - print ''."\n"; - print ''."\n"; - print ''."\n"; - } +if (empty($conf->global->ADHERENT_LOGIN_NOT_REQUIRED)) { + print ''."\n"; + print ''."\n"; + print ''."\n"; +} // Birthday print ''."\n"; // Add specific fields used by Dolibarr foundation for example - if (!empty($conf->global->MEMBER_NEWFORM_DOLIBARRTURNOVER)) { - $arraybudget = array('50'=>'<= 100 000', '100'=>'<= 200 000', '200'=>'<= 500 000', '300'=>'<= 1 500 000', '600'=>'<= 3 000 000', '1000'=>'<= 5 000 000', '2000'=>'5 000 000+'); - print ''."\n"; + print ''."\n"; +} +if (!empty($conf->global->MEMBER_NEWFORM_AMOUNT) || !empty($conf->global->MEMBER_NEWFORM_PAYONLINE)) { + // $conf->global->MEMBER_NEWFORM_SHOWAMOUNT is an amount + + // Set amount for the subscription + $amount = isset($amount) ? $amount : 0; + + if (!empty($conf->global->MEMBER_NEWFORM_AMOUNT)) { + $amount = $conf->global->MEMBER_NEWFORM_AMOUNT; } - if (!empty($conf->global->MEMBER_NEWFORM_AMOUNT) || !empty($conf->global->MEMBER_NEWFORM_PAYONLINE)) { - // $conf->global->MEMBER_NEWFORM_SHOWAMOUNT is an amount - // Set amount for the subscription - $amount = isset($amount) ? $amount : 0; - - if (!empty($conf->global->MEMBER_NEWFORM_AMOUNT)) { - $amount = $conf->global->MEMBER_NEWFORM_AMOUNT; - } - - if (!empty($conf->global->MEMBER_NEWFORM_PAYONLINE)) { - $amount = $amount ? $amount : (GETPOST('amount') ? GETPOST('amount') : $conf->global->MEMBER_NEWFORM_AMOUNT); - } - // $conf->global->MEMBER_NEWFORM_PAYONLINE is 'paypal', 'paybox' or 'stripe' - print ''; + if (!empty($conf->global->MEMBER_NEWFORM_PAYONLINE)) { + $amount = $amount ? $amount : (GETPOST('amount') ? GETPOST('amount') : $conf->global->MEMBER_NEWFORM_AMOUNT); } + // $conf->global->MEMBER_NEWFORM_PAYONLINE is 'paypal', 'paybox' or 'stripe' + print ''; +} print "
'.$langs->trans("Type").' *'; - print $form->selectarray("typeid", $adht->liste_array(), GETPOST('typeid') ? GETPOST('typeid') : $defaulttype, $isempty); - print '
'.$langs->trans("Type").' *'; + print $form->selectarray("typeid", $adht->liste_array(), GETPOST('typeid') ? GETPOST('typeid') : $defaulttype, $isempty); + print '
'.$langs->trans('MemberNature').' *'."\n"; - print $form->selectarray("morphy", $morphys, GETPOST('morphy'), 1); - print '
'.$langs->trans('MemberNature').' *'."\n"; + print $form->selectarray("morphy", $morphys, GETPOST('morphy'), 1); + print '
'.$langs->trans('UserTitle').''; print $formcompany->select_civility(GETPOST('civility_id'), 'civility_id').'
'.$langs->trans('Country').''; $country_id = GETPOST('country_id'); - if (!$country_id && !empty($conf->global->MEMBER_NEWFORM_FORCECOUNTRYCODE)) { - $country_id = getCountry($conf->global->MEMBER_NEWFORM_FORCECOUNTRYCODE, 2, $db, $langs); - } - if (!$country_id && !empty($conf->geoipmaxmind->enabled)) { - $country_code = dol_user_country(); - //print $country_code; - if ($country_code) { - $new_country_id = getCountry($country_code, 3, $db, $langs); - //print 'xxx'.$country_code.' - '.$new_country_id; - if ($new_country_id) { - $country_id = $new_country_id; - } +if (!$country_id && !empty($conf->global->MEMBER_NEWFORM_FORCECOUNTRYCODE)) { + $country_id = getCountry($conf->global->MEMBER_NEWFORM_FORCECOUNTRYCODE, 2, $db, $langs); +} +if (!$country_id && !empty($conf->geoipmaxmind->enabled)) { + $country_code = dol_user_country(); + //print $country_code; + if ($country_code) { + $new_country_id = getCountry($country_code, 3, $db, $langs); + //print 'xxx'.$country_code.' - '.$new_country_id; + if ($new_country_id) { + $country_id = $new_country_id; } } +} $country_code = getCountry($country_id, 2, $db, $langs); print $form->select_country($country_id, 'country_id'); print '
'.$langs->trans('State').''; - if ($country_code) { - print $formcompany->select_state(GETPOST("state_id"), $country_code); - } - print '
'.$langs->trans('State').''; + if ($country_code) { + print $formcompany->select_state(GETPOST("state_id"), $country_code); } + print '
'.$langs->trans("Email").' *
'.$langs->trans("Login").' *
'.$langs->trans("Password").' *
'.$langs->trans("PasswordAgain").' *
'.$langs->trans("Login").' *
'.$langs->trans("Password").' *
'.$langs->trans("PasswordAgain").' *
'.$langs->trans("DateOfBirth").''; print $form->selectDate($birthday, 'birth', 0, 0, 1, "newmember", 1, 0); @@ -653,13 +653,13 @@ jQuery(document).ready(function () { print '
'.$langs->trans("TurnoverOrBudget").' *'; - print $form->selectarray('budget', $arraybudget, GETPOST('budget'), 1); - print ' € or $'; +if (!empty($conf->global->MEMBER_NEWFORM_DOLIBARRTURNOVER)) { + $arraybudget = array('50'=>'<= 100 000', '100'=>'<= 200 000', '200'=>'<= 500 000', '300'=>'<= 1 500 000', '600'=>'<= 3 000 000', '1000'=>'<= 5 000 000', '2000'=>'5 000 000+'); + print '
'.$langs->trans("TurnoverOrBudget").' *'; + print $form->selectarray('budget', $arraybudget, GETPOST('budget'), 1); + print ' € or $'; - print ''; - print '
'.$langs->trans("Subscription").''; - if (!empty($conf->global->MEMBER_NEWFORM_EDITAMOUNT)) { - print ''; - } else { - print ''; - print ''; - } - print ' '.$langs->trans("Currency".$conf->currency); - print '
'.$langs->trans("Subscription").''; + if (!empty($conf->global->MEMBER_NEWFORM_EDITAMOUNT)) { + print ''; + } else { + print ''; + print ''; + } + print ' '.$langs->trans("Currency".$conf->currency); + print '
\n"; print dol_get_fiche_end(); @@ -726,9 +726,9 @@ jQuery(document).ready(function () { // Save print '
'; print ''; - if (!empty($backtopage)) { - print '     '; - } +if (!empty($backtopage)) { + print '     '; +} print '
'; From 16dfde112806d813c9c5718d2a63bb0756fa88fa Mon Sep 17 00:00:00 2001 From: daraelmin Date: Sat, 17 Apr 2021 14:39:14 +0200 Subject: [PATCH 5/6] Update new.php --- htdocs/public/members/new.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/public/members/new.php b/htdocs/public/members/new.php index 13705796ad5..fa9c844288f 100644 --- a/htdocs/public/members/new.php +++ b/htdocs/public/members/new.php @@ -218,7 +218,7 @@ if (empty($reshook) && $action == 'add') { $error++; $errmsg .= $langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Lastname"))."
\n"; } - if (!GETPOST('firstname')) { ä + if (!GETPOST('firstname')) { $error++; $errmsg .= $langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Firstname"))."
\n"; } From b96d3cebda23f09b1581a56ca17143ccf01df672 Mon Sep 17 00:00:00 2001 From: daraelmin Date: Sat, 17 Apr 2021 14:51:05 +0200 Subject: [PATCH 6/6] Update new.php --- htdocs/public/members/new.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/public/members/new.php b/htdocs/public/members/new.php index fa9c844288f..677e1e1b906 100644 --- a/htdocs/public/members/new.php +++ b/htdocs/public/members/new.php @@ -227,8 +227,8 @@ if (empty($reshook) && $action == 'add') { $langs->load("errors"); $errmsg .= $langs->trans("ErrorBadEMail", GETPOST('email'))."
\n"; } - $birthday = dol_mktime(GETPOST("birthhour", 'int'), GETPOST('birthmin', 'int'), GETPOST('birthsec', 'int'), GETPOST('birthmonth', 'int'), GETPOST('birthday', 'int'), GETPOST('birthyear', 'int')); - if GETPOSTISSET('birthmonth') { && empty($birthday)) + $birthday = dol_mktime(GETPOST('birthhour', 'int'), GETPOST('birthmin', 'int'), GETPOST('birthsec', 'int'), GETPOST('birthmonth', 'int'), GETPOST('birthday', 'int'), GETPOST('birthyear', 'int')); + if (GETPOSTISSET('birthmonth') && empty($birthday)) { $error++; $langs->load("errors"); $errmsg .= $langs->trans("ErrorBadDateFormat")."
\n";