From 80ce8da7a388f157beb81e46ed465b952004a857 Mon Sep 17 00:00:00 2001
From: Laurent Destailleur <eldy@destailleur.fr>
Date: Tue, 23 May 2017 15:13:52 +0200
Subject: [PATCH] Fix migration errors and responsive design

---
 htdocs/contrat/card.php                       | 67 ++++++++++---------
 htdocs/core/class/html.formactions.class.php  |  5 +-
 htdocs/install/default.css                    |  6 +-
 .../install/mysql/migration/5.0.0-6.0.0.sql   | 17 +++++
 .../mysql/tables/llx_opensurvey_sondage.sql   |  2 +-
 htdocs/install/step5.php                      |  8 +--
 htdocs/theme/eldy/style.css.php               |  2 +-
 htdocs/theme/md/style.css.php                 | 17 +++--
 8 files changed, 72 insertions(+), 52 deletions(-)

diff --git a/htdocs/contrat/card.php b/htdocs/contrat/card.php
index f00816e9d4b..31e5d6f3094 100644
--- a/htdocs/contrat/card.php
+++ b/htdocs/contrat/card.php
@@ -2083,44 +2083,45 @@ else
 
             print "</div>";
         }
-	// Select mail models is same action as presend
-	if (GETPOST('modelselected')) {
-		$action = 'presend';
-	}
-
-	if ($action != 'presend')
-	{
-		print '<div class="fichecenter"><div class="fichehalfleft">';
-
-		/*
-		 * Documents generes
-		*/
-		$filename = dol_sanitizeFileName($object->ref);
-		$filedir = $conf->contrat->dir_output . "/" . dol_sanitizeFileName($object->ref);
-		$urlsource = $_SERVER["PHP_SELF"] . "?id=" . $object->id;
-		$genallowed = $user->rights->contrat->creer;
-		$delallowed = $user->rights->contrat->supprimer;
-
-		$var = true;
-
-		print $formfile->showdocuments('contract', $filename, $filedir, $urlsource, $genallowed, $delallowed, $object->modelpdf, 1, 0, 0, 28, 0, '', 0, '', $soc->default_lang);
-
-
-			// Show links to link elements
-			$linktoelem = $form->showLinkToObjectBlock($object, null, array('contrat'));
-			$somethingshown = $form->showLinkedObjectBlock($object, $linktoelem);
-
-
-		print '</div><div class="fichehalfright"><div class="ficheaddleft">';
-
+        
+    	// Select mail models is same action as presend
+    	if (GETPOST('modelselected')) {
+    		$action = 'presend';
+    	}
+    
+    	if ($action != 'presend')
+    	{
+    		print '<div class="fichecenter"><div class="fichehalfleft">';
+    
+    		/*
+    		 * Documents generes
+    		*/
+    		$filename = dol_sanitizeFileName($object->ref);
+    		$filedir = $conf->contrat->dir_output . "/" . dol_sanitizeFileName($object->ref);
+    		$urlsource = $_SERVER["PHP_SELF"] . "?id=" . $object->id;
+    		$genallowed = $user->rights->contrat->creer;
+    		$delallowed = $user->rights->contrat->supprimer;
+    
+    		$var = true;
+    
+    		print $formfile->showdocuments('contract', $filename, $filedir, $urlsource, $genallowed, $delallowed, $object->modelpdf, 1, 0, 0, 28, 0, '', 0, '', $soc->default_lang);
+    
+    
+    			// Show links to link elements
+    			$linktoelem = $form->showLinkToObjectBlock($object, null, array('contrat'));
+    			$somethingshown = $form->showLinkedObjectBlock($object, $linktoelem);
+    
+    
+    		print '</div><div class="fichehalfright"><div class="ficheaddleft">';
+    
 			// List of actions on element
 			include_once DOL_DOCUMENT_ROOT . '/core/class/html.formactions.class.php';
 			$formactions = new FormActions($db);
 			$somethingshown = $formactions->showactions($object, 'contract', $socid);
 
-
-		print '</div></div></div>';
-	}
+    
+    		print '</div></div></div>';
+    	}
 
 		/*
 		 * Action presend
diff --git a/htdocs/core/class/html.formactions.class.php b/htdocs/core/class/html.formactions.class.php
index 452ff89d914..456faa7931e 100644
--- a/htdocs/core/class/html.formactions.class.php
+++ b/htdocs/core/class/html.formactions.class.php
@@ -189,7 +189,9 @@ class FormActions
 
         	$page=0; $param=''; $sortfield='a.datep';
         	
-        	$total = 0;	$var=true; 
+        	$total = 0; 
+        	
+        	print '<div class="div-table-responsive">';
         	print '<table class="noborder'.($morecss?' '.$morecss:'').'" width="100%">';
         	print '<tr class="liste_titre">';
         	print_liste_field_titre($langs->trans('Ref'), $_SERVER["PHP_SELF"], '', $page, $param, '');
@@ -243,6 +245,7 @@ class FormActions
         		print '</tr>';
         	}
         	print '</table>';
+        	print '</div>';
         }
 
         return $num;
diff --git a/htdocs/install/default.css b/htdocs/install/default.css
index 9725b06b8bc..b3905e63a49 100644
--- a/htdocs/install/default.css
+++ b/htdocs/install/default.css
@@ -54,9 +54,9 @@ span.titre {
 	font-weight: bold;
 	background: #FFFFFF;
 	color: #444;
-	border: 1px solid #999;
-	padding: 5px 5px 5px 5px;
-	margin: 0 0 0 15px;
+	border: 1px solid #bbb;
+	padding: 10px 10px 10px 10px;
+	margin: 0 0 10px 10px;
 }
 
 div.soustitre {
diff --git a/htdocs/install/mysql/migration/5.0.0-6.0.0.sql b/htdocs/install/mysql/migration/5.0.0-6.0.0.sql
index 0bd68ddfcfb..a21c340b556 100644
--- a/htdocs/install/mysql/migration/5.0.0-6.0.0.sql
+++ b/htdocs/install/mysql/migration/5.0.0-6.0.0.sql
@@ -25,6 +25,23 @@
 -- -- VMYSQL4.1 DELETE FROM llx_usergroup_user      WHERE fk_usergroup NOT IN (SELECT rowid from llx_usergroup);
 
 
+-- Clean corrupted values for tms
+-- VMYSQL4.1 SET sql_mode = 'ALLOW_INVALID_DATES';
+-- VMYSQL4.1 update llx_opensurvey_sondage set tms = date_fin where DATE(STR_TO_DATE(tms, '%Y-%m-%d')) IS NULL;
+-- VMYSQL4.1 SET sql_mode = 'NO_ZERO_DATE';
+-- VMYSQL4.1 update llx_opensurvey_sondage set tms = date_fin where DATE(STR_TO_DATE(tms, '%Y-%m-%d')) IS NULL;
+-- Remove default not null on date_fin
+-- VMYSQL4.3 ALTER TABLE llx_opensurvey_sondage MODIFY COLUMN date_fin DATETIME NULL DEFAULT NULL;
+-- VPGSQL8.2 ALTER TABLE llx_opensurvey_sondage ALTER COLUMN date_fin DROP NOT NULL;
+
+ALTER TABLE llx_opensurvey_sondage MODIFY COLUMN tms timestamp DEFAULT CURRENT_TIMESTAMP;
+
+ALTER TABLE llx_opensurvey_sondage ADD COLUMN fk_user_creat integer NOT NULL DEFAULT 0;
+ALTER TABLE llx_opensurvey_sondage ADD COLUMN status integer DEFAULT 1 after date_fin;
+ALTER TABLE llx_opensurvey_sondage ADD COLUMN entity integer DEFAULT 1 NOT NULL;
+ALTER TABLE llx_opensurvey_sondage ADD COLUMN allow_comments tinyint NOT NULL DEFAULT 1;
+
+
 create table llx_notify_def_object
 (
   id				integer AUTO_INCREMENT PRIMARY KEY,
diff --git a/htdocs/install/mysql/tables/llx_opensurvey_sondage.sql b/htdocs/install/mysql/tables/llx_opensurvey_sondage.sql
index 5ea2183758a..e9b2481757d 100644
--- a/htdocs/install/mysql/tables/llx_opensurvey_sondage.sql
+++ b/htdocs/install/mysql/tables/llx_opensurvey_sondage.sql
@@ -23,7 +23,7 @@ CREATE TABLE llx_opensurvey_sondage (
 	nom_admin VARCHAR(64),
 	fk_user_creat integer NOT NULL,
 	titre TEXT NOT NULL,
-	date_fin DATETIME NOT NULL,
+	date_fin DATETIME NULL,
     status integer DEFAULT 1,
 	format VARCHAR(2) NOT NULL,                 -- 'A' = Text choice (choices are saved into sujet field), 'D' = Date choice (choices are saved into sujet field), 'F' = Form survey
 	mailsonde tinyint NOT NULL DEFAULT 0,
diff --git a/htdocs/install/step5.php b/htdocs/install/step5.php
index 96cc1c4fdcf..875fd9378f2 100644
--- a/htdocs/install/step5.php
+++ b/htdocs/install/step5.php
@@ -1,6 +1,6 @@
 <?php
 /* Copyright (C) 2004       Rodolphe Quiedeville    <rodolphe@quiedeville.org>
- * Copyright (C) 2004-2012  Laurent Destailleur     <eldy@users.sourceforge.net>
+ * Copyright (C) 2004-2017  Laurent Destailleur     <eldy@users.sourceforge.net>
  * Copyright (C) 2004       Benoit Mortier          <benoit.mortier@opensides.be>
  * Copyright (C) 2004       Sebastien DiCintio      <sdicintio@ressource-toi.org>
  * Copyright (C) 2005-2012  Regis Houssin           <regis.houssin@capnetworks.com>
@@ -395,11 +395,11 @@ elseif (empty($action) || preg_match('/upgrade/i',$action))
             print '<br><div class="warning">'.$langs->trans("WarningRemoveInstallDir")."</div>";
         }
 
-        print "<br>";
+        print "<br><br>";
 
         print '<div class="center"><a href="../index.php?mainmenu=home' . (isset($login) ? '&username=' . urlencode($login) : '') . '">';
-        print $langs->trans("GoToDolibarr");
-        print '</a></div>';
+        print $langs->trans("GoToDolibarr").'...';
+        print '</a></div><br>';
     }
     else
     {
diff --git a/htdocs/theme/eldy/style.css.php b/htdocs/theme/eldy/style.css.php
index b8f31b4e224..a8eddcd825f 100644
--- a/htdocs/theme/eldy/style.css.php
+++ b/htdocs/theme/eldy/style.css.php
@@ -698,7 +698,7 @@ div.fiche>form>div.div-table-responsive {
     justify-content: flex-start;
 }
 .thumbstat {
-	flex: 1 1 114px;
+	flex: 1 1 116px;
 }
 .thumbstat150 {
 	flex: 1 1 170px;
diff --git a/htdocs/theme/md/style.css.php b/htdocs/theme/md/style.css.php
index 91a4c0922d9..943540fa02f 100644
--- a/htdocs/theme/md/style.css.php
+++ b/htdocs/theme/md/style.css.php
@@ -544,7 +544,7 @@ textarea.centpercent {
 .cursorpointer {
 	cursor: pointer;
 }
-.cusormove {
+.cursormove {
 	cursor: move;
 }
 .badge {
@@ -701,7 +701,7 @@ div.fiche>form>div.div-table-responsive {
     justify-content: flex-start;
 }
 .thumbstat {
-	flex: 1 1 114px;
+	flex: 1 1 116px;
 }
 .thumbstat150 {
 	flex: 1 1 150px;
@@ -1979,9 +1979,10 @@ div.tabsElem { margin-top: 6px; }		/* To avoid overlap of tabs when not browser
 
 div.tabBar {
     color: #<?php echo $colortextbacktab; ?>;
-    padding-top: <?php echo ($dol_optimize_smallscreen?'4':'16'); ?>px;
-    padding-left: <?php echo ($dol_optimize_smallscreen?'4':'16'); ?>px;
-    padding-right: <?php echo ($dol_optimize_smallscreen?'4':'16'); ?>px;
+    padding-top: 16px;
+    padding-left: 16px;
+    padding-right: 16px;
+	padding-bottom: 16px;
     margin: 0px 0px 16px 0px;
     -moz-border-radius:3px;
     -webkit-border-radius: 3px;
@@ -1991,8 +1992,6 @@ div.tabBar {
     border-top: 1px solid #CCC;
 	width: auto;
 	background: rgb(<?php echo $colorbacktabcard1; ?>);
-
-	padding-bottom: 12px;
 	border-bottom: 1px solid #aaa; 
 }
 div.tabBar div.titre {
@@ -4627,8 +4626,8 @@ border-top-right-radius: 6px;
 	}
 
     div.tabBar {
-        padding-left: 0px;
-        padding-right: 0px;
+        padding-left: 8px;
+        padding-right: 8px;
         -moz-border-radius: 0;
         -webkit-border-radius: 0;
     	border-radius: 0px;
-- 
GitLab