NEW users can set their own length for short lists

This commit is contained in:
Laurent Destailleur
2024-04-30 10:20:40 +02:00
parent 6b70b32f1e
commit 9393c2c0e2
5 changed files with 48 additions and 19 deletions

View File

@@ -249,7 +249,7 @@ if ($action == 'update') {
dolibarr_set_const($db, "MAIN_IHM_PARAMS_REV", getDolGlobalInt('MAIN_IHM_PARAMS_REV') + 1, 'chaine', 0, '', $conf->entity);
dolibarr_set_const($db, "MAIN_SIZE_LISTE_LIMIT", GETPOSTINT("MAIN_SIZE_LISTE_LIMIT"), 'chaine', 0, '', $conf->entity);
dolibarr_set_const($db, "MAIN_SIZE_SHORTLIST_LIMIT", GETPOSTINT("main_size_shortliste_limit"), 'chaine', 0, '', $conf->entity);
dolibarr_set_const($db, "MAIN_SIZE_SHORTLIST_LIMIT", GETPOSTINT("MAIN_SIZE_SHORTLIST_LIMIT"), 'chaine', 0, '', $conf->entity);
if (GETPOSTISSET("MAIN_CHECKBOX_LEFT_COLUMN")) {
dolibarr_set_const($db, "MAIN_CHECKBOX_LEFT_COLUMN", GETPOSTINT("MAIN_CHECKBOX_LEFT_COLUMN"), 'chaine', 0, '', $conf->entity);
@@ -430,11 +430,11 @@ if ($mode == 'other') {
print '</tr>';
// Max size of lists
print '<tr class="oddeven"><td>' . $langs->trans("DefaultMaxSizeList") . '</td><td><input class="flat" name="MAIN_SIZE_LISTE_LIMIT" size="4" value="' . getDolGlobalString('MAIN_SIZE_LISTE_LIMIT') . '"></td>';
print '<tr class="oddeven"><td>' . $langs->trans("DefaultMaxSizeList") . '</td><td><input class="flat width50" name="MAIN_SIZE_LISTE_LIMIT" value="' . getDolGlobalString('MAIN_SIZE_LISTE_LIMIT') . '"></td>';
print '</tr>';
// Max size of short lists on customer card
print '<tr class="oddeven"><td>' . $langs->trans("DefaultMaxSizeShortList") . '</td><td><input class="flat" name="main_size_shortliste_limit" size="4" value="' . getDolGlobalString('MAIN_SIZE_SHORTLIST_LIMIT') . '"></td>';
print '<tr class="oddeven"><td>' . $langs->trans("DefaultMaxSizeShortList") . '</td><td><input class="flat width50" name="MAIN_SIZE_SHORTLIST_LIMIT" value="' . getDolGlobalString('MAIN_SIZE_SHORTLIST_LIMIT') . '"></td>';
print '</tr>';
// Display checkboxes and fields menu left / right

View File

@@ -1373,7 +1373,7 @@ class FormOther
$boxlista .= "\n<!-- Box left container -->\n";
// Define $box_max_lines
$box_max_lines = getDolGlobalInt('MAIN_SIZE_SHORTLIST_LIMIT', 6);
$box_max_lines = getDolUserInt('MAIN_SIZE_SHORTLIST_LIMIT', getDolGlobalInt('MAIN_SIZE_SHORTLIST_LIMIT', 5));
$ii = 0;
foreach ($boxactivated as $key => $box) {

View File

@@ -3445,9 +3445,9 @@ function dol_filecache($directory, $filename, $object)
/**
* Test if Refresh needed.
*
* @param string $directory Directory of cache
* @param string $filename Name of filecache
* @param int $cachetime Cachetime delay
* @param string $directory Directory of cache
* @param string $filename Name of filecache
* @param int $cachetime Cachetime delay
* @return boolean 0 no refresh 1 if refresh needed
*/
function dol_cache_refresh($directory, $filename, $cachetime)
@@ -3461,9 +3461,9 @@ function dol_cache_refresh($directory, $filename, $cachetime)
/**
* Read object from cachefile.
*
* @param string $directory Directory of cache
* @param string $filename Name of filecache
* @return mixed Unserialise from file
* @param string $directory Directory of cache
* @param string $filename Name of filecache
* @return mixed Unserialise from file
*/
function dol_readcachefile($directory, $filename)
{
@@ -3475,7 +3475,7 @@ function dol_readcachefile($directory, $filename)
/**
* Return the relative dirname (relative to DOL_DATA_ROOT) of a full path string.
*
* @param string $pathfile Full path of a file
* @param string $pathfile Full path of a file
* @return string Path of file relative to DOL_DATA_ROOT
*/
function dirbasename($pathfile)

View File

@@ -1205,10 +1205,11 @@ DefaultMenuManager= Standard menu manager
DefaultMenuSmartphoneManager=Smartphone menu manager
Skin=Skin theme
DefaultSkin=Default skin theme
MaxSizeList=Max length for list
MaxSizeList=Max length for lists
DefaultMaxSizeList=Default max length for lists
DisplayGrandTotalInList=Display grand total (for all pages) in lists footer
MaxSizeShortList=Max length for short lists
DefaultMaxSizeShortList=Default max length for short lists (i.e. in customer card)
DisplayGrandTotalInList=Display grand total (for all pages) in lists footer
MessageOfDay=Message of the day
MessageLogin=Login page message
LoginPage=Login page

View File

@@ -110,12 +110,18 @@ if (empty($reshook)) {
$tabparam["MAIN_LANG_DEFAULT"] = '';
}
if (GETPOST("check_SIZE_LISTE_LIMIT") == "on") {
if (GETPOST("check_MAIN_SIZE_LISTE_LIMIT") == "on") {
$tabparam["MAIN_SIZE_LISTE_LIMIT"] = GETPOSTINT("MAIN_SIZE_LISTE_LIMIT");
} else {
$tabparam["MAIN_SIZE_LISTE_LIMIT"] = '';
}
if (GETPOST("check_MAIN_SIZE_SHORTLIST_LIMIT") == "on") {
$tabparam["MAIN_SIZE_SHORTLIST_LIMIT"] = GETPOSTINT("MAIN_SIZE_SHORTLIST_LIMIT");
} else {
$tabparam["MAIN_SIZE_SHORTLIST_LIMIT"] = '';
}
if (GETPOST("check_AGENDA_DEFAULT_VIEW") == "on") {
$tabparam["AGENDA_DEFAULT_VIEW"] = GETPOST("AGENDA_DEFAULT_VIEW", 'aZ09');
} else {
@@ -174,6 +180,10 @@ if (empty($reshook)) {
$result = dol_set_user_param($db, $conf, $object, $tabparam);
// Clear cache of widgets (because we may have modified the length of cached widget lists)
$cachedir = DOL_DATA_ROOT.'/users/temp/widgets';
dol_delete_dir_recursive($cachedir);
header('Location: '.$_SERVER["PHP_SELF"].'?id='.$id);
exit;
}
@@ -307,9 +317,12 @@ if ($action == 'edit') {
if (jQuery("#check_MAIN_LANG_DEFAULT").prop("checked")) { jQuery("#main_lang_default").removeAttr(\'disabled\'); }
else { jQuery("#main_lang_default").attr(\'disabled\',\'disabled\'); }
if (jQuery("#check_SIZE_LISTE_LIMIT").prop("checked")) { jQuery("#MAIN_SIZE_LISTE_LIMIT").removeAttr(\'disabled\'); }
if (jQuery("#check_MAIN_SIZE_LISTE_LIMIT").prop("checked")) { jQuery("#MAIN_SIZE_LISTE_LIMIT").removeAttr(\'disabled\'); }
else { jQuery("#MAIN_SIZE_LISTE_LIMIT").attr(\'disabled\',\'disabled\'); }
if (jQuery("#check_MAIN_SIZE_SHORTLIST_LIMIT").prop("checked")) { jQuery("#MAIN_SIZE_SHORTLIST_LIMIT").removeAttr(\'disabled\'); }
else { jQuery("#MAIN_SIZE_SHORTLIST_LIMIT").attr(\'disabled\',\'disabled\'); }
if (jQuery("#check_AGENDA_DEFAULT_VIEW").prop("checked")) { jQuery("#AGENDA_DEFAULT_VIEW").removeAttr(\'disabled\'); }
else { jQuery("#AGENDA_DEFAULT_VIEW").attr(\'disabled\',\'disabled\'); }
@@ -322,7 +335,8 @@ if ($action == 'edit') {
init_myfunc();
jQuery("#check_MAIN_LANDING_PAGE").click(function() { init_myfunc(); });
jQuery("#check_MAIN_LANG_DEFAULT").click(function() { init_myfunc(); });
jQuery("#check_SIZE_LISTE_LIMIT").click(function() { init_myfunc(); });
jQuery("#check_MAIN_SIZE_LISTE_LIMIT").click(function() { init_myfunc(); });
jQuery("#check_MAIN_SIZE_SHORTLIST_LIMIT").click(function() { init_myfunc(); });
jQuery("#check_AGENDA_DEFAULT_VIEW").click(function() { init_myfunc(); });
jQuery("#check_MAIN_THEME").click(function() { init_myfunc(); });
jQuery("#check_THEME_ELDY_TOPMENU_BACK1").click(function() { init_myfunc(); });
@@ -379,11 +393,19 @@ if ($action == 'edit') {
// Max size of lists
print '<tr class="oddeven"><td>'.$langs->trans("MaxSizeList").'</td>';
print '<td>' . getDolGlobalString('MAIN_SIZE_LISTE_LIMIT').'</td>';
print '<td class="nowrap" width="20%"><input class="oddeven" name="check_SIZE_LISTE_LIMIT" id="check_SIZE_LISTE_LIMIT" type="checkbox" '.(!empty($object->conf->MAIN_SIZE_LISTE_LIMIT) ? " checked" : "");
print '<td class="nowrap" width="20%"><input class="oddeven" name="check_MAIN_SIZE_LISTE_LIMIT" id="check_MAIN_SIZE_LISTE_LIMIT" type="checkbox" '.(!empty($object->conf->MAIN_SIZE_LISTE_LIMIT) ? " checked" : "");
print empty($dolibarr_main_demo) ? '' : ' disabled="disabled"'; // Disabled for demo
print '> <label for="check_SIZE_LISTE_LIMIT">'.$langs->trans("UsePersonalValue").'</label></td>';
print '> <label for="check_MAIN_SIZE_LISTE_LIMIT">'.$langs->trans("UsePersonalValue").'</label></td>';
print '<td><input class="flat" name="MAIN_SIZE_LISTE_LIMIT" id="MAIN_SIZE_LISTE_LIMIT" size="4" value="'.(!empty($object->conf->MAIN_SIZE_LISTE_LIMIT) ? $object->conf->MAIN_SIZE_LISTE_LIMIT : '').'"></td></tr>';
// Max size of lists
print '<tr class="oddeven"><td>'.$langs->trans("MaxSizeShortList").'</td>';
print '<td>' . getDolGlobalString('MAIN_SIZE_SHORTLIST_LIMIT').'</td>';
print '<td class="nowrap" width="20%"><input class="oddeven" name="check_MAIN_SIZE_SHORTLIST_LIMIT" id="check_MAIN_SIZE_SHORTLIST_LIMIT" type="checkbox" '.(!empty($object->conf->MAIN_SIZE_SHORTLIST_LIMIT) ? " checked" : "");
print empty($dolibarr_main_demo) ? '' : ' disabled="disabled"'; // Disabled for demo
print '> <label for="check_MAIN_SIZE_SHORTLIST_LIMIT">'.$langs->trans("UsePersonalValue").'</label></td>';
print '<td><input class="flat" name="MAIN_SIZE_SHORTLIST_LIMIT" id="MAIN_SIZE_SHORTLIST_LIMIT" size="4" value="'.(!empty($object->conf->MAIN_SIZE_SHORTLIST_LIMIT) ? $object->conf->MAIN_SIZE_SHORTLIST_LIMIT : '').'"></td></tr>';
print '</table><br>';
// Theme
@@ -505,10 +527,16 @@ if ($action == 'edit') {
// Max size for lists
print '<tr class="oddeven"><td>'.$langs->trans("MaxSizeList").'</td>';
print '<td>'.(getDolGlobalString('MAIN_SIZE_LISTE_LIMIT') ? $conf->global->MAIN_SIZE_LISTE_LIMIT : '&nbsp;').'</td>';
print '<td>'.getDolGlobalString('MAIN_SIZE_LISTE_LIMIT', '&nbsp;').'</td>';
print '<td class="nowrap" width="20%"><input class="oddeven" type="checkbox" disabled '.(!empty($object->conf->MAIN_SIZE_LISTE_LIMIT) ? " checked" : "").'> '.$langs->trans("UsePersonalValue").'</td>';
print '<td>'.(!empty($object->conf->MAIN_SIZE_LISTE_LIMIT) ? $object->conf->MAIN_SIZE_LISTE_LIMIT : '&nbsp;').'</td></tr>';
// Max size for lists
print '<tr class="oddeven"><td>'.$langs->trans("MaxSizeShortList").'</td>';
print '<td>'.getDolGlobalString('MAIN_SIZE_SHORTLIST_LIMIT', '&nbsp;').'</td>';
print '<td class="nowrap" width="20%"><input class="oddeven" type="checkbox" disabled '.(!empty($object->conf->MAIN_SIZE_SHORTLIST_LIMIT) ? " checked" : "").'> '.$langs->trans("UsePersonalValue").'</td>';
print '<td>'.(!empty($object->conf->MAIN_SIZE_SHORTLIST_LIMIT) ? $object->conf->MAIN_SIZE_SHORTLIST_LIMIT : '&nbsp;').'</td></tr>';
print '</table>';
print '</div>';
print '<br>';