From f1ae0eb7c6159ecb03e502bafbd05f4681f260a4 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur <eldy@destailleur.fr> Date: Mon, 10 Apr 2017 12:51:52 +0200 Subject: [PATCH] Default value --- htdocs/admin/defaultvalues.php | 44 +++++++++++++++++++++------------- htdocs/core/lib/admin.lib.php | 16 ++++++++++--- htdocs/langs/en_US/admin.lang | 4 ++++ htdocs/langs/en_US/main.lang | 4 ++++ 4 files changed, 49 insertions(+), 19 deletions(-) diff --git a/htdocs/admin/defaultvalues.php b/htdocs/admin/defaultvalues.php index 4a4815e726b..3056b981535 100644 --- a/htdocs/admin/defaultvalues.php +++ b/htdocs/admin/defaultvalues.php @@ -50,6 +50,10 @@ $pagenext = $page + 1; if (! $sortfield) $sortfield='lang,transkey'; if (! $sortorder) $sortorder='ASC'; +$defaulturl = GETPOST('defaulturl'); +$defaultkey = GETPOST('defaultkey','alpha'); +$defaultvalue = GETPOST('defaultvalue'); + /* * Actions @@ -67,8 +71,9 @@ include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php'; // Purge search criteria if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter.x") || GETPOST("button_removefilter")) // All test are required to be compatible with all browsers { - $transkey=''; - $transvalue=''; + $defaulturl=''; + $defaultkey=''; + $defaultvalue=''; $toselect=''; $search_array_options=array(); } @@ -101,8 +106,9 @@ if ($action == 'add' || (GETPOST('add') && $action != 'update')) { setEventMessages($langs->trans("RecordSaved"), null, 'mesgs'); $action=""; - $transkey=""; - $transvalue=""; + $defaulturl=''; + $defaultkey=''; + $defaultvalue=''; } else { @@ -136,6 +142,7 @@ if ($action == 'delete') * View */ +$form=new Form($db); $formadmin = new FormAdmin($db); $wikihelp='EN:Setup|FR:Paramétrage|ES:Configuración'; @@ -149,10 +156,10 @@ print "<br>\n"; $param='&mode='.$mode; if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.$contextpage; if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.$limit; -if ($optioncss != '') $param.='&optioncss='.$optioncss; -if ($langcode) $param.='&langcode='.urlencode($langcode); -if ($transkey) $param.='&transkey='.urlencode($transkey); -if ($transvalue) $param.='&transvalue='.urlencode($transvalue); +if ($optioncss != '') $param.='&optioncss='.$optioncss; +if (defaulturl) $param.='&defaulturl='.urlencode(defaulturl); +if (defaultkey) $param.='&defaultkey='.urlencode(defaultkey); +if (defaultvalue) $param.='&defaultvalue='.urlencode(defaultvalue); print '<form action="'.$_SERVER["PHP_SELF"].((empty($user->entity) && $debug)?'?debug=1':'').'" method="POST">'; @@ -165,7 +172,7 @@ print '<input type="hidden" name="sortorder" value="'.$sortorder.'">'; $head=defaultvalues_prepare_head(); -dol_fiche_head($head, 'overwrite', '', -1, ''); +dol_fiche_head($head, $mode, '', -1, ''); print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; @@ -174,9 +181,13 @@ print '<input type="hidden" id="mode" name="mode" value="'.$mode.'">'; print '<table class="noborder" width="100%">'; print '<tr class="liste_titre">'; -print_liste_field_titre($langs->trans("Language").' (en_US, es_MX, ...)',$_SERVER["PHP_SELF"],'lang,transkey','',$param,'',$sortfield,$sortorder); -print_liste_field_titre($langs->trans("Key"),$_SERVER["PHP_SELF"],'transkey','',$param,'',$sortfield,$sortorder); -print_liste_field_titre($langs->trans("NewTranslationStringToShow"),$_SERVER["PHP_SELF"],'transvalue','',$param,'',$sortfield,$sortorder); +$texthelp=$langs->trans("PageUrlForDefaultValues"); +if ($mode == 'createform') $texthelp.=$langs->trans("PageUrlForDefaultValuesCreate", 'societe/card.php'); +else $texthelp.=$langs->trans("PageUrlForDefaultValuesList", 'societe/list.php'); +$texturl=$form->textwithpicto($langs->trans("Url"), $texthelp); +print_liste_field_titre($texturl,$_SERVER["PHP_SELF"],'defaulturl','',$param,'',$sortfield,$sortorder); +print_liste_field_titre($langs->trans("Key"),$_SERVER["PHP_SELF"],'defaultkey','',$param,'',$sortfield,$sortorder); +print_liste_field_titre($langs->trans("Value"),$_SERVER["PHP_SELF"],'defaultvalue','',$param,'',$sortfield,$sortorder); //if (! empty($conf->multicompany->enabled) && !$user->entity) print_liste_field_titre($langs->trans("Entity"),$_SERVER["PHP_SELF"],'entity,transkey','',$param,'',$sortfield,$sortorder); print '<td align="center"></td>'; print "</tr>\n"; @@ -185,13 +196,14 @@ print "</tr>\n"; // Line to add new record print "\n"; -print '<tr class="oddeven"><td>'; -print $formadmin->select_language(GETPOST('langcode'), 'langcode', 0, null, 1, 0, 0, 'maxwidthonsmartphone', 1); +print '<tr class="oddeven">'; +print '<td>'; +print '<input type="text" class="flat minwidth200 maxwidthonsmartphone" name="defaulturl" value="">'; print '</td>'."\n"; print '<td>'; -print '<input type="text" class="flat maxwidthonsmartphone" name="transkey" value="">'; +print '<input type="text" class="flat maxwidth100" name="defaultkey" value="">'; print '</td><td>'; -print '<input type="text" class="quatrevingtpercent" name="transvalue" value="">'; +print '<input type="text" class="flat maxwidthonsmartphone" name="defaultvalue" value="">'; print '</td>'; // Limit to superadmin /*if (! empty($conf->multicompany->enabled) && !$user->entity) diff --git a/htdocs/core/lib/admin.lib.php b/htdocs/core/lib/admin.lib.php index 5c4df1bcd91..63b06dbd737 100644 --- a/htdocs/core/lib/admin.lib.php +++ b/htdocs/core/lib/admin.lib.php @@ -609,9 +609,19 @@ function defaultvalues_prepare_head() $h = 0; $head = array(); - $head[$h][0] = DOL_URL_ROOT."/admin/defaultvalues.php?mode=overwrite"; - $head[$h][1] = $langs->trans("DefaultValuesOverwriteKey"); - $head[$h][2] = 'overwrite'; + $head[$h][0] = DOL_URL_ROOT."/admin/defaultvalues.php?mode=createform"; + $head[$h][1] = $langs->trans("DefaultCreateForm"); + $head[$h][2] = 'createform'; + $h++; + + $head[$h][0] = DOL_URL_ROOT."/admin/defaultvalues.php?mode=filters"; + $head[$h][1] = $langs->trans("DefaultSearchFilters"); + $head[$h][2] = 'filters'; + $h++; + + $head[$h][0] = DOL_URL_ROOT."/admin/defaultvalues.php?mode=sortorder"; + $head[$h][1] = $langs->trans("DefaultSortOrder"); + $head[$h][2] = 'sortorder'; $h++; /*$head[$h][0] = DOL_URL_ROOT."/admin/translation.php?mode=searchkey"; diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang index ded46d762d9..9ab6408714c 100644 --- a/htdocs/langs/en_US/admin.lang +++ b/htdocs/langs/en_US/admin.lang @@ -1338,6 +1338,10 @@ CacheByServer=Cache by server CacheByClient=Cache by browser CompressionOfResources=Compression of HTTP responses TestNotPossibleWithCurrentBrowsers=Such an automatic detection is not possible with current browsers +DefaultValuesDesc=You can defined here the default value you want to get when your create a new record, and/or defaut filters or soting order when your list record. +DefaultCreateForm=Create forms +DefaultSearchFilters=Search filters +DefaultSortOrder=Sort orders ##### Products ##### ProductSetup=Products module setup ServiceSetup=Services module setup diff --git a/htdocs/langs/en_US/main.lang b/htdocs/langs/en_US/main.lang index 918f46a44b7..85d86d77abf 100644 --- a/htdocs/langs/en_US/main.lang +++ b/htdocs/langs/en_US/main.lang @@ -309,6 +309,10 @@ Copy=Copy Paste=Paste Default=Default DefaultValue=Default value +DefaultValues=Default values +PageUrlForDefaultValues=You must enter here the relative url of the page. Examples: +PageUrlForDefaultValuesCreate=<br>For form to create a new thirdparty, it is <strong>%s</strong>. +PageUrlForDefaultValuesList=<br>For page that list thirdparties, it is <strong>%s</strong>. Price=Price UnitPrice=Unit price UnitPriceHT=Unit price (net) -- GitLab