Add button to disable all personalized default values in one click.

This commit is contained in:
Laurent Destailleur 2017-05-06 17:08:38 +02:00
parent 44bdf91715
commit d948447600
6 changed files with 40 additions and 13 deletions

View File

@ -84,6 +84,11 @@ if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter.x") || GETP
$search_array_options=array();
}
if ($action == 'setMAIN_ENABLE_DEFAULT_VALUES')
{
if (GETPOST('value')) dolibarr_set_const($db, 'MAIN_ENABLE_DEFAULT_VALUES', 1, 'chaine', 0, '', $conf->entity);
else dolibarr_set_const($db, 'MAIN_ENABLE_DEFAULT_VALUES', 0, 'chaine', 0, '', $conf->entity);
}
if (($action == 'add' || (GETPOST('add') && $action != 'update')) || GETPOST('actionmodify'))
{
@ -185,6 +190,23 @@ print load_fiche_titre($langs->trans("DefaultValues"),'','title_setup');
print $langs->trans("DefaultValuesDesc")."<br>\n";
print "<br>\n";
print $langs->trans("EnableDefaultValues").' ';
if (empty($conf->global->MAIN_ENABLE_DEFAULT_VALUES))
{
// Button off, click to enable
print '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?action=setMAIN_ENABLE_DEFAULT_VALUES&amp;value=1">';
print img_picto($langs->trans("Disabled"),'switch_off');
print '</a>';
}
else
{
// Button on, click to disable
print '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?action=setMAIN_ENABLE_DEFAULT_VALUES&amp;value=0">';
print img_picto($langs->trans("Activated"),'switch_on');
print '</a>';
}
print "<br><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;

View File

@ -640,7 +640,8 @@ if ($mode == 'common')
{
$disableSetup = 0;
print '<td class="center valignmiddle" width="80px">';
// Link enable/disabme
print '<td class="center valignmiddle" width="60px">';
if (! empty($arrayofwarnings[$modName]))
{
print '<!-- This module has a warning to show when we activate it (note: your country is '.$mysoc->country_code.') -->'."\n";
@ -662,12 +663,12 @@ if ($mode == 'common')
}
print '</td>'."\n";
// Config link
// Link config
if (! empty($objMod->config_page_url) && !$disableSetup)
{
if (is_array($objMod->config_page_url))
{
print '<td class="tdsetuppicto right" width="40px"">';
print '<td class="tdsetuppicto right" width="60px">';
$i=0;
foreach ($objMod->config_page_url as $page)
{
@ -693,22 +694,23 @@ if ($mode == 'common')
}
else if (preg_match('/^([^@]+)@([^@]+)$/i',$objMod->config_page_url,$regs))
{
print '<td class="tdsetuppicto right valignmiddle" width="80px"><a href="'.dol_buildpath('/'.$regs[2].'/admin/'.$regs[1],1).'" title="'.$langs->trans("Setup").'">'.img_picto($langs->trans("Setup"),"setup",'style="padding-right: 6px"').'</a></td>';
print '<td class="tdsetuppicto right valignmiddle" width="60px"><a href="'.dol_buildpath('/'.$regs[2].'/admin/'.$regs[1],1).'" title="'.$langs->trans("Setup").'">'.img_picto($langs->trans("Setup"),"setup",'style="padding-right: 6px"').'</a></td>';
}
else
{
print '<td class="tdsetuppicto right valignmiddle" width="80px"><a href="'.$objMod->config_page_url.'" title="'.$langs->trans("Setup").'">'.img_picto($langs->trans("Setup"),"setup",'style="padding-right: 6px"').'</a></td>';
print '<td class="tdsetuppicto right valignmiddle" width="60px"><a href="'.$objMod->config_page_url.'" title="'.$langs->trans("Setup").'">'.img_picto($langs->trans("Setup"),"setup",'style="padding-right: 6px"').'</a></td>';
}
}
else
{
print '<td class="tdsetuppicto right valignmiddle" width="80px">'.img_picto($langs->trans("NothingToSetup"),"setup",'class="opacitytransp" style="padding-right: 6px"').'</td>';
print '<td class="tdsetuppicto right valignmiddle" width="60px">'.img_picto($langs->trans("NothingToSetup"),"setup",'class="opacitytransp" style="padding-right: 6px"').'</td>';
}
}
else // Module not yet activated
{
print '<td class="center valignmiddle" width="80px">';
// Link enable/disable
print '<td class="center valignmiddle" width="60px">';
if (! empty($objMod->always_enabled))
{
// Should never happened
@ -754,7 +756,9 @@ if ($mode == 'common')
print "</a>\n";
}
print "</td>\n";
print '<td class="tdsetuppicto right valignmiddle" width="80px">'.img_picto($langs->trans("NothingToSetup"),"setup",'class="opacitytransp" style="padding-right: 6px"').'</td>';
// Link config
print '<td class="tdsetuppicto right valignmiddle" width="60px">'.img_picto($langs->trans("NothingToSetup"),"setup",'class="opacitytransp" style="padding-right: 6px"').'</td>';
}
print "</tr>\n";

View File

@ -149,6 +149,7 @@ if (! empty($conf->productbatch->enabled))
//if (! empty($conf->global->STOCK_CALCULATE_ON_VALIDATE_ORDER) || ! empty($conf->global->STOCK_CALCULATE_ON_SHIPMENT))
//{
print info_admin($langs->trans("IfYouUsePointOfSaleCheckModule"));
print '<br>';
//}
// Title rule for stock decrease

View File

@ -260,7 +260,7 @@ function GETPOST($paramname, $check='', $method=0, $filter=NULL, $options=NULL)
global $conf;
// Management of default values
if (! isset($_GET['sortfield']) && empty($conf->global->MAIN_DISABLE_DEFAULT_VALUES)) // If we did a click on a field to sort, we do no apply default values. Same if option MAIN_DISABLE_DEFAULT_VALUES is on
if (! isset($_GET['sortfield']) && ! empty($conf->global->MAIN_ENABLE_DEFAULT_VALUES)) // If we did a click on a field to sort, we do no apply default values. Same if option MAIN_DISABLE_DEFAULT_VALUES is on
{
if (! empty($_GET['action']) && $_GET['action'] == 'create' && ! empty($paramname) && ! isset($_GET[$paramname]) && ! isset($_POST[$paramname]))
{

View File

@ -431,6 +431,7 @@ TheKeyIsTheNameOfHtmlField=This is the name of the HTML field. This need to have
PageUrlForDefaultValues=You must enter here the relative url of the page. If you include parameters in URL, the default values will be effective if all parameters are set to same value. 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>
EnableDefaultValues=Enable usage of personalized default values
GoIntoTranslationMenuToChangeThis=A translation has been found for the key with this code, so to change this value, you must edit it fom Home-Setup-translation.
WarningSettingSortOrder=Warning, setting a default sort order may result in a technical error when going on the list page if field is an unknown field. If you experience such an error, come back to this page to remove the default sort order and restore default behavior.
Field=Field

View File

@ -277,16 +277,14 @@ if ($action == 'edit')
}
else if ($action != 'add')
{
//if ($cnt_trans) print '<div class="underbanner clearboth"></div>';
if (! empty($object->multilangs))
{
foreach ($object->multilangs as $key => $value)
{
$s=picto_from_langcode($key);
//print '<tr><td>';
print ($s?$s.' ':'')." <b>".$langs->trans('Language_'.$key).":</b> ".'<a href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=delete&langtodelete='.$key.'">'.img_delete('', 'class="valigntextbottom"').'</a>';
//print '</td><td></td></tr>';
print '<div class="fichecenter">';
print '<div class="underbanner clearboth"></div>';
print '<table class="border" width="100%">';
print '<tr><td class="titlefieldcreate">'.$langs->trans('Label').'</td><td>'.$object->multilangs[$key]["label"].'</td></tr>';
@ -296,6 +294,7 @@ else if ($action != 'add')
print '<tr><td>'.$langs->trans('Other').' ('.$langs->trans("NotUsed").')</td><td>'.$object->multilangs[$key]["other"].'</td></tr>';
}
print '</table>';
print '</div>';
}
}
if (! $cnt_trans && $action != 'add') print '<div class="opacitymedium">'. $langs->trans('NoTranslation').'</div>';