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';
50$sortfield =
GETPOST(
'sortfield',
'aZ09comma');
51$sortorder =
GETPOST(
'sortorder',
'aZ09comma');
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')) {
89if (!
GETPOST(
'confirmmassaction',
'alpha') && !empty($massaction) && $massaction !=
'presend' && $massaction !=
'confirm_presend') {
94$reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
99include DOL_DOCUMENT_ROOT.
'/core/actions_changeselectedfields.inc.php';
102if (
GETPOST(
'button_removefilter_x',
'alpha') ||
GETPOST(
'button_removefilter.x',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha')) {
107 $search_array_options = array();
110if ($action ==
'setMAIN_ENABLE_DEFAULT_VALUES') {
112 dolibarr_set_const($db,
'MAIN_ENABLE_DEFAULT_VALUES', 1,
'chaine', 0,
'', $conf->entity);
114 dolibarr_set_const($db,
'MAIN_ENABLE_DEFAULT_VALUES', 0,
'chaine', 0,
'', $conf->entity);
118if (($action ==
'add' || (
GETPOST(
'add') && $action !=
'update')) ||
GETPOST(
'actionmodify')) {
121 if (($action ==
'add' || (
GETPOST(
'add') && $action !=
'update'))) {
122 if (empty($defaulturl)) {
123 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Url")),
null,
'errors');
126 if (empty($defaultkey)) {
127 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Field")),
null,
'errors');
132 if (empty($urlpage)) {
133 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Url")),
null,
'errors');
137 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Field")),
null,
'errors');
143 if ($action ==
'add' || (
GETPOST(
'add') && $action !=
'update')) {
150 $result=
$object->create($user);
169 $result=
$object->update($user);
185if ($action ==
'delete') {
187 $result=
$object->delete($user);
200$form =
new Form($db);
203$wikihelp =
'EN:First_setup|FR:Premiers_paramétrages|ES:Primeras_configuraciones';
204llxHeader(
'', $langs->trans(
"Setup"), $wikihelp,
'', 0, 0,
'',
'',
'',
'mod-admin page-defaultvalues');
206$param =
'&mode='.$mode;
208$enabledisablehtml = $langs->trans(
"EnableDefaultValues").
' ';
211 $enabledisablehtml .=
'<a class="reposition valignmiddle" href="'.$_SERVER[
"PHP_SELF"].
'?action=setMAIN_ENABLE_DEFAULT_VALUES&token='.
newToken().
'&value=1'.$param.
'">';
212 $enabledisablehtml .=
img_picto($langs->trans(
"Disabled"),
'switch_off');
213 $enabledisablehtml .=
'</a>';
216 $enabledisablehtml .=
'<a class="reposition valignmiddle" href="'.$_SERVER[
"PHP_SELF"].
'?action=setMAIN_ENABLE_DEFAULT_VALUES&token='.
newToken().
'&value=0'.$param.
'">';
217 $enabledisablehtml .=
img_picto($langs->trans(
"Activated"),
'switch_on');
218 $enabledisablehtml .=
'</a>';
221print
load_fiche_titre($langs->trans(
"DefaultValues"), $enabledisablehtml,
'title_setup');
223print
'<span class="opacitymedium">'.$langs->trans(
"DefaultValuesDesc").
"</span><br>\n";
226if (!empty($contextpage) && $contextpage != $_SERVER[
"PHP_SELF"]) {
227 $param .=
'&contextpage='.urlencode($contextpage);
229if ($limit > 0 && $limit != $conf->liste_limit) {
230 $param .=
'&limit='.((int) $limit);
232if ($optioncss !=
'') {
233 $param .=
'&optioncss='.urlencode($optioncss);
236 $param .=
'&defaulturl='.urlencode($defaulturl);
239 $param .=
'&defaultkey='.urlencode($defaultkey);
242 $param .=
'&defaultvalue='.urlencode($defaultvalue);
246print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
247if ($optioncss !=
'') {
248 print
'<input type="hidden" name="optioncss" value="'.$optioncss.
'">';
250print
'<input type="hidden" name="token" value="'.newToken().
'">';
251print
'<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
252print
'<input type="hidden" name="action" value="list">';
253print
'<input type="hidden" name="sortfield" value="'.$sortfield.
'">';
254print
'<input type="hidden" name="sortorder" value="'.$sortorder.
'">';
255print
'<input type="hidden" name="page" value="'.$page.
'">';
261if ($mode ==
'sortorder') {
262 print
info_admin($langs->trans(
"WarningSettingSortOrder")).
'<br>';
264if ($mode ==
'mandatory') {
265 print
info_admin($langs->trans(
"FeatureSupportedOnTextFieldsOnly")).
'<br>';
268print
'<input type="hidden" name="token" value="'.newToken().
'">';
269print
'<input type="hidden" id="action" name="action" value="">';
270print
'<input type="hidden" id="mode" name="mode" value="'.dol_escape_htmltag($mode).
'">';
272print
'<div class="div-table-responsive-no-min">';
273print
'<table class="noborder centpercent">';
274print
'<tr class="liste_titre">';
276$texthelp = $langs->trans(
"PageUrlForDefaultValues");
277if ($mode ==
'createform') {
278 $texthelp .= $langs->trans(
"PageUrlForDefaultValuesCreate",
'societe/card.php',
'societe/card.php?abc=val1&def=val2');
280 $texthelp .= $langs->trans(
"PageUrlForDefaultValuesList",
'societe/list.php',
'societe/list.php?abc=val1&def=val2');
282$texthelp .=
'<br><br>'.$langs->trans(
"AlsoDefaultValuesAreEffectiveForActionCreate");
283$texturl = $form->textwithpicto($langs->trans(
"RelativeURL"), $texthelp);
286$texthelp = $langs->trans(
"TheKeyIsTheNameOfHtmlField");
287if ($mode !=
'sortorder') {
288 $textkey = $form->textwithpicto($langs->trans(
"Field"), $texthelp);
290 $texthelp =
'field or alias.field';
291 $textkey = $form->textwithpicto($langs->trans(
"Field"), $texthelp);
295if ($mode !=
'focus' && $mode !=
'mandatory') {
296 if ($mode !=
'sortorder') {
298 unset($substitutionarray[
'__USER_SIGNATURE__']);
299 unset($substitutionarray[
'__SENDEREMAIL_SIGNATURE__']);
300 $texthelp = $langs->trans(
"FollowingConstantsWillBeSubstituted").
'<br>';
301 foreach ($substitutionarray as $key => $val) {
302 $texthelp .= $key.
' -> '.$val.
'<br>';
304 $textvalue = $form->textwithpicto($langs->trans(
"Value"), $texthelp, 1,
'help',
'', 0, 2,
'subsitutiontooltip');
306 $texthelp =
'ASC or DESC';
307 $textvalue = $form->textwithpicto($langs->trans(
"SortOrder"), $texthelp);
312if (isModEnabled(
'multicompany') && !$user->entity) {
313 print_liste_field_titre(
"Entity", $_SERVER[
"PHP_SELF"],
'entity,page',
'', $param,
'', $sortfield, $sortorder);
325print
'<tr class="oddeven">';
328print
'<input type="text" class="flat minwidth200 maxwidthonsmartphone" name="defaulturl" value="'.dol_escape_htmltag($defaulturl).
'">';
332print
'<input type="text" class="flat maxwidth100onsmartphone" name="defaultkey" value="'.dol_escape_htmltag($defaultkey).
'">';
335if ($mode !=
'focus' && $mode !=
'mandatory') {
337 print
'<input type="text" class="flat maxwidth100onsmartphone" name="defaultvalue" value="'.dol_escape_htmltag($defaultvalue).
'">';
341if (isModEnabled(
'multicompany') && !$user->entity) {
343 print
'<input type="text" class="flat" size="1" disabled name="entity" value="' . $conf->entity .
'">';
346 print
'<td class="center">';
347 print
'<input type="hidden" name="entity" value="' . $conf->entity .
'">';
350print
'<td class="center">';
353 $disabled =
' disabled="disabled"';
355print
'<input type="submit" class="button"'.$disabled.
' value="'.$langs->trans(
"Add").
'" name="add">';
359$result =
$object->fetchAll($sortorder, $sortfield, 0, 0, array(
't.type'=>$mode,
't.entity'=>array($user->entity,$conf->entity)));
361if (!is_array($result) && $result < 0) {
363} elseif (is_array($result) && count($result) > 0) {
364 foreach ($result as $key => $defaultvalue) {
365 print
'<tr class="oddeven">';
369 if ($action !=
'edit' ||
GETPOSTINT(
'rowid') != $defaultvalue->id) {
370 print $defaultvalue->page;
372 print
'<input type="text" name="urlpage" value="'.dol_escape_htmltag($defaultvalue->page).
'">';
378 if ($action !=
'edit' ||
GETPOST(
'rowid') != $defaultvalue->id) {
379 print $defaultvalue->param;
381 print
'<input type="text" name="key" value="'.dol_escape_htmltag($defaultvalue->param).
'">';
386 if ($mode !=
'focus' && $mode !=
'mandatory') {
388 if ($action !=
'edit' ||
GETPOST(
'rowid') != $defaultvalue->id) {
391 print
'<input type="text" name="value" value="'.dol_escape_htmltag($defaultvalue->value).
'">';
398 if (isModEnabled(
'multicompany')) {
404 print
'<td class="center">';
405 if ($action !=
'edit' ||
GETPOST(
'rowid') != $defaultvalue->id) {
406 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>';
407 print
'<a class="marginleftonly marginrightonly" href="'.$_SERVER[
'PHP_SELF'].
'?rowid='.$defaultvalue->id.
'&entity='.$defaultvalue->entity.
'&mode='.$mode.
'&action=delete&token='.
newToken().
'">'.
img_delete().
'</a>';
409 print
'<input type="hidden" name="page" value="'.$page.
'">';
410 print
'<input type="hidden" name="rowid" value="'.$id.
'">';
411 print
'<div name="'.(!empty($defaultvalue->id) ? $defaultvalue->id :
'none').
'"></div>';
412 print
'<input type="submit" class="button button-edit" name="actionmodify" value="'.$langs->trans(
"Modify").
'">';
413 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()
Empty header.
load_fiche_titre($title, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
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.
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.
getDolGlobalString($key, $default='')
Return 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.