30require
'../main.inc.php';
38require_once DOL_DOCUMENT_ROOT.
'/core/lib/admin.lib.php';
39require_once DOL_DOCUMENT_ROOT.
'/core/lib/security.lib.php';
45$action =
GETPOST(
'action',
'aZ09');
46$massaction =
GETPOST(
'massaction',
'aZ09');
47$toselect =
GETPOST(
'toselect',
'array:int');
48$confirm =
GETPOST(
'confirm',
'alpha');
51$consts =
GETPOST(
'const',
'array');
52$constname =
GETPOST(
'constname',
'aZ09');
53$constvalue =
GETPOST(
'constvalue',
'restricthtml');
54$constnote =
GETPOST(
'constnote',
'alphanohtml');
57$search_name =
GETPOST(
'search_name',
'alpha');
58$search_value =
GETPOST(
'search_value',
'alpha');
61if (
GETPOST(
'button_removefilter_x',
'alpha') ||
GETPOST(
'button_removefilter.x',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha')) {
67$filterbuttonclicked = (bool) (
GETPOST(
'button_search_x',
'alpha') ||
GETPOST(
'button_search.x',
'alpha')
68 ||
GETPOST(
'button_removefilter_x',
'alpha') ||
GETPOST(
'button_removefilter.x',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha'));
72$sortfield =
GETPOST(
'sortfield',
'aZ09comma');
73$sortorder =
GETPOST(
'sortorder',
'aZ09comma');
75if (empty($page) || $page == -1 ||
GETPOST(
'button_search',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha') || (empty($toselect) && $massaction ===
'0')) {
78$offset = $limit * $page;
81if (empty($sortfield)) {
82 $sortfield =
'entity,name';
84if (empty($sortorder)) {
88if ($action ==
'add' &&
GETPOST(
'update')) {
102if (!
GETPOST(
'confirmmassaction',
'alpha')) {
107if ($action ==
'add' && empty($massaction) &&
GETPOSTISSET(
'constname') && empty($filterbuttonclicked)) {
110 if (empty($constname)) {
111 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Name")),
null,
'errors');
114 if ($constvalue ==
'') {
115 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Value")),
null,
'errors');
120 if (
dolibarr_set_const($db, $constname, $constvalue,
'chaine', 1, $constnote, $entity) >= 0) {
121 setEventMessages($langs->trans(
"RecordSaved"),
null,
'mesgs');
127 dol_print_error($db);
133if (!empty($consts) && $action ==
'update') {
135 foreach ($consts as $const) {
136 if (!empty($const[
"rowid"]) && in_array((
int) $const[
"rowid"], $toselect)) {
137 if (
dolibarr_set_const($db, $const[
"name"], $const[
"value"], $const[
"type"], 1, $const[
"note"], $const[
"entity"]) >= 0) {
140 dol_print_error($db);
144 if ($nbmodified > 0) {
145 setEventMessages($langs->trans(
"RecordSaved"),
null,
'mesgs');
151if ($massaction ==
'delete' || ($action ==
'delete' && $confirm ==
'yes')) {
153 foreach ($toselect as $constrowid) {
157 dol_print_error($db);
160 if ($nbdeleted > 1) {
161 setEventMessages($langs->trans(
"RecordsDeleted", $nbdeleted),
null,
'mesgs');
162 } elseif ($nbdeleted > 0) {
163 setEventMessages($langs->trans(
"RecordDeleted"),
null,
'mesgs');
165 setEventMessages($langs->trans(
"NoRecordDeleted"),
null,
'mesgs');
176$form =
new Form($db);
178$wikihelp =
'EN:Setup_Other|FR:Paramétrage_Divers|ES:Configuración_Varios';
179llxHeader(
'', $langs->trans(
"Setup"), $wikihelp,
'', 0, 0,
'',
'',
'',
'mod-admin page-const');
182if (
$conf->use_javascript_ajax) {
184<script
type=
"text/javascript">
185jQuery(document).ready(
function() {
186 jQuery(
"#updateconst").hide();
187 jQuery(
".checkforselect").change(
function() {
188 jQuery(
"#updateconst").show();
190 jQuery(
".inputforupdate").keyup(
function() {
191 jQuery(
"#updateconst").show();
192 jQuery(
"#action").val(
'update');
193 jQuery(
this).closest(
"tr").find(
".checkforselect").prop(
"checked",
true);
195 jQuery(
"#add").click(
function() {
196 jQuery(
"#action").val(
'add');
204$arrayofmassactions = array(
205 'predelete' => img_picto(
'',
'delete',
'class="pictofixedwidth"').$langs->trans(
"Delete"),
207if (
GETPOSTINT(
'nomassaction') || $massaction ==
'predelete') {
208 $arrayofmassactions = array();
210$massactionbutton = $form->selectMassAction(
'', $arrayofmassactions);
213$selectedfields = (count($arrayofmassactions) ? $form->showCheckAddButtons(
'checkforselect', 1) :
'');
215$arrayofselected = is_array($toselect) ? $toselect : array();
218$addformvisible = (($action ==
'create' || ($action ==
'add' &&
GETPOSTISSET(
'constname'))) && empty($massaction) && empty($filterbuttonclicked));
219$urlbuttonplus = $_SERVER[
'PHP_SELF'].($addformvisible ?
'' :
'?action=create');
220if (empty($user->entity) && $debug) {
221 $urlbuttonplus .= $addformvisible ?
'?debug=1' :
'&debug=1';
223$newcardbutton =
dolGetButtonTitle($langs->trans(
'New'),
'',
'fa fa-plus-circle', $urlbuttonplus,
'', ($addformvisible ? 2 : 1));
226if ($search_name !==
'') {
227 $param .=
'&search_name='.urlencode($search_name);
229if ($search_value !==
'') {
230 $param .=
'&search_value='.urlencode($search_value);
234print
'<form action="'.$_SERVER[
"PHP_SELF"].((empty($user->entity) && $debug) ?
'?debug=1' :
'').
'" method="POST" spellcheck="false">';
235print
'<input type="hidden" name="token" value="'.newToken().
'">';
236print
'<input type="hidden" id="action" name="action" value="add">';
237print
'<input type="hidden" name="sortfield" value="'.$sortfield.
'">';
238print
'<input type="hidden" name="sortorder" value="'.$sortorder.
'">';
240print
load_fiche_titre($langs->trans(
"OtherSetup"), $newcardbutton,
'title_setup', 0,
'',
'', $massactionbutton);
242print
'<div class="info">'.$langs->trans(
"ConstDesc").
"</div><br>\n";
245if ($addformvisible) {
247 print
'<div class="div-table-responsive-no-min">';
248 print
'<table class="noborder centpercent">';
251 print
'<tr class="liste_titre">';
252 print
'<th>'.$langs->trans(
"Name").
'</th>';
253 print
'<th>'.$langs->trans(
"Value").
'</th>';
254 print
'<th>'.$langs->trans(
"Comment").
'</th>';
255 print
'<th class="center">'.$langs->trans(
"DateModificationShort").
'</th>';
257 print
'<th class="center">'.$langs->trans(
"Entity").
'</th>';
259 print
'<th class="center"></th>';
265 print
'<tr class="oddeven nohover"><td>';
266 print
'<input type="text" class="flat minwidth300" name="constname" value="'.dolPrintHTMLForAttribute($constname).
'" spellcheck="false">';
269 print
'<input type="text" class="flat minwidth100" name="constvalue" value="'.dolPrintHTMLForAttribute($constvalue, 1).
'" spellcheck="false">';
272 print
'<input type="text" class="flat minwidth100" name="constnote" value="'.dolPrintHTMLForAttribute($constnote).
'">';
278 print
'<td class="center">';
279 print
'<input type="text" class="width50" name="entity" value="' .
$conf->entity .
'">';
281 print
'<td class="center">';
283 print
'<td class="center">';
284 print
'<input type="hidden" name="entity" value="' .
$conf->entity .
'">';
286 print
'<input type="submit" class="button button-add small" id="add" name="add" value="'.$langs->trans(
"Add").
'">';
296if ($massaction ==
'predelete') {
297 print $form->formconfirm($_SERVER[
"PHP_SELF"], $langs->trans(
"ConfirmMassDeletion"), $langs->trans(
"ConfirmMassDeletionQuestion", count($toselect)),
"delete",
null,
'', 0, 200, 500, 1);
301print
'<div class="div-table-responsive-no-min">';
302print
'<table class="noborder centpercent">';
305print
'<tr class="liste_titre_filter">';
307if (
$conf->main_checkbox_left_column) {
308 print
'<td class="liste_titre center maxwidthsearch">';
309 print $form->showFilterButtons();
313print
'<td class="liste_titre">';
314print
'<input type="text" class="flat maxwidth100" name="search_name" value="'.dol_escape_htmltag($search_name).
'">';
317print
'<td class="liste_titre">';
318print
'<input type="text" class="flat maxwidth100" name="search_value" value="'.dol_escape_htmltag($search_value).
'">';
321print
'<td class="liste_titre"></td>';
323print
'<td class="liste_titre"></td>';
326 print
'<td class="liste_titre"></td>';
329if (!
$conf->main_checkbox_left_column) {
330 print
'<td class="liste_titre center maxwidthsearch">';
331 print $form->showFilterButtons();
336print
'<tr class="liste_titre">';
338if (
$conf->main_checkbox_left_column) {
339 print
getTitleFieldOfList($selectedfields, 0, $_SERVER[
"PHP_SELF"],
'',
'', $param,
'', $sortfield, $sortorder,
'center maxwidthsearch ');
341print
getTitleFieldOfList(
'Name', 0, $_SERVER[
'PHP_SELF'],
'name',
'', $param,
'', $sortfield, $sortorder,
'') .
"\n";
342print
getTitleFieldOfList(
"Value", 0, $_SERVER[
"PHP_SELF"],
'',
'', $param,
'', $sortfield, $sortorder);
343print
getTitleFieldOfList(
"Comment", 0, $_SERVER[
"PHP_SELF"],
'',
'', $param,
'', $sortfield, $sortorder);
344print
getTitleFieldOfList(
'DateModificationShort', 0, $_SERVER[
'PHP_SELF'],
'tms',
'', $param,
'', $sortfield, $sortorder,
'center ') .
"\n";
346 print
getTitleFieldOfList(
'Entity', 0, $_SERVER[
'PHP_SELF'],
'tms',
'', $param,
'', $sortfield, $sortorder,
'center ') .
"\n";
349if (!
$conf->main_checkbox_left_column) {
350 print
getTitleFieldOfList($selectedfields, 0, $_SERVER[
"PHP_SELF"],
'',
'', $param,
'', $sortfield, $sortorder,
'center maxwidthsearch ');
358$sql .=
", ".$db->decrypt(
'name').
" as name";
359$sql .=
", ".$db->decrypt(
'value').
" as value";
364$sql .=
" FROM ".MAIN_DB_PREFIX.
"const";
365$sql .=
" WHERE entity IN (".$db->sanitize($user->entity.
",".((
int)
$conf->entity)).
")";
366if ((empty($user->entity)) && $debug) {
370 $sql .=
" AND visible = 1";
372if ($search_name !==
'') {
375if ($search_value !==
'') {
378$sql .= $db->order($sortfield, $sortorder);
381$result = $db->query($sql);
383 $num = $db->num_rows($result);
387 $obj = $db->fetch_object($result);
393 if (in_array((
int) $obj->rowid, $arrayofselected)) {
396 $actioncolumncontent =
'<input id="cb'.$obj->rowid.
'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$obj->rowid.
'"'.($selected ?
' checked="checked"' :
'').
'>';
400 print
'<tr class="oddeven">';
403 if (
$conf->main_checkbox_left_column) {
404 print
'<td class="center">'.$actioncolumncontent.
'</td>';
407 print
'<td>'.dol_escape_htmltag($obj->name).
'</td>'.
"\n";
411 print
'<input type="hidden" name="const['.$i.
'][rowid]" value="'.$obj->rowid.
'">';
412 print
'<input type="hidden" name="const['.$i.
'][name]" value="'.$obj->name.
'">';
413 print
'<input type="hidden" name="const['.$i.
'][type]" value="'.$obj->type.
'">';
414 if (!
isModEnabled(
'multicompany') || !empty($user->entity)) {
415 print
'<input type="hidden" name="const['.$i.
'][entity]" value="'.((int) $obj->entity).
'">';
417 print
'<input type="text" id="value_'.$i.
'" class="flat inputforupdate minwidth150" name="const['.$i.
'][value]" value="'.(isset($value) ? htmlspecialchars($value) :
'').
'">';
422 print
'<input type="text" id="note_'.$i.
'" class="flat inputforupdate minwidth200" name="const['.$i.
'][note]" value="'.(empty($obj->note) ?
'' : htmlspecialchars($obj->note, 1)).
'">';
426 print
'<td class="nowraponall center">';
431 if (
isModEnabled(
'multicompany') && empty($user->entity)) {
432 print
'<td class="center">';
433 print
'<input type="text" class="flat" size="1" name="const['.$i.
'][entity]" value="'.((int) $obj->entity).
'">';
438 if (!
$conf->main_checkbox_left_column) {
439 print
'<td class="center">'.$actioncolumncontent.
'</td>';
454 print
'<tr><td colspan="'.$colspan.
'"><span class="opacitymedium">'.$langs->trans(
"NoRecordFound").
'</span></td></tr>';
462if (
$conf->use_javascript_ajax) {
464 print
'<div id="updateconst" class="right">';
465 print
'<input type="submit" class="button button-edit marginbottomonly" name="update" value="'.$langs->trans(
"Modify").
'">';
$propal type
'integer', 'integer:ObjectClass:PathToClass[:AddCreateButtonOrNot[:Filter[:Sortfield]]]',...
dolibarr_set_const($db, $name, $value, $type='chaine', $visible=0, $note='', $entity=1)
Insert a parameter (key,value) into database (delete old key then insert it again).
dolibarr_del_const($db, $name, $entity=1)
Delete a constant.
llxFooter($comment='', $zone='private', $disabledoutputofmessages=0)
Empty footer.
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader($head='', $title='', $help_url='', $target='', $disablejs=0, $disablehead=0, $arrayofjs='', $arrayofcss='', $morequerystring='', $morecssonbody='', $replacemainareaby='', $disablenofollow=0, $disablenoindex=0)
Empty header.
if(!isModEnabled('ai')||!getDolGlobalString('AI_ASSISTANT_ENABLED')) global $conf
The main.inc.php has been included so the following variable are now defined:
natural_search($fields, $value, $mode=0, $nofirstand=0, $sqltoadd='')
Generate natural SQL search string for a criteria (this criteria can be tested on one or several fiel...
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0, $nodefault=0)
Return value of a param into GET or POST supervariable.
GETPOSTINT($paramname, $method=0, $nodefault=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs=null, $encodetooutput=false, $decorate=0)
Output date in a string format according to outputlangs (or langs if not defined).
GETPOSTISSET($paramname)
Return true if we are in a context of submitting the parameter $paramname from a POST of a form.
isModEnabled($module)
Is Dolibarr module enabled.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
dolGetButtonTitle($label, $helpText='', $iconClass='fa fa-file', $url='', $id='', $status=1, $params=array())
Function dolGetButtonTitle : this kind of buttons are used in title in list.
getTitleFieldOfList($name, $thead=0, $file="", $field="", $begin="", $moreparam="", $moreattrib="", $sortfield="", $sortorder="", $prefix="", $disablesortlink=0, $tooltip='', $forcenowrapcolumntitle=0)
Get title line of an array.
load_fiche_titre($title, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='', $morecssonpicto='widthpictotitle')
Load a title with picto.
dol_set_focus($selector, $nooutput=0)
Set focus onto field with selector (similar behaviour of 'autofocus' HTML5 tag)
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.
dolDecrypt($chain, $key='', $patterntotest='')
Decode a string with a symmetric encryption.