Debug amount suggested on membership public form
This commit is contained in:
parent
6d0e42a82e
commit
d278909f5b
2 changed files with 197 additions and 89 deletions
|
|
@ -207,8 +207,9 @@ MembershipStatistics=Membership statistics
|
|||
NbOfSubscriptions=Number of memberships
|
||||
AmountOfSubscriptions=Amount collected from membership payments
|
||||
TurnoverOrBudget=Turnover (for a company) or Budget (for a foundation)
|
||||
AreYouAPreferredPartner=Are you (or plan to be) a %s
|
||||
DefaultAmount=Default amount of membership payment (used only if no amount is defined at member type level)
|
||||
MinimumAmount=Minimum amount of membership payment (has priority on any default amounts)
|
||||
MinimumAmount=Minimum amount of membership payment (has priority on any default amounts that is lower)
|
||||
CanEditAmount=Membership amount can be defined by the member
|
||||
CanEditAmountDetail=Visitor can choose/edit amount of its contribution regardless of the member type
|
||||
AmountIsLowerToMinimumNotice=The amount is lower than the minimum %s
|
||||
|
|
|
|||
|
|
@ -62,6 +62,14 @@ define("DOLENTITY", $entity);
|
|||
|
||||
// Load Dolibarr environment
|
||||
require '../../main.inc.php';
|
||||
/**
|
||||
* @var Conf $conf
|
||||
* @var DoliDB $db
|
||||
* @var HookManager $hookmanager
|
||||
* @var Societe $mysoc
|
||||
* @var Translate $langs
|
||||
* @var User $user
|
||||
*/
|
||||
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';
|
||||
|
|
@ -79,15 +87,6 @@ $errmsg = '';
|
|||
$num = 0;
|
||||
$error = 0;
|
||||
|
||||
/**
|
||||
* @var Conf $conf
|
||||
* @var DoliDB $db
|
||||
* @var HookManager $hookmanager
|
||||
* @var Societe $mysoc
|
||||
* @var Translate $langs
|
||||
* @var User $user
|
||||
*/
|
||||
|
||||
// Load translation files
|
||||
$langs->loadLangs(array("main", "members", "companies", "install", "other", "errors"));
|
||||
|
||||
|
|
@ -336,11 +335,14 @@ if (empty($reshook) && $action == 'add') { // Test on permission not required he
|
|||
$error++;
|
||||
$errmsg .= $langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv('Nature'))."<br>\n";
|
||||
}
|
||||
|
||||
$lastname = GETPOST("lastname", 'alphanohtml');
|
||||
$firstname = GETPOST("firstname", 'alphanohtml');
|
||||
$societe = GETPOST("societe", 'alphanohtml');
|
||||
$morphy = GETPOST("morphy", 'alphanohtml');
|
||||
$email = preg_replace('/\s+/', '', GETPOST("member_email", 'aZ09arobase'));
|
||||
$country_id = getDolGlobalInt("MEMBER_NEWFORM_FORCECOUNTRYCODE", GETPOSTINT('country_id'));
|
||||
|
||||
if ($morphy != 'mor' && empty($lastname)) {
|
||||
$error++;
|
||||
$langs->load("errors");
|
||||
|
|
@ -356,6 +358,11 @@ if (empty($reshook) && $action == 'add') { // Test on permission not required he
|
|||
$langs->load("errors");
|
||||
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("Company")), null, 'errors');
|
||||
}
|
||||
if (empty($country_id)) {
|
||||
$error++;
|
||||
$langs->load("errors");
|
||||
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("Country")), null, 'errors');
|
||||
}
|
||||
if (getDolGlobalString('ADHERENT_MAIL_REQUIRED') && !isValidEmail($email)) {
|
||||
$error++;
|
||||
$langs->load("errors");
|
||||
|
|
@ -367,8 +374,10 @@ if (empty($reshook) && $action == 'add') { // Test on permission not required he
|
|||
$langs->load("errors");
|
||||
$errmsg .= $langs->trans("ErrorBadDateFormat")."<br>\n";
|
||||
}
|
||||
|
||||
// TODO Add this in a hook
|
||||
if (getDolGlobalString('MEMBER_NEWFORM_DOLIBARRTURNOVER')) {
|
||||
if (GETPOST("morphy") == 'mor' && GETPOST('budget') <= 0) {
|
||||
if (GETPOST("morphy") == 'mor' && GETPOSTFLOAT('budget') <= 0) {
|
||||
$error++;
|
||||
$errmsg .= $langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("TurnoverOrBudget"))."<br>\n";
|
||||
}
|
||||
|
|
@ -661,7 +670,7 @@ if ($action == "subscription") {
|
|||
}
|
||||
|
||||
// Print form
|
||||
print '<form action="'.$_SERVER["PHP_SELF"].'" method="POST" name="newmember">'."\n";
|
||||
print '<form action="'.$_SERVER["PHP_SELF"].'" method="POST" name="newmember" id="newmember">'."\n";
|
||||
print '<input type="hidden" name="token" value="'.newToken().'" />';
|
||||
print '<input type="hidden" name="entity" value="'.$entity.'" />';
|
||||
print '<input type="hidden" name="page_y" value="" />';
|
||||
|
|
@ -685,7 +694,7 @@ if (getDolGlobalString('MEMBER_SKIP_TABLE') || getDolGlobalString('MEMBER_NEWFOR
|
|||
jQuery("#selectcountry_id").change(function() {
|
||||
console.log("We change country, so we reload page");
|
||||
document.newmember.action.value="create";
|
||||
document.newmember.submit();
|
||||
jQuery("#newmember").submit();
|
||||
});
|
||||
function initfieldrequired() {
|
||||
console.log("initfieldrequired");
|
||||
|
|
@ -713,7 +722,7 @@ if (getDolGlobalString('MEMBER_SKIP_TABLE') || getDolGlobalString('MEMBER_NEWFOR
|
|||
// Type
|
||||
if (!getDolGlobalString('MEMBER_NEWFORM_FORCETYPE')) {
|
||||
$typeid = GETPOSTINT("typeid");
|
||||
print '<tr><td class="fieldrequired">'.$langs->trans("MemberType").'</td><td>';
|
||||
print '<tr><td class="fieldrequired titlefieldmiddle">'.$langs->trans("MemberType").'</td><td>';
|
||||
$listetype = $adht->liste_array(1);
|
||||
print img_picto('', $adht->picto, 'class="pictofixedwidth"');
|
||||
if (count($listetype)) {
|
||||
|
|
@ -721,11 +730,11 @@ if (getDolGlobalString('MEMBER_SKIP_TABLE') || getDolGlobalString('MEMBER_NEWFOR
|
|||
} else {
|
||||
print '<span class="error">'.$langs->trans("NoTypeDefinedGoToSetup").'</span>';
|
||||
}
|
||||
print '</td></tr>'."\n";
|
||||
} else {
|
||||
$adht->fetch(getDolGlobalInt('MEMBER_NEWFORM_FORCETYPE'));
|
||||
print '<input type="hidden" id="typeid" name="typeid" value="' . getDolGlobalString('MEMBER_NEWFORM_FORCETYPE').'">';
|
||||
}
|
||||
print '</td></tr>'."\n";
|
||||
|
||||
// Moral/Physic attribute
|
||||
$morphys = [
|
||||
|
|
@ -742,8 +751,10 @@ if (getDolGlobalString('MEMBER_SKIP_TABLE') || getDolGlobalString('MEMBER_NEWFOR
|
|||
}
|
||||
|
||||
print '<tr><td class="fieldrequired">'.$langs->trans("MemberNature")."</td><td>\n";
|
||||
print '<span id="spannature1" class="nonature-back spannature paddinglarge marginrightonly"><label for="phisicalinput" class="valignmiddle">'.$morphys["phy"].'<input id="phisicalinput" class="flat checkforselect marginleftonly valignmiddle" type="radio" name="morphy" value="phy"'.($checkednature == "phy" ? ' checked="checked"' : '').($checkednature == "mor" ? ' disabled="disabled"' : '').'></label></span>';
|
||||
print '<span id="spannature2" class="nonature-back spannature paddinglarge marginrightonly"><label for="moralinput" class="valignmiddle">'.$morphys["mor"].'<input id="moralinput" class="flat checkforselect marginleftonly valignmiddle" type="radio" name="morphy" value="mor"'.($checkednature == "mor" ? ' checked="checked"' : '').($checkednature == "phy" ? ' disabled="disabled"' : '').'></label></span>';
|
||||
//$disabledphy = ($checkednature == "mor" ? ' disabled="disabled"' : '');
|
||||
//$disabledmor = ($checkednature == "phy" ? ' disabled="disabled"' : '');
|
||||
print '<span id="spannature1" class="nonature-back spannature paddinglarge marginrightonly"><label for="phisicalinput" class="valignmiddle">'.$morphys["phy"].'<input id="phisicalinput" class="flat checkforselect marginleftonly valignmiddle" type="radio" name="morphy" value="phy"'.($checkednature == "phy" ? ' checked="checked"' : '').$disabledphy.'></label></span>';
|
||||
print '<span id="spannature2" class="nonature-back spannature paddinglarge marginrightonly"><label for="moralinput" class="valignmiddle">'.$morphys["mor"].'<input id="moralinput" class="flat checkforselect marginleftonly valignmiddle" type="radio" name="morphy" value="mor"'.($checkednature == "mor" ? ' checked="checked"' : '').$disabledmor.'></label></span>';
|
||||
|
||||
// Add JS to manage the background of nature
|
||||
if ($conf->use_javascript_ajax) {
|
||||
|
|
@ -775,7 +786,7 @@ if (getDolGlobalString('MEMBER_SKIP_TABLE') || getDolGlobalString('MEMBER_NEWFOR
|
|||
});
|
||||
|
||||
$("#typeid").on("change", function() {
|
||||
console.log("Type of member is modified");
|
||||
console.log("Type of membership is modified");
|
||||
let morphy = listetype_natures[$(this).val()];
|
||||
console.log("morphy="+morphy);
|
||||
|
||||
|
|
@ -789,8 +800,8 @@ if (getDolGlobalString('MEMBER_SKIP_TABLE') || getDolGlobalString('MEMBER_NEWFOR
|
|||
|
||||
switch (morphy) {
|
||||
case "phy":
|
||||
$phyInput.prop({disabled: false, checked: true});
|
||||
$morInput.prop({disabled: true, checked: false});
|
||||
/* $phyInput.prop({disabled: false, checked: true});
|
||||
$morInput.prop({disabled: true, checked: false}); */
|
||||
$span1.addClass("member-individual-back").removeClass("nonature-back");
|
||||
$span2.removeClass("member-company-back").addClass("nonature-back");
|
||||
$tdLast.addClass("fieldrequired");
|
||||
|
|
@ -799,8 +810,8 @@ if (getDolGlobalString('MEMBER_SKIP_TABLE') || getDolGlobalString('MEMBER_NEWFOR
|
|||
break;
|
||||
|
||||
case "mor":
|
||||
$phyInput.prop({disabled: true, checked: false});
|
||||
$morInput.prop({disabled: false, checked: true});
|
||||
/* $phyInput.prop({disabled: true, checked: false});
|
||||
$morInput.prop({disabled: false, checked: true}); */
|
||||
$span2.addClass("member-company-back").removeClass("nonature-back");
|
||||
$span1.removeClass("member-individual-back").addClass("nonature-back");
|
||||
$tdCompany.addClass("fieldrequired");
|
||||
|
|
@ -810,7 +821,8 @@ if (getDolGlobalString('MEMBER_SKIP_TABLE') || getDolGlobalString('MEMBER_NEWFOR
|
|||
|
||||
default:';
|
||||
if ($action != "subscription" && !GETPOST('morphy')) {
|
||||
print ' $phyInput.prop({disabled: false, checked: false});
|
||||
print '
|
||||
$phyInput.prop({disabled: false, checked: false});
|
||||
$morInput.prop({disabled: false, checked: false});
|
||||
$span1.removeClass("member-individual-back").addClass("nonature-back");
|
||||
$span2.removeClass("member-company-back").addClass("nonature-back");';
|
||||
|
|
@ -875,10 +887,11 @@ if (getDolGlobalString('MEMBER_SKIP_TABLE') || getDolGlobalString('MEMBER_NEWFOR
|
|||
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 paddingright"');
|
||||
$country_id = GETPOSTINT('country_id');
|
||||
|
||||
// Country
|
||||
print '<tr><td class="fieldrequired">'.$langs->trans('Country').'</td><td>';
|
||||
print img_picto('', 'country', 'class="pictofixedwidth paddingright"');
|
||||
if (!$country_id && getDolGlobalString('MEMBER_NEWFORM_FORCECOUNTRYCODE')) {
|
||||
$country_id = getCountry(getDolGlobalString('MEMBER_NEWFORM_FORCECOUNTRYCODE'), '2', $db, $langs);
|
||||
}
|
||||
|
|
@ -894,7 +907,7 @@ if (getDolGlobalString('MEMBER_SKIP_TABLE') || getDolGlobalString('MEMBER_NEWFOR
|
|||
}
|
||||
}
|
||||
$country_code = getCountry($country_id, '2', $db, $langs);
|
||||
print $form->select_country($country_id, 'country_id', '', 0, 'minwidth150 maxwidth300 widthcentpercentminusx');
|
||||
print $form->select_country($country_id, 'country_id', '', 0, 'minwidth150 maxwidth300 widthcentpercentminusx reposition');
|
||||
print '</td></tr>';
|
||||
|
||||
// State
|
||||
|
|
@ -944,42 +957,165 @@ if (getDolGlobalString('MEMBER_SKIP_TABLE') || getDolGlobalString('MEMBER_NEWFOR
|
|||
print '<td class="tdtop"><textarea placeholder="'.dolPrintHTML($langs->trans("Comments")).'" 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.
|
||||
|
||||
// Define amount by default to suggest
|
||||
$typeid = getDolGlobalInt('MEMBER_NEWFORM_FORCETYPE', GETPOSTINT('typeid'));
|
||||
$adht = new AdherentType($db);
|
||||
$adht->fetch($typeid);
|
||||
$caneditamount = $adht->caneditamount;
|
||||
$amountbytype = $adht->amountByType(1); // Load the array of amount per type
|
||||
var_dump($amountbytype);
|
||||
foreach ($amountbytype as $k => $v) {
|
||||
$amount = max(0, (float) $v, (float) getDolGlobalInt("MEMBER_NEWFORM_AMOUNT"));
|
||||
$amountbytype[$k] = $amount;
|
||||
}
|
||||
|
||||
$amountbytype_json = json_encode($amountbytype);
|
||||
$caneditamountbytype = $adht->caneditamountByType(1); // Load the array of caneditamount per type
|
||||
$caneditamountbytype_json = json_encode($caneditamountbytype);
|
||||
|
||||
|
||||
// Set amount for the subscription from the the type and options:
|
||||
// - First check the amount of the member type.
|
||||
$amount = empty($amountbytype[$typeid]) ? 0 : $amountbytype[$typeid];
|
||||
var_dump($amountbytype);
|
||||
// - If not found, take the default amount only if the user is authorized to edit it
|
||||
if (empty($amount) && getDolGlobalString('MEMBER_NEWFORM_AMOUNT')) {
|
||||
$amount = getDolGlobalString('MEMBER_NEWFORM_AMOUNT');
|
||||
}
|
||||
// - If not set, we accept to have amount defined as parameter (for backward compatibility).
|
||||
if (empty($amount)) {
|
||||
$amount = (GETPOST('amount') ? price2num(GETPOST('amount', 'alpha'), 'MT', 2) : '');
|
||||
}
|
||||
// - If a min is set, we take it into account
|
||||
$amount = max(0, (float) $amount, (float) getDolGlobalInt("MEMBER_MIN_AMOUNT"));
|
||||
|
||||
// Clean the amount
|
||||
$amount = price2num($amount);
|
||||
|
||||
|
||||
|
||||
// Add hook to complete the form
|
||||
$parameters = array('country_id' => $country_id);
|
||||
$reshook = $hookmanager->executeHooks('membershipNewSubscriptionPublicForm', $parameters, $object, $action);
|
||||
if ($reshook < 0) {
|
||||
setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
|
||||
$error++;
|
||||
}
|
||||
// TODO Move this into previous hook
|
||||
if (getDolGlobalString('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").'</td><td>';
|
||||
print $form->selectarray('budget', $arraybudget, GETPOST('budget'), 1);
|
||||
// Do not set a default amount MEMBER_NEWFORM_AMOUNT if you use MEMBER_NEWFORM_DOLIBARRTURNOVER
|
||||
$s = $langs->trans("AreYouAPreferredPartner", '<a href="https://partners.dolibarr.org" target="_blank">{s1}</a>');
|
||||
$s = str_replace('{s1}', 'Peferred Partner', $s);
|
||||
print '<tr id="trbudget" class="trcompany"><td><label for="pp">'.$s.'</label></td><td>';
|
||||
print '<input type="checkbox" name="pp" id="pp" value="1"'.(GETPOST('pp') ? ' checked="checked"' : '').' class="reposition">';
|
||||
print '</td></tr>';
|
||||
|
||||
print '<tr id="trbudget" class="trcompany"><td class="fieldrequired">'.$langs->trans("TurnoverOrBudget").'</td><td>';
|
||||
|
||||
$country_code = dol_getIdFromCode($db, $country_id, 'c_country', 'rowid', 'code');
|
||||
if ($country_code === 'FR' && $checkednature === 'mor' && GETPOST('pp')) {
|
||||
print '<input type="text" name="budget" id="budget" class="flat turnover right width75" value="'.GETPOST('budget').'">';
|
||||
} else {
|
||||
$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 $form->selectarray('budget', $arraybudget, GETPOSTINT('budget'), 1, 0, '', 0, 0, 0, '');
|
||||
}
|
||||
print ' € or $';
|
||||
|
||||
print '<script type="text/javascript">
|
||||
jQuery(document).ready(function () {
|
||||
initturnover();
|
||||
jQuery(document).ready(function() {
|
||||
firstload = true;
|
||||
|
||||
jQuery("#morphy").change(function() {
|
||||
initturnover();
|
||||
newamount = initturnover();
|
||||
jQuery("#amount").val(newamount);
|
||||
|
||||
firstload = false;
|
||||
|
||||
jQuery("#selectcountry_id").change(function() {
|
||||
console.log("We change country (code added for association, replace common code), so we reload page");
|
||||
jQuery("#budget").val(\'\');
|
||||
jQuery("#amount").val(\'\');
|
||||
jQuery("#amounthidden").val(\'\');
|
||||
});
|
||||
jQuery("#phisicalinput,#moralinput").click(function() {
|
||||
console.log("We change the nature of membership");
|
||||
newamount = initturnover();
|
||||
jQuery("#amount").val(newamount);
|
||||
});
|
||||
jQuery("#pp").change(function() {
|
||||
console.log("We change the preferred partner status");
|
||||
selectcountry_id = jQuery("#selectcountry_id").val();
|
||||
morphy = jQuery("#moralinput").is(\':checked\') ? \'mor\' : \'phy\';
|
||||
jQuery("#budget").val(\'\');
|
||||
jQuery("#amount").val(\'\');
|
||||
jQuery("#amounthidden").val(\'\');
|
||||
document.newmember.action.value="create";
|
||||
jQuery("#newmember").submit();
|
||||
});
|
||||
jQuery("#budget").change(function() {
|
||||
if (jQuery("#budget").val() > 0) { jQuery(".amount").val(jQuery("#budget").val()); }
|
||||
else { jQuery("#budget").val(\'\'); }
|
||||
console.log("Turnover amount has been modified");
|
||||
newamount = initturnover();
|
||||
jQuery("#amount").val(newamount);
|
||||
});
|
||||
jQuery("#budget").keyup(function() {
|
||||
console.log("Turnover amount has been modified");
|
||||
newamount = initturnover();
|
||||
jQuery("#amount").val(newamount);
|
||||
});
|
||||
|
||||
function initturnover() {
|
||||
console.log("Set fields according to nature mor/phy");
|
||||
if (jQuery("#morphy").val()==\'phy\') {
|
||||
jQuery(".amount").val(20);
|
||||
jQuery("#trbudget").hide();
|
||||
jQuery("#trcompany").hide();
|
||||
}
|
||||
if (jQuery("#morphy").val()==\'mor\') {
|
||||
newamount = 0;
|
||||
|
||||
morphy = jQuery("#moralinput").is(\':checked\') ? \'mor\' : \'phy\';
|
||||
selectcountry_id = jQuery("#selectcountry_id").val();
|
||||
pp = jQuery("#pp").is(\':checked\') ? true : false;
|
||||
console.log("Set fields according to nature other properties");
|
||||
console.log("morphy="+morphy);
|
||||
console.log("selectcountry_id="+selectcountry_id);
|
||||
console.log("pp="+pp);
|
||||
|
||||
if (morphy == \'phy\') {
|
||||
jQuery(".amount").val('.((float) $amount).');
|
||||
jQuery("#trbirth").show();
|
||||
jQuery(".trcompany").hide();
|
||||
jQuery(".trbudget").hide();
|
||||
newamount = '.((float) $amount).';
|
||||
} else {
|
||||
jQuery(".amount").val(\'\');
|
||||
jQuery("#trcompany").show();
|
||||
jQuery("#trbirth").hide();
|
||||
jQuery("#trbudget").show();
|
||||
jQuery(".trcompany").show();
|
||||
jQuery(".trbudget").show();
|
||||
jQuery(".hideifautoturnover").hide();
|
||||
if (jQuery("#budget").val() > 0) { jQuery(".amount").val(jQuery("#budget").val()); }
|
||||
else { jQuery("#budget").val(\'\'); }
|
||||
if (firstload) {
|
||||
jQuery("#budget").val(\'\');
|
||||
}
|
||||
|
||||
if (selectcountry_id == 1) {
|
||||
if (pp) {
|
||||
console.log("value selected in input text field is "+jQuery("#budget").val());
|
||||
newamount = Math.max(Math.round(jQuery("#budget").val() * 0.005), 50);
|
||||
console.log("newamount = "+newamount);
|
||||
} else {
|
||||
console.log("not a pp");
|
||||
if (jQuery("#budget").val() > 0) {
|
||||
console.log("value found in budget is "+jQuery("#budget").val());
|
||||
newamount = jQuery("#budget").val();
|
||||
} else {
|
||||
jQuery("#budget").val(\'\');
|
||||
newamount = \'\';
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (jQuery("#budget").val() > 0) {
|
||||
newamount = jQuery("#budget").val();
|
||||
} else {
|
||||
jQuery("#budget").val(\'\');
|
||||
newamount = \'\';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return newamount;
|
||||
}
|
||||
});
|
||||
</script>';
|
||||
|
|
@ -987,42 +1123,12 @@ if (getDolGlobalString('MEMBER_SKIP_TABLE') || getDolGlobalString('MEMBER_NEWFOR
|
|||
}
|
||||
|
||||
if (getDolGlobalString('MEMBER_NEWFORM_PAYONLINE')) { // Can be 'all', 'paypal', 'paybox', 'stripe'...
|
||||
$typeid = getDolGlobalInt('MEMBER_NEWFORM_FORCETYPE', GETPOSTINT('typeid'));
|
||||
$adht = new AdherentType($db);
|
||||
$adht->fetch($typeid);
|
||||
$caneditamount = $adht->caneditamount;
|
||||
$amountbytype = $adht->amountByType(1); // Load the array of amount per type
|
||||
foreach ($amountbytype as $k => $v) {
|
||||
$amount = max(0, (float) $v, (float) getDolGlobalInt("MEMBER_MIN_AMOUNT"));
|
||||
$amountbytype[$k] = $amount;
|
||||
}
|
||||
|
||||
$amountbytype_json = json_encode($amountbytype);
|
||||
$caneditamountbytype = $adht->caneditamountByType(1); // Load the array of caneditamount per type
|
||||
$caneditamountbytype_json = json_encode($caneditamountbytype);
|
||||
|
||||
|
||||
// Set amount for the subscription from the the type and options:
|
||||
// - First check the amount of the member type.
|
||||
$amount = empty($amountbytype[$typeid]) ? 0 : $amountbytype[$typeid];
|
||||
// - If not found, take the default amount only if the user is authorized to edit it
|
||||
if (empty($amount) && getDolGlobalString('MEMBER_NEWFORM_AMOUNT')) {
|
||||
$amount = getDolGlobalString('MEMBER_NEWFORM_AMOUNT');
|
||||
}
|
||||
// - If not set, we accept to have amount defined as parameter (for backward compatibility).
|
||||
if (empty($amount)) {
|
||||
$amount = (GETPOST('amount') ? price2num(GETPOST('amount', 'alpha'), 'MT', 2) : '');
|
||||
}
|
||||
// - If a min is set, we take it into account
|
||||
$amount = max(0, (float) $amount, (float) getDolGlobalInt("MEMBER_MIN_AMOUNT"));
|
||||
|
||||
// Clean the amount
|
||||
$amount = price2num($amount);
|
||||
$showedamount = $amount > 0 ? $amount : 0;
|
||||
|
||||
print '<tr><td>'.$langs->trans("Subscription");
|
||||
if (getDolGlobalString('MEMBER_EXT_URL_SUBSCRIPTION_INFO')) {
|
||||
print ' - <a href="' . getDolGlobalString('MEMBER_EXT_URL_SUBSCRIPTION_INFO').'" rel="external" target="_blank" rel="noopener noreferrer">'.$langs->trans("SeeHere").'</a>';
|
||||
print '<br>';
|
||||
print '<a href="' . getDolGlobalString('MEMBER_EXT_URL_SUBSCRIPTION_INFO').'" rel="external" target="_blank" rel="noopener noreferrer">';
|
||||
print img_picto('', 'url', 'class="pictofixedwidth"').$langs->trans("SeeHere");
|
||||
print '</a>';
|
||||
}
|
||||
print '</td><td class="nowrap">';
|
||||
|
||||
|
|
@ -1030,19 +1136,20 @@ if (getDolGlobalString('MEMBER_SKIP_TABLE') || getDolGlobalString('MEMBER_NEWFOR
|
|||
$amount = getDolGlobalString('MEMBER_NEWFORM_AMOUNT');
|
||||
}
|
||||
|
||||
$showedamount = $amount > 0 ? $amount : 0;
|
||||
if ($caneditamount === "1") {
|
||||
print '<input type="text" name="amount" id="amount" class="flat amount width50" value="'.$showedamount.'">';
|
||||
print '<input type="text" name="amount" id="amounthidden" class="flat amount width50 hidden" disabled value="'.$showedamount.'">';
|
||||
print ' '.$langs->trans("Currency".$conf->currency).'<span class="opacitymedium hideifautoturnover">';
|
||||
print '<input type="text" name="amount" id="amount" class="flat amount right width75" value="'.$showedamount.'">';
|
||||
print '<input type="text" name="amount" id="amounthidden" class="flat amount width75 hidden" disabled value="'.$showedamount.'">';
|
||||
print ' '.$langs->getCurrencySymbol($conf->currency).'<span class="opacitymedium hideifautoturnover small">';
|
||||
if (!getDolGlobalString('MEMBER_NEWFORM_DOLIBARRTURNOVER')) {
|
||||
print ' - ';
|
||||
print $amount > 0 ? $langs->trans("AnyAmountWithAdvisedAmount", price($amount, 0, $langs, 1, -1, -1, $conf->currency)) : $langs->trans("AnyAmountWithoutAdvisedAmount");
|
||||
}
|
||||
print '</span>';
|
||||
} else {
|
||||
print '<input type="text" name="amount" id="amount" class="flat amount width50 hidden" value="'.$showedamount.'">';
|
||||
print '<input type="text" name="amount" id="amounthidden" class="flat amount width50" disabled value="'.$showedamount.'">';
|
||||
print ' '.$langs->trans("Currency".$conf->currency).'<span class="opacitymedium hideifautoturnover hidden">';
|
||||
print '<input type="text" name="amount" id="amount" class="flat amount width75 right hidden" value="'.$showedamount.'">';
|
||||
print '<input type="text" name="amount" id="amounthidden" class="flat amount width75" disabled value="'.$showedamount.'">';
|
||||
print ' '.$langs->getCurrencySymbol($conf->currency).'<span class="opacitymedium hideifautoturnover hidden small">';
|
||||
if (!getDolGlobalString('MEMBER_NEWFORM_DOLIBARRTURNOVER')) {
|
||||
print ' - ';
|
||||
print $amount > 0 ? $langs->trans("AnyAmountWithAdvisedAmount", price($amount, 0, $langs, 1, -1, -1, $conf->currency)) : $langs->trans("AnyAmountWithoutAdvisedAmount");
|
||||
|
|
|
|||
Loading…
Reference in a new issue