Go to the documentation of this file.
27 require
'../main.inc.php';
28 require_once DOL_DOCUMENT_ROOT.
'/core/lib/admin.lib.php';
31 $langs->load(
"admin");
37 $rowid =
GETPOST(
'rowid',
'int');
38 $entity =
GETPOST(
'entity',
'int');
39 $action =
GETPOST(
'action',
'aZ09');
40 $debug =
GETPOST(
'debug',
'int');
41 $consts =
GETPOST(
'const',
'array');
42 $constname =
GETPOST(
'constname',
'alphanohtml');
43 $constvalue =
GETPOST(
'constvalue',
'restricthtml');
44 $constnote =
GETPOST(
'constnote',
'alpha');
47 $limit =
GETPOST(
'limit',
'int') ?
GETPOST(
'limit',
'int') : $conf->liste_limit;
48 $sortfield =
GETPOST(
'sortfield',
'aZ09comma');
49 $sortorder =
GETPOST(
'sortorder',
'aZ09comma');
51 if (empty($page) || $page == -1 ||
GETPOST(
'button_search',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha') || (empty($toselect) && $massaction ===
'0')) {
54 $offset = $limit * $page;
55 $pageprev = $page - 1;
56 $pagenext = $page + 1;
57 if (empty($sortfield)) {
58 $sortfield =
'entity,name';
60 if (empty($sortorder)) {
69 if ($action ==
'add' || (
GETPOST(
'add') && $action !=
'update')) {
72 if (empty($constname)) {
73 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Name")),
null,
'errors');
76 if ($constvalue ==
'') {
77 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Value")),
null,
'errors');
82 if (
dolibarr_set_const($db, $constname, $constvalue,
'chaine', 1, $constnote, $entity) >= 0) {
95 if (!empty($consts) && $action ==
'update') {
97 foreach ($consts as $const) {
98 if (!empty($const[
"check"])) {
99 if (
dolibarr_set_const($db, $const[
"name"], $const[
"value"], $const[
"type"], 1, $const[
"note"], $const[
"entity"]) >= 0) {
106 if ($nbmodified > 0) {
113 if (!empty($consts) && $action ==
'delete') {
115 foreach ($consts as $const) {
116 if (!empty($const[
"check"])) {
124 if ($nbdeleted > 0) {
131 if ($action ==
'delete') {
146 $wikihelp =
'EN:Setup_Other|FR:Paramétrage_Divers|ES:Configuración_Varios';
150 if ($conf->use_javascript_ajax) {
152 <script
type=
"text/javascript">
153 jQuery(document).ready(
function() {
154 jQuery(
"#updateconst").hide();
155 jQuery(
"#delconst").hide();
156 jQuery(
".checkboxfordelete").click(
function() {
157 jQuery(
"#delconst").show();
158 jQuery(
"#action").val(
'delete');
160 jQuery(
".inputforupdate").keyup(
function() {
161 var field_id = jQuery(
this).attr(
"id");
162 var row_num = field_id.split(
"_");
163 jQuery(
"#updateconst").show();
164 jQuery(
"#action").val(
'update');
165 jQuery(
"#check_" + row_num[1]).prop(
"checked",
true);
174 print
'<span class="opacitymedium">'.$langs->trans(
"ConstDesc").
"</span><br>\n";
179 print
'<form action="'.$_SERVER[
"PHP_SELF"].((empty($user->entity) && $debug) ?
'?debug=1' :
'').
'" method="POST">';
180 print
'<input type="hidden" name="token" value="'.newToken().
'">';
181 print
'<input type="hidden" id="action" name="action" value="">';
182 print
'<input type="hidden" name="sortfield" value="'.$sortfield.
'">';
183 print
'<input type="hidden" name="sortorder" value="'.$sortorder.
'">';
185 print
'<div class="div-table-responsive-no-min">';
186 print
'<table class="noborder centpercent">';
187 print
'<tr class="liste_titre">';
188 print
getTitleFieldOfList(
'Name', 0, $_SERVER[
'PHP_SELF'],
'name',
'', $param,
'', $sortfield, $sortorder,
'').
"\n";
189 print
getTitleFieldOfList(
"Value", 0, $_SERVER[
"PHP_SELF"],
'',
'', $param,
'', $sortfield, $sortorder);
190 print
getTitleFieldOfList(
"Comment", 0, $_SERVER[
"PHP_SELF"],
'',
'', $param,
'', $sortfield, $sortorder);
191 print
getTitleFieldOfList(
'DateModificationShort', 0, $_SERVER[
'PHP_SELF'],
'tms',
'', $param,
'', $sortfield, $sortorder,
'center ').
"\n";
192 if (!empty($conf->multicompany->enabled) && !$user->entity) {
193 print
getTitleFieldOfList(
'Entity', 0, $_SERVER[
'PHP_SELF'],
'tms',
'', $param,
'', $sortfield, $sortorder,
'center ').
"\n";
195 print
getTitleFieldOfList(
"", 0, $_SERVER[
"PHP_SELF"],
'',
'', $param,
'', $sortfield, $sortorder,
'center ');
202 print
'<tr class="oddeven nohover"><td>';
203 print
'<input type="text" class="flat minwidth300" name="constname" value="'.$constname.
'">';
206 print
'<input type="text" class="flat minwidth100" name="constvalue" value="'.$constvalue.
'">';
209 print
'<input type="text" class="flat minwidth100" name="constnote" value="'.$constnote.
'">';
214 if (!empty($conf->multicompany->enabled) && !$user->entity) {
216 print
'<input type="text" class="flat" size="1" name="entity" value="'.$conf->entity.
'">';
218 print
'<td class="center">';
220 print
'<td class="center">';
221 print
'<input type="hidden" name="entity" value="'.$conf->entity.
'">';
223 print
'<input type="submit" class="button button-add small" name="add" value="'.$langs->trans(
"Add").
'">';
231 $sql .=
", ".$db->decrypt(
'name').
" as name";
232 $sql .=
", ".$db->decrypt(
'value').
" as value";
237 $sql .=
" FROM ".MAIN_DB_PREFIX.
"const";
238 $sql .=
" WHERE entity IN (".$db->sanitize($user->entity.
",".$conf->entity).
")";
239 if ((empty($user->entity) || $user->admin) && $debug) {
242 $sql .=
" AND visible = 1";
247 $sql .= $db->order($sortfield, $sortorder);
250 $result = $db->query($sql);
252 $num = $db->num_rows($result);
256 $obj = $db->fetch_object($result);
260 print
'<tr class="oddeven" data-checkbox-id="check_'.$i.
'"><td>'.$obj->name.
'</td>'.
"\n";
264 print
'<input type="hidden" name="const['.$i.
'][rowid]" value="'.$obj->rowid.
'">';
265 print
'<input type="hidden" name="const['.$i.
'][name]" value="'.$obj->name.
'">';
266 print
'<input type="hidden" name="const['.$i.
'][type]" value="'.$obj->type.
'">';
267 print
'<input type="text" id="value_'.$i.
'" class="flat inputforupdate minwidth150" name="const['.$i.
'][value]" value="'.htmlspecialchars($obj->value).
'">';
272 print
'<input type="text" id="note_'.$i.
'" class="flat inputforupdate minwidth200" name="const['.$i.
'][note]" value="'.htmlspecialchars($obj->note, 1).
'">';
276 print
'<td class="nowraponall center">';
281 if (!empty($conf->multicompany->enabled) && !$user->entity) {
283 print
'<input type="text" class="flat" size="1" name="const['.$i.
'][entity]" value="'.$obj->entity.
'">';
285 print
'<td class="center">';
287 print
'<td class="center">';
288 print
'<input type="hidden" name="const['.$i.
'][entity]" value="'.$obj->entity.
'">';
291 if ($conf->use_javascript_ajax) {
292 print
'<input type="checkbox" class="flat checkboxfordelete" id="check_'.$i.
'" name="const['.$i.
'][check]" value="1">';
294 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>';
297 print
"</td></tr>\n";
308 if ($conf->use_javascript_ajax) {
310 print
'<div id="updateconst" class="right">';
311 print
'<input type="submit" class="button button-edit marginbottomonly" name="update" value="'.$langs->trans(
"Modify").
'">';
313 print
'<div id="delconst" class="right">';
314 print
'<input type="submit" class="button button-cancel marginbottomonly" name="delete" value="'.$langs->trans(
"Delete").
'">';
dolibarr_del_const($db, $name, $entity=1)
Delete a constant.
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($titre, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
dol_print_error($db='', $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
if($cancel &&! $id) if($action=='add' &&! $cancel) if($action=='delete') if($id) $form
Actions.
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs='', $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
img_delete($titlealt='default', $other='class="pictodelete"', $morecss='')
Show delete logo.
if($actionsave) if(!isset($conf->global->MAIN_AGENDA_EXPORT_PAST_DELAY)) $wikihelp
View.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
newToken()
Return the value of token currently saved into session with name 'newtoken'.
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).
GETPOSTISSET($paramname)
Return true if we are in a context of submitting the parameter $paramname from a POST of a form.
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...
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='')
Set event messages in dol_events session object.
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program Calling this function terminate execution ...
if(preg_match('/crypted:/i', $dolibarr_main_db_pass)||!empty($dolibarr_main_db_encrypted_pass)) $conf db type
if(!defined('NOREQUIRESOC')) if(!defined('NOREQUIRETRAN')) if(!defined('NOCSRFCHECK')) if(!defined('NOTOKENRENEWAL')) if(!defined('NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined('NOREQUIREAJAX')) llxHeader()
Empty header.