27 require
'../main.inc.php';
28 require_once DOL_DOCUMENT_ROOT.
'/core/lib/admin.lib.php';
31 $langs->load(
"admin");
36 $rowid =
GETPOST(
'rowid',
'int');
37 $entity =
GETPOST(
'entity',
'int');
38 $action =
GETPOST(
'action',
'aZ09');
39 $update =
GETPOST(
'update',
'alpha');
40 $delete =
GETPOST(
'delete',
'none');
41 $debug =
GETPOST(
'debug',
'int');
42 $consts =
GETPOST(
'const',
'array');
43 $constname =
GETPOST(
'constname',
'alphanohtml');
44 $constvalue =
GETPOST(
'constvalue',
'restricthtml');
45 $constnote =
GETPOST(
'constnote',
'alpha');
48 $limit =
GETPOST(
'limit',
'int') ?
GETPOST(
'limit',
'int') : $conf->liste_limit;
49 $sortfield =
GETPOST(
'sortfield',
'aZ09comma');
50 $sortorder =
GETPOST(
'sortorder',
'aZ09comma');
52 if (empty($page) || $page == -1 ||
GETPOST(
'button_search',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha') || (empty($toselect) && $massaction ===
'0')) { $page = 0; }
53 $offset = $limit * $page;
54 $pageprev = $page - 1;
55 $pagenext = $page + 1;
56 if (empty($sortfield)) $sortfield =
'entity,name';
57 if (empty($sortorder)) $sortorder =
'ASC';
64 if ($action ==
'add' || (
GETPOST(
'add') && $action !=
'update'))
68 if (empty($constname))
70 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Name")), null,
'errors');
73 if ($constvalue ==
'')
75 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Value")), null,
'errors');
81 if (
dolibarr_set_const($db, $constname, $constvalue,
'chaine', 1, $constnote, $entity) >= 0)
95 if (!empty($consts) && $action ==
'update')
98 foreach ($consts as $const)
100 if (!empty($const[
"check"]))
102 if (
dolibarr_set_const($db, $const[
"name"], $const[
"value"], $const[
"type"], 1, $const[
"note"], $const[
"entity"]) >= 0)
110 if ($nbmodified > 0)
setEventMessages($langs->trans(
"RecordSaved"), null,
'mesgs');
115 if (!empty($consts) && $action ==
'delete')
118 foreach ($consts as $const)
120 if (!empty($const[
"check"]))
130 if ($nbdeleted > 0)
setEventMessages($langs->trans(
"RecordDeleted"), null,
'mesgs');
135 if ($action ==
'delete')
150 $form =
new Form($db);
152 $wikihelp =
'EN:Setup_Other|FR:Paramétrage_Divers|ES:Configuración_Varios';
156 if ($conf->use_javascript_ajax)
159 <script
type=
"text/javascript">
160 jQuery(document).ready(
function() {
161 jQuery(
"#updateconst").hide();
162 jQuery(
"#delconst").hide();
163 jQuery(
".checkboxfordelete").click(
function() {
164 jQuery(
"#delconst").show();
165 jQuery(
"#action").val(
'delete');
167 jQuery(
".inputforupdate").keyup(
function() {
168 var field_id = jQuery(
this).attr(
"id");
169 var row_num = field_id.split(
"_");
170 jQuery(
"#updateconst").show();
171 jQuery(
"#action").val(
'update');
172 jQuery(
"#check_" + row_num[1]).prop(
"checked",
true);
181 print '<span class="opacitymedium">'.$langs->trans(
"ConstDesc").
"</span><br>\n";
186 print '<form action="'.$_SERVER[
"PHP_SELF"].((empty($user->entity) && $debug) ?
'?debug=1' :
'').
'" method="POST">';
187 print '<input type="hidden" name="token" value="'.newToken().
'">';
188 print '<input type="hidden" id="action" name="action" value="">';
189 print '<input type="hidden" name="sortfield" value="'.$sortfield.
'">';
190 print '<input type="hidden" name="sortorder" value="'.$sortorder.
'">';
192 print '<div class="div-table-responsive-no-min">';
193 print '<table class="noborder centpercent">';
194 print '<tr class="liste_titre">';
199 if (!empty($conf->multicompany->enabled) && !$user->entity)
210 print '<tr class="oddeven nohover"><td>';
211 print '<input type="text" class="flat minwidth300" name="constname" value="'.$constname.
'">';
214 print '<input type="text" class="flat minwidth100" name="constvalue" value="'.$constvalue.
'">';
217 print '<input type="text" class="flat minwidth100" name="constnote" value="'.$constnote.
'">';
222 if (!empty($conf->multicompany->enabled) && !$user->entity)
225 print '<input type="text" class="flat" size="1" name="entity" value="'.$conf->entity.
'">';
227 print '<td class="center">';
229 print '<td class="center">';
230 print '<input type="hidden" name="entity" value="'.$conf->entity.
'">';
232 print '<input type="submit" class="button" value="'.$langs->trans(
"Add").
'" name="add">';
240 $sql .=
", ".$db->decrypt(
'name').
" as name";
241 $sql .=
", ".$db->decrypt(
'value').
" as value";
246 $sql .=
" FROM ".MAIN_DB_PREFIX.
"const";
247 $sql .=
" WHERE entity IN (".$user->entity.
",".$conf->entity.
")";
248 if ((empty($user->entity) || $user->admin) && $debug) {}
249 elseif (!
GETPOST(
'visible') ||
GETPOST(
'visible') !=
'all') $sql .= " AND visible = 1";
251 $sql .= $db->order($sortfield, $sortorder);
254 $result = $db->query($sql);
257 $num = $db->num_rows($result);
262 $obj = $db->fetch_object($result);
266 print '<tr class="oddeven"><td>'.$obj->name.
'</td>'.
"\n";
270 print '<input type="hidden" name="const['.$i.
'][rowid]" value="'.$obj->rowid.
'">';
271 print '<input type="hidden" name="const['.$i.
'][name]" value="'.$obj->name.
'">';
272 print '<input type="hidden" name="const['.$i.
'][type]" value="'.$obj->type.
'">';
273 print '<input type="text" id="value_'.$i.
'" class="flat inputforupdate" size="30" name="const['.$i.
'][value]" value="'.htmlspecialchars($obj->value).
'">';
278 print '<input type="text" id="note_'.$i.
'" class="flat inputforupdate" size="40" name="const['.$i.
'][note]" value="'.htmlspecialchars($obj->note, 1).
'">';
287 if (!empty($conf->multicompany->enabled) && !$user->entity)
290 print
'<input type="text" class="flat" size="1" name="const['.$i.
'][entity]" value="'.$obj->entity.
'">';
292 print
'<td class="center">';
294 print
'<td class="center">';
295 print
'<input type="hidden" name="const['.$i.
'][entity]" value="'.$obj->entity.
'">';
298 if ($conf->use_javascript_ajax)
300 print
'<input type="checkbox" class="flat checkboxfordelete" id="check_'.$i.
'" name="const['.$i.
'][check]" value="1">';
302 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>';
305 print
"</td></tr>\n";
316 if ($conf->use_javascript_ajax)
319 print
'<div id="updateconst" class="right">';
320 print
'<input type="submit" name="update" class="button marginbottomonly" value="'.$langs->trans(
"Modify").
'">';
322 print
'<div id="delconst" class="right">';
323 print
'<input type="submit" name="delete" class="button marginbottomonly" value="'.$langs->trans(
"Delete").
'">';
GETPOST($paramname, $check= 'alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
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).
$conf db name
Only used if Module[ID]Name translation string is not found.
if(GETPOST('button_removefilter_x', 'alpha')||GETPOST('button_removefilter.x', 'alpha')||GETPOST('button_removefilter', 'alpha')) if(GETPOST('button_search_x', 'alpha')||GETPOST('button_search.x', 'alpha')||GETPOST('button_search', 'alpha')) if($action=="save"&&empty($cancel)) $wikihelp
View.
setEventMessages($mesg, $mesgs, $style= 'mesgs', $messagekey= '')
Set event messages in dol_events session object.
GETPOSTISSET($paramname)
Return true if we are in a context of submitting the parameter $paramname.
load_fiche_titre($titre, $morehtmlright= '', $picto= 'generic', $pictoisfullpath=0, $id= '', $morecssontable= '', $morehtmlcenter= '')
Load a title with picto.
dolibarr_del_const($db, $name, $entity=1)
Effacement d'une constante dans la base de donnees.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename= '', $restricttologhandler= '', $logcontext=null)
Write log message into outputs.
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 ...
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...
print $_SERVER["PHP_SELF"]
Edit parameters.
print
Draft customers invoices.
dol_print_date($time, $format= '', $tzoutput= 'auto', $outputlangs= '', $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
dol_print_error($db= '', $error= '', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
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.
img_delete($titlealt= 'default', $other= 'class="pictodelete"', $morecss= '')
Show delete logo.
if(!defined('CSRFCHECK_WITH_TOKEN')) define('CSRFCHECK_WITH_TOKEN'
Draft customers invoices.
if(preg_match('/crypted:/i', $dolibarr_main_db_pass)||!empty($dolibarr_main_db_encrypted_pass)) $conf db type