NEW: Add free membership amounts at the membership type level
This commit is contained in:
parent
0fca79529a
commit
5998999f18
@ -94,6 +94,11 @@ class AdherentType extends CommonObject
|
|||||||
*/
|
*/
|
||||||
public $amount;
|
public $amount;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var int Amount can be choosen by the visitor during subscription (0 or 1)
|
||||||
|
*/
|
||||||
|
public $caneditamount;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var string Public note
|
* @var string Public note
|
||||||
* @deprecated
|
* @deprecated
|
||||||
@ -380,6 +385,7 @@ class AdherentType extends CommonObject
|
|||||||
$sql .= "morphy = '".$this->db->escape($this->morphy)."',";
|
$sql .= "morphy = '".$this->db->escape($this->morphy)."',";
|
||||||
$sql .= "subscription = '".$this->db->escape($this->subscription)."',";
|
$sql .= "subscription = '".$this->db->escape($this->subscription)."',";
|
||||||
$sql .= "amount = ".((empty($this->amount) && $this->amount == '') ? 'null' : ((float) $this->amount)).",";
|
$sql .= "amount = ".((empty($this->amount) && $this->amount == '') ? 'null' : ((float) $this->amount)).",";
|
||||||
|
$sql .= "caneditamount = '".$this->db->escape($this->caneditamount)."',";
|
||||||
$sql .= "duration = '".$this->db->escape($this->duration_value.$this->duration_unit)."',";
|
$sql .= "duration = '".$this->db->escape($this->duration_value.$this->duration_unit)."',";
|
||||||
$sql .= "note = '".$this->db->escape($this->note_public)."',";
|
$sql .= "note = '".$this->db->escape($this->note_public)."',";
|
||||||
$sql .= "vote = ".(integer) $this->db->escape($this->vote).",";
|
$sql .= "vote = ".(integer) $this->db->escape($this->vote).",";
|
||||||
@ -474,7 +480,7 @@ class AdherentType extends CommonObject
|
|||||||
{
|
{
|
||||||
global $langs, $conf;
|
global $langs, $conf;
|
||||||
|
|
||||||
$sql = "SELECT d.rowid, d.libelle as label, d.morphy, d.statut as status, d.duration, d.subscription, d.amount, d.mail_valid, d.note as note_public, d.vote";
|
$sql = "SELECT d.rowid, d.libelle as label, d.morphy, d.statut as status, d.duration, d.subscription, d.amount, d.caneditamount, d.mail_valid, d.note as note_public, d.vote";
|
||||||
$sql .= " FROM ".MAIN_DB_PREFIX."adherent_type as d";
|
$sql .= " FROM ".MAIN_DB_PREFIX."adherent_type as d";
|
||||||
$sql .= " WHERE d.rowid = ".(int) $rowid;
|
$sql .= " WHERE d.rowid = ".(int) $rowid;
|
||||||
|
|
||||||
@ -495,6 +501,7 @@ class AdherentType extends CommonObject
|
|||||||
$this->duration_unit = substr($obj->duration, -1);
|
$this->duration_unit = substr($obj->duration, -1);
|
||||||
$this->subscription = $obj->subscription;
|
$this->subscription = $obj->subscription;
|
||||||
$this->amount = $obj->amount;
|
$this->amount = $obj->amount;
|
||||||
|
$this->caneditamount = $obj->caneditamount;
|
||||||
$this->mail_valid = $obj->mail_valid;
|
$this->mail_valid = $obj->mail_valid;
|
||||||
$this->note = $obj->note_public; // deprecated
|
$this->note = $obj->note_public; // deprecated
|
||||||
$this->note_public = $obj->note_public;
|
$this->note_public = $obj->note_public;
|
||||||
@ -850,6 +857,7 @@ class AdherentType extends CommonObject
|
|||||||
$this->note_public = 'This is a public note';
|
$this->note_public = 'This is a public note';
|
||||||
$this->mail_valid = 'This is welcome email';
|
$this->mail_valid = 'This is welcome email';
|
||||||
$this->subscription = 1;
|
$this->subscription = 1;
|
||||||
|
$this->caneditamount = 0;
|
||||||
$this->vote = 0;
|
$this->vote = 0;
|
||||||
|
|
||||||
$this->status = 1;
|
$this->status = 1;
|
||||||
|
|||||||
@ -122,6 +122,7 @@ if ($action == 'add' && $user->rights->adherent->configurer) {
|
|||||||
$object->status = (int) $status;
|
$object->status = (int) $status;
|
||||||
$object->subscription = (int) $subscription;
|
$object->subscription = (int) $subscription;
|
||||||
$object->amount = ($amount == '' ? '' : price2num($amount, 'MT'));
|
$object->amount = ($amount == '' ? '' : price2num($amount, 'MT'));
|
||||||
|
$object->caneditamount = (int) GETPOST("caneditamount", 'int');
|
||||||
$object->duration_value = $duration_value;
|
$object->duration_value = $duration_value;
|
||||||
$object->duration_unit = $duration_unit;
|
$object->duration_unit = $duration_unit;
|
||||||
$object->note = trim($comment);
|
$object->note = trim($comment);
|
||||||
@ -229,7 +230,7 @@ llxHeader('', $langs->trans("MembersTypeSetup"), $help_url);
|
|||||||
if (!$rowid && $action != 'create' && $action != 'edit') {
|
if (!$rowid && $action != 'create' && $action != 'edit') {
|
||||||
//print dol_get_fiche_head('');
|
//print dol_get_fiche_head('');
|
||||||
|
|
||||||
$sql = "SELECT d.rowid, d.libelle as label, d.subscription, d.amount, d.vote, d.statut as status, d.morphy";
|
$sql = "SELECT d.rowid, d.libelle as label, d.subscription, d.amount, d.caneditamount, d.vote, d.statut as status, d.morphy";
|
||||||
$sql .= " FROM ".MAIN_DB_PREFIX."adherent_type as d";
|
$sql .= " FROM ".MAIN_DB_PREFIX."adherent_type as d";
|
||||||
$sql .= " WHERE d.entity IN (".getEntity('member_type').")";
|
$sql .= " WHERE d.entity IN (".getEntity('member_type').")";
|
||||||
|
|
||||||
@ -276,6 +277,7 @@ if (!$rowid && $action != 'create' && $action != 'edit') {
|
|||||||
print '<th class="center">'.$langs->trans("MembersNature").'</th>';
|
print '<th class="center">'.$langs->trans("MembersNature").'</th>';
|
||||||
print '<th class="center">'.$langs->trans("SubscriptionRequired").'</th>';
|
print '<th class="center">'.$langs->trans("SubscriptionRequired").'</th>';
|
||||||
print '<th class="center">'.$langs->trans("Amount").'</th>';
|
print '<th class="center">'.$langs->trans("Amount").'</th>';
|
||||||
|
print '<th class="center">'.$langs->trans("CanEditAmountShort").'</th>';
|
||||||
print '<th class="center">'.$langs->trans("VoteAllowed").'</th>';
|
print '<th class="center">'.$langs->trans("VoteAllowed").'</th>';
|
||||||
print '<th class="center">'.$langs->trans("Status").'</th>';
|
print '<th class="center">'.$langs->trans("Status").'</th>';
|
||||||
print '<th> </th>';
|
print '<th> </th>';
|
||||||
@ -292,6 +294,7 @@ if (!$rowid && $action != 'create' && $action != 'edit') {
|
|||||||
$membertype->status = $objp->status;
|
$membertype->status = $objp->status;
|
||||||
$membertype->subscription = $objp->subscription;
|
$membertype->subscription = $objp->subscription;
|
||||||
$membertype->amount = $objp->amount;
|
$membertype->amount = $objp->amount;
|
||||||
|
$membertype->caneditamount = $objp->caneditamount;
|
||||||
|
|
||||||
print '<tr class="oddeven">';
|
print '<tr class="oddeven">';
|
||||||
print '<td class="nowraponall">';
|
print '<td class="nowraponall">';
|
||||||
@ -310,6 +313,7 @@ if (!$rowid && $action != 'create' && $action != 'edit') {
|
|||||||
print '</td>';
|
print '</td>';
|
||||||
print '<td class="center">'.yn($objp->subscription).'</td>';
|
print '<td class="center">'.yn($objp->subscription).'</td>';
|
||||||
print '<td class="center"><span class="amount">'.(is_null($objp->amount) || $objp->amount === '' ? '' : price($objp->amount)).'</span></td>';
|
print '<td class="center"><span class="amount">'.(is_null($objp->amount) || $objp->amount === '' ? '' : price($objp->amount)).'</span></td>';
|
||||||
|
print '<td class="center">'.yn($objp->caneditamount).'</td>';
|
||||||
print '<td class="center">'.yn($objp->vote).'</td>';
|
print '<td class="center">'.yn($objp->vote).'</td>';
|
||||||
print '<td class="center">'.$membertype->getLibStatut(5).'</td>';
|
print '<td class="center">'.$membertype->getLibStatut(5).'</td>';
|
||||||
if ($user->rights->adherent->configurer) {
|
if ($user->rights->adherent->configurer) {
|
||||||
@ -380,6 +384,10 @@ if ($action == 'create') {
|
|||||||
print '<input name="amount" size="5" value="'.(GETPOSTISSET('amount') ? GETPOST('amount') : price($amount)).'">';
|
print '<input name="amount" size="5" value="'.(GETPOSTISSET('amount') ? GETPOST('amount') : price($amount)).'">';
|
||||||
print '</td></tr>';
|
print '</td></tr>';
|
||||||
|
|
||||||
|
print '<tr><td>'.$langs->trans("CanEditAmountShort").'</td><td>';
|
||||||
|
print $form->selectyesno("caneditamount", 0, 1);
|
||||||
|
print '</td></tr>';
|
||||||
|
|
||||||
print '<tr><td>'.$langs->trans("VoteAllowed").'</td><td>';
|
print '<tr><td>'.$langs->trans("VoteAllowed").'</td><td>';
|
||||||
print $form->selectyesno("vote", GETPOSTISSET("vote") ? GETPOST('vote', 'aZ09') : 1, 1);
|
print $form->selectyesno("vote", GETPOSTISSET("vote") ? GETPOST('vote', 'aZ09') : 1, 1);
|
||||||
print '</td></tr>';
|
print '</td></tr>';
|
||||||
|
|||||||
@ -318,7 +318,9 @@ function getOnlinePaymentUrl($mode, $type, $ref = '', $amount = '9.99', $freetag
|
|||||||
}
|
}
|
||||||
} elseif ($type == 'member' || $type == 'membersubscription') {
|
} elseif ($type == 'member' || $type == 'membersubscription') {
|
||||||
$newtype = 'member';
|
$newtype = 'member';
|
||||||
$out = $urltouse.'/public/payment/newpayment.php?source=member&ref='.($mode ? '<span style="color: #666666">' : '');
|
$out = $urltouse.'/public/payment/newpayment.php?source=member';
|
||||||
|
$out .= '&amount='.$amount;
|
||||||
|
$out .= '&ref='.($mode ? '<span style="color: #666666">' : '');
|
||||||
if ($mode == 1) {
|
if ($mode == 1) {
|
||||||
$out .= 'member_ref';
|
$out .= 'member_ref';
|
||||||
}
|
}
|
||||||
|
|||||||
@ -648,4 +648,5 @@ ALTER TABLE llx_paiement MODIFY COLUMN ext_payment_id varchar(255);
|
|||||||
ALTER TABLE llx_payment_donation MODIFY COLUMN ext_payment_id varchar(255);
|
ALTER TABLE llx_payment_donation MODIFY COLUMN ext_payment_id varchar(255);
|
||||||
ALTER TABLE llx_prelevement_facture_demande MODIFY COLUMN ext_payment_id varchar(255);
|
ALTER TABLE llx_prelevement_facture_demande MODIFY COLUMN ext_payment_id varchar(255);
|
||||||
|
|
||||||
|
-- Allow users to make subscriptions of any amount during membership subscription
|
||||||
|
ALTER TABLE llx_adherent_type ADD COLUMN caneditamount varchar(3) DEFAULT 0 AFTER amount;
|
||||||
|
|||||||
@ -71,6 +71,9 @@ MemberTypeCanNotBeDeleted=Member type can not be deleted
|
|||||||
NewSubscription=New contribution
|
NewSubscription=New contribution
|
||||||
NewSubscriptionDesc=This form allows you to record your subscription as a new member of the foundation. If you want to renew your subscription (if already a member), please contact foundation board instead by email %s.
|
NewSubscriptionDesc=This form allows you to record your subscription as a new member of the foundation. If you want to renew your subscription (if already a member), please contact foundation board instead by email %s.
|
||||||
Subscription=Contribution
|
Subscription=Contribution
|
||||||
|
AnyAmountWithAdvisedAmount=Any amount with a recommended amount of %s %s
|
||||||
|
AnyAmountWithoutAdvisedAmount=Any amount
|
||||||
|
CanEditAmountShort=Any amount
|
||||||
Subscriptions=Contributions
|
Subscriptions=Contributions
|
||||||
SubscriptionLate=Late
|
SubscriptionLate=Late
|
||||||
SubscriptionNotReceived=Contribution never received
|
SubscriptionNotReceived=Contribution never received
|
||||||
|
|||||||
@ -199,6 +199,9 @@ AmountOfSubscriptions=Montant des cotisations
|
|||||||
TurnoverOrBudget=Chiffre affaire (pour société) ou Budget (asso ou collectivité)
|
TurnoverOrBudget=Chiffre affaire (pour société) ou Budget (asso ou collectivité)
|
||||||
DefaultAmount=Montant par défaut de la cotisation
|
DefaultAmount=Montant par défaut de la cotisation
|
||||||
CanEditAmount=Le visiteur peut modifier / choisir le montant de sa cotisation
|
CanEditAmount=Le visiteur peut modifier / choisir le montant de sa cotisation
|
||||||
|
AnyAmountWithAdvisedAmount=Montant libre avec un montant recommandé de %s %s
|
||||||
|
AnyAmountWithoutAdvisedAmount=Montant libre
|
||||||
|
CanEditAmountShort=Montant libre
|
||||||
MEMBER_NEWFORM_PAYONLINE=Rediriger sur la page intégrée de paiement en ligne
|
MEMBER_NEWFORM_PAYONLINE=Rediriger sur la page intégrée de paiement en ligne
|
||||||
ByProperties=Par nature
|
ByProperties=Par nature
|
||||||
MembersStatisticsByProperties=Statistiques des adhérents par nature
|
MembersStatisticsByProperties=Statistiques des adhérents par nature
|
||||||
|
|||||||
@ -692,16 +692,31 @@ if (!empty($conf->global->MEMBER_NEWFORM_PAYONLINE)) {
|
|||||||
|
|
||||||
// Clean the amount
|
// Clean the amount
|
||||||
$amount = price2num($amount);
|
$amount = price2num($amount);
|
||||||
|
$adht = new AdherentType($db);
|
||||||
|
$adht->fetch($typeid);
|
||||||
|
$caneditamount = $adht->caneditamount;
|
||||||
|
$showedamount = $amount>0? $amount: 0;
|
||||||
// $conf->global->MEMBER_NEWFORM_PAYONLINE is 'paypal', 'paybox' or 'stripe'
|
// $conf->global->MEMBER_NEWFORM_PAYONLINE is 'paypal', 'paybox' or 'stripe'
|
||||||
print '<tr><td>'.$langs->trans("Subscription").'</td><td class="nowrap">';
|
print '<tr><td>'.$langs->trans("Subscription");
|
||||||
if (!empty($conf->global->MEMBER_NEWFORM_EDITAMOUNT)) {
|
if (!empty($conf->global->MEMBER_EXT_URL_SUBSCRIPTION_INFO)) {
|
||||||
print '<input type="text" name="amount" id="amount" class="flat amount width50" value="'.$amount.'">';
|
print ' - <a href="'.$conf->global->MEMBER_EXT_URL_SUBSCRIPTION_INFO.'" rel="external" target="_blank" rel="noopener noreferrer">'.$langs->trans("SeeHere").'</a>';
|
||||||
} else {
|
}
|
||||||
print '<input type="text" name="amount" id="amounthidden" class="flat amount width50" disabled value="'.$amount.'">';
|
print '</td><td class="nowrap">';
|
||||||
print '<input type="hidden" name="amount" id="amount" class="flat amount" value="'.$amount.'">';
|
|
||||||
|
if (empty($amount) && !empty($conf->global->MEMBER_NEWFORM_AMOUNT)) {
|
||||||
|
$amount = $conf->global->MEMBER_NEWFORM_AMOUNT;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!empty($conf->global->MEMBER_NEWFORM_EDITAMOUNT) || $caneditamount) {
|
||||||
|
print '<input type="text" name="amount" id="amount" class="flat amount width50" value="'.$showedamount.'">';
|
||||||
|
print ' '.$langs->trans("Currency".$conf->currency).'<span class="opacitymedium"> – ';
|
||||||
|
print $amount>0? $langs->trans("AnyAmountWithAdvisedAmount", $amount, $langs->trans("Currency".$conf->currency)): $langs->trans("AnyAmountWithoutAdvisedAmount");
|
||||||
|
print '</span>';
|
||||||
|
} else {
|
||||||
|
print '<input type="hidden" name="amount" id="amount" class="flat amount" value="'.$showedamount.'">';
|
||||||
|
print '<input type="text" name="amount" id="amounthidden" class="flat amount width50" disabled value="'.$showedamount.'">';
|
||||||
|
print ' '.$langs->trans("Currency".$conf->currency);
|
||||||
}
|
}
|
||||||
print ' '.$langs->trans("Currency".$conf->currency);
|
|
||||||
print '</td></tr>';
|
print '</td></tr>';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user