Merge pull request #23302 from frederic34/membernumbering

NEW add numbering modules for members
This commit is contained in:
Laurent Destailleur 2022-12-21 19:21:21 +01:00 committed by GitHub
commit f11c4c3e2f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
68 changed files with 492 additions and 168 deletions

View File

@ -152,10 +152,13 @@ if ($action == 'set_default') {
setEventMessages('RecordModifiedSuccessfully', null, 'mesgs');
$db->commit();
}
}
// Action to update or add a constant
if ($action == 'update' || $action == 'add') {
} elseif ($action == 'setcodemember') {
$result = dolibarr_set_const($db, "MEMBER_CODEMEMBER_ADDON", $value, 'chaine', 0, '', $conf->entity);
if ($result <= 0) {
dol_print_error($db);
}
} elseif ($action == 'update' || $action == 'add') {
// Action to update or add a constant
$constname = GETPOST('constname', 'alpha');
$constvalue = (GETPOST('constvalue_'.$constname) ? GETPOST('constvalue_'.$constname) : GETPOST('constvalue'));
@ -223,6 +226,97 @@ $head = member_admin_prepare_head();
print dol_get_fiche_head($head, 'general', $langs->trans("Members"), -1, 'user');
$dirModMember = array_merge(array('/core/modules/member/'), $conf->modules_parts['member']);
foreach ($conf->modules_parts['models'] as $mo) {
//Add more models
$dirModMember[] = $mo.'core/modules/member/';
}
// Module to manage customer/supplier code
print load_fiche_titre($langs->trans("MemberCodeChecker"), '', '');
print '<div class="div-table-responsive-no-min">';
print '<table class="noborder centpercent">'."\n";
print '<tr class="liste_titre">'."\n";
print ' <td>'.$langs->trans("Name").'</td>';
print ' <td>'.$langs->trans("Description").'</td>';
print ' <td>'.$langs->trans("Example").'</td>';
print ' <td class="center" width="80">'.$langs->trans("Status").'</td>';
print ' <td class="center" width="60">'.$langs->trans("ShortInfo").'</td>';
print "</tr>\n";
$arrayofmodules = array();
foreach ($dirModMember as $dirroot) {
$dir = dol_buildpath($dirroot, 0);
$handle = @opendir($dir);
if (is_resource($handle)) {
// Loop on each module find in opened directory
while (($file = readdir($handle)) !== false) {
// module filename has to start with mod_member_
if (substr($file, 0, 11) == 'mod_member_' && substr($file, -3) == 'php') {
$file = substr($file, 0, dol_strlen($file) - 4);
try {
dol_include_once($dirroot.$file.'.php');
} catch (Exception $e) {
dol_syslog($e->getMessage(), LOG_ERR);
continue;
}
$modCodeMember = new $file;
// Show modules according to features level
if ($modCodeMember->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) {
continue;
}
if ($modCodeMember->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) {
continue;
}
$arrayofmodules[$file] = $modCodeMember;
}
}
closedir($handle);
}
}
$arrayofmodules = dol_sort_array($arrayofmodules, 'position');
foreach ($arrayofmodules as $file => $modCodeMember) {
print '<tr class="oddeven">'."\n";
print '<td width="140">'.$modCodeMember->name.'</td>'."\n";
print '<td>'.$modCodeMember->info($langs).'</td>'."\n";
print '<td class="nowrap">'.$modCodeMember->getExample($langs).'</td>'."\n";
if (getDolGlobalString('MEMBER_CODEMEMBER_ADDON') == "$file") {
print '<td class="center">'."\n";
print img_picto($langs->trans("Activated"), 'switch_on');
print "</td>\n";
} else {
$disabled = (isModEnabled('multicompany') && (is_object($mc) && !empty($mc->sharings['referent']) && $mc->sharings['referent'] != $conf->entity) ? true : false);
print '<td class="center">';
if (!$disabled) {
print '<a class="reposition" href="'.$_SERVER['PHP_SELF'].'?action=setcodemember&token='.newToken().'&value='.urlencode($file).'">';
}
print img_picto($langs->trans("Disabled"), 'switch_off');
if (!$disabled) {
print '</a>';
}
print '</td>';
}
print '<td class="center">';
$s = $modCodeMember->getToolTip($langs, null, -1);
print $form->textwithpicto('', $s, 1);
print '</td>';
print '</tr>';
}
print '</table>';
print '</div>';
print "<br>";
print '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
print '<input type="hidden" name="token" value="'.newToken().'">';
print '<input type="hidden" name="action" value="updatemainoptions">';

View File

@ -92,6 +92,7 @@ class Adherent extends CommonObject
/**
* @var string company name
* @deprecated
* @see $company
*/
public $societe;
@ -102,8 +103,14 @@ class Adherent extends CommonObject
/**
* @var int Thirdparty ID
* @deprecated
* @see $socid
*/
public $fk_soc;
/**
* @var int socid
*/
public $socid;
/**
@ -154,24 +161,28 @@ class Adherent extends CommonObject
/**
* @var string skype account
* @deprecated
* @see $socialnetworks
*/
public $skype;
/**
* @var string twitter account
* @deprecated
* @see $socialnetworks
*/
public $twitter;
/**
* @var string facebook account
* @deprecated
* @see $socialnetworks
*/
public $facebook;
/**
* @var string linkedin account
* @deprecated
* @see $socialnetworks
*/
public $linkedin;
@ -259,10 +270,19 @@ class Adherent extends CommonObject
*/
public $type;
/**
* @var int need_subscription
*/
public $need_subscription;
/**
* @var int user_id
*/
public $user_id;
/**
* @var string user_login
*/
public $user_login;
public $datefin;
@ -576,7 +596,7 @@ class Adherent extends CommonObject
*/
public function create($user, $notrigger = 0)
{
global $conf, $langs;
global $conf, $langs, $mysoc;
$error = 0;
@ -624,7 +644,22 @@ class Adherent extends CommonObject
$id = $this->db->last_insert_id(MAIN_DB_PREFIX."adherent");
if ($id > 0) {
$this->id = $id;
$this->ref = (string) $id;
if (getDolGlobalString('MEMBER_CODEMEMBER_ADDON') == '') {
// keep old numbering
$this->ref = (string) $id;
} else {
// auto code
$modfile = dol_buildpath('core/modules/member/'.getDolGlobalString('MEMBER_CODEMEMBER_ADDON').'.php', 0);
try {
require_once $modfile;
$modname = getDolGlobalString('MEMBER_CODEMEMBER_ADDON');
$modCodeMember = new $modname;
$this->ref = $modCodeMember->getNextValue($mysoc, $this);
} catch (Exception $e) {
dol_syslog($e->getMessage(), LOG_ERR);
$error++;
}
}
// Update minor fields
$result = $this->update($user, 1, 1, 0, 0, 'add'); // nosync is 1 to avoid update data of user
@ -1505,7 +1540,7 @@ class Adherent extends CommonObject
require_once DOL_DOCUMENT_ROOT.'/adherents/class/subscription.class.php';
$sql = "SELECT c.rowid, c.fk_adherent, c.fk_type, c.subscription, c.note, c.fk_bank,";
$sql = "SELECT c.rowid, c.fk_adherent, c.fk_type, c.subscription, c.note as note_public, c.fk_bank,";
$sql .= " c.tms as datem,";
$sql .= " c.datec as datec,";
$sql .= " c.dateadh as dateh,";
@ -1537,7 +1572,8 @@ class Adherent extends CommonObject
$subscription->fk_adherent = $obj->fk_adherent;
$subscription->fk_type = $obj->fk_type;
$subscription->amount = $obj->subscription;
$subscription->note = $obj->note;
$subscription->note = $obj->note_public;
$subscription->note_public = $obj->note_public;
$subscription->fk_bank = $obj->fk_bank;
$subscription->datem = $this->db->jdate($obj->datem);
$subscription->datec = $this->db->jdate($obj->datec);

View File

@ -133,6 +133,7 @@ class Conf
'barcode' => array(),
'models' => array(),
'societe' => array(),
'member' => array(),
'hooks' => array(),
'dir' => array(),
'syslog' => array()
@ -145,22 +146,22 @@ class Conf
$this->expedition_bon = new stdClass();
$this->delivery_note = new stdClass();
$this->fournisseur = new stdClass();
$this->product = new stdClass();
$this->service = new stdClass();
$this->contrat = new stdClass();
$this->actions = new stdClass();
$this->agenda = new stdClass();
$this->product = new stdClass();
$this->service = new stdClass();
$this->contrat = new stdClass();
$this->actions = new stdClass();
$this->agenda = new stdClass();
$this->commande = new stdClass();
$this->propal = new stdClass();
$this->facture = new stdClass();
$this->contrat = new stdClass();
$this->facture = new stdClass();
$this->contrat = new stdClass();
$this->user = new stdClass();
$this->adherent = new stdClass();
$this->adherent = new stdClass();
$this->bank = new stdClass();
$this->notification = new stdClass();
$this->notification = new stdClass();
$this->mailing = new stdClass();
$this->expensereport = new stdClass();
$this->productbatch = new stdClass();
$this->expensereport = new stdClass();
$this->productbatch = new stdClass();
}
/**
@ -215,22 +216,22 @@ class Conf
$this->expedition_bon = new stdClass();
$this->delivery_note = new stdClass();
$this->fournisseur = new stdClass();
$this->product = new stdClass();
$this->service = new stdClass();
$this->contrat = new stdClass();
$this->actions = new stdClass();
$this->agenda = new stdClass();
$this->product = new stdClass();
$this->service = new stdClass();
$this->contrat = new stdClass();
$this->actions = new stdClass();
$this->agenda = new stdClass();
$this->commande = new stdClass();
$this->propal = new stdClass();
$this->facture = new stdClass();
$this->contrat = new stdClass();
$this->facture = new stdClass();
$this->contrat = new stdClass();
$this->user = new stdClass();
$this->adherent = new stdClass();
$this->adherent = new stdClass();
$this->bank = new stdClass();
$this->notification = new stdClass();
$this->notification = new stdClass();
$this->mailing = new stdClass();
$this->expensereport = new stdClass();
$this->productbatch = new stdClass();
$this->expensereport = new stdClass();
$this->productbatch = new stdClass();
// Common arrays
$this->cache = array();
@ -249,6 +250,7 @@ class Conf
'barcode' => array(),
'models' => array(),
'societe' => array(),
'member' => array(),
'hooks' => array(),
'dir' => array(),
'syslog' => array(),

View File

@ -53,7 +53,7 @@ class mod_asset_advanced extends ModeleNumRefAsset
/**
* Returns the description of the numbering model
*
* @return string Texte descripif
* @return string Descriptive text
*/
public function info()
{

View File

@ -121,7 +121,7 @@ abstract class ModeleNumRefAsset
/**
* Returns the default description of the numbering template
*
* @return string Texte descripif
* @return string Descriptive text
*/
public function info()
{

View File

@ -58,7 +58,7 @@ class modPhpbarcode extends ModeleBarCode
/**
* Return description
*
* @return string Texte descripif
* @return string Descriptive text
*/
public function info()
{

View File

@ -54,7 +54,7 @@ class mod_bom_advanced extends ModeleNumRefboms
/**
* Returns the description of the numbering model
*
* @return string Texte descripif
* @return string Descriptive text
*/
public function info()
{

View File

@ -87,7 +87,7 @@ abstract class ModeleNumRefBoms
/**
* Returns the default description of the numbering template
*
* @return string Texte descripif
* @return string Descriptive text
*/
public function info()
{

View File

@ -48,7 +48,7 @@ class mod_chequereceipt_thyme extends ModeleNumRefChequeReceipts
/**
* Returns the description of the numbering model
*
* @return string Texte descripif
* @return string Descriptive text
*/
public function info()
{

View File

@ -54,7 +54,7 @@ abstract class ModeleNumRefChequeReceipts
/**
* Return the default description of numbering module
*
* @return string Texte descripif
* @return string Descriptive text
*/
public function info()
{

View File

@ -54,7 +54,7 @@ class mod_commande_saphir extends ModeleNumRefCommandes
/**
* Returns the description of the numbering model
*
* @return string Texte descripif
* @return string Descriptive text
*/
public function info()
{

View File

@ -86,9 +86,9 @@ abstract class ModeleNumRefCommandes
}
/**
* Renvoie la description par defaut du modele de numerotation
* Returns the default description of the numbering pattern
*
* @return string Texte descripif
* @return string Descriptive text
*/
public function info()
{

View File

@ -63,7 +63,7 @@ class mod_delivery_jade extends ModeleNumRefDeliveryOrder
/**
* Returns the description of the numbering model
*
* @return string Texte descripif
* @return string Descriptive text
*/
public function info()
{
@ -174,7 +174,7 @@ class mod_delivery_jade extends ModeleNumRefDeliveryOrder
*
* @param Societe $objsoc Object thirdparty
* @param Object $object Object livraison
* @return string Texte descriptif
* @return string Descriptive text
*/
public function delivery_get_num($objsoc = 0, $object = '')
{

View File

@ -58,7 +58,7 @@ class mod_delivery_saphir extends ModeleNumRefDeliveryOrder
/**
* Returns the description of the numbering model
*
* @return string Texte descripif
* @return string Descriptive text
*/
public function info()
{
@ -162,7 +162,7 @@ class mod_delivery_saphir extends ModeleNumRefDeliveryOrder
*
* @param Societe $objsoc Object thirdparty
* @param Object $object Objet livraison
* @return string Texte descripif
* @return string Descriptive text
*/
public function delivery_get_num($objsoc = 0, $object = '')
{

View File

@ -88,9 +88,9 @@ abstract class ModeleNumRefDeliveryOrder
}
/**
* Renvoi la description par defaut du modele de numerotation
* Returns the default description of the numbering pattern
*
* @return string Texte descripif
* @return string Descriptive text
*/
public function info()
{

View File

@ -84,9 +84,9 @@ abstract class ModeleNumRefDons
}
/**
* Renvoi la description par defaut du modele de numerotation
* Returns the default description of the numbering pattern
*
* @return string Texte descripif
* @return string Descriptive text
*/
public function info()
{

View File

@ -57,7 +57,7 @@ class mod_expensereport_sand extends ModeleNumRefExpenseReport
/**
* Returns the description of the numbering model
*
* @return string Texte descripif
* @return string Descriptive text
*/
public function info()
{

View File

@ -72,7 +72,7 @@ class mod_facture_mars extends ModeleNumRefFactures
/**
* Returns the description of the numbering model
*
* @return string Texte descripif
* @return string Descriptive text
*/
public function info()
{

View File

@ -49,7 +49,7 @@ class mod_facture_mercure extends ModeleNumRefFactures
/**
* Returns the description of the numbering model
*
* @return string Texte descripif
* @return string Descriptive text
*/
public function info()
{

View File

@ -88,7 +88,7 @@ class mod_facture_terre extends ModeleNumRefFactures
/**
* Returns the description of the numbering model
*
* @return string Texte descripif
* @return string Descriptive text
*/
public function info()
{

View File

@ -94,9 +94,9 @@ abstract class ModeleNumRefFactures
}
/**
* Renvoi la description par defaut du modele de numerotation
* Returns the default description of the numbering pattern
*
* @return string Texte descripif
* @return string Descriptive text
*/
public function info()
{

View File

@ -59,7 +59,7 @@ class mod_arctic extends ModeleNumRefFicheinter
/**
* Returns the description of the numbering model
*
* @return string Texte descripif
* @return string Descriptive text
*/
public function info()
{

View File

@ -54,7 +54,7 @@ class mod_evaluation_advanced extends ModeleNumRefEvaluation
/**
* Returns the description of the numbering model
*
* @return string Texte descripif
* @return string Descriptive text
*/
public function info()
{

View File

@ -86,7 +86,7 @@ abstract class ModeleNumRefEvaluation
/**
* Returns the default description of the numbering template
*
* @return string Texte descripif
* @return string Descriptive text
*/
public function info()
{

View File

@ -0,0 +1,165 @@
<?php
/* Copyright (C) 2021 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2022 Frédéric France <frederic.france@netlogic.fr>
*
* 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
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
* or see https://www.gnu.org/
*/
/**
* \file htdocs/core/modules/member/mod_member_advanced.php
* \ingroup member
* \brief File with class to manage the numbering module Advanced for member references
*/
require_once DOL_DOCUMENT_ROOT.'/core/modules/member/modules_member.class.php';
/**
* Class to manage the numbering module Advanced for member references
*/
class mod_member_advanced extends ModeleNumRefMembers
{
/**
* Dolibarr version of the loaded document
* @var string
*/
public $version = 'dolibarr';
/**
* prefix
*
* @var string
*/
public $prefix = 'MEM';
/**
* @var string Error code (or message)
*/
public $error = '';
/**
* @var string model name
*/
public $name = 'Advanced';
/**
* @var int Automatic numbering
*/
public $code_auto = 1;
/**
* Return description of numbering module
*
* @return string Text with description
*/
public function info()
{
global $langs;
return $langs->trans("AdvancedNumRefModelDesc", $this->prefix);
}
/**
* Return an example of numbering module values
*
* @return string Example
*/
public function getExample()
{
return $this->prefix."2301-0001";
}
/**
* Checks if the numbers already in the database do not
* cause conflicts that would prevent this numbering working.
*
* @return boolean false if conflict, true if ok
*/
public function canBeActivated()
{
global $conf, $langs, $db;
$coyymm = '';
$max = '';
$posindice = strlen($this->prefix) + 6;
$sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max";
$sql .= " FROM ".MAIN_DB_PREFIX."adherent";
$sql .= " WHERE ref LIKE '".$db->escape($this->prefix)."____-%'";
$sql .= " AND entity = ".$conf->entity;
$resql = $db->query($sql);
if ($resql) {
$row = $db->fetch_row($resql);
if ($row) {
$coyymm = substr($row[0], 0, 6);
$max = $row[0];
}
}
if (!$coyymm || preg_match('/'.$this->prefix.'[0-9][0-9][0-9][0-9]/i', $coyymm)) {
return true;
} else {
$langs->load("errors");
$this->error = $langs->trans('ErrorNumRefModel', $max);
return false;
}
}
/**
* Return next value
*
* @param Societe $objsoc Object third party
* @param Member $object Object we need next value for
* @return string Value if OK, 0 if KO
*/
public function getNextValue($objsoc, $object)
{
global $db, $conf;
// First, we get the max value
$posindice = strlen($this->prefix) + 6;
$sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max";
$sql .= " FROM ".MAIN_DB_PREFIX."adherent";
$sql .= " WHERE ref LIKE '".$db->escape($this->prefix)."____-%'";
$sql .= " AND entity = ".$conf->entity;
$resql = $db->query($sql);
if ($resql) {
$obj = $db->fetch_object($resql);
if ($obj) {
$max = intval($obj->max);
} else {
$max = 0;
}
} else {
dol_syslog("mod_member_advanced::getNextValue", LOG_DEBUG);
return -1;
}
$date = empty($object->datec) ? dol_now() : $object->datec;
$yymm = dol_print_date($date, '%y%m', 'gmt');
if ($max >= (pow(10, 4) - 1)) {
$num = $max + 1; // If counter > 9999, we do not format on 4 chars, we take number as it is
} else {
$num = sprintf("%04s", $max + 1);
}
dol_syslog("mod_member_advanced::getNextValue return ".$this->prefix.$yymm."-".$num, LOG_INFO);
return $this->prefix.$yymm."-".$num;
}
}

View File

@ -1,5 +1,6 @@
<?php
/* Copyright (C) 2021 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2022 Frédéric France <frederic.france@netlogic.fr>
*
* 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
@ -34,27 +35,29 @@ class mod_member_simple extends ModeleNumRefMembers
* Dolibarr version of the loaded document
* @var string
*/
public $version = 'dolibarr'; // 'development', 'experimental', 'dolibarr'
public $version = 'dolibarr';
public $prefix = 'MEM';
/**
* prefix
*
* @var string
*/
public $prefix = '';
/**
* @var string Error code (or message)
*/
public $error = '';
/**
* @var string Nom du modele
* @deprecated
* @see $name
*/
public $nom = 'Simple';
/**
* @var string model name
*/
public $name = 'Simple';
/**
* @var int Automatic numbering
*/
public $code_auto = 1;
/**
* Return description of numbering module
@ -64,7 +67,7 @@ class mod_member_simple extends ModeleNumRefMembers
public function info()
{
global $langs;
return $langs->trans("SimpleNumRefModelDesc", $this->prefix);
return $langs->trans("SimpleRefNumRefModelDesc");
}
@ -75,7 +78,7 @@ class mod_member_simple extends ModeleNumRefMembers
*/
public function getExample()
{
return $this->prefix."0501-0001";
return "1";
}
@ -92,11 +95,9 @@ class mod_member_simple extends ModeleNumRefMembers
$coyymm = '';
$max = '';
$posindice = strlen($this->prefix) + 6;
$sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max";
$sql = "SELECT MAX(CAST(ref AS SIGNED)) as max";
$sql .= " FROM ".MAIN_DB_PREFIX."adherent";
$sql .= " WHERE ref LIKE '".$db->escape($this->prefix)."____-%'";
$sql .= " AND entity = ".$conf->entity;
$sql .= " WHERE entity = ".$conf->entity;
$resql = $db->query($sql);
if ($resql) {
$row = $db->fetch_row($resql);
@ -105,7 +106,7 @@ class mod_member_simple extends ModeleNumRefMembers
$max = $row[0];
}
}
if (!$coyymm || preg_match('/'.$this->prefix.'[0-9][0-9][0-9][0-9]/i', $coyymm)) {
if (!$coyymm || preg_match('/[0-9][0-9][0-9][0-9]/i', $coyymm)) {
return true;
} else {
$langs->load("errors");
@ -119,65 +120,31 @@ class mod_member_simple extends ModeleNumRefMembers
* Return next value
*
* @param Societe $objsoc Object third party
* @param Object $object Object we need next value for
* @param Member $object Object we need next value for
* @return string Value if OK, 0 if KO
*/
public function getNextValue($objsoc, $object)
{
global $db, $conf;
global $conf, $db;
/*
// First, we get the max value
$posindice = strlen($this->prefix) + 6;
$sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max";
// the ref of a member is the rowid
$sql = "SELECT MAX(CAST(ref AS SIGNED)) as max";
$sql .= " FROM ".MAIN_DB_PREFIX."adherent";
$sql .= " WHERE ref LIKE '".$db->escape($this->prefix)."____-%'";
$sql .= " AND entity = ".$conf->entity;
$sql .= " WHERE entity = ".(int) $conf->entity;
$resql = $db->query($sql);
if ($resql) {
$obj = $db->fetch_object($resql);
if ($obj) {
$max = intval($obj->max);
$max = intval($obj->max) + 1;
} else {
$max = 0;
$max = 1;
}
} else {
dol_syslog("mod_member_simple::getNextValue", LOG_DEBUG);
return -1;
}
$date = empty($object->date_c) ? dol_now() : $object->date_c;
//$yymm = strftime("%y%m",time());
$yymm = strftime("%y%m", $date);
if ($max >= (pow(10, 4) - 1)) {
$num = $max + 1; // If counter > 9999, we do not format on 4 chars, we take number as it is
} else {
$num = sprintf("%04s", $max + 1);
}
dol_syslog("mod_member_simple::getNextValue return ".$this->prefix.$yymm."-".$num);
return $this->prefix.$yymm."-".$num;
*/
// For the moment, the ref of a member is the rowid
$sql = "SELECT MAX(rowid) as max";
$sql .= " FROM ".MAIN_DB_PREFIX."adherent";
$resql = $db->query($sql);
if ($resql) {
$obj = $db->fetch_object($resql);
if ($obj) {
$max = intval($obj->max);
} else {
$max = 0;
}
} else {
dol_syslog("mod_member_simple::getNextValue", LOG_DEBUG);
return -1;
}
return ($max + 1);
$max = str_pad((string) $max, getDolGlobalInt('MEMBER_MOD_SIMPLE_LPAD'), "0", STR_PAD_LEFT);
return $max;
}
}

View File

@ -84,9 +84,9 @@ abstract class ModeleNumRefMembers
}
/**
* Renvoi la description par defaut du modele de numerotation
* Returns the default description of the numbering pattern
*
* @return string Texte descripif
* @return string Descriptive text
*/
public function info()
{
@ -95,6 +95,16 @@ abstract class ModeleNumRefMembers
return $langs->trans("NoDescription");
}
/**
* Return name of module
*
* @return string Module name
*/
public function getName()
{
return $this->name;
}
/**
* Return an example of numbering
*
@ -153,4 +163,50 @@ abstract class ModeleNumRefMembers
return $langs->trans("NotAvailable");
}
}
/**
* Return description of module parameters
*
* @param Translate $langs Output language
* @param Societe $soc Third party object
* @return string HTML translated description
*/
public function getToolTip($langs, $soc)
{
global $conf;
$langs->loadLangs(array("admin", "companies"));
$strikestart = '';
$strikeend = '';
if (!empty($conf->global->MAIN_MEMBER_CODE_ALWAYS_REQUIRED) && !empty($this->code_null)) {
$strikestart = '<strike>';
$strikeend = '</strike> '.yn(1, 1, 2).' ('.$langs->trans("ForcedToByAModule", $langs->transnoentities("yes")).')';
}
$s = '';
$s .= $langs->trans("Name").': <b>'.$this->getName().'</b><br>';
$s .= $langs->trans("Version").': <b>'.$this->getVersion().'</b><br>';
$s .= $langs->trans("MemberCodeDesc").'<br>';
$s .= $langs->trans("ValidityControledByModule").': <b>'.$this->getName().'</b><br>';
$s .= '<br>';
$s .= '<u>'.$langs->trans("ThisIsModuleRules").':</u><br>';
$s .= $langs->trans("Required").': '.$strikestart;
$s .= yn(!$this->code_null, 1, 2).$strikeend;
$s .= '<br>';
$s .= $langs->trans("CanBeModifiedIfOk").': ';
$s .= yn($this->code_modifiable, 1, 2);
$s .= '<br>';
$s .= $langs->trans("CanBeModifiedIfKo").': '.yn($this->code_modifiable_invalide, 1, 2).'<br>';
$s .= $langs->trans("AutomaticCode").': '.yn($this->code_auto, 1, 2).'<br>';
$s .= '<br>';
$nextval = $this->getNextValue($soc, 0);
if (empty($nextval)) {
$nextval = $langs->trans("Undefined");
}
$s .= $langs->trans("NextValue").' ('.$langs->trans("Member").'): <b>'.$nextval.'</b><br>';
return $s;
}
}

View File

@ -55,7 +55,7 @@ class mod_mo_advanced extends ModeleNumRefMos
/**
* Returns the description of the numbering model
*
* @return string Texte descripif
* @return string Descriptive text
*/
public function info()
{

View File

@ -87,7 +87,7 @@ abstract class ModeleNumRefMos
/**
* Returns the default description of the numbering template
*
* @return string Texte descripif
* @return string Descriptive text
*/
public function info()
{

View File

@ -57,7 +57,7 @@ class mod_payment_ant extends ModeleNumRefPayments
/**
* Returns the description of the numbering model
*
* @return string Texte descripif
* @return string Descriptive text
*/
public function info()
{

View File

@ -41,7 +41,7 @@ abstract class ModeleNumRefPayments
/**
* Return the default description of numbering module
*
* @return string Texte descripif
* @return string Descriptive text
*/
public function info()
{

View File

@ -104,10 +104,10 @@ abstract class ModeleProductCode
*/
public $error = '';
/** Renvoi la description par defaut du modele de numerotation
/** Returns the default description of the numbering pattern
*
* @param Translate $langs Object langs
* @return string Texte descripif
* @return string Descriptive text
*/
public function info($langs)
{

View File

@ -55,7 +55,7 @@ class mod_lot_advanced extends ModeleNumRefBatch
/**
* Returns the description of the numbering model
*
* @return string Texte descripif
* @return string Descriptive text
*/
public function info()
{

View File

@ -55,7 +55,7 @@ class mod_sn_advanced extends ModeleNumRefBatch
/**
* Returns the description of the numbering model
*
* @return string Texte descripif
* @return string Descriptive text
*/
public function info()
{

View File

@ -89,7 +89,7 @@ abstract class ModeleNumRefBatch
/**
* Returns the default description of the numbering template
*
* @return string Texte descripif
* @return string Descriptive text
*/
public function info()
{

View File

@ -62,7 +62,7 @@ class mod_project_universal extends ModeleNumRefProjects
/**
* Returns the description of the numbering model
*
* @return string Texte descripif
* @return string Descriptive text
*/
public function info()
{

View File

@ -143,9 +143,9 @@ abstract class ModeleNumRefProjects
}
/**
* Renvoi la description par defaut du modele de numerotation
* Returns the default description of the numbering pattern
*
* @return string Texte descripif
* @return string Descriptive text
*/
public function info()
{

View File

@ -57,7 +57,7 @@ class mod_task_universal extends ModeleNumRefTask
/**
* Returns the description of the numbering model
*
* @return string Texte descripif
* @return string Descriptive text
*/
public function info()
{

View File

@ -84,9 +84,9 @@ abstract class ModeleNumRefTask
}
/**
* Renvoi la description par defaut du modele de numerotation
* Returns the default description of the numbering pattern
*
* @return string Texte descripif
* @return string Descriptive text
*/
public function info()
{

View File

@ -60,7 +60,7 @@ class mod_propale_saphir extends ModeleNumRefPropales
/**
* Return description of module
*
* @return string Texte descripif
* @return string Descriptive text
*/
public function info()
{

View File

@ -87,9 +87,9 @@ abstract class ModeleNumRefPropales
}
/**
* Renvoi la description par defaut du modele de numerotation
* Returns the default description of the numbering pattern
*
* @return string Texte descripif
* @return string Descriptive text
*/
public function info()
{

View File

@ -75,10 +75,10 @@ abstract class ModeleThirdPartyCode
public $errors;
/** Renvoi la description par defaut du modele de numerotation
/** Returns the default description of the numbering pattern
*
* @param Translate $langs Object langs
* @return string Texte descripif
* @return string Descriptive text
*/
public function info($langs)
{

View File

@ -55,7 +55,7 @@ class mod_stocktransfer_advanced extends ModeleNumRefStockTransfer
/**
* Returns the description of the numbering model
*
* @return string Texte descripif
* @return string Descriptive text
*/
public function info()
{

View File

@ -87,7 +87,7 @@ abstract class ModeleNumRefStockTransfer
/**
* Returns the default description of the numbering template
*
* @return string Texte descripif
* @return string Descriptive text
*/
public function info()
{

View File

@ -178,7 +178,7 @@ class mod_commande_fournisseur_muguet extends ModeleNumRefSuppliersOrders
*
* @param Societe $objsoc Object third party
* @param Object $object Object
* @return string Texte descripif
* @return string Descriptive text
*/
public function commande_get_num($objsoc = 0, $object = '')
{

View File

@ -59,7 +59,7 @@ class mod_commande_fournisseur_orchidee extends ModeleNumRefSuppliersOrders
/**
* Returns the description of the numbering model
*
* @return string Texte descripif
* @return string Descriptive text
*/
public function info()
{
@ -150,7 +150,7 @@ class mod_commande_fournisseur_orchidee extends ModeleNumRefSuppliersOrders
*
* @param Societe $objsoc Object third party
* @param Object $object Object
* @return string Texte descripif
* @return string Descriptive text
*/
public function commande_get_num($objsoc = 0, $object = '')
{

View File

@ -57,7 +57,7 @@ class mod_supplier_payment_brodator extends ModeleNumRefSupplierPayments
/**
* Returns the description of the numbering model
*
* @return string Texte descripif
* @return string Descriptive text
*/
public function info()
{

View File

@ -111,7 +111,7 @@ abstract class ModeleNumRefSupplierPayments
/**
* Return the default description of numbering module
*
* @return string Texte descripif
* @return string Descriptive text
*/
public function info()
{

View File

@ -60,7 +60,7 @@ class mod_supplier_proposal_saphir extends ModeleNumRefSupplierProposal
/**
* Return description of module
*
* @return string Texte descripif
* @return string Descriptive text
*/
public function info()
{

View File

@ -87,9 +87,9 @@ abstract class ModeleNumRefSupplierProposal
}
/**
* Renvoi la description par defaut du modele de numerotation
* Returns the default description of the numbering pattern
*
* @return string Texte descripif
* @return string Descriptive text
*/
public function info()
{

View File

@ -54,7 +54,7 @@ class mod_takepos_ref_universal extends ModeleNumRefTakepos
/**
* return description of the numbering model
*
* @return string Texte descripif
* @return string Descriptive text
*/
public function info()
{

View File

@ -52,9 +52,9 @@ abstract class ModeleNumRefTakepos
}
/**
* Renvoi la description par defaut du modele de numerotation
* Returns the default description of the numbering pattern
*
* @return string Texte descripif
* @return string Descriptive text
*/
public function info()
{

View File

@ -55,7 +55,7 @@ class mod_ticket_universal extends ModeleNumRefTicket
/**
* Returns the description of the numbering model
*
* @return string Texte descripif
* @return string Descriptive text
*/
public function info()
{

View File

@ -78,9 +78,9 @@ abstract class ModeleNumRefTicket
}
/**
* Renvoi la description par defaut du modele de numerotation
* Returns the default description of the numbering pattern
*
* @return string Texte descripif
* @return string Descriptive text
*/
public function info()
{

View File

@ -55,7 +55,7 @@ class mod_workstation_advanced extends ModeleNumRefWorkstation
/**
* Returns the description of the numbering model
*
* @return string Texte descripif
* @return string Descriptive text
*/
public function info()
{

View File

@ -87,7 +87,7 @@ abstract class ModeleNumRefWorkstation
/**
* Returns the default description of the numbering template
*
* @return string Texte descripif
* @return string Descriptive text
*/
public function info()
{

View File

@ -54,7 +54,7 @@ class mod_knowledgerecord_advanced extends ModeleNumRefKnowledgeRecord
/**
* Returns the description of the numbering model
*
* @return string Texte descripif
* @return string Descriptive text
*/
public function info()
{

View File

@ -86,7 +86,7 @@ abstract class ModeleNumRefKnowledgeRecord
/**
* Returns the default description of the numbering template
*
* @return string Texte descripif
* @return string Descriptive text
*/
public function info()
{

View File

@ -1302,6 +1302,8 @@ YouMustRunCommandFromCommandLineAfterLoginToUser=You must run this command from
YourPHPDoesNotHaveSSLSupport=SSL functions not available in your PHP
DownloadMoreSkins=More skins to download
SimpleNumRefModelDesc=Returns the reference number in the format %syymm-nnnn where yy is the year, mm is the month and nnnn is a sequential auto-incrementing number with no reset
SimpleRefNumRefModelDesc=Returns the reference number in the format n where n is a sequential auto-incrementing number with no reset
AdvancedNumRefModelDesc=Returns the reference number in the format %syymm-nnnn where yy is the year, mm is the month and nnnn is a sequential auto-incrementing number with no reset
SimpleNumRefNoDateModelDesc=Returns the reference number in the format %s-nnnn where nnnn is a sequential auto-incrementing number with no reset
ShowProfIdInAddress=Show professional ID with addresses
ShowVATIntaInAddress=Hide intra-Community VAT number
@ -1488,6 +1490,7 @@ WatermarkOnDraftContractCards=Watermark on draft contracts (none if empty)
##### Members #####
MembersSetup=Members module setup
MemberMainOptions=Main options
MemberCodeChecker=Options for automatic generation of member codes
AdherentLoginRequired= Manage a Login for each member
AdherentMailRequired=Email required to create a new member
MemberSendInformationByMailByDefault=Checkbox to send mail confirmation to members (validation or new subscription) is on by default

View File

@ -98,7 +98,7 @@ MorAndPhy=Corporation and Individual
Reenable=Re-Enable
ExcludeMember=Exclude a member
Exclude=Exclude
ConfirmExcludeMember=Are you sure you want to exclude this member ?
ConfirmExcludeMember=Are you sure you want to exclude this member ?
ResiliateMember=Terminate a member
ConfirmResiliateMember=Are you sure you want to terminate this member?
DeleteMember=Delete a member
@ -230,4 +230,5 @@ ForceMemberNature=Force member nature (Individual or Corporation)
CreateDolibarrLoginDesc=The creation of a user login for members allows them to connect to the application. Depending on the authorizations granted, they will be able, for example, to consult or modify their file themselves.
CreateDolibarrThirdPartyDesc=A thirdparty is the legal entity that will be used on the invoice if you decide to generate invoice for each contribution. You will be able to create it later during the process of recording the contribution.
MemberFirstname=Member firstname
MemberLastname=Member lastname
MemberLastname=Member lastname
MemberCodeDesc=Member Code, unique for all members

View File

@ -54,7 +54,7 @@ class mod_myobject_advanced extends ModeleNumRefMyObject
/**
* Returns the description of the numbering model
*
* @return string Texte descripif
* @return string Descriptive text
*/
public function info()
{

View File

@ -122,7 +122,7 @@ abstract class ModeleNumRefMyObject
/**
* Returns the default description of the numbering template
*
* @return string Texte descripif
* @return string Descriptive text
*/
public function info()
{

View File

@ -54,7 +54,7 @@ class mod_partnership_advanced extends ModeleNumRefPartnership
/**
* Returns the description of the numbering model
*
* @return string Texte descripif
* @return string Descriptive text
*/
public function info()
{

View File

@ -86,7 +86,7 @@ abstract class ModeleNumRefPartnership
/**
* Returns the default description of the numbering template
*
* @return string Texte descripif
* @return string Descriptive text
*/
public function info()
{

View File

@ -54,7 +54,7 @@ class mod_recruitmentcandidature_advanced extends ModeleNumRefRecruitmentCandida
/**
* Returns the description of the numbering model
*
* @return string Texte descripif
* @return string Descriptive text
*/
public function info()
{

View File

@ -54,7 +54,7 @@ class mod_recruitmentjobposition_advanced extends ModeleNumRefRecruitmentJobPosi
/**
* Returns the description of the numbering model
*
* @return string Texte descripif
* @return string Descriptive text
*/
public function info()
{

View File

@ -86,7 +86,7 @@ abstract class ModeleNumRefRecruitmentCandidature
/**
* Returns the default description of the numbering template
*
* @return string Texte descripif
* @return string Descriptive text
*/
public function info()
{

View File

@ -122,7 +122,7 @@ abstract class ModeleNumRefRecruitmentJobPosition
/**
* Returns the default description of the numbering template
*
* @return string Texte descripif
* @return string Descriptive text
*/
public function info()
{