Merge pull request #21412 from ymollard/membership-rework

Membership rework
This commit is contained in:
Laurent Destailleur 2022-07-11 12:13:34 +02:00 committed by GitHub
commit 5ba446f736
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
14 changed files with 424 additions and 302 deletions

View File

@ -677,7 +677,8 @@ if (empty($reshook)) {
if (empty($labeltouse) || (int) $labeltouse === -1) { if (empty($labeltouse) || (int) $labeltouse === -1) {
//fallback on the old configuration. //fallback on the old configuration.
setEventMessages('WarningMandatorySetupNotComplete', null, 'errors'); $langs->load("errors");
setEventMessages('<a href="'.DOL_URL_ROOT.'/adherents/admin/member_emails.php">'.$langs->trans('WarningMandatorySetupNotComplete').'</a>', null, 'errors');
$error++; $error++;
} else { } else {
$substitutionarray = getCommonSubstitutionArray($outputlangs, 0, null, $object); $substitutionarray = getCommonSubstitutionArray($outputlangs, 0, null, $object);
@ -2028,9 +2029,14 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) {
if ($useonlinepayment) { if ($useonlinepayment) {
print '<br>'; print '<br>';
if (empty($amount)) { // Take the maximum amount among what the member is supposed to pay / has paid in the past
$amount = price(max($adht->amount, $object->first_subscription_amount, $object->last_subscription_amount));
}
if (empty($amount)) {
$amount = 0;
}
require_once DOL_DOCUMENT_ROOT.'/core/lib/payments.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/payments.lib.php';
print showOnlinePaymentUrl('membersubscription', $object->ref); print showOnlinePaymentUrl('membersubscription', $object->ref, $amount);
} }
print '</div><div class="fichehalfright">'; print '</div><div class="fichehalfright">';

View File

@ -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 = ".((int) $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;

View File

@ -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 = GETPOSTINT("caneditamount");
$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>&nbsp;</th>'; print '<th>&nbsp;</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>';

View File

@ -173,9 +173,10 @@ function getValidOnlinePaymentMethods($paymentmethod = '')
* *
* @param string $type Type of URL ('free', 'order', 'invoice', 'contractline', 'member' ...) * @param string $type Type of URL ('free', 'order', 'invoice', 'contractline', 'member' ...)
* @param string $ref Ref of object * @param string $ref Ref of object
* @param int $amount Amount of money to request for
* @return string Url string * @return string Url string
*/ */
function showOnlinePaymentUrl($type, $ref) function showOnlinePaymentUrl($type, $ref, $amount = '9.99')
{ {
global $langs; global $langs;
@ -185,7 +186,7 @@ function showOnlinePaymentUrl($type, $ref)
$servicename = ''; // Link is a generic link for all payments services (paypal, stripe, ...) $servicename = ''; // Link is a generic link for all payments services (paypal, stripe, ...)
$out = img_picto('', 'globe').' <span class="opacitymedium">'.$langs->trans("ToOfferALinkForOnlinePayment", $servicename).'</span><br>'; $out = img_picto('', 'globe').' <span class="opacitymedium">'.$langs->trans("ToOfferALinkForOnlinePayment", $servicename).'</span><br>';
$url = getOnlinePaymentUrl(0, $type, $ref); $url = getOnlinePaymentUrl(0, $type, $ref, $amount);
$out .= '<div class="urllink"><input type="text" id="onlinepaymenturl" class="quatrevingtpercentminusx" value="'.$url.'">'; $out .= '<div class="urllink"><input type="text" id="onlinepaymenturl" class="quatrevingtpercentminusx" value="'.$url.'">';
$out .= '<a class="" href="'.$url.'" target="_blank" rel="noopener noreferrer">'.img_picto('', 'globe', 'class="paddingleft"').'</a>'; $out .= '<a class="" href="'.$url.'" target="_blank" rel="noopener noreferrer">'.img_picto('', 'globe', 'class="paddingleft"').'</a>';
$out .= '</div>'; $out .= '</div>';
@ -199,11 +200,12 @@ function showOnlinePaymentUrl($type, $ref)
* @param string $type Type of URL ('free', 'order', 'invoice', 'contractline', 'member' ...) * @param string $type Type of URL ('free', 'order', 'invoice', 'contractline', 'member' ...)
* @param string $ref Ref of object * @param string $ref Ref of object
* @param string $label Text or HTML tag to display, if empty it display the URL * @param string $label Text or HTML tag to display, if empty it display the URL
* @param int $amount Amount of money to request for
* @return string Url string * @return string Url string
*/ */
function getHtmlOnlinePaymentLink($type, $ref, $label = '') function getHtmlOnlinePaymentLink($type, $ref, $label = '', $amount = '9.99')
{ {
$url = getOnlinePaymentUrl(0, $type, $ref); $url = getOnlinePaymentUrl(0, $type, $ref, $amount);
$label = $label ? $label : $url; $label = $label ? $label : $url;
return '<a href="'.$url.'" target="_blank" rel="noopener noreferrer">'.$label.'</a>'; return '<a href="'.$url.'" target="_blank" rel="noopener noreferrer">'.$label.'</a>';
} }
@ -215,7 +217,7 @@ function getHtmlOnlinePaymentLink($type, $ref, $label = '')
* @param int $mode 0=True url, 1=Url formated with colors * @param int $mode 0=True url, 1=Url formated with colors
* @param string $type Type of URL ('free', 'order', 'invoice', 'contractline', 'member', 'boothlocation', ...) * @param string $type Type of URL ('free', 'order', 'invoice', 'contractline', 'member', 'boothlocation', ...)
* @param string $ref Ref of object * @param string $ref Ref of object
* @param int $amount Amount (required and used for $type='free' only) * @param int $amount Amount of money to request for
* @param string $freetag Free tag (required and used for $type='free' only) * @param string $freetag Free tag (required and used for $type='free' only)
* @param string $localorexternal 0=Url for browser, 1=Url for external access * @param string $localorexternal 0=Url for browser, 1=Url for external access
* @return string Url string * @return string Url string
@ -318,7 +320,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';
} }

View File

@ -798,6 +798,18 @@ class InterfaceActionsAuto extends DolibarrTriggers
$object->actionmsg .= "\n".$langs->transnoentities("Member").': '.$object->getFullName($langs); $object->actionmsg .= "\n".$langs->transnoentities("Member").': '.$object->getFullName($langs);
$object->actionmsg .= "\n".$langs->transnoentities("Type").': '.$object->type; $object->actionmsg .= "\n".$langs->transnoentities("Type").': '.$object->type;
$object->sendtoid = 0;
} elseif ($action == 'MEMBER_EXCLUDE') {
// Load translation files required by the page
$langs->loadLangs(array("agenda", "other", "members"));
if (empty($object->actionmsg2)) {
$object->actionmsg2 = $langs->transnoentities("MemberExcludedInDolibarr", $object->getFullName($langs));
}
$object->actionmsg = $langs->transnoentities("MemberExcludedInDolibarr", $object->getFullName($langs));
$object->actionmsg .= "\n".$langs->transnoentities("Member").': '.$object->getFullName($langs);
$object->actionmsg .= "\n".$langs->transnoentities("Type").': '.$object->type;
$object->sendtoid = 0; $object->sendtoid = 0;
} elseif ($action == 'PROJECT_CREATE') { } elseif ($action == 'PROJECT_CREATE') {
// Projects // Projects

View File

@ -32,7 +32,6 @@
-- -- VPGSQL8.2 SELECT dol_util_rebuild_sequences(); -- -- VPGSQL8.2 SELECT dol_util_rebuild_sequences();
-- Missing in v16 or lower -- Missing in v16 or lower
ALTER TABLE llx_c_action_trigger MODIFY elementtype VARCHAR(64); ALTER TABLE llx_c_action_trigger MODIFY elementtype VARCHAR(64);
@ -54,5 +53,5 @@ ALTER TABLE llx_facture ADD COLUMN close_missing_amount double(24, 8) after clos
ALTER TABLE llx_facture_fourn ADD COLUMN close_missing_amount double(24, 8) after close_code; ALTER TABLE llx_facture_fourn ADD COLUMN close_missing_amount double(24, 8) after close_code;
-- Allow users to make subscriptions of any amount during membership subscription
ALTER TABLE llx_adherent_type ADD COLUMN caneditamount integer DEFAULT 0 AFTER amount;

View File

@ -57,6 +57,7 @@ MemberValidatedInDolibarr=Member %s validated
MemberModifiedInDolibarr=Member %s modified MemberModifiedInDolibarr=Member %s modified
MemberResiliatedInDolibarr=Member %s terminated MemberResiliatedInDolibarr=Member %s terminated
MemberDeletedInDolibarr=Member %s deleted MemberDeletedInDolibarr=Member %s deleted
MemberExcludedInDolibarr=Member %s excluded
MemberSubscriptionAddedInDolibarr=Subscription %s for member %s added MemberSubscriptionAddedInDolibarr=Subscription %s for member %s added
MemberSubscriptionModifiedInDolibarr=Subscription %s for member %s modified MemberSubscriptionModifiedInDolibarr=Subscription %s for member %s modified
MemberSubscriptionDeletedInDolibarr=Subscription %s for member %s deleted MemberSubscriptionDeletedInDolibarr=Subscription %s for member %s deleted

View File

@ -27,6 +27,7 @@ ErrorDatabaseVersionTooLow=Database version (%s) too old. Version %s or higher i
ErrorPHPVersionTooLow=PHP version too old. Version %s is required. ErrorPHPVersionTooLow=PHP version too old. Version %s is required.
ErrorConnectedButDatabaseNotFound=Connection to server successful but database '%s' not found. ErrorConnectedButDatabaseNotFound=Connection to server successful but database '%s' not found.
ErrorDatabaseAlreadyExists=Database '%s' already exists. ErrorDatabaseAlreadyExists=Database '%s' already exists.
ErrorNoMigrationFilesFoundForParameters=No migration file found for the selected versions
IfDatabaseNotExistsGoBackAndUncheckCreate=If the database does not exist, go back and check option "Create database". IfDatabaseNotExistsGoBackAndUncheckCreate=If the database does not exist, go back and check option "Create database".
IfDatabaseExistsGoBackAndCheckCreate=If database already exists, go back and uncheck "Create database" option. IfDatabaseExistsGoBackAndCheckCreate=If database already exists, go back and uncheck "Create database" option.
WarningBrowserTooOld=Version of browser is too old. Upgrading your browser to a recent version of Firefox, Chrome or Opera is highly recommended. WarningBrowserTooOld=Version of browser is too old. Upgrading your browser to a recent version of Firefox, Chrome or Opera is highly recommended.

View File

@ -72,6 +72,12 @@ 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
CanEditAmountShortForValues=recommended, any amount
MembershipDuration=Duration
GetMembershipButtonLabel=Get membership
Subscriptions=Contributions Subscriptions=Contributions
SubscriptionLate=Late SubscriptionLate=Late
SubscriptionNotReceived=Contribution never received SubscriptionNotReceived=Contribution never received
@ -136,7 +142,7 @@ CardContent=Content of your member card
# Text of email templates # Text of email templates
ThisIsContentOfYourMembershipRequestWasReceived=We want to let you know that your membership request was received.<br><br> ThisIsContentOfYourMembershipRequestWasReceived=We want to let you know that your membership request was received.<br><br>
ThisIsContentOfYourMembershipWasValidated=We want to let you know that your membership was validated with the following information:<br><br> ThisIsContentOfYourMembershipWasValidated=We want to let you know that your membership was validated with the following information:<br><br>
ThisIsContentOfYourSubscriptionWasRecorded=We want to let you know that your new subscription was recorded.<br><br> ThisIsContentOfYourSubscriptionWasRecorded=We want to let you know that your new subscription was recorded. Please find your invoice here enclosed.<br><br>
ThisIsContentOfSubscriptionReminderEmail=We want to let you know that your subscription is about to expire or has already expired (__MEMBER_LAST_SUBSCRIPTION_DATE_END__). We hope you will renew it.<br><br> ThisIsContentOfSubscriptionReminderEmail=We want to let you know that your subscription is about to expire or has already expired (__MEMBER_LAST_SUBSCRIPTION_DATE_END__). We hope you will renew it.<br><br>
ThisIsContentOfYourCard=This is a summary of the information we have about you. Please contact us if anything is incorrect.<br><br> ThisIsContentOfYourCard=This is a summary of the information we have about you. Please contact us if anything is incorrect.<br><br>
DescADHERENT_AUTOREGISTER_NOTIF_MAIL_SUBJECT=Subject of the notification email received in case of auto-inscription of a guest DescADHERENT_AUTOREGISTER_NOTIF_MAIL_SUBJECT=Subject of the notification email received in case of auto-inscription of a guest
@ -199,7 +205,8 @@ NbOfSubscriptions=Number of contributions
AmountOfSubscriptions=Amount collected from contributions AmountOfSubscriptions=Amount collected from contributions
TurnoverOrBudget=Turnover (for a company) or Budget (for a foundation) TurnoverOrBudget=Turnover (for a company) or Budget (for a foundation)
DefaultAmount=Default amount of contribution DefaultAmount=Default amount of contribution
CanEditAmount=Visitor can choose/edit amount of its contribution CanEditAmount=Visitor can choose/edit amount of its contribution regardless of the member type
AmountIsLowerToMinimumNotice=sur un dû total de %s
MEMBER_NEWFORM_PAYONLINE=Jump on integrated online payment page MEMBER_NEWFORM_PAYONLINE=Jump on integrated online payment page
ByProperties=By nature ByProperties=By nature
MembersStatisticsByProperties=Members statistics by nature MembersStatisticsByProperties=Members statistics by nature

View File

@ -34,3 +34,4 @@ ARollbackWasPerformedOnPostActions=A rollback was performed on all Post actions.
ValidationOfPaymentFailed=Validation of payment has failed ValidationOfPaymentFailed=Validation of payment has failed
CardOwner=Card holder CardOwner=Card holder
PayPalBalance=Paypal credit PayPalBalance=Paypal credit
OnlineSubscriptionPaymentLine=Online subscription recorded on %s<br>Paid via %s<br>Originating IP address: %s<br>Transaction ID: %s

View File

@ -198,7 +198,14 @@ NbOfSubscriptions=Nombre de cotisations
AmountOfSubscriptions=Montant des cotisations 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 quel que soit le type d'adhésion
AmountIsLowerToMinimumNotice=sur un dû total de %s
AnyAmountWithAdvisedAmount=Montant libre avec un montant recommandé de %s %s
AnyAmountWithoutAdvisedAmount=Montant libre
CanEditAmountShortForValues=conseillé, montant libre
MembershipDuration=Durée
GetMembershipButtonLabel=Adhérer
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

View File

@ -64,10 +64,12 @@ if (is_numeric($entity)) {
require '../../main.inc.php'; require '../../main.inc.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/payments.lib.php';
require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php'; require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php';
require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent_type.class.php'; require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent_type.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/cunits.class.php';
// Init vars // Init vars
$errmsg = ''; $errmsg = '';
@ -473,11 +475,10 @@ dol_htmloutput_errors($errmsg);
print '<form action="'.$_SERVER["PHP_SELF"].'" method="POST" name="newmember">'."\n"; print '<form action="'.$_SERVER["PHP_SELF"].'" method="POST" name="newmember">'."\n";
print '<input type="hidden" name="token" value="'.newToken().'" / >'; print '<input type="hidden" name="token" value="'.newToken().'" / >';
print '<input type="hidden" name="entity" value="'.$entity.'" />'; print '<input type="hidden" name="entity" value="'.$entity.'" />';
if (!empty($conf->global->MEMBER_SKIP_TABLE) || !empty($conf->global->MEMBER_NEWFORM_FORCETYPE) || $action == 'create') {
print '<input type="hidden" name="action" value="add" />'; print '<input type="hidden" name="action" value="add" />';
print '<input type="hidden" name="page_y" value="" />';
print '<br>'; print '<br>';
print '<br><span class="opacitymedium">'.$langs->trans("FieldsWithAreMandatory", '*').'</span><br>'; print '<br><span class="opacitymedium">'.$langs->trans("FieldsWithAreMandatory", '*').'</span><br>';
//print $langs->trans("FieldsWithIsForPublic",'**').'<br>'; //print $langs->trans("FieldsWithIsForPublic",'**').'<br>';
@ -673,15 +674,17 @@ if (!empty($conf->global->MEMBER_NEWFORM_DOLIBARRTURNOVER)) {
} }
if (!empty($conf->global->MEMBER_NEWFORM_PAYONLINE)) { if (!empty($conf->global->MEMBER_NEWFORM_PAYONLINE)) {
$amount = 0;
$typeid = $conf->global->MEMBER_NEWFORM_FORCETYPE ? $conf->global->MEMBER_NEWFORM_FORCETYPE : GETPOST('typeid', 'int'); $typeid = $conf->global->MEMBER_NEWFORM_FORCETYPE ? $conf->global->MEMBER_NEWFORM_FORCETYPE : GETPOST('typeid', 'int');
$adht = new AdherentType($db);
$adht->fetch($typeid);
$caneditamount = $adht->caneditamount;
// Set amount for the subscription: // Set amount for the subscription:
// - First check the amount of the member type. // - First check the amount of the member type.
$amountbytype = $adht->amountByType(1); // Load the array of amount per type $amountbytype = $adht->amountByType(1); // Load the array of amount per type
$amount = empty($amountbytype[$typeid]) ? (isset($amount) ? $amount : 0) : $amountbytype[$typeid]; $amount = empty($amountbytype[$typeid]) ? (isset($amount) ? $amount : 0) : $amountbytype[$typeid];
// - If not found, take the default amount // - If not found, take the default amount only of the user is authorized to edit it
if (empty($amount) && !empty($conf->global->MEMBER_NEWFORM_AMOUNT)) { if ($caneditamount && empty($amount) && !empty($conf->global->MEMBER_NEWFORM_AMOUNT)) {
$amount = $conf->global->MEMBER_NEWFORM_AMOUNT; $amount = $conf->global->MEMBER_NEWFORM_AMOUNT;
} }
// - If not set, we accept ot have amount defined as parameter (for backward compatibility). // - If not set, we accept ot have amount defined as parameter (for backward compatibility).
@ -691,16 +694,28 @@ if (!empty($conf->global->MEMBER_NEWFORM_PAYONLINE)) {
// Clean the amount // Clean the amount
$amount = price2num($amount); $amount = price2num($amount);
$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 '<input type="hidden" name="amount" id="amount" class="flat amount" value="'.$amount.'">';
} }
print '</td><td class="nowrap">';
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>';
} }
@ -710,7 +725,7 @@ print dol_get_fiche_end();
// Save // Save
print '<div class="center">'; print '<div class="center">';
print '<input type="submit" value="'.$langs->trans("Submit").'" id="submitsave" class="button">'; print '<input type="submit" value="'.$langs->trans("GetMembershipButtonLabel").'" id="submitsave" class="button">';
if (!empty($backtopage)) { if (!empty($backtopage)) {
print ' &nbsp; &nbsp; <input type="submit" value="'.$langs->trans("Cancel").'" id="submitcancel" class="button button-cancel">'; print ' &nbsp; &nbsp; <input type="submit" value="'.$langs->trans("Cancel").'" id="submitcancel" class="button button-cancel">';
} }
@ -720,6 +735,92 @@ print '</div>';
print "</form>\n"; print "</form>\n";
print "<br>"; print "<br>";
print '</div></div>'; print '</div></div>';
}
else { // Show the table of membership types
// Get units
$measuringUnits = new CUnits($db);
$result = $measuringUnits->fetchAll('', '', 0, 0, array('t.active' => 1));
$units = array();
foreach ($measuringUnits->records as $lines)
$units[$lines->short_label] = $langs->trans(ucfirst($lines->label));
$sql = "SELECT d.rowid, d.libelle as label, d.subscription, d.amount, d.caneditamount, d.vote, d.note, d.duration, d.statut as status, d.morphy";
$sql .= " FROM ".MAIN_DB_PREFIX."adherent_type as d";
$sql .= " WHERE d.entity IN (".getEntity('member_type').")";
$sql .= " AND d.statut=1";
$result = $db->query($sql);
if ($result) {
$num = $db->num_rows($result);
print '<br><div class="div-table-responsive">';
print '<table class="tagtable liste">'."\n";
print '<input type="hidden" name="action" value="create">';
print '<tr class="liste_titre">';
print '<th>'.$langs->trans("Label").'</th>';
print '<th class="center">'.$langs->trans("MembershipDuration").'</th>';
print '<th class="center">'.$langs->trans("Amount").'</th>';
print '<th class="center">'.$langs->trans("MembersNature").'</th>';
print '<th class="center">'.$langs->trans("VoteAllowed").'</th>';
print '<th class="center">'.$langs->trans("NewSubscription").'</th>';
print "</tr>\n";
$i = 0;
while ($i < $num) {
$objp = $db->fetch_object($result);
print '<tr class="oddeven">';
print '<td>'.dol_escape_htmltag($objp->label).'</td>';
print '<td class="nowrap">';
$unit = preg_replace("/[^a-zA-Z]+/", "", $objp->duration);
print max(1, intval($objp->duration)).' '.$units[$unit];
print '</td>';
print '<td class="center"><span class="amount nowrap">';
$displayedamount = max(intval($objp->amount), intval($conf->global->MEMBER_MIN_AMOUNT));
$caneditamount = !empty($conf->global->MEMBER_NEWFORM_EDITAMOUNT) || $objp->caneditamount;
if ($objp->subscription) {
if ($displayedamount > 0 || !$caneditamount) {
print $displayedamount.' '.strtoupper($conf->currency);
}
if ($caneditamount && $displayedamount>0) {
print $form->textwithpicto('', $langs->transnoentities("CanEditAmountShortForValues"), 1, 'help', '', 0, 3);
} elseif ($caneditamount) {
print $langs->transnoentities("CanEditAmountShort");
}
} else {
print ""; // No subscription required
}
print '</span></td>';
print '<td class="center">';
if ($objp->morphy == 'phy') {
print $langs->trans("Physical");
} elseif ($objp->morphy == 'mor') {
print $langs->trans("Moral");
} else {
print $langs->trans("MorAndPhy");
}
print '</td>';
print '<td class="center">'.yn($objp->vote).'</td>';
print '<td class="center"><button class="button button-save reposition" name="typeid" type="submit" name="submit" value="'.$objp->rowid.'">'.$langs->trans("GetMembershipButtonLabel").'</button></td>';
print "</tr>";
$i++;
}
// If no record found
if ($num == 0) {
$colspan = 8;
print '<tr><td colspan="'.$colspan.'" class="opacitymedium">'.$langs->trans("NoRecordFound").'</td></tr>';
}
print "</table>";
print '</div>';
print '</form>';
} else {
dol_print_error($db);
}
}
llxFooterVierge(); llxFooterVierge();

View File

@ -1500,7 +1500,7 @@ if ($source == 'member' || $source == 'membersubscription') {
$amount = $adht->amount; $amount = $adht->amount;
} }
$amount = price2num($amount, 'MT'); $amount = max(0, price2num($amount, 'MT'));
} }
if (GETPOST('fulltag', 'alpha')) { if (GETPOST('fulltag', 'alpha')) {
@ -1596,7 +1596,7 @@ if ($source == 'member' || $source == 'membersubscription') {
print '</td><td class="CTableRow2">'; print '</td><td class="CTableRow2">';
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 $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 "</td></tr>\n"; print "</td></tr>\n";
} elseif ($action == dopayment) { } elseif ($action == 'dopayment') {
print '<tr class="CTableRow2"><td class="CTableRow2">'.$langs->trans("NewMemberType"); print '<tr class="CTableRow2"><td class="CTableRow2">'.$langs->trans("NewMemberType");
print '</td><td class="CTableRow2">'.dol_escape_htmltag($member->type); print '</td><td class="CTableRow2">'.dol_escape_htmltag($member->type);
print '<input type="hidden" name="membertypeid" value="'.$member->typeid.'">'; print '<input type="hidden" name="membertypeid" value="'.$member->typeid.'">';
@ -1611,57 +1611,23 @@ if ($source == 'member' || $source == 'membersubscription') {
// Amount // Amount
print '<tr class="CTableRow2"><td class="CTableRow2">'.$langs->trans("Amount"); print '<tr class="CTableRow2"><td class="CTableRow2">'.$langs->trans("Amount");
if (empty($amount)) { // This place no longer allows amount edition
if (empty($conf->global->MEMBER_NEWFORM_AMOUNT)) {
print ' ('.$langs->trans("ToComplete");
}
if (!empty($conf->global->MEMBER_EXT_URL_SUBSCRIPTION_INFO)) { if (!empty($conf->global->MEMBER_EXT_URL_SUBSCRIPTION_INFO)) {
print ' - <a href="'.$conf->global->MEMBER_EXT_URL_SUBSCRIPTION_INFO.'" rel="external" target="_blank" rel="noopener noreferrer">'.$langs->trans("SeeHere").'</a>'; print ' - <a href="'.$conf->global->MEMBER_EXT_URL_SUBSCRIPTION_INFO.'" rel="external" target="_blank" rel="noopener noreferrer">'.$langs->trans("SeeHere").'</a>';
} }
if (empty($conf->global->MEMBER_NEWFORM_AMOUNT)) {
print ')';
}
}
print '</td><td class="CTableRow2">'; print '</td><td class="CTableRow2">';
$valtoshow = ''; if (!empty($conf->global->MEMBER_MIN_AMOUNT) && $amount) {
if (empty($amount) || !is_numeric($amount)) { $amount = max(0, $conf->global->MEMBER_MIN_AMOUNT, $amount);
$valtoshow = price2num(GETPOST("newamount", 'alpha'), 'MT');
// force default subscription amount to value defined into constant...
if (empty($valtoshow)) {
if (!empty($conf->global->MEMBER_NEWFORM_EDITAMOUNT)) {
if (!empty($conf->global->MEMBER_NEWFORM_AMOUNT)) {
$valtoshow = $conf->global->MEMBER_NEWFORM_AMOUNT;
} }
} else { print '<b class="amount">'.price($amount, 1, $langs, 1, -1, -1, $currency).'</b>'; // Price with currency
if (!empty($conf->global->MEMBER_NEWFORM_AMOUNT)) { $caneditamount = !empty($conf->global->MEMBER_NEWFORM_EDITAMOUNT) || $adht->caneditamount;
$amount = $conf->global->MEMBER_NEWFORM_AMOUNT; $minimumamount = empty($conf->global->MEMBER_MIN_AMOUNT)? $adht->amount : max($conf->global->MEMBER_MIN_AMOUNT, $adht->amount > $amount);
} if (!$caneditamount && $minimumamount > $amount) {
} print ' '. $langs->trans("AmountIsLowerToMinimumNotice", price($adht->amount, 1, $langs, 1, -1, -1, $currency));
}
}
if (empty($amount) || !is_numeric($amount)) {
//$valtoshow=price2num(GETPOST("newamount",'alpha'),'MT');
if (!empty($conf->global->MEMBER_MIN_AMOUNT) && $valtoshow) {
$valtoshow = max($conf->global->MEMBER_MIN_AMOUNT, $valtoshow);
}
print '<input type="hidden" name="amount" value="'.price2num(GETPOST("amount", 'alpha'), 'MT').'">';
if (empty($conf->global->MEMBER_NEWFORM_EDITAMOUNT)) {
print '<input class="flat maxwidth75" type="text" name="newamountbis" value="'.$valtoshow.'" disabled="disabled">';
print '<input type="hidden" name="newamount" value="'.$valtoshow.'">';
} else {
print '<input class="flat maxwidth75" type="text" name="newamount" value="'.$valtoshow.'">';
}
print ' <b>'.$langs->trans("Currency".$currency).'</b>';
} else {
$valtoshow = $amount;
if (!empty($conf->global->MEMBER_MIN_AMOUNT) && $valtoshow) {
$valtoshow = max($conf->global->MEMBER_MIN_AMOUNT, $valtoshow);
$amount = $valtoshow;
}
print '<b class="amount">'.price($valtoshow, 1, $langs, 1, -1, -1, $currency).'</b>'; // Price with currency
print '<input type="hidden" name="amount" value="'.$valtoshow.'">';
print '<input type="hidden" name="newamount" value="'.$valtoshow.'">';
} }
print '<input type="hidden" name="amount" value="'.$amount.'">';
print '<input type="hidden" name="newamount" value="'.$amount.'">';
print '<input type="hidden" name="currency" value="'.$currency.'">'; print '<input type="hidden" name="currency" value="'.$currency.'">';
print '</td></tr>'."\n"; print '</td></tr>'."\n";

View File

@ -504,9 +504,13 @@ if ($ispaymentok) {
$datesubend = dol_time_plus_duree($datesubend, -1, 'd'); $datesubend = dol_time_plus_duree($datesubend, -1, 'd');
} }
// Set output language
$outputlangs = new Translate('', $conf);
$outputlangs->setDefaultLang(empty($object->thirdparty->default_lang) ? $mysoc->default_lang : $object->thirdparty->default_lang);
$paymentdate = $now; $paymentdate = $now;
$amount = $FinalPaymentAmt; $amount = $FinalPaymentAmt;
$label = 'Online subscription '.dol_print_date($now, 'standard').' using '.$paymentmethod.' from '.$ipaddress.' - Transaction ID = '.$TRANSACTIONID; $formatteddate = dol_print_date($paymentdate, 'dayhour', 'auto', $outputlangs);
$label = $langs->trans("OnlineSubscriptionPaymentLine", $formatteddate, $paymentmethod, $ipaddress, $TRANSACTIONID);
// Payment informations // Payment informations
$accountid = 0; $accountid = 0;
@ -693,9 +697,6 @@ if ($ispaymentok) {
// Send subscription email // Send subscription email
include_once DOL_DOCUMENT_ROOT.'/core/class/html.formmail.class.php'; include_once DOL_DOCUMENT_ROOT.'/core/class/html.formmail.class.php';
$formmail = new FormMail($db); $formmail = new FormMail($db);
// Set output language
$outputlangs = new Translate('', $conf);
$outputlangs->setDefaultLang(empty($object->thirdparty->default_lang) ? $mysoc->default_lang : $object->thirdparty->default_lang);
// Load traductions files required by page // Load traductions files required by page
$outputlangs->loadLangs(array("main", "members")); $outputlangs->loadLangs(array("main", "members"));
// Get email content from template // Get email content from template