Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NEW add numbering modules for members #23302

Merged
merged 5 commits into from Dec 21, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
102 changes: 98 additions & 4 deletions htdocs/adherents/admin/member.php
Expand Up @@ -152,10 +152,13 @@
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'));

Expand Down Expand Up @@ -223,6 +226,97 @@

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">';
Expand Down
44 changes: 40 additions & 4 deletions htdocs/adherents/class/adherent.class.php
Expand Up @@ -92,6 +92,7 @@ class Adherent extends CommonObject
/**
* @var string company name
* @deprecated
* @see $company
*/
public $societe;

Expand All @@ -102,8 +103,14 @@ class Adherent extends CommonObject

/**
* @var int Thirdparty ID
* @deprecated
* @see $socid
*/
public $fk_soc;

/**
* @var int socid
*/
public $socid;

/**
Expand Down Expand Up @@ -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;

Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -576,7 +596,7 @@ public function getmorphylib($morphy = '', $addbadge = 0)
*/
public function create($user, $notrigger = 0)
{
global $conf, $langs;
global $conf, $langs, $mysoc;

$error = 0;

Expand Down Expand Up @@ -624,7 +644,22 @@ public function create($user, $notrigger = 0)
$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
Expand Down Expand Up @@ -1505,7 +1540,7 @@ public function fetch_subscriptions()

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,";
Expand Down Expand Up @@ -1537,7 +1572,8 @@ public function fetch_subscriptions()
$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);
Expand Down
46 changes: 24 additions & 22 deletions htdocs/core/class/conf.class.php
Expand Up @@ -133,6 +133,7 @@ public function __construct()
'barcode' => array(),
'models' => array(),
'societe' => array(),
'member' => array(),
'hooks' => array(),
'dir' => array(),
'syslog' => array()
Expand All @@ -145,22 +146,22 @@ public function __construct()
$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();
}

/**
Expand Down Expand Up @@ -215,22 +216,22 @@ public function setValues($db)
$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();
Expand All @@ -249,6 +250,7 @@ public function setValues($db)
'barcode' => array(),
'models' => array(),
'societe' => array(),
'member' => array(),
'hooks' => array(),
'dir' => array(),
'syslog' => array(),
Expand Down
2 changes: 1 addition & 1 deletion htdocs/core/modules/asset/mod_asset_advanced.php
Expand Up @@ -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()
{
Expand Down
2 changes: 1 addition & 1 deletion htdocs/core/modules/asset/modules_asset.php
Expand Up @@ -121,7 +121,7 @@ public function isEnabled()
/**
* Returns the default description of the numbering template
*
* @return string Texte descripif
* @return string Descriptive text
*/
public function info()
{
Expand Down
2 changes: 1 addition & 1 deletion htdocs/core/modules/barcode/doc/phpbarcode.modules.php
Expand Up @@ -58,7 +58,7 @@ public function isEnabled()
/**
* Return description
*
* @return string Texte descripif
* @return string Descriptive text
*/
public function info()
{
Expand Down
2 changes: 1 addition & 1 deletion htdocs/core/modules/bom/mod_bom_advanced.php
Expand Up @@ -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()
{
Expand Down
2 changes: 1 addition & 1 deletion htdocs/core/modules/bom/modules_bom.php
Expand Up @@ -87,7 +87,7 @@ public function isEnabled()
/**
* Returns the default description of the numbering template
*
* @return string Texte descripif
* @return string Descriptive text
*/
public function info()
{
Expand Down
2 changes: 1 addition & 1 deletion htdocs/core/modules/cheque/mod_chequereceipt_thyme.php
Expand Up @@ -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()
{
Expand Down
2 changes: 1 addition & 1 deletion htdocs/core/modules/cheque/modules_chequereceipts.php
Expand Up @@ -54,7 +54,7 @@ public function isEnabled()
/**
* Return the default description of numbering module
*
* @return string Texte descripif
* @return string Descriptive text
*/
public function info()
{
Expand Down
2 changes: 1 addition & 1 deletion htdocs/core/modules/commande/mod_commande_saphir.php
Expand Up @@ -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()
{
Expand Down