Clean code
This commit is contained in:
parent
2acfba25ee
commit
66d9964861
@ -543,14 +543,13 @@ class AdherentType extends CommonObject
|
||||
}
|
||||
|
||||
/**
|
||||
* Return list of amount by type id
|
||||
* Return the array of all amounts per membership type id
|
||||
*
|
||||
* @param int $status Filter on status of type
|
||||
* @return array List of types of members
|
||||
* @return array Array of membership type
|
||||
*/
|
||||
public function amountByType($status = null)
|
||||
{
|
||||
|
||||
global $conf, $langs;
|
||||
|
||||
$amountbytype = array();
|
||||
@ -578,6 +577,7 @@ class AdherentType extends CommonObject
|
||||
} else {
|
||||
print $this->db->error();
|
||||
}
|
||||
|
||||
return $amountbytype;
|
||||
}
|
||||
|
||||
|
||||
@ -730,21 +730,24 @@ if (!empty($conf->global->MEMBER_NEWFORM_DOLIBARRTURNOVER)) {
|
||||
print '</td></tr>'."\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 = 0;
|
||||
$typeid = $conf->global->MEMBER_NEWFORM_FORCETYPE ? $conf->global->MEMBER_NEWFORM_FORCETYPE : GETPOST('typeid', 'int');
|
||||
|
||||
// Set amount for the subscription
|
||||
$amountbytype = $adht->amountByType(1);
|
||||
$amount = !empty($amountbytype[GETPOST('typeid', 'int')]) ? $amountbytype[GETPOST('typeid', 'int')] : (isset($amount) ? $amount : 0);
|
||||
|
||||
if (!empty($conf->global->MEMBER_NEWFORM_AMOUNT)) {
|
||||
// Set amount for the subscription:
|
||||
// - First check the amount of the member type.
|
||||
$amountbytype = $adht->amountByType(1); // Load the array of amount per type
|
||||
$amount = empty($amountbytype[$typeid]) ? (isset($amount) ? $amount : 0) : $amountbytype[$typeid];
|
||||
// - If not found, take the default amount
|
||||
if (empty($amount) && !empty($conf->global->MEMBER_NEWFORM_AMOUNT)) {
|
||||
$amount = $conf->global->MEMBER_NEWFORM_AMOUNT;
|
||||
}
|
||||
|
||||
if (!empty($conf->global->MEMBER_NEWFORM_PAYONLINE)) {
|
||||
$amount = $amount ? $amount : (GETPOST('amount') ? price2num(GETPOST('amount', 'alpha'), 'MT', 2) : $conf->global->MEMBER_NEWFORM_AMOUNT);
|
||||
// - If not set, we accept ot have amount defined as parameter (for backward compatibility).
|
||||
if (empty($amount)) {
|
||||
$amount = (GETPOST('amount') ? price2num(GETPOST('amount', 'alpha'), 'MT', 2) : '');
|
||||
}
|
||||
|
||||
// Clean the amount
|
||||
$amount = price2num($amount);
|
||||
|
||||
// $conf->global->MEMBER_NEWFORM_PAYONLINE is 'paypal', 'paybox' or 'stripe'
|
||||
@ -758,6 +761,7 @@ if (!empty($conf->global->MEMBER_NEWFORM_AMOUNT) || !empty($conf->global->MEMBER
|
||||
print ' '.$langs->trans("Currency".$conf->currency);
|
||||
print '</td></tr>';
|
||||
}
|
||||
|
||||
print "</table>\n";
|
||||
|
||||
print dol_get_fiche_end();
|
||||
|
||||
Loading…
Reference in New Issue
Block a user