28 require
'../main.inc.php';
29 require_once DOL_DOCUMENT_ROOT.
'/core/lib/admin.lib.php';
30 require_once DOL_DOCUMENT_ROOT.
'/core/lib/security.lib.php';
33 $langs->load(
"admin");
39 $rowid =
GETPOST(
'rowid',
'int');
40 $entity =
GETPOST(
'entity',
'int');
41 $action =
GETPOST(
'action',
'aZ09');
42 $debug =
GETPOST(
'debug',
'int');
43 $consts =
GETPOST(
'const',
'array');
44 $constname =
GETPOST(
'constname',
'alphanohtml');
45 $constvalue =
GETPOST(
'constvalue',
'restricthtml');
46 $constnote =
GETPOST(
'constnote',
'alpha');
49 $limit =
GETPOST(
'limit',
'int') ?
GETPOST(
'limit',
'int') : $conf->liste_limit;
50 $sortfield =
GETPOST(
'sortfield',
'aZ09comma');
51 $sortorder =
GETPOST(
'sortorder',
'aZ09comma');
53 if (empty($page) || $page == -1 ||
GETPOST(
'button_search',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha') || (empty($toselect) && $massaction ===
'0')) {
56 $offset = $limit * $page;
57 $pageprev = $page - 1;
58 $pagenext = $page + 1;
59 if (empty($sortfield)) {
60 $sortfield =
'entity,name';
62 if (empty($sortorder)) {
71 if ($action ==
'add' || (
GETPOST(
'add') && $action !=
'update')) {
74 if (empty($constname)) {
75 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Name")),
null,
'errors');
78 if ($constvalue ==
'') {
79 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Value")),
null,
'errors');
84 if (
dolibarr_set_const($db, $constname, $constvalue,
'chaine', 1, $constnote, $entity) >= 0) {
97 if (!empty($consts) && $action ==
'update') {
99 foreach ($consts as $const) {
100 if (!empty($const[
"check"])) {
101 if (
dolibarr_set_const($db, $const[
"name"], $const[
"value"], $const[
"type"], 1, $const[
"note"], $const[
"entity"]) >= 0) {
108 if ($nbmodified > 0) {
115 if (!empty($consts) && $action ==
'delete') {
117 foreach ($consts as $const) {
118 if (!empty($const[
"check"])) {
126 if ($nbdeleted > 0) {
133 if ($action ==
'delete') {
148 $wikihelp =
'EN:Setup_Other|FR:Paramétrage_Divers|ES:Configuración_Varios';
152 if ($conf->use_javascript_ajax) {
154 <script
type=
"text/javascript">
155 jQuery(document).ready(
function() {
156 jQuery(
"#updateconst").hide();
157 jQuery(
"#delconst").hide();
158 jQuery(
".checkboxfordelete").click(
function() {
159 jQuery(
"#delconst").show();
160 jQuery(
"#action").val(
'delete');
162 jQuery(
".inputforupdate").keyup(
function() {
163 var field_id = jQuery(
this).attr(
"id");
164 var row_num = field_id.split(
"_");
165 jQuery(
"#updateconst").show();
166 jQuery(
"#action").val(
'update');
167 jQuery(
"#check_" + row_num[1]).prop(
"checked",
true);
176 print
'<span class="opacitymedium">'.$langs->trans(
"ConstDesc").
"</span><br>\n";
181 print
'<form action="'.$_SERVER[
"PHP_SELF"].((empty($user->entity) && $debug) ?
'?debug=1' :
'').
'" method="POST">';
182 print
'<input type="hidden" name="token" value="'.newToken().
'">';
183 print
'<input type="hidden" id="action" name="action" value="">';
184 print
'<input type="hidden" name="sortfield" value="'.$sortfield.
'">';
185 print
'<input type="hidden" name="sortorder" value="'.$sortorder.
'">';
187 print
'<div class="div-table-responsive-no-min">';
188 print
'<table class="noborder centpercent">';
189 print
'<tr class="liste_titre">';
190 print
getTitleFieldOfList(
'Name', 0, $_SERVER[
'PHP_SELF'],
'name',
'', $param,
'', $sortfield, $sortorder,
'') .
"\n";
191 print
getTitleFieldOfList(
"Value", 0, $_SERVER[
"PHP_SELF"],
'',
'', $param,
'', $sortfield, $sortorder);
192 print
getTitleFieldOfList(
"Comment", 0, $_SERVER[
"PHP_SELF"],
'',
'', $param,
'', $sortfield, $sortorder);
193 print
getTitleFieldOfList(
'DateModificationShort', 0, $_SERVER[
'PHP_SELF'],
'tms',
'', $param,
'', $sortfield, $sortorder,
'center ') .
"\n";
195 print
getTitleFieldOfList(
'Entity', 0, $_SERVER[
'PHP_SELF'],
'tms',
'', $param,
'', $sortfield, $sortorder,
'center ') .
"\n";
197 print
getTitleFieldOfList(
"", 0, $_SERVER[
"PHP_SELF"],
'',
'', $param,
'', $sortfield, $sortorder,
'center ');
204 print
'<tr class="oddeven nohover"><td>';
205 print
'<input type="text" class="flat minwidth300" name="constname" value="'.$constname.
'">';
208 print
'<input type="text" class="flat minwidth100" name="constvalue" value="'.$constvalue.
'">';
211 print
'<input type="text" class="flat minwidth100" name="constnote" value="'.$constnote.
'">';
218 print
'<input type="text" class="flat" size="1" name="entity" value="' . $conf->entity .
'">';
220 print
'<td class="center">';
222 print
'<td class="center">';
223 print
'<input type="hidden" name="entity" value="' . $conf->entity .
'">';
225 print
'<input type="submit" class="button button-add small" name="add" value="'.$langs->trans(
"Add").
'">';
233 $sql .=
", ".$db->decrypt(
'name').
" as name";
234 $sql .=
", ".$db->decrypt(
'value').
" as value";
239 $sql .=
" FROM ".MAIN_DB_PREFIX.
"const";
240 $sql .=
" WHERE entity IN (".$db->sanitize($user->entity.
",".$conf->entity).
")";
241 if ((empty($user->entity) || $user->admin) && $debug) {
244 $sql .=
" AND visible = 1";
249 $sql .= $db->order($sortfield, $sortorder);
252 $result = $db->query($sql);
254 $num = $db->num_rows($result);
258 $obj = $db->fetch_object($result);
264 print
'<tr class="oddeven" data-checkbox-id="check_'.$i.
'"><td>'.
dol_escape_htmltag($obj->name).
'</td>'.
"\n";
268 print
'<input type="hidden" name="const['.$i.
'][rowid]" value="'.$obj->rowid.
'">';
269 print
'<input type="hidden" name="const['.$i.
'][name]" value="'.$obj->name.
'">';
270 print
'<input type="hidden" name="const['.$i.
'][type]" value="'.$obj->type.
'">';
271 print
'<input type="text" id="value_'.$i.
'" class="flat inputforupdate minwidth150" name="const['.$i.
'][value]" value="'.htmlspecialchars($value).
'">';
276 print
'<input type="text" id="note_'.$i.
'" class="flat inputforupdate minwidth200" name="const['.$i.
'][note]" value="'.htmlspecialchars($obj->note, 1).
'">';
280 print
'<td class="nowraponall center">';
287 print
'<input type="text" class="flat" size="1" name="const['.$i.
'][entity]" value="'.((int) $obj->entity).
'">';
289 print
'<td class="center">';
291 print
'<td class="center">';
292 print
'<input type="hidden" name="const['.$i.
'][entity]" value="'.((int) $obj->entity).
'">';
295 if ($conf->use_javascript_ajax) {
296 print
'<input type="checkbox" class="flat checkboxfordelete" id="check_'.$i.
'" name="const['.$i.
'][check]" value="1">';
298 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>';
301 print
"</td></tr>\n";
312 if ($conf->use_javascript_ajax) {
314 print
'<div id="updateconst" class="right">';
315 print
'<input type="submit" class="button button-edit marginbottomonly" name="update" value="'.$langs->trans(
"Modify").
'">';
317 print
'<div id="delconst" class="right">';
318 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($actionsave) if(!isset($conf->global->MAIN_AGENDA_EXPORT_PAST_DELAY)) $wikihelp
View.
if(!defined('NOREQUIRESOC')) if(!defined('NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined('NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined('NOREQUIREAJAX')) llxHeader()
Empty header.
if($cancel &&! $id) if($action=='add' &&! $cancel) if($action=='delete') if($id) $form
Actions.
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_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $noescapetags='', $escapeonlyhtmltags=0)
Returns text escaped for inclusion in HTML alt or title tags, or into values of HTML input fields.
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...
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='')
Set event messages in dol_events session object.
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs='', $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
newToken()
Return the value of token currently saved into session with name 'newtoken'.
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.
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.
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.