Permalink
Browse files

Fix: Reorder boxes

  • Loading branch information...
eldy committed Mar 28, 2012
1 parent eb9bee1 commit 3e7136459f74219c9074ae9048e615234992775c
Showing with 15 additions and 4 deletions.
  1. +15 −4 htdocs/admin/boxes.php
View
@@ -169,14 +169,25 @@
$objto=new ModeleBoxes($db);
$objto->fetch($_GET["switchto"]);
+ $resultupdatefrom=0;
+ $resultupdateto=0;
if (is_object($objfrom) && is_object($objto))
{
- $sql="UPDATE ".MAIN_DB_PREFIX."boxes set box_order='".$objto->box_order."' WHERE rowid=".$objfrom->rowid;
- //print "xx".$sql;
+ $newfirst=$objto->box_order;
+ $newsecond=$objfrom->box_order;
+ if ($newfirst == $newsecond)
+ {
+ $newsecondchar=preg_replace('/[0-9]+/','',$newsecond);
+ $newsecondnum=preg_replace('/[a-zA-Z]+/','',$newsecond);
+ $newsecond=sprintf("%s%02d",$newsecondchar?$newsecondchar:'A',$newsecondnum+1);
+ }
+ $sql="UPDATE ".MAIN_DB_PREFIX."boxes set box_order='".$newfirst."' WHERE rowid=".$objfrom->rowid;
+ dol_syslog($sql);
$resultupdatefrom = $db->query($sql);
if (! $resultupdatefrom) { dol_print_error($db); }
- $sql="UPDATE ".MAIN_DB_PREFIX."boxes set box_order='".$objfrom->box_order."' WHERE rowid=".$objto->rowid;
- //print "xx".$sql;
+
+ $sql="UPDATE ".MAIN_DB_PREFIX."boxes set box_order='".$newsecond."' WHERE rowid=".$objto->rowid;
+ dol_syslog($sql);
$resultupdateto = $db->query($sql);
if (! $resultupdateto) { dol_print_error($db); }
}

0 comments on commit 3e71364

Please sign in to comment.