mirror of
https://github.com/Dolibarr/dolibarr.git
synced 2026-02-12 10:52:37 +01:00
New option to define the start period of a first subscription (#26484)
* New option to define the start period of a first subscription add default date of starting (year, month or subscription payment) add delay for subscription period * Update member.php * Fix period for statistique if delay is set
This commit is contained in:
@@ -9,6 +9,7 @@
|
||||
* Copyright (C) 2012 J. Fernando Lagrange <fernando@demo-tic.org>
|
||||
* Copyright (C) 2015 Jean-François Ferry <jfefe@aternatik.fr>
|
||||
* Copyright (C) 2020-2021 Frédéric France <frederic.france@netlogic.fr>
|
||||
* Copyright (C) 2023 Waël Almoman <info@almoman.com>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@@ -103,13 +104,15 @@ if ($action == 'set_default') {
|
||||
}
|
||||
} elseif ($action == 'updatemainoptions') {
|
||||
$db->begin();
|
||||
$res1 = $res2 = $res3 = $res4 = $res5 = $res6 = $res7 = 0;
|
||||
$res1 = $res2 = $res3 = $res4 = $res5 = $res6 = $res7 = $res8 = $res9 = 0;
|
||||
$res1 = dolibarr_set_const($db, 'ADHERENT_LOGIN_NOT_REQUIRED', GETPOST('ADHERENT_LOGIN_NOT_REQUIRED', 'alpha') ? 0 : 1, 'chaine', 0, '', $conf->entity);
|
||||
$res2 = dolibarr_set_const($db, 'ADHERENT_MAIL_REQUIRED', GETPOST('ADHERENT_MAIL_REQUIRED', 'alpha'), 'chaine', 0, '', $conf->entity);
|
||||
$res3 = dolibarr_set_const($db, 'ADHERENT_DEFAULT_SENDINFOBYMAIL', GETPOST('ADHERENT_DEFAULT_SENDINFOBYMAIL', 'alpha'), 'chaine', 0, '', $conf->entity);
|
||||
$res3 = dolibarr_set_const($db, 'ADHERENT_CREATE_EXTERNAL_USER_LOGIN', GETPOST('ADHERENT_CREATE_EXTERNAL_USER_LOGIN', 'alpha'), 'chaine', 0, '', $conf->entity);
|
||||
$res4 = dolibarr_set_const($db, 'ADHERENT_BANK_USE', GETPOST('ADHERENT_BANK_USE', 'alpha'), 'chaine', 0, '', $conf->entity);
|
||||
$res7 = dolibarr_set_const($db, 'MEMBER_PUBLIC_ENABLED', GETPOST('MEMBER_PUBLIC_ENABLED', 'alpha'), 'chaine', 0, '', $conf->entity);
|
||||
$res8 = dolibarr_set_const($db, 'MEMBER_SUBSCRIPTION_START_FIRST_DAY_OF', GETPOST('MEMBER_SUBSCRIPTION_START_FIRST_DAY_OF', 'alpha'), 'chaine', 0, '', $conf->entity);
|
||||
$res9 = dolibarr_set_const($db, 'MEMBER_SUBSCRIPTION_START_AFTER', GETPOST('MEMBER_SUBSCRIPTION_START_AFTER', 'alpha'), 'chaine', 0, '', $conf->entity);
|
||||
// Use vat for invoice creation
|
||||
if (isModEnabled('facture')) {
|
||||
$res4 = dolibarr_set_const($db, 'ADHERENT_VAT_FOR_SUBSCRIPTIONS', GETPOST('ADHERENT_VAT_FOR_SUBSCRIPTIONS', 'alpha'), 'chaine', 0, '', $conf->entity);
|
||||
@@ -335,6 +338,24 @@ print '<td>'.$langs->trans("Description").'</td>';
|
||||
print '<td>'.$langs->trans("Value").'</td>';
|
||||
print "</tr>\n";
|
||||
|
||||
// Start date of new membership
|
||||
$startpoint[0] = $langs->trans("SubscriptionPayment");
|
||||
$startpoint["m"] = $langs->trans("Month");
|
||||
$startpoint["Y"] = $langs->trans("Year");
|
||||
print '<tr class="oddeven drag" id="startfirstdayof"><td>';
|
||||
print $langs->trans("MemberSubscriptionStartFirstDayOf");
|
||||
print '</td><td>';
|
||||
$startfirstdayof = !getDolGlobalString('MEMBER_SUBSCRIPTION_START_FIRST_DAY_OF') ? 0 : getDolGlobalString('MEMBER_SUBSCRIPTION_START_FIRST_DAY_OF');
|
||||
print $form->selectarray("MEMBER_SUBSCRIPTION_START_FIRST_DAY_OF", $startpoint, $startfirstdayof, 0);
|
||||
print "</td></tr>\n";
|
||||
|
||||
// Delay to start the new membership ([+/-][0-99][Y/m/d], for instance, with "+4m", the subscription will start in 4 month.)
|
||||
print '<tr class="oddeven drag" id="startfirstdayof"><td>';
|
||||
print $langs->trans("MemberSubscriptionStartAfter");
|
||||
print '</td><td>';
|
||||
print '<input type="text" class="right width50" id="MEMBER_SUBSCRIPTION_START_AFTER" name="MEMBER_SUBSCRIPTION_START_AFTER" value="'.(getDolGlobalString('MEMBER_SUBSCRIPTION_START_AFTER') ? getDolGlobalString('MEMBER_SUBSCRIPTION_START_AFTER') : '').'">';
|
||||
print "</td></tr>\n";
|
||||
|
||||
// Mail required for members
|
||||
print '<tr class="oddeven"><td>'.$langs->trans("AdherentMailRequired").'</td><td>';
|
||||
print $form->selectyesno('ADHERENT_MAIL_REQUIRED', (getDolGlobalString('ADHERENT_MAIL_REQUIRED') ? $conf->global->ADHERENT_MAIL_REQUIRED : 0), 1);
|
||||
|
||||
@@ -48,8 +48,11 @@ if ($user->socid > 0) {
|
||||
$result = restrictedArea($user, 'adherent', '', '', 'cotisation');
|
||||
|
||||
$year = dol_print_date(dol_now('gmt'), "%Y", 'gmt');
|
||||
$startyear = $year - (!getDolGlobalString('MAIN_STATS_GRAPHS_SHOW_N_YEARS') ? 2 : max(1, min(10, $conf->global->MAIN_STATS_GRAPHS_SHOW_N_YEARS)));
|
||||
$startyear = $year - (!getDolGlobalInt('MAIN_STATS_GRAPHS_SHOW_N_YEARS') ? 2 : max(1, min(10, getDolGlobalInt('MAIN_STATS_GRAPHS_SHOW_N_YEARS'))));
|
||||
$endyear = $year;
|
||||
if (!empty(getDolGlobalString('MEMBER_SUBSCRIPTION_START_AFTER')) ) {
|
||||
$endyear = dol_print_date(dol_time_plus_duree(dol_now('gmt'), (int) substr(getDolGlobalString('MEMBER_SUBSCRIPTION_START_AFTER'), 0, -1), substr(getDolGlobalString('MEMBER_SUBSCRIPTION_START_AFTER'), -1)), "%Y", 'gmt');
|
||||
}
|
||||
|
||||
// Load translation files required by the page
|
||||
$langs->loadLangs(array("companies", "members"));
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
* Copyright (C) 2015-2016 Alexandre Spangaro <aspangaro@open-dsi.fr>
|
||||
* Copyright (C) 2018-2023 Frédéric France <frederic.france@netlogic.fr>
|
||||
* Copyright (C) 2019 Thibault FOUCART <support@ptibogxiv.net>
|
||||
* Copyright (C) 2023 Waël Almoman <info@almoman.com>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@@ -53,7 +54,7 @@ $typeid = GETPOST('typeid', 'int');
|
||||
$cancel = GETPOST('cancel');
|
||||
|
||||
// Load variable for pagination
|
||||
$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit;
|
||||
$limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit;
|
||||
$sortfield = GETPOST('sortfield', 'aZ09comma');
|
||||
$sortorder = GETPOST('sortorder', 'aZ09comma');
|
||||
$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
|
||||
@@ -960,8 +961,6 @@ if (($action == 'addsubscription' || $action == 'create_thirdparty') && $user->h
|
||||
print '<table class="border centpercent">'."\n";
|
||||
print '<tbody>';
|
||||
|
||||
$now = dol_now();
|
||||
|
||||
// Date payment
|
||||
if (GETPOST('paymentyear') && GETPOST('paymentmonth') && GETPOST('paymentday')) {
|
||||
$paymentdate = dol_mktime(0, 0, 0, GETPOST('paymentmonth'), GETPOST('paymentday'), GETPOST('paymentyear'));
|
||||
@@ -977,10 +976,16 @@ if (($action == 'addsubscription' || $action == 'create_thirdparty') && $user->h
|
||||
}
|
||||
if (!$datefrom) {
|
||||
$datefrom = $object->datevalid;
|
||||
if ($object->datefin > 0 && dol_time_plus_duree($object->datefin, $defaultdelay, $defaultdelayunit) > dol_now()) {
|
||||
if (!empty(getDolGlobalString('MEMBER_SUBSCRIPTION_START_AFTER')) ) {
|
||||
$datefrom = dol_time_plus_duree($now, (int) substr(getDolGlobalString('MEMBER_SUBSCRIPTION_START_AFTER'), 0, -1), substr(getDolGlobalString('MEMBER_SUBSCRIPTION_START_AFTER'), -1));
|
||||
} elseif ($object->datefin > 0 && dol_time_plus_duree($object->datefin, $defaultdelay, $defaultdelayunit) > $now) {
|
||||
$datefrom = dol_time_plus_duree($object->datefin, 1, 'd');
|
||||
} else {
|
||||
$datefrom = dol_get_first_day($currentyear);
|
||||
}
|
||||
|
||||
if (getDolGlobalString('MEMBER_SUBSCRIPTION_START_FIRST_DAY_OF') === "m") {
|
||||
$datefrom = dol_get_first_day(dol_print_date($datefrom, "%Y"), dol_print_date($datefrom, "%m"));
|
||||
} elseif (getDolGlobalString('MEMBER_SUBSCRIPTION_START_FIRST_DAY_OF') === "Y") {
|
||||
$datefrom = dol_get_first_day(dol_print_date($datefrom, "%Y"));
|
||||
}
|
||||
}
|
||||
print $form->selectDate($datefrom, '', '', '', '', "subscription", 1, 1);
|
||||
|
||||
@@ -241,3 +241,5 @@ MemberFirstname=Member firstname
|
||||
MemberLastname=Member lastname
|
||||
MemberCodeDesc=Member Code, unique for all members
|
||||
NoRecordedMembers=No recorded members
|
||||
MemberSubscriptionStartFirstDayOf=The start date of a membership corresponds to the first day of a
|
||||
MemberSubscriptionStartAfter=Minimum period before the entry into force of the start date of a subscription except renewals (example +3m = +3 months, -5d = -3 days, +1Y = +1 year) (example: +3m = +3 months, -5d = -3 days, +1Y = +1 year)
|
||||
@@ -241,3 +241,5 @@ MemberFirstname=Prénom du membre
|
||||
MemberLastname=Nom de famille du membre
|
||||
MemberCodeDesc=Code membre, unique pour tous les membres
|
||||
NoRecordedMembers=Aucun membre enregistré
|
||||
MemberSubscriptionStartFirstDayOf=La date de début d'une adhésion correspond au premier jour d'un(e)
|
||||
MemberSubscriptionStartAfter=Délai minimum avant l'entrée en vigueur de la date de début d'une souscription hors renouvellement (exemple +3m = +3 mois, -5d = -3 jours, +1Y = +1 année)
|
||||
@@ -2,7 +2,7 @@
|
||||
/* Copyright (C) 2001-2002 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
||||
* Copyright (C) 2006-2013 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
* Copyright (C) 2012 Regis Houssin <regis.houssin@inodbox.com>
|
||||
* Copyright (C) 2021 Waël Almoman <info@almoman.com>
|
||||
* Copyright (C) 2021-2023 Waël Almoman <info@almoman.com>
|
||||
* Copyright (C) 2021 Maxime Demarest <maxime@indelog.fr>
|
||||
* Copyright (C) 2021 Dorian Vabre <dorian.vabre@gmail.com>
|
||||
*
|
||||
@@ -522,9 +522,17 @@ if ($ispaymentok) {
|
||||
}
|
||||
|
||||
// Subscription informations
|
||||
$datesubscription = $object->datevalid;
|
||||
$datesubscription = $object->datevalid; // By default, the subscription start date is the payment date
|
||||
if ($object->datefin > 0) {
|
||||
$datesubscription = dol_time_plus_duree($object->datefin, 1, 'd');
|
||||
} elseif (getDolGlobalString('MEMBER_SUBSCRIPTION_START_AFTER')) {
|
||||
$datesubscription = dol_time_plus_duree($now, (int) substr(getDolGlobalString('MEMBER_SUBSCRIPTION_START_AFTER'), 0, -1), substr(getDolGlobalString('MEMBER_SUBSCRIPTION_START_AFTER'), -1));
|
||||
}
|
||||
|
||||
if (getDolGlobalString('MEMBER_SUBSCRIPTION_START_FIRST_DAY_OF') === "m") {
|
||||
$datesubscription = dol_get_first_day(dol_print_date($datesubscription, "%Y"), dol_print_date($datesubscription, "%m"));
|
||||
} elseif (getDolGlobalString('MEMBER_SUBSCRIPTION_START_FIRST_DAY_OF') === "Y") {
|
||||
$datesubscription = dol_get_first_day(dol_print_date($datesubscription, "%Y"));
|
||||
}
|
||||
|
||||
$datesubend = null;
|
||||
|
||||
Reference in New Issue
Block a user