Debug v17
This commit is contained in:
parent
b67d1359e8
commit
aed0896e98
@ -218,25 +218,25 @@ class FormMargin
|
||||
if ($reshook < 0) {
|
||||
setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
|
||||
} elseif (empty($reshook)) {
|
||||
if (!empty($conf->global->MARGIN_ADD_SHOWHIDE_BUTTON)) { // TODO Warning this feature rely on an external js file that may be removed. Using native js function document.cookie should be better
|
||||
print $langs->trans('ShowMarginInfos') . ' : ';
|
||||
if (!empty($conf->global->MARGIN_ADD_SHOWHIDE_BUTTON)) {
|
||||
print $langs->trans('ShowMarginInfos') . ' ';
|
||||
$hidemargininfos = preg_replace('/[^a-zA-Z0-9_\-]/', '', $_COOKIE['DOLUSER_MARGININFO_HIDE_SHOW']); // Clean cookie
|
||||
print '<span id="showMarginInfos" class="linkobject ' . (!empty($hidemargininfos) ? '' : 'hideobject') . '">' . img_picto($langs->trans("Disabled"), 'switch_off') . '</span>';
|
||||
print '<span id="hideMarginInfos" class="linkobject ' . (!empty($hidemargininfos) ? 'hideobject' : '') . '">' . img_picto($langs->trans("Enabled"), 'switch_on') . '</span>';
|
||||
print '<span id="showMarginInfos" class="linkobject valignmiddle ' . (!empty($hidemargininfos) ? '' : 'hideobject') . '">' . img_picto($langs->trans("Disabled"), 'switch_off') . '</span>';
|
||||
print '<span id="hideMarginInfos" class="linkobject valignmiddle ' . (!empty($hidemargininfos) ? 'hideobject' : '') . '">' . img_picto($langs->trans("Enabled"), 'switch_on') . '</span>';
|
||||
|
||||
print '<script>$(document).ready(function() {
|
||||
$("span#showMarginInfos").click(function() { $.getScript( "' . dol_buildpath('/includes/jquery/plugins/jquerytreeview/lib/jquery.cookie.js', 1) . '", function( data, textStatus, jqxhr ) { $.cookie("DOLUSER_MARGININFO_HIDE_SHOW", 0); $(".margininfos").show(); $("span#showMarginInfos").addClass("hideobject"); $("span#hideMarginInfos").removeClass("hideobject");})});
|
||||
$("span#hideMarginInfos").click(function() { $.getScript( "' . dol_buildpath('/includes/jquery/plugins/jquerytreeview/lib/jquery.cookie.js', 1) . '", function( data, textStatus, jqxhr ) { $.cookie("DOLUSER_MARGININFO_HIDE_SHOW", 1); $(".margininfos").hide(); $("span#hideMarginInfos").addClass("hideobject"); $("span#showMarginInfos").removeClass("hideobject");})});
|
||||
$("span#showMarginInfos").click(function() { console.log("click on showMargininfos"); date = new Date(); date.setTime(date.getTime()+(30*86400000)); document.cookie = "DOLUSER_MARGININFO_HIDE_SHOW=0; expires=" + date.toGMTString() + "; path=/ "; $(".margintable").show(); $("span#showMarginInfos").addClass("hideobject"); $("span#hideMarginInfos").removeClass("hideobject"); });
|
||||
$("span#hideMarginInfos").click(function() { console.log("click on hideMarginInfos"); date = new Date(); date.setTime(date.getTime()+(30*86400000)); document.cookie = "DOLUSER_MARGININFO_HIDE_SHOW=1; expires=" + date.toGMTString() + "; path=/ "; $(".margintable").hide(); $("span#hideMarginInfos").addClass("hideobject"); $("span#showMarginInfos").removeClass("hideobject"); });
|
||||
});</script>';
|
||||
if (!empty($hidemargininfos)) {
|
||||
print '<script>$(document).ready(function() {$(".margininfos").hide();});</script>';
|
||||
print '<script>$(document).ready(function() { console.log("hide the margin info"); $("#margintable").hide(); });</script>';
|
||||
}
|
||||
}
|
||||
|
||||
print '<div class="div-table-responsive-no-min">';
|
||||
print '<!-- Margin table -->' . "\n";
|
||||
|
||||
print '<table class="noborder margintable centpercent">';
|
||||
print '<table class="noborder margintable centpercent" id="margintable">';
|
||||
print '<tr class="liste_titre">';
|
||||
print '<td class="liste_titre">' . $langs->trans('Margins') . '</td>';
|
||||
print '<td class="liste_titre right">' . $langs->trans('SellingPrice') . '</td>';
|
||||
|
||||
@ -420,9 +420,13 @@ $sql .= " ORDER BY r.family_position, r.module_position, r.module, r.id";
|
||||
$result = $db->query($sql);
|
||||
if ($result) {
|
||||
$num = $db->num_rows($result);
|
||||
$i = 0;
|
||||
$i = 0; $j = 0;
|
||||
$oldmod = '';
|
||||
|
||||
$cookietohidegroup = (empty($_COOKIE["DOLUSER_PERMS_HIDE_GRP"]) ? '' : preg_replace('/^,/', '', $_COOKIE["DOLUSER_PERMS_HIDE_GRP"]));
|
||||
$cookietohidegrouparray = explode(',', $cookietohidegroup);
|
||||
//var_dump($cookietohidegrouparray);
|
||||
|
||||
while ($i < $num) {
|
||||
$obj = $db->fetch_object($result);
|
||||
|
||||
@ -472,26 +476,39 @@ if ($result) {
|
||||
}
|
||||
*/
|
||||
|
||||
/*$isexpanded = ($updatedmodulename == $obj->module || $module == "allmodules");
|
||||
if (!$action) {
|
||||
$isexpanded = 1; // By default (no action done) we have lines expanded
|
||||
}*/
|
||||
$ishidden = GETPOST('forbreakperms_'.$obj->module, 'int');
|
||||
if (GETPOSTISSET('forbreakperms_'.$obj->module)) {
|
||||
$ishidden = GETPOST('forbreakperms_'.$obj->module, 'int');
|
||||
} elseif (in_array($j, $cookietohidegrouparray)) { // If j is among list of hidden group
|
||||
$ishidden = 1;
|
||||
} else {
|
||||
$ishidden = 0;
|
||||
}
|
||||
$isexpanded = ! $ishidden;
|
||||
//var_dump($isexpanded);
|
||||
//var_dump("isexpanded=".$isexpanded);
|
||||
|
||||
// Break found, it's a new module to catch
|
||||
if (isset($obj->module) && ($oldmod <> $obj->module)) {
|
||||
$oldmod = $obj->module;
|
||||
|
||||
$j++;
|
||||
if (GETPOSTISSET('forbreakperms_'.$obj->module)) {
|
||||
$ishidden = GETPOST('forbreakperms_'.$obj->module, 'int');
|
||||
} elseif (in_array($j, $cookietohidegrouparray)) { // If j is among list of hidden group
|
||||
$ishidden = 1;
|
||||
} else {
|
||||
$ishidden = 0;
|
||||
}
|
||||
$isexpanded = ! $ishidden;
|
||||
//var_dump('$obj->module='.$obj->module.' isexpanded='.$isexpanded);
|
||||
|
||||
// Break detected, we get objMod
|
||||
$objMod = $modules[$obj->module];
|
||||
$picto = ($objMod->picto ? $objMod->picto : 'generic');
|
||||
|
||||
// Show break line
|
||||
print '<tr class="oddeven">';
|
||||
print '<td class="maxwidthonsmartphone tdoverflowonsmartphone trforbreakperms" data-hide-perms="'.$obj->module.'">';
|
||||
print '<input type="hidden" name="forbreakperms_'.$obj->module.'" id="idforbreakperms_'.$obj->module.'" value="'.($isexpanded ? '0' : "1").'">';
|
||||
print '<tr class="oddeven trforbreakperms" data-hide-perms="'.$obj->module.'" data-j="'.$j.'">';
|
||||
print '<td class="maxwidthonsmartphone tdoverflowonsmartphone tdforbreakperms" data-hide-perms="'.$obj->module.'">';
|
||||
print '<input type="hidden" name="forbreakperms_'.$obj->module.'" id="idforbreakperms_'.$obj->module.'" css="cssforfieldishiden" data-j="'.$j.'" value="'.($isexpanded ? '0' : "1").'">';
|
||||
print img_object('', $picto, 'class="pictoobjectwidth paddingright"').' '.$objMod->getName();
|
||||
print '<a name="'.$objMod->getName().'"></a>';
|
||||
print '</td>';
|
||||
@ -502,11 +519,11 @@ if ($result) {
|
||||
print ' / ';
|
||||
print '<a class="reposition alink addexpandedmodulesinparamlist" title="'.dol_escape_htmltag($langs->trans("None")).'" alt="'.dol_escape_htmltag($langs->trans("None")).'" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=delrights&token='.newToken().'&entity='.$entity.'&module='.$obj->module.'&confirm=yes&updatedmodulename='.$obj->module.'">'.$langs->trans("None")."</a>";
|
||||
print '</td>';
|
||||
print '<td class="permtoshow_'.$obj->module.' trforbreakperms" data-hide-perms="'.$obj->module.'"'.($isexpanded ? ' style="display:none"' : '').'> </td>';
|
||||
print '<td class="permtoshow_'.$obj->module.' tdforbreakperms" data-hide-perms="'.$obj->module.'"'.($isexpanded ? ' style="display:none"' : '').'> </td>';
|
||||
} else {
|
||||
print '<td class="trforbreakperms" data-hide-perms="'.$obj->module.'"> </td>';
|
||||
print '<td class="tdforbreakperms" data-hide-perms="'.$obj->module.'"> </td>';
|
||||
}
|
||||
print '<td class="trforbreakperms" data-hide-perms="'.$obj->module.'"> </td>';
|
||||
print '<td class="tdforbreakperms" data-hide-perms="'.$obj->module.'"> </td>';
|
||||
} else {
|
||||
if ($caneditperms) {
|
||||
print '<td class="center wraponsmartphone permtohide_'.$obj->module.'"'.(!$isexpanded ? ' style="display:none"' : '').'>';
|
||||
@ -515,15 +532,15 @@ if ($result) {
|
||||
print '<a class="reposition alink" title="'.dol_escape_htmltag($langs->trans("None")).'" alt="'.dol_escape_htmltag($langs->trans("None")).'" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=delrights&token='.newToken().'&entity='.$entity.'&module='.$obj->module.'&confirm=yes&updatedmodulename='.$obj->module.'">'.$langs->trans("None")."</a>";
|
||||
*/
|
||||
print '</td>';
|
||||
print '<td class="permtoshow_'.$obj->module.' trforbreakperms" data-hide-perms="'.$obj->module.'"'.($isexpanded ? ' style="display:none"' : '').'> </td>';
|
||||
print '<td class="permtoshow_'.$obj->module.' tdforbreakperms" data-hide-perms="'.$obj->module.'"'.($isexpanded ? ' style="display:none"' : '').'> </td>';
|
||||
} else {
|
||||
print '<td class="right trforbreakperms" data-hide-perms="'.$obj->module.'"></td>';
|
||||
print '<td class="right tdforbreakperms" data-hide-perms="'.$obj->module.'"></td>';
|
||||
}
|
||||
print '<td class="trforbreakperms" data-hide-perms="'.$obj->module.'"> </td>';
|
||||
print '<td class="tdforbreakperms" data-hide-perms="'.$obj->module.'"> </td>';
|
||||
}
|
||||
print '<td class="trforbreakperms" data-hide-perms="'.$obj->module.'"> </td>';
|
||||
print '<td class="tdforbreakperms" data-hide-perms="'.$obj->module.'"> </td>';
|
||||
|
||||
print '<td class="maxwidthonsmartphone right trforbreakperms" data-hide-perms="'.$obj->module.'">';
|
||||
print '<td class="maxwidthonsmartphone right tdforbreakperms" data-hide-perms="'.$obj->module.'">';
|
||||
print '<div class="switchfolderperms folderperms_'.$obj->module.'"'.($isexpanded ? ' style="display:none;"' : '').'>';
|
||||
print img_picto('', 'folder', 'class="marginright"');
|
||||
print '</div>';
|
||||
@ -640,69 +657,71 @@ print '</table>';
|
||||
print '</div>';
|
||||
|
||||
print '<script>';
|
||||
print '$(".trforbreakperms:not(.alink)").on("click", function(){
|
||||
console.log("Click on trforbreakperms");
|
||||
print '$(".tdforbreakperms:not(.alink)").on("click", function(){
|
||||
console.log("Click on tdforbreakperms");
|
||||
moduletohide = $(this).data("hide-perms");
|
||||
j = $(this).data("j");
|
||||
if ($("#idforbreakperms_"+moduletohide).val() == 1) {
|
||||
console.log("idforbreakperms_"+moduletohide+" to say if hidden was 1");
|
||||
console.log("idforbreakperms_"+moduletohide+" has value hidden=1");
|
||||
$(".trtohide_"+moduletohide).show();
|
||||
$(".permtoshow_"+moduletohide).hide();
|
||||
$(".permtohide_"+moduletohide).show();
|
||||
$(".folderperms_"+moduletohide).hide();
|
||||
$(".folderopenperms_"+moduletohide).show();
|
||||
$(this).data("hidden-perms", 0);
|
||||
$("#idforbreakperms_"+moduletohide).val("0");
|
||||
} else {
|
||||
console.log("idforbreakperms_"+moduletohide+" to say if hidden was 0");
|
||||
console.log("idforbreakperms_"+moduletohide+" has value hidden=0");
|
||||
$(".trtohide_"+moduletohide).hide();
|
||||
$(".folderopenperms_"+moduletohide).hide();
|
||||
$(".folderperms_"+moduletohide).show();
|
||||
$(".permtoshow_"+moduletohide).show();
|
||||
$(".permtohide_"+moduletohide).hide();
|
||||
$(this).data("hidden-perms", 1);
|
||||
$("#idforbreakperms_"+moduletohide).val("1");
|
||||
}
|
||||
});';
|
||||
print "\n";
|
||||
|
||||
|
||||
// addexpandedmodulesinparamlist
|
||||
print '$(".addexpandedmodulesinparamlist").on("click", function(){
|
||||
console.log("Click on a link with addexpandedmodulesinparamlist");
|
||||
//event.preventDefault();
|
||||
var oldUrl = $(this).attr("href"); // Get current url of clicked link
|
||||
oldUrl = oldUrl.replace(/expandedmodulesinparamlist=[\d,]+$/, "");
|
||||
oldurl = oldUrl.replace(/&&+/, "&");
|
||||
|
||||
// Build list of expanded modules
|
||||
|
||||
|
||||
var newUrl = oldUrl+"&expandedmodulesinparamlist=";
|
||||
$(this).attr("href", newUrl); // Set herf value
|
||||
console.log(newUrl);
|
||||
event.preventDefault();
|
||||
// Now rebuild the value for cookie
|
||||
var hideuserperm="";
|
||||
$(".trforbreakperms").each(function(index) {
|
||||
//console.log( index + ": " + $( this ).data("j") + " " + $( this ).data("hide-perms") + " " + $("input[data-j="+(index+1)+"]").val());
|
||||
if ($("input[data-j="+(index+1)+"]").val() == 1) {
|
||||
hideuserperm=hideuserperm+","+(index+1);
|
||||
}
|
||||
});
|
||||
// set cookie by js
|
||||
date = new Date(); date.setTime(date.getTime()+(30*86400000));
|
||||
if (hideuserperm) {
|
||||
console.log("set cookie DOLUSER_PERMS_HIDE_GRP="+hideuserperm);
|
||||
document.cookie = "DOLUSER_PERMS_HIDE_GRP=" + hideuserperm + "; expires=" + date.toGMTString() + "; path=/ ";
|
||||
} else {
|
||||
console.log("delete cookie DOLUSER_PERMS_HIDE_GRP");
|
||||
document.cookie = "DOLUSER_PERMS_HIDE_GRP=; expires=Thu, 01-Jan-70 00:00:01 GMT; path=/ ";
|
||||
}
|
||||
});';
|
||||
print "\n";
|
||||
|
||||
// Button expand / collapse all
|
||||
print '$(".showallperms").on("click", function(){
|
||||
console.log("Click on showallperms");
|
||||
$(".trforbreakperms").each( function(){
|
||||
|
||||
console.log("delete cookie DOLUSER_PERMS_HIDE_GRP from showallperms click");
|
||||
document.cookie = "DOLUSER_PERMS_HIDE_GRP=; expires=Thu, 01-Jan-70 00:00:01 GMT; path=/ ";
|
||||
$(".tdforbreakperms").each( function(){
|
||||
moduletohide = $(this).data("hide-perms");
|
||||
console.log(moduletohide);
|
||||
//console.log(moduletohide);
|
||||
if ($("#idforbreakperms_"+moduletohide).val() != 0) {
|
||||
$(this).trigger("click");
|
||||
$(this).trigger("click"); // emulate the click, so the cooki will be resaved
|
||||
}
|
||||
})
|
||||
});
|
||||
|
||||
$(".hideallperms").on("click", function(){
|
||||
console.log("Click on hideallperms");
|
||||
$(".trforbreakperms").each( function(){
|
||||
|
||||
$(".tdforbreakperms").each( function(){
|
||||
moduletohide = $(this).data("hide-perms");
|
||||
console.log(moduletohide);
|
||||
//console.log(moduletohide);
|
||||
if ($("#idforbreakperms_"+moduletohide).val() != 1) {
|
||||
$(this).trigger("click");
|
||||
$(this).trigger("click"); // emulate the click, so the cooki will be resaved
|
||||
}
|
||||
})
|
||||
});';
|
||||
|
||||
Loading…
Reference in New Issue
Block a user