dolibarr 24.0.0-beta
mod_member_custom.php
Go to the documentation of this file.
1<?php
2/* Copyright (C) 2025 Christophe Battarel <christophe@altairis.fr>
3 * Copyright (C) 2025 Frédéric France <frederic.france@free.fr>
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 3 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <https://www.gnu.org/licenses/>.
17 * or see https://www.gnu.org/
18 */
19
26require_once DOL_DOCUMENT_ROOT.'/core/modules/member/modules_member.class.php';
27require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php';
28
29
34{
38 public $name = 'Custom';
39
44 public $version = 'dolibarr'; // 'development', 'experimental', 'dolibarr'
45
49 public $position = 50;
50
54 public $error = '';
55
56
63 public function info($langs)
64 {
65 global $db, $langs;
66
67 $langs->load("bills");
68
69 $form = new Form($db);
70
71 $texte = $langs->trans('GenericNumRefModelDesc')."<br>\n";
72 $texte .= '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
73 $texte .= '<input type="hidden" name="token" value="'.newToken().'">';
74 $texte .= '<input type="hidden" name="action" value="updateMask">';
75 $texte .= '<input type="hidden" name="maskconst" value="MEMBER_CUSTOM_MASK">';
76 $texte .= '<input type="hidden" name="page_y" value="">';
77
78 $texte .= '<table class="nobordernopadding centpercent">';
79
80 $tooltip = $langs->trans("GenericMaskCodes", $langs->transnoentities("Member"), $langs->transnoentities("Member"));
81 $tooltip .= $langs->trans("GenericMaskCodes1");
82 $tooltip .= '<br>';
83 //$tooltip.=$langs->trans("GenericMaskCodes2");
84 $tooltip .= $langs->trans("GenericMaskCodes3");
85 $tooltip .= $langs->trans("GenericMaskCodes4a", $langs->transnoentities("Member"), $langs->transnoentities("Member"));
86 $tooltip .= $langs->trans("GenericMaskCodes5");
87 $tooltip .= '<br>'.$langs->trans("GenericMaskCodes5b");
88
89 // Setting of prefix
90 $texte .= '<tr><td>'.$langs->trans("Mask").':</td>';
91 $mask = getDolGlobalString('MEMBER_CUSTOM_MASK');
92 $texte .= '<td class="right">'.$form->textwithpicto('<input type="text" class="flat minwidth175" name="maskvalue" value="'.$mask.'">', $tooltip, 1, 'help', 'valignmiddle', 0, 3, $this->name).'</td>';
93
94 $texte .= '<td class="left" rowspan="2">&nbsp; <input type="submit" class="button button-edit reposition smallpaddingimp" name="Button" value="'.$langs->trans("Save").'"></td>';
95
96 $texte .= '</tr>';
97
98 $texte .= '</table>';
99 $texte .= '</form>';
100
101 return $texte;
102 }
103
109 public function getExample()
110 {
111 global $db, $langs, $user;
112
113 $member = new Adherent($db);
114 $member->initAsSpecimen();
115 $member->fk_user_author = $user->id;
116
117 $numExample = $this->getNextValue(null, $member);
118
119 if (!$numExample) {
120 $numExample = $langs->trans('NotConfigured');
121 }
122 return $numExample;
123 }
124
132 public function getNextValue($objsoc, $object)
133 {
134 global $db;
135
136 require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
137
138 // We get cursor rule
139 $mask = getDolGlobalString('MEMBER_CUSTOM_MASK');
140
141 if (!$mask) {
142 $this->error = 'NotConfigured';
143 return 0;
144 }
145
146 $date = dol_now();
147
148 $fuser = null;
149 if ($object->fk_user_author > 0) {
150 $fuser = new User($db);
151 $fuser->fetch($object->fk_user_author);
152 }
153
154 // Get entities
155 $entity = getEntity('membernumber', 1, $object);
156
157 $numFinal = get_next_value($db, $mask, 'adherent', 'ref', '', null, $date, 'next', true, $fuser, $entity);
158
159 return $numFinal;
160 }
161}
if(! $sortfield) if(! $sortorder) $object
Definition account.php:100
Class to manage members of a foundation.
Class to manage generation of HTML components Only common components must be here.
Class mere des modeles de numerotation des references de members.
Class to manage Dolibarr users.
Class to manage member report numbering rules Custom.
info($langs)
Returns the description of the numbering model.
getExample()
Return an example of numbering.
getNextValue($objsoc, $object)
Return next free value.
if(!isModEnabled('ai')||!getDolGlobalString('AI_ASSISTANT_ENABLED')) global $db
API class for accounts.
get_next_value($db, $mask, $table, $field, $where='', $objsoc='', $date='', $mode='next', $bentityon=true, $objuser=null, $forceentity=null, $objbookkeeping=null)
Return last or next value for a mask (according to area we should not reset)
dol_now($mode='gmt')
Return date for now.
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
getEntity($element, $shared=1, $currentobject=null)
Get list of entity id to use.