Browse Source

clean indent

Frédéric FRANCE 5 years ago
parent
commit
8f6d38ee82
88 changed files with 2572 additions and 2617 deletions
  1. 2 2
      dev/setup/codesniffer/ruleset.xml
  2. 6 6
      htdocs/core/actions_builddoc.inc.php
  3. 58 57
      htdocs/core/actions_linkedfiles.inc.php
  4. 1 1
      htdocs/core/actions_massactions.inc.php
  5. 13 14
      htdocs/core/db/mssql.class.php
  6. 25 22
      htdocs/core/db/pgsql.class.php
  7. 3 3
      htdocs/core/db/sqlite3.class.php
  8. 1 1
      htdocs/core/js/lib_head.js.php
  9. 29 30
      htdocs/core/login/functions_ldap.php
  10. 1 1
      htdocs/core/menus/standard/eldy_menu.php
  11. 8 6
      htdocs/core/menus/standard/empty.php
  12. 1 1
      htdocs/core/modules/commande/doc/doc_generic_order_odt.modules.php
  13. 84 86
      htdocs/core/modules/commande/doc/pdf_einstein.modules.php
  14. 86 89
      htdocs/core/modules/commande/doc/pdf_eratosthene.modules.php
  15. 2 2
      htdocs/core/modules/contract/doc/doc_generic_contract_odt.modules.php
  16. 34 36
      htdocs/core/modules/dons/html_cerfafr.modules.php
  17. 1 1
      htdocs/core/modules/expedition/doc/doc_generic_shipment_odt.modules.php
  18. 20 21
      htdocs/core/modules/expedition/doc/pdf_rouget.modules.php
  19. 13 13
      htdocs/core/modules/expensereport/mod_expensereport_jade.php
  20. 1 1
      htdocs/core/modules/facture/doc/doc_generic_invoice_odt.modules.php
  21. 79 80
      htdocs/core/modules/facture/doc/pdf_crabe.modules.php
  22. 151 160
      htdocs/core/modules/facture/doc/pdf_sponge.modules.php
  23. 2 2
      htdocs/core/modules/fichinter/doc/pdf_soleil.modules.php
  24. 2 2
      htdocs/core/modules/import/import_csv.modules.php
  25. 5 3
      htdocs/core/modules/mailings/fraise.modules.php
  26. 20 21
      htdocs/core/modules/mailings/thirdparties.modules.php
  27. 11 10
      htdocs/core/modules/modComptabilite.class.php
  28. 4 4
      htdocs/core/modules/modECM.class.php
  29. 4 5
      htdocs/core/modules/modExpedition.class.php
  30. 4 5
      htdocs/core/modules/modReception.class.php
  31. 5 5
      htdocs/core/modules/modSociete.class.php
  32. 4 4
      htdocs/core/modules/modStripe.class.php
  33. 1 1
      htdocs/core/modules/modVariants.class.php
  34. 9 11
      htdocs/core/modules/modWebsite.class.php
  35. 1 2
      htdocs/core/modules/product/doc/pdf_standard.modules.php
  36. 1 1
      htdocs/core/modules/project/doc/pdf_beluga.modules.php
  37. 7 7
      htdocs/core/modules/project/mod_project_simple.php
  38. 7 7
      htdocs/core/modules/project/mod_project_universal.php
  39. 7 7
      htdocs/core/modules/project/task/mod_task_simple.php
  40. 7 7
      htdocs/core/modules/project/task/mod_task_universal.php
  41. 1 1
      htdocs/core/modules/propale/doc/doc_generic_proposal_odt.modules.php
  42. 85 85
      htdocs/core/modules/propale/doc/pdf_azur.modules.php
  43. 85 85
      htdocs/core/modules/propale/doc/pdf_cyan.modules.php
  44. 1 1
      htdocs/core/modules/reception/doc/doc_generic_reception_odt.modules.php
  45. 25 27
      htdocs/core/modules/reception/doc/pdf_squille.modules.php
  46. 15 17
      htdocs/core/modules/societe/doc/doc_generic_odt.modules.php
  47. 1 1
      htdocs/core/modules/stock/doc/doc_generic_stock_odt.modules.php
  48. 36 38
      htdocs/core/modules/supplier_invoice/pdf/pdf_canelle.modules.php
  49. 2 2
      htdocs/core/modules/supplier_order/pdf/doc_generic_supplier_order_odt.modules.php
  50. 2 2
      htdocs/core/modules/supplier_payment/doc/pdf_standard.modules.php
  51. 1 1
      htdocs/core/modules/supplier_proposal/doc/doc_generic_supplier_proposal_odt.modules.php
  52. 91 91
      htdocs/core/modules/supplier_proposal/doc/pdf_aurore.modules.php
  53. 476 483
      htdocs/core/tpl/advtarget.tpl.php
  54. 71 78
      htdocs/core/tpl/contacts.tpl.php
  55. 13 15
      htdocs/core/tpl/login.tpl.php
  56. 232 238
      htdocs/core/tpl/objectline_create.tpl.php
  57. 19 19
      htdocs/core/tpl/objectline_edit.tpl.php
  58. 13 11
      htdocs/core/tpl/objectline_title.tpl.php
  59. 234 253
      htdocs/core/tpl/objectline_view.tpl.php
  60. 4 4
      htdocs/core/tpl/passwordforgotten.tpl.php
  61. 2 2
      htdocs/expensereport/ajax/ajaxprojet.php
  62. 20 20
      htdocs/expensereport/class/expensereport.class.php
  63. 9 7
      htdocs/expensereport/list.php
  64. 10 13
      htdocs/expensereport/tpl/linkedobjectblock.tpl.php
  65. 14 13
      htdocs/fichinter/card.php
  66. 15 14
      htdocs/fichinter/contact.php
  67. 16 15
      htdocs/fichinter/document.php
  68. 15 14
      htdocs/fichinter/note.php
  69. 5 8
      htdocs/fichinter/tpl/linkedobjectblock.tpl.php
  70. 45 44
      htdocs/index.php
  71. 13 12
      htdocs/salaries/card.php
  72. 11 11
      htdocs/societe/admin/societe.php
  73. 8 7
      htdocs/societe/canvas/company/tpl/card_create.tpl.php
  74. 5 6
      htdocs/societe/canvas/company/tpl/card_edit.tpl.php
  75. 1 3
      htdocs/societe/canvas/company/tpl/card_view.tpl.php
  76. 8 7
      htdocs/societe/canvas/individual/tpl/card_create.tpl.php
  77. 2 2
      htdocs/societe/canvas/individual/tpl/card_edit.tpl.php
  78. 4 9
      htdocs/societe/canvas/individual/tpl/card_view.tpl.php
  79. 9 9
      htdocs/societe/card.php
  80. 57 53
      htdocs/societe/class/api_thirdparties.class.php
  81. 17 17
      htdocs/societe/class/companybankaccount.class.php
  82. 13 13
      htdocs/societe/class/societe.class.php
  83. 4 4
      htdocs/societe/list.php
  84. 73 68
      htdocs/societe/paymentmodes.php
  85. 21 21
      htdocs/stripe/admin/stripe.php
  86. 29 23
      htdocs/stripe/charge.php
  87. 8 2
      htdocs/stripe/class/stripe.class.php
  88. 11 11
      htdocs/stripe/payment.php

+ 2 - 2
dev/setup/codesniffer/ruleset.xml

@@ -186,7 +186,7 @@
 	<!-- Check indent are done with spaces and with correct number -->
 	<!-- Disabled as this does not support tab -->
 	<!-- <rule ref="Generic.WhiteSpace.ScopeIndent" /> -->
- 	<!-- TODO Enable this
+
 	<arg name="tab-width" value="4"/>
 	<rule ref="Generic.WhiteSpace.ScopeIndent">
 	  <properties>
@@ -194,7 +194,7 @@
 	    <property name="tabIndent" value="true"/>
 	  </properties>
 	</rule>
-	-->
+
 
     <rule ref="Squiz.WhiteSpace.ScopeClosingBrace.Indent" />
 

+ 6 - 6
htdocs/core/actions_builddoc.inc.php

@@ -57,12 +57,12 @@ if ($action == 'builddoc' && $permissioncreate)
         // Special case to force bank account
         //if (property_exists($object, 'fk_bank'))
         //{
-            if (GETPOST('fk_bank', 'int')) {
-                // this field may come from an external module
-                $object->fk_bank = GETPOST('fk_bank', 'int');
-            } elseif (! empty($object->fk_account)) {
-                $object->fk_bank = $object->fk_account;
-            }
+        if (GETPOST('fk_bank', 'int')) {
+            // this field may come from an external module
+            $object->fk_bank = GETPOST('fk_bank', 'int');
+        } elseif (! empty($object->fk_account)) {
+            $object->fk_bank = $object->fk_account;
+        }
         //}
 
         $outputlangs = $langs;

+ 58 - 57
htdocs/core/actions_linkedfiles.inc.php

@@ -81,78 +81,79 @@ elseif (GETPOST('linkit', 'none') && ! empty($conf->global->MAIN_UPLOAD_DOC))
 // Delete file/link
 if ($action == 'confirm_deletefile' && $confirm == 'yes')
 {
-        $urlfile = GETPOST('urlfile', 'alpha', 0, null, null, 1);				// Do not use urldecode here ($_GET and $_REQUEST are already decoded by PHP).
-        if (GETPOST('section', 'alpha')) 	// For a delete from the ECM module, upload_dir is ECM root dir and urlfile contains relative path from upload_dir
-        {
-        	$file = $upload_dir . (preg_match('/\/$/', $upload_dir) ? '' : '/') . $urlfile;
-        }
-        else								// For a delete from the file manager into another module, or from documents pages, upload_dir contains already path to file from module dir, so we clean path into urlfile.
-		{
-       		$urlfile=basename($urlfile);
-       		$file = $upload_dir . (preg_match('/\/$/', $upload_dir) ? '' : '/') . $urlfile;
-			if (! empty($upload_dirold)) $fileold = $upload_dirold . "/" . $urlfile;
-		}
-        $linkid = GETPOST('linkid', 'int');
+    $urlfile = GETPOST('urlfile', 'alpha', 0, null, null, 1);				// Do not use urldecode here ($_GET and $_REQUEST are already decoded by PHP).
+    if (GETPOST('section', 'alpha')) {
+        // For a delete from the ECM module, upload_dir is ECM root dir and urlfile contains relative path from upload_dir
+        $file = $upload_dir . (preg_match('/\/$/', $upload_dir) ? '' : '/') . $urlfile;
+    }
+    else								// For a delete from the file manager into another module, or from documents pages, upload_dir contains already path to file from module dir, so we clean path into urlfile.
+	{
+       	$urlfile=basename($urlfile);
+       	$file = $upload_dir . (preg_match('/\/$/', $upload_dir) ? '' : '/') . $urlfile;
+		if (! empty($upload_dirold)) $fileold = $upload_dirold . "/" . $urlfile;
+	}
+    $linkid = GETPOST('linkid', 'int');
 
-        if ($urlfile)		// delete of a file
-        {
-	        $dir = dirname($file).'/';		// Chemin du dossier contenant l'image d'origine
-	        $dirthumb = $dir.'/thumbs/';	// Chemin du dossier contenant la vignette (if file is an image)
+    if ($urlfile) {
+        // delete of a file
+	    $dir = dirname($file).'/';		// Chemin du dossier contenant l'image d'origine
+        $dirthumb = $dir.'/thumbs/';	// Chemin du dossier contenant la vignette (if file is an image)
 
-	        $ret = dol_delete_file($file, 0, 0, 0, (is_object($object)?$object:null));
-            if (! empty($fileold)) dol_delete_file($fileold, 0, 0, 0, (is_object($object)?$object:null));     // Delete file using old path
+        $ret = dol_delete_file($file, 0, 0, 0, (is_object($object)?$object:null));
+        if (! empty($fileold)) dol_delete_file($fileold, 0, 0, 0, (is_object($object)?$object:null));     // Delete file using old path
 
-	        // Si elle existe, on efface la vignette
-	        if (preg_match('/(\.jpg|\.jpeg|\.bmp|\.gif|\.png|\.tiff)$/i', $file, $regs))
+        // Si elle existe, on efface la vignette
+        if (preg_match('/(\.jpg|\.jpeg|\.bmp|\.gif|\.png|\.tiff)$/i', $file, $regs))
+        {
+	        $photo_vignette=basename(preg_replace('/'.$regs[0].'/i', '', $file).'_small'.$regs[0]);
+	        if (file_exists(dol_osencode($dirthumb.$photo_vignette)))
 	        {
-		        $photo_vignette=basename(preg_replace('/'.$regs[0].'/i', '', $file).'_small'.$regs[0]);
-		        if (file_exists(dol_osencode($dirthumb.$photo_vignette)))
-		        {
-			        dol_delete_file($dirthumb.$photo_vignette);
-		        }
+		        dol_delete_file($dirthumb.$photo_vignette);
+	        }
 
-		        $photo_vignette=basename(preg_replace('/'.$regs[0].'/i', '', $file).'_mini'.$regs[0]);
-		        if (file_exists(dol_osencode($dirthumb.$photo_vignette)))
-		        {
-			        dol_delete_file($dirthumb.$photo_vignette);
-		        }
+	        $photo_vignette=basename(preg_replace('/'.$regs[0].'/i', '', $file).'_mini'.$regs[0]);
+	        if (file_exists(dol_osencode($dirthumb.$photo_vignette)))
+	        {
+		        dol_delete_file($dirthumb.$photo_vignette);
 	        }
+        }
 
-            if ($ret) setEventMessages($langs->trans("FileWasRemoved", $urlfile), null, 'mesgs');
-            else setEventMessages($langs->trans("ErrorFailToDeleteFile", $urlfile), null, 'errors');
+        if ($ret) {
+            setEventMessages($langs->trans("FileWasRemoved", $urlfile), null, 'mesgs');
+        } else {
+            setEventMessages($langs->trans("ErrorFailToDeleteFile", $urlfile), null, 'errors');
         }
-        elseif ($linkid)	// delete of external link
-        {
-            require_once DOL_DOCUMENT_ROOT . '/core/class/link.class.php';
-            $link = new Link($db);
-            $link->fetch($linkid);
-            $res = $link->delete($user);
+    }
+    elseif ($linkid)	// delete of external link
+    {
+        require_once DOL_DOCUMENT_ROOT . '/core/class/link.class.php';
+        $link = new Link($db);
+        $link->fetch($linkid);
+        $res = $link->delete($user);
 
-            $langs->load('link');
-            if ($res > 0) {
-                setEventMessages($langs->trans("LinkRemoved", $link->label), null, 'mesgs');
+        $langs->load('link');
+        if ($res > 0) {
+            setEventMessages($langs->trans("LinkRemoved", $link->label), null, 'mesgs');
+        } else {
+            if (count($link->errors)) {
+                setEventMessages('', $link->errors, 'errors');
             } else {
-                if (count($link->errors)) {
-                    setEventMessages('', $link->errors, 'errors');
-                } else {
-                    setEventMessages($langs->trans("ErrorFailedToDeleteLink", $link->label), null, 'errors');
-                }
+                setEventMessages($langs->trans("ErrorFailedToDeleteLink", $link->label), null, 'errors');
             }
         }
+    }
 
-        if (is_object($object) && $object->id > 0)
+    if (is_object($object) && $object->id > 0) {
+        if ($backtopage) {
+            header('Location: ' . $backtopage);
+            exit;
+        }
+        else
         {
-        	if ($backtopage)
-        	{
-        		header('Location: ' . $backtopage);
-        		exit;
-        	}
-        	else
-        	{
-        		header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id.(GETPOST('section_dir', 'alpha')?'&section_dir='.urlencode(GETPOST('section_dir', 'alpha')):'').(!empty($withproject)?'&withproject=1':''));
-        		exit;
-        	}
+            header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id.(GETPOST('section_dir', 'alpha')?'&section_dir='.urlencode(GETPOST('section_dir', 'alpha')):'').(!empty($withproject)?'&withproject=1':''));
+            exit;
         }
+    }
 }
 elseif ($action == 'confirm_updateline' && GETPOST('save', 'alpha') && GETPOST('link', 'alpha'))
 {

+ 1 - 1
htdocs/core/actions_massactions.inc.php

@@ -1085,7 +1085,7 @@ if (! $error && $massaction == "builddoc" && $permtoread && ! GETPOST('button_se
 		}
 		else
 		{
-		setEventMessages($langs->trans('NoPDFAvailableForDocGenAmongChecked'), null, 'errors');
+            setEventMessages($langs->trans('NoPDFAvailableForDocGenAmongChecked'), null, 'errors');
 		}
 	}
 }

+ 13 - 14
htdocs/core/db/mssql.class.php

@@ -220,11 +220,10 @@ class DoliDBMssql extends DoliDB
      */
     public function close()
     {
-        if ($this->db)
-        {
-          if ($this->transaction_opened > 0) dol_syslog(get_class($this)."::close Closing a connection with an opened transaction depth=".$this->transaction_opened, LOG_ERR);
-          $this->connected=false;
-          return mssql_close($this->db);
+        if ($this->db) {
+            if ($this->transaction_opened > 0) dol_syslog(get_class($this)."::close Closing a connection with an opened transaction depth=".$this->transaction_opened, LOG_ERR);
+            $this->connected=false;
+            return mssql_close($this->db);
         }
         return false;
     }
@@ -407,15 +406,15 @@ class DoliDBMssql extends DoliDB
     			// Inserer la date en parametre et le reste de la requete
     			$query = $newquery." DATEPART(week, ".$extractvalue.$endofquery;
     		}
-    	   if (preg_match('/^insert\h+(?:INTO)?\h*(\w+?)\h*\(.*\b(?:row)?id\b.*\)\h+VALUES/i', $query, $matches))
-    	   {
-    	       //var_dump($query);
-    	       //var_dump($matches);
-    	       //if (stripos($query,'llx_c_departements') !== false) var_dump($query);
-    	       $sql='SET IDENTITY_INSERT ['.trim($matches[1]).'] ON;';
-    	       @mssql_query($sql, $this->db);
-    	       $post_query='SET IDENTITY_INSERT ['.trim($matches[1]).'] OFF;';
-    	   }
+    	    if (preg_match('/^insert\h+(?:INTO)?\h*(\w+?)\h*\(.*\b(?:row)?id\b.*\)\h+VALUES/i', $query, $matches))
+    	    {
+    	        //var_dump($query);
+    	        //var_dump($matches);
+    	        //if (stripos($query,'llx_c_departements') !== false) var_dump($query);
+    	        $sql='SET IDENTITY_INSERT ['.trim($matches[1]).'] ON;';
+    	        @mssql_query($sql, $this->db);
+    	        $post_query='SET IDENTITY_INSERT ['.trim($matches[1]).'] OFF;';
+    	    }
 		}
 		//print "<!--".$query."-->";
 

+ 25 - 22
htdocs/core/db/pgsql.class.php

@@ -36,7 +36,7 @@ require_once DOL_DOCUMENT_ROOT .'/core/db/DoliDB.class.php';
 class DoliDBPgsql extends DoliDB
 {
     //! Database type
-	public $type='pgsql';            // Name of manager
+    public $type='pgsql';            // Name of manager
     //! Database label
 	const LABEL='PostgreSQL';      // Label of manager
 	//! Charset
@@ -174,9 +174,9 @@ class DoliDBPgsql extends DoliDB
 
 		    if ($type == 'auto')
 		    {
-              if (preg_match('/ALTER TABLE/i', $line)) $type='dml';
-              elseif (preg_match('/CREATE TABLE/i', $line)) $type='dml';
-              elseif (preg_match('/DROP TABLE/i', $line)) $type='dml';
+                if (preg_match('/ALTER TABLE/i', $line)) $type='dml';
+                elseif (preg_match('/CREATE TABLE/i', $line)) $type='dml';
+                elseif (preg_match('/DROP TABLE/i', $line)) $type='dml';
 		    }
 
     		$line=preg_replace('/ as signed\)/i', ' as integer)', $line);
@@ -457,8 +457,8 @@ class DoliDBPgsql extends DoliDB
 		$resql=$this->query('SHOW server_version');
 		if ($resql)
 		{
-		  $liste=$this->fetch_array($resql);
-		  return $liste['server_version'];
+		    $liste=$this->fetch_array($resql);
+		    return $liste['server_version'];
 		}
 		return '';
 	}
@@ -483,9 +483,9 @@ class DoliDBPgsql extends DoliDB
     {
         if ($this->db)
         {
-          if ($this->transaction_opened > 0) dol_syslog(get_class($this)."::close Closing a connection with an opened transaction depth=".$this->transaction_opened, LOG_ERR);
-          $this->connected=false;
-          return pg_close($this->db);
+            if ($this->transaction_opened > 0) dol_syslog(get_class($this)."::close Closing a connection with an opened transaction depth=".$this->transaction_opened, LOG_ERR);
+            $this->connected=false;
+            return pg_close($this->db);
         }
         return false;
     }
@@ -955,10 +955,10 @@ class DoliDBPgsql extends DoliDB
 		$result = $this->query($sql);
 		if ($result)
 		{
-    		 while($row = $this->fetch_row($result))
-    		 {
+    		while($row = $this->fetch_row($result))
+    		{
     			$infotables[] = $row;
-    		 }
+    		}
 		}
         return $infotables;
 	}
@@ -1127,21 +1127,24 @@ class DoliDBPgsql extends DoliDB
 		$sql= "ALTER TABLE ".$table." ADD ".$field_name." ";
 		$sql .= $field_desc['type'];
 		if (preg_match("/^[^\s]/i", $field_desc['value']))
-		    if (! in_array($field_desc['type'], array('int','date','datetime')))
-		    {
-		        $sql.= "(".$field_desc['value'].")";
-		    }
+	    if (! in_array($field_desc['type'], array('int','date','datetime')))
+	    {
+	        $sql.= "(".$field_desc['value'].")";
+	    }
 		if (preg_match("/^[^\s]/i", $field_desc['attribute']))
             $sql .= " ".$field_desc['attribute'];
 		if (preg_match("/^[^\s]/i", $field_desc['null']))
             $sql .= " ".$field_desc['null'];
-		if (preg_match("/^[^\s]/i", $field_desc['default']))
-            if (preg_match("/null/i", $field_desc['default']))
+		if (preg_match("/^[^\s]/i", $field_desc['default'])) {
+            if (preg_match("/null/i", $field_desc['default'])) {
                 $sql .= " default ".$field_desc['default'];
-		    else
-                $sql .= " default '".$field_desc['default']."'";
-		if (preg_match("/^[^\s]/i", $field_desc['extra']))
-            $sql .= " ".$field_desc['extra'];
+			} else {
+				$sql .= " default '".$field_desc['default']."'";
+			}
+		}
+		if (preg_match("/^[^\s]/i", $field_desc['extra'])) {
+			$sql .= " ".$field_desc['extra'];
+		}
 		$sql .= " ".$field_position;
 
 		dol_syslog($sql, LOG_DEBUG);

+ 3 - 3
htdocs/core/db/sqlite3.class.php

@@ -149,9 +149,9 @@ class DoliDBSqlite3 extends DoliDB
         {
             if ($type == 'auto')
             {
-              if (preg_match('/ALTER TABLE/i', $line)) $type='dml';
-              elseif (preg_match('/CREATE TABLE/i', $line)) $type='dml';
-              elseif (preg_match('/DROP TABLE/i', $line)) $type='dml';
+                if (preg_match('/ALTER TABLE/i', $line)) $type='dml';
+                elseif (preg_match('/CREATE TABLE/i', $line)) $type='dml';
+                elseif (preg_match('/DROP TABLE/i', $line)) $type='dml';
             }
 
             if ($type == 'dml')

+ 1 - 1
htdocs/core/js/lib_head.js.php

@@ -1081,7 +1081,7 @@ function price2numjs(amount) {
 
 <?php
 if (empty($conf->global->MAIN_DISABLE_JQUERY_JNOTIFY) && ! defined('DISABLE_JQUERY_JNOTIFY')) {
-?>
+    ?>
 // Defined properties for JNotify
 $(document).ready(function() {
 	if (typeof $.jnotify == 'function')

+ 29 - 30
htdocs/core/login/functions_ldap.php

@@ -156,41 +156,41 @@ function check_user_password_ldap($usertotest, $passwordtotest, $entitytotest)
 				// ldap2dolibarr synchronisation
 				if ($login && ! empty($conf->ldap->enabled) && $conf->global->LDAP_SYNCHRO_ACTIVE == 'ldap2dolibarr')	// ldap2dolibarr synchronisation
 				{
-						dol_syslog("functions_ldap::check_user_password_ldap Sync ldap2dolibarr");
+					dol_syslog("functions_ldap::check_user_password_ldap Sync ldap2dolibarr");
 
-						// On charge les attributs du user ldap
-						if ($ldapdebug) print "DEBUG: login ldap = ".$login."<br>\n";
-						$resultFetchLdapUser = $ldap->fetch($login, $userSearchFilter);
+					// On charge les attributs du user ldap
+					if ($ldapdebug) print "DEBUG: login ldap = ".$login."<br>\n";
+					$resultFetchLdapUser = $ldap->fetch($login, $userSearchFilter);
 
-						if ($ldapdebug) print "DEBUG: UACF = ".join(',', $ldap->uacf)."<br>\n";
-						if ($ldapdebug) print "DEBUG: pwdLastSet = ".dol_print_date($ldap->pwdlastset, 'day')."<br>\n";
-						if ($ldapdebug) print "DEBUG: badPasswordTime = ".dol_print_date($ldap->badpwdtime, 'day')."<br>\n";
+					if ($ldapdebug) print "DEBUG: UACF = ".join(',', $ldap->uacf)."<br>\n";
+					if ($ldapdebug) print "DEBUG: pwdLastSet = ".dol_print_date($ldap->pwdlastset, 'day')."<br>\n";
+					if ($ldapdebug) print "DEBUG: badPasswordTime = ".dol_print_date($ldap->badpwdtime, 'day')."<br>\n";
 
-						// On recherche le user dolibarr en fonction de son SID ldap (only for Active Directory)
-						$sid = null;
-						if ($conf->global->LDAP_SERVER_TYPE == "activedirectory")
-						{
-							$sid = $ldap->getObjectSid($login);
-							if ($ldapdebug) print "DEBUG: sid = ".$sid."<br>\n";
-						}
-
-						$usertmp=new User($db);
-						$resultFetchUser=$usertmp->fetch('', $login, $sid);
-						if ($resultFetchUser > 0)
-						{
-							dol_syslog("functions_ldap::check_user_password_ldap Sync user found user id=".$usertmp->id);
-							// On verifie si le login a change et on met a jour les attributs dolibarr
+					// On recherche le user dolibarr en fonction de son SID ldap (only for Active Directory)
+					$sid = null;
+					if ($conf->global->LDAP_SERVER_TYPE == "activedirectory")
+					{
+						$sid = $ldap->getObjectSid($login);
+						if ($ldapdebug) print "DEBUG: sid = ".$sid."<br>\n";
+					}
 
-							if ($usertmp->login != $ldap->login && $ldap->login)
-							{
-								$usertmp->login = $ldap->login;
-								$usertmp->update($usertmp);
-								// TODO Que faire si update echoue car on update avec un login deja existant.
-							}
+					$usertmp=new User($db);
+					$resultFetchUser=$usertmp->fetch('', $login, $sid);
+					if ($resultFetchUser > 0)
+					{
+						dol_syslog("functions_ldap::check_user_password_ldap Sync user found user id=".$usertmp->id);
+						// On verifie si le login a change et on met a jour les attributs dolibarr
 
-							//$resultUpdate = $usertmp->update_ldap2dolibarr($ldap);
+						if ($usertmp->login != $ldap->login && $ldap->login)
+						{
+							$usertmp->login = $ldap->login;
+							$usertmp->update($usertmp);
+							// TODO Que faire si update echoue car on update avec un login deja existant.
 						}
-						unset($usertmp);
+
+						//$resultUpdate = $usertmp->update_ldap2dolibarr($ldap);
+					}
+					unset($usertmp);
 				}
 
 				if (! empty($conf->multicompany->enabled))	// We must check entity (even if sync is not active)
@@ -240,7 +240,6 @@ function check_user_password_ldap($usertotest, $passwordtotest, $entitytotest)
 
 			// Load translation files required by the page
             $langs->loadLangs(array('main', 'other', 'errors'));
-;
 			$_SESSION["dol_loginmesg"]=($ldap->error?$ldap->error:$langs->trans("ErrorBadLoginPassword"));
 		}
 

+ 1 - 1
htdocs/core/menus/standard/eldy_menu.php

@@ -79,7 +79,7 @@ class MenuManager
         	$_SESSION["leftmenuopened"]="";
         }
         else
-       {
+        {
         	// On va le chercher en session si non defini par le lien
         	$mainmenu=isset($_SESSION["mainmenu"])?$_SESSION["mainmenu"]:'';
         }

+ 8 - 6
htdocs/core/menus/standard/empty.php

@@ -307,10 +307,12 @@ class MenuManager
 		                    print $val2['titre'];
 		                    if ($relurl2)
 		                    {
-		                        if ($val2['enabled'])	// Allowed
-		                            print '</a>';
-		                            else
-		                                print '</a>';
+		                        if ($val2['enabled']) {
+                                    // Allowed
+                                    print '</a>';
+                                } else {
+                                    print '</a>';
+                                }
 		                    }
 		                    print '</li>'."\n";
 		                }
@@ -448,7 +450,7 @@ class MenuManager
 				unset($this->menu->liste);
 			}
 		}
-/*
+        /*
 		if ($mode == 'jmobile')
 		{
 			foreach($this->menu->liste as $key => $val)		// $val['url','titre','level','enabled'=0|1|2,'target','mainmenu','leftmenu'
@@ -506,7 +508,7 @@ class MenuManager
 				break;	// Only first menu entry (so home)
 			}
 		}
-*/
+        */
 		unset($this->menu);
 
 		return $res;

+ 1 - 1
htdocs/core/modules/commande/doc/doc_generic_order_odt.modules.php

@@ -486,7 +486,7 @@ class doc_generic_order_odt extends ModelePDFCommandes
 				}
 				else {
 					try {
-					$odfHandler->saveToDisk($file);
+					    $odfHandler->saveToDisk($file);
 					} catch (Exception $e) {
                         $this->error=$e->getMessage();
                         dol_syslog($e->getMessage(), LOG_INFO);

+ 84 - 86
htdocs/core/modules/commande/doc/pdf_einstein.modules.php

@@ -912,66 +912,64 @@ class pdf_einstein extends ModelePDFCommandes
 				//Local tax 1 before VAT
 				//if (! empty($conf->global->FACTURE_LOCAL_TAX1_OPTION) && $conf->global->FACTURE_LOCAL_TAX1_OPTION=='localtax1on')
 				//{
-					foreach($this->localtax1 as $localtax_type => $localtax_rate)
+				foreach($this->localtax1 as $localtax_type => $localtax_rate)
+				{
+					if (in_array((string) $localtax_type, array('1','3','5'))) continue;
+					foreach($localtax_rate as $tvakey => $tvaval)
 					{
-						if (in_array((string) $localtax_type, array('1','3','5'))) continue;
-						foreach($localtax_rate as $tvakey => $tvaval)
+						if ($tvakey!=0)    // On affiche pas taux 0
 						{
-							if ($tvakey!=0)    // On affiche pas taux 0
+							//$this->atleastoneratenotnull++;
+
+							$index++;
+							$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
+
+							$tvacompl='';
+							if (preg_match('/\*/', $tvakey))
 							{
-								//$this->atleastoneratenotnull++;
-
-								$index++;
-								$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
-
-								$tvacompl='';
-								if (preg_match('/\*/', $tvakey))
-								{
-									$tvakey=str_replace('*', '', $tvakey);
-									$tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")";
-								}
-								$totalvat = $outputlangs->transcountrynoentities("TotalLT1", $mysoc->country_code).' ';
-								$totalvat.=vatrate(abs($tvakey), 1).$tvacompl;
-								$pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1);
-
-								$pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
-								$pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1);
+								$tvakey=str_replace('*', '', $tvakey);
+								$tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")";
 							}
+							$totalvat = $outputlangs->transcountrynoentities("TotalLT1", $mysoc->country_code).' ';
+							$totalvat.=vatrate(abs($tvakey), 1).$tvacompl;
+							$pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1);
+
+							$pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
+							$pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1);
 						}
 					}
+				}
 	      		//}
 				//Local tax 2 before VAT
 				//if (! empty($conf->global->FACTURE_LOCAL_TAX2_OPTION) && $conf->global->FACTURE_LOCAL_TAX2_OPTION=='localtax2on')
 				//{
-					foreach($this->localtax2 as $localtax_type => $localtax_rate)
+				foreach($this->localtax2 as $localtax_type => $localtax_rate)
+				{
+					if (in_array((string) $localtax_type, array('1','3','5'))) continue;
+					foreach($localtax_rate as $tvakey => $tvaval)
 					{
-						if (in_array((string) $localtax_type, array('1','3','5'))) continue;
-						foreach($localtax_rate as $tvakey => $tvaval)
+						if ($tvakey!=0)    // On affiche pas taux 0
 						{
-							if ($tvakey!=0)    // On affiche pas taux 0
-							{
-								//$this->atleastoneratenotnull++;
+							//$this->atleastoneratenotnull++;
 
+							$index++;
+							$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
 
-
-								$index++;
-								$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
-
-								$tvacompl='';
-								if (preg_match('/\*/', $tvakey))
-								{
-									$tvakey=str_replace('*', '', $tvakey);
-									$tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")";
-								}
-								$totalvat = $outputlangs->transcountrynoentities("TotalLT2", $mysoc->country_code).' ';
-								$totalvat.=vatrate(abs($tvakey), 1).$tvacompl;
-								$pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1);
-
-								$pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
-								$pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1);
+							$tvacompl='';
+							if (preg_match('/\*/', $tvakey))
+							{
+								$tvakey=str_replace('*', '', $tvakey);
+								$tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")";
 							}
+							$totalvat = $outputlangs->transcountrynoentities("TotalLT2", $mysoc->country_code).' ';
+							$totalvat.=vatrate(abs($tvakey), 1).$tvacompl;
+							$pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1);
+
+							$pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
+							$pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1);
 						}
 					}
+				}
 				//}
 				// VAT
 				foreach($this->tva as $tvakey => $tvaval)
@@ -1001,67 +999,67 @@ class pdf_einstein extends ModelePDFCommandes
 				//Local tax 1 after VAT
 				//if (! empty($conf->global->FACTURE_LOCAL_TAX1_OPTION) && $conf->global->FACTURE_LOCAL_TAX1_OPTION=='localtax1on')
 				//{
-					foreach($this->localtax1 as $localtax_type => $localtax_rate)
-					{
-						if (in_array((string) $localtax_type, array('2','4','6'))) continue;
+				foreach($this->localtax1 as $localtax_type => $localtax_rate)
+				{
+					if (in_array((string) $localtax_type, array('2','4','6'))) continue;
 
-						foreach($localtax_rate as $tvakey => $tvaval)
+					foreach($localtax_rate as $tvakey => $tvaval)
+					{
+						if ($tvakey != 0)    // On affiche pas taux 0
 						{
-							if ($tvakey != 0)    // On affiche pas taux 0
+							//$this->atleastoneratenotnull++;
+
+							$index++;
+							$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
+
+							$tvacompl='';
+							if (preg_match('/\*/', $tvakey))
 							{
-								//$this->atleastoneratenotnull++;
-
-								$index++;
-								$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
-
-								$tvacompl='';
-								if (preg_match('/\*/', $tvakey))
-								{
-									$tvakey=str_replace('*', '', $tvakey);
-									$tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")";
-								}
-								$totalvat = $outputlangs->transcountrynoentities("TotalLT1", $mysoc->country_code).' ';
-
-								$totalvat.=vatrate(abs($tvakey), 1).$tvacompl;
-								$pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1);
-								$pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
-								$pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1);
+								$tvakey=str_replace('*', '', $tvakey);
+								$tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")";
 							}
+							$totalvat = $outputlangs->transcountrynoentities("TotalLT1", $mysoc->country_code).' ';
+
+							$totalvat.=vatrate(abs($tvakey), 1).$tvacompl;
+							$pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1);
+							$pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
+							$pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1);
 						}
 					}
+				}
 	      		//}
 				//Local tax 2 after VAT
 				//if (! empty($conf->global->FACTURE_LOCAL_TAX2_OPTION) && $conf->global->FACTURE_LOCAL_TAX2_OPTION=='localtax2on')
 				//{
-					foreach($this->localtax2 as $localtax_type => $localtax_rate)
-					{
-						if (in_array((string) $localtax_type, array('2','4','6'))) continue;
+				foreach($this->localtax2 as $localtax_type => $localtax_rate)
+				{
+					if (in_array((string) $localtax_type, array('2','4','6'))) continue;
 
-						foreach($localtax_rate as $tvakey => $tvaval)
+					foreach($localtax_rate as $tvakey => $tvaval)
+					{
+						if ($tvakey != 0)    // On affiche pas taux 0
 						{
-							if ($tvakey != 0)    // On affiche pas taux 0
-							{
-								//$this->atleastoneratenotnull++;
+							//$this->atleastoneratenotnull++;
 
-								$index++;
-								$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
+							$index++;
+							$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
 
-								$tvacompl='';
-								if (preg_match('/\*/', $tvakey))
-								{
-									$tvakey=str_replace('*', '', $tvakey);
-									$tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")";
-								}
-								$totalvat = $outputlangs->transcountrynoentities("TotalLT2", $mysoc->country_code).' ';
+							$tvacompl='';
+							if (preg_match('/\*/', $tvakey))
+							{
+								$tvakey=str_replace('*', '', $tvakey);
+								$tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")";
+							}
+							$totalvat = $outputlangs->transcountrynoentities("TotalLT2", $mysoc->country_code).' ';
 
-								$totalvat.=vatrate(abs($tvakey), 1).$tvacompl;
-								$pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1);
+							$totalvat.=vatrate(abs($tvakey), 1).$tvacompl;
+							$pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1);
 
-								$pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
-								$pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1);
-							}
+							$pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
+							$pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1);
 						}
 					}
+				}
 				//}
 
 				// Total TTC

+ 86 - 89
htdocs/core/modules/commande/doc/pdf_eratosthene.modules.php

@@ -1,13 +1,13 @@
 <?php
-/* Copyright (C) 2004-2014	Laurent Destailleur	<eldy@users.sourceforge.net>
- * Copyright (C) 2005-2012	Regis Houssin		<regis.houssin@inodbox.com>
+/* Copyright (C) 2004-2014  Laurent Destailleur <eldy@users.sourceforge.net>
+ * Copyright (C) 2005-2012  Regis Houssin		<regis.houssin@inodbox.com>
  * Copyright (C) 2008		Raphael Bertrand	<raphael.bertrand@resultic.fr>
  * Copyright (C) 2010-2013	Juanjo Menent		<jmenent@2byte.es>
  * Copyright (C) 2012      	Christophe Battarel <christophe.battarel@altairis.fr>
  * Copyright (C) 2012       Cedric Salvador     <csalvador@gpcsolutions.fr>
  * Copyright (C) 2015       Marcos García       <marcosgdf@gmail.com>
  * Copyright (C) 2017       Ferran Marcet       <fmarcet@2byte.es>
- * Copyright (C) 2018       Frédéric France     <frederic.france@netlogic.fr>
+ * Copyright (C) 2018-2019  Frédéric France     <frederic.france@netlogic.fr>
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -1099,66 +1099,63 @@ class pdf_eratosthene extends ModelePDFCommandes
 				//Local tax 1 before VAT
 				//if (! empty($conf->global->FACTURE_LOCAL_TAX1_OPTION) && $conf->global->FACTURE_LOCAL_TAX1_OPTION=='localtax1on')
 				//{
-					foreach($this->localtax1 as $localtax_type => $localtax_rate)
+				foreach($this->localtax1 as $localtax_type => $localtax_rate)
+				{
+					if (in_array((string) $localtax_type, array('1','3','5'))) continue;
+					foreach($localtax_rate as $tvakey => $tvaval)
 					{
-						if (in_array((string) $localtax_type, array('1','3','5'))) continue;
-						foreach($localtax_rate as $tvakey => $tvaval)
+						if ($tvakey!=0)    // On affiche pas taux 0
 						{
-							if ($tvakey!=0)    // On affiche pas taux 0
+							//$this->atleastoneratenotnull++;
+							$index++;
+							$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
+
+							$tvacompl='';
+							if (preg_match('/\*/', $tvakey))
 							{
-								//$this->atleastoneratenotnull++;
-
-								$index++;
-								$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
-
-								$tvacompl='';
-								if (preg_match('/\*/', $tvakey))
-								{
-									$tvakey=str_replace('*', '', $tvakey);
-									$tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")";
-								}
-								$totalvat = $outputlangs->transcountrynoentities("TotalLT1", $mysoc->country_code).' ';
-								$totalvat.=vatrate(abs($tvakey), 1).$tvacompl;
-								$pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1);
-
-								$pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
-								$pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1);
+								$tvakey=str_replace('*', '', $tvakey);
+								$tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")";
 							}
+							$totalvat = $outputlangs->transcountrynoentities("TotalLT1", $mysoc->country_code).' ';
+							$totalvat.=vatrate(abs($tvakey), 1).$tvacompl;
+							$pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1);
+
+							$pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
+							$pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1);
 						}
 					}
+				}
 	      		//}
 				//Local tax 2 before VAT
 				//if (! empty($conf->global->FACTURE_LOCAL_TAX2_OPTION) && $conf->global->FACTURE_LOCAL_TAX2_OPTION=='localtax2on')
 				//{
-					foreach($this->localtax2 as $localtax_type => $localtax_rate)
+				foreach($this->localtax2 as $localtax_type => $localtax_rate)
+				{
+					if (in_array((string) $localtax_type, array('1','3','5'))) continue;
+					foreach($localtax_rate as $tvakey => $tvaval)
 					{
-						if (in_array((string) $localtax_type, array('1','3','5'))) continue;
-						foreach($localtax_rate as $tvakey => $tvaval)
+						if ($tvakey!=0)    // On affiche pas taux 0
 						{
-							if ($tvakey!=0)    // On affiche pas taux 0
-							{
-								//$this->atleastoneratenotnull++;
-
+							//$this->atleastoneratenotnull++;
 
+							$index++;
+							$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
 
-								$index++;
-								$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
-
-								$tvacompl='';
-								if (preg_match('/\*/', $tvakey))
-								{
-									$tvakey=str_replace('*', '', $tvakey);
-									$tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")";
-								}
-								$totalvat = $outputlangs->transcountrynoentities("TotalLT2", $mysoc->country_code).' ';
-								$totalvat.=vatrate(abs($tvakey), 1).$tvacompl;
-								$pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1);
-
-								$pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
-								$pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1);
+							$tvacompl='';
+							if (preg_match('/\*/', $tvakey))
+							{
+								$tvakey=str_replace('*', '', $tvakey);
+								$tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")";
 							}
+							$totalvat = $outputlangs->transcountrynoentities("TotalLT2", $mysoc->country_code).' ';
+							$totalvat.=vatrate(abs($tvakey), 1).$tvacompl;
+							$pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1);
+
+							$pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
+							$pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1);
 						}
 					}
+				}
 				//}
 				// VAT
 				foreach($this->tva as $tvakey => $tvaval)
@@ -1188,67 +1185,67 @@ class pdf_eratosthene extends ModelePDFCommandes
 				//Local tax 1 after VAT
 				//if (! empty($conf->global->FACTURE_LOCAL_TAX1_OPTION) && $conf->global->FACTURE_LOCAL_TAX1_OPTION=='localtax1on')
 				//{
-					foreach($this->localtax1 as $localtax_type => $localtax_rate)
-					{
-						if (in_array((string) $localtax_type, array('2','4','6'))) continue;
+				foreach($this->localtax1 as $localtax_type => $localtax_rate)
+				{
+					if (in_array((string) $localtax_type, array('2','4','6'))) continue;
 
-						foreach($localtax_rate as $tvakey => $tvaval)
+					foreach($localtax_rate as $tvakey => $tvaval)
+					{
+						if ($tvakey != 0)    // On affiche pas taux 0
 						{
-							if ($tvakey != 0)    // On affiche pas taux 0
+							//$this->atleastoneratenotnull++;
+
+							$index++;
+							$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
+
+							$tvacompl='';
+							if (preg_match('/\*/', $tvakey))
 							{
-								//$this->atleastoneratenotnull++;
-
-								$index++;
-								$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
-
-								$tvacompl='';
-								if (preg_match('/\*/', $tvakey))
-								{
-									$tvakey=str_replace('*', '', $tvakey);
-									$tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")";
-								}
-								$totalvat = $outputlangs->transcountrynoentities("TotalLT1", $mysoc->country_code).' ';
-
-								$totalvat.=vatrate(abs($tvakey), 1).$tvacompl;
-								$pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1);
-								$pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
-								$pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1);
+								$tvakey=str_replace('*', '', $tvakey);
+								$tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")";
 							}
+							$totalvat = $outputlangs->transcountrynoentities("TotalLT1", $mysoc->country_code).' ';
+
+							$totalvat.=vatrate(abs($tvakey), 1).$tvacompl;
+							$pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1);
+							$pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
+							$pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1);
 						}
 					}
+				}
 	      		//}
 				//Local tax 2 after VAT
 				//if (! empty($conf->global->FACTURE_LOCAL_TAX2_OPTION) && $conf->global->FACTURE_LOCAL_TAX2_OPTION=='localtax2on')
 				//{
-					foreach($this->localtax2 as $localtax_type => $localtax_rate)
-					{
-						if (in_array((string) $localtax_type, array('2','4','6'))) continue;
+				foreach($this->localtax2 as $localtax_type => $localtax_rate)
+				{
+					if (in_array((string) $localtax_type, array('2','4','6'))) continue;
 
-						foreach($localtax_rate as $tvakey => $tvaval)
+					foreach($localtax_rate as $tvakey => $tvaval)
+					{
+						if ($tvakey != 0)    // On affiche pas taux 0
 						{
-							if ($tvakey != 0)    // On affiche pas taux 0
-							{
-								//$this->atleastoneratenotnull++;
+							//$this->atleastoneratenotnull++;
 
-								$index++;
-								$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
+							$index++;
+							$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
 
-								$tvacompl='';
-								if (preg_match('/\*/', $tvakey))
-								{
-									$tvakey=str_replace('*', '', $tvakey);
-									$tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")";
-								}
-								$totalvat = $outputlangs->transcountrynoentities("TotalLT2", $mysoc->country_code).' ';
+							$tvacompl='';
+							if (preg_match('/\*/', $tvakey))
+							{
+								$tvakey=str_replace('*', '', $tvakey);
+								$tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")";
+							}
+							$totalvat = $outputlangs->transcountrynoentities("TotalLT2", $mysoc->country_code).' ';
 
-								$totalvat.=vatrate(abs($tvakey), 1).$tvacompl;
-								$pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1);
+							$totalvat.=vatrate(abs($tvakey), 1).$tvacompl;
+							$pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1);
 
-								$pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
-								$pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1);
-							}
+							$pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
+							$pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1);
 						}
 					}
+				}
 				//}
 
 				// Total TTC

+ 2 - 2
htdocs/core/modules/contract/doc/doc_generic_contract_odt.modules.php

@@ -342,7 +342,7 @@ class doc_generic_contract_odt extends ModelePDFContract
 				// Open and load template
 				require_once ODTPHP_PATH.'odf.php';
 				try {
-    $odfHandler = new odf(
+                    $odfHandler = new odf(
 						$srctemplatepath,
 						array(
 						'PATH_TO_TMP'	  => $conf->contrat->dir_temp,
@@ -470,7 +470,7 @@ class doc_generic_contract_odt extends ModelePDFContract
 				}
 				else {
 					try {
-					$odfHandler->saveToDisk($file);
+					    $odfHandler->saveToDisk($file);
 					} catch (Exception $e) {
 						$this->error=$e->getMessage();
 						return -1;

+ 34 - 36
htdocs/core/modules/dons/html_cerfafr.modules.php

@@ -322,82 +322,80 @@ class html_cerfafr extends ModeleDon
 			}
 			elseif ($dix[$i]==2) {
 				if ($unite[$i]==1) {
-				$secon[$i]='vingt et';
-				$prim[$i]=$chif[$unite[$i]];
-				}
-				else {
-				$secon[$i]='vingt';
-				$prim[$i]=$chif[$unite[$i]];
+                    $secon[$i]='vingt et';
+                    $prim[$i]=$chif[$unite[$i]];
+				} else {
+                    $secon[$i]='vingt';
+                    $prim[$i]=$chif[$unite[$i]];
 				}
 			}
 			elseif ($dix[$i]==3) {
 				if ($unite[$i]==1) {
-				$secon[$i]='trente et';
-				$prim[$i]=$chif[$unite[$i]];
-				}
-				else {
-				$secon[$i]='trente';
-				$prim[$i]=$chif[$unite[$i]];
+                    $secon[$i]='trente et';
+                    $prim[$i]=$chif[$unite[$i]];
+				} else {
+                    $secon[$i]='trente';
+                    $prim[$i]=$chif[$unite[$i]];
 				}
 			}
 			elseif ($dix[$i]==4) {
 				if ($unite[$i]==1) {
-				$secon[$i]='quarante et';
-				$prim[$i]=$chif[$unite[$i]];
+                    $secon[$i]='quarante et';
+                    $prim[$i]=$chif[$unite[$i]];
 				}
 				else {
-				$secon[$i]='quarante';
-				$prim[$i]=$chif[$unite[$i]];
+                    $secon[$i]='quarante';
+                    $prim[$i]=$chif[$unite[$i]];
 				}
 			}
 			elseif ($dix[$i]==5) {
 				if ($unite[$i]==1) {
-				$secon[$i]='cinquante et';
-				$prim[$i]=$chif[$unite[$i]];
+                    $secon[$i]='cinquante et';
+                    $prim[$i]=$chif[$unite[$i]];
 				}
 				else {
-				$secon[$i]='cinquante';
-				$prim[$i]=$chif[$unite[$i]];
+                    $secon[$i]='cinquante';
+                    $prim[$i]=$chif[$unite[$i]];
 				}
 			}
 			elseif ($dix[$i]==6) {
 				if ($unite[$i]==1) {
-				$secon[$i]='soixante et';
-				$prim[$i]=$chif[$unite[$i]];
+                    $secon[$i]='soixante et';
+                    $prim[$i]=$chif[$unite[$i]];
 				}
 				else {
-				$secon[$i]='soixante';
-				$prim[$i]=$chif[$unite[$i]];
+                    $secon[$i]='soixante';
+                    $prim[$i]=$chif[$unite[$i]];
 				}
 			}
 			elseif ($dix[$i]==7) {
 				if ($unite[$i]==1) {
-				$secon[$i]='soixante et';
-				$prim[$i]=$chif[$unite[$i]+10];
+                    $secon[$i]='soixante et';
+                    $prim[$i]=$chif[$unite[$i]+10];
 				}
 				else {
-				$secon[$i]='soixante';
-				$prim[$i]=$chif[$unite[$i]+10];
+                    $secon[$i]='soixante';
+                    $prim[$i]=$chif[$unite[$i]+10];
 				}
 			}
 			elseif ($dix[$i]==8) {
 				if ($unite[$i]==1) {
-				$secon[$i]='quatre-vingts et';
-				$prim[$i]=$chif[$unite[$i]];
+                    $secon[$i]='quatre-vingts et';
+                    $prim[$i]=$chif[$unite[$i]];
 				}
 				else {
-				$secon[$i]='quatre-vingt';
-				$prim[$i]=$chif[$unite[$i]];
+                    $secon[$i]='quatre-vingt';
+                    $prim[$i]=$chif[$unite[$i]];
 				}
 			}
 			elseif ($dix[$i]==9) {
 				if ($unite[$i]==1) {
-				$secon[$i]='quatre-vingts et';
-				$prim[$i]=$chif[$unite[$i]+10];
+                    $secon[$i]='quatre-vingts et';
+                    $prim[$i]=$chif[$unite[$i]+10];
 				}
 				else {
-				$secon[$i]='quatre-vingts';
-				$prim[$i]=$chif[$unite[$i]+10];
+                    $secon[$i]='quatre-vingts';
+                    $prim[$i]=$chif[$unite[$i]+10];
 				}
 			}
 			if($cent[$i]==1) $trio[$i]='cent';

+ 1 - 1
htdocs/core/modules/expedition/doc/doc_generic_shipment_odt.modules.php

@@ -562,7 +562,7 @@ class doc_generic_shipment_odt extends ModelePdfExpedition
 				}
 				else {
 					try {
-					$odfHandler->saveToDisk($file);
+					    $odfHandler->saveToDisk($file);
 					} catch (Exception $e) {
 						$this->error=$e->getMessage();
                         dol_syslog($e->getMessage(), LOG_INFO);

+ 20 - 21
htdocs/core/modules/expedition/doc/pdf_rouget.modules.php

@@ -218,26 +218,25 @@ class pdf_rouget extends ModelePdfExpedition
 
 				$realpath='';
 
-                foreach ($objphoto->liste_photos($dir, 1) as $key => $obj)
+                foreach ($objphoto->liste_photos($dir, 1) as $key => $obj) {
+                    if (empty($conf->global->CAT_HIGH_QUALITY_IMAGES)) {
+                        // If CAT_HIGH_QUALITY_IMAGES not defined, we use thumb if defined and then original photo
+                        if ($obj['photo_vignette'])
                         {
-                            if (empty($conf->global->CAT_HIGH_QUALITY_IMAGES))		// If CAT_HIGH_QUALITY_IMAGES not defined, we use thumb if defined and then original photo
-                            {
-                                if ($obj['photo_vignette'])
-                                {
-                                    $filename= $obj['photo_vignette'];
-                                }
-                                else
-                                {
-                                    $filename=$obj['photo'];
-                                }
-                            }
-                            else
-                            {
-                                $filename=$obj['photo'];
-                            }
-
-                            $realpath = $dir.$filename;
-                            break;
+                            $filename= $obj['photo_vignette'];
+                        }
+                        else
+                        {
+                            $filename=$obj['photo'];
+                        }
+                    }
+                    else
+                    {
+                        $filename=$obj['photo'];
+                    }
+
+                    $realpath = $dir.$filename;
+                    break;
                 }
 
                 if ($realpath) $realpatharray[$i]=$realpath;
@@ -541,8 +540,8 @@ class pdf_rouget extends ModelePdfExpedition
 
 					if (empty($conf->global->SHIPPING_PDF_HIDE_ORDERED))
 					{
-					   $pdf->SetXY($this->posxqtyordered, $curY);
-					   $pdf->MultiCell(($this->posxqtytoship - $this->posxqtyordered), 3, $object->lines[$i]->qty_asked, '', 'C');
+					    $pdf->SetXY($this->posxqtyordered, $curY);
+					    $pdf->MultiCell(($this->posxqtytoship - $this->posxqtyordered), 3, $object->lines[$i]->qty_asked, '', 'C');
 					}
 
 					if (empty($conf->global->SHIPPING_PDF_HIDE_QTYTOSHIP))

+ 13 - 13
htdocs/core/modules/expensereport/mod_expensereport_jade.php

@@ -139,19 +139,19 @@ class mod_expensereport_jade extends ModeleNumRefExpenseReport
 
 			$result = $db->query($sql);
 
-			if($db->num_rows($result) > 0):
-			$objp = $db->fetch_object($result);
-			$newref = $objp->max;
-			$newref++;
-			while(strlen($newref) < $num_car):
-				$newref = "0".$newref;
-			endwhile;
-			else:
-				$newref = 1;
-			while(strlen($newref) < $num_car):
-				$newref = "0".$newref;
-			endwhile;
-			endif;
+            if ($db->num_rows($result) > 0) {
+                $objp = $db->fetch_object($result);
+                $newref = $objp->max;
+                $newref++;
+                while (strlen($newref) < $num_car) {
+                    $newref = "0".$newref;
+                }
+            } else {
+                $newref = 1;
+                while (strlen($newref) < $num_car) {
+                    $newref = "0".$newref;
+                }
+            }
 
 			$ref_number_int = ($newref+1)-1;
 

+ 1 - 1
htdocs/core/modules/facture/doc/doc_generic_invoice_odt.modules.php

@@ -344,7 +344,7 @@ class doc_generic_invoice_odt extends ModelePDFFactures
 				// Open and load template
 				require_once ODTPHP_PATH.'odf.php';
 				try {
-    $odfHandler = new odf(
+                    $odfHandler = new odf(
 						$srctemplatepath,
 						array(
 						'PATH_TO_TMP'	  => $conf->facture->dir_temp,

+ 79 - 80
htdocs/core/modules/facture/doc/pdf_crabe.modules.php

@@ -1177,69 +1177,69 @@ class pdf_crabe extends ModelePDFFactures
 				//Local tax 1 before VAT
 				//if (! empty($conf->global->FACTURE_LOCAL_TAX1_OPTION) && $conf->global->FACTURE_LOCAL_TAX1_OPTION=='localtax1on')
 				//{
-					foreach($this->localtax1 as $localtax_type => $localtax_rate)
-					{
-						if (in_array((string) $localtax_type, array('1','3','5'))) continue;
+				foreach($this->localtax1 as $localtax_type => $localtax_rate)
+				{
+					if (in_array((string) $localtax_type, array('1','3','5'))) continue;
 
-						foreach($localtax_rate as $tvakey => $tvaval)
+					foreach($localtax_rate as $tvakey => $tvaval)
+					{
+						if ($tvakey!=0)    // On affiche pas taux 0
 						{
-							if ($tvakey!=0)    // On affiche pas taux 0
-							{
-								//$this->atleastoneratenotnull++;
+							//$this->atleastoneratenotnull++;
 
-								$index++;
-								$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
+							$index++;
+							$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
 
-								$tvacompl='';
-								if (preg_match('/\*/', $tvakey))
-								{
-									$tvakey=str_replace('*', '', $tvakey);
-									$tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")";
-								}
+							$tvacompl='';
+							if (preg_match('/\*/', $tvakey))
+							{
+								$tvakey=str_replace('*', '', $tvakey);
+								$tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")";
+							}
 
-								$totalvat = $outputlangs->transcountrynoentities("TotalLT1", $mysoc->country_code).' ';
-								$totalvat.=vatrate(abs($tvakey), 1).$tvacompl;
-								$pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1);
+							$totalvat = $outputlangs->transcountrynoentities("TotalLT1", $mysoc->country_code).' ';
+							$totalvat.=vatrate(abs($tvakey), 1).$tvacompl;
+							$pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1);
 
-								$pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
-								$pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1);
-							}
+							$pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
+							$pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1);
 						}
 					}
+				}
 	      		//}
 				//Local tax 2 before VAT
 				//if (! empty($conf->global->FACTURE_LOCAL_TAX2_OPTION) && $conf->global->FACTURE_LOCAL_TAX2_OPTION=='localtax2on')
 				//{
-					foreach($this->localtax2 as $localtax_type => $localtax_rate)
-					{
-						if (in_array((string) $localtax_type, array('1','3','5'))) continue;
+				foreach($this->localtax2 as $localtax_type => $localtax_rate)
+				{
+					if (in_array((string) $localtax_type, array('1','3','5'))) continue;
 
-						foreach($localtax_rate as $tvakey => $tvaval)
+					foreach($localtax_rate as $tvakey => $tvaval)
+					{
+						if ($tvakey!=0)    // On affiche pas taux 0
 						{
-							if ($tvakey!=0)    // On affiche pas taux 0
-							{
-								//$this->atleastoneratenotnull++;
-
+							//$this->atleastoneratenotnull++;
 
 
-								$index++;
-								$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
 
-								$tvacompl='';
-								if (preg_match('/\*/', $tvakey))
-								{
-									$tvakey=str_replace('*', '', $tvakey);
-									$tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")";
-								}
-								$totalvat = $outputlangs->transcountrynoentities("TotalLT2", $mysoc->country_code).' ';
-								$totalvat.=vatrate(abs($tvakey), 1).$tvacompl;
-								$pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1);
+							$index++;
+							$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
 
-								$pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
-								$pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1);
+							$tvacompl='';
+							if (preg_match('/\*/', $tvakey))
+							{
+								$tvakey=str_replace('*', '', $tvakey);
+								$tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")";
 							}
+							$totalvat = $outputlangs->transcountrynoentities("TotalLT2", $mysoc->country_code).' ';
+							$totalvat.=vatrate(abs($tvakey), 1).$tvacompl;
+							$pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1);
+
+							$pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
+							$pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1);
 						}
 					}
+				}
 
                 //}
 
@@ -1271,43 +1271,12 @@ class pdf_crabe extends ModelePDFFactures
 				//Local tax 1 after VAT
 				//if (! empty($conf->global->FACTURE_LOCAL_TAX1_OPTION) && $conf->global->FACTURE_LOCAL_TAX1_OPTION=='localtax1on')
 				//{
-					foreach($this->localtax1 as $localtax_type => $localtax_rate)
-					{
-						if (in_array((string) $localtax_type, array('2','4','6'))) continue;
+				foreach ($this->localtax1 as $localtax_type => $localtax_rate) {
+					if (in_array((string) $localtax_type, array('2','4','6'))) continue;
 
-						foreach($localtax_rate as $tvakey => $tvaval)
-						{
-							if ($tvakey != 0)    // On affiche pas taux 0
-							{
-								//$this->atleastoneratenotnull++;
-
-								$index++;
-								$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
-
-								$tvacompl='';
-								if (preg_match('/\*/', $tvakey))
-								{
-									$tvakey=str_replace('*', '', $tvakey);
-									$tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")";
-								}
-								$totalvat = $outputlangs->transcountrynoentities("TotalLT1", $mysoc->country_code).' ';
-								$totalvat.=vatrate(abs($tvakey), 1).$tvacompl;
-
-								$pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1);
-								$pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
-								$pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1);
-							}
-						}
-					}
-	      		//}
-				//Local tax 2 after VAT
-				//if (! empty($conf->global->FACTURE_LOCAL_TAX2_OPTION) && $conf->global->FACTURE_LOCAL_TAX2_OPTION=='localtax2on')
-				//{
-					foreach($this->localtax2 as $localtax_type => $localtax_rate)
+					foreach($localtax_rate as $tvakey => $tvaval)
 					{
-						if (in_array((string) $localtax_type, array('2','4','6'))) continue;
-
-						foreach($localtax_rate as $tvakey => $tvaval)
+						if ($tvakey != 0)    // On affiche pas taux 0
 						{
 							//$this->atleastoneratenotnull++;
 
@@ -1320,15 +1289,45 @@ class pdf_crabe extends ModelePDFFactures
 								$tvakey=str_replace('*', '', $tvakey);
 								$tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")";
 							}
-							$totalvat = $outputlangs->transcountrynoentities("TotalLT2", $mysoc->country_code).' ';
-
+							$totalvat = $outputlangs->transcountrynoentities("TotalLT1", $mysoc->country_code).' ';
 							$totalvat.=vatrate(abs($tvakey), 1).$tvacompl;
-							$pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1);
 
+							$pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1);
 							$pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
 							$pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1);
 						}
 					}
+				}
+	      		//}
+				//Local tax 2 after VAT
+				//if (! empty($conf->global->FACTURE_LOCAL_TAX2_OPTION) && $conf->global->FACTURE_LOCAL_TAX2_OPTION=='localtax2on')
+				//{
+				foreach($this->localtax2 as $localtax_type => $localtax_rate)
+				{
+					if (in_array((string) $localtax_type, array('2','4','6'))) continue;
+
+					foreach($localtax_rate as $tvakey => $tvaval)
+					{
+						//$this->atleastoneratenotnull++;
+
+						$index++;
+						$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
+
+						$tvacompl='';
+						if (preg_match('/\*/', $tvakey))
+						{
+							$tvakey=str_replace('*', '', $tvakey);
+							$tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")";
+						}
+						$totalvat = $outputlangs->transcountrynoentities("TotalLT2", $mysoc->country_code).' ';
+
+						$totalvat.=vatrate(abs($tvakey), 1).$tvacompl;
+						$pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1);
+
+						$pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
+						$pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1);
+					}
+				}
 				//}
 
 				// Revenue stamp

+ 151 - 160
htdocs/core/modules/facture/doc/pdf_sponge.modules.php

@@ -371,10 +371,10 @@ class pdf_sponge extends ModelePDFFactures
 
 	            // Does we have at least one line with discount $this->atleastonediscount
 	            foreach ($object->lines as $line) {
-	               if ($line->remise_percent){
+                    if ($line->remise_percent) {
 	                    $this->atleastonediscount = true;
 	                    break;
-	               }
+	                }
 	            }
 
 
@@ -769,65 +769,62 @@ class pdf_sponge extends ModelePDFFactures
 	                }
 
 	                // retrieve global local tax
-	                if ($localtax1_type && $localtax1ligne != 0)
-	                    $this->localtax1[$localtax1_type][$localtax1_rate]+=$localtax1ligne;
-	                    if ($localtax2_type && $localtax2ligne != 0)
-	                        $this->localtax2[$localtax2_type][$localtax2_rate]+=$localtax2ligne;
-
-	                        if (($object->lines[$i]->info_bits & 0x01) == 0x01) $vatrate.='*';
-	                        if (! isset($this->tva[$vatrate])) 				$this->tva[$vatrate]=0;
-	                        $this->tva[$vatrate] += $tvaligne;
-
-	                        $nexY = max($nexY, $posYAfterImage);
-
-	                        // Add line
-	                        if (! empty($conf->global->MAIN_PDF_DASH_BETWEEN_LINES) && $i < ($nblines - 1))
-	                        {
-	                            $pdf->setPage($pageposafter);
-	                            $pdf->SetLineStyle(array('dash'=>'1,1','color'=>array(80,80,80)));
-	                            //$pdf->SetDrawColor(190,190,200);
-	                            $pdf->line($this->marge_gauche, $nexY+1, $this->page_largeur - $this->marge_droite, $nexY+1);
-	                            $pdf->SetLineStyle(array('dash'=>0));
-	                        }
-
-	                        $nexY+=2;    // Add space between lines
-
-	                        // Detect if some page were added automatically and output _tableau for past pages
-	                        while ($pagenb < $pageposafter)
-	                        {
-	                            $pdf->setPage($pagenb);
-	                            if ($pagenb == $pageposbeforeprintlines)
-	                            {
-	                                $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, $hidetop, 1, $object->multicurrency_code);
-	                            }
-	                            else
-	                            {
-	                                $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1, $object->multicurrency_code);
-	                            }
-	                            $this->_pagefoot($pdf, $object, $outputlangs, 1);
-	                            $pagenb++;
-	                            $pdf->setPage($pagenb);
-	                            $pdf->setPageOrientation('', 1, 0);	// The only function to edit the bottom margin of current page to set it.
-	                            if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
-	                        }
-
-	                        if (isset($object->lines[$i+1]->pagebreak) && $object->lines[$i+1]->pagebreak)
-	                        {
-	                            if ($pagenb == $pageposafter)
-	                            {
-	                                $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, $hidetop, 1, $object->multicurrency_code);
-	                            }
-	                            else
-	                            {
-	                                $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1, $object->multicurrency_code);
-	                            }
-	                            $this->_pagefoot($pdf, $object, $outputlangs, 1);
-	                            // New page
-	                            $pdf->AddPage();
-	                            if (! empty($tplidx)) $pdf->useTemplate($tplidx);
-	                            $pagenb++;
-	                            if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
-	                        }
+                    if ($localtax1_type && $localtax1ligne != 0) {
+                        $this->localtax1[$localtax1_type][$localtax1_rate]+=$localtax1ligne;
+                    }
+                    if ($localtax2_type && $localtax2ligne != 0) {
+                        $this->localtax2[$localtax2_type][$localtax2_rate]+=$localtax2ligne;
+                    }
+
+                    if (($object->lines[$i]->info_bits & 0x01) == 0x01) $vatrate.='*';
+                    if (! isset($this->tva[$vatrate])) 				$this->tva[$vatrate]=0;
+                    $this->tva[$vatrate] += $tvaligne;
+
+                    $nexY = max($nexY, $posYAfterImage);
+
+                    // Add line
+                    if (! empty($conf->global->MAIN_PDF_DASH_BETWEEN_LINES) && $i < ($nblines - 1)) {
+                        $pdf->setPage($pageposafter);
+                        $pdf->SetLineStyle(array('dash'=>'1,1','color'=>array(80,80,80)));
+                        //$pdf->SetDrawColor(190,190,200);
+                        $pdf->line($this->marge_gauche, $nexY+1, $this->page_largeur - $this->marge_droite, $nexY+1);
+                        $pdf->SetLineStyle(array('dash'=>0));
+                    }
+
+                    $nexY+=2;    // Add space between lines
+
+                    // Detect if some page were added automatically and output _tableau for past pages
+                    while ($pagenb < $pageposafter) {
+                        $pdf->setPage($pagenb);
+                        if ($pagenb == $pageposbeforeprintlines) {
+                            $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, $hidetop, 1, $object->multicurrency_code);
+                        }
+                        else
+                        {
+                            $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1, $object->multicurrency_code);
+                        }
+                        $this->_pagefoot($pdf, $object, $outputlangs, 1);
+                        $pagenb++;
+                        $pdf->setPage($pagenb);
+                        $pdf->setPageOrientation('', 1, 0);	// The only function to edit the bottom margin of current page to set it.
+                        if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
+                    }
+
+                    if (isset($object->lines[$i+1]->pagebreak) && $object->lines[$i+1]->pagebreak) {
+                        if ($pagenb == $pageposafter) {
+                            $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, $hidetop, 1, $object->multicurrency_code);
+                        }
+                        else
+                        {
+                            $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1, $object->multicurrency_code);
+                        }
+                        $this->_pagefoot($pdf, $object, $outputlangs, 1);
+                        // New page
+                        $pdf->AddPage();
+                        if (! empty($tplidx)) $pdf->useTemplate($tplidx);
+                        $pagenb++;
+                        if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
+                    }
 	            }
 
 	            // Show square
@@ -1266,14 +1263,11 @@ class pdf_sponge extends ModelePDFFactures
 
 		$deja_paye = 0;
 		$i = 1;
-		if(!empty($TPreviousIncoice)){
+		if (!empty($TPreviousIncoice)) {
 		    $pdf->setY($tab2_top);
 		    $posy = $pdf->GetY();
 
-
-
-
-		    foreach ($TPreviousIncoice as &$fac){
+		    foreach ($TPreviousIncoice as &$fac) {
 		        if($posy  > $this->page_hauteur - 4 ) {
 		            $this->_pagefoot($pdf, $object, $outputlangs, 1);
 		            $pdf->addPage();
@@ -1290,8 +1284,8 @@ class pdf_sponge extends ModelePDFFactures
 		        $pdf->SetXY($col2x, $posy);
 
 		        $facSign = '';
-		        if($i>1){
-		          $facSign = $fac->total_ht>=0?'+':'';
+		        if ($i>1) {
+		            $facSign = $fac->total_ht>=0?'+':'';
 		        }
 
 		        $displayAmount = ' '.$facSign.' '.price($fac->total_ht, 0, $outputlangs);
@@ -1312,11 +1306,11 @@ class pdf_sponge extends ModelePDFFactures
 
 		    $pdf->SetXY($col2x, $posy);
 		    $facSign = '';
-		    if($i>1){
+		    if ($i>1) {
 		        $facSign = $object->total_ht>=0?'+':''; // management of a particular customer case
 		    }
 
-		    if($fac->type === facture::TYPE_CREDIT_NOTE){
+		    if ($fac->type === facture::TYPE_CREDIT_NOTE) {
 		        $facSign = '-'; // les avoirs
 		    }
 
@@ -1375,7 +1369,7 @@ class pdf_sponge extends ModelePDFFactures
 		        $pdf->SetFillColor(255, 255, 255);
 		        $pdf->SetXY($col1x, $tab2_top + 0);
 		        $pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("TotalHTBeforeDiscount"), 0, 'L', 1);
-		$pdf->SetXY($col2x, $tab2_top + 0);
+                $pdf->SetXY($col2x, $tab2_top + 0);
 		        $pdf->MultiCell($largcol2, $tab2_hl, price($total_line_remise + $total_ht, 0, $outputlangs), 0, 'R', 1);
 
 		        $index++;
@@ -1410,70 +1404,67 @@ class pdf_sponge extends ModelePDFFactures
 				//Local tax 1 before VAT
 				//if (! empty($conf->global->FACTURE_LOCAL_TAX1_OPTION) && $conf->global->FACTURE_LOCAL_TAX1_OPTION=='localtax1on')
 				//{
-					foreach($this->localtax1 as $localtax_type => $localtax_rate)
-					{
-						if (in_array((string) $localtax_type, array('1', '3', '5'))) continue;
+				foreach($this->localtax1 as $localtax_type => $localtax_rate)
+				{
+					if (in_array((string) $localtax_type, array('1', '3', '5'))) continue;
 
-						foreach($localtax_rate as $tvakey => $tvaval)
+					foreach($localtax_rate as $tvakey => $tvaval)
+					{
+						if ($tvakey!=0)    // On affiche pas taux 0
 						{
-							if ($tvakey!=0)    // On affiche pas taux 0
-							{
-								//$this->atleastoneratenotnull++;
+							//$this->atleastoneratenotnull++;
 
-								$index++;
-								$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
+							$index++;
+							$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
 
-								$tvacompl='';
-								if (preg_match('/\*/', $tvakey))
-								{
-									$tvakey=str_replace('*', '', $tvakey);
-									$tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")";
-								}
+							$tvacompl='';
+							if (preg_match('/\*/', $tvakey))
+							{
+								$tvakey=str_replace('*', '', $tvakey);
+								$tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")";
+							}
 
-								$totalvat = $outputlangs->transcountrynoentities("TotalLT1", $mysoc->country_code).' ';
-								$totalvat.=vatrate(abs($tvakey), 1).$tvacompl;
-								$pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1);
+							$totalvat = $outputlangs->transcountrynoentities("TotalLT1", $mysoc->country_code).' ';
+							$totalvat.=vatrate(abs($tvakey), 1).$tvacompl;
+							$pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1);
 
-								$pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
-								$pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1);
-							}
+							$pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
+							$pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1);
 						}
 					}
+				}
 	      		//}
 				//Local tax 2 before VAT
 				//if (! empty($conf->global->FACTURE_LOCAL_TAX2_OPTION) && $conf->global->FACTURE_LOCAL_TAX2_OPTION=='localtax2on')
 				//{
-					foreach($this->localtax2 as $localtax_type => $localtax_rate)
-					{
-						if (in_array((string) $localtax_type, array('1','3','5'))) continue;
+				foreach($this->localtax2 as $localtax_type => $localtax_rate)
+				{
+					if (in_array((string) $localtax_type, array('1','3','5'))) continue;
 
-						foreach($localtax_rate as $tvakey => $tvaval)
+					foreach($localtax_rate as $tvakey => $tvaval)
+					{
+						if ($tvakey!=0)    // On affiche pas taux 0
 						{
-							if ($tvakey!=0)    // On affiche pas taux 0
-							{
-								//$this->atleastoneratenotnull++;
+							//$this->atleastoneratenotnull++;
 
+							$index++;
+							$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
 
-
-								$index++;
-								$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
-
-								$tvacompl='';
-								if (preg_match('/\*/', $tvakey))
-								{
-									$tvakey=str_replace('*', '', $tvakey);
-									$tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")";
-								}
-								$totalvat = $outputlangs->transcountrynoentities("TotalLT2", $mysoc->country_code).' ';
-								$totalvat.=vatrate(abs($tvakey), 1).$tvacompl;
-								$pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1);
-
-								$pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
-								$pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1);
+							$tvacompl='';
+							if (preg_match('/\*/', $tvakey))
+							{
+								$tvakey=str_replace('*', '', $tvakey);
+								$tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")";
 							}
+							$totalvat = $outputlangs->transcountrynoentities("TotalLT2", $mysoc->country_code).' ';
+							$totalvat.=vatrate(abs($tvakey), 1).$tvacompl;
+							$pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1);
+
+							$pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
+							$pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1);
 						}
 					}
-
+				}
                 //}
 
 				// VAT
@@ -1527,68 +1518,68 @@ class pdf_sponge extends ModelePDFFactures
 				//Local tax 1 after VAT
 				//if (! empty($conf->global->FACTURE_LOCAL_TAX1_OPTION) && $conf->global->FACTURE_LOCAL_TAX1_OPTION=='localtax1on')
 				//{
-					foreach($this->localtax1 as $localtax_type => $localtax_rate)
-					{
-						if (in_array((string) $localtax_type, array('2','4','6'))) continue;
+				foreach($this->localtax1 as $localtax_type => $localtax_rate)
+				{
+					if (in_array((string) $localtax_type, array('2','4','6'))) continue;
 
-						foreach($localtax_rate as $tvakey => $tvaval)
+					foreach($localtax_rate as $tvakey => $tvaval)
+					{
+						if ($tvakey != 0)    // On affiche pas taux 0
 						{
-							if ($tvakey != 0)    // On affiche pas taux 0
+							//$this->atleastoneratenotnull++;
+
+							$index++;
+							$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
+
+							$tvacompl='';
+							if (preg_match('/\*/', $tvakey))
 							{
-								//$this->atleastoneratenotnull++;
-
-								$index++;
-								$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
-
-								$tvacompl='';
-								if (preg_match('/\*/', $tvakey))
-								{
-									$tvakey=str_replace('*', '', $tvakey);
-									$tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")";
-								}
-								$totalvat = $outputlangs->transcountrynoentities("TotalLT1", $mysoc->country_code).' ';
-								$totalvat.=vatrate(abs($tvakey), 1).$tvacompl;
-
-								$pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1);
-								$pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
-								$pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1);
+								$tvakey=str_replace('*', '', $tvakey);
+								$tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")";
 							}
+							$totalvat = $outputlangs->transcountrynoentities("TotalLT1", $mysoc->country_code).' ';
+							$totalvat.=vatrate(abs($tvakey), 1).$tvacompl;
+
+							$pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1);
+							$pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
+							$pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1);
 						}
 					}
+				}
 	      		//}
 				//Local tax 2 after VAT
 				//if (! empty($conf->global->FACTURE_LOCAL_TAX2_OPTION) && $conf->global->FACTURE_LOCAL_TAX2_OPTION=='localtax2on')
 				//{
-					foreach($this->localtax2 as $localtax_type => $localtax_rate)
-					{
-						if (in_array((string) $localtax_type, array('2','4','6'))) continue;
+				foreach($this->localtax2 as $localtax_type => $localtax_rate)
+				{
+					if (in_array((string) $localtax_type, array('2','4','6'))) continue;
 
-						foreach($localtax_rate as $tvakey => $tvaval)
+					foreach($localtax_rate as $tvakey => $tvaval)
+					{
+					    // retrieve global local tax
+						if ($tvakey != 0)    // On affiche pas taux 0
 						{
-						    // retrieve global local tax
-							if ($tvakey != 0)    // On affiche pas taux 0
-							{
-								//$this->atleastoneratenotnull++;
+							//$this->atleastoneratenotnull++;
 
-								$index++;
-								$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
+							$index++;
+							$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
 
-								$tvacompl='';
-								if (preg_match('/\*/', $tvakey))
-								{
-									$tvakey=str_replace('*', '', $tvakey);
-									$tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")";
-								}
-								$totalvat = $outputlangs->transcountrynoentities("TotalLT2", $mysoc->country_code).' ';
+							$tvacompl='';
+							if (preg_match('/\*/', $tvakey))
+							{
+								$tvakey=str_replace('*', '', $tvakey);
+								$tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")";
+							}
+							$totalvat = $outputlangs->transcountrynoentities("TotalLT2", $mysoc->country_code).' ';
 
-								$totalvat.=vatrate(abs($tvakey), 1).$tvacompl;
-								$pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1);
+							$totalvat.=vatrate(abs($tvakey), 1).$tvacompl;
+							$pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1);
 
-								$pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
-								$pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1);
-							}
+							$pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
+							$pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1);
 						}
 					}
+				}
 
 
 				// Revenue stamp

+ 2 - 2
htdocs/core/modules/fichinter/doc/pdf_soleil.modules.php

@@ -502,7 +502,7 @@ class pdf_soleil extends ModelePDFFicheinter
 
 
 		$default_font_size = pdf_getPDFFontSize($outputlangs);
-/*
+        /*
 		$pdf->SetXY($this->marge_gauche, $tab_top);
 		$pdf->MultiCell(190,8,$outputlangs->transnoentities("Description"),0,'L',0);
 		$pdf->line($this->marge_gauche, $tab_top + 8, $this->page_largeur-$this->marge_droite, $tab_top + 8);
@@ -526,7 +526,7 @@ class pdf_soleil extends ModelePDFFicheinter
 		$pdf->line($this->marge_gauche, $nexY, $this->page_largeur-$this->marge_droite, $nexY);
 
 		$pdf->MultiCell(0, 3, '');		// Set interline to 3. Then writeMultiCell must use 3 also.
-*/
+        */
 
 		// Output Rect
 		$this->printRect($pdf, $this->marge_gauche, $tab_top, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $tab_height+1, 0, 0);	// Rect takes a length in 3rd parameter and 4th parameter

+ 2 - 2
htdocs/core/modules/import/import_csv.modules.php

@@ -217,9 +217,9 @@ class ImportCsv extends ModeleImports
 	 * 	@return		int		<0 if KO, >=0 if OK
 	 */
     public function import_get_nb_of_lines($file)
-	{
+    {
         // phpcs:enable
-       return dol_count_nb_of_line($file);
+        return dol_count_nb_of_line($file);
     }
 
 

+ 5 - 3
htdocs/core/modules/mailings/fraise.modules.php

@@ -255,9 +255,11 @@ class mailing_fraise extends MailingTargets
         $sql.= " WHERE a.entity IN (".getEntity('member').") AND a.email <> ''";     // Note that null != '' is false
         $sql.= " AND a.email NOT IN (SELECT email FROM ".MAIN_DB_PREFIX."mailing_cibles WHERE fk_mailing=".$this->db->escape($mailing_id).")";
         // Filter on status
-        if (isset($_POST["filter"]) && $_POST["filter"] == '-1') $sql.= " AND a.statut=-1";
-	if (isset($_POST["filter"]) && $_POST["filter"] == '1a') $sql.= " AND a.statut=1 AND (a.datefin >= '".$this->db->idate($now)."' OR ta.subscription = 0)";
-	if (isset($_POST["filter"]) && $_POST["filter"] == '1b') $sql.= " AND a.statut=1 AND ((a.datefin IS NULL or a.datefin < '".$this->db->idate($now)."') AND ta.subscription = 1)";
+        if (isset($_POST["filter"]) && $_POST["filter"] == '-1') {
+            $sql.= " AND a.statut=-1";
+        }
+        if (isset($_POST["filter"]) && $_POST["filter"] == '1a') $sql.= " AND a.statut=1 AND (a.datefin >= '".$this->db->idate($now)."' OR ta.subscription = 0)";
+        if (isset($_POST["filter"]) && $_POST["filter"] == '1b') $sql.= " AND a.statut=1 AND ((a.datefin IS NULL or a.datefin < '".$this->db->idate($now)."') AND ta.subscription = 1)";
         if (isset($_POST["filter"]) && $_POST["filter"] == '0')  $sql.= " AND a.statut=0";
         // Filter on date
         if ($dateendsubscriptionafter > 0)  $sql.=" AND datefin > '".$this->db->idate($dateendsubscriptionafter)."'";

+ 20 - 21
htdocs/core/modules/mailings/thirdparties.modules.php

@@ -288,29 +288,28 @@ class mailing_thirdparties extends MailingTargets
 		}
 
 		$s.='</select> ';
-                $s.= $langs->trans('ProspectCustomer');
-                $s.=': <select name="filter_client" class="flat">';
-                $s.= '<option value="-1">&nbsp;</option>';
-                if (empty($conf->global->SOCIETE_DISABLE_PROSPECTS))
-                {
-                    $s.= '<option value="2">'.$langs->trans('Prospect').'</option>';
-                }
-                if (empty($conf->global->SOCIETE_DISABLE_PROSPECTS) && empty($conf->global->SOCIETE_DISABLE_CUSTOMERS) && empty($conf->global->SOCIETE_DISABLE_PROSPECTSCUSTOMERS)) {
-                    $s.= '<option value="3">'.$langs->trans('ProspectCustomer').'</option>';
-                }
-                if (empty($conf->global->SOCIETE_DISABLE_CUSTOMERS)) {
-                    $s.= '<option value="1">'.$langs->trans('Customer').'</option>';
-                }
-                $s.= '<option value="0">'.$langs->trans('NorProspectNorCustomer').'</option>';
+        $s.= $langs->trans('ProspectCustomer');
+        $s.=': <select name="filter_client" class="flat">';
+        $s.= '<option value="-1">&nbsp;</option>';
+        if (empty($conf->global->SOCIETE_DISABLE_PROSPECTS)) {
+            $s.= '<option value="2">'.$langs->trans('Prospect').'</option>';
+        }
+        if (empty($conf->global->SOCIETE_DISABLE_PROSPECTS) && empty($conf->global->SOCIETE_DISABLE_CUSTOMERS) && empty($conf->global->SOCIETE_DISABLE_PROSPECTSCUSTOMERS)) {
+            $s.= '<option value="3">'.$langs->trans('ProspectCustomer').'</option>';
+        }
+        if (empty($conf->global->SOCIETE_DISABLE_CUSTOMERS)) {
+            $s.= '<option value="1">'.$langs->trans('Customer').'</option>';
+        }
+        $s.= '<option value="0">'.$langs->trans('NorProspectNorCustomer').'</option>';
 
-                $s.='</select> ';
+        $s.= '</select> ';
 
-                $s.=$langs->trans("Status");
-                $s.=': <select name="filter_status" class="flat">';
-                $s.='<option value="-1">&nbsp;</option>';
-                $s.='<option value="1" selected>'.$langs->trans("Enabled").'</option>';
-                $s.='<option value="0">'.$langs->trans("Disabled").'</option>';
-		$s.='</select>';
+        $s.= $langs->trans("Status");
+        $s.= ': <select name="filter_status" class="flat">';
+        $s.= '<option value="-1">&nbsp;</option>';
+        $s.= '<option value="1" selected>'.$langs->trans("Enabled").'</option>';
+        $s.= '<option value="0">'.$langs->trans("Disabled").'</option>';
+        $s.= '</select>';
 		return $s;
 	}
 

+ 11 - 10
htdocs/core/modules/modComptabilite.class.php

@@ -35,11 +35,11 @@ include_once DOL_DOCUMENT_ROOT .'/core/modules/DolibarrModules.class.php';
 class modComptabilite extends DolibarrModules
 {
 
-   /**
-	 *   Constructor. Define names, constants, directories, boxes, permissions
-	 *
-	 *   @param      DoliDB		$db      Database handler
-    */
+    /**
+     *   Constructor. Define names, constants, directories, boxes, permissions
+     *
+     *   @param      DoliDB		$db      Database handler
+     */
 	public function __construct($db)
 	{
 		global $conf;
@@ -72,11 +72,12 @@ class modComptabilite extends DolibarrModules
 		$this->const = array();
 
 		// Data directories to create when module is enabled
-		$this->dirs = array("/comptabilite/temp",
-		                    "/comptabilite/rapport",
-		                    "/comptabilite/export",
-		                    "/comptabilite/bordereau"
-		                    );
+        $this->dirs = array(
+            "/comptabilite/temp",
+            "/comptabilite/rapport",
+            "/comptabilite/export",
+            "/comptabilite/bordereau"
+        );
 
 		// Boxes
 		$this->boxes = array();

+ 4 - 4
htdocs/core/modules/modECM.class.php

@@ -32,10 +32,10 @@ include_once DOL_DOCUMENT_ROOT .'/core/modules/DolibarrModules.class.php';
 class modECM extends DolibarrModules
 {
 
-   /**
-	 *   Constructor. Define names, constants, directories, boxes, permissions
-	 *
-	 *   @param      DoliDB		$db      Database handler
+    /**
+     *   Constructor. Define names, constants, directories, boxes, permissions
+     *
+     *   @param      DoliDB		$db      Database handler
     */
     public function __construct($db)
 	{

+ 4 - 5
htdocs/core/modules/modExpedition.class.php

@@ -298,11 +298,10 @@ class modExpedition extends DolibarrModules
 		$this->export_sql_end[$r] .=' , '.MAIN_DB_PREFIX.'commandedet as cd';
 		$this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'product as p on cd.fk_product = p.rowid';
 		$this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'product_extrafields as extraprod ON p.rowid = extraprod.fk_object';
-		if ($idcontacts && ! empty($conf->global->SHIPMENT_ADD_CONTACTS_IN_EXPORT))
-		{
-		  $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'element_contact as ee ON ee.element_id = cd.fk_commande AND ee.fk_c_type_contact IN ('.$idcontacts.')';
-		  $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'socpeople as sp ON sp.rowid = ee.fk_socpeople';
-		  $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'socpeople_extrafields as extra3 ON sp.rowid = extra3.fk_object';
+		if ($idcontacts && ! empty($conf->global->SHIPMENT_ADD_CONTACTS_IN_EXPORT)) {
+		    $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'element_contact as ee ON ee.element_id = cd.fk_commande AND ee.fk_c_type_contact IN ('.$idcontacts.')';
+		    $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'socpeople as sp ON sp.rowid = ee.fk_socpeople';
+		    $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'socpeople_extrafields as extra3 ON sp.rowid = extra3.fk_object';
 		}
 		$this->export_sql_end[$r] .=' WHERE c.fk_soc = s.rowid AND c.rowid = ed.fk_expedition AND ed.fk_origin_line = cd.rowid';
 		$this->export_sql_end[$r] .=' AND c.entity IN ('.getEntity('expedition').')';

+ 4 - 5
htdocs/core/modules/modReception.class.php

@@ -223,11 +223,10 @@ class modReception extends DolibarrModules
 		$this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'commande_fournisseur_dispatch_extrafields as extra2 ON ed.rowid = extra2.fk_object';
 		$this->export_sql_end[$r] .=' , '.MAIN_DB_PREFIX.'commande_fournisseurdet as cd';
 		$this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'product as p on cd.fk_product = p.rowid';
-		if ($idcontacts && ! empty($conf->global->RECEPTION_ADD_CONTACTS_IN_EXPORT))
-		{
-		  $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'element_contact as ee ON ee.element_id = cd.fk_commande AND ee.fk_c_type_contact IN ('.$idcontacts.')';
-		  $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'socpeople as sp ON sp.rowid = ee.fk_socpeople';
-		  $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'socpeople_extrafields as extra3 ON sp.rowid = extra3.fk_object';
+		if ($idcontacts && ! empty($conf->global->RECEPTION_ADD_CONTACTS_IN_EXPORT)) {
+		    $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'element_contact as ee ON ee.element_id = cd.fk_commande AND ee.fk_c_type_contact IN ('.$idcontacts.')';
+		    $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'socpeople as sp ON sp.rowid = ee.fk_socpeople';
+		    $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'socpeople_extrafields as extra3 ON sp.rowid = extra3.fk_object';
 		}
 		$this->export_sql_end[$r] .=' WHERE c.fk_soc = s.rowid AND c.rowid = ed.fk_reception AND ed.fk_commandefourndet = cd.rowid';
 		$this->export_sql_end[$r] .=' AND c.entity IN ('.getEntity('reception').')';

+ 5 - 5
htdocs/core/modules/modSociete.class.php

@@ -148,7 +148,7 @@ class modSociete extends DolibarrModules
 		$this->rights[$r][3] = 0; // La permission est-elle une permission par defaut
 		$this->rights[$r][4] = 'lire';
 
-/*		$r++;
+        /*$r++;
 		$this->rights[$r][0] = 241;
 		$this->rights[$r][1] = 'Read thirdparties customers';
 		$this->rights[$r][2] = 'r';
@@ -163,7 +163,7 @@ class modSociete extends DolibarrModules
 		$this->rights[$r][3] = 0;
 		$this->rights[$r][4] = 'thirdparty_supplier_advance';      // Visible if option MAIN_USE_ADVANCED_PERMS is on
 		$this->rights[$r][5] = 'read';
-*/
+        */
 
 		$r++;
 		$this->rights[$r][0] = 122; // id de la permission
@@ -172,8 +172,8 @@ class modSociete extends DolibarrModules
 		$this->rights[$r][3] = 0; // La permission est-elle une permission par defaut
 		$this->rights[$r][4] = 'creer';
 
-/*		$r++;
-		 $this->rights[$r][0] = 251;
+        /* $r++;
+		$this->rights[$r][0] = 251;
 		$this->rights[$r][1] = 'Create thirdparties customers';
 		$this->rights[$r][2] = 'r';
 		$this->rights[$r][3] = 0;
@@ -187,7 +187,7 @@ class modSociete extends DolibarrModules
 		$this->rights[$r][3] = 0;
 		$this->rights[$r][4] = 'thirdparty_supplier_advance';      // Visible if option MAIN_USE_ADVANCED_PERMS is on
 		$this->rights[$r][5] = 'read';
-*/
+        */
 
 		$r++;
 		$this->rights[$r][0] = 125; // id de la permission

+ 4 - 4
htdocs/core/modules/modStripe.class.php

@@ -82,8 +82,8 @@ class modStripe extends DolibarrModules
         // New pages on tabs
         $this->tabs = array();
 
-        // Boxes
-        $this->boxes = array();			// List of boxes
+        // List of boxes
+        $this->boxes = array();
         $r=0;
 
         // Permissions
@@ -92,8 +92,8 @@ class modStripe extends DolibarrModules
 
         // Main menu entries
         $r=0;
-       /* $this->menu[$r]=array(
-        	'fk_menu'=>'fk_mainmenu=billing,fk_leftmenu=customers_bills_payment',		    // Use 'fk_mainmenu=xxx' or 'fk_mainmenu=xxx,fk_leftmenu=yyy' where xxx is mainmenucode and yyy is a leftmenucode
+        /* $this->menu[$r]=array(
+            'fk_menu'=>'fk_mainmenu=billing,fk_leftmenu=customers_bills_payment',		    // Use 'fk_mainmenu=xxx' or 'fk_mainmenu=xxx,fk_leftmenu=yyy' where xxx is mainmenucode and yyy is a leftmenucode
 	        'mainmenu'=>'billing',
         	'leftmenu'=>'customers_bills_payment_stripe',
         	'type'=>'left',			                // This is a Left menu entry

+ 1 - 1
htdocs/core/modules/modVariants.class.php

@@ -92,7 +92,7 @@ class modVariants extends DolibarrModules
 
 		// Array to add new pages in new tabs
 		$this->tabs = array(
-//			'product:+combinations:Combinaciones:products:1:/variants/combinations.php?id=__ID__'
+        //	'product:+combinations:Combinaciones:products:1:/variants/combinations.php?id=__ID__'
 		);
 
 		// Dictionaries

+ 9 - 11
htdocs/core/modules/modWebsite.class.php

@@ -186,17 +186,15 @@ class modWebsite extends DolibarrModules
     	dol_mkdir($destroot);
 
     	$docs=dol_dir_list($srcroot, 'files', 0, 'website_.*(\.zip|\.jpg)$');
-    	foreach($docs as $cursorfile)
-    	{
-	    		$src=$srcroot.'/'.$cursorfile['name'];
-	    		$dest=$destroot.'/'.$cursorfile['name'];
-
-	    		$result=dol_copy($src, $dest, 0, 0);
-	    		if ($result < 0)
-	    		{
-	    			$langs->load("errors");
-	    			$this->error=$langs->trans('ErrorFailToCopyFile', $src, $dest);
-	    		}
+    	foreach($docs as $cursorfile) {
+	    	$src=$srcroot.'/'.$cursorfile['name'];
+	    	$dest=$destroot.'/'.$cursorfile['name'];
+
+	    	$result=dol_copy($src, $dest, 0, 0);
+	    	if ($result < 0) {
+	    		$langs->load("errors");
+	    		$this->error=$langs->trans('ErrorFailToCopyFile', $src, $dest);
+	    	}
     	}
 
     	$sql = array();

+ 1 - 2
htdocs/core/modules/product/doc/pdf_standard.modules.php

@@ -668,8 +668,7 @@ class pdf_standard extends ModelePDFProduct
 	        $pdf->line($this->posxunit - 1, $tab_top, $this->posxunit - 1, $tab_top + $tab_height);
 	        if (empty($hidetop)) {
 	            $pdf->SetXY($this->posxunit - 1, $tab_top + 1);
-            $pdf->MultiCell($this->posxdiscount - $this->posxunit - 1, 2, $outputlangs->transnoentities("Unit"), '',
-	                'C');
+                $pdf->MultiCell($this->posxdiscount - $this->posxunit - 1, 2, $outputlangs->transnoentities("Unit"), '', 'C');
 	        }
 	    }
 

+ 1 - 1
htdocs/core/modules/project/doc/pdf_beluga.modules.php

@@ -107,7 +107,7 @@ class pdf_beluga extends ModelePDFProjects
 		$this->emetteur=$mysoc;
 		if (! $this->emetteur->country_code) $this->emetteur->country_code=substr($langs->defaultlang, -2);    // By default if not defined
 
-    // Define position of columns
+        // Define position of columns
         if ($this->orientation == 'L' || $this->orientation == 'Landscape') {
             $this->posxref=$this->marge_gauche+1;
             $this->posxdate=$this->marge_gauche+105;

+ 7 - 7
htdocs/core/modules/project/mod_project_simple.php

@@ -116,13 +116,13 @@ class mod_project_simple extends ModeleNumRefProjects
     }
 
 
-   /**
-	*  Return next value
-	*
-	*  @param   Societe	$objsoc		Object third party
-	*  @param   Project	$project	Object project
-	*  @return	string				Value if OK, 0 if KO
-	*/
+    /**
+     *  Return next value
+     *
+     *  @param   Societe	$objsoc		Object third party
+     *  @param   Project	$project	Object project
+     *  @return	string				Value if OK, 0 if KO
+     */
     public function getNextValue($objsoc, $project)
     {
 		global $db,$conf;

+ 7 - 7
htdocs/core/modules/project/mod_project_universal.php

@@ -116,13 +116,13 @@ class mod_project_universal extends ModeleNumRefProjects
 		return $numExample;
     }
 
-   /**
-	*  Return next value
-	*
-	*  @param	Societe		$objsoc		Object third party
-	*  @param   Project		$project	Object project
-	*  @return  string					Value if OK, 0 if KO
-	*/
+    /**
+     *  Return next value
+     *
+     *  @param	Societe		$objsoc		Object third party
+     *  @param   Project		$project	Object project
+     *  @return  string					Value if OK, 0 if KO
+     */
     public function getNextValue($objsoc, $project)
     {
 		global $db,$conf;

+ 7 - 7
htdocs/core/modules/project/task/mod_task_simple.php

@@ -117,13 +117,13 @@ class mod_task_simple extends ModeleNumRefTask
     }
 
 
-   /**
-	*  Return next value
-	*
-	*  @param   Societe	$objsoc		Object third party
-	*  @param   Task	$object		Object Task
-	*  @return	string				Value if OK, 0 if KO
-	*/
+    /**
+     *  Return next value
+     *
+     *  @param   Societe	$objsoc		Object third party
+     *  @param   Task	$object		Object Task
+     *  @return	string				Value if OK, 0 if KO
+     */
     public function getNextValue($objsoc, $object)
     {
 		global $db,$conf;

+ 7 - 7
htdocs/core/modules/project/task/mod_task_universal.php

@@ -116,13 +116,13 @@ class mod_task_universal extends ModeleNumRefTask
 		return $numExample;
     }
 
-   /**
-	*  Return next value
-	*
-	*  @param	Societe		$objsoc		Object third party
-	*  @param   Task		$object	    Object task
-	*  @return  string					Value if OK, 0 if KO
-	*/
+    /**
+     *  Return next value
+     *
+     *  @param	Societe		$objsoc		Object third party
+     *  @param   Task		$object	    Object task
+     *  @return  string					Value if OK, 0 if KO
+     */
     public function getNextValue($objsoc, $object)
     {
 		global $db,$conf;

+ 1 - 1
htdocs/core/modules/propale/doc/doc_generic_proposal_odt.modules.php

@@ -515,7 +515,7 @@ class doc_generic_proposal_odt extends ModelePDFPropales
 				}
 				else {
 					try {
-					$odfHandler->saveToDisk($file);
+					    $odfHandler->saveToDisk($file);
 					} catch (Exception $e) {
 						$this->error=$e->getMessage();
                         dol_syslog($e->getMessage(), LOG_INFO);

+ 85 - 85
htdocs/core/modules/propale/doc/pdf_azur.modules.php

@@ -1088,68 +1088,68 @@ class pdf_azur extends ModelePDFPropales
 				//Local tax 1 before VAT
 				//if (! empty($conf->global->FACTURE_LOCAL_TAX1_OPTION) && $conf->global->FACTURE_LOCAL_TAX1_OPTION=='localtax1on')
 				//{
-					foreach($this->localtax1 as $localtax_type => $localtax_rate)
-					{
-						if (in_array((string) $localtax_type, array('1','3','5'))) continue;
+				foreach($this->localtax1 as $localtax_type => $localtax_rate)
+				{
+					if (in_array((string) $localtax_type, array('1','3','5'))) continue;
 
-						foreach($localtax_rate as $tvakey => $tvaval)
+					foreach($localtax_rate as $tvakey => $tvaval)
+					{
+						if ($tvakey!=0)    // On affiche pas taux 0
 						{
-							if ($tvakey!=0)    // On affiche pas taux 0
-							{
-								//$this->atleastoneratenotnull++;
-
-								$index++;
-								$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
+							//$this->atleastoneratenotnull++;
 
-								$tvacompl='';
-								if (preg_match('/\*/', $tvakey))
-								{
-									$tvakey=str_replace('*', '', $tvakey);
-									$tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")";
-								}
-								$totalvat = $outputlangs->transcountrynoentities("TotalLT1", $mysoc->country_code).' ';
-								$totalvat.=vatrate(abs($tvakey), 1).$tvacompl;
-								$pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1);
+							$index++;
+							$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
 
-								$pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
-								$pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1);
+							$tvacompl='';
+							if (preg_match('/\*/', $tvakey))
+							{
+								$tvakey=str_replace('*', '', $tvakey);
+								$tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")";
 							}
+							$totalvat = $outputlangs->transcountrynoentities("TotalLT1", $mysoc->country_code).' ';
+							$totalvat.=vatrate(abs($tvakey), 1).$tvacompl;
+							$pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1);
+
+							$pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
+							$pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1);
 						}
 					}
+				}
 	      		//}
 				//Local tax 2 before VAT
 				//if (! empty($conf->global->FACTURE_LOCAL_TAX2_OPTION) && $conf->global->FACTURE_LOCAL_TAX2_OPTION=='localtax2on')
 				//{
-					foreach($this->localtax2 as $localtax_type => $localtax_rate)
-					{
-						if (in_array((string) $localtax_type, array('1','3','5'))) continue;
+				foreach($this->localtax2 as $localtax_type => $localtax_rate)
+				{
+					if (in_array((string) $localtax_type, array('1','3','5'))) continue;
 
-						foreach($localtax_rate as $tvakey => $tvaval)
+					foreach($localtax_rate as $tvakey => $tvaval)
+					{
+						if ($tvakey!=0)    // On affiche pas taux 0
 						{
-							if ($tvakey!=0)    // On affiche pas taux 0
-							{
-								//$this->atleastoneratenotnull++;
-
+							//$this->atleastoneratenotnull++;
 
 
-								$index++;
-								$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
 
-								$tvacompl='';
-								if (preg_match('/\*/', $tvakey))
-								{
-									$tvakey=str_replace('*', '', $tvakey);
-									$tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")";
-								}
-								$totalvat = $outputlangs->transcountrynoentities("TotalLT2", $mysoc->country_code).' ';
-								$totalvat.=vatrate(abs($tvakey), 1).$tvacompl;
-								$pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1);
+							$index++;
+							$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
 
-								$pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
-								$pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1);
+							$tvacompl='';
+							if (preg_match('/\*/', $tvakey))
+							{
+								$tvakey=str_replace('*', '', $tvakey);
+								$tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")";
 							}
+							$totalvat = $outputlangs->transcountrynoentities("TotalLT2", $mysoc->country_code).' ';
+							$totalvat.=vatrate(abs($tvakey), 1).$tvacompl;
+							$pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1);
+
+							$pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
+							$pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1);
 						}
 					}
+				}
 				//}
 				// VAT
 				foreach($this->tva as $tvakey => $tvaval)
@@ -1179,68 +1179,68 @@ class pdf_azur extends ModelePDFPropales
 				//Local tax 1 after VAT
 				//if (! empty($conf->global->FACTURE_LOCAL_TAX1_OPTION) && $conf->global->FACTURE_LOCAL_TAX1_OPTION=='localtax1on')
 				//{
-					foreach($this->localtax1 as $localtax_type => $localtax_rate)
-					{
-						if (in_array((string) $localtax_type, array('2','4','6'))) continue;
+				foreach($this->localtax1 as $localtax_type => $localtax_rate)
+				{
+					if (in_array((string) $localtax_type, array('2','4','6'))) continue;
 
-						foreach($localtax_rate as $tvakey => $tvaval)
+					foreach($localtax_rate as $tvakey => $tvaval)
+					{
+						if ($tvakey != 0)    // On affiche pas taux 0
 						{
-							if ($tvakey != 0)    // On affiche pas taux 0
-							{
-								//$this->atleastoneratenotnull++;
-
-								$index++;
-								$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
+							//$this->atleastoneratenotnull++;
 
-								$tvacompl='';
-								if (preg_match('/\*/', $tvakey))
-								{
-									$tvakey=str_replace('*', '', $tvakey);
-									$tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")";
-								}
-								$totalvat = $outputlangs->transcountrynoentities("TotalLT1", $mysoc->country_code).' ';
+							$index++;
+							$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
 
-								$totalvat.=vatrate(abs($tvakey), 1).$tvacompl;
-								$pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1);
-								$pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
-								$pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1);
+							$tvacompl='';
+							if (preg_match('/\*/', $tvakey))
+							{
+								$tvakey=str_replace('*', '', $tvakey);
+								$tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")";
 							}
+							$totalvat = $outputlangs->transcountrynoentities("TotalLT1", $mysoc->country_code).' ';
+
+							$totalvat.=vatrate(abs($tvakey), 1).$tvacompl;
+							$pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1);
+							$pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
+							$pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1);
 						}
 					}
+				}
 	      		//}
 				//Local tax 2 after VAT
 				//if (! empty($conf->global->FACTURE_LOCAL_TAX2_OPTION) && $conf->global->FACTURE_LOCAL_TAX2_OPTION=='localtax2on')
 				//{
-					foreach($this->localtax2 as $localtax_type => $localtax_rate)
-					{
-						if (in_array((string) $localtax_type, array('2','4','6'))) continue;
+				foreach($this->localtax2 as $localtax_type => $localtax_rate)
+				{
+					if (in_array((string) $localtax_type, array('2','4','6'))) continue;
 
-						foreach($localtax_rate as $tvakey => $tvaval)
+					foreach($localtax_rate as $tvakey => $tvaval)
+					{
+					    // retrieve global local tax
+						if ($tvakey != 0)    // On affiche pas taux 0
 						{
-						    // retrieve global local tax
-							if ($tvakey != 0)    // On affiche pas taux 0
-							{
-								//$this->atleastoneratenotnull++;
+							//$this->atleastoneratenotnull++;
 
-								$index++;
-								$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
+							$index++;
+							$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
 
-								$tvacompl='';
-								if (preg_match('/\*/', $tvakey))
-								{
-									$tvakey=str_replace('*', '', $tvakey);
-									$tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")";
-								}
-								$totalvat = $outputlangs->transcountrynoentities("TotalLT2", $mysoc->country_code).' ';
+							$tvacompl='';
+							if (preg_match('/\*/', $tvakey))
+							{
+								$tvakey=str_replace('*', '', $tvakey);
+								$tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")";
+							}
+							$totalvat = $outputlangs->transcountrynoentities("TotalLT2", $mysoc->country_code).' ';
 
-								$totalvat.=vatrate(abs($tvakey), 1).$tvacompl;
-								$pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1);
+							$totalvat.=vatrate(abs($tvakey), 1).$tvacompl;
+							$pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1);
 
-								$pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
-								$pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1);
-							}
+							$pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
+							$pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1);
 						}
 					}
+				}
 				//}
 
 				// Total TTC

+ 85 - 85
htdocs/core/modules/propale/doc/pdf_cyan.modules.php

@@ -1191,68 +1191,68 @@ class pdf_cyan extends ModelePDFPropales
 				//Local tax 1 before VAT
 				//if (! empty($conf->global->FACTURE_LOCAL_TAX1_OPTION) && $conf->global->FACTURE_LOCAL_TAX1_OPTION=='localtax1on')
 				//{
-					foreach($this->localtax1 as $localtax_type => $localtax_rate)
-					{
-						if (in_array((string) $localtax_type, array('1','3','5'))) continue;
+				foreach($this->localtax1 as $localtax_type => $localtax_rate)
+				{
+					if (in_array((string) $localtax_type, array('1','3','5'))) continue;
 
-						foreach($localtax_rate as $tvakey => $tvaval)
+					foreach($localtax_rate as $tvakey => $tvaval)
+					{
+						if ($tvakey!=0)    // On affiche pas taux 0
 						{
-							if ($tvakey!=0)    // On affiche pas taux 0
-							{
-								//$this->atleastoneratenotnull++;
-
-								$index++;
-								$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
+							//$this->atleastoneratenotnull++;
 
-								$tvacompl='';
-								if (preg_match('/\*/', $tvakey))
-								{
-									$tvakey=str_replace('*', '', $tvakey);
-									$tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")";
-								}
-								$totalvat = $outputlangs->transcountrynoentities("TotalLT1", $mysoc->country_code).' ';
-								$totalvat.=vatrate(abs($tvakey), 1).$tvacompl;
-								$pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1);
+							$index++;
+							$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
 
-								$pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
-								$pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1);
+							$tvacompl='';
+							if (preg_match('/\*/', $tvakey))
+							{
+								$tvakey=str_replace('*', '', $tvakey);
+								$tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")";
 							}
+							$totalvat = $outputlangs->transcountrynoentities("TotalLT1", $mysoc->country_code).' ';
+							$totalvat.=vatrate(abs($tvakey), 1).$tvacompl;
+							$pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1);
+
+							$pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
+							$pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1);
 						}
 					}
+				}
 	      		//}
 				//Local tax 2 before VAT
 				//if (! empty($conf->global->FACTURE_LOCAL_TAX2_OPTION) && $conf->global->FACTURE_LOCAL_TAX2_OPTION=='localtax2on')
 				//{
-					foreach($this->localtax2 as $localtax_type => $localtax_rate)
-					{
-						if (in_array((string) $localtax_type, array('1','3','5'))) continue;
+				foreach($this->localtax2 as $localtax_type => $localtax_rate)
+				{
+					if (in_array((string) $localtax_type, array('1','3','5'))) continue;
 
-						foreach($localtax_rate as $tvakey => $tvaval)
+					foreach($localtax_rate as $tvakey => $tvaval)
+					{
+						if ($tvakey!=0)    // On affiche pas taux 0
 						{
-							if ($tvakey!=0)    // On affiche pas taux 0
-							{
-								//$this->atleastoneratenotnull++;
-
+							//$this->atleastoneratenotnull++;
 
 
-								$index++;
-								$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
 
-								$tvacompl='';
-								if (preg_match('/\*/', $tvakey))
-								{
-									$tvakey=str_replace('*', '', $tvakey);
-									$tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")";
-								}
-								$totalvat = $outputlangs->transcountrynoentities("TotalLT2", $mysoc->country_code).' ';
-								$totalvat.=vatrate(abs($tvakey), 1).$tvacompl;
-								$pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1);
+							$index++;
+							$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
 
-								$pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
-								$pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1);
+							$tvacompl='';
+							if (preg_match('/\*/', $tvakey))
+							{
+								$tvakey=str_replace('*', '', $tvakey);
+								$tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")";
 							}
+							$totalvat = $outputlangs->transcountrynoentities("TotalLT2", $mysoc->country_code).' ';
+							$totalvat.=vatrate(abs($tvakey), 1).$tvacompl;
+							$pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1);
+
+							$pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
+							$pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1);
 						}
 					}
+				}
 				//}
 				// VAT
 				foreach($this->tva as $tvakey => $tvaval)
@@ -1282,68 +1282,68 @@ class pdf_cyan extends ModelePDFPropales
 				//Local tax 1 after VAT
 				//if (! empty($conf->global->FACTURE_LOCAL_TAX1_OPTION) && $conf->global->FACTURE_LOCAL_TAX1_OPTION=='localtax1on')
 				//{
-					foreach($this->localtax1 as $localtax_type => $localtax_rate)
-					{
-						if (in_array((string) $localtax_type, array('2','4','6'))) continue;
+				foreach($this->localtax1 as $localtax_type => $localtax_rate)
+				{
+					if (in_array((string) $localtax_type, array('2','4','6'))) continue;
 
-						foreach($localtax_rate as $tvakey => $tvaval)
+					foreach($localtax_rate as $tvakey => $tvaval)
+					{
+						if ($tvakey != 0)    // On affiche pas taux 0
 						{
-							if ($tvakey != 0)    // On affiche pas taux 0
-							{
-								//$this->atleastoneratenotnull++;
-
-								$index++;
-								$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
+							//$this->atleastoneratenotnull++;
 
-								$tvacompl='';
-								if (preg_match('/\*/', $tvakey))
-								{
-									$tvakey=str_replace('*', '', $tvakey);
-									$tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")";
-								}
-								$totalvat = $outputlangs->transcountrynoentities("TotalLT1", $mysoc->country_code).' ';
+							$index++;
+							$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
 
-								$totalvat.=vatrate(abs($tvakey), 1).$tvacompl;
-								$pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1);
-								$pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
-								$pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1);
+							$tvacompl='';
+							if (preg_match('/\*/', $tvakey))
+							{
+								$tvakey=str_replace('*', '', $tvakey);
+								$tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")";
 							}
+							$totalvat = $outputlangs->transcountrynoentities("TotalLT1", $mysoc->country_code).' ';
+
+							$totalvat.=vatrate(abs($tvakey), 1).$tvacompl;
+							$pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1);
+							$pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
+							$pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1);
 						}
 					}
+				}
 	      		//}
 				//Local tax 2 after VAT
 				//if (! empty($conf->global->FACTURE_LOCAL_TAX2_OPTION) && $conf->global->FACTURE_LOCAL_TAX2_OPTION=='localtax2on')
 				//{
-					foreach($this->localtax2 as $localtax_type => $localtax_rate)
-					{
-						if (in_array((string) $localtax_type, array('2','4','6'))) continue;
+				foreach($this->localtax2 as $localtax_type => $localtax_rate)
+				{
+					if (in_array((string) $localtax_type, array('2','4','6'))) continue;
 
-						foreach($localtax_rate as $tvakey => $tvaval)
+					foreach($localtax_rate as $tvakey => $tvaval)
+					{
+					    // retrieve global local tax
+						if ($tvakey != 0)    // On affiche pas taux 0
 						{
-						    // retrieve global local tax
-							if ($tvakey != 0)    // On affiche pas taux 0
-							{
-								//$this->atleastoneratenotnull++;
+							//$this->atleastoneratenotnull++;
 
-								$index++;
-								$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
+							$index++;
+							$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
 
-								$tvacompl='';
-								if (preg_match('/\*/', $tvakey))
-								{
-									$tvakey=str_replace('*', '', $tvakey);
-									$tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")";
-								}
-								$totalvat = $outputlangs->transcountrynoentities("TotalLT2", $mysoc->country_code).' ';
+							$tvacompl='';
+							if (preg_match('/\*/', $tvakey))
+							{
+								$tvakey=str_replace('*', '', $tvakey);
+								$tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")";
+							}
+							$totalvat = $outputlangs->transcountrynoentities("TotalLT2", $mysoc->country_code).' ';
 
-								$totalvat.=vatrate(abs($tvakey), 1).$tvacompl;
-								$pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1);
+							$totalvat.=vatrate(abs($tvakey), 1).$tvacompl;
+							$pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1);
 
-								$pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
-								$pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1);
-							}
+							$pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
+							$pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1);
 						}
 					}
+				}
 				//}
 
 				// Total TTC

+ 1 - 1
htdocs/core/modules/reception/doc/doc_generic_reception_odt.modules.php

@@ -497,7 +497,7 @@ class doc_generic_reception_odt extends ModelePdfReception
 				}
 				else {
 					try {
-					$odfHandler->saveToDisk($file);
+					    $odfHandler->saveToDisk($file);
 					} catch (Exception $e){
 						$this->error=$e->getMessage();
 						return -1;

+ 25 - 27
htdocs/core/modules/reception/doc/pdf_squille.modules.php

@@ -142,26 +142,25 @@ class pdf_squille extends ModelePdfReception
 
 				$realpath='';
 
-                foreach ($objphoto->liste_photos($dir, 1) as $key => $obj)
+                foreach ($objphoto->liste_photos($dir, 1) as $key => $obj) {
+                    if (empty($conf->global->CAT_HIGH_QUALITY_IMAGES)) {
+                        // If CAT_HIGH_QUALITY_IMAGES not defined, we use thumb if defined and then original photo
+                        if ($obj['photo_vignette'])
                         {
-                            if (empty($conf->global->CAT_HIGH_QUALITY_IMAGES))		// If CAT_HIGH_QUALITY_IMAGES not defined, we use thumb if defined and then original photo
-                            {
-                                if ($obj['photo_vignette'])
-                                {
-                                    $filename= $obj['photo_vignette'];
-                                }
-                                else
-                                {
-                                    $filename=$obj['photo'];
-                                }
-                            }
-                            else
-                            {
-                                $filename=$obj['photo'];
-                            }
-
-                            $realpath = $dir.$filename;
-                            break;
+                            $filename= $obj['photo_vignette'];
+                        }
+                        else
+                        {
+                            $filename=$obj['photo'];
+                        }
+                    }
+                    else
+                    {
+                        $filename=$obj['photo'];
+                    }
+
+                    $realpath = $dir.$filename;
+                    break;
                 }
 
                 if ($realpath) $realpatharray[$i]=$realpath;
@@ -461,14 +460,13 @@ class pdf_squille extends ModelePdfReception
 					$pdf->writeHTMLCell($this->posxqtyordered - $this->posxweightvol + 2, 3, $this->posxweightvol - 1, $curY, $weighttxt.(($weighttxt && $voltxt)?'<br>':'').$voltxt, 0, 0, false, true, 'C');
 					//$pdf->MultiCell(($this->posxqtyordered - $this->posxweightvol), 3, $weighttxt.(($weighttxt && $voltxt)?'<br>':'').$voltxt,'','C');
 
-					if (empty($conf->global->RECEPTION_PDF_HIDE_ORDERED))
-					{
-					   $pdf->SetXY($this->posxqtyordered, $curY);
-					   if($object->lines[$i]->fk_commandefourndet!=$fk_commandefourndet){
-						   $pdf->MultiCell(($this->posxqtytoship - $this->posxqtyordered), 3, $object->lines[$i]->qty_asked, '', 'C');
-						   $totalOrdered+=$object->lines[$i]->qty_asked;
-					   }
-					   $fk_commandefourndet = $object->lines[$i]->fk_commandefourndet;
+					if (empty($conf->global->RECEPTION_PDF_HIDE_ORDERED)) {
+					    $pdf->SetXY($this->posxqtyordered, $curY);
+					    if($object->lines[$i]->fk_commandefourndet!=$fk_commandefourndet){
+						    $pdf->MultiCell(($this->posxqtytoship - $this->posxqtyordered), 3, $object->lines[$i]->qty_asked, '', 'C');
+						    $totalOrdered+=$object->lines[$i]->qty_asked;
+					    }
+					    $fk_commandefourndet = $object->lines[$i]->fk_commandefourndet;
 					}
 
 					$pdf->SetXY($this->posxqtytoship, $curY);

+ 15 - 17
htdocs/core/modules/societe/doc/doc_generic_odt.modules.php

@@ -197,14 +197,13 @@ class doc_generic_odt extends ModeleThirdPartyDoc
 			return -1;
 		}
 
-                // Add odtgeneration hook
-                if (! is_object($hookmanager))
-                {
-                        include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php';
-                        $hookmanager=new HookManager($this->db);
-                }
-                $hookmanager->initHooks(array('odtgeneration'));
-                global $action;
+        // Add odtgeneration hook
+        if (! is_object($hookmanager)) {
+            include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php';
+            $hookmanager=new HookManager($this->db);
+        }
+        $hookmanager->initHooks(array('odtgeneration'));
+        global $action;
 
 		if (! is_object($outputlangs)) $outputlangs=$langs;
 		$sav_charset_output=$outputlangs->charset_output;
@@ -408,17 +407,16 @@ class doc_generic_odt extends ModeleThirdPartyDoc
 				}
 				else {
 				    try {
-					   $odfHandler->creator = $user->getFullName($outputlangs);
-					   $odfHandler->title = $object->builddoc_filename;
-					   $odfHandler->subject = $object->builddoc_filename;
+                        $odfHandler->creator = $user->getFullName($outputlangs);
+                        $odfHandler->title = $object->builddoc_filename;
+                        $odfHandler->subject = $object->builddoc_filename;
 
-					   if (! empty($conf->global->ODT_ADD_DOLIBARR_ID))
-					   {
-    					  $odfHandler->userdefined['dol_id'] = $object->id;
-	   		  		      $odfHandler->userdefined['dol_element'] = $object->element;
-					   }
+                        if (! empty($conf->global->ODT_ADD_DOLIBARR_ID)) {
+                            $odfHandler->userdefined['dol_id'] = $object->id;
+                            $odfHandler->userdefined['dol_element'] = $object->element;
+                        }
 
-					   $odfHandler->saveToDisk($file);
+                        $odfHandler->saveToDisk($file);
 					} catch (Exception $e){
 						$this->error=$e->getMessage();
                         dol_syslog($e->getMessage(), LOG_INFO);

+ 1 - 1
htdocs/core/modules/stock/doc/doc_generic_stock_odt.modules.php

@@ -495,7 +495,7 @@ class doc_generic_stock_odt extends ModelePDFStock
 				}
 				else {
 					try {
-					$odfHandler->saveToDisk($file);
+					    $odfHandler->saveToDisk($file);
 					} catch (Exception $e) {
 						$this->error=$e->getMessage();
                         dol_syslog($e->getMessage(), LOG_INFO);

+ 36 - 38
htdocs/core/modules/supplier_invoice/pdf/pdf_canelle.modules.php

@@ -714,58 +714,56 @@ class pdf_canelle extends ModelePDFSuppliersInvoices
 		{
 			//if (! empty($conf->global->FACTURE_LOCAL_TAX1_OPTION) && $conf->global->FACTURE_LOCAL_TAX1_OPTION=='localtax1on')
 			//{
-				//Local tax 1
-				foreach($this->localtax1 as $tvakey => $tvaval)
+			//Local tax 1
+			foreach ($this->localtax1 as $tvakey => $tvaval) {
+				if ($tvakey != 0)    // On affiche pas taux 0
 				{
-					if ($tvakey != 0)    // On affiche pas taux 0
-					{
-						//$this->atleastoneratenotnull++;
-
-						$index++;
-						$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
+					//$this->atleastoneratenotnull++;
 
-						$tvacompl='';
-						if (preg_match('/\*/', $tvakey))
-						{
-							$tvakey=str_replace('*', '', $tvakey);
-							$tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")";
-						}
-						$totalvat = $outputlangs->transcountrynoentities("TotalLT1", $mysoc->country_code).' ';
-						$totalvat.= vatrate(abs($tvakey), 1).$tvacompl;
-						$pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1);
+					$index++;
+					$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
 
-						$pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
-						$pdf->MultiCell($largcol2, $tab2_hl, price($tvaval), 0, 'R', 1);
+					$tvacompl='';
+					if (preg_match('/\*/', $tvakey))
+					{
+						$tvakey=str_replace('*', '', $tvakey);
+						$tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")";
 					}
+					$totalvat = $outputlangs->transcountrynoentities("TotalLT1", $mysoc->country_code).' ';
+					$totalvat.= vatrate(abs($tvakey), 1).$tvacompl;
+					$pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1);
+
+					$pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
+					$pdf->MultiCell($largcol2, $tab2_hl, price($tvaval), 0, 'R', 1);
 				}
+			}
 			//}
 
 			//if (! empty($conf->global->FACTURE_LOCAL_TAX2_OPTION) && $conf->global->FACTURE_LOCAL_TAX2_OPTION=='localtax2on')
 			//{
-				//Local tax 2
-				foreach($this->localtax2 as $tvakey => $tvaval)
+			//Local tax 2
+			foreach($this->localtax2 as $tvakey => $tvaval) {
+				if ($tvakey != 0)    // On affiche pas taux 0
 				{
-					if ($tvakey != 0)    // On affiche pas taux 0
-					{
-						//$this->atleastoneratenotnull++;
-
-						$index++;
-						$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
+					//$this->atleastoneratenotnull++;
 
-						$tvacompl='';
-						if (preg_match('/\*/', $tvakey))
-						{
-							$tvakey=str_replace('*', '', $tvakey);
-							$tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")";
-						}
-						$totalvat = $outputlangs->transcountrynoentities("TotalLT2", $mysoc->country_code).' ';
-						$totalvat.= vatrate(abs($tvakey), 1).$tvacompl;
-						$pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1);
+					$index++;
+					$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
 
-						$pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
-						$pdf->MultiCell($largcol2, $tab2_hl, price($tvaval), 0, 'R', 1);
+					$tvacompl='';
+					if (preg_match('/\*/', $tvakey))
+					{
+						$tvakey=str_replace('*', '', $tvakey);
+						$tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")";
 					}
+					$totalvat = $outputlangs->transcountrynoentities("TotalLT2", $mysoc->country_code).' ';
+					$totalvat.= vatrate(abs($tvakey), 1).$tvacompl;
+					$pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1);
+
+					$pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
+					$pdf->MultiCell($largcol2, $tab2_hl, price($tvaval), 0, 'R', 1);
 				}
+			}
 			//}
 		}
 

+ 2 - 2
htdocs/core/modules/supplier_order/pdf/doc_generic_supplier_order_odt.modules.php

@@ -4,7 +4,7 @@
  * Copyright (C) 2014		Marcos García		<marcosgdf@gmail.com>
  * Copyright (C) 2016		Charlie Benke		<charlie@patas-monkey.com>
  * Copyright (C) 2018-2019  Philippe Grand      <philippe.grand@atoo-net.com>
- * Copyright (C) 2018       Frédéric France     <frederic.france@netlogic.fr>
+ * Copyright (C) 2018-2019  Frédéric France     <frederic.france@netlogic.fr>
  * Copyright (C) 2019       Tim Otte		    <otte@meuser.it>
  *
  * This program is free software; you can redistribute it and/or modify
@@ -485,7 +485,7 @@ class doc_generic_supplier_order_odt extends ModelePDFSuppliersOrders
 				}
 				else {
 					try {
-					$odfHandler->saveToDisk($file);
+					    $odfHandler->saveToDisk($file);
 					} catch (Exception $e) {
                         $this->error=$e->getMessage();
                         dol_syslog($e->getMessage(), LOG_INFO);

+ 2 - 2
htdocs/core/modules/supplier_payment/doc/pdf_standard.modules.php

@@ -674,7 +674,7 @@ class pdf_standard extends ModelePDFSuppliersPayments
 			$text=$this->emetteur->name;
 			$pdf->MultiCell(100, 4, $outputlangs->convToOutputCharset($text), 0, 'L');
 		}
-/*
+        /*
 		$pdf->SetFont('','B', $default_font_size + 3);
 		$pdf->SetXY($posx,$posy);
 		$pdf->SetTextColor(0,0,60);
@@ -734,7 +734,7 @@ class pdf_standard extends ModelePDFSuppliersPayments
 
 		// Show list of linked objects
 		$posy = pdf_writeLinkedObjects($pdf, $object, $outputlangs, $posx, $posy, 100, 3, 'R', $default_font_size);
-*/
+        */
 		if ($showaddress)
 		{
 			// Sender properties

+ 1 - 1
htdocs/core/modules/supplier_proposal/doc/doc_generic_supplier_proposal_odt.modules.php

@@ -365,7 +365,7 @@ class doc_generic_supplier_proposal_odt extends ModelePDFSupplierProposal
 				// Open and load template
 				require_once ODTPHP_PATH.'odf.php';
 				try {
-    $odfHandler = new odf(
+                    $odfHandler = new odf(
 						$srctemplatepath,
 						array(
 							'PATH_TO_TMP'	  => $conf->supplier_proposal->dir_temp,

+ 91 - 91
htdocs/core/modules/supplier_proposal/doc/pdf_aurore.modules.php

@@ -941,68 +941,68 @@ class pdf_aurore extends ModelePDFSupplierProposal
 				//Local tax 1 before VAT
 				//if (! empty($conf->global->FACTURE_LOCAL_TAX1_OPTION) && $conf->global->FACTURE_LOCAL_TAX1_OPTION=='localtax1on')
 				//{
-					foreach($this->localtax1 as $localtax_type => $localtax_rate)
-					{
-						if (in_array((string) $localtax_type, array('1','3','5'))) continue;
+				foreach($this->localtax1 as $localtax_type => $localtax_rate)
+				{
+					if (in_array((string) $localtax_type, array('1','3','5'))) continue;
 
-						foreach($localtax_rate as $tvakey => $tvaval)
+					foreach($localtax_rate as $tvakey => $tvaval)
+					{
+						if ($tvakey!=0)    // On affiche pas taux 0
 						{
-							if ($tvakey!=0)    // On affiche pas taux 0
+							//$this->atleastoneratenotnull++;
+
+							$index++;
+							$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
+
+							$tvacompl='';
+							if (preg_match('/\*/', $tvakey))
 							{
-								//$this->atleastoneratenotnull++;
-
-								$index++;
-								$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
-
-								$tvacompl='';
-								if (preg_match('/\*/', $tvakey))
-								{
-									$tvakey=str_replace('*', '', $tvakey);
-									$tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")";
-								}
-								$totalvat = $outputlangs->transcountrynoentities("TotalLT1", $mysoc->country_code).' ';
-								$totalvat.=vatrate(abs($tvakey), 1).$tvacompl;
-								$pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1);
-
-								$pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
-								$pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1);
+								$tvakey=str_replace('*', '', $tvakey);
+								$tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")";
 							}
+							$totalvat = $outputlangs->transcountrynoentities("TotalLT1", $mysoc->country_code).' ';
+							$totalvat.=vatrate(abs($tvakey), 1).$tvacompl;
+							$pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1);
+
+							$pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
+							$pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1);
 						}
 					}
+				}
 	      		//}
 				//Local tax 2 before VAT
 				//if (! empty($conf->global->FACTURE_LOCAL_TAX2_OPTION) && $conf->global->FACTURE_LOCAL_TAX2_OPTION=='localtax2on')
 				//{
-					foreach($this->localtax2 as $localtax_type => $localtax_rate)
-					{
-						if (in_array((string) $localtax_type, array('1','3','5'))) continue;
+				foreach($this->localtax2 as $localtax_type => $localtax_rate)
+				{
+					if (in_array((string) $localtax_type, array('1','3','5'))) continue;
 
-						foreach($localtax_rate as $tvakey => $tvaval)
+					foreach($localtax_rate as $tvakey => $tvaval)
+					{
+						if ($tvakey!=0)    // On affiche pas taux 0
 						{
-							if ($tvakey!=0)    // On affiche pas taux 0
-							{
-								//$this->atleastoneratenotnull++;
-
+							//$this->atleastoneratenotnull++;
 
 
-								$index++;
-								$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
 
-								$tvacompl='';
-								if (preg_match('/\*/', $tvakey))
-								{
-									$tvakey=str_replace('*', '', $tvakey);
-									$tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")";
-								}
-								$totalvat = $outputlangs->transcountrynoentities("TotalLT2", $mysoc->country_code).' ';
-								$totalvat.=vatrate(abs($tvakey), 1).$tvacompl;
-								$pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1);
+							$index++;
+							$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
 
-								$pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
-								$pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1);
+							$tvacompl='';
+							if (preg_match('/\*/', $tvakey))
+							{
+								$tvakey=str_replace('*', '', $tvakey);
+								$tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")";
 							}
+							$totalvat = $outputlangs->transcountrynoentities("TotalLT2", $mysoc->country_code).' ';
+							$totalvat.=vatrate(abs($tvakey), 1).$tvacompl;
+							$pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1);
+
+							$pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
+							$pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1);
 						}
 					}
+				}
 				//}
 				// VAT
 				foreach($this->tva as $tvakey => $tvaval)
@@ -1032,68 +1032,68 @@ class pdf_aurore extends ModelePDFSupplierProposal
 				//Local tax 1 after VAT
 				//if (! empty($conf->global->FACTURE_LOCAL_TAX1_OPTION) && $conf->global->FACTURE_LOCAL_TAX1_OPTION=='localtax1on')
 				//{
-					foreach($this->localtax1 as $localtax_type => $localtax_rate)
-					{
-						if (in_array((string) $localtax_type, array('2','4','6'))) continue;
+				foreach($this->localtax1 as $localtax_type => $localtax_rate)
+				{
+					if (in_array((string) $localtax_type, array('2','4','6'))) continue;
 
-						foreach($localtax_rate as $tvakey => $tvaval)
+					foreach($localtax_rate as $tvakey => $tvaval)
+					{
+						if ($tvakey != 0)    // On affiche pas taux 0
 						{
-							if ($tvakey != 0)    // On affiche pas taux 0
+							//$this->atleastoneratenotnull++;
+
+							$index++;
+							$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
+
+							$tvacompl='';
+							if (preg_match('/\*/', $tvakey))
 							{
-								//$this->atleastoneratenotnull++;
-
-								$index++;
-								$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
-
-								$tvacompl='';
-								if (preg_match('/\*/', $tvakey))
-								{
-									$tvakey=str_replace('*', '', $tvakey);
-									$tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")";
-								}
-								$totalvat = $outputlangs->transcountrynoentities("TotalLT1", $mysoc->country_code).' ';
-
-								$totalvat.=vatrate(abs($tvakey), 1).$tvacompl;
-								$pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1);
-								$pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
-								$pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1);
+								$tvakey=str_replace('*', '', $tvakey);
+								$tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")";
 							}
+							$totalvat = $outputlangs->transcountrynoentities("TotalLT1", $mysoc->country_code).' ';
+
+							$totalvat.=vatrate(abs($tvakey), 1).$tvacompl;
+							$pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1);
+							$pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
+							$pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1);
 						}
 					}
+				}
 	      		//}
 				//Local tax 2 after VAT
 				//if (! empty($conf->global->FACTURE_LOCAL_TAX2_OPTION) && $conf->global->FACTURE_LOCAL_TAX2_OPTION=='localtax2on')
 				//{
-					foreach($this->localtax2 as $localtax_type => $localtax_rate)
-					{
-						if (in_array((string) $localtax_type, array('2','4','6'))) continue;
+				foreach($this->localtax2 as $localtax_type => $localtax_rate)
+				{
+					if (in_array((string) $localtax_type, array('2','4','6'))) continue;
 
-						foreach($localtax_rate as $tvakey => $tvaval)
+					foreach($localtax_rate as $tvakey => $tvaval)
+					{
+					    // retrieve global local tax
+						if ($tvakey != 0)    // On affiche pas taux 0
 						{
-						    // retrieve global local tax
-							if ($tvakey != 0)    // On affiche pas taux 0
-							{
-								//$this->atleastoneratenotnull++;
+							//$this->atleastoneratenotnull++;
 
-								$index++;
-								$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
+							$index++;
+							$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
 
-								$tvacompl='';
-								if (preg_match('/\*/', $tvakey))
-								{
-									$tvakey=str_replace('*', '', $tvakey);
-									$tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")";
-								}
-								$totalvat = $outputlangs->transcountrynoentities("TotalLT2", $mysoc->country_code).' ';
+							$tvacompl='';
+							if (preg_match('/\*/', $tvakey))
+							{
+								$tvakey=str_replace('*', '', $tvakey);
+								$tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")";
+							}
+							$totalvat = $outputlangs->transcountrynoentities("TotalLT2", $mysoc->country_code).' ';
 
-								$totalvat.=vatrate(abs($tvakey), 1).$tvacompl;
-								$pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1);
+							$totalvat.=vatrate(abs($tvakey), 1).$tvacompl;
+							$pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1);
 
-								$pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
-								$pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1);
-							}
+							$pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
+							$pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1);
 						}
 					}
+				}
 				//}
 
 				// Total TTC
@@ -1240,7 +1240,7 @@ class pdf_aurore extends ModelePDFSupplierProposal
 		    $pdf->line($this->posxunit - 1, $tab_top, $this->posxunit - 1, $tab_top + $tab_height);
 		    if (empty($hidetop)) {
 		        $pdf->SetXY($this->posxunit - 1, $tab_top + 1);
-        $pdf->MultiCell($this->posxdiscount - $this->posxunit - 1, 2, $outputlangs->transnoentities("Unit"), '', 'C');
+                $pdf->MultiCell($this->posxdiscount - $this->posxunit - 1, 2, $outputlangs->transnoentities("Unit"), '', 'C');
 		    }
 		}
 
@@ -1345,12 +1345,12 @@ class pdf_aurore extends ModelePDFSupplierProposal
 			$pdf->SetTextColor(0, 0, 60);
 			$pdf->MultiCell(100, 3, $outputlangs->transnoentities("RefCustomer")." : " . $outputlangs->convToOutputCharset($object->ref_client), '', 'R');
 		}
-/* PHFAVRE
+        /* PHFAVRE
 		$posy+=4;
 		$pdf->SetXY($posx,$posy);
 		$pdf->SetTextColor(0,0,60);
-		$pdf->MultiCell(100, 3, $outputlangs->transnoentities("SupplierProposalDate")." : " . dol_print_date($object->date_livraison,"day",false,$outputlangs,true), '', 'R');
-*/
+		$pdf->MultiCell(100, 3, $outputlangs->transnoentities("SupplierProposalDate")." : " . dol_print_date($object->date_livraison, "day", false, $outputlangs, true), '', 'R');
+        */
 
 		if ($object->thirdparty->code_fournisseur)
 		{

+ 476 - 483
htdocs/core/tpl/advtarget.tpl.php

@@ -47,499 +47,492 @@ print '<script type="text/javascript" language="javascript">
 </script>';
 
 
-		print load_fiche_titre($langs->trans("AdvTgtTitle"));
-
-		print '<div class="tabBar">' . "\n";
-		print '<form name="find_customer" id="find_customer" action="' . $_SERVER['PHP_SELF'] . '?id=' . $id . '"  method="POST">' . "\n";
-		print '<input type="hidden" name="token" value="' . $_SESSION['newtoken'] . '">' . "\n";
-		print '<input type="hidden" name="action" value="">' . "\n";
-		print '<table class="border centpercent">' . "\n";
-
-		print '<tr>' . "\n";
-		print '<td colspan="3" class="right">' . "\n";
-
-		print '<input type="button" name="addcontact" id="addcontact" value="' . $langs->trans('AdvTgtAddContact') . '" class="butAction"/>' . "\n";
-
-		print '</td>' . "\n";
-		print '</tr>' . "\n";
-
-		print '<tr><td>' . $langs->trans('AdvTgtNameTemplate') . '</td><td>';
-		if (! empty($template_id)) {
-			$default_template = $template_id;
-		} else {
-			$default_template = $advTarget->id;
-		}
-		print $formadvtargetemaling->selectAdvtargetemailingTemplate('template_id', $default_template, 0, $advTarget->type_element);
-		print '<input type="button" name="loadfilter" id="loadfilter" value="' . $langs->trans('AdvTgtLoadFilter') . '" class="butAction"/>';
-		print '<input type="button" name="deletefilter" id="deletefilter" value="' . $langs->trans('AdvTgtDeleteFilter') . '" class="butAction"/>';
-		print '<input type="button" name="savefilter" id="savefilter" value="' . $langs->trans('AdvTgtSaveFilter') . '" class="butAction"/>';
-		print $langs->trans('AdvTgtOrCreateNewFilter');
-		print '<input type="text" name="template_name" id="template_name" value=""/>';
-		print '<input type="button" name="createfilter" id="createfilter" value="' . $langs->trans('AdvTgtCreateFilter') . '" class="butAction"/>';
-		print '</td><td>' . "\n";
-		print '</td></tr>' . "\n";
-
-		print '<tr><td>' . $langs->trans('AdvTgtTypeOfIncude') . '</td><td>';
-		print $form->selectarray('type_of_target', $advTarget->select_target_type, $array_query['type_of_target']);
-		print '</td><td>' . "\n";
-		print $form->textwithpicto('', $langs->trans("AdvTgtTypeOfIncudeHelp"), 1, 'help');
-		print '</td></tr>' . "\n";
-
-		// Customer name
-		print '<tr><td>' . $langs->trans('ThirdPartyName');
-		if (! empty($array_query['cust_name'])) {
-			print img_picto($langs->trans('AdvTgtUse'), 'ok.png@advtargetemailing');
-		}
-		print '</td><td><input type="text" name="cust_name" value="' . $array_query['cust_name'] . '"/></td><td>' . "\n";
-		print $form->textwithpicto('', $langs->trans("AdvTgtSearchTextHelp"), 1, 'help');
-		print '</td></tr>' . "\n";
-
-		// Code Client
-		print '<tr><td>' . $langs->trans('CustomerCode');
-		if (! empty($array_query['cust_code'])) {
-			print img_picto($langs->trans('AdvTgtUse'), 'ok.png@advtargetemailing');
-		}
-		print '</td><td><input type="text" name="cust_code" value="' . $array_query['cust_code'] . '"/></td><td>' . "\n";
-		print $form->textwithpicto('', $langs->trans("AdvTgtSearchTextHelp"), 1, 'help');
-		print '</td></tr>' . "\n";
-
-		// Address Client
-		print '<tr><td>' . $langs->trans('Address');
-		if (! empty($array_query['cust_adress'])) {
-			print img_picto($langs->trans('AdvTgtUse'), 'ok.png@advtargetemailing');
-		}
-		print '</td><td><input type="text" name="cust_adress" value="' . $array_query['cust_adress'] . '"/></td><td>' . "\n";
-		print $form->textwithpicto('', $langs->trans("AdvTgtSearchTextHelp"), 1, 'help');
-		print '</td></tr>' . "\n";
-
-		// Zip Client
-		print '<tr><td>' . $langs->trans('Zip');
-		if (! empty($array_query['cust_zip'])) {
-			print img_picto($langs->trans('AdvTgtUse'), 'ok.png@advtargetemailing');
-		}
-		print '</td><td><input type="text" name="cust_zip" value="' . $array_query['cust_zip'] . '"/></td><td>' . "\n";
-		print $form->textwithpicto('', $langs->trans("AdvTgtSearchTextHelp"), 1, 'help');
-		print '</td></tr>' . "\n";
-
-		// City Client
-		print '<tr><td>' . $langs->trans('Town');
-		if (! empty($array_query['cust_city'])) {
-			print img_picto($langs->trans('AdvTgtUse'), 'ok.png@advtargetemailing');
-		}
-		print '</td><td><input type="text" name="cust_city" value="' . $array_query['cust_city'] . '"/></td><td>' . "\n";
-		print $form->textwithpicto('', $langs->trans("AdvTgtSearchTextHelp"), 1, 'help');
-		print '</td></tr>' . "\n";
-
-		// Customer Country
-		print '<tr><td>' . $langs->trans("Country");
-		if (count($array_query['cust_country']) > 0) {
-			print img_picto($langs->trans('AdvTgtUse'), 'ok.png@advtargetemailing');
-		}
-		print '</td><td>' . "\n";
-		print $formadvtargetemaling->multiselectCountry('cust_country', $array_query['cust_country']);
-		print '</td><td>' . "\n";
-		print '</td></tr>' . "\n";
-
-		// State Customer
-		print '<tr><td>' . $langs->trans('Status') . ' ' . $langs->trans('ThirdParty');
-		if (count($array_query['cust_status']) > 0) {
-			print img_picto($langs->trans('AdvTgtUse'), 'ok.png@advtargetemailing');
-		}
-		print '</td><td>';
-        print $formadvtargetemaling->advMultiselectarray(
-            'cust_status', array (
-				'0' => $langs->trans('ActivityCeased'),
-				'1' => $langs->trans('InActivity')
-            ),
-            $array_query['cust_status']
-        );
-		print '</td><td>' . "\n";
-		print '</td></tr>' . "\n";
-
-		// Mother Company
-		print '<tr><td>' . $langs->trans("Maison mère");
-		if (! empty($array_query['cust_mothercompany'])) {
-			print img_picto($langs->trans('AdvTgtUse'), 'ok.png@advtargetemailing');
-		}
-		print '</td><td>' . "\n";
-		print '<input type="text" name="cust_mothercompany" value="' . $array_query['cust_mothercompany'] . '"/>';
-		print '</td><td>' . "\n";
-		print $form->textwithpicto('', $langs->trans("AdvTgtSearchTextHelp"), 1, 'help');
-		print '</td></tr>' . "\n";
-
-		// Prospect/Customer
-		$selected = $array_query['cust_typecust'];
-		print '<tr><td>' . $langs->trans('ProspectCustomer') . ' ' . $langs->trans('ThirdParty');
-		if (count($array_query['cust_typecust']) > 0) {
-			print img_picto($langs->trans('AdvTgtUse'), 'ok.png@advtargetemailing');
-		}
-		print '</td><td>';
-		$options_array = array (
-				2 => $langs->trans('Prospect'),
-				3 => $langs->trans('ProspectCustomer'),
-				1 => $langs->trans('Customer'),
-				0 => $langs->trans('NorProspectNorCustomer')
-		);
-		print $formadvtargetemaling->advMultiselectarray('cust_typecust', $options_array, $array_query['cust_typecust']);
-		print '</td><td>' . "\n";
-		print '</td></tr>' . "\n";
-
-		// Prospection status
-		print '<tr><td>' . $langs->trans('ProspectLevel');
-		if (count($array_query['cust_prospect_status']) > 0) {
-			print img_picto($langs->trans('AdvTgtUse'), 'ok.png@advtargetemailing');
-		}
-		print '</td><td>';
-		print $formadvtargetemaling->multiselectProspectionStatus($array_query['cust_prospect_status'], 'cust_prospect_status', 1);
-		print '</td><td>' . "\n";
-		print '</td></tr>' . "\n";
-
-		// Prospection comm status
-		print '<tr><td>' . $langs->trans('StatusProsp');
-		if (count($array_query['cust_comm_status']) > 0) {
-			print img_picto($langs->trans('AdvTgtUse'), 'ok.png@advtargetemailing');
-		}
-		print '</td><td>';
-		print $formadvtargetemaling->advMultiselectarray('cust_comm_status', $advTarget->type_statuscommprospect, $array_query['cust_comm_status']);
-		print '</td><td>' . "\n";
-		print '</td></tr>' . "\n";
-
-		// Customer Type
-		print '<tr><td>' . $langs->trans("ThirdPartyType");
-		if (count($array_query['cust_typeent']) > 0) {
-			print img_picto($langs->trans('AdvTgtUse'), 'ok.png@advtargetemailing');
-		}
-		print '</td><td>' . "\n";
-		print $formadvtargetemaling->advMultiselectarray('cust_typeent', $formcompany->typent_array(0, " AND id <> 0"), $array_query['cust_typeent']);
-		print '</td><td>' . "\n";
-		print '</td></tr>' . "\n";
-
-		// Staff number
-		print '<td>' . $langs->trans("Staff");
-		if (count($array_query['cust_effectif_id']) > 0) {
-			print img_picto($langs->trans('AdvTgtUse'), 'ok.png@advtargetemailing');
-		}
-		print '</td><td>';
-		print $formadvtargetemaling->advMultiselectarray("cust_effectif_id", $formcompany->effectif_array(0, " AND id <> 0"), $array_query['cust_effectif_id']);
-		print '</td><td>' . "\n";
-		print '</td></tr>' . "\n";
-
-		// Sales manager
-		print '<tr><td>' . $langs->trans("SalesRepresentatives");
-		if (count($array_query['cust_saleman']) > 0) {
-			print img_picto($langs->trans('AdvTgtUse'), 'ok.png@advtargetemailing');
-		}
-		print '</td><td>' . "\n";
-		print $formadvtargetemaling->multiselectselectSalesRepresentatives('cust_saleman', $array_query['cust_saleman'], $user);
-		print '</td><td>' . "\n";
-		print '</td></tr>' . "\n";
-
-		// Customer Default Langauge
-		if (! empty($conf->global->MAIN_MULTILANGS)) {
-			print '<tr><td>' . $langs->trans("DefaultLang");
-			if (count($array_query['cust_language']) > 0) {
+print load_fiche_titre($langs->trans("AdvTgtTitle"));
+
+print '<div class="tabBar">' . "\n";
+print '<form name="find_customer" id="find_customer" action="' . $_SERVER['PHP_SELF'] . '?id=' . $id . '"  method="POST">' . "\n";
+print '<input type="hidden" name="token" value="' . $_SESSION['newtoken'] . '">' . "\n";
+print '<input type="hidden" name="action" value="">' . "\n";
+print '<table class="border centpercent">' . "\n";
+
+print '<tr>' . "\n";
+print '<td colspan="3" class="right">' . "\n";
+
+print '<input type="button" name="addcontact" id="addcontact" value="' . $langs->trans('AdvTgtAddContact') . '" class="butAction"/>' . "\n";
+
+print '</td>' . "\n";
+print '</tr>' . "\n";
+
+print '<tr><td>' . $langs->trans('AdvTgtNameTemplate') . '</td><td>';
+if (! empty($template_id)) {
+	$default_template = $template_id;
+} else {
+	$default_template = $advTarget->id;
+}
+print $formadvtargetemaling->selectAdvtargetemailingTemplate('template_id', $default_template, 0, $advTarget->type_element);
+print '<input type="button" name="loadfilter" id="loadfilter" value="' . $langs->trans('AdvTgtLoadFilter') . '" class="butAction"/>';
+print '<input type="button" name="deletefilter" id="deletefilter" value="' . $langs->trans('AdvTgtDeleteFilter') . '" class="butAction"/>';
+print '<input type="button" name="savefilter" id="savefilter" value="' . $langs->trans('AdvTgtSaveFilter') . '" class="butAction"/>';
+print $langs->trans('AdvTgtOrCreateNewFilter');
+print '<input type="text" name="template_name" id="template_name" value=""/>';
+print '<input type="button" name="createfilter" id="createfilter" value="' . $langs->trans('AdvTgtCreateFilter') . '" class="butAction"/>';
+print '</td><td>' . "\n";
+print '</td></tr>' . "\n";
+
+print '<tr><td>' . $langs->trans('AdvTgtTypeOfIncude') . '</td><td>';
+print $form->selectarray('type_of_target', $advTarget->select_target_type, $array_query['type_of_target']);
+print '</td><td>' . "\n";
+print $form->textwithpicto('', $langs->trans("AdvTgtTypeOfIncudeHelp"), 1, 'help');
+print '</td></tr>' . "\n";
+
+// Customer name
+print '<tr><td>' . $langs->trans('ThirdPartyName');
+if (! empty($array_query['cust_name'])) {
+	print img_picto($langs->trans('AdvTgtUse'), 'ok.png@advtargetemailing');
+}
+print '</td><td><input type="text" name="cust_name" value="' . $array_query['cust_name'] . '"/></td><td>' . "\n";
+print $form->textwithpicto('', $langs->trans("AdvTgtSearchTextHelp"), 1, 'help');
+print '</td></tr>' . "\n";
+
+// Code Client
+print '<tr><td>' . $langs->trans('CustomerCode');
+if (! empty($array_query['cust_code'])) {
+	print img_picto($langs->trans('AdvTgtUse'), 'ok.png@advtargetemailing');
+}
+print '</td><td><input type="text" name="cust_code" value="' . $array_query['cust_code'] . '"/></td><td>' . "\n";
+print $form->textwithpicto('', $langs->trans("AdvTgtSearchTextHelp"), 1, 'help');
+print '</td></tr>' . "\n";
+
+// Address Client
+print '<tr><td>' . $langs->trans('Address');
+if (! empty($array_query['cust_adress'])) {
+	print img_picto($langs->trans('AdvTgtUse'), 'ok.png@advtargetemailing');
+}
+print '</td><td><input type="text" name="cust_adress" value="' . $array_query['cust_adress'] . '"/></td><td>' . "\n";
+print $form->textwithpicto('', $langs->trans("AdvTgtSearchTextHelp"), 1, 'help');
+print '</td></tr>' . "\n";
+
+// Zip Client
+print '<tr><td>' . $langs->trans('Zip');
+if (! empty($array_query['cust_zip'])) {
+	print img_picto($langs->trans('AdvTgtUse'), 'ok.png@advtargetemailing');
+}
+print '</td><td><input type="text" name="cust_zip" value="' . $array_query['cust_zip'] . '"/></td><td>' . "\n";
+print $form->textwithpicto('', $langs->trans("AdvTgtSearchTextHelp"), 1, 'help');
+print '</td></tr>' . "\n";
+
+// City Client
+print '<tr><td>' . $langs->trans('Town');
+if (! empty($array_query['cust_city'])) {
+	print img_picto($langs->trans('AdvTgtUse'), 'ok.png@advtargetemailing');
+}
+print '</td><td><input type="text" name="cust_city" value="' . $array_query['cust_city'] . '"/></td><td>' . "\n";
+print $form->textwithpicto('', $langs->trans("AdvTgtSearchTextHelp"), 1, 'help');
+print '</td></tr>' . "\n";
+
+// Customer Country
+print '<tr><td>' . $langs->trans("Country");
+if (count($array_query['cust_country']) > 0) {
+	print img_picto($langs->trans('AdvTgtUse'), 'ok.png@advtargetemailing');
+}
+print '</td><td>' . "\n";
+print $formadvtargetemaling->multiselectCountry('cust_country', $array_query['cust_country']);
+print '</td><td>' . "\n";
+print '</td></tr>' . "\n";
+
+// State Customer
+print '<tr><td>' . $langs->trans('Status') . ' ' . $langs->trans('ThirdParty');
+if (count($array_query['cust_status']) > 0) {
+	print img_picto($langs->trans('AdvTgtUse'), 'ok.png@advtargetemailing');
+}
+print '</td><td>';
+print $formadvtargetemaling->advMultiselectarray(
+    'cust_status', array (
+		'0' => $langs->trans('ActivityCeased'),
+		'1' => $langs->trans('InActivity')
+    ),
+    $array_query['cust_status']
+);
+print '</td><td>' . "\n";
+print '</td></tr>' . "\n";
+
+// Mother Company
+print '<tr><td>' . $langs->trans("Maison mère");
+if (! empty($array_query['cust_mothercompany'])) {
+	print img_picto($langs->trans('AdvTgtUse'), 'ok.png@advtargetemailing');
+}
+print '</td><td>' . "\n";
+print '<input type="text" name="cust_mothercompany" value="' . $array_query['cust_mothercompany'] . '"/>';
+print '</td><td>' . "\n";
+print $form->textwithpicto('', $langs->trans("AdvTgtSearchTextHelp"), 1, 'help');
+print '</td></tr>' . "\n";
+
+// Prospect/Customer
+$selected = $array_query['cust_typecust'];
+print '<tr><td>' . $langs->trans('ProspectCustomer') . ' ' . $langs->trans('ThirdParty');
+if (count($array_query['cust_typecust']) > 0) {
+	print img_picto($langs->trans('AdvTgtUse'), 'ok.png@advtargetemailing');
+}
+print '</td><td>';
+$options_array = array (
+	2 => $langs->trans('Prospect'),
+	3 => $langs->trans('ProspectCustomer'),
+	1 => $langs->trans('Customer'),
+	0 => $langs->trans('NorProspectNorCustomer')
+);
+print $formadvtargetemaling->advMultiselectarray('cust_typecust', $options_array, $array_query['cust_typecust']);
+print '</td><td>' . "\n";
+print '</td></tr>' . "\n";
+
+// Prospection status
+print '<tr><td>' . $langs->trans('ProspectLevel');
+if (count($array_query['cust_prospect_status']) > 0) {
+	print img_picto($langs->trans('AdvTgtUse'), 'ok.png@advtargetemailing');
+}
+print '</td><td>';
+print $formadvtargetemaling->multiselectProspectionStatus($array_query['cust_prospect_status'], 'cust_prospect_status', 1);
+print '</td><td>' . "\n";
+print '</td></tr>' . "\n";
+
+// Prospection comm status
+print '<tr><td>' . $langs->trans('StatusProsp');
+if (count($array_query['cust_comm_status']) > 0) {
+	print img_picto($langs->trans('AdvTgtUse'), 'ok.png@advtargetemailing');
+}
+print '</td><td>';
+print $formadvtargetemaling->advMultiselectarray('cust_comm_status', $advTarget->type_statuscommprospect, $array_query['cust_comm_status']);
+print '</td><td>' . "\n";
+print '</td></tr>' . "\n";
+
+// Customer Type
+print '<tr><td>' . $langs->trans("ThirdPartyType");
+if (count($array_query['cust_typeent']) > 0) {
+	print img_picto($langs->trans('AdvTgtUse'), 'ok.png@advtargetemailing');
+}
+print '</td><td>' . "\n";
+print $formadvtargetemaling->advMultiselectarray('cust_typeent', $formcompany->typent_array(0, " AND id <> 0"), $array_query['cust_typeent']);
+print '</td><td>' . "\n";
+print '</td></tr>' . "\n";
+
+// Staff number
+print '<td>' . $langs->trans("Staff");
+if (count($array_query['cust_effectif_id']) > 0) {
+	print img_picto($langs->trans('AdvTgtUse'), 'ok.png@advtargetemailing');
+}
+print '</td><td>';
+print $formadvtargetemaling->advMultiselectarray("cust_effectif_id", $formcompany->effectif_array(0, " AND id <> 0"), $array_query['cust_effectif_id']);
+print '</td><td>' . "\n";
+print '</td></tr>' . "\n";
+
+// Sales manager
+print '<tr><td>' . $langs->trans("SalesRepresentatives");
+if (count($array_query['cust_saleman']) > 0) {
+	print img_picto($langs->trans('AdvTgtUse'), 'ok.png@advtargetemailing');
+}
+print '</td><td>' . "\n";
+print $formadvtargetemaling->multiselectselectSalesRepresentatives('cust_saleman', $array_query['cust_saleman'], $user);
+print '</td><td>' . "\n";
+print '</td></tr>' . "\n";
+
+// Customer Default Langauge
+if (! empty($conf->global->MAIN_MULTILANGS)) {
+	print '<tr><td>' . $langs->trans("DefaultLang");
+	if (count($array_query['cust_language']) > 0) {
+		print img_picto($langs->trans('AdvTgtUse'), 'ok.png@advtargetemailing');
+	}
+	print '</td><td>' . "\n";
+	print $formadvtargetemaling->multiselectselectLanguage('cust_language', $array_query['cust_language']);
+	print '</td><td>' . "\n";
+	print '</td></tr>' . "\n";
+}
+
+if (! empty($conf->categorie->enabled) && $user->rights->categorie->lire) {
+	// Customer Categories
+	print '<tr><td>' . $langs->trans("CustomersCategoryShort");
+	if (count($array_query['cust_categ']) > 0) {
+		print img_picto($langs->trans('AdvTgtUse'), 'ok.png@advtargetemailing');
+	}
+	print '</td><td>' . "\n";
+	print $formadvtargetemaling->multiselectCustomerCategories('cust_categ', $array_query['cust_categ']);
+	print '</td><td>' . "\n";
+	print '</td></tr>' . "\n";
+}
+
+// Standard Extrafield feature
+if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) {
+	$elementtype = Societe::$table_element;
+	// fetch optionals attributes and labels
+	dol_include_once('/core/class/extrafields.class.php');
+	$extrafields = new ExtraFields($db);
+	$extrafields->fetch_name_optionals_label($elementtype);
+	foreach ($extrafields->attributes[$elementtype]['label'] as $key => $val) {
+		if ($key != 'ts_nameextra' && $key != 'ts_payeur') {
+			print '<tr><td>' . $extrafields->attributes[$elementtype]['label'][$key];
+			if (! empty($array_query['options_' . $key]) || (is_array($array_query['options_' . $key]) && count($array_query['options_' . $key]) > 0)) {
 				print img_picto($langs->trans('AdvTgtUse'), 'ok.png@advtargetemailing');
 			}
-			print '</td><td>' . "\n";
-			print $formadvtargetemaling->multiselectselectLanguage('cust_language', $array_query['cust_language']);
-			print '</td><td>' . "\n";
-			print '</td></tr>' . "\n";
-		}
-
-		if (! empty($conf->categorie->enabled) && $user->rights->categorie->lire) {
-			// Customer Categories
-			print '<tr><td>' . $langs->trans("CustomersCategoryShort");
-			if (count($array_query['cust_categ']) > 0) {
-				print img_picto($langs->trans('AdvTgtUse'), 'ok.png@advtargetemailing');
-			}
-			print '</td><td>' . "\n";
-			print $formadvtargetemaling->multiselectCustomerCategories('cust_categ', $array_query['cust_categ']);
-			print '</td><td>' . "\n";
-			print '</td></tr>' . "\n";
-		}
-
-		// Standard Extrafield feature
-		if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) {
-			$elementtype = Societe::$table_element;
-			// fetch optionals attributes and labels
-			dol_include_once('/core/class/extrafields.class.php');
-			$extrafields = new ExtraFields($db);
-			$extrafields->fetch_name_optionals_label($elementtype);
-			foreach ($extrafields->attributes[$elementtype]['label'] as $key => $val) {
-				if ($key != 'ts_nameextra' && $key != 'ts_payeur') {
-					print '<tr><td>' . $extrafields->attributes[$elementtype]['label'][$key];
-					if (! empty($array_query['options_' . $key]) || (is_array($array_query['options_' . $key]) && count($array_query['options_' . $key]) > 0)) {
-						print img_picto($langs->trans('AdvTgtUse'), 'ok.png@advtargetemailing');
-					}
-					print '</td><td>';
-					if (($extrafields->attributes[$elementtype]['type'][$key] == 'varchar') || ($extrafields->attributes[$elementtype]['type'][$key] == 'text')) {
-						print '<input type="text" name="options_' . $key . '"/></td><td>' . "\n";
-						print $form->textwithpicto('', $langs->trans("AdvTgtSearchTextHelp"), 1, 'help');
-					} elseif (($extrafields->attributes[$elementtype]['type'][$key] == 'int') || ($extrafields->attributes[$elementtype]['type'][$key] == 'double')) {
-						print $langs->trans("AdvTgtMinVal") . '<input type="text" name="options' . $key . '_min"/>';
-						print $langs->trans("AdvTgtMaxVal") . '<input type="text" name="options' . $key . '_max"/>';
-						print '</td><td>' . "\n";
-						print $form->textwithpicto('', $langs->trans("AdvTgtSearchIntHelp"), 1, 'help');
-					} elseif (($extrafields->attributes[$elementtype]['type'][$key] == 'date') || ($extrafields->attributes[$elementtype]['type'][$key] == 'datetime')) {
-						print '<table class="nobordernopadding"><tr>';
-						print '<td>' . $langs->trans("AdvTgtStartDt") . '</td><td>';
-						print $form->selectDate('', 'options_' . $key . '_st_dt');
-						print '</td><td>' . $langs->trans("AdvTgtEndDt") . '</td><td>';
-						print $form->selectDate('', 'options_' . $key . '_end_dt');
-						print '</td></tr></table>';
-
-						print '</td><td>' . "\n";
-						print $form->textwithpicto('', $langs->trans("AdvTgtSearchDtHelp"), 1, 'help');
-					} elseif (($extrafields->attributes[$elementtype]['type'][$key] == 'boolean')) {
-                        print $form->selectarray(
-                            'options_' . $key,
-                            array (
-								'' => '',
-								'1' => $langs->trans('Yes'),
-								'0' => $langs->trans('No')
-                            ),
-                            $array_query['options_' . $key]
-                        );
-						print '</td><td>' . "\n";
-					} elseif (($extrafields->attributes[$elementtype]['type'][$key] == 'select')) {
-						print $formadvtargetemaling->advMultiselectarray('options_' . $key, $extrafields->attribute_param[$key]['options'], $array_query['options_' . $key]);
-						print '</td><td>' . "\n";
-					} elseif (($extrafields->attributes[$elementtype]['type'][$key] == 'sellist')) {
-						print $formadvtargetemaling->advMultiselectarraySelllist('options_' . $key, $extrafields->attribute_param[$key]['options'], $array_query['options_' . $key]);
-						print '</td><td>' . "\n";
-					} else {
-						print '<table class="nobordernopadding"><tr>';
-						print '<td></td><td>';
-						if (is_array($array_query['options_' . $key])) {
-							print $extrafields->showInputField($key, implode(',', $array_query['options_' . $key]));
-						} else {
-							print $extrafields->showInputField($key, $array_query['options_' . $key]);
-						}
-						print '</td></tr></table>';
-
-						print '</td><td>' . "\n";
-					}
-					print '</td></tr>' . "\n";
+			print '</td><td>';
+			if (($extrafields->attributes[$elementtype]['type'][$key] == 'varchar') || ($extrafields->attributes[$elementtype]['type'][$key] == 'text')) {
+				print '<input type="text" name="options_' . $key . '"/></td><td>' . "\n";
+				print $form->textwithpicto('', $langs->trans("AdvTgtSearchTextHelp"), 1, 'help');
+			} elseif (($extrafields->attributes[$elementtype]['type'][$key] == 'int') || ($extrafields->attributes[$elementtype]['type'][$key] == 'double')) {
+				print $langs->trans("AdvTgtMinVal") . '<input type="text" name="options' . $key . '_min"/>';
+				print $langs->trans("AdvTgtMaxVal") . '<input type="text" name="options' . $key . '_max"/>';
+				print '</td><td>' . "\n";
+				print $form->textwithpicto('', $langs->trans("AdvTgtSearchIntHelp"), 1, 'help');
+			} elseif (($extrafields->attributes[$elementtype]['type'][$key] == 'date') || ($extrafields->attributes[$elementtype]['type'][$key] == 'datetime')) {
+				print '<table class="nobordernopadding"><tr>';
+				print '<td>' . $langs->trans("AdvTgtStartDt") . '</td><td>';
+				print $form->selectDate('', 'options_' . $key . '_st_dt');
+				print '</td><td>' . $langs->trans("AdvTgtEndDt") . '</td><td>';
+				print $form->selectDate('', 'options_' . $key . '_end_dt');
+				print '</td></tr></table>';
+
+				print '</td><td>' . "\n";
+				print $form->textwithpicto('', $langs->trans("AdvTgtSearchDtHelp"), 1, 'help');
+			} elseif (($extrafields->attributes[$elementtype]['type'][$key] == 'boolean')) {
+                print $form->selectarray(
+                    'options_' . $key,
+                    array (
+						'' => '',
+						'1' => $langs->trans('Yes'),
+						'0' => $langs->trans('No')
+                    ),
+                    $array_query['options_' . $key]
+                );
+				print '</td><td>' . "\n";
+			} elseif (($extrafields->attributes[$elementtype]['type'][$key] == 'select')) {
+				print $formadvtargetemaling->advMultiselectarray('options_' . $key, $extrafields->attribute_param[$key]['options'], $array_query['options_' . $key]);
+				print '</td><td>' . "\n";
+			} elseif (($extrafields->attributes[$elementtype]['type'][$key] == 'sellist')) {
+				print $formadvtargetemaling->advMultiselectarraySelllist('options_' . $key, $extrafields->attribute_param[$key]['options'], $array_query['options_' . $key]);
+				print '</td><td>' . "\n";
+			} else {
+				print '<table class="nobordernopadding"><tr>';
+				print '<td></td><td>';
+				if (is_array($array_query['options_' . $key])) {
+					print $extrafields->showInputField($key, implode(',', $array_query['options_' . $key]));
+				} else {
+					print $extrafields->showInputField($key, $array_query['options_' . $key]);
 				}
-			}
-		} else {
-			$std_soc = new Societe($db);
-			$action_search = 'query';
+				print '</td></tr></table>';
 
-			// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
-			include_once DOL_DOCUMENT_ROOT . '/core/class/hookmanager.class.php';
-			$hookmanager = new HookManager($db);
-			$hookmanager->initHooks(array ('thirdpartycard'));
-
-			$parameters=array();
-			if (! empty($advTarget->id)) {
-				$parameters = array('array_query' => $advTarget->filtervalue);
+				print '</td><td>' . "\n";
 			}
-			// Other attributes
-			$reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $std_soc, $action_search);
-            print $hookmanager->resPrint;
+			print '</td></tr>' . "\n";
 		}
-
-		// State Contact
-		print '<tr><td>' . $langs->trans('Status') . ' ' . $langs->trans('Contact');
-		if (count($array_query['contact_status']) > 0) {
+	}
+} else {
+	$std_soc = new Societe($db);
+	$action_search = 'query';
+
+	// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
+	include_once DOL_DOCUMENT_ROOT . '/core/class/hookmanager.class.php';
+	$hookmanager = new HookManager($db);
+	$hookmanager->initHooks(array ('thirdpartycard'));
+
+	$parameters=array();
+	if (! empty($advTarget->id)) {
+		$parameters = array('array_query' => $advTarget->filtervalue);
+	}
+	// Other attributes
+	$reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $std_soc, $action_search);
+    print $hookmanager->resPrint;
+}
+
+// State Contact
+print '<tr><td>' . $langs->trans('Status') . ' ' . $langs->trans('Contact');
+if (count($array_query['contact_status']) > 0) {
+	print img_picto($langs->trans('AdvTgtUse'), 'ok.png@advtargetemailing');
+}
+print '</td><td>';
+print $formadvtargetemaling->advMultiselectarray(
+    'contact_status',
+    array (
+		'0' => $langs->trans('ActivityCeased'),
+		'1' => $langs->trans('InActivity')
+    ),
+    $array_query['contact_status']
+);
+print '</td><td>' . "\n";
+print $form->textwithpicto('', $langs->trans("AdvTgtContactHelp"), 1, 'help');
+print '</td></tr>' . "\n";
+
+// Civility
+print '<tr><td width="15%">' . $langs->trans("UserTitle");
+if (count($array_query['contact_civility']) > 0) {
+	print img_picto($langs->trans('AdvTgtUse'), 'ok.png@advtargetemailing');
+}
+print '</td><td>';
+print $formadvtargetemaling->multiselectCivility('contact_civility', $array_query['contact_civility']);
+print '</td></tr>';
+
+// contact name
+print '<tr><td>' . $langs->trans('Contact') . ' ' . $langs->trans('Lastname');
+if (! empty($array_query['contact_lastname'])) {
+	print img_picto($langs->trans('AdvTgtUse'), 'ok.png@advtargetemailing');
+}
+print '</td><td><input type="text" name="contact_lastname" value="' . $array_query['contact_lastname'] . '"/></td><td>' . "\n";
+print $form->textwithpicto('', $langs->trans("AdvTgtSearchTextHelp"), 1, 'help');
+print '</td></tr>' . "\n";
+print '<tr><td>' . $langs->trans('Contact') . ' ' . $langs->trans('Firstname');
+if (! empty($array_query['contact_firstname'])) {
+	print img_picto($langs->trans('AdvTgtUse'), 'ok.png@advtargetemailing');
+}
+print '</td><td><input type="text" name="contact_firstname" value="' . $array_query['contact_firstname'] . '"/></td><td>' . "\n";
+print $form->textwithpicto('', $langs->trans("AdvTgtSearchTextHelp"), 1, 'help');
+print '</td></tr>' . "\n";
+
+// Contact Country
+print '<tr><td>' . $langs->trans('Contact') . ' ' . $langs->trans("Country");
+if (count($array_query['contact_country']) > 0) {
+	print img_picto($langs->trans('AdvTgtUse'), 'ok.png@advtargetemailing');
+}
+print '</td><td>' . "\n";
+print $formadvtargetemaling->multiselectCountry('contact_country', $array_query['contact_country']);
+print '</td><td>' . "\n";
+print '</td></tr>' . "\n";
+
+// Never send mass mailing
+print '<tr><td>' . $langs->trans('Contact') . ' ' . $langs->trans("No_Email");
+if (! empty($array_query['contact_no_email'])) {
+	print img_picto($langs->trans('AdvTgtUse'), 'ok.png@advtargetemailing');
+}
+print '</td><td>' . "\n";
+print $form->selectarray(
+    'contact_no_email',
+    array (
+		'' => '',
+		'1' => $langs->trans('Yes'),
+		'0' => $langs->trans('No')
+    ),
+    $array_query['contact_no_email']
+);
+print '</td><td>' . "\n";
+print '</td></tr>' . "\n";
+
+// Contact Date Create
+print '<tr><td>' . $langs->trans('Contact') . ' ' . $langs->trans("DateCreation");
+if (! empty($array_query['contact_create_st_dt'])) {
+	print img_picto($langs->trans('AdvTgtUse'), 'ok.png@advtargetemailing');
+}
+print '</td><td>' . "\n";
+print '<table class="nobordernopadding"><tr>';
+print '<td>' . $langs->trans("AdvTgtStartDt") . '</td><td>';
+print $form->selectDate($array_query['contact_create_st_dt'], 'contact_create_st_dt', 0, 0, 1, 'find_customer', 1, 1);
+print '</td><td>' . $langs->trans("AdvTgtEndDt") . '</td><td>';
+print $form->selectDate($array_query['contact_create_end_dt'], 'contact_create_end_dt', 0, 0, 1, 'find_customer', 1, 1);
+print '</td></tr></table>';
+print '</td><td>' . "\n";
+print '</td></tr>' . "\n";
+
+// Contact update Create
+print '<tr><td>' . $langs->trans('Contact') . ' ' . $langs->trans("DateLastModification");
+if (! empty($array_query['contact_update_st_dt'])) {
+	print img_picto($langs->trans('AdvTgtUse'), 'ok.png@advtargetemailing');
+}
+print '</td><td>' . "\n";
+print '<table class="nobordernopadding"><tr>';
+print '<td>' . $langs->trans("AdvTgtStartDt") . '</td><td>';
+print $form->selectDate($array_query['contact_update_st_dt'], 'contact_update_st_dt', 0, 0, 1, 'find_customer', 1, 1);
+print '</td><td>' . $langs->trans("AdvTgtEndDt") . '</td><td>';
+print $form->selectDate($array_query['contact_update_end_dt'], 'contact_update_end_dt', 0, 0, 1, 'find_customer', 1, 1);
+print '</td></tr></table>';
+print '</td><td>' . "\n";
+print '</td></tr>' . "\n";
+
+if (! empty($conf->categorie->enabled) && $user->rights->categorie->lire) {
+	// Customer Categories
+	print '<tr><td>' . $langs->trans("ContactCategoriesShort");
+	if (count($array_query['contact_categ']) > 0) {
+		print img_picto($langs->trans('AdvTgtUse'), 'ok.png@advtargetemailing');
+	}
+	print '</td><td>' . "\n";
+	print $formadvtargetemaling->multiselectContactCategories('contact_categ', $array_query['contact_categ']);
+	print '</td><td>' . "\n";
+	print '</td></tr>' . "\n";
+}
+
+// Standard Extrafield feature
+if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) {
+	$elementype=Contact::$table_element;
+	// fetch optionals attributes and labels
+	dol_include_once('/core/class/extrafields.class.php');
+	$extrafields = new ExtraFields($db);
+	$extrafields->fetch_name_optionals_label($elementype);
+    foreach($extrafields->attributes[$elementtype]['type'] as $key=>&$value) {
+        if($value == 'radio')$value = 'select';
+    }
+
+    foreach ($extrafields->attributes[$elementtype]['label'] as $key => $val) {
+		print '<tr><td>' . $extrafields->attributes[$elementtype]['label'][$key];
+		if ($array_query['options_' . $key . '_cnct'] != '' || (is_array($array_query['options_' . $key . '_cnct']) && count($array_query['options_' . $key . '_cnct']) > 0)) {
 			print img_picto($langs->trans('AdvTgtUse'), 'ok.png@advtargetemailing');
 		}
 		print '</td><td>';
-        print $formadvtargetemaling->advMultiselectarray(
-            'contact_status',
-            array (
-				'0' => $langs->trans('ActivityCeased'),
-				'1' => $langs->trans('InActivity')
-            ),
-            $array_query['contact_status']
-        );
-		print '</td><td>' . "\n";
-		print $form->textwithpicto('', $langs->trans("AdvTgtContactHelp"), 1, 'help');
-		print '</td></tr>' . "\n";
-
-		// Civility
-		print '<tr><td width="15%">' . $langs->trans("UserTitle");
-		if (count($array_query['contact_civility']) > 0) {
-			print img_picto($langs->trans('AdvTgtUse'), 'ok.png@advtargetemailing');
-		}
-		print '</td><td>';
-		print $formadvtargetemaling->multiselectCivility('contact_civility', $array_query['contact_civility']);
-		print '</td></tr>';
-
-		// contact name
-		print '<tr><td>' . $langs->trans('Contact') . ' ' . $langs->trans('Lastname');
-		if (! empty($array_query['contact_lastname'])) {
-			print img_picto($langs->trans('AdvTgtUse'), 'ok.png@advtargetemailing');
-		}
-		print '</td><td><input type="text" name="contact_lastname" value="' . $array_query['contact_lastname'] . '"/></td><td>' . "\n";
-		print $form->textwithpicto('', $langs->trans("AdvTgtSearchTextHelp"), 1, 'help');
-		print '</td></tr>' . "\n";
-		print '<tr><td>' . $langs->trans('Contact') . ' ' . $langs->trans('Firstname');
-		if (! empty($array_query['contact_firstname'])) {
-			print img_picto($langs->trans('AdvTgtUse'), 'ok.png@advtargetemailing');
-		}
-		print '</td><td><input type="text" name="contact_firstname" value="' . $array_query['contact_firstname'] . '"/></td><td>' . "\n";
-		print $form->textwithpicto('', $langs->trans("AdvTgtSearchTextHelp"), 1, 'help');
-		print '</td></tr>' . "\n";
-
-		// Contact Country
-		print '<tr><td>' . $langs->trans('Contact') . ' ' . $langs->trans("Country");
-		if (count($array_query['contact_country']) > 0) {
-			print img_picto($langs->trans('AdvTgtUse'), 'ok.png@advtargetemailing');
-		}
-		print '</td><td>' . "\n";
-		print $formadvtargetemaling->multiselectCountry('contact_country', $array_query['contact_country']);
-		print '</td><td>' . "\n";
-		print '</td></tr>' . "\n";
-
-		// Never send mass mailing
-		print '<tr><td>' . $langs->trans('Contact') . ' ' . $langs->trans("No_Email");
-		if (! empty($array_query['contact_no_email'])) {
-			print img_picto($langs->trans('AdvTgtUse'), 'ok.png@advtargetemailing');
-		}
-		print '</td><td>' . "\n";
-        print $form->selectarray(
-            'contact_no_email',
-            array (
-				'' => '',
-				'1' => $langs->trans('Yes'),
-				'0' => $langs->trans('No')
-            ),
-            $array_query['contact_no_email']
-        );
-		print '</td><td>' . "\n";
-		print '</td></tr>' . "\n";
-
-		// Contact Date Create
-		print '<tr><td>' . $langs->trans('Contact') . ' ' . $langs->trans("DateCreation");
-		if (! empty($array_query['contact_create_st_dt'])) {
-			print img_picto($langs->trans('AdvTgtUse'), 'ok.png@advtargetemailing');
-		}
-		print '</td><td>' . "\n";
-		print '<table class="nobordernopadding"><tr>';
-		print '<td>' . $langs->trans("AdvTgtStartDt") . '</td><td>';
-		print $form->selectDate($array_query['contact_create_st_dt'], 'contact_create_st_dt', 0, 0, 1, 'find_customer', 1, 1);
-		print '</td><td>' . $langs->trans("AdvTgtEndDt") . '</td><td>';
-		print $form->selectDate($array_query['contact_create_end_dt'], 'contact_create_end_dt', 0, 0, 1, 'find_customer', 1, 1);
-		print '</td></tr></table>';
-		print '</td><td>' . "\n";
-		print '</td></tr>' . "\n";
-
-		// Contact update Create
-		print '<tr><td>' . $langs->trans('Contact') . ' ' . $langs->trans("DateLastModification");
-		if (! empty($array_query['contact_update_st_dt'])) {
-			print img_picto($langs->trans('AdvTgtUse'), 'ok.png@advtargetemailing');
-		}
-		print '</td><td>' . "\n";
-		print '<table class="nobordernopadding"><tr>';
-		print '<td>' . $langs->trans("AdvTgtStartDt") . '</td><td>';
-		print $form->selectDate($array_query['contact_update_st_dt'], 'contact_update_st_dt', 0, 0, 1, 'find_customer', 1, 1);
-		print '</td><td>' . $langs->trans("AdvTgtEndDt") . '</td><td>';
-		print $form->selectDate($array_query['contact_update_end_dt'], 'contact_update_end_dt', 0, 0, 1, 'find_customer', 1, 1);
-		print '</td></tr></table>';
-		print '</td><td>' . "\n";
-		print '</td></tr>' . "\n";
-
-		if (! empty($conf->categorie->enabled) && $user->rights->categorie->lire) {
-			// Customer Categories
-			print '<tr><td>' . $langs->trans("ContactCategoriesShort");
-			if (count($array_query['contact_categ']) > 0) {
-				print img_picto($langs->trans('AdvTgtUse'), 'ok.png@advtargetemailing');
-			}
+		if (($extrafields->attributes[$elementtype]['type'][$key] == 'varchar') || ($extrafields->attributes[$elementtype]['type'][$key] == 'text')) {
+			print '<input type="text" name="options_' . $key . '_cnct"/></td><td>' . "\n";
+			print $form->textwithpicto('', $langs->trans("AdvTgtSearchTextHelp"), 1, 'help');
+		} elseif (($extrafields->attributes[$elementtype]['type'][$key] == 'int') || ($extrafields->attributes[$elementtype]['type'][$key] == 'double')) {
+			print $langs->trans("AdvTgtMinVal") . '<input type="text" name="options_' . $key . '_min_cnct"/>';
+			print $langs->trans("AdvTgtMaxVal") . '<input type="text" name="options_' . $key . '_max_cnct"/>';
 			print '</td><td>' . "\n";
-			print $formadvtargetemaling->multiselectContactCategories('contact_categ', $array_query['contact_categ']);
+			print $form->textwithpicto('', $langs->trans("AdvTgtSearchIntHelp"), 1, 'help');
+		} elseif (($extrafields->attributes[$elementtype]['type'][$key] == 'date') || ($extrafields->attributes[$elementtype]['type'][$key] == 'datetime')) {
+			print '<table class="nobordernopadding"><tr>';
+			print '<td>' . $langs->trans("AdvTgtStartDt") . '</td><td>';
+			print $form->selectDate('', 'options_' . $key . '_st_dt' . '_cnct');
+			print '</td><td>' . $langs->trans("AdvTgtEndDt") . '</td><td>';
+			print $form->selectDate('', 'options_' . $key . '_end_dt' . '_cnct');
+			print '</td></tr></table>';
 			print '</td><td>' . "\n";
-			print '</td></tr>' . "\n";
-		}
-
-		// Standard Extrafield feature
-		if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) {
-			$elementype=Contact::$table_element;
-			// fetch optionals attributes and labels
-			dol_include_once('/core/class/extrafields.class.php');
-			$extrafields = new ExtraFields($db);
-			$extrafields->fetch_name_optionals_label($elementype);
-            foreach($extrafields->attributes[$elementtype]['type'] as $key=>&$value) {
-                if($value == 'radio')$value = 'select';
-            }
-
-            foreach ($extrafields->attributes[$elementtype]['label'] as $key => $val)
-            {
-				print '<tr><td>' . $extrafields->attributes[$elementtype]['label'][$key];
-				if ($array_query['options_' . $key . '_cnct'] != '' || (is_array($array_query['options_' . $key . '_cnct']) && count($array_query['options_' . $key . '_cnct']) > 0)) {
-					print img_picto($langs->trans('AdvTgtUse'), 'ok.png@advtargetemailing');
-				}
-				print '</td><td>';
-				if (($extrafields->attributes[$elementtype]['type'][$key] == 'varchar') || ($extrafields->attributes[$elementtype]['type'][$key] == 'text')) {
-					print '<input type="text" name="options_' . $key . '_cnct"/></td><td>' . "\n";
-					print $form->textwithpicto('', $langs->trans("AdvTgtSearchTextHelp"), 1, 'help');
-				} elseif (($extrafields->attributes[$elementtype]['type'][$key] == 'int') || ($extrafields->attributes[$elementtype]['type'][$key] == 'double')) {
-					print $langs->trans("AdvTgtMinVal") . '<input type="text" name="options_' . $key . '_min_cnct"/>';
-					print $langs->trans("AdvTgtMaxVal") . '<input type="text" name="options_' . $key . '_max_cnct"/>';
-					print '</td><td>' . "\n";
-					print $form->textwithpicto('', $langs->trans("AdvTgtSearchIntHelp"), 1, 'help');
-				} elseif (($extrafields->attributes[$elementtype]['type'][$key] == 'date') || ($extrafields->attributes[$elementtype]['type'][$key] == 'datetime')) {
-					print '<table class="nobordernopadding"><tr>';
-					print '<td>' . $langs->trans("AdvTgtStartDt") . '</td><td>';
-					print $form->selectDate('', 'options_' . $key . '_st_dt' . '_cnct');
-					print '</td><td>' . $langs->trans("AdvTgtEndDt") . '</td><td>';
-					print $form->selectDate('', 'options_' . $key . '_end_dt' . '_cnct');
-					print '</td></tr></table>';
-
-					print '</td><td>' . "\n";
-					print $form->textwithpicto('', $langs->trans("AdvTgtSearchDtHelp"), 1, 'help');
-				} elseif (($extrafields->attributes[$elementtype]['type'][$key] == 'boolean')) {
-                    print $form->selectarray(
-                        'options_' . $key . '_cnct',
-                        array (
-							'' => '',
-							'1' => $langs->trans('Yes'),
-							'0' => $langs->trans('No')
-                        ),
-                        $array_query['options_' . $key . '_cnct']
-                    );
-					print '</td><td>' . "\n";
-				} elseif (($extrafields->attributes[$elementtype]['type'][$key] == 'select')) {
-					print $formadvtargetemaling->advMultiselectarray('options_' . $key . '_cnct', $extrafields->attribute_param[$key]['options'], $array_query['options_' . $key . '_cnct']);
-					print '</td><td>' . "\n";
-				} elseif (($extrafields->attributes[$elementtype]['type'][$key] == 'sellist')) {
-					print $formadvtargetemaling->advMultiselectarraySelllist('options_' . $key . '_cnct', $extrafields->attribute_param[$key]['options'], $array_query['options_' . $key . '_cnct']);
-					print '</td><td>' . "\n";
-				} else {
-					print '<table class="nobordernopadding"><tr>';
-					print '<td></td><td>';
-					if (is_array($array_query['options_' . $key . '_cnct'])) {
-						print $extrafields->showInputField($key, implode(',', $array_query['options_' . $key . '_cnct']), '', '_cnct');
-					} else {
-						print $extrafields->showInputField($key, $array_query['options_' . $key . '_cnct'], '', '_cnct');
-					}
-					print '</td></tr></table>';
-
-					print '</td><td>' . "\n";
-				}
-				print '</td></tr>' . "\n";
+			print $form->textwithpicto('', $langs->trans("AdvTgtSearchDtHelp"), 1, 'help');
+		} elseif (($extrafields->attributes[$elementtype]['type'][$key] == 'boolean')) {
+            print $form->selectarray(
+                'options_' . $key . '_cnct',
+                array (
+					'' => '',
+					'1' => $langs->trans('Yes'),
+					'0' => $langs->trans('No')
+                ),
+                $array_query['options_' . $key . '_cnct']
+            );
+			print '</td><td>' . "\n";
+		} elseif (($extrafields->attributes[$elementtype]['type'][$key] == 'select')) {
+			print $formadvtargetemaling->advMultiselectarray('options_' . $key . '_cnct', $extrafields->attribute_param[$key]['options'], $array_query['options_' . $key . '_cnct']);
+			print '</td><td>' . "\n";
+		} elseif (($extrafields->attributes[$elementtype]['type'][$key] == 'sellist')) {
+			print $formadvtargetemaling->advMultiselectarraySelllist('options_' . $key . '_cnct', $extrafields->attribute_param[$key]['options'], $array_query['options_' . $key . '_cnct']);
+			print '</td><td>' . "\n";
+		} else {
+			print '<table class="nobordernopadding"><tr>';
+			print '<td></td><td>';
+			if (is_array($array_query['options_' . $key . '_cnct'])) {
+				print $extrafields->showInputField($key, implode(',', $array_query['options_' . $key . '_cnct']), '', '_cnct');
+			} else {
+				print $extrafields->showInputField($key, $array_query['options_' . $key . '_cnct'], '', '_cnct');
 			}
+			print '</td></tr></table>';
+			print '</td><td>' . "\n";
 		}
-
-		print '<tr>' . "\n";
-		print '<td colspan="3" class="right">' . "\n";
-
-		print '<input type="button" name="addcontact" id="addcontact" value="' . $langs->trans('AdvTgtAddContact') . '" class="butAction"/>' . "\n";
-
-		print '</td>' . "\n";
-		print '</tr>' . "\n";
-		print '</table>' . "\n";
-		print '</form>' . "\n";
-		print '</div>' . "\n";
-
-		print '<form action="' . $_SERVER['PHP_SELF'] . '?action=clear&id=' . $object->id . '" method="POST">';
-		print '<input type="hidden" name="token" value="' . $_SESSION['newtoken'] . '">';
-		print load_fiche_titre($langs->trans("ToClearAllRecipientsClickHere"));
-		print '<table class="noborder" width="100%">';
-		print '<tr class="liste_titre">';
-		print '<td class="liste_titre right"><input type="submit" class="button" value="' . $langs->trans("TargetsReset") . '"></td>';
-		print '</tr>';
-		print '</table>';
-		print '</form>';
-		print '<br>';
+		print '</td></tr>' . "\n";
+	}
+}
+print '<tr>' . "\n";
+print '<td colspan="3" class="right">' . "\n";
+print '<input type="button" name="addcontact" id="addcontact" value="' . $langs->trans('AdvTgtAddContact') . '" class="butAction"/>' . "\n";
+print '</td>' . "\n";
+print '</tr>' . "\n";
+print '</table>' . "\n";
+print '</form>' . "\n";
+print '</div>' . "\n";
+print '<form action="' . $_SERVER['PHP_SELF'] . '?action=clear&id=' . $object->id . '" method="POST">';
+print '<input type="hidden" name="token" value="' . $_SESSION['newtoken'] . '">';
+print load_fiche_titre($langs->trans("ToClearAllRecipientsClickHere"));
+print '<table class="noborder" width="100%">';
+print '<tr class="liste_titre">';
+print '<td class="liste_titre right"><input type="submit" class="button" value="' . $langs->trans("TargetsReset") . '"></td>';
+print '</tr>';
+print '</table>';
+print '</form>';
+print '<br>';

+ 71 - 78
htdocs/core/tpl/contacts.tpl.php

@@ -67,7 +67,7 @@ $userstatic=new User($db);
 
 <?php
 if ($permission) {
-?>
+    ?>
 	<form class="tagtr liste_titre">
 		<div class="tagtd liste_titre"><?php echo $langs->trans("NatureOfContact"); ?></div>
 		<div class="tagtd liste_titre"><?php echo $langs->trans("ThirdParty"); ?></div>
@@ -81,13 +81,13 @@ if ($permission) {
 
 	if (empty($hideaddcontactforuser))
 	{
-	?>
+	    ?>
 	<form class="tagtr impair" action="<?php echo $_SERVER["PHP_SELF"].'?id='.$object->id; ?>" method="POST">
 	<input type="hidden" name="token" value="<?php echo $_SESSION['newtoken']; ?>" />
 	<input type="hidden" name="id" value="<?php echo $object->id; ?>" />
 	<input type="hidden" name="action" value="addcontact" />
 	<input type="hidden" name="source" value="internal" />
-	<?php if ($withproject) print '<input type="hidden" name="withproject" value="'.$withproject.'">'; ?>
+	    <?php if ($withproject) print '<input type="hidden" name="withproject" value="'.$withproject.'">'; ?>
 		<div class="nowrap tagtd"><?php echo img_object('', 'user').' '.$langs->trans("Users"); ?></div>
 		<div class="tagtd"><?php echo $conf->global->MAIN_INFO_SOCIETE_NOM; ?></div>
 		<div class="tagtd maxwidthonsmartphone"><?php echo $form->select_dolusers($user->id, 'userid', 0, (! empty($userAlreadySelected)?$userAlreadySelected:null), 0, null, null, 0, 56, '', 0, '', 'minwidth200imp'); ?></div>
@@ -101,19 +101,19 @@ if ($permission) {
 		<div class="tagtd center"><input type="submit" class="button" value="<?php echo $langs->trans("Add"); ?>"></div>
 	</form>
 
-	<?php
+	    <?php
 	}
 
 	if (empty($hideaddcontactforthirdparty))
 	{
-	?>
+	    ?>
 
 	<form class="tagtr pair" action="<?php echo $_SERVER["PHP_SELF"].'?id='.$object->id; ?>" method="POST">
 	<input type="hidden" name="token" value="<?php echo $_SESSION['newtoken']; ?>" />
 	<input type="hidden" name="id" value="<?php echo $object->id; ?>" />
 	<input type="hidden" name="action" value="addcontact" />
 	<input type="hidden" name="source" value="external" />
-	<?php if ($withproject) print '<input type="hidden" name="withproject" value="'.$withproject.'">'; ?>
+	    <?php if ($withproject) print '<input type="hidden" name="withproject" value="'.$withproject.'">'; ?>
 		<div class="tagtd nowrap noborderbottom"><?php echo img_object('', 'contact').' '.$langs->trans("ThirdPartyContacts"); ?></div>
 		<div class="tagtd nowrap maxwidthonsmartphone noborderbottom">
 			<?php $selectedCompany = isset($_GET["newcompany"])?$_GET["newcompany"]:$object->socid; ?>
@@ -141,7 +141,7 @@ if ($permission) {
 		</div>
 	</form>
 
-<?php
+        <?php
 	}
 }
 ?>
@@ -155,21 +155,21 @@ if ($permission) {
 		<div class="tagtd liste_titre">&nbsp;</div>
 	</form>
 
-	<?php
-	$var = false;
+<?php
+$var = false;
 
-	$arrayofsource=array('internal','external');	// Show both link to user and thirdparties contacts
-	foreach($arrayofsource as $source) {
-		$tmpobject=$object;
-		if (($object->element == 'shipping'|| $object->element == 'reception') && is_object($objectsrc)) $tmpobject=$objectsrc;
+$arrayofsource=array('internal','external');	// Show both link to user and thirdparties contacts
+foreach($arrayofsource as $source) {
+	$tmpobject=$object;
+	if (($object->element == 'shipping'|| $object->element == 'reception') && is_object($objectsrc)) $tmpobject=$objectsrc;
 
-		$tab = $tmpobject->liste_contact(-1, $source);
-		$num=count($tab);
+	$tab = $tmpobject->liste_contact(-1, $source);
+	$num=count($tab);
 
-		$i = 0;
-		while ($i < $num) {
-		    $var = ! $var;
-	?>
+	$i = 0;
+	while ($i < $num) {
+	    $var = ! $var;
+        ?>
 
 	<form class="tagtr oddeven <?php echo ($var?'impair':'pair') ?>">
 		<div class="tagtd left">
@@ -177,75 +177,68 @@ if ($permission) {
 			<?php if ($tab[$i]['source']=='external') echo $langs->trans("ThirdPartyContact"); ?>
 		</div>
 		<div class="tagtd left">
-			<?php
-			if ($tab[$i]['socid'] > 0)
-			{
-				$companystatic->fetch($tab[$i]['socid']);
-				echo $companystatic->getNomUrl(1);
-			}
-			if ($tab[$i]['socid'] < 0)
-			{
-				echo $conf->global->MAIN_INFO_SOCIETE_NOM;
-			}
-			if (! $tab[$i]['socid'])
-			{
-				echo '&nbsp;';
-			}
-			?>
+		<?php
+		if ($tab[$i]['socid'] > 0)
+		{
+			$companystatic->fetch($tab[$i]['socid']);
+			echo $companystatic->getNomUrl(1);
+		}
+		if ($tab[$i]['socid'] < 0)
+		{
+			echo $conf->global->MAIN_INFO_SOCIETE_NOM;
+		}
+		if (! $tab[$i]['socid'])
+		{
+			echo '&nbsp;';
+		}
+		?>
 		</div>
 		<div class="tagtd">
-			<?php
-			$statusofcontact = $tab[$i]['status'];
-
-			if ($tab[$i]['source']=='internal')
-			{
-				$userstatic->fetch($tab[$i]['id']);
-				echo $userstatic->getNomUrl(-1, '', 0, 0, 0, 0, '', 'valignmiddle');
-			}
-			if ($tab[$i]['source']=='external')
-			{
-				$contactstatic->fetch($tab[$i]['id']);
-				echo $contactstatic->getNomUrl(1, '', 0, '', 0, 0);
-			}
-			?>
+		<?php
+		$statusofcontact = $tab[$i]['status'];
+
+		if ($tab[$i]['source']=='internal')
+		{
+			$userstatic->fetch($tab[$i]['id']);
+			echo $userstatic->getNomUrl(-1, '', 0, 0, 0, 0, '', 'valignmiddle');
+		}
+		if ($tab[$i]['source']=='external')
+		{
+			$contactstatic->fetch($tab[$i]['id']);
+			echo $contactstatic->getNomUrl(1, '', 0, '', 0, 0);
+		}
+		?>
 		</div>
 		<div class="tagtd"><?php echo $tab[$i]['libelle']; ?></div>
 		<div class="tagtd center">
-			<?php //if ($object->statut >= 0) echo '<a href="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'&amp;action=swapstatut&amp;ligne='.$tab[$i]['rowid'].'">'; ?>
-			<?php
-			if ($tab[$i]['source']=='internal')
-			{
-				echo $userstatic->LibStatut($tab[$i]['statuscontact'], 3);
-			}
-			if ($tab[$i]['source']=='external')
-			{
-				echo $contactstatic->LibStatut($tab[$i]['statuscontact'], 3);
-			}
-			?>
-			<?php //if ($object->statut >= 0) echo '</a>'; ?>
+		<?php //if ($object->statut >= 0) echo '<a href="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'&amp;action=swapstatut&amp;ligne='.$tab[$i]['rowid'].'">';
+		if ($tab[$i]['source']=='internal')
+		{
+			echo $userstatic->LibStatut($tab[$i]['statuscontact'], 3);
+		}
+		if ($tab[$i]['source']=='external')
+		{
+			echo $contactstatic->LibStatut($tab[$i]['statuscontact'], 3);
+		}
+		//if ($object->statut >= 0) echo '</a>'; ?>
 		</div>
 		<div class="tagtd nowrap right">
-			<?php if ($permission) { ?>
+		<?php if ($permission) { ?>
 				&nbsp;<a href="<?php echo $_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=deletecontact&amp;lineid='.$tab[$i]['rowid']; ?>"><?php echo img_picto($langs->trans('Unlink'), 'unlink'); ?></a>
-			<?php } ?>
+		<?php } ?>
 		</div>
 	</form>
 
-<?php $i++; ?>
-<?php
-        }
+        <?php $i++;
     }
-?>
+}
 
-</div>
-</div>
-<!-- TEMPLATE CONTACTS HOOK BEGIN HERE -->
-<?php
-	if (is_object($hookmanager))
-	{
-		$hookmanager->initHooks(array('contacttpl'));
-		$parameters=array();
-		$reshook=$hookmanager->executeHooks('formContactTpl', $parameters, $object, $action);
-	}
-?>
-<!-- END PHP TEMPLATE CONTACTS -->
+print "</div>\n";
+print "</div>\n";
+print "<!-- TEMPLATE CONTACTS HOOK BEGIN HERE -->\n";
+if (is_object($hookmanager)) {
+    $hookmanager->initHooks(array('contacttpl'));
+    $parameters=array();
+    $reshook=$hookmanager->executeHooks('formContactTpl', $parameters, $object, $action);
+}
+print "<!-- END PHP TEMPLATE CONTACTS -->\n";

+ 13 - 15
htdocs/core/tpl/login.tpl.php

@@ -63,19 +63,17 @@ if (! isset($conf->global->THEME_ELDY_TOPMENU_BACK1)) $conf->global->THEME_ELDY_
 $colorbackhmenu1 = empty($user->conf->THEME_ELDY_ENABLE_PERSONALIZED)?(empty($conf->global->THEME_ELDY_TOPMENU_BACK1)?$colorbackhmenu1:$conf->global->THEME_ELDY_TOPMENU_BACK1):(empty($user->conf->THEME_ELDY_TOPMENU_BACK1)?$colorbackhmenu1:$user->conf->THEME_ELDY_TOPMENU_BACK1);
 $colorbackhmenu1 = join(',', colorStringToArray($colorbackhmenu1));    // Normalize value to 'x,y,z'
 
-?>
-<!-- BEGIN PHP TEMPLATE LOGIN.TPL.PHP -->
+print "<!-- BEGIN PHP TEMPLATE LOGIN.TPL.PHP -->\n";
 
-<?php
 if (!empty($conf->global->ADD_UNSPLASH_LOGIN_BACKGROUND)) {
 	// For example $conf->global->ADD_UNSPLASH_LOGIN_BACKGROUND = 'https://source.unsplash.com/random'
-?>
+	?>
 	<body class="body bodylogin" style="background-image: url('<?php echo dol_escape_htmltag($conf->global->ADD_UNSPLASH_LOGIN_BACKGROUND); ?>'); background-repeat: no-repeat; background-position: center center; background-attachment: fixed; background-size: cover; background-color: #ffffff;">
-<?php
+	<?php
 } else {
-?>
+	?>
 	<body class="body bodylogin"<?php print empty($conf->global->MAIN_LOGIN_BACKGROUND)?'':' style="background-size: cover; background-position: center center; background-attachment: fixed; background-repeat: no-repeat; background-image: url(\''.DOL_URL_ROOT.'/viewimage.php?cache=1&noalt=1&modulepart=mycompany&file=logos/'.urlencode($conf->global->MAIN_LOGIN_BACKGROUND).'\')"'; ?>>
-<?php
+	<?php
 }
 ?>
 
@@ -179,7 +177,7 @@ if ($captcha) {
 	if (preg_match('/\?/', $php_self)) $php_self.='&time='.dol_print_date(dol_now(), 'dayhourlog');
 	else $php_self.='?time='.dol_print_date(dol_now(), 'dayhourlog');
 	// TODO: provide accessible captcha variants
-?>
+	?>
 	<!-- Captcha -->
 	<div class="trinputlogin">
 	<div class="tagtd nowraponall none center valignmiddle tdinputlogin">
@@ -279,11 +277,11 @@ if (isset($conf->file->main_authentication) && preg_match('/openid/', $conf->fil
 // Show error message if defined
 if (! empty($_SESSION['dol_loginmesg']))
 {
-?>
+	?>
 	<div class="center login_main_message"><div class="error">
 	<?php echo $_SESSION['dol_loginmesg']; ?>
 	</div></div>
-<?php
+	<?php
 }
 
 // Add commit strip
@@ -306,11 +304,11 @@ if (!empty($conf->global->MAIN_EASTER_EGG_COMMITSTRIP)) {
 
 <?php if ($main_home)
 {
-?>
+	?>
 	<div class="center login_main_home paddingtopbottom <?php echo empty($conf->global->MAIN_LOGIN_BACKGROUND)?'':' backgroundsemitransparent'; ?>" style="max-width: 70%">
 	<?php echo $main_home; ?>
 	</div><br>
-<?php
+	<?php
 }
 ?>
 
@@ -362,7 +360,7 @@ if (! empty($conf->google->enabled) && ! empty($conf->global->MAIN_GOOGLE_AD_CLI
 {
 	if (empty($conf->dol_use_jmobile))
 	{
-?>
+		?>
 	<div class="center"><br>
 		<script type="text/javascript"><!--
 			google_ad_client = "<?php echo $conf->global->MAIN_GOOGLE_AD_CLIENT ?>";
@@ -375,14 +373,14 @@ if (! empty($conf->google->enabled) && ! empty($conf->global->MAIN_GOOGLE_AD_CLI
 			src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
 		</script>
 	</div>
-<?php
+		<?php
 	}
 }
 ?>
 
 
 </div>
-</div>	<!-- end of center -->
+</div><!-- end of center -->
 
 
 </body>

+ 232 - 238
htdocs/core/tpl/objectline_create.tpl.php

@@ -90,13 +90,11 @@ if (!empty($extrafields))
 	}
 }
 
-?>
 
-<!-- BEGIN PHP TEMPLATE objectline_create.tpl.php -->
-<?php
+print "<!-- BEGIN PHP TEMPLATE objectline_create.tpl.php -->\n";
 $nolinesbefore=(count($this->lines) == 0 || $forcetoshowtitlelines);
 if ($nolinesbefore) {
-?>
+	?>
 <tr class="liste_titre<?php echo (($nolinesbefore || $object->element=='contrat')?'':' liste_titre_add_') ?> nodrag nodrop">
 	<?php if (! empty($conf->global->MAIN_VIEW_LINE_NUMBER)) { ?>
 	<td class="linecolnum center"></td>
@@ -107,9 +105,9 @@ if ($nolinesbefore) {
 	<?php
 	if ($object->element == 'supplier_proposal' || $object->element == 'order_supplier' || $object->element == 'invoice_supplier')	// We must have same test in printObjectLines
 	{
-	?>
+		?>
 		<td class="linecolrefsupplier"><span id="title_fourn_ref"><?php echo $langs->trans('SupplierRef'); ?></span></td>
-	<?php
+		<?php
 	}
 	?>
 	<td class="linecolvat right"><span id="title_vat"><?php echo $langs->trans('VAT'); ?></span></td>
@@ -156,109 +154,109 @@ if ($nolinesbefore) {
 	?>
 	<td class="linecoledit" colspan="<?php echo $colspan; ?>">&nbsp;</td>
 </tr>
-<?php
+	<?php
 }
 ?>
 <tr class="pair nodrag nodrop nohoverpair<?php echo ($nolinesbefore || $object->element=='contrat')?'':' liste_titre_create'; ?>">
 <?php
-    $coldisplay=0;
-
-    // Adds a line numbering column
-    if (! empty($conf->global->MAIN_VIEW_LINE_NUMBER)) {
-      $coldisplay++;
-      echo '<td class="nobottom linecolnum center"></td>';
-    }
+$coldisplay=0;
 
+// Adds a line numbering column
+if (! empty($conf->global->MAIN_VIEW_LINE_NUMBER)) {
     $coldisplay++;
-    ?>
+    echo '<td class="nobottom linecolnum center"></td>';
+}
+
+$coldisplay++;
+?>
 	<td class="nobottom linecoldescription minwidth500imp">
 
-	<?php
+<?php
 
-	$freelines = false;
-	if (empty($conf->global->MAIN_DISABLE_FREE_LINES))
+$freelines = false;
+if (empty($conf->global->MAIN_DISABLE_FREE_LINES))
+{
+	$freelines = true;
+	$forceall=1;	// We always force all type for free lines (module product or service means we use predefined product or service)
+	if ($object->element == 'contrat')
 	{
-		$freelines = true;
-		$forceall=1;	// We always force all type for free lines (module product or service means we use predefined product or service)
-		if ($object->element == 'contrat')
-		{
-			if (empty($conf->product->enabled) && empty($conf->service->enabled) && empty($conf->global->CONTRACT_SUPPORT_PRODUCTS)) $forceall=-1;	// With contract, by default, no choice at all, except if CONTRACT_SUPPORT_PRODUCTS is set
-			elseif (empty($conf->global->CONTRACT_SUPPORT_PRODUCTS)) $forceall=3;
-		}
+		if (empty($conf->product->enabled) && empty($conf->service->enabled) && empty($conf->global->CONTRACT_SUPPORT_PRODUCTS)) $forceall=-1;	// With contract, by default, no choice at all, except if CONTRACT_SUPPORT_PRODUCTS is set
+		elseif (empty($conf->global->CONTRACT_SUPPORT_PRODUCTS)) $forceall=3;
+	}
 
-		// Free line
-		echo '<span class="prod_entry_mode_free">';
-		// Show radio free line
-		if ($forceall >= 0 && (! empty($conf->product->enabled) || ! empty($conf->service->enabled)))
+	// Free line
+	echo '<span class="prod_entry_mode_free">';
+	// Show radio free line
+	if ($forceall >= 0 && (! empty($conf->product->enabled) || ! empty($conf->service->enabled)))
+	{
+		echo '<label for="prod_entry_mode_free">';
+		echo '<input type="radio" class="prod_entry_mode_free" name="prod_entry_mode" id="prod_entry_mode_free" value="free"';
+		//echo (GETPOST('prod_entry_mode')=='free' ? ' checked' : ((empty($forceall) && (empty($conf->product->enabled) || empty($conf->service->enabled)))?' checked':'') );
+		echo (GETPOST('prod_entry_mode')=='free' ? ' checked' : '');
+		echo '> ';
+		// Show type selector
+		echo $langs->trans("FreeLineOfType");
+		echo '</label>';
+		echo ' ';
+	}
+	else
+	{
+		echo '<input type="hidden" id="prod_entry_mode_free" name="prod_entry_mode" value="free">';
+		// Show type selector
+		if ($forceall >= 0)
 		{
-			echo '<label for="prod_entry_mode_free">';
-			echo '<input type="radio" class="prod_entry_mode_free" name="prod_entry_mode" id="prod_entry_mode_free" value="free"';
-			//echo (GETPOST('prod_entry_mode')=='free' ? ' checked' : ((empty($forceall) && (empty($conf->product->enabled) || empty($conf->service->enabled)))?' checked':'') );
-			echo (GETPOST('prod_entry_mode')=='free' ? ' checked' : '');
-			echo '> ';
-			// Show type selector
-			echo $langs->trans("FreeLineOfType");
-			echo '</label>';
+		    if (empty($conf->product->enabled) || empty($conf->service->enabled)) echo $langs->trans("Type");
+			else echo $langs->trans("FreeLineOfType");
 			echo ' ';
 		}
-		else
-		{
-			echo '<input type="hidden" id="prod_entry_mode_free" name="prod_entry_mode" value="free">';
-			// Show type selector
-			if ($forceall >= 0)
-			{
-			    if (empty($conf->product->enabled) || empty($conf->service->enabled)) echo $langs->trans("Type");
-				else echo $langs->trans("FreeLineOfType");
-				echo ' ';
-			}
-		}
+	}
 
-		echo $form->select_type_of_lines(isset($_POST["type"])?GETPOST("type", 'alpha', 2):-1, 'type', 1, 1, $forceall);
+	echo $form->select_type_of_lines(isset($_POST["type"])?GETPOST("type", 'alpha', 2):-1, 'type', 1, 1, $forceall);
+
+	echo '</span>';
+}
 
-		echo '</span>';
+// Predefined product/service
+if (! empty($conf->product->enabled) || ! empty($conf->service->enabled))
+{
+	if ($forceall >= 0 && $freelines) echo '<br>';
+	echo '<span class="prod_entry_mode_predef">';
+	echo '<label for="prod_entry_mode_predef">';
+	echo '<input type="radio" class="prod_entry_mode_predef" name="prod_entry_mode" id="prod_entry_mode_predef" value="predef"'.(GETPOST('prod_entry_mode')=='predef'?' checked':'').'> ';
+	if (empty($senderissupplier))
+	{
+		if (! empty($conf->product->enabled) && empty($conf->service->enabled)) echo $langs->trans('PredefinedProductsToSell');
+		elseif ((empty($conf->product->enabled) && ! empty($conf->service->enabled)) || ($object->element == 'contrat' && empty($conf->global->CONTRACT_SUPPORT_PRODUCTS))) echo $langs->trans('PredefinedServicesToSell');
+		else echo $langs->trans('PredefinedProductsAndServicesToSell');
 	}
+	else
+	{
+		if (! empty($conf->product->enabled) && empty($conf->service->enabled)) echo $langs->trans('PredefinedProductsToPurchase');
+		elseif (empty($conf->product->enabled) && ! empty($conf->service->enabled)) echo $langs->trans('PredefinedServicesToPurchase');
+		else echo $langs->trans('PredefinedProductsAndServicesToPurchase');
+	}
+	echo '</label>';
+	echo ' ';
+
+	$filtertype='';
+	if (! empty($object->element) && $object->element == 'contrat' && empty($conf->global->CONTRACT_SUPPORT_PRODUCTS)) $filtertype='1';
 
-	// Predefined product/service
-	if (! empty($conf->product->enabled) || ! empty($conf->service->enabled))
+	if (empty($senderissupplier))
 	{
-		if ($forceall >= 0 && $freelines) echo '<br>';
-		echo '<span class="prod_entry_mode_predef">';
-		echo '<label for="prod_entry_mode_predef">';
-		echo '<input type="radio" class="prod_entry_mode_predef" name="prod_entry_mode" id="prod_entry_mode_predef" value="predef"'.(GETPOST('prod_entry_mode')=='predef'?' checked':'').'> ';
-		if (empty($senderissupplier))
+		$statustoshow = 1;
+		if (! empty($conf->global->ENTREPOT_EXTRA_STATUS))
 		{
-			if (! empty($conf->product->enabled) && empty($conf->service->enabled)) echo $langs->trans('PredefinedProductsToSell');
-			elseif ((empty($conf->product->enabled) && ! empty($conf->service->enabled)) || ($object->element == 'contrat' && empty($conf->global->CONTRACT_SUPPORT_PRODUCTS))) echo $langs->trans('PredefinedServicesToSell');
-			else echo $langs->trans('PredefinedProductsAndServicesToSell');
+			// hide products in closed warehouse, but show products for internal transfer
+			$form->select_produits(GETPOST('idprod'), 'idprod', $filtertype, $conf->product->limit_size, $buyer->price_level, $statustoshow, 2, '', 1, array(), $buyer->id, '1', 0, 'maxwidth300', 0, 'warehouseopen,warehouseinternal', GETPOST('combinations', 'array'));
 		}
 		else
 		{
-			if (! empty($conf->product->enabled) && empty($conf->service->enabled)) echo $langs->trans('PredefinedProductsToPurchase');
-			elseif (empty($conf->product->enabled) && ! empty($conf->service->enabled)) echo $langs->trans('PredefinedServicesToPurchase');
-			else echo $langs->trans('PredefinedProductsAndServicesToPurchase');
+			$form->select_produits(GETPOST('idprod'), 'idprod', $filtertype, $conf->product->limit_size, $buyer->price_level, $statustoshow, 2, '', 1, array(), $buyer->id, '1', 0, 'maxwidth300', 0, '', GETPOST('combinations', 'array'));
 		}
-		echo '</label>';
-		echo ' ';
-
-		$filtertype='';
-		if (! empty($object->element) && $object->element == 'contrat' && empty($conf->global->CONTRACT_SUPPORT_PRODUCTS)) $filtertype='1';
 
-		if (empty($senderissupplier))
+		if (! empty($conf->global->MAIN_AUTO_OPEN_SELECT2_ON_FOCUS_FOR_CUSTOMER_PRODUCTS))
 		{
-			$statustoshow = 1;
-			if (! empty($conf->global->ENTREPOT_EXTRA_STATUS))
-			{
-				// hide products in closed warehouse, but show products for internal transfer
-				$form->select_produits(GETPOST('idprod'), 'idprod', $filtertype, $conf->product->limit_size, $buyer->price_level, $statustoshow, 2, '', 1, array(), $buyer->id, '1', 0, 'maxwidth300', 0, 'warehouseopen,warehouseinternal', GETPOST('combinations', 'array'));
-			}
-			else
-			{
-				$form->select_produits(GETPOST('idprod'), 'idprod', $filtertype, $conf->product->limit_size, $buyer->price_level, $statustoshow, 2, '', 1, array(), $buyer->id, '1', 0, 'maxwidth300', 0, '', GETPOST('combinations', 'array'));
-			}
-
-			if (! empty($conf->global->MAIN_AUTO_OPEN_SELECT2_ON_FOCUS_FOR_CUSTOMER_PRODUCTS))
-			{
-				?>
+			?>
 	            <script type="text/javascript">
 	                $(document).ready(function(){
 		                	// On first focus on a select2 combo, auto open the menu (this allow to use the keyboard only)
@@ -272,34 +270,34 @@ if ($nolinesbefore) {
 		                	});
 	                });
 	            </script>
-	            <?php
-		    }
-		}
-		else
-		{
-			// $senderissupplier=2 is the same as 1 but disables test on minimum qty and disable autofill qty with minimum
-		    if ($senderissupplier != 2)
-		    {
-    			$ajaxoptions=array(
-    				'update' => array('qty'=>'qty','remise_percent' => 'discount','idprod' => 'idprod'),	// html id tags that will be edited with which ajax json response key
-    				'option_disabled' => 'idthatdoesnotexists',					// html id to disable once select is done
-    				'warning' => $langs->trans("NoPriceDefinedForThisSupplier") // translation of an error saved into var 'warning' (for example shown we select a disabled option into combo)
-    			);
-    			$alsoproductwithnosupplierprice=0;
-		    }
-		    else
-		    {
-		        $ajaxoptions = array(
-                    'update' => array('remise_percent' => 'discount')			// html id tags that will be edited with each ajax json response key
-    			);
-		        $alsoproductwithnosupplierprice=1;
-		    }
-
-		    $form->select_produits_fournisseurs($object->socid, GETPOST('idprodfournprice'), 'idprodfournprice', '', '', $ajaxoptions, 1, $alsoproductwithnosupplierprice, 'maxwidth300');
-
-		    if (! empty($conf->global->MAIN_AUTO_OPEN_SELECT2_ON_FOCUS_FOR_SUPPLIER_PRODUCTS))
-		    {
-			    ?>
+            <?php
+	    }
+	}
+	else
+	{
+		// $senderissupplier=2 is the same as 1 but disables test on minimum qty and disable autofill qty with minimum
+	    if ($senderissupplier != 2)
+	    {
+    		$ajaxoptions=array(
+    			'update' => array('qty'=>'qty','remise_percent' => 'discount','idprod' => 'idprod'),	// html id tags that will be edited with which ajax json response key
+    			'option_disabled' => 'idthatdoesnotexists',					// html id to disable once select is done
+    			'warning' => $langs->trans("NoPriceDefinedForThisSupplier") // translation of an error saved into var 'warning' (for example shown we select a disabled option into combo)
+    		);
+    		$alsoproductwithnosupplierprice=0;
+	    }
+	    else
+	    {
+	        $ajaxoptions = array(
+                'update' => array('remise_percent' => 'discount')			// html id tags that will be edited with each ajax json response key
+    		);
+	        $alsoproductwithnosupplierprice=1;
+	    }
+
+	    $form->select_produits_fournisseurs($object->socid, GETPOST('idprodfournprice'), 'idprodfournprice', '', '', $ajaxoptions, 1, $alsoproductwithnosupplierprice, 'maxwidth300');
+
+	    if (! empty($conf->global->MAIN_AUTO_OPEN_SELECT2_ON_FOCUS_FOR_SUPPLIER_PRODUCTS))
+	    {
+		    ?>
 	            <script type="text/javascript">
 	                $(document).ready(function(){
 		                	// On first focus on a select2 combo, auto open the menu (this allow to use the keyboard only)
@@ -312,155 +310,155 @@ if ($nolinesbefore) {
 		                	});
 	                });
 	            </script>
-	            <?php
-		    }
-		}
-		echo '<input type="hidden" name="pbq" id="pbq" value="">';
-		echo '</span>';
+            <?php
+	    }
 	}
+	echo '<input type="hidden" name="pbq" id="pbq" value="">';
+	echo '</span>';
+}
 
-	if (is_object($hookmanager) && empty($senderissupplier))
-	{
-        $parameters=array('fk_parent_line'=>GETPOST('fk_parent_line', 'int'));
-		$reshook=$hookmanager->executeHooks('formCreateProductOptions', $parameters, $object, $action);
-		if (!empty($hookmanager->resPrint)) {
-			print $hookmanager->resPrint;
-		}
+if (is_object($hookmanager) && empty($senderissupplier))
+{
+    $parameters=array('fk_parent_line'=>GETPOST('fk_parent_line', 'int'));
+	$reshook=$hookmanager->executeHooks('formCreateProductOptions', $parameters, $object, $action);
+	if (!empty($hookmanager->resPrint)) {
+		print $hookmanager->resPrint;
 	}
-	if (is_object($hookmanager) && ! empty($senderissupplier))
-	{
-		$parameters=array('htmlname'=>'addproduct');
-		$reshook=$hookmanager->executeHooks('formCreateProductSupplierOptions', $parameters, $object, $action);
-		if (!empty($hookmanager->resPrint)) {
-			print $hookmanager->resPrint;
-		}
+}
+if (is_object($hookmanager) && ! empty($senderissupplier))
+{
+	$parameters=array('htmlname'=>'addproduct');
+	$reshook=$hookmanager->executeHooks('formCreateProductSupplierOptions', $parameters, $object, $action);
+	if (!empty($hookmanager->resPrint)) {
+		print $hookmanager->resPrint;
 	}
+}
 
 
-	if (! empty($conf->product->enabled) || ! empty($conf->service->enabled)) {
-		if (!empty($conf->variants->enabled)) {
-			echo '<div id="attributes_box"></div>';
-		}
-
-		echo '<br>';
+if (! empty($conf->product->enabled) || ! empty($conf->service->enabled)) {
+	if (!empty($conf->variants->enabled)) {
+		echo '<div id="attributes_box"></div>';
 	}
 
-	// Editor wysiwyg
-	require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
-	$nbrows=ROWS_2;
-	$enabled=(! empty($conf->global->FCKEDITOR_ENABLE_DETAILS)?$conf->global->FCKEDITOR_ENABLE_DETAILS:0);
-	if (! empty($conf->global->MAIN_INPUT_DESC_HEIGHT)) $nbrows=$conf->global->MAIN_INPUT_DESC_HEIGHT;
-	$toolbarname='dolibarr_details';
-	if (! empty($conf->global->FCKEDITOR_ENABLE_DETAILS_FULL)) $toolbarname='dolibarr_notes';
-	$doleditor=new DolEditor('dp_desc', GETPOST('dp_desc', 'none'), '', (empty($conf->global->MAIN_DOLEDITOR_HEIGHT)?100:$conf->global->MAIN_DOLEDITOR_HEIGHT), $toolbarname, '', false, true, $enabled, $nbrows, '98%');
-	$doleditor->Create();
-
-	// Show autofill date for recurring invoices
-	if (! empty($conf->service->enabled) && $object->element == 'facturerec')
-	{
-		echo '<div class="divlinefordates"><br>';
-		echo $langs->trans('AutoFillDateFrom').' ';
-		echo $form->selectyesno('date_start_fill', $line->date_start_fill, 1);
-		echo ' - ';
-		echo $langs->trans('AutoFillDateTo').' ';
-		echo $form->selectyesno('date_end_fill', $line->date_end_fill, 1);
-		echo '</div>';
-	}
-	echo '</td>';
+	echo '<br>';
+}
 
-	if ($object->element == 'supplier_proposal' || $object->element == 'order_supplier' || $object->element == 'invoice_supplier')	// We must have same test in printObjectLines
-	{
-		$coldisplay++;
-        ?>
-		<td class="nobottom linecolresupplier"><input id="fourn_ref" name="fourn_ref" class="flat minwidth50 maxwidth150" value="<?php echo (isset($_POST["fourn_ref"])?GETPOST("fourn_ref", 'alpha', 2):''); ?>"></td>
-	<?php } ?>
+// Editor wysiwyg
+require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
+$nbrows=ROWS_2;
+$enabled=(! empty($conf->global->FCKEDITOR_ENABLE_DETAILS)?$conf->global->FCKEDITOR_ENABLE_DETAILS:0);
+if (! empty($conf->global->MAIN_INPUT_DESC_HEIGHT)) $nbrows=$conf->global->MAIN_INPUT_DESC_HEIGHT;
+$toolbarname='dolibarr_details';
+if (! empty($conf->global->FCKEDITOR_ENABLE_DETAILS_FULL)) $toolbarname='dolibarr_notes';
+$doleditor=new DolEditor('dp_desc', GETPOST('dp_desc', 'none'), '', (empty($conf->global->MAIN_DOLEDITOR_HEIGHT)?100:$conf->global->MAIN_DOLEDITOR_HEIGHT), $toolbarname, '', false, true, $enabled, $nbrows, '98%');
+$doleditor->Create();
+
+// Show autofill date for recurring invoices
+if (! empty($conf->service->enabled) && $object->element == 'facturerec')
+{
+	echo '<div class="divlinefordates"><br>';
+	echo $langs->trans('AutoFillDateFrom').' ';
+	echo $form->selectyesno('date_start_fill', $line->date_start_fill, 1);
+	echo ' - ';
+	echo $langs->trans('AutoFillDateTo').' ';
+	echo $form->selectyesno('date_end_fill', $line->date_end_fill, 1);
+	echo '</div>';
+}
+echo '</td>';
 
-	<td class="nobottom linecolvat right"><?php
+if ($object->element == 'supplier_proposal' || $object->element == 'order_supplier' || $object->element == 'invoice_supplier')	// We must have same test in printObjectLines
+{
 	$coldisplay++;
-	if ($seller->tva_assuj == "0") echo '<input type="hidden" name="tva_tx" id="tva_tx" value="0">'.vatrate(0, true);
-	else echo $form->load_tva('tva_tx', (isset($_POST["tva_tx"])?GETPOST("tva_tx", 'alpha', 2):-1), $seller, $buyer, 0, 0, '', false, 1);
-	?>
+    ?>
+	<td class="nobottom linecolresupplier"><input id="fourn_ref" name="fourn_ref" class="flat minwidth50 maxwidth150" value="<?php echo (isset($_POST["fourn_ref"])?GETPOST("fourn_ref", 'alpha', 2):''); ?>"></td>
+<?php }
+
+print '<td class="nobottom linecolvat right">';
+$coldisplay++;
+if ($seller->tva_assuj == "0") echo '<input type="hidden" name="tva_tx" id="tva_tx" value="0">'.vatrate(0, true);
+else echo $form->load_tva('tva_tx', (isset($_POST["tva_tx"])?GETPOST("tva_tx", 'alpha', 2):-1), $seller, $buyer, 0, 0, '', false, 1);
+?>
 	</td>
 
 	<td class="nobottom linecoluht right"><?php $coldisplay++; ?>
 	<input type="text" size="5" name="price_ht" id="price_ht" class="flat right" value="<?php echo (isset($_POST["price_ht"])?GETPOST("price_ht", 'alpha', 2):''); ?>">
 	</td>
 
-	<?php if (!empty($conf->multicurrency->enabled) && $this->multicurrency_code != $conf->currency) {
-	    $coldisplay++;
+<?php if (!empty($conf->multicurrency->enabled) && $this->multicurrency_code != $conf->currency) {
+    $coldisplay++;
 	?>
 	<td class="nobottom linecoluht_currency right">
 	<input type="text" size="5" name="multicurrency_price_ht" id="multicurrency_price_ht" class="flat right" value="<?php echo (isset($_POST["multicurrency_price_ht"])?GETPOST("multicurrency_price_ht", 'alpha', 2):''); ?>">
 	</td>
-	<?php } ?>
+<?php }
 
-	<?php if (! empty($inputalsopricewithtax)) {
-	   $coldisplay++;
+if (! empty($inputalsopricewithtax)) {
+    $coldisplay++;
 	?>
 	<td class="nobottom linecoluttc right">
 	<input type="text" size="5" name="price_ttc" id="price_ttc" class="flat" value="<?php echo (isset($_POST["price_ttc"])?GETPOST("price_ttc", 'alpha', 2):''); ?>">
 	</td>
-	<?php }
+<?php }
 
-	$coldisplay++;
-	?>
+$coldisplay++;
+?>
 	<td class="nobottom linecolqty right"><input type="text" size="2" name="qty" id="qty" class="flat right" value="<?php echo (isset($_POST["qty"])?GETPOST("qty", 'alpha', 2):1); ?>">
 	</td>
-	<?php
-	if($conf->global->PRODUCT_USE_UNITS)
-	{
-	    $coldisplay++;
-		print '<td class="nobottom linecoluseunit left">';
-		print $form->selectUnits($line->fk_unit, "units");
-		print '</td>';
-	}
-	$remise_percent = $buyer->remise_percent;
-	if($object->element == 'supplier_proposal' || $object->element == 'order_supplier' || $object->element == 'invoice_supplier')
-	{
-		$remise_percent = $seller->remise_supplier_percent;
-	}
+<?php
+if($conf->global->PRODUCT_USE_UNITS)
+{
+    $coldisplay++;
+	print '<td class="nobottom linecoluseunit left">';
+	print $form->selectUnits($line->fk_unit, "units");
+	print '</td>';
+}
+$remise_percent = $buyer->remise_percent;
+if($object->element == 'supplier_proposal' || $object->element == 'order_supplier' || $object->element == 'invoice_supplier')
+{
+	$remise_percent = $seller->remise_supplier_percent;
+}
 
-	$coldisplay++;
-	?>
+$coldisplay++;
+?>
 	<td class="nobottom nowrap linecoldiscount right"><input type="text" size="1" name="remise_percent" id="remise_percent" class="flat right" value="<?php echo (isset($_POST["remise_percent"])?GETPOST("remise_percent", 'alpha', 2):$remise_percent); ?>"><span class="hideonsmartphone">%</span></td>
-	<?php
+<?php
 
-	if ($this->situation_cycle_ref) {
-		$coldisplay++;
-		print '<td class="nobottom nowrap right"><input class="falt right" type="text" size="1" value="0" name="progress">%</td>';
-		$coldisplay++;
-		print '<td></td>';
-	}
+if ($this->situation_cycle_ref) {
+	$coldisplay++;
+	print '<td class="nobottom nowrap right"><input class="falt right" type="text" size="1" value="0" name="progress">%</td>';
+	$coldisplay++;
+	print '<td></td>';
+}
 
-	if (! empty($usemargins))
-	{
-		if (!empty($user->rights->margins->creer)) {
-		    $coldisplay++;
-			?>
+if (! empty($usemargins))
+{
+	if (!empty($user->rights->margins->creer)) {
+	    $coldisplay++;
+		?>
 			<td class="nobottom margininfos linecolmargin right">
 				<!-- For predef product -->
-				<?php if (! empty($conf->product->enabled) || ! empty($conf->service->enabled)) { ?>
+		<?php if (! empty($conf->product->enabled) || ! empty($conf->service->enabled)) { ?>
 				<select id="fournprice_predef" name="fournprice_predef" class="flat minwidth75imp" style="display: none;"></select>
-				<?php } ?>
+		<?php } ?>
 				<!-- For free product -->
 				<input type="text" id="buying_price" name="buying_price" class="flat maxwidth75 right" value="<?php echo (isset($_POST["buying_price"])?GETPOST("buying_price", 'alpha', 2):''); ?>">
 			</td>
-			<?php
-			if (! empty($conf->global->DISPLAY_MARGIN_RATES))
-			{
-				echo '<td class="nobottom nowrap margininfos right"><input class="flat right" type="text" size="2" id="np_marginRate" name="np_marginRate" value="'.(isset($_POST["np_marginRate"])?GETPOST("np_marginRate", 'alpha', 2):'').'"><span class="np_marginRate hideonsmartphone">%</span></td>';
-				$coldisplay++;
-			}
-			if (! empty($conf->global->DISPLAY_MARK_RATES))
-			{
-				echo '<td class="nobottom nowrap margininfos right"><input class="flat right" type="text" size="2" id="np_markRate" name="np_markRate" value="'.(isset($_POST["np_markRate"])?GETPOST("np_markRate", 'alpha', 2):'').'"><span class="np_markRate hideonsmartphone">%</span></td>';
-				$coldisplay++;
-			}
+		<?php
+		if (! empty($conf->global->DISPLAY_MARGIN_RATES))
+		{
+			echo '<td class="nobottom nowrap margininfos right"><input class="flat right" type="text" size="2" id="np_marginRate" name="np_marginRate" value="'.(isset($_POST["np_marginRate"])?GETPOST("np_marginRate", 'alpha', 2):'').'"><span class="np_marginRate hideonsmartphone">%</span></td>';
+			$coldisplay++;
+		}
+		if (! empty($conf->global->DISPLAY_MARK_RATES))
+		{
+			echo '<td class="nobottom nowrap margininfos right"><input class="flat right" type="text" size="2" id="np_markRate" name="np_markRate" value="'.(isset($_POST["np_markRate"])?GETPOST("np_markRate", 'alpha', 2):'').'"><span class="np_markRate hideonsmartphone">%</span></td>';
+			$coldisplay++;
 		}
 	}
+}
 
-	$coldisplay+=$colspan;
-	?>
+$coldisplay+=$colspan;
+?>
 	<td class="nobottom linecoledit center valignmiddle" colspan="<?php echo $colspan; ?>">
 		<input type="submit" class="button" value="<?php echo $langs->trans('Add'); ?>" name="addline" id="addline">
 	</td>
@@ -512,37 +510,33 @@ if ((! empty($conf->service->enabled) || ($object->element == 'contrat')) && $da
 			print 'jQuery("#date_endmin").val("'.$conf->global->MAIN_DEFAULT_DATE_END_MIN.'");';
 		}
 	}
-	print '</script>'
-	?>
-	</td>
-	</tr>
-<?php
+	print '</script>';
+	print '</td>';
+	print "</tr>\n";
 }
-?>
 
-<script>
+print "<script>\n";
 
-<?php
 if (! empty($usemargins) && $user->rights->margins->creer)
 {
-?>
+	?>
 
 	/* Some js test when we click on button "Add" */
 	jQuery(document).ready(function() {
-		<?php
-		if (! empty($conf->global->DISPLAY_MARGIN_RATES)) { ?>
+	<?php
+	if (! empty($conf->global->DISPLAY_MARGIN_RATES)) { ?>
 			$("input[name='np_marginRate']:first").blur(function(e) {
 				return checkFreeLine(e, "np_marginRate");
 			});
 		<?php
-		}
-		if (! empty($conf->global->DISPLAY_MARK_RATES)) { ?>
+	}
+	if (! empty($conf->global->DISPLAY_MARK_RATES)) { ?>
 			$("input[name='np_markRate']:first").blur(function(e) {
 				return checkFreeLine(e, "np_markRate");
 			});
 		<?php
-		}
-		?>
+	}
+	?>
 	});
 
 	/* TODO This does not work for number with thousand separator that is , */
@@ -590,7 +584,7 @@ if (! empty($usemargins) && $user->rights->margins->creer)
 		return true;
 	}
 
-<?php
+	<?php
 }
 ?>
 
@@ -657,7 +651,7 @@ jQuery(document).ready(function() {
 	<?php
 	if(!$freelines) { ?>
 		$("#prod_entry_mode_predef").click();
-	<?php
+		<?php
 	}
 	?>
 
@@ -672,14 +666,14 @@ jQuery(document).ready(function() {
 		<?php
 		if (empty($conf->global->MAIN_DISABLE_EDIT_PREDEF_PRICEHT))
 		{
-		?>
+			?>
 			// get the HT price for the product and display it
 			$.post('<?php echo DOL_URL_ROOT; ?>/product/ajax/products.php?action=fetch', { 'id': $(this).val(), 'socid' : <?php print $object->socid; ?> }, function(data) {
 				jQuery("#price_ht").val(data.price_ht);
 			},
 			'json');
 
-		<?php
+			<?php
 		}
 
 		if (! empty($usemargins) && $user->rights->margins->creer)
@@ -782,7 +776,7 @@ jQuery(document).ready(function() {
     	  	},
     	  	'json');
 
-  		<?php
+  			<?php
         }
         ?>
 

+ 19 - 19
htdocs/core/tpl/objectline_edit.tpl.php

@@ -54,20 +54,18 @@ $colspan = 3;	// Col total ht + col edit + col delete
 if (! empty($inputalsopricewithtax)) $colspan++;	// We add 1 if col total ttc
 if (in_array($object->element, array('propal','supplier_proposal','facture','facturerec','invoice','commande','order','order_supplier','invoice_supplier'))) $colspan++;	// With this, there is a column move button
 if (!empty($conf->multicurrency->enabled) && $this->multicurrency_code != $conf->currency) $colspan+=2;
-?>
 
-<!-- BEGIN PHP TEMPLATE objectline_edit.tpl.php -->
+print "<!-- BEGIN PHP TEMPLATE objectline_edit.tpl.php -->\n";
 
-<?php
 $coldisplay=0;
 ?>
 <tr class="oddeven tredited">
-	<?php if (! empty($conf->global->MAIN_VIEW_LINE_NUMBER)) { ?>
+<?php if (! empty($conf->global->MAIN_VIEW_LINE_NUMBER)) { ?>
 		<td class="linecolnum center"><?php $coldisplay++; ?><?php echo ($i+1); ?></td>
-	<?php }
+<?php }
 
-	$coldisplay++;
-	?>
+$coldisplay++;
+?>
 	<td>
 	<div id="line_<?php echo $line->id; ?>"></div>
 
@@ -138,9 +136,9 @@ $coldisplay=0;
 	if ($object->element == 'supplier_proposal' || $object->element == 'order_supplier' || $object->element == 'invoice_supplier')	// We must have same test in printObjectLines
 	{
 	    $coldisplay++;
-	?>
+		?>
 		<td class="right"><input id="fourn_ref" name="fourn_ref" class="flat minwidth50 maxwidth150" value="<?php echo ($line->ref_supplier ? $line->ref_supplier : $line->ref_fourn); ?>"></td>
-	<?php
+		<?php
 	}
 
 	$coldisplay++;
@@ -168,8 +166,9 @@ $coldisplay=0;
 		print '></td>';
 	}
 	?>
-	<td class="right"><?php $coldisplay++; ?>
-	<?php if (($line->info_bits & 2) != 2) {
+	<td class="right">
+	<?php $coldisplay++;
+	if (($line->info_bits & 2) != 2) {
 		// I comment this because it shows info even when not required
 		// for example always visible on invoice but must be visible only if stock module on and stock decrease option is on invoice validation and status is not validated
 		// must also not be output for most entities (proposal, intervention, ...)
@@ -192,8 +191,9 @@ $coldisplay=0;
 	}
 	?>
 
-	<td class="nowrap right"><?php $coldisplay++; ?>
-	<?php if (($line->info_bits & 2) != 2) {
+	<td class="nowrap right">
+	<?php $coldisplay++;
+	if (($line->info_bits & 2) != 2) {
 		print '<input size="1" type="text" class="flat right" name="remise_percent" id="remise_percent" value="' . $line->remise_percent . '"';
 		if ($line->fk_prev_id != null ) print ' readonly';
 		print '>%';
@@ -201,7 +201,7 @@ $coldisplay=0;
 		&nbsp;
 	<?php } ?>
 	</td>
-<?php
+	<?php
 	if ($this->situation_cycle_ref) {
 		$coldisplay++;
 		print '<td class="nowrap right linecolcycleref"><input class="right" type="text" size="1" value="' . $line->situation_percent . '" name="progress">%</td>';
@@ -213,7 +213,7 @@ $coldisplay=0;
         if (!empty($user->rights->margins->creer))
         {
             $coldisplay++;
-        ?>
+        	?>
         <td class="margininfos right">
 			<!-- For predef product -->
 			<?php if (! empty($conf->product->enabled) || ! empty($conf->service->enabled)) { ?>
@@ -247,7 +247,7 @@ $coldisplay=0;
 			}
 		}
 	}
-?>
+	?>
 
 	<!-- colspan for this td because it replace total_ht+3 td for buttons+... -->
 	<td class="center valignmiddle" colspan="<?php echo $colspan; ?>"><?php $coldisplay+=$colspan; ?>
@@ -264,7 +264,7 @@ if (!empty($extrafields))
 }
 ?>
 
-<?php if (! empty($conf->service->enabled) && $line->product_type == 1 && $dateSelector)	 { ?>
+<?php if (! empty($conf->service->enabled) && $line->product_type == 1 && $dateSelector) { ?>
 <tr id="service_duration_area" class="treditedlinefordate">
 	<?php if (! empty($conf->global->MAIN_VIEW_LINE_NUMBER)) { ?>
 		<td class="linecolnum center"></td>
@@ -329,7 +329,7 @@ jQuery(document).ready(function()
     <?php
     if (! empty($conf->margin->enabled))
     {
-    ?>
+        ?>
 		/* Add rule to clear margin when we change some data, so when we change sell or buy price, margin will be recalculated after submitting form */
 		jQuery("#tva_tx").click(function() {						/* somtimes field is a text, sometimes a combo */
 			jQuery("input[name='np_marginRate']:first").val('');
@@ -392,7 +392,7 @@ jQuery(document).ready(function()
 			$('#buying_price').show();
 		}
 		}, 'json');
-    <?php
+        <?php
     }
     ?>
 });

+ 13 - 11
htdocs/core/tpl/objectline_title.tpl.php

@@ -39,9 +39,9 @@ if (empty($object) || ! is_object($object))
 	print "Error, template page can't be called as URL";
 	exit;
 }
-?>
-<!-- BEGIN PHP TEMPLATE objectline_title.tpl.php -->
-<?php
+
+print "<!-- BEGIN PHP TEMPLATE objectline_title.tpl.php -->\n";
+
 // Title line
 print "<thead>\n";
 
@@ -90,16 +90,19 @@ if ($usemargins && ! empty($conf->margin->enabled) && empty($user->societe_id))
 {
 	if (!empty($user->rights->margins->creer))
 	{
-		if ($conf->global->MARGIN_TYPE == "1")
+		if ($conf->global->MARGIN_TYPE == "1") {
 			print '<td class="linecolmargin1 margininfos right" style="width: 80px">'.$langs->trans('BuyingPrice').'</td>';
-			else
-				print '<td class="linecolmargin1 margininfos right" style="width: 80px">'.$langs->trans('CostPrice').'</td>';
+		} else {
+			print '<td class="linecolmargin1 margininfos right" style="width: 80px">'.$langs->trans('CostPrice').'</td>';
+		}
 	}
 
-	if (! empty($conf->global->DISPLAY_MARGIN_RATES) && $user->rights->margins->liretous)
+	if (! empty($conf->global->DISPLAY_MARGIN_RATES) && $user->rights->margins->liretous) {
 		print '<td class="linecolmargin2 margininfos right" style="width: 50px">'.$langs->trans('MarginRate').'</td>';
-		if (! empty($conf->global->DISPLAY_MARK_RATES) && $user->rights->margins->liretous)
-			print '<td class="linecolmargin2 margininfos right" style="width: 50px">'.$langs->trans('MarkRate').'</td>';
+	}
+	if (! empty($conf->global->DISPLAY_MARK_RATES) && $user->rights->margins->liretous) {
+		print '<td class="linecolmargin2 margininfos right" style="width: 50px">'.$langs->trans('MarkRate').'</td>';
+	}
 }
 
 // Total HT
@@ -126,6 +129,5 @@ if($action == 'selectlines')
 
 print "</tr>\n";
 print "</thead>\n";
-?>
 
-<!-- END PHP TEMPLATE objectline_title.tpl.php -->
+print "<!-- END PHP TEMPLATE objectline_title.tpl.php -->\n";

+ 234 - 253
htdocs/core/tpl/objectline_view.tpl.php

@@ -64,313 +64,294 @@ $domData .= ' data-qty="'.$line->qty.'"';
 $domData .= ' data-product_type="'.$line->product_type.'"';
 
 
-?>
-<?php $coldisplay=0; ?>
+$coldisplay=0; ?>
 <!-- BEGIN PHP TEMPLATE objectline_view.tpl.php -->
 <tr  id="row-<?php echo $line->id?>" class="drag drop oddeven" <?php echo $domData; ?> >
-	<?php if (! empty($conf->global->MAIN_VIEW_LINE_NUMBER)) { ?>
+<?php if (! empty($conf->global->MAIN_VIEW_LINE_NUMBER)) { ?>
 	<td class="linecolnum center"><?php $coldisplay++; ?><?php echo ($i+1); ?></td>
-	<?php } ?>
+<?php } ?>
 	<td class="linecoldescription minwidth300imp"><?php $coldisplay++; ?><div id="line_<?php echo $line->id; ?>"></div>
-	<?php
-	if (($line->info_bits & 2) == 2) {
-	?>
-		<a href="<?php echo DOL_URL_ROOT.'/comm/remx.php?id='.$this->socid; ?>">
-		<?php
-		$txt='';
-		print img_object($langs->trans("ShowReduc"), 'reduc').' ';
-		if ($line->description == '(DEPOSIT)') $txt=$langs->trans("Deposit");
-		elseif ($line->description == '(EXCESS RECEIVED)') $txt=$langs->trans("ExcessReceived");
-		elseif ($line->description == '(EXCESS PAID)') $txt=$langs->trans("ExcessPaid");
-		//else $txt=$langs->trans("Discount");
-		print $txt;
-		?>
-		</a>
-		<?php
-		if ($line->description)
-		{
-			if ($line->description == '(CREDIT_NOTE)' && $line->fk_remise_except > 0)
-			{
-				$discount=new DiscountAbsolute($this->db);
-				$discount->fetch($line->fk_remise_except);
-				echo ($txt?' - ':'').$langs->transnoentities("DiscountFromCreditNote", $discount->getNomUrl(0));
-			}
-			elseif ($line->description == '(DEPOSIT)' && $line->fk_remise_except > 0)
-			{
-				$discount=new DiscountAbsolute($this->db);
-				$discount->fetch($line->fk_remise_except);
-				echo ($txt?' - ':'').$langs->transnoentities("DiscountFromDeposit", $discount->getNomUrl(0));
-				// Add date of deposit
-				if (! empty($conf->global->INVOICE_ADD_DEPOSIT_DATE))
-				    echo ' ('.dol_print_date($discount->datec).')';
-			}
-			elseif ($line->description == '(EXCESS RECEIVED)' && $objp->fk_remise_except > 0)
-			{
-				$discount=new DiscountAbsolute($this->db);
-				$discount->fetch($line->fk_remise_except);
-				echo ($txt?' - ':'').$langs->transnoentities("DiscountFromExcessReceived", $discount->getNomUrl(0));
-			}
-			elseif ($line->description == '(EXCESS PAID)' && $objp->fk_remise_except > 0)
-			{
-				$discount=new DiscountAbsolute($this->db);
-				$discount->fetch($line->fk_remise_except);
-				echo ($txt?' - ':'').$langs->transnoentities("DiscountFromExcessPaid", $discount->getNomUrl(0));
-			}
-			else
-			{
-				echo ($txt?' - ':'').dol_htmlentitiesbr($line->description);
-			}
-		}
-	}
-	else
+<?php
+if (($line->info_bits & 2) == 2) {
+    print '<a href="'.DOL_URL_ROOT.'/comm/remx.php?id='.$this->socid.'">';
+	$txt='';
+	print img_object($langs->trans("ShowReduc"), 'reduc').' ';
+	if ($line->description == '(DEPOSIT)') $txt=$langs->trans("Deposit");
+	elseif ($line->description == '(EXCESS RECEIVED)') $txt=$langs->trans("ExcessReceived");
+	elseif ($line->description == '(EXCESS PAID)') $txt=$langs->trans("ExcessPaid");
+	//else $txt=$langs->trans("Discount");
+	print $txt;
+	print '</a>';
+	if ($line->description)
 	{
-		$format = $conf->global->MAIN_USE_HOURMIN_IN_DATE_RANGE?'dayhour':'day';
-
-	    if ($line->fk_product > 0)
+		if ($line->description == '(CREDIT_NOTE)' && $line->fk_remise_except > 0)
 		{
-			echo $form->textwithtooltip($text, $description, 3, '', '', $i, 0, (!empty($line->fk_parent_line)?img_picto('', 'rightarrow'):''));
+			$discount=new DiscountAbsolute($this->db);
+			$discount->fetch($line->fk_remise_except);
+			echo ($txt?' - ':'').$langs->transnoentities("DiscountFromCreditNote", $discount->getNomUrl(0));
 		}
-		else
+		elseif ($line->description == '(DEPOSIT)' && $line->fk_remise_except > 0)
 		{
-			if ($type==1) $text = img_object($langs->trans('Service'), 'service');
-			else $text = img_object($langs->trans('Product'), 'product');
-
-			if (! empty($line->label)) {
-				$text.= ' <strong>'.$line->label.'</strong>';
-				echo $form->textwithtooltip($text, dol_htmlentitiesbr($line->description), 3, '', '', $i, 0, (!empty($line->fk_parent_line)?img_picto('', 'rightarrow'):''));
-			} else {
-				if (! empty($line->fk_parent_line)) echo img_picto('', 'rightarrow');
-				echo $text.' '.dol_htmlentitiesbr($line->description);
-			}
+			$discount=new DiscountAbsolute($this->db);
+			$discount->fetch($line->fk_remise_except);
+			echo ($txt?' - ':'').$langs->transnoentities("DiscountFromDeposit", $discount->getNomUrl(0));
+			// Add date of deposit
+			if (! empty($conf->global->INVOICE_ADD_DEPOSIT_DATE))
+			    echo ' ('.dol_print_date($discount->datec).')';
 		}
-
-		// Show date range
-		if ($line->element == 'facturedetrec') {
-			if ($line->date_start_fill || $line->date_end_fill) echo '<br><div class="clearboth nowraponall">';
-			if ($line->date_start_fill) echo $langs->trans('AutoFillDateFromShort').': '.yn($line->date_start_fill);
-			if ($line->date_start_fill && $line->date_end_fill) echo ' - ';
-			if ($line->date_end_fill) echo $langs->trans('AutoFillDateToShort').': '.yn($line->date_end_fill);
-			if ($line->date_start_fill || $line->date_end_fill) echo '</div>';
+		elseif ($line->description == '(EXCESS RECEIVED)' && $objp->fk_remise_except > 0)
+		{
+			$discount=new DiscountAbsolute($this->db);
+			$discount->fetch($line->fk_remise_except);
+			echo ($txt?' - ':'').$langs->transnoentities("DiscountFromExcessReceived", $discount->getNomUrl(0));
 		}
-		else {
-			if ($line->date_start || $line->date_end) echo '<br><div class="clearboth nowraponall">'.get_date_range($line->date_start, $line->date_end, $format).'</div>';
-			//echo get_date_range($line->date_start, $line->date_end, $format);
+		elseif ($line->description == '(EXCESS PAID)' && $objp->fk_remise_except > 0)
+		{
+			$discount=new DiscountAbsolute($this->db);
+			$discount->fetch($line->fk_remise_except);
+			echo ($txt?' - ':'').$langs->transnoentities("DiscountFromExcessPaid", $discount->getNomUrl(0));
 		}
-
-		// Add description in form
-		if ($line->fk_product > 0 && ! empty($conf->global->PRODUIT_DESC_IN_FORM))
+		else
 		{
-			print (! empty($line->description) && $line->description!=$line->product_label)?'<br>'.dol_htmlentitiesbr($line->description):'';
+			echo ($txt?' - ':'').dol_htmlentitiesbr($line->description);
 		}
 	}
+}
+else
+{
+	$format = $conf->global->MAIN_USE_HOURMIN_IN_DATE_RANGE?'dayhour':'day';
 
-	if ($user->rights->fournisseur->lire && $line->fk_fournprice > 0)
+    if ($line->fk_product > 0)
 	{
-    require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.product.class.php';
-		$productfourn = new ProductFournisseur($this->db);
-		$productfourn->fetch_product_fournisseur_price($line->fk_fournprice);
-		echo '<div class="clearboth"></div><span class="opacitymedium">' . $langs->trans('Supplier') . ' : </span>' . $productfourn->getSocNomUrl(1, 'supplier') . ' - <span class="opacitymedium">' . $langs->trans('Ref') . ' : </span>';
-						// Supplier ref
-						if ($user->rights->produit->creer || $user->rights->service->creer) // change required right here
-						{
-							echo $productfourn->getNomUrl();
-						}
-						else
-						{
-							echo $productfourn->ref_supplier;
-						}
+		echo $form->textwithtooltip($text, $description, 3, '', '', $i, 0, (!empty($line->fk_parent_line)?img_picto('', 'rightarrow'):''));
+	}
+	else
+	{
+		if ($type==1) $text = img_object($langs->trans('Service'), 'service');
+		else $text = img_object($langs->trans('Product'), 'product');
+
+		if (! empty($line->label)) {
+			$text.= ' <strong>'.$line->label.'</strong>';
+			echo $form->textwithtooltip($text, dol_htmlentitiesbr($line->description), 3, '', '', $i, 0, (!empty($line->fk_parent_line)?img_picto('', 'rightarrow'):''));
+		} else {
+			if (! empty($line->fk_parent_line)) echo img_picto('', 'rightarrow');
+			echo $text.' '.dol_htmlentitiesbr($line->description);
+		}
+	}
+
+	// Show date range
+	if ($line->element == 'facturedetrec') {
+		if ($line->date_start_fill || $line->date_end_fill) echo '<br><div class="clearboth nowraponall">';
+		if ($line->date_start_fill) echo $langs->trans('AutoFillDateFromShort').': '.yn($line->date_start_fill);
+		if ($line->date_start_fill && $line->date_end_fill) echo ' - ';
+		if ($line->date_end_fill) echo $langs->trans('AutoFillDateToShort').': '.yn($line->date_end_fill);
+		if ($line->date_start_fill || $line->date_end_fill) echo '</div>';
+	}
+	else {
+		if ($line->date_start || $line->date_end) echo '<br><div class="clearboth nowraponall">'.get_date_range($line->date_start, $line->date_end, $format).'</div>';
+		//echo get_date_range($line->date_start, $line->date_end, $format);
 	}
 
-	if (! empty($conf->accounting->enabled) && $line->fk_accounting_account > 0)
+	// Add description in form
+	if ($line->fk_product > 0 && ! empty($conf->global->PRODUIT_DESC_IN_FORM))
 	{
-		$accountingaccount=new AccountingAccount($this->db);
-		$accountingaccount->fetch($line->fk_accounting_account);
-		echo '<div class="clearboth"></div><br><span class="opacitymedium">' . $langs->trans('AccountingAffectation') . ' : </span>' . $accountingaccount->getNomUrl(0, 1, 1);
+		print (! empty($line->description) && $line->description!=$line->product_label)?'<br>'.dol_htmlentitiesbr($line->description):'';
 	}
+}
 
-	?>
-	</td>
-	<?php
-	if ($object->element == 'supplier_proposal' || $object->element == 'order_supplier' || $object->element == 'invoice_supplier')	// We must have same test in printObjectLines
+if ($user->rights->fournisseur->lire && $line->fk_fournprice > 0)
+{
+    require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.product.class.php';
+	$productfourn = new ProductFournisseur($this->db);
+	$productfourn->fetch_product_fournisseur_price($line->fk_fournprice);
+	echo '<div class="clearboth"></div><span class="opacitymedium">' . $langs->trans('Supplier') . ' : </span>' . $productfourn->getSocNomUrl(1, 'supplier') . ' - <span class="opacitymedium">' . $langs->trans('Ref') . ' : </span>';
+	// Supplier ref
+	if ($user->rights->produit->creer || $user->rights->service->creer) // change required right here
 	{
-	?>
-		<td class="linecolrefsupplier"><?php
-		echo ($line->ref_fourn?$line->ref_fourn:$line->ref_supplier);
-		?></td>
-	<?php
+		echo $productfourn->getNomUrl();
 	}
-	// VAT Rate
-	?>
-	<td class="linecolvat nowrap right"><?php $coldisplay++; ?><?php
-	$positiverates='';
-	if (price2num($line->tva_tx))          $positiverates.=($positiverates?'/':'').price2num($line->tva_tx);
-	if (price2num($line->total_localtax1)) $positiverates.=($positiverates?'/':'').price2num($line->localtax1_tx);
-	if (price2num($line->total_localtax2)) $positiverates.=($positiverates?'/':'').price2num($line->localtax2_tx);
-	if (empty($positiverates)) $positiverates='0';
-	echo vatrate($positiverates.($line->vat_src_code?' ('.$line->vat_src_code.')':''), '%', $line->info_bits);
-	//echo vatrate($line->tva_tx.($line->vat_src_code?(' ('.$line->vat_src_code.')'):''), '%', $line->info_bits);
-	?></td>
+	else
+	{
+		echo $productfourn->ref_supplier;
+	}
+}
+
+if (! empty($conf->accounting->enabled) && $line->fk_accounting_account > 0)
+{
+	$accountingaccount=new AccountingAccount($this->db);
+	$accountingaccount->fetch($line->fk_accounting_account);
+	echo '<div class="clearboth"></div><br><span class="opacitymedium">' . $langs->trans('AccountingAffectation') . ' : </span>' . $accountingaccount->getNomUrl(0, 1, 1);
+}
+
+print '</td>';
+if ($object->element == 'supplier_proposal' || $object->element == 'order_supplier' || $object->element == 'invoice_supplier')	// We must have same test in printObjectLines
+{
+	print '<td class="linecolrefsupplier">';
+	echo ($line->ref_fourn?$line->ref_fourn:$line->ref_supplier);
+	print '</td>';
+}
+// VAT Rate
+print '<td class="linecolvat nowrap right">';
+$coldisplay++;
+$positiverates='';
+if (price2num($line->tva_tx))          $positiverates.=($positiverates?'/':'').price2num($line->tva_tx);
+if (price2num($line->total_localtax1)) $positiverates.=($positiverates?'/':'').price2num($line->localtax1_tx);
+if (price2num($line->total_localtax2)) $positiverates.=($positiverates?'/':'').price2num($line->localtax2_tx);
+if (empty($positiverates)) $positiverates='0';
+echo vatrate($positiverates.($line->vat_src_code?' ('.$line->vat_src_code.')':''), '%', $line->info_bits);
+//echo vatrate($line->tva_tx.($line->vat_src_code?(' ('.$line->vat_src_code.')'):''), '%', $line->info_bits);
+?></td>
 
 	<td class="linecoluht nowrap right"><?php $coldisplay++; ?><?php echo price($line->subprice); ?></td>
 
-	<?php if (!empty($conf->multicurrency->enabled) && $this->multicurrency_code != $conf->currency) { ?>
+<?php if (!empty($conf->multicurrency->enabled) && $this->multicurrency_code != $conf->currency) { ?>
 	<td class="linecoluht_currency nowrap right"><?php $coldisplay++; ?><?php echo price($line->multicurrency_subprice); ?></td>
-	<?php } ?>
+<?php }
 
-	<?php if ($inputalsopricewithtax) { ?>
+if ($inputalsopricewithtax) { ?>
 	<td class="linecoluttc nowrap right"><?php $coldisplay++; ?><?php echo (isset($line->pu_ttc)?price($line->pu_ttc):price($line->subprice)); ?></td>
-	<?php } ?>
+<?php } ?>
 
 	<td class="linecolqty nowrap right"><?php $coldisplay++; ?>
-    <?php
-    if ((($line->info_bits & 2) != 2) && $line->special_code != 3) {
-		// I comment this because it shows info even when not required
-		// for example always visible on invoice but must be visible only if stock module on and stock decrease option is on invoice validation and status is not validated
-		// must also not be output for most entities (proposal, intervention, ...)
-		//if($line->qty > $line->stock) print img_picto($langs->trans("StockTooLow"),"warning", 'style="vertical-align: bottom;"')." ";
-		echo price($line->qty, 0, '', 0, 0);  // Yes, it is a quantity, not a price, but we just want the formating role of function price
-    } else echo '&nbsp;';
-    ?>
-	</td>
-
-	<?php
-	if($conf->global->PRODUCT_USE_UNITS)
-	{
-		print '<td class="linecoluseunit nowrap left">';
-		$label = $line->getLabelOfUnit('short');
-		if ($label !== '') {
-			print $langs->trans($label);
-		}
-		print '</td>';
+<?php
+if ((($line->info_bits & 2) != 2) && $line->special_code != 3) {
+	// I comment this because it shows info even when not required
+	// for example always visible on invoice but must be visible only if stock module on and stock decrease option is on invoice validation and status is not validated
+	// must also not be output for most entities (proposal, intervention, ...)
+	//if($line->qty > $line->stock) print img_picto($langs->trans("StockTooLow"),"warning", 'style="vertical-align: bottom;"')." ";
+	echo price($line->qty, 0, '', 0, 0);  // Yes, it is a quantity, not a price, but we just want the formating role of function price
+} else echo '&nbsp;';
+print '</td>';
+
+if ($conf->global->PRODUCT_USE_UNITS)
+{
+	print '<td class="linecoluseunit nowrap left">';
+	$label = $line->getLabelOfUnit('short');
+	if ($label !== '') {
+		print $langs->trans($label);
 	}
-	?>
+	print '</td>';
+}
+if (!empty($line->remise_percent) && $line->special_code != 3) {
+	print '<td class="linecoldiscount right">';
+	$coldisplay++;
+	include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
+	echo dol_print_reduction($line->remise_percent, $langs);
+	print '</td>';
+} else {
+	print '<td class="linecoldiscount">&nbsp;</td>';
+	$coldisplay++;
+}
 
-	<?php if (!empty($line->remise_percent) && $line->special_code != 3) { ?>
-	<td class="linecoldiscount right"><?php
-		$coldisplay++;
-		include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
-		echo dol_print_reduction($line->remise_percent, $langs);
-	?></td>
-	<?php } else { ?>
-	<td class="linecoldiscount"><?php $coldisplay++; ?>&nbsp;</td>
-	<?php }
+$rounding = min($conf->global->MAIN_MAX_DECIMALS_UNIT, $conf->global->MAIN_MAX_DECIMALS_TOT);
 
-	$rounding = min($conf->global->MAIN_MAX_DECIMALS_UNIT, $conf->global->MAIN_MAX_DECIMALS_TOT);
+// Fields for situation invoices
+if ($this->situation_cycle_ref)
+{
+    include_once DOL_DOCUMENT_ROOT.'/core/lib/price.lib.php';
+	$coldisplay++;
+	print '<td class="linecolcycleref nowrap right">' . $line->situation_percent . '%</td>';
+	$coldisplay++;
+	$locataxes_array = getLocalTaxesFromRate($line->tva.($line->vat_src_code ? ' ('.$line->vat_src_code.')' : ''), 0, ($senderissupplier?$mysoc:$object->thirdparty), ($senderissupplier?$object->thirdparty:$mysoc));
+	$tmp = calcul_price_total($line->qty, $line->pu, $line->remise_percent, $line->txtva, -1, -1, 0, 'HT', $line->info_bits, $line->type, ($senderissupplier?$object->thirdparty:$mysoc), $locataxes_array, 100, $object->multicurrency_tx, $line->multicurrency_subprice);
+	print '<td align="right" class="linecolcycleref2 nowrap">' . price($tmp[0]) . '</td>';
+}
 
-	// Fields for situation invoices
-	if ($this->situation_cycle_ref)
+if ($usemargins && ! empty($conf->margin->enabled) && empty($user->societe_id))
+{
+	if (!empty($user->rights->margins->creer)) { ?>
+		<td class="linecolmargin1 nowrap margininfos right"><?php $coldisplay++; ?><?php echo price($line->pa_ht); ?></td>
+	<?php }
+	if (! empty($conf->global->DISPLAY_MARGIN_RATES) && $user->rights->margins->liretous) { ?>
+		<td class="linecolmargin2 nowrap margininfos right"><?php $coldisplay++; ?><?php echo (($line->pa_ht == 0)?'n/a':price($line->marge_tx, null, null, null, null, $rounding).'%'); ?></td>
+	<?php }
+    if (! empty($conf->global->DISPLAY_MARK_RATES) && $user->rights->margins->liretous) {?>
+  	  <td class="linecolmargin2 nowrap margininfos right"><?php $coldisplay++; ?><?php echo price($line->marque_tx, null, null, null, null, $rounding).'%'; ?></td>
+    <?php }
+}
+if ($line->special_code == 3)	{ ?>
+	<td class="linecoloption nowrap right"><?php $coldisplay++; ?><?php echo $langs->trans('Option'); ?></td>
+<?php } else {
+	print '<td class="linecolht nowrap right">';
+	$coldisplay++;
+	if (empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER))
 	{
-	    include_once DOL_DOCUMENT_ROOT.'/core/lib/price.lib.php';
-		$coldisplay++;
-		print '<td class="linecolcycleref nowrap right">' . $line->situation_percent . '%</td>';
+    	print '<span class="classfortooltip" title="';
+    	print $langs->transcountry("TotalHT", $mysoc->country_code).'='.price($line->total_ht);
+    	print '<br>'.$langs->transcountry("TotalVAT", ($senderissupplier?$object->thirdparty->country_code:$mysoc->country_code)).'='.price($line->total_tva);
+    	if (price2num($line->total_localtax1)) print '<br>'.$langs->transcountry("TotalLT1", ($senderissupplier?$object->thirdparty->country_code:$mysoc->country_code)).'='.price($line->total_localtax1);
+    	if (price2num($line->total_localtax2)) print '<br>'.$langs->transcountry("TotalLT2", ($senderissupplier?$object->thirdparty->country_code:$mysoc->country_code)).'='.price($line->total_localtax2);
+    	print '<br>'.$langs->transcountry("TotalTTC", $mysoc->country_code).'='.price($line->total_ttc);
+    	print '">';
+	}
+	print price($line->total_ht);
+	if (empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER))
+	{
+	    print '</span>';
+	}
+	print '</td>';
+	if (!empty($conf->multicurrency->enabled) && $this->multicurrency_code != $conf->currency) {
+		print '<td class="linecolutotalht_currency nowrap right">'.price($line->multicurrency_total_ht).'</td>';
 		$coldisplay++;
-		$locataxes_array = getLocalTaxesFromRate($line->tva.($line->vat_src_code ? ' ('.$line->vat_src_code.')' : ''), 0, ($senderissupplier?$mysoc:$object->thirdparty), ($senderissupplier?$object->thirdparty:$mysoc));
-		$tmp = calcul_price_total($line->qty, $line->pu, $line->remise_percent, $line->txtva, -1, -1, 0, 'HT', $line->info_bits, $line->type, ($senderissupplier?$object->thirdparty:$mysoc), $locataxes_array, 100, $object->multicurrency_tx, $line->multicurrency_subprice);
-		print '<td align="right" class="linecolcycleref2 nowrap">' . price($tmp[0]) . '</td>';
 	}
+}
+if ($outputalsopricetotalwithtax) {
+    print '<td class="linecolht nowrap right">'.price($line->total_ttc).'</td>';
+	$coldisplay++;
+}
 
-  	if ($usemargins && ! empty($conf->margin->enabled) && empty($user->societe_id))
-  	{
-  		if (!empty($user->rights->margins->creer)) { ?>
-	  	  <td class="linecolmargin1 nowrap margininfos right"><?php $coldisplay++; ?><?php echo price($line->pa_ht); ?></td>
-	  	<?php } ?>
-	  	<?php if (! empty($conf->global->DISPLAY_MARGIN_RATES) && $user->rights->margins->liretous) { ?>
-	  	  <td class="linecolmargin2 nowrap margininfos right"><?php $coldisplay++; ?><?php echo (($line->pa_ht == 0)?'n/a':price($line->marge_tx, null, null, null, null, $rounding).'%'); ?></td>
-	  	<?php }
-	    if (! empty($conf->global->DISPLAY_MARK_RATES) && $user->rights->margins->liretous) {?>
-	  	  <td class="linecolmargin2 nowrap margininfos right"><?php $coldisplay++; ?><?php echo price($line->marque_tx, null, null, null, null, $rounding).'%'; ?></td>
-	    <?php }
+if ($this->statut == 0  && ($object_rights->creer) && $action != 'selectlines' ) {
+	print '<td class="linecoledit center">';
+	$coldisplay++;
+	if (($line->info_bits & 2) == 2 || ! empty($disableedit)) {
+	} else { ?>
+		<a href="<?php echo $_SERVER["PHP_SELF"].'?id='.$this->id.'&amp;action=editline&amp;lineid='.$line->id.'#line_'.$line->id; ?>">
+		<?php echo img_edit().'</a>';
 	}
-	?>
-
-	<?php if ($line->special_code == 3)	{ ?>
-		<td class="linecoloption nowrap right"><?php $coldisplay++; ?><?php echo $langs->trans('Option'); ?></td>
-	<?php } else { ?>
-		<td class="linecolht nowrap right"><?php
-		  $coldisplay++;
-		  if (empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER))
-		  {
-    		  print '<span class="classfortooltip" title="';
-    		  print $langs->transcountry("TotalHT", $mysoc->country_code).'='.price($line->total_ht);
-    		  print '<br>'.$langs->transcountry("TotalVAT", ($senderissupplier?$object->thirdparty->country_code:$mysoc->country_code)).'='.price($line->total_tva);
-    		  if (price2num($line->total_localtax1)) print '<br>'.$langs->transcountry("TotalLT1", ($senderissupplier?$object->thirdparty->country_code:$mysoc->country_code)).'='.price($line->total_localtax1);
-    		  if (price2num($line->total_localtax2)) print '<br>'.$langs->transcountry("TotalLT2", ($senderissupplier?$object->thirdparty->country_code:$mysoc->country_code)).'='.price($line->total_localtax2);
-    		  print '<br>'.$langs->transcountry("TotalTTC", $mysoc->country_code).'='.price($line->total_ttc);
-    		  print '">';
-		  }
-		  print price($line->total_ht);
-		  if (empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER))
-		  {
-		      print '</span>';
-		  }
-		  ?>
-		</td>
-		<?php if (!empty($conf->multicurrency->enabled) && $this->multicurrency_code != $conf->currency) { ?>
-			<td class="linecolutotalht_currency nowrap right"><?php $coldisplay++; ?><?php echo price($line->multicurrency_total_ht); ?></td>
-		<?php } ?>
-	<?php } ?>
-    <?php if ($outputalsopricetotalwithtax) { ?>
-        <td class="linecolht nowrap right"><?php $coldisplay++; ?><?php echo price($line->total_ttc); ?></td>
-    <?php } ?>
-
-
-	<?php
-	if ($this->statut == 0  && ($object_rights->creer) && $action != 'selectlines' ) { ?>
-		<td class="linecoledit center"><?php $coldisplay++; ?>
-			<?php if (($line->info_bits & 2) == 2 || ! empty($disableedit)) { ?>
-			<?php } else { ?>
-			<a href="<?php echo $_SERVER["PHP_SELF"].'?id='.$this->id.'&amp;action=editline&amp;lineid='.$line->id.'#line_'.$line->id; ?>">
-			<?php echo img_edit(); ?>
-			</a>
-			<?php } ?>
-		</td>
-
-		<td class="linecoldelete center"><?php $coldisplay++; ?>
-			<?php
-			if (($line->fk_prev_id == null ) && empty($disableremove)) { //La suppression n'est autorisée que si il n'y a pas de ligne dans une précédente situation
-				print '<a href="' . $_SERVER["PHP_SELF"] . '?id=' . $this->id . '&amp;action=ask_deleteline&amp;lineid=' . $line->id . '">';
-				print img_delete();
-				print '</a>';
-			}
-			?>
-		</td>
+	print '</td>';
+
+	print '<td class="linecoldelete center">';
+	$coldisplay++;
+	if (($line->fk_prev_id == null ) && empty($disableremove)) { //La suppression n'est autorisée que si il n'y a pas de ligne dans une précédente situation
+		print '<a href="' . $_SERVER["PHP_SELF"] . '?id=' . $this->id . '&amp;action=ask_deleteline&amp;lineid=' . $line->id . '">';
+		print img_delete();
+		print '</a>';
+	}
+	print '</td>';
 
-		<?php
-		if ($num > 1 && $conf->browser->layout != 'phone' && ($this->situation_counter == 1 || !$this->situation_cycle_ref) && empty($disablemove)) { ?>
-		<td class="linecolmove tdlineupdown center"><?php $coldisplay++; ?>
-			<?php if ($i > 0) { ?>
+	if ($num > 1 && $conf->browser->layout != 'phone' && ($this->situation_counter == 1 || !$this->situation_cycle_ref) && empty($disablemove)) {
+		print '<td class="linecolmove tdlineupdown center">';
+		$coldisplay++;
+		if ($i > 0) { ?>
 			<a class="lineupdown" href="<?php echo $_SERVER["PHP_SELF"].'?id='.$this->id.'&amp;action=up&amp;rowid='.$line->id; ?>">
 			<?php echo img_up('default', 0, 'imgupforline'); ?>
 			</a>
-			<?php } ?>
-			<?php if ($i < $num-1) { ?>
+		<?php }
+		if ($i < $num-1) { ?>
 			<a class="lineupdown" href="<?php echo $_SERVER["PHP_SELF"].'?id='.$this->id.'&amp;action=down&amp;rowid='.$line->id; ?>">
 			<?php echo img_down('default', 0, 'imgdownforline'); ?>
 			</a>
-			<?php } ?>
-		</td>
-	    <?php } else { ?>
-	    <td <?php echo (($conf->browser->layout != 'phone' && empty($disablemove)) ?' class="linecolmove tdlineupdown center"':' class="linecolmove center"'); ?>><?php $coldisplay++; ?></td>
-		<?php } ?>
-	<?php
+		<?php }
+		print '</td>';
     } else {
-	?>
-		<td colspan="3"><?php $coldisplay=$coldisplay+3; ?></td>
-	<?php
-    }
+		print '<td '.(($conf->browser->layout != 'phone' && empty($disablemove)) ?' class="linecolmove tdlineupdown center"':' class="linecolmove center"').'></td>';
+		$coldisplay++;
+	}
+} else {
+	print '<td colspan="3"></td>';
+	$coldisplay = $coldisplay+3;
+}
 
-    if ($action == 'selectlines') { ?>
-		<td class="linecolcheck center"><input type="checkbox" class="linecheckbox" name="line_checkbox[<?php echo $i+1; ?>]" value="<?php echo $line->id; ?>" ></td>
-	<?php } ?>
+if ($action == 'selectlines') { ?>
+	<td class="linecolcheck center"><input type="checkbox" class="linecheckbox" name="line_checkbox[<?php echo $i+1; ?>]" value="<?php echo $line->id; ?>" ></td>
+<?php }
 
-</tr>
+print "</tr>\n";
 
-<?php
 //Line extrafield
 if (!empty($extrafields))
 {
 	print $line->showOptionals($extrafields, 'view', array('style'=>'class="drag drop oddeven"','colspan'=>$coldisplay), '', '', empty($conf->global->MAIN_EXTRAFIELDS_IN_ONE_TD)?0:1);
 }
-?>
 
-<!-- END PHP TEMPLATE objectline_view.tpl.php -->
+print "<!-- END PHP TEMPLATE objectline_view.tpl.php -->\n";

+ 4 - 4
htdocs/core/tpl/passwordforgotten.tpl.php

@@ -128,10 +128,10 @@ if (! empty($morelogincontent)) {
 ?>
 
 <?php if ($captcha) {
-		// Add a variable param to force not using cache (jmobile)
-		$php_self = preg_replace('/[&\?]time=(\d+)/', '', $php_self);	// Remove param time
-		if (preg_match('/\?/', $php_self)) $php_self.='&time='.dol_print_date(dol_now(), 'dayhourlog');
-		else $php_self.='?time='.dol_print_date(dol_now(), 'dayhourlog');
+	// Add a variable param to force not using cache (jmobile)
+	$php_self = preg_replace('/[&\?]time=(\d+)/', '', $php_self);	// Remove param time
+	if (preg_match('/\?/', $php_self)) $php_self.='&time='.dol_print_date(dol_now(), 'dayhourlog');
+	else $php_self.='?time='.dol_print_date(dol_now(), 'dayhourlog');
 	?>
 	<!-- Captcha -->
 	<div class="trinputlogin">

+ 2 - 2
htdocs/expensereport/ajax/ajaxprojet.php

@@ -69,8 +69,8 @@ if (GETPOST('fk_projet') != '')
 		{
 		    $label=$row['ref'].' - '.$row['title'];
 		    $row_array['label'] = $label;
-			 $row_array['value'] = $label;
-	       $row_array['key'] = $row['rowid'];
+			$row_array['value'] = $label;
+	        $row_array['key'] = $row['rowid'];
 
 	        array_push($return_arr, $row_array);
 	    }

+ 20 - 20
htdocs/expensereport/class/expensereport.class.php

@@ -972,10 +972,10 @@ class ExpenseReport extends CommonObject
             $num = $this->db->num_rows($result);
             $i = 0;
             while ($i < $num):
-            $objp = $this->db->fetch_object($result);
-            $total_ht+=$objp->total_ht;
-            $total_tva+=$objp->total_tva;
-            $i++;
+                $objp = $this->db->fetch_object($result);
+                $total_ht+=$objp->total_ht;
+                $total_tva+=$objp->total_tva;
+                $i++;
             endwhile;
 
             $total_ttc = $total_ht + $total_tva;
@@ -985,13 +985,13 @@ class ExpenseReport extends CommonObject
             $sql.= " , total_tva = ".$total_tva;
             $sql.= " WHERE rowid = ".$id;
             $result = $this->db->query($sql);
-            if($result):
-            $this->db->free($result);
-            return 1;
+            if ($result):
+                $this->db->free($result);
+                return 1;
             else:
-            $this->error=$this->db->lasterror();
-            dol_syslog(get_class($this)."::recalculer: Error ".$this->error, LOG_ERR);
-            return -3;
+                $this->error=$this->db->lasterror();
+                dol_syslog(get_class($this)."::recalculer: Error ".$this->error, LOG_ERR);
+                return -3;
             endif;
         }
         else
@@ -1695,10 +1695,10 @@ class ExpenseReport extends CommonObject
 
         $result = $this->db->query($sql);
         if ($result):
-        return 1;
+            return 1;
         else:
-        $this->error=$this->db->error();
-        return -1;
+            $this->error=$this->db->error();
+            return -1;
         endif;
     }
 
@@ -1725,10 +1725,10 @@ class ExpenseReport extends CommonObject
 
         $result = $this->db->query($sql);
         if ($result):
-        return 1;
+            return 1;
         else:
-        $this->error=$this->db->error();
-        return -1;
+            $this->error=$this->db->error();
+            return -1;
         endif;
     }
 
@@ -2372,10 +2372,10 @@ class ExpenseReport extends CommonObject
 	        $response = new WorkboardResponse();
 	        if ($option == 'toapprove')
 	        {
-	           $response->warning_delay=$conf->expensereport->approve->warning_delay/60/60/24;
-	           $response->label=$langs->trans("ExpenseReportsToApprove");
-	           $response->labelShort=$langs->trans("ToApprove");
-	           $response->url=DOL_URL_ROOT.'/expensereport/list.php?mainmenu=hrm&amp;statut=2';
+	            $response->warning_delay=$conf->expensereport->approve->warning_delay/60/60/24;
+	            $response->label=$langs->trans("ExpenseReportsToApprove");
+	            $response->labelShort=$langs->trans("ToApprove");
+	            $response->url=DOL_URL_ROOT.'/expensereport/list.php?mainmenu=hrm&amp;statut=2';
 	        }
 	        else
 	        {

+ 9 - 7
htdocs/expensereport/list.php

@@ -537,8 +537,9 @@ if ($resql)
 	if (! empty($arrayfields['d.date_debut']['checked']))
 	{
     	print '<td class="liste_titre" align="center">';
-	if (! empty($conf->global->MAIN_LIST_FILTER_ON_DAY))
-		print '<input class="flat width25" type="text" maxlength="2" name="day_start" value="'.dol_escape_htmltag($day_start).'">';
+        if (! empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) {
+            print '<input class="flat width25" type="text" maxlength="2" name="day_start" value="'.dol_escape_htmltag($day_start).'">';
+        }
 
     	print '<input class="flat valignmiddle" type="text" size="1" maxlength="2" name="month_start" value="'.$month_start.'">';
     	$formother->select_year($year_start, 'year_start', 1, $min_year, $max_year);
@@ -548,9 +549,10 @@ if ($resql)
 	if (! empty($arrayfields['d.date_fin']['checked']))
 	{
     	print '<td class="liste_titre" align="center">';
-	if (! empty($conf->global->MAIN_LIST_FILTER_ON_DAY))
-		print '<input class="flat width25" type="text" maxlength="2" name="day_end" value="'.dol_escape_htmltag($day_end).'">';
-	print '<input class="flat valignmiddle" type="text" size="1" maxlength="2" name="month_end" value="'.$month_end.'">';
+		if (! empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) {
+			print '<input class="flat width25" type="text" maxlength="2" name="day_end" value="'.dol_escape_htmltag($day_end).'">';
+		}
+		print '<input class="flat valignmiddle" type="text" size="1" maxlength="2" name="month_end" value="'.$month_end.'">';
     	$formother->select_year($year_end, 'year_end', 1, $min_year, $max_year);
     	print '</td>';
     }
@@ -577,12 +579,12 @@ if ($resql)
 	}
 	if (! empty($arrayfields['d.total_vat']['checked']))
 	{
-	   print '<td class="liste_titre right"><input class="flat" type="text" size="5" name="search_amount_vat" value="'.$search_amount_vat.'"></td>';
+	    print '<td class="liste_titre right"><input class="flat" type="text" size="5" name="search_amount_vat" value="'.$search_amount_vat.'"></td>';
 	}
 	// Amount with all taxes
 	if (! empty($arrayfields['d.total_ttc']['checked']))
 	{
-	   print '<td class="liste_titre right"><input class="flat" type="text" size="5" name="search_amount_ttc" value="'.$search_amount_ttc.'"></td>';
+	    print '<td class="liste_titre right"><input class="flat" type="text" size="5" name="search_amount_ttc" value="'.$search_amount_ttc.'"></td>';
 	}
 	// Extra fields
 	include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php';

+ 10 - 13
htdocs/expensereport/tpl/linkedobjectblock.tpl.php

@@ -24,37 +24,34 @@ if (empty($conf) || ! is_object($conf))
 	exit;
 }
 
-?>
 
-<!-- BEGIN PHP TEMPLATE -->
+print "<!-- BEGIN PHP TEMPLATE -->\n";
 
-<?php
 
 global $user;
 
 $langs = $GLOBALS['langs'];
 $linkedObjectBlock = $GLOBALS['linkedObjectBlock'];
 
-$var=true;
-$total=0;
+$var = true;
+$total = 0;
 foreach($linkedObjectBlock as $key => $objectlink)
 {
-?>
+	?>
 <tr <?php echo $GLOBALS['bc'][$var]; ?> >
 	<td><?php echo $langs->trans("ExpenseReport"); ?></td>
     <td><?php echo $objectlink->getNomUrl(1); ?></td>
     <td></td>
 	<td class="center"><?php echo dol_print_date($objectlink->date_debut, 'day'); ?></td>
 	<td class="right"><?php
-		if ($user->rights->expensereport->lire) {
-			$total = $total + $objectlink->total_ht;
-			echo price($objectlink->total_ht);
-		} ?></td>
+	if ($user->rights->expensereport->lire) {
+		$total = $total + $objectlink->total_ht;
+		echo price($objectlink->total_ht);
+	} ?></td>
 	<td class="right"><?php echo $objectlink->getLibStatut(3); ?></td>
 	<td class="right"><a href="<?php echo $_SERVER["PHP_SELF"].'?id='.$object->id.'&action=dellink&dellinkid='.$key; ?>"><?php echo img_picto($langs->transnoentitiesnoconv("RemoveLink"), 'unlink'); ?></a></td>
 </tr>
-<?php
+	<?php
 }
-?>
 
-<!-- END PHP TEMPLATE -->
+print "<!-- END PHP TEMPLATE -->\n";

+ 14 - 13
htdocs/fichinter/card.php

@@ -1196,19 +1196,20 @@ elseif ($id > 0 || ! empty($ref))
 	    $morehtmlref.='<br>'.$langs->trans('Project') . ' ';
 	    if ($user->rights->ficheinter->creer)
 	    {
-	        if ($action != 'classify')
-	            $morehtmlref.='<a class="editfielda" href="' . $_SERVER['PHP_SELF'] . '?action=classify&amp;id=' . $object->id . '">' . img_edit($langs->transnoentitiesnoconv('SetProject')) . '</a> : ';
-	            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);
-	            }
+            if ($action != 'classify') {
+                $morehtmlref.='<a class="editfielda" href="' . $_SERVER['PHP_SELF'] . '?action=classify&amp;id=' . $object->id . '">' . img_edit($langs->transnoentitiesnoconv('SetProject')) . '</a> : ';
+            }
+            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);

+ 15 - 14
htdocs/fichinter/contact.php

@@ -141,20 +141,21 @@ if ($id > 0 || ! empty($ref))
 	    $morehtmlref.='<br>'.$langs->trans('Project') . ' ';
 	    if ($user->rights->ficheinter->creer)
 	    {
-	        if ($action != 'classify')
-	        	//$morehtmlref.='<a class="editfielda" 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);
-	            }
+	        if ($action != 'classify') {
+                //$morehtmlref.='<a class="editfielda" 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);

+ 16 - 15
htdocs/fichinter/document.php

@@ -120,21 +120,22 @@ if ($object->id)
 	    $morehtmlref.='<br>'.$langs->trans('Project') . ' ';
 	    if ($user->rights->commande->creer)
 	    {
-	        if ($action != 'classify')
-	        	//$morehtmlref.='<a class="editfielda" 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 ($action != 'classify') {
+                //$morehtmlref.='<a class="editfielda" 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);

+ 15 - 14
htdocs/fichinter/note.php

@@ -86,20 +86,21 @@ if ($id > 0 || ! empty($ref))
 	    $morehtmlref.='<br>'.$langs->trans('Project') . ' ';
 	    if ($user->rights->commande->creer)
 	    {
-	        if ($action != 'classify')
-	        	//$morehtmlref.='<a class="editfielda" 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);
-	            }
+            if ($action != 'classify') {
+                //$morehtmlref.='<a class="editfielda" 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);

+ 5 - 8
htdocs/fichinter/tpl/linkedobjectblock.tpl.php

@@ -22,11 +22,9 @@ if (empty($conf) || ! is_object($conf))
 	exit;
 }
 
-?>
 
-<!-- BEGIN PHP TEMPLATE -->
+print "<!-- BEGIN PHP TEMPLATE -->\n";
 
-<?php
 
 global $user;
 
@@ -37,14 +35,14 @@ $langs->load("interventions");
 
 $linkedObjectBlock = dol_sort_array($linkedObjectBlock, 'date', 'desc', 0, 0, 1);
 
-$ilink=0;
+$ilink = 0;
 foreach($linkedObjectBlock as $key => $objectlink)
 {
     $ilink++;
 
     $trclass='oddeven';
     if ($ilink == count($linkedObjectBlock) && empty($noMoreLinkedObjectBlockAfter) && count($linkedObjectBlock) <= 1) $trclass.=' liste_sub_total';
-?>
+	?>
     <tr class="<?php echo $trclass; ?>">
 		<td><?php echo $langs->trans("Intervention"); ?></td>
 	    <td><?php echo $objectlink->getNomUrl(1); ?></td>
@@ -54,8 +52,7 @@ foreach($linkedObjectBlock as $key => $objectlink)
 		<td class="right"><?php echo $objectlink->getLibStatut(3); ?></td>
 		<td class="right"><a href="<?php echo $_SERVER["PHP_SELF"].'?id='.$object->id.'&action=dellink&dellinkid='.$key; ?>"><?php echo img_picto($langs->transnoentitiesnoconv("RemoveLink"), 'unlink'); ?></a></td>
 	</tr>
-<?php
+	<?php
 }
-?>
 
-<!-- END PHP TEMPLATE -->
+print "<!-- END PHP TEMPLATE -->\n";

+ 45 - 44
htdocs/index.php

@@ -283,26 +283,27 @@ if (empty($user->societe_id) && empty($conf->global->MAIN_DISABLE_GLOBAL_BOXSTAT
 			DOL_URL_ROOT.'/don/list.php?leftmenu=donations'
 	    );
 	    // Translation lang files
-	    $langfile=array("users",
-	                    "companies",
-	                    "prospects",
-	                    "suppliers",
-	                    "companies",
-	                    "members",
-	                    "products",
-	                    "products",
-	                    "propal",
-	                    "orders",
-            	        "bills",
-						"contracts",
-						"interventions",
-	                    "bills",
-	                    "bills",
-	                    "supplier_proposal",
-	                    "projects",
-						"trips",
-                        "holiday",
-						"donations"
+	    $langfile=array(
+            "users",
+            "companies",
+            "prospects",
+            "suppliers",
+            "companies",
+            "members",
+            "products",
+            "products",
+            "propal",
+            "orders",
+            "bills",
+			"contracts",
+			"interventions",
+            "bills",
+            "bills",
+            "supplier_proposal",
+	        "projects",
+			"trips",
+            "holiday",
+			"donations",
 	    );
 
 
@@ -353,34 +354,34 @@ if (empty($user->societe_id) && empty($conf->global->MAIN_DISABLE_GLOBAL_BOXSTAT
 if (empty($conf->global->MAIN_DISABLE_GLOBAL_WORKBOARD)) {
     $showweather = (empty($conf->global->MAIN_DISABLE_METEO) || $conf->global->MAIN_DISABLE_METEO == 2) ? 1 : 0;
 
-//Array that contains all WorkboardResponse classes to process them
+    //Array that contains all WorkboardResponse classes to process them
     $dashboardlines = array();
 
-// Do not include sections without management permission
+    // Do not include sections without management permission
     require_once DOL_DOCUMENT_ROOT . '/core/class/workboardresponse.class.php';
 
-// Number of actions to do (late)
+    // Number of actions to do (late)
     if (!empty($conf->agenda->enabled) && $user->rights->agenda->myactions->read) {
         include_once DOL_DOCUMENT_ROOT . '/comm/action/class/actioncomm.class.php';
         $board = new ActionComm($db);
         $dashboardlines[$board->element] = $board->load_board($user);
     }
 
-// Number of project opened
+    // Number of project opened
     if (!empty($conf->projet->enabled) && $user->rights->projet->lire) {
         include_once DOL_DOCUMENT_ROOT . '/projet/class/project.class.php';
         $board = new Project($db);
         $dashboardlines[$board->element] = $board->load_board($user);
     }
 
-// Number of tasks to do (late)
+    // Number of tasks to do (late)
     if (!empty($conf->projet->enabled) && empty($conf->global->PROJECT_HIDE_TASKS) && $user->rights->projet->lire) {
         include_once DOL_DOCUMENT_ROOT . '/projet/class/task.class.php';
         $board = new Task($db);
         $dashboardlines[$board->element] = $board->load_board($user);
     }
 
-// Number of commercial proposals opened (expired)
+    // Number of commercial proposals opened (expired)
     if (!empty($conf->propal->enabled) && $user->rights->propale->lire) {
         include_once DOL_DOCUMENT_ROOT . '/comm/propal/class/propal.class.php';
         $board = new Propal($db);
@@ -389,7 +390,7 @@ if (empty($conf->global->MAIN_DISABLE_GLOBAL_WORKBOARD)) {
         $dashboardlines[$board->element . '_signed'] = $board->load_board($user, "signed");
     }
 
-// Number of commercial proposals opened (expired)
+    // Number of commercial proposals opened (expired)
     if (!empty($conf->supplier_proposal->enabled) && $user->rights->supplier_proposal->lire) {
         include_once DOL_DOCUMENT_ROOT . '/supplier_proposal/class/supplier_proposal.class.php';
         $board = new SupplierProposal($db);
@@ -398,14 +399,14 @@ if (empty($conf->global->MAIN_DISABLE_GLOBAL_WORKBOARD)) {
         $dashboardlines[$board->element . '_signed'] = $board->load_board($user, "signed");
     }
 
-// Number of customer orders a deal
+    // Number of customer orders a deal
     if (!empty($conf->commande->enabled) && $user->rights->commande->lire) {
         include_once DOL_DOCUMENT_ROOT . '/commande/class/commande.class.php';
         $board = new Commande($db);
         $dashboardlines[$board->element] = $board->load_board($user);
     }
 
-// Number of suppliers orders a deal
+    // Number of suppliers orders a deal
     if (!empty($conf->supplier_order->enabled) && $user->rights->fournisseur->commande->lire) {
         include_once DOL_DOCUMENT_ROOT . '/fourn/class/fournisseur.commande.class.php';
         $board = new CommandeFournisseur($db);
@@ -413,7 +414,7 @@ if (empty($conf->global->MAIN_DISABLE_GLOBAL_WORKBOARD)) {
         $dashboardlines[$board->element . '_awaiting'] = $board->load_board($user, 'awaiting');
     }
 
-// Number of services enabled (delayed)
+    // Number of services enabled (delayed)
     if (!empty($conf->contrat->enabled) && $user->rights->contrat->lire) {
         include_once DOL_DOCUMENT_ROOT . '/contrat/class/contrat.class.php';
         $board = new Contrat($db);
@@ -421,21 +422,21 @@ if (empty($conf->global->MAIN_DISABLE_GLOBAL_WORKBOARD)) {
         // Number of active services (expired)
         $dashboardlines[$board->element . '_active'] = $board->load_board($user, "active");
     }
-// Number of invoices customers (has paid)
+    // Number of invoices customers (has paid)
     if (!empty($conf->facture->enabled) && $user->rights->facture->lire) {
         include_once DOL_DOCUMENT_ROOT . '/compta/facture/class/facture.class.php';
         $board = new Facture($db);
         $dashboardlines[$board->element] = $board->load_board($user);
     }
 
-// Number of supplier invoices (has paid)
+    // Number of supplier invoices (has paid)
     if (!empty($conf->supplier_invoice->enabled) && !empty($user->rights->fournisseur->facture->lire)) {
         include_once DOL_DOCUMENT_ROOT . '/fourn/class/fournisseur.facture.class.php';
         $board = new FactureFournisseur($db);
         $dashboardlines[$board->element] = $board->load_board($user);
     }
 
-// Number of transactions to conciliate
+    // Number of transactions to conciliate
     if (!empty($conf->banque->enabled) && $user->rights->banque->lire && !$user->societe_id) {
         include_once DOL_DOCUMENT_ROOT . '/compta/bank/class/account.class.php';
         $board = new Account($db);
@@ -445,35 +446,35 @@ if (empty($conf->global->MAIN_DISABLE_GLOBAL_WORKBOARD)) {
         }
     }
 
-// Number of cheque to send
+    // Number of cheque to send
     if (!empty($conf->banque->enabled) && $user->rights->banque->lire && !$user->societe_id && empty($conf->global->BANK_DISABLE_CHECK_DEPOSIT)) {
         include_once DOL_DOCUMENT_ROOT . '/compta/paiement/cheque/class/remisecheque.class.php';
         $board = new RemiseCheque($db);
         $dashboardlines['RemiseCheque'] = $board->load_board($user);
     }
 
-// Number of foundation members
+    // Number of foundation members
     if (!empty($conf->adherent->enabled) && $user->rights->adherent->lire && !$user->societe_id) {
         include_once DOL_DOCUMENT_ROOT . '/adherents/class/adherent.class.php';
         $board = new Adherent($db);
         $dashboardlines['Adherent'] = $board->load_board($user);
     }
 
-// Number of expense reports to approve
+    // Number of expense reports to approve
     if (!empty($conf->expensereport->enabled) && $user->rights->expensereport->approve) {
         include_once DOL_DOCUMENT_ROOT . '/expensereport/class/expensereport.class.php';
         $board = new ExpenseReport($db);
         $dashboardlines['ExpenseReport'] = $board->load_board($user, 'toapprove');
     }
 
-// Number of expense reports to pay
+    // Number of expense reports to pay
     if (!empty($conf->expensereport->enabled) && $user->rights->expensereport->to_paid) {
         include_once DOL_DOCUMENT_ROOT . '/expensereport/class/expensereport.class.php';
         $board = new ExpenseReport($db);
         $dashboardlines['ExpenseReport'] = $board->load_board($user, 'topay');
     }
 
-// Number of holidays to approve
+    // Number of holidays to approve
     if (!empty($conf->holiday->enabled) && $user->rights->holiday->approve) {
         include_once DOL_DOCUMENT_ROOT . '/holiday/class/holiday.class.php';
         $board = new Holiday($db);
@@ -591,11 +592,11 @@ if (empty($conf->global->MAIN_DISABLE_GLOBAL_WORKBOARD)) {
     }
 
 
-// Calculate total nb of late
+    // Calculate total nb of late
     $totallate = $totaltodo = 0;
 
-//Remove any invalid response
-//load_board can return an integer if failed or WorkboardResponse if OK
+    //Remove any invalid response
+    //load_board can return an integer if failed or WorkboardResponse if OK
     $valid_dashboardlines = array();
     foreach ($dashboardlines as $infoKey => $tmp) {
         if ($tmp instanceof WorkboardResponse) {
@@ -603,7 +604,7 @@ if (empty($conf->global->MAIN_DISABLE_GLOBAL_WORKBOARD)) {
         }
     }
 
-// We calculate $totallate. Must be defined before start of next loop because it is show in first fetch on next loop
+    // We calculate $totallate. Must be defined before start of next loop because it is show in first fetch on next loop
     foreach ($valid_dashboardlines as $board) {
         if ($board->nbtodolate > 0) {
             $totaltodo += $board->nbtodo;
@@ -645,7 +646,7 @@ if (empty($conf->global->MAIN_DISABLE_GLOBAL_WORKBOARD)) {
     $boxwork .= '</th>';
     $boxwork .= '</tr>' . "\n";
 
-// Show dashboard
+    // Show dashboard
     $nbworkboardempty = 0;
     $isIntopOpenedDashBoard = $globalStatInTopOpenedDashBoard = array();
     if (!empty($valid_dashboardlines)) {
@@ -1001,7 +1002,7 @@ function showWeather($totallate, $text, $options, $morecss = '')
 {
     global $conf;
 
-	$weather = getWeatherStatus($totallate);
+    $weather = getWeatherStatus($totallate);
     return img_weather($text, $weather->picto, $options, 0, $morecss);
 }
 

+ 13 - 12
htdocs/salaries/card.php

@@ -390,19 +390,20 @@ if ($id)
 		$morehtmlref.='<br>'.$langs->trans('Project') . ' ';
 		if ($user->rights->salaries->write)
 		{
-			if ($action != 'classify')
+			if ($action != 'classify') {
 				$morehtmlref.='<a class="editfielda" href="' . $_SERVER['PHP_SELF'] . '?action=classify&amp;id=' . $object->id . '">' . img_edit($langs->transnoentitiesnoconv('SetProject')) . '</a> : ';
-				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(0, $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);
-				}
+			}
+			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(0, $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);

+ 11 - 11
htdocs/societe/admin/societe.php

@@ -311,17 +311,17 @@ if ($action == 'sethideinactivethirdparty')
 	}
 }
 if($action=='setonsearchandlistgooncustomerorsuppliercard'){
-       $setonsearchandlistgooncustomerorsuppliercard = GETPOST('value', 'int');
-       $res = dolibarr_set_const($db, "SOCIETE_ON_SEARCH_AND_LIST_GO_ON_CUSTOMER_OR_SUPPLIER_CARD", $setonsearchandlistgooncustomerorsuppliercard, 'yesno', 0, '', $conf->entity);
-       if (! $res > 0) $error++;
-       if (! $error)
-       {
-               setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
-       }
-       else
-       {
-               setEventMessages($langs->trans("Error"), null, 'errors');
-       }
+    $setonsearchandlistgooncustomerorsuppliercard = GETPOST('value', 'int');
+    $res = dolibarr_set_const($db, "SOCIETE_ON_SEARCH_AND_LIST_GO_ON_CUSTOMER_OR_SUPPLIER_CARD", $setonsearchandlistgooncustomerorsuppliercard, 'yesno', 0, '', $conf->entity);
+    if (! $res > 0) $error++;
+    if (! $error)
+    {
+        setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
+    }
+    else
+    {
+        setEventMessages($langs->trans("Error"), null, 'errors');
+    }
 }
 
 /*

+ 8 - 7
htdocs/societe/canvas/company/tpl/card_create.tpl.php

@@ -32,15 +32,15 @@ if (empty($conf) || ! is_object($conf))
 <?php echo $this->control->tpl['error']; ?>
 
 <?php if ($conf->use_javascript_ajax) { ?>
-<?php echo $this->control->tpl['ajax_selecttype']; ?>
+	<?php echo $this->control->tpl['ajax_selecttype']; ?>
 <br>
-<?php echo $langs->trans("ThirdPartyType") ?>: &nbsp;
+	<?php echo $langs->trans("ThirdPartyType") ?>: &nbsp;
 <input type="radio" id="radiocompany" class="flat" name="private" value="0" checked>
-<?php echo $langs->trans("CompanyFoundation"); ?> &nbsp; &nbsp;
+	<?php echo $langs->trans("CompanyFoundation"); ?> &nbsp; &nbsp;
 <input type="radio" id="radioprivate" class="flat" name="private" value="1"> <?php echo $langs->trans("Individual"); ?> (<?php echo $langs->trans("ToCreateContactWithSameName") ?>)
 <br>
 <br>
-<?php echo $this->control->tpl['ajax_selectcountry']; ?>
+	<?php echo $this->control->tpl['ajax_selectcountry']; ?>
 <?php } ?>
 
 <?php if ($this->control->tpl['js_checkVatPopup']) echo $this->control->tpl['js_checkVatPopup']; ?>
@@ -96,14 +96,15 @@ if (empty($conf) || ! is_object($conf))
 	</td>
 </tr>
 
-<?php if (count($this->control->tpl['suppliercategory']) > 0) { ?>
+	<?php if (count($this->control->tpl['suppliercategory']) > 0) { ?>
 <tr>
 	<td><?php echo $langs->trans('SupplierCategory'); ?></td>
 	<td colspan="3"><?php echo $this->control->tpl['select_suppliercategory']; ?></td>
 </tr>
-<?php } }?>
+	<?php }
+}
 
-<?php if (! empty($conf->barcode->enabled)) { ?>
+if (! empty($conf->barcode->enabled)) { ?>
 <tr>
 	<td><?php echo $langs->trans('Gencod'); ?></td>
 	<td colspan="3"><input type="text" name="barcode" value="<?php echo $this->control->tpl['barcode']; ?>"></td>

+ 5 - 6
htdocs/societe/canvas/company/tpl/card_edit.tpl.php

@@ -59,7 +59,7 @@ $contact = $GLOBALS['objcanvas']->control->object;
 	<td colspan="3">
 	<?php if (($this->control->tpl['prefix_customercode'] || $this->control->tpl['prefix_suppliercode']) && $this->control->tpl['prefix_comm']) { ?>
 	<input type="hidden" name="prefix_comm" value="<?php echo $this->control->tpl['prefix_comm']; ?>">
-	<?php echo $this->control->tpl['prefix_comm']; ?>
+		<?php echo $this->control->tpl['prefix_comm']; ?>
 	<?php } else { ?>
 	<input type="text" size="5" maxlength="5" name="prefix_comm" value="<?php echo $this->control->tpl['prefix_comm']; ?>">
 	<?php } ?>
@@ -116,12 +116,11 @@ if ($this->control->tpl['fournisseur']) {
 	<td><?php echo $langs->trans('SupplierCategory'); ?></td>
 	<td colspan="3"><?php echo $this->control->tpl['select_suppliercategory']; ?></td>
 </tr>
-<?php
+		<?php
     }
 }
-?>
 
-<?php if (! empty($conf->barcode->enabled)) { ?>
+if (! empty($conf->barcode->enabled)) { ?>
 <tr>
 	<td><?php echo $langs->trans('Gencod'); ?></td>
 	<td colspan="3"><input type="text" name="barcode" value="<?php echo $this->control->tpl['barcode']; ?>"></td>
@@ -209,9 +208,9 @@ for ($i=1; $i<=4; $i++) {
 	<td><?php echo $langs->trans("DefaultLang"); ?></td>
 	<td colspan="3"><?php echo $this->control->tpl['select_lang']; ?></td>
 </tr>
-<?php } ?>
+<?php }
 
-<?php if(!empty($this->control->tpl['localtax'])) echo $this->control->tpl['localtax']; ?>
+if(!empty($this->control->tpl['localtax'])) echo $this->control->tpl['localtax']; ?>
 
 </table>
 <br>

+ 1 - 3
htdocs/societe/canvas/company/tpl/card_view.tpl.php

@@ -25,10 +25,8 @@ if (empty($conf) || ! is_object($conf))
 
 $soc = $GLOBALS['objcanvas']->control->object;
 
-?>
 
-<!-- BEGIN PHP TEMPLATE CARD_VIEW.TPL.PHP COMPANY -->
-<?php
+print "<!-- BEGIN PHP TEMPLATE CARD_VIEW.TPL.PHP COMPANY -->\n";
 
 $head = societe_prepare_head($soc);
 

+ 8 - 7
htdocs/societe/canvas/individual/tpl/card_create.tpl.php

@@ -32,15 +32,15 @@ if (empty($conf) || ! is_object($conf))
 <?php echo $this->control->tpl['error']; ?>
 
 <?php if ($conf->use_javascript_ajax) { ?>
-<?php echo $this->control->tpl['ajax_selecttype']; ?>
+    <?php echo $this->control->tpl['ajax_selecttype']; ?>
 <br>
-<?php echo $langs->trans("ThirdPartyType") ?>: &nbsp;
+    <?php echo $langs->trans("ThirdPartyType") ?>: &nbsp;
 <input type="radio" id="radiocompany" class="flat" name="private" value="0">
-<?php echo $langs->trans("CompanyFoundation"); ?> &nbsp; &nbsp;
+    <?php echo $langs->trans("CompanyFoundation"); ?> &nbsp; &nbsp;
 <input type="radio" id="radioprivate" class="flat" name="private" value="1" checked> <?php echo $langs->trans("Individual"); ?> (<?php echo $langs->trans("ToCreateContactWithSameName") ?>)
 <br>
 <br>
-<?php echo $this->control->tpl['ajax_selectcountry']; ?>
+    <?php echo $this->control->tpl['ajax_selectcountry']; ?>
 <?php } ?>
 
 <form action="<?php echo $_SERVER["PHP_SELF"]; ?>" method="POST" name="formsoc">
@@ -106,14 +106,15 @@ if (empty($conf) || ! is_object($conf))
 	</td>
 </tr>
 
-<?php if (count($this->control->tpl['suppliercategory']) > 0) { ?>
+    <?php if (count($this->control->tpl['suppliercategory']) > 0) { ?>
 <tr>
 	<td><?php echo $langs->trans('SupplierCategory'); ?></td>
 	<td colspan="3"><?php echo $this->control->tpl['select_suppliercategory']; ?></td>
 </tr>
-<?php } }?>
+    <?php }
+}
 
-<?php if (! empty($conf->barcode->enabled)) { ?>
+if (! empty($conf->barcode->enabled)) { ?>
 <tr>
 	<td><?php echo $langs->trans('Gencod'); ?></td>
 	<td colspan="3"><input type="text" name="barcode" value="<?php echo $this->control->tpl['barcode']; ?>"></td>

+ 2 - 2
htdocs/societe/canvas/individual/tpl/card_edit.tpl.php

@@ -56,7 +56,7 @@ if (empty($conf) || ! is_object($conf))
 	<td colspan="3">
 	<?php if (($this->control->tpl['prefix_customercode'] || $this->control->tpl['prefix_suppliercode']) && $this->control->tpl['prefix_comm']) { ?>
 	<input type="hidden" name="prefix_comm" value="<?php echo $this->control->tpl['prefix_comm']; ?>">
-	<?php echo $this->control->tpl['prefix_comm']; ?>
+		<?php echo $this->control->tpl['prefix_comm']; ?>
 	<?php } else { ?>
 	<input type="text" size="5" maxlength="5" name="prefix_comm" value="<?php echo $this->control->tpl['prefix_comm']; ?>">
 	<?php } ?>
@@ -113,7 +113,7 @@ if ($this->control->tpl['fournisseur']) {
 	<td><?php echo $langs->trans('SupplierCategory'); ?></td>
 	<td colspan="3"><?php echo $this->control->tpl['select_suppliercategory']; ?></td>
 </tr>
-<?php
+		<?php
     }
 }
 ?>

+ 4 - 9
htdocs/societe/canvas/individual/tpl/card_view.tpl.php

@@ -25,19 +25,15 @@ if (empty($conf) || ! is_object($conf))
 
 $object = $GLOBALS['objcanvas']->control->object;
 
-?>
 
-<!-- BEGIN PHP TEMPLATE CARD_VIEW.TPL.PHP INDIVIDUAL -->
-<?php
+print "<!-- BEGIN PHP TEMPLATE CARD_VIEW.TPL.PHP INDIVIDUAL -->\n";
 
 $head = societe_prepare_head($object);
 
 dol_fiche_head($head, 'card', $langs->trans("ThirdParty"), 0, 'company');
 
-?>
-
-<?php if ($this->control->tpl['error']) echo $this->control->tpl['error']; ?>
-<?php if ($this->control->tpl['action_delete']) echo $this->control->tpl['action_delete']; ?>
+if ($this->control->tpl['error']) echo $this->control->tpl['error'];
+if ($this->control->tpl['action_delete']) echo $this->control->tpl['action_delete']; ?>
 
 <table class="border allwidth">
 
@@ -230,6 +226,5 @@ $result=show_contacts($conf, $langs, $db, $object);
 
 // Projects list
 $result=show_projects($conf, $langs, $db, $object);
-?>
 
-<!-- END PHP TEMPLATE -->
+print "<!-- END PHP TEMPLATE -->\n";

+ 9 - 9
htdocs/societe/card.php

@@ -599,11 +599,11 @@ if (empty($reshook))
 						{
 						    case 1: //uploaded file exceeds the upload_max_filesize directive in php.ini
 						    case 2: //uploaded file exceeds the MAX_FILE_SIZE directive that was specified in the html form
-						      $errors[] = "ErrorFileSizeTooLarge";
-						      break;
+						        $errors[] = "ErrorFileSizeTooLarge";
+						        break;
 	      					case 3: //uploaded file was only partially uploaded
-						      $errors[] = "ErrorFilePartiallyUploaded";
-						      break;
+						        $errors[] = "ErrorFilePartiallyUploaded";
+						        break;
 						}
 	                }
                     // Gestion du logo de la société
@@ -764,11 +764,11 @@ if (empty($reshook))
 					{
 					    case 1: //uploaded file exceeds the upload_max_filesize directive in php.ini
 					    case 2: //uploaded file exceeds the MAX_FILE_SIZE directive that was specified in the html form
-					      $errors[] = "ErrorFileSizeTooLarge";
-					      break;
+					        $errors[] = "ErrorFileSizeTooLarge";
+					        break;
       					case 3: //uploaded file was only partially uploaded
-					      $errors[] = "ErrorFilePartiallyUploaded";
-					      break;
+					        $errors[] = "ErrorFilePartiallyUploaded";
+					        break;
 					}
                 }
                 // Gestion du logo de la société
@@ -1855,7 +1855,7 @@ else
 	                    print '<input type="text" name="supplier_code" id="supplier_code" size="16" value="'.$object->code_fournisseur.'" maxlength="15">';
 	                }
 	                else
-	              {
+	                {
 	                    print $object->code_fournisseur;
 	                    print '<input type="hidden" name="supplier_code" value="'.$object->code_fournisseur.'">';
 	                }

+ 57 - 53
htdocs/societe/class/api_thirdparties.class.php

@@ -1060,12 +1060,13 @@ class Thirdparties extends DolibarrApi
 
 		$returnAccounts = array();
 
-		foreach($accounts as $account){
-			$object= array();
-			foreach($account as $key => $value)
-				if(in_array($key, $fields)){
+		foreach ($accounts as $account) {
+			$object = array();
+			foreach ($account as $key => $value) {
+				if (in_array($key, $fields)) {
 					$object[$key] = $value;
 				}
+			}
 			$returnAccounts[] = $object;
 		}
 
@@ -1264,7 +1265,7 @@ class Thirdparties extends DolibarrApi
 		}
     }
 
-  /**
+    /**
 	 * Get a specific gateway attached to a thirdparty (by specifying the site key)
 	 *
 	 * @param int $id ID of thirdparty
@@ -1321,12 +1322,13 @@ class Thirdparties extends DolibarrApi
 
 		$returnAccounts = array();
 
-		foreach($accounts as $account){
-			$object= array();
-			foreach($account as $key => $value)
-				if(in_array($key, $fields)){
+		foreach ($accounts as $account) {
+			$object = array();
+			foreach ($account as $key => $value) {
+				if(in_array($key, $fields)) {
 					$object[$key] = $value;
 				}
+			}
 			$returnAccounts[] = $object;
 		}
 
@@ -1439,16 +1441,18 @@ class Thirdparties extends DolibarrApi
 			$account->fk_soc = $id;
 			$account->site = $site;
 
-			if ($account->create(DolibarrApiAccess::$user) < 0)
+			if ($account->create(DolibarrApiAccess::$user) < 0) {
 				throw new RestException(500, 'Error creating SocieteAccount entity.');
-		// We found an existing SocieteAccount entity, we are replacing it
+			}
+			// We found an existing SocieteAccount entity, we are replacing it
 		} else {
-			if(isset($request_data['site']) && $request_data['site'] !== $site) {
+			if (isset($request_data['site']) && $request_data['site'] !== $site) {
 				$sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."societe_account WHERE fk_soc  = ".$id." AND site = '". $request_data['site']."' ";
 				$result = $db->query($sql);
 
-				if($result->num_rows !== 0)
+				if ($result->num_rows !== 0) {
 					throw new RestException(409, "You are trying to update this thirdparty SocieteAccount (gateway record) from $site to ".$request_data['site'] . " but another SocieteAccount entity already exists with this site key.");
+				}
 			}
 
 			$obj = $db->fetch_object($result);
@@ -1664,12 +1668,12 @@ class Thirdparties extends DolibarrApi
         return $thirdparty;
     }
 
-  /**
-   * Fetch properties of a thirdparty object.
-   *
-   * Return an array with thirdparty informations
-   *
-   * @param	   int		$rowid      Id of third party to load
+    /**
+     * Fetch properties of a thirdparty object.
+     *
+     * Return an array with thirdparty informations
+     *
+     * @param	   int		$rowid      Id of third party to load
 	 * @param    string	$ref        Reference of third party, name (Warning, this can return several records)
 	 * @param    string	$ref_ext    External reference of third party (Warning, this information is a free field not provided by Dolibarr)
 	 * @param    string	$ref_int    Internal reference of third party (not used by dolibarr)
@@ -1681,38 +1685,38 @@ class Thirdparties extends DolibarrApi
 	 * @param    string	$idprof6		Prof id 6 of third party (Warning, this can return several records)
 	 * @param    string	$email   		Email of third party (Warning, this can return several records)
 	 * @param    string	$ref_alias  Name_alias of third party (Warning, this can return several records)
-   * @return array|mixed data without useless information
-   *
-   * @throws RestException
-   */
-  private function _fetch($rowid, $ref = '', $ref_ext = '', $ref_int = '', $idprof1 = '', $idprof2 = '', $idprof3 = '', $idprof4 = '', $idprof5 = '', $idprof6 = '', $email = '', $ref_alias = '')
-  {
-      if(! DolibarrApiAccess::$user->rights->societe->lire) {
-          throw new RestException(401);
-      }
-
-      $result = $this->company->fetch($rowid, $ref, $ref_ext, $ref_int, $idprof1, $idprof2, $idprof3, $idprof4, $idprof5, $idprof6, $email, $ref_alias);
-      if( ! $result ) {
-          throw new RestException(404, 'Thirdparty not found');
-      }
-
-      if( ! DolibarrApi::_checkAccessToResource('societe', $this->company->id)) {
-          throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
-      }
-
-      if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) {
-          $filterabsolutediscount = "fk_facture_source IS NULL"; // If we want deposit to be substracted to payments only and not to total of final invoice
-          $filtercreditnote = "fk_facture_source IS NOT NULL"; // If we want deposit to be substracted to payments only and not to total of final invoice
-      } else {
-          $filterabsolutediscount = "fk_facture_source IS NULL OR (description LIKE '(DEPOSIT)%' AND description NOT LIKE '(EXCESS RECEIVED)%')";
-          $filtercreditnote = "fk_facture_source IS NOT NULL AND (description NOT LIKE '(DEPOSIT)%' OR description LIKE '(EXCESS RECEIVED)%')";
-      }
-
-      $absolute_discount = $this->company->getAvailableDiscounts('', $filterabsolutediscount);
-      $absolute_creditnote = $this->company->getAvailableDiscounts('', $filtercreditnote);
-      $this->company->absolute_discount = price2num($absolute_discount, 'MT');
-      $this->company->absolute_creditnote = price2num($absolute_creditnote, 'MT');
-
-      return $this->_cleanObjectDatas($this->company);
-  }
+     * @return array|mixed data without useless information
+     *
+     * @throws RestException
+    */
+    private function _fetch($rowid, $ref = '', $ref_ext = '', $ref_int = '', $idprof1 = '', $idprof2 = '', $idprof3 = '', $idprof4 = '', $idprof5 = '', $idprof6 = '', $email = '', $ref_alias = '')
+    {
+        if(! DolibarrApiAccess::$user->rights->societe->lire) {
+            throw new RestException(401);
+        }
+
+        $result = $this->company->fetch($rowid, $ref, $ref_ext, $ref_int, $idprof1, $idprof2, $idprof3, $idprof4, $idprof5, $idprof6, $email, $ref_alias);
+        if( ! $result ) {
+            throw new RestException(404, 'Thirdparty not found');
+        }
+
+        if( ! DolibarrApi::_checkAccessToResource('societe', $this->company->id)) {
+            throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
+        }
+
+        if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) {
+            $filterabsolutediscount = "fk_facture_source IS NULL"; // If we want deposit to be substracted to payments only and not to total of final invoice
+            $filtercreditnote = "fk_facture_source IS NOT NULL"; // If we want deposit to be substracted to payments only and not to total of final invoice
+        } else {
+            $filterabsolutediscount = "fk_facture_source IS NULL OR (description LIKE '(DEPOSIT)%' AND description NOT LIKE '(EXCESS RECEIVED)%')";
+            $filtercreditnote = "fk_facture_source IS NOT NULL AND (description NOT LIKE '(DEPOSIT)%' OR description LIKE '(EXCESS RECEIVED)%')";
+        }
+
+        $absolute_discount = $this->company->getAvailableDiscounts('', $filterabsolutediscount);
+        $absolute_creditnote = $this->company->getAvailableDiscounts('', $filtercreditnote);
+        $this->company->absolute_discount = price2num($absolute_discount, 'MT');
+        $this->company->absolute_creditnote = price2num($absolute_creditnote, 'MT');
+
+        return $this->_cleanObjectDatas($this->company);
+    }
 }

+ 17 - 17
htdocs/societe/class/companybankaccount.class.php

@@ -20,9 +20,9 @@
  */
 
 /**
- * 		\file		htdocs/societe/class/companybankaccount.class.php
- *		\ingroup    societe
- *		\brief      File of class to manage bank accounts description of third parties
+ *  \file		htdocs/societe/class/companybankaccount.class.php
+ *  \ingroup    societe
+ *  \brief      File of class to manage bank accounts description of third parties
  */
 
 require_once DOL_DOCUMENT_ROOT .'/compta/bank/class/account.class.php';
@@ -174,27 +174,27 @@ class CompanyBankAccount extends Account
 		$result = $this->db->query($sql);
 		if ($result)
 		{
-		if (! $notrigger)
-		{
-			// Call trigger
-			$result=$this->call_trigger('COMPANY_RIB_MODIFY', $user);
-			if ($result < 0) $error++;
-			// End call triggers
-			if(! $error )
+			if (! $notrigger)
 			{
-				return 1;
+				// Call trigger
+				$result=$this->call_trigger('COMPANY_RIB_MODIFY', $user);
+				if ($result < 0) $error++;
+				// End call triggers
+				if(! $error )
+				{
+					return 1;
+				}
+				else
+				{
+					return -1;
+				}
 			}
 			else
 			{
-				return -1;
+				return 1;
 			}
 		}
 		else
-		{
-			return 1;
-		}
-		}
-		else
 		{
 			dol_print_error($this->db);
 			return -1;

+ 13 - 13
htdocs/societe/class/societe.class.php

@@ -1226,7 +1226,7 @@ class Societe extends CommonObject
 			}
 		}
 		else
-	   {
+	    {
 			$this->db->rollback();
 			dol_syslog(get_class($this)."::Update fails verify ".join(',', $this->errors), LOG_WARNING);
 			return -3;
@@ -2126,8 +2126,8 @@ class Societe extends CommonObject
 
 		if ($option == 'customer' || $option == 'compta' || $option == 'category' || $option == 'category_supplier')
 		{
-		   $label.= '<u>' . $langs->trans("ShowCustomer") . '</u>';
-		   $linkstart = '<a href="'.DOL_URL_ROOT.'/comm/card.php?socid='.$this->id;
+		    $label.= '<u>' . $langs->trans("ShowCustomer") . '</u>';
+		    $linkstart = '<a href="'.DOL_URL_ROOT.'/comm/card.php?socid='.$this->id;
 		}
 		elseif ($option == 'prospect' && empty($conf->global->SOCIETE_DISABLE_PROSPECTS))
 		{
@@ -3065,8 +3065,8 @@ class Societe extends CommonObject
 			//Check NIF
 			if (preg_match('/(^[0-9]{8}[A-Z]{1}$)/', $string))
 				if ($num[8] == substr('TRWAGMYFPDXBNJZSQVHLCKE', substr($string, 0, 8) % 23, 1))
-				return 1;
-				else
+					return 1;
+			else
 				return -1;
 
 			//algorithm checking type code CIF
@@ -3078,29 +3078,29 @@ class Societe extends CommonObject
 			//Chek special NIF
 			if (preg_match('/^[KLM]{1}/', $string))
 				if ($num[8] == chr(64 + $n) || $num[8] == substr('TRWAGMYFPDXBNJZSQVHLCKE', substr($string, 1, 8) % 23, 1))
-				return 1;
-				else
+					return 1;
+			else
 				return -1;
 
 			//Check CIF
 			if (preg_match('/^[ABCDEFGHJNPQRSUVW]{1}/', $string))
 				if ($num[8] == chr(64 + $n) || $num[8] == substr($n, strlen($n) - 1, 1))
-				return 2;
-				else
+					return 2;
+			else
 				return -2;
 
 			//Check NIE T
 			if (preg_match('/^[T]{1}/', $string))
 				if ($num[8] == preg_match('/^[T]{1}[A-Z0-9]{8}$/', $string))
-				return 3;
-				else
+					return 3;
+			else
 				return -3;
 
 			//Check NIE XYZ
 			if (preg_match('/^[XYZ]{1}/', $string))
 				if ($num[8] == substr('TRWAGMYFPDXBNJZSQVHLCKE', substr(str_replace(array('X','Y','Z'), array('0','1','2'), $string), 0, 8) % 23, 1))
-				return 3;
-				else
+					return 3;
+			else
 				return -3;
 
 			//Can not be verified

+ 4 - 4
htdocs/societe/list.php

@@ -234,7 +234,7 @@ if ($action=="change")	// Change customer for TakePOS
     // @TODO Check if draft invoice already exists, if not create it or return a warning to ask to enter at least one line to have it created automatically
     $sql="UPDATE ".MAIN_DB_PREFIX."facture set fk_soc=".$idcustomer." where ref='(PROV-POS".$_SESSION["takeposterminal"]."-".$place.")'";
     $resql = $db->query($sql);
-	    ?>
+    ?>
 	    <script>
 	    parent.$("#poslines").load("invoice.php?place="+<?php print $place;?>, function() {
 	        //parent.$("#poslines").scrollTop(parent.$("#poslines")[0].scrollHeight);
@@ -244,7 +244,7 @@ if ($action=="change")	// Change customer for TakePOS
 	        parent.$.colorbox.close(); /* Close the popup */
 	    });
 	    </script>
-	    <?php
+    <?php
     exit;
 }
 
@@ -1248,8 +1248,8 @@ while ($i < min($num, $limit))
 	    print '<td class="center">';
 	    if ($companystatic->fk_parent > 0)
 	    {
-	       $companyparent->fetch($companystatic->fk_parent);
-	       print $companyparent->getNomUrl(1);
+	        $companyparent->fetch($companystatic->fk_parent);
+	        print $companyparent->getNomUrl(1);
 	    }
 	    print "</td>";
 	    if (! $i) $totalarray['nbfield']++;

+ 73 - 68
htdocs/societe/paymentmodes.php

@@ -564,13 +564,13 @@ if (empty($reshook))
 
 			$db->begin();
 
-                if (empty($newcu)) {
-                        $sql  = "DELETE FROM ".MAIN_DB_PREFIX."societe_account WHERE site = 'stripe' AND fk_soc = ".$object->id." AND status = ".$servicestatus." AND entity = ".$conf->entity;
-                } else {
-			$sql = 'UPDATE '.MAIN_DB_PREFIX."societe_account";
-			$sql.= " SET key_account = '".$db->escape(GETPOST('key_account', 'alpha'))."'";
-			$sql.= " WHERE site = 'stripe' AND fk_soc = ".$object->id." AND status = ".$servicestatus." AND entity = ".$conf->entity;	// Keep = here for entity. Only 1 record must be modified !
-                }
+            if (empty($newcu)) {
+                $sql  = "DELETE FROM ".MAIN_DB_PREFIX."societe_account WHERE site = 'stripe' AND fk_soc = ".$object->id." AND status = ".$servicestatus." AND entity = ".$conf->entity;
+            } else {
+                $sql = 'UPDATE '.MAIN_DB_PREFIX."societe_account";
+                $sql.= " SET key_account = '".$db->escape(GETPOST('key_account', 'alpha'))."'";
+                $sql.= " WHERE site = 'stripe' AND fk_soc = ".$object->id." AND status = ".$servicestatus." AND entity = ".$conf->entity;	// Keep = here for entity. Only 1 record must be modified !
+            }
 
 			$resql = $db->query($sql);
 			$num = $db->num_rows($resql);
@@ -609,37 +609,33 @@ if (empty($reshook))
 
 			$db->begin();
 
-                if (empty($newsup)) {
-                        $sql  = "DELETE FROM ".MAIN_DB_PREFIX."oauth_token WHERE fk_soc = ".$object->id." AND service = '".$service."' AND entity = ".$conf->entity;
-                } else {
-      try {
-      $stripesup = \Stripe\Account::retrieve($db->escape(GETPOST('key_account_supplier', 'alpha')));
-      $tokenstring['stripe_user_id'] = $stripesup->id;
-      $tokenstring['type'] = $stripesup->type;
-			$sql = "UPDATE ".MAIN_DB_PREFIX."oauth_token";
-			$sql.= " SET tokenstring = '".dol_json_encode($tokenstring)."'";
-			$sql.= " WHERE fk_soc = ".$object->id." AND service = '".$service."' AND entity = ".$conf->entity;	// Keep = here for entity. Only 1 record must be modified !
-	  }
-					catch(Exception $e)
-					{
-						$error++;
-						setEventMessages($e->getMessage(), null, 'errors');
-					}
+            if (empty($newsup)) {
+                $sql  = "DELETE FROM ".MAIN_DB_PREFIX."oauth_token WHERE fk_soc = ".$object->id." AND service = '".$service."' AND entity = ".$conf->entity;
+            } else {
+                try {
+                    $stripesup = \Stripe\Account::retrieve($db->escape(GETPOST('key_account_supplier', 'alpha')));
+                    $tokenstring['stripe_user_id'] = $stripesup->id;
+                    $tokenstring['type'] = $stripesup->type;
+                    $sql = "UPDATE ".MAIN_DB_PREFIX."oauth_token";
+                    $sql.= " SET tokenstring = '".dol_json_encode($tokenstring)."'";
+                    $sql.= " WHERE fk_soc = ".$object->id." AND service = '".$service."' AND entity = ".$conf->entity;	// Keep = here for entity. Only 1 record must be modified !
+                } catch(Exception $e) {
+					$error++;
+					setEventMessages($e->getMessage(), null, 'errors');
 				}
+			}
 
 			$resql = $db->query($sql);
 			$num = $db->num_rows($resql);
 			if (empty($num) && !empty($newsup))
 			{
-      try {
-      $stripesup = \Stripe\Account::retrieve($db->escape(GETPOST('key_account_supplier', 'alpha')));
-      $tokenstring['stripe_user_id'] = $stripesup->id;
-      $tokenstring['type'] = $stripesup->type;
-			$sql = "INSERT INTO ".MAIN_DB_PREFIX."oauth_token (service, fk_soc, entity, tokenstring)";
-			$sql .= " VALUES ('".$service."', ".$object->id.", ".$conf->entity.", '".dol_json_encode($tokenstring)."')";
-	  }
-				catch(Exception $e)
-				{
+                try {
+                    $stripesup = \Stripe\Account::retrieve($db->escape(GETPOST('key_account_supplier', 'alpha')));
+                    $tokenstring['stripe_user_id'] = $stripesup->id;
+                    $tokenstring['type'] = $stripesup->type;
+                    $sql = "INSERT INTO ".MAIN_DB_PREFIX."oauth_token (service, fk_soc, entity, tokenstring)";
+                    $sql .= " VALUES ('".$service."', ".$object->id.", ".$conf->entity.", '".dol_json_encode($tokenstring)."')";
+                } catch(Exception $e) {
 					$error++;
 					setEventMessages($e->getMessage(), null, 'errors');
 				}
@@ -700,23 +696,25 @@ if (empty($reshook))
 		{
 			try {
 				if (preg_match('/pm_/', $source))
-					{
-            		$payment_method = \Stripe\PaymentMethod::retrieve($source, array("stripe_account" => $stripeacc));
-					if ($payment_method)
-				    {
-					  $payment_method->detach();
+				{
+                    $payment_method = \Stripe\PaymentMethod::retrieve($source, array("stripe_account" => $stripeacc));
+                    if ($payment_method)
+			        {
+					    $payment_method->detach();
 				    }
 				}
 				else
 				{
-				$cu=$stripe->customerStripe($object, $stripeacc, $servicestatus);
-				$card=$cu->sources->retrieve("$source");
-				if ($card)
-				{
-					// $card->detach();  Does not work with card_, only with src_
-					if (method_exists($card, 'detach')) $card->detach();
-					else $card->delete();
-				}
+				    $cu = $stripe->customerStripe($object, $stripeacc, $servicestatus);
+				    $card = $cu->sources->retrieve("$source");
+				    if ($card) {
+					    // $card->detach();  Does not work with card_, only with src_
+					    if (method_exists($card, 'detach')) {
+							$card->detach();
+						} else {
+							$card->delete();
+						}
+				    }
 				}
 
 				$url=DOL_URL_ROOT.'/societe/paymentmodes.php?socid='.$object->id;
@@ -1296,54 +1294,60 @@ if ($socid && $action != 'edit' && $action != 'create' && $action != 'editcard'
 		}
 		print "</table>";
 		print "</div>";
-   	print '<br>';
+        print '<br>';
 	}
 
   	// List of Stripe payment modes
 	if (! empty($conf->stripe->enabled) && ! empty($conf->stripeconnect->enabled) && $object->fournisseur && ! empty($stripesupplieracc))
 	{
-  print load_fiche_titre($langs->trans('StripeBalance').($stripesupplieracc?' (Stripe connection with StripeConnect account '.$stripesupplieracc.')':' (Stripe connection with keys from Stripe module setup)'), $morehtmlright, '');
-  $balance = \Stripe\Balance::retrieve(array("stripe_account" => $stripesupplieracc));
+        print load_fiche_titre($langs->trans('StripeBalance').($stripesupplieracc?' (Stripe connection with StripeConnect account '.$stripesupplieracc.')':' (Stripe connection with keys from Stripe module setup)'), $morehtmlright, '');
+        $balance = \Stripe\Balance::retrieve(array("stripe_account" => $stripesupplieracc));
 		print '<table class="liste" width="100%">'."\n";
 		print '<tr class="liste_titre">';
 		print '<td>'.$langs->trans('Currency').'</td>';
 		print '<td>'.$langs->trans('Available').'</td>';
 		print '<td>'.$langs->trans('Pending').'</td>';
-    print '<td>'.$langs->trans('Total').'</td>';
-    print '</tr>';
+        print '<td>'.$langs->trans('Total').'</td>';
+        print '</tr>';
 
-    $currencybalance = array();
+        $currencybalance = array();
 		if (is_array($balance->available) && count($balance->available))
 		{
 			foreach ($balance->available as $cpt)
 			{
-		$arrayzerounitcurrency=array('BIF', 'CLP', 'DJF', 'GNF', 'JPY', 'KMF', 'KRW', 'MGA', 'PYG', 'RWF', 'VND', 'VUV', 'XAF', 'XOF', 'XPF');
-		if (! in_array($cpt->currency, $arrayzerounitcurrency)) $currencybalance[$cpt->currency]->available=$cpt->amount / 100;
-		else $currencybalance[$cpt->currency]->available=$cpt->amount;
-    $currencybalance[$cpt->currency]->currency=$cpt->currency;
+		        $arrayzerounitcurrency=array('BIF', 'CLP', 'DJF', 'GNF', 'JPY', 'KMF', 'KRW', 'MGA', 'PYG', 'RWF', 'VND', 'VUV', 'XAF', 'XOF', 'XPF');
+		        if (! in_array($cpt->currency, $arrayzerounitcurrency)) {
+					$currencybalance[$cpt->currency]->available=$cpt->amount / 100;
+				} else {
+					$currencybalance[$cpt->currency]->available=$cpt->amount;
+				}
+                $currencybalance[$cpt->currency]->currency=$cpt->currency;
 			}
 		}
 
-    if (is_array($balance->pending) && count($balance->pending))
+        if (is_array($balance->pending) && count($balance->pending))
 		{
 			foreach ($balance->pending as $cpt)
 			{
-		$arrayzerounitcurrency=array('BIF', 'CLP', 'DJF', 'GNF', 'JPY', 'KMF', 'KRW', 'MGA', 'PYG', 'RWF', 'VND', 'VUV', 'XAF', 'XOF', 'XPF');
-		if (! in_array($cpt->currency, $arrayzerounitcurrency))  $currencybalance[$cpt->currency]->pending=$currencybalance[$cpt->currency]->available+$cpt->amount / 100;
-		else $currencybalance[$cpt->currency]->pending=$currencybalance[$cpt->currency]->available+$cpt->amount;
+		        $arrayzerounitcurrency=array('BIF', 'CLP', 'DJF', 'GNF', 'JPY', 'KMF', 'KRW', 'MGA', 'PYG', 'RWF', 'VND', 'VUV', 'XAF', 'XOF', 'XPF');
+		        if (! in_array($cpt->currency, $arrayzerounitcurrency)) {
+					$currencybalance[$cpt->currency]->pending=$currencybalance[$cpt->currency]->available+$cpt->amount / 100;
+				} else {
+					$currencybalance[$cpt->currency]->pending=$currencybalance[$cpt->currency]->available+$cpt->amount;
+				}
 			}
-    }
+        }
 
 		if (is_array($currencybalance))
 		{
 			foreach ($currencybalance as $cpt)
 			{
-      print '<tr><td>'.$langs->trans("Currency".strtoupper($cpt->currency)).'</td><td>'.price($cpt->available, 0, '', 1, - 1, - 1, strtoupper($cpt->currency)).'</td><td>'.price($cpt->pending, 0, '', 1, - 1, - 1, strtoupper($cpt->currency)).'</td><td>'.price($cpt->available+$cpt->pending, 0, '', 1, - 1, - 1, strtoupper($cpt->currency)).'</td></tr>';
+                print '<tr><td>'.$langs->trans("Currency".strtoupper($cpt->currency)).'</td><td>'.price($cpt->available, 0, '', 1, - 1, - 1, strtoupper($cpt->currency)).'</td><td>'.price($cpt->pending, 0, '', 1, - 1, - 1, strtoupper($cpt->currency)).'</td><td>'.price($cpt->available+$cpt->pending, 0, '', 1, - 1, - 1, strtoupper($cpt->currency)).'</td></tr>';
 			}
 		}
 
-    print '</table>';
-    print '<br>';
+        print '</table>';
+        print '<br>';
 	}
 
 	// List of bank accounts
@@ -1394,12 +1398,13 @@ if ($socid && $action != 'edit' && $action != 'create' && $action != 'editcard'
 					$string .= $rib->code_guichet.' ';
 				} elseif ($val == 'BankAccountNumberKey') {
 					$string .= $rib->cle_rib.' ';
-				/* Already output after
-                }elseif ($val == 'BIC') {
-                    $string .= $rib->bic.' ';
-                }elseif ($val == 'IBAN') {
-                    $string .= $rib->iban.' ';*/
 				}
+                // Already output after
+                // } elseif ($val == 'BIC') {
+                //     $string .= $rib->bic.' ';
+                // } elseif ($val == 'IBAN') {
+                //     $string .= $rib->iban.' ';*/
+				//}
 			}
 			if (! empty($rib->label) && $rib->number) {
 				if (! checkBanForAccount($rib)) {

+ 21 - 21
htdocs/stripe/admin/stripe.php

@@ -177,12 +177,12 @@ print "</tr>\n";
 print '<tr class="oddeven">';
 print '<td class="titlefield">';
 print $langs->trans("StripeLiveEnabled").'</td><td>';
-  if ($conf->use_javascript_ajax) {
+if ($conf->use_javascript_ajax) {
     print ajax_constantonoff('STRIPE_LIVE');
-  } else {
+} else {
     $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes"));
     print $form->selectarray("STRIPE_LIVE", $arrval, $conf->global->STRIPE_LIVE);
-  }
+}
 print '</td><td></td></tr>';
 
 if (empty($conf->stripeconnect->enabled))
@@ -203,7 +203,7 @@ if (empty($conf->stripeconnect->enabled))
 	print '<span class="titlefield">'.$langs->trans("STRIPE_TEST_WEBHOOK_KEY").'</span></td><td>';
 	if ($conf->global->MAIN_FEATURES_LEVEL >= 2) {
 	    print '<input class="minwidth300" type="text" name="STRIPE_TEST_WEBHOOK_ID" value="'.$conf->global->STRIPE_TEST_WEBHOOK_ID.'">';
-      print ' &nbsp; '.$langs->trans("Example").': we_xxxxxxxxxxxxxxxxxxxxxxxx<br>';
+        print ' &nbsp; '.$langs->trans("Example").': we_xxxxxxxxxxxxxxxxxxxxxxxx<br>';
 	}
 	print '<input class="minwidth300" type="text" name="STRIPE_TEST_WEBHOOK_KEY" value="'.$conf->global->STRIPE_TEST_WEBHOOK_KEY.'">';
 	print ' &nbsp; '.$langs->trans("Example").': whsec_xxxxxxxxxxxxxxxxxxxxxxxx';
@@ -239,7 +239,7 @@ if (empty($conf->stripeconnect->enabled))
             	print '<a class="reposition" href="'.$_SERVER['PHP_SELF'].'?action=ipn&webhook='.$endpoint->id.'&status=1">';
             	print img_picto($langs->trans("Disabled"), 'switch_off');
             }
-        //print $endpoint;
+            //print $endpoint;
         }
         else
         {
@@ -275,8 +275,8 @@ if (empty($conf->stripeconnect->enabled))
 	print '<tr class="oddeven"><td>';
 	print '<span class="titlefield">'.$langs->trans("STRIPE_LIVE_WEBHOOK_KEY").'</span></td><td>';
 	if ($conf->global->MAIN_FEATURES_LEVEL >= 2) {
-      print '<input class="minwidth300" type="text" name="STRIPE_LIVE_WEBHOOK_ID" value="'.$conf->global->STRIPE_LIVE_WEBHOOK_ID.'">';
-      print ' &nbsp; '.$langs->trans("Example").': we_xxxxxxxxxxxxxxxxxxxxxxxx<br>';
+        print '<input class="minwidth300" type="text" name="STRIPE_LIVE_WEBHOOK_ID" value="'.$conf->global->STRIPE_LIVE_WEBHOOK_ID.'">';
+        print ' &nbsp; '.$langs->trans("Example").': we_xxxxxxxxxxxxxxxxxxxxxxxx<br>';
 	}
 	print '<input class="minwidth300" type="text" name="STRIPE_LIVE_WEBHOOK_KEY" value="'.$conf->global->STRIPE_LIVE_WEBHOOK_KEY.'">';
 	print ' &nbsp; '.$langs->trans("Example").': whsec_xxxxxxxxxxxxxxxxxxxxxxxx';
@@ -312,7 +312,7 @@ if (empty($conf->stripeconnect->enabled))
                 print '<a class="reposition" href="'.$_SERVER['PHP_SELF'].'?action=ipn&webhook='.$endpoint->id.'&status=1">';
                 print img_picto($langs->trans("Disabled"), 'switch_off');
             }
-        //print $endpoint;
+            //print $endpoint;
         }
         else
         {
@@ -366,14 +366,14 @@ if ($conf->global->MAIN_FEATURES_LEVEL >= 2)	// What is this for ?
 // Activate Payment Request API
 if ($conf->global->MAIN_FEATURES_LEVEL >= 2)	// TODO Not used by current code
 {
-  print '<tr class="oddeven"><td>';
+    print '<tr class="oddeven"><td>';
 	print $langs->trans("STRIPE_PAYMENT_REQUEST_API").'</td><td>';
-  if ($conf->use_javascript_ajax) {
-    print ajax_constantonoff('STRIPE_PAYMENT_REQUEST_API');
-  } else {
-    $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes"));
-    print $form->selectarray("STRIPE_PAYMENT_REQUEST_API", $arrval, $conf->global->STRIPE_PAYMENT_REQUEST_API);
-  }
+    if ($conf->use_javascript_ajax) {
+        print ajax_constantonoff('STRIPE_PAYMENT_REQUEST_API');
+    } else {
+        $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes"));
+        print $form->selectarray("STRIPE_PAYMENT_REQUEST_API", $arrval, $conf->global->STRIPE_PAYMENT_REQUEST_API);
+    }
 	print '</td></tr>';
 }
 
@@ -382,12 +382,12 @@ if ($conf->global->MAIN_FEATURES_LEVEL >= 2)	// TODO Not used by current code
 {
 	print '<tr class="oddeven"><td>';
 	print $langs->trans("STRIPE_SEPA_DIRECT_DEBIT").'</td><td>';
-  if ($conf->use_javascript_ajax) {
-    print ajax_constantonoff('STRIPE_SEPA_DIRECT_DEBIT');
-  } else {
-    $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes"));
-    print $form->selectarray("STRIPE_SEPA_DIRECT_DEBIT", $arrval, $conf->global->STRIPE_SEPA_DIRECT_DEBIT);
-  }
+    if ($conf->use_javascript_ajax) {
+        print ajax_constantonoff('STRIPE_SEPA_DIRECT_DEBIT');
+    } else {
+        $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes"));
+        print $form->selectarray("STRIPE_SEPA_DIRECT_DEBIT", $arrval, $conf->global->STRIPE_SEPA_DIRECT_DEBIT);
+    }
 	print '</td></tr>';
 }
 

+ 29 - 23
htdocs/stripe/charge.php

@@ -1,5 +1,6 @@
 <?php
-/* Copyright (C) 2018 	Thibault FOUCART        <support@ptibogxiv.net>
+/* Copyright (C) 2018       Thibault FOUCART        <support@ptibogxiv.net>
+ * Copyright (C) 2019       Frédéric France         <frederic.france@netlogic.fr>
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -121,29 +122,28 @@ if (!$rowid)
 	//print $list;
 	foreach ($list->data as $charge)
 	{
-	  if ($charge->refunded=='1'){
+	    if ($charge->refunded=='1') {
 	    	$status = img_picto($langs->trans("refunded"), 'statut6');
-	  } elseif ($charge->paid=='1'){
-        $status = img_picto($langs->trans("".$charge->status.""), 'statut4');
-	  } else {
+	    } elseif ($charge->paid=='1') {
+            $status = img_picto($langs->trans("".$charge->status.""), 'statut4');
+	    } else {
 	    	$label="Message: ".$charge->failure_message."<br>";
 	    	$label.="Réseau: ".$charge->outcome->network_status."<br>";
 	    	$label.="Statut: ".$langs->trans("".$charge->outcome->seller_message."");
 	    	$status = $form->textwithpicto(img_picto($langs->trans("".$charge->status.""), 'statut8'), $label, 1);
-	  }
+	    }
 
-      if ($charge->payment_method_details->type=='card')
-	  {
+        if ($charge->payment_method_details->type=='card') {
 		    $type = $langs->trans("card");
-	  } elseif ($charge->source->type=='card'){
+	    } elseif ($charge->source->type=='card'){
 			$type = $langs->trans("card");
-	  } elseif ($charge->payment_method_details->type=='three_d_secure'){
+	    } elseif ($charge->payment_method_details->type=='three_d_secure'){
 			$type = $langs->trans("card3DS");
-	  }
+	    }
 
-    if (! empty($charge->payment_intent)) {
-    $charge = \Stripe\PaymentIntent::retrieve($charge->payment_intent);
-    }
+        if (! empty($charge->payment_intent)) {
+            $charge = \Stripe\PaymentIntent::retrieve($charge->payment_intent);
+        }
 
 		// The metadata FULLTAG is defined by the online payment page
 		$FULLTAG=$charge->metadata->FULLTAG;
@@ -211,19 +211,25 @@ if (!$rowid)
 		print "</td>\n";
 		// Origine
 		print "<td>";
-		if ($charge->metadata->dol_type=="order"){
+		if ($charge->metadata->dol_type=="order") {
 			$object = new Commande($db);
 			$object->fetch($charge->metadata->dol_id);
-      if ($object->id > 0) {
-			print "<a href='".DOL_URL_ROOT."/commande/card.php?id=".$object->id."'>".img_picto('', 'object_order')." ".$object->ref."</a>";
-      } else print $FULLTAG;
-		} elseif ($charge->metadata->dol_type=="invoice"){
+            if ($object->id > 0) {
+                print "<a href='".DOL_URL_ROOT."/commande/card.php?id=".$object->id."'>".img_picto('', 'object_order')." ".$object->ref."</a>";
+            } else {
+                print $FULLTAG;
+            }
+		} elseif ($charge->metadata->dol_type=="invoice") {
 			$object = new Facture($db);
 			$object->fetch($charge->metadata->dol_id);
-      if ($object->id > 0) {
-		  print "<a href='".DOL_URL_ROOT."/compta/facture/card.php?facid=".$charge->metadata->dol_id."'>".img_picto('', 'object_invoice')." ".$object->ref."</a>";
-      } else print $FULLTAG;
-		} else print $FULLTAG;
+            if ($object->id > 0) {
+		        print "<a href='".DOL_URL_ROOT."/compta/facture/card.php?facid=".$charge->metadata->dol_id."'>".img_picto('', 'object_invoice')." ".$object->ref."</a>";
+            } else {
+				print $FULLTAG;
+			}
+		} else {
+			print $FULLTAG;
+		}
 	    print "</td>\n";
 		// Date payment
 	    print '<td class="center">'.dol_print_date($charge->created, '%d/%m/%Y %H:%M')."</td>\n";

+ 8 - 2
htdocs/stripe/class/stripe.class.php

@@ -62,6 +62,9 @@ class Stripe extends CommonObject
 	public $code;
 	public $declinecode;
 
+    /**
+     * @var string Message
+     */
 	public $message;
 
 	/**
@@ -338,8 +341,11 @@ class Stripe extends CommonObject
 		} elseif ($fee < $conf->global->STRIPE_APPLICATION_FEE_MINIMAL) {
 		    $fee = $conf->global->STRIPE_APPLICATION_FEE_MINIMAL;
 		}
-				if (! in_array($currency_code, $arrayzerounitcurrency)) $stripefee = round($fee * 100);
-				else $stripefee = round($fee);
+		if (! in_array($currency_code, $arrayzerounitcurrency)) {
+			$stripefee = round($fee * 100);
+		} else {
+			$stripefee = round($fee);
+		}
 
 		$paymentintent = null;
 

+ 11 - 11
htdocs/stripe/payment.php

@@ -186,12 +186,12 @@ if (empty($reshook))
 			}
 	    }
 
-	    // Check parameters
-//	    if (! GETPOST('paiementcode'))
-//	    {
-//	        setEventMessages($langs->transnoentities('ErrorFieldRequired',$langs->transnoentities('PaymentMode')), null, 'errors');
-//	        $error++;
-//	    }
+        // Check parameters
+        /*if (! GETPOST('paiementcode'))
+        {
+            setEventMessages($langs->transnoentities('ErrorFieldRequired',$langs->transnoentities('PaymentMode')), null, 'errors');
+            $error++;
+        }*/
 
 	    if (! empty($conf->banque->enabled))
 	    {
@@ -209,11 +209,11 @@ if (empty($reshook))
 	        $error++;
 	    }
 
-//	    if (empty($datepaye))
-//	    {
-//	        setEventMessages($langs->transnoentities('ErrorFieldRequired',$langs->transnoentities('Date')), null, 'errors');
-//	        $error++;
-//	    }
+        /*if (empty($datepaye))
+        {
+            setEventMessages($langs->transnoentities('ErrorFieldRequired',$langs->transnoentities('Date')), null, 'errors');
+            $error++;
+        }*/
 
 		// Check if payments in both currency
 		if ($totalpayment > 0 && $multicurrency_totalpayment > 0)