From f1ec2c04ed73b990db6d7f54e9e9c90973cc1b52 Mon Sep 17 00:00:00 2001
From: Laurent Destailleur <eldy@destailleur.fr>
Date: Fri, 28 Oct 2016 18:40:26 +0200
Subject: [PATCH] Uniformize code

---
 htdocs/comm/propal/card.php        |   2 +-
 htdocs/comm/propal/contact.php     | 107 +++++++++++------------
 htdocs/comm/propal/document.php    |  92 +++++++++++++-------
 htdocs/comm/propal/info.php        |  60 ++++++++++++-
 htdocs/comm/propal/note.php        | 133 ++++++++++++++---------------
 htdocs/product/stock/mouvement.php |  16 ++--
 htdocs/projet/document.php         |   1 +
 7 files changed, 243 insertions(+), 168 deletions(-)

diff --git a/htdocs/comm/propal/card.php b/htdocs/comm/propal/card.php
index 887290b1247..6b47d5205b6 100644
--- a/htdocs/comm/propal/card.php
+++ b/htdocs/comm/propal/card.php
@@ -1710,7 +1710,7 @@ if ($action == 'create')
 	$morehtmlref.=$form->editfieldkey("RefCustomer", 'ref_client', $object->ref_client, $object, $user->rights->propal->creer, 'string', '', 0, 1);
 	$morehtmlref.=$form->editfieldval("RefCustomer", 'ref_client', $object->ref_client, $object, $user->rights->propal->creer, 'string', '', null, null, '', 1);
     // Thirdparty
-    $morehtmlref.='<br>'.$langs->trans('ThirdParty') . ' : ' . $soc->getNomUrl(1);
+    $morehtmlref.='<br>'.$langs->trans('ThirdParty') . ' : ' . $object->thirdparty->getNomUrl(1);
     // Project
     if (! empty($conf->projet->enabled))
     {
diff --git a/htdocs/comm/propal/contact.php b/htdocs/comm/propal/contact.php
index 33504a1d27b..f82732a49ff 100644
--- a/htdocs/comm/propal/contact.php
+++ b/htdocs/comm/propal/contact.php
@@ -1,6 +1,6 @@
 <?php
 /* Copyright (C) 2005      Patrick Rouillon     <patrick@rouillon.net>
- * Copyright (C) 2005-2009 Destailleur Laurent  <eldy@users.sourceforge.net>
+ * Copyright (C) 2005-2016 Destailleur Laurent  <eldy@users.sourceforge.net>
  * Copyright (C) 2005-2012 Regis Houssin		<regis.houssin@capnetworks.com>
  * Copyright (C) 2011-2015 Philippe Grand       <philippe.grand@atoo-net.com>
  *
@@ -149,66 +149,61 @@ $formother = new FormOther($db);
 
 if ($object->id > 0)
 {
-	$head = propal_prepare_head($object);
+    $head = propal_prepare_head($object);
 	dol_fiche_head($head, 'contact', $langs->trans("Proposal"), 0, 'propal');
 
-	/*
-	 * Propal synthese pour rappel
-	 */
-	print '<table class="border" width="100%">';
-
-	$linkback='<a href="'.DOL_URL_ROOT.'/comm/propal/list.php'.(! empty($socid)?'?socid='.$socid:'').'">'.$langs->trans("BackToList").'</a>';
-
-	// Ref
-	print '<tr><td width="25%">'.$langs->trans('Ref').'</td><td colspan="3">';
-	print $form->showrefnav($object,'ref',$linkback,1,'ref','ref','');
-	print '</td></tr>';
-
-	// Ref client
-	print '<tr><td>';
-	print '<table class="nobordernopadding" width="100%"><tr><td class="nowrap">';
-	print $langs->trans('RefCustomer').'</td><td align="left">';
-	print '</td>';
-	print '</tr></table>';
-	print '</td><td colspan="3">';
-	print $object->ref_client;
-	print '</td>';
-	print '</tr>';
-
-	// Customer
-	print "<tr><td>".$langs->trans("Company")."</td>";
-	print '<td colspan="3">'.$object->thirdparty->getNomUrl(1).'</td></tr>';
-
-	// Delivery address
-	if (! empty($conf->global->SOCIETE_ADDRESSES_MANAGEMENT))
-	{
-		print '<tr><td>';
-		print '<table class="nobordernopadding" width="100%"><tr><td>';
-		print $langs->trans('DeliveryAddress');
-		print '</td>';
-
-		if ($action != 'editdelivery_address' && ! empty($object->brouillon))
-			print '<td align="right"><a href="'.$_SERVER["PHP_SELF"].'?action=editdelivery_address&amp;socid='.$object->socid.'&amp;id='.$object->id.'">'.img_edit($langs->transnoentitiesnoconv('SetDeliveryAddress'),1).'</a></td>';
-		print '</tr></table>';
-		print '</td><td colspan="3">';
 
-		if ($action == 'editdelivery_address')
-		{
-			$formother->form_address($_SERVER['PHP_SELF'].'?id='.$object->id,$object->fk_delivery_address,$object->socid,'fk_address','propal',$object->id);
-		}
-		else
-		{
-			$formother->form_address($_SERVER['PHP_SELF'].'?id='.$object->id,$object->fk_delivery_address,$object->socid,'none','propal',$object->id);
-		}
-		print '</td></tr>';
+	// Proposal card
+	
+	$linkback = '<a href="' . DOL_URL_ROOT . '/comm/propal/list.php' . (! empty($socid) ? '?socid=' . $socid : '') . '">' . $langs->trans("BackToList") . '</a>';
+	
+	
+	$morehtmlref='<div class="refidno">';
+	// Ref customer
+	$morehtmlref.=$form->editfieldkey("RefCustomer", 'ref_client', $object->ref_client, $object, 0, 'string', '', 0, 1);
+	$morehtmlref.=$form->editfieldval("RefCustomer", 'ref_client', $object->ref_client, $object, 0, 'string', '', null, null, '', 1);
+	// Thirdparty
+	$morehtmlref.='<br>'.$langs->trans('ThirdParty') . ' : ' . $object->thirdparty->getNomUrl(1);
+	// Project
+	if (! empty($conf->projet->enabled))
+	{
+	    $langs->load("projects");
+	    $morehtmlref.='<br>'.$langs->trans('Project') . ' ';
+	    if ($user->rights->propal->creer)
+	    {
+	        if ($action != 'classify')
+	            //$morehtmlref.='<a href="' . $_SERVER['PHP_SELF'] . '?action=classify&amp;id=' . $object->id . '">' . img_edit($langs->transnoentitiesnoconv('SetProject')) . '</a>';
+	            $morehtmlref.=' : ';
+	            if ($action == 'classify') {
+	                //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1);
+	                $morehtmlref.='<form method="post" action="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'">';
+	                $morehtmlref.='<input type="hidden" name="action" value="classin">';
+	                $morehtmlref.='<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
+	                $morehtmlref.=$formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1);
+	                $morehtmlref.='<input type="submit" class="button valignmiddle" value="'.$langs->trans("Modify").'">';
+	                $morehtmlref.='</form>';
+	            } else {
+	                $morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1);
+	            }
+	    } else {
+	        if (! empty($object->fk_project)) {
+	            $proj = new Project($db);
+	            $proj->fetch($object->fk_project);
+	            $morehtmlref.='<a href="'.DOL_URL_ROOT.'/projet/card.php?id=' . $object->fk_project . '" title="' . $langs->trans('ShowProject') . '">';
+	            $morehtmlref.=$proj->ref;
+	            $morehtmlref.='</a>';
+	        } else {
+	            $morehtmlref.='';
+	        }
+	    }
 	}
+	$morehtmlref.='</div>';
+	
+	dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref, '', 0, '', '', 1);
 
-	print "</table>";
-
-	print '</div>';
-
-	print '<br>';
-
+	dol_fiche_end();
+	
+	
 	// Contacts lines (modules that overwrite templates must declare this into descriptor)
 	$dirtpls=array_merge($conf->modules_parts['tpl'],array('/core/tpl'));
 	foreach($dirtpls as $reldir)
diff --git a/htdocs/comm/propal/document.php b/htdocs/comm/propal/document.php
index 289ba272b8c..9b875e434f7 100644
--- a/htdocs/comm/propal/document.php
+++ b/htdocs/comm/propal/document.php
@@ -100,36 +100,70 @@ if ($object->id > 0)
 	}
 
 
-	print '<table class="border"width="100%">';
-
-	$linkback='<a href="'.DOL_URL_ROOT.'/comm/propal/list.php'.(! empty($socid)?'?socid='.$socid:'').'">'.$langs->trans("BackToList").'</a>';
-
-	// Ref
-	print '<tr><td width="25%">'.$langs->trans('Ref').'</td><td colspan="3">';
-	print $form->showrefnav($object,'ref',$linkback,1,'ref','ref','');
-	print '</td></tr>';
-
-	// Ref client
-	print '<tr><td>';
-	print '<table class="nobordernopadding" width="100%"><tr><td class="nowrap">';
-	print $langs->trans('RefCustomer').'</td><td align="left">';
-	print '</td>';
-	print '</tr></table>';
-	print '</td><td colspan="3">';
-	print $object->ref_client;
-	print '</td>';
-	print '</tr>';
-
-	// Customer
-	print "<tr><td>".$langs->trans("Company")."</td>";
-	print '<td colspan="3">'.$object->thirdparty->getNomUrl(1).'</td></tr>';
-
-	print '<tr><td>'.$langs->trans("NbOfAttachedFiles").'</td><td colspan="3">'.count($filearray).'</td></tr>';
-	print '<tr><td>'.$langs->trans("TotalSizeOfAttachedFiles").'</td><td colspan="3">'.$totalsize.' '.$langs->trans("bytes").'</td></tr>';
-
-	print '</table>';
-
+	// Proposal card
+	
+	$linkback = '<a href="' . DOL_URL_ROOT . '/comm/propal/list.php' . (! empty($socid) ? '?socid=' . $socid : '') . '">' . $langs->trans("BackToList") . '</a>';
+	
+	
+	$morehtmlref='<div class="refidno">';
+	// Ref customer
+	$morehtmlref.=$form->editfieldkey("RefCustomer", 'ref_client', $object->ref_client, $object, 0, 'string', '', 0, 1);
+	$morehtmlref.=$form->editfieldval("RefCustomer", 'ref_client', $object->ref_client, $object, 0, 'string', '', null, null, '', 1);
+	// Thirdparty
+	$morehtmlref.='<br>'.$langs->trans('ThirdParty') . ' : ' . $object->thirdparty->getNomUrl(1);
+	// Project
+	if (! empty($conf->projet->enabled))
+	{
+	    $langs->load("projects");
+	    $morehtmlref.='<br>'.$langs->trans('Project') . ' ';
+	    if ($user->rights->propal->creer)
+	    {
+	        if ($action != 'classify')
+	            //$morehtmlref.='<a href="' . $_SERVER['PHP_SELF'] . '?action=classify&amp;id=' . $object->id . '">' . img_edit($langs->transnoentitiesnoconv('SetProject')) . '</a>';
+	            $morehtmlref.=' : ';
+	            if ($action == 'classify') {
+	                //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1);
+	                $morehtmlref.='<form method="post" action="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'">';
+	                $morehtmlref.='<input type="hidden" name="action" value="classin">';
+	                $morehtmlref.='<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
+	                $morehtmlref.=$formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1);
+	                $morehtmlref.='<input type="submit" class="button valignmiddle" value="'.$langs->trans("Modify").'">';
+	                $morehtmlref.='</form>';
+	            } else {
+	                $morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1);
+	            }
+	    } else {
+	        if (! empty($object->fk_project)) {
+	            $proj = new Project($db);
+	            $proj->fetch($object->fk_project);
+	            $morehtmlref.='<a href="'.DOL_URL_ROOT.'/projet/card.php?id=' . $object->fk_project . '" title="' . $langs->trans('ShowProject') . '">';
+	            $morehtmlref.=$proj->ref;
+	            $morehtmlref.='</a>';
+	        } else {
+	            $morehtmlref.='';
+	        }
+	    }
+	}
+	$morehtmlref.='</div>';
+	
+	dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref);
+	
+	
+	print '<div class="fichecenter">';
+	print '<div class="underbanner clearboth"></div>';
+	
+	print '<table class="border" width="100%">';
+	
+	// Files infos
+	print '<tr><td class="titlefield">'.$langs->trans("NbOfAttachedFiles").'</td><td>'.count($filearray).'</td></tr>';
+	print '<tr><td>'.$langs->trans("TotalSizeOfAttachedFiles").'</td><td>'.$totalsize.' '.$langs->trans("bytes").'</td></tr>';
+	
+	print "</table>\n";
+	
 	print '</div>';
+	
+	
+	dol_fiche_end();
 
 	$modulepart = 'propal';
 	$permission = $user->rights->propal->creer;
diff --git a/htdocs/comm/propal/info.php b/htdocs/comm/propal/info.php
index d3a3899537b..8415cb8618f 100644
--- a/htdocs/comm/propal/info.php
+++ b/htdocs/comm/propal/info.php
@@ -54,12 +54,66 @@ dol_fiche_head($head, 'info', $langs->trans('Proposal'), 0, 'propal');
 
 $object->info($object->id);
 
-print '<table width="100%"><tr><td>';
+
+// Proposal card
+
+$linkback = '<a href="' . DOL_URL_ROOT . '/comm/propal/list.php' . (! empty($socid) ? '?socid=' . $socid : '') . '">' . $langs->trans("BackToList") . '</a>';
+
+
+$morehtmlref='<div class="refidno">';
+// Ref customer
+$morehtmlref.=$form->editfieldkey("RefCustomer", 'ref_client', $object->ref_client, $object, 0, 'string', '', 0, 1);
+$morehtmlref.=$form->editfieldval("RefCustomer", 'ref_client', $object->ref_client, $object, 0, 'string', '', null, null, '', 1);
+// Thirdparty
+$morehtmlref.='<br>'.$langs->trans('ThirdParty') . ' : ' . $object->thirdparty->getNomUrl(1);
+// Project
+if (! empty($conf->projet->enabled))
+{
+    $langs->load("projects");
+    $morehtmlref.='<br>'.$langs->trans('Project') . ' ';
+    if ($user->rights->propal->creer)
+    {
+        if ($action != 'classify')
+            //$morehtmlref.='<a href="' . $_SERVER['PHP_SELF'] . '?action=classify&amp;id=' . $object->id . '">' . img_edit($langs->transnoentitiesnoconv('SetProject')) . '</a>';
+            $morehtmlref.=' : ';
+            if ($action == 'classify') {
+                //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1);
+                $morehtmlref.='<form method="post" action="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'">';
+                $morehtmlref.='<input type="hidden" name="action" value="classin">';
+                $morehtmlref.='<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
+                $morehtmlref.=$formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1);
+                $morehtmlref.='<input type="submit" class="button valignmiddle" value="'.$langs->trans("Modify").'">';
+                $morehtmlref.='</form>';
+            } else {
+                $morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1);
+            }
+    } else {
+        if (! empty($object->fk_project)) {
+            $proj = new Project($db);
+            $proj->fetch($object->fk_project);
+            $morehtmlref.='<a href="'.DOL_URL_ROOT.'/projet/card.php?id=' . $object->fk_project . '" title="' . $langs->trans('ShowProject') . '">';
+            $morehtmlref.=$proj->ref;
+            $morehtmlref.='</a>';
+        } else {
+            $morehtmlref.='';
+        }
+    }
+}
+$morehtmlref.='</div>';
+
+dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref);
+
+print '<div class="fichecenter">';
+print '<div class="underbanner clearboth"></div>';
+
+print '<br>';
+
 dol_print_object_info($object);
-print '</td></tr></table>';
 
+print '</div>';
 print '</div>';
 
-
+dol_fiche_end();
+	
 llxFooter();
 $db->close();
diff --git a/htdocs/comm/propal/note.php b/htdocs/comm/propal/note.php
index 89f31256717..d161fe03870 100644
--- a/htdocs/comm/propal/note.php
+++ b/htdocs/comm/propal/note.php
@@ -1,6 +1,6 @@
 <?php
 /* Copyright (C) 2004      Rodolphe Quiedeville <rodolphe@quiedeville.org>
- * Copyright (C) 2004-2015 Laurent Destailleur  <eldy@users.sourceforge.net>
+ * Copyright (C) 2004-2016 Laurent Destailleur  <eldy@users.sourceforge.net>
  * Copyright (C) 2004      Eric Seigne          <eric.seigne@ryxeo.com>
  * Copyright (C) 2005-2012 Regis Houssin        <regis.houssin@capnetworks.com>
  * Copyright (C) 2013      Florian Henry		  	<florian.henry@open-concept.pro>
@@ -45,10 +45,9 @@ $result = restrictedArea($user, 'propale', $id, 'propal');
 $object = new Propal($db);
 
 
-
-/******************************************************************************/
-/*                     Actions                                                */
-/******************************************************************************/
+/*
+ * Actions
+ */
 
 $permissionnote=$user->rights->propale->creer;	// Used by the include of actions_setnotes.inc.php
 
@@ -56,9 +55,9 @@ include DOL_DOCUMENT_ROOT.'/core/actions_setnotes.inc.php';	// Must be include,
 
 
 
-/******************************************************************************/
-/* Affichage fiche                                                            */
-/******************************************************************************/
+/*
+ * View 
+ */
 
 llxHeader('',$langs->trans('Proposal'),'EN:Commercial_Proposals|FR:Proposition_commerciale|ES:Presupuestos');
 
@@ -70,10 +69,9 @@ if ($id > 0 || ! empty($ref))
 
 	$now=dol_now();
 
-	if ($object->fetch($id, $ref))
+	if ($object->fetch($id, $ref) > 0)
 	{
-		$societe = new Societe($db);
-		if ( $societe->fetch($object->socid) )
+		if ($object->fetch_thirdparty() > 0)
 		{
 		    $head = propal_prepare_head($object);
 			dol_fiche_head($head, 'note', $langs->trans('Proposal'), 0, 'propal');
@@ -81,71 +79,64 @@ if ($id > 0 || ! empty($ref))
 			$cssclass='titlefield';
 			//if ($action == 'editnote_public') $cssclass='titlefieldcreate';
 			//if ($action == 'editnote_private') $cssclass='titlefieldcreate';
-					
-			print '<table class="border" width="100%">';
-
-			$linkback = '<a href="'.DOL_URL_ROOT.'/comm/propal/list.php'.(! empty($socid)?'?socid='.$socid:'').'">'.$langs->trans('BackToList').'</a>';
-
-			// Ref
-			print '<tr><td class="titlefield">'.$langs->trans('Ref').'</td><td colspan="3">';
-			print $form->showrefnav($object,'ref',$linkback,1,'ref','ref','');
-			print '</td></tr>';
-
-			// Ref client
-			print '<tr><td>';
-			print '<table class="nobordernopadding" width="100%"><tr><td class="nowrap">';
-			print $langs->trans('RefCustomer').'</td><td align="left">';
-			print '</td>';
-			print '</tr></table>';
-			print '</td><td colspan="3">';
-			print $object->ref_client;
-			print '</td>';
-			print '</tr>';
-
-			// Customer
-			if ( is_null($object->thirdparty) )
-				$object->fetch_thirdparty();
-			print "<tr><td>".$langs->trans("Company")."</td>";
-			print '<td colspan="3">'.$object->thirdparty->getNomUrl(1).'</td></tr>';
-
-			// Discounts
-			print '<tr><td>'.$langs->trans('Discounts').'</td><td colspan="3">';
-			if ($societe->remise_percent) print $langs->trans("CompanyHasRelativeDiscount",$societe->remise_percent);
-			else print $langs->trans("CompanyHasNoRelativeDiscount");
-			$absolute_discount=$societe->getAvailableDiscounts();
-			print '. ';
-			if ($absolute_discount) print $langs->trans("CompanyHasAbsoluteDiscount",price($absolute_discount),$langs->trans("Currency".$conf->currency));
-			else print $langs->trans("CompanyHasNoAbsoluteDiscount");
-			print '.';
-			print '</td></tr>';
-
-			// Date
-			print '<tr><td>'.$langs->trans('Date').'</td><td colspan="3">';
-			print dol_print_date($object->date,'daytext');
-			print '</td>';
-			print '</tr>';
-
-			// Date fin propal
-			print '<tr>';
-			print '<td>'.$langs->trans('DateEndPropal').'</td><td colspan="3">';
-			if ($object->fin_validite)
+				
+			
+			// Proposal card
+			
+			$linkback = '<a href="' . DOL_URL_ROOT . '/comm/propal/list.php' . (! empty($socid) ? '?socid=' . $socid : '') . '">' . $langs->trans("BackToList") . '</a>';
+			
+			
+			$morehtmlref='<div class="refidno">';
+			// Ref customer
+			$morehtmlref.=$form->editfieldkey("RefCustomer", 'ref_client', $object->ref_client, $object, 0, 'string', '', 0, 1);
+			$morehtmlref.=$form->editfieldval("RefCustomer", 'ref_client', $object->ref_client, $object, 0, 'string', '', null, null, '', 1);
+			// Thirdparty
+			$morehtmlref.='<br>'.$langs->trans('ThirdParty') . ' : ' . $object->thirdparty->getNomUrl(1);
+			// Project
+			if (! empty($conf->projet->enabled))
 			{
-				print dol_print_date($object->fin_validite,'daytext');
-				if ($object->statut == Propal::STATUS_VALIDATED && $object->fin_validite < ($now - $conf->propal->cloture->warning_delay)) print img_warning($langs->trans("Late"));
+			    $langs->load("projects");
+			    $morehtmlref.='<br>'.$langs->trans('Project') . ' ';
+			    if ($user->rights->propal->creer)
+			    {
+			        if ($action != 'classify')
+			            //$morehtmlref.='<a href="' . $_SERVER['PHP_SELF'] . '?action=classify&amp;id=' . $object->id . '">' . img_edit($langs->transnoentitiesnoconv('SetProject')) . '</a>';
+			            $morehtmlref.=' : ';
+			            if ($action == 'classify') {
+			                //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1);
+			                $morehtmlref.='<form method="post" action="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'">';
+			                $morehtmlref.='<input type="hidden" name="action" value="classin">';
+			                $morehtmlref.='<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
+			                $morehtmlref.=$formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1);
+			                $morehtmlref.='<input type="submit" class="button valignmiddle" value="'.$langs->trans("Modify").'">';
+			                $morehtmlref.='</form>';
+			            } else {
+			                $morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1);
+			            }
+			    } else {
+			        if (! empty($object->fk_project)) {
+			            $proj = new Project($db);
+			            $proj->fetch($object->fk_project);
+			            $morehtmlref.='<a href="'.DOL_URL_ROOT.'/projet/card.php?id=' . $object->fk_project . '" title="' . $langs->trans('ShowProject') . '">';
+			            $morehtmlref.=$proj->ref;
+			            $morehtmlref.='</a>';
+			        } else {
+			            $morehtmlref.='';
+			        }
+			    }
 			}
-			else
-			{
-				print $langs->trans("Unknown");
-			}
-			print '</td>';
-			print '</tr>';
-
-			print "</table>";
-
-			//print '<br>';
+			$morehtmlref.='</div>';
+			
+			dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref);
 
+			print '<div class="fichecenter">';
+			print '<div class="underbanner clearboth"></div>';
+			
 			include DOL_DOCUMENT_ROOT.'/core/tpl/notes.tpl.php';
 
+			print '</div>';
+			print '</div>';
+			
 			dol_fiche_end();
 		}
 	}
diff --git a/htdocs/product/stock/mouvement.php b/htdocs/product/stock/mouvement.php
index c9344306eb6..7d80032e1d9 100644
--- a/htdocs/product/stock/mouvement.php
+++ b/htdocs/product/stock/mouvement.php
@@ -740,7 +740,7 @@ if ($resql)
     {
 	    // Ref
 	    print '<td class="liste_titre" align="left">';
-	    print '<input class="flat" type="text" size="4" name="search_ref" value="'.$search_ref.'">';
+	    print '<input class="flat" type="text" size="3" name="search_ref" value="'.dol_escape_htmltag($search_ref).'">';
 	    print '</td>';
     }
     if (! empty($arrayfields['m.datem']['checked'])) 
@@ -758,20 +758,20 @@ if ($resql)
     {
 	    // Product Ref
 	    print '<td class="liste_titre" align="left">';
-	    print '<input class="flat" type="text" size="6" name="search_product_ref" value="'.($idproduct?$product->ref:$search_product_ref).'">';
+	    print '<input class="flat" type="text" size="6" name="search_product_ref" value="'.dol_escape_htmltag($idproduct?$product->ref:$search_product_ref).'">';
 	    print '</td>';
     }
     if (! empty($arrayfields['p.label']['checked'])) 
     {
 	    // Product label
 	    print '<td class="liste_titre" align="left">';
-	    print '<input class="flat" type="text" size="10" name="search_product" value="'.($idproduct?$product->label:$search_product).'">';
+	    print '<input class="flat" type="text" size="10" name="search_product" value="'.dol_escape_htmltag($idproduct?$product->label:$search_product).'">';
 	    print '</td>';
     }
     // Batch
     if (! empty($arrayfields['m.batch']['checked'])) 
     {
-    	print '<td align="center"><input class="flat" type="text" size="5" name="search_batch" value="'.($search_batch).'"></td>';
+    	print '<td align="center"><input class="flat" type="text" size="5" name="search_batch" value="'.dol_escape_htmltag($search_batch).'"></td>';
 	}
     if (! empty($arrayfields['pl.eatby']['checked']))
     {
@@ -795,21 +795,21 @@ if ($resql)
     {
 	    // Author
 	    print '<td class="liste_titre" align="left">';
-	    print '<input class="flat" type="text" size="6" name="search_user" value="'.($search_user).'">';
+	    print '<input class="flat" type="text" size="6" name="search_user" value="'.dol_escape_htmltag($search_user).'">';
 	    print '</td>';
     }
     if (! empty($arrayfields['m.inventorycode']['checked'])) 
     {
 	    // Inventory code
 	    print '<td class="liste_titre" align="left">';
-	    print '<input class="flat" type="text" size="4" name="search_inventorycode" value="'.$search_inventorycode.'">';
+	    print '<input class="flat" type="text" size="4" name="search_inventorycode" value="'.dol_escape_htmltag($search_inventorycode).'">';
 	    print '</td>';
     }
     if (! empty($arrayfields['m.label']['checked'])) 
     {
 	    // Label of movement
 	    print '<td class="liste_titre" align="left">';
-	    print '<input class="flat" type="text" size="8" name="search_movement" value="'.$search_movement.'">';
+	    print '<input class="flat" type="text" size="8" name="search_movement" value="'.dol_escape_htmltag($search_movement).'">';
 	    print '</td>';
     }
     if (! empty($arrayfields['origin']['checked'])) 
@@ -823,7 +823,7 @@ if ($resql)
     {
 	    // Qty
 	    print '<td class="liste_titre" align="right">';
-	    print '<input class="flat" type="text" size="4" name="search_qty" value="'.$search_qty.'">';
+	    print '<input class="flat" type="text" size="4" name="search_qty" value="'.dol_escape_htmltag($search_qty).'">';
 	    print '</td>';
     }
 	// Extra fields
diff --git a/htdocs/projet/document.php b/htdocs/projet/document.php
index d5768c355a2..f6f1a51fed7 100644
--- a/htdocs/projet/document.php
+++ b/htdocs/projet/document.php
@@ -143,6 +143,7 @@ if ($object->id > 0)
 	print "</table>\n";
 	
 	print '</div>';
+
 	
 	dol_fiche_end();
 
-- 
GitLab