Default value

This commit is contained in:
Laurent Destailleur 2017-04-10 12:51:52 +02:00
parent b054ca8267
commit f1ae0eb7c6
4 changed files with 49 additions and 19 deletions

View File

@ -50,6 +50,10 @@ $pagenext = $page + 1;
if (! $sortfield) $sortfield='lang,transkey'; if (! $sortfield) $sortfield='lang,transkey';
if (! $sortorder) $sortorder='ASC'; if (! $sortorder) $sortorder='ASC';
$defaulturl = GETPOST('defaulturl');
$defaultkey = GETPOST('defaultkey','alpha');
$defaultvalue = GETPOST('defaultvalue');
/* /*
* Actions * Actions
@ -67,8 +71,9 @@ include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php';
// Purge search criteria // 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 if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter.x") || GETPOST("button_removefilter")) // All test are required to be compatible with all browsers
{ {
$transkey=''; $defaulturl='';
$transvalue=''; $defaultkey='';
$defaultvalue='';
$toselect=''; $toselect='';
$search_array_options=array(); $search_array_options=array();
} }
@ -101,8 +106,9 @@ if ($action == 'add' || (GETPOST('add') && $action != 'update'))
{ {
setEventMessages($langs->trans("RecordSaved"), null, 'mesgs'); setEventMessages($langs->trans("RecordSaved"), null, 'mesgs');
$action=""; $action="";
$transkey=""; $defaulturl='';
$transvalue=""; $defaultkey='';
$defaultvalue='';
} }
else else
{ {
@ -136,6 +142,7 @@ if ($action == 'delete')
* View * View
*/ */
$form=new Form($db);
$formadmin = new FormAdmin($db); $formadmin = new FormAdmin($db);
$wikihelp='EN:Setup|FR:Paramétrage|ES:Configuración'; $wikihelp='EN:Setup|FR:Paramétrage|ES:Configuración';
@ -150,9 +157,9 @@ $param='&mode='.$mode;
if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.$contextpage; if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.$contextpage;
if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.$limit; if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.$limit;
if ($optioncss != '') $param.='&optioncss='.$optioncss; if ($optioncss != '') $param.='&optioncss='.$optioncss;
if ($langcode) $param.='&langcode='.urlencode($langcode); if (defaulturl) $param.='&defaulturl='.urlencode(defaulturl);
if ($transkey) $param.='&transkey='.urlencode($transkey); if (defaultkey) $param.='&defaultkey='.urlencode(defaultkey);
if ($transvalue) $param.='&transvalue='.urlencode($transvalue); if (defaultvalue) $param.='&defaultvalue='.urlencode(defaultvalue);
print '<form action="'.$_SERVER["PHP_SELF"].((empty($user->entity) && $debug)?'?debug=1':'').'" method="POST">'; 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(); $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'].'">'; 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 '<table class="noborder" width="100%">';
print '<tr class="liste_titre">'; print '<tr class="liste_titre">';
print_liste_field_titre($langs->trans("Language").' (en_US, es_MX, ...)',$_SERVER["PHP_SELF"],'lang,transkey','',$param,'',$sortfield,$sortorder); $texthelp=$langs->trans("PageUrlForDefaultValues");
print_liste_field_titre($langs->trans("Key"),$_SERVER["PHP_SELF"],'transkey','',$param,'',$sortfield,$sortorder); if ($mode == 'createform') $texthelp.=$langs->trans("PageUrlForDefaultValuesCreate", 'societe/card.php');
print_liste_field_titre($langs->trans("NewTranslationStringToShow"),$_SERVER["PHP_SELF"],'transvalue','',$param,'',$sortfield,$sortorder); 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); //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 '<td align="center"></td>';
print "</tr>\n"; print "</tr>\n";
@ -185,13 +196,14 @@ print "</tr>\n";
// Line to add new record // Line to add new record
print "\n"; print "\n";
print '<tr class="oddeven"><td>'; print '<tr class="oddeven">';
print $formadmin->select_language(GETPOST('langcode'), 'langcode', 0, null, 1, 0, 0, 'maxwidthonsmartphone', 1); print '<td>';
print '<input type="text" class="flat minwidth200 maxwidthonsmartphone" name="defaulturl" value="">';
print '</td>'."\n"; print '</td>'."\n";
print '<td>'; 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 '</td><td>';
print '<input type="text" class="quatrevingtpercent" name="transvalue" value="">'; print '<input type="text" class="flat maxwidthonsmartphone" name="defaultvalue" value="">';
print '</td>'; print '</td>';
// Limit to superadmin // Limit to superadmin
/*if (! empty($conf->multicompany->enabled) && !$user->entity) /*if (! empty($conf->multicompany->enabled) && !$user->entity)

View File

@ -609,9 +609,19 @@ function defaultvalues_prepare_head()
$h = 0; $h = 0;
$head = array(); $head = array();
$head[$h][0] = DOL_URL_ROOT."/admin/defaultvalues.php?mode=overwrite"; $head[$h][0] = DOL_URL_ROOT."/admin/defaultvalues.php?mode=createform";
$head[$h][1] = $langs->trans("DefaultValuesOverwriteKey"); $head[$h][1] = $langs->trans("DefaultCreateForm");
$head[$h][2] = 'overwrite'; $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++; $h++;
/*$head[$h][0] = DOL_URL_ROOT."/admin/translation.php?mode=searchkey"; /*$head[$h][0] = DOL_URL_ROOT."/admin/translation.php?mode=searchkey";

View File

@ -1338,6 +1338,10 @@ CacheByServer=Cache by server
CacheByClient=Cache by browser CacheByClient=Cache by browser
CompressionOfResources=Compression of HTTP responses CompressionOfResources=Compression of HTTP responses
TestNotPossibleWithCurrentBrowsers=Such an automatic detection is not possible with current browsers 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 ##### ##### Products #####
ProductSetup=Products module setup ProductSetup=Products module setup
ServiceSetup=Services module setup ServiceSetup=Services module setup

View File

@ -309,6 +309,10 @@ Copy=Copy
Paste=Paste Paste=Paste
Default=Default Default=Default
DefaultValue=Default value 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 Price=Price
UnitPrice=Unit price UnitPrice=Unit price
UnitPriceHT=Unit price (net) UnitPriceHT=Unit price (net)