diff --git a/htdocs/public/payment/newpayment.php b/htdocs/public/payment/newpayment.php
index 38732d3825f..b58a57fc706 100644
--- a/htdocs/public/payment/newpayment.php
+++ b/htdocs/public/payment/newpayment.php
@@ -762,6 +762,8 @@ if ($action == 'charge' && !empty($conf->stripe->enabled)) {
* View
*/
+$form = new Form($db);
+
$head = '';
if (!empty($conf->global->ONLINE_PAYMENT_CSS_URL)) {
$head = ''."\n";
@@ -1483,32 +1485,42 @@ if ($source == 'member' || $source == 'membersubscription') {
}
if ($member->type) {
- // Last member type
- print '
'.$langs->trans("LastMemberType");
- print '
'.dol_escape_htmltag($member->type);
- print "
\n";
+ $oldtypeid = $member->typeid;
+ $newtypeid = (int) (GETPOSTISSET("typeid") ? GETPOST("typeid", 'int') : $member->typeid);
- require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent_type.class.php';
- $adht = new AdherentType($db);
- // Amount by member type
- $amountbytype = $adht->amountByType(1);
- // Set the member type
- $member->typeid = (int) (GETPOSTISSET("typeid") ? GETPOST("typeid", 'int') : $member->typeid);
- // If we change the type of membership, we set also label of new type
- $member->type = dol_getIdFromCode($db, $member->typeid, 'adherent_type', 'rowid', 'libelle');
- // Set amount for the subscription
- $amount = (!empty($amountbytype[$member->typeid])) ? $amountbytype[$member->typeid] : $member->last_subscription_amount;
- // list member type
- if ( !$action) {
- $form = new Form($db); // so we can call method selectarray
- print '
'.$langs->trans("NewMemberType");
+ if ($oldtypeid != $newtypeid && !empty($conf->global->MEMBER_ALLOW_CHANGE_OF_TYPE)) {
+ require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent_type.class.php';
+ $adht = new AdherentType($db);
+ // Amount by member type
+ $amountbytype = $adht->amountByType(1);
+
+ // Last member type
+ print '
'.$langs->trans("LastMemberType");
+ print '
'.dol_escape_htmltag($member->type);
+ print "
\n";
+
+ // Set the new member type
+ $member->typeid = $newtypeid;
+ $member->type = dol_getIdFromCode($db, $newtypeid, 'adherent_type', 'rowid', 'libelle');
+
+ // list member type
+ if (!$action) {
+ // Set amount for the subscription
+ $amount = (!empty($amountbytype[$member->typeid])) ? $amountbytype[$member->typeid] : $member->last_subscription_amount;
+
+ print '