Skip to content

Commit

Permalink
fix(Menu) correct sql updates for reordering. fixes #356
Browse files Browse the repository at this point in the history
  • Loading branch information
joebordes committed Jan 30, 2017
1 parent 362be97 commit d0be9ad
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion modules/evvtMenu/Save.php
Expand Up @@ -88,8 +88,15 @@ function delMenuBranch($topofbranch) {
$id = $ids[$i];
$parent = $parents[$i];
$position = $positions[$i];
$rs = $adb->pquery('select mseq from vtiger_evvtmenu WHERE evvtmenuid=?', array($id));
$currentseq = $adb->query_result($rs, 0, 0);
if ($currentseq<$position) {
$adb->pquery('update vtiger_evvtmenu set mseq = mseq - 1 WHERE mparent=? AND mseq <= ? AND evvtmenuid <> ?', array($parent, $position, $id));
}
$adb->pquery('update vtiger_evvtmenu set mparent=?, mseq=? WHERE evvtmenuid=?', array($parent, $position, $id));
$adb->pquery('update vtiger_evvtmenu set mseq = mseq + 1 WHERE mparent=? AND mseq >= ? AND evvtmenuid <> ?', array($parent, $position, $id));
if ($currentseq>$position) {
$adb->pquery('update vtiger_evvtmenu set mseq = mseq + 1 WHERE mparent=? AND mseq >= ? AND evvtmenuid <> ?', array($parent, $position, $id));
}
}
break;
}
Expand Down

0 comments on commit d0be9ad

Please sign in to comment.