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) {
//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++;
} else {
$substitutionarray = getCommonSubstitutionArray($outputlangs, 0, null, $object);
@ -2028,9 +2029,14 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) {
if ($useonlinepayment) {
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';
print showOnlinePaymentUrl('membersubscription', $object->ref);
print showOnlinePaymentUrl('membersubscription', $object->ref, $amount);
}
print '</div><div class="fichehalfright">';

View File

@ -94,6 +94,11 @@ class AdherentType extends CommonObject
*/
public $amount;
/**
* @var int Amount can be choosen by the visitor during subscription (0 or 1)
*/
public $caneditamount;
/**
* @var string Public note
* @deprecated
@ -380,6 +385,7 @@ class AdherentType extends CommonObject
$sql .= "morphy = '".$this->db->escape($this->morphy)."',";
$sql .= "subscription = '".$this->db->escape($this->subscription)."',";
$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 .= "note = '".$this->db->escape($this->note_public)."',";
$sql .= "vote = ".(integer) $this->db->escape($this->vote).",";
@ -474,7 +480,7 @@ class AdherentType extends CommonObject
{
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 .= " WHERE d.rowid = ".(int) $rowid;
@ -495,6 +501,7 @@ class AdherentType extends CommonObject
$this->duration_unit = substr($obj->duration, -1);
$this->subscription = $obj->subscription;
$this->amount = $obj->amount;
$this->caneditamount = $obj->caneditamount;
$this->mail_valid = $obj->mail_valid;
$this->note = $obj->note_public; // deprecated
$this->note_public = $obj->note_public;
@ -850,6 +857,7 @@ class AdherentType extends CommonObject
$this->note_public = 'This is a public note';
$this->mail_valid = 'This is welcome email';
$this->subscription = 1;
$this->caneditamount = 0;
$this->vote = 0;
$this->status = 1;

View File

@ -122,6 +122,7 @@ if ($action == 'add' && $user->rights->adherent->configurer) {
$object->status = (int) $status;
$object->subscription = (int) $subscription;
$object->amount = ($amount == '' ? '' : price2num($amount, 'MT'));
$object->caneditamount = GETPOSTINT("caneditamount");
$object->duration_value = $duration_value;
$object->duration_unit = $duration_unit;
$object->note = trim($comment);
@ -229,7 +230,7 @@ llxHeader('', $langs->trans("MembersTypeSetup"), $help_url);
if (!$rowid && $action != 'create' && $action != 'edit') {
//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 .= " 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("SubscriptionRequired").'</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("Status").'</th>';
print '<th>&nbsp;</th>';
@ -292,6 +294,7 @@ if (!$rowid && $action != 'create' && $action != 'edit') {
$membertype->status = $objp->status;
$membertype->subscription = $objp->subscription;
$membertype->amount = $objp->amount;
$membertype->caneditamount = $objp->caneditamount;
print '<tr class="oddeven">';
print '<td class="nowraponall">';
@ -310,6 +313,7 @@ if (!$rowid && $action != 'create' && $action != 'edit') {
print '</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">'.yn($objp->caneditamount).'</td>';
print '<td class="center">'.yn($objp->vote).'</td>';
print '<td class="center">'.$membertype->getLibStatut(5).'</td>';
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 '</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 $form->selectyesno("vote", GETPOSTISSET("vote") ? GETPOST('vote', 'aZ09') : 1, 1);
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 $ref Ref of object
* @param int $amount Amount of money to request for
* @return string Url string
*/
function showOnlinePaymentUrl($type, $ref)
function showOnlinePaymentUrl($type, $ref, $amount = '9.99')
{
global $langs;
@ -185,7 +186,7 @@ function showOnlinePaymentUrl($type, $ref)
$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>';
$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 .= '<a class="" href="'.$url.'" target="_blank" rel="noopener noreferrer">'.img_picto('', 'globe', 'class="paddingleft"').'</a>';
$out .= '</div>';
@ -199,11 +200,12 @@ function showOnlinePaymentUrl($type, $ref)
* @param string $type Type of URL ('free', 'order', 'invoice', 'contractline', 'member' ...)
* @param string $ref Ref of object
* @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
*/
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;
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 string $type Type of URL ('free', 'order', 'invoice', 'contractline', 'member', 'boothlocation', ...)
* @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 $localorexternal 0=Url for browser, 1=Url for external access
* @return string Url string
@ -318,7 +320,9 @@ function getOnlinePaymentUrl($mode, $type, $ref = '', $amount = '9.99', $freetag
}
} elseif ($type == 'member' || $type == 'membersubscription') {
$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) {
$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("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;
} elseif ($action == 'PROJECT_CREATE') {
// Projects

View File

@ -32,7 +32,6 @@
-- -- VPGSQL8.2 SELECT dol_util_rebuild_sequences();
-- Missing in v16 or lower
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;
-- 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
MemberResiliatedInDolibarr=Member %s terminated
MemberDeletedInDolibarr=Member %s deleted
MemberExcludedInDolibarr=Member %s excluded
MemberSubscriptionAddedInDolibarr=Subscription %s for member %s added
MemberSubscriptionModifiedInDolibarr=Subscription %s for member %s modified
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.
ErrorConnectedButDatabaseNotFound=Connection to server successful but database '%s' not found.
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".
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.

View File

@ -72,6 +72,12 @@ MemberTypeCanNotBeDeleted=Member type can not be deleted
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.
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
SubscriptionLate=Late
SubscriptionNotReceived=Contribution never received
@ -136,7 +142,7 @@ CardContent=Content of your member card
# Text of email templates
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>
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>
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
@ -199,7 +205,8 @@ NbOfSubscriptions=Number of contributions
AmountOfSubscriptions=Amount collected from contributions
TurnoverOrBudget=Turnover (for a company) or Budget (for a foundation)
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
ByProperties=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
CardOwner=Card holder
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
TurnoverOrBudget=Chiffre affaire (pour société) ou Budget (asso ou collectivité)
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
ByProperties=Par nature
MembersStatisticsByProperties=Statistiques des adhérents par nature

View File

@ -64,10 +64,12 @@ if (is_numeric($entity)) {
require '../../main.inc.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_type.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/cunits.class.php';
// Init vars
$errmsg = '';
@ -473,253 +475,352 @@ dol_htmloutput_errors($errmsg);
print '<form action="'.$_SERVER["PHP_SELF"].'" method="POST" name="newmember">'."\n";
print '<input type="hidden" name="token" value="'.newToken().'" / >';
print '<input type="hidden" name="entity" value="'.$entity.'" />';
print '<input type="hidden" name="action" value="add" />';
print '<input type="hidden" name="page_y" value="" />';
print '<br>';
if (!empty($conf->global->MEMBER_SKIP_TABLE) || !empty($conf->global->MEMBER_NEWFORM_FORCETYPE) || $action == 'create') {
print '<input type="hidden" name="action" value="add" />';
print '<br>';
print '<br><span class="opacitymedium">'.$langs->trans("FieldsWithAreMandatory", '*').'</span><br>';
//print $langs->trans("FieldsWithIsForPublic",'**').'<br>';
print '<br><span class="opacitymedium">'.$langs->trans("FieldsWithAreMandatory", '*').'</span><br>';
//print $langs->trans("FieldsWithIsForPublic",'**').'<br>';
print dol_get_fiche_head('');
print '<script type="text/javascript">
jQuery(document).ready(function () {
jQuery(document).ready(function () {
function initmorphy()
{
console.log("Call initmorphy");
if (jQuery("#morphy").val() == \'phy\') {
jQuery("#trcompany").hide();
}
if (jQuery("#morphy").val() == \'mor\') {
jQuery("#trcompany").show();
}
};
initmorphy();
jQuery("#morphy").change(function() {
initmorphy();
});
jQuery("#selectcountry_id").change(function() {
document.newmember.action.value="create";
document.newmember.submit();
});
jQuery("#typeid").change(function() {
document.newmember.action.value="create";
document.newmember.submit();
});
});
});
</script>';
print '<table class="border" summary="form to subscribe" id="tablesubscribe">'."\n";
// Type
if (empty($conf->global->MEMBER_NEWFORM_FORCETYPE)) {
$listoftype = $adht->liste_array();
$tmp = array_keys($listoftype);
$defaulttype = '';
$isempty = 1;
if (count($listoftype) == 1) {
$defaulttype = $tmp[0];
$isempty = 0;
}
print '<tr><td class="titlefield">'.$langs->trans("Type").' <span style="color: red">*</span></td><td>';
print $form->selectarray("typeid", $adht->liste_array(1), GETPOST('typeid') ? GETPOST('typeid') : $defaulttype, $isempty);
print '</td></tr>'."\n";
} else {
$adht->fetch($conf->global->MEMBER_NEWFORM_FORCETYPE);
print '<input type="hidden" id="typeid" name="typeid" value="'.$conf->global->MEMBER_NEWFORM_FORCETYPE.'">';
}
// Moral/Physic attribute
$morphys["phy"] = $langs->trans("Physical");
$morphys["mor"] = $langs->trans("Moral");
if (empty($conf->global->MEMBER_NEWFORM_FORCEMORPHY)) {
print '<tr class="morphy"><td class="titlefield">'.$langs->trans('MemberNature').' <span style="color: red">*</span></td><td>'."\n";
print $form->selectarray("morphy", $morphys, GETPOST('morphy'), 1);
print '</td></tr>'."\n";
} else {
print $morphys[$conf->global->MEMBER_NEWFORM_FORCEMORPHY];
print '<input type="hidden" id="morphy" name="morphy" value="'.$conf->global->MEMBER_NEWFORM_FORCEMORPHY.'">';
}
// Company
print '<tr id="trcompany" class="trcompany"><td>'.$langs->trans("Company").'</td><td>';
print img_picto('', 'company', 'class="pictofixedwidth"');
print '<input type="text" name="societe" class="minwidth150 widthcentpercentminusx" value="'.dol_escape_htmltag(GETPOST('societe')).'"></td></tr>'."\n";
// Title
print '<tr><td class="titlefield">'.$langs->trans('UserTitle').'</td><td>';
print $formcompany->select_civility(GETPOST('civility_id'), 'civility_id').'</td></tr>'."\n";
// Lastname
print '<tr><td>'.$langs->trans("Lastname").' <span style="color: red">*</span></td><td><input type="text" name="lastname" class="minwidth150" value="'.dol_escape_htmltag(GETPOST('lastname')).'"></td></tr>'."\n";
// Firstname
print '<tr><td>'.$langs->trans("Firstname").' <span style="color: red">*</span></td><td><input type="text" name="firstname" class="minwidth150" value="'.dol_escape_htmltag(GETPOST('firstname')).'"></td></tr>'."\n";
// EMail
print '<tr><td>'.$langs->trans("Email").($conf->global->ADHERENT_MAIL_REQUIRED ? ' <span style="color:red;">*</span>' : '').'</td><td>';
//print img_picto('', 'email', 'class="pictofixedwidth"');
print '<input type="text" name="email" maxlength="255" class="minwidth200" value="'.dol_escape_htmltag(GETPOST('email')).'"></td></tr>'."\n";
// Login
if (empty($conf->global->ADHERENT_LOGIN_NOT_REQUIRED)) {
print '<tr><td>'.$langs->trans("Login").' <span style="color: red">*</span></td><td><input type="text" name="login" maxlength="50" class="minwidth100"value="'.dol_escape_htmltag(GETPOST('login')).'"></td></tr>'."\n";
print '<tr><td>'.$langs->trans("Password").' <span style="color: red">*</span></td><td><input type="password" maxlength="128" name="pass1" class="minwidth100" value="'.dol_escape_htmltag(GETPOST("pass1", "none", 2)).'"></td></tr>'."\n";
print '<tr><td>'.$langs->trans("PasswordAgain").' <span style="color: red">*</span></td><td><input type="password" maxlength="128" name="pass2" class="minwidth100" value="'.dol_escape_htmltag(GETPOST("pass2", "none", 2)).'"></td></tr>'."\n";
}
// Gender
print '<tr><td>'.$langs->trans("Gender").'</td>';
print '<td>';
$arraygender = array('man'=>$langs->trans("Genderman"), 'woman'=>$langs->trans("Genderwoman"));
print $form->selectarray('gender', $arraygender, GETPOST('gender') ?GETPOST('gender') : $object->gender, 1);
print '</td></tr>';
// Address
print '<tr><td>'.$langs->trans("Address").'</td><td>'."\n";
print '<textarea name="address" id="address" wrap="soft" class="quatrevingtpercent" rows="'.ROWS_3.'">'.dol_escape_htmltag(GETPOST('address', 'restricthtml'), 0, 1).'</textarea></td></tr>'."\n";
// Zip / Town
print '<tr><td>'.$langs->trans('Zip').' / '.$langs->trans('Town').'</td><td>';
print $formcompany->select_ziptown(GETPOST('zipcode'), 'zipcode', array('town', 'selectcountry_id', 'state_id'), 0, 1, '', 'width75');
print ' / ';
print $formcompany->select_ziptown(GETPOST('town'), 'town', array('zipcode', 'selectcountry_id', 'state_id'), 0, 1);
print '</td></tr>';
// Country
print '<tr><td>'.$langs->trans('Country').'</td><td>';
print img_picto('', 'country', 'class="pictofixedwidth"');
$country_id = GETPOST('country_id', 'int');
if (!$country_id && !empty($conf->global->MEMBER_NEWFORM_FORCECOUNTRYCODE)) {
$country_id = getCountry($conf->global->MEMBER_NEWFORM_FORCECOUNTRYCODE, 2, $db, $langs);
}
if (!$country_id && !empty($conf->geoipmaxmind->enabled)) {
$country_code = dol_user_country();
//print $country_code;
if ($country_code) {
$new_country_id = getCountry($country_code, 3, $db, $langs);
//print 'xxx'.$country_code.' - '.$new_country_id;
if ($new_country_id) {
$country_id = $new_country_id;
}
}
}
$country_code = getCountry($country_id, 2, $db, $langs);
print $form->select_country($country_id, 'country_id');
print '</td></tr>';
// State
if (empty($conf->global->SOCIETE_DISABLE_STATE)) {
print '<tr><td>'.$langs->trans('State').'</td><td>';
if ($country_code) {
print $formcompany->select_state(GETPOST("state_id"), $country_code);
}
print '</td></tr>';
}
// Birthday
print '<tr id="trbirth" class="trbirth"><td>'.$langs->trans("DateOfBirth").'</td><td>';
print $form->selectDate($birthday, 'birth', 0, 0, 1, "newmember", 1, 0);
print '</td></tr>'."\n";
// Photo
print '<tr><td>'.$langs->trans("URLPhoto").'</td><td><input type="text" name="photo" class="minwidth150" value="'.dol_escape_htmltag(GETPOST('photo')).'"></td></tr>'."\n";
// Public
print '<tr><td>'.$langs->trans("Public").'</td><td><input type="checkbox" name="public"></td></tr>'."\n";
// Other attributes
$tpl_context = 'public'; // define template context to public
include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_add.tpl.php';
// Comments
print '<tr>';
print '<td class="tdtop">'.$langs->trans("Comments").'</td>';
print '<td class="tdtop"><textarea name="note_private" id="note_private" wrap="soft" class="quatrevingtpercent" rows="'.ROWS_3.'">'.dol_escape_htmltag(GETPOST('note_private', 'restricthtml'), 0, 1).'</textarea></td>';
print '</tr>'."\n";
// Add specific fields used by Dolibarr foundation for example
// TODO Move this into generic feature.
if (!empty($conf->global->MEMBER_NEWFORM_DOLIBARRTURNOVER)) {
$arraybudget = array('50'=>'<= 100 000', '100'=>'<= 200 000', '200'=>'<= 500 000', '300'=>'<= 1 500 000', '600'=>'<= 3 000 000', '1000'=>'<= 5 000 000', '2000'=>'5 000 000+');
print '<tr id="trbudget" class="trcompany"><td>'.$langs->trans("TurnoverOrBudget").' <span style="color: red">*</span></td><td>';
print $form->selectarray('budget', $arraybudget, GETPOST('budget'), 1);
print ' € or $';
print dol_get_fiche_head('');
print '<script type="text/javascript">
jQuery(document).ready(function () {
initturnover();
jQuery("#morphy").click(function() {
initturnover();
});
jQuery("#budget").change(function() {
if (jQuery("#budget").val() > 0) { jQuery(".amount").val(jQuery("#budget").val()); }
else { jQuery("#budget").val(\'\'); }
});
/*jQuery("#typeid").change(function() {
if (jQuery("#typeid").val()==1) { jQuery("#morphy").val(\'mor\'); }
if (jQuery("#typeid").val()==2) { jQuery("#morphy").val(\'phy\'); }
if (jQuery("#typeid").val()==3) { jQuery("#morphy").val(\'mor\'); }
if (jQuery("#typeid").val()==4) { jQuery("#morphy").val(\'mor\'); }
initturnover();
});*/
function initturnover() {
if (jQuery("#morphy").val()==\'phy\') {
jQuery(".amount").val(20);
jQuery("#trbudget").hide();
jQuery("#trcompany").hide();
}
if (jQuery("#morphy").val()==\'mor\') {
jQuery(".amount").val(\'\');
jQuery("#trcompany").show();
jQuery("#trbirth").hide();
jQuery("#trbudget").show();
if (jQuery("#budget").val() > 0) { jQuery(".amount").val(jQuery("#budget").val()); }
else { jQuery("#budget").val(\'\'); }
}
}
});
</script>';
print '</td></tr>'."\n";
}
jQuery(document).ready(function () {
jQuery(document).ready(function () {
function initmorphy()
{
console.log("Call initmorphy");
if (jQuery("#morphy").val() == \'phy\') {
jQuery("#trcompany").hide();
}
if (jQuery("#morphy").val() == \'mor\') {
jQuery("#trcompany").show();
}
};
initmorphy();
jQuery("#morphy").change(function() {
initmorphy();
});
jQuery("#selectcountry_id").change(function() {
document.newmember.action.value="create";
document.newmember.submit();
});
jQuery("#typeid").change(function() {
document.newmember.action.value="create";
document.newmember.submit();
});
});
});
</script>';
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:
// - 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 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) : '');
}
print '<table class="border" summary="form to subscribe" id="tablesubscribe">'."\n";
// Clean the amount
$amount = price2num($amount);
// $conf->global->MEMBER_NEWFORM_PAYONLINE is 'paypal', 'paybox' or 'stripe'
print '<tr><td>'.$langs->trans("Subscription").'</td><td class="nowrap">';
if (!empty($conf->global->MEMBER_NEWFORM_EDITAMOUNT)) {
print '<input type="text" name="amount" id="amount" class="flat amount width50" value="'.$amount.'">';
// Type
if (empty($conf->global->MEMBER_NEWFORM_FORCETYPE)) {
$listoftype = $adht->liste_array();
$tmp = array_keys($listoftype);
$defaulttype = '';
$isempty = 1;
if (count($listoftype) == 1) {
$defaulttype = $tmp[0];
$isempty = 0;
}
print '<tr><td class="titlefield">'.$langs->trans("Type").' <span style="color: red">*</span></td><td>';
print $form->selectarray("typeid", $adht->liste_array(1), GETPOST('typeid') ? GETPOST('typeid') : $defaulttype, $isempty);
print '</td></tr>'."\n";
} 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.'">';
$adht->fetch($conf->global->MEMBER_NEWFORM_FORCETYPE);
print '<input type="hidden" id="typeid" name="typeid" value="'.$conf->global->MEMBER_NEWFORM_FORCETYPE.'">';
}
print ' '.$langs->trans("Currency".$conf->currency);
// Moral/Physic attribute
$morphys["phy"] = $langs->trans("Physical");
$morphys["mor"] = $langs->trans("Moral");
if (empty($conf->global->MEMBER_NEWFORM_FORCEMORPHY)) {
print '<tr class="morphy"><td class="titlefield">'.$langs->trans('MemberNature').' <span style="color: red">*</span></td><td>'."\n";
print $form->selectarray("morphy", $morphys, GETPOST('morphy'), 1);
print '</td></tr>'."\n";
} else {
print $morphys[$conf->global->MEMBER_NEWFORM_FORCEMORPHY];
print '<input type="hidden" id="morphy" name="morphy" value="'.$conf->global->MEMBER_NEWFORM_FORCEMORPHY.'">';
}
// Company
print '<tr id="trcompany" class="trcompany"><td>'.$langs->trans("Company").'</td><td>';
print img_picto('', 'company', 'class="pictofixedwidth"');
print '<input type="text" name="societe" class="minwidth150 widthcentpercentminusx" value="'.dol_escape_htmltag(GETPOST('societe')).'"></td></tr>'."\n";
// Title
print '<tr><td class="titlefield">'.$langs->trans('UserTitle').'</td><td>';
print $formcompany->select_civility(GETPOST('civility_id'), 'civility_id').'</td></tr>'."\n";
// Lastname
print '<tr><td>'.$langs->trans("Lastname").' <span style="color: red">*</span></td><td><input type="text" name="lastname" class="minwidth150" value="'.dol_escape_htmltag(GETPOST('lastname')).'"></td></tr>'."\n";
// Firstname
print '<tr><td>'.$langs->trans("Firstname").' <span style="color: red">*</span></td><td><input type="text" name="firstname" class="minwidth150" value="'.dol_escape_htmltag(GETPOST('firstname')).'"></td></tr>'."\n";
// EMail
print '<tr><td>'.$langs->trans("Email").($conf->global->ADHERENT_MAIL_REQUIRED ? ' <span style="color:red;">*</span>' : '').'</td><td>';
//print img_picto('', 'email', 'class="pictofixedwidth"');
print '<input type="text" name="email" maxlength="255" class="minwidth200" value="'.dol_escape_htmltag(GETPOST('email')).'"></td></tr>'."\n";
// Login
if (empty($conf->global->ADHERENT_LOGIN_NOT_REQUIRED)) {
print '<tr><td>'.$langs->trans("Login").' <span style="color: red">*</span></td><td><input type="text" name="login" maxlength="50" class="minwidth100"value="'.dol_escape_htmltag(GETPOST('login')).'"></td></tr>'."\n";
print '<tr><td>'.$langs->trans("Password").' <span style="color: red">*</span></td><td><input type="password" maxlength="128" name="pass1" class="minwidth100" value="'.dol_escape_htmltag(GETPOST("pass1", "none", 2)).'"></td></tr>'."\n";
print '<tr><td>'.$langs->trans("PasswordAgain").' <span style="color: red">*</span></td><td><input type="password" maxlength="128" name="pass2" class="minwidth100" value="'.dol_escape_htmltag(GETPOST("pass2", "none", 2)).'"></td></tr>'."\n";
}
// Gender
print '<tr><td>'.$langs->trans("Gender").'</td>';
print '<td>';
$arraygender = array('man'=>$langs->trans("Genderman"), 'woman'=>$langs->trans("Genderwoman"));
print $form->selectarray('gender', $arraygender, GETPOST('gender') ?GETPOST('gender') : $object->gender, 1);
print '</td></tr>';
// Address
print '<tr><td>'.$langs->trans("Address").'</td><td>'."\n";
print '<textarea name="address" id="address" wrap="soft" class="quatrevingtpercent" rows="'.ROWS_3.'">'.dol_escape_htmltag(GETPOST('address', 'restricthtml'), 0, 1).'</textarea></td></tr>'."\n";
// Zip / Town
print '<tr><td>'.$langs->trans('Zip').' / '.$langs->trans('Town').'</td><td>';
print $formcompany->select_ziptown(GETPOST('zipcode'), 'zipcode', array('town', 'selectcountry_id', 'state_id'), 0, 1, '', 'width75');
print ' / ';
print $formcompany->select_ziptown(GETPOST('town'), 'town', array('zipcode', 'selectcountry_id', 'state_id'), 0, 1);
print '</td></tr>';
// Country
print '<tr><td>'.$langs->trans('Country').'</td><td>';
print img_picto('', 'country', 'class="pictofixedwidth"');
$country_id = GETPOST('country_id', 'int');
if (!$country_id && !empty($conf->global->MEMBER_NEWFORM_FORCECOUNTRYCODE)) {
$country_id = getCountry($conf->global->MEMBER_NEWFORM_FORCECOUNTRYCODE, 2, $db, $langs);
}
if (!$country_id && !empty($conf->geoipmaxmind->enabled)) {
$country_code = dol_user_country();
//print $country_code;
if ($country_code) {
$new_country_id = getCountry($country_code, 3, $db, $langs);
//print 'xxx'.$country_code.' - '.$new_country_id;
if ($new_country_id) {
$country_id = $new_country_id;
}
}
}
$country_code = getCountry($country_id, 2, $db, $langs);
print $form->select_country($country_id, 'country_id');
print '</td></tr>';
// State
if (empty($conf->global->SOCIETE_DISABLE_STATE)) {
print '<tr><td>'.$langs->trans('State').'</td><td>';
if ($country_code) {
print $formcompany->select_state(GETPOST("state_id"), $country_code);
}
print '</td></tr>';
}
// Birthday
print '<tr id="trbirth" class="trbirth"><td>'.$langs->trans("DateOfBirth").'</td><td>';
print $form->selectDate($birthday, 'birth', 0, 0, 1, "newmember", 1, 0);
print '</td></tr>'."\n";
// Photo
print '<tr><td>'.$langs->trans("URLPhoto").'</td><td><input type="text" name="photo" class="minwidth150" value="'.dol_escape_htmltag(GETPOST('photo')).'"></td></tr>'."\n";
// Public
print '<tr><td>'.$langs->trans("Public").'</td><td><input type="checkbox" name="public"></td></tr>'."\n";
// Other attributes
$tpl_context = 'public'; // define template context to public
include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_add.tpl.php';
// Comments
print '<tr>';
print '<td class="tdtop">'.$langs->trans("Comments").'</td>';
print '<td class="tdtop"><textarea name="note_private" id="note_private" wrap="soft" class="quatrevingtpercent" rows="'.ROWS_3.'">'.dol_escape_htmltag(GETPOST('note_private', 'restricthtml'), 0, 1).'</textarea></td>';
print '</tr>'."\n";
// Add specific fields used by Dolibarr foundation for example
// TODO Move this into generic feature.
if (!empty($conf->global->MEMBER_NEWFORM_DOLIBARRTURNOVER)) {
$arraybudget = array('50'=>'<= 100 000', '100'=>'<= 200 000', '200'=>'<= 500 000', '300'=>'<= 1 500 000', '600'=>'<= 3 000 000', '1000'=>'<= 5 000 000', '2000'=>'5 000 000+');
print '<tr id="trbudget" class="trcompany"><td>'.$langs->trans("TurnoverOrBudget").' <span style="color: red">*</span></td><td>';
print $form->selectarray('budget', $arraybudget, GETPOST('budget'), 1);
print ' € or $';
print '<script type="text/javascript">
jQuery(document).ready(function () {
initturnover();
jQuery("#morphy").click(function() {
initturnover();
});
jQuery("#budget").change(function() {
if (jQuery("#budget").val() > 0) { jQuery(".amount").val(jQuery("#budget").val()); }
else { jQuery("#budget").val(\'\'); }
});
/*jQuery("#typeid").change(function() {
if (jQuery("#typeid").val()==1) { jQuery("#morphy").val(\'mor\'); }
if (jQuery("#typeid").val()==2) { jQuery("#morphy").val(\'phy\'); }
if (jQuery("#typeid").val()==3) { jQuery("#morphy").val(\'mor\'); }
if (jQuery("#typeid").val()==4) { jQuery("#morphy").val(\'mor\'); }
initturnover();
});*/
function initturnover() {
if (jQuery("#morphy").val()==\'phy\') {
jQuery(".amount").val(20);
jQuery("#trbudget").hide();
jQuery("#trcompany").hide();
}
if (jQuery("#morphy").val()==\'mor\') {
jQuery(".amount").val(\'\');
jQuery("#trcompany").show();
jQuery("#trbirth").hide();
jQuery("#trbudget").show();
if (jQuery("#budget").val() > 0) { jQuery(".amount").val(jQuery("#budget").val()); }
else { jQuery("#budget").val(\'\'); }
}
}
});
</script>';
print '</td></tr>'."\n";
}
if (!empty($conf->global->MEMBER_NEWFORM_PAYONLINE)) {
$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:
// - 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 only of the user is authorized to edit it
if ($caneditamount && empty($amount) && !empty($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 (empty($amount)) {
$amount = (GETPOST('amount') ? price2num(GETPOST('amount', 'alpha'), 'MT', 2) : '');
}
// Clean the amount
$amount = price2num($amount);
$showedamount = $amount>0? $amount: 0;
// $conf->global->MEMBER_NEWFORM_PAYONLINE is 'paypal', 'paybox' or 'stripe'
print '<tr><td>'.$langs->trans("Subscription");
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 '</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 '</td></tr>';
}
print "</table>\n";
print dol_get_fiche_end();
// Save
print '<div class="center">';
print '<input type="submit" value="'.$langs->trans("GetMembershipButtonLabel").'" id="submitsave" class="button">';
if (!empty($backtopage)) {
print ' &nbsp; &nbsp; <input type="submit" value="'.$langs->trans("Cancel").'" id="submitcancel" class="button button-cancel">';
}
print '</div>';
print "</form>\n";
print "<br>";
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));
print "</table>\n";
$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";
print dol_get_fiche_end();
$result = $db->query($sql);
if ($result) {
$num = $db->num_rows($result);
// Save
print '<div class="center">';
print '<input type="submit" value="'.$langs->trans("Submit").'" id="submitsave" class="button">';
if (!empty($backtopage)) {
print ' &nbsp; &nbsp; <input type="submit" value="'.$langs->trans("Cancel").'" id="submitcancel" class="button button-cancel">';
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);
}
}
print '</div>';
print "</form>\n";
print "<br>";
print '</div></div>';
llxFooterVierge();

View File

@ -1500,7 +1500,7 @@ if ($source == 'member' || $source == 'membersubscription') {
$amount = $adht->amount;
}
$amount = price2num($amount, 'MT');
$amount = max(0, price2num($amount, 'MT'));
}
if (GETPOST('fulltag', 'alpha')) {
@ -1596,7 +1596,7 @@ if ($source == 'member' || $source == 'membersubscription') {
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 "</td></tr>\n";
} elseif ($action == dopayment) {
} elseif ($action == 'dopayment') {
print '<tr class="CTableRow2"><td class="CTableRow2">'.$langs->trans("NewMemberType");
print '</td><td class="CTableRow2">'.dol_escape_htmltag($member->type);
print '<input type="hidden" name="membertypeid" value="'.$member->typeid.'">';
@ -1611,57 +1611,23 @@ if ($source == 'member' || $source == 'membersubscription') {
// Amount
print '<tr class="CTableRow2"><td class="CTableRow2">'.$langs->trans("Amount");
if (empty($amount)) {
if (empty($conf->global->MEMBER_NEWFORM_AMOUNT)) {
print ' ('.$langs->trans("ToComplete");
}
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>';
}
if (empty($conf->global->MEMBER_NEWFORM_AMOUNT)) {
print ')';
}
// This place no longer allows amount edition
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 '</td><td class="CTableRow2">';
$valtoshow = '';
if (empty($amount) || !is_numeric($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 {
if (!empty($conf->global->MEMBER_NEWFORM_AMOUNT)) {
$amount = $conf->global->MEMBER_NEWFORM_AMOUNT;
}
}
}
if (!empty($conf->global->MEMBER_MIN_AMOUNT) && $amount) {
$amount = max(0, $conf->global->MEMBER_MIN_AMOUNT, $amount);
}
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 '<b class="amount">'.price($amount, 1, $langs, 1, -1, -1, $currency).'</b>'; // Price with currency
$caneditamount = !empty($conf->global->MEMBER_NEWFORM_EDITAMOUNT) || $adht->caneditamount;
$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));
}
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 '</td></tr>'."\n";

View File

@ -504,9 +504,13 @@ if ($ispaymentok) {
$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;
$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
$accountid = 0;
@ -693,9 +697,6 @@ if ($ispaymentok) {
// Send subscription email
include_once DOL_DOCUMENT_ROOT.'/core/class/html.formmail.class.php';
$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
$outputlangs->loadLangs(array("main", "members"));
// Get email content from template