31require
'../main.inc.php';
32require_once DOL_DOCUMENT_ROOT.
'/core/lib/admin.lib.php';
33require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
34require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formadmin.class.php';
35require_once DOL_DOCUMENT_ROOT.
'/core/class/defaultvalues.class.php';
38$langs->loadLangs(array(
'companies',
'products',
'admin',
'sms',
'other',
'errors'));
45$action =
GETPOST(
'action',
'aZ09');
46$optioncss =
GETPOST(
'optionscss',
'alphanohtml');
48$mode =
GETPOST(
'mode',
'aZ09') ?
GETPOST(
'mode',
'aZ09') :
'createform';
51$sortfield =
GETPOST(
'sortfield',
'aZ09comma');
52$sortorder =
GETPOST(
'sortorder',
'aZ09comma');
54if (empty($page) || $page == -1) {
57$offset = $limit * $page;
61 $sortfield =
'page,param';
67$defaulturl =
GETPOST(
'defaulturl',
'alphanohtml');
68$defaultkey =
GETPOST(
'defaultkey',
'alphanohtml');
69$defaultvalue =
GETPOST(
'defaultvalue',
'restricthtml');
71$defaulturl = preg_replace(
'/^\//',
'', $defaulturl);
73$urlpage =
GETPOST(
'urlpage',
'alphanohtml');
74$key =
GETPOST(
'key',
'alphanohtml');
75$value =
GETPOST(
'value',
'restricthtml');
78$hookmanager->initHooks(array(
'admindefaultvalues',
'globaladmin'));
86if (
GETPOST(
'cancel',
'alpha')) {
90if (!
GETPOST(
'confirmmassaction',
'alpha') && !empty($massaction) && $massaction !=
'presend' && $massaction !=
'confirm_presend') {
95$reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
100include DOL_DOCUMENT_ROOT.
'/core/actions_changeselectedfields.inc.php';
103if (
GETPOST(
'button_removefilter_x',
'alpha') ||
GETPOST(
'button_removefilter.x',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha')) {
108 $search_array_options = array();
111if ($action ==
'setMAIN_ENABLE_DEFAULT_VALUES') {
113 dolibarr_set_const($db,
'MAIN_ENABLE_DEFAULT_VALUES', 1,
'chaine', 0,
'', $conf->entity);
115 dolibarr_set_const($db,
'MAIN_ENABLE_DEFAULT_VALUES', 0,
'chaine', 0,
'', $conf->entity);
119if (($action ==
'add' || (
GETPOST(
'add') && $action !=
'update')) ||
GETPOST(
'actionmodify')) {
122 if (($action ==
'add' || (
GETPOST(
'add') && $action !=
'update'))) {
123 if (empty($defaulturl)) {
124 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Url")),
null,
'errors');
127 if (empty($defaultkey)) {
128 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Field")),
null,
'errors');
133 if (empty($urlpage)) {
134 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Url")),
null,
'errors');
138 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Field")),
null,
'errors');
144 if ($action ==
'add' || (
GETPOST(
'add') && $action !=
'update')) {
149 $object->value = $defaultvalue;
150 $object->entity = $conf->entity;
151 $result =
$object->create($user);
169 $object->entity = $conf->entity;
170 $result =
$object->update($user);
186if ($action ==
'delete') {
188 $result =
$object->delete($user);
201$form =
new Form($db);
204$wikihelp =
'EN:First_setup|FR:Premiers_paramétrages|ES:Primeras_configuraciones';
205llxHeader(
'', $langs->trans(
"Setup"), $wikihelp,
'', 0, 0,
'',
'',
'',
'mod-admin page-defaultvalues');
207$param =
'&mode='.$mode;
209$enabledisablehtml = $langs->trans(
"EnableDefaultValues").
' ';
212 $enabledisablehtml .=
'<a class="reposition valignmiddle" href="'.$_SERVER[
"PHP_SELF"].
'?action=setMAIN_ENABLE_DEFAULT_VALUES&token='.
newToken().
'&value=1'.$param.
'">';
213 $enabledisablehtml .=
img_picto($langs->trans(
"Disabled"),
'switch_off');
214 $enabledisablehtml .=
'</a>';
217 $enabledisablehtml .=
'<a class="reposition valignmiddle" href="'.$_SERVER[
"PHP_SELF"].
'?action=setMAIN_ENABLE_DEFAULT_VALUES&token='.
newToken().
'&value=0'.$param.
'">';
218 $enabledisablehtml .=
img_picto($langs->trans(
"Activated"),
'switch_on');
219 $enabledisablehtml .=
'</a>';
222print
load_fiche_titre($langs->trans(
"DefaultValues"), $enabledisablehtml,
'title_setup');
224print
'<span class="opacitymedium">'.$langs->trans(
"DefaultValuesDesc").
"</span><br>\n";
227if (!empty($contextpage) && $contextpage != $_SERVER[
"PHP_SELF"]) {
228 $param .=
'&contextpage='.urlencode($contextpage);
230if ($limit > 0 && $limit != $conf->liste_limit) {
231 $param .=
'&limit='.((int) $limit);
233if ($optioncss !=
'') {
234 $param .=
'&optioncss='.urlencode($optioncss);
237 $param .=
'&defaulturl='.urlencode($defaulturl);
240 $param .=
'&defaultkey='.urlencode($defaultkey);
243 $param .=
'&defaultvalue='.urlencode($defaultvalue);
247print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
248if ($optioncss !=
'') {
249 print
'<input type="hidden" name="optioncss" value="'.$optioncss.
'">';
251print
'<input type="hidden" name="token" value="'.newToken().
'">';
252print
'<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
253print
'<input type="hidden" name="action" value="list">';
254print
'<input type="hidden" name="sortfield" value="'.$sortfield.
'">';
255print
'<input type="hidden" name="sortorder" value="'.$sortorder.
'">';
256print
'<input type="hidden" name="page" value="'.$page.
'">';
262if ($mode ==
'sortorder') {
263 print
info_admin($langs->trans(
"WarningSettingSortOrder")).
'<br>';
265if ($mode ==
'mandatory') {
266 print
info_admin($langs->trans(
"FeatureSupportedOnTextFieldsOnly")).
'<br>';
269print
'<input type="hidden" name="token" value="'.newToken().
'">';
270print
'<input type="hidden" id="action" name="action" value="">';
271print
'<input type="hidden" id="mode" name="mode" value="'.dol_escape_htmltag($mode).
'">';
273print
'<div class="div-table-responsive-no-min">';
274print
'<table class="noborder centpercent">';
275print
'<tr class="liste_titre">';
277$texthelp = $langs->trans(
"PageUrlForDefaultValues");
278if ($mode ==
'createform') {
279 $texthelp .= $langs->trans(
"PageUrlForDefaultValuesCreate",
'societe/card.php',
'societe/card.php?abc=val1&def=val2');
281 $texthelp .= $langs->trans(
"PageUrlForDefaultValuesList",
'societe/list.php',
'societe/list.php?abc=val1&def=val2');
283$texthelp .=
'<br><br>'.$langs->trans(
"AlsoDefaultValuesAreEffectiveForActionCreate");
284$texturl = $form->textwithpicto($langs->trans(
"RelativeURL"), $texthelp);
287$texthelp = $langs->trans(
"TheKeyIsTheNameOfHtmlField");
288if ($mode !=
'sortorder') {
289 $textkey = $form->textwithpicto($langs->trans(
"Field"), $texthelp);
291 $texthelp =
'field or alias.field';
292 $textkey = $form->textwithpicto($langs->trans(
"Field"), $texthelp);
296if ($mode !=
'focus' && $mode !=
'mandatory') {
297 if ($mode !=
'sortorder') {
299 unset($substitutionarray[
'__USER_SIGNATURE__']);
300 unset($substitutionarray[
'__SENDEREMAIL_SIGNATURE__']);
301 $texthelp = $langs->trans(
"FollowingConstantsWillBeSubstituted").
'<br>';
302 foreach ($substitutionarray as $key => $val) {
303 $texthelp .= $key.
' -> '.$val.
'<br>';
305 $textvalue = $form->textwithpicto($langs->trans(
"Value"), $texthelp, 1,
'help',
'', 0, 2,
'subsitutiontooltip');
307 $texthelp =
'ASC or DESC';
308 $textvalue = $form->textwithpicto($langs->trans(
"SortOrder"), $texthelp);
313if (isModEnabled(
'multicompany') && !$user->entity) {
314 print_liste_field_titre(
"Entity", $_SERVER[
"PHP_SELF"],
'entity,page',
'', $param,
'', $sortfield, $sortorder);
326print
'<tr class="oddeven">';
329print
'<input type="text" class="flat minwidth200 maxwidthonsmartphone" name="defaulturl" value="'.dol_escape_htmltag($defaulturl).
'">';
333print
'<input type="text" class="flat maxwidth100onsmartphone" name="defaultkey" value="'.dol_escape_htmltag($defaultkey).
'">';
336if ($mode !=
'focus' && $mode !=
'mandatory') {
338 print
'<input type="text" class="flat maxwidth100onsmartphone" name="defaultvalue" value="'.dol_escape_htmltag($defaultvalue).
'">';
342if (isModEnabled(
'multicompany') && !$user->entity) {
344 print
'<input type="text" class="flat" size="1" disabled name="entity" value="' . $conf->entity .
'">';
347 print
'<td class="center">';
348 print
'<input type="hidden" name="entity" value="' . $conf->entity .
'">';
351print
'<td class="center">';
354 $disabled =
' disabled="disabled"';
356print
'<input type="submit" class="button"'.$disabled.
' value="'.$langs->trans(
"Add").
'" name="add">';
360$result =
$object->fetchAll($sortorder, $sortfield, 0, 0, array(
't.type' => $mode,
't.entity' => array($user->entity,$conf->entity)));
362if (!is_array($result) && $result < 0) {
364} elseif (is_array($result) && count($result) > 0) {
365 foreach ($result as $key => $defaultvalue) {
366 print
'<tr class="oddeven">';
370 if ($action !=
'edit' ||
GETPOSTINT(
'rowid') != $defaultvalue->id) {
371 print $defaultvalue->page;
373 print
'<input type="text" name="urlpage" value="'.dol_escape_htmltag($defaultvalue->page).
'">';
379 if ($action !=
'edit' ||
GETPOST(
'rowid') != $defaultvalue->id) {
380 print $defaultvalue->param;
382 print
'<input type="text" name="key" value="'.dol_escape_htmltag($defaultvalue->param).
'">';
387 if ($mode !=
'focus' && $mode !=
'mandatory') {
389 if ($action !=
'edit' ||
GETPOST(
'rowid') != $defaultvalue->id) {
392 print
'<input type="text" name="value" value="'.dol_escape_htmltag($defaultvalue->value).
'">';
399 if (isModEnabled(
'multicompany')) {
405 print
'<td class="center">';
406 if ($action !=
'edit' ||
GETPOST(
'rowid') != $defaultvalue->id) {
407 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>';
408 print
'<a class="marginleftonly marginrightonly" href="'.$_SERVER[
'PHP_SELF'].
'?rowid='.$defaultvalue->id.
'&entity='.$defaultvalue->entity.
'&mode='.$mode.
'&action=delete&token='.
newToken().
'">'.
img_delete().
'</a>';
410 print
'<input type="hidden" name="page" value="'.$page.
'">';
411 print
'<input type="hidden" name="rowid" value="'.$id.
'">';
412 print
'<div name="'.(!empty($defaultvalue->id) ? $defaultvalue->id :
'none').
'"></div>';
413 print
'<input type="submit" class="button button-edit" name="actionmodify" value="'.$langs->trans(
"Modify").
'">';
414 print
'<input type="submit" class="button button-cancel" name="actioncancel" value="'.$langs->trans(
"Cancel").
'">';
if( $user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $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.
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.
load_fiche_titre($title, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0, $attop=0)
Set event messages in dol_events session object.
img_delete($titlealt='default', $other='class="pictodelete"', $morecss='')
Show delete logo.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
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)
Show tabs of a record.
dol_get_fiche_end($notab=0)
Return tab footer of a card.
newToken()
Return the value of token currently saved into session with name 'newtoken'.
print_liste_field_titre($name, $file="", $field="", $begin="", $moreparam="", $moreattrib="", $sortfield="", $sortorder="", $prefix="", $tooltip="", $forcenowrapcolumntitle=0)
Show 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.
getCommonSubstitutionArray($outputlangs, $onlykey=0, $exclude=null, $object=null, $include=null)
Return array of possible common substitutions.
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
info_admin($text, $infoonimgalt=0, $nodiv=0, $admin='1', $morecss='hideonsmartphone', $textfordropdown='', $picto='')
Show information in HTML for admin users or standard users.
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.