32require
'../main.inc.php';
33require_once DOL_DOCUMENT_ROOT.
'/core/lib/admin.lib.php';
34require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
35require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formadmin.class.php';
36require_once DOL_DOCUMENT_ROOT.
'/core/class/defaultvalues.class.php';
47$langs->loadLangs(array(
'companies',
'products',
'admin',
'sms',
'other',
'errors'));
54$action =
GETPOST(
'action',
'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);
210$form =
new Form($db);
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 = $langs->trans(
"EnableDefaultValues").
' ';
221 $enabledisablehtml .=
'<a class="reposition valignmiddle" href="'.$_SERVER[
"PHP_SELF"].
'?action=setMAIN_ENABLE_DEFAULT_VALUES&token='.
newToken().
'&value=1'.$param.
'">';
222 $enabledisablehtml .=
img_picto($langs->trans(
"Disabled"),
'switch_off');
223 $enabledisablehtml .=
'</a>';
226 $enabledisablehtml .=
'<a class="reposition valignmiddle" href="'.$_SERVER[
"PHP_SELF"].
'?action=setMAIN_ENABLE_DEFAULT_VALUES&token='.
newToken().
'&value=0'.$param.
'">';
227 $enabledisablehtml .=
img_picto($langs->trans(
"Activated"),
'switch_on');
228 $enabledisablehtml .=
'</a>';
231print
load_fiche_titre($langs->trans(
"DefaultValues"), $enabledisablehtml,
'title_setup');
233print
'<span class="opacitymedium">'.$langs->trans(
"DefaultValuesDesc").
"</span><br>\n";
236if (!empty($contextpage) && $contextpage != $_SERVER[
"PHP_SELF"]) {
237 $param .=
'&contextpage='.urlencode($contextpage);
239if ($limit > 0 && $limit !=
$conf->liste_limit) {
240 $param .=
'&limit='.((int) $limit);
242if ($optioncss !=
'') {
243 $param .=
'&optioncss='.urlencode($optioncss);
246 $param .=
'&defaulturl='.urlencode($defaulturl);
249 $param .=
'&defaultkey='.urlencode($defaultkey);
252 $param .=
'&defaultvalue='.urlencode($defaultvalue);
256print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
257if ($optioncss !=
'') {
258 print
'<input type="hidden" name="optioncss" value="'.$optioncss.
'">';
260print
'<input type="hidden" name="token" value="'.newToken().
'">';
261print
'<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
262print
'<input type="hidden" name="action" value="list">';
263print
'<input type="hidden" name="sortfield" value="'.$sortfield.
'">';
264print
'<input type="hidden" name="sortorder" value="'.$sortorder.
'">';
265print
'<input type="hidden" name="page" value="'.$page.
'">';
271if ($mode ==
'sortorder') {
272 print
info_admin($langs->trans(
"WarningSettingSortOrder")).
'<br>';
274if ($mode ==
'mandatory') {
275 print
info_admin($langs->trans(
"FeatureSupportedOnTextFieldsOnly")).
'<br>';
278print
'<input type="hidden" name="token" value="'.newToken().
'">';
279print
'<input type="hidden" id="action" name="action" value="">';
280print
'<input type="hidden" id="mode" name="mode" value="'.dol_escape_htmltag($mode).
'">';
282print
'<div class="div-table-responsive-no-min">';
283print
'<table class="noborder centpercent">';
284print
'<tr class="liste_titre">';
286$texthelp = $langs->trans(
"PageUrlForDefaultValues");
287if ($mode ==
'createform') {
288 $texthelp .= $langs->trans(
"PageUrlForDefaultValuesCreate",
'societe/card.php',
'societe/card.php?abc=val1&def=val2');
290 $texthelp .= $langs->trans(
"PageUrlForDefaultValuesList",
'societe/list.php',
'societe/list.php?abc=val1&def=val2');
292$texthelp .=
'<br><br>'.$langs->trans(
"AlsoDefaultValuesAreEffectiveForActionCreate");
293$texturl = $form->textwithpicto($langs->trans(
"RelativeURL"), $texthelp);
296$texthelp = $langs->trans(
"TheKeyIsTheNameOfHtmlField");
297if ($mode !=
'sortorder') {
298 $textkey = $form->textwithpicto($langs->trans(
"Field"), $texthelp);
300 $texthelp =
'field or alias.field';
301 $textkey = $form->textwithpicto($langs->trans(
"Field"), $texthelp);
305if ($mode !=
'focus' && $mode !=
'mandatory') {
306 if ($mode !=
'sortorder') {
308 unset($substitutionarray[
'__USER_SIGNATURE__']);
309 unset($substitutionarray[
'__SENDEREMAIL_SIGNATURE__']);
310 $texthelp = $langs->trans(
"FollowingConstantsWillBeSubstituted").
'<br>';
311 foreach ($substitutionarray as $key => $val) {
312 $texthelp .= $key.
' -> '.$val.
'<br>';
314 $textvalue = $form->textwithpicto($langs->trans(
"Value"), $texthelp, 1,
'help',
'', 0, 2,
'subsitutiontooltip');
316 $texthelp =
'ASC or DESC';
317 $textvalue = $form->textwithpicto($langs->trans(
"SortOrder"), $texthelp);
322if (isModEnabled(
'multicompany') && !$user->entity) {
323 print_liste_field_titre(
"Entity", $_SERVER[
"PHP_SELF"],
'entity,page',
'', $param,
'', $sortfield, $sortorder);
335print
'<tr class="oddeven">';
338print
'<input type="text" class="flat minwidth200 maxwidthonsmartphone" name="defaulturl" value="'.dol_escape_htmltag($defaulturl).
'">';
342print
'<input type="text" class="flat maxwidth100onsmartphone" name="defaultkey" value="'.dol_escape_htmltag($defaultkey).
'">';
345if ($mode !=
'focus' && $mode !=
'mandatory') {
347 print
'<input type="text" class="flat maxwidth100onsmartphone" name="defaultvalue" value="'.dol_escape_htmltag($defaultvalue).
'">';
351if (isModEnabled(
'multicompany') && !$user->entity) {
353 print
'<input type="text" class="flat" size="1" disabled name="entity" value="' .
$conf->entity .
'">';
356 print
'<td class="center">';
357 print
'<input type="hidden" name="entity" value="' .
$conf->entity .
'">';
360print
'<td class="center">';
363 $disabled =
' disabled="disabled"';
365print
'<input type="submit" class="button"'.$disabled.
' value="'.$langs->trans(
"Add").
'" name="add">';
369$result =
$object->fetchAll($sortorder, $sortfield, 0, 0, array(
't.type' => $mode,
't.entity' => array($user->entity,
$conf->entity)));
371if (!is_array($result) && $result < 0) {
373} elseif (is_array($result) && count($result) > 0) {
374 foreach ($result as $key => $defaultvalue) {
375 print
'<tr class="oddeven">';
379 if ($action !=
'edit' ||
GETPOSTINT(
'rowid') != $defaultvalue->id) {
380 print $defaultvalue->page;
382 print
'<input type="text" name="urlpage" value="'.dol_escape_htmltag($defaultvalue->page).
'">';
388 if ($action !=
'edit' ||
GETPOST(
'rowid') != $defaultvalue->id) {
389 print $defaultvalue->param;
391 print
'<input type="text" name="key" value="'.dol_escape_htmltag($defaultvalue->param).
'">';
396 if ($mode !=
'focus' && $mode !=
'mandatory') {
398 if ($action !=
'edit' ||
GETPOST(
'rowid') != $defaultvalue->id) {
401 print
'<input type="text" name="value" value="'.dol_escape_htmltag($defaultvalue->value).
'">';
408 if (isModEnabled(
'multicompany')) {
414 print
'<td class="center">';
415 if ($action !=
'edit' ||
GETPOST(
'rowid') != $defaultvalue->id) {
416 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>';
417 print
'<a class="marginleftonly marginrightonly" href="'.$_SERVER[
'PHP_SELF'].
'?rowid='.$defaultvalue->id.
'&entity='.$defaultvalue->entity.
'&mode='.$mode.
'&action=delete&token='.
newToken().
'">'.
img_delete().
'</a>';
419 print
'<input type="hidden" name="page" value="'.$page.
'">';
420 print
'<input type="hidden" name="rowid" value="'.$id.
'">';
421 print
'<div name="'.(!empty($defaultvalue->id) ? $defaultvalue->id :
'none').
'"></div>';
422 print
'<input type="submit" class="button button-edit" name="actionmodify" value="'.$langs->trans(
"Modify").
'">';
423 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...
global $conf
The following vars must be defined: $type2label $form $conf, $lang, The following vars may also be de...
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.