From 5a5fa1edbb8c214b54f6bcfd43dcf9a537a08a93 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 27 May 2021 11:57:17 +0200 Subject: [PATCH] Fix regression amount was always empty. --- htdocs/public/payment/newpayment.php | 60 +++++++++++++++++----------- htdocs/stripe/class/stripe.class.php | 2 +- 2 files changed, 37 insertions(+), 25 deletions(-) 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("NewSubscription"); - print ''; - print $form->selectarray("typeid", $adht->liste_array(1), $member->typeid, 0, 0, 0, 'onchange="window.location.replace(\''.$urlwithroot.'/public/payment/newpayment.php?source='.urlencode($source).'&ref='.urlencode($ref).'&amount='.urlencode($amount).'&typeid=\' + this.value + \'&securekey='.urlencode($SECUREKEY).'\');"', 0, 0, 0, '', '', 1); - print "\n"; - } elseif ($action == dopayment) { - 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 ''.$langs->trans("NewSubscription"); + print ''; + print $form->selectarray("typeid", $adht->liste_array(1), $member->typeid, 0, 0, 0, 'onchange="window.location.replace(\''.$urlwithroot.'/public/payment/newpayment.php?source='.urlencode($source).'&ref='.urlencode($ref).'&amount='.urlencode($amount).'&typeid=\' + this.value + \'&securekey='.urlencode($SECUREKEY).'\');"', 0, 0, 0, '', '', 1); + print "\n"; + } elseif ($action == dopayment) { + print ''.$langs->trans("NewMemberType"); + print ''.dol_escape_htmltag($member->type); + print ''; + print "\n"; + } + } else { + print ''.$langs->trans("MemberType"); print ''.dol_escape_htmltag($member->type); - print ''; print "\n"; } } diff --git a/htdocs/stripe/class/stripe.class.php b/htdocs/stripe/class/stripe.class.php index 7f325090b5e..5614b3c6138 100644 --- a/htdocs/stripe/class/stripe.class.php +++ b/htdocs/stripe/class/stripe.class.php @@ -514,7 +514,7 @@ class Stripe extends CommonObject if (!$resql) { $error++; $this->error = $this->db->lasterror(); - dol_syslog(get_class($this)."::PaymentIntent failed to insert paymentintent with id=".$paymentintent->id." into database."); + dol_syslog(get_class($this)."::PaymentIntent failed to insert paymentintent with id=".$paymentintent->id." into database.", LOG_ERR); } } } else {