29 require
'../main.inc.php';
30 require_once DOL_DOCUMENT_ROOT.
'/core/lib/admin.lib.php';
31 require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
32 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formadmin.class.php';
35 $langs->loadLangs(array(
'companies',
'products',
'admin',
'sms',
'other',
'errors'));
40 $action =
GETPOST(
'action',
'aZ09');
41 $optioncss =
GETPOST(
'optionscss',
'alphanohtml');
43 $mode =
GETPOST(
'mode',
'aZ09') ?
GETPOST(
'mode',
'aZ09') :
'createform';
45 $limit =
GETPOST(
'limit',
'int') ?
GETPOST(
'limit',
'int') : $conf->liste_limit;
46 $sortfield =
GETPOST(
"sortfield",
'alpha');
47 $sortorder =
GETPOST(
"sortorder",
'alpha');
49 if (empty($page) || $page == -1) { $page = 0; }
50 $offset = $limit * $page;
51 $pageprev = $page - 1;
52 $pagenext = $page + 1;
53 if (!$sortfield) $sortfield =
'page,param';
54 if (!$sortorder) $sortorder =
'ASC';
56 $defaulturl =
GETPOST(
'defaulturl',
'alphanohtml');
57 $defaultkey =
GETPOST(
'defaultkey',
'alphanohtml');
58 $defaultvalue =
GETPOST(
'defaultvalue',
'none');
60 $defaulturl = preg_replace(
'/^\//',
'', $defaulturl);
62 $urlpage =
GETPOST(
'urlpage',
'alphanohtml');
63 $key =
GETPOST(
'key',
'alphanohtml');
64 $value =
GETPOST(
'value',
'restricthtml');
67 $hookmanager->initHooks(array(
'admindefaultvalues',
'globaladmin'));
74 if (
GETPOST(
'cancel',
'alpha')) { $action =
'list'; $massaction =
''; }
75 if (!
GETPOST(
'confirmmassaction',
'alpha') && $massaction !=
'presend' && $massaction !=
'confirm_presend') { $massaction =
''; }
77 $parameters = array(
'socid'=>$socid);
78 $reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
79 if ($reshook < 0)
setEventMessages($hookmanager->error, $hookmanager->errors,
'errors');
81 include DOL_DOCUMENT_ROOT.
'/core/actions_changeselectedfields.inc.php';
84 if (
GETPOST(
'button_removefilter_x',
'alpha') ||
GETPOST(
'button_removefilter.x',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha'))
90 $search_array_options = array();
93 if ($action ==
'setMAIN_ENABLE_DEFAULT_VALUES')
96 else dolibarr_set_const($db,
'MAIN_ENABLE_DEFAULT_VALUES', 0,
'chaine', 0,
'', $conf->entity);
99 if (($action ==
'add' || (
GETPOST(
'add') && $action !=
'update')) ||
GETPOST(
'actionmodify'))
103 if (($action ==
'add' || (
GETPOST(
'add') && $action !=
'update')))
105 if (empty($defaulturl))
107 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Url")), null,
'errors');
110 if (empty($defaultkey))
112 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Field")), null,
'errors');
120 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Url")), null,
'errors');
125 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Field")), null,
'errors');
134 if ($action ==
'add' || (
GETPOST(
'add') && $action !=
'update'))
136 $sql =
"INSERT INTO ".MAIN_DB_PREFIX.
"default_values(type, user_id, page, param, value, entity) VALUES ('".$db->escape($mode).
"', 0, '".$db->escape($defaulturl).
"','".$db->escape($defaultkey).
"','".$db->escape($defaultvalue).
"', ".$db->escape($conf->entity).
")";
140 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"default_values SET page = '".$db->escape($urlpage).
"', param = '".$db->escape($key).
"', value = '".$db->escape($value).
"'";
141 $sql .=
" WHERE rowid = ".$id;
144 $result = $db->query($sql);
162 if ($action ==
'delete')
164 $sql =
"DELETE FROM ".MAIN_DB_PREFIX.
"default_values WHERE rowid = ".$db->escape($id);
166 $result = $db->query($sql);
181 $form =
new Form($db);
184 $wikihelp =
'EN:First_setup|FR:Premiers_paramétrages|ES:Primeras_configuraciones';
187 $param =
'&mode='.$mode;
189 $enabledisablehtml .= $langs->trans(
"EnableDefaultValues").
' ';
190 if (empty($conf->global->MAIN_ENABLE_DEFAULT_VALUES))
193 $enabledisablehtml .=
'<a class="reposition valignmiddle" href="'.$_SERVER[
"PHP_SELF"].
'?action=setMAIN_ENABLE_DEFAULT_VALUES&token='.
newToken().
'&value=1'.$param.
'">';
194 $enabledisablehtml .=
img_picto($langs->trans(
"Disabled"),
'switch_off');
195 $enabledisablehtml .=
'</a>';
198 $enabledisablehtml .=
'<a class="reposition valignmiddle" href="'.$_SERVER[
"PHP_SELF"].
'?action=setMAIN_ENABLE_DEFAULT_VALUES&token='.
newToken().
'&value=0'.$param.
'">';
199 $enabledisablehtml .=
img_picto($langs->trans(
"Activated"),
'switch_on');
200 $enabledisablehtml .=
'</a>';
205 print '<span class="opacitymedium">'.$langs->trans(
"DefaultValuesDesc").
"</span><br>\n";
208 if (!empty($contextpage) && $contextpage !=
$_SERVER[
"PHP_SELF"]) $param .=
'&contextpage='.urlencode($contextpage);
209 if ($limit > 0 && $limit != $conf->liste_limit) $param .=
'&limit='.urlencode($limit);
210 if ($optioncss !=
'') $param .=
'&optioncss='.urlencode($optioncss);
211 if ($defaulturl) $param .=
'&defaulturl='.urlencode($defaulturl);
212 if ($defaultkey) $param .=
'&defaultkey='.urlencode($defaultkey);
213 if ($defaultvalue) $param .=
'&defaultvalue='.urlencode($defaultvalue);
216 print '<form action="'.$_SERVER[
"PHP_SELF"].((empty($user->entity) && $debug) ?
'?debug=1' :
'').
'" method="POST">';
217 if ($optioncss !=
'')
print '<input type="hidden" name="optioncss" value="'.$optioncss.
'">';
218 print '<input type="hidden" name="token" value="'.newToken().
'">';
219 print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
220 print '<input type="hidden" name="action" value="list">';
221 print '<input type="hidden" name="sortfield" value="'.$sortfield.
'">';
222 print '<input type="hidden" name="sortorder" value="'.$sortorder.
'">';
223 print '<input type="hidden" name="page" value="'.$page.
'">';
229 if ($mode ==
'sortorder')
233 if ($mode ==
'mandatory')
235 print info_admin($langs->trans(
"FeatureSupportedOnTextFieldsOnly")).
'<br>';
238 print '<input type="hidden" name="token" value="'.newToken().
'">';
239 print '<input type="hidden" id="action" name="action" value="">';
240 print '<input type="hidden" id="mode" name="mode" value="'.dol_escape_htmltag($mode).
'">';
242 print '<div class="div-table-responsive-no-min">';
243 print '<table class="noborder centpercent">';
244 print '<tr class="liste_titre">';
246 $texthelp = $langs->trans(
"PageUrlForDefaultValues");
247 if ($mode ==
'createform') $texthelp .= $langs->trans(
"PageUrlForDefaultValuesCreate",
'societe/card.php',
'societe/card.php?abc=val1&def=val2');
248 else $texthelp .= $langs->trans(
"PageUrlForDefaultValuesList",
'societe/list.php',
'societe/list.php?abc=val1&def=val2');
249 $texthelp .=
'<br><br>'.$langs->trans(
"AlsoDefaultValuesAreEffectiveForActionCreate");
250 $texturl = $form->textwithpicto($langs->trans(
"RelativeURL"), $texthelp);
253 $texthelp = $langs->trans(
"TheKeyIsTheNameOfHtmlField");
254 if ($mode !=
'sortorder')
256 $textkey = $form->textwithpicto($langs->trans(
"Field"), $texthelp);
258 $texthelp =
'field or alias.field';
259 $textkey = $form->textwithpicto($langs->trans(
"Field"), $texthelp);
263 if ($mode !=
'focus' && $mode !=
'mandatory')
265 if ($mode !=
'sortorder')
268 unset($substitutionarray[
'__USER_SIGNATURE__']);
269 $texthelp = $langs->trans(
"FollowingConstantsWillBeSubstituted").
'<br>';
270 foreach ($substitutionarray as $key => $val)
272 $texthelp .= $key.
' -> '.$val.
'<br>';
274 $textvalue = $form->textwithpicto($langs->trans(
"Value"), $texthelp, 1,
'help',
'', 0, 2,
'subsitutiontooltip');
276 $texthelp =
'ASC or DESC';
277 $textvalue = $form->textwithpicto($langs->trans(
"SortOrder"), $texthelp);
282 if (!empty($conf->multicompany->enabled) && !$user->entity)
print_liste_field_titre(
"Entity",
$_SERVER[
"PHP_SELF"],
'entity,page',
'', $param,
'', $sortfield, $sortorder);
292 print '<tr class="oddeven">';
295 print '<input type="text" class="flat minwidth200 maxwidthonsmartphone" name="defaulturl" value="'.dol_escape_htmltag(
GETPOST(
'defaulturl',
'alphanohtml')).
'">';
299 print '<input type="text" class="flat maxwidth100onsmartphone" name="defaultkey" value="'.dol_escape_htmltag(
GETPOST(
'defaultkey',
'alphanohtml')).
'">';
302 if ($mode !=
'focus' && $mode !=
'mandatory')
305 print '<input type="text" class="flat maxwidth100onsmartphone" name="defaultvalue" value="">';
309 if (!empty($conf->multicompany->enabled) && !$user->entity)
312 print '<input type="text" class="flat" size="1" disabled name="entity" value="'.$conf->entity.
'">';
315 print '<td class="center">';
316 print '<input type="hidden" name="entity" value="'.$conf->entity.
'">';
319 print '<td class="center">';
321 if (empty($conf->global->MAIN_ENABLE_DEFAULT_VALUES)) $disabled =
' disabled="disabled"';
322 print '<input type="submit" class="button"'.$disabled.
' value="'.$langs->trans(
"Add").
'" name="add">';
328 $sql =
"SELECT rowid, entity, type, page, param, value";
329 $sql .=
" FROM ".MAIN_DB_PREFIX.
"default_values";
330 $sql .=
" WHERE type = '".$db->escape($mode).
"'";
331 $sql .=
" AND entity IN (".$user->entity.
",".$conf->entity.
")";
332 $sql .= $db->order($sortfield, $sortorder);
334 dol_syslog(
"translation::select from table", LOG_DEBUG);
335 $result = $db->query($sql);
338 $num = $db->num_rows($result);
343 $obj = $db->fetch_object($result);
347 print '<tr class="oddeven">';
351 if ($action !=
'edit' ||
GETPOST(
'rowid',
'int') != $obj->rowid)
print $obj->page;
352 else print '<input type="text" name="urlpage" value="'.dol_escape_htmltag($obj->page).
'">';
357 if ($action !=
'edit' ||
GETPOST(
'rowid') != $obj->rowid)
print $obj->param;
358 else print '<input type="text" name="key" value="'.dol_escape_htmltag($obj->param).
'">';
362 if ($mode !=
'focus' && $mode !=
'mandatory')
371 else print '<input type="text" name="value" value="'.dol_escape_htmltag($obj->value).
'">';
378 print '<td class="center">';
379 if ($action !=
'edit' ||
GETPOST(
'rowid') != $obj->rowid)
381 print '<a class="editfielda marginleftonly marginrightonly" href="'.$_SERVER[
'PHP_SELF'].
'?rowid='.$obj->rowid.
'&entity='.$obj->entity.
'&mode='.$mode.
'&action=edit&token='.
newToken().((empty($user->entity) && $debug) ?
'&debug=1' :
'').
'">'.
img_edit().
'</a>';
382 print '<a class="marginleftonly marginrightonly" href="'.$_SERVER[
'PHP_SELF'].
'?rowid='.$obj->rowid.
'&entity='.$obj->entity.
'&mode='.$mode.
'&action=delete&token='.
newToken().((empty($user->entity) && $debug) ?
'&debug=1' :
'').
'">'.
img_delete().
'</a>';
384 print '<input type="hidden" name="page" value="'.$page.
'">';
385 print '<input type="hidden" name="rowid" value="'.$id.
'">';
386 print '<div name="'.(!empty($obj->rowid) ? $obj->rowid :
'none').
'"></div>';
387 print '<input type="submit" class="button" name="actionmodify" value="'.$langs->trans(
"Modify").
'">';
388 print '<input type="submit" class="button button-cancel" name="actioncancel" value="'.$langs->trans(
"Cancel").
'">';
GETPOST($paramname, $check= 'alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
img_edit($titlealt= 'default', $float=0, $other= '')
Show logo editer/modifier fiche.
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).
if(GETPOST('button_removefilter_x', 'alpha')||GETPOST('button_removefilter.x', 'alpha')||GETPOST('button_removefilter', 'alpha')) if(GETPOST('button_search_x', 'alpha')||GETPOST('button_search.x', 'alpha')||GETPOST('button_search', 'alpha')) if($action=="save"&&empty($cancel)) $wikihelp
View.
getCommonSubstitutionArray($outputlangs, $onlykey=0, $exclude=null, $object=null)
Return array of possible common substitutions.
setEventMessages($mesg, $mesgs, $style= 'mesgs', $messagekey= '')
Set event messages in dol_events session object.
GETPOSTISSET($paramname)
Return true if we are in a context of submitting the parameter $paramname.
print_liste_field_titre($name, $file="", $field="", $begin="", $moreparam="", $moreattrib="", $sortfield="", $sortorder="", $prefix="", $tooltip="", $forcenowrapcolumntitle=0)
Show title line of an array.
load_fiche_titre($titre, $morehtmlright= '', $picto= 'generic', $pictoisfullpath=0, $id= '', $morecssontable= '', $morehtmlcenter= '')
Load a title with picto.
img_picto($titlealt, $picto, $moreatt= '', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt= '', $morecss= '', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename= '', $restricttologhandler= '', $logcontext=null)
Write log message into outputs.
accessforbidden($message= '', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program Calling this function terminate execution ...
print $_SERVER["PHP_SELF"]
Edit parameters.
dol_get_fiche_head($links=array(), $active= '', $title= '', $notab=0, $picto= '', $pictoisfullpath=0, $morehtmlright= '', $morecss= '', $limittoshow=0, $moretabssuffix= '')
Show tabs of a record.
print
Draft customers invoices.
defaultvalues_prepare_head()
Prepare array with list of tabs.
dol_print_error($db= '', $error= '', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
newToken()
Return the value of token currently saved into session with name 'newtoken'.
dol_get_fiche_end($notab=0)
Return tab footer of a card.
img_delete($titlealt= 'default', $other= 'class="pictodelete"', $morecss= '')
Show delete logo.
info_admin($text, $infoonimgalt=0, $nodiv=0, $admin= '1', $morecss= '', $textfordropdown= '')
Show information for admin users or standard users.
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $keepmoretags= '', $escapeonlyhtmltags=0)
Returns text escaped for inclusion in HTML alt or title tags, or into values of HTML input fields...