diff --git a/htdocs/adherents/card.php b/htdocs/adherents/card.php index 0096ba9a285..c60308138d2 100644 --- a/htdocs/adherents/card.php +++ b/htdocs/adherents/card.php @@ -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(''.$langs->trans('WarningMandatorySetupNotComplete').'', null, 'errors'); $error++; } else { $substitutionarray = getCommonSubstitutionArray($outputlangs, 0, null, $object); @@ -2028,9 +2029,14 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { if ($useonlinepayment) { print '
'; - + 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 '
'; diff --git a/htdocs/adherents/class/adherent_type.class.php b/htdocs/adherents/class/adherent_type.class.php index 3f857ce827b..86ec35139e1 100644 --- a/htdocs/adherents/class/adherent_type.class.php +++ b/htdocs/adherents/class/adherent_type.class.php @@ -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; diff --git a/htdocs/adherents/type.php b/htdocs/adherents/type.php index bcd6c99afbf..0f1acf1bed0 100644 --- a/htdocs/adherents/type.php +++ b/htdocs/adherents/type.php @@ -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 ''.$langs->trans("MembersNature").''; print ''.$langs->trans("SubscriptionRequired").''; print ''.$langs->trans("Amount").''; + print ''.$langs->trans("CanEditAmountShort").''; print ''.$langs->trans("VoteAllowed").''; print ''.$langs->trans("Status").''; print ' '; @@ -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 ''; print ''; @@ -310,6 +313,7 @@ if (!$rowid && $action != 'create' && $action != 'edit') { print ''; print ''.yn($objp->subscription).''; print ''.(is_null($objp->amount) || $objp->amount === '' ? '' : price($objp->amount)).''; + print ''.yn($objp->caneditamount).''; print ''.yn($objp->vote).''; print ''.$membertype->getLibStatut(5).''; if ($user->rights->adherent->configurer) { @@ -380,6 +384,10 @@ if ($action == 'create') { print ''; print ''; + print ''.$langs->trans("CanEditAmountShort").''; + print $form->selectyesno("caneditamount", 0, 1); + print ''; + print ''.$langs->trans("VoteAllowed").''; print $form->selectyesno("vote", GETPOSTISSET("vote") ? GETPOST('vote', 'aZ09') : 1, 1); print ''; diff --git a/htdocs/core/lib/payments.lib.php b/htdocs/core/lib/payments.lib.php index fe89dcea00f..809b5f8dc73 100644 --- a/htdocs/core/lib/payments.lib.php +++ b/htdocs/core/lib/payments.lib.php @@ -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').' '.$langs->trans("ToOfferALinkForOnlinePayment", $servicename).'
'; - $url = getOnlinePaymentUrl(0, $type, $ref); + $url = getOnlinePaymentUrl(0, $type, $ref, $amount); $out .= ''; @@ -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 ''.$label.''; } @@ -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 ? '' : ''); + $out = $urltouse.'/public/payment/newpayment.php?source=member'; + $out .= '&amount='.$amount; + $out .= '&ref='.($mode ? '' : ''); if ($mode == 1) { $out .= 'member_ref'; } diff --git a/htdocs/core/triggers/interface_50_modAgenda_ActionsAuto.class.php b/htdocs/core/triggers/interface_50_modAgenda_ActionsAuto.class.php index 0e018514353..4e926050f24 100644 --- a/htdocs/core/triggers/interface_50_modAgenda_ActionsAuto.class.php +++ b/htdocs/core/triggers/interface_50_modAgenda_ActionsAuto.class.php @@ -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 diff --git a/htdocs/install/mysql/migration/16.0.0-17.0.0.sql b/htdocs/install/mysql/migration/16.0.0-17.0.0.sql index 41669848486..fa61ba725de 100644 --- a/htdocs/install/mysql/migration/16.0.0-17.0.0.sql +++ b/htdocs/install/mysql/migration/16.0.0-17.0.0.sql @@ -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; diff --git a/htdocs/langs/en_US/agenda.lang b/htdocs/langs/en_US/agenda.lang index 272ec22df5c..b8f9ffa857b 100644 --- a/htdocs/langs/en_US/agenda.lang +++ b/htdocs/langs/en_US/agenda.lang @@ -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 diff --git a/htdocs/langs/en_US/install.lang b/htdocs/langs/en_US/install.lang index a6716034c2d..32f251707a4 100644 --- a/htdocs/langs/en_US/install.lang +++ b/htdocs/langs/en_US/install.lang @@ -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. diff --git a/htdocs/langs/en_US/members.lang b/htdocs/langs/en_US/members.lang index 1c205f48f46..e4ca610c44f 100644 --- a/htdocs/langs/en_US/members.lang +++ b/htdocs/langs/en_US/members.lang @@ -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.

ThisIsContentOfYourMembershipWasValidated=We want to let you know that your membership was validated with the following information:

-ThisIsContentOfYourSubscriptionWasRecorded=We want to let you know that your new subscription was recorded.

+ThisIsContentOfYourSubscriptionWasRecorded=We want to let you know that your new subscription was recorded. Please find your invoice here enclosed.

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.

ThisIsContentOfYourCard=This is a summary of the information we have about you. Please contact us if anything is incorrect.

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 diff --git a/htdocs/langs/en_US/paypal.lang b/htdocs/langs/en_US/paypal.lang index beaf9a5ea3f..a935cd38434 100644 --- a/htdocs/langs/en_US/paypal.lang +++ b/htdocs/langs/en_US/paypal.lang @@ -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
Paid via %s
Originating IP address: %s
Transaction ID: %s diff --git a/htdocs/langs/fr_FR/members.lang b/htdocs/langs/fr_FR/members.lang index a6f805daca6..a5a76c9be55 100644 --- a/htdocs/langs/fr_FR/members.lang +++ b/htdocs/langs/fr_FR/members.lang @@ -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 diff --git a/htdocs/public/members/new.php b/htdocs/public/members/new.php index 31f1fa9f952..7b9f59ee5cc 100644 --- a/htdocs/public/members/new.php +++ b/htdocs/public/members/new.php @@ -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 '
'."\n"; print ''; print ''; -print ''; -print ''; -print '
'; +if (!empty($conf->global->MEMBER_SKIP_TABLE) || !empty($conf->global->MEMBER_NEWFORM_FORCETYPE) || $action == 'create') { + print ''; + print '
'; + print '
'.$langs->trans("FieldsWithAreMandatory", '*').'
'; + //print $langs->trans("FieldsWithIsForPublic",'**').'
'; -print '
'.$langs->trans("FieldsWithAreMandatory", '*').'
'; -//print $langs->trans("FieldsWithIsForPublic",'**').'
'; - -print dol_get_fiche_head(''); - -print ''; - - -print ''."\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 ''."\n"; -} else { - $adht->fetch($conf->global->MEMBER_NEWFORM_FORCETYPE); - print ''; -} - -// Moral/Physic attribute -$morphys["phy"] = $langs->trans("Physical"); -$morphys["mor"] = $langs->trans("Moral"); -if (empty($conf->global->MEMBER_NEWFORM_FORCEMORPHY)) { - print ''."\n"; -} else { - print $morphys[$conf->global->MEMBER_NEWFORM_FORCEMORPHY]; - print ''; -} - -// Company -print ''."\n"; -// Title -print ''."\n"; -// Lastname -print ''."\n"; -// Firstname -print ''."\n"; -// EMail -print ''."\n"; -// Login -if (empty($conf->global->ADHERENT_LOGIN_NOT_REQUIRED)) { - print ''."\n"; - print ''."\n"; - print ''."\n"; -} -// Gender -print ''; -print ''; -// Address -print ''."\n"; -// Zip / Town -print ''; -// Country -print ''; -// State -if (empty($conf->global->SOCIETE_DISABLE_STATE)) { - print ''; -} -// Birthday -print ''."\n"; -// Photo -print ''."\n"; -// Public -print ''."\n"; -// Other attributes -$tpl_context = 'public'; // define template context to public -include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_add.tpl.php'; -// Comments -print ''; -print ''; -print ''; -print ''."\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 ''."\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(); + }); + }); + }); + '; -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 '
'.$langs->trans("Type").' *'; - print $form->selectarray("typeid", $adht->liste_array(1), GETPOST('typeid') ? GETPOST('typeid') : $defaulttype, $isempty); - print '
'.$langs->trans('MemberNature').' *'."\n"; - print $form->selectarray("morphy", $morphys, GETPOST('morphy'), 1); - print '
'.$langs->trans("Company").''; -print img_picto('', 'company', 'class="pictofixedwidth"'); -print '
'.$langs->trans('UserTitle').''; -print $formcompany->select_civility(GETPOST('civility_id'), 'civility_id').'
'.$langs->trans("Lastname").' *
'.$langs->trans("Firstname").' *
'.$langs->trans("Email").($conf->global->ADHERENT_MAIL_REQUIRED ? ' *' : '').''; -//print img_picto('', 'email', 'class="pictofixedwidth"'); -print '
'.$langs->trans("Login").' *
'.$langs->trans("Password").' *
'.$langs->trans("PasswordAgain").' *
'.$langs->trans("Gender").''; -$arraygender = array('man'=>$langs->trans("Genderman"), 'woman'=>$langs->trans("Genderwoman")); -print $form->selectarray('gender', $arraygender, GETPOST('gender') ?GETPOST('gender') : $object->gender, 1); -print '
'.$langs->trans("Address").''."\n"; -print '
'.$langs->trans('Zip').' / '.$langs->trans('Town').''; -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 '
'.$langs->trans('Country').''; -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 '
'.$langs->trans('State').''; - if ($country_code) { - print $formcompany->select_state(GETPOST("state_id"), $country_code); - } - print '
'.$langs->trans("DateOfBirth").''; -print $form->selectDate($birthday, 'birth', 0, 0, 1, "newmember", 1, 0); -print '
'.$langs->trans("URLPhoto").'
'.$langs->trans("Public").'
'.$langs->trans("Comments").'
'.$langs->trans("TurnoverOrBudget").' *'; - print $form->selectarray('budget', $arraybudget, GETPOST('budget'), 1); - print ' € or $'; + print dol_get_fiche_head(''); print ''; - print '
'."\n"; - // Clean the amount - $amount = price2num($amount); - - // $conf->global->MEMBER_NEWFORM_PAYONLINE is 'paypal', 'paybox' or 'stripe' - print ''."\n"; } else { - print ''; - print ''; + $adht->fetch($conf->global->MEMBER_NEWFORM_FORCETYPE); + print ''; } - 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 ''."\n"; + } else { + print $morphys[$conf->global->MEMBER_NEWFORM_FORCEMORPHY]; + print ''; + } + + // Company + print ''."\n"; + // Title + print ''."\n"; + // Lastname + print ''."\n"; + // Firstname + print ''."\n"; + // EMail + print ''."\n"; + // Login + if (empty($conf->global->ADHERENT_LOGIN_NOT_REQUIRED)) { + print ''."\n"; + print ''."\n"; + print ''."\n"; + } + // Gender + print ''; + print ''; + // Address + print ''."\n"; + // Zip / Town + print ''; + // Country + print ''; + // State + if (empty($conf->global->SOCIETE_DISABLE_STATE)) { + print ''; + } + // Birthday + print ''."\n"; + // Photo + print ''."\n"; + // Public + print ''."\n"; + // Other attributes + $tpl_context = 'public'; // define template context to public + include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_add.tpl.php'; + // Comments + print ''; + print ''; + print ''; + print ''."\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 ''."\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 ''; + } + + print "
'.$langs->trans("Subscription").''; - if (!empty($conf->global->MEMBER_NEWFORM_EDITAMOUNT)) { - print ''; + // 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 '
'.$langs->trans("Type").' *'; + print $form->selectarray("typeid", $adht->liste_array(1), GETPOST('typeid') ? GETPOST('typeid') : $defaulttype, $isempty); + print '
'.$langs->trans('MemberNature').' *'."\n"; + print $form->selectarray("morphy", $morphys, GETPOST('morphy'), 1); + print '
'.$langs->trans("Company").''; + print img_picto('', 'company', 'class="pictofixedwidth"'); + print '
'.$langs->trans('UserTitle').''; + print $formcompany->select_civility(GETPOST('civility_id'), 'civility_id').'
'.$langs->trans("Lastname").' *
'.$langs->trans("Firstname").' *
'.$langs->trans("Email").($conf->global->ADHERENT_MAIL_REQUIRED ? ' *' : '').''; + //print img_picto('', 'email', 'class="pictofixedwidth"'); + print '
'.$langs->trans("Login").' *
'.$langs->trans("Password").' *
'.$langs->trans("PasswordAgain").' *
'.$langs->trans("Gender").''; + $arraygender = array('man'=>$langs->trans("Genderman"), 'woman'=>$langs->trans("Genderwoman")); + print $form->selectarray('gender', $arraygender, GETPOST('gender') ?GETPOST('gender') : $object->gender, 1); print '
'.$langs->trans("Address").''."\n"; + print '
'.$langs->trans('Zip').' / '.$langs->trans('Town').''; + 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 '
'.$langs->trans('Country').''; + 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 '
'.$langs->trans('State').''; + if ($country_code) { + print $formcompany->select_state(GETPOST("state_id"), $country_code); + } + print '
'.$langs->trans("DateOfBirth").''; + print $form->selectDate($birthday, 'birth', 0, 0, 1, "newmember", 1, 0); + print '
'.$langs->trans("URLPhoto").'
'.$langs->trans("Public").'
'.$langs->trans("Comments").'
'.$langs->trans("TurnoverOrBudget").' *'; + print $form->selectarray('budget', $arraybudget, GETPOST('budget'), 1); + print ' € or $'; + + print ''; + print '
'.$langs->trans("Subscription"); + if (!empty($conf->global->MEMBER_EXT_URL_SUBSCRIPTION_INFO)) { + print ' - '.$langs->trans("SeeHere").''; + } + print ''; + + if (empty($amount) && !empty($conf->global->MEMBER_NEWFORM_AMOUNT)) { + $amount = $conf->global->MEMBER_NEWFORM_AMOUNT; + } + + if (!empty($conf->global->MEMBER_NEWFORM_EDITAMOUNT) || $caneditamount) { + print ''; + print ' '.$langs->trans("Currency".$conf->currency).' – '; + print $amount>0? $langs->trans("AnyAmountWithAdvisedAmount", $amount, $langs->trans("Currency".$conf->currency)): $langs->trans("AnyAmountWithoutAdvisedAmount"); + print ''; + } else { + print ''; + print ''; + print ' '.$langs->trans("Currency".$conf->currency); + } + print '
\n"; + + print dol_get_fiche_end(); + + // Save + print '
'; + print ''; + if (!empty($backtopage)) { + print '     '; + } + print '
'; + + + print "
\n"; + print "
"; + print '
'; } +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 "\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 '
'; -print ''; -if (!empty($backtopage)) { - print '     '; + print '
'; + print ''."\n"; + print ''; + + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print "\n"; + + $i = 0; + while ($i < $num) { + $objp = $db->fetch_object($result); + + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ""; + $i++; + } + + // If no record found + if ($num == 0) { + $colspan = 8; + print ''; + } + + print "
'.$langs->trans("Label").''.$langs->trans("MembershipDuration").''.$langs->trans("Amount").''.$langs->trans("MembersNature").''.$langs->trans("VoteAllowed").''.$langs->trans("NewSubscription").'
'.dol_escape_htmltag($objp->label).''; + $unit = preg_replace("/[^a-zA-Z]+/", "", $objp->duration); + print max(1, intval($objp->duration)).' '.$units[$unit]; + print ''; + $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 ''; + if ($objp->morphy == 'phy') { + print $langs->trans("Physical"); + } elseif ($objp->morphy == 'mor') { + print $langs->trans("Moral"); + } else { + print $langs->trans("MorAndPhy"); + } + print ''.yn($objp->vote).'
'.$langs->trans("NoRecordFound").'
"; + print '
'; + + print ''; + } else { + dol_print_error($db); + } } -print '
'; - - -print "\n"; -print "
"; -print ''; llxFooterVierge(); diff --git a/htdocs/public/payment/newpayment.php b/htdocs/public/payment/newpayment.php index b61a2e22a06..faf3cafc59a 100644 --- a/htdocs/public/payment/newpayment.php +++ b/htdocs/public/payment/newpayment.php @@ -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 ''; 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 "\n"; - } elseif ($action == dopayment) { + } elseif ($action == 'dopayment') { print ''.$langs->trans("NewMemberType"); print ''.dol_escape_htmltag($member->type); print ''; @@ -1611,57 +1611,23 @@ if ($source == 'member' || $source == 'membersubscription') { // Amount print ''.$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 ' - '.$langs->trans("SeeHere").''; - } - 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 ' - '.$langs->trans("SeeHere").''; } print ''; - $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 ''; - if (empty($conf->global->MEMBER_NEWFORM_EDITAMOUNT)) { - print ''; - print ''; - } else { - print ''; - } - print ' '.$langs->trans("Currency".$currency).''; - } else { - $valtoshow = $amount; - if (!empty($conf->global->MEMBER_MIN_AMOUNT) && $valtoshow) { - $valtoshow = max($conf->global->MEMBER_MIN_AMOUNT, $valtoshow); - $amount = $valtoshow; - } - print ''.price($valtoshow, 1, $langs, 1, -1, -1, $currency).''; // Price with currency - print ''; - print ''; + print ''.price($amount, 1, $langs, 1, -1, -1, $currency).''; // 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 ''; + print ''; print ''; print ''."\n"; diff --git a/htdocs/public/payment/paymentok.php b/htdocs/public/payment/paymentok.php index c0b88736ce3..992e7ab403d 100644 --- a/htdocs/public/payment/paymentok.php +++ b/htdocs/public/payment/paymentok.php @@ -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