27 require
'../main.inc.php';
28 require_once DOL_DOCUMENT_ROOT.
'/core/lib/admin.lib.php';
31 $langs->load(
"admin");
37 $entity=
GETPOST(
'entity',
'int');
38 $action=
GETPOST(
'action',
'alpha');
39 $update=
GETPOST(
'update',
'alpha');
40 $delete=
GETPOST(
'delete',
'none');
42 $consts=
GETPOST(
'const',
'array');
43 $constname=
GETPOST(
'constname',
'alpha');
44 $constvalue=
GETPOST(
'constvalue',
'none');
45 $constnote=
GETPOST(
'constnote',
'alpha');
53 if ($action ==
'add' || (
GETPOST(
'add') && $action !=
'update'))
57 if (empty($constname))
59 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Name")), null,
'errors');
62 if ($constvalue ==
'')
64 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Value")), null,
'errors');
70 if (
dolibarr_set_const($db, $constname, $constvalue,
'chaine', 1, $constnote, $entity) >= 0)
86 if (! empty($consts) && $action ==
'update')
89 foreach($consts as $const)
91 if (! empty($const[
"check"]))
93 if (
dolibarr_set_const($db, $const[
"name"], $const[
"value"], $const[
"type"], 1, $const[
"note"], $const[
"entity"]) >= 0)
103 if ($nbmodified > 0)
setEventMessages($langs->trans(
"RecordSaved"), null,
'mesgs');
108 if (! empty($consts) && $action ==
'delete')
112 foreach($consts as $const)
114 if (! empty($const[
"check"]))
126 if ($nbdeleted > 0)
setEventMessages($langs->trans(
"RecordDeleted"), null,
'mesgs');
131 if ($action ==
'delete')
148 $form =
new Form($db);
150 $wikihelp=
'EN:Setup_Other|FR:Paramétrage_Divers|ES:Configuración_Varios';
154 if ($conf->use_javascript_ajax)
157 <script
type=
"text/javascript">
158 jQuery(document).ready(
function() {
159 jQuery(
"#updateconst").hide();
160 jQuery(
"#delconst").hide();
161 jQuery(
".checkboxfordelete").click(
function() {
162 jQuery(
"#delconst").show();
163 jQuery(
"#action").val(
'delete');
165 jQuery(
".inputforupdate").keyup(
function() {
166 var field_id = jQuery(
this).attr(
"id");
167 var row_num = field_id.split(
"_");
168 jQuery(
"#updateconst").show();
169 jQuery(
"#action").val(
'update');
170 jQuery(
"#check_" + row_num[1]).prop(
"checked",
true);
179 print $langs->trans(
"ConstDesc").
"<br>\n";
182 print '<form action="'.$_SERVER[
"PHP_SELF"].((empty($user->entity) && $debug)?
'?debug=1':
'').
'" method="POST">';
183 print '<input type="hidden" name="token" value="'.$_SESSION[
'newtoken'].
'">';
184 print '<input type="hidden" id="action" name="action" value="">';
186 print '<div class="div-table-responsive-no-min">';
187 print '<table class="noborder" width="100%">';
188 print '<tr class="liste_titre">';
189 print '<td>'.$langs->trans(
"Name").
'</td>';
190 print '<td>'.$langs->trans(
"Value").
'</td>';
191 print '<td>'.$langs->trans(
"Comment").
'</td>';
192 if (! empty($conf->multicompany->enabled) && !$user->entity)
print '<td>'.$langs->trans(
"Entity").
'</td>';
193 print '<td align="center">'.$langs->trans(
"Action").
'</td>';
201 print '<tr class="oddeven"><td><input type="text" class="flat" size="24" name="constname" value="'.$constname.
'"></td>'.
"\n";
203 print '<input type="text" class="flat" size="30" name="constvalue" value="'.$constvalue.
'">';
205 print '<input type="text" class="flat" size="40" name="constnote" value="'.$constnote.
'">';
208 if (! empty($conf->multicompany->enabled) && !$user->entity)
211 print '<input type="text" class="flat" size="1" name="entity" value="'.$conf->entity.
'">';
213 print '<td align="center">';
217 print '<td align="center">';
218 print '<input type="hidden" name="entity" value="'.$conf->entity.
'">';
220 print '<input type="submit" class="button" value="'.$langs->trans(
"Add").
'" name="add">';
228 $sql.=
", ".$db->decrypt(
'name').
" as name";
229 $sql.=
", ".$db->decrypt(
'value').
" as value";
233 $sql.=
" FROM ".MAIN_DB_PREFIX.
"const";
234 $sql.=
" WHERE entity IN (".$user->entity.
",".$conf->entity.
")";
235 if ((empty($user->entity) || $user->admin) && $debug) {}
236 else if (!
GETPOST(
'visible') ||
GETPOST(
'visible') !=
'all') $sql.=
" AND visible = 1";
238 $sql.=
" ORDER BY entity, name ASC";
241 $result = $db->query($sql);
244 $num = $db->num_rows($result);
250 $obj = $db->fetch_object($result);
255 print '<tr class="oddeven"><td>'.$obj->name.
'</td>'.
"\n";
259 print '<input type="hidden" name="const['.$i.
'][rowid]" value="'.$obj->rowid.
'">';
260 print '<input type="hidden" name="const['.$i.
'][name]" value="'.$obj->name.
'">';
261 print '<input type="hidden" name="const['.$i.
'][type]" value="'.$obj->type.
'">';
262 print '<input type="text" id="value_'.$i.
'" class="flat inputforupdate" size="30" name="const['.$i.
'][value]" value="'.htmlspecialchars($obj->value).
'">';
267 print '<input type="text" id="note_'.$i.
'" class="flat inputforupdate" size="40" name="const['.$i.
'][note]" value="'.htmlspecialchars($obj->note,1).
'">';
271 if (! empty($conf->multicompany->enabled) && !$user->entity)
274 print '<input type="text" class="flat" size="1" name="const['.$i.
'][entity]" value="'.$obj->entity.
'">';
276 print '<td align="center">';
280 print '<td align="center">';
281 print '<input type="hidden" name="const['.$i.
'][entity]" value="'.$obj->entity.
'">';
284 if ($conf->use_javascript_ajax)
286 print '<input type="checkbox" class="flat checkboxfordelete" id="check_'.$i.
'" name="const['.$i.
'][check]" value="1">';
290 print '<a href="'.$_SERVER[
'PHP_SELF'].
'?rowid='.$obj->rowid.
'&entity='.$obj->entity.
'&action=delete'.((empty($user->entity) && $debug)?
'&debug=1':
'').
'">'.
img_delete().
'</a>';
293 print "</td></tr>\n";
304 if ($conf->use_javascript_ajax)
307 print '<div id="updateconst" align="right">';
308 print '<input type="submit" name="update" class="button" value="'.$langs->trans(
"Modify").
'">';
310 print '<div id="delconst" align="right">';
311 print '<input type="submit" name="delete" class="button" value="'.$langs->trans(
"Delete").
'">';
load_fiche_titre($titre, $morehtmlright='', $picto='title_generic.png', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
GETPOST($paramname, $check='none', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
print
Draft customers invoices.
setEventMessages($mesg, $mesgs, $style='mesgs')
Set event messages in dol_events session object.
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).
dol_print_error($db='', $error='', $errors=null)
Affiche message erreur system avec toutes les informations pour faciliter le diagnostic et la remonte...
img_delete($titlealt='default', $other='class="pictodelete"')
Show delete logo.
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0)
Show a message to say access is forbidden and stop program Calling this function terminate execution ...
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='')
Write log message into outputs.
dolibarr_del_const($db, $name, $entity=1)
Effacement d'une constante dans la base de donnees.
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...
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.