32require
'../main.inc.php';
40require_once DOL_DOCUMENT_ROOT.
'/core/lib/admin.lib.php';
41require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
42require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formadmin.class.php';
43require_once DOL_DOCUMENT_ROOT.
'/core/class/defaultvalues.class.php';
46$langs->loadLangs(array(
'companies',
'products',
'admin',
'sms',
'other',
'errors'));
53$action =
GETPOST(
'action',
'aZ09');
54$contextpage =
GETPOST(
'contextpage',
'aZ09');
55$optioncss =
GETPOST(
'optionscss',
'alphanohtml');
57$mode =
GETPOST(
'mode',
'aZ09') ?
GETPOST(
'mode',
'aZ09') :
'createform';
60$sortfield =
GETPOST(
'sortfield',
'aZ09comma');
61$sortorder =
GETPOST(
'sortorder',
'aZ09comma');
63if (empty($page) || $page == -1) {
66$offset = $limit * $page;
70 $sortfield =
'page,param';
76$defaulturl =
GETPOST(
'defaulturl',
'alphanohtml');
77$defaultkey =
GETPOST(
'defaultkey',
'alphanohtml');
78$defaultvalue =
GETPOST(
'defaultvalue',
'restricthtml');
80$defaulturl = preg_replace(
'/^\//',
'', $defaulturl);
82$urlpage =
GETPOST(
'urlpage',
'alphanohtml');
83$key =
GETPOST(
'key',
'alphanohtml');
84$value =
GETPOST(
'value',
'restricthtml');
87$hookmanager->initHooks(array(
'admindefaultvalues',
'globaladmin'));
95if (
GETPOST(
'cancel',
'alpha')) {
99if (!
GETPOST(
'confirmmassaction',
'alpha') && !empty($massaction) && $massaction !=
'presend' && $massaction !=
'confirm_presend') {
103$parameters = array();
104$reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
109include DOL_DOCUMENT_ROOT.
'/core/actions_changeselectedfields.inc.php';
112if (
GETPOST(
'button_removefilter_x',
'alpha') ||
GETPOST(
'button_removefilter.x',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha')) {
117 $search_array_options = array();
120if ($action ==
'setMAIN_ENABLE_DEFAULT_VALUES') {
128if (($action ==
'add' || (
GETPOST(
'add') && $action !=
'update')) ||
GETPOST(
'actionmodify')) {
131 if (($action ==
'add' || (
GETPOST(
'add') && $action !=
'update'))) {
132 if (empty($defaulturl)) {
133 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Url")),
null,
'errors');
136 if (empty($defaultkey)) {
137 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Field")),
null,
'errors');
142 if (empty($urlpage)) {
143 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Url")),
null,
'errors');
147 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Field")),
null,
'errors');
153 if ($action ==
'add' || (
GETPOST(
'add') && $action !=
'update')) {
158 $object->value = $defaultvalue;
160 $result =
$object->create($user);
179 $result =
$object->update($user);
195if ($action ==
'delete') {
197 $result =
$object->delete($user);
213$wikihelp =
'EN:First_setup|FR:Premiers_paramétrages|ES:Primeras_configuraciones';
214llxHeader(
'', $langs->trans(
"Setup"), $wikihelp,
'', 0, 0,
'',
'',
'',
'mod-admin page-defaultvalues');
216$param =
'&mode='.$mode;
218$enabledisablehtml =
'<span class="divfilteralone">';
221 $enabledisablehtml .=
'<a class="reposition valignmiddle nounderlineimp unsetcolor small" href="'.$_SERVER[
"PHP_SELF"].
'?action=setMAIN_ENABLE_DEFAULT_VALUES&token='.newToken().
'&value=1'.$param.
'">';
224 $enabledisablehtml .=
'<a class="reposition valignmiddle nounderlineimp unsetcolor small" href="'.$_SERVER[
"PHP_SELF"].
'?action=setMAIN_ENABLE_DEFAULT_VALUES&token='.newToken().
'&value=0'.$param.
'">';
226$enabledisablehtml .=
'<span class="hideonsmartphone">'.$langs->trans(
"EnableDefaultValues").
'</span>';
228 $enabledisablehtml .=
img_picto($langs->trans(
"Disabled"),
'switch_off',
'class="paddingleft valignmiddle"');
230 $enabledisablehtml .=
img_picto($langs->trans(
"Activated"),
'switch_on',
'class="paddingleft valignmiddle"');
232$enabledisablehtml .=
'</a>';
233$enabledisablehtml .=
'</span>';
235print
load_fiche_titre($langs->trans(
"DefaultValues"), $enabledisablehtml,
'title_setup');
237print
'<div class="info hideonsmartphone">'.$langs->trans(
"DefaultValuesDesc").
"</div>\n";
239if (!empty($contextpage) && $contextpage != $_SERVER[
"PHP_SELF"]) {
240 $param .=
'&contextpage='.urlencode($contextpage);
242if ($limit > 0 && $limit !=
$conf->liste_limit) {
243 $param .=
'&limit='.((int) $limit);
245if ($optioncss !=
'') {
246 $param .=
'&optioncss='.urlencode($optioncss);
249 $param .=
'&defaulturl='.urlencode($defaulturl);
252 $param .=
'&defaultkey='.urlencode($defaultkey);
255 $param .=
'&defaultvalue='.urlencode($defaultvalue);
259print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
260if ($optioncss !=
'') {
261 print
'<input type="hidden" name="optioncss" value="'.$optioncss.
'">';
263print
'<input type="hidden" name="token" value="'.newToken().
'">';
264print
'<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
265print
'<input type="hidden" name="action" value="list">';
266print
'<input type="hidden" name="sortfield" value="'.$sortfield.
'">';
267print
'<input type="hidden" name="sortorder" value="'.$sortorder.
'">';
268print
'<input type="hidden" name="page" value="'.$page.
'">';
274if ($mode ==
'sortorder') {
275 print
info_admin($langs->trans(
"WarningSettingSortOrder"), 0, 0,
'warning').
'<br>';
277if ($mode ==
'mandatory') {
278 print
info_admin($langs->trans(
"FeatureSupportedOnTextFieldsOnly"), 0, 0,
'warning').
'<br>';
281print
'<input type="hidden" name="token" value="'.newToken().
'">';
282print
'<input type="hidden" id="action" name="action" value="">';
283print
'<input type="hidden" id="mode" name="mode" value="'.dol_escape_htmltag($mode).
'">';
285print
'<div class="div-table-responsive-no-min">';
286print
'<table class="noborder centpercent">';
287print
'<tr class="liste_titre">';
289$texthelp = $langs->trans(
"PageUrlForDefaultValues");
290if ($mode ==
'createform') {
291 $texthelp .= $langs->trans(
"PageUrlForDefaultValuesCreate",
'societe/card.php',
'societe/card.php?abc=val1&def=val2');
293 $texthelp .= $langs->trans(
"PageUrlForDefaultValuesList",
'societe/list.php',
'societe/list.php?abc=val1&def=val2');
295$texthelp .=
'<br><br>'.$langs->trans(
"AlsoDefaultValuesAreEffectiveForActionCreate");
296$texturl = $form->textwithpicto($langs->trans(
"RelativeURL"), $texthelp);
299$texthelp = $langs->trans(
"TheKeyIsTheNameOfHtmlField");
300if ($mode !=
'sortorder') {
301 $textkey = $form->textwithpicto($langs->trans(
"Field"), $texthelp);
303 $texthelp =
'field or alias.field';
304 $textkey = $form->textwithpicto($langs->trans(
"Field"), $texthelp);
308if ($mode !=
'focus' && $mode !=
'mandatory') {
309 if ($mode !=
'sortorder') {
310 $substitutionarray = getCommonSubstitutionArray($langs, 2, array(
'object',
'objectamount'));
311 unset($substitutionarray[
'__USER_SIGNATURE__']);
312 unset($substitutionarray[
'__SENDEREMAIL_SIGNATURE__']);
313 $texthelp = $langs->trans(
"FollowingConstantsWillBeSubstituted").
'<br>';
314 foreach ($substitutionarray as $key => $val) {
315 $texthelp .= $key.
' -> '.$val.
'<br>';
317 $textvalue = $form->textwithpicto($langs->trans(
"Value"), $langs->trans(
"DefaultValuesHelpText"));
319 $texthelp =
'ASC or DESC';
320 $textvalue = $form->textwithpicto($langs->trans(
"SortOrder"), $texthelp);
326 print_liste_field_titre(
"Entity", $_SERVER[
"PHP_SELF"],
'entity,page',
'', $param,
'', $sortfield, $sortorder);
338print
'<tr class="oddeven">';
341print
'<input type="text" class="flat minwidth200 maxwidthonsmartphone" name="defaulturl" value="'.dol_escape_htmltag($defaulturl).
'">';
345print
'<input type="text" class="flat maxwidth100onsmartphone" name="defaultkey" value="'.dol_escape_htmltag($defaultkey).
'">';
348if ($mode !=
'focus' && $mode !=
'mandatory') {
350 print
'<span class="nowraponall"><input type="text" class="flat maxwidth100onsmartphone" name="defaultvalue" value="'.dol_escape_htmltag($defaultvalue).
'">';
351 if ($mode !=
'sortorder') {
352 print $form->textwithpicto(
'', $texthelp, 1,
'list-alt',
'paddingleftimp cursorpointer', 0, 2,
'subsitutiontooltip');
354 print
'</span></td>';
359 print
'<input type="text" class="flat" size="1" disabled name="entity" value="' .
$conf->entity .
'">';
362 print
'<td class="center">';
363 print
'<input type="hidden" name="entity" value="' .
$conf->entity .
'">';
366print
'<td class="center">';
369 $disabled =
' disabled="disabled"';
371print
'<input type="submit" class="button"'.$disabled.
' value="'.$langs->trans(
"Add").
'" name="add">';
375$result =
$object->fetchAll($sortorder, $sortfield, 0, 0,
"(t.type:=:'".$mode.
"') AND (t.entity:in:".((
int) $user->entity).
", ".((
int)
$conf->entity).
")");
377if (!is_array($result) && $result < 0) {
379} elseif (is_array($result) && count($result) > 0) {
380 foreach ($result as $key => $defaultvalue) {
381 print
'<tr class="oddeven">';
385 if ($action !=
'edit' ||
GETPOSTINT(
'rowid') != $defaultvalue->id) {
386 print $defaultvalue->page;
388 print
'<input type="text" name="urlpage" value="'.dol_escape_htmltag($defaultvalue->page).
'">';
394 if ($action !=
'edit' ||
GETPOST(
'rowid') != $defaultvalue->id) {
395 print $defaultvalue->param;
397 print
'<input type="text" name="key" value="'.dol_escape_htmltag($defaultvalue->param).
'">';
402 if ($mode !=
'focus' && $mode !=
'mandatory') {
404 if ($action !=
'edit' ||
GETPOST(
'rowid') != $defaultvalue->id) {
407 print
'<input type="text" name="value" value="'.dol_escape_htmltag($defaultvalue->value).
'">';
420 print
'<td class="center">';
421 if ($action !=
'edit' ||
GETPOST(
'rowid') != $defaultvalue->id) {
422 print
'<a class="editfielda marginleftonly marginrightonly" href="'.$_SERVER[
'PHP_SELF'].
'?rowid='.$defaultvalue->id.
'&entity='.$defaultvalue->entity.
'&mode='.$mode.
'&action=edit&token='.newToken().
'">'.
img_edit().
'</a>';
423 print
'<a class="marginleftonly marginrightonly" href="'.$_SERVER[
'PHP_SELF'].
'?rowid='.$defaultvalue->id.
'&entity='.$defaultvalue->entity.
'&mode='.$mode.
'&action=delete&token='.newToken().
'">'.
img_delete().
'</a>';
425 print
'<input type="hidden" name="page" value="'.$page.
'">';
426 print
'<input type="hidden" name="rowid" value="'.$id.
'">';
427 print
'<div name="'.(!empty($defaultvalue->id) ? $defaultvalue->id :
'none').
'"></div>';
428 print
'<input type="submit" class="button button-edit" name="actionmodify" value="'.$langs->trans(
"Modify").
'">';
429 print
'<input type="submit" class="button button-cancel" name="actioncancel" value="'.$langs->trans(
"Cancel").
'">';
$id
Support class for third parties, contacts, members, users or resources.
if(! $sortfield) if(! $sortorder) $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).
defaultvalues_prepare_head()
Prepare array with list of tabs.
llxFooter($comment='', $zone='private', $disabledoutputofmessages=0)
Empty footer.
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader($head='', $title='', $help_url='', $target='', $disablejs=0, $disablehead=0, $arrayofjs='', $arrayofcss='', $morequerystring='', $morecssonbody='', $replacemainareaby='', $disablenofollow=0, $disablenoindex=0)
Empty header.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0, $attop=0)
Set event messages in dol_events session object.
print_liste_field_titre($name, $file="", $field="", $begin="", $param="", $moreattrib="", $sortfield="", $sortorder="", $prefix="", $tooltip="", $forcenowrapcolumntitle=0)
Show title line of an array.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2, $allowothertags=array())
Show picto whatever it's its name (generic function)
info_admin($text, $infoonimgalt=0, $nodiv=0, $admin='1', $morecss='hideonsmartphone', $textfordropdown='', $picto='', $textonpictotooltip='')
Show information in HTML for admin users or standard users.
img_delete($titlealt='default', $other='class="pictodelete"', $morecss='')
Show delete logo.
GETPOSTINT($paramname, $method=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limittoshow=0, $moretabssuffix='', $dragdropfile=0, $morecssdiv='')
Show tabs of a record.
dol_get_fiche_end($notab=0)
Return tab footer of a card.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
load_fiche_titre($title, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='', $morecssonpicto='widthpictotitle')
Load a title with picto.
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
isModEnabled($module)
Is Dolibarr module enabled.
img_edit($titlealt='default', $float=0, $other='')
Show logo edit/modify fiche.
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...
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.