30require
'../main.inc.php';
31require_once DOL_DOCUMENT_ROOT.
'/core/lib/admin.lib.php';
32require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
33require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formadmin.class.php';
34require_once DOL_DOCUMENT_ROOT.
'/core/class/defaultvalues.class.php';
37$langs->loadLangs(array(
'companies',
'products',
'admin',
'sms',
'other',
'errors'));
44$action =
GETPOST(
'action',
'aZ09');
45$optioncss =
GETPOST(
'optionscss',
'alphanohtml');
47$mode =
GETPOST(
'mode',
'aZ09') ?
GETPOST(
'mode',
'aZ09') :
'createform';
49$limit =
GETPOST(
'limit',
'int') ?
GETPOST(
'limit',
'int') : $conf->liste_limit;
50$sortfield =
GETPOST(
'sortfield',
'aZ09comma');
51$sortorder =
GETPOST(
'sortorder',
'aZ09comma');
52$page = GETPOSTISSET(
'pageplusone') ? (
GETPOST(
'pageplusone') - 1) :
GETPOST(
"page",
'int');
53if (empty($page) || $page == -1) {
56$offset = $limit * $page;
60 $sortfield =
'page,param';
66$defaulturl =
GETPOST(
'defaulturl',
'alphanohtml');
67$defaultkey =
GETPOST(
'defaultkey',
'alphanohtml');
68$defaultvalue =
GETPOST(
'defaultvalue',
'restricthtml');
70$defaulturl = preg_replace(
'/^\//',
'', $defaulturl);
72$urlpage =
GETPOST(
'urlpage',
'alphanohtml');
73$key =
GETPOST(
'key',
'alphanohtml');
74$value =
GETPOST(
'value',
'restricthtml');
77$hookmanager->initHooks(array(
'admindefaultvalues',
'globaladmin'));
85if (
GETPOST(
'cancel',
'alpha')) {
86 $action =
'list'; $massaction =
'';
88if (!
GETPOST(
'confirmmassaction',
'alpha') && !empty($massaction) && $massaction !=
'presend' && $massaction !=
'confirm_presend') {
93$reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
98include DOL_DOCUMENT_ROOT.
'/core/actions_changeselectedfields.inc.php';
101if (
GETPOST(
'button_removefilter_x',
'alpha') ||
GETPOST(
'button_removefilter.x',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha')) {
106 $search_array_options = array();
109if ($action ==
'setMAIN_ENABLE_DEFAULT_VALUES') {
111 dolibarr_set_const($db,
'MAIN_ENABLE_DEFAULT_VALUES', 1,
'chaine', 0,
'', $conf->entity);
113 dolibarr_set_const($db,
'MAIN_ENABLE_DEFAULT_VALUES', 0,
'chaine', 0,
'', $conf->entity);
117if (($action ==
'add' || (
GETPOST(
'add') && $action !=
'update')) ||
GETPOST(
'actionmodify')) {
120 if (($action ==
'add' || (
GETPOST(
'add') && $action !=
'update'))) {
121 if (empty($defaulturl)) {
122 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Url")),
null,
'errors');
125 if (empty($defaultkey)) {
126 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Field")),
null,
'errors');
131 if (empty($urlpage)) {
132 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Url")),
null,
'errors');
136 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Field")),
null,
'errors');
142 if ($action ==
'add' || (
GETPOST(
'add') && $action !=
'update')) {
145 $object->page=$defaulturl;
146 $object->param=$defaultkey;
147 $object->value=$defaultvalue;
148 $object->entity=$conf->entity;
149 $result=$object->create($user);
164 $object->page=$urlpage;
166 $object->value=$value;
167 $object->entity=$conf->entity;
168 $result=$object->update($user);
184if ($action ==
'delete') {
186 $result=$object->delete($user);
199$form =
new Form($db);
202$wikihelp =
'EN:First_setup|FR:Premiers_paramétrages|ES:Primeras_configuraciones';
203llxHeader(
'', $langs->trans(
"Setup"), $wikihelp);
205$param =
'&mode='.$mode;
207$enabledisablehtml = $langs->trans(
"EnableDefaultValues").
' ';
208if (empty($conf->global->MAIN_ENABLE_DEFAULT_VALUES)) {
210 $enabledisablehtml .=
'<a class="reposition valignmiddle" href="'.$_SERVER[
"PHP_SELF"].
'?action=setMAIN_ENABLE_DEFAULT_VALUES&token='.newToken().
'&value=1'.$param.
'">';
211 $enabledisablehtml .=
img_picto($langs->trans(
"Disabled"),
'switch_off');
212 $enabledisablehtml .=
'</a>';
215 $enabledisablehtml .=
'<a class="reposition valignmiddle" href="'.$_SERVER[
"PHP_SELF"].
'?action=setMAIN_ENABLE_DEFAULT_VALUES&token='.newToken().
'&value=0'.$param.
'">';
216 $enabledisablehtml .=
img_picto($langs->trans(
"Activated"),
'switch_on');
217 $enabledisablehtml .=
'</a>';
220print
load_fiche_titre($langs->trans(
"DefaultValues"), $enabledisablehtml,
'title_setup');
222print
'<span class="opacitymedium">'.$langs->trans(
"DefaultValuesDesc").
"</span><br>\n";
225if (!empty($contextpage) && $contextpage != $_SERVER[
"PHP_SELF"]) {
226 $param .=
'&contextpage='.urlencode($contextpage);
228if ($limit > 0 && $limit != $conf->liste_limit) {
229 $param .=
'&limit='.((int) $limit);
231if ($optioncss !=
'') {
232 $param .=
'&optioncss='.urlencode($optioncss);
235 $param .=
'&defaulturl='.urlencode($defaulturl);
238 $param .=
'&defaultkey='.urlencode($defaultkey);
241 $param .=
'&defaultvalue='.urlencode($defaultvalue);
245print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
246if ($optioncss !=
'') {
247 print
'<input type="hidden" name="optioncss" value="'.$optioncss.
'">';
249print
'<input type="hidden" name="token" value="'.newToken().
'">';
250print
'<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
251print
'<input type="hidden" name="action" value="list">';
252print
'<input type="hidden" name="sortfield" value="'.$sortfield.
'">';
253print
'<input type="hidden" name="sortorder" value="'.$sortorder.
'">';
254print
'<input type="hidden" name="page" value="'.$page.
'">';
260if ($mode ==
'sortorder') {
261 print
info_admin($langs->trans(
"WarningSettingSortOrder")).
'<br>';
263if ($mode ==
'mandatory') {
264 print
info_admin($langs->trans(
"FeatureSupportedOnTextFieldsOnly")).
'<br>';
267print
'<input type="hidden" name="token" value="'.newToken().
'">';
268print
'<input type="hidden" id="action" name="action" value="">';
269print
'<input type="hidden" id="mode" name="mode" value="'.dol_escape_htmltag($mode).
'">';
271print
'<div class="div-table-responsive-no-min">';
272print
'<table class="noborder centpercent">';
273print
'<tr class="liste_titre">';
275$texthelp = $langs->trans(
"PageUrlForDefaultValues");
276if ($mode ==
'createform') {
277 $texthelp .= $langs->trans(
"PageUrlForDefaultValuesCreate",
'societe/card.php',
'societe/card.php?abc=val1&def=val2');
279 $texthelp .= $langs->trans(
"PageUrlForDefaultValuesList",
'societe/list.php',
'societe/list.php?abc=val1&def=val2');
281$texthelp .=
'<br><br>'.$langs->trans(
"AlsoDefaultValuesAreEffectiveForActionCreate");
282$texturl = $form->textwithpicto($langs->trans(
"RelativeURL"), $texthelp);
285$texthelp = $langs->trans(
"TheKeyIsTheNameOfHtmlField");
286if ($mode !=
'sortorder') {
287 $textkey = $form->textwithpicto($langs->trans(
"Field"), $texthelp);
289 $texthelp =
'field or alias.field';
290 $textkey = $form->textwithpicto($langs->trans(
"Field"), $texthelp);
294if ($mode !=
'focus' && $mode !=
'mandatory') {
295 if ($mode !=
'sortorder') {
297 unset($substitutionarray[
'__USER_SIGNATURE__']);
298 unset($substitutionarray[
'__SENDEREMAIL_SIGNATURE__']);
299 $texthelp = $langs->trans(
"FollowingConstantsWillBeSubstituted").
'<br>';
300 foreach ($substitutionarray as $key => $val) {
301 $texthelp .= $key.
' -> '.$val.
'<br>';
303 $textvalue = $form->textwithpicto($langs->trans(
"Value"), $texthelp, 1,
'help',
'', 0, 2,
'subsitutiontooltip');
305 $texthelp =
'ASC or DESC';
306 $textvalue = $form->textwithpicto($langs->trans(
"SortOrder"), $texthelp);
311if (isModEnabled(
'multicompany') && !$user->entity) {
312 print_liste_field_titre(
"Entity", $_SERVER[
"PHP_SELF"],
'entity,page',
'', $param,
'', $sortfield, $sortorder);
324print
'<tr class="oddeven">';
327print
'<input type="text" class="flat minwidth200 maxwidthonsmartphone" name="defaulturl" value="'.dol_escape_htmltag($defaulturl).
'">';
331print
'<input type="text" class="flat maxwidth100onsmartphone" name="defaultkey" value="'.dol_escape_htmltag($defaultkey).
'">';
334if ($mode !=
'focus' && $mode !=
'mandatory') {
336 print
'<input type="text" class="flat maxwidth100onsmartphone" name="defaultvalue" value="'.dol_escape_htmltag($defaultvalue).
'">';
340if (isModEnabled(
'multicompany') && !$user->entity) {
342 print
'<input type="text" class="flat" size="1" disabled name="entity" value="' . $conf->entity .
'">';
345 print
'<td class="center">';
346 print
'<input type="hidden" name="entity" value="' . $conf->entity .
'">';
349print
'<td class="center">';
351if (empty($conf->global->MAIN_ENABLE_DEFAULT_VALUES)) {
352 $disabled =
' disabled="disabled"';
354print
'<input type="submit" class="button"'.$disabled.
' value="'.$langs->trans(
"Add").
'" name="add">';
358$result = $object->fetchAll($sortorder, $sortfield, 0, 0, array(
't.type'=>$mode,
't.entity'=>array($user->entity,$conf->entity)));
360if (!is_array($result) && $result < 0) {
362} elseif (is_array($result) && count($result) > 0) {
363 foreach ($result as $key => $defaultvalue) {
364 print
'<tr class="oddeven">';
368 if ($action !=
'edit' ||
GETPOST(
'rowid',
'int') != $defaultvalue->id) print $defaultvalue->page;
369 else print
'<input type="text" name="urlpage" value="'.dol_escape_htmltag($defaultvalue->page).
'">';
374 if ($action !=
'edit' ||
GETPOST(
'rowid') != $defaultvalue->id) print $defaultvalue->param;
375 else print
'<input type="text" name="key" value="'.dol_escape_htmltag($defaultvalue->param).
'">';
379 if ($mode !=
'focus' && $mode !=
'mandatory') {
382 else print
'<input type="text" name="value" value="'.dol_escape_htmltag($defaultvalue->value).
'">';
388 if (isModEnabled(
'multicompany')) {
394 print
'<td class="center">';
395 if ($action !=
'edit' ||
GETPOST(
'rowid') != $defaultvalue->id) {
396 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>';
397 print
'<a class="marginleftonly marginrightonly" href="'.$_SERVER[
'PHP_SELF'].
'?rowid='.$defaultvalue->id.
'&entity='.$defaultvalue->entity.
'&mode='.$mode.
'&action=delete&token='.newToken().
'">'.
img_delete().
'</a>';
399 print
'<input type="hidden" name="page" value="'.$page.
'">';
400 print
'<input type="hidden" name="rowid" value="'.$id.
'">';
401 print
'<div name="'.(!empty($defaultvalue->id) ? $defaultvalue->id :
'none').
'"></div>';
402 print
'<input type="submit" class="button button-edit" name="actionmodify" value="'.$langs->trans(
"Modify").
'">';
403 print
'<input type="submit" class="button button-cancel" name="actioncancel" value="'.$langs->trans(
"Cancel").
'">';
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()
Empty header.
load_fiche_titre($titre, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
img_delete($titlealt='default', $other='class="pictodelete"', $morecss='')
Show delete logo.
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.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
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.
info_admin($text, $infoonimgalt=0, $nodiv=0, $admin='1', $morecss='hideonsmartphone', $textfordropdown='')
Show information for admin users or standard users.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0)
Set event messages in dol_events session object.
getCommonSubstitutionArray($outputlangs, $onlykey=0, $exclude=null, $object=null, $include=null)
Return array of possible common substitutions.
img_edit($titlealt='default', $float=0, $other='')
Show logo editer/modifier 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.