28require
'../main.inc.php';
29require_once DOL_DOCUMENT_ROOT.
'/core/lib/admin.lib.php';
30require_once DOL_DOCUMENT_ROOT.
'/core/lib/security.lib.php';
35$rowid =
GETPOST(
'rowid',
'int');
36$entity =
GETPOST(
'entity',
'int');
37$action =
GETPOST(
'action',
'aZ09');
38$debug =
GETPOST(
'debug',
'int');
39$consts =
GETPOST(
'const',
'array');
40$constname =
GETPOST(
'constname',
'alphanohtml');
41$constvalue =
GETPOST(
'constvalue',
'restricthtml');
42$constnote =
GETPOST(
'constnote',
'alpha');
44$limit =
GETPOST(
'limit',
'int') ?
GETPOST(
'limit',
'int') : $conf->liste_limit;
45$sortfield =
GETPOST(
'sortfield',
'aZ09comma');
46$sortorder =
GETPOST(
'sortorder',
'aZ09comma');
47$page = GETPOSTISSET(
'pageplusone') ? (
GETPOST(
'pageplusone') - 1) :
GETPOST(
"page",
'int');
48if (empty($page) || $page == -1 ||
GETPOST(
'button_search',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha') || (empty($toselect) && $massaction ===
'0')) {
51$offset = $limit * $page;
54if (empty($sortfield)) {
55 $sortfield =
'entity,name';
57if (empty($sortorder)) {
61if ($action ==
'add' &&
GETPOST(
'update')) {
64if ($action ==
'add' &&
GETPOST(
'delete')) {
70if ($action ==
'delete' &&
GETPOST(
'add')) {
84if ($action ==
'add') {
87 if (empty($constname)) {
88 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Name")),
null,
'errors');
91 if ($constvalue ==
'') {
92 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Value")),
null,
'errors');
97 if (
dolibarr_set_const($db, $constname, $constvalue,
'chaine', 1, $constnote, $entity) >= 0) {
110if (!empty($consts) && $action ==
'update') {
112 foreach ($consts as $const) {
113 if (!empty($const[
"check"])) {
114 if (
dolibarr_set_const($db, $const[
"name"], $const[
"value"], $const[
"type"], 1, $const[
"note"], $const[
"entity"]) >= 0) {
121 if ($nbmodified > 0) {
128if (!empty($consts) && $action ==
'delete') {
130 foreach ($consts as $const) {
131 if (!empty($const[
"check"])) {
139 if ($nbdeleted > 0) {
146if ($action ==
'delete') {
159$form =
new Form($db);
161$wikihelp =
'EN:Setup_Other|FR:Paramétrage_Divers|ES:Configuración_Varios';
162llxHeader(
'', $langs->trans(
"Setup"), $wikihelp);
165if ($conf->use_javascript_ajax) {
167<script
type=
"text/javascript">
168jQuery(document).ready(
function() {
169 jQuery(
"#updateconst").hide();
170 jQuery(
"#delconst").hide();
171 jQuery(
".checkboxfordelete").click(
function() {
172 jQuery(
"#delconst").show();
174 jQuery(
".inputforupdate").keyup(
function() {
175 var field_id = jQuery(
this).attr(
"id");
176 var row_num = field_id.split(
"_");
177 jQuery(
"#updateconst").show();
178 jQuery(
"#action").val(
'update');
179 jQuery(
"#check_" + row_num[1]).prop(
"checked",
true);
188print
'<span class="opacitymedium">'.$langs->trans(
"ConstDesc").
"</span><br>\n";
193print
'<form action="'.$_SERVER[
"PHP_SELF"].((empty($user->entity) && $debug) ?
'?debug=1' :
'').
'" method="POST">';
194print
'<input type="hidden" name="token" value="'.newToken().
'">';
195print
'<input type="hidden" id="action" name="action" value="add">';
196print
'<input type="hidden" name="sortfield" value="'.$sortfield.
'">';
197print
'<input type="hidden" name="sortorder" value="'.$sortorder.
'">';
199print
'<div class="div-table-responsive-no-min">';
200print
'<table class="noborder centpercent">';
201print
'<tr class="liste_titre">';
202print
getTitleFieldOfList(
'Name', 0, $_SERVER[
'PHP_SELF'],
'name',
'', $param,
'', $sortfield, $sortorder,
'') .
"\n";
203print
getTitleFieldOfList(
"Value", 0, $_SERVER[
"PHP_SELF"],
'',
'', $param,
'', $sortfield, $sortorder);
204print
getTitleFieldOfList(
"Comment", 0, $_SERVER[
"PHP_SELF"],
'',
'', $param,
'', $sortfield, $sortorder);
205print
getTitleFieldOfList(
'DateModificationShort', 0, $_SERVER[
'PHP_SELF'],
'tms',
'', $param,
'', $sortfield, $sortorder,
'center ') .
"\n";
206if (isModEnabled(
'multicompany') && !$user->entity) {
207 print
getTitleFieldOfList(
'Entity', 0, $_SERVER[
'PHP_SELF'],
'tms',
'', $param,
'', $sortfield, $sortorder,
'center ') .
"\n";
209print
getTitleFieldOfList(
"", 0, $_SERVER[
"PHP_SELF"],
'',
'', $param,
'', $sortfield, $sortorder,
'center ');
216print
'<tr class="oddeven nohover"><td>';
217print
'<input type="text" class="flat minwidth300" name="constname" value="'.$constname.
'">';
220print
'<input type="text" class="flat minwidth100" name="constvalue" value="'.$constvalue.
'">';
223print
'<input type="text" class="flat minwidth100" name="constnote" value="'.$constnote.
'">';
228if (isModEnabled(
'multicompany') && !$user->entity) {
230 print
'<input type="text" class="flat" size="1" name="entity" value="' . $conf->entity .
'">';
232 print
'<td class="center">';
234 print
'<td class="center">';
235 print
'<input type="hidden" name="entity" value="' . $conf->entity .
'">';
237print
'<input type="submit" class="button button-add small" id="add" name="add" value="'.$langs->trans(
"Add").
'">';
245$sql .=
", ".$db->decrypt(
'name').
" as name";
246$sql .=
", ".$db->decrypt(
'value').
" as value";
251$sql .=
" FROM ".MAIN_DB_PREFIX.
"const";
252$sql .=
" WHERE entity IN (".$db->sanitize($user->entity.
",".$conf->entity).
")";
253if ((empty($user->entity) || $user->admin) && $debug) {
256 $sql .=
" AND visible = 1";
261$sql .= $db->order($sortfield, $sortorder);
264$result = $db->query($sql);
266 $num = $db->num_rows($result);
270 $obj = $db->fetch_object($result);
276 print
'<tr class="oddeven" data-checkbox-id="check_'.$i.
'"><td>'.
dol_escape_htmltag($obj->name).
'</td>'.
"\n";
280 print
'<input type="hidden" name="const['.$i.
'][rowid]" value="'.$obj->rowid.
'">';
281 print
'<input type="hidden" name="const['.$i.
'][name]" value="'.$obj->name.
'">';
282 print
'<input type="hidden" name="const['.$i.
'][type]" value="'.$obj->type.
'">';
283 print
'<input type="text" id="value_'.$i.
'" class="flat inputforupdate minwidth150" name="const['.$i.
'][value]" value="'.($value ? htmlspecialchars($value) :
'').
'">';
288 print
'<input type="text" id="note_'.$i.
'" class="flat inputforupdate minwidth200" name="const['.$i.
'][note]" value="'.(empty($obj->note) ?
'' : htmlspecialchars($obj->note, 1)).
'">';
292 print
'<td class="nowraponall center">';
297 if (isModEnabled(
'multicompany') && empty($user->entity)) {
299 print
'<input type="text" class="flat" size="1" name="const['.$i.
'][entity]" value="'.((int) $obj->entity).
'">';
301 print
'<td class="center">';
303 print
'<td class="center">';
304 print
'<input type="hidden" name="const['.$i.
'][entity]" value="'.((int) $obj->entity).
'">';
307 if (!empty($conf->use_javascript_ajax)) {
308 print
'<input type="checkbox" class="flat checkboxfordelete" id="check_'.$i.
'" name="const['.$i.
'][check]" value="1">';
310 print
'<a href="'.$_SERVER[
'PHP_SELF'].
'?rowid='.$obj->rowid.
'&entity='.$obj->entity.
'&action=delete&token='.newToken().((empty($user->entity) && $debug) ?
'&debug=1' :
'').
'">'.
img_delete().
'</a>';
313 print
"</td></tr>\n";
324if ($conf->use_javascript_ajax) {
326 print
'<div id="updateconst" class="right">';
327 print
'<input type="submit" class="button button-edit marginbottomonly" name="update" value="'.$langs->trans(
"Modify").
'">';
329 print
'<div id="delconst" class="right">';
330 print
'<input type="submit" class="button button-cancel marginbottomonly" name="delete" value="'.$langs->trans(
"Delete").
'">';
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.
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader()
Empty header.
load_fiche_titre($titre, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
img_delete($titlealt='default', $other='class="pictodelete"', $morecss='')
Show delete logo.
dol_print_error($db='', $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
natural_search($fields, $value, $mode=0, $nofirstand=0)
Generate natural SQL search string for a criteria (this criteria can be tested on one or several fiel...
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs='', $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
getTitleFieldOfList($name, $thead=0, $file="", $field="", $begin="", $moreparam="", $moreattrib="", $sortfield="", $sortorder="", $prefix="", $disablesortlink=0, $tooltip='', $forcenowrapcolumntitle=0)
Get title line of an array.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0)
Set event messages in dol_events session object.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $noescapetags='', $escapeonlyhtmltags=0, $cleanalsojavascript=0)
Returns text escaped for inclusion in HTML alt or title or value tags, or into values of HTML input f...
if(preg_match('/crypted:/i', $dolibarr_main_db_pass)||!empty($dolibarr_main_db_encrypted_pass)) $conf db type
dolDecrypt($chain, $key='')
Decode a string with a symetric encryption.
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.