dolibarr 23.0.3
mod_member_custom.php
Go to the documentation of this file.
1<?php
2/* Copyright (C) 2025 Christophe Battarel <christophe@altairis.fr>
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 3 of the License, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <https://www.gnu.org/licenses/>.
16 * or see https://www.gnu.org/
17 */
18
25require_once DOL_DOCUMENT_ROOT.'/core/modules/member/modules_member.class.php';
26require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php';
27
28
33{
37 public $name = 'Custom';
38
43 public $version = 'dolibarr'; // 'development', 'experimental', 'dolibarr'
44
48 public $position = 50;
49
53 public $error = '';
54
55
62 public function info($langs)
63 {
64 global $db, $langs;
65
66 $langs->load("bills");
67
68 $form = new Form($db);
69
70 $texte = $langs->trans('GenericNumRefModelDesc')."<br>\n";
71 $texte .= '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
72 $texte .= '<input type="hidden" name="token" value="'.newToken().'">';
73 $texte .= '<input type="hidden" name="action" value="updateMask">';
74 $texte .= '<input type="hidden" name="maskconst" value="MEMBER_CUSTOM_MASK">';
75 $texte .= '<input type="hidden" name="page_y" value="">';
76
77 $texte .= '<table class="nobordernopadding centpercent">';
78
79 $tooltip = $langs->trans("GenericMaskCodes", $langs->transnoentities("Member"), $langs->transnoentities("Member"));
80 $tooltip .= $langs->trans("GenericMaskCodes1");
81 $tooltip .= '<br>';
82 //$tooltip.=$langs->trans("GenericMaskCodes2");
83 $tooltip .= $langs->trans("GenericMaskCodes3");
84 $tooltip .= $langs->trans("GenericMaskCodes4a", $langs->transnoentities("Member"), $langs->transnoentities("Member"));
85 $tooltip .= $langs->trans("GenericMaskCodes5");
86 $tooltip .= '<br>'.$langs->trans("GenericMaskCodes5b");
87
88 // Parametrage du prefix
89 $texte .= '<tr><td>'.$langs->trans("Mask").':</td>';
90 $mask = getDolGlobalString('MEMBER_CUSTOM_MASK');
91 $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>';
92
93 $texte .= '<td class="left" rowspan="2">&nbsp; <input type="submit" class="button button-edit reposition smallpaddingimp" name="Button" value="'.$langs->trans("Save").'"></td>';
94
95 $texte .= '</tr>';
96
97 $texte .= '</table>';
98 $texte .= '</form>';
99
100 return $texte;
101 }
102
108 public function getExample()
109 {
110 global $db, $langs, $user;
111
112 $member = new Adherent($db);
113 $member->initAsSpecimen();
114 $member->fk_user_author = $user->id;
115
116 $numExample = $this->getNextValue(null, $member);
117
118 if (!$numExample) {
119 $numExample = $langs->trans('NotConfigured');
120 }
121 return $numExample;
122 }
123
131 public function getNextValue($objsoc, $object)
132 {
133 global $db;
134
135 require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
136
137 // We get cursor rule
138 $mask = getDolGlobalString('MEMBER_CUSTOM_MASK');
139
140 if (!$mask) {
141 $this->error = 'NotConfigured';
142 return 0;
143 }
144
145 $date = dol_now();
146
147 $fuser = null;
148 if ($object->fk_user_author > 0) {
149 $fuser = new User($db);
150 $fuser->fetch($object->fk_user_author);
151 }
152
153 // Get entities
154 $entity = getEntity('membernumber', 1, $object);
155
156 $numFinal = get_next_value($db, $mask, 'adherent', 'ref', '', null, $date, 'next', true, $fuser, $entity);
157
158 return $numFinal;
159 }
160}
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.
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.