diff --git a/build/rpm/dolibarr_generic.spec b/build/rpm/dolibarr_generic.spec
index 8a9d4de92fb5cc9e69a9efc1bc6fb18c996b5953..1b0ac324962017f1f2e96009bdfefc6af7ac5ce7 100755
--- a/build/rpm/dolibarr_generic.spec
+++ b/build/rpm/dolibarr_generic.spec
@@ -305,6 +305,11 @@ done >>%{name}.lang
 %post
 
 echo Run post script of packager dolibarr_generic.spec
+echo Detected constant fedora=0%{?fedora}
+echo Detected constant rhel_version=0%{?rhel_version}
+echo Detected constant centos_version=0%{?centos_version}
+echo Detected constant mdkversion=0%{?mdkversion}
+echo Detected constant suse_version=0%{?suse_version}
 
 # Define vars
 export docdir="/var/lib/dolibarr/documents"
@@ -465,9 +470,12 @@ echo Restart mysql server
 %else
 %if 0%{?suse_version}
 if [ -f /etc/init.d/mysqld ]; then
-  /etc/init.d/mysqld restart
-else
+  /sbin/service mysqld restart
+  #/etc/init.d/mysqld restart
+fi
+if [ -f /etc/init.d/mysql ]; then
   /sbin/service mysql restart
+  #/etc/init.d/mysql restart
 fi
 %else
 if [ -f /etc/init.d/mysqld ]; then
diff --git a/build/rpm/dolibarr_opensuse.spec b/build/rpm/dolibarr_opensuse.spec
index ae1f1668bd571f78068efe2d06451895e573b357..7e5e21e009d716be2d0b5f907fed5a7ea1d47e2c 100755
--- a/build/rpm/dolibarr_opensuse.spec
+++ b/build/rpm/dolibarr_opensuse.spec
@@ -289,8 +289,9 @@ fi
 # Restart mysql
 echo Restart mysql
 if [ -f /etc/init.d/mysqld ]; then
-  /etc/init.d/mysqld restart
-else
+  /sbin/service mysqld restart
+fi
+if [ -f /etc/init.d/mysql ]; then
   /sbin/service mysql restart
 fi
 
diff --git a/htdocs/categories/class/categorie.class.php b/htdocs/categories/class/categorie.class.php
index 81ea914e481aa260cbf1d0d025047a639fe30ce3..dbbfc83b8eada565334221134e201efd0b8b973c 100644
--- a/htdocs/categories/class/categorie.class.php
+++ b/htdocs/categories/class/categorie.class.php
@@ -292,6 +292,20 @@ class Categorie
 
 		$this->db->begin();
 
+		/* FIX #1317 : Check for child cat and move up 1 level*/
+		if (! $error)
+		{
+			$sql = "UPDATE ".MAIN_DB_PREFIX."categorie";
+			$sql.= " SET fk_parent = ".$this->fk_parent; 
+			$sql.= " WHERE fk_parent = ".$this->id;
+
+			if (!$this->db->query($sql))
+			{
+				$this->error=$this->db->lasterror();
+				dol_syslog("Error sql=".$sql." ".$this->error, LOG_ERR);
+				$error++;
+			}
+		}
 		if (! $error)
 		{
 			$sql  = "DELETE FROM ".MAIN_DB_PREFIX."categorie_societe";
diff --git a/htdocs/core/lib/company.lib.php b/htdocs/core/lib/company.lib.php
index b6e8e4c6786710b092d269c33bd6774ddc2adc23..68f124f7a88acd2dbad00d6ab82e2a8d9951a0b3 100644
--- a/htdocs/core/lib/company.lib.php
+++ b/htdocs/core/lib/company.lib.php
@@ -775,15 +775,14 @@ function show_contacts($conf,$langs,$db,$object,$backtopage='')
 <div id="dialog" title="<?php echo dol_escape_htmltag($langs->trans('Address')); ?>" style="display: none;"></div>
 <?php
 	print '<script type="text/javascript">
-	$("#dialog").dialog()
-			function copyToClipboard (text) {
+		function copyToClipboard (text) {
 			  text = text.replace(/<br \/>/g,"\n");
 			  var newElem = "<textarea id=\"coords\" style=\"border: none; width: 90%; height: 120px;\">"+text+"</textarea><br/><br/>'.$langs->trans('HelpCopyToClipboard').'";
 			  $("#dialog").html(newElem);
 			  $("#dialog").dialog();
 			  $("#coords").select();
 			  return false;
-			}
+		}
 	</script>';
 
     return $i;