diff --git a/htdocs/contact/card.php b/htdocs/contact/card.php
index 37bd3078c7d2f38d463d8d7bbfc8686c242f1e9d..7d95da69aef0319447f2b2cae054c7b1b635707e 100644
--- a/htdocs/contact/card.php
+++ b/htdocs/contact/card.php
@@ -714,6 +714,11 @@ else
                 print '     ';
                 print '<input type="submit" class="button" name="cancel" value="'.$langs->trans("Cancel").'">';
             }
+            else
+            {
+                print ' &nbsp; &nbsp; ';
+                print '<input type="button" class="button" value="' . $langs->trans("Cancel") . '" onClick="javascript:history.go(-1)">';
+            }
             print '</div>';
 
             print "</form>";
@@ -997,7 +1002,7 @@ else
 
             print '<div class="center">';
             print '<input type="submit" class="button" name="save" value="'.$langs->trans("Save").'">';
-            print '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
+            print ' &nbsp; &nbsp; ';
             print '<input type="submit" class="button" name="cancel" value="'.$langs->trans("Cancel").'">';
             print '</div>';
 
@@ -1229,33 +1234,7 @@ else
         }
 
         print "</div>";
-        //print "<br>";
 
-        /*
-		if (! empty($conf->agenda->enabled))
-		{
-			$objthirdparty=$objsoc;
-			$objcon=$object;
-
-		    $out='';
-		    $permok=$user->rights->agenda->myactions->create;
-		    if ((! empty($objthirdparty->id) || ! empty($objcon->id)) && $permok)
-		    {
-		        $out.='<a href="'.DOL_URL_ROOT.'/comm/action/card.php?action=create';
-		        if (get_class($objthirdparty) == 'Societe') $out.='&amp;socid='.$objthirdparty->id;
-		        $out.=(! empty($objcon->id)?'&amp;contactid='.$objcon->id:'').'&amp;backtopage=1&amp;percentage=-1">';
-		    	$out.=$langs->trans("AddAnAction").' ';
-		    	$out.=img_picto($langs->trans("AddAnAction"),'filenew');
-		    	$out.="</a>";
-			}
-
-        	print load_fiche_titre($langs->trans("TasksHistoryForThisContact"),$out,'');
-
-        	//print show_actions_todo($conf,$langs,$db,$objsoc,$object);
-
-        	print show_actions_done($conf,$langs,$db,$objsoc,$object,0,'','');
-		}
-		*/
     }
 }
 
diff --git a/htdocs/core/class/html.formprojet.class.php b/htdocs/core/class/html.formprojet.class.php
index 6e5284aaab31925b3407ca7183b32d3e41f8f691..ffce8300a0c7e986d9356902bfd353a058049a3f 100644
--- a/htdocs/core/class/html.formprojet.class.php
+++ b/htdocs/core/class/html.formprojet.class.php
@@ -566,9 +566,10 @@ class FormProjets
 	 *    @param   int         $useshortlabel      Use short label
 	 *    @param   int         $showallnone        Add choice "All" and "None"
 	 *    @param   int         $showpercent        Show default probability for status
+	 *    @param   string      $morecss            Add more css
 	 *    @return  int|string                      The HTML select list of element or '' if nothing or -1 if KO
 	 */
-	function selectOpportunityStatus($htmlname, $preselected='-1', $showempty=1, $useshortlabel=0, $showallnone=0, $showpercent=0)
+	function selectOpportunityStatus($htmlname, $preselected='-1', $showempty=1, $useshortlabel=0, $showallnone=0, $showpercent=0, $morecss='')
 	{
 		global $conf, $langs;
 
@@ -584,7 +585,7 @@ class FormProjets
 			$i = 0;
 			if ($num > 0)
 			{
-				$sellist = '<select class="flat oppstatus" id="'.$htmlname.'" name="'.$htmlname.'">';
+				$sellist = '<select class="flat oppstatus'.($morecss?' '.$morecss:'').'" id="'.$htmlname.'" name="'.$htmlname.'">';
 				if ($showempty) $sellist.= '<option value="-1"></option>';
 				if ($showallnone) $sellist.= '<option value="all"'.($preselected == 'all'?' selected="selected"':'').'>--'.$langs->trans("OnlyOpportunitiesShort").'--</option>';
 				if ($showallnone) $sellist.= '<option value="openedopp"'.($preselected == 'openedopp'?' selected="selected"':'').'>--'.$langs->trans("OpenedOpportunitiesShort").'--</option>';
diff --git a/htdocs/langs/en_US/projects.lang b/htdocs/langs/en_US/projects.lang
index 1defe9d9163e7bc8f008314e4d29d0fb75bf0a5f..8e40307cac68df6f6d5c181aaa725c226afe0299 100644
--- a/htdocs/langs/en_US/projects.lang
+++ b/htdocs/langs/en_US/projects.lang
@@ -96,6 +96,7 @@ ValidateProject=Validate projet
 ConfirmValidateProject=Are you sure you want to validate this project?
 CloseAProject=Close project
 ConfirmCloseAProject=Are you sure you want to close this project?
+AlsoCloseAProject=Also close project (keep it open if you still need to follow production tasks on it)
 ReOpenAProject=Open project
 ConfirmReOpenAProject=Are you sure you want to re-open this project?
 ProjectContact=Project contacts
diff --git a/htdocs/product/card.php b/htdocs/product/card.php
index ade5916792d71982060fec7dbe41dcae7ad0fe56..e8d86bbdbf20c2e638b123f9a2ee3489283749de 100644
--- a/htdocs/product/card.php
+++ b/htdocs/product/card.php
@@ -1149,7 +1149,7 @@ else
 
 		print '<div class="center">';
 		print '<input type="submit" class="button" value="' . $langs->trans("Create") . '">';
-		print '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
+        print ' &nbsp; &nbsp; ';
 		print '<input type="button" class="button" value="' . $langs->trans("Cancel") . '" onClick="javascript:history.go(-1)">';
 		print '</div>';
 
diff --git a/htdocs/projet/card.php b/htdocs/projet/card.php
index 71f2dcd02c9cde75b824156f072bc8474e4fdbe4..6221e4c2b8777c0b1b1b8b65afed0822d1094984 100644
--- a/htdocs/projet/card.php
+++ b/htdocs/projet/card.php
@@ -286,11 +286,23 @@ if (empty($reshook))
 	    		if ($result < 0)
 	    		{
 	    			$error++;
-				    setEventMessages($langs->trans("ErrorShiftTaskDate").':'.$object->error, $langs->trans("ErrorShiftTaskDate").':'.$object->errors, 'errors');
+				    setEventMessages($langs->trans("ErrorShiftTaskDate").':'.$object->error, $object->errors, 'errors');
 	    		}
 	    	}
 	    }
 
+		// Check if we must change status
+	    if (GETPOST('closeproject'))
+	    {
+	        $resclose = $object->setClose($user);
+	        if ($resclose < 0)
+	        {
+	            $error++;
+			    setEventMessages($langs->trans("FailedToCloseProject").':'.$object->error, $object->errors, 'errors');
+	        }
+	    }
+	    
+	    
 	    if ($error)
 	    {
 			$db->rollback();
@@ -303,6 +315,7 @@ if (empty($reshook))
 			if (GETPOST('socid','int') > 0) $object->fetch_thirdparty(GETPOST('socid','int'));
 			else unset($object->thirdparty);
 	    }
+	    
 	}
 
 	// Build doc
@@ -594,6 +607,11 @@ if ($action == 'create' && $user->rights->projet->creer)
         print ' &nbsp; &nbsp; ';
 	    print '<input type="submit" class="button" name="cancel" value="'.$langs->trans("Cancel").'">';
     }
+    else
+    {
+        print ' &nbsp; &nbsp; ';
+        print '<input type="button" class="button" value="' . $langs->trans("Cancel") . '" onClick="javascript:history.go(-1)">';
+    }    
     print '</div>';
 
     print '</form>';
@@ -730,7 +748,11 @@ elseif ($object->id > 0)
 	        // Opportunity status
 		    print '<tr><td>'.$langs->trans("OpportunityStatus").'</td>';
 	    	print '<td>';
-		    print $formproject->selectOpportunityStatus('opp_status', $object->opp_status, 1);
+		    print $formproject->selectOpportunityStatus('opp_status', $object->opp_status, 1, 0, 0, 0, 'inline-block valignmiddle');
+		    print '<div id="divtocloseproject" class="inline-block valign" style="display: none;"> &nbsp; &nbsp; ';
+		    print '<input type="checkbox" id="inputcloseproject" name="closeproject" /> ';
+		    print $langs->trans("AlsoCloseAProject");
+		    print '</div>';
 		    print '</td>';
 		    print '</tr>';
 
@@ -843,12 +865,12 @@ elseif ($object->id > 0)
 
 	        // Opportunity percent
 	        print '<tr><td>'.$langs->trans("OpportunityProbability").'</td><td>';
-	        if (strcmp($object->opp_percent,'')) print price($object->opp_percent,'',$langs,1,0).' %';
+	        if (strcmp($object->opp_percent,'')) print price($object->opp_percent,0,$langs,1,0).' %';
 	        print '</td></tr>';
 
 	        // Opportunity Amount
 	        print '<tr><td>'.$langs->trans("OpportunityAmount").'</td><td>';
-	        if (strcmp($object->opp_amount,'')) print price($object->opp_amount,'',$langs,1,0,0,$conf->currency);
+	        if (strcmp($object->opp_amount,'')) print price($object->opp_amount,0,$langs,1,0,0,$conf->currency);
 	        print '</td></tr>';
 	    }
     
@@ -865,7 +887,7 @@ elseif ($object->id > 0)
     	     
         // Budget
         print '<tr><td>'.$langs->trans("Budget").'</td><td>';
-        if (strcmp($object->budget_amount, '')) print price($object->budget_amount,'',$langs,1,0,0,$conf->currency);
+        if (strcmp($object->budget_amount, '')) print price($object->budget_amount,0,$langs,1,0,0,$conf->currency);
         print '</td></tr>';
 
         // Other attributes
@@ -915,27 +937,49 @@ elseif ($object->id > 0)
     print '</form>';
 
     // Change probability from status
-    if (! empty($conf->use_javascript_ajax))
+    if (! empty($conf->use_javascript_ajax) && ! empty($conf->global->PROJECT_USE_OPPORTUNITIES))
     {
+        $defaultcheckedwhenoppclose=1;
+        if (empty($conf->global->PROJECT_HIDE_TASKS)) $defaultcheckedwhenoppclose=0;
+        
+        print '<!-- Javascript to manage opportunity status change -->';
         print '<script type="text/javascript" language="javascript">
-        jQuery(document).ready(function() {
-        	function change_percent()
-        	{
-                var element = jQuery("#opp_status option:selected");
-                var defaultpercent = element.attr("defaultpercent");
-                var elemcode = element.attr("elemcode");
-                /* Change percent of default percent of new status is higher */
-                if (parseFloat(jQuery("#opp_percent").val()) != parseFloat(defaultpercent))
-                {
-                    if (jQuery("#opp_percent").val() != \'\' && ! jQuery("#oldopppercent").text()) jQuery("#oldopppercent").text(\' - '.dol_escape_js($langs->transnoentities("PreviousValue")).': \'+jQuery("#opp_percent").val()+\' %\');
-                    jQuery("#opp_percent").val(defaultpercent);
-
-                }
-        	}
-        	/*init_myfunc();*/
-        	jQuery("#opp_status").change(function() {
-        		change_percent();
-        	});
+            jQuery(document).ready(function() {
+            	function change_percent()
+            	{
+                    var element = jQuery("#opp_status option:selected");
+                    var defaultpercent = element.attr("defaultpercent");
+                    var defaultcloseproject = '.$defaultcheckedwhenoppclose.';
+                    var elemcode = element.attr("elemcode");
+                    var oldpercent = \''.dol_escape_js($object->opp_percent).'\';
+
+                    console.log("We select "+elemcode);
+                    if (elemcode == \'LOST\') defaultcloseproject = 1;
+                    jQuery("#divtocloseproject").show();
+                    if (defaultcloseproject) jQuery("#inputcloseproject").prop("checked", true);
+                    else jQuery("#inputcloseproject").prop("checked", false);
+                        
+                    /* Make close project visible or not */
+                    if (elemcode == \'WON\' || elemcode == \'LOST\') 
+                    {
+                        jQuery("#divtocloseproject").show();
+                    }
+                    else
+                    {
+                        jQuery("#divtocloseproject").hide();
+                    }
+                        
+                    /* Change percent of default percent of new status is higher */
+                    if (parseFloat(jQuery("#opp_percent").val()) != parseFloat(defaultpercent))
+                    {
+                        if (jQuery("#opp_percent").val() != \'\' && oldpercent != \'\') jQuery("#oldopppercent").text(\' - '.dol_escape_js($langs->transnoentities("PreviousValue")).': \'+oldpercent+\' %\');
+                        jQuery("#opp_percent").val(defaultpercent);
+                    }
+            	}
+
+            	jQuery("#opp_status").change(function() {
+            		change_percent();
+            	});
         });
         </script>';
     }
diff --git a/htdocs/projet/class/project.class.php b/htdocs/projet/class/project.class.php
index 460e698e432dd796515af97545c07a928a9b68f5..b242f7d6b0698ec20126b7966fe31880039db4bd 100644
--- a/htdocs/projet/class/project.class.php
+++ b/htdocs/projet/class/project.class.php
@@ -773,7 +773,7 @@ class Project extends CommonObject
      * 		Close a project
      *
      * 		@param		User	$user		User that close project
-     * 		@return		int					<0 if KO, >0 if OK
+     * 		@return		int					<0 if KO, 0 if already closed, >0 if OK
      */
     function setClose($user)
     {
@@ -828,6 +828,8 @@ class Project extends CommonObject
                 return -1;
             }
         }
+        
+        return 0;
     }
 
     /**
diff --git a/htdocs/societe/soc.php b/htdocs/societe/soc.php
index 374a87c72effbc4c9655428238873a9c1e49c96e..3da099390ac942e5d00af317fc775749adb3578d 100644
--- a/htdocs/societe/soc.php
+++ b/htdocs/societe/soc.php
@@ -1308,11 +1308,16 @@ else
 
         print '<div class="center">';
         print '<input type="submit" class="button" name="create" value="'.$langs->trans('AddThirdParty').'">';
-        if ($backtopage)
+        if (! empty($backtopage))
         {
-            print ' &nbsp; ';
+            print ' &nbsp; &nbsp; ';
             print '<input type="submit" class="button" name="cancel" value="'.$langs->trans('Cancel').'">';
         }
+        else
+        {
+            print ' &nbsp; &nbsp; ';
+            print '<input type="button" class="button" value="' . $langs->trans("Cancel") . '" onClick="javascript:history.go(-1)">';
+        }
         print '</div>'."\n";
 
         print '</form>'."\n";
@@ -1898,7 +1903,7 @@ else
 
             print '<div align="center">';
             print '<input type="submit" class="button" name="save" value="'.$langs->trans("Save").'">';
-            print '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
+            print ' &nbsp; &nbsp; ';
             print '<input type="submit" class="button" name="cancel" value="'.$langs->trans("Cancel").'">';
             print '</div>';